@capybara-hq/kernel 0.1.0-rc.137 → 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/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/catalog/catalog-content.d.ts +5 -7
- package/dist/catalog/catalog-items.js +1 -1
- package/dist/catalog/catalog-scope.service.js +5 -5
- package/dist/catalog/catalog.module.js +5 -4
- package/dist/catalog/catalog.service.d.ts +7 -1
- package/dist/catalog/catalog.service.js +19 -2
- 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 +2 -0
- package/dist/catalog/org-catalog.service.js +68 -12
- package/dist/catalog/org-intent.d.ts +4 -2
- package/dist/catalog/org-intent.js +25 -4
- package/dist/catalog/owned-items.d.ts +5 -1
- package/dist/catalog/owned-items.js +18 -3
- package/dist/catalog/plugin-import.d.ts +4 -2
- package/dist/catalog/plugin-import.js +10 -5
- package/dist/catalog/plugin-install.d.ts +17 -51
- package/dist/catalog/plugin-install.js +209 -235
- package/dist/catalog/plugin-upgrade.d.ts +8 -3
- package/dist/catalog/plugin-upgrade.js +63 -34
- 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 -114
- package/dist/catalog/scope-sync.js +220 -239
- package/dist/catalog/scope-writer.d.ts +10 -1
- package/dist/catalog/scope-writer.js +62 -4
- package/dist/catalog/template-connector-ensure.js +1 -1
- package/dist/catalog/unshare.js +1 -2
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +7 -4
- package/dist/db/kernel-schema.d.ts +21 -5
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/erasure/org-rules.js +2 -0
- package/dist/extensions/admin-ops.d.ts +1 -1
- package/dist/extensions/admin-ops.js +1 -1
- package/dist/extensions/admin-view.d.ts +4 -1
- package/dist/extensions/admin-view.js +27 -11
- package/dist/extensions/bootstrap.d.ts +1 -1
- package/dist/extensions/bootstrap.js +2 -3
- package/dist/extensions/enabled.d.ts +160 -0
- package/dist/extensions/enabled.js +7 -0
- package/dist/extensions/host.d.ts +1 -0
- package/dist/extensions/host.js +5 -2
- package/dist/extensions/isolated/authorization.d.ts +8 -0
- package/dist/extensions/isolated/authorization.js +56 -11
- package/dist/extensions/isolated/broker.js +30 -11
- 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 +11 -3
- package/dist/extensions/isolated/lanes.js +43 -16
- package/dist/extensions/isolated/postgres-gate.d.ts +1 -0
- package/dist/extensions/isolated/postgres-gate.js +6 -6
- package/dist/extensions/isolated/revision.d.ts +1 -1
- package/dist/extensions/isolated/revision.js +3 -2
- package/dist/extensions/isolated/sandbox.d.ts +10 -6
- package/dist/extensions/isolated/sandbox.js +101 -117
- package/dist/extensions/lifecycle-topics.d.ts +1 -0
- package/dist/extensions/lifecycle-topics.js +1 -0
- package/dist/extensions/lifecycle.js +23 -2
- package/dist/extensions/permission-view.d.ts +6 -1
- package/dist/inbox/platform-inbox.service.js +16 -27
- 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/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -1
- 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/extensions-admin.ops.js +20 -3
- package/dist/platform/ops/org-plugins.ops.js +5 -2
- package/dist/platform/ops/plugins.ops.js +11 -10
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +6 -2
- package/package.json +2 -2
- package/src/migrations/0231_plugin_effect_work.sql +171 -0
- package/dist/catalog/install-status.d.ts +0 -5
- package/dist/catalog/install-status.js +0 -5
- package/dist/catalog/scope-jobs.d.ts +0 -59
- package/dist/catalog/scope-jobs.js +0 -78
|
@@ -4,14 +4,14 @@ import { ExtensionAdmin } from "../extensions/admin-view.js";
|
|
|
4
4
|
import { type DeploymentConfigView, ExtensionDeploymentConfigService } from "../extensions/deployment-config.js";
|
|
5
5
|
import { ExtensionInstalls, type PackageReview } from "../extensions/installs.js";
|
|
6
6
|
import { type OrgOverrideSummary, OrgOverrides } from "../extensions/org-overrides.js";
|
|
7
|
-
import type { AdminExtensionView } from "../extensions/permission-view.js";
|
|
7
|
+
import type { AdminExtensionView, ExtensionOrgCounts } from "../extensions/permission-view.js";
|
|
8
8
|
import { PluginGuides, type RenderedSetupGuide } from "../extensions/plugin-guides.js";
|
|
9
9
|
import { type Principal } from "../identity/principal.js";
|
|
10
10
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
11
11
|
import type { SetupCheckState } from "../setup/setup-check-registry.js";
|
|
12
12
|
import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery } from "../setup/setup-checks.schemas.js";
|
|
13
13
|
import { SetupChecksService } from "../setup/setup-checks.service.js";
|
|
14
|
-
import { AdminExtensionConfigBody } from "./extensions.schemas.js";
|
|
14
|
+
import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
|
|
15
15
|
declare const ApproveSchema: z.ZodObject<{
|
|
16
16
|
sha256: z.ZodNullable<z.ZodString>;
|
|
17
17
|
reviewHash: z.ZodString;
|
|
@@ -52,6 +52,9 @@ export declare class AdminExtensionsController {
|
|
|
52
52
|
extensions: AdminExtensionView[];
|
|
53
53
|
drainSeconds: number;
|
|
54
54
|
}>;
|
|
55
|
+
counts(query: z.infer<typeof AdminExtensionOrgCountsQuery>): Promise<{
|
|
56
|
+
counts: ExtensionOrgCounts[];
|
|
57
|
+
}>;
|
|
55
58
|
/** A single extension; unknown -> 404 `extension.not_found`. */
|
|
56
59
|
get(name: string): Promise<AdminExtensionView>;
|
|
57
60
|
/**
|
|
@@ -23,7 +23,7 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
23
23
|
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
24
24
|
import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery, } from "../setup/setup-checks.schemas.js";
|
|
25
25
|
import { SetupChecksService } from "../setup/setup-checks.service.js";
|
|
26
|
-
import { AdminExtensionConfigBody } from "./extensions.schemas.js";
|
|
26
|
+
import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
|
|
27
27
|
const ApproveSchema = z.object({
|
|
28
28
|
/** 安装记录的包(审阅时的 sha256);配置声明的插件为 null。 */
|
|
29
29
|
sha256: z
|
|
@@ -46,6 +46,8 @@ class ExtensionInstallBody extends createZodDto(InstallSchema, "ExtensionInstall
|
|
|
46
46
|
}
|
|
47
47
|
class ExtensionConfigBody extends createZodDto(AdminExtensionConfigBody, "ExtensionConfigBody") {
|
|
48
48
|
}
|
|
49
|
+
class ExtensionOrgCountsQuery extends createZodDto(AdminExtensionOrgCountsQuery, "ExtensionOrgCountsQuery") {
|
|
50
|
+
}
|
|
49
51
|
class ExtensionNpmImportBody extends createZodDto(NpmSchema, "ExtensionNpmImportBody") {
|
|
50
52
|
}
|
|
51
53
|
/** The `:name` route parameter of the org-overrides list (decision R20). */
|
|
@@ -100,6 +102,9 @@ let AdminExtensionsController = class AdminExtensionsController {
|
|
|
100
102
|
drainSeconds: this.kernelConfig.get().extensionHost.drainSeconds,
|
|
101
103
|
};
|
|
102
104
|
}
|
|
105
|
+
async counts(query) {
|
|
106
|
+
return { counts: await this.admin.orgCounts(query.names.split(",")) };
|
|
107
|
+
}
|
|
103
108
|
/** A single extension; unknown -> 404 `extension.not_found`. */
|
|
104
109
|
get(name) {
|
|
105
110
|
return this.admin.get(name);
|
|
@@ -244,6 +249,10 @@ let AdminExtensionsController = class AdminExtensionsController {
|
|
|
244
249
|
__decorate([
|
|
245
250
|
Get()
|
|
246
251
|
], AdminExtensionsController.prototype, "list", null);
|
|
252
|
+
__decorate([
|
|
253
|
+
Get("counts/orgs"),
|
|
254
|
+
__param(0, ZQuery(ExtensionOrgCountsQuery))
|
|
255
|
+
], AdminExtensionsController.prototype, "counts", null);
|
|
247
256
|
__decorate([
|
|
248
257
|
Get(":name"),
|
|
249
258
|
__param(0, Param("name"))
|
|
@@ -25,4 +25,8 @@ export declare const AdminExtensionConfigBody: z.ZodObject<{
|
|
|
25
25
|
renameFrom: z.ZodOptional<z.ZodString>;
|
|
26
26
|
}, z.core.$strict>>>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
|
+
export declare const EXTENSION_ORG_COUNT_PAGE_SIZE = 20;
|
|
29
|
+
export declare const AdminExtensionOrgCountsQuery: z.ZodObject<{
|
|
30
|
+
names: z.ZodString;
|
|
31
|
+
}, z.core.$strict>;
|
|
28
32
|
export declare const ADMIN_EXTENSION_ROUTES: readonly RouteSchemas[];
|
|
@@ -31,10 +31,19 @@ export const AdminExtensionConfigBody = z.object({
|
|
|
31
31
|
/** Single keys of hinted secret records (extension config forms spec §4.3), applied in order. */
|
|
32
32
|
secretEntries: z.array(AdminExtensionSecretEntry).max(200).optional(),
|
|
33
33
|
});
|
|
34
|
+
export const EXTENSION_ORG_COUNT_PAGE_SIZE = 20;
|
|
35
|
+
export const AdminExtensionOrgCountsQuery = z
|
|
36
|
+
.object({
|
|
37
|
+
names: z
|
|
38
|
+
.string()
|
|
39
|
+
.regex(/^[a-z0-9][a-z0-9_-]{0,63}(,[a-z0-9][a-z0-9_-]{0,63}){0,19}$/, "Pass one to 20 comma-separated extension names"),
|
|
40
|
+
})
|
|
41
|
+
.strict();
|
|
34
42
|
export const ADMIN_EXTENSION_ROUTES = [
|
|
35
43
|
// the extension package is the raw body (no schema)
|
|
36
44
|
{ route: "POST /api/v1/admin/extensions/packages/file" },
|
|
37
45
|
{ route: "GET /api/v1/admin/extensions" },
|
|
46
|
+
{ route: "GET /api/v1/admin/extensions/counts/orgs", query: AdminExtensionOrgCountsQuery },
|
|
38
47
|
{ route: "GET /api/v1/admin/extensions/:name", params: AdminExtensionNamePathParams },
|
|
39
48
|
{ route: "POST /api/v1/admin/extensions/:name/enable", params: AdminExtensionNamePathParams },
|
|
40
49
|
{ route: "POST /api/v1/admin/extensions/:name/disable", params: AdminExtensionNamePathParams },
|
|
@@ -5,7 +5,7 @@ import { type LiveReplica, ReplicaPresence } from "../infra/presence/replica-pre
|
|
|
5
5
|
import type { KernelLogger } from "../log.js";
|
|
6
6
|
import { DeviceProviders } from "../sandbox/providers.js";
|
|
7
7
|
/** The kernel's own queues, in the order the overview lists them (extension queues are not read). */
|
|
8
|
-
export declare const KERNEL_QUEUE_NAMES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-tool-watch", "cap-kernel-plugin-
|
|
8
|
+
export declare const KERNEL_QUEUE_NAMES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-tool-watch", "cap-kernel-plugin-effects", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver", "cap-connector-tools", "cap-template-connectors", "cap-device-service-events", "cap-external-calls"];
|
|
9
9
|
/** How long each source's reads may take before the answer marks it unavailable. */
|
|
10
10
|
export declare const HEALTH_READ_TIMEOUT_MS = 3000;
|
|
11
11
|
/** A live replica as the overview shows it. */
|
|
@@ -10,7 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { getQueueToken } from "@nestjs/bullmq";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
|
-
import {
|
|
13
|
+
import { PLUGIN_EFFECT_QUEUE } from "../catalog/scope-sync.js";
|
|
14
14
|
import { TEMPLATE_CONNECTORS_QUEUE } from "../catalog/template-connector-jobs.js";
|
|
15
15
|
import { CHANNEL_QUEUE_NAME } from "../channels/jobs.js";
|
|
16
16
|
import { EXTERNAL_CALLS_QUEUE } from "../conversations/external/external-calls.js";
|
|
@@ -38,7 +38,7 @@ export const KERNEL_QUEUE_NAMES = [
|
|
|
38
38
|
CHANNEL_QUEUE_NAME,
|
|
39
39
|
MAINTENANCE_QUEUE_NAME,
|
|
40
40
|
TOOL_WATCH_QUEUE,
|
|
41
|
-
|
|
41
|
+
PLUGIN_EFFECT_QUEUE,
|
|
42
42
|
TITLE_QUEUE,
|
|
43
43
|
PROMPT_SUGGESTION_QUEUE,
|
|
44
44
|
USAGE_REPORT_QUEUE,
|
|
@@ -305,7 +305,7 @@ AdminHealthService = __decorate([
|
|
|
305
305
|
__param(7, Inject(getQueueToken(CHANNEL_QUEUE_NAME))),
|
|
306
306
|
__param(8, Inject(getQueueToken(MAINTENANCE_QUEUE_NAME))),
|
|
307
307
|
__param(9, Inject(getQueueToken(TOOL_WATCH_QUEUE))),
|
|
308
|
-
__param(10, Inject(getQueueToken(
|
|
308
|
+
__param(10, Inject(getQueueToken(PLUGIN_EFFECT_QUEUE))),
|
|
309
309
|
__param(11, Inject(getQueueToken(TITLE_QUEUE))),
|
|
310
310
|
__param(12, Inject(getQueueToken(PROMPT_SUGGESTION_QUEUE))),
|
|
311
311
|
__param(13, Inject(getQueueToken(USAGE_REPORT_QUEUE))),
|
|
@@ -36,11 +36,9 @@ export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "mark
|
|
|
36
36
|
switchable: boolean;
|
|
37
37
|
/** The plugin's extension (or a template's connector extension) is not on the deployment. */
|
|
38
38
|
notDeployed: boolean;
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* kept for the web until its upgrade dialog goes).
|
|
43
|
-
*/
|
|
39
|
+
/** Pending work or the latest failed effect, independent of whether the plugin can be used. */
|
|
40
|
+
setup?: "pending" | "install_failed";
|
|
41
|
+
/** The version of this plugin's applied org resources, when it owns any. */
|
|
44
42
|
installed: {
|
|
45
43
|
pluginInstallId: string;
|
|
46
44
|
version: string;
|
|
@@ -192,10 +190,10 @@ export interface OrgInstallResult {
|
|
|
192
190
|
installed: {
|
|
193
191
|
itemId: string;
|
|
194
192
|
version: string;
|
|
195
|
-
pluginInstallId: string;
|
|
193
|
+
pluginInstallId: string | null;
|
|
196
194
|
};
|
|
197
195
|
/** The install view (its components, dependency installs included). */
|
|
198
|
-
install: PluginInstallView;
|
|
196
|
+
install: PluginInstallView | null;
|
|
199
197
|
}
|
|
200
198
|
/**
|
|
201
199
|
* The org actions installing / uninstalling a plugin needs: the union over its components (an
|
|
@@ -458,7 +458,7 @@ export async function countInstalls(db, itemIds) {
|
|
|
458
458
|
.innerJoin("orgs as org", "org.id", "install.org_id")
|
|
459
459
|
.select(["install.item_id", (eb) => eb.fn.count("install.org_id").distinct().as("n")])
|
|
460
460
|
.where("install.item_id", "in", itemIds)
|
|
461
|
-
.where("install.
|
|
461
|
+
.where("install.version", "is not", null)
|
|
462
462
|
.where("org.deleted_at", "is", null)
|
|
463
463
|
.groupBy("install.item_id")
|
|
464
464
|
.execute();
|
|
@@ -24,7 +24,6 @@ import { CatalogService } from "./catalog.service.js";
|
|
|
24
24
|
import { assertOrgsExist } from "./catalog-items.js";
|
|
25
25
|
import { nameConflictError } from "./component-scope.service.js";
|
|
26
26
|
import { agentsUsing, COMPONENT_KINDS, componentOffered, componentOn, listedIn, loadComponents, loadScopeState, pluginFactsOf, skillNameClashes, switchOf, themeIdClashes, } from "./component-state.js";
|
|
27
|
-
import { LIVE_INSTALL_STATUSES } from "./install-status.js";
|
|
28
27
|
import { orgUsable } from "./org-intent.js";
|
|
29
28
|
import { assertOwnerListed, assertShareable, assertShareableTarget, newlySharedWith, } from "./ownership.js";
|
|
30
29
|
import { PluginImport } from "./plugin-import.js";
|
|
@@ -287,7 +286,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
287
286
|
...opts.auditDetail,
|
|
288
287
|
},
|
|
289
288
|
});
|
|
290
|
-
await this.enqueue(itemId);
|
|
289
|
+
await this.enqueue(itemId, from);
|
|
291
290
|
},
|
|
292
291
|
};
|
|
293
292
|
});
|
|
@@ -370,6 +369,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
370
369
|
}
|
|
371
370
|
if (narrowed)
|
|
372
371
|
await this.enqueue(itemId);
|
|
372
|
+
this.scopeWriter.refreshIsolatedOrgIntent();
|
|
373
373
|
}
|
|
374
374
|
/**
|
|
375
375
|
* Adds one org to a `named` item's list in the caller's transaction (an approved `access`
|
|
@@ -392,8 +392,8 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
392
392
|
await this.enqueue(itemId);
|
|
393
393
|
}
|
|
394
394
|
/** Owes the item's scope sync in the transaction that changes its scope (outbox spec §8.1). */
|
|
395
|
-
async enqueue(itemId) {
|
|
396
|
-
await this.sync.enqueueItem(itemId);
|
|
395
|
+
async enqueue(itemId, previousOrgs = []) {
|
|
396
|
+
await this.sync.enqueueItem(itemId, previousOrgs);
|
|
397
397
|
}
|
|
398
398
|
/**
|
|
399
399
|
* 409 `theme.platform_default` when a live theme of the item is the platform default and `after`
|
|
@@ -484,7 +484,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
484
484
|
.selectFrom("plugin_installs")
|
|
485
485
|
.select(["id", "org_id"])
|
|
486
486
|
.where("item_id", "=", item.id)
|
|
487
|
-
.where("
|
|
487
|
+
.where("version", "is not", null)
|
|
488
488
|
.execute();
|
|
489
489
|
const live = new Map(installs.map((install) => [install.org_id, install.id]));
|
|
490
490
|
const affected = [];
|
|
@@ -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,13 +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";
|
|
28
29
|
import { ScopeWriter } from "./scope-writer.js";
|
|
29
30
|
import { TemplateConnectorEnsurer } from "./template-connector-ensure.js";
|
|
30
31
|
import { TemplateConnectorsQueueModule } from "./template-connector-jobs.js";
|
|
31
32
|
export { CatalogImportModule };
|
|
32
33
|
/** The plugin scope sync's queue registration (re-exported: the admin health reads its counts). */
|
|
33
|
-
const
|
|
34
|
+
const PLUGIN_EFFECT_QUEUE_MODULE = QueueModule.registerQueue(PLUGIN_EFFECT_QUEUE);
|
|
34
35
|
/** This module's maintenance queue registration (re-exported for the admin health). */
|
|
35
36
|
const MAINTENANCE_QUEUE_MODULE = QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME);
|
|
36
37
|
/**
|
|
@@ -57,7 +58,7 @@ CatalogModule = __decorate([
|
|
|
57
58
|
ToolsModule,
|
|
58
59
|
// the plugin scope sync's queue: the outbox dispatcher adds the owed jobs through it
|
|
59
60
|
// (`PluginScopeWorkersModule` consumes it)
|
|
60
|
-
|
|
61
|
+
PLUGIN_EFFECT_QUEUE_MODULE,
|
|
61
62
|
// the queue of a removed org plugin's owed cleanup job (`OwnedItems`, `CatalogScopeService`;
|
|
62
63
|
// consumed by the worker role's `MaintenanceProcessor`)
|
|
63
64
|
MAINTENANCE_QUEUE_MODULE,
|
|
@@ -80,7 +81,7 @@ CatalogModule = __decorate([
|
|
|
80
81
|
TemplateConnectorEnsurer,
|
|
81
82
|
],
|
|
82
83
|
exports: [
|
|
83
|
-
|
|
84
|
+
PLUGIN_EFFECT_QUEUE_MODULE,
|
|
84
85
|
TemplateConnectorsQueueModule,
|
|
85
86
|
MAINTENANCE_QUEUE_MODULE,
|
|
86
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";
|
|
@@ -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. */
|
|
@@ -19,14 +19,19 @@ import { captureSourceIntent, restoreSourceIntent } from "../extensions/source-i
|
|
|
19
19
|
import { audit } from "../identity/audit.js";
|
|
20
20
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
21
21
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
22
|
+
import { afterCommit } from "../infra/database/after-commit.js";
|
|
22
23
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
23
24
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
24
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";
|
|
25
29
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
26
30
|
import { sameRepository } from "../packages/provenance.js";
|
|
27
31
|
import { assertNotPlatformDefault } from "../themes/theme-usage.js";
|
|
28
32
|
import { countInstalls, inAuthorOrder, itemConfirmations, itemScopeFacts, itemView, marketplaceLatest, versionUsable, } from "./catalog-items.js";
|
|
29
33
|
import { retireCatalogDependencyEdges } from "./dependency-edges.js";
|
|
34
|
+
import { EFFECT_CANDIDATES_LOCK, oweEffectWork } from "./effect-work.js";
|
|
30
35
|
import { expandGitUrl, GitSourceError, gitErrorDetails, normalGitPath, readGitTreeAndOids, resolveGitCommit, } from "./git-source.js";
|
|
31
36
|
import { fetchMarketplaceArchive, marketplaceNetPolicy, marketplaceUrlProblem, requireMarketplacePublisher, } from "./marketplace-fetch.js";
|
|
32
37
|
import { assertEntryNotDeprecated, entryCompatible, entrySourceHost, HOST_VERSIONS, hostAllowed, loadMarketplaceEntry, MarketplacesService, pluginNameFrom, } from "./marketplaces.service.js";
|
|
@@ -106,6 +111,9 @@ let CatalogService = class CatalogService {
|
|
|
106
111
|
installLock;
|
|
107
112
|
orgLock;
|
|
108
113
|
txHost;
|
|
114
|
+
xactLock;
|
|
115
|
+
outbox;
|
|
116
|
+
events;
|
|
109
117
|
constructor(kdb,
|
|
110
118
|
/** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
|
|
111
119
|
adminLock, config, installs,
|
|
@@ -118,7 +126,7 @@ let CatalogService = class CatalogService {
|
|
|
118
126
|
/** Serializes a claim release with an install of that name still committing (F10). */
|
|
119
127
|
installLock,
|
|
120
128
|
/** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
|
|
121
|
-
orgLock, txHost) {
|
|
129
|
+
orgLock, txHost, xactLock, outbox, events) {
|
|
122
130
|
this.kdb = kdb;
|
|
123
131
|
this.adminLock = adminLock;
|
|
124
132
|
this.config = config;
|
|
@@ -129,6 +137,9 @@ let CatalogService = class CatalogService {
|
|
|
129
137
|
this.installLock = installLock;
|
|
130
138
|
this.orgLock = orgLock;
|
|
131
139
|
this.txHost = txHost;
|
|
140
|
+
this.xactLock = xactLock;
|
|
141
|
+
this.outbox = outbox;
|
|
142
|
+
this.events = events;
|
|
132
143
|
}
|
|
133
144
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
134
145
|
get db() {
|
|
@@ -526,6 +537,7 @@ let CatalogService = class CatalogService {
|
|
|
526
537
|
await this.assertExtensionDisabled(this.kdb.db, itemId);
|
|
527
538
|
}
|
|
528
539
|
async writeRemove(actor, itemId, opts) {
|
|
540
|
+
await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
|
|
529
541
|
await this.adminLock.lockAndAuthorize(actor);
|
|
530
542
|
// The orgs whose connectors the delete switches off, sorted, before the item (the global lock
|
|
531
543
|
// order, ruling P3-50, as the platform plugin update takes them)
|
|
@@ -673,7 +685,9 @@ let CatalogService = class CatalogService {
|
|
|
673
685
|
for (const [plugin, before] of sourceIntent) {
|
|
674
686
|
await restoreSourceIntent(t, plugin, before, actor);
|
|
675
687
|
}
|
|
688
|
+
await oweEffectWork(this.outbox, t, { itemIds: [itemId] });
|
|
676
689
|
await retireCatalogDependencyEdges(t, itemId);
|
|
690
|
+
afterCommit(() => this.events.emit("catalog.org-intent-changed", {}));
|
|
677
691
|
return { name: row.name };
|
|
678
692
|
}
|
|
679
693
|
};
|
|
@@ -694,6 +708,9 @@ CatalogService = __decorate([
|
|
|
694
708
|
__param(6, Inject(MarketplacesService)),
|
|
695
709
|
__param(7, Inject(PluginInstallLock)),
|
|
696
710
|
__param(8, Inject(OrgLock)),
|
|
697
|
-
__param(9, Inject(TransactionHost))
|
|
711
|
+
__param(9, Inject(TransactionHost)),
|
|
712
|
+
__param(10, Inject(XactLock)),
|
|
713
|
+
__param(11, Inject(OutboxService)),
|
|
714
|
+
__param(12, Inject(KernelEvents))
|
|
698
715
|
], CatalogService);
|
|
699
716
|
export { CatalogService };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
import type { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
3
|
+
export declare const PLUGIN_EFFECT_QUEUE = "cap-kernel-plugin-effects";
|
|
4
|
+
export declare const PLUGIN_EFFECT_JOB = "plugin-effect";
|
|
5
|
+
export declare const EFFECT_CANDIDATES_LOCK = "capybara.plugin-effect-candidates";
|
|
6
|
+
export type EffectJob = {
|
|
7
|
+
kind: "chunk";
|
|
8
|
+
itemId: string;
|
|
9
|
+
orgIds: [string];
|
|
10
|
+
};
|
|
11
|
+
type Outbox = Pick<OutboxService, "addMany">;
|
|
12
|
+
export declare function effectGeneration(jobId: string, { itemId, orgIds }: EffectJob): string;
|
|
13
|
+
type EffectMutation = {
|
|
14
|
+
itemIds: readonly string[];
|
|
15
|
+
previousOrgs?: readonly string[];
|
|
16
|
+
orgId?: string;
|
|
17
|
+
includeDependents?: boolean;
|
|
18
|
+
} | {
|
|
19
|
+
orgId: string;
|
|
20
|
+
};
|
|
21
|
+
/** Selects sparse intent or ownership first. Only an all-scope root needs the org census. */
|
|
22
|
+
export declare function oweEffectWork(outbox: Outbox, db: KernelSchemaDb, mutation: EffectMutation): Promise<void>;
|
|
23
|
+
/** Re-owes the same generation if a worker did not settle it. */
|
|
24
|
+
export declare function recoverEffectWork(outbox: Outbox, db: KernelSchemaDb): Promise<void>;
|
|
25
|
+
/** Resolve a deployed extension's live catalog item before owing its affected pairs. */
|
|
26
|
+
export declare function oweDeployedExtensionSync(outbox: Outbox, db: KernelSchemaDb, extensionName: string): Promise<void>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
import { asPlatform } from "../infra/database/org-scope.js";
|
|
3
|
+
export const PLUGIN_EFFECT_QUEUE = "cap-kernel-plugin-effects";
|
|
4
|
+
export const PLUGIN_EFFECT_JOB = "plugin-effect";
|
|
5
|
+
export const EFFECT_CANDIDATES_LOCK = "capybara.plugin-effect-candidates";
|
|
6
|
+
const pairPrefix = (itemId, orgId) => `${itemId}-${orgId}-`;
|
|
7
|
+
export function effectGeneration(jobId, { itemId, orgIds }) {
|
|
8
|
+
const orgId = orgIds[0];
|
|
9
|
+
const prefix = pairPrefix(itemId, orgId);
|
|
10
|
+
const generation = jobId.slice(prefix.length);
|
|
11
|
+
if (orgIds.length !== 1 ||
|
|
12
|
+
!orgId ||
|
|
13
|
+
!jobId.startsWith(prefix) ||
|
|
14
|
+
jobId.includes(":") ||
|
|
15
|
+
!/^[1-9][0-9]{0,18}$/.test(generation) ||
|
|
16
|
+
BigInt(generation) > 9223372036854775807n) {
|
|
17
|
+
throw new Error("invalid plugin effect job id");
|
|
18
|
+
}
|
|
19
|
+
return generation;
|
|
20
|
+
}
|
|
21
|
+
async function owePairs(outbox, pairs) {
|
|
22
|
+
await outbox.addMany(pairs.map(({ item_id: itemId, org_id: orgId, generation }) => ({
|
|
23
|
+
queue: PLUGIN_EFFECT_QUEUE,
|
|
24
|
+
name: PLUGIN_EFFECT_JOB,
|
|
25
|
+
jobId: `${pairPrefix(itemId, orgId)}${generation}`,
|
|
26
|
+
data: { kind: "chunk", itemId, orgIds: [orgId] },
|
|
27
|
+
orgId,
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
/** Selects sparse intent or ownership first. Only an all-scope root needs the org census. */
|
|
31
|
+
export async function oweEffectWork(outbox, db, mutation) {
|
|
32
|
+
const itemIds = "itemIds" in mutation ? [...mutation.itemIds] : null;
|
|
33
|
+
if (itemIds?.length === 0)
|
|
34
|
+
return;
|
|
35
|
+
const previousOrgs = "itemIds" in mutation ? [...(mutation.previousOrgs ?? [])] : [];
|
|
36
|
+
const orgId = mutation.orgId ?? null;
|
|
37
|
+
const includeDependents = !("itemIds" in mutation) || mutation.includeDependents !== false;
|
|
38
|
+
// org-filter: deployment-wide effect candidates derived from a single committed intent graph.
|
|
39
|
+
await asPlatform("Select affected plugin effect pairs", async () => {
|
|
40
|
+
const { rows } = await sql `
|
|
41
|
+
WITH RECURSIVE affected(id) AS (
|
|
42
|
+
SELECT id FROM capybara.catalog_items
|
|
43
|
+
WHERE (${itemIds}::uuid[] IS NULL OR id = ANY(${itemIds}::uuid[]))
|
|
44
|
+
UNION
|
|
45
|
+
SELECT edge.item_id
|
|
46
|
+
FROM capybara.catalog_dependency_edges AS edge
|
|
47
|
+
JOIN affected ON affected.id = edge.dependency_item_id
|
|
48
|
+
WHERE ${includeDependents}::boolean
|
|
49
|
+
), subjects AS (
|
|
50
|
+
SELECT item.id, item.scope, item.owner_org_id, item.shareable, item.deleted_at
|
|
51
|
+
FROM affected
|
|
52
|
+
JOIN capybara.catalog_items AS item USING (id)
|
|
53
|
+
WHERE NOT item.builtin
|
|
54
|
+
), candidates(item_id, org_id) AS (
|
|
55
|
+
SELECT subjects.id, org.id
|
|
56
|
+
FROM subjects CROSS JOIN capybara.orgs AS org
|
|
57
|
+
WHERE subjects.scope = 'all' AND subjects.deleted_at IS NULL
|
|
58
|
+
AND (subjects.owner_org_id IS NULL OR subjects.owner_org_id = org.id OR subjects.shareable)
|
|
59
|
+
AND (${orgId}::text IS NULL OR org.id = ${orgId})
|
|
60
|
+
UNION
|
|
61
|
+
SELECT named.item_id, named.org_id
|
|
62
|
+
FROM capybara.catalog_item_scope_orgs AS named
|
|
63
|
+
JOIN subjects ON subjects.id = named.item_id
|
|
64
|
+
UNION
|
|
65
|
+
SELECT choice.item_id, choice.org_id
|
|
66
|
+
FROM capybara.catalog_item_org_switches AS choice
|
|
67
|
+
JOIN subjects ON subjects.id = choice.item_id
|
|
68
|
+
UNION
|
|
69
|
+
SELECT template.catalog_item_id, org.id
|
|
70
|
+
FROM capybara.platform_connector_templates AS template
|
|
71
|
+
JOIN subjects ON subjects.id = template.catalog_item_id
|
|
72
|
+
CROSS JOIN capybara.orgs AS org
|
|
73
|
+
WHERE template.scope_mode = 'own' AND template.scope = 'all'
|
|
74
|
+
AND template.deleted_at IS NULL AND NOT template.disabled
|
|
75
|
+
AND (template.owner_org_id IS NULL OR template.owner_org_id = org.id OR template.shareable)
|
|
76
|
+
AND (${orgId}::text IS NULL OR org.id = ${orgId})
|
|
77
|
+
UNION
|
|
78
|
+
SELECT template.catalog_item_id, named.org_id
|
|
79
|
+
FROM capybara.platform_connector_templates AS template
|
|
80
|
+
JOIN subjects ON subjects.id = template.catalog_item_id
|
|
81
|
+
JOIN capybara.component_scope_orgs AS named
|
|
82
|
+
ON named.kind = 'connector_template' AND named.component_id = template.id
|
|
83
|
+
UNION
|
|
84
|
+
SELECT template.catalog_item_id, choice.org_id
|
|
85
|
+
FROM capybara.platform_connector_templates AS template
|
|
86
|
+
JOIN subjects ON subjects.id = template.catalog_item_id
|
|
87
|
+
JOIN capybara.component_org_switches AS choice
|
|
88
|
+
ON choice.kind = 'connector_template' AND choice.component_id = template.id
|
|
89
|
+
UNION
|
|
90
|
+
SELECT inst.item_id, inst.org_id
|
|
91
|
+
FROM capybara.plugin_installs AS inst
|
|
92
|
+
JOIN subjects ON subjects.id = inst.item_id
|
|
93
|
+
UNION
|
|
94
|
+
SELECT work.item_id, work.org_id
|
|
95
|
+
FROM capybara.plugin_effect_work AS work
|
|
96
|
+
JOIN subjects ON subjects.id = work.item_id
|
|
97
|
+
WHERE work.state = 'pending'
|
|
98
|
+
UNION
|
|
99
|
+
SELECT subjects.id, old.org_id
|
|
100
|
+
FROM subjects CROSS JOIN unnest(${previousOrgs}::text[]) AS old(org_id)
|
|
101
|
+
)
|
|
102
|
+
INSERT INTO capybara.plugin_effect_work (item_id, org_id, generation, state, generation_started_at, updated_at)
|
|
103
|
+
SELECT candidate.item_id, candidate.org_id, 1, 'pending',
|
|
104
|
+
statement_timestamp(), statement_timestamp()
|
|
105
|
+
FROM candidates AS candidate
|
|
106
|
+
JOIN capybara.orgs AS org ON org.id = candidate.org_id AND org.deleted_at IS NULL
|
|
107
|
+
WHERE ${orgId}::text IS NULL OR candidate.org_id = ${orgId}
|
|
108
|
+
ORDER BY candidate.item_id, candidate.org_id
|
|
109
|
+
ON CONFLICT (item_id, org_id) DO UPDATE
|
|
110
|
+
SET generation = plugin_effect_work.generation + 1,
|
|
111
|
+
state = 'pending',
|
|
112
|
+
generation_started_at = EXCLUDED.generation_started_at,
|
|
113
|
+
updated_at = EXCLUDED.updated_at
|
|
114
|
+
-- Multiple writes in the same transaction owe its final state once.
|
|
115
|
+
WHERE plugin_effect_work.xmin <> pg_current_xact_id()::xid
|
|
116
|
+
RETURNING item_id, org_id, generation
|
|
117
|
+
`.execute(db);
|
|
118
|
+
await owePairs(outbox, rows);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** Re-owes the same generation if a worker did not settle it. */
|
|
122
|
+
export async function recoverEffectWork(outbox, db) {
|
|
123
|
+
// org-filter: deployment-wide stale effect pairs; the job itself enters the pair's org scope.
|
|
124
|
+
await asPlatform("Recover stale plugin effect pairs", async () => {
|
|
125
|
+
const { rows } = await sql `
|
|
126
|
+
WITH stale AS (
|
|
127
|
+
SELECT item_id, org_id FROM capybara.plugin_effect_work
|
|
128
|
+
WHERE state = 'pending' AND updated_at < statement_timestamp() - INTERVAL '2 minutes'
|
|
129
|
+
ORDER BY updated_at, item_id, org_id
|
|
130
|
+
LIMIT 100
|
|
131
|
+
FOR UPDATE SKIP LOCKED
|
|
132
|
+
)
|
|
133
|
+
UPDATE capybara.plugin_effect_work AS work SET updated_at = statement_timestamp()
|
|
134
|
+
FROM stale WHERE work.item_id = stale.item_id AND work.org_id = stale.org_id
|
|
135
|
+
RETURNING work.item_id, work.org_id, work.generation
|
|
136
|
+
`.execute(db);
|
|
137
|
+
await owePairs(outbox, rows);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** Resolve a deployed extension's live catalog item before owing its affected pairs. */
|
|
141
|
+
export async function oweDeployedExtensionSync(outbox, db, extensionName) {
|
|
142
|
+
const item = await db
|
|
143
|
+
.selectFrom("catalog_items")
|
|
144
|
+
.select("id")
|
|
145
|
+
.where("name", "=", extensionName)
|
|
146
|
+
.where("deleted_at", "is", null)
|
|
147
|
+
.where("builtin", "=", false)
|
|
148
|
+
.executeTakeFirst();
|
|
149
|
+
if (item)
|
|
150
|
+
await oweEffectWork(outbox, db, { itemIds: [item.id] });
|
|
151
|
+
}
|
package/dist/catalog/jobs.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { LockService } from "../infra/lock/lock.service.js";
|
|
|
3
3
|
import type { KernelLogger } from "../log.js";
|
|
4
4
|
import { MarketplacesService } from "./marketplaces.service.js";
|
|
5
5
|
import { PluginImport } from "./plugin-import.js";
|
|
6
|
+
import { PluginScopeSync } from "./scope-sync.js";
|
|
6
7
|
import { TemplateConnectorEnsurer } from "./template-connector-ensure.js";
|
|
7
8
|
/**
|
|
8
9
|
* The catalog's periodic jobs, each run once per tick across replicas: the marketplace refresh
|
|
@@ -15,10 +16,11 @@ export declare class CatalogJobs {
|
|
|
15
16
|
private readonly marketplaces;
|
|
16
17
|
private readonly imports;
|
|
17
18
|
private readonly templateConnectors;
|
|
19
|
+
private readonly pluginEffects;
|
|
18
20
|
readonly config: KernelConfigService;
|
|
19
21
|
readonly lockService: LockService;
|
|
20
22
|
readonly log: KernelLogger;
|
|
21
|
-
constructor(marketplaces: MarketplacesService, imports: PluginImport, templateConnectors: TemplateConnectorEnsurer, config: KernelConfigService, lockService: LockService, log: KernelLogger);
|
|
23
|
+
constructor(marketplaces: MarketplacesService, imports: PluginImport, templateConnectors: TemplateConnectorEnsurer, pluginEffects: PluginScopeSync, config: KernelConfigService, lockService: LockService, log: KernelLogger);
|
|
22
24
|
/**
|
|
23
25
|
* Refreshes every enabled marketplace in turn (overall deadline
|
|
24
26
|
* {@link MARKETPLACES_REFRESH_DEADLINE_MS}; the job's signal aborts it: the stop, or the run
|
|
@@ -31,6 +33,7 @@ export declare class CatalogJobs {
|
|
|
31
33
|
* each connector is created in its own (`TemplateConnectorEnsurer`).
|
|
32
34
|
*/
|
|
33
35
|
sweepTemplateConnectors(stop?: AbortSignal): Promise<void>;
|
|
36
|
+
recoverPluginEffects(): Promise<void>;
|
|
34
37
|
/** Deletes expired staging rows and their objects. */
|
|
35
38
|
cleanupStaging(): Promise<void>;
|
|
36
39
|
}
|
package/dist/catalog/jobs.js
CHANGED
|
@@ -16,6 +16,7 @@ import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
|
16
16
|
import { MARKETPLACES_REFRESH_JOB, PLUGIN_STAGING_CLEANUP_JOB, TEMPLATE_CONNECTORS_SWEEP_BATCH, TEMPLATE_CONNECTORS_SWEEP_JOB, TEMPLATE_CONNECTORS_SWEEP_PERIOD_MS, } from "./job-ids.js";
|
|
17
17
|
import { MARKETPLACES_REFRESH_DEADLINE_MS, MarketplacesService } from "./marketplaces.service.js";
|
|
18
18
|
import { PluginImport } from "./plugin-import.js";
|
|
19
|
+
import { PluginScopeSync } from "./scope-sync.js";
|
|
19
20
|
import { TemplateConnectorEnsurer } from "./template-connector-ensure.js";
|
|
20
21
|
/**
|
|
21
22
|
* The catalog's periodic jobs, each run once per tick across replicas: the marketplace refresh
|
|
@@ -28,13 +29,15 @@ let CatalogJobs = class CatalogJobs {
|
|
|
28
29
|
marketplaces;
|
|
29
30
|
imports;
|
|
30
31
|
templateConnectors;
|
|
32
|
+
pluginEffects;
|
|
31
33
|
config;
|
|
32
34
|
lockService;
|
|
33
35
|
log;
|
|
34
|
-
constructor(marketplaces, imports, templateConnectors, config, lockService, log) {
|
|
36
|
+
constructor(marketplaces, imports, templateConnectors, pluginEffects, config, lockService, log) {
|
|
35
37
|
this.marketplaces = marketplaces;
|
|
36
38
|
this.imports = imports;
|
|
37
39
|
this.templateConnectors = templateConnectors;
|
|
40
|
+
this.pluginEffects = pluginEffects;
|
|
38
41
|
this.config = config;
|
|
39
42
|
this.lockService = lockService;
|
|
40
43
|
this.log = log;
|
|
@@ -61,6 +64,9 @@ let CatalogJobs = class CatalogJobs {
|
|
|
61
64
|
if (r.created > 0)
|
|
62
65
|
this.log.info("template connector sweep created connectors", r);
|
|
63
66
|
}
|
|
67
|
+
async recoverPluginEffects() {
|
|
68
|
+
await this.pluginEffects.recover();
|
|
69
|
+
}
|
|
64
70
|
/** Deletes expired staging rows and their objects. */
|
|
65
71
|
async cleanupStaging() {
|
|
66
72
|
const n = await this.imports.cleanupExpired();
|
|
@@ -76,6 +82,9 @@ __decorate([
|
|
|
76
82
|
__decorate([
|
|
77
83
|
LockedInterval(TEMPLATE_CONNECTORS_SWEEP_JOB, () => TEMPLATE_CONNECTORS_SWEEP_PERIOD_MS)
|
|
78
84
|
], CatalogJobs.prototype, "sweepTemplateConnectors", null);
|
|
85
|
+
__decorate([
|
|
86
|
+
LockedInterval("plugin-effect-recovery", () => 10_000)
|
|
87
|
+
], CatalogJobs.prototype, "recoverPluginEffects", null);
|
|
79
88
|
__decorate([
|
|
80
89
|
LockedCron("0 * * * *", { name: PLUGIN_STAGING_CLEANUP_JOB })
|
|
81
90
|
], CatalogJobs.prototype, "cleanupStaging", null);
|
|
@@ -84,8 +93,9 @@ CatalogJobs = __decorate([
|
|
|
84
93
|
__param(0, Inject(MarketplacesService)),
|
|
85
94
|
__param(1, Inject(PluginImport)),
|
|
86
95
|
__param(2, Inject(TemplateConnectorEnsurer)),
|
|
87
|
-
__param(3, Inject(
|
|
88
|
-
__param(4, Inject(
|
|
89
|
-
__param(5, Inject(
|
|
96
|
+
__param(3, Inject(PluginScopeSync)),
|
|
97
|
+
__param(4, Inject(KernelConfigService)),
|
|
98
|
+
__param(5, Inject(LockService)),
|
|
99
|
+
__param(6, Inject(KERNEL_LOGGER))
|
|
90
100
|
], CatalogJobs);
|
|
91
101
|
export { CatalogJobs };
|
|
@@ -119,6 +119,8 @@ export declare class OrgCatalogService {
|
|
|
119
119
|
uninstall(orgId: string, actor: string, installId: string, actorTokenId?: string,
|
|
120
120
|
/** Merged into the audit detail (a write made through the Platform tool). */
|
|
121
121
|
auditDetail?: Record<string, unknown>): Promise<UninstallReport>;
|
|
122
|
+
/** The switch-off impact even when there are no applied org resources. */
|
|
123
|
+
previewContentOff(orgId: string, itemId: string): Promise<UninstallPreview | null>;
|
|
122
124
|
private itemOf;
|
|
123
125
|
/**
|
|
124
126
|
* Writes the org's switch row of the item under the org row lock. The item row is locked FOR
|