@capybara-hq/kernel 0.1.0-rc.57 → 0.1.0-rc.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/extensions.controller.d.ts +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-catalog.controller.d.ts +0 -5
- package/dist/catalog/org-catalog.controller.js +3 -17
- package/dist/catalog/org-catalog.schemas.d.ts +43 -0
- package/dist/catalog/org-catalog.schemas.js +43 -2
- 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/catalog/plugin-install.d.ts +2 -0
- package/dist/catalog/plugin-install.js +3 -3
- 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/channels.schemas.d.ts +3 -0
- package/dist/channels/channels.schemas.js +8 -0
- package/dist/channels/connections.service.d.ts +17 -2
- package/dist/channels/connections.service.js +30 -5
- package/dist/channels/outbound.js +25 -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 +35 -0
- package/dist/conversations/events.js +29 -0
- package/dist/conversations/leak-check.d.ts +26 -0
- package/dist/conversations/leak-check.js +69 -0
- package/dist/ctx/secrets.d.ts +13 -1
- package/dist/ctx/secrets.js +19 -1
- package/dist/db/kernel-schema.d.ts +34 -0
- package/dist/devices/working-root.d.ts +2 -3
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +19 -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/http/api.module.js +6 -0
- package/dist/identity/initial-passwords.job.d.ts +3 -2
- package/dist/identity/initial-passwords.job.js +11 -5
- package/dist/orgs/invitations.controller.d.ts +3 -11
- package/dist/orgs/invitations.controller.js +9 -10
- package/dist/orgs/invitations.service.d.ts +12 -2
- package/dist/orgs/invitations.service.js +14 -7
- package/dist/orgs/members.service.d.ts +12 -2
- package/dist/orgs/members.service.js +10 -8
- package/dist/orgs/orgs.controller.d.ts +4 -12
- package/dist/orgs/orgs.controller.js +10 -10
- package/dist/orgs/orgs.schemas.d.ts +26 -0
- package/dist/orgs/orgs.schemas.js +22 -0
- package/dist/platform/connector-person-fields.d.ts +67 -0
- package/dist/platform/connector-person-fields.js +129 -0
- package/dist/platform/exclusions.js +6 -141
- package/dist/platform/method.js +1 -0
- package/dist/platform/operation.d.ts +61 -2
- package/dist/platform/operation.js +4 -4
- package/dist/platform/ops/accounts.ops.js +1 -0
- package/dist/platform/ops/channels.ops.d.ts +10 -3
- package/dist/platform/ops/channels.ops.js +223 -5
- package/dist/platform/ops/connectors.ops.d.ts +22 -4
- package/dist/platform/ops/connectors.ops.js +664 -13
- 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/org-plugins.ops.d.ts +15 -2
- package/dist/platform/ops/org-plugins.ops.js +323 -4
- package/dist/platform/ops/orgs.ops.d.ts +40 -3
- package/dist/platform/ops/orgs.ops.js +293 -12
- package/dist/platform/ops/person-inputs.d.ts +65 -0
- package/dist/platform/ops/person-inputs.js +129 -0
- package/dist/platform/ops/plugins.ops.d.ts +3 -1
- package/dist/platform/ops/plugins.ops.js +33 -20
- package/dist/platform/parity.d.ts +7 -2
- package/dist/platform/parity.js +75 -13
- package/dist/platform/person-fields.d.ts +119 -0
- package/dist/platform/person-fields.js +403 -0
- package/dist/platform/platform.module.d.ts +4 -3
- package/dist/platform/platform.module.js +8 -5
- package/dist/platform/route-schemas.js +2 -0
- package/dist/platform/sealed-inputs.d.ts +44 -0
- package/dist/platform/sealed-inputs.js +116 -0
- package/dist/platform/sealed-reveals.controller.d.ts +20 -0
- package/dist/platform/sealed-reveals.controller.js +48 -0
- package/dist/platform/sealed-reveals.d.ts +52 -0
- package/dist/platform/sealed-reveals.js +153 -0
- package/dist/runtime/project/knowledge.js +24 -19
- package/dist/runtime/waits.js +8 -2
- package/dist/sandbox/permission-facts.d.ts +5 -1
- package/dist/sandbox/permission-facts.js +8 -2
- package/dist/setup/setup-guides.service.d.ts +5 -0
- package/dist/setup/setup-guides.service.js +2 -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 +214 -15
- package/dist/tools/connectors.controller.d.ts +6 -7
- package/dist/tools/connectors.controller.js +4 -44
- package/dist/tools/connectors.schemas.d.ts +170 -1
- package/dist/tools/connectors.schemas.js +82 -3
- package/dist/tools/connectors.service.d.ts +16 -6
- package/dist/tools/connectors.service.js +39 -24
- package/dist/tools/oauth/oauth.controller.d.ts +3 -6
- package/dist/tools/oauth/oauth.controller.js +3 -12
- package/dist/tools/oauth/oauth.schemas.d.ts +14 -0
- package/dist/tools/oauth/oauth.schemas.js +27 -0
- package/dist/tools/pipeline.d.ts +31 -2
- package/dist/tools/pipeline.js +89 -17
- package/dist/tools/policy.d.ts +4 -0
- package/dist/tools/policy.js +8 -0
- package/dist/tools/registry.d.ts +29 -0
- package/dist/tools/tools.module.js +3 -0
- package/package.json +3 -3
- package/src/migrations/0169_platform_sealed_inputs.sql +23 -0
- package/src/migrations/0170_platform_sealed_reveals.sql +27 -0
|
@@ -7,6 +7,7 @@ import { type OrgOverrideSummary, OrgOverrides } from "../extensions/org-overrid
|
|
|
7
7
|
import type { AdminExtensionView } from "../extensions/permission-view.js";
|
|
8
8
|
import { type Principal } from "../identity/principal.js";
|
|
9
9
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
10
|
+
import { AdminExtensionConfigBody } from "./extensions.schemas.js";
|
|
10
11
|
declare const ApproveSchema: z.ZodObject<{
|
|
11
12
|
sha256: z.ZodNullable<z.ZodString>;
|
|
12
13
|
reviewHash: z.ZodString;
|
|
@@ -14,15 +15,6 @@ declare const ApproveSchema: z.ZodObject<{
|
|
|
14
15
|
declare const InstallSchema: z.ZodObject<{
|
|
15
16
|
sha256: z.ZodString;
|
|
16
17
|
}, z.core.$strip>;
|
|
17
|
-
declare const ConfigSchema: z.ZodObject<{
|
|
18
|
-
values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
19
|
-
secretEntries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
-
path: z.ZodString;
|
|
21
|
-
key: z.ZodString;
|
|
22
|
-
value: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
23
|
-
renameFrom: z.ZodOptional<z.ZodString>;
|
|
24
|
-
}, z.core.$strict>>>;
|
|
25
|
-
}, z.core.$strip>;
|
|
26
18
|
declare const NpmSchema: z.ZodObject<{
|
|
27
19
|
package: z.ZodString;
|
|
28
20
|
version: z.ZodOptional<z.ZodString>;
|
|
@@ -80,7 +72,7 @@ export declare class AdminExtensionsController {
|
|
|
80
72
|
* loads (no restart). `secretEntries` set, rename or remove single keys of a secret record a
|
|
81
73
|
* config UI hint draws per item (a path no hint names -> 400 `validation_failed`).
|
|
82
74
|
*/
|
|
83
|
-
putConfig(principal: Principal, name: string, body: z.infer<typeof
|
|
75
|
+
putConfig(principal: Principal, name: string, body: z.infer<typeof AdminExtensionConfigBody>): Promise<DeploymentConfigView>;
|
|
84
76
|
/**
|
|
85
77
|
* Clears the deployment config saved here: the stored fields and every stored secret value of
|
|
86
78
|
* the extension; audits `extension.config_cleared`. Fields from the startup config (file / Nacos
|
|
@@ -19,6 +19,7 @@ import { CurrentPrincipal, patTokenId, requireUser, SuperAdmin, } from "../ident
|
|
|
19
19
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
20
20
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
21
21
|
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
22
|
+
import { AdminExtensionConfigBody } from "./extensions.schemas.js";
|
|
22
23
|
const ApproveSchema = z.object({
|
|
23
24
|
/** 安装记录的包(审阅时的 sha256);配置声明的插件为 null。 */
|
|
24
25
|
sha256: z
|
|
@@ -31,29 +32,6 @@ const InstallSchema = z.object({
|
|
|
31
32
|
/** 包存储里的包(上传 / npm 导入返回的 sha256)。 */
|
|
32
33
|
sha256: z.string().regex(/^[0-9a-f]{64}$/),
|
|
33
34
|
});
|
|
34
|
-
const SecretEntrySchema = z
|
|
35
|
-
.object({
|
|
36
|
-
/** A secret record field some `x-ui.secrets[].path` names. */
|
|
37
|
-
path: z.string().min(1).max(256),
|
|
38
|
-
key: z.string().min(1).max(256),
|
|
39
|
-
/** A string sets the key, `null` removes it. */
|
|
40
|
-
value: z.string().max(65_536).nullable().optional(),
|
|
41
|
-
/** Moves the value at this key to `key` first. */
|
|
42
|
-
renameFrom: z.string().min(1).max(256).optional(),
|
|
43
|
-
})
|
|
44
|
-
.strict()
|
|
45
|
-
.refine((e) => e.value !== undefined || e.renameFrom !== undefined, {
|
|
46
|
-
message: "an entry needs value or renameFrom",
|
|
47
|
-
})
|
|
48
|
-
.refine((e) => e.key !== "__proto__" && e.renameFrom !== "__proto__", {
|
|
49
|
-
message: "__proto__ is not a valid key",
|
|
50
|
-
});
|
|
51
|
-
const ConfigSchema = z.object({
|
|
52
|
-
/** 字段点路径 → 新值(`null` 清除)。 */
|
|
53
|
-
values: z.record(z.string().min(1).max(256), z.unknown()),
|
|
54
|
-
/** Single keys of hinted secret records (extension config forms spec §4.3), applied in order. */
|
|
55
|
-
secretEntries: z.array(SecretEntrySchema).max(200).optional(),
|
|
56
|
-
});
|
|
57
35
|
const NpmSchema = z.object({
|
|
58
36
|
package: z.string().min(1).max(214),
|
|
59
37
|
version: z.string().min(1).max(256).optional(),
|
|
@@ -62,7 +40,7 @@ class ExtensionApproveBody extends createZodDto(ApproveSchema, "ExtensionApprove
|
|
|
62
40
|
}
|
|
63
41
|
class ExtensionInstallBody extends createZodDto(InstallSchema, "ExtensionInstallBody") {
|
|
64
42
|
}
|
|
65
|
-
class ExtensionConfigBody extends createZodDto(
|
|
43
|
+
class ExtensionConfigBody extends createZodDto(AdminExtensionConfigBody, "ExtensionConfigBody") {
|
|
66
44
|
}
|
|
67
45
|
class ExtensionNpmImportBody extends createZodDto(NpmSchema, "ExtensionNpmImportBody") {
|
|
68
46
|
}
|
|
@@ -4,4 +4,25 @@ import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
|
4
4
|
export declare const AdminExtensionNamePathParams: z.ZodObject<{
|
|
5
5
|
name: z.ZodString;
|
|
6
6
|
}, z.core.$strip>;
|
|
7
|
+
/**
|
|
8
|
+
* One key of a secret record a config UI hint draws per item (extension config forms spec §4.3).
|
|
9
|
+
* `value` is a secret (`secret()` meta): a Platform operation never takes it as a param
|
|
10
|
+
* (`platform-op-secret-param`).
|
|
11
|
+
*/
|
|
12
|
+
export declare const AdminExtensionSecretEntry: z.ZodObject<{
|
|
13
|
+
path: z.ZodString;
|
|
14
|
+
key: z.ZodString;
|
|
15
|
+
value: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16
|
+
renameFrom: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
/** `PUT /admin/extensions/:name/config`: the deployment config fields to save. */
|
|
19
|
+
export declare const AdminExtensionConfigBody: z.ZodObject<{
|
|
20
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
21
|
+
secretEntries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
22
|
+
path: z.ZodString;
|
|
23
|
+
key: z.ZodString;
|
|
24
|
+
value: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
renameFrom: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strict>>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
7
28
|
export declare const ADMIN_EXTENSION_ROUTES: readonly RouteSchemas[];
|
|
@@ -1,10 +1,47 @@
|
|
|
1
|
+
import { secret } from "@capybara-hq/plugin-sdk";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
/** `:name` as the lifecycle and detail routes take it (`@Param`). */
|
|
3
4
|
export const AdminExtensionNamePathParams = z.object({ name: z.string().min(1) });
|
|
5
|
+
/**
|
|
6
|
+
* One key of a secret record a config UI hint draws per item (extension config forms spec §4.3).
|
|
7
|
+
* `value` is a secret (`secret()` meta): a Platform operation never takes it as a param
|
|
8
|
+
* (`platform-op-secret-param`).
|
|
9
|
+
*/
|
|
10
|
+
export const AdminExtensionSecretEntry = z
|
|
11
|
+
.object({
|
|
12
|
+
/** A secret record field some `x-ui.secrets[].path` names. */
|
|
13
|
+
path: z.string().min(1).max(256),
|
|
14
|
+
key: z.string().min(1).max(256),
|
|
15
|
+
/** A string sets the key, `null` removes it. */
|
|
16
|
+
value: secret(z.string().max(65_536).nullable().optional()),
|
|
17
|
+
/** Moves the value at this key to `key` first. */
|
|
18
|
+
renameFrom: z.string().min(1).max(256).optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict()
|
|
21
|
+
.refine((e) => e.value !== undefined || e.renameFrom !== undefined, {
|
|
22
|
+
message: "an entry needs value or renameFrom",
|
|
23
|
+
})
|
|
24
|
+
.refine((e) => e.key !== "__proto__" && e.renameFrom !== "__proto__", {
|
|
25
|
+
message: "__proto__ is not a valid key",
|
|
26
|
+
});
|
|
27
|
+
/** `PUT /admin/extensions/:name/config`: the deployment config fields to save. */
|
|
28
|
+
export const AdminExtensionConfigBody = z.object({
|
|
29
|
+
/** Field dot path -> new value (`null` clears, omitted keeps). */
|
|
30
|
+
values: z.record(z.string().min(1).max(256), z.unknown()),
|
|
31
|
+
/** Single keys of hinted secret records (extension config forms spec §4.3), applied in order. */
|
|
32
|
+
secretEntries: z.array(AdminExtensionSecretEntry).max(200).optional(),
|
|
33
|
+
});
|
|
4
34
|
export const ADMIN_EXTENSION_ROUTES = [
|
|
5
35
|
{ route: "GET /api/v1/admin/extensions" },
|
|
6
36
|
{ route: "GET /api/v1/admin/extensions/:name", params: AdminExtensionNamePathParams },
|
|
7
37
|
{ route: "POST /api/v1/admin/extensions/:name/enable", params: AdminExtensionNamePathParams },
|
|
8
38
|
{ route: "POST /api/v1/admin/extensions/:name/disable", params: AdminExtensionNamePathParams },
|
|
9
39
|
{ route: "DELETE /api/v1/admin/extensions/:name", params: AdminExtensionNamePathParams },
|
|
40
|
+
{ route: "GET /api/v1/admin/extensions/:name/config", params: AdminExtensionNamePathParams },
|
|
41
|
+
{
|
|
42
|
+
route: "PUT /api/v1/admin/extensions/:name/config",
|
|
43
|
+
params: AdminExtensionNamePathParams,
|
|
44
|
+
body: AdminExtensionConfigBody,
|
|
45
|
+
},
|
|
46
|
+
{ route: "DELETE /api/v1/admin/extensions/:name/config", params: AdminExtensionNamePathParams },
|
|
10
47
|
];
|
|
@@ -188,7 +188,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
188
188
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
189
189
|
export declare const HOST_VERSIONS: {
|
|
190
190
|
readonly kernel: string;
|
|
191
|
-
readonly sdk: "0.1.0-rc.
|
|
191
|
+
readonly sdk: "0.1.0-rc.43";
|
|
192
192
|
};
|
|
193
193
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
194
194
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -11,7 +11,6 @@ import { CatalogGuideQuery, CatalogMarketplaceRequestBody, CatalogRequestBody, C
|
|
|
11
11
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
12
12
|
import { PluginInstaller, type PluginInstallView, type UninstallPreview, type UninstallReport } from "./plugin-install.js";
|
|
13
13
|
import { CatalogRequestsService, type CatalogRequestView } from "./requests.service.js";
|
|
14
|
-
/** The connectors body (ruling P2-10): the input of missing connectors, by template id, as at install. */
|
|
15
14
|
declare const ConnectorsBody: z.ZodObject<{
|
|
16
15
|
inputs: z.ZodObject<{
|
|
17
16
|
connectors: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -26,10 +25,6 @@ declare const ConnectorsBody: z.ZodObject<{
|
|
|
26
25
|
}, z.core.$strict>>;
|
|
27
26
|
}, z.core.$strict>;
|
|
28
27
|
}, z.core.$strict>;
|
|
29
|
-
/**
|
|
30
|
-
* One more connector from a platform connector template (ruling P4-T6-8): its name and an
|
|
31
|
-
* install's connector input (`config`).
|
|
32
|
-
*/
|
|
33
28
|
declare const TemplateConnectorBody: z.ZodObject<{
|
|
34
29
|
name: z.ZodOptional<z.ZodString>;
|
|
35
30
|
config: z.ZodObject<{
|
|
@@ -16,26 +16,12 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
16
16
|
import { ZBody, ZQuery } from "../infra/validation/zod-params.js";
|
|
17
17
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
18
18
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
19
|
-
import {
|
|
19
|
+
import { CatalogGuideQuery, CatalogMarketplaceRequestBody, CatalogRequestBody, CatalogRequestsListQuery, NetworkRequestBody, OrgPluginConnectorsSchema, OrgPluginInstallBody, OrgPluginSwitchBody, OrgTemplateConnectorSchema, } from "./org-catalog.schemas.js";
|
|
20
20
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
21
21
|
import { PluginInstaller, } from "./plugin-install.js";
|
|
22
22
|
import { CatalogRequestsService } from "./requests.service.js";
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
.object({
|
|
26
|
-
inputs: z.object({ connectors: z.record(z.string(), CatalogConnectorInput) }).strict(),
|
|
27
|
-
})
|
|
28
|
-
.strict();
|
|
29
|
-
/**
|
|
30
|
-
* One more connector from a platform connector template (ruling P4-T6-8): its name and an
|
|
31
|
-
* install's connector input (`config`).
|
|
32
|
-
*/
|
|
33
|
-
const TemplateConnectorBody = z
|
|
34
|
-
.object({
|
|
35
|
-
name: z.string().trim().min(1).max(80).optional(),
|
|
36
|
-
config: CatalogConnectorInput.omit({ name: true }),
|
|
37
|
-
})
|
|
38
|
-
.strict();
|
|
23
|
+
const ConnectorsBody = OrgPluginConnectorsSchema;
|
|
24
|
+
const TemplateConnectorBody = OrgTemplateConnectorSchema;
|
|
39
25
|
/**
|
|
40
26
|
* 条目图标的响应头:图标可能是 SVG(可含脚本),只许网页以 `<img>` 显示;直接打开时 CSP sandbox 禁止脚本与一切外部
|
|
41
27
|
* 请求,nosniff 防浏览器按内容另行判型。
|
|
@@ -27,6 +27,11 @@ export declare const CatalogMarketplaceRequestBody: z.ZodObject<{
|
|
|
27
27
|
version: z.ZodString;
|
|
28
28
|
note: z.ZodOptional<z.ZodString>;
|
|
29
29
|
}, z.core.$strict>;
|
|
30
|
+
/**
|
|
31
|
+
* One connector template's input at install (C30): name, slug, endpoint, credential or OAuth
|
|
32
|
+
* client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
33
|
+
* operation never takes them as params; the person enters them on the confirmation card.
|
|
34
|
+
*/
|
|
30
35
|
export declare const CatalogConnectorInput: z.ZodObject<{
|
|
31
36
|
name: z.ZodOptional<z.ZodString>;
|
|
32
37
|
slug: z.ZodOptional<z.ZodString>;
|
|
@@ -54,6 +59,44 @@ export declare const OrgPluginInstallBody: z.ZodObject<{
|
|
|
54
59
|
}, z.core.$strict>>>;
|
|
55
60
|
extensionConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
56
61
|
}, z.core.$strict>;
|
|
62
|
+
/**
|
|
63
|
+
* `POST …/catalog/:itemId/connectors` (ruling P2-10): the input of missing connectors, by template
|
|
64
|
+
* id, as at install.
|
|
65
|
+
*/
|
|
66
|
+
export declare const OrgPluginConnectorsSchema: z.ZodObject<{
|
|
67
|
+
inputs: z.ZodObject<{
|
|
68
|
+
connectors: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
69
|
+
name: z.ZodOptional<z.ZodString>;
|
|
70
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
71
|
+
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
72
|
+
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
73
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
74
|
+
clientId: z.ZodString;
|
|
75
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strict>>;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
}, z.core.$strict>;
|
|
80
|
+
/**
|
|
81
|
+
* `POST …/connector-templates/:templateId/connectors` (ruling P4-T6-8): one more connector from a
|
|
82
|
+
* platform connector template, its name and an install's connector input (`config`).
|
|
83
|
+
*/
|
|
84
|
+
export declare const OrgTemplateConnectorSchema: z.ZodObject<{
|
|
85
|
+
name: z.ZodOptional<z.ZodString>;
|
|
86
|
+
config: z.ZodObject<{
|
|
87
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
88
|
+
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
89
|
+
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
91
|
+
clientId: z.ZodString;
|
|
92
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.core.$strict>>;
|
|
94
|
+
}, z.core.$strict>;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
/** `:templateId` of the template connector route (`@Param`). */
|
|
97
|
+
export declare const ConnectorTemplatePathParams: z.ZodObject<{
|
|
98
|
+
templateId: z.ZodString;
|
|
99
|
+
}, z.core.$strip>;
|
|
57
100
|
/** The switch body: on (with the install inputs), or off (with the preview's hash to confirm). */
|
|
58
101
|
export declare const OrgPluginSwitchBody: z.ZodObject<{
|
|
59
102
|
enabled: z.ZodBoolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { secret, validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { CredentialValue } from "../tools/connectors.schemas.js";
|
|
4
4
|
export const CatalogRequestBody = z
|
|
@@ -49,6 +49,11 @@ export const CatalogMarketplaceRequestBody = z
|
|
|
49
49
|
note: z.string().max(1000).optional(),
|
|
50
50
|
})
|
|
51
51
|
.strict();
|
|
52
|
+
/**
|
|
53
|
+
* One connector template's input at install (C30): name, slug, endpoint, credential or OAuth
|
|
54
|
+
* client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
55
|
+
* operation never takes them as params; the person enters them on the confirmation card.
|
|
56
|
+
*/
|
|
52
57
|
export const CatalogConnectorInput = z
|
|
53
58
|
.object({
|
|
54
59
|
name: z.string().trim().min(1).max(80).optional(),
|
|
@@ -58,7 +63,7 @@ export const CatalogConnectorInput = z
|
|
|
58
63
|
client: z
|
|
59
64
|
.object({
|
|
60
65
|
clientId: z.string().min(1).max(500),
|
|
61
|
-
clientSecret: z.string().min(1).max(4000).optional(),
|
|
66
|
+
clientSecret: secret(z.string().min(1).max(4000)).optional(),
|
|
62
67
|
})
|
|
63
68
|
.strict()
|
|
64
69
|
.optional(),
|
|
@@ -74,6 +79,27 @@ export const OrgPluginInstallBody = z
|
|
|
74
79
|
extensionConfig: z.record(z.string(), z.unknown()).optional(),
|
|
75
80
|
})
|
|
76
81
|
.strict();
|
|
82
|
+
/**
|
|
83
|
+
* `POST …/catalog/:itemId/connectors` (ruling P2-10): the input of missing connectors, by template
|
|
84
|
+
* id, as at install.
|
|
85
|
+
*/
|
|
86
|
+
export const OrgPluginConnectorsSchema = z
|
|
87
|
+
.object({
|
|
88
|
+
inputs: z.object({ connectors: z.record(z.string(), CatalogConnectorInput) }).strict(),
|
|
89
|
+
})
|
|
90
|
+
.strict();
|
|
91
|
+
/**
|
|
92
|
+
* `POST …/connector-templates/:templateId/connectors` (ruling P4-T6-8): one more connector from a
|
|
93
|
+
* platform connector template, its name and an install's connector input (`config`).
|
|
94
|
+
*/
|
|
95
|
+
export const OrgTemplateConnectorSchema = z
|
|
96
|
+
.object({
|
|
97
|
+
name: z.string().trim().min(1).max(80).optional(),
|
|
98
|
+
config: CatalogConnectorInput.omit({ name: true }),
|
|
99
|
+
})
|
|
100
|
+
.strict();
|
|
101
|
+
/** `:templateId` of the template connector route (`@Param`). */
|
|
102
|
+
export const ConnectorTemplatePathParams = z.object({ templateId: z.string().min(1) });
|
|
77
103
|
/** The switch body: on (with the install inputs), or off (with the preview's hash to confirm). */
|
|
78
104
|
export const OrgPluginSwitchBody = z
|
|
79
105
|
.object({
|
|
@@ -127,6 +153,21 @@ export const ORG_CATALOG_ROUTES = [
|
|
|
127
153
|
body: CatalogRequestBody,
|
|
128
154
|
},
|
|
129
155
|
{ route: "POST /api/v1/orgs/:orgId/marketplace-requests", body: CatalogMarketplaceRequestBody },
|
|
156
|
+
{
|
|
157
|
+
route: "POST /api/v1/orgs/:orgId/catalog/:itemId/install",
|
|
158
|
+
params: CatalogItemPathParams,
|
|
159
|
+
body: OrgPluginInstallBody,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
route: "POST /api/v1/orgs/:orgId/catalog/:itemId/connectors",
|
|
163
|
+
params: CatalogItemPathParams,
|
|
164
|
+
body: OrgPluginConnectorsSchema,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
route: "POST /api/v1/orgs/:orgId/connector-templates/:templateId/connectors",
|
|
168
|
+
params: ConnectorTemplatePathParams,
|
|
169
|
+
body: OrgTemplateConnectorSchema,
|
|
170
|
+
},
|
|
130
171
|
{
|
|
131
172
|
route: "PUT /api/v1/orgs/:orgId/catalog/:itemId/switch",
|
|
132
173
|
params: CatalogItemPathParams,
|
|
@@ -40,7 +40,9 @@ export declare class OrgExtensionSwitch {
|
|
|
40
40
|
*/
|
|
41
41
|
put(orgId: string, actor: string, extension: string, body: OrgExtensionInput & {
|
|
42
42
|
confirm?: string | undefined;
|
|
43
|
-
}, actorTokenId?: string
|
|
43
|
+
}, actorTokenId?: string,
|
|
44
|
+
/** Merged into the audit details (a Platform operation's `via: "agent"`). */
|
|
45
|
+
auditDetail?: Record<string, unknown>): Promise<OrgExtensionPutResult>;
|
|
44
46
|
private applyAtomic;
|
|
45
47
|
private apply;
|
|
46
48
|
}
|
|
@@ -44,8 +44,11 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
44
44
|
* keep the direct write.
|
|
45
45
|
* - `config` is always written directly, after the switch.
|
|
46
46
|
*/
|
|
47
|
-
async put(orgId, actor, extension, body, actorTokenId
|
|
47
|
+
async put(orgId, actor, extension, body, actorTokenId,
|
|
48
|
+
/** Merged into the audit details (a Platform operation's `via: "agent"`). */
|
|
49
|
+
auditDetail) {
|
|
48
50
|
const { confirm, ...input } = body;
|
|
51
|
+
const audited = auditDetail !== undefined ? { auditDetail } : {};
|
|
49
52
|
const plan = input.enabled === undefined
|
|
50
53
|
? { kind: "direct" }
|
|
51
54
|
: await this.configs.switchPlan(extension, input.enabled);
|
|
@@ -55,7 +58,7 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
55
58
|
if (plan.kind === "direct") {
|
|
56
59
|
return {
|
|
57
60
|
kind: "done",
|
|
58
|
-
view: await this.configs.put(orgId, extension, input, actor, actorTokenId),
|
|
61
|
+
view: await this.configs.put(orgId, extension, input, actor, actorTokenId, audited),
|
|
59
62
|
};
|
|
60
63
|
}
|
|
61
64
|
const { enabled } = input;
|
|
@@ -79,6 +82,7 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
79
82
|
input,
|
|
80
83
|
confirm,
|
|
81
84
|
actorTokenId,
|
|
85
|
+
auditDetail,
|
|
82
86
|
};
|
|
83
87
|
const r = await (installing ? this.apply(args, true) : this.applyAtomic(args));
|
|
84
88
|
if (r !== "readBack")
|
|
@@ -91,6 +95,7 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
91
95
|
kind: "done",
|
|
92
96
|
view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
|
|
93
97
|
ifDisabled: { skipped: false },
|
|
98
|
+
...audited,
|
|
94
99
|
}),
|
|
95
100
|
};
|
|
96
101
|
}
|
|
@@ -98,7 +103,8 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
98
103
|
return this.apply(a, false);
|
|
99
104
|
}
|
|
100
105
|
async apply(a, installing) {
|
|
101
|
-
const { orgId, actor, extension, itemId, enabled, input, confirm, actorTokenId } = a;
|
|
106
|
+
const { orgId, actor, extension, itemId, enabled, input, confirm, actorTokenId, auditDetail } = a;
|
|
107
|
+
const audited = auditDetail !== undefined ? { auditDetail } : {};
|
|
102
108
|
// Switching on inside the transaction relies on the live install seen before it: one removed
|
|
103
109
|
// meanwhile would run the install saga here, which commits on its own. Refuse instead; the
|
|
104
110
|
// retry takes the install path.
|
|
@@ -111,7 +117,7 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
111
117
|
enabled: true,
|
|
112
118
|
...(input.config !== undefined && { inputs: { extensionConfig: input.config } }),
|
|
113
119
|
}
|
|
114
|
-
: { enabled: false, ...(confirm !== undefined && { confirm }) }, actorTokenId)
|
|
120
|
+
: { enabled: false, ...(confirm !== undefined && { confirm }) }, actorTokenId, auditDetail)
|
|
115
121
|
.catch((e) => {
|
|
116
122
|
throw configInvalidOf(e) ?? e;
|
|
117
123
|
});
|
|
@@ -126,12 +132,13 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
126
132
|
kind: "done",
|
|
127
133
|
view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
|
|
128
134
|
ifDisabled: { skipped: false },
|
|
135
|
+
...audited,
|
|
129
136
|
}),
|
|
130
137
|
};
|
|
131
138
|
}
|
|
132
139
|
return {
|
|
133
140
|
kind: "done",
|
|
134
|
-
view: await this.configs.put(orgId, extension, { config: input.config, ...(enabled && { enabled: true }) }, actor, actorTokenId, installing ? { ifDisabled: { skipped: false } } :
|
|
141
|
+
view: await this.configs.put(orgId, extension, { config: input.config, ...(enabled && { enabled: true }) }, actor, actorTokenId, installing ? { ifDisabled: { skipped: false }, ...audited } : audited),
|
|
135
142
|
};
|
|
136
143
|
}
|
|
137
144
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LocalizedName, SuggestedAppearance } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import type { z } from "zod";
|
|
3
3
|
import { type ClientBuildSummary, ClientBuilds } from "../client/client-builds.service.js";
|
|
4
4
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
5
5
|
import { OrgExtensionConfigs, type OrgExtensionView } from "../extensions/org-config.js";
|
|
@@ -10,27 +10,9 @@ import { type OrgContext } from "../orgs/org.guard.js";
|
|
|
10
10
|
import { type OrgToolSwitch, OrgToolSwitches, type OrgToolSwitchResult } from "../tools/org-tool-switches.js";
|
|
11
11
|
import { AppearanceApplyBody } from "./appearance.schemas.js";
|
|
12
12
|
import { type AppearanceResult, AppearanceService } from "./appearance.service.js";
|
|
13
|
-
import { OrgExtensionParams as ExtensionParams, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut } from "./org-extension.schemas.js";
|
|
13
|
+
import { OrgExtensionParams as ExtensionParams, OrgOverridesPut as OverridesPut, OrgOverridesTake as OverridesTake, OrgExtensionPut as PutBody, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut } from "./org-extension.schemas.js";
|
|
14
14
|
import { OrgExtensionSwitch } from "./org-extension-switch.js";
|
|
15
15
|
import type { UninstallPreview } from "./plugin-install.js";
|
|
16
|
-
declare const PutBody: z.ZodObject<{
|
|
17
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
19
|
-
force: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
-
confirm: z.ZodOptional<z.ZodString>;
|
|
21
|
-
}, z.core.$strict>;
|
|
22
|
-
declare const OverridesPut: z.ZodObject<{
|
|
23
|
-
values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
24
|
-
secretEntries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
-
path: z.ZodString;
|
|
26
|
-
key: z.ZodString;
|
|
27
|
-
value: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
-
renameFrom: z.ZodOptional<z.ZodString>;
|
|
29
|
-
}, z.core.$strict>>>;
|
|
30
|
-
}, z.core.$strict>;
|
|
31
|
-
declare const OverridesTake: z.ZodObject<{
|
|
32
|
-
paths: z.ZodArray<z.ZodString>;
|
|
33
|
-
}, z.core.$strict>;
|
|
34
16
|
/**
|
|
35
17
|
* One extension of the org list: the org view plus the plugin's display name, the URL of its
|
|
36
18
|
* plugin's icon on the org's catalog route (null without one or when the org may not see the
|
|
@@ -130,4 +112,3 @@ export declare class OrgExtensionToolSwitchesController {
|
|
|
130
112
|
*/
|
|
131
113
|
set(principal: Principal, org: OrgContext, { extension, tool }: z.infer<typeof ToolParams>, body: z.infer<typeof ToolSwitchPut>): Promise<OrgToolSwitchResult>;
|
|
132
114
|
}
|
|
133
|
-
export {};
|
|
@@ -8,7 +8,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Delete, Get, HttpCode, Inject, Param, Post, Put } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { ClientBuilds } from "../client/client-builds.service.js";
|
|
13
12
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
14
13
|
import { OrgExtensionConfigs, providesOf, } from "../extensions/org-config.js";
|
|
@@ -22,46 +21,10 @@ import { roleAtLeast } from "../orgs/roles.js";
|
|
|
22
21
|
import { OrgToolSwitches, } from "../tools/org-tool-switches.js";
|
|
23
22
|
import { AppearanceApplyBody } from "./appearance.schemas.js";
|
|
24
23
|
import { AppearanceService } from "./appearance.service.js";
|
|
25
|
-
import { OrgExtensionParams as ExtensionParams, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut, } from "./org-extension.schemas.js";
|
|
24
|
+
import { OrgExtensionParams as ExtensionParams, OrgOverridesPut as OverridesPut, OrgOverridesTake as OverridesTake, OrgExtensionPut as PutBody, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut, } from "./org-extension.schemas.js";
|
|
26
25
|
import { OrgExtensionSwitch } from "./org-extension-switch.js";
|
|
27
|
-
const PutBody = z
|
|
28
|
-
.object({
|
|
29
|
-
enabled: z.boolean().optional(),
|
|
30
|
-
config: z.record(z.string(), z.unknown()).optional(),
|
|
31
|
-
force: z.boolean().optional(),
|
|
32
|
-
/** The hash of the plugin uninstall preview, to confirm switching the extension's plugin off. */
|
|
33
|
-
confirm: z.string().optional(),
|
|
34
|
-
})
|
|
35
|
-
.strict();
|
|
36
26
|
class OrgExtensionPutBody extends createZodDto(PutBody, "OrgExtensionPutBody") {
|
|
37
27
|
}
|
|
38
|
-
const OverrideSecretEntry = z
|
|
39
|
-
.object({
|
|
40
|
-
/** A secret record field of the copy some `x-ui.secrets[].path` names. */
|
|
41
|
-
path: z.string().min(1).max(256),
|
|
42
|
-
key: z.string().min(1).max(256),
|
|
43
|
-
/** A string sets the key, `null` removes it. */
|
|
44
|
-
value: z.string().max(65_536).nullable().optional(),
|
|
45
|
-
/** Moves the value at this key to `key` first. */
|
|
46
|
-
renameFrom: z.string().min(1).max(256).optional(),
|
|
47
|
-
})
|
|
48
|
-
.strict()
|
|
49
|
-
.refine((e) => e.value !== undefined || e.renameFrom !== undefined, {
|
|
50
|
-
message: "an entry needs value or renameFrom",
|
|
51
|
-
})
|
|
52
|
-
.refine((e) => e.key !== "__proto__" && e.renameFrom !== "__proto__", {
|
|
53
|
-
message: "__proto__ is not a valid key",
|
|
54
|
-
});
|
|
55
|
-
const OverridesPut = z
|
|
56
|
-
.object({
|
|
57
|
-
/** Overridable field dot path -> new value (`null` clears); secret fields too. */
|
|
58
|
-
values: z.record(z.string().min(1).max(256), z.unknown()),
|
|
59
|
-
secretEntries: z.array(OverrideSecretEntry).max(200).optional(),
|
|
60
|
-
})
|
|
61
|
-
.strict();
|
|
62
|
-
const OverridesTake = z
|
|
63
|
-
.object({ paths: z.array(z.string().min(1).max(256)).min(1).max(200) })
|
|
64
|
-
.strict();
|
|
65
28
|
class OrgToolSwitchPutBody extends createZodDto(ToolSwitchPut, "OrgToolSwitchPutBody") {
|
|
66
29
|
}
|
|
67
30
|
class OrgExtensionParamsDto extends createZodDto(ExtensionParams, "OrgExtensionParams") {
|
|
@@ -12,4 +12,35 @@ export declare const OrgToolSwitchPut: z.ZodObject<{
|
|
|
12
12
|
enabled: z.ZodBoolean;
|
|
13
13
|
confirm: z.ZodOptional<z.ZodString>;
|
|
14
14
|
}, z.core.$strict>;
|
|
15
|
+
/** `PUT /orgs/:orgId/extensions/:extension`: enablement and / or the org config. */
|
|
16
|
+
export declare const OrgExtensionPut: z.ZodObject<{
|
|
17
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
19
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
confirm: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
/**
|
|
23
|
+
* One key of a secret record of the org's copy. `value` is a secret (`secret()` meta): a Platform
|
|
24
|
+
* operation never takes it as a param (`platform-op-secret-param`).
|
|
25
|
+
*/
|
|
26
|
+
export declare const OrgOverrideSecretEntry: z.ZodObject<{
|
|
27
|
+
path: z.ZodString;
|
|
28
|
+
key: z.ZodString;
|
|
29
|
+
value: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
renameFrom: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
/** `PUT …/overrides`: overridable fields of the org's copy. */
|
|
33
|
+
export declare const OrgOverridesPut: z.ZodObject<{
|
|
34
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
35
|
+
secretEntries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
|
+
path: z.ZodString;
|
|
37
|
+
key: z.ZodString;
|
|
38
|
+
value: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
39
|
+
renameFrom: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>>>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
/** `POST …/overrides/take`: the non-secret fields to take from the platform. */
|
|
43
|
+
export declare const OrgOverridesTake: z.ZodObject<{
|
|
44
|
+
paths: z.ZodArray<z.ZodString>;
|
|
45
|
+
}, z.core.$strict>;
|
|
15
46
|
export declare const ORG_EXTENSION_ROUTES: readonly RouteSchemas[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { secret } from "@capybara-hq/plugin-sdk";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
3
4
|
export const OrgExtensionParams = z.object({ extension: z.string().min(1).max(64) });
|
|
@@ -11,6 +12,50 @@ export const OrgToolSwitchPut = z
|
|
|
11
12
|
confirm: z.string().min(1).max(128).optional(),
|
|
12
13
|
})
|
|
13
14
|
.strict();
|
|
15
|
+
/** `PUT /orgs/:orgId/extensions/:extension`: enablement and / or the org config. */
|
|
16
|
+
export const OrgExtensionPut = z
|
|
17
|
+
.object({
|
|
18
|
+
enabled: z.boolean().optional(),
|
|
19
|
+
/** The whole org config: secret fields omitted keep, `null` clears, a value sets. */
|
|
20
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
21
|
+
force: z.boolean().optional(),
|
|
22
|
+
/** The hash of the plugin uninstall preview, to confirm switching the extension's plugin off. */
|
|
23
|
+
confirm: z.string().optional(),
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
/**
|
|
27
|
+
* One key of a secret record of the org's copy. `value` is a secret (`secret()` meta): a Platform
|
|
28
|
+
* operation never takes it as a param (`platform-op-secret-param`).
|
|
29
|
+
*/
|
|
30
|
+
export const OrgOverrideSecretEntry = z
|
|
31
|
+
.object({
|
|
32
|
+
/** A secret record field of the copy some `x-ui.secrets[].path` names. */
|
|
33
|
+
path: z.string().min(1).max(256),
|
|
34
|
+
key: z.string().min(1).max(256),
|
|
35
|
+
/** A string sets the key, `null` removes it. */
|
|
36
|
+
value: secret(z.string().max(65_536).nullable().optional()),
|
|
37
|
+
/** Moves the value at this key to `key` first. */
|
|
38
|
+
renameFrom: z.string().min(1).max(256).optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict()
|
|
41
|
+
.refine((e) => e.value !== undefined || e.renameFrom !== undefined, {
|
|
42
|
+
message: "an entry needs value or renameFrom",
|
|
43
|
+
})
|
|
44
|
+
.refine((e) => e.key !== "__proto__" && e.renameFrom !== "__proto__", {
|
|
45
|
+
message: "__proto__ is not a valid key",
|
|
46
|
+
});
|
|
47
|
+
/** `PUT …/overrides`: overridable fields of the org's copy. */
|
|
48
|
+
export const OrgOverridesPut = z
|
|
49
|
+
.object({
|
|
50
|
+
/** Overridable field dot path -> new value (`null` clears); secret fields too. */
|
|
51
|
+
values: z.record(z.string().min(1).max(256), z.unknown()),
|
|
52
|
+
secretEntries: z.array(OrgOverrideSecretEntry).max(200).optional(),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
/** `POST …/overrides/take`: the non-secret fields to take from the platform. */
|
|
56
|
+
export const OrgOverridesTake = z
|
|
57
|
+
.object({ paths: z.array(z.string().min(1).max(256)).min(1).max(200) })
|
|
58
|
+
.strict();
|
|
14
59
|
export const ORG_EXTENSION_ROUTES = [
|
|
15
60
|
{ route: "GET /api/v1/orgs/:orgId/extensions" },
|
|
16
61
|
{ route: "GET /api/v1/orgs/:orgId/extensions/:extension/tools", params: OrgExtensionParams },
|
|
@@ -19,4 +64,24 @@ export const ORG_EXTENSION_ROUTES = [
|
|
|
19
64
|
params: OrgExtensionToolParams,
|
|
20
65
|
body: OrgToolSwitchPut,
|
|
21
66
|
},
|
|
67
|
+
{
|
|
68
|
+
route: "PUT /api/v1/orgs/:orgId/extensions/:extension",
|
|
69
|
+
params: OrgExtensionParams,
|
|
70
|
+
body: OrgExtensionPut,
|
|
71
|
+
},
|
|
72
|
+
{ route: "GET /api/v1/orgs/:orgId/extensions/:extension/overrides", params: OrgExtensionParams },
|
|
73
|
+
{
|
|
74
|
+
route: "PUT /api/v1/orgs/:orgId/extensions/:extension/overrides",
|
|
75
|
+
params: OrgExtensionParams,
|
|
76
|
+
body: OrgOverridesPut,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
route: "DELETE /api/v1/orgs/:orgId/extensions/:extension/overrides",
|
|
80
|
+
params: OrgExtensionParams,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
route: "POST /api/v1/orgs/:orgId/extensions/:extension/overrides/take",
|
|
84
|
+
params: OrgExtensionParams,
|
|
85
|
+
body: OrgOverridesTake,
|
|
86
|
+
},
|
|
22
87
|
];
|