@capybara-hq/kernel 0.1.0-rc.56 → 0.1.0-rc.58
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 +3 -3
- package/dist/admin/extensions.controller.d.ts +2 -10
- package/dist/admin/extensions.controller.js +2 -24
- package/dist/admin/extensions.schemas.d.ts +21 -0
- package/dist/admin/extensions.schemas.js +37 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-extension-switch.d.ts +3 -1
- package/dist/catalog/org-extension-switch.js +12 -5
- package/dist/catalog/org-extension.controller.d.ts +2 -21
- package/dist/catalog/org-extension.controller.js +1 -38
- package/dist/catalog/org-extension.schemas.d.ts +31 -0
- package/dist/catalog/org-extension.schemas.js +65 -0
- package/dist/channels/actions.js +2 -0
- package/dist/channels/cards.d.ts +8 -0
- package/dist/channels/cards.js +18 -0
- package/dist/channels/outbound.js +8 -1
- package/dist/channels/phrases.d.ts +10 -0
- package/dist/channels/phrases.js +10 -0
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +5 -0
- package/dist/conversations/leak-check.d.ts +26 -0
- package/dist/conversations/leak-check.js +69 -0
- package/dist/ctx/secrets.d.ts +5 -0
- package/dist/ctx/secrets.js +5 -0
- package/dist/db/kernel-schema.d.ts +15 -0
- package/dist/devices/device-projects.service.d.ts +3 -1
- package/dist/devices/device-projects.service.js +25 -7
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +9 -0
- package/dist/extensions/deployment-config.d.ts +6 -2
- package/dist/extensions/deployment-config.js +35 -23
- package/dist/extensions/org-config.d.ts +2 -0
- package/dist/extensions/org-config.js +1 -0
- package/dist/extensions/org-overrides.d.ts +2 -0
- package/dist/extensions/org-overrides.js +3 -2
- package/dist/identity/initial-passwords.job.d.ts +3 -2
- package/dist/identity/initial-passwords.job.js +9 -5
- package/dist/platform/exclusions.js +1 -41
- package/dist/platform/method.js +1 -0
- package/dist/platform/operation.d.ts +30 -2
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/extensions-admin.ops.d.ts +15 -2
- package/dist/platform/ops/extensions-admin.ops.js +153 -5
- package/dist/platform/ops/extensions.ops.d.ts +19 -5
- package/dist/platform/ops/extensions.ops.js +285 -10
- package/dist/platform/ops/person-inputs.d.ts +35 -0
- package/dist/platform/ops/person-inputs.js +79 -0
- package/dist/platform/ops/plugins.ops.d.ts +2 -0
- package/dist/platform/ops/plugins.ops.js +30 -17
- package/dist/platform/parity.d.ts +6 -2
- package/dist/platform/parity.js +38 -1
- package/dist/platform/person-fields.d.ts +103 -0
- package/dist/platform/person-fields.js +381 -0
- package/dist/platform/platform.module.d.ts +3 -3
- package/dist/platform/platform.module.js +6 -5
- package/dist/platform/sealed-inputs.d.ts +44 -0
- package/dist/platform/sealed-inputs.js +116 -0
- package/dist/runtime/waits.js +8 -2
- package/dist/sandbox/sandbox.service.js +5 -1
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.controller.js +19 -0
- package/dist/tools/approvals.service.d.ts +50 -1
- package/dist/tools/approvals.service.js +118 -10
- package/dist/tools/builtins/builtin-tools.d.ts +3 -0
- package/dist/tools/builtins/builtin-tools.js +31 -9
- package/dist/tools/builtins/platform.d.ts +20 -0
- package/dist/tools/builtins/platform.js +174 -15
- package/dist/tools/pipeline.d.ts +24 -2
- package/dist/tools/pipeline.js +80 -17
- package/dist/tools/policy.d.ts +3 -0
- package/dist/tools/policy.js +6 -0
- package/dist/tools/registry.d.ts +22 -0
- package/dist/tools/tools.module.js +3 -0
- package/package.json +4 -4
- package/src/migrations/0169_platform_sealed_inputs.sql +23 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { OrgAction } from "../orgs/roles.js";
|
|
3
3
|
import type { ErrorRole } from "./errors.js";
|
|
4
|
+
import type { PersonFieldTarget } from "./person-fields.js";
|
|
4
5
|
/**
|
|
5
6
|
* How an operation is confirmed (spec §6.2): `read` runs; `personal` asks each time and may be
|
|
6
7
|
* remembered; `org` / `platform` ask each time and are never remembered.
|
|
@@ -33,6 +34,24 @@ export interface OperationContext {
|
|
|
33
34
|
* then with `roleFor` in ./ops/unavailable.ts.
|
|
34
35
|
*/
|
|
35
36
|
errorRole?: ErrorRole;
|
|
37
|
+
/**
|
|
38
|
+
* The values the person typed on the approval card for this call's secret fields (platform web
|
|
39
|
+
* parity spec §4.3): present only when the approved call asked for person fields. `paths` are the
|
|
40
|
+
* asked fields; `apply` consumes the sealed values once and runs `fn` with them in the same
|
|
41
|
+
* transaction (a throw puts them back), so the handler passes them to the route's service method
|
|
42
|
+
* inside `fn`. The values never go into the result: the tool appends a line per entered path.
|
|
43
|
+
* `apply` throws when the values expired; the tool returns the "expired" text then.
|
|
44
|
+
*/
|
|
45
|
+
personInputs?: {
|
|
46
|
+
paths: readonly string[];
|
|
47
|
+
apply<T>(fn: (values: Readonly<Record<string, string>>) => Promise<T>): Promise<T>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* At confirmation time, for an operation with `personFields`: the paths the planned card asks
|
|
51
|
+
* the person for (`askPerson` plus the required secrets without a stored value), so `summary`
|
|
52
|
+
* names every field the card shows. Absent elsewhere.
|
|
53
|
+
*/
|
|
54
|
+
personAsk?: readonly string[];
|
|
36
55
|
}
|
|
37
56
|
/**
|
|
38
57
|
* The next step after an error: one text, or one per role where the step differs (spec §14.5
|
|
@@ -57,8 +76,9 @@ export interface OperationError {
|
|
|
57
76
|
* Some codes exist only in the tool, never answered by a route: `marketplace.already_added` (the
|
|
58
77
|
* `marketplaces.add` duplicate check is tool policy; the web accepts a duplicate source),
|
|
59
78
|
* `plugin.needs_input` (input only a person enters on the web), `agent.visibility_web_only`,
|
|
60
|
-
* `catalog.org_owned` (`plugins.set-shown` leaves an org's own plugin to that org),
|
|
61
|
-
* `account.self` / `account.no_change` (disabling your own account, a status that is set already)
|
|
79
|
+
* `catalog.org_owned` (`plugins.set-shown` leaves an org's own plugin to that org),
|
|
80
|
+
* `account.self` / `account.no_change` (disabling your own account, a status that is set already),
|
|
81
|
+
* and `platform.secret_record_web_only` (a secret record the card cannot ask for; ruling R1).
|
|
62
82
|
*/
|
|
63
83
|
export type PrecheckResult = {
|
|
64
84
|
ok: true;
|
|
@@ -133,6 +153,14 @@ export interface PlatformOperation<I = unknown> {
|
|
|
133
153
|
* errors speak.
|
|
134
154
|
*/
|
|
135
155
|
precheck?(input: I, ctx: OperationContext): Promise<PrecheckResult>;
|
|
156
|
+
/**
|
|
157
|
+
* The secret fields of the write's target (platform web parity spec §4.1): read at confirmation
|
|
158
|
+
* time, after availability, and planned against the input's `values`, `askPerson` and
|
|
159
|
+
* `clearSecrets` (`planPersonFields`). Only for writes whose input carries
|
|
160
|
+
* `personFieldParams`; a secret in `values` is refused before the card, and the asked fields
|
|
161
|
+
* make the call always ask the person, once, on the web. Absent: the write has no person fields.
|
|
162
|
+
*/
|
|
163
|
+
personFields?(input: I, ctx: OperationContext): Promise<PersonFieldTarget>;
|
|
136
164
|
/**
|
|
137
165
|
* The bilingual card summary of a write, rendered from the input and kernel reads (names of
|
|
138
166
|
* the targets, preview counts), never from model text; required unless `confirm` is `read`.
|
|
@@ -41,7 +41,7 @@ export const PLATFORM_DOMAINS = [
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
id: "extensions",
|
|
44
|
-
description: "Extensions in the org (state, tool switches, extension point defaults, file previewers) and, for the super admin, on the platform (state, pending permission confirmations, enable, disable, uninstall).",
|
|
44
|
+
description: "Extensions in the org (state, tool switches, extension point defaults, file previewers, the org config and the org's copy of platform config) and, for the super admin, on the platform (state, deployment config, pending permission confirmations, enable, disable, uninstall). Secrets are entered by the person on the confirmation card.",
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
id: "conversations",
|
|
@@ -2,14 +2,26 @@ import { type OnModuleInit } from "@nestjs/common";
|
|
|
2
2
|
import { CatalogService } from "../../catalog/catalog.service.js";
|
|
3
3
|
import { ExtensionAdminOps } from "../../extensions/admin-ops.js";
|
|
4
4
|
import { ExtensionAdmin } from "../../extensions/admin-view.js";
|
|
5
|
+
import { type DeploymentConfigView, ExtensionDeploymentConfigService } from "../../extensions/deployment-config.js";
|
|
5
6
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
6
7
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
8
|
+
import { type PersonFieldTarget } from "../person-fields.js";
|
|
7
9
|
import { PlatformOperations } from "../registry.js";
|
|
10
|
+
/**
|
|
11
|
+
* The person fields of an extension's deployment config (platform web parity spec §4.1): the
|
|
12
|
+
* secret fields of its form schema, set or not. A secret field the schema walk cannot address (no
|
|
13
|
+
* form schema, a record) is never asked, and a value for it in `values` is refused as web only. A
|
|
14
|
+
* secret set in the startup config (read-only here) is never asked either: naming it in
|
|
15
|
+
* `askPerson` / `clearSecrets`, or giving it in `values`, is refused before the card with the
|
|
16
|
+
* route's `extension.config_readonly`, so the person never types a value the write would refuse.
|
|
17
|
+
*/
|
|
18
|
+
export declare function deploymentPersonFields(v: DeploymentConfigView, named?: readonly string[], values?: Readonly<Record<string, unknown>>): PersonFieldTarget;
|
|
8
19
|
/**
|
|
9
20
|
* The super admin's extension operations of the `Platform` tool (spec §14.2 "admin console",
|
|
10
21
|
* §14.5 item 1): the deployment's extensions (list, read), enable, disable and uninstall. Installing
|
|
11
22
|
* a package (upload, npm) and approving permissions stay on the web: a person reviews the
|
|
12
|
-
* permissions there.
|
|
23
|
+
* permissions there. The deployment config is read (secrets as set or not) and written here, its
|
|
24
|
+
* secrets entered by the person on the confirmation card (platform web parity spec §4).
|
|
13
25
|
*/
|
|
14
26
|
export declare class ExtensionsAdminOperations implements OnModuleInit {
|
|
15
27
|
private readonly registry;
|
|
@@ -18,7 +30,8 @@ export declare class ExtensionsAdminOperations implements OnModuleInit {
|
|
|
18
30
|
private readonly config;
|
|
19
31
|
private readonly kdb;
|
|
20
32
|
private readonly catalog;
|
|
21
|
-
|
|
33
|
+
private readonly deploymentConfigs;
|
|
34
|
+
constructor(registry: PlatformOperations, admin: ExtensionAdmin, ops: ExtensionAdminOps, config: KernelConfigService, kdb: KernelDb, catalog: CatalogService, deploymentConfigs: ExtensionDeploymentConfigService);
|
|
22
35
|
/** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
|
|
23
36
|
private viewFor;
|
|
24
37
|
onModuleInit(): void;
|
|
@@ -9,25 +9,64 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
|
-
import { AdminExtensionNamePathParams } from "../../admin/extensions.schemas.js";
|
|
12
|
+
import { AdminExtensionConfigBody, AdminExtensionNamePathParams, } from "../../admin/extensions.schemas.js";
|
|
13
13
|
import { CatalogService } from "../../catalog/catalog.service.js";
|
|
14
|
+
import { ApiError } from "../../errors.js";
|
|
14
15
|
import { ExtensionAdminOps } from "../../extensions/admin-ops.js";
|
|
15
16
|
import { ExtensionAdmin } from "../../extensions/admin-view.js";
|
|
17
|
+
import { ExtensionDeploymentConfigService, } from "../../extensions/deployment-config.js";
|
|
16
18
|
import { SINGLE_PROVIDER_ENABLED, SINGLE_PROVIDER_REQUIRED, singleProviderMessage, } from "../../extensions/single-provider.js";
|
|
17
19
|
import { unavailableReason } from "../../extensions/unavailable.js";
|
|
18
20
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
19
21
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
20
22
|
import { defineOperation } from "../operation.js";
|
|
23
|
+
import { pathsTouched, personFieldParams, secretFieldsOf, } from "../person-fields.js";
|
|
21
24
|
import { PlatformOperations } from "../registry.js";
|
|
22
25
|
import { precheckBy, viaAgent } from "./errors.js";
|
|
23
26
|
import { assertExtensionNotOtherOrgs, OTHER_ORG, otherOrgExtensions } from "./other-orgs.js";
|
|
24
27
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
28
|
+
import { configChanges, flatValues, withPersonInputs } from "./person-inputs.js";
|
|
25
29
|
import { localized } from "./summary.js";
|
|
26
30
|
import { unavailableFields } from "./unavailable.js";
|
|
27
31
|
/** An extension's name (`:name` of the admin routes), bounded like the org routes' `:extension`. */
|
|
28
32
|
const Name = AdminExtensionNamePathParams.shape.name.max(64);
|
|
29
33
|
const NameInput = z.object({ name: Name }).strict();
|
|
30
34
|
const EXAMPLE = { name: "model-anthropic" };
|
|
35
|
+
/** `values` of the deployment config route: field dot path -> value (`null` clears). */
|
|
36
|
+
const ConfigValues = AdminExtensionConfigBody.shape.values;
|
|
37
|
+
/**
|
|
38
|
+
* The person fields of an extension's deployment config (platform web parity spec §4.1): the
|
|
39
|
+
* secret fields of its form schema, set or not. A secret field the schema walk cannot address (no
|
|
40
|
+
* form schema, a record) is never asked, and a value for it in `values` is refused as web only. A
|
|
41
|
+
* secret set in the startup config (read-only here) is never asked either: naming it in
|
|
42
|
+
* `askPerson` / `clearSecrets`, or giving it in `values`, is refused before the card with the
|
|
43
|
+
* route's `extension.config_readonly`, so the person never types a value the write would refuse.
|
|
44
|
+
*/
|
|
45
|
+
export function deploymentPersonFields(v, named = [], values) {
|
|
46
|
+
const secrets = v.fields.filter((f) => f.secret);
|
|
47
|
+
const readonly = secrets.filter((f) => f.readonly);
|
|
48
|
+
const ro = new Set(readonly.map((f) => f.path));
|
|
49
|
+
const hit = [
|
|
50
|
+
...new Set([
|
|
51
|
+
...named.filter((p) => ro.has(p)),
|
|
52
|
+
...pathsTouched(values, readonly.map((f) => f.path)),
|
|
53
|
+
]),
|
|
54
|
+
];
|
|
55
|
+
if (hit.length > 0) {
|
|
56
|
+
throw new ApiError("extension.config_readonly", `These deployment config fields of extension ${v.plugin} are set in the startup config (file, Nacos or environment) and are read-only here: ${hit.join(", ")}`, hit.map((path) => ({ path, source: readonly.find((f) => f.path === path)?.source })));
|
|
57
|
+
}
|
|
58
|
+
const found = secretFieldsOf(v.schema, new Set(secrets.filter((f) => f.set).map((f) => f.path)));
|
|
59
|
+
const fields = found.fields.filter((f) => !ro.has(f.path));
|
|
60
|
+
const asked = new Set(fields.map((f) => f.path));
|
|
61
|
+
const n = localized(v.displayName, v.plugin);
|
|
62
|
+
return {
|
|
63
|
+
target: { zh: `扩展「${n.zh}」的部署配置`, en: `${n.en}: deployment config` },
|
|
64
|
+
fields,
|
|
65
|
+
recordOnly: [
|
|
66
|
+
...new Set([...found.recordOnly, ...secrets.map((f) => f.path).filter((p) => !asked.has(p))]),
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
31
70
|
/** The English name of an extension as next steps name it. */
|
|
32
71
|
const enName = (v) => localized(v.displayName, v.name).en;
|
|
33
72
|
/** Why an extension does not run, and the super admin's next step (absent when it runs). */
|
|
@@ -90,7 +129,8 @@ const pendingPlugin = (i) => ({
|
|
|
90
129
|
* The super admin's extension operations of the `Platform` tool (spec §14.2 "admin console",
|
|
91
130
|
* §14.5 item 1): the deployment's extensions (list, read), enable, disable and uninstall. Installing
|
|
92
131
|
* a package (upload, npm) and approving permissions stay on the web: a person reviews the
|
|
93
|
-
* permissions there.
|
|
132
|
+
* permissions there. The deployment config is read (secrets as set or not) and written here, its
|
|
133
|
+
* secrets entered by the person on the confirmation card (platform web parity spec §4).
|
|
94
134
|
*/
|
|
95
135
|
let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
96
136
|
registry;
|
|
@@ -99,13 +139,15 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
|
99
139
|
config;
|
|
100
140
|
kdb;
|
|
101
141
|
catalog;
|
|
102
|
-
|
|
142
|
+
deploymentConfigs;
|
|
143
|
+
constructor(registry, admin, ops, config, kdb, catalog, deploymentConfigs) {
|
|
103
144
|
this.registry = registry;
|
|
104
145
|
this.admin = admin;
|
|
105
146
|
this.ops = ops;
|
|
106
147
|
this.config = config;
|
|
107
148
|
this.kdb = kdb;
|
|
108
149
|
this.catalog = catalog;
|
|
150
|
+
this.deploymentConfigs = deploymentConfigs;
|
|
109
151
|
}
|
|
110
152
|
/** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
|
|
111
153
|
async viewFor(name, orgId) {
|
|
@@ -198,7 +240,7 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
|
198
240
|
}),
|
|
199
241
|
defineOperation({
|
|
200
242
|
id: "extensions.platform-enable",
|
|
201
|
-
description: "Enable an installed extension on the platform (super admin): every replica loads it, without a restart. It runs once its permissions are approved and its deployment config is valid (
|
|
243
|
+
description: "Enable an installed extension on the platform (super admin): every replica loads it, without a restart. It runs once its permissions are approved (on the web) and its deployment config is valid (extensions.platform-config, extensions.platform-set-config); orgs then switch it on themselves.",
|
|
202
244
|
input: NameInput,
|
|
203
245
|
example: EXAMPLE,
|
|
204
246
|
authz: { superAdmin: true },
|
|
@@ -357,6 +399,111 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
|
357
399
|
return { uninstalled: input.name };
|
|
358
400
|
},
|
|
359
401
|
}),
|
|
402
|
+
defineOperation({
|
|
403
|
+
id: "extensions.platform-config",
|
|
404
|
+
description: "Read an extension's deployment config (super admin): each field's source (env, file or nacos: read-only here; db: saved here; default; unset), the effective value of non-secret fields, whether each secret field is set (never its value), the form's JSON Schema (secret fields carry x-secret), whether the config is valid and the problems (paths only), and the overridable fields every org must fill in itself (orgMustConfigure).",
|
|
405
|
+
input: NameInput,
|
|
406
|
+
example: EXAMPLE,
|
|
407
|
+
authz: { superAdmin: true },
|
|
408
|
+
mirrors: ["GET /api/v1/admin/extensions/:name/config"],
|
|
409
|
+
confirm: "read",
|
|
410
|
+
errors: [
|
|
411
|
+
{
|
|
412
|
+
code: "extension.not_found",
|
|
413
|
+
next: "Check the extension name with extensions.platform-list.",
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
run: async (input, ctx) => {
|
|
417
|
+
await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
|
|
418
|
+
return this.deploymentConfigs.view(input.name);
|
|
419
|
+
},
|
|
420
|
+
}),
|
|
421
|
+
defineOperation({
|
|
422
|
+
id: "extensions.platform-set-config",
|
|
423
|
+
description: "Save fields of an extension's deployment config (super admin): values maps field dot paths to new values (null clears a non-secret field; a field left out keeps its value). Secret fields are never in values: list them in askPerson and the person types them on the confirmation card (on the web); list stored secrets to empty in clearSecrets. Required secrets without a stored value are asked even when not listed. Every replica applies the saved config without a restart. Read the fields first with extensions.platform-config.",
|
|
424
|
+
input: z
|
|
425
|
+
.object({
|
|
426
|
+
name: Name,
|
|
427
|
+
values: ConfigValues.default({}),
|
|
428
|
+
askPerson: personFieldParams.askPerson,
|
|
429
|
+
clearSecrets: personFieldParams.clearSecrets,
|
|
430
|
+
})
|
|
431
|
+
.strict(),
|
|
432
|
+
example: { name: "model-anthropic", values: {}, askPerson: ["apiKey"], clearSecrets: [] },
|
|
433
|
+
authz: { superAdmin: true },
|
|
434
|
+
mirrors: ["PUT /api/v1/admin/extensions/:name/config"],
|
|
435
|
+
// secret record entries are entered on the web page (ruling R1)
|
|
436
|
+
omits: ["secretEntries"],
|
|
437
|
+
extras: ["askPerson", "clearSecrets"],
|
|
438
|
+
loosens: {
|
|
439
|
+
values: "defaults to {} so a call that only asks the person for secrets needs no values",
|
|
440
|
+
},
|
|
441
|
+
confirm: "platform",
|
|
442
|
+
errors: [
|
|
443
|
+
{
|
|
444
|
+
code: "extension.not_found",
|
|
445
|
+
next: "Check the extension name with extensions.platform-list.",
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
code: "extension.config_invalid",
|
|
449
|
+
next: "Read the fields and their schema with extensions.platform-config, correct the values (the error's details name the fields), then call again.",
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
code: "extension.config_readonly",
|
|
453
|
+
next: "These fields come from the startup config (file, Nacos or environment): only the deployment's config changes them. Leave them out and call again.",
|
|
454
|
+
},
|
|
455
|
+
],
|
|
456
|
+
personFields: async (i, ctx) => {
|
|
457
|
+
await assertExtensionNotOtherOrgs(this.kdb.db, i.name, ctx.orgId);
|
|
458
|
+
return deploymentPersonFields(await this.deploymentConfigs.view(i.name), [...i.askPerson, ...i.clearSecrets], i.values);
|
|
459
|
+
},
|
|
460
|
+
summary: async (i, ctx) => {
|
|
461
|
+
const v = await this.deploymentConfigs.view(i.name);
|
|
462
|
+
const n = localized(v.displayName, v.plugin);
|
|
463
|
+
const c = configChanges(i, ctx);
|
|
464
|
+
return {
|
|
465
|
+
zh: `保存扩展「${n.zh}」的平台部署配置:${c.zh}`,
|
|
466
|
+
en: `Save the platform deployment config of extension "${n.en}": ${c.en}`,
|
|
467
|
+
};
|
|
468
|
+
},
|
|
469
|
+
run: async (input, ctx) => {
|
|
470
|
+
await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
|
|
471
|
+
const view = await withPersonInputs("extensions.platform-set-config", ctx, (entered, detail) => this.deploymentConfigs.put(input.name, flatValues(input.values, entered, input.clearSecrets), ctx.actorAccountId, undefined, [], detail));
|
|
472
|
+
return {
|
|
473
|
+
config: view,
|
|
474
|
+
next: "Replicas apply it in the background; check the extension's state with extensions.platform-get.",
|
|
475
|
+
};
|
|
476
|
+
},
|
|
477
|
+
}),
|
|
478
|
+
defineOperation({
|
|
479
|
+
id: "extensions.platform-clear-config",
|
|
480
|
+
description: "Clear the deployment config saved on the platform for an extension (super admin): every saved field and every stored secret. Fields from the startup config (file, Nacos, environment) stay in effect. The extension reloads from what remains, or waits for configuration when that is missing or invalid.",
|
|
481
|
+
input: NameInput,
|
|
482
|
+
example: EXAMPLE,
|
|
483
|
+
authz: { superAdmin: true },
|
|
484
|
+
mirrors: ["DELETE /api/v1/admin/extensions/:name/config"],
|
|
485
|
+
confirm: "platform",
|
|
486
|
+
rememberable: false,
|
|
487
|
+
errors: [
|
|
488
|
+
{
|
|
489
|
+
code: "extension.not_found",
|
|
490
|
+
next: "Check the extension name with extensions.platform-list.",
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
summary: async (i) => {
|
|
494
|
+
const v = await this.deploymentConfigs.view(i.name);
|
|
495
|
+
const n = localized(v.displayName, v.plugin);
|
|
496
|
+
return {
|
|
497
|
+
zh: `清除扩展「${n.zh}」保存在平台上的部署配置(含全部密钥;启动配置中的字段保留)`,
|
|
498
|
+
en: `Clear the deployment config of extension "${n.en}" saved on the platform (every secret too; startup config fields stay)`,
|
|
499
|
+
};
|
|
500
|
+
},
|
|
501
|
+
run: async (input, ctx) => {
|
|
502
|
+
await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
|
|
503
|
+
const view = await this.deploymentConfigs.clear(input.name, ctx.actorAccountId, undefined, viaAgent("extensions.platform-clear-config", ctx));
|
|
504
|
+
return { config: view };
|
|
505
|
+
},
|
|
506
|
+
}),
|
|
360
507
|
]);
|
|
361
508
|
}
|
|
362
509
|
};
|
|
@@ -367,6 +514,7 @@ ExtensionsAdminOperations = __decorate([
|
|
|
367
514
|
__param(2, Inject(ExtensionAdminOps)),
|
|
368
515
|
__param(3, Inject(KernelConfigService)),
|
|
369
516
|
__param(4, Inject(KernelDb)),
|
|
370
|
-
__param(5, Inject(CatalogService))
|
|
517
|
+
__param(5, Inject(CatalogService)),
|
|
518
|
+
__param(6, Inject(ExtensionDeploymentConfigService))
|
|
371
519
|
], ExtensionsAdminOperations);
|
|
372
520
|
export { ExtensionsAdminOperations };
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { OrgExtensionSwitch } from "../../catalog/org-extension-switch.js";
|
|
2
3
|
import { ExtensionDisplayNames } from "../../extensions/display-name.js";
|
|
3
4
|
import { OrgExtensionConfigs } from "../../extensions/org-config.js";
|
|
5
|
+
import { OrgOverrides, type OrgOverrideView } from "../../extensions/org-overrides.js";
|
|
4
6
|
import { ExtensionPointDefaults } from "../../extensions/point-defaults.js";
|
|
5
7
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
6
8
|
import { OrgToolSwitches } from "../../tools/org-tool-switches.js";
|
|
9
|
+
import { type PersonFieldTarget } from "../person-fields.js";
|
|
7
10
|
import { PlatformOperations } from "../registry.js";
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
12
|
+
* The person fields of the org's copy: the copy's own secrets (under overridable top-level fields),
|
|
13
|
+
* set or not. A secret under a read-only field is not the org's to set: never asked, and a value
|
|
14
|
+
* for it in `values` is refused as well.
|
|
15
|
+
*/
|
|
16
|
+
export declare function copyPersonFields(v: OrgOverrideView): Pick<PersonFieldTarget, "fields" | "recordOnly">;
|
|
17
|
+
/**
|
|
18
|
+
* Extension operations of the `Platform` tool (spec §7): the org's extensions (the member projection
|
|
19
|
+
* of `GET /orgs/:orgId/extensions`, whatever the actor's role), their tool switches and point
|
|
20
|
+
* defaults, and for org admins the org config and the org's copy of overridable platform fields
|
|
21
|
+
* (read, write, take, save, drop; platform web parity spec §7.2). Secrets are never returned (only
|
|
22
|
+
* whether each is set) and never taken as params: the person enters them on the confirmation card.
|
|
13
23
|
*/
|
|
14
24
|
export declare class ExtensionsOperations implements OnModuleInit {
|
|
15
25
|
private readonly registry;
|
|
@@ -18,7 +28,11 @@ export declare class ExtensionsOperations implements OnModuleInit {
|
|
|
18
28
|
private readonly kdb;
|
|
19
29
|
private readonly switches;
|
|
20
30
|
private readonly pointDefaults;
|
|
21
|
-
|
|
31
|
+
private readonly overrides;
|
|
32
|
+
private readonly extSwitch;
|
|
33
|
+
constructor(registry: PlatformOperations, configs: OrgExtensionConfigs, displayNames: ExtensionDisplayNames, kdb: KernelDb, switches: OrgToolSwitches, pointDefaults: ExtensionPointDefaults, overrides: OrgOverrides, extSwitch: OrgExtensionSwitch);
|
|
34
|
+
/** The org view of one extension, or `extension.not_found` (not installed or not offered). */
|
|
35
|
+
private viewOf;
|
|
22
36
|
/** An extension's display name for a card (its plugin's), else the name, clipped. */
|
|
23
37
|
private nameOf;
|
|
24
38
|
onModuleInit(): void;
|