Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps/api/Accounts
diff options
context:
space:
mode:
authorLeitwolf112026-10-29 09:53:57 +0300
committerLeitwolf112026-10-29 09:53:57 +0300
commit58fa0d19d223aaebf9973ebd446c4bb855351ef9 (patch)
tree6fce1c3d9f2255e80ec92c3040e7280c0ce131ae /apps/api/Accounts
parentf22418235a0a87bc05b3bf9079fcdefba002d3b2 (diff)
downloadprogmaweb-58fa0d19d223aaebf9973ebd446c4bb855351ef9.tar.gz
Add the Tazel plugin catalog of ViGet to the API
ViGet opens in stages: first only Progmasoft publishes Tazel plugins, later every account. This adds the catalog and the server-side publishing for the first stage; nothing publishes through the API yet. - ViGet/: the catalog of Tazel plugins (in memory, or in PostgreSQL beside the accounts with its own numbered schema steps), the descriptor read from the JAR (META-INF/tazel-plugin.properties, with a reader of the Java properties format, and the ProjectPlugin service entry), and publishing: the publisher must be in ViGet:TazelPublishers (Progmasoft for now) and an existing account of that exact name, a version is never replaced, names that differ only in letter case are refused, and ViGet needs a description, an author and a license. The JAR is kept at dslplugins/tazel/<Publisher>/<Name>/<Version>/<Name>-<Version>.jar below ViGet:ArtifactRoot. - Read endpoints under /api/v1/viget/dslplugins/tazel: the list, a plugin, and index.json, the index Tazel reads. - 'viget publish-tazel-plugin <jar>' and 'viget yank-tazel-plugin' run with the configuration of the service instead of the service. - The account store can find an account by name. The pages, the Nginx routes and the deployment follow.
Diffstat (limited to 'apps/api/Accounts')
-rw-r--r--apps/api/Accounts/IAccountStore.cs7
-rw-r--r--apps/api/Accounts/InMemoryAccountStore.cs13
-rw-r--r--apps/api/Accounts/PostgresAccountStore.cs6
3 files changed, 26 insertions, 0 deletions
diff --git a/apps/api/Accounts/IAccountStore.cs b/apps/api/Accounts/IAccountStore.cs
index efb7c5b..ccb4c02 100644
--- a/apps/api/Accounts/IAccountStore.cs
+++ b/apps/api/Accounts/IAccountStore.cs
@@ -31,6 +31,13 @@ internal interface IAccountStore
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>The account, or <see langword="null"/> when it does not exist.</returns>
ValueTask<AccountRecord?> FindByIdAsync(Guid id, CancellationToken cancellationToken);
+ /// <summary>Finds an account by its normalized name.</summary>
+ /// <param name="normalizedAccountName">
+ /// Upper-case account name, as <see cref="AccountNamePolicy.NormalizeForLookup"/> produces it.
+ /// </param>
+ /// <param name="cancellationToken">Cancels the operation.</param>
+ /// <returns>The account, or <see langword="null"/> when no account has this name.</returns>
+ ValueTask<AccountRecord?> FindByAccountNameAsync(string normalizedAccountName, CancellationToken cancellationToken);
/// <summary>Stores a session, replacing one with the same token digest.</summary>
/// <param name="session">The session to store.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
diff --git a/apps/api/Accounts/InMemoryAccountStore.cs b/apps/api/Accounts/InMemoryAccountStore.cs
index 8606443..2f9af9d 100644
--- a/apps/api/Accounts/InMemoryAccountStore.cs
+++ b/apps/api/Accounts/InMemoryAccountStore.cs
@@ -82,6 +82,19 @@ internal sealed class InMemoryAccountStore : IAccountStore
}
/// <inheritdoc/>
+ public ValueTask<AccountRecord?> FindByAccountNameAsync(
+ string normalizedAccountName,
+ CancellationToken cancellationToken)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ lock (gate)
+ {
+ return ValueTask.FromResult(
+ accountIdsByName.TryGetValue(normalizedAccountName, out Guid id) ? accountsById[id] : null);
+ }
+ }
+
+ /// <inheritdoc/>
public ValueTask<AccountRecord?> FindByIdAsync(Guid id, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
diff --git a/apps/api/Accounts/PostgresAccountStore.cs b/apps/api/Accounts/PostgresAccountStore.cs
index a0e3444..3a3ea82 100644
--- a/apps/api/Accounts/PostgresAccountStore.cs
+++ b/apps/api/Accounts/PostgresAccountStore.cs
@@ -98,6 +98,12 @@ internal sealed class PostgresAccountStore(NpgsqlDataSource dataSource) : IAccou
FindAccountAsync("google_subject", googleSubject, cancellationToken);
/// <inheritdoc/>
+ public ValueTask<AccountRecord?> FindByAccountNameAsync(
+ string normalizedAccountName,
+ CancellationToken cancellationToken) =>
+ FindAccountAsync("normalized_account_name", normalizedAccountName, cancellationToken);
+
+ /// <inheritdoc/>
public ValueTask<AccountRecord?> FindByIdAsync(Guid id, CancellationToken cancellationToken) =>
FindAccountAsync("id", id, cancellationToken);