@capybara-hq/kernel 0.1.0-rc.136 → 0.1.0-rc.138
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/audit-log.service.d.ts +96 -12
- package/dist/admin/audit-log.service.js +508 -44
- package/dist/admin/audit-targets.d.ts +17 -0
- package/dist/admin/audit-targets.js +84 -0
- package/dist/admin/audit.controller.d.ts +12 -9
- package/dist/admin/audit.controller.js +29 -8
- package/dist/admin/audit.schemas.d.ts +20 -4
- package/dist/admin/audit.schemas.js +42 -17
- package/dist/admin/extensions.controller.d.ts +5 -2
- package/dist/admin/extensions.controller.js +10 -1
- package/dist/admin/extensions.schemas.d.ts +4 -0
- package/dist/admin/extensions.schemas.js +9 -0
- package/dist/admin/health.service.d.ts +1 -1
- package/dist/admin/health.service.js +3 -3
- package/dist/agents/templates.js +3 -10
- package/dist/app.d.ts +3 -1
- package/dist/app.js +1 -0
- package/dist/automations/automations.service.js +4 -5
- package/dist/catalog/catalog-content.d.ts +6 -8
- package/dist/catalog/catalog-content.js +17 -22
- package/dist/catalog/catalog-items.d.ts +5 -10
- package/dist/catalog/catalog-items.js +27 -51
- package/dist/catalog/catalog-scope.service.d.ts +4 -2
- package/dist/catalog/catalog-scope.service.js +109 -145
- package/dist/catalog/catalog.module.js +7 -4
- package/dist/catalog/catalog.service.d.ts +10 -4
- package/dist/catalog/catalog.service.js +52 -10
- package/dist/catalog/cli.js +17 -0
- package/dist/catalog/component-promotion.js +8 -4
- package/dist/catalog/component-scope.service.d.ts +3 -1
- package/dist/catalog/component-scope.service.js +101 -140
- package/dist/catalog/component-state.d.ts +10 -8
- package/dist/catalog/component-state.js +42 -30
- package/dist/catalog/dependency-edges.d.ts +25 -0
- package/dist/catalog/dependency-edges.js +125 -0
- package/dist/catalog/effect-work.d.ts +27 -0
- package/dist/catalog/effect-work.js +151 -0
- package/dist/catalog/jobs.d.ts +4 -1
- package/dist/catalog/jobs.js +14 -4
- package/dist/catalog/org-catalog.service.d.ts +5 -1
- package/dist/catalog/org-catalog.service.js +101 -106
- package/dist/catalog/org-intent.d.ts +45 -0
- package/dist/catalog/org-intent.js +205 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +27 -32
- package/dist/catalog/ownership.d.ts +2 -3
- package/dist/catalog/ownership.js +10 -28
- package/dist/catalog/platform-components.d.ts +3 -1
- package/dist/catalog/platform-components.js +9 -1
- package/dist/catalog/plugin-import.d.ts +4 -2
- package/dist/catalog/plugin-import.js +22 -21
- package/dist/catalog/plugin-install.d.ts +19 -54
- package/dist/catalog/plugin-install.js +221 -271
- package/dist/catalog/plugin-upgrade.d.ts +10 -5
- package/dist/catalog/plugin-upgrade.js +80 -67
- package/dist/catalog/request-rules.js +20 -8
- package/dist/catalog/scope-orgs.js +2 -7
- package/dist/catalog/scope-state.d.ts +6 -6
- package/dist/catalog/scope-state.js +24 -43
- package/dist/catalog/scope-sync-workers.d.ts +7 -11
- package/dist/catalog/scope-sync-workers.js +10 -26
- package/dist/catalog/scope-sync.d.ts +19 -116
- package/dist/catalog/scope-sync.js +228 -275
- package/dist/catalog/scope-writer.d.ts +87 -0
- package/dist/catalog/scope-writer.js +239 -0
- package/dist/catalog/template-connector-ensure.js +1 -1
- package/dist/catalog/unshare.js +9 -43
- package/dist/channels/connections.service.js +6 -6
- package/dist/channels/supervisor.js +3 -7
- package/dist/client/client-access.service.js +2 -12
- package/dist/config/schema.d.ts +6 -0
- package/dist/config/schema.js +32 -1
- package/dist/ctx/create-ctx.d.ts +2 -2
- package/dist/ctx/create-ctx.js +2 -60
- package/dist/ctx/guard-db.d.ts +6 -0
- package/dist/ctx/guard-db.js +55 -0
- package/dist/db/extension-handoff-schema.d.ts +1 -1
- package/dist/db/extension-handoff-schema.js +48 -10
- package/dist/db/extension-schema-transfer.js +5 -2
- package/dist/db/kernel-schema.d.ts +32 -6
- package/dist/device-access/host-services.d.ts +2 -2
- package/dist/device-access/host-services.js +5 -6
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/erasure/org-rules.js +7 -0
- package/dist/extensions/admin-ops.d.ts +10 -6
- package/dist/extensions/admin-ops.js +53 -9
- package/dist/extensions/admin-view.d.ts +4 -1
- package/dist/extensions/admin-view.js +27 -14
- package/dist/extensions/bootstrap.d.ts +1 -1
- package/dist/extensions/bootstrap.js +6 -4
- package/dist/extensions/cli.js +1 -0
- package/dist/extensions/effective-config.js +1 -4
- package/dist/extensions/enabled.d.ts +183 -29
- package/dist/extensions/enabled.js +148 -62
- package/dist/extensions/host.d.ts +65 -45
- package/dist/extensions/host.js +446 -128
- package/dist/extensions/installs.d.ts +9 -0
- package/dist/extensions/installs.js +23 -0
- package/dist/extensions/isolated/admission.d.ts +10 -0
- package/dist/extensions/isolated/admission.js +206 -0
- package/dist/extensions/isolated/authorization.d.ts +45 -0
- package/dist/extensions/isolated/authorization.js +191 -0
- package/dist/extensions/isolated/broker.d.ts +15 -0
- package/dist/extensions/isolated/broker.js +471 -0
- package/dist/extensions/isolated/child-protocol.d.ts +84 -0
- package/dist/extensions/isolated/child-protocol.js +21 -0
- package/dist/extensions/isolated/child-registration.d.ts +22 -0
- package/dist/extensions/isolated/child-registration.js +152 -0
- package/dist/extensions/isolated/child-session.d.ts +6 -0
- package/dist/extensions/isolated/child-session.js +343 -0
- package/dist/extensions/isolated/child-streams.d.ts +4 -0
- package/dist/extensions/isolated/child-streams.js +142 -0
- package/dist/extensions/isolated/child.d.ts +1 -0
- package/dist/extensions/isolated/child.js +10 -0
- package/dist/extensions/isolated/configured-package.d.ts +15 -0
- package/dist/extensions/isolated/configured-package.js +73 -0
- package/dist/extensions/isolated/engine-binds.d.ts +9 -0
- package/dist/extensions/isolated/engine-binds.js +82 -0
- package/dist/extensions/isolated/engine-policy.d.ts +85 -0
- package/dist/extensions/isolated/engine-policy.js +75 -0
- package/dist/extensions/isolated/engine-proxy-main.d.ts +1 -0
- package/dist/extensions/isolated/engine-proxy-main.js +20 -0
- package/dist/extensions/isolated/engine-proxy.d.ts +7 -0
- package/dist/extensions/isolated/engine-proxy.js +408 -0
- package/dist/extensions/isolated/engine-vaults.d.ts +12 -0
- package/dist/extensions/isolated/engine-vaults.js +93 -0
- package/dist/extensions/isolated/lanes.d.ts +108 -0
- package/dist/extensions/isolated/lanes.js +726 -0
- package/dist/extensions/isolated/postgres-gate.d.ts +15 -0
- package/dist/extensions/isolated/postgres-gate.js +255 -0
- package/dist/extensions/isolated/revision.d.ts +32 -0
- package/dist/extensions/isolated/revision.js +359 -0
- package/dist/extensions/isolated/rpc-frame.d.ts +50 -0
- package/dist/extensions/isolated/rpc-frame.js +193 -0
- package/dist/extensions/isolated/rpc.d.ts +66 -0
- package/dist/extensions/isolated/rpc.js +314 -0
- package/dist/extensions/isolated/sandbox.d.ts +39 -0
- package/dist/extensions/isolated/sandbox.js +356 -0
- package/dist/extensions/isolated/tier.d.ts +6 -0
- package/dist/extensions/isolated/tier.js +45 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/lifecycle-topics.d.ts +2 -0
- package/dist/extensions/lifecycle-topics.js +2 -0
- package/dist/extensions/lifecycle.d.ts +3 -1
- package/dist/extensions/lifecycle.js +53 -5
- package/dist/extensions/locks.d.ts +2 -0
- package/dist/extensions/locks.js +7 -0
- package/dist/extensions/org-config.d.ts +17 -27
- package/dist/extensions/org-config.js +114 -129
- package/dist/extensions/permission-view.d.ts +6 -1
- package/dist/extensions/plugin-guides.d.ts +5 -10
- package/dist/extensions/plugin-guides.js +18 -37
- package/dist/extensions/plugin-icons.d.ts +3 -21
- package/dist/extensions/plugin-icons.js +9 -44
- package/dist/extensions/plugin-items.d.ts +10 -30
- package/dist/extensions/plugin-items.js +32 -73
- package/dist/extensions/source-intent.d.ts +14 -0
- package/dist/extensions/source-intent.js +77 -0
- package/dist/inbox/platform-inbox.service.js +16 -27
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/infra/database/database.module.js +6 -1
- package/dist/infra/database/kernel-db.d.ts +3 -1
- package/dist/infra/database/kernel-db.js +4 -0
- package/dist/infra/events/kernel-events.d.ts +4 -0
- package/dist/infra/outbox/registry.d.ts +3 -36
- package/dist/infra/outbox/registry.js +4 -49
- package/dist/infra/paging/paged-read.d.ts +56 -0
- package/dist/infra/paging/paged-read.js +78 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -1
- package/dist/kernel.d.ts +3 -2
- package/dist/kernel.js +21 -2
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +22 -12
- package/dist/lifecycle/tokens.d.ts +8 -0
- package/dist/lifecycle/tokens.js +2 -0
- package/dist/orgs/directory-sync.js +1 -4
- package/dist/orgs/org-lock.d.ts +3 -1
- package/dist/orgs/org-lock.js +3 -1
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +15 -8
- package/dist/overrides.d.ts +0 -3
- package/dist/overrides.js +0 -2
- package/dist/platform/ops/admin.ops.js +14 -3
- package/dist/platform/ops/extensions-admin.ops.js +20 -3
- package/dist/platform/ops/org-plugins.ops.js +5 -2
- package/dist/platform/ops/orgs.ops.js +13 -3
- package/dist/platform/ops/plugins.ops.js +11 -10
- package/dist/setup/setup-checks.service.js +3 -2
- package/dist/skills/usable.js +41 -30
- package/dist/themes/theme-state.js +3 -3
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/registry.js +7 -3
- package/package.json +2 -2
- package/src/migrations/0228_extension_org_switches.sql +56 -0
- package/src/migrations/0229_catalog_dependency_edges.sql +17 -0
- package/src/migrations/0230_audit_filter_idx.sql +18 -0
- package/src/migrations/0231_plugin_effect_work.sql +171 -0
- package/dist/catalog/install-status.d.ts +0 -6
- package/dist/catalog/install-status.js +0 -6
- package/dist/catalog/scope-jobs.d.ts +0 -59
- package/dist/catalog/scope-jobs.js +0 -78
|
@@ -17,6 +17,7 @@ import { ToolsModule } from "../tools/tools.module.js";
|
|
|
17
17
|
import { CatalogImportModule } from "./catalog-import.module.js";
|
|
18
18
|
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
19
19
|
import { ComponentScopeService } from "./component-scope.service.js";
|
|
20
|
+
import { PLUGIN_EFFECT_QUEUE } from "./effect-work.js";
|
|
20
21
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
21
22
|
import { OrgPluginUploads } from "./org-plugin-uploads.js";
|
|
22
23
|
import { OwnedItems } from "./owned-items.js";
|
|
@@ -24,12 +25,13 @@ import { PlatformImportUpdate } from "./platform-import-update.js";
|
|
|
24
25
|
import { PluginInstaller } from "./plugin-install.js";
|
|
25
26
|
import { PlatformPluginUpdater } from "./plugin-upgrade.js";
|
|
26
27
|
import { CatalogRequestsService } from "./requests.service.js";
|
|
27
|
-
import {
|
|
28
|
+
import { PluginScopeSync } from "./scope-sync.js";
|
|
29
|
+
import { ScopeWriter } from "./scope-writer.js";
|
|
28
30
|
import { TemplateConnectorEnsurer } from "./template-connector-ensure.js";
|
|
29
31
|
import { TemplateConnectorsQueueModule } from "./template-connector-jobs.js";
|
|
30
32
|
export { CatalogImportModule };
|
|
31
33
|
/** The plugin scope sync's queue registration (re-exported: the admin health reads its counts). */
|
|
32
|
-
const
|
|
34
|
+
const PLUGIN_EFFECT_QUEUE_MODULE = QueueModule.registerQueue(PLUGIN_EFFECT_QUEUE);
|
|
33
35
|
/** This module's maintenance queue registration (re-exported for the admin health). */
|
|
34
36
|
const MAINTENANCE_QUEUE_MODULE = QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME);
|
|
35
37
|
/**
|
|
@@ -56,7 +58,7 @@ CatalogModule = __decorate([
|
|
|
56
58
|
ToolsModule,
|
|
57
59
|
// the plugin scope sync's queue: the outbox dispatcher adds the owed jobs through it
|
|
58
60
|
// (`PluginScopeWorkersModule` consumes it)
|
|
59
|
-
|
|
61
|
+
PLUGIN_EFFECT_QUEUE_MODULE,
|
|
60
62
|
// the queue of a removed org plugin's owed cleanup job (`OwnedItems`, `CatalogScopeService`;
|
|
61
63
|
// consumed by the worker role's `MaintenanceProcessor`)
|
|
62
64
|
MAINTENANCE_QUEUE_MODULE,
|
|
@@ -70,6 +72,7 @@ CatalogModule = __decorate([
|
|
|
70
72
|
PlatformPluginUpdater,
|
|
71
73
|
OrgCatalogService,
|
|
72
74
|
PluginScopeSync,
|
|
75
|
+
ScopeWriter,
|
|
73
76
|
CatalogScopeService,
|
|
74
77
|
ComponentScopeService,
|
|
75
78
|
OrgPluginUploads,
|
|
@@ -78,7 +81,7 @@ CatalogModule = __decorate([
|
|
|
78
81
|
TemplateConnectorEnsurer,
|
|
79
82
|
],
|
|
80
83
|
exports: [
|
|
81
|
-
|
|
84
|
+
PLUGIN_EFFECT_QUEUE_MODULE,
|
|
82
85
|
TemplateConnectorsQueueModule,
|
|
83
86
|
MAINTENANCE_QUEUE_MODULE,
|
|
84
87
|
CatalogImportModule,
|
|
@@ -7,6 +7,9 @@ import { SuperAdminLock } from "../identity/super-admin.js";
|
|
|
7
7
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
8
8
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
9
9
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
10
|
+
import { XactLock } from "../infra/database/xact-lock.js";
|
|
11
|
+
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
12
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
10
13
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
11
14
|
import type { OfficialPublisherProof } from "../packages/official-publisher.js";
|
|
12
15
|
import type { TranslationReport } from "./claude/report.js";
|
|
@@ -52,7 +55,7 @@ export interface CatalogItemView {
|
|
|
52
55
|
* shareable`, P3-1); false for platform items, which pass the gate anyway.
|
|
53
56
|
*/
|
|
54
57
|
shareable: boolean;
|
|
55
|
-
/**
|
|
58
|
+
/** Organizations where the plugin is usable. */
|
|
56
59
|
enabledOrgs: number;
|
|
57
60
|
/**
|
|
58
61
|
* Orgs whose admin switched it off while its scope is `all` (layering spec §4: on in every org
|
|
@@ -257,6 +260,9 @@ export declare class CatalogService {
|
|
|
257
260
|
/** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
|
|
258
261
|
private readonly orgLock;
|
|
259
262
|
readonly txHost: TransactionHost;
|
|
263
|
+
private readonly xactLock;
|
|
264
|
+
private readonly outbox;
|
|
265
|
+
private readonly events;
|
|
260
266
|
constructor(kdb: KernelDb,
|
|
261
267
|
/** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
|
|
262
268
|
adminLock: SuperAdminLock, config: KernelConfigService, installs: ExtensionInstalls,
|
|
@@ -269,7 +275,7 @@ export declare class CatalogService {
|
|
|
269
275
|
/** Serializes a claim release with an install of that name still committing (F10). */
|
|
270
276
|
installLock: PluginInstallLock,
|
|
271
277
|
/** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
|
|
272
|
-
orgLock: OrgLock, txHost: TransactionHost);
|
|
278
|
+
orgLock: OrgLock, txHost: TransactionHost, xactLock: XactLock, outbox: OutboxService, events: KernelEvents);
|
|
273
279
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
274
280
|
private get db();
|
|
275
281
|
/** Downloads a marketplace archive source, verified against its integrity. */
|
|
@@ -368,8 +374,8 @@ export declare class CatalogService {
|
|
|
368
374
|
private lockConnectorOrgs;
|
|
369
375
|
/**
|
|
370
376
|
* A live platform item whose extension (the install of the item's name from its package) is
|
|
371
|
-
* enabled -> 409 `catalog.extension_enabled`.
|
|
372
|
-
*
|
|
377
|
+
* enabled -> 409 `catalog.extension_enabled`. The removal holds the extension install locks
|
|
378
|
+
* while checking and retiring the item.
|
|
373
379
|
*/
|
|
374
380
|
private assertExtensionDisabled;
|
|
375
381
|
/**
|
|
@@ -14,16 +14,24 @@ import { ApiError } from "../errors.js";
|
|
|
14
14
|
import { ExtensionAdmin } from "../extensions/admin-view.js";
|
|
15
15
|
import { ExtensionInstalls } from "../extensions/installs.js";
|
|
16
16
|
import { PluginInstallLock } from "../extensions/locks.js";
|
|
17
|
+
import { extensionSourcesQuery } from "../extensions/plugin-items.js";
|
|
18
|
+
import { captureSourceIntent, restoreSourceIntent } from "../extensions/source-intent.js";
|
|
17
19
|
import { audit } from "../identity/audit.js";
|
|
18
20
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
19
21
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
22
|
+
import { afterCommit } from "../infra/database/after-commit.js";
|
|
20
23
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
21
24
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
22
25
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
26
|
+
import { XactLock } from "../infra/database/xact-lock.js";
|
|
27
|
+
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
28
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
23
29
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
24
30
|
import { sameRepository } from "../packages/provenance.js";
|
|
25
31
|
import { assertNotPlatformDefault } from "../themes/theme-usage.js";
|
|
26
32
|
import { countInstalls, inAuthorOrder, itemConfirmations, itemScopeFacts, itemView, marketplaceLatest, versionUsable, } from "./catalog-items.js";
|
|
33
|
+
import { retireCatalogDependencyEdges } from "./dependency-edges.js";
|
|
34
|
+
import { EFFECT_CANDIDATES_LOCK, oweEffectWork } from "./effect-work.js";
|
|
27
35
|
import { expandGitUrl, GitSourceError, gitErrorDetails, normalGitPath, readGitTreeAndOids, resolveGitCommit, } from "./git-source.js";
|
|
28
36
|
import { fetchMarketplaceArchive, marketplaceNetPolicy, marketplaceUrlProblem, requireMarketplacePublisher, } from "./marketplace-fetch.js";
|
|
29
37
|
import { assertEntryNotDeprecated, entryCompatible, entrySourceHost, HOST_VERSIONS, hostAllowed, loadMarketplaceEntry, MarketplacesService, pluginNameFrom, } from "./marketplaces.service.js";
|
|
@@ -103,6 +111,9 @@ let CatalogService = class CatalogService {
|
|
|
103
111
|
installLock;
|
|
104
112
|
orgLock;
|
|
105
113
|
txHost;
|
|
114
|
+
xactLock;
|
|
115
|
+
outbox;
|
|
116
|
+
events;
|
|
106
117
|
constructor(kdb,
|
|
107
118
|
/** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
|
|
108
119
|
adminLock, config, installs,
|
|
@@ -115,7 +126,7 @@ let CatalogService = class CatalogService {
|
|
|
115
126
|
/** Serializes a claim release with an install of that name still committing (F10). */
|
|
116
127
|
installLock,
|
|
117
128
|
/** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
|
|
118
|
-
orgLock, txHost) {
|
|
129
|
+
orgLock, txHost, xactLock, outbox, events) {
|
|
119
130
|
this.kdb = kdb;
|
|
120
131
|
this.adminLock = adminLock;
|
|
121
132
|
this.config = config;
|
|
@@ -126,6 +137,9 @@ let CatalogService = class CatalogService {
|
|
|
126
137
|
this.installLock = installLock;
|
|
127
138
|
this.orgLock = orgLock;
|
|
128
139
|
this.txHost = txHost;
|
|
140
|
+
this.xactLock = xactLock;
|
|
141
|
+
this.outbox = outbox;
|
|
142
|
+
this.events = events;
|
|
129
143
|
}
|
|
130
144
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
131
145
|
get db() {
|
|
@@ -441,7 +455,7 @@ let CatalogService = class CatalogService {
|
|
|
441
455
|
list.push(v);
|
|
442
456
|
byItem.set(v.item_id, list);
|
|
443
457
|
}
|
|
444
|
-
const installs = await countInstalls(this.db, items
|
|
458
|
+
const installs = await countInstalls(this.db, items.map((item) => item.id));
|
|
445
459
|
const latest = await marketplaceLatest(this.db, this.config.get(), items, byItem);
|
|
446
460
|
const facts = await itemScopeFacts(this.db, items, await itemConfirmations(this.admin, items, byItem));
|
|
447
461
|
return {
|
|
@@ -467,7 +481,7 @@ let CatalogService = class CatalogService {
|
|
|
467
481
|
.execute()).filter((v) => item.owner_org_id !== null || versionUsable(v));
|
|
468
482
|
rows.sort((a, b) => newestFirst({ version: a.version, importedAt: a.imported_at }, { version: b.version, importedAt: b.imported_at }));
|
|
469
483
|
const byItem = new Map([[item.id, rows]]);
|
|
470
|
-
const installs = await countInstalls(this.db, [item]
|
|
484
|
+
const installs = await countInstalls(this.db, [item.id]);
|
|
471
485
|
const latest = await marketplaceLatest(this.db, this.config.get(), [item], byItem);
|
|
472
486
|
const facts = await itemScopeFacts(this.db, [item], await itemConfirmations(this.admin, [item], byItem));
|
|
473
487
|
return {
|
|
@@ -523,6 +537,7 @@ let CatalogService = class CatalogService {
|
|
|
523
537
|
await this.assertExtensionDisabled(this.kdb.db, itemId);
|
|
524
538
|
}
|
|
525
539
|
async writeRemove(actor, itemId, opts) {
|
|
540
|
+
await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
|
|
526
541
|
await this.adminLock.lockAndAuthorize(actor);
|
|
527
542
|
// The orgs whose connectors the delete switches off, sorted, before the item (the global lock
|
|
528
543
|
// order, ruling P3-50, as the platform plugin update takes them)
|
|
@@ -535,7 +550,16 @@ let CatalogService = class CatalogService {
|
|
|
535
550
|
.where("id", "=", itemId)
|
|
536
551
|
.forUpdate()
|
|
537
552
|
.execute();
|
|
538
|
-
await this.
|
|
553
|
+
const names = await this.db
|
|
554
|
+
.selectFrom(extensionSourcesQuery(this.db).as("source"))
|
|
555
|
+
.select("source.plugin")
|
|
556
|
+
.where("source.item_id", "=", itemId)
|
|
557
|
+
.union(this.db.selectFrom("catalog_items").select("name as plugin").where("id", "=", itemId))
|
|
558
|
+
.orderBy("plugin")
|
|
559
|
+
.execute();
|
|
560
|
+
for (const { plugin } of names)
|
|
561
|
+
await this.installLock.lock(plugin);
|
|
562
|
+
await this.assertExtensionDisabled(this.db, itemId);
|
|
539
563
|
if ((await this.removeIn(actor, itemId, opts)) === null)
|
|
540
564
|
throw notFound();
|
|
541
565
|
}
|
|
@@ -559,10 +583,10 @@ let CatalogService = class CatalogService {
|
|
|
559
583
|
}
|
|
560
584
|
/**
|
|
561
585
|
* A live platform item whose extension (the install of the item's name from its package) is
|
|
562
|
-
* enabled -> 409 `catalog.extension_enabled`.
|
|
563
|
-
*
|
|
586
|
+
* enabled -> 409 `catalog.extension_enabled`. The removal holds the extension install locks
|
|
587
|
+
* while checking and retiring the item.
|
|
564
588
|
*/
|
|
565
|
-
async assertExtensionDisabled(db, itemId
|
|
589
|
+
async assertExtensionDisabled(db, itemId) {
|
|
566
590
|
const item = await db
|
|
567
591
|
.selectFrom("catalog_items")
|
|
568
592
|
.select(["name", "package_name", "owner_org_id", "display_name"])
|
|
@@ -571,8 +595,6 @@ let CatalogService = class CatalogService {
|
|
|
571
595
|
.executeTakeFirst();
|
|
572
596
|
if (!item || item.owner_org_id !== null)
|
|
573
597
|
return;
|
|
574
|
-
if (lock)
|
|
575
|
-
await this.installLock.lock(item.name);
|
|
576
598
|
const install = await db
|
|
577
599
|
.selectFrom("extension_installs as x")
|
|
578
600
|
.innerJoin("extension_packages as p", "p.sha256", "x.sha256")
|
|
@@ -607,6 +629,17 @@ let CatalogService = class CatalogService {
|
|
|
607
629
|
.forUpdate()
|
|
608
630
|
.execute();
|
|
609
631
|
await assertNotPlatformDefault(t, themes.map((r) => r.id), () => "gone");
|
|
632
|
+
const sources = await t
|
|
633
|
+
.selectFrom(extensionSourcesQuery(t).as("source"))
|
|
634
|
+
.select("plugin")
|
|
635
|
+
.where("item_id", "=", itemId)
|
|
636
|
+
.orderBy("plugin")
|
|
637
|
+
.execute();
|
|
638
|
+
const sourceIntent = new Map();
|
|
639
|
+
for (const { plugin } of sources) {
|
|
640
|
+
await this.installLock.lock(plugin);
|
|
641
|
+
sourceIntent.set(plugin, await captureSourceIntent(t, plugin, "retire"));
|
|
642
|
+
}
|
|
610
643
|
const row = await t
|
|
611
644
|
.updateTable("catalog_items")
|
|
612
645
|
.set({
|
|
@@ -649,6 +682,12 @@ let CatalogService = class CatalogService {
|
|
|
649
682
|
...opts.auditDetail,
|
|
650
683
|
},
|
|
651
684
|
});
|
|
685
|
+
for (const [plugin, before] of sourceIntent) {
|
|
686
|
+
await restoreSourceIntent(t, plugin, before, actor);
|
|
687
|
+
}
|
|
688
|
+
await oweEffectWork(this.outbox, t, { itemIds: [itemId] });
|
|
689
|
+
await retireCatalogDependencyEdges(t, itemId);
|
|
690
|
+
afterCommit(() => this.events.emit("catalog.org-intent-changed", {}));
|
|
652
691
|
return { name: row.name };
|
|
653
692
|
}
|
|
654
693
|
};
|
|
@@ -669,6 +708,9 @@ CatalogService = __decorate([
|
|
|
669
708
|
__param(6, Inject(MarketplacesService)),
|
|
670
709
|
__param(7, Inject(PluginInstallLock)),
|
|
671
710
|
__param(8, Inject(OrgLock)),
|
|
672
|
-
__param(9, Inject(TransactionHost))
|
|
711
|
+
__param(9, Inject(TransactionHost)),
|
|
712
|
+
__param(10, Inject(XactLock)),
|
|
713
|
+
__param(11, Inject(OutboxService)),
|
|
714
|
+
__param(12, Inject(KernelEvents))
|
|
673
715
|
], CatalogService);
|
|
674
716
|
export { CatalogService };
|
package/dist/catalog/cli.js
CHANGED
|
@@ -5,9 +5,11 @@ import { OBJECT_STORE_EXTENSION_POINT, } from "@capybara-hq/plugin-sdk";
|
|
|
5
5
|
import { ClientBuilds } from "../client/client-builds.service.js";
|
|
6
6
|
import { ApiError } from "../errors.js";
|
|
7
7
|
import { planApprovals, snapshotCovers } from "../extensions/approvals.js";
|
|
8
|
+
import { loadBootstrapManifest } from "../extensions/bootstrap-extra.js";
|
|
8
9
|
import { openExtensionCli } from "../extensions/cli.js";
|
|
9
10
|
import { assertSecretsReachable } from "../extensions/host.js";
|
|
10
11
|
import { importExtensionModule, matchesSection } from "../extensions/instance.js";
|
|
12
|
+
import { installedExtensionTier } from "../extensions/isolated/tier.js";
|
|
11
13
|
import { packageRootOf, syncPackage } from "../extensions/sync.js";
|
|
12
14
|
import { packagePath } from "../packages/tgz.js";
|
|
13
15
|
import { PrefixedStorage } from "../storage/storage.service.js";
|
|
@@ -73,6 +75,10 @@ export async function loadCliObjectStore(cli, log, syncDir) {
|
|
|
73
75
|
};
|
|
74
76
|
for (const provider of providers) {
|
|
75
77
|
const name = provider.manifest.name;
|
|
78
|
+
if (provider.isolated) {
|
|
79
|
+
reasons.push(`${name} requires isolated execution`);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
76
82
|
const decision = decisions.find((d) => d.plugin === name);
|
|
77
83
|
if (decision?.action === "pending") {
|
|
78
84
|
reasons.push(`${name} awaits permission approval`);
|
|
@@ -88,6 +94,17 @@ export async function loadCliObjectStore(cli, log, syncDir) {
|
|
|
88
94
|
return { store };
|
|
89
95
|
}
|
|
90
96
|
for (const d of installed) {
|
|
97
|
+
try {
|
|
98
|
+
const tier = await installedExtensionTier(d, () => loadBootstrapManifest({}), { get: (sha) => cli.readPackage(sha) }, true);
|
|
99
|
+
if (tier !== "trusted") {
|
|
100
|
+
reasons.push(`${d.name} did not pass trusted admission`);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
reasons.push(`${d.name} could not be verified for trusted execution`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
91
108
|
// Replicas set it up only after its migrations ran (ensureMigrated records migrated_sha); the
|
|
92
109
|
// CLI never migrates, so a package whose migrations have not run for this sha is skipped
|
|
93
110
|
if (d.section.migrations !== undefined && d.migratedSha !== d.sha256) {
|
|
@@ -27,6 +27,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
27
27
|
import { StorageService } from "../storage/storage.service.js";
|
|
28
28
|
import { putCatalogFiles } from "./catalog-items.js";
|
|
29
29
|
import { platformSkillPrefix, uniqueVersionPrefix } from "./platform-components.js";
|
|
30
|
+
import { writeScope } from "./scope-writer.js";
|
|
30
31
|
/** The org row changed between {@link ComponentPromotion.prepare} and its transaction: prepare again. */
|
|
31
32
|
export class PromotionStale extends Error {
|
|
32
33
|
}
|
|
@@ -249,10 +250,13 @@ let ComponentPromotion = class ComponentPromotion {
|
|
|
249
250
|
.where("org_id", "=", row.orgId)
|
|
250
251
|
.execute();
|
|
251
252
|
}
|
|
252
|
-
await this.db
|
|
253
|
-
.
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
await writeScope(this.db, {
|
|
254
|
+
kind: p.kind,
|
|
255
|
+
id: p.platformId,
|
|
256
|
+
scopeMode: "own",
|
|
257
|
+
scope: "named",
|
|
258
|
+
orgs: [row.orgId],
|
|
259
|
+
});
|
|
256
260
|
await audit(this.db, {
|
|
257
261
|
actorAccountId: actor,
|
|
258
262
|
orgId: row.orgId,
|
|
@@ -13,6 +13,7 @@ import { type ComponentKind } from "./component-state.js";
|
|
|
13
13
|
import { type Owner } from "./ownership.js";
|
|
14
14
|
import { PluginInstaller } from "./plugin-install.js";
|
|
15
15
|
import type { PluginScope } from "./scope.js";
|
|
16
|
+
import { ScopeWriter } from "./scope-writer.js";
|
|
16
17
|
/**
|
|
17
18
|
* What a component scope change, a component disable or a switch back to its plugin's scope would
|
|
18
19
|
* do (spec §5 rules 8 and 10): the orgs where it is on now and would be off, with their agents that
|
|
@@ -240,6 +241,7 @@ export declare function nameConflictError(conflicts: ComponentScopePreview["conf
|
|
|
240
241
|
export declare class ComponentScopeService {
|
|
241
242
|
private readonly kdb;
|
|
242
243
|
private readonly adminLock;
|
|
244
|
+
private readonly scopeWriter;
|
|
243
245
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
244
246
|
private readonly orgLock;
|
|
245
247
|
/** Promote on share (ruling P3-3): an org row shown or associated becomes a platform row. */
|
|
@@ -249,7 +251,7 @@ export declare class ComponentScopeService {
|
|
|
249
251
|
private readonly guides;
|
|
250
252
|
/** A connector template switched on where its plugin is installed gets its connector. */
|
|
251
253
|
private readonly installer;
|
|
252
|
-
constructor(kdb: KernelDb, adminLock: SuperAdminLock,
|
|
254
|
+
constructor(kdb: KernelDb, adminLock: SuperAdminLock, scopeWriter: ScopeWriter,
|
|
253
255
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
254
256
|
orgLock: OrgLock,
|
|
255
257
|
/** Promote on share (ruling P3-3): an org row shown or associated becomes a platform row. */
|