@capybara-hq/kernel 0.1.0-rc.76 → 0.1.0-rc.78
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 +6 -6
- package/dist/admin/outbox-dead.service.js +4 -1
- package/dist/agents/admin-agents.js +2 -0
- package/dist/agents/agent-lookup.js +4 -0
- package/dist/agents/agent-profile.service.js +3 -0
- package/dist/agents/agents.service.js +7 -0
- package/dist/agents/org-templates.js +1 -0
- package/dist/agents/pending-connector-requests.js +6 -0
- package/dist/agents/pending-connectors.service.js +2 -0
- package/dist/agents/readiness.service.d.ts +9 -3
- package/dist/agents/readiness.service.js +3 -3
- package/dist/agents/templates.js +1 -0
- package/dist/background/finish.js +3 -0
- package/dist/background/stop.js +2 -0
- package/dist/background/store.js +44 -0
- package/dist/background/tasks.service.js +3 -2
- package/dist/background/wake-rules.js +1 -0
- package/dist/catalog/admin-catalog.controller.d.ts +6 -0
- package/dist/catalog/admin-catalog.controller.js +13 -0
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-content.js +1 -0
- package/dist/catalog/catalog-items.js +4 -0
- package/dist/catalog/catalog-scope.service.js +4 -1
- package/dist/catalog/component-promotion.js +2 -0
- package/dist/catalog/component-scope.controller.d.ts +9 -15
- package/dist/catalog/component-scope.controller.js +14 -9
- package/dist/catalog/component-scope.service.js +5 -0
- package/dist/catalog/component-state.js +2 -0
- package/dist/catalog/marketplaces.service.d.ts +6 -1
- package/dist/catalog/marketplaces.service.js +8 -3
- package/dist/catalog/org-catalog.controller.d.ts +9 -0
- package/dist/catalog/org-catalog.controller.js +18 -0
- package/dist/catalog/org-catalog.schemas.d.ts +2 -4
- package/dist/catalog/org-catalog.schemas.js +2 -3
- package/dist/catalog/org-catalog.service.d.ts +10 -1
- package/dist/catalog/org-catalog.service.js +34 -23
- package/dist/catalog/org-extension-switch.d.ts +3 -10
- package/dist/catalog/org-extension-switch.js +14 -60
- package/dist/catalog/org-extension.controller.d.ts +6 -7
- package/dist/catalog/org-extension.controller.js +4 -4
- package/dist/catalog/org-extension.schemas.d.ts +1 -2
- package/dist/catalog/org-extension.schemas.js +1 -3
- package/dist/catalog/owned-items.js +10 -1
- package/dist/catalog/ownership.js +2 -0
- package/dist/catalog/plugin-import.js +8 -0
- package/dist/catalog/plugin-install.d.ts +1 -4
- package/dist/catalog/plugin-install.js +11 -12
- package/dist/catalog/plugin-upgrade.js +4 -1
- package/dist/catalog/request-rules.js +6 -0
- package/dist/catalog/requests.service.js +4 -0
- package/dist/catalog/scope-orgs.js +1 -0
- package/dist/catalog/scope-sync.d.ts +8 -5
- package/dist/catalog/scope-sync.js +21 -23
- package/dist/catalog/unshare.js +3 -0
- package/dist/channels/connections.service.js +1 -0
- package/dist/channels/inbound.js +1 -0
- package/dist/channels/jobs.js +1 -0
- package/dist/channels/outbound.js +6 -0
- package/dist/channels/supervisor.js +1 -0
- package/dist/channels/threads.js +1 -0
- package/dist/client/client-reports.service.js +1 -0
- package/dist/config/fields.js +20 -4
- package/dist/conversations/access.js +1 -0
- package/dist/conversations/attachments.service.js +16 -4
- package/dist/conversations/conversations.service.js +17 -3
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +3 -1
- package/dist/conversations/files.js +3 -2
- package/dist/conversations/permission-profiles.service.js +1 -0
- package/dist/conversations/prompt-suggestions.js +2 -0
- package/dist/conversations/queue.js +8 -0
- package/dist/conversations/queue.service.js +6 -2
- package/dist/conversations/source.js +2 -0
- package/dist/conversations/titles.js +10 -2
- package/dist/conversations/tree.js +6 -0
- package/dist/db/kernel-schema.d.ts +3 -1
- package/dist/devices/conversation-devices.js +3 -0
- package/dist/devices/device-projects.service.js +2 -0
- package/dist/devices/devices.service.js +5 -0
- package/dist/devices/legacy-cleanup.job.js +5 -2
- package/dist/dial-in/handlers.js +2 -0
- package/dist/dial-in/machines.js +11 -2
- package/dist/dial-in/targets.d.ts +0 -2
- package/dist/dial-in/targets.js +0 -10
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/evals/budget.js +14 -1
- package/dist/evals/run-replay.js +4 -0
- package/dist/evals/runs.service.js +13 -7
- package/dist/evals/sets.service.js +23 -8
- package/dist/evals/trajectory.service.d.ts +1 -1
- package/dist/evals/trajectory.service.js +1 -0
- package/dist/evals/worker.js +5 -1
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +3 -1
- package/dist/extensions/bootstrap-packages.d.ts +12 -1
- package/dist/extensions/bootstrap-packages.js +49 -9
- package/dist/extensions/bootstrap.d.ts +36 -4
- package/dist/extensions/bootstrap.js +103 -16
- package/dist/extensions/config-json-schema.d.ts +2 -2
- package/dist/extensions/config-json-schema.js +1 -3
- package/dist/extensions/deployment-config.d.ts +5 -3
- package/dist/extensions/deployment-config.js +3 -3
- package/dist/extensions/effective-config.d.ts +8 -7
- package/dist/extensions/effective-config.js +8 -7
- package/dist/extensions/enabled.js +1 -0
- package/dist/extensions/host.d.ts +4 -3
- package/dist/extensions/host.js +11 -12
- package/dist/extensions/instance.d.ts +1 -1
- package/dist/extensions/instance.js +17 -2
- package/dist/extensions/org-config.d.ts +35 -97
- package/dist/extensions/org-config.js +48 -315
- package/dist/extensions/org-levels.d.ts +22 -9
- package/dist/extensions/org-levels.js +100 -20
- package/dist/extensions/org-overrides.d.ts +14 -15
- package/dist/extensions/org-overrides.js +20 -20
- package/dist/extensions/package.js +1 -1
- package/dist/extensions/permission-set.d.ts +1 -3
- package/dist/extensions/permission-set.js +3 -7
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +5 -4
- package/dist/extensions/plugin-icons.d.ts +72 -1
- package/dist/extensions/plugin-icons.js +194 -2
- package/dist/extensions/point-defaults.d.ts +17 -18
- package/dist/extensions/point-defaults.js +25 -28
- package/dist/identity/accounts.js +6 -0
- package/dist/identity/api-tokens.js +8 -0
- package/dist/infra/outbox/outbox.dispatcher.js +4 -1
- package/dist/infra/outbox/outbox.service.js +2 -0
- package/dist/orgs/directory-sync.d.ts +9 -6
- package/dist/orgs/directory-sync.js +15 -12
- package/dist/orgs/invitations.service.js +2 -0
- package/dist/orgs/members.service.js +2 -0
- package/dist/orgs/offboarding.js +2 -0
- package/dist/packages/npm.d.ts +9 -1
- package/dist/packages/npm.js +37 -5
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin-items.ops.js +1 -0
- package/dist/platform/ops/agents.ops.js +1 -0
- package/dist/platform/ops/extensions.ops.d.ts +6 -8
- package/dist/platform/ops/extensions.ops.js +18 -97
- package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
- package/dist/platform/ops/org-plugins.ops.js +14 -65
- package/dist/platform/ops/outbox.ops.js +1 -0
- package/dist/platform/ops/person-inputs.d.ts +0 -4
- package/dist/platform/ops/person-inputs.js +0 -8
- package/dist/platform/ops/plugins.ops.d.ts +4 -1
- package/dist/platform/ops/plugins.ops.js +27 -34
- package/dist/platform/person-fields.d.ts +1 -1
- package/dist/platform/person-fields.js +1 -1
- package/dist/platform/sealed-reveals.js +2 -0
- package/dist/push/recipients.js +9 -2
- package/dist/runtime/permission-context.service.js +1 -0
- package/dist/runtime/plugin-context.service.js +1 -0
- package/dist/runtime/project/knowledge.service.js +1 -0
- package/dist/runtime/run-context.service.js +1 -0
- package/dist/runtime/run-deletion.js +4 -0
- package/dist/runtime/run-execution.js +2 -0
- package/dist/runtime/run-finish.js +3 -0
- package/dist/runtime/run-jobs.js +3 -0
- package/dist/runtime/run-orphan-check.job.js +7 -0
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +5 -0
- package/dist/runtime/step-log.js +1 -0
- package/dist/runtime/subagents/child.js +2 -0
- package/dist/runtime/subagents/deliveries.js +3 -0
- package/dist/runtime/subagents/dispatch.js +5 -1
- package/dist/runtime/subagents/messages.js +2 -0
- package/dist/runtime/subagents/org-agents.d.ts +1 -1
- package/dist/runtime/subagents/org-agents.js +2 -1
- package/dist/runtime/usage-report-jobs.js +1 -0
- package/dist/runtime/usage-report.js +3 -0
- package/dist/runtime/waits.js +5 -0
- package/dist/sandbox/cloud-permission-snapshot.js +9 -3
- package/dist/sandbox/device-reports.js +3 -0
- package/dist/sandbox/legacy-retirement.js +5 -1
- package/dist/sandbox/managed-device-context.js +1 -0
- package/dist/sandbox/modes.d.ts +5 -2
- package/dist/sandbox/modes.js +8 -4
- package/dist/sandbox/network-grants.js +2 -0
- package/dist/sandbox/operation-intents.js +58 -0
- package/dist/sandbox/operation-reconcile.job.js +2 -0
- package/dist/sandbox/permission-authority-lock.js +12 -6
- package/dist/sandbox/permission-call-grants.js +6 -0
- package/dist/sandbox/permission-ceiling-writes.js +5 -0
- package/dist/sandbox/permission-config-publication.js +5 -0
- package/dist/sandbox/permission-instance-writes.js +4 -0
- package/dist/sandbox/permission-runtime-reports.js +10 -1
- package/dist/sandbox/permission-transitions.js +3 -0
- package/dist/sandbox/review/review.service.js +8 -5
- package/dist/sandbox/sandbox.service.d.ts +14 -0
- package/dist/sandbox/sandbox.service.js +195 -29
- package/dist/sandbox/unreachable.js +4 -1
- package/dist/schedules/fire.js +9 -3
- package/dist/schedules/pause.js +2 -0
- package/dist/schedules/run-tracker.js +16 -1
- package/dist/schedules/scheduled-tasks.service.js +4 -2
- package/dist/schedules/store.js +8 -0
- package/dist/schedules/unattended.js +4 -0
- package/dist/setup/setup-checks.service.d.ts +1 -10
- package/dist/setup/setup-checks.service.js +19 -29
- package/dist/shares/share-open.service.js +1 -0
- package/dist/shares/shares.service.js +2 -0
- package/dist/skills/agent-skills.service.d.ts +1 -1
- package/dist/skills/agent-skills.service.js +13 -2
- package/dist/skills/catalog.js +3 -0
- package/dist/skills/changes.service.js +10 -2
- package/dist/skills/conversation-catalog.js +1 -0
- package/dist/skills/skills.service.js +4 -0
- package/dist/tools/approvals.service.js +40 -0
- package/dist/tools/builtins/schedules.js +11 -6
- package/dist/tools/builtins/skill-load.d.ts +10 -9
- package/dist/tools/builtins/skill-load.js +15 -19
- package/dist/tools/builtins/web/fetch.js +1 -1
- package/dist/tools/builtins/web/search.js +1 -1
- package/dist/tools/connector-account-policies.js +3 -0
- package/dist/tools/connectors.controller.d.ts +20 -8
- package/dist/tools/connectors.controller.js +30 -12
- package/dist/tools/connectors.service.d.ts +8 -0
- package/dist/tools/connectors.service.js +21 -1
- package/dist/tools/drift.js +5 -0
- package/dist/tools/git-push-policy.js +3 -0
- package/dist/tools/oauth/flow.js +1 -0
- package/dist/tools/outputs.js +2 -0
- package/dist/tools/permission-approval-jobs.js +3 -0
- package/dist/tools/pipeline.js +2 -0
- package/dist/tools/policy.js +3 -0
- package/dist/tools/questions.service.js +13 -0
- package/package.json +3 -3
|
@@ -1240,7 +1240,10 @@ __decorate([
|
|
|
1240
1240
|
Transactional({ propagation: "mandatory" })
|
|
1241
1241
|
], CatalogScopeService.prototype, "enqueue", null);
|
|
1242
1242
|
CatalogScopeService = __decorate([
|
|
1243
|
-
Injectable()
|
|
1243
|
+
Injectable()
|
|
1244
|
+
// org-filter: super admin's platform plugin scope: an item's scope list, org switches and installs
|
|
1245
|
+
// span every org by design (keyed by the platform item id)
|
|
1246
|
+
,
|
|
1244
1247
|
__param(0, Inject(KernelDb)),
|
|
1245
1248
|
__param(1, Inject(SuperAdminLock)),
|
|
1246
1249
|
__param(2, Inject(CatalogService)),
|
|
@@ -205,6 +205,7 @@ let ComponentPromotion = class ComponentPromotion {
|
|
|
205
205
|
.updateTable("skills")
|
|
206
206
|
.set({ platform_skill_id: p.platformId, updated_at: sql `now()` })
|
|
207
207
|
.where("id", "=", row.id)
|
|
208
|
+
.where("org_id", "=", row.orgId)
|
|
208
209
|
.execute();
|
|
209
210
|
}
|
|
210
211
|
else {
|
|
@@ -245,6 +246,7 @@ let ComponentPromotion = class ComponentPromotion {
|
|
|
245
246
|
.updateTable("agent_templates")
|
|
246
247
|
.set({ platform_template_id: p.platformId, updated_at: new Date() })
|
|
247
248
|
.where("id", "=", row.id)
|
|
249
|
+
.where("org_id", "=", row.orgId)
|
|
248
250
|
.execute();
|
|
249
251
|
}
|
|
250
252
|
await this.db
|
|
@@ -3,7 +3,7 @@ import { PluginIcons } from "../extensions/plugin-icons.js";
|
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
5
5
|
import { ComponentParams, ComponentDisabledSchema as DisabledBody, ComponentIdSchema as IdParams, ComponentListQuery as ListQuery, OrgComponentListQuery, ComponentScopePreviewSchema as PreviewBody, ComponentScopeSchema as ScopeBody, ComponentShownSchema as ShownBody, ComponentSwitchBody as SwitchBody, ComponentTemplateVersionSchema as TemplateVersionBody } from "./component-scope.schemas.js";
|
|
6
|
-
import { type ComponentScopePreview, ComponentScopeService, type ComponentVersionView, type ComponentView, type OrgComponentView, type OrgOfferedComponentView } from "./component-scope.service.js";
|
|
6
|
+
import { type ComponentScopePreview, ComponentScopeService, type ComponentSwitchResult, type ComponentVersionView, type ComponentView, type OrgComponentView, type OrgOfferedComponentView } from "./component-scope.service.js";
|
|
7
7
|
import { PlatformComponents, type UploadedComponentVersion } from "./platform-components.js";
|
|
8
8
|
/**
|
|
9
9
|
* Platform components (`/api/v1/admin/components/*`, super admins; plugin scope phase 2, Task 6):
|
|
@@ -30,7 +30,8 @@ export declare class AdminComponentsController {
|
|
|
30
30
|
uploadAgentTemplateVersion(principal: Principal, p: z.infer<typeof IdParams>, body: z.infer<typeof TemplateVersionBody>): Promise<UploadedComponentVersion>;
|
|
31
31
|
/**
|
|
32
32
|
* `GET ?kind=`: every platform component of the kind (plugin, owner, scope, version, orgs on),
|
|
33
|
-
* each with its display name and
|
|
33
|
+
* each with its display name and `icon` (a connector template's own icon, else its plugin's, on
|
|
34
|
+
* the admin routes; null without one).
|
|
34
35
|
*/
|
|
35
36
|
list(q: z.infer<typeof ListQuery>): Promise<{
|
|
36
37
|
components: (ComponentView & {
|
|
@@ -78,8 +79,9 @@ export declare class OrgComponentsController {
|
|
|
78
79
|
* The platform components offered to the org (`?kind=`, `?itemId=`: only those; Task 10): each
|
|
79
80
|
* with its state in the org (`on`, `locked` for `all`, the org's `switch`) and whether an org
|
|
80
81
|
* admin may switch it. Members read it (the workspace pages are read-only for them). Each has
|
|
81
|
-
* its display name and `icon`, its plugin's
|
|
82
|
-
* or when the org's catalog does not show the plugin to the reader:
|
|
82
|
+
* its display name and `icon`, a connector template's own icon, else its plugin's, on the org's
|
|
83
|
+
* routes (null without one, or when the org's catalog does not show the plugin to the reader:
|
|
84
|
+
* the share gate holds).
|
|
83
85
|
*/
|
|
84
86
|
list(org: OrgContext, q: z.infer<typeof OrgComponentListQuery>): Promise<{
|
|
85
87
|
components: (OrgOfferedComponentView & {
|
|
@@ -88,15 +90,7 @@ export declare class OrgComponentsController {
|
|
|
88
90
|
}>;
|
|
89
91
|
setSwitch(principal: Principal, org: OrgContext, p: z.infer<typeof ComponentParams>, body: z.infer<typeof SwitchBody>): Promise<{
|
|
90
92
|
component: OrgComponentView;
|
|
91
|
-
} | {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
id: string;
|
|
95
|
-
name: string;
|
|
96
|
-
refs: string[];
|
|
97
|
-
}[];
|
|
98
|
-
connectorsKept: number;
|
|
99
|
-
};
|
|
100
|
-
confirm: string;
|
|
101
|
-
}>;
|
|
93
|
+
} | Omit<Extract<ComponentSwitchResult, {
|
|
94
|
+
kind: "preview";
|
|
95
|
+
}>, "kind">>;
|
|
102
96
|
}
|
|
@@ -38,14 +38,17 @@ class ComponentShownBody extends createZodDto(ShownBody, "ComponentShownBody") {
|
|
|
38
38
|
class ComponentSwitchBody extends createZodDto(SwitchBody, "ComponentSwitchBody") {
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Each component with `icon
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* Each component with `icon` on the reader's route: a connector template's own icon, else its
|
|
42
|
+
* plugin's icon (maintainer decision 2026-11-09: a connector template without an icon of its own
|
|
43
|
+
* shows its plugin's); null without one, for a component without a plugin, or when the reader may
|
|
44
|
+
* not see the plugin.
|
|
44
45
|
*/
|
|
45
46
|
async function withIcons(icons, rows, scope) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const urls = await icons.ofTemplatesOrItems(rows.map((r) => ({
|
|
48
|
+
templateId: r.kind === "connector_template" ? r.id : null,
|
|
49
|
+
itemId: r.itemId,
|
|
50
|
+
})), scope);
|
|
51
|
+
return rows.map((r, i) => ({ ...r, icon: urls[i] ?? null }));
|
|
49
52
|
}
|
|
50
53
|
const actorOpts = (actor) => {
|
|
51
54
|
const tokenId = patTokenId(actor);
|
|
@@ -88,7 +91,8 @@ let AdminComponentsController = class AdminComponentsController {
|
|
|
88
91
|
}
|
|
89
92
|
/**
|
|
90
93
|
* `GET ?kind=`: every platform component of the kind (plugin, owner, scope, version, orgs on),
|
|
91
|
-
* each with its display name and
|
|
94
|
+
* each with its display name and `icon` (a connector template's own icon, else its plugin's, on
|
|
95
|
+
* the admin routes; null without one).
|
|
92
96
|
*/
|
|
93
97
|
async list(q) {
|
|
94
98
|
return {
|
|
@@ -217,8 +221,9 @@ let OrgComponentsController = class OrgComponentsController {
|
|
|
217
221
|
* The platform components offered to the org (`?kind=`, `?itemId=`: only those; Task 10): each
|
|
218
222
|
* with its state in the org (`on`, `locked` for `all`, the org's `switch`) and whether an org
|
|
219
223
|
* admin may switch it. Members read it (the workspace pages are read-only for them). Each has
|
|
220
|
-
* its display name and `icon`, its plugin's
|
|
221
|
-
* or when the org's catalog does not show the plugin to the reader:
|
|
224
|
+
* its display name and `icon`, a connector template's own icon, else its plugin's, on the org's
|
|
225
|
+
* routes (null without one, or when the org's catalog does not show the plugin to the reader:
|
|
226
|
+
* the share gate holds).
|
|
222
227
|
*/
|
|
223
228
|
async list(org, q) {
|
|
224
229
|
const rows = await this.scope.orgList(org.orgId, {
|
|
@@ -331,6 +331,7 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
331
331
|
* (ruling P2-11): listed read-only, on in their org only. Connector templates have none; an
|
|
332
332
|
* org's own theme is a platform_themes row with its org as owner, listed with the platform ones.
|
|
333
333
|
*/
|
|
334
|
+
// org-filter: super admin's component list: every org's own skills and templates are listed
|
|
334
335
|
async orgOwned(kind, orgs) {
|
|
335
336
|
if (kind === "connector_template" || kind === "theme")
|
|
336
337
|
return [];
|
|
@@ -676,6 +677,8 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
676
677
|
})
|
|
677
678
|
.where("id", "=", id)
|
|
678
679
|
.execute();
|
|
680
|
+
// org-filter: super admin's scope change (adminLock above) replaces the platform component's
|
|
681
|
+
// whole named list, which spans orgs by design
|
|
679
682
|
await this.db
|
|
680
683
|
.deleteFrom("component_scope_orgs")
|
|
681
684
|
.where("kind", "=", kind)
|
|
@@ -883,6 +886,7 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
883
886
|
* The scope that offers the component now: its own (`listed`: its own list), or for `follow` its
|
|
884
887
|
* plugin's (`all` for a builtin or deleted plugin: the widest, so nothing counts as widening).
|
|
885
888
|
*/
|
|
889
|
+
// org-filter: a platform plugin's named org list, keyed by its platform item id (spans orgs)
|
|
886
890
|
async effectiveScope(c, listed) {
|
|
887
891
|
if (c.scopeMode === "own" || c.itemId === null)
|
|
888
892
|
return { scope: c.scope, orgs: listed };
|
|
@@ -902,6 +906,7 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
902
906
|
return { scope: item.scope, orgs: rows.map((r) => r.org_id) };
|
|
903
907
|
}
|
|
904
908
|
/** The component's own `named` list, sorted. */
|
|
909
|
+
// org-filter: a platform component's named org list, keyed by its platform id (spans orgs)
|
|
905
910
|
async listed(kind, id) {
|
|
906
911
|
const rows = await this.db
|
|
907
912
|
.selectFrom("component_scope_orgs")
|
|
@@ -180,6 +180,8 @@ const groupBy = (rows, key, value) => {
|
|
|
180
180
|
return out;
|
|
181
181
|
};
|
|
182
182
|
/** Reads the {@link ScopeState} of `comps` (all of one kind), one query after the other. */
|
|
183
|
+
// org-filter: the scope state of platform components and their plugins for every org (named lists,
|
|
184
|
+
// installs, switches keyed by platform ids); callers pick their own org out of it
|
|
183
185
|
export async function loadScopeState(db, kind, comps) {
|
|
184
186
|
const itemIds = [...new Set(comps.map((c) => c.itemId).filter((x) => x !== null))];
|
|
185
187
|
const ids = comps.map((c) => c.id);
|
|
@@ -33,6 +33,11 @@ export type MarketplaceForm = "http" | "git";
|
|
|
33
33
|
/** 一个清单来源(后台列表)。令牌不回显,只给 `hasToken`。 */
|
|
34
34
|
export interface MarketplaceView {
|
|
35
35
|
id: string;
|
|
36
|
+
/**
|
|
37
|
+
* The label: the official marketplace's is "Capybara"; a config-managed one shows its
|
|
38
|
+
* marketplace.json `owner.name` (its config name before a refresh read one); a custom one, the
|
|
39
|
+
* name the admin gave it.
|
|
40
|
+
*/
|
|
36
41
|
name: string;
|
|
37
42
|
url: string;
|
|
38
43
|
form: MarketplaceForm;
|
|
@@ -203,7 +208,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
203
208
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
204
209
|
export declare const HOST_VERSIONS: {
|
|
205
210
|
readonly kernel: string;
|
|
206
|
-
readonly sdk: "0.1.0-rc.
|
|
211
|
+
readonly sdk: "0.1.0-rc.64";
|
|
207
212
|
};
|
|
208
213
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
209
214
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -35,8 +35,11 @@ import { withoutRemovedManifestFields } from "./plugin-package.js";
|
|
|
35
35
|
import { compareVersions, newestFirst, sameRelease } from "./versions.js";
|
|
36
36
|
/** 官方清单来源的 id。 */
|
|
37
37
|
export const OFFICIAL_MARKETPLACE_ID = "official";
|
|
38
|
-
/**
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The official marketplace lists the upstream project's plugins, so it carries the project's name
|
|
40
|
+
* under any platform name.
|
|
41
|
+
*/
|
|
42
|
+
const OFFICIAL_MARKETPLACE_NAME = "Capybara";
|
|
40
43
|
/** 企业清单的可选令牌:secrets 的 namespace `kernel`、org `_deployment`、键 `catalog-token:<id>`(preflight #65)。 */
|
|
41
44
|
const SECRETS_NAMESPACE = "kernel";
|
|
42
45
|
const tokenKey = (id) => `catalog-token:${id}`;
|
|
@@ -1673,7 +1676,9 @@ let MarketplacesService = class MarketplacesService {
|
|
|
1673
1676
|
const count = new Map(counts.map((c) => [c.source_id, Number(c.n)]));
|
|
1674
1677
|
return rows.map((r) => ({
|
|
1675
1678
|
id: r.id,
|
|
1676
|
-
name
|
|
1679
|
+
// A config-managed row's name is the manifest's key (`config:<name>`, the token's env name):
|
|
1680
|
+
// it shows the owner its marketplace.json names once a refresh read it
|
|
1681
|
+
name: r.managed === "config" ? (r.owner_name ?? r.name) : r.name,
|
|
1677
1682
|
url: r.url,
|
|
1678
1683
|
form: r.form,
|
|
1679
1684
|
ref: r.ref,
|
|
@@ -94,6 +94,15 @@ export declare class OrgCatalogController {
|
|
|
94
94
|
* -> 404 `catalog.icon_not_found`; members do not see disabled items.
|
|
95
95
|
*/
|
|
96
96
|
icon(org: OrgContext, itemId: string, reply: FastifyReply): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* A platform connector template's own icon (svg or png, same response headers as the item icon,
|
|
99
|
+
* see {@link sendCatalogIcon}); the connector pages show it for the template's cards and the
|
|
100
|
+
* connectors made from it (`PluginIcons.ofTemplatesOrItems`), so guests, who read connectors,
|
|
101
|
+
* may load it. A template the org's catalog does not show (its plugin hidden from the org, or
|
|
102
|
+
* another org's template behind the share gate) -> 404 `component.not_found`; no icon of its own
|
|
103
|
+
* -> 404 `catalog.icon_not_found`.
|
|
104
|
+
*/
|
|
105
|
+
templateIcon(org: OrgContext, templateId: string, reply: FastifyReply): Promise<void>;
|
|
97
106
|
/**
|
|
98
107
|
* A setup guide of the item, rendered for this org (spec 2026-11-09-setup-guides-v2-design.md
|
|
99
108
|
* §7.2): the document's blocks with the place's variables filled in, its modes, audiences and
|
|
@@ -118,6 +118,17 @@ let OrgCatalogController = class OrgCatalogController {
|
|
|
118
118
|
const icon = await this.catalog.icon(itemId, roleAtLeast(org.role, "admin"), org.orgId);
|
|
119
119
|
await sendCatalogIcon(reply, icon);
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* A platform connector template's own icon (svg or png, same response headers as the item icon,
|
|
123
|
+
* see {@link sendCatalogIcon}); the connector pages show it for the template's cards and the
|
|
124
|
+
* connectors made from it (`PluginIcons.ofTemplatesOrItems`), so guests, who read connectors,
|
|
125
|
+
* may load it. A template the org's catalog does not show (its plugin hidden from the org, or
|
|
126
|
+
* another org's template behind the share gate) -> 404 `component.not_found`; no icon of its own
|
|
127
|
+
* -> 404 `catalog.icon_not_found`.
|
|
128
|
+
*/
|
|
129
|
+
async templateIcon(org, templateId, reply) {
|
|
130
|
+
await sendCatalogIcon(reply, await this.icons.readTemplateIcon(templateId, orgIconScope(org)));
|
|
131
|
+
}
|
|
121
132
|
/**
|
|
122
133
|
* A setup guide of the item, rendered for this org (spec 2026-11-09-setup-guides-v2-design.md
|
|
123
134
|
* §7.2): the document's blocks with the place's variables filled in, its modes, audiences and
|
|
@@ -248,6 +259,13 @@ __decorate([
|
|
|
248
259
|
__param(1, Param("itemId")),
|
|
249
260
|
__param(2, Res())
|
|
250
261
|
], OrgCatalogController.prototype, "icon", null);
|
|
262
|
+
__decorate([
|
|
263
|
+
Get("connector-templates/:templateId/icon"),
|
|
264
|
+
OrgAction("connectors.use"),
|
|
265
|
+
__param(0, CurrentOrg()),
|
|
266
|
+
__param(1, Param("templateId")),
|
|
267
|
+
__param(2, Res())
|
|
268
|
+
], OrgCatalogController.prototype, "templateIcon", null);
|
|
251
269
|
__decorate([
|
|
252
270
|
Get("catalog/:itemId/guides/:guideId"),
|
|
253
271
|
OrgAction("catalog.read"),
|
|
@@ -43,8 +43,8 @@ export declare const CatalogConnectorInput: z.ZodObject<{
|
|
|
43
43
|
}, z.core.$strict>>;
|
|
44
44
|
}, z.core.$strict>;
|
|
45
45
|
/**
|
|
46
|
-
* The org install body: template input
|
|
47
|
-
*
|
|
46
|
+
* The org install body: template input. No version: an org installs the platform version (one per
|
|
47
|
+
* deployment, ruling P2-17).
|
|
48
48
|
*/
|
|
49
49
|
export declare const OrgPluginInstallBody: z.ZodObject<{
|
|
50
50
|
connectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -57,7 +57,6 @@ export declare const OrgPluginInstallBody: z.ZodObject<{
|
|
|
57
57
|
clientSecret: z.ZodOptional<z.ZodString>;
|
|
58
58
|
}, z.core.$strict>>;
|
|
59
59
|
}, z.core.$strict>>>;
|
|
60
|
-
extensionConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
61
60
|
}, z.core.$strict>;
|
|
62
61
|
/**
|
|
63
62
|
* `POST …/catalog/:itemId/connectors` (ruling P2-10): the input of missing connectors, by template
|
|
@@ -111,7 +110,6 @@ export declare const OrgPluginSwitchBody: z.ZodObject<{
|
|
|
111
110
|
clientSecret: z.ZodOptional<z.ZodString>;
|
|
112
111
|
}, z.core.$strict>>;
|
|
113
112
|
}, z.core.$strict>>>;
|
|
114
|
-
extensionConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
115
113
|
}, z.core.$strict>>;
|
|
116
114
|
confirm: z.ZodOptional<z.ZodString>;
|
|
117
115
|
}, z.core.$strict>;
|
|
@@ -70,13 +70,12 @@ export const CatalogConnectorInput = z
|
|
|
70
70
|
})
|
|
71
71
|
.strict();
|
|
72
72
|
/**
|
|
73
|
-
* The org install body: template input
|
|
74
|
-
*
|
|
73
|
+
* The org install body: template input. No version: an org installs the platform version (one per
|
|
74
|
+
* deployment, ruling P2-17).
|
|
75
75
|
*/
|
|
76
76
|
export const OrgPluginInstallBody = z
|
|
77
77
|
.object({
|
|
78
78
|
connectors: z.record(z.string(), CatalogConnectorInput).optional(),
|
|
79
|
-
extensionConfig: z.record(z.string(), z.unknown()).optional(),
|
|
80
79
|
})
|
|
81
80
|
.strict();
|
|
82
81
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
2
|
+
import { PluginIcons } from "../extensions/plugin-icons.js";
|
|
1
3
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
2
4
|
import { ExtensionAvailability } from "../extensions/unavailable.js";
|
|
3
5
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -38,11 +40,16 @@ export declare class OrgCatalogService {
|
|
|
38
40
|
readonly txHost: TransactionHost;
|
|
39
41
|
/** Why a plugin's extension cannot run (the `unavailable` state's reason). */
|
|
40
42
|
private readonly availability;
|
|
43
|
+
/** The effective config of an extension for the org: a wanted plugin whose config is not valid needs input. */
|
|
44
|
+
private readonly effective;
|
|
45
|
+
private readonly icons;
|
|
41
46
|
constructor(kdb: KernelDb,
|
|
42
47
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
43
48
|
orgLock: OrgLock, storage: StorageService, registry: ExtensionRegistry, pluginInstaller: PluginInstaller, log: KernelLogger, txHost: TransactionHost,
|
|
44
49
|
/** Why a plugin's extension cannot run (the `unavailable` state's reason). */
|
|
45
|
-
availability: ExtensionAvailability
|
|
50
|
+
availability: ExtensionAvailability,
|
|
51
|
+
/** The effective config of an extension for the org: a wanted plugin whose config is not valid needs input. */
|
|
52
|
+
effective: Pick<EffectiveConfigs, "get">, icons: PluginIcons);
|
|
46
53
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
47
54
|
private get db();
|
|
48
55
|
/**
|
|
@@ -57,6 +64,8 @@ export declare class OrgCatalogService {
|
|
|
57
64
|
* connector templates (endpoint preset, editable paths, auth preset), dependencies, skills and
|
|
58
65
|
* agent templates.
|
|
59
66
|
*/
|
|
67
|
+
/** The account is an admin (or owner) of the org. */
|
|
68
|
+
private isOrgAdmin;
|
|
60
69
|
detail(orgId: string, accountId: string, itemId: string): Promise<OrgCatalogDetail>;
|
|
61
70
|
/**
|
|
62
71
|
* The item's icon; members don't see disabled items, nobody outside its list sees a hidden
|
|
@@ -9,7 +9,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { ApiError } from "../errors.js";
|
|
12
|
+
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
12
13
|
import { templateGuideOf } from "../extensions/plugin-guides.js";
|
|
14
|
+
import { PluginIcons } from "../extensions/plugin-icons.js";
|
|
13
15
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
14
16
|
import { ExtensionAvailability } from "../extensions/unavailable.js";
|
|
15
17
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -51,11 +53,15 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
51
53
|
log;
|
|
52
54
|
txHost;
|
|
53
55
|
availability;
|
|
56
|
+
effective;
|
|
57
|
+
icons;
|
|
54
58
|
constructor(kdb,
|
|
55
59
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
56
60
|
orgLock, storage, registry, pluginInstaller, log, txHost,
|
|
57
61
|
/** Why a plugin's extension cannot run (the `unavailable` state's reason). */
|
|
58
|
-
availability
|
|
62
|
+
availability,
|
|
63
|
+
/** The effective config of an extension for the org: a wanted plugin whose config is not valid needs input. */
|
|
64
|
+
effective, icons) {
|
|
59
65
|
this.kdb = kdb;
|
|
60
66
|
this.orgLock = orgLock;
|
|
61
67
|
this.storage = storage;
|
|
@@ -64,6 +70,8 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
64
70
|
this.log = log;
|
|
65
71
|
this.txHost = txHost;
|
|
66
72
|
this.availability = availability;
|
|
73
|
+
this.effective = effective;
|
|
74
|
+
this.icons = icons;
|
|
67
75
|
}
|
|
68
76
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
69
77
|
get db() {
|
|
@@ -75,13 +83,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
75
83
|
* and absent for members. Each item carries the org's pending request for it.
|
|
76
84
|
*/
|
|
77
85
|
async list(orgId, accountId, itemId) {
|
|
78
|
-
const
|
|
79
|
-
.selectFrom("memberships")
|
|
80
|
-
.select("role")
|
|
81
|
-
.where("org_id", "=", orgId)
|
|
82
|
-
.where("account_id", "=", accountId)
|
|
83
|
-
.executeTakeFirst();
|
|
84
|
-
const isAdmin = m !== undefined && roleAtLeast(m.role, "admin");
|
|
86
|
+
const isAdmin = await this.isOrgAdmin(orgId, accountId);
|
|
85
87
|
let q = this.db
|
|
86
88
|
.selectFrom("catalog_items")
|
|
87
89
|
.selectAll()
|
|
@@ -116,7 +118,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
116
118
|
return [];
|
|
117
119
|
const sw = new Map(switches.map((r) => [r.item_id, r.enabled]));
|
|
118
120
|
const ids = items.map((i) => i.id);
|
|
119
|
-
const [versions, pluginInstalls,
|
|
121
|
+
const [versions, pluginInstalls, requests] = await Promise.all([
|
|
120
122
|
this.db
|
|
121
123
|
.selectFrom("catalog_item_versions")
|
|
122
124
|
.select([
|
|
@@ -138,12 +140,6 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
138
140
|
.where("org_id", "=", orgId)
|
|
139
141
|
.where("status", "in", [...LIVE_INSTALL_STATUSES])
|
|
140
142
|
.execute(),
|
|
141
|
-
this.db
|
|
142
|
-
.selectFrom("extension_org_configs")
|
|
143
|
-
.select("plugin")
|
|
144
|
-
.where("org_id", "=", orgId)
|
|
145
|
-
.where("config", "is not", null)
|
|
146
|
-
.execute(),
|
|
147
143
|
this.db
|
|
148
144
|
.selectFrom("catalog_requests")
|
|
149
145
|
.select(["id", "item_id", "kind", "created_at"])
|
|
@@ -162,7 +158,6 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
162
158
|
const v = versions.find((x) => x.item_id === i.id && x.version === i.latest_version);
|
|
163
159
|
return v ? [v] : [];
|
|
164
160
|
}));
|
|
165
|
-
const configured = new Set(configs.map((c) => c.plugin));
|
|
166
161
|
const owners = await ownersOf(this.db, items.flatMap((i) => (i.owner_org_id === null ? [] : [i.owner_org_id])));
|
|
167
162
|
const loaded = new Map(this.registry.manifests().map((x) => [x.name, x]));
|
|
168
163
|
// the extensions of the latest versions that are not loaded: why (the `unavailable` reason)
|
|
@@ -222,9 +217,8 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
222
217
|
const templateIds = (m?.connectorTemplates ?? []).map((t) => templateIdOfPath(t.path));
|
|
223
218
|
const needsInputs = (await connectorTemplatesOn(this.db, orgId, i.id, templateIds)).size > 0 ||
|
|
224
219
|
(m?.extension !== undefined &&
|
|
225
|
-
ext
|
|
226
|
-
!
|
|
227
|
-
!configured.has(m.name));
|
|
220
|
+
ext !== undefined &&
|
|
221
|
+
!(await this.effective.get(orgId, m.name)).ok);
|
|
228
222
|
// Wanted but not installed and needing nothing: the sync has not installed it (yet, or its
|
|
229
223
|
// install failed); `off`, so an org admin can switch it on (the worker start retries it)
|
|
230
224
|
state = needsInputs ? "needs_config" : "off";
|
|
@@ -258,6 +252,16 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
258
252
|
* connector templates (endpoint preset, editable paths, auth preset), dependencies, skills and
|
|
259
253
|
* agent templates.
|
|
260
254
|
*/
|
|
255
|
+
/** The account is an admin (or owner) of the org. */
|
|
256
|
+
async isOrgAdmin(orgId, accountId) {
|
|
257
|
+
const m = await this.db
|
|
258
|
+
.selectFrom("memberships")
|
|
259
|
+
.select("role")
|
|
260
|
+
.where("org_id", "=", orgId)
|
|
261
|
+
.where("account_id", "=", accountId)
|
|
262
|
+
.executeTakeFirst();
|
|
263
|
+
return m !== undefined && roleAtLeast(m.role, "admin");
|
|
264
|
+
}
|
|
261
265
|
async detail(orgId, accountId, itemId) {
|
|
262
266
|
if (!UUID_RE.test(itemId))
|
|
263
267
|
throw itemNotFound();
|
|
@@ -293,6 +297,12 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
293
297
|
return [];
|
|
294
298
|
throw e;
|
|
295
299
|
});
|
|
300
|
+
const missing = item.installed !== null && item.state === "needs_config"
|
|
301
|
+
? ((await this.pluginInstaller.missingConnectors(orgId, itemId))?.templates ?? [])
|
|
302
|
+
: [];
|
|
303
|
+
// Each template's icon on the org's routes (its own, else the plugin's)
|
|
304
|
+
const icons = await this.icons.ofItemTemplates(itemId, [...templates, ...missing].map((t) => t.id), { kind: "org", orgId, isAdmin: await this.isOrgAdmin(orgId, accountId) });
|
|
305
|
+
const iconOf = (templateId) => icons.get(templateId) ?? null;
|
|
296
306
|
return {
|
|
297
307
|
item,
|
|
298
308
|
hasIcon: m.icon !== undefined,
|
|
@@ -301,6 +311,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
301
311
|
guide: guideOf(t.id),
|
|
302
312
|
on: on.has(t.id),
|
|
303
313
|
connected: connected.has(t.id),
|
|
314
|
+
icon: iconOf(t.id),
|
|
304
315
|
})),
|
|
305
316
|
dependencies: [
|
|
306
317
|
...(m.dependencies ?? []).map((d) => ({ name: d.name, range: d.version })),
|
|
@@ -308,9 +319,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
308
319
|
],
|
|
309
320
|
skills: (m.skills ?? []).map((s) => packagePath(s.path)),
|
|
310
321
|
agents: (m.agents ?? []).map((a) => packagePath(a.path)),
|
|
311
|
-
missingTemplates:
|
|
312
|
-
? ((await this.pluginInstaller.missingConnectors(orgId, itemId))?.templates ?? []).map((t) => orgTemplateView(t.id, t.file, { guide: guideOf(t.id), on: true }))
|
|
313
|
-
: [],
|
|
322
|
+
missingTemplates: missing.map((t) => orgTemplateView(t.id, t.file, { guide: guideOf(t.id), on: true, icon: iconOf(t.id) })),
|
|
314
323
|
};
|
|
315
324
|
}
|
|
316
325
|
/**
|
|
@@ -603,6 +612,8 @@ OrgCatalogService = __decorate([
|
|
|
603
612
|
__param(4, Inject(PluginInstaller)),
|
|
604
613
|
__param(5, Inject(KERNEL_LOGGER)),
|
|
605
614
|
__param(6, Inject(TransactionHost)),
|
|
606
|
-
__param(7, Inject(ExtensionAvailability))
|
|
615
|
+
__param(7, Inject(ExtensionAvailability)),
|
|
616
|
+
__param(8, Inject(EffectiveConfigs)),
|
|
617
|
+
__param(9, Inject(PluginIcons))
|
|
607
618
|
], OrgCatalogService);
|
|
608
619
|
export { OrgCatalogService };
|
|
@@ -15,15 +15,9 @@ export type OrgExtensionPutResult = {
|
|
|
15
15
|
* `PUT orgs/:orgId/extensions/:extension`: for an extension that ships in a catalog plugin, `enabled`
|
|
16
16
|
* is the plugin's org switch ({@link OrgCatalogService.setSwitch}); anything else is the direct
|
|
17
17
|
* {@link OrgExtensionConfigs.put}. Lives in the catalog module because the catalog depends on the
|
|
18
|
-
* extensions, not the other way round. No in-process state.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* before the plugin switches with the plain 400 `extension.config_invalid`. Switching on validates
|
|
22
|
-
* the effective config (the stored one with its secrets, or the given `config` merged with them),
|
|
23
|
-
* and the install receives the given `config` as its `extensionConfig`, so the extension is enabled
|
|
24
|
-
* with it. A config write that fails for another reason after the switch succeeded returns that
|
|
25
|
-
* error in the same transaction as the switch, so the switch stays as it was (a fresh install is the
|
|
26
|
-
* exception: it commits on its own and carries the config itself).
|
|
18
|
+
* extensions, not the other way round. No in-process state. Switching never checks a config: an
|
|
19
|
+
* extension whose effective config is not valid in the org is switched on and reported
|
|
20
|
+
* `needsConfig` (spec A §6).
|
|
27
21
|
*/
|
|
28
22
|
export declare class OrgExtensionSwitch {
|
|
29
23
|
readonly txHost: TransactionHost;
|
|
@@ -36,7 +30,6 @@ export declare class OrgExtensionSwitch {
|
|
|
36
30
|
* source items) -> 409 `plugin.scope_locked` (an `all` one may go off, layering spec §4).
|
|
37
31
|
* - A required bootstrap plugin, a config-declared extension and one sourced from several items
|
|
38
32
|
* keep the direct write.
|
|
39
|
-
* - `config` is always written directly, after the switch.
|
|
40
33
|
*/
|
|
41
34
|
put(orgId: string, actor: string, extension: string, body: OrgExtensionInput & {
|
|
42
35
|
confirm?: string | undefined;
|
|
@@ -17,15 +17,9 @@ import { OrgCatalogService } from "./org-catalog.service.js";
|
|
|
17
17
|
* `PUT orgs/:orgId/extensions/:extension`: for an extension that ships in a catalog plugin, `enabled`
|
|
18
18
|
* is the plugin's org switch ({@link OrgCatalogService.setSwitch}); anything else is the direct
|
|
19
19
|
* {@link OrgExtensionConfigs.put}. Lives in the catalog module because the catalog depends on the
|
|
20
|
-
* extensions, not the other way round. No in-process state.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* before the plugin switches with the plain 400 `extension.config_invalid`. Switching on validates
|
|
24
|
-
* the effective config (the stored one with its secrets, or the given `config` merged with them),
|
|
25
|
-
* and the install receives the given `config` as its `extensionConfig`, so the extension is enabled
|
|
26
|
-
* with it. A config write that fails for another reason after the switch succeeded returns that
|
|
27
|
-
* error in the same transaction as the switch, so the switch stays as it was (a fresh install is the
|
|
28
|
-
* exception: it commits on its own and carries the config itself).
|
|
20
|
+
* extensions, not the other way round. No in-process state. Switching never checks a config: an
|
|
21
|
+
* extension whose effective config is not valid in the org is switched on and reported
|
|
22
|
+
* `needsConfig` (spec A §6).
|
|
29
23
|
*/
|
|
30
24
|
let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
31
25
|
txHost;
|
|
@@ -42,7 +36,6 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
42
36
|
* source items) -> 409 `plugin.scope_locked` (an `all` one may go off, layering spec §4).
|
|
43
37
|
* - A required bootstrap plugin, a config-declared extension and one sourced from several items
|
|
44
38
|
* keep the direct write.
|
|
45
|
-
* - `config` is always written directly, after the switch.
|
|
46
39
|
*/
|
|
47
40
|
async put(orgId, actor, extension, body, actorTokenId,
|
|
48
41
|
/** Merged into the audit details (a Platform operation's `via: "agent"`). */
|
|
@@ -62,16 +55,9 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
62
55
|
};
|
|
63
56
|
}
|
|
64
57
|
const { enabled } = input;
|
|
65
|
-
const config = input.config !== undefined ? { config: input.config } : {};
|
|
66
|
-
// Fail before the switch when the config would be refused: switching on checks the effective
|
|
67
|
-
// config (a required field never saved is refused here, not as a failed install)
|
|
68
|
-
if (enabled || input.config !== undefined) {
|
|
69
|
-
await this.configs.put(orgId, extension, { ...config, ...(enabled && { enabled: true }) }, actor, actorTokenId, { validateOnly: true });
|
|
70
|
-
}
|
|
71
58
|
// A fresh install is a multi-step saga that commits on its own and already enables the
|
|
72
|
-
// extension
|
|
73
|
-
//
|
|
74
|
-
// transaction: a failing config write leaves the switch as it was.
|
|
59
|
+
// extension: no transaction spans it. Everything else (the switch row, an uninstall, reading
|
|
60
|
+
// the result back) is one transaction.
|
|
75
61
|
const installing = enabled === true && !(await this.catalog.hasLiveInstall(orgId, plan.itemId));
|
|
76
62
|
const args = {
|
|
77
63
|
orgId,
|
|
@@ -79,7 +65,6 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
79
65
|
extension,
|
|
80
66
|
itemId: plan.itemId,
|
|
81
67
|
enabled,
|
|
82
|
-
input,
|
|
83
68
|
confirm,
|
|
84
69
|
actorTokenId,
|
|
85
70
|
auditDetail,
|
|
@@ -103,7 +88,7 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
103
88
|
return this.apply(a, false);
|
|
104
89
|
}
|
|
105
90
|
async apply(a, installing) {
|
|
106
|
-
const { orgId, actor, extension, itemId, enabled,
|
|
91
|
+
const { orgId, actor, extension, itemId, enabled, confirm, actorTokenId, auditDetail } = a;
|
|
107
92
|
const audited = auditDetail !== undefined ? { auditDetail } : {};
|
|
108
93
|
// Switching on inside the transaction relies on the live install seen before it: one removed
|
|
109
94
|
// meanwhile would run the install saga here, which commits on its own. Refuse instead; the
|
|
@@ -111,34 +96,18 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
111
96
|
if (!installing && enabled === true && !(await this.catalog.hasLiveInstall(orgId, itemId))) {
|
|
112
97
|
throw new ApiError("conflict", "The plugin's install in this organization changed while it was being switched on; try again");
|
|
113
98
|
}
|
|
114
|
-
const r = await this.catalog
|
|
115
|
-
.setSwitch(orgId, actor, itemId, enabled
|
|
116
|
-
? {
|
|
117
|
-
enabled: true,
|
|
118
|
-
...(input.config !== undefined && { inputs: { extensionConfig: input.config } }),
|
|
119
|
-
}
|
|
120
|
-
: { enabled: false, ...(confirm !== undefined && { confirm }) }, actorTokenId, auditDetail)
|
|
121
|
-
.catch((e) => {
|
|
122
|
-
throw configInvalidOf(e) ?? e;
|
|
123
|
-
});
|
|
99
|
+
const r = await this.catalog.setSwitch(orgId, actor, itemId, enabled ? { enabled: true } : { enabled: false, ...(confirm !== undefined && { confirm }) }, actorTokenId, auditDetail);
|
|
124
100
|
if (r.kind === "preview")
|
|
125
101
|
return r;
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
// Switching on: the install enabled it already (no second write)
|
|
131
|
-
return {
|
|
132
|
-
kind: "done",
|
|
133
|
-
view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
|
|
134
|
-
ifDisabled: { skipped: false },
|
|
135
|
-
...audited,
|
|
136
|
-
}),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
102
|
+
if (!enabled)
|
|
103
|
+
return "readBack";
|
|
104
|
+
// Switching on: the install enabled it already (no second write)
|
|
139
105
|
return {
|
|
140
106
|
kind: "done",
|
|
141
|
-
view: await this.configs.put(orgId, extension, {
|
|
107
|
+
view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
|
|
108
|
+
ifDisabled: { skipped: false },
|
|
109
|
+
...audited,
|
|
110
|
+
}),
|
|
142
111
|
};
|
|
143
112
|
}
|
|
144
113
|
};
|
|
@@ -152,18 +121,3 @@ OrgExtensionSwitch = __decorate([
|
|
|
152
121
|
__param(2, Inject(OrgCatalogService))
|
|
153
122
|
], OrgExtensionSwitch);
|
|
154
123
|
export { OrgExtensionSwitch };
|
|
155
|
-
/**
|
|
156
|
-
* An install that failed only at its own extension step on the org config (it was valid when
|
|
157
|
-
* checked, then changed concurrently): the plain 400 `extension.config_invalid` with the field
|
|
158
|
-
* issues, as when saving the config; the install was rolled back. Anything else: undefined.
|
|
159
|
-
*/
|
|
160
|
-
function configInvalidOf(e) {
|
|
161
|
-
if (!(e instanceof ApiError) || e.code !== "plugin.install_failed")
|
|
162
|
-
return undefined;
|
|
163
|
-
const [d] = (e.details ?? []);
|
|
164
|
-
if (d?.step !== "extension" || d.code !== "extension.config_invalid")
|
|
165
|
-
return undefined;
|
|
166
|
-
if (d.dependency !== undefined || d.rolledBack !== true)
|
|
167
|
-
return undefined;
|
|
168
|
-
return new ApiError("extension.config_invalid", d.message ?? "Invalid organization config", d.causeDetails);
|
|
169
|
-
}
|