@capybara-hq/kernel 0.1.0-rc.148 → 0.1.0-rc.149
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 +29 -29
- package/dist/admin/extensions.controller.d.ts +26 -2
- package/dist/admin/extensions.controller.js +52 -3
- package/dist/admin/extensions.schemas.d.ts +4 -0
- package/dist/admin/extensions.schemas.js +6 -0
- package/dist/catalog/cli.d.ts +3 -2
- package/dist/catalog/cli.js +19 -3
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +3 -0
- package/dist/channels/connection-summary.d.ts +32 -0
- package/dist/channels/connection-summary.js +67 -0
- package/dist/db/kernel-schema.d.ts +27 -0
- package/dist/erasure/org-catalog.js +4 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.d.ts +5 -0
- package/dist/extensions/admin-view.js +19 -2
- package/dist/extensions/config-json-schema.d.ts +10 -6
- package/dist/extensions/config-json-schema.js +12 -8
- package/dist/extensions/deployment-config-store.d.ts +2 -0
- package/dist/extensions/deployment-config.d.ts +1 -1
- package/dist/extensions/deployment-config.js +5 -2
- package/dist/extensions/enabled.d.ts +1 -0
- package/dist/extensions/grant-epoch.d.ts +11 -2
- package/dist/extensions/grant-epoch.js +26 -3
- package/dist/extensions/host.d.ts +3 -0
- package/dist/extensions/host.js +5 -2
- package/dist/extensions/org-overrides.js +1 -1
- package/dist/extensions/permission-view.d.ts +5 -0
- package/dist/net/private-endpoint-preflight.js +1 -1
- package/dist/orgs/directory-sync-state.d.ts +125 -0
- package/dist/orgs/directory-sync-state.js +259 -0
- package/dist/orgs/directory-sync.controller.d.ts +16 -3
- package/dist/orgs/directory-sync.controller.js +29 -5
- package/dist/orgs/directory-sync.d.ts +18 -7
- package/dist/orgs/directory-sync.js +238 -106
- package/dist/orgs/directory-sync.schemas.d.ts +26 -0
- package/dist/orgs/directory-sync.schemas.js +50 -0
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +5 -1
- package/dist/platform/ops/extensions-admin.ops.js +43 -3
- package/dist/platform/ops/extensions.ops.d.ts +3 -1
- package/dist/platform/ops/extensions.ops.js +19 -2
- package/dist/platform/route-schemas.js +3 -0
- package/package.json +2 -2
- package/src/migrations/0240_directory_sync_state.sql +34 -0
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
|
|
10
|
+
import { extensionPointRefs, SDK_VERSION } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { EXTENSION_ORG_COUNT_PAGE_SIZE } from "../admin/extensions.schemas.js";
|
|
@@ -145,6 +145,17 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
145
145
|
const [counts] = await this.orgCountsForSubjects([s]);
|
|
146
146
|
return { ...view, ...counts };
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Refuses a name this deployment does not know (`extension.not_found`) without reading its
|
|
150
|
+
* package: for reads keyed by the name that need nothing of the package.
|
|
151
|
+
*/
|
|
152
|
+
async assertKnown(name) {
|
|
153
|
+
if (this.host.declaredPlugins().some((p) => p.name === name))
|
|
154
|
+
return;
|
|
155
|
+
if ((await this.installs.list()).some((r) => r.name === name))
|
|
156
|
+
return;
|
|
157
|
+
throw new ApiError("extension.not_found", `Extension ${name} is not known to this deployment`);
|
|
158
|
+
}
|
|
148
159
|
/**
|
|
149
160
|
* The review digest of a stored package (the `reviewHash` its extension would show once
|
|
150
161
|
* installed); null when the package cannot be read.
|
|
@@ -296,6 +307,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
296
307
|
version: p.version,
|
|
297
308
|
set: p.permissions,
|
|
298
309
|
install: null,
|
|
310
|
+
provides: p.provides,
|
|
299
311
|
configurable: p.configurable,
|
|
300
312
|
configValid: p.configValid,
|
|
301
313
|
warnings: [],
|
|
@@ -324,6 +336,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
324
336
|
version: r.version,
|
|
325
337
|
set: EMPTY_SET,
|
|
326
338
|
install: r,
|
|
339
|
+
provides: [],
|
|
327
340
|
configurable: false,
|
|
328
341
|
configValid: null,
|
|
329
342
|
broken: detail,
|
|
@@ -331,13 +344,14 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
331
344
|
});
|
|
332
345
|
continue;
|
|
333
346
|
}
|
|
334
|
-
const { set, configurable, warnings } = info;
|
|
347
|
+
const { set, configurable, warnings, provides } = info;
|
|
335
348
|
out.push({
|
|
336
349
|
name: r.name,
|
|
337
350
|
source: "install",
|
|
338
351
|
version: r.version,
|
|
339
352
|
set,
|
|
340
353
|
install: r,
|
|
354
|
+
provides,
|
|
341
355
|
configurable,
|
|
342
356
|
configValid: null,
|
|
343
357
|
warnings,
|
|
@@ -358,6 +372,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
358
372
|
cached = {
|
|
359
373
|
set: permissionSetOfPackage(pkg),
|
|
360
374
|
warnings: migrationWarnings(pkg.migrationSql, pkg.section.manifest.name),
|
|
375
|
+
provides: extensionPointRefs(pkg.section.manifest.provides),
|
|
361
376
|
};
|
|
362
377
|
if (this.packageSets.size >= PACKAGE_SET_CACHE_MAX)
|
|
363
378
|
this.packageSets.clear();
|
|
@@ -498,6 +513,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
498
513
|
sensitive: false,
|
|
499
514
|
warnings: [],
|
|
500
515
|
snapshot: snapshotView(snap),
|
|
516
|
+
provides: s.provides,
|
|
501
517
|
configurable: false,
|
|
502
518
|
configValid,
|
|
503
519
|
removable: install?.required !== true,
|
|
@@ -552,6 +568,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
552
568
|
sensitive: permissions.some((g) => g.sensitive),
|
|
553
569
|
warnings: s.warnings,
|
|
554
570
|
snapshot: snapshotView(snap),
|
|
571
|
+
provides: s.provides,
|
|
555
572
|
configurable: s.configurable,
|
|
556
573
|
configValid,
|
|
557
574
|
removable: s.source === "install" && install?.required !== true,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (`configJsonSchema`, extension config forms spec §4.1) so the packer, the checks and the kernel
|
|
4
4
|
* share one implementation; the kernel keeps no copy.
|
|
5
5
|
*/
|
|
6
|
-
import { type ConfigUiProblem, type JsonSchema } from "@capybara-hq/plugin-sdk";
|
|
6
|
+
import { type ConfigUiProblem, type JsonSchema, type ValidateConfigUiOptions } from "@capybara-hq/plugin-sdk";
|
|
7
7
|
import type { z } from "zod";
|
|
8
8
|
export { configJsonSchema as configToJsonSchema, type JsonSchema } from "@capybara-hq/plugin-sdk";
|
|
9
9
|
/** The config level a schema belongs to (which hints `validateConfigUi` allows). */
|
|
@@ -21,11 +21,15 @@ export interface ConfigFormSchema {
|
|
|
21
21
|
export declare function stripConfigUi(node: unknown): void;
|
|
22
22
|
/**
|
|
23
23
|
* Validates the hints of a JSON Schema at a level and strips every `x-ui` when there is any
|
|
24
|
-
* problem (in place): invalid hints never reach a form, and never fail a load (spec §4.1).
|
|
24
|
+
* problem (in place): invalid hints never reach a form, and never fail a load (spec §4.1). With
|
|
25
|
+
* `provides` (the extension's points), a `capability` hint naming another point is a problem too.
|
|
25
26
|
*/
|
|
26
|
-
export declare function checkConfigUi(schema: JsonSchema, level: ConfigLevel): ConfigUiProblem[];
|
|
27
|
-
/**
|
|
28
|
-
|
|
27
|
+
export declare function checkConfigUi(schema: JsonSchema, level: ConfigLevel, opts?: ValidateConfigUiOptions): ConfigUiProblem[];
|
|
28
|
+
/**
|
|
29
|
+
* A config schema's form JSON Schema ({@link checkConfigUi} applied), cached per schema object.
|
|
30
|
+
* A deployment schema belongs to one manifest, so every caller passes that manifest's `provides`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function configFormSchema(schema: z.ZodTypeAny, level: ConfigLevel, opts?: ValidateConfigUiOptions): ConfigFormSchema;
|
|
29
33
|
/**
|
|
30
34
|
* {@link configFormSchema} that never throws, for every caller that serves a form schema or reads
|
|
31
35
|
* its messages (deployment, connection, issues). A hint conversion that throws (a hand-made
|
|
@@ -33,7 +37,7 @@ export declare function configFormSchema(schema: z.ZodTypeAny, level: ConfigLeve
|
|
|
33
37
|
* `x-ui` stripped, else `null` when even the plain conversion fails. `onFallback` runs once per
|
|
34
38
|
* schema object and level on this replica (the caller's one warning); later calls reuse the result.
|
|
35
39
|
*/
|
|
36
|
-
export declare function safeConfigFormSchema(schema: z.ZodTypeAny, level: ConfigLevel, onFallback: (err: unknown, fallback: "plain" | "none") => void): ConfigFormSchema | null;
|
|
40
|
+
export declare function safeConfigFormSchema(schema: z.ZodTypeAny, level: ConfigLevel, onFallback: (err: unknown, fallback: "plain" | "none") => void, opts?: ValidateConfigUiOptions): ConfigFormSchema | null;
|
|
37
41
|
/**
|
|
38
42
|
* The secret record paths some `x-ui.secrets[].path` of a form schema names (spec §4.3), anywhere in
|
|
39
43
|
* the schema. Read from a checked schema: one whose hints were invalid was stripped and names none.
|
|
@@ -35,10 +35,11 @@ export function stripConfigUi(node) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Validates the hints of a JSON Schema at a level and strips every `x-ui` when there is any
|
|
38
|
-
* problem (in place): invalid hints never reach a form, and never fail a load (spec §4.1).
|
|
38
|
+
* problem (in place): invalid hints never reach a form, and never fail a load (spec §4.1). With
|
|
39
|
+
* `provides` (the extension's points), a `capability` hint naming another point is a problem too.
|
|
39
40
|
*/
|
|
40
|
-
export function checkConfigUi(schema, level) {
|
|
41
|
-
const problems = validateConfigUi(schema, level);
|
|
41
|
+
export function checkConfigUi(schema, level, opts = {}) {
|
|
42
|
+
const problems = validateConfigUi(schema, level, opts);
|
|
42
43
|
if (problems.length > 0)
|
|
43
44
|
stripConfigUi(schema);
|
|
44
45
|
return problems;
|
|
@@ -48,13 +49,16 @@ const caches = {
|
|
|
48
49
|
deployment: new WeakMap(),
|
|
49
50
|
connection: new WeakMap(),
|
|
50
51
|
};
|
|
51
|
-
/**
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* A config schema's form JSON Schema ({@link checkConfigUi} applied), cached per schema object.
|
|
54
|
+
* A deployment schema belongs to one manifest, so every caller passes that manifest's `provides`.
|
|
55
|
+
*/
|
|
56
|
+
export function configFormSchema(schema, level, opts = {}) {
|
|
53
57
|
const cache = caches[level];
|
|
54
58
|
let r = cache.get(schema);
|
|
55
59
|
if (!r) {
|
|
56
60
|
const js = configJsonSchema(schema);
|
|
57
|
-
r = { schema: js, problems: checkConfigUi(js, level) };
|
|
61
|
+
r = { schema: js, problems: checkConfigUi(js, level, opts) };
|
|
58
62
|
cache.set(schema, r);
|
|
59
63
|
}
|
|
60
64
|
return r;
|
|
@@ -71,12 +75,12 @@ const fallbacks = {
|
|
|
71
75
|
* `x-ui` stripped, else `null` when even the plain conversion fails. `onFallback` runs once per
|
|
72
76
|
* schema object and level on this replica (the caller's one warning); later calls reuse the result.
|
|
73
77
|
*/
|
|
74
|
-
export function safeConfigFormSchema(schema, level, onFallback) {
|
|
78
|
+
export function safeConfigFormSchema(schema, level, onFallback, opts = {}) {
|
|
75
79
|
const failed = fallbacks[level].get(schema);
|
|
76
80
|
if (failed !== undefined)
|
|
77
81
|
return failed;
|
|
78
82
|
try {
|
|
79
|
-
return configFormSchema(schema, level);
|
|
83
|
+
return configFormSchema(schema, level, opts);
|
|
80
84
|
}
|
|
81
85
|
catch (err) {
|
|
82
86
|
let r = null;
|
|
@@ -22,6 +22,8 @@ export interface DeploymentSchemaInfo {
|
|
|
22
22
|
* (`extension.configSchemas.deployment`), shown but never used to validate.
|
|
23
23
|
*/
|
|
24
24
|
jsonSchema?: JsonSchema | undefined;
|
|
25
|
+
/** The extension points the extension provides (its `capability` hints must name one). */
|
|
26
|
+
provides?: readonly string[] | undefined;
|
|
25
27
|
fields: {
|
|
26
28
|
path: string;
|
|
27
29
|
secret: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedName } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { core } from "zod";
|
|
3
3
|
import type { KernelAppOptions } from "../app.js";
|
|
4
4
|
import { type ConfigSourceKind } from "../config/sources.js";
|
|
@@ -8,6 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { isDeepStrictEqual } from "node:util";
|
|
11
|
+
import { extensionPointRefs, } from "@capybara-hq/plugin-sdk";
|
|
11
12
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
13
|
import { configFields, describeSchema, getPath, secretValues } from "../config/fields.js";
|
|
13
14
|
import { configSourceKind, extensionConfigSources, fieldSource, } from "../config/sources.js";
|
|
@@ -487,7 +488,7 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
487
488
|
formSchemaOf(plugin, info) {
|
|
488
489
|
if (!info.schema)
|
|
489
490
|
return info.jsonSchema;
|
|
490
|
-
const r = safeConfigFormSchema(info.schema, "deployment", (err, schema) => this.log.warn("the deployment config form schema could not be built with its UI hints; hints dropped", { plugin, version: info.version, schema, err }));
|
|
491
|
+
const r = safeConfigFormSchema(info.schema, "deployment", (err, schema) => this.log.warn("the deployment config form schema could not be built with its UI hints; hints dropped", { plugin, version: info.version, schema, err }), { provides: info.provides ?? [] });
|
|
491
492
|
return r?.schema;
|
|
492
493
|
}
|
|
493
494
|
messagesOf(plugin, info) {
|
|
@@ -596,7 +597,9 @@ export async function staticDeploymentSchema(db, plugin) {
|
|
|
596
597
|
let jsonSchema;
|
|
597
598
|
if (typeof stored === "object" && stored !== null && !Array.isArray(stored)) {
|
|
598
599
|
jsonSchema = structuredClone(stored);
|
|
599
|
-
checkConfigUi(jsonSchema, "deployment"
|
|
600
|
+
checkConfigUi(jsonSchema, "deployment", {
|
|
601
|
+
provides: extensionPointRefs(section.manifest.provides ?? []),
|
|
602
|
+
});
|
|
600
603
|
}
|
|
601
604
|
return {
|
|
602
605
|
version: row.version,
|
|
@@ -98,6 +98,7 @@ export declare function extensionOrgCountsQuery(db: KernelSchemaDb, names: reado
|
|
|
98
98
|
device_site_grants: import("../db/kernel-schema.js").DeviceSiteGrantsTable;
|
|
99
99
|
devices: import("../db/kernel-schema.js").DevicesTable;
|
|
100
100
|
directory_exclusions: import("../db/kernel-schema.js").DirectoryExclusionsTable;
|
|
101
|
+
directory_sync_state: import("../db/kernel-schema.js").DirectorySyncStateTable;
|
|
101
102
|
en: {
|
|
102
103
|
org_id: string;
|
|
103
104
|
plugin: string;
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* ({@link FENCE_SLACK_MS}, 1 s) never push a refusal past the bound. For a revocation that commits
|
|
13
13
|
* after the start `t` of the last read that saw the old epoch (that read's snapshot predates the
|
|
14
14
|
* commit):
|
|
15
|
-
* - admissions: a cached grant is trusted only until `t + maxAgeMs` (3 s by default)
|
|
15
|
+
* - admissions: a cached grant is trusted only until `t + maxAgeMs` (3 s by default), and a caller
|
|
16
|
+
* waiting for a fresh read is answered by `t + 4 s` at the latest ({@link GrantEpoch.ensureFresh}):
|
|
17
|
+
* a hung read never holds a refusal past the fence deadline;
|
|
16
18
|
* - in-flight work: when a later read sees the change, work not revalidated at the new epoch is
|
|
17
19
|
* fenced at `t + 4 s` ({@link GrantEpochOptions.onSettleDeadline}), at once if that time has
|
|
18
20
|
* passed, however slow the reads in between were;
|
|
@@ -99,7 +101,14 @@ export declare class GrantEpoch {
|
|
|
99
101
|
* first read or when stopped (the `grant_epoch_lag` gauge).
|
|
100
102
|
*/
|
|
101
103
|
lagSeconds(): number | undefined;
|
|
102
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* The fresh epoch, reading PostgreSQL first when needed; undefined when that read fails. After a
|
|
106
|
+
* successful read at `t`, a caller never waits past `t + FENCE_DEADLINE_MS`: the read may run
|
|
107
|
+
* until its own timeout, which can end at `t + 2 * maxAgeMs - pollMs` (the 5 s bound at the
|
|
108
|
+
* default age, past it with a larger one), so
|
|
109
|
+
* the wait is cut at the fence deadline, and past it the caller is refused at once. The read is
|
|
110
|
+
* still started (or joined) so the next caller sees the epoch as soon as PostgreSQL answers.
|
|
111
|
+
*/
|
|
103
112
|
ensureFresh(): Promise<string | undefined>;
|
|
104
113
|
/** One read at a time; concurrent callers share it. It settles within the read timeout. */
|
|
105
114
|
refresh(): Promise<string | undefined>;
|
|
@@ -15,7 +15,9 @@ import { KERNEL_APPLICATION_NAME } from "../db/pool.js";
|
|
|
15
15
|
* ({@link FENCE_SLACK_MS}, 1 s) never push a refusal past the bound. For a revocation that commits
|
|
16
16
|
* after the start `t` of the last read that saw the old epoch (that read's snapshot predates the
|
|
17
17
|
* commit):
|
|
18
|
-
* - admissions: a cached grant is trusted only until `t + maxAgeMs` (3 s by default)
|
|
18
|
+
* - admissions: a cached grant is trusted only until `t + maxAgeMs` (3 s by default), and a caller
|
|
19
|
+
* waiting for a fresh read is answered by `t + 4 s` at the latest ({@link GrantEpoch.ensureFresh}):
|
|
20
|
+
* a hung read never holds a refusal past the fence deadline;
|
|
19
21
|
* - in-flight work: when a later read sees the change, work not revalidated at the new epoch is
|
|
20
22
|
* fenced at `t + 4 s` ({@link GrantEpochOptions.onSettleDeadline}), at once if that time has
|
|
21
23
|
* passed, however slow the reads in between were;
|
|
@@ -147,9 +149,30 @@ export class GrantEpoch {
|
|
|
147
149
|
return undefined;
|
|
148
150
|
return Math.max(0, this.now() - this.readAt) / 1000;
|
|
149
151
|
}
|
|
150
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* The fresh epoch, reading PostgreSQL first when needed; undefined when that read fails. After a
|
|
154
|
+
* successful read at `t`, a caller never waits past `t + FENCE_DEADLINE_MS`: the read may run
|
|
155
|
+
* until its own timeout, which can end at `t + 2 * maxAgeMs - pollMs` (the 5 s bound at the
|
|
156
|
+
* default age, past it with a larger one), so
|
|
157
|
+
* the wait is cut at the fence deadline, and past it the caller is refused at once. The read is
|
|
158
|
+
* still started (or joined) so the next caller sees the epoch as soon as PostgreSQL answers.
|
|
159
|
+
*/
|
|
151
160
|
async ensureFresh() {
|
|
152
|
-
|
|
161
|
+
const fresh = this.fresh();
|
|
162
|
+
if (fresh !== undefined)
|
|
163
|
+
return fresh;
|
|
164
|
+
const reading = this.refresh();
|
|
165
|
+
// never read on this replica: nothing was trusted, so there is no deadline to keep
|
|
166
|
+
if (this.readAt === Number.NEGATIVE_INFINITY)
|
|
167
|
+
return reading;
|
|
168
|
+
const left = this.readAt + FENCE_DEADLINE_MS - this.now();
|
|
169
|
+
if (left <= 0)
|
|
170
|
+
return undefined;
|
|
171
|
+
let timer;
|
|
172
|
+
const deadline = new Promise((resolve) => {
|
|
173
|
+
timer = this.timer(() => resolve(undefined), left);
|
|
174
|
+
});
|
|
175
|
+
return Promise.race([reading, deadline]).finally(() => clearTimeout(timer));
|
|
153
176
|
}
|
|
154
177
|
/** One read at a time; concurrent callers share it. It settles within the read timeout. */
|
|
155
178
|
refresh() {
|
|
@@ -125,6 +125,8 @@ export interface DeclaredExtensionInfo {
|
|
|
125
125
|
configValid: boolean;
|
|
126
126
|
/** The plugin.json `displayName` of the module's plugin directory, if any. */
|
|
127
127
|
displayName: LocalizedName | null;
|
|
128
|
+
/** The extension points the manifest provides, in declared order. */
|
|
129
|
+
provides: string[];
|
|
128
130
|
}
|
|
129
131
|
/** The extension sources of {@link ExtensionHost.load}, loaded in this order (see {@link ExtensionSource}). */
|
|
130
132
|
export interface ExtensionLoadPlan {
|
|
@@ -730,6 +732,7 @@ export declare class ExtensionHost {
|
|
|
730
732
|
deploymentSchema(plugin: string): {
|
|
731
733
|
version: string;
|
|
732
734
|
schema: core.$ZodType | undefined;
|
|
735
|
+
provides: readonly string[];
|
|
733
736
|
} | undefined;
|
|
734
737
|
/** 在本副本生效、声明了部署级配置的插件。 */
|
|
735
738
|
configurablePlugins(): string[];
|
package/dist/extensions/host.js
CHANGED
|
@@ -1886,7 +1886,9 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1886
1886
|
if (!schema)
|
|
1887
1887
|
continue;
|
|
1888
1888
|
try {
|
|
1889
|
-
const { problems } = configFormSchema(schema, level
|
|
1889
|
+
const { problems } = configFormSchema(schema, level, {
|
|
1890
|
+
provides: manifest.provides,
|
|
1891
|
+
});
|
|
1890
1892
|
if (problems.length > 0)
|
|
1891
1893
|
parts.push(describeConfigUiProblems(level, problems));
|
|
1892
1894
|
}
|
|
@@ -2240,6 +2242,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
2240
2242
|
configValid: this.configValidity.get(name) ??
|
|
2241
2243
|
(schema ? parseLoadGate(schema, this.extensionConfig[name] ?? {}).success : true),
|
|
2242
2244
|
displayName: this.declaredDisplayNames.get(name) ?? null,
|
|
2245
|
+
provides: extensionPointRefs(d.manifest.provides),
|
|
2243
2246
|
};
|
|
2244
2247
|
});
|
|
2245
2248
|
}
|
|
@@ -2722,7 +2725,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
2722
2725
|
const m = this.registry.current(plugin)?.manifest ??
|
|
2723
2726
|
this.declaredInfo.get(plugin)?.manifest ??
|
|
2724
2727
|
this.importedManifests.get(plugin)?.manifest;
|
|
2725
|
-
return m && { version: m.version, schema: m.config?.deployment };
|
|
2728
|
+
return m && { version: m.version, schema: m.config?.deployment, provides: m.provides };
|
|
2726
2729
|
}
|
|
2727
2730
|
/** 在本副本生效、声明了部署级配置的插件。 */
|
|
2728
2731
|
configurablePlugins() {
|
|
@@ -355,7 +355,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
355
355
|
formSchemaOf(plugin, run) {
|
|
356
356
|
if (!run.schema)
|
|
357
357
|
return undefined;
|
|
358
|
-
const r = safeConfigFormSchema(run.schema, "deployment", (err, fallback) => this.log.warn("the deployment config form schema could not be built with its UI hints; hints dropped", { plugin, version: run.inst.manifest.version, schema: fallback, err }));
|
|
358
|
+
const r = safeConfigFormSchema(run.schema, "deployment", (err, fallback) => this.log.warn("the deployment config form schema could not be built with its UI hints; hints dropped", { plugin, version: run.inst.manifest.version, schema: fallback, err }), { provides: run.inst.manifest.provides });
|
|
359
359
|
return r?.schema;
|
|
360
360
|
}
|
|
361
361
|
async lockedRow(orgId, plugin) {
|
|
@@ -150,6 +150,11 @@ export interface AdminExtensionView {
|
|
|
150
150
|
approvedBy: string | null;
|
|
151
151
|
source: "cli" | "auto" | "web" | "bootstrap";
|
|
152
152
|
} | null;
|
|
153
|
+
/**
|
|
154
|
+
* The extension points the manifest provides, in declared order (the Extension tab draws one
|
|
155
|
+
* section per point in this order); empty when the package cannot be read.
|
|
156
|
+
*/
|
|
157
|
+
provides: string[];
|
|
153
158
|
/** 有部署级配置字段。 */
|
|
154
159
|
configurable: boolean;
|
|
155
160
|
configValid: boolean;
|
|
@@ -37,7 +37,7 @@ export const BROKERED_ENDPOINT_PINS = [
|
|
|
37
37
|
alias: "object-store",
|
|
38
38
|
methods: ["GET", "HEAD", "PUT", "POST", "DELETE"],
|
|
39
39
|
target: s3Target,
|
|
40
|
-
ctxNetFrom:
|
|
40
|
+
ctxNetFrom: "0.1.0-rc.15",
|
|
41
41
|
},
|
|
42
42
|
];
|
|
43
43
|
export const PRIVATE_ENDPOINTS_DOC = "docs/deploy/upgrade.md#private-endpoints-for-plugin-egress";
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { Redis } from "ioredis";
|
|
2
|
+
import type { DirectorySyncCountsJson } from "../db/kernel-schema.js";
|
|
3
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
|
+
/** The run lock's TTL (renewed while held); a crashed holder's lock expires within it. */
|
|
6
|
+
export declare const DIRECTORY_SYNC_LOCK_TTL_MS = 30000;
|
|
7
|
+
/** The `LockService` key of one (org, extension) sync: one sync at a time. */
|
|
8
|
+
export declare const directorySyncLockKey: (orgId: string, plugin: string) => string;
|
|
9
|
+
/** What started a sync: the hourly scan, an inbound `directory_changed` hint, an admin. */
|
|
10
|
+
export type DirectorySyncTrigger = "schedule" | "changed" | "manual";
|
|
11
|
+
/**
|
|
12
|
+
* How a run ended: every member listed and processed (`synced`); listed but not complete enough to
|
|
13
|
+
* remove anyone (`partial`: member failures, a change during the run, the extension no longer
|
|
14
|
+
* eligible, the lock lost before the removals); stopped by the mass-removal guard
|
|
15
|
+
* (`removal_blocked`, Ruling A17); the listing did not finish (`failed`).
|
|
16
|
+
*/
|
|
17
|
+
export type DirectorySyncOutcome = "synced" | "partial" | "removal_blocked" | "failed";
|
|
18
|
+
/** The kernel's word for why a run was `failed` or `partial`. */
|
|
19
|
+
export type DirectorySyncErrorCode = "list_failed" | "page_limit" | "cursor_loop" | "timeout" | "member_failures" | "changed_during_sync" | "no_longer_eligible" | "lock_lost";
|
|
20
|
+
export type DirectorySyncCounts = DirectorySyncCountsJson;
|
|
21
|
+
/** The directory sync state of one (org, extension), as the org's page reads it. */
|
|
22
|
+
export interface DirectorySyncState {
|
|
23
|
+
orgId: string;
|
|
24
|
+
plugin: string;
|
|
25
|
+
/** When the current run took its lock; null when no run is recorded as running. */
|
|
26
|
+
runningSince: string | null;
|
|
27
|
+
/** A run holds the lock now (a crashed run's stale `runningSince` reads as false). */
|
|
28
|
+
running: boolean;
|
|
29
|
+
lastStartedAt: string | null;
|
|
30
|
+
lastFinishedAt: string | null;
|
|
31
|
+
lastTrigger: DirectorySyncTrigger | null;
|
|
32
|
+
lastOutcome: DirectorySyncOutcome | null;
|
|
33
|
+
lastCounts: DirectorySyncCounts | null;
|
|
34
|
+
lastErrorCode: DirectorySyncErrorCode | null;
|
|
35
|
+
/** The extension's message, truncated, with the org's secret config values masked. */
|
|
36
|
+
lastError: string | null;
|
|
37
|
+
/** The end of the last `synced` run. */
|
|
38
|
+
lastSuccessAt: string | null;
|
|
39
|
+
/** `failed` runs in a row (0 after any other outcome). */
|
|
40
|
+
consecutiveFailures: number;
|
|
41
|
+
/** The org's members this directory added (live count). */
|
|
42
|
+
people: number;
|
|
43
|
+
}
|
|
44
|
+
/** One org of the platform's directory list of an extension. */
|
|
45
|
+
export interface DirectorySyncOrgRow {
|
|
46
|
+
orgId: string;
|
|
47
|
+
orgName: string;
|
|
48
|
+
/** Whether the org follows the platform's config or keeps its own copy (since when). */
|
|
49
|
+
config: {
|
|
50
|
+
kind: "platform";
|
|
51
|
+
} | {
|
|
52
|
+
kind: "own";
|
|
53
|
+
since: string;
|
|
54
|
+
};
|
|
55
|
+
people: number;
|
|
56
|
+
lastFinishedAt: string | null;
|
|
57
|
+
lastOutcome: DirectorySyncOutcome | null;
|
|
58
|
+
lastErrorCode: DirectorySyncErrorCode | null;
|
|
59
|
+
lastError: string | null;
|
|
60
|
+
}
|
|
61
|
+
/** The outcomes the platform list's `attention` filter keeps. */
|
|
62
|
+
export declare const ATTENTION_OUTCOMES: readonly DirectorySyncOutcome[];
|
|
63
|
+
/** Rows per page of the platform list. */
|
|
64
|
+
export declare const DIRECTORY_ORG_PAGE_SIZE = 50;
|
|
65
|
+
/** Characters of a stored error message. */
|
|
66
|
+
export declare const SYNC_ERROR_MAX_CHARS = 500;
|
|
67
|
+
/**
|
|
68
|
+
* An extension's error message as stored: every secret value replaced by `***` (longest first, so
|
|
69
|
+
* a secret that contains another is masked whole), then truncated to {@link SYNC_ERROR_MAX_CHARS}
|
|
70
|
+
* characters. Masking runs before truncation so a cut can never leave half a secret.
|
|
71
|
+
*/
|
|
72
|
+
export declare function redactSyncError(message: string, secrets: readonly string[]): string;
|
|
73
|
+
/**
|
|
74
|
+
* Directory sync state per (org, directory extension) (`capybara.directory_sync_state`, RLS):
|
|
75
|
+
* `DirectorySync` marks a run started when it takes the lock and records the outcome in the
|
|
76
|
+
* transaction of its `org.directory.synced` audit row; the org's page and the platform list read
|
|
77
|
+
* it. No process state: a crashed run leaves `running_since`, which reads as not running once the
|
|
78
|
+
* run lock is gone.
|
|
79
|
+
*/
|
|
80
|
+
export declare class DirectorySyncStates {
|
|
81
|
+
private readonly db;
|
|
82
|
+
readonly txHost: TransactionHost;
|
|
83
|
+
private readonly redis;
|
|
84
|
+
constructor(db: KernelDb, txHost: TransactionHost, redis: Pick<Redis, "exists">);
|
|
85
|
+
/**
|
|
86
|
+
* A run took the lock (intent first: visible as running until it ends or the lock lapses).
|
|
87
|
+
* Returns the recorded start, which the run passes to {@link markFinished}.
|
|
88
|
+
*/
|
|
89
|
+
markStarted(orgId: string, plugin: string, trigger: DirectorySyncTrigger, now?: Date): Promise<Date>;
|
|
90
|
+
/**
|
|
91
|
+
* A run ended: its outcome, counts and (for `failed` / `partial`) the reason. Joins the caller's
|
|
92
|
+
* transaction, the one that writes the run's `org.directory.synced` audit row. `error` must
|
|
93
|
+
* already be redacted ({@link redactSyncError}); it is truncated again here as a guard.
|
|
94
|
+
* Written only while the row's start is still `startedAt`: a run that lost its lock never
|
|
95
|
+
* overwrites the state of a newer run that took it since. Returns whether it was written.
|
|
96
|
+
*/
|
|
97
|
+
markFinished(orgId: string, plugin: string, startedAt: Date, result: {
|
|
98
|
+
outcome: DirectorySyncOutcome;
|
|
99
|
+
counts: DirectorySyncCounts;
|
|
100
|
+
errorCode?: DirectorySyncErrorCode | undefined;
|
|
101
|
+
error?: string | undefined;
|
|
102
|
+
}, now?: Date): Promise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* The org's state for `plugin`, or null when no run was ever recorded. Runs under the caller's
|
|
105
|
+
* org scope. `running`: `runningSince` is set and either younger than the lock TTL or the run
|
|
106
|
+
* lock is still held (a long run renews it); a crashed run's row reads as not running once its
|
|
107
|
+
* lock lapsed.
|
|
108
|
+
*/
|
|
109
|
+
get(orgId: string, plugin: string, now?: Date): Promise<DirectorySyncState | null>;
|
|
110
|
+
private isRunning;
|
|
111
|
+
/**
|
|
112
|
+
* The orgs where `plugin` is enabled, with their directory state, by org name: whether each
|
|
113
|
+
* follows the platform's config or keeps its own copy, its directory members, the last run.
|
|
114
|
+
* `attention` keeps the orgs whose last run was `failed`, `partial` or `removal_blocked`.
|
|
115
|
+
* Deployment-wide (super admin).
|
|
116
|
+
*/
|
|
117
|
+
listForPlugin(plugin: string, opts?: {
|
|
118
|
+
cursor?: string | undefined;
|
|
119
|
+
attention?: boolean;
|
|
120
|
+
limit?: number;
|
|
121
|
+
}): Promise<{
|
|
122
|
+
items: DirectorySyncOrgRow[];
|
|
123
|
+
next: string | null;
|
|
124
|
+
}>;
|
|
125
|
+
}
|