@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +27 -3
- package/dist/admin/admin.controller.d.ts +8 -72
- package/dist/admin/admin.controller.js +21 -46
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +13 -5
- package/dist/agents/agents.service.js +67 -13
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +20 -3
- package/dist/agents/models.controller.d.ts +1 -2
- package/dist/agents/models.controller.js +1 -1
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +9 -1
- package/dist/conversations/conversations.service.js +23 -18
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/db/kernel-schema.d.ts +20 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +13 -0
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +6 -6
- package/dist/evals/runs.service.js +32 -18
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +33 -2
- package/dist/extensions/host.js +107 -1
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +14 -0
- package/dist/identity/me.controller.js +39 -1
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/enablement.d.ts +2 -0
- package/dist/models/enablement.js +1 -0
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +12 -2
- package/dist/models/purposes.js +22 -8
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +68 -849
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +62 -7
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin.ops.d.ts +36 -0
- package/dist/platform/ops/admin.ops.js +389 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
- package/dist/platform/ops/agent-skills.ops.js +226 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
- package/dist/platform/ops/agent-templates.ops.js +194 -14
- package/dist/platform/ops/agents.ops.d.ts +19 -1
- package/dist/platform/ops/agents.ops.js +481 -58
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
- package/dist/platform/ops/catalog-admin.ops.js +587 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +853 -0
- package/dist/platform/ops/connectors.ops.d.ts +4 -2
- package/dist/platform/ops/connectors.ops.js +68 -6
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/environments.ops.d.ts +26 -0
- package/dist/platform/ops/environments.ops.js +289 -0
- package/dist/platform/ops/errors.d.ts +10 -5
- package/dist/platform/ops/errors.js +19 -11
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +344 -0
- package/dist/platform/ops/extensions.ops.d.ts +7 -1
- package/dist/platform/ops/extensions.ops.js +248 -17
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +378 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
- package/dist/platform/ops/marketplaces.ops.js +326 -17
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
- package/dist/platform/ops/org-plugins.ops.js +329 -0
- package/dist/platform/ops/org-settings.ops.d.ts +16 -0
- package/dist/platform/ops/org-settings.ops.js +102 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +295 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/platform.ops.d.ts +4 -4
- package/dist/platform/ops/platform.ops.js +23 -24
- package/dist/platform/ops/plugins.ops.d.ts +10 -8
- package/dist/platform/ops/plugins.ops.js +176 -77
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.js +57 -19
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +129 -11
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +111 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +32 -0
- package/dist/platform/platform-ops.module.js +78 -11
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +60 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/model-call.js +2 -1
- package/dist/runtime/providers.js +8 -1
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +5 -0
- package/dist/runtime/run-worker.js +31 -6
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +46 -115
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +3 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -4,14 +4,16 @@ import { OrgCatalogService } from "../../catalog/org-catalog.service.js";
|
|
|
4
4
|
import { PluginInstaller } from "../../catalog/plugin-install.js";
|
|
5
5
|
import { PlatformPluginUpdater } from "../../catalog/plugin-upgrade.js";
|
|
6
6
|
import { OrgExtensionConfigs } from "../../extensions/org-config.js";
|
|
7
|
+
import { ExtensionAvailability } from "../../extensions/unavailable.js";
|
|
7
8
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
8
9
|
import { PlatformOperations } from "../registry.js";
|
|
9
|
-
export
|
|
10
|
+
export { OTHER_ORG } from "./other-orgs.js";
|
|
10
11
|
export declare const NEEDS_INPUT = "This plugin needs configuration a person must enter; ask them to enable it on the \u63D2\u4EF6 page.";
|
|
11
12
|
/**
|
|
12
13
|
* Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
|
|
13
14
|
* and the super admin's platform view (list, get, update with its preview). Every platform result
|
|
14
|
-
*
|
|
15
|
+
* shows the admin console's data in full for platform items and the org's own (spec §14.5 item 1);
|
|
16
|
+
* plugins other orgs own are only counted, and reading or updating one is refused.
|
|
15
17
|
*/
|
|
16
18
|
export declare class PluginsOperations implements OnModuleInit {
|
|
17
19
|
private readonly registry;
|
|
@@ -21,13 +23,13 @@ export declare class PluginsOperations implements OnModuleInit {
|
|
|
21
23
|
private readonly installer;
|
|
22
24
|
private readonly extensions;
|
|
23
25
|
private readonly kdb;
|
|
24
|
-
|
|
26
|
+
private readonly availability;
|
|
27
|
+
constructor(registry: PlatformOperations, orgCatalog: OrgCatalogService, catalog: CatalogService, updater: PlatformPluginUpdater, installer: PluginInstaller, extensions: OrgExtensionConfigs, kdb: KernelDb, availability: ExtensionAvailability);
|
|
25
28
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
29
|
+
* Installed (or builtin) plugins whose extension stopped loading: the reason, keyed by plugin
|
|
30
|
+
* name. Their state stays (`on` / `needs_config`) so an org admin can still switch them off;
|
|
31
|
+
* the reason and next step tell why the plugin does nothing now.
|
|
28
32
|
*/
|
|
29
|
-
private
|
|
30
|
-
/** How many live catalog items other orgs own (left out of the platform list). */
|
|
31
|
-
private otherOrgItems;
|
|
33
|
+
private stopped;
|
|
32
34
|
onModuleInit(): void;
|
|
33
35
|
}
|
|
@@ -10,37 +10,56 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { ToolError } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { z } from "zod";
|
|
13
|
+
import { CatalogIdPathParams, CatalogUpdateBody } from "../../catalog/admin-catalog.schemas.js";
|
|
13
14
|
import { CatalogService } from "../../catalog/catalog.service.js";
|
|
15
|
+
import { CatalogItemPathParams } from "../../catalog/org-catalog.schemas.js";
|
|
14
16
|
import { OrgCatalogService } from "../../catalog/org-catalog.service.js";
|
|
15
17
|
import { PluginInstaller, uninstallPreviewHash } from "../../catalog/plugin-install.js";
|
|
16
18
|
import { PlatformPluginUpdater } from "../../catalog/plugin-upgrade.js";
|
|
17
19
|
import { OrgExtensionConfigs } from "../../extensions/org-config.js";
|
|
20
|
+
import { ExtensionAvailability } from "../../extensions/unavailable.js";
|
|
18
21
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
19
22
|
import { defineOperation } from "../operation.js";
|
|
20
|
-
import { redactOrgs } from "../redact-orgs.js";
|
|
21
23
|
import { PlatformOperations } from "../registry.js";
|
|
22
|
-
import {
|
|
24
|
+
import { viaAgent } from "./errors.js";
|
|
25
|
+
import { assertNotOtherOrgs, otherOrgItems } from "./other-orgs.js";
|
|
23
26
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
24
27
|
import { localized } from "./summary.js";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
+
import { roleFor, unavailableFields, unavailableMessage, unavailableNext } from "./unavailable.js";
|
|
29
|
+
/** An org catalog item id (`:itemId` of the org routes). */
|
|
30
|
+
const ItemId = CatalogItemPathParams.shape.itemId.max(100);
|
|
31
|
+
/** A platform catalog item id (`:id` of the admin routes), named `itemId` like the org's. */
|
|
32
|
+
const PlatformItemId = CatalogIdPathParams.shape.id.max(100);
|
|
33
|
+
const Version = CatalogUpdateBody.shape.version.max(100);
|
|
34
|
+
/** The switch-off confirm: the uninstall preview's hash, or `nothing-installed`. */
|
|
35
|
+
const Confirm = z.string().min(1).max(200);
|
|
28
36
|
/** Entries per page of the paged lists (the tool caps a bare list at 50). */
|
|
29
37
|
const PAGE = 50;
|
|
30
38
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
31
|
-
export
|
|
39
|
+
export { OTHER_ORG } from "./other-orgs.js";
|
|
32
40
|
const LOCKED = "This plugin is on for every org (or shipped with the platform) and cannot be switched off in one org.";
|
|
33
41
|
/** The confirm value of switching off a plugin with nothing installed in the org. */
|
|
34
42
|
const NOTHING_INSTALLED = "nothing-installed";
|
|
35
43
|
export const NEEDS_INPUT = "This plugin needs configuration a person must enter; ask them to enable it on the 插件 page.";
|
|
36
|
-
/**
|
|
37
|
-
const
|
|
44
|
+
/** The English name of a plugin as next steps and messages name it. */
|
|
45
|
+
const enName = (i) => localized(i.displayName, i.name).en;
|
|
46
|
+
/** The item with the reason its extension stopped loading (state unchanged), when it has one. */
|
|
47
|
+
const withStopped = (i, stopped) => {
|
|
48
|
+
const reason = i.reason ?? stopped.get(i.name);
|
|
49
|
+
return reason === undefined ? i : { ...i, reason };
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* An org's view of a plugin (`plugins.get`): the state, and when unavailable the reason and the
|
|
53
|
+
* actor's next step (spec §14.2 problem 4: one call decides it).
|
|
54
|
+
*/
|
|
55
|
+
const brief = (i, role) => ({
|
|
38
56
|
id: i.id,
|
|
39
57
|
name: i.name,
|
|
40
58
|
displayName: i.displayName,
|
|
41
59
|
description: i.description,
|
|
42
60
|
scope: i.scope,
|
|
43
61
|
state: i.state,
|
|
62
|
+
...unavailableFields(i.reason, enName(i), role),
|
|
44
63
|
switchable: i.switchable,
|
|
45
64
|
builtin: i.builtin,
|
|
46
65
|
notDeployed: i.notDeployed,
|
|
@@ -50,6 +69,16 @@ const brief = (i) => ({
|
|
|
50
69
|
owner: i.owner,
|
|
51
70
|
request: i.request,
|
|
52
71
|
});
|
|
72
|
+
/** A plugin as `plugins.list` shows it: a compact row; the rest comes from `plugins.get`. */
|
|
73
|
+
const row = (i, role) => ({
|
|
74
|
+
id: i.id,
|
|
75
|
+
name: i.name,
|
|
76
|
+
state: i.state,
|
|
77
|
+
...unavailableFields(i.reason, enName(i), role),
|
|
78
|
+
displayName: i.displayName,
|
|
79
|
+
switchable: i.switchable,
|
|
80
|
+
request: i.request,
|
|
81
|
+
});
|
|
53
82
|
const hasConfigFields = (schema) => {
|
|
54
83
|
const props = schema?.properties;
|
|
55
84
|
return typeof props === "object" && props !== null && Object.keys(props).length > 0;
|
|
@@ -74,7 +103,8 @@ function needsInput(item, extensions) {
|
|
|
74
103
|
/**
|
|
75
104
|
* Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
|
|
76
105
|
* and the super admin's platform view (list, get, update with its preview). Every platform result
|
|
77
|
-
*
|
|
106
|
+
* shows the admin console's data in full for platform items and the org's own (spec §14.5 item 1);
|
|
107
|
+
* plugins other orgs own are only counted, and reading or updating one is refused.
|
|
78
108
|
*/
|
|
79
109
|
let PluginsOperations = class PluginsOperations {
|
|
80
110
|
registry;
|
|
@@ -84,7 +114,8 @@ let PluginsOperations = class PluginsOperations {
|
|
|
84
114
|
installer;
|
|
85
115
|
extensions;
|
|
86
116
|
kdb;
|
|
87
|
-
|
|
117
|
+
availability;
|
|
118
|
+
constructor(registry, orgCatalog, catalog, updater, installer, extensions, kdb, availability) {
|
|
88
119
|
this.registry = registry;
|
|
89
120
|
this.orgCatalog = orgCatalog;
|
|
90
121
|
this.catalog = catalog;
|
|
@@ -92,52 +123,49 @@ let PluginsOperations = class PluginsOperations {
|
|
|
92
123
|
this.installer = installer;
|
|
93
124
|
this.extensions = extensions;
|
|
94
125
|
this.kdb = kdb;
|
|
126
|
+
this.availability = availability;
|
|
95
127
|
}
|
|
96
128
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
129
|
+
* Installed (or builtin) plugins whose extension stopped loading: the reason, keyed by plugin
|
|
130
|
+
* name. Their state stays (`on` / `needs_config`) so an org admin can still switch them off;
|
|
131
|
+
* the reason and next step tell why the plugin does nothing now.
|
|
99
132
|
*/
|
|
100
|
-
async
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/** How many live catalog items other orgs own (left out of the platform list). */
|
|
112
|
-
async otherOrgItems(orgId) {
|
|
113
|
-
const r = await this.kdb.db
|
|
114
|
-
.selectFrom("catalog_items")
|
|
115
|
-
.select((eb) => eb.fn.countAll().as("n"))
|
|
116
|
-
.where("deleted_at", "is", null)
|
|
117
|
-
.where("owner_org_id", "is not", null)
|
|
118
|
-
.where("owner_org_id", "!=", orgId)
|
|
119
|
-
.executeTakeFirstOrThrow();
|
|
120
|
-
return Number(r.n);
|
|
133
|
+
async stopped(items) {
|
|
134
|
+
const names = items
|
|
135
|
+
.filter((i) => i.reason === undefined &&
|
|
136
|
+
i.componentCounts.extension > 0 &&
|
|
137
|
+
(i.installed !== null || i.builtin))
|
|
138
|
+
// a plugin's extension carries the plugin's name
|
|
139
|
+
.map((i) => i.name);
|
|
140
|
+
const out = new Map();
|
|
141
|
+
for (const [name, u] of await this.availability.unavailable(names))
|
|
142
|
+
out.set(name, u.reason);
|
|
143
|
+
return out;
|
|
121
144
|
}
|
|
122
145
|
onModuleInit() {
|
|
123
146
|
this.registry.register([
|
|
124
147
|
defineOperation({
|
|
125
148
|
id: "plugins.list",
|
|
126
|
-
description: "List the plugins this org can see,
|
|
149
|
+
description: "List the plugins this org can see, one compact row each: the state here (on, off, needs_config, unavailable, not_offered), why an unavailable one cannot be used (reason) and your next step (next; an installed plugin whose extension stopped running keeps its state and carries them too), whether an org admin can switch it, and the org's pending request. Details come from plugins.get. Pages by 50: pass the returned next as params.cursor.",
|
|
127
150
|
input: z.object({ cursor: Cursor.optional() }).strict(),
|
|
128
151
|
example: {},
|
|
129
152
|
authz: { orgAction: "catalog.read" },
|
|
130
153
|
mirrors: ["GET /api/v1/orgs/:orgId/catalog"],
|
|
154
|
+
extras: ["cursor"],
|
|
131
155
|
confirm: "read",
|
|
132
156
|
run: async (input, ctx) => {
|
|
133
|
-
const all = await
|
|
134
|
-
|
|
157
|
+
const [all, role] = await Promise.all([
|
|
158
|
+
this.orgCatalog.list(ctx.orgId, ctx.actorAccountId),
|
|
159
|
+
roleFor(this.kdb.db, ctx),
|
|
160
|
+
]);
|
|
161
|
+
const stopped = await this.stopped(all);
|
|
162
|
+
return pageOf(all.map((i) => row(withStopped(i, stopped), role)), startOf(input.cursor), PAGE);
|
|
135
163
|
},
|
|
136
164
|
}),
|
|
137
165
|
defineOperation({
|
|
138
166
|
id: "plugins.get",
|
|
139
|
-
description: "Read one plugin as this org sees it: its state, extension, connector templates (presets only, never credentials), dependencies, skills and agent templates.",
|
|
140
|
-
input: z.object({ itemId:
|
|
167
|
+
description: "Read one plugin as this org sees it: its state (with the reason and your next step when it is unavailable, or installed but its extension stopped running), extension, connector templates (presets only, never credentials), dependencies, skills and agent templates.",
|
|
168
|
+
input: z.object({ itemId: ItemId }).strict(),
|
|
141
169
|
example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
|
|
142
170
|
authz: { orgAction: "catalog.read" },
|
|
143
171
|
mirrors: ["GET /api/v1/orgs/:orgId/catalog/:itemId"],
|
|
@@ -145,15 +173,18 @@ let PluginsOperations = class PluginsOperations {
|
|
|
145
173
|
errors: [
|
|
146
174
|
{ code: "catalog.item_not_found", next: "Check the plugin id with plugins.list." },
|
|
147
175
|
],
|
|
148
|
-
run: async (input, ctx) =>
|
|
149
|
-
const d = await
|
|
150
|
-
|
|
151
|
-
|
|
176
|
+
run: async (input, ctx) => {
|
|
177
|
+
const [d, role] = await Promise.all([
|
|
178
|
+
this.orgCatalog.detail(ctx.orgId, ctx.actorAccountId, input.itemId),
|
|
179
|
+
roleFor(this.kdb.db, ctx),
|
|
180
|
+
]);
|
|
181
|
+
return { ...d, item: brief(withStopped(d.item, await this.stopped([d.item])), role) };
|
|
182
|
+
},
|
|
152
183
|
}),
|
|
153
184
|
defineOperation({
|
|
154
185
|
id: "plugins.disable-preview",
|
|
155
186
|
description: "Preview switching a plugin off in this org (org admins): what it would remove and which agents use it, and the confirm value plugins.set-enabled needs to switch it off. Show the preview to the person before switching off.",
|
|
156
|
-
input: z.object({ itemId:
|
|
187
|
+
input: z.object({ itemId: ItemId }).strict(),
|
|
157
188
|
example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
|
|
158
189
|
// the web previews through the switch route itself (no confirm); writes nothing here
|
|
159
190
|
authz: { orgAction: "org.extensions.manage" },
|
|
@@ -162,7 +193,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
162
193
|
errors: [
|
|
163
194
|
{ code: "catalog.item_not_found", next: "Check the plugin id with plugins.list." },
|
|
164
195
|
],
|
|
165
|
-
run: async (input, ctx) =>
|
|
196
|
+
run: async (input, ctx) => {
|
|
166
197
|
const d = await this.orgCatalog.detail(ctx.orgId, ctx.actorAccountId, input.itemId);
|
|
167
198
|
if (!d.item.switchable)
|
|
168
199
|
throw new ToolError(LOCKED);
|
|
@@ -176,14 +207,14 @@ let PluginsOperations = class PluginsOperations {
|
|
|
176
207
|
}
|
|
177
208
|
const preview = await this.installer.previewUninstall(ctx.orgId, live.pluginInstallId);
|
|
178
209
|
return { preview, confirm: uninstallPreviewHash(preview) };
|
|
179
|
-
}
|
|
210
|
+
},
|
|
180
211
|
}),
|
|
181
212
|
defineOperation({
|
|
182
213
|
id: "plugins.set-enabled",
|
|
183
214
|
description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs configuration a person enters (connector credentials, extension config) is refused, so point the person to the 插件 page. Switching off removes what the plugin brought and needs confirm: the value plugins.disable-preview returned with the preview the person saw.",
|
|
184
215
|
input: z.discriminatedUnion("enabled", [
|
|
185
|
-
z.object({ itemId:
|
|
186
|
-
z.object({ itemId:
|
|
216
|
+
z.object({ itemId: ItemId, enabled: z.literal(true) }).strict(),
|
|
217
|
+
z.object({ itemId: ItemId, enabled: z.literal(false), confirm: Confirm }).strict(),
|
|
187
218
|
]),
|
|
188
219
|
example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c", enabled: true },
|
|
189
220
|
// the route needs catalog.read; setSwitch requires an org admin (any of skills.manage,
|
|
@@ -191,6 +222,11 @@ let PluginsOperations = class PluginsOperations {
|
|
|
191
222
|
authz: { orgAction: "org.extensions.manage" },
|
|
192
223
|
authzNote: "service-enforced",
|
|
193
224
|
mirrors: ["PUT /api/v1/orgs/:orgId/catalog/:itemId/switch"],
|
|
225
|
+
// install inputs a person enters on the web (a plugin that needs them is refused)
|
|
226
|
+
omits: ["inputs"],
|
|
227
|
+
loosens: {
|
|
228
|
+
confirm: "also takes `nothing-installed` (plugins.disable-preview's value when nothing is installed), which the route's hash pattern rejects; the service checks confirm only when something is installed",
|
|
229
|
+
},
|
|
194
230
|
confirm: "org",
|
|
195
231
|
errors: [
|
|
196
232
|
{
|
|
@@ -203,17 +239,64 @@ let PluginsOperations = class PluginsOperations {
|
|
|
203
239
|
},
|
|
204
240
|
{
|
|
205
241
|
code: "plugin.disabled",
|
|
206
|
-
next:
|
|
242
|
+
next: {
|
|
243
|
+
superAdmin: "The plugin is stopped on the platform: turn it back on in the admin console under Plugins, then call again.",
|
|
244
|
+
orgAdmin: "The super admin stopped this plugin on the platform; ask them.",
|
|
245
|
+
member: "The super admin stopped this plugin on the platform; tell your org admin, who can ask the super admin.",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
code: "catalog.item_not_found",
|
|
250
|
+
next: "Check the plugin id with plugins.list.",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
code: "plugin.needs_input",
|
|
254
|
+
next: "Ask the person to enable it on the 插件 page, where they enter its configuration.",
|
|
207
255
|
},
|
|
208
256
|
{
|
|
209
257
|
code: "catalog.approval_required",
|
|
210
258
|
next: "The plugin is not offered to this org: create an access request with requests.create.",
|
|
211
259
|
},
|
|
260
|
+
{
|
|
261
|
+
code: "catalog.not_deployed",
|
|
262
|
+
next: {
|
|
263
|
+
superAdmin: "Open the admin console → Extensions → the plugin's extension to see why it is not running (deployment config, permission approval, disabled, or failed to load); fix it, then call again.",
|
|
264
|
+
orgAdmin: "Only the super admin can make the plugin's extension run; plugins.get shows the reason. There is no request operation for this (requests.create covers enabling and access only), so tell the super admin directly.",
|
|
265
|
+
member: "Ask an org admin: the super admin must set up the plugin's extension on the platform first.",
|
|
266
|
+
},
|
|
267
|
+
},
|
|
212
268
|
{
|
|
213
269
|
code: "plugin.skill_conflict",
|
|
214
270
|
next: "An org skill has the name of one of the plugin's skills; the person resolves it on the web.",
|
|
215
271
|
},
|
|
216
272
|
],
|
|
273
|
+
// what is known to fail before the card: an unknown plugin, switching off a locked one,
|
|
274
|
+
// switching on one whose extension cannot run (with the role's next step naming it) or
|
|
275
|
+
// that needs a person's input
|
|
276
|
+
precheck: async (i, ctx) => {
|
|
277
|
+
const [item] = UUID_RE.test(i.itemId)
|
|
278
|
+
? await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, i.itemId)
|
|
279
|
+
: [];
|
|
280
|
+
if (item === undefined) {
|
|
281
|
+
return { ok: false, code: "catalog.item_not_found", message: "Catalog item not found" };
|
|
282
|
+
}
|
|
283
|
+
if (!i.enabled && !item.switchable) {
|
|
284
|
+
return { ok: false, code: "plugin.scope_locked", message: LOCKED };
|
|
285
|
+
}
|
|
286
|
+
if (i.enabled && item.state === "unavailable" && item.reason !== undefined) {
|
|
287
|
+
const name = enName(item);
|
|
288
|
+
return {
|
|
289
|
+
ok: false,
|
|
290
|
+
code: item.reason === "plugin_disabled" ? "plugin.disabled" : "catalog.not_deployed",
|
|
291
|
+
message: unavailableMessage(item.reason, name),
|
|
292
|
+
next: unavailableNext(item.reason, name),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
if (i.enabled && needsInput(item, await this.extensions.list(ctx.orgId))) {
|
|
296
|
+
return { ok: false, code: "plugin.needs_input", message: NEEDS_INPUT };
|
|
297
|
+
}
|
|
298
|
+
return { ok: true };
|
|
299
|
+
},
|
|
217
300
|
summary: async (i, ctx) => {
|
|
218
301
|
const [item] = await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, i.itemId);
|
|
219
302
|
if (item === undefined)
|
|
@@ -236,7 +319,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
236
319
|
en: `Disable plugin "${n.en}" in the org: removes ${p.components.length} components; ${p.agents.length} agents use it`,
|
|
237
320
|
};
|
|
238
321
|
},
|
|
239
|
-
run: async (input, ctx) =>
|
|
322
|
+
run: async (input, ctx) => {
|
|
240
323
|
if (input.enabled) {
|
|
241
324
|
const [item] = await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, input.itemId);
|
|
242
325
|
if (item && needsInput(item, await this.extensions.list(ctx.orgId))) {
|
|
@@ -244,36 +327,43 @@ let PluginsOperations = class PluginsOperations {
|
|
|
244
327
|
}
|
|
245
328
|
}
|
|
246
329
|
const r = await this.orgCatalog.setSwitch(ctx.orgId, ctx.actorAccountId, input.itemId, input.enabled ? { enabled: true } : { enabled: false, confirm: input.confirm }, undefined, viaAgent("plugins.set-enabled", ctx));
|
|
247
|
-
if (r.kind === "done")
|
|
248
|
-
return {
|
|
330
|
+
if (r.kind === "done") {
|
|
331
|
+
return {
|
|
332
|
+
item: brief(r.item, await roleFor(this.kdb.db, ctx)),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
249
335
|
// unreachable: confirm is required when switching off
|
|
250
336
|
return { preview: r.preview, confirm: r.confirm };
|
|
251
|
-
}
|
|
337
|
+
},
|
|
252
338
|
}),
|
|
253
339
|
defineOperation({
|
|
254
340
|
id: "plugins.platform-list",
|
|
255
|
-
description: "List the platform's plugins and this org's own (super admin): scope, disabled, versions, pending confirmation and how many orgs use it. Plugins other orgs own are only counted (otherOrgItems)
|
|
341
|
+
description: "List the platform's plugins and this org's own (super admin): scope, disabled, versions, pending confirmation and how many orgs use it. Plugins other orgs own are only counted (otherOrgItems). Pages by 50: pass the returned next as params.cursor.",
|
|
256
342
|
input: z.object({ cursor: Cursor.optional() }).strict(),
|
|
257
343
|
example: {},
|
|
258
344
|
authz: { superAdmin: true },
|
|
259
345
|
mirrors: ["GET /api/v1/admin/catalog/items"],
|
|
346
|
+
// paged by cursor; deleted items and the pending filter are the admin console's
|
|
347
|
+
omits: ["includeDeleted", "limit", "offset", "pending"],
|
|
348
|
+
extras: ["cursor"],
|
|
260
349
|
confirm: "read",
|
|
261
350
|
run: async (input, ctx) => {
|
|
262
351
|
const p = await this.catalog.page({ limit: PAGE, offset: startOf(input.cursor) });
|
|
263
|
-
return
|
|
352
|
+
return {
|
|
264
353
|
items: p.items.filter((i) => i.owner.kind !== "org" || i.owner.orgId === ctx.orgId),
|
|
265
|
-
otherOrgItems: await this.
|
|
354
|
+
otherOrgItems: await otherOrgItems(this.kdb.db, ctx.orgId),
|
|
266
355
|
next: p.nextOffset === null ? null : String(p.nextOffset),
|
|
267
|
-
}
|
|
356
|
+
};
|
|
268
357
|
},
|
|
269
358
|
}),
|
|
270
359
|
defineOperation({
|
|
271
360
|
id: "plugins.platform-get",
|
|
272
|
-
description: "Read one platform catalog plugin (super admin): the item, its platform version and every version with its source.
|
|
273
|
-
input: z.object({ itemId:
|
|
361
|
+
description: "Read one platform catalog plugin (super admin): the item, its platform version and every version with its source, and the orgs it is offered to. Another org's own plugin is refused.",
|
|
362
|
+
input: z.object({ itemId: PlatformItemId }).strict(),
|
|
274
363
|
example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
|
|
275
364
|
authz: { superAdmin: true },
|
|
276
365
|
mirrors: ["GET /api/v1/admin/catalog/items/:id"],
|
|
366
|
+
renames: { itemId: "id" },
|
|
277
367
|
confirm: "read",
|
|
278
368
|
errors: [
|
|
279
369
|
{
|
|
@@ -281,10 +371,10 @@ let PluginsOperations = class PluginsOperations {
|
|
|
281
371
|
next: "Check the plugin id with plugins.platform-list.",
|
|
282
372
|
},
|
|
283
373
|
],
|
|
284
|
-
run: async (input, ctx) =>
|
|
285
|
-
await this.
|
|
374
|
+
run: async (input, ctx) => {
|
|
375
|
+
await assertNotOtherOrgs(this.kdb.db, input.itemId, ctx.orgId);
|
|
286
376
|
const d = await this.catalog.get(input.itemId);
|
|
287
|
-
return
|
|
377
|
+
return {
|
|
288
378
|
item: d.item,
|
|
289
379
|
versions: d.versions.map((v) => ({
|
|
290
380
|
version: v.version,
|
|
@@ -294,16 +384,17 @@ let PluginsOperations = class PluginsOperations {
|
|
|
294
384
|
importedAt: v.importedAt,
|
|
295
385
|
...(v.version === d.item.platformVersion && { manifest: v.manifest }),
|
|
296
386
|
})),
|
|
297
|
-
}
|
|
298
|
-
}
|
|
387
|
+
};
|
|
388
|
+
},
|
|
299
389
|
}),
|
|
300
390
|
defineOperation({
|
|
301
391
|
id: "plugins.update-preview",
|
|
302
|
-
description: "Preview updating a platform plugin to another imported version (super admin): every component's change, the extension step and the org connectors it touches, with the diffHash plugins.update takes.
|
|
303
|
-
input: z.object({ itemId:
|
|
392
|
+
description: "Preview updating a platform plugin to another imported version (super admin): every component's change, the extension step and the org connectors it touches, with the diffHash plugins.update takes. Another org's own plugin is refused.",
|
|
393
|
+
input: z.object({ itemId: PlatformItemId, version: Version }).strict(),
|
|
304
394
|
example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c", version: "1.2.0" },
|
|
305
395
|
authz: { superAdmin: true },
|
|
306
396
|
mirrors: ["POST /api/v1/admin/catalog/items/:id/update/preview"],
|
|
397
|
+
renames: { itemId: "id" },
|
|
307
398
|
confirm: "read",
|
|
308
399
|
errors: [
|
|
309
400
|
{
|
|
@@ -311,15 +402,21 @@ let PluginsOperations = class PluginsOperations {
|
|
|
311
402
|
next: "Check the plugin id and its versions with plugins.platform-get.",
|
|
312
403
|
},
|
|
313
404
|
],
|
|
314
|
-
run: async (input, ctx) =>
|
|
315
|
-
await this.
|
|
316
|
-
return
|
|
317
|
-
}
|
|
405
|
+
run: async (input, ctx) => {
|
|
406
|
+
await assertNotOtherOrgs(this.kdb.db, input.itemId, ctx.orgId);
|
|
407
|
+
return this.updater.preview(input.itemId, input.version);
|
|
408
|
+
},
|
|
318
409
|
}),
|
|
319
410
|
defineOperation({
|
|
320
411
|
id: "plugins.update",
|
|
321
412
|
description: "Update a platform plugin to the version previewed (super admin), for every org at once: pass the version and the diffHash plugins.update-preview returned. A preview that is out of date is refused; preview again.",
|
|
322
|
-
input: z
|
|
413
|
+
input: z
|
|
414
|
+
.object({
|
|
415
|
+
itemId: PlatformItemId,
|
|
416
|
+
version: Version,
|
|
417
|
+
diffHash: CatalogUpdateBody.shape.diffHash,
|
|
418
|
+
})
|
|
419
|
+
.strict(),
|
|
323
420
|
example: {
|
|
324
421
|
itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c",
|
|
325
422
|
version: "1.2.0",
|
|
@@ -327,6 +424,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
327
424
|
},
|
|
328
425
|
authz: { superAdmin: true },
|
|
329
426
|
mirrors: ["PUT /api/v1/admin/catalog/items/:id/update"],
|
|
427
|
+
renames: { itemId: "id" },
|
|
330
428
|
confirm: "platform",
|
|
331
429
|
errors: [
|
|
332
430
|
{
|
|
@@ -339,7 +437,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
339
437
|
},
|
|
340
438
|
],
|
|
341
439
|
summary: async (i, ctx) => {
|
|
342
|
-
await this.
|
|
440
|
+
await assertNotOtherOrgs(this.kdb.db, i.itemId, ctx.orgId);
|
|
343
441
|
const [{ item }, p] = await Promise.all([
|
|
344
442
|
this.catalog.get(i.itemId),
|
|
345
443
|
this.updater.preview(i.itemId, i.version),
|
|
@@ -349,17 +447,17 @@ let PluginsOperations = class PluginsOperations {
|
|
|
349
447
|
const changed = count("upgrade", "downgrade");
|
|
350
448
|
const added = count("added");
|
|
351
449
|
const removed = count("removed");
|
|
352
|
-
// one version for every org:
|
|
450
|
+
// one version for every org: how many orgs it is on in
|
|
353
451
|
const orgs = item.enabledOrgs;
|
|
354
452
|
return {
|
|
355
453
|
zh: `把平台插件「${n.zh}」从 ${p.from ?? "无"} 更新到 ${p.to}:组件 ${changed} 个更新、${added} 个新增、${removed} 个移除,影响 ${orgs} 个组织`,
|
|
356
454
|
en: `Update platform plugin "${n.en}" from ${p.from ?? "none"} to ${p.to}: components ${changed} updated, ${added} added, ${removed} removed; ${orgs} orgs affected`,
|
|
357
455
|
};
|
|
358
456
|
},
|
|
359
|
-
run: async (input, ctx) =>
|
|
360
|
-
await this.
|
|
361
|
-
return
|
|
362
|
-
}
|
|
457
|
+
run: async (input, ctx) => {
|
|
458
|
+
await assertNotOtherOrgs(this.kdb.db, input.itemId, ctx.orgId);
|
|
459
|
+
return this.updater.update(ctx.actorAccountId, input.itemId, { version: input.version, diffHash: input.diffHash }, { auditDetail: viaAgent("plugins.update", ctx) });
|
|
460
|
+
},
|
|
363
461
|
}),
|
|
364
462
|
]);
|
|
365
463
|
}
|
|
@@ -372,6 +470,7 @@ PluginsOperations = __decorate([
|
|
|
372
470
|
__param(3, Inject(PlatformPluginUpdater)),
|
|
373
471
|
__param(4, Inject(PluginInstaller)),
|
|
374
472
|
__param(5, Inject(OrgExtensionConfigs)),
|
|
375
|
-
__param(6, Inject(KernelDb))
|
|
473
|
+
__param(6, Inject(KernelDb)),
|
|
474
|
+
__param(7, Inject(ExtensionAvailability))
|
|
376
475
|
], PluginsOperations);
|
|
377
476
|
export { PluginsOperations };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { PreviewerRegistry } from "../../files/previewers.js";
|
|
3
|
+
import { PlatformOperations } from "../registry.js";
|
|
4
|
+
/**
|
|
5
|
+
* File previewer operations (the `extensions` domain): the org's order of the previewers its
|
|
6
|
+
* extensions provide and which are off (org admins, `org.extensions.manage`). Rendering a preview
|
|
7
|
+
* is the web's (`transport`).
|
|
8
|
+
*/
|
|
9
|
+
export declare class PreviewersOperations implements OnModuleInit {
|
|
10
|
+
private readonly registry;
|
|
11
|
+
private readonly previewers;
|
|
12
|
+
constructor(registry: PlatformOperations, previewers: PreviewerRegistry);
|
|
13
|
+
onModuleInit(): void;
|
|
14
|
+
}
|