@capybara-hq/kernel 0.1.0-rc.142 → 0.1.0-rc.144
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/dist/admin/admin-agents.controller.d.ts +3 -5
- package/dist/admin/admin-agents.controller.js +1 -1
- package/dist/admin/admin-connectors.controller.d.ts +3 -5
- package/dist/admin/admin-connectors.controller.js +1 -1
- package/dist/admin/admin-items.schemas.d.ts +6 -6
- package/dist/admin/admin-items.schemas.js +5 -9
- package/dist/admin/admin.controller.d.ts +18 -12
- package/dist/admin/admin.controller.js +29 -15
- package/dist/admin/admin.schemas.d.ts +12 -3
- package/dist/admin/admin.schemas.js +17 -6
- package/dist/agents/admin-agents.d.ts +10 -8
- package/dist/agents/admin-agents.js +13 -9
- package/dist/agents/agents.module.js +3 -0
- package/dist/agents/agents.service.js +1 -1
- package/dist/agents/org-templates.d.ts +3 -1
- package/dist/agents/org-templates.js +7 -3
- package/dist/agents/pending-connector-requests.d.ts +10 -4
- package/dist/agents/pending-connector-requests.js +29 -7
- package/dist/automations/automations.controller.d.ts +9 -5
- package/dist/automations/automations.controller.js +21 -4
- package/dist/automations/automations.schemas.d.ts +19 -0
- package/dist/automations/automations.schemas.js +9 -0
- package/dist/automations/automations.service.d.ts +25 -8
- package/dist/automations/automations.service.js +40 -34
- package/dist/automations/events/acceptance.d.ts +6 -1
- package/dist/automations/events/acceptance.js +30 -11
- package/dist/automations/store.d.ts +17 -0
- package/dist/automations/store.js +35 -0
- package/dist/catalog/admin-catalog.controller.d.ts +64 -2
- package/dist/catalog/admin-catalog.controller.js +17 -0
- package/dist/catalog/catalog-import.module.js +3 -0
- package/dist/catalog/catalog-scope.service.d.ts +3 -1
- package/dist/catalog/catalog-scope.service.js +11 -7
- package/dist/catalog/catalog.module.js +3 -0
- package/dist/catalog/catalog.service.d.ts +3 -1
- package/dist/catalog/catalog.service.js +8 -4
- package/dist/catalog/cli.js +2 -2
- package/dist/catalog/component-promotion.d.ts +3 -1
- package/dist/catalog/component-promotion.js +7 -3
- package/dist/catalog/component-scope.service.d.ts +3 -1
- package/dist/catalog/component-scope.service.js +7 -3
- package/dist/catalog/enable-requests.d.ts +10 -8
- package/dist/catalog/enable-requests.js +40 -21
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/owned-items.d.ts +3 -1
- package/dist/catalog/owned-items.js +13 -9
- package/dist/catalog/platform-components.d.ts +6 -1
- package/dist/catalog/platform-components.js +9 -3
- package/dist/catalog/plugin-connectors.d.ts +8 -4
- package/dist/catalog/plugin-connectors.js +12 -6
- package/dist/catalog/plugin-import.d.ts +3 -1
- package/dist/catalog/plugin-import.js +14 -5
- package/dist/catalog/plugin-install.d.ts +3 -1
- package/dist/catalog/plugin-install.js +8 -4
- package/dist/catalog/plugin-package.js +2 -1
- package/dist/catalog/plugin-upgrade.d.ts +3 -1
- package/dist/catalog/plugin-upgrade.js +8 -4
- package/dist/catalog/request-hints.d.ts +19 -0
- package/dist/catalog/request-hints.js +34 -0
- package/dist/catalog/request-rules.d.ts +9 -5
- package/dist/catalog/request-rules.js +16 -9
- package/dist/catalog/requests.service.d.ts +3 -1
- package/dist/catalog/requests.service.js +28 -9
- package/dist/catalog/scope-orgs.d.ts +2 -1
- package/dist/catalog/scope-orgs.js +2 -2
- package/dist/catalog/scope-sync.d.ts +3 -1
- package/dist/catalog/scope-sync.js +12 -2
- package/dist/catalog/scope-writer.d.ts +6 -3
- package/dist/catalog/scope-writer.js +28 -10
- package/dist/catalog/unshare.d.ts +3 -2
- package/dist/catalog/unshare.js +4 -4
- package/dist/client/client-access.service.js +29 -1
- package/dist/config/schema.d.ts +12 -0
- package/dist/config/schema.js +56 -0
- package/dist/ctx/create-ctx.d.ts +2 -19
- package/dist/ctx/create-ctx.js +3 -93
- package/dist/ctx/durable-relay.d.ts +2 -5
- package/dist/ctx/durable-relay.js +56 -29
- package/dist/db/extension-handoff-schema.js +5 -0
- package/dist/db/kernel-schema.d.ts +74 -0
- package/dist/db/migrator.js +36 -0
- package/dist/erasure/account-batches.js +2 -0
- package/dist/erasure/account-residual.js +1 -0
- package/dist/erasure/org-catalog.js +8 -3
- package/dist/erasure/org-rules.js +1 -0
- package/dist/evals/evals.schemas.d.ts +15 -5
- package/dist/evals/evals.schemas.js +17 -10
- package/dist/evals/runs.controller.d.ts +4 -12
- package/dist/evals/runs.controller.js +14 -11
- package/dist/evals/runs.service.d.ts +29 -25
- package/dist/evals/runs.service.js +73 -61
- package/dist/evals/trajectory.controller.d.ts +10 -6
- package/dist/evals/trajectory.controller.js +11 -4
- package/dist/evals/trajectory.service.d.ts +17 -9
- package/dist/evals/trajectory.service.js +52 -35
- package/dist/extensions/admin-ops.d.ts +6 -1
- package/dist/extensions/admin-ops.js +21 -7
- package/dist/extensions/blobs.d.ts +2 -0
- package/dist/extensions/blobs.js +11 -0
- package/dist/extensions/deployment-config.d.ts +6 -1
- package/dist/extensions/deployment-config.js +13 -2
- package/dist/extensions/enabled.d.ts +5 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/grant-epoch.d.ts +108 -0
- package/dist/extensions/grant-epoch.js +214 -0
- package/dist/extensions/host.d.ts +29 -9
- package/dist/extensions/host.js +148 -42
- package/dist/extensions/instance.d.ts +3 -3
- package/dist/extensions/instance.js +1 -1
- package/dist/extensions/isolated/authorization.d.ts +54 -2
- package/dist/extensions/isolated/authorization.js +148 -35
- package/dist/extensions/isolated/child-session.js +0 -1
- package/dist/extensions/isolated/revision.js +1 -1
- package/dist/extensions/org-config.d.ts +3 -1
- package/dist/extensions/org-config.js +13 -4
- package/dist/extensions/org-overrides.d.ts +6 -1
- package/dist/extensions/org-overrides.js +13 -2
- package/dist/extensions/package-digest.job.d.ts +34 -0
- package/dist/extensions/package-digest.job.js +121 -0
- package/dist/extensions/package.js +10 -6
- package/dist/extensions/permission-set.d.ts +14 -78
- package/dist/extensions/permission-set.js +17 -143
- package/dist/extensions/permission-view.d.ts +13 -1
- package/dist/extensions/permission-view.js +20 -0
- package/dist/extensions/registry.js +4 -1
- package/dist/extensions/resolve.d.ts +7 -8
- package/dist/extensions/resolve.js +7 -8
- package/dist/extensions/revision-approvals.d.ts +167 -0
- package/dist/extensions/revision-approvals.js +353 -0
- package/dist/extensions/revision-grants.d.ts +197 -0
- package/dist/extensions/revision-grants.js +584 -0
- package/dist/extensions/state.module.js +12 -1
- package/dist/identity/accounts.d.ts +10 -4
- package/dist/identity/accounts.js +18 -5
- package/dist/inbox/inbox-items.service.d.ts +6 -1
- package/dist/inbox/inbox-items.service.js +29 -10
- package/dist/inbox/inbox.module.js +3 -0
- package/dist/inbox/inbox.service.d.ts +3 -1
- package/dist/inbox/inbox.service.js +9 -2
- package/dist/inbox/org-notices.d.ts +4 -3
- package/dist/inbox/org-notices.js +9 -6
- package/dist/inbox/platform-inbox.service.d.ts +3 -1
- package/dist/inbox/platform-inbox.service.js +11 -3
- package/dist/inbox/platform-notices.d.ts +3 -2
- package/dist/inbox/platform-notices.js +10 -4
- package/dist/infra/config/kernel-config.service.js +4 -1
- package/dist/infra/database/extension-effect-key-lock.js +7 -0
- package/dist/infra/paging/paged-read.d.ts +34 -4
- package/dist/infra/paging/paged-read.js +38 -1
- package/dist/invalidation/audiences.d.ts +32 -0
- package/dist/invalidation/audiences.js +43 -0
- package/dist/invalidation/hints.d.ts +6 -0
- package/dist/invalidation/hints.js +7 -1
- package/dist/invalidation/invalidation-hints.d.ts +12 -1
- package/dist/invalidation/invalidation-hints.js +46 -5
- package/dist/invalidation/invalidation-hints.module.d.ts +2 -0
- package/dist/invalidation/invalidation-hints.module.js +4 -1
- package/dist/invalidation/me-stream.d.ts +1 -11
- package/dist/invalidation/me-stream.js +12 -41
- package/dist/invalidation/org-intent-bridge.d.ts +18 -0
- package/dist/invalidation/org-intent-bridge.js +46 -0
- package/dist/models/enablement.d.ts +3 -1
- package/dist/models/enablement.js +25 -5
- package/dist/orgs/invitations.controller.d.ts +4 -7
- package/dist/orgs/invitations.controller.js +8 -5
- package/dist/orgs/invitations.service.d.ts +17 -3
- package/dist/orgs/invitations.service.js +35 -13
- package/dist/orgs/members.service.d.ts +35 -0
- package/dist/orgs/members.service.js +52 -3
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +7 -3
- package/dist/orgs/orgs.controller.d.ts +11 -4
- package/dist/orgs/orgs.controller.js +25 -5
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.schemas.d.ts +14 -0
- package/dist/orgs/orgs.schemas.js +19 -2
- package/dist/orgs/orgs.service.d.ts +24 -2
- package/dist/orgs/orgs.service.js +47 -4
- package/dist/orgs/security-settings.service.d.ts +14 -6
- package/dist/orgs/security-settings.service.js +18 -13
- package/dist/orgs/settings.controller.d.ts +7 -4
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/ops/accounts.ops.js +7 -16
- package/dist/platform/ops/admin-items.ops.js +7 -7
- package/dist/platform/ops/automations.ops.js +6 -4
- package/dist/platform/ops/evals.ops.js +30 -15
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +44 -27
- package/dist/push/delivery.d.ts +3 -1
- package/dist/push/delivery.js +7 -3
- package/dist/push/push-processor.js +8 -1
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/step-log.d.ts +1 -1
- package/dist/runtime/step-log.js +5 -4
- package/dist/runtime/stream-limit.d.ts +13 -0
- package/dist/runtime/stream-limit.js +40 -0
- package/dist/runtime/stream.controller.d.ts +2 -0
- package/dist/runtime/stream.controller.js +2 -0
- package/dist/runtime/stream.d.ts +1 -0
- package/dist/runtime/stream.js +15 -6
- package/dist/sandbox/permission-authority.module.js +6 -1
- package/dist/sandbox/permission-transitions.d.ts +3 -1
- package/dist/sandbox/permission-transitions.js +17 -2
- package/dist/setup/kernel-checks.d.ts +3 -3
- package/dist/setup/kernel-checks.js +4 -4
- package/dist/setup/setup-check-registry.d.ts +16 -5
- package/dist/setup/setup-check-registry.js +11 -3
- package/dist/setup/setup-checks.service.d.ts +1 -2
- package/dist/setup/setup-checks.service.js +7 -6
- package/dist/skills/agent-skills.service.d.ts +6 -1
- package/dist/skills/agent-skills.service.js +12 -3
- package/dist/skills/changes.service.d.ts +6 -1
- package/dist/skills/changes.service.js +11 -3
- package/dist/skills/conversation-catalog.d.ts +3 -0
- package/dist/skills/conversation-catalog.js +2 -0
- package/dist/skills/skills.module.js +3 -0
- package/dist/skills/skills.service.d.ts +3 -1
- package/dist/skills/skills.service.js +8 -4
- package/dist/tools/admin-connectors.d.ts +10 -8
- package/dist/tools/admin-connectors.js +12 -10
- package/dist/tools/approvals.service.d.ts +12 -1
- package/dist/tools/approvals.service.js +36 -9
- package/dist/tools/builtins/automations.d.ts +1 -1
- package/dist/tools/builtins/automations.js +1 -1
- package/dist/tools/connectors.service.d.ts +3 -1
- package/dist/tools/connectors.service.js +29 -7
- package/dist/tools/tools.module.js +3 -0
- package/dist/ui/admin-ui.controller.d.ts +3 -1
- package/dist/ui/admin-ui.controller.js +3 -1
- package/dist/ui/ui-stream.d.ts +2 -0
- package/dist/ui/ui-stream.js +20 -6
- package/dist/ui/views.controller.d.ts +4 -2
- package/dist/ui/views.controller.js +4 -2
- package/package.json +3 -3
- package/src/migrations/0234_extension_grant_epoch.sql +141 -0
- package/src/migrations/0235_extension_revision_grants.sql +166 -0
- package/src/migrations/0236_paged_table_idx.sql +33 -0
- package/src/migrations/0237_extension_handoff_health.sql +18 -0
|
@@ -120,7 +120,8 @@ function clientUndeclared(text) {
|
|
|
120
120
|
if (!isObj(ext) || ext.client === undefined)
|
|
121
121
|
return undefined;
|
|
122
122
|
const perms = isObj(ext.manifest) ? ext.manifest.permissions : undefined;
|
|
123
|
-
if (isObj(perms) &&
|
|
123
|
+
if (isObj(perms) &&
|
|
124
|
+
(perms.client === true || (isObj(perms.client) && Object.hasOwn(perms.client, "purpose"))))
|
|
124
125
|
return undefined;
|
|
125
126
|
return `${PLUGIN_MANIFEST_FILE}: extension.client ships client code, but the extension manifest does not declare permissions.client: true; client code must be declared so it is reviewed (capybara-plugin pack writes both)`;
|
|
126
127
|
}
|
|
@@ -12,6 +12,7 @@ import { XactLock } from "../infra/database/xact-lock.js";
|
|
|
12
12
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
13
13
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
14
14
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
15
|
+
import type { HintPublisher } from "../invalidation/audiences.js";
|
|
15
16
|
import type { KernelLogger } from "../log.js";
|
|
16
17
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
17
18
|
import { StorageService } from "../storage/storage.service.js";
|
|
@@ -271,6 +272,7 @@ export declare class PlatformPluginUpdater {
|
|
|
271
272
|
private readonly guides;
|
|
272
273
|
/** Owes the template connector ensure of the orgs with a deferred connector (ruling R27). */
|
|
273
274
|
private readonly outbox;
|
|
275
|
+
private readonly hints;
|
|
274
276
|
constructor(kdb: KernelDb, txHost: TransactionHost, xactLock: XactLock, events: KernelEvents, adminLock: SuperAdminLock, itemLock: CatalogItemLock, orgLock: OrgLock, locks: LockService, storage: StorageService, registry: ExtensionRegistry, ops: ExtensionAdminOps,
|
|
275
277
|
/** Reads the target's extension package (its permissions, for `needsApproval`). */
|
|
276
278
|
blobs: ExtensionBlobs, config: KernelConfigService, platform: PlatformComponents,
|
|
@@ -279,7 +281,7 @@ export declare class PlatformPluginUpdater {
|
|
|
279
281
|
/** The connector template guides an update changes (the preview's `guideChanges`). */
|
|
280
282
|
guides: Pick<PluginGuides, "templateGuideChanges">,
|
|
281
283
|
/** Owes the template connector ensure of the orgs with a deferred connector (ruling R27). */
|
|
282
|
-
outbox: Pick<OutboxService, "add"
|
|
284
|
+
outbox: Pick<OutboxService, "add">, hints: HintPublisher);
|
|
283
285
|
private get db();
|
|
284
286
|
/** The update preview (see the class comment); writes nothing. */
|
|
285
287
|
preview(itemId: string, version: string): Promise<PlatformUpdatePreview>;
|
|
@@ -36,6 +36,7 @@ import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
|
36
36
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
37
37
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
38
38
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
39
|
+
import { InvalidationHints } from "../invalidation/invalidation-hints.js";
|
|
39
40
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
40
41
|
import { sha512Hex } from "../packages/provenance.js";
|
|
41
42
|
import { packagePath } from "../packages/tgz.js";
|
|
@@ -150,6 +151,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
150
151
|
log;
|
|
151
152
|
guides;
|
|
152
153
|
outbox;
|
|
154
|
+
hints;
|
|
153
155
|
constructor(kdb, txHost, xactLock, events, adminLock, itemLock, orgLock, locks, storage, registry, ops,
|
|
154
156
|
/** Reads the target's extension package (its permissions, for `needsApproval`). */
|
|
155
157
|
blobs, config, platform,
|
|
@@ -158,7 +160,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
158
160
|
/** The connector template guides an update changes (the preview's `guideChanges`). */
|
|
159
161
|
guides,
|
|
160
162
|
/** Owes the template connector ensure of the orgs with a deferred connector (ruling R27). */
|
|
161
|
-
outbox) {
|
|
163
|
+
outbox, hints) {
|
|
162
164
|
this.kdb = kdb;
|
|
163
165
|
this.txHost = txHost;
|
|
164
166
|
this.xactLock = xactLock;
|
|
@@ -179,6 +181,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
179
181
|
this.log = log;
|
|
180
182
|
this.guides = guides;
|
|
181
183
|
this.outbox = outbox;
|
|
184
|
+
this.hints = hints;
|
|
182
185
|
}
|
|
183
186
|
get db() {
|
|
184
187
|
return this.kdb.db;
|
|
@@ -612,7 +615,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
612
615
|
.where("id", "=", c.id)
|
|
613
616
|
.execute();
|
|
614
617
|
// every org's pending enable requests that name it (target, subject or a follower's)
|
|
615
|
-
await reconcileEnableRequestsOf(t, { kind: c.kind, id: c.id }, null);
|
|
618
|
+
await reconcileEnableRequestsOf(t, this.hints, { kind: c.kind, id: c.id }, null);
|
|
616
619
|
}
|
|
617
620
|
// Pins of linked copies: moved to the plugin's version (spec §7.1)
|
|
618
621
|
for (const c of diff.components) {
|
|
@@ -698,7 +701,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
698
701
|
// The orgs using a shared org-owned plugin are told, one notice per plugin (a platform-owned
|
|
699
702
|
// plugin tells nobody); a plugin never synced before has no version to come from
|
|
700
703
|
if (diff.from !== null) {
|
|
701
|
-
await notifySharedUpdate(t, { kind: "plugin", id: itemId }, { name: diff.name, from: diff.from, to: diff.to.version });
|
|
704
|
+
await notifySharedUpdate(t, this.hints, { kind: "plugin", id: itemId }, { name: diff.name, from: diff.from, to: diff.to.version });
|
|
702
705
|
}
|
|
703
706
|
await audit(t, {
|
|
704
707
|
actorAccountId: actor,
|
|
@@ -1696,7 +1699,8 @@ PlatformPluginUpdater = __decorate([
|
|
|
1696
1699
|
__param(16, Inject(PluginScopeSync)),
|
|
1697
1700
|
__param(17, Inject(KERNEL_LOGGER)),
|
|
1698
1701
|
__param(18, Inject(PluginGuides)),
|
|
1699
|
-
__param(19, Inject(OutboxService))
|
|
1702
|
+
__param(19, Inject(OutboxService)),
|
|
1703
|
+
__param(20, Inject(InvalidationHints))
|
|
1700
1704
|
], PlatformPluginUpdater);
|
|
1701
1705
|
export { PlatformPluginUpdater };
|
|
1702
1706
|
/** The preview of a diff (without `guideChanges`, which reads PG). */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HintPublisher } from "../invalidation/audiences.js";
|
|
2
|
+
/** The catalog request kinds the super admin decides (their rows are the platform inbox's too). */
|
|
3
|
+
export declare const DEPLOYMENT_KINDS: readonly ["access", "import"];
|
|
4
|
+
/** The columns of a catalog request row its hint audience comes from (no extra query). */
|
|
5
|
+
export interface RequestHintRow {
|
|
6
|
+
org_id: string;
|
|
7
|
+
requested_by: string | null;
|
|
8
|
+
kind: string;
|
|
9
|
+
/** An enable request's detail names its followers (other kinds: ignored). */
|
|
10
|
+
detail?: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Publishes `requests` after the commit for written catalog request rows (account invalidation
|
|
14
|
+
* stream spec §4): to each row's requester and followers and to the admins and owners of each
|
|
15
|
+
* row's org, in one publish; a row the super admin decides (`access`, `import`) also publishes
|
|
16
|
+
* `platform-inbox` to the super admins. `extraAccounts`: accounts the write concerns that the
|
|
17
|
+
* rows do not name (a follower dropped from a row). Nothing for no rows.
|
|
18
|
+
*/
|
|
19
|
+
export declare function publishRequestHints(hints: HintPublisher, rows: readonly RequestHintRow[], extraAccounts?: readonly string[]): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { acctTopic, orgRoleTopic, PLATFORM_ADMINS_TOPIC, } from "../invalidation/hints.js";
|
|
2
|
+
import { readEnableDetail } from "./enable-targets.js";
|
|
3
|
+
/** The catalog request kinds the super admin decides (their rows are the platform inbox's too). */
|
|
4
|
+
export const DEPLOYMENT_KINDS = ["access", "import"];
|
|
5
|
+
/**
|
|
6
|
+
* Publishes `requests` after the commit for written catalog request rows (account invalidation
|
|
7
|
+
* stream spec §4): to each row's requester and followers and to the admins and owners of each
|
|
8
|
+
* row's org, in one publish; a row the super admin decides (`access`, `import`) also publishes
|
|
9
|
+
* `platform-inbox` to the super admins. `extraAccounts`: accounts the write concerns that the
|
|
10
|
+
* rows do not name (a follower dropped from a row). Nothing for no rows.
|
|
11
|
+
*/
|
|
12
|
+
export function publishRequestHints(hints, rows, extraAccounts = []) {
|
|
13
|
+
if (rows.length === 0 && extraAccounts.length === 0)
|
|
14
|
+
return;
|
|
15
|
+
const topics = new Set();
|
|
16
|
+
let platform = false;
|
|
17
|
+
for (const r of rows) {
|
|
18
|
+
topics.add(orgRoleTopic(r.org_id, "admin"));
|
|
19
|
+
if (r.requested_by !== null)
|
|
20
|
+
topics.add(acctTopic(r.requested_by));
|
|
21
|
+
if (r.kind === "enable") {
|
|
22
|
+
for (const f of readEnableDetail(r.detail)?.followers ?? []) {
|
|
23
|
+
topics.add(acctTopic(f.accountId));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (DEPLOYMENT_KINDS.includes(r.kind))
|
|
27
|
+
platform = true;
|
|
28
|
+
}
|
|
29
|
+
for (const a of extraAccounts)
|
|
30
|
+
topics.add(acctTopic(a));
|
|
31
|
+
hints.publishAfterCommit([...topics], { kind: "requests" });
|
|
32
|
+
if (platform)
|
|
33
|
+
hints.publishAfterCommit([PLATFORM_ADMINS_TOPIC], { kind: "platform-inbox" });
|
|
34
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
2
|
import { ApiError } from "../errors.js";
|
|
3
|
+
import type { HintPublisher } from "../invalidation/audiences.js";
|
|
3
4
|
/**
|
|
4
5
|
* Before an org creates a component from the catalog (enabling an extension, creating a connector
|
|
5
6
|
* from a template, importing a skill), re-checks in the caller's transaction that the item is live
|
|
@@ -38,9 +39,10 @@ export interface RequestActorOpts {
|
|
|
38
39
|
* item or the org is deleted), status `cancelled` (the decider is the actor). For an item, that is
|
|
39
40
|
* its own requests and the enable requests that target it or need it on (`detail.bundle`: an
|
|
40
41
|
* extension, component, connector or model of it). Each one audits `catalog.request_cancelled`
|
|
41
|
-
* (with the reason). Returns how many
|
|
42
|
+
* (with the reason) and the cancelled rows publish `requests` after the commit. Returns how many
|
|
43
|
+
* were cancelled.
|
|
42
44
|
*/
|
|
43
|
-
export declare function cancelPendingRequests(db: KernelSchemaDb, where: {
|
|
45
|
+
export declare function cancelPendingRequests(db: KernelSchemaDb, hints: HintPublisher, where: {
|
|
44
46
|
itemId: string;
|
|
45
47
|
} | {
|
|
46
48
|
orgId: string;
|
|
@@ -50,8 +52,9 @@ export declare function cancelPendingRequests(db: KernelSchemaDb, where: {
|
|
|
50
52
|
* pending `access` request the scope has since granted is approved with the installer as the
|
|
51
53
|
* decider (null for the scope sync), audited `catalog.request_decided` with `installed: true`;
|
|
52
54
|
* the pending enable requests that target the plugin are settled ({@link settleEnableRequests}).
|
|
55
|
+
* The rows written publish `requests` after the commit.
|
|
53
56
|
*/
|
|
54
|
-
export declare function resolveRequestsByInstall(db: KernelSchemaDb, orgId: string, itemId: string, actor: string | null, opts?: RequestActorOpts): Promise<void>;
|
|
57
|
+
export declare function resolveRequestsByInstall(db: KernelSchemaDb, hints: HintPublisher, orgId: string, itemId: string, actor: string | null, opts?: RequestActorOpts): Promise<void>;
|
|
55
58
|
/** The pending `import` request linked to a staged import (its approval prepared it), if any. */
|
|
56
59
|
export declare function importRequestOf(db: KernelSchemaDb, stagingId: string): Promise<{
|
|
57
60
|
id: string;
|
|
@@ -62,6 +65,7 @@ export declare function hasImportRequests(db: KernelSchemaDb, stagingId: string)
|
|
|
62
65
|
/**
|
|
63
66
|
* The confirm of a staged import, in its transaction: the pending `import` requests linked to the
|
|
64
67
|
* staging are approved (decider: the confirming admin) and point at the item. Audits
|
|
65
|
-
* `catalog.request_decided
|
|
68
|
+
* `catalog.request_decided`; the rows publish `requests` (and `platform-inbox`) after the commit.
|
|
69
|
+
* Returns the requests' orgs.
|
|
66
70
|
*/
|
|
67
|
-
export declare function resolveImportRequests(db: KernelSchemaDb, stagingId: string, itemId: string, actor: string | null, opts?: RequestActorOpts): Promise<string[]>;
|
|
71
|
+
export declare function resolveImportRequests(db: KernelSchemaDb, hints: HintPublisher, stagingId: string, itemId: string, actor: string | null, opts?: RequestActorOpts): Promise<string[]>;
|
|
@@ -5,6 +5,7 @@ import { audit } from "../identity/audit.js";
|
|
|
5
5
|
import { asPlatform, withOrgScope } from "../infra/database/org-scope.js";
|
|
6
6
|
import { settleEnableRequests } from "./enable-requests.js";
|
|
7
7
|
import { isUsable } from "./ownership.js";
|
|
8
|
+
import { publishRequestHints } from "./request-hints.js";
|
|
8
9
|
import { visibleTo } from "./scope.js";
|
|
9
10
|
/**
|
|
10
11
|
* The catalog's database-level rules shared by the installers, the import confirm and the request
|
|
@@ -128,9 +129,10 @@ export async function assertPluginSourcesInstallable(t, orgId, plugin) {
|
|
|
128
129
|
* item or the org is deleted), status `cancelled` (the decider is the actor). For an item, that is
|
|
129
130
|
* its own requests and the enable requests that target it or need it on (`detail.bundle`: an
|
|
130
131
|
* extension, component, connector or model of it). Each one audits `catalog.request_cancelled`
|
|
131
|
-
* (with the reason). Returns how many
|
|
132
|
+
* (with the reason) and the cancelled rows publish `requests` after the commit. Returns how many
|
|
133
|
+
* were cancelled.
|
|
132
134
|
*/
|
|
133
|
-
export async function cancelPendingRequests(db, where, actor, reason, opts = {}) {
|
|
135
|
+
export async function cancelPendingRequests(db, hints, where, actor, reason, opts = {}) {
|
|
134
136
|
// Rows are locked in id order first, as settlement and reconciliation lock them (no deadlock),
|
|
135
137
|
// then cancelled by id
|
|
136
138
|
const cancel = async (ids) => {
|
|
@@ -141,7 +143,7 @@ export async function cancelPendingRequests(db, where, actor, reason, opts = {})
|
|
|
141
143
|
.updateTable("catalog_requests")
|
|
142
144
|
.set({ status: "cancelled", decided_by: actor, decided_at: sql `now()` })
|
|
143
145
|
.where("id", "in", [...ids])
|
|
144
|
-
.returning(["id", "org_id", "item_id", "kind"])
|
|
146
|
+
.returning(["id", "org_id", "item_id", "kind", "requested_by", "detail"])
|
|
145
147
|
.execute();
|
|
146
148
|
return done;
|
|
147
149
|
};
|
|
@@ -171,6 +173,7 @@ export async function cancelPendingRequests(db, where, actor, reason, opts = {})
|
|
|
171
173
|
.orderBy("id")
|
|
172
174
|
.forUpdate()
|
|
173
175
|
.execute()).map((r) => r.id));
|
|
176
|
+
publishRequestHints(hints, rows);
|
|
174
177
|
for (const r of rows) {
|
|
175
178
|
await withOrgScope(r.org_id, () => audit(db, {
|
|
176
179
|
actorAccountId: actor,
|
|
@@ -188,8 +191,9 @@ export async function cancelPendingRequests(db, where, actor, reason, opts = {})
|
|
|
188
191
|
* pending `access` request the scope has since granted is approved with the installer as the
|
|
189
192
|
* decider (null for the scope sync), audited `catalog.request_decided` with `installed: true`;
|
|
190
193
|
* the pending enable requests that target the plugin are settled ({@link settleEnableRequests}).
|
|
194
|
+
* The rows written publish `requests` after the commit.
|
|
191
195
|
*/
|
|
192
|
-
export async function resolveRequestsByInstall(db, orgId, itemId, actor, opts = {}) {
|
|
196
|
+
export async function resolveRequestsByInstall(db, hints, orgId, itemId, actor, opts = {}) {
|
|
193
197
|
const rows = await db
|
|
194
198
|
.updateTable("catalog_requests")
|
|
195
199
|
.set({ status: "approved", decided_by: actor, decided_at: sql `now()` })
|
|
@@ -197,8 +201,9 @@ export async function resolveRequestsByInstall(db, orgId, itemId, actor, opts =
|
|
|
197
201
|
.where("item_id", "=", itemId)
|
|
198
202
|
.where("kind", "<>", "enable")
|
|
199
203
|
.where("status", "=", "pending")
|
|
200
|
-
.returning(["id", "kind"])
|
|
204
|
+
.returning(["id", "org_id", "kind", "requested_by"])
|
|
201
205
|
.execute();
|
|
206
|
+
publishRequestHints(hints, rows);
|
|
202
207
|
for (const r of rows) {
|
|
203
208
|
await audit(db, {
|
|
204
209
|
actorAccountId: actor,
|
|
@@ -209,7 +214,7 @@ export async function resolveRequestsByInstall(db, orgId, itemId, actor, opts =
|
|
|
209
214
|
detail: { itemId, kind: r.kind, decision: "approve", installed: true },
|
|
210
215
|
});
|
|
211
216
|
}
|
|
212
|
-
await settleEnableRequests(db, orgId, { kind: "plugin", id: itemId }, actor, opts);
|
|
217
|
+
await settleEnableRequests(db, hints, orgId, { kind: "plugin", id: itemId }, actor, opts);
|
|
213
218
|
}
|
|
214
219
|
/** The pending `import` request linked to a staged import (its approval prepared it), if any. */
|
|
215
220
|
// org-filter: by the staging id of the confirm's own staging row (ownStaging checked it); a platform
|
|
@@ -240,11 +245,12 @@ export async function hasImportRequests(db, stagingId) {
|
|
|
240
245
|
/**
|
|
241
246
|
* The confirm of a staged import, in its transaction: the pending `import` requests linked to the
|
|
242
247
|
* staging are approved (decider: the confirming admin) and point at the item. Audits
|
|
243
|
-
* `catalog.request_decided
|
|
248
|
+
* `catalog.request_decided`; the rows publish `requests` (and `platform-inbox`) after the commit.
|
|
249
|
+
* Returns the requests' orgs.
|
|
244
250
|
*/
|
|
245
251
|
// org-filter: by the staging id of the confirm's own staging row (ownStaging checked it); a platform
|
|
246
252
|
// staging prepared by approving import requests links requests of several orgs, read on purpose
|
|
247
|
-
export async function resolveImportRequests(db, stagingId, itemId, actor, opts = {}) {
|
|
253
|
+
export async function resolveImportRequests(db, hints, stagingId, itemId, actor, opts = {}) {
|
|
248
254
|
const rows = await db
|
|
249
255
|
.updateTable("catalog_requests")
|
|
250
256
|
.set({
|
|
@@ -256,8 +262,9 @@ export async function resolveImportRequests(db, stagingId, itemId, actor, opts =
|
|
|
256
262
|
.where("staging_id", "=", stagingId)
|
|
257
263
|
.where("kind", "=", "import")
|
|
258
264
|
.where("status", "=", "pending")
|
|
259
|
-
.returning(["id", "org_id"])
|
|
265
|
+
.returning(["id", "org_id", "kind", "requested_by"])
|
|
260
266
|
.execute();
|
|
267
|
+
publishRequestHints(hints, rows);
|
|
261
268
|
for (const r of rows) {
|
|
262
269
|
await audit(db, {
|
|
263
270
|
actorAccountId: actor,
|
|
@@ -6,6 +6,7 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
6
6
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
7
7
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
8
8
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
9
|
+
import type { HintPublisher } from "../invalidation/audiences.js";
|
|
9
10
|
import { ModelEnablement } from "../models/enablement.js";
|
|
10
11
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
11
12
|
import { OrgSettingsService } from "../orgs/settings.service.js";
|
|
@@ -207,6 +208,7 @@ export declare class CatalogRequestsService {
|
|
|
207
208
|
private readonly connectors;
|
|
208
209
|
private readonly extensions;
|
|
209
210
|
private readonly providers;
|
|
211
|
+
private readonly hints;
|
|
210
212
|
constructor(kdb: KernelDb,
|
|
211
213
|
/** The org row and super admin locks: both join the caller's transaction. */
|
|
212
214
|
orgLock: OrgLock, adminLock: SuperAdminLock, orgCatalog: OrgCatalogService, scope: CatalogScopeService, catalog: CatalogService, config: KernelConfigService, pluginImport: PluginImport,
|
|
@@ -219,7 +221,7 @@ export declare class CatalogRequestsService {
|
|
|
219
221
|
* (extension, component, model, connector; a plugin goes through `orgCatalog.setSwitch`), and
|
|
220
222
|
* the deployment's live state a request is checked against (loaded extensions, listed models).
|
|
221
223
|
*/
|
|
222
|
-
orgExtensions: OrgExtensionConfigs, components: ComponentScopeService, models: ModelEnablement, connectors: ConnectorsService, extensions: ExtensionRegistry, providers: ProviderRegistry);
|
|
224
|
+
orgExtensions: OrgExtensionConfigs, components: ComponentScopeService, models: ModelEnablement, connectors: ConnectorsService, extensions: ExtensionRegistry, providers: ProviderRegistry, hints: HintPublisher);
|
|
223
225
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
224
226
|
private get db();
|
|
225
227
|
/**
|
|
@@ -24,6 +24,8 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
24
24
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
25
25
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
26
26
|
import { WithLock } from "../infra/lock/with-lock.decorator.js";
|
|
27
|
+
import { acctTopic } from "../invalidation/hints.js";
|
|
28
|
+
import { InvalidationHints } from "../invalidation/invalidation-hints.js";
|
|
27
29
|
import { ModelEnablement } from "../models/enablement.js";
|
|
28
30
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
29
31
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
@@ -42,6 +44,7 @@ import { decodeModelId, readEnableDetail, sameTarget, targetKey, } from "./enabl
|
|
|
42
44
|
import { assertEntryNotDeprecated, loadMarketplaceEntry } from "./marketplaces.service.js";
|
|
43
45
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
44
46
|
import { PluginImport } from "./plugin-import.js";
|
|
47
|
+
import { DEPLOYMENT_KINDS, publishRequestHints } from "./request-hints.js";
|
|
45
48
|
import { itemsSeenBy } from "./scope-state.js";
|
|
46
49
|
/** The most pending `network_allowlist` requests one member may have in an org. */
|
|
47
50
|
export const NETWORK_REQUESTS_PENDING_MAX = 10;
|
|
@@ -70,8 +73,6 @@ function sandboxAllowlist(limits, org) {
|
|
|
70
73
|
const outsideCeiling = (hosts) => new ApiError("catalog.request_invalid", `The platform limits sandbox hosts to its allowlist; only a super admin can add ${hosts.join(", ")} (sandbox.limits.allowHosts)`);
|
|
71
74
|
/** A unique violation (the partial index of pending requests). */
|
|
72
75
|
const isUniqueViolation = (e) => typeof e === "object" && e !== null && e.code === "23505";
|
|
73
|
-
/** The deployment-level kinds (decided by the super admin). */
|
|
74
|
-
const DEPLOYMENT_KINDS = ["access", "import"];
|
|
75
76
|
/** The org-level kinds (decided by the org admins). */
|
|
76
77
|
const ORG_KINDS = ["enable", "connector_setup", "network_allowlist"];
|
|
77
78
|
/**
|
|
@@ -112,6 +113,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
112
113
|
connectors;
|
|
113
114
|
extensions;
|
|
114
115
|
providers;
|
|
116
|
+
hints;
|
|
115
117
|
constructor(kdb,
|
|
116
118
|
/** The org row and super admin locks: both join the caller's transaction. */
|
|
117
119
|
orgLock, adminLock, orgCatalog, scope, catalog, config, pluginImport,
|
|
@@ -124,7 +126,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
124
126
|
* (extension, component, model, connector; a plugin goes through `orgCatalog.setSwitch`), and
|
|
125
127
|
* the deployment's live state a request is checked against (loaded extensions, listed models).
|
|
126
128
|
*/
|
|
127
|
-
orgExtensions, components, models, connectors, extensions, providers) {
|
|
129
|
+
orgExtensions, components, models, connectors, extensions, providers, hints) {
|
|
128
130
|
this.kdb = kdb;
|
|
129
131
|
this.orgLock = orgLock;
|
|
130
132
|
this.adminLock = adminLock;
|
|
@@ -142,6 +144,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
142
144
|
this.connectors = connectors;
|
|
143
145
|
this.extensions = extensions;
|
|
144
146
|
this.providers = providers;
|
|
147
|
+
this.hints = hints;
|
|
145
148
|
}
|
|
146
149
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
147
150
|
get db() {
|
|
@@ -224,6 +227,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
224
227
|
throw pendingExists();
|
|
225
228
|
throw e;
|
|
226
229
|
}
|
|
230
|
+
publishRequestHints(this.hints, [{ org_id: orgId, requested_by: actor, kind: input.kind }]);
|
|
227
231
|
await audit(t, {
|
|
228
232
|
actorAccountId: actor,
|
|
229
233
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
@@ -330,6 +334,9 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
330
334
|
note: input.note ?? "",
|
|
331
335
|
})
|
|
332
336
|
.execute();
|
|
337
|
+
publishRequestHints(this.hints, [
|
|
338
|
+
{ org_id: orgId, requested_by: actor, kind: "network_allowlist" },
|
|
339
|
+
]);
|
|
333
340
|
await audit(t, {
|
|
334
341
|
actorAccountId: actor,
|
|
335
342
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
@@ -432,7 +439,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
432
439
|
// a pending request whose own subject went stale (removed, hidden, another switch first) is
|
|
433
440
|
// settled first (row locked above), so it never absorbs new askers; a fresh request follows
|
|
434
441
|
const stale = existing !== undefined &&
|
|
435
|
-
(await settleRequestRows(t, orgId, [existing], { kind: "reconcile" }, () => ({
|
|
442
|
+
(await settleRequestRows(t, this.hints, orgId, [existing], { kind: "reconcile" }, () => ({
|
|
436
443
|
actor: null,
|
|
437
444
|
}))).has(existing.id);
|
|
438
445
|
if (existing && !stale) {
|
|
@@ -462,6 +469,9 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
462
469
|
.where("id", "=", existing.id)
|
|
463
470
|
.where("org_id", "=", orgId)
|
|
464
471
|
.execute();
|
|
472
|
+
publishRequestHints(this.hints, [
|
|
473
|
+
{ org_id: orgId, requested_by: existing.requested_by, kind: "enable", detail: next },
|
|
474
|
+
]);
|
|
465
475
|
}
|
|
466
476
|
return { id: existing.id, created: false };
|
|
467
477
|
}
|
|
@@ -488,6 +498,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
488
498
|
throw pendingExists();
|
|
489
499
|
throw e;
|
|
490
500
|
}
|
|
501
|
+
publishRequestHints(this.hints, [{ org_id: orgId, requested_by: actor, kind: "enable" }]);
|
|
491
502
|
await audit(t, {
|
|
492
503
|
actorAccountId: actor,
|
|
493
504
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
@@ -575,6 +586,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
575
586
|
throw pendingExists();
|
|
576
587
|
throw e;
|
|
577
588
|
}
|
|
589
|
+
publishRequestHints(this.hints, [{ org_id: orgId, requested_by: actor, kind: "import" }]);
|
|
578
590
|
await audit(t, {
|
|
579
591
|
actorAccountId: actor,
|
|
580
592
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
@@ -723,7 +735,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
723
735
|
const detail = readEnableDetail(row.detail);
|
|
724
736
|
if (detail === null)
|
|
725
737
|
throw requestNotFound();
|
|
726
|
-
const outcomes = await settleRequestRows(this.db, orgId, [row], { kind: "final" }, () => ({
|
|
738
|
+
const outcomes = await settleRequestRows(this.db, this.hints, orgId, [row], { kind: "final" }, () => ({
|
|
727
739
|
actor,
|
|
728
740
|
actorTokenId: opts.actorTokenId,
|
|
729
741
|
auditDetail: { requestId, ...opts.auditDetail },
|
|
@@ -851,7 +863,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
851
863
|
// org-filter: super admin links any org's import request (adminLock just above)
|
|
852
864
|
const row = await this.db
|
|
853
865
|
.selectFrom("catalog_requests")
|
|
854
|
-
.select(["org_id", "status", "entry_name"])
|
|
866
|
+
.select(["org_id", "status", "entry_name", "requested_by", "kind"])
|
|
855
867
|
.where("id", "=", requestId)
|
|
856
868
|
.forUpdate()
|
|
857
869
|
.executeTakeFirstOrThrow();
|
|
@@ -863,6 +875,8 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
863
875
|
.where("id", "=", requestId)
|
|
864
876
|
.where("org_id", "=", row.org_id)
|
|
865
877
|
.execute();
|
|
878
|
+
// the request views carry the pending staging (the platform inbox's and the requester's)
|
|
879
|
+
publishRequestHints(this.hints, [row]);
|
|
866
880
|
await audit(this.db, {
|
|
867
881
|
actorAccountId: actor,
|
|
868
882
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
@@ -885,7 +899,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
885
899
|
await this.adminLock.lockAndAuthorize(actor);
|
|
886
900
|
let q = t
|
|
887
901
|
.selectFrom("catalog_requests")
|
|
888
|
-
.select(["id", "org_id", "item_id", "kind", "status", "decided_by", "detail"])
|
|
902
|
+
.select(["id", "org_id", "item_id", "kind", "status", "decided_by", "detail", "requested_by"])
|
|
889
903
|
.where("id", "=", requestId);
|
|
890
904
|
q =
|
|
891
905
|
"orgId" in side
|
|
@@ -937,6 +951,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
937
951
|
.where("id", "=", requestId)
|
|
938
952
|
.where("org_id", "=", row.org_id)
|
|
939
953
|
.execute();
|
|
954
|
+
publishRequestHints(this.hints, [row]);
|
|
940
955
|
await audit(t, {
|
|
941
956
|
actorAccountId: actor,
|
|
942
957
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
@@ -1025,8 +1040,10 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
1025
1040
|
.where(decidedForRequester("status", "detail"))
|
|
1026
1041
|
.where("dismissed_at", "is", null)
|
|
1027
1042
|
.executeTakeFirst();
|
|
1043
|
+
// a dismissal changes only the dismissing person's inbox (no admin list shows it)
|
|
1044
|
+
const dismissed = () => this.hints.publishAfterCommit([acctTopic(accountId)], { kind: "requests" });
|
|
1028
1045
|
if (r.numUpdatedRows > 0n)
|
|
1029
|
-
return;
|
|
1046
|
+
return dismissed();
|
|
1030
1047
|
// a follower of an enable request dismisses their own copy of the notice
|
|
1031
1048
|
const f = await this.db
|
|
1032
1049
|
.updateTable("catalog_requests")
|
|
@@ -1043,6 +1060,7 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
1043
1060
|
.executeTakeFirst();
|
|
1044
1061
|
if (f.numUpdatedRows === 0n)
|
|
1045
1062
|
throw requestNotFound();
|
|
1063
|
+
dismissed();
|
|
1046
1064
|
}
|
|
1047
1065
|
/** 超级管理员的申请列表(`access` / `import`;`status` 缺省 pending),新的在前。 */
|
|
1048
1066
|
async listDeployment(q = {}) {
|
|
@@ -1365,7 +1383,8 @@ CatalogRequestsService = __decorate([
|
|
|
1365
1383
|
__param(13, Inject(ModelEnablement)),
|
|
1366
1384
|
__param(14, Inject(ConnectorsService)),
|
|
1367
1385
|
__param(15, Inject(ExtensionRegistry)),
|
|
1368
|
-
__param(16, Inject(ProviderRegistry))
|
|
1386
|
+
__param(16, Inject(ProviderRegistry)),
|
|
1387
|
+
__param(17, Inject(InvalidationHints))
|
|
1369
1388
|
], CatalogRequestsService);
|
|
1370
1389
|
export { CatalogRequestsService };
|
|
1371
1390
|
/** The view fields of a `connector_setup` request (ruling P4-T6-5); null for other kinds. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
import type { HintPublisher } from "../invalidation/audiences.js";
|
|
2
3
|
/**
|
|
3
4
|
* Adds one org to a `named` item's list in the caller's transaction (the caller holds the item row
|
|
4
5
|
* `FOR UPDATE`): audits `catalog.scope_changed` the way a scope change
|
|
@@ -8,7 +9,7 @@ import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
|
8
9
|
* than its owner to an org-owned item that is not shareable -> 409 `catalog.not_shareable` (the
|
|
9
10
|
* share gate, ruling P3-16, read on the caller's locked row).
|
|
10
11
|
*/
|
|
11
|
-
export declare function addScopeOrg(db: KernelSchemaDb, actor: string | null, item: {
|
|
12
|
+
export declare function addScopeOrg(db: KernelSchemaDb, hints: HintPublisher, actor: string | null, item: {
|
|
12
13
|
id: string;
|
|
13
14
|
name: string;
|
|
14
15
|
scope: "all" | "optional" | "named";
|
|
@@ -12,7 +12,7 @@ import { addNamedPluginOrg } from "./scope-writer.js";
|
|
|
12
12
|
* than its owner to an org-owned item that is not shareable -> 409 `catalog.not_shareable` (the
|
|
13
13
|
* share gate, ruling P3-16, read on the caller's locked row).
|
|
14
14
|
*/
|
|
15
|
-
export async function addScopeOrg(db, actor, item, orgId, opts = {}) {
|
|
15
|
+
export async function addScopeOrg(db, hints, actor, item, orgId, opts = {}) {
|
|
16
16
|
if (item.builtin || item.scope !== "named")
|
|
17
17
|
return false;
|
|
18
18
|
if (!shareGate(item) && orgId !== item.owner_org_id) {
|
|
@@ -55,7 +55,7 @@ export async function addScopeOrg(db, actor, item, orgId, opts = {}) {
|
|
|
55
55
|
...(opts.requestId !== undefined && { requestId: opts.requestId }),
|
|
56
56
|
},
|
|
57
57
|
});
|
|
58
|
-
await notifyItemShared(db, item.owner_org_id, { kind: "plugin", id: item.id }, item.name, [
|
|
58
|
+
await notifyItemShared(db, hints, item.owner_org_id, { kind: "plugin", id: item.id }, item.name, [
|
|
59
59
|
orgId,
|
|
60
60
|
]);
|
|
61
61
|
return true;
|
|
@@ -5,6 +5,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
6
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
7
7
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
8
|
+
import { type HintPublisher } from "../invalidation/audiences.js";
|
|
8
9
|
import type { KernelLogger } from "../log.js";
|
|
9
10
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
10
11
|
import { type EffectJob } from "./effect-work.js";
|
|
@@ -25,7 +26,8 @@ export declare class PluginScopeSync {
|
|
|
25
26
|
private readonly locks;
|
|
26
27
|
private readonly log;
|
|
27
28
|
readonly txHost: TransactionHost;
|
|
28
|
-
|
|
29
|
+
private readonly hints;
|
|
30
|
+
constructor(kdb: KernelDb, outbox: Pick<OutboxService, "add" | "addMany">, installer: PluginInstaller, registry: ExtensionRegistry, config: KernelConfigService, effective: Pick<EffectiveConfigs, "get">, orgLock: OrgLock, locks: LockService, log: KernelLogger, txHost: TransactionHost, hints: HintPublisher);
|
|
29
31
|
private get db();
|
|
30
32
|
enqueueItem(itemId: string, previousOrgs?: readonly string[]): Promise<void>;
|
|
31
33
|
enqueueOrg(orgId: string): Promise<void>;
|
|
@@ -23,6 +23,8 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
23
23
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
24
24
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
25
25
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
26
|
+
import { publishCapabilities } from "../invalidation/audiences.js";
|
|
27
|
+
import { InvalidationHints } from "../invalidation/invalidation-hints.js";
|
|
26
28
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
27
29
|
import { effectGeneration, oweEffectWork, recoverEffectWork, } from "./effect-work.js";
|
|
28
30
|
import { isUsable } from "./ownership.js";
|
|
@@ -50,7 +52,8 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
50
52
|
locks;
|
|
51
53
|
log;
|
|
52
54
|
txHost;
|
|
53
|
-
|
|
55
|
+
hints;
|
|
56
|
+
constructor(kdb, outbox, installer, registry, config, effective, orgLock, locks, log, txHost, hints) {
|
|
54
57
|
this.kdb = kdb;
|
|
55
58
|
this.outbox = outbox;
|
|
56
59
|
this.installer = installer;
|
|
@@ -61,6 +64,7 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
61
64
|
this.locks = locks;
|
|
62
65
|
this.log = log;
|
|
63
66
|
this.txHost = txHost;
|
|
67
|
+
this.hints = hints;
|
|
64
68
|
}
|
|
65
69
|
get db() {
|
|
66
70
|
return this.kdb.db;
|
|
@@ -165,6 +169,9 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
165
169
|
if (!(await this.settleGeneration(itemId, orgId, generation))) {
|
|
166
170
|
throw new SupersededEffect();
|
|
167
171
|
}
|
|
172
|
+
// the pair's generation settled: the org's capabilities changed (one hint per owed pair, the
|
|
173
|
+
// org set the writer computed)
|
|
174
|
+
publishCapabilities(this.hints, [orgId]);
|
|
168
175
|
await this.db
|
|
169
176
|
.updateTable("plugin_installs")
|
|
170
177
|
.set({ status: "on", error: null })
|
|
@@ -389,6 +396,8 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
389
396
|
return;
|
|
390
397
|
if (!(await this.settleGeneration(itemId, orgId, generation)))
|
|
391
398
|
return;
|
|
399
|
+
// the pair settled as failed: the org's catalog shows the failure (and the intent it settles)
|
|
400
|
+
publishCapabilities(this.hints, [orgId]);
|
|
392
401
|
const { op, code } = failure;
|
|
393
402
|
const error = {
|
|
394
403
|
generation: generation ?? "0",
|
|
@@ -458,6 +467,7 @@ PluginScopeSync = __decorate([
|
|
|
458
467
|
__param(6, Inject(OrgLock)),
|
|
459
468
|
__param(7, Inject(LockService)),
|
|
460
469
|
__param(8, Inject(KERNEL_LOGGER)),
|
|
461
|
-
__param(9, Inject(TransactionHost))
|
|
470
|
+
__param(9, Inject(TransactionHost)),
|
|
471
|
+
__param(10, Inject(InvalidationHints))
|
|
462
472
|
], PluginScopeSync);
|
|
463
473
|
export { PluginScopeSync };
|
|
@@ -7,6 +7,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
7
7
|
import { XactLock } from "../infra/database/xact-lock.js";
|
|
8
8
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
9
9
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
10
|
+
import { type HintPublisher } from "../invalidation/audiences.js";
|
|
10
11
|
import type { ComponentKind } from "./component-state.js";
|
|
11
12
|
import type { RequestActorOpts } from "./request-rules.js";
|
|
12
13
|
import type { PluginScope } from "./scope.js";
|
|
@@ -44,9 +45,10 @@ type ScopeListChange = {
|
|
|
44
45
|
/**
|
|
45
46
|
* Apply a typed scope change in the caller's transaction and under its target lock. Every scope
|
|
46
47
|
* write re-checks the pending enable requests of the subject in every org
|
|
47
|
-
* ({@link reconcileEnableRequestsOf}), so no caller can narrow a scope and leave a stale request
|
|
48
|
+
* ({@link reconcileEnableRequestsOf}), so no caller can narrow a scope and leave a stale request;
|
|
49
|
+
* `hints` publishes the requests it settles.
|
|
48
50
|
*/
|
|
49
|
-
export declare function writeScope(db: KernelSchemaDb, change: ScopeListChange): Promise<void>;
|
|
51
|
+
export declare function writeScope(db: KernelSchemaDb, hints: HintPublisher, change: ScopeListChange): Promise<void>;
|
|
50
52
|
/** Extend a named plugin scope under its item lock. */
|
|
51
53
|
export declare function addNamedPluginOrg(db: KernelSchemaDb, itemId: string, orgId: string): Promise<boolean>;
|
|
52
54
|
type ScopeConfirmation = {
|
|
@@ -77,7 +79,8 @@ export declare class ScopeWriter {
|
|
|
77
79
|
private readonly adminLock;
|
|
78
80
|
readonly txHost: TransactionHost;
|
|
79
81
|
private readonly events;
|
|
80
|
-
|
|
82
|
+
private readonly hints;
|
|
83
|
+
constructor(kdb: KernelDb, installLock: PluginInstallLock, xactLock: XactLock, outbox: OutboxService, adminLock: SuperAdminLock, txHost: TransactionHost, events: KernelEvents, hints: HintPublisher);
|
|
81
84
|
platformChange<Result, Conflict>(actor: string, confirmation: ScopeConfirmation, prepare: () => Promise<PreparedScopeWrite<Result, Conflict> | undefined>): Promise<Result | undefined>;
|
|
82
85
|
/** Persist the scope and its named list together after platform confirmation. */
|
|
83
86
|
replaceScope(change: ScopeListChange): Promise<void>;
|