@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +27 -3
- package/dist/admin/admin.controller.d.ts +8 -72
- package/dist/admin/admin.controller.js +21 -46
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +13 -5
- package/dist/agents/agents.service.js +67 -13
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +20 -3
- package/dist/agents/models.controller.d.ts +1 -2
- package/dist/agents/models.controller.js +1 -1
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +9 -1
- package/dist/conversations/conversations.service.js +23 -18
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/db/kernel-schema.d.ts +20 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +13 -0
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +6 -6
- package/dist/evals/runs.service.js +32 -18
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +33 -2
- package/dist/extensions/host.js +107 -1
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +12 -0
- package/dist/identity/me.controller.js +31 -1
- package/dist/identity/me.schemas.d.ts +14 -0
- package/dist/identity/me.schemas.js +17 -0
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/enablement.d.ts +2 -0
- package/dist/models/enablement.js +1 -0
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +12 -2
- package/dist/models/purposes.js +22 -8
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +58 -849
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +63 -8
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin.ops.d.ts +36 -0
- package/dist/platform/ops/admin.ops.js +389 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
- package/dist/platform/ops/agent-skills.ops.js +226 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
- package/dist/platform/ops/agent-templates.ops.js +194 -14
- package/dist/platform/ops/agents.ops.d.ts +19 -1
- package/dist/platform/ops/agents.ops.js +481 -58
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
- package/dist/platform/ops/catalog-admin.ops.js +587 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +853 -0
- package/dist/platform/ops/connectors.ops.d.ts +4 -2
- package/dist/platform/ops/connectors.ops.js +68 -6
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/environments.ops.d.ts +26 -0
- package/dist/platform/ops/environments.ops.js +289 -0
- package/dist/platform/ops/errors.d.ts +10 -5
- package/dist/platform/ops/errors.js +19 -11
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +344 -0
- package/dist/platform/ops/extensions.ops.d.ts +7 -1
- package/dist/platform/ops/extensions.ops.js +248 -17
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +378 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
- package/dist/platform/ops/marketplaces.ops.js +326 -17
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
- package/dist/platform/ops/org-plugins.ops.js +329 -0
- package/dist/platform/ops/org-settings.ops.d.ts +16 -0
- package/dist/platform/ops/org-settings.ops.js +102 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +295 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/platform.ops.d.ts +11 -6
- package/dist/platform/ops/platform.ops.js +73 -27
- package/dist/platform/ops/plugins.ops.d.ts +10 -8
- package/dist/platform/ops/plugins.ops.js +176 -77
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.js +57 -19
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +129 -11
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +111 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +32 -0
- package/dist/platform/platform-ops.module.js +78 -11
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +63 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/model-call.js +2 -1
- package/dist/runtime/providers.js +8 -1
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +5 -0
- package/dist/runtime/run-worker.js +31 -6
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +46 -115
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +3 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -496,6 +496,25 @@ let MarketplacesService = class MarketplacesService {
|
|
|
496
496
|
await this.writeAdd(actor, id, { ...input, name, form, url }, opts);
|
|
497
497
|
return this.get(id);
|
|
498
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* The read-only checks of {@link add}, for the `Platform` tool's precheck (before the card): the
|
|
501
|
+
* name, URL and git fields as `add` checks them (throws `validation_failed`), then the source
|
|
502
|
+
* that has the same URL and ref already, if any (adding a duplicate is allowed; the tool points
|
|
503
|
+
* the agent at the existing source instead).
|
|
504
|
+
*/
|
|
505
|
+
async checkAdd(input) {
|
|
506
|
+
this.checkName(input.name);
|
|
507
|
+
const { form, url } = marketplaceForm(input.url);
|
|
508
|
+
this.checkUrls(url, []);
|
|
509
|
+
this.checkGitFields(form, input.ref ?? null, []);
|
|
510
|
+
const same = await this.db
|
|
511
|
+
.selectFrom("marketplaces")
|
|
512
|
+
.select(["id", "name"])
|
|
513
|
+
.where("url", "=", url)
|
|
514
|
+
.where("ref", input.ref === undefined ? "is" : "=", input.ref ?? null)
|
|
515
|
+
.executeTakeFirst();
|
|
516
|
+
return same ?? null;
|
|
517
|
+
}
|
|
499
518
|
async writeAdd(actor, id, input, opts) {
|
|
500
519
|
const { name, url, form } = input;
|
|
501
520
|
const t = this.db;
|
|
@@ -639,6 +658,7 @@ let MarketplacesService = class MarketplacesService {
|
|
|
639
658
|
...(set.url !== undefined && { url: set.url }),
|
|
640
659
|
...(set.form !== undefined && { form: set.form }),
|
|
641
660
|
...(set.ref !== undefined && { ref: set.ref }),
|
|
661
|
+
...opts.auditDetail,
|
|
642
662
|
},
|
|
643
663
|
});
|
|
644
664
|
}
|
|
@@ -667,7 +687,7 @@ let MarketplacesService = class MarketplacesService {
|
|
|
667
687
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
668
688
|
action: "marketplace.removed",
|
|
669
689
|
target: id,
|
|
670
|
-
detail: { name: row.name, url: row.url },
|
|
690
|
+
detail: { name: row.name, url: row.url, ...opts.auditDetail },
|
|
671
691
|
});
|
|
672
692
|
}
|
|
673
693
|
/**
|
|
@@ -1204,6 +1224,7 @@ let MarketplacesService = class MarketplacesService {
|
|
|
1204
1224
|
from: cur.last_status,
|
|
1205
1225
|
to: status,
|
|
1206
1226
|
...(lastError !== null && { error: lastError }),
|
|
1227
|
+
...opts.auditDetail,
|
|
1207
1228
|
},
|
|
1208
1229
|
});
|
|
1209
1230
|
}
|
|
@@ -5,40 +5,10 @@ import { type OrgContext } from "../orgs/org.guard.js";
|
|
|
5
5
|
import type { ConnectorDetail, ToolIssue } from "../tools/connectors.service.js";
|
|
6
6
|
import type { MarketplaceImportResult } from "./catalog.service.js";
|
|
7
7
|
import type { CatalogIcon, OrgCatalogDetail, OrgCatalogItem, OrgInstallResult } from "./catalog-content.js";
|
|
8
|
+
import { CatalogMarketplaceRequestBody, CatalogRequestBody, CatalogRequestsListQuery, OrgPluginInstallBody, OrgPluginSwitchBody } from "./org-catalog.schemas.js";
|
|
8
9
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
9
10
|
import { PluginInstaller, type PluginInstallView, type UninstallPreview, type UninstallReport } from "./plugin-install.js";
|
|
10
11
|
import { CatalogRequestsService, type CatalogRequestView } from "./requests.service.js";
|
|
11
|
-
declare const RequestBody: z.ZodObject<{
|
|
12
|
-
kind: z.ZodEnum<{
|
|
13
|
-
access: "access";
|
|
14
|
-
enable: "enable";
|
|
15
|
-
}>;
|
|
16
|
-
note: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, z.core.$strict>;
|
|
18
|
-
/** An org admin's request for a marketplace entry not in the catalog yet. */
|
|
19
|
-
declare const MarketplaceRequestBody: z.ZodObject<{
|
|
20
|
-
marketplaceId: z.ZodString;
|
|
21
|
-
name: z.ZodString;
|
|
22
|
-
version: z.ZodString;
|
|
23
|
-
note: z.ZodOptional<z.ZodString>;
|
|
24
|
-
}, z.core.$strict>;
|
|
25
|
-
/**
|
|
26
|
-
* The org install body: template input, the extension's org config. No version: an org installs the
|
|
27
|
-
* platform version (one per deployment, ruling P2-17).
|
|
28
|
-
*/
|
|
29
|
-
declare const InstallBody: z.ZodObject<{
|
|
30
|
-
connectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
31
|
-
name: z.ZodOptional<z.ZodString>;
|
|
32
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
33
|
-
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
|
-
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
35
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
36
|
-
clientId: z.ZodString;
|
|
37
|
-
clientSecret: z.ZodOptional<z.ZodString>;
|
|
38
|
-
}, z.core.$strict>>;
|
|
39
|
-
}, z.core.$strict>>>;
|
|
40
|
-
extensionConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
41
|
-
}, z.core.$strict>;
|
|
42
12
|
/** The connectors body (ruling P2-10): the input of missing connectors, by template id, as at install. */
|
|
43
13
|
declare const ConnectorsBody: z.ZodObject<{
|
|
44
14
|
inputs: z.ZodObject<{
|
|
@@ -70,24 +40,6 @@ declare const TemplateConnectorBody: z.ZodObject<{
|
|
|
70
40
|
}, z.core.$strict>>;
|
|
71
41
|
}, z.core.$strict>;
|
|
72
42
|
}, z.core.$strict>;
|
|
73
|
-
/** The switch body: on (with the install inputs), or off (with the preview's hash to confirm). */
|
|
74
|
-
declare const SwitchBody: z.ZodObject<{
|
|
75
|
-
enabled: z.ZodBoolean;
|
|
76
|
-
inputs: z.ZodOptional<z.ZodObject<{
|
|
77
|
-
connectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
78
|
-
name: z.ZodOptional<z.ZodString>;
|
|
79
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
80
|
-
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
81
|
-
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
82
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
83
|
-
clientId: z.ZodString;
|
|
84
|
-
clientSecret: z.ZodOptional<z.ZodString>;
|
|
85
|
-
}, z.core.$strict>>;
|
|
86
|
-
}, z.core.$strict>>>;
|
|
87
|
-
extensionConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
88
|
-
}, z.core.$strict>>;
|
|
89
|
-
confirm: z.ZodOptional<z.ZodString>;
|
|
90
|
-
}, z.core.$strict>;
|
|
91
43
|
/**
|
|
92
44
|
* 条目图标的响应头:图标可能是 SVG(可含脚本),只许网页以 `<img>` 显示;直接打开时 CSP sandbox 禁止脚本与一切外部
|
|
93
45
|
* 请求,nosniff 防浏览器按内容另行判型。
|
|
@@ -97,14 +49,6 @@ declare const DecideBody: z.ZodObject<{
|
|
|
97
49
|
approve: z.ZodBoolean;
|
|
98
50
|
reason: z.ZodOptional<z.ZodString>;
|
|
99
51
|
}, z.core.$strict>;
|
|
100
|
-
declare const AdminListQuery: z.ZodObject<{
|
|
101
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
102
|
-
approved: "approved";
|
|
103
|
-
cancelled: "cancelled";
|
|
104
|
-
pending: "pending";
|
|
105
|
-
rejected: "rejected";
|
|
106
|
-
}>>;
|
|
107
|
-
}, z.core.$strip>;
|
|
108
52
|
/**
|
|
109
53
|
* The platform catalog from an organization's view (`/api/v1/orgs/:orgId/...`, human users only):
|
|
110
54
|
* - `GET catalog` (`catalog.read`, member and up; members do not see disabled items);
|
|
@@ -150,23 +94,23 @@ export declare class OrgCatalogController {
|
|
|
150
94
|
* A request for an item (spec §5.1): `enable` (members and up, an item that is off) or `access`
|
|
151
95
|
* (org admins, a `named` item shown to the org) -> 201 `{ request }`.
|
|
152
96
|
*/
|
|
153
|
-
request(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof
|
|
97
|
+
request(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof CatalogRequestBody>): Promise<{
|
|
154
98
|
request: CatalogRequestView;
|
|
155
99
|
}>;
|
|
156
100
|
/**
|
|
157
101
|
* An org admin asks for a marketplace entry to be imported (deployment setting
|
|
158
102
|
* `orgMarketplaceBrowse`) -> 201 `{ request }`.
|
|
159
103
|
*/
|
|
160
|
-
marketplaceRequest(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
104
|
+
marketplaceRequest(principal: Principal, org: OrgContext, body: z.infer<typeof CatalogMarketplaceRequestBody>): Promise<{
|
|
161
105
|
request: CatalogRequestView;
|
|
162
106
|
}>;
|
|
163
|
-
setSwitch(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof
|
|
107
|
+
setSwitch(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof OrgPluginSwitchBody>): Promise<{
|
|
164
108
|
item: OrgCatalogItem;
|
|
165
109
|
} | {
|
|
166
110
|
preview: UninstallPreview;
|
|
167
111
|
confirm: string;
|
|
168
112
|
}>;
|
|
169
|
-
install(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof
|
|
113
|
+
install(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof OrgPluginInstallBody>, reply: FastifyReply): Promise<Omit<OrgInstallResult, "status">>;
|
|
170
114
|
/**
|
|
171
115
|
* Creates the connectors an installed plugin is missing (ruling P2-10: a connector template on
|
|
172
116
|
* in the org without a connector there, e.g. added by a platform update; the plugin shows
|
|
@@ -209,7 +153,7 @@ export declare class OrgCatalogController {
|
|
|
209
153
|
export declare class AdminCatalogRequestsController {
|
|
210
154
|
private readonly requests;
|
|
211
155
|
constructor(requests: CatalogRequestsService);
|
|
212
|
-
list(q: z.infer<typeof
|
|
156
|
+
list(q: z.infer<typeof CatalogRequestsListQuery>): Promise<{
|
|
213
157
|
requests: CatalogRequestView[];
|
|
214
158
|
}>;
|
|
215
159
|
decide(principal: Principal, id: string, body: z.infer<typeof DecideBody>): Promise<{
|
|
@@ -14,54 +14,14 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
14
14
|
import { ZBody, ZQuery } from "../infra/validation/zod-params.js";
|
|
15
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
16
16
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
17
|
-
import {
|
|
17
|
+
import { CatalogConnectorInput, CatalogMarketplaceRequestBody, CatalogRequestBody, CatalogRequestsListQuery, OrgPluginInstallBody, OrgPluginSwitchBody, } from "./org-catalog.schemas.js";
|
|
18
18
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
19
19
|
import { PluginInstaller, } from "./plugin-install.js";
|
|
20
20
|
import { CatalogRequestsService } from "./requests.service.js";
|
|
21
|
-
const RequestBody = z
|
|
22
|
-
.object({
|
|
23
|
-
kind: z.enum(["access", "enable"]),
|
|
24
|
-
note: z.string().max(1000).optional(),
|
|
25
|
-
})
|
|
26
|
-
.strict();
|
|
27
|
-
/** An org admin's request for a marketplace entry not in the catalog yet. */
|
|
28
|
-
const MarketplaceRequestBody = z
|
|
29
|
-
.object({
|
|
30
|
-
marketplaceId: z.string().min(1).max(100),
|
|
31
|
-
name: z.string().min(1).max(214),
|
|
32
|
-
version: z.string().min(1).max(256),
|
|
33
|
-
note: z.string().max(1000).optional(),
|
|
34
|
-
})
|
|
35
|
-
.strict();
|
|
36
|
-
const ConnectorInput = z
|
|
37
|
-
.object({
|
|
38
|
-
name: z.string().trim().min(1).max(80).optional(),
|
|
39
|
-
slug: z.string().max(24).optional(),
|
|
40
|
-
endpoint: z.record(z.string(), z.unknown()).optional(),
|
|
41
|
-
credential: CredentialValue.optional(),
|
|
42
|
-
client: z
|
|
43
|
-
.object({
|
|
44
|
-
clientId: z.string().min(1).max(500),
|
|
45
|
-
clientSecret: z.string().min(1).max(4000).optional(),
|
|
46
|
-
})
|
|
47
|
-
.strict()
|
|
48
|
-
.optional(),
|
|
49
|
-
})
|
|
50
|
-
.strict();
|
|
51
|
-
/**
|
|
52
|
-
* The org install body: template input, the extension's org config. No version: an org installs the
|
|
53
|
-
* platform version (one per deployment, ruling P2-17).
|
|
54
|
-
*/
|
|
55
|
-
const InstallBody = z
|
|
56
|
-
.object({
|
|
57
|
-
connectors: z.record(z.string(), ConnectorInput).optional(),
|
|
58
|
-
extensionConfig: z.record(z.string(), z.unknown()).optional(),
|
|
59
|
-
})
|
|
60
|
-
.strict();
|
|
61
21
|
/** The connectors body (ruling P2-10): the input of missing connectors, by template id, as at install. */
|
|
62
22
|
const ConnectorsBody = z
|
|
63
23
|
.object({
|
|
64
|
-
inputs: z.object({ connectors: z.record(z.string(),
|
|
24
|
+
inputs: z.object({ connectors: z.record(z.string(), CatalogConnectorInput) }).strict(),
|
|
65
25
|
})
|
|
66
26
|
.strict();
|
|
67
27
|
/**
|
|
@@ -71,18 +31,7 @@ const ConnectorsBody = z
|
|
|
71
31
|
const TemplateConnectorBody = z
|
|
72
32
|
.object({
|
|
73
33
|
name: z.string().trim().min(1).max(80).optional(),
|
|
74
|
-
config:
|
|
75
|
-
})
|
|
76
|
-
.strict();
|
|
77
|
-
/** The switch body: on (with the install inputs), or off (with the preview's hash to confirm). */
|
|
78
|
-
const SwitchBody = z
|
|
79
|
-
.object({
|
|
80
|
-
enabled: z.boolean(),
|
|
81
|
-
inputs: InstallBody.optional(),
|
|
82
|
-
confirm: z
|
|
83
|
-
.string()
|
|
84
|
-
.regex(/^[0-9a-f]{64}$/)
|
|
85
|
-
.optional(),
|
|
34
|
+
config: CatalogConnectorInput.omit({ name: true }),
|
|
86
35
|
})
|
|
87
36
|
.strict();
|
|
88
37
|
/**
|
|
@@ -100,24 +49,21 @@ export async function sendCatalogIcon(reply, icon) {
|
|
|
100
49
|
const DecideBody = z
|
|
101
50
|
.object({ approve: z.boolean(), reason: z.string().max(1000).optional() })
|
|
102
51
|
.strict();
|
|
103
|
-
|
|
104
|
-
status: z.enum(["pending", "approved", "rejected", "cancelled"]).optional(),
|
|
105
|
-
});
|
|
106
|
-
class CatalogRequestsQuery extends createZodDto(AdminListQuery, "CatalogRequestsQuery") {
|
|
52
|
+
class CatalogRequestsQuery extends createZodDto(CatalogRequestsListQuery, "CatalogRequestsQuery") {
|
|
107
53
|
}
|
|
108
54
|
class CatalogDecideBody extends createZodDto(DecideBody, "CatalogDecideBody") {
|
|
109
55
|
}
|
|
110
|
-
class
|
|
56
|
+
class OrgPluginInstallBodyDto extends createZodDto(OrgPluginInstallBody, "OrgPluginInstallBody") {
|
|
111
57
|
}
|
|
112
58
|
class OrgPluginConnectorsBody extends createZodDto(ConnectorsBody, "OrgPluginConnectorsBody") {
|
|
113
59
|
}
|
|
114
|
-
class
|
|
60
|
+
class OrgPluginSwitchBodyDto extends createZodDto(OrgPluginSwitchBody, "OrgPluginSwitchBody") {
|
|
115
61
|
}
|
|
116
62
|
class OrgTemplateConnectorBody extends createZodDto(TemplateConnectorBody, "OrgTemplateConnectorBody") {
|
|
117
63
|
}
|
|
118
|
-
class
|
|
64
|
+
class CatalogRequestBodyDto extends createZodDto(CatalogRequestBody, "CatalogRequestBody") {
|
|
119
65
|
}
|
|
120
|
-
class
|
|
66
|
+
class CatalogMarketplaceRequestBodyDto extends createZodDto(CatalogMarketplaceRequestBody, "CatalogMarketplaceRequestBody") {
|
|
121
67
|
}
|
|
122
68
|
/**
|
|
123
69
|
* The platform catalog from an organization's view (`/api/v1/orgs/:orgId/...`, human users only):
|
|
@@ -289,7 +235,7 @@ __decorate([
|
|
|
289
235
|
__param(0, CurrentPrincipal()),
|
|
290
236
|
__param(1, CurrentOrg()),
|
|
291
237
|
__param(2, Param("itemId")),
|
|
292
|
-
__param(3, ZBody(
|
|
238
|
+
__param(3, ZBody(CatalogRequestBodyDto))
|
|
293
239
|
], OrgCatalogController.prototype, "request", null);
|
|
294
240
|
__decorate([
|
|
295
241
|
Post("marketplace-requests"),
|
|
@@ -297,7 +243,7 @@ __decorate([
|
|
|
297
243
|
OrgAction("catalog.decide"),
|
|
298
244
|
__param(0, CurrentPrincipal()),
|
|
299
245
|
__param(1, CurrentOrg()),
|
|
300
|
-
__param(2, ZBody(
|
|
246
|
+
__param(2, ZBody(CatalogMarketplaceRequestBodyDto))
|
|
301
247
|
], OrgCatalogController.prototype, "marketplaceRequest", null);
|
|
302
248
|
__decorate([
|
|
303
249
|
Put("catalog/:itemId/switch"),
|
|
@@ -305,7 +251,7 @@ __decorate([
|
|
|
305
251
|
__param(0, CurrentPrincipal()),
|
|
306
252
|
__param(1, CurrentOrg()),
|
|
307
253
|
__param(2, Param("itemId")),
|
|
308
|
-
__param(3, ZBody(
|
|
254
|
+
__param(3, ZBody(OrgPluginSwitchBodyDto))
|
|
309
255
|
], OrgCatalogController.prototype, "setSwitch", null);
|
|
310
256
|
__decorate([
|
|
311
257
|
Post("catalog/:itemId/install"),
|
|
@@ -313,7 +259,7 @@ __decorate([
|
|
|
313
259
|
__param(0, CurrentPrincipal()),
|
|
314
260
|
__param(1, CurrentOrg()),
|
|
315
261
|
__param(2, Param("itemId")),
|
|
316
|
-
__param(3, ZBody(
|
|
262
|
+
__param(3, ZBody(OrgPluginInstallBodyDto)),
|
|
317
263
|
__param(4, Res({ passthrough: true }))
|
|
318
264
|
], OrgCatalogController.prototype, "install", null);
|
|
319
265
|
__decorate([
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const CatalogRequestBody: z.ZodObject<{
|
|
4
|
+
kind: z.ZodEnum<{
|
|
5
|
+
access: "access";
|
|
6
|
+
enable: "enable";
|
|
7
|
+
}>;
|
|
8
|
+
note: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
/** An org admin's request for a marketplace entry not in the catalog yet. */
|
|
11
|
+
export declare const CatalogMarketplaceRequestBody: z.ZodObject<{
|
|
12
|
+
marketplaceId: z.ZodString;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
version: z.ZodString;
|
|
15
|
+
note: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export declare const CatalogConnectorInput: z.ZodObject<{
|
|
18
|
+
name: z.ZodOptional<z.ZodString>;
|
|
19
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
20
|
+
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
+
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
clientId: z.ZodString;
|
|
24
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$strict>>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
/**
|
|
28
|
+
* The org install body: template input, the extension's org config. No version: an org installs the
|
|
29
|
+
* platform version (one per deployment, ruling P2-17).
|
|
30
|
+
*/
|
|
31
|
+
export declare const OrgPluginInstallBody: z.ZodObject<{
|
|
32
|
+
connectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
33
|
+
name: z.ZodOptional<z.ZodString>;
|
|
34
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
35
|
+
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
36
|
+
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
37
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
clientId: z.ZodString;
|
|
39
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
}, z.core.$strict>>>;
|
|
42
|
+
extensionConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
/** The switch body: on (with the install inputs), or off (with the preview's hash to confirm). */
|
|
45
|
+
export declare const OrgPluginSwitchBody: z.ZodObject<{
|
|
46
|
+
enabled: z.ZodBoolean;
|
|
47
|
+
inputs: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
connectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
49
|
+
name: z.ZodOptional<z.ZodString>;
|
|
50
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
51
|
+
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
52
|
+
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
53
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
54
|
+
clientId: z.ZodString;
|
|
55
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strict>>;
|
|
57
|
+
}, z.core.$strict>>>;
|
|
58
|
+
extensionConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
59
|
+
}, z.core.$strict>>;
|
|
60
|
+
confirm: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
/** `:itemId` as the routes take it (`@Param`). */
|
|
63
|
+
export declare const CatalogItemPathParams: z.ZodObject<{
|
|
64
|
+
itemId: z.ZodString;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/** `:installId` as the uninstall route takes it (`@Param`). */
|
|
67
|
+
export declare const PluginInstallPathParams: z.ZodObject<{
|
|
68
|
+
installId: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
/** The super admin's request list filter. */
|
|
71
|
+
export declare const CatalogRequestsListQuery: z.ZodObject<{
|
|
72
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
approved: "approved";
|
|
74
|
+
cancelled: "cancelled";
|
|
75
|
+
pending: "pending";
|
|
76
|
+
rejected: "rejected";
|
|
77
|
+
}>>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export declare const ORG_CATALOG_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CredentialValue } from "../tools/connectors.schemas.js";
|
|
3
|
+
export const CatalogRequestBody = z
|
|
4
|
+
.object({
|
|
5
|
+
kind: z.enum(["access", "enable"]),
|
|
6
|
+
note: z.string().max(1000).optional(),
|
|
7
|
+
})
|
|
8
|
+
.strict();
|
|
9
|
+
/** An org admin's request for a marketplace entry not in the catalog yet. */
|
|
10
|
+
export const CatalogMarketplaceRequestBody = z
|
|
11
|
+
.object({
|
|
12
|
+
marketplaceId: z.string().min(1).max(100),
|
|
13
|
+
name: z.string().min(1).max(214),
|
|
14
|
+
version: z.string().min(1).max(256),
|
|
15
|
+
note: z.string().max(1000).optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
export const CatalogConnectorInput = z
|
|
19
|
+
.object({
|
|
20
|
+
name: z.string().trim().min(1).max(80).optional(),
|
|
21
|
+
slug: z.string().max(24).optional(),
|
|
22
|
+
endpoint: z.record(z.string(), z.unknown()).optional(),
|
|
23
|
+
credential: CredentialValue.optional(),
|
|
24
|
+
client: z
|
|
25
|
+
.object({
|
|
26
|
+
clientId: z.string().min(1).max(500),
|
|
27
|
+
clientSecret: z.string().min(1).max(4000).optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict()
|
|
30
|
+
.optional(),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
/**
|
|
34
|
+
* The org install body: template input, the extension's org config. No version: an org installs the
|
|
35
|
+
* platform version (one per deployment, ruling P2-17).
|
|
36
|
+
*/
|
|
37
|
+
export const OrgPluginInstallBody = z
|
|
38
|
+
.object({
|
|
39
|
+
connectors: z.record(z.string(), CatalogConnectorInput).optional(),
|
|
40
|
+
extensionConfig: z.record(z.string(), z.unknown()).optional(),
|
|
41
|
+
})
|
|
42
|
+
.strict();
|
|
43
|
+
/** The switch body: on (with the install inputs), or off (with the preview's hash to confirm). */
|
|
44
|
+
export const OrgPluginSwitchBody = z
|
|
45
|
+
.object({
|
|
46
|
+
enabled: z.boolean(),
|
|
47
|
+
inputs: OrgPluginInstallBody.optional(),
|
|
48
|
+
confirm: z
|
|
49
|
+
.string()
|
|
50
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
51
|
+
.optional(),
|
|
52
|
+
})
|
|
53
|
+
.strict();
|
|
54
|
+
/** `:itemId` as the routes take it (`@Param`). */
|
|
55
|
+
export const CatalogItemPathParams = z.object({ itemId: z.string().min(1) });
|
|
56
|
+
/** `:installId` as the uninstall route takes it (`@Param`). */
|
|
57
|
+
export const PluginInstallPathParams = z.object({ installId: z.string().min(1) });
|
|
58
|
+
/** The super admin's request list filter. */
|
|
59
|
+
export const CatalogRequestsListQuery = z.object({
|
|
60
|
+
status: z.enum(["pending", "approved", "rejected", "cancelled"]).optional(),
|
|
61
|
+
});
|
|
62
|
+
export const ORG_CATALOG_ROUTES = [
|
|
63
|
+
{ route: "GET /api/v1/orgs/:orgId/catalog" },
|
|
64
|
+
{ route: "GET /api/v1/orgs/:orgId/catalog/:itemId", params: CatalogItemPathParams },
|
|
65
|
+
{
|
|
66
|
+
route: "POST /api/v1/orgs/:orgId/catalog/:itemId/requests",
|
|
67
|
+
params: CatalogItemPathParams,
|
|
68
|
+
body: CatalogRequestBody,
|
|
69
|
+
},
|
|
70
|
+
{ route: "POST /api/v1/orgs/:orgId/marketplace-requests", body: CatalogMarketplaceRequestBody },
|
|
71
|
+
{
|
|
72
|
+
route: "PUT /api/v1/orgs/:orgId/catalog/:itemId/switch",
|
|
73
|
+
params: CatalogItemPathParams,
|
|
74
|
+
body: OrgPluginSwitchBody,
|
|
75
|
+
},
|
|
76
|
+
{ route: "GET /api/v1/orgs/:orgId/plugin-installs" },
|
|
77
|
+
{
|
|
78
|
+
route: "DELETE /api/v1/orgs/:orgId/plugin-installs/:installId",
|
|
79
|
+
params: PluginInstallPathParams,
|
|
80
|
+
},
|
|
81
|
+
{ route: "GET /api/v1/admin/catalog/requests", query: CatalogRequestsListQuery },
|
|
82
|
+
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
2
|
+
import { ExtensionAvailability } from "../extensions/unavailable.js";
|
|
2
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
4
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
5
|
import type { KernelLogger } from "../log.js";
|
|
@@ -35,9 +36,13 @@ export declare class OrgCatalogService {
|
|
|
35
36
|
private readonly pluginInstaller;
|
|
36
37
|
private readonly log;
|
|
37
38
|
readonly txHost: TransactionHost;
|
|
39
|
+
/** Why a plugin's extension cannot run (the `unavailable` state's reason). */
|
|
40
|
+
private readonly availability;
|
|
38
41
|
constructor(kdb: KernelDb,
|
|
39
42
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
40
|
-
orgLock: OrgLock, storage: StorageService, registry: ExtensionRegistry, pluginInstaller: PluginInstaller, log: KernelLogger, txHost: TransactionHost
|
|
43
|
+
orgLock: OrgLock, storage: StorageService, registry: ExtensionRegistry, pluginInstaller: PluginInstaller, log: KernelLogger, txHost: TransactionHost,
|
|
44
|
+
/** Why a plugin's extension cannot run (the `unavailable` state's reason). */
|
|
45
|
+
availability: ExtensionAvailability);
|
|
41
46
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
42
47
|
private get db();
|
|
43
48
|
/**
|
|
@@ -99,7 +104,9 @@ export declare class OrgCatalogService {
|
|
|
99
104
|
* install writes the switch row false in the uninstall's transaction (an `all` item then stays
|
|
100
105
|
* off in the org); removing a failed or stale one writes none.
|
|
101
106
|
*/
|
|
102
|
-
uninstall(orgId: string, actor: string, installId: string, actorTokenId?: string
|
|
107
|
+
uninstall(orgId: string, actor: string, installId: string, actorTokenId?: string,
|
|
108
|
+
/** Merged into the audit detail (a write made through the Platform tool). */
|
|
109
|
+
auditDetail?: Record<string, unknown>): Promise<UninstallReport>;
|
|
103
110
|
private itemOf;
|
|
104
111
|
/**
|
|
105
112
|
* Writes the org's switch row of the item under the org row lock. The item row is locked FOR
|
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { ApiError } from "../errors.js";
|
|
12
12
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
13
|
+
import { ExtensionAvailability } from "../extensions/unavailable.js";
|
|
13
14
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
15
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
15
16
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
@@ -47,9 +48,12 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
47
48
|
pluginInstaller;
|
|
48
49
|
log;
|
|
49
50
|
txHost;
|
|
51
|
+
availability;
|
|
50
52
|
constructor(kdb,
|
|
51
53
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
52
|
-
orgLock, storage, registry, pluginInstaller, log, txHost
|
|
54
|
+
orgLock, storage, registry, pluginInstaller, log, txHost,
|
|
55
|
+
/** Why a plugin's extension cannot run (the `unavailable` state's reason). */
|
|
56
|
+
availability) {
|
|
53
57
|
this.kdb = kdb;
|
|
54
58
|
this.orgLock = orgLock;
|
|
55
59
|
this.storage = storage;
|
|
@@ -57,6 +61,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
57
61
|
this.pluginInstaller = pluginInstaller;
|
|
58
62
|
this.log = log;
|
|
59
63
|
this.txHost = txHost;
|
|
64
|
+
this.availability = availability;
|
|
60
65
|
}
|
|
61
66
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
62
67
|
get db() {
|
|
@@ -158,6 +163,16 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
158
163
|
const configured = new Set(configs.map((c) => c.plugin));
|
|
159
164
|
const owners = await ownersOf(this.db, items.flatMap((i) => (i.owner_org_id === null ? [] : [i.owner_org_id])));
|
|
160
165
|
const loaded = new Map(this.registry.manifests().map((x) => [x.name, x]));
|
|
166
|
+
// the extensions of the latest versions that are not loaded: why (the `unavailable` reason)
|
|
167
|
+
const extensionOf = (i) => {
|
|
168
|
+
const v = versions.find((x) => x.item_id === i.id && x.version === i.latest_version);
|
|
169
|
+
const m = v?.manifest;
|
|
170
|
+
return m?.extension ? m.name : undefined;
|
|
171
|
+
};
|
|
172
|
+
const unloaded = await this.availability.unavailable(items.flatMap((i) => {
|
|
173
|
+
const n = extensionOf(i);
|
|
174
|
+
return n === undefined ? [] : [n];
|
|
175
|
+
}));
|
|
161
176
|
const out = [];
|
|
162
177
|
for (const i of items) {
|
|
163
178
|
// Another org sees only an org-owned plugin's applied version, never one its owner
|
|
@@ -172,12 +187,23 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
172
187
|
const scope = i.builtin ? "all" : i.scope;
|
|
173
188
|
const wanted = wantedOn(i, inList.has(i.id), sw.get(i.id) ?? null);
|
|
174
189
|
let state;
|
|
190
|
+
let reason;
|
|
191
|
+
const extName = extensionOf(i);
|
|
192
|
+
const why = extName === undefined ? undefined : unloaded.get(extName);
|
|
175
193
|
if (i.awaiting_confirmation)
|
|
176
194
|
state = "awaiting_confirmation";
|
|
177
|
-
else if (i.disabled)
|
|
195
|
+
else if (i.disabled) {
|
|
178
196
|
state = "unavailable";
|
|
197
|
+
reason = "plugin_disabled";
|
|
198
|
+
}
|
|
179
199
|
else if (requestable(i, inList.has(i.id)))
|
|
180
200
|
state = "not_offered";
|
|
201
|
+
// not installed here and its extension cannot run: switching it on would fail (spec §14.2
|
|
202
|
+
// problem 1); an installed one keeps its state (an org admin can still switch it off)
|
|
203
|
+
else if (!a && why !== undefined) {
|
|
204
|
+
state = "unavailable";
|
|
205
|
+
reason = why.reason;
|
|
206
|
+
}
|
|
181
207
|
else if (a) {
|
|
182
208
|
// An on connector template without a connector here (ruling P2-10)
|
|
183
209
|
const missing = await this.pluginInstaller.missingConnectors(orgId, i.id);
|
|
@@ -208,6 +234,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
208
234
|
scope,
|
|
209
235
|
builtin: i.builtin,
|
|
210
236
|
state,
|
|
237
|
+
...(reason !== undefined && { reason }),
|
|
211
238
|
switchable: state !== "not_offered" && state !== "awaiting_confirmation" && switchable(i),
|
|
212
239
|
notDeployed: latest !== undefined && undeployed.has(i.id),
|
|
213
240
|
installed: a
|
|
@@ -467,7 +494,9 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
467
494
|
* install writes the switch row false in the uninstall's transaction (an `all` item then stays
|
|
468
495
|
* off in the org); removing a failed or stale one writes none.
|
|
469
496
|
*/
|
|
470
|
-
async uninstall(orgId, actor, installId, actorTokenId
|
|
497
|
+
async uninstall(orgId, actor, installId, actorTokenId,
|
|
498
|
+
/** Merged into the audit detail (a write made through the Platform tool). */
|
|
499
|
+
auditDetail) {
|
|
471
500
|
if (!UUID_RE.test(installId))
|
|
472
501
|
throw new ApiError("plugin.install_not_found", "Plugin install not found");
|
|
473
502
|
const row = await this.db
|
|
@@ -482,7 +511,10 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
482
511
|
if (row !== undefined && live && !switchable(row)) {
|
|
483
512
|
throw new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be uninstalled here");
|
|
484
513
|
}
|
|
485
|
-
return this.pluginInstaller.uninstall(orgId, actor, installId,
|
|
514
|
+
return this.pluginInstaller.uninstall(orgId, actor, installId, {
|
|
515
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
516
|
+
...(auditDetail !== undefined && { auditDetail }),
|
|
517
|
+
},
|
|
486
518
|
// only a live install was on: removing a failed or stale one writes no switch row, so an
|
|
487
519
|
// item its scope wants stays wanted and the sync installs it again
|
|
488
520
|
row !== undefined && live ? {} : undefined);
|
|
@@ -546,6 +578,7 @@ OrgCatalogService = __decorate([
|
|
|
546
578
|
__param(3, Inject(ExtensionRegistry)),
|
|
547
579
|
__param(4, Inject(PluginInstaller)),
|
|
548
580
|
__param(5, Inject(KERNEL_LOGGER)),
|
|
549
|
-
__param(6, Inject(TransactionHost))
|
|
581
|
+
__param(6, Inject(TransactionHost)),
|
|
582
|
+
__param(7, Inject(ExtensionAvailability))
|
|
550
583
|
], OrgCatalogService);
|
|
551
584
|
export { OrgCatalogService };
|
|
@@ -6,6 +6,7 @@ import { OrgOverrides, type OrgOverrideView } from "../extensions/org-overrides.
|
|
|
6
6
|
import { type Principal } from "../identity/principal.js";
|
|
7
7
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
8
8
|
import { type OrgToolSwitch, OrgToolSwitches, type OrgToolSwitchResult } from "../tools/org-tool-switches.js";
|
|
9
|
+
import { OrgExtensionParams as ExtensionParams, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut } from "./org-extension.schemas.js";
|
|
9
10
|
import { OrgExtensionSwitch } from "./org-extension-switch.js";
|
|
10
11
|
import type { UninstallPreview } from "./plugin-install.js";
|
|
11
12
|
declare const PutBody: z.ZodObject<{
|
|
@@ -26,18 +27,6 @@ declare const OverridesPut: z.ZodObject<{
|
|
|
26
27
|
declare const OverridesTake: z.ZodObject<{
|
|
27
28
|
paths: z.ZodArray<z.ZodString>;
|
|
28
29
|
}, z.core.$strict>;
|
|
29
|
-
declare const ToolSwitchPut: z.ZodObject<{
|
|
30
|
-
enabled: z.ZodBoolean;
|
|
31
|
-
confirm: z.ZodOptional<z.ZodString>;
|
|
32
|
-
}, z.core.$strict>;
|
|
33
|
-
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
34
|
-
declare const ExtensionParams: z.ZodObject<{
|
|
35
|
-
extension: z.ZodString;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
declare const ToolParams: z.ZodObject<{
|
|
38
|
-
extension: z.ZodString;
|
|
39
|
-
tool: z.ZodString;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
30
|
/**
|
|
42
31
|
* One extension of the org list: the org view plus the plugin's display name and the extension
|
|
43
32
|
* points it provides (`channel@1`, `web-search@1`, … the names only, also for members).
|
|
@@ -18,6 +18,7 @@ import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
|
18
18
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
19
19
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
20
20
|
import { OrgToolSwitches, } from "../tools/org-tool-switches.js";
|
|
21
|
+
import { OrgExtensionParams as ExtensionParams, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut, } from "./org-extension.schemas.js";
|
|
21
22
|
import { OrgExtensionSwitch } from "./org-extension-switch.js";
|
|
22
23
|
const PutBody = z
|
|
23
24
|
.object({
|
|
@@ -57,18 +58,8 @@ const OverridesPut = z
|
|
|
57
58
|
const OverridesTake = z
|
|
58
59
|
.object({ paths: z.array(z.string().min(1).max(256)).min(1).max(200) })
|
|
59
60
|
.strict();
|
|
60
|
-
const ToolSwitchPut = z
|
|
61
|
-
.object({
|
|
62
|
-
enabled: z.boolean(),
|
|
63
|
-
/** The hash of the switch-off preview, to confirm turning the tool off. */
|
|
64
|
-
confirm: z.string().min(1).max(128).optional(),
|
|
65
|
-
})
|
|
66
|
-
.strict();
|
|
67
61
|
class OrgToolSwitchPutBody extends createZodDto(ToolSwitchPut, "OrgToolSwitchPutBody") {
|
|
68
62
|
}
|
|
69
|
-
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
70
|
-
const ExtensionParams = z.object({ extension: z.string().min(1).max(64) });
|
|
71
|
-
const ToolParams = ExtensionParams.extend({ tool: z.string().min(1).max(64) });
|
|
72
63
|
class OrgExtensionParamsDto extends createZodDto(ExtensionParams, "OrgExtensionParams") {
|
|
73
64
|
}
|
|
74
65
|
class OrgExtensionToolParamsDto extends createZodDto(ToolParams, "OrgExtensionToolParams") {
|