@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
|
@@ -9,6 +9,7 @@ import { OrgLock } from "../orgs/org-lock.js";
|
|
|
9
9
|
import { EffectiveConfigs } from "./effective-config.js";
|
|
10
10
|
import { ExtensionHost } from "./host.js";
|
|
11
11
|
import { ExtensionInstalls } from "./installs.js";
|
|
12
|
+
import { PluginInstallLock } from "./locks.js";
|
|
12
13
|
import { type DeploymentExtensionStatus, type PermissionGroup } from "./permission-view.js";
|
|
13
14
|
import { ExtensionAvailability, type ExtensionUnavailableReason } from "./unavailable.js";
|
|
14
15
|
/**
|
|
@@ -55,15 +56,8 @@ export interface OrgExtensionView {
|
|
|
55
56
|
} | null;
|
|
56
57
|
/** The org admin can switch it: never for a required one or a builtin plugin's. */
|
|
57
58
|
switchable: boolean;
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
* `not_installed` for an extension with a plugin path (one catalog plugin, not builtin, not
|
|
61
|
-
* required), null without one (required, config-declared, several sources, builtin). The org's
|
|
62
|
-
* Extensions and Models pages list an extension unless it is `not_installed` and off
|
|
63
|
-
* ({@link listedInOrg}); its switch starts or stops the extension only, and switching on needs
|
|
64
|
-
* the plugin installed (`extension.plugin_not_installed`; extension switch spec 2026-12-02).
|
|
65
|
-
*/
|
|
66
|
-
pluginInstall: "installed" | "not_installed" | null;
|
|
59
|
+
/** Effective intent of the plugin whose switch this extension follows, or null without one. */
|
|
60
|
+
pluginUsable: boolean | null;
|
|
67
61
|
/**
|
|
68
62
|
* The two-level deployment config (spec A §5.3, §5.4): `following` the platform, a `copy` of the
|
|
69
63
|
* overridable fields, or `none` (the extension has no overridable field, or is unavailable).
|
|
@@ -75,13 +69,8 @@ export interface OrgExtensionView {
|
|
|
75
69
|
*/
|
|
76
70
|
needsConfig: boolean;
|
|
77
71
|
}
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
* `extensions.list`) show the extension: everything except one whose plugin is not installed in
|
|
81
|
-
* the org and that is off (the Plugins page installs it; one left on shows, so it can be stopped).
|
|
82
|
-
* The web applies the same rule (`apps/web/src/lib/extensions.ts`).
|
|
83
|
-
*/
|
|
84
|
-
export declare function listedInOrg(view: Pick<OrgExtensionView, "pluginInstall" | "enabled">): boolean;
|
|
72
|
+
/** The management list shows extensions whose bundle is usable or that are independently enabled. */
|
|
73
|
+
export declare function listedInOrg(view: Pick<OrgExtensionView, "pluginUsable" | "enabled">): boolean;
|
|
85
74
|
/** The extension points an extension provides, from its permission list's `provides` group. */
|
|
86
75
|
export declare function providesOf(view: Pick<OrgExtensionView, "permissions">): string[];
|
|
87
76
|
/** The input of `put`: enablement only. */
|
|
@@ -118,12 +107,13 @@ export interface OrgExtensionPutOptions {
|
|
|
118
107
|
auditDetail?: Record<string, unknown>;
|
|
119
108
|
}
|
|
120
109
|
/**
|
|
121
|
-
* Org-level extension
|
|
110
|
+
* Org-level extension intent and the org's view of
|
|
122
111
|
* each extension. OrgOverrides manages the org's copy of overridable deployment fields.
|
|
123
112
|
* EffectiveConfigs validates the config used for org-bound calls. Each replica reads enablement
|
|
124
113
|
* from PostgreSQL.
|
|
125
114
|
*/
|
|
126
115
|
export declare class OrgExtensionConfigs {
|
|
116
|
+
private readonly installLock;
|
|
127
117
|
private readonly kdb;
|
|
128
118
|
readonly txHost: TransactionHost;
|
|
129
119
|
private readonly host;
|
|
@@ -139,7 +129,7 @@ export declare class OrgExtensionConfigs {
|
|
|
139
129
|
private readonly availability;
|
|
140
130
|
/** Owes the org's template connector ensure when an extension is switched on (ruling R27). */
|
|
141
131
|
private readonly outbox;
|
|
142
|
-
constructor(kdb: KernelDb, txHost: TransactionHost, host: ExtensionHost,
|
|
132
|
+
constructor(installLock: PluginInstallLock, kdb: KernelDb, txHost: TransactionHost, host: ExtensionHost,
|
|
143
133
|
/** The org row lock (orgs/org-lock.ts): joins the transaction. */
|
|
144
134
|
orgLock: OrgLock,
|
|
145
135
|
/** Install records (any desired state): the ones not loaded are listed unavailable (T14). */
|
|
@@ -181,9 +171,9 @@ export declare class OrgExtensionConfigs {
|
|
|
181
171
|
* How an `enabled` write of this extension in the org is handled, read before the write (the
|
|
182
172
|
* Platform tool's precheck; {@link put} repeats every rule under the org row lock): `direct`, a
|
|
183
173
|
* write of the extension's own switch (a required bootstrap plugin keeps `extension.required`;
|
|
184
|
-
* the
|
|
174
|
+
* the bundle keeps its intent either way, extension switch spec 2026-12-02 §3.1), `locked` (a live
|
|
185
175
|
* item is builtin and the write switches off: `plugin.scope_locked`), or `not_installed` (switching
|
|
186
|
-
* on an extension whose plugin is
|
|
176
|
+
* on an extension whose plugin is off in the org: `extension.plugin_not_installed`).
|
|
187
177
|
*/
|
|
188
178
|
switchPlan(orgId: string, plugin: string, enabled: boolean): Promise<{
|
|
189
179
|
kind: "direct";
|
|
@@ -199,7 +189,7 @@ export declare class OrgExtensionConfigs {
|
|
|
199
189
|
* - Extension not loaded -> `extension.not_found`; `enabled: false` for a required bootstrap
|
|
200
190
|
* plugin -> `extension.required` (it stays enabled in every org).
|
|
201
191
|
* - Switches the extension only, never its plugin (extension switch spec 2026-12-02 §3.1): with a
|
|
202
|
-
* plugin path ({@link pluginPathItem}) switching on needs the plugin
|
|
192
|
+
* plugin path ({@link pluginPathItem}) switching on needs the plugin usable in the org
|
|
203
193
|
* (`extension.plugin_not_installed`; the install itself passes `viaItem`), and switching off an
|
|
204
194
|
* extension that is off already while its plugin is not installed writes nothing.
|
|
205
195
|
* - Enabling never checks a config: an extension whose effective config is not valid for the org
|
|
@@ -216,8 +206,7 @@ export declare class OrgExtensionConfigs {
|
|
|
216
206
|
*/
|
|
217
207
|
private assertSwitchRules;
|
|
218
208
|
/**
|
|
219
|
-
*
|
|
220
|
-
* its plugin is builtin: `enabled.ts`) is enabled without a row; no row otherwise -> undefined.
|
|
209
|
+
* The extension's committed intent in the org; absent when it is off and has no explicit switch.
|
|
221
210
|
* Inside a caller's transaction it reads in that transaction (it sees the caller's uncommitted
|
|
222
211
|
* writes). The extension's config for the org is its effective config ({@link EffectiveConfigs}).
|
|
223
212
|
*/
|
|
@@ -230,8 +219,9 @@ export declare class OrgExtensionConfigs {
|
|
|
230
219
|
*/
|
|
231
220
|
enabledDependents(orgId: string, plugin: string): Promise<string[]>;
|
|
232
221
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
222
|
+
* Stops the extension during bundle rollback or uninstall under the caller's org lock and
|
|
223
|
+
* authorization. It keeps configuration, skips dependent checks and audits the reason.
|
|
224
|
+
* The caller invokes {@link afterDisable} after commit.
|
|
235
225
|
*/
|
|
236
226
|
disableIn(orgId: string, plugin: string, actorAccountId: string | null, reason: string): Promise<boolean>;
|
|
237
227
|
/** {@link disableIn} 的事务提交之后:通知停用(断开该插件的渠道连接等)。 */
|
|
@@ -252,12 +242,12 @@ export declare class OrgExtensionConfigs {
|
|
|
252
242
|
}
|
|
253
243
|
/**
|
|
254
244
|
* Whether the org may see `plugin` (a required bootstrap plugin always; else under its catalog
|
|
255
|
-
* items'
|
|
245
|
+
* items' visibility).
|
|
256
246
|
* `db` may be a transaction.
|
|
257
247
|
*/
|
|
258
248
|
export declare function extensionVisibleTo(db: KernelSchemaDb, orgId: string, plugin: string): Promise<boolean>;
|
|
259
249
|
/**
|
|
260
|
-
* `extension.plugin_not_installed`: switching on an extension whose plugin is
|
|
250
|
+
* `extension.plugin_not_installed`: switching on an extension whose plugin is off in the
|
|
261
251
|
* org. Names the plugin (details `[{ itemId, plugin }]`). `db` may be a transaction.
|
|
262
252
|
*/
|
|
263
253
|
export declare function pluginNotInstalledError(db: KernelSchemaDb, extension: string, itemId: string): Promise<ApiError>;
|
|
@@ -9,7 +9,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { EXTENSION_POINTS, parseExtensionPoint, } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
|
+
import { orgUsable } from "../catalog/org-intent.js";
|
|
12
13
|
import { assertItemInstallable, assertPluginSourcesInstallable, disabledPluginItems, pluginItemDisabled, } from "../catalog/request-rules.js";
|
|
14
|
+
import { itemsSeenBy, pluginUsable } from "../catalog/scope-state.js";
|
|
15
|
+
import { writeComponentSwitch } from "../catalog/scope-writer.js";
|
|
13
16
|
import { oweTemplateConnectors } from "../catalog/template-connector-jobs.js";
|
|
14
17
|
import { oweHostServicesStop } from "../device-access/host-service-stop.js";
|
|
15
18
|
import { revokeSiteGrantsOfExtension } from "../device-access/site-grants.js";
|
|
@@ -23,21 +26,17 @@ import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
|
23
26
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
24
27
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
25
28
|
import { EffectiveConfigs } from "./effective-config.js";
|
|
26
|
-
import { alwaysOnExtensions, enabledExtensionsQuery, requiredExtensions } from "./enabled.js";
|
|
29
|
+
import { alwaysOnExtensions, enabledExtensionsQuery, extensionSwitch, isExtensionEnabled, requiredExtensions, } from "./enabled.js";
|
|
27
30
|
import { ExtensionHost } from "./host.js";
|
|
28
31
|
import { ExtensionInstalls } from "./installs.js";
|
|
32
|
+
import { PluginInstallLock } from "./locks.js";
|
|
29
33
|
import { fieldLevels } from "./org-levels.js";
|
|
30
34
|
import { permissionGroups, } from "./permission-view.js";
|
|
31
|
-
import { itemLocked,
|
|
35
|
+
import { itemLocked, pluginItemsOf, pluginPathItem, } from "./plugin-items.js";
|
|
32
36
|
import { ExtensionAvailability } from "./unavailable.js";
|
|
33
|
-
/**
|
|
34
|
-
* Whether the org's lists of its extensions (the Extensions page, the Models page's model services,
|
|
35
|
-
* `extensions.list`) show the extension: everything except one whose plugin is not installed in
|
|
36
|
-
* the org and that is off (the Plugins page installs it; one left on shows, so it can be stopped).
|
|
37
|
-
* The web applies the same rule (`apps/web/src/lib/extensions.ts`).
|
|
38
|
-
*/
|
|
37
|
+
/** The management list shows extensions whose bundle is usable or that are independently enabled. */
|
|
39
38
|
export function listedInOrg(view) {
|
|
40
|
-
return view.
|
|
39
|
+
return view.pluginUsable !== false || view.enabled;
|
|
41
40
|
}
|
|
42
41
|
/** The extension points an extension provides, from its permission list's `provides` group. */
|
|
43
42
|
export function providesOf(view) {
|
|
@@ -48,23 +47,24 @@ export function providesOf(view) {
|
|
|
48
47
|
* With several source items, a builtin one locks the extension on (scope `all`); an `all` one does
|
|
49
48
|
* not (layering spec §4).
|
|
50
49
|
*/
|
|
51
|
-
function scopeFields(items, required) {
|
|
52
|
-
const primary = items?.
|
|
50
|
+
function scopeFields(items, required, seen) {
|
|
51
|
+
const primary = items?.find((item) => seen === undefined || seen.has(item.id));
|
|
52
|
+
const locked = required || items?.some(itemLocked) === true;
|
|
53
53
|
if (!primary)
|
|
54
|
-
return { catalogItem: null, switchable: !
|
|
55
|
-
const locked = required || items.some(itemLocked);
|
|
54
|
+
return { catalogItem: null, switchable: !locked };
|
|
56
55
|
return {
|
|
57
56
|
catalogItem: { itemId: primary.id, scope: locked ? "all" : primary.scope },
|
|
58
57
|
switchable: !locked,
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
60
|
/**
|
|
62
|
-
* Org-level extension
|
|
61
|
+
* Org-level extension intent and the org's view of
|
|
63
62
|
* each extension. OrgOverrides manages the org's copy of overridable deployment fields.
|
|
64
63
|
* EffectiveConfigs validates the config used for org-bound calls. Each replica reads enablement
|
|
65
64
|
* from PostgreSQL.
|
|
66
65
|
*/
|
|
67
66
|
let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
67
|
+
installLock;
|
|
68
68
|
kdb;
|
|
69
69
|
txHost;
|
|
70
70
|
host;
|
|
@@ -74,7 +74,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
74
74
|
effective;
|
|
75
75
|
availability;
|
|
76
76
|
outbox;
|
|
77
|
-
constructor(kdb, txHost, host,
|
|
77
|
+
constructor(installLock, kdb, txHost, host,
|
|
78
78
|
/** The org row lock (orgs/org-lock.ts): joins the transaction. */
|
|
79
79
|
orgLock,
|
|
80
80
|
/** Install records (any desired state): the ones not loaded are listed unavailable (T14). */
|
|
@@ -87,6 +87,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
87
87
|
availability,
|
|
88
88
|
/** Owes the org's template connector ensure when an extension is switched on (ruling R27). */
|
|
89
89
|
outbox) {
|
|
90
|
+
this.installLock = installLock;
|
|
90
91
|
this.kdb = kdb;
|
|
91
92
|
this.txHost = txHost;
|
|
92
93
|
this.host = host;
|
|
@@ -158,33 +159,40 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
158
159
|
*/
|
|
159
160
|
async listSnapshot(orgId, installed) {
|
|
160
161
|
const t = this.db;
|
|
161
|
-
const
|
|
162
|
-
.selectFrom("extension_org_configs")
|
|
163
|
-
.select(["plugin", "enabled"])
|
|
164
|
-
.where("org_id", "=", orgId)
|
|
165
|
-
.execute();
|
|
166
|
-
// Required bootstrap plugins and builtin plugins' extensions are listed enabled (no org
|
|
167
|
-
// config row needed, spec §7; enabled.ts)
|
|
162
|
+
const enabled = new Set((await enabledExtensionsQuery(t, orgId).execute()).map((row) => row.plugin));
|
|
168
163
|
const required = await requiredExtensions(t);
|
|
169
|
-
const on = await alwaysOnExtensions(t);
|
|
170
164
|
const loaded = this.host.manifests();
|
|
171
165
|
const items = await pluginItemsOf(t, [
|
|
172
166
|
...loaded.map((m) => m.name),
|
|
173
167
|
...installed.map((i) => i.name),
|
|
174
168
|
]);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
const itemIds = [
|
|
170
|
+
...new Set([...items.values()].flatMap((sources) => sources.map((source) => source.id))),
|
|
171
|
+
];
|
|
172
|
+
const shown = await itemsSeenBy(t, orgId, itemIds, "offered");
|
|
173
|
+
const usable = new Set(itemIds.length === 0
|
|
174
|
+
? []
|
|
175
|
+
: (await t
|
|
176
|
+
.selectFrom("catalog_items")
|
|
177
|
+
.select("id")
|
|
178
|
+
.where("id", "in", itemIds)
|
|
179
|
+
.where(({ ref }) => orgUsable(t, orgId, ref("id")))
|
|
180
|
+
.execute()).map((item) => item.id));
|
|
181
|
+
const followsBundle = (name) => {
|
|
182
|
+
const path = pluginPathItem(items.get(name), required.has(name));
|
|
183
|
+
return path === null ? null : usable.has(path);
|
|
184
|
+
};
|
|
185
|
+
const seen = (name) => {
|
|
186
|
+
if (required.has(name))
|
|
187
|
+
return true;
|
|
188
|
+
const sources = items.get(name);
|
|
189
|
+
return (sources === undefined ||
|
|
190
|
+
(sources.some((source) => shown.has(source.id)) &&
|
|
191
|
+
(enabled.has(name) || sources.every((source) => !source.disabled))));
|
|
192
|
+
};
|
|
185
193
|
const views = loaded
|
|
186
194
|
.filter((m) => seen(m.name))
|
|
187
|
-
.map((m) => this.view(m,
|
|
195
|
+
.map((m) => this.view(m, enabled.has(m.name), required.has(m.name), items.get(m.name), followsBundle(m.name), shown));
|
|
188
196
|
const names = new Set(loaded.map((m) => m.name));
|
|
189
197
|
const unavailable = installed
|
|
190
198
|
.filter((i) => !names.has(i.name) && seen(i.name))
|
|
@@ -192,7 +200,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
192
200
|
.map((i) => ({
|
|
193
201
|
plugin: i.name,
|
|
194
202
|
version: i.version,
|
|
195
|
-
enabled:
|
|
203
|
+
enabled: enabled.has(i.name),
|
|
196
204
|
configurable: false,
|
|
197
205
|
permissions: [],
|
|
198
206
|
available: false,
|
|
@@ -200,8 +208,8 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
200
208
|
status: "converging",
|
|
201
209
|
reason: "loading",
|
|
202
210
|
required: required.has(i.name),
|
|
203
|
-
...scopeFields(items.get(i.name), required.has(i.name)),
|
|
204
|
-
|
|
211
|
+
...scopeFields(items.get(i.name), required.has(i.name), shown),
|
|
212
|
+
pluginUsable: followsBundle(i.name),
|
|
205
213
|
overrideState: "none",
|
|
206
214
|
needsConfig: false,
|
|
207
215
|
}));
|
|
@@ -211,9 +219,9 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
211
219
|
* How an `enabled` write of this extension in the org is handled, read before the write (the
|
|
212
220
|
* Platform tool's precheck; {@link put} repeats every rule under the org row lock): `direct`, a
|
|
213
221
|
* write of the extension's own switch (a required bootstrap plugin keeps `extension.required`;
|
|
214
|
-
* the
|
|
222
|
+
* the bundle keeps its intent either way, extension switch spec 2026-12-02 §3.1), `locked` (a live
|
|
215
223
|
* item is builtin and the write switches off: `plugin.scope_locked`), or `not_installed` (switching
|
|
216
|
-
* on an extension whose plugin is
|
|
224
|
+
* on an extension whose plugin is off in the org: `extension.plugin_not_installed`).
|
|
217
225
|
*/
|
|
218
226
|
async switchPlan(orgId, plugin, enabled) {
|
|
219
227
|
const t = this.db;
|
|
@@ -228,7 +236,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
228
236
|
const itemId = pluginPathItem(items, required);
|
|
229
237
|
if (!enabled || itemId === null)
|
|
230
238
|
return { kind: "direct" };
|
|
231
|
-
return (await
|
|
239
|
+
return (await pluginUsable(t, orgId, itemId))
|
|
232
240
|
? { kind: "direct" }
|
|
233
241
|
: { kind: "not_installed", itemId };
|
|
234
242
|
}
|
|
@@ -238,7 +246,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
238
246
|
* - Extension not loaded -> `extension.not_found`; `enabled: false` for a required bootstrap
|
|
239
247
|
* plugin -> `extension.required` (it stays enabled in every org).
|
|
240
248
|
* - Switches the extension only, never its plugin (extension switch spec 2026-12-02 §3.1): with a
|
|
241
|
-
* plugin path ({@link pluginPathItem}) switching on needs the plugin
|
|
249
|
+
* plugin path ({@link pluginPathItem}) switching on needs the plugin usable in the org
|
|
242
250
|
* (`extension.plugin_not_installed`; the install itself passes `viaItem`), and switching off an
|
|
243
251
|
* extension that is off already while its plugin is not installed writes nothing.
|
|
244
252
|
* - Enabling never checks a config: an extension whose effective config is not valid for the org
|
|
@@ -254,46 +262,44 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
254
262
|
async write(orgId, plugin, manifest, input, actorAccountId, actorTokenId, opts) {
|
|
255
263
|
const t = this.db;
|
|
256
264
|
await this.orgLock.lockFor(orgId, actorAccountId, "org.extensions.manage");
|
|
257
|
-
|
|
258
|
-
.
|
|
259
|
-
|
|
260
|
-
.where("plugin", "=", plugin)
|
|
261
|
-
.where("org_id", "=", orgId)
|
|
262
|
-
.executeTakeFirst();
|
|
265
|
+
if (opts.viaItem === undefined)
|
|
266
|
+
await this.installLock.shared(plugin);
|
|
267
|
+
const row = await extensionSwitch(t, orgId, plugin).executeTakeFirst();
|
|
263
268
|
const required = (await requiredExtensions(t)).has(plugin);
|
|
264
|
-
|
|
265
|
-
const on = required || (await alwaysOnExtensions(t)).has(plugin);
|
|
269
|
+
const locked = required || (await alwaysOnExtensions(t)).has(plugin);
|
|
266
270
|
const item = (await pluginItemsOf(t, [plugin])).get(plugin);
|
|
271
|
+
const before = await isExtensionEnabled(t, orgId, plugin);
|
|
267
272
|
if (required && input.enabled === false)
|
|
268
273
|
throw requiredError(plugin);
|
|
269
|
-
if (
|
|
274
|
+
if (locked && input.enabled === false)
|
|
270
275
|
throw scopeLockedError();
|
|
271
|
-
// The org's live installs matter only to an extension with a plugin path
|
|
272
276
|
const pathItem = pluginPathItem(item, required);
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
const bundleUsable = pathItem === null ? null : await pluginUsable(t, orgId, pathItem);
|
|
278
|
+
const snapshot = () => this.view(manifest, before, required, item, bundleUsable);
|
|
279
|
+
if (opts.viaItem !== undefined) {
|
|
280
|
+
// A bundle applies effects. The org's extension choice belongs to its own switch.
|
|
281
|
+
if (locked || pathItem !== opts.viaItem || row?.enabled === false) {
|
|
282
|
+
if (opts.ifDisabled)
|
|
283
|
+
opts.ifDisabled.skipped = true;
|
|
284
|
+
return snapshot();
|
|
285
|
+
}
|
|
286
|
+
await this.assertSwitchRules(t, orgId, manifest, input, before, locked, opts);
|
|
287
|
+
await oweTemplateConnectors(this.outbox, t, orgId);
|
|
288
|
+
return snapshot();
|
|
277
289
|
}
|
|
278
|
-
|
|
279
|
-
|
|
290
|
+
if (input.enabled === true && !before && (item ?? []).some((source) => source.disabled)) {
|
|
291
|
+
throw pluginItemDisabled([plugin]);
|
|
292
|
+
}
|
|
293
|
+
if (!locked && pathItem !== null && !before && bundleUsable === false) {
|
|
280
294
|
if (input.enabled === true)
|
|
281
295
|
throw await pluginNotInstalledError(t, plugin, pathItem);
|
|
282
|
-
|
|
283
|
-
return this.view(manifest, row, required, item, on, live);
|
|
296
|
+
return snapshot();
|
|
284
297
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
await this.assertSwitchRules(t, orgId, manifest, input,
|
|
288
|
-
await t
|
|
289
|
-
|
|
290
|
-
.values({ plugin, org_id: orgId, enabled, updated_by: actorAccountId })
|
|
291
|
-
.onConflict((oc) => oc.columns(["plugin", "org_id"]).doUpdateSet({
|
|
292
|
-
enabled,
|
|
293
|
-
updated_by: actorAccountId,
|
|
294
|
-
updated_at: new Date(),
|
|
295
|
-
}))
|
|
296
|
-
.execute();
|
|
298
|
+
if (input.enabled === undefined || locked)
|
|
299
|
+
return snapshot();
|
|
300
|
+
await this.assertSwitchRules(t, orgId, manifest, input, before, locked, opts);
|
|
301
|
+
await writeComponentSwitch(t, { kind: "extension", id: plugin }, orgId, input.enabled, actorAccountId);
|
|
302
|
+
const enabled = await isExtensionEnabled(t, orgId, plugin);
|
|
297
303
|
if (!enabled) {
|
|
298
304
|
await revokeSiteGrantsOfExtension(t, { orgId, extensionName: plugin });
|
|
299
305
|
// its host services on the org's machines stop (local agents spec, call 5)
|
|
@@ -302,7 +308,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
302
308
|
// Switched on: it may provide the connector kind of a template whose plugin is installed in
|
|
303
309
|
// the org without its connector; a worker creates the connectors it never had, once the
|
|
304
310
|
// extension is loaded there (ruling R27)
|
|
305
|
-
if (
|
|
311
|
+
if (enabled && !before) {
|
|
306
312
|
await oweTemplateConnectors(this.outbox, t, orgId);
|
|
307
313
|
}
|
|
308
314
|
await audit(t, {
|
|
@@ -317,7 +323,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
317
323
|
...opts.auditDetail,
|
|
318
324
|
},
|
|
319
325
|
});
|
|
320
|
-
const view = this.view(manifest,
|
|
326
|
+
const view = this.view(manifest, enabled, required, item, bundleUsable);
|
|
321
327
|
// Only once the root transaction committed (an outer caller's too): a rolled-back write
|
|
322
328
|
// disconnects nothing
|
|
323
329
|
afterCommit(async () => {
|
|
@@ -330,14 +336,14 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
330
336
|
* re-checks the item policy and grants (C22; one already enabled is unaffected), enabling needs
|
|
331
337
|
* the dependencies enabled, disabling (without `force`) no enabled dependents.
|
|
332
338
|
*/
|
|
333
|
-
async assertSwitchRules(t, orgId, manifest, input,
|
|
339
|
+
async assertSwitchRules(t, orgId, manifest, input, enabledBefore, alwaysOn, opts) {
|
|
334
340
|
const plugin = manifest.name;
|
|
335
|
-
if (input.enabled === true &&
|
|
336
|
-
//
|
|
341
|
+
if (input.enabled === true && !enabledBefore && !alwaysOn) {
|
|
342
|
+
// Deployment disable prevents every new enable (ruling M-5).
|
|
337
343
|
const killed = await disabledPluginItems(t, [plugin]);
|
|
338
344
|
if (killed.length > 0)
|
|
339
345
|
throw pluginItemDisabled(killed);
|
|
340
|
-
//
|
|
346
|
+
// Bundle installs use that source's policy. Direct enables enforce every source's policy.
|
|
341
347
|
if (opts.viaItem !== undefined) {
|
|
342
348
|
await assertItemInstallable(t, orgId, opts.viaItem, opts.approvedBy ?? opts.viaItem);
|
|
343
349
|
}
|
|
@@ -351,24 +357,18 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
351
357
|
}
|
|
352
358
|
}
|
|
353
359
|
/**
|
|
354
|
-
*
|
|
355
|
-
* its plugin is builtin: `enabled.ts`) is enabled without a row; no row otherwise -> undefined.
|
|
360
|
+
* The extension's committed intent in the org; absent when it is off and has no explicit switch.
|
|
356
361
|
* Inside a caller's transaction it reads in that transaction (it sees the caller's uncommitted
|
|
357
362
|
* writes). The extension's config for the org is its effective config ({@link EffectiveConfigs}).
|
|
358
363
|
*/
|
|
359
364
|
async get(orgId, plugin) {
|
|
360
365
|
this.manifest(plugin);
|
|
361
366
|
const t = this.db;
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
.executeTakeFirst();
|
|
368
|
-
const on = (await alwaysOnExtensions(t)).has(plugin);
|
|
369
|
-
if (!row && !on)
|
|
370
|
-
return undefined;
|
|
371
|
-
return { enabled: on || row?.enabled === true };
|
|
367
|
+
const enabled = await isExtensionEnabled(t, orgId, plugin);
|
|
368
|
+
if (enabled)
|
|
369
|
+
return { enabled };
|
|
370
|
+
const row = await extensionSwitch(t, orgId, plugin).executeTakeFirst();
|
|
371
|
+
return row === undefined ? undefined : { enabled };
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
374
|
* 该组织里已启用、且所 requires 的按组织启用的能力只剩这个插件提供的插件(停用它会让它们失去依赖)。
|
|
@@ -399,23 +399,16 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
399
399
|
return [...out].sort();
|
|
400
400
|
}
|
|
401
401
|
/**
|
|
402
|
-
*
|
|
403
|
-
*
|
|
402
|
+
* Stops the extension during bundle rollback or uninstall under the caller's org lock and
|
|
403
|
+
* authorization. It keeps configuration, skips dependent checks and audits the reason.
|
|
404
|
+
* The caller invokes {@link afterDisable} after commit.
|
|
404
405
|
*/
|
|
405
406
|
async disableIn(orgId, plugin, actorAccountId, reason) {
|
|
406
407
|
const t = this.db;
|
|
407
|
-
|
|
408
|
-
if ((await alwaysOnExtensions(t)).has(plugin))
|
|
408
|
+
if (await isExtensionEnabled(t, orgId, plugin))
|
|
409
409
|
return false;
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
.set({ enabled: false, updated_by: actorAccountId, updated_at: new Date() })
|
|
413
|
-
.where("plugin", "=", plugin)
|
|
414
|
-
.where("org_id", "=", orgId)
|
|
415
|
-
.where("enabled", "=", true)
|
|
416
|
-
.returning("plugin")
|
|
417
|
-
.executeTakeFirst();
|
|
418
|
-
if (!r)
|
|
410
|
+
const row = await extensionSwitch(t, orgId, plugin).executeTakeFirst();
|
|
411
|
+
if (row?.enabled === false)
|
|
419
412
|
return false;
|
|
420
413
|
await revokeSiteGrantsOfExtension(t, { orgId, extensionName: plugin });
|
|
421
414
|
await oweHostServicesStop(t, this.outbox, { orgId, extension: plugin });
|
|
@@ -497,23 +490,19 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
|
|
|
497
490
|
throw new ApiError("extension.not_found", `Extension ${plugin} is not installed`);
|
|
498
491
|
return set;
|
|
499
492
|
}
|
|
500
|
-
view(m,
|
|
501
|
-
/** Always on in every org (enabled.ts): required, or its plugin is builtin. */
|
|
502
|
-
alwaysOn,
|
|
503
|
-
/** The items with a live install in the org ({@link liveInstalledItems}). */
|
|
504
|
-
liveItems) {
|
|
493
|
+
view(m, enabled, required, items, bundleUsable, seen) {
|
|
505
494
|
const configurable = [...fieldLevels(m.config?.deployment).values()].includes("override");
|
|
506
495
|
return {
|
|
507
496
|
plugin: m.name,
|
|
508
497
|
version: m.version,
|
|
509
|
-
enabled
|
|
498
|
+
enabled,
|
|
510
499
|
configurable,
|
|
511
500
|
permissions: permissionGroups(this.permissionsOf(m.name)),
|
|
512
501
|
available: true,
|
|
513
502
|
status: "enabled",
|
|
514
503
|
required,
|
|
515
|
-
...scopeFields(items, required),
|
|
516
|
-
|
|
504
|
+
...scopeFields(items, required, seen),
|
|
505
|
+
pluginUsable: bundleUsable,
|
|
517
506
|
// filled in by `withLayers` (the copy rows and the effective config)
|
|
518
507
|
overrideState: configurable ? "following" : "none",
|
|
519
508
|
needsConfig: false,
|
|
@@ -538,20 +527,21 @@ __decorate([
|
|
|
538
527
|
], OrgExtensionConfigs.prototype, "disableIn", null);
|
|
539
528
|
OrgExtensionConfigs = __decorate([
|
|
540
529
|
Injectable(),
|
|
541
|
-
__param(0, Inject(
|
|
542
|
-
__param(1, Inject(
|
|
543
|
-
__param(2, Inject(
|
|
544
|
-
__param(3, Inject(
|
|
545
|
-
__param(4, Inject(
|
|
546
|
-
__param(5, Inject(
|
|
547
|
-
__param(6, Inject(
|
|
548
|
-
__param(7, Inject(
|
|
549
|
-
__param(8, Inject(
|
|
530
|
+
__param(0, Inject(PluginInstallLock)),
|
|
531
|
+
__param(1, Inject(KernelDb)),
|
|
532
|
+
__param(2, Inject(TransactionHost)),
|
|
533
|
+
__param(3, Inject(ExtensionHost)),
|
|
534
|
+
__param(4, Inject(OrgLock)),
|
|
535
|
+
__param(5, Inject(ExtensionInstalls)),
|
|
536
|
+
__param(6, Inject(KernelEvents)),
|
|
537
|
+
__param(7, Inject(EffectiveConfigs)),
|
|
538
|
+
__param(8, Inject(ExtensionAvailability)),
|
|
539
|
+
__param(9, Inject(OutboxService))
|
|
550
540
|
], OrgExtensionConfigs);
|
|
551
541
|
export { OrgExtensionConfigs };
|
|
552
542
|
/**
|
|
553
543
|
* Whether the org may see `plugin` (a required bootstrap plugin always; else under its catalog
|
|
554
|
-
* items'
|
|
544
|
+
* items' visibility).
|
|
555
545
|
* `db` may be a transaction.
|
|
556
546
|
*/
|
|
557
547
|
export async function extensionVisibleTo(db, orgId, plugin) {
|
|
@@ -560,17 +550,12 @@ export async function extensionVisibleTo(db, orgId, plugin) {
|
|
|
560
550
|
const items = (await pluginItemsOf(db, [plugin])).get(plugin);
|
|
561
551
|
if (!items)
|
|
562
552
|
return true;
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
.select("item_id")
|
|
566
|
-
.where("org_id", "=", orgId)
|
|
567
|
-
.where("item_id", "in", items.map((i) => i.id))
|
|
568
|
-
.execute()).map((r) => r.item_id));
|
|
569
|
-
return itemsVisible(items, listed);
|
|
553
|
+
const visible = await itemsSeenBy(db, orgId, items.map((item) => item.id), "offered");
|
|
554
|
+
return visible.size > 0;
|
|
570
555
|
}
|
|
571
556
|
const scopeLockedError = () => new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be switched off here");
|
|
572
557
|
/**
|
|
573
|
-
* `extension.plugin_not_installed`: switching on an extension whose plugin is
|
|
558
|
+
* `extension.plugin_not_installed`: switching on an extension whose plugin is off in the
|
|
574
559
|
* org. Names the plugin (details `[{ itemId, plugin }]`). `db` may be a transaction.
|
|
575
560
|
*/
|
|
576
561
|
export async function pluginNotInstalledError(db, extension, itemId) {
|
|
@@ -580,6 +565,6 @@ export async function pluginNotInstalledError(db, extension, itemId) {
|
|
|
580
565
|
.where("id", "=", itemId)
|
|
581
566
|
.executeTakeFirst();
|
|
582
567
|
const name = item?.name ?? extension;
|
|
583
|
-
return new ApiError("extension.plugin_not_installed", `Extension ${extension} comes with the plugin ${name}, which is
|
|
568
|
+
return new ApiError("extension.plugin_not_installed", `Extension ${extension} comes with the plugin ${name}, which is off in this organization. Turn on ${name} on the Plugins page first`, [{ itemId, plugin: name }]);
|
|
584
569
|
}
|
|
585
570
|
const requiredError = (plugin) => new ApiError("extension.required", `Extension ${plugin} is required by this deployment (a bootstrap plugin): it is enabled in every organization and cannot be disabled`);
|
|
@@ -149,7 +149,7 @@ export interface AdminExtensionView {
|
|
|
149
149
|
/** The scope of the catalog plugin the extension ships in (builtin: `all`); null without one. */
|
|
150
150
|
scope: PluginScope | null;
|
|
151
151
|
/** Orgs where the extension is enabled (a required plugin: every org). */
|
|
152
|
-
enabledOrgs
|
|
152
|
+
enabledOrgs?: number;
|
|
153
153
|
/** Shipped with the deployment (a builtin plugin or a required bootstrap plugin). */
|
|
154
154
|
builtin: boolean;
|
|
155
155
|
/** Where the install record came from (`bootstrap` for the bootstrap step); null for config-declared. */
|
|
@@ -296,3 +296,8 @@ export interface PackageWarning {
|
|
|
296
296
|
/** 语句(压成一行,字符串字面量已抹掉)。 */
|
|
297
297
|
statement: string;
|
|
298
298
|
}
|
|
299
|
+
export interface ExtensionOrgCounts {
|
|
300
|
+
name: string;
|
|
301
|
+
enabledOrgs: number;
|
|
302
|
+
orgsNeedingConfig?: number;
|
|
303
|
+
}
|
|
@@ -108,9 +108,10 @@ type VersionFile = {
|
|
|
108
108
|
sha256: string;
|
|
109
109
|
};
|
|
110
110
|
/** The live items (with their latest version) by name or id. */
|
|
111
|
-
declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[]
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[], org?: {
|
|
112
|
+
orgId: string;
|
|
113
|
+
role: OrgRole;
|
|
114
|
+
}): Promise<{
|
|
114
115
|
files: {
|
|
115
116
|
path: string;
|
|
116
117
|
size: number;
|
|
@@ -120,10 +121,6 @@ declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[]): P
|
|
|
120
121
|
latest_version: string;
|
|
121
122
|
manifest: unknown;
|
|
122
123
|
name: string;
|
|
123
|
-
owner_org_id: string | null;
|
|
124
|
-
scope: "all" | "named" | "optional";
|
|
125
|
-
shareable: boolean;
|
|
126
|
-
shown_to_others: boolean;
|
|
127
124
|
}[]>;
|
|
128
125
|
/** A live item with its latest version, as {@link PluginGuides} reads it. */
|
|
129
126
|
export type ItemRow = Awaited<ReturnType<typeof latestItems>>[number];
|
|
@@ -137,7 +134,7 @@ export declare const templateGuideOf: (manifest: unknown, templateId: string) =>
|
|
|
137
134
|
* catalog item (the item of the same name, its latest version), renders a guide document for a
|
|
138
135
|
* place, audience, mode and target with the place's safe variables (`guide-places.ts`; never a
|
|
139
136
|
* secret), and computes the drift hashes targets record to tell when an upgrade changed their
|
|
140
|
-
* setup. Org reads follow the catalog icon's visibility ({@link
|
|
137
|
+
* setup. Org reads follow the catalog icon's visibility ({@link orgSees}), the platform
|
|
141
138
|
* preview any live item. Stateless: everything comes from PG (version rows, target rows, the
|
|
142
139
|
* documents in `catalog_files`).
|
|
143
140
|
*/
|
|
@@ -147,8 +144,6 @@ export declare class PluginGuides {
|
|
|
147
144
|
private readonly log;
|
|
148
145
|
constructor(db: KernelDb, config: Pick<KernelConfigService, "get">, log: Pick<KernelLogger, "warn">);
|
|
149
146
|
private latest;
|
|
150
|
-
/** The rows the org's catalog shows ({@link orgVisibleItems}); all of them without an org. */
|
|
151
|
-
private visibleTo;
|
|
152
147
|
/** The English documents of guides, by `<itemId>/<guideId>` (one PG read); absent when not stored. */
|
|
153
148
|
private englishSources;
|
|
154
149
|
/** The admin drift hash of a guide for a mode. */
|