@capybara-hq/kernel 0.1.0-rc.76 → 0.1.0-rc.78
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 +6 -6
- package/dist/admin/outbox-dead.service.js +4 -1
- package/dist/agents/admin-agents.js +2 -0
- package/dist/agents/agent-lookup.js +4 -0
- package/dist/agents/agent-profile.service.js +3 -0
- package/dist/agents/agents.service.js +7 -0
- package/dist/agents/org-templates.js +1 -0
- package/dist/agents/pending-connector-requests.js +6 -0
- package/dist/agents/pending-connectors.service.js +2 -0
- package/dist/agents/readiness.service.d.ts +9 -3
- package/dist/agents/readiness.service.js +3 -3
- package/dist/agents/templates.js +1 -0
- package/dist/background/finish.js +3 -0
- package/dist/background/stop.js +2 -0
- package/dist/background/store.js +44 -0
- package/dist/background/tasks.service.js +3 -2
- package/dist/background/wake-rules.js +1 -0
- package/dist/catalog/admin-catalog.controller.d.ts +6 -0
- package/dist/catalog/admin-catalog.controller.js +13 -0
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-content.js +1 -0
- package/dist/catalog/catalog-items.js +4 -0
- package/dist/catalog/catalog-scope.service.js +4 -1
- package/dist/catalog/component-promotion.js +2 -0
- package/dist/catalog/component-scope.controller.d.ts +9 -15
- package/dist/catalog/component-scope.controller.js +14 -9
- package/dist/catalog/component-scope.service.js +5 -0
- package/dist/catalog/component-state.js +2 -0
- package/dist/catalog/marketplaces.service.d.ts +6 -1
- package/dist/catalog/marketplaces.service.js +8 -3
- package/dist/catalog/org-catalog.controller.d.ts +9 -0
- package/dist/catalog/org-catalog.controller.js +18 -0
- package/dist/catalog/org-catalog.schemas.d.ts +2 -4
- package/dist/catalog/org-catalog.schemas.js +2 -3
- package/dist/catalog/org-catalog.service.d.ts +10 -1
- package/dist/catalog/org-catalog.service.js +34 -23
- package/dist/catalog/org-extension-switch.d.ts +3 -10
- package/dist/catalog/org-extension-switch.js +14 -60
- package/dist/catalog/org-extension.controller.d.ts +6 -7
- package/dist/catalog/org-extension.controller.js +4 -4
- package/dist/catalog/org-extension.schemas.d.ts +1 -2
- package/dist/catalog/org-extension.schemas.js +1 -3
- package/dist/catalog/owned-items.js +10 -1
- package/dist/catalog/ownership.js +2 -0
- package/dist/catalog/plugin-import.js +8 -0
- package/dist/catalog/plugin-install.d.ts +1 -4
- package/dist/catalog/plugin-install.js +11 -12
- package/dist/catalog/plugin-upgrade.js +4 -1
- package/dist/catalog/request-rules.js +6 -0
- package/dist/catalog/requests.service.js +4 -0
- package/dist/catalog/scope-orgs.js +1 -0
- package/dist/catalog/scope-sync.d.ts +8 -5
- package/dist/catalog/scope-sync.js +21 -23
- package/dist/catalog/unshare.js +3 -0
- package/dist/channels/connections.service.js +1 -0
- package/dist/channels/inbound.js +1 -0
- package/dist/channels/jobs.js +1 -0
- package/dist/channels/outbound.js +6 -0
- package/dist/channels/supervisor.js +1 -0
- package/dist/channels/threads.js +1 -0
- package/dist/client/client-reports.service.js +1 -0
- package/dist/config/fields.js +20 -4
- package/dist/conversations/access.js +1 -0
- package/dist/conversations/attachments.service.js +16 -4
- package/dist/conversations/conversations.service.js +17 -3
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +3 -1
- package/dist/conversations/files.js +3 -2
- package/dist/conversations/permission-profiles.service.js +1 -0
- package/dist/conversations/prompt-suggestions.js +2 -0
- package/dist/conversations/queue.js +8 -0
- package/dist/conversations/queue.service.js +6 -2
- package/dist/conversations/source.js +2 -0
- package/dist/conversations/titles.js +10 -2
- package/dist/conversations/tree.js +6 -0
- package/dist/db/kernel-schema.d.ts +3 -1
- package/dist/devices/conversation-devices.js +3 -0
- package/dist/devices/device-projects.service.js +2 -0
- package/dist/devices/devices.service.js +5 -0
- package/dist/devices/legacy-cleanup.job.js +5 -2
- package/dist/dial-in/handlers.js +2 -0
- package/dist/dial-in/machines.js +11 -2
- package/dist/dial-in/targets.d.ts +0 -2
- package/dist/dial-in/targets.js +0 -10
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/evals/budget.js +14 -1
- package/dist/evals/run-replay.js +4 -0
- package/dist/evals/runs.service.js +13 -7
- package/dist/evals/sets.service.js +23 -8
- package/dist/evals/trajectory.service.d.ts +1 -1
- package/dist/evals/trajectory.service.js +1 -0
- package/dist/evals/worker.js +5 -1
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +3 -1
- package/dist/extensions/bootstrap-packages.d.ts +12 -1
- package/dist/extensions/bootstrap-packages.js +49 -9
- package/dist/extensions/bootstrap.d.ts +36 -4
- package/dist/extensions/bootstrap.js +103 -16
- package/dist/extensions/config-json-schema.d.ts +2 -2
- package/dist/extensions/config-json-schema.js +1 -3
- package/dist/extensions/deployment-config.d.ts +5 -3
- package/dist/extensions/deployment-config.js +3 -3
- package/dist/extensions/effective-config.d.ts +8 -7
- package/dist/extensions/effective-config.js +8 -7
- package/dist/extensions/enabled.js +1 -0
- package/dist/extensions/host.d.ts +4 -3
- package/dist/extensions/host.js +11 -12
- package/dist/extensions/instance.d.ts +1 -1
- package/dist/extensions/instance.js +17 -2
- package/dist/extensions/org-config.d.ts +35 -97
- package/dist/extensions/org-config.js +48 -315
- package/dist/extensions/org-levels.d.ts +22 -9
- package/dist/extensions/org-levels.js +100 -20
- package/dist/extensions/org-overrides.d.ts +14 -15
- package/dist/extensions/org-overrides.js +20 -20
- package/dist/extensions/package.js +1 -1
- package/dist/extensions/permission-set.d.ts +1 -3
- package/dist/extensions/permission-set.js +3 -7
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +5 -4
- package/dist/extensions/plugin-icons.d.ts +72 -1
- package/dist/extensions/plugin-icons.js +194 -2
- package/dist/extensions/point-defaults.d.ts +17 -18
- package/dist/extensions/point-defaults.js +25 -28
- package/dist/identity/accounts.js +6 -0
- package/dist/identity/api-tokens.js +8 -0
- package/dist/infra/outbox/outbox.dispatcher.js +4 -1
- package/dist/infra/outbox/outbox.service.js +2 -0
- package/dist/orgs/directory-sync.d.ts +9 -6
- package/dist/orgs/directory-sync.js +15 -12
- package/dist/orgs/invitations.service.js +2 -0
- package/dist/orgs/members.service.js +2 -0
- package/dist/orgs/offboarding.js +2 -0
- package/dist/packages/npm.d.ts +9 -1
- package/dist/packages/npm.js +37 -5
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin-items.ops.js +1 -0
- package/dist/platform/ops/agents.ops.js +1 -0
- package/dist/platform/ops/extensions.ops.d.ts +6 -8
- package/dist/platform/ops/extensions.ops.js +18 -97
- package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
- package/dist/platform/ops/org-plugins.ops.js +14 -65
- package/dist/platform/ops/outbox.ops.js +1 -0
- package/dist/platform/ops/person-inputs.d.ts +0 -4
- package/dist/platform/ops/person-inputs.js +0 -8
- package/dist/platform/ops/plugins.ops.d.ts +4 -1
- package/dist/platform/ops/plugins.ops.js +27 -34
- package/dist/platform/person-fields.d.ts +1 -1
- package/dist/platform/person-fields.js +1 -1
- package/dist/platform/sealed-reveals.js +2 -0
- package/dist/push/recipients.js +9 -2
- package/dist/runtime/permission-context.service.js +1 -0
- package/dist/runtime/plugin-context.service.js +1 -0
- package/dist/runtime/project/knowledge.service.js +1 -0
- package/dist/runtime/run-context.service.js +1 -0
- package/dist/runtime/run-deletion.js +4 -0
- package/dist/runtime/run-execution.js +2 -0
- package/dist/runtime/run-finish.js +3 -0
- package/dist/runtime/run-jobs.js +3 -0
- package/dist/runtime/run-orphan-check.job.js +7 -0
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +5 -0
- package/dist/runtime/step-log.js +1 -0
- package/dist/runtime/subagents/child.js +2 -0
- package/dist/runtime/subagents/deliveries.js +3 -0
- package/dist/runtime/subagents/dispatch.js +5 -1
- package/dist/runtime/subagents/messages.js +2 -0
- package/dist/runtime/subagents/org-agents.d.ts +1 -1
- package/dist/runtime/subagents/org-agents.js +2 -1
- package/dist/runtime/usage-report-jobs.js +1 -0
- package/dist/runtime/usage-report.js +3 -0
- package/dist/runtime/waits.js +5 -0
- package/dist/sandbox/cloud-permission-snapshot.js +9 -3
- package/dist/sandbox/device-reports.js +3 -0
- package/dist/sandbox/legacy-retirement.js +5 -1
- package/dist/sandbox/managed-device-context.js +1 -0
- package/dist/sandbox/modes.d.ts +5 -2
- package/dist/sandbox/modes.js +8 -4
- package/dist/sandbox/network-grants.js +2 -0
- package/dist/sandbox/operation-intents.js +58 -0
- package/dist/sandbox/operation-reconcile.job.js +2 -0
- package/dist/sandbox/permission-authority-lock.js +12 -6
- package/dist/sandbox/permission-call-grants.js +6 -0
- package/dist/sandbox/permission-ceiling-writes.js +5 -0
- package/dist/sandbox/permission-config-publication.js +5 -0
- package/dist/sandbox/permission-instance-writes.js +4 -0
- package/dist/sandbox/permission-runtime-reports.js +10 -1
- package/dist/sandbox/permission-transitions.js +3 -0
- package/dist/sandbox/review/review.service.js +8 -5
- package/dist/sandbox/sandbox.service.d.ts +14 -0
- package/dist/sandbox/sandbox.service.js +195 -29
- package/dist/sandbox/unreachable.js +4 -1
- package/dist/schedules/fire.js +9 -3
- package/dist/schedules/pause.js +2 -0
- package/dist/schedules/run-tracker.js +16 -1
- package/dist/schedules/scheduled-tasks.service.js +4 -2
- package/dist/schedules/store.js +8 -0
- package/dist/schedules/unattended.js +4 -0
- package/dist/setup/setup-checks.service.d.ts +1 -10
- package/dist/setup/setup-checks.service.js +19 -29
- package/dist/shares/share-open.service.js +1 -0
- package/dist/shares/shares.service.js +2 -0
- package/dist/skills/agent-skills.service.d.ts +1 -1
- package/dist/skills/agent-skills.service.js +13 -2
- package/dist/skills/catalog.js +3 -0
- package/dist/skills/changes.service.js +10 -2
- package/dist/skills/conversation-catalog.js +1 -0
- package/dist/skills/skills.service.js +4 -0
- package/dist/tools/approvals.service.js +40 -0
- package/dist/tools/builtins/schedules.js +11 -6
- package/dist/tools/builtins/skill-load.d.ts +10 -9
- package/dist/tools/builtins/skill-load.js +15 -19
- package/dist/tools/builtins/web/fetch.js +1 -1
- package/dist/tools/builtins/web/search.js +1 -1
- package/dist/tools/connector-account-policies.js +3 -0
- package/dist/tools/connectors.controller.d.ts +20 -8
- package/dist/tools/connectors.controller.js +30 -12
- package/dist/tools/connectors.service.d.ts +8 -0
- package/dist/tools/connectors.service.js +21 -1
- package/dist/tools/drift.js +5 -0
- package/dist/tools/git-push-policy.js +3 -0
- package/dist/tools/oauth/flow.js +1 -0
- package/dist/tools/outputs.js +2 -0
- package/dist/tools/permission-approval-jobs.js +3 -0
- package/dist/tools/pipeline.js +2 -0
- package/dist/tools/policy.js +3 -0
- package/dist/tools/questions.service.js +13 -0
- package/package.json +3 -3
|
@@ -9,10 +9,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { sql } from "kysely";
|
|
12
|
+
import { readCatalogDisplayFiles, readCatalogIcon, } from "../catalog/catalog-content.js";
|
|
13
|
+
import { iconProblem } from "../catalog/plugin-package.js";
|
|
12
14
|
import { requestable } from "../catalog/scope.js";
|
|
15
|
+
import { ApiError } from "../errors.js";
|
|
13
16
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
17
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
15
18
|
import { packagePath } from "../packages/tgz.js";
|
|
19
|
+
import { UUID_RE } from "../ui/registry.js";
|
|
16
20
|
/** The icon scope of an org route's caller (its org and role). */
|
|
17
21
|
export const orgIconScope = (org) => ({
|
|
18
22
|
kind: "org",
|
|
@@ -71,6 +75,194 @@ let PluginIcons = class PluginIcons {
|
|
|
71
75
|
const icons = await this.resolve("id", ids, scope);
|
|
72
76
|
return new Map(icons.map((i) => [i.id, i.url]));
|
|
73
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Platform connector template id -> the URL of the template's own icon (`ConnectorTemplateFile.
|
|
80
|
+
* icon`, stored as a catalog display file of the template's current version); templates without
|
|
81
|
+
* one, or that the reader may not see, are absent. The admin scope gets
|
|
82
|
+
* `GET /api/v1/admin/catalog/connector-templates/:templateId/icon` for every live template; an org
|
|
83
|
+
* gets `GET /api/v1/orgs/:orgId/connector-templates/:templateId/icon` only when its catalog shows
|
|
84
|
+
* the template's plugin (the gate of the plugin icon) and the template passes the share gate.
|
|
85
|
+
* The URL carries the template's version (the platform's one version of it).
|
|
86
|
+
*/
|
|
87
|
+
async ofTemplates(ids, scope) {
|
|
88
|
+
const out = new Map();
|
|
89
|
+
for (const [id, version] of await this.templateIconVersions(ids, scope)) {
|
|
90
|
+
out.set(id, this.sourceUrl({ kind: "template", id, version }, scope));
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The icon of each connector template shown (in the order given): its own icon
|
|
96
|
+
* ({@link ofTemplates}), else its plugin's ({@link ofItems}), else null. One lookup each for all
|
|
97
|
+
* rows.
|
|
98
|
+
*/
|
|
99
|
+
async ofTemplatesOrItems(refs, scope) {
|
|
100
|
+
return (await this.sources(refs, scope)).map((s) => (s ? this.sourceUrl(s, scope) : null));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The icon of each connector template of a catalog item, by template file id (`connectors/<id>.
|
|
104
|
+
* json`, as the item detail lists them): the platform template's own icon, else the plugin's,
|
|
105
|
+
* else null ({@link ofTemplatesOrItems}). A file id without a live platform template gets the
|
|
106
|
+
* plugin's icon.
|
|
107
|
+
*/
|
|
108
|
+
async ofItemTemplates(itemId, templateIds, scope) {
|
|
109
|
+
if (templateIds.length === 0)
|
|
110
|
+
return new Map();
|
|
111
|
+
const platform = new Map((await this.db
|
|
112
|
+
.selectFrom("platform_connector_templates")
|
|
113
|
+
.select(["id", "template_id"])
|
|
114
|
+
.where("catalog_item_id", "=", itemId)
|
|
115
|
+
.where("template_id", "in", [...new Set(templateIds)])
|
|
116
|
+
.where("deleted_at", "is", null)
|
|
117
|
+
.execute()).map((r) => [r.template_id, r.id]));
|
|
118
|
+
const urls = await this.ofTemplatesOrItems(templateIds.map((t) => ({ templateId: platform.get(t) ?? null, itemId })), scope);
|
|
119
|
+
return new Map(templateIds.map((t, i) => [t, urls[i] ?? null]));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The icon of each of an org's connectors (in the order given), resolved as
|
|
123
|
+
* {@link ofTemplatesOrItems} (its platform template's own icon, else its plugin's, else null)
|
|
124
|
+
* but always served by the connector's own route, `GET /api/v1/orgs/:orgId/connectors/:id/icon`
|
|
125
|
+
* (`connectors.use`, see {@link readConnectorIcon}): everyone who sees the connector pages,
|
|
126
|
+
* guests included, can load it, while the catalog's icon route stays `catalog.read`. The URL
|
|
127
|
+
* carries where the icon comes from and its version, so a new icon is not stale-cached.
|
|
128
|
+
*/
|
|
129
|
+
async ofConnectors(rows, scope) {
|
|
130
|
+
const sources = await this.sources(rows, scope);
|
|
131
|
+
return rows.map((r, i) => {
|
|
132
|
+
const s = sources[i];
|
|
133
|
+
if (!s)
|
|
134
|
+
return null;
|
|
135
|
+
const v = `${s.kind === "template" ? "t" : "p"}-${s.version}`;
|
|
136
|
+
return `/api/v1/orgs/${enc(scope.orgId)}/connectors/${enc(r.id)}/icon?v=${enc(v)}`;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Reads the icon a connector shows ({@link ofConnectors}); the caller has checked that the
|
|
141
|
+
* connector is the org's. No icon the reader may see -> `catalog.icon_not_found`.
|
|
142
|
+
*/
|
|
143
|
+
async readConnectorIcon(ref, scope) {
|
|
144
|
+
const [s] = await this.sources([ref], scope);
|
|
145
|
+
if (!s)
|
|
146
|
+
throw new ApiError("catalog.icon_not_found", "This connector has no icon");
|
|
147
|
+
if (s.kind === "template")
|
|
148
|
+
return this.readTemplateIcon(s.id, scope);
|
|
149
|
+
// the item's visibility was decided above (the same gate as the plugin icon route)
|
|
150
|
+
return readCatalogIcon(this.db.db, s.id, true);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Reads a connector template's own icon (served only through kernel routes with nosniff and a
|
|
154
|
+
* CSP sandbox, like the plugin icon). A template that is unknown, removed or not visible to the
|
|
155
|
+
* reader -> `component.not_found` (decided before any file is read, so "no icon" never reveals
|
|
156
|
+
* that it exists); no icon of its own -> `catalog.icon_not_found`; stored content that is not a
|
|
157
|
+
* valid svg / png (checked at import; this guards against tampered storage) -> `internal`.
|
|
158
|
+
*/
|
|
159
|
+
async readTemplateIcon(templateId, scope) {
|
|
160
|
+
const [row] = await this.visibleTemplates(await this.templateRows([templateId]), scope);
|
|
161
|
+
if (row === undefined) {
|
|
162
|
+
throw new ApiError("component.not_found", "This connector template does not exist");
|
|
163
|
+
}
|
|
164
|
+
if (row.iconFile === undefined) {
|
|
165
|
+
throw new ApiError("catalog.icon_not_found", "This connector template has no icon");
|
|
166
|
+
}
|
|
167
|
+
const [file] = await readCatalogDisplayFiles(this.db, [row.iconFile]);
|
|
168
|
+
if (!file)
|
|
169
|
+
throw new ApiError("catalog.icon_not_found", "This connector template has no icon");
|
|
170
|
+
const problem = iconProblem(row.iconFile.path, file.data);
|
|
171
|
+
if (problem !== undefined)
|
|
172
|
+
throw new ApiError("internal", `Stored icon is invalid: ${problem}`);
|
|
173
|
+
return {
|
|
174
|
+
data: file.data,
|
|
175
|
+
contentType: /\.svg$/i.test(row.iconFile.path) ? "image/svg+xml" : "image/png",
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/** Where each ref's icon comes from: its template's own icon, else its plugin's, else none. */
|
|
179
|
+
async sources(refs, scope) {
|
|
180
|
+
const nonNull = (xs) => xs.filter((x) => x !== null);
|
|
181
|
+
const [own, plugin] = await Promise.all([
|
|
182
|
+
this.templateIconVersions(nonNull(refs.map((r) => r.templateId)), scope),
|
|
183
|
+
this.resolve("id", nonNull(refs.map((r) => r.itemId)), scope),
|
|
184
|
+
]);
|
|
185
|
+
const items = new Map(plugin.map((i) => [i.id, i.version]));
|
|
186
|
+
return refs.map((r) => {
|
|
187
|
+
const tv = r.templateId !== null ? own.get(r.templateId) : undefined;
|
|
188
|
+
if (r.templateId !== null && tv !== undefined) {
|
|
189
|
+
return { kind: "template", id: r.templateId, version: tv };
|
|
190
|
+
}
|
|
191
|
+
const iv = r.itemId !== null ? items.get(r.itemId) : undefined;
|
|
192
|
+
return r.itemId !== null && iv !== undefined
|
|
193
|
+
? { kind: "item", id: r.itemId, version: iv }
|
|
194
|
+
: null;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/** The URL of an icon source on the reader's routes (template or catalog item route). */
|
|
198
|
+
sourceUrl(s, scope) {
|
|
199
|
+
const path = s.kind === "template"
|
|
200
|
+
? scope.kind === "admin"
|
|
201
|
+
? `/api/v1/admin/catalog/connector-templates/${enc(s.id)}/icon`
|
|
202
|
+
: `/api/v1/orgs/${enc(scope.orgId)}/connector-templates/${enc(s.id)}/icon`
|
|
203
|
+
: scope.kind === "admin"
|
|
204
|
+
? `/api/v1/admin/catalog/items/${enc(s.id)}/icon`
|
|
205
|
+
: `/api/v1/orgs/${enc(scope.orgId)}/catalog/${enc(s.id)}/icon`;
|
|
206
|
+
return `${path}?v=${enc(s.version)}`;
|
|
207
|
+
}
|
|
208
|
+
/** Template id -> its version, for the templates with an own icon the reader may see. */
|
|
209
|
+
async templateIconVersions(ids, scope) {
|
|
210
|
+
const rows = (await this.templateRows(ids)).filter((r) => r.iconFile !== undefined);
|
|
211
|
+
return new Map((await this.visibleTemplates(rows, scope)).map((r) => [r.templateId, r.version]));
|
|
212
|
+
}
|
|
213
|
+
/** Live platform connector templates (of live items) with their item's visibility columns. */
|
|
214
|
+
async templateRows(ids) {
|
|
215
|
+
const unique = [...new Set(ids)].filter((id) => UUID_RE.test(id));
|
|
216
|
+
if (unique.length === 0)
|
|
217
|
+
return [];
|
|
218
|
+
const rows = await this.db
|
|
219
|
+
.selectFrom("platform_connector_templates as t")
|
|
220
|
+
.innerJoin("catalog_items as i", "i.id", "t.catalog_item_id")
|
|
221
|
+
.innerJoin("catalog_item_versions as v", (j) => j.onRef("v.item_id", "=", "t.catalog_item_id").onRef("v.version", "=", "t.current_version"))
|
|
222
|
+
.select([
|
|
223
|
+
"t.id as template_id",
|
|
224
|
+
"t.owner_org_id as template_owner_org_id",
|
|
225
|
+
"t.shareable as template_shareable",
|
|
226
|
+
"t.current_version",
|
|
227
|
+
sql `t.file->>'icon'`.as("icon"),
|
|
228
|
+
"v.files",
|
|
229
|
+
"i.id",
|
|
230
|
+
"i.scope",
|
|
231
|
+
"i.builtin",
|
|
232
|
+
"i.disabled",
|
|
233
|
+
"i.shown_to_others",
|
|
234
|
+
"i.owner_org_id",
|
|
235
|
+
"i.shareable",
|
|
236
|
+
"i.awaiting_confirmation",
|
|
237
|
+
])
|
|
238
|
+
.where("t.id", "in", unique)
|
|
239
|
+
.where("t.deleted_at", "is", null)
|
|
240
|
+
.where("i.deleted_at", "is", null)
|
|
241
|
+
.execute();
|
|
242
|
+
return rows.map((r) => {
|
|
243
|
+
const path = r.icon === null ? undefined : packagePath(r.icon);
|
|
244
|
+
const files = r.files;
|
|
245
|
+
return {
|
|
246
|
+
...r,
|
|
247
|
+
templateId: r.template_id,
|
|
248
|
+
version: r.current_version,
|
|
249
|
+
iconFile: path === undefined ? undefined : files.find((f) => f.path === path),
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The templates the reader may see: every one for the admin scope; for an org, those whose
|
|
255
|
+
* plugin its catalog shows ({@link orgVisibleItems}) and that pass the template's own share gate
|
|
256
|
+
* (the platform's, the org's own, or shared by its owner).
|
|
257
|
+
*/
|
|
258
|
+
async visibleTemplates(rows, scope) {
|
|
259
|
+
if (scope.kind === "admin")
|
|
260
|
+
return rows;
|
|
261
|
+
const shared = rows.filter((r) => r.template_owner_org_id === null ||
|
|
262
|
+
r.template_owner_org_id === scope.orgId ||
|
|
263
|
+
r.template_shareable);
|
|
264
|
+
return orgVisibleItems(this.db, shared, scope.orgId, scope.isAdmin);
|
|
265
|
+
}
|
|
74
266
|
async resolve(by, keys, scope) {
|
|
75
267
|
const out = [];
|
|
76
268
|
const unique = [...new Set(keys)];
|
|
@@ -107,13 +299,13 @@ let PluginIcons = class PluginIcons {
|
|
|
107
299
|
if (scope.kind === "admin") {
|
|
108
300
|
for (const r of withIcon) {
|
|
109
301
|
const url = `/api/v1/admin/catalog/items/${enc(r.id)}/icon?v=${enc(r.latest_version)}`;
|
|
110
|
-
out.push({ id: r.id, name: r.name, url });
|
|
302
|
+
out.push({ id: r.id, name: r.name, url, version: r.latest_version });
|
|
111
303
|
}
|
|
112
304
|
return out;
|
|
113
305
|
}
|
|
114
306
|
for (const r of await orgVisibleItems(this.db, withIcon, scope.orgId, scope.isAdmin)) {
|
|
115
307
|
const url = `/api/v1/orgs/${enc(scope.orgId)}/catalog/${enc(r.id)}/icon?v=${enc(r.latest_version)}`;
|
|
116
|
-
out.push({ id: r.id, name: r.name, url });
|
|
308
|
+
out.push({ id: r.id, name: r.name, url, version: r.latest_version });
|
|
117
309
|
}
|
|
118
310
|
return out;
|
|
119
311
|
}
|
|
@@ -5,14 +5,13 @@ import { EffectiveConfigs } from "./effective-config.js";
|
|
|
5
5
|
import { OrgExtensionConfigs } from "./org-config.js";
|
|
6
6
|
import { ExtensionRegistry } from "./registry.js";
|
|
7
7
|
/**
|
|
8
|
-
* The outcome of {@link ExtensionPointDefaults.resolve}: the provider with its
|
|
9
|
-
*
|
|
8
|
+
* The outcome of {@link ExtensionPointDefaults.resolve}: the provider with its effective deployment
|
|
9
|
+
* config for the org (layering spec A §6), to pass back to it.
|
|
10
10
|
*/
|
|
11
11
|
export type PointResolution<T> = {
|
|
12
12
|
ok: true;
|
|
13
13
|
extension: string;
|
|
14
14
|
impl: T;
|
|
15
|
-
orgConfig: unknown;
|
|
16
15
|
config: unknown;
|
|
17
16
|
} | {
|
|
18
17
|
ok: false;
|
|
@@ -20,12 +19,11 @@ export type PointResolution<T> = {
|
|
|
20
19
|
};
|
|
21
20
|
/**
|
|
22
21
|
* One provider of a multi-provider extension point for an org ({@link ExtensionPointDefaults.providersFor}),
|
|
23
|
-
* with its
|
|
22
|
+
* with its effective deployment config for the org, to pass back to it.
|
|
24
23
|
*/
|
|
25
24
|
export interface PointProvider<T> {
|
|
26
25
|
extension: string;
|
|
27
26
|
impl: T;
|
|
28
|
-
orgConfig: unknown;
|
|
29
27
|
config: unknown;
|
|
30
28
|
}
|
|
31
29
|
/** One `org-default` extension point of an org (the admin view). */
|
|
@@ -41,8 +39,9 @@ export interface OrgPointDefaultView {
|
|
|
41
39
|
/**
|
|
42
40
|
* The org default provider of an `org-default` extension point (web tools spec §6). Per call,
|
|
43
41
|
* never cached in process: the candidates are the providers loaded on this replica that are
|
|
44
|
-
* enabled in the org, whose
|
|
45
|
-
*
|
|
42
|
+
* enabled in the org, whose effective deployment config for the org (layering spec A §6) is valid,
|
|
43
|
+
* and whose `configured(config)` (when present) does not return false with it. One candidate is
|
|
44
|
+
* used as is; several need the org's stored default
|
|
46
45
|
* (`capybara.org_extension_point_defaults`), else the choice is ambiguous. A stored default that
|
|
47
46
|
* is not a candidate (disabled, uninstalled, unconfigured) stays and counts again once it is one.
|
|
48
47
|
*/
|
|
@@ -56,18 +55,18 @@ export declare class ExtensionPointDefaults {
|
|
|
56
55
|
constructor(kdb: KernelDb, txHost: TransactionHost, registry: Pick<ExtensionRegistry, "list">, orgConfigs: Pick<OrgExtensionConfigs, "get">, effective: Pick<EffectiveConfigs, "get">, log: KernelLogger);
|
|
57
56
|
/**
|
|
58
57
|
* The provider of `point` (the name without the major, e.g. `web-search`) for `orgId`, with the
|
|
59
|
-
*
|
|
60
|
-
*
|
|
58
|
+
* effective deployment config for the org to pass back to it. Throws when the point has no
|
|
59
|
+
* `selection`.
|
|
61
60
|
*/
|
|
62
61
|
resolve<T>(orgId: string, point: string): Promise<PointResolution<T>>;
|
|
63
62
|
/**
|
|
64
63
|
* Every provider of `point` (the name without the major, e.g. `context`) that could serve
|
|
65
64
|
* `orgId` now, in extension-name order: the same candidates {@link resolve} chooses from (loaded
|
|
66
|
-
* here, enabled in the org, valid
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* transient database error); they are neither serving nor known to be off. An invalid
|
|
70
|
-
*
|
|
65
|
+
* here, enabled in the org, valid effective config, `configured()` not false), for points whose
|
|
66
|
+
* every enabled provider is used (no `selection`). `failed`: the providers enabled in the org
|
|
67
|
+
* whose status could not be read (reading the effective config or `configured()` threw, e.g. a
|
|
68
|
+
* transient database error); they are neither serving nor known to be off. An invalid effective
|
|
69
|
+
* config is not a read error: that provider is off.
|
|
71
70
|
*/
|
|
72
71
|
providersFor<T>(orgId: string, point: string): Promise<{
|
|
73
72
|
providers: PointProvider<T>[];
|
|
@@ -90,20 +89,20 @@ export declare class ExtensionPointDefaults {
|
|
|
90
89
|
auditDetail?: Record<string, unknown>): Promise<void>;
|
|
91
90
|
/**
|
|
92
91
|
* The candidates of `point` in `orgId`, by extension name, and the enabled providers whose status
|
|
93
|
-
* could not be read (a read or `configured()` threw: excluded, logged). A provider whose
|
|
94
|
-
*
|
|
92
|
+
* could not be read (a read or `configured()` threw: excluded, logged). A provider whose
|
|
93
|
+
* effective config is invalid is excluded but not `failed`: it is known to be off.
|
|
95
94
|
*/
|
|
96
95
|
private candidates;
|
|
97
96
|
/**
|
|
98
97
|
* Whether the one provider `extension` of `point` evaluates as a candidate in `orgId`. The
|
|
99
98
|
* provider must be loaded on this replica and provide `point`; the org must have it enabled; its
|
|
100
|
-
*
|
|
99
|
+
* effective config must be valid; and its `configured()` must not return false.
|
|
101
100
|
* These are exactly the criteria of {@link providersFor} / {@link resolve}, with only that one
|
|
102
101
|
* provider evaluated. A provider whose status cannot be read counts as not serving (logged).
|
|
103
102
|
*/
|
|
104
103
|
serves(orgId: string, point: string, extension: string): Promise<boolean>;
|
|
105
104
|
/**
|
|
106
|
-
* One enabled provider's candidacy:
|
|
105
|
+
* One enabled provider's candidacy: enabled, a valid effective config and `configured(config)`
|
|
107
106
|
* not false. Undefined when it is off; a provider whose status could not be read is also added
|
|
108
107
|
* to `failed`.
|
|
109
108
|
*/
|
|
@@ -17,7 +17,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
17
17
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
18
18
|
import { EffectiveConfigs } from "./effective-config.js";
|
|
19
19
|
import { enabledExtensionsQuery, isExtensionEnabled } from "./enabled.js";
|
|
20
|
-
import {
|
|
20
|
+
import { OrgExtensionConfigs } from "./org-config.js";
|
|
21
21
|
import { ExtensionRegistry } from "./registry.js";
|
|
22
22
|
/** The extension points whose provider each org chooses (`selection: "org-default"`). */
|
|
23
23
|
function selectionPoints() {
|
|
@@ -29,8 +29,9 @@ const hasSelection = (point) => EXTENSION_POINTS[point]?.selection === "org-defa
|
|
|
29
29
|
/**
|
|
30
30
|
* The org default provider of an `org-default` extension point (web tools spec §6). Per call,
|
|
31
31
|
* never cached in process: the candidates are the providers loaded on this replica that are
|
|
32
|
-
* enabled in the org, whose
|
|
33
|
-
*
|
|
32
|
+
* enabled in the org, whose effective deployment config for the org (layering spec A §6) is valid,
|
|
33
|
+
* and whose `configured(config)` (when present) does not return false with it. One candidate is
|
|
34
|
+
* used as is; several need the org's stored default
|
|
34
35
|
* (`capybara.org_extension_point_defaults`), else the choice is ambiguous. A stored default that
|
|
35
36
|
* is not a candidate (disabled, uninstalled, unconfigured) stays and counts again once it is one.
|
|
36
37
|
*/
|
|
@@ -51,8 +52,8 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
54
|
* The provider of `point` (the name without the major, e.g. `web-search`) for `orgId`, with the
|
|
54
|
-
*
|
|
55
|
-
*
|
|
55
|
+
* effective deployment config for the org to pass back to it. Throws when the point has no
|
|
56
|
+
* `selection`.
|
|
56
57
|
*/
|
|
57
58
|
async resolve(orgId, point) {
|
|
58
59
|
if (!hasSelection(point)) {
|
|
@@ -67,18 +68,17 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
67
68
|
ok: true,
|
|
68
69
|
extension: c.extension,
|
|
69
70
|
impl: c.impl,
|
|
70
|
-
orgConfig: c.orgConfig,
|
|
71
71
|
config: c.config,
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Every provider of `point` (the name without the major, e.g. `context`) that could serve
|
|
76
76
|
* `orgId` now, in extension-name order: the same candidates {@link resolve} chooses from (loaded
|
|
77
|
-
* here, enabled in the org, valid
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* transient database error); they are neither serving nor known to be off. An invalid
|
|
81
|
-
*
|
|
77
|
+
* here, enabled in the org, valid effective config, `configured()` not false), for points whose
|
|
78
|
+
* every enabled provider is used (no `selection`). `failed`: the providers enabled in the org
|
|
79
|
+
* whose status could not be read (reading the effective config or `configured()` threw, e.g. a
|
|
80
|
+
* transient database error); they are neither serving nor known to be off. An invalid effective
|
|
81
|
+
* config is not a read error: that provider is off.
|
|
82
82
|
*/
|
|
83
83
|
async providersFor(orgId, point) {
|
|
84
84
|
const { candidates, failed } = await this.candidates(orgId, point);
|
|
@@ -86,7 +86,6 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
86
86
|
providers: candidates.map((c) => ({
|
|
87
87
|
extension: c.extension,
|
|
88
88
|
impl: c.impl,
|
|
89
|
-
orgConfig: c.orgConfig,
|
|
90
89
|
config: c.config,
|
|
91
90
|
})),
|
|
92
91
|
failed,
|
|
@@ -151,8 +150,8 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
151
150
|
}
|
|
152
151
|
/**
|
|
153
152
|
* The candidates of `point` in `orgId`, by extension name, and the enabled providers whose status
|
|
154
|
-
* could not be read (a read or `configured()` threw: excluded, logged). A provider whose
|
|
155
|
-
*
|
|
153
|
+
* could not be read (a read or `configured()` threw: excluded, logged). A provider whose
|
|
154
|
+
* effective config is invalid is excluded but not `failed`: it is known to be off.
|
|
156
155
|
*/
|
|
157
156
|
async candidates(orgId, point) {
|
|
158
157
|
const db = this.kdb.db;
|
|
@@ -178,7 +177,7 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
178
177
|
/**
|
|
179
178
|
* Whether the one provider `extension` of `point` evaluates as a candidate in `orgId`. The
|
|
180
179
|
* provider must be loaded on this replica and provide `point`; the org must have it enabled; its
|
|
181
|
-
*
|
|
180
|
+
* effective config must be valid; and its `configured()` must not return false.
|
|
182
181
|
* These are exactly the criteria of {@link providersFor} / {@link resolve}, with only that one
|
|
183
182
|
* provider evaluated. A provider whose status cannot be read counts as not serving (logged).
|
|
184
183
|
*/
|
|
@@ -189,7 +188,7 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
189
188
|
return (await this.evaluate(orgId, point, extension, entry.impl, new Set())) !== undefined;
|
|
190
189
|
}
|
|
191
190
|
/**
|
|
192
|
-
* One enabled provider's candidacy:
|
|
191
|
+
* One enabled provider's candidacy: enabled, a valid effective config and `configured(config)`
|
|
193
192
|
* not false. Undefined when it is off; a provider whose status could not be read is also added
|
|
194
193
|
* to `failed`.
|
|
195
194
|
*/
|
|
@@ -199,14 +198,13 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
199
198
|
cfg = await this.orgConfigs.get(orgId, extension);
|
|
200
199
|
}
|
|
201
200
|
catch (err) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
failed.add(extension);
|
|
201
|
+
this.log.warn("extension point provider excluded, cannot read whether it is enabled", {
|
|
202
|
+
orgId,
|
|
203
|
+
point,
|
|
204
|
+
extension,
|
|
205
|
+
err,
|
|
206
|
+
});
|
|
207
|
+
failed.add(extension);
|
|
210
208
|
return undefined;
|
|
211
209
|
}
|
|
212
210
|
if (!cfg?.enabled)
|
|
@@ -228,12 +226,11 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
228
226
|
}
|
|
229
227
|
if (!effective.ok)
|
|
230
228
|
return undefined;
|
|
231
|
-
const configured = impl
|
|
232
|
-
.configured;
|
|
229
|
+
const configured = impl.configured;
|
|
233
230
|
if (typeof configured === "function") {
|
|
234
231
|
let ok;
|
|
235
232
|
try {
|
|
236
|
-
ok = configured.call(impl,
|
|
233
|
+
ok = configured.call(impl, effective.config) !== false;
|
|
237
234
|
}
|
|
238
235
|
catch (err) {
|
|
239
236
|
this.log.warn("extension point provider excluded, configured() threw", {
|
|
@@ -248,7 +245,7 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
248
245
|
if (!ok)
|
|
249
246
|
return undefined;
|
|
250
247
|
}
|
|
251
|
-
return { extension, impl,
|
|
248
|
+
return { extension, impl, config: effective.config };
|
|
252
249
|
}
|
|
253
250
|
async choose(orgId, point, candidates) {
|
|
254
251
|
if (candidates.length < 2)
|
|
@@ -334,6 +334,8 @@ let AccountsService = class AccountsService {
|
|
|
334
334
|
.execute();
|
|
335
335
|
// the other devices stop receiving push; the current session's registrations stay
|
|
336
336
|
await deletePushRegistrationsForSessions(this.db.db, sessions.map((r) => r.id));
|
|
337
|
+
// org-filter: a password change revokes the account's personal tokens in every org on purpose
|
|
338
|
+
// (accounts are platform-wide; ruling R24)
|
|
337
339
|
await this.db
|
|
338
340
|
.updateTable("api_tokens")
|
|
339
341
|
.set({ revoked_at: sql `now()` })
|
|
@@ -579,6 +581,8 @@ let AccountsService = class AccountsService {
|
|
|
579
581
|
if (patch.status !== undefined && patch.status !== before.status) {
|
|
580
582
|
await this.ceilings.lock({}, "platform");
|
|
581
583
|
await this.ceilings.publishLocked({}, "platform", patch.status === "disabled" ? (_scope, row) => row.account_id === id : false);
|
|
584
|
+
// org-filter: a super-admin account status change resets Full consent on the account's
|
|
585
|
+
// conversations in every org on purpose (accounts are platform-wide)
|
|
582
586
|
await this.db
|
|
583
587
|
.updateTable("conversations")
|
|
584
588
|
.set((eb) => ({
|
|
@@ -623,6 +627,8 @@ let AccountsService = class AccountsService {
|
|
|
623
627
|
.where("revoked_at", "is", null)
|
|
624
628
|
.returning("id")
|
|
625
629
|
.execute();
|
|
630
|
+
// org-filter: disabling an account (super admin) revokes its personal tokens in every org on
|
|
631
|
+
// purpose (accounts are platform-wide)
|
|
626
632
|
await this.db
|
|
627
633
|
.updateTable("api_tokens")
|
|
628
634
|
.set({ revoked_at: sql `now()` })
|
|
@@ -131,6 +131,8 @@ let ApiTokenService = class ApiTokenService {
|
|
|
131
131
|
: undefined;
|
|
132
132
|
if (!kind)
|
|
133
133
|
return null;
|
|
134
|
+
// org-filter: lookup by the token's secret hash, before any org is known; the record carries
|
|
135
|
+
// the token's org (or none for a personal token)
|
|
134
136
|
const row = await this.db
|
|
135
137
|
.selectFrom("api_tokens")
|
|
136
138
|
.selectAll()
|
|
@@ -142,6 +144,7 @@ let ApiTokenService = class ApiTokenService {
|
|
|
142
144
|
if (!row)
|
|
143
145
|
return null;
|
|
144
146
|
// 节流:同一令牌 5 分钟内最多写一次 last_used_at
|
|
147
|
+
// org-filter: by primary key of the token just authenticated above
|
|
145
148
|
const touched = await this.db
|
|
146
149
|
.updateTable("api_tokens")
|
|
147
150
|
.set({ last_used_at: sql `now()` })
|
|
@@ -158,6 +161,8 @@ let ApiTokenService = class ApiTokenService {
|
|
|
158
161
|
return record;
|
|
159
162
|
}
|
|
160
163
|
/** 列出该 scope 下未吊销的令牌(含已过期),按创建时间升序。 */
|
|
164
|
+
// org-filter: scoped() filters a service token by org_id and a personal one (org_id null) by
|
|
165
|
+
// account_id
|
|
161
166
|
async list(scope) {
|
|
162
167
|
const rows = await this.scoped(this.db.selectFrom("api_tokens").selectAll(), scope)
|
|
163
168
|
.where("revoked_at", "is", null)
|
|
@@ -167,6 +172,8 @@ let ApiTokenService = class ApiTokenService {
|
|
|
167
172
|
return rows.map(toRecord);
|
|
168
173
|
}
|
|
169
174
|
/** Revokes a token (in the context's transaction when there is one); missing, revoked or out of scope → `token.not_found`. */
|
|
175
|
+
// org-filter: scoped() filters a service token by org_id and a personal one (org_id null) by
|
|
176
|
+
// account_id
|
|
170
177
|
async revoke(id, scope) {
|
|
171
178
|
const r = await this.scoped(this.db.updateTable("api_tokens").set({ revoked_at: sql `now()` }), scope)
|
|
172
179
|
.where("id", "=", id)
|
|
@@ -185,6 +192,7 @@ let ApiTokenService = class ApiTokenService {
|
|
|
185
192
|
.where("revoked_at", "is", null)
|
|
186
193
|
.execute();
|
|
187
194
|
}
|
|
195
|
+
// org-filter: personal tokens belong to the account, not an org (org_id null)
|
|
188
196
|
async revokeAllPersonal(accountId) {
|
|
189
197
|
await this.db
|
|
190
198
|
.updateTable("api_tokens")
|
|
@@ -299,7 +299,10 @@ __decorate([
|
|
|
299
299
|
Transactional({ propagation: "requires_new" })
|
|
300
300
|
], OutboxDispatcher.prototype, "claimAndSend", null);
|
|
301
301
|
OutboxDispatcher = __decorate([
|
|
302
|
-
Injectable()
|
|
302
|
+
Injectable()
|
|
303
|
+
// org-filter: deployment-wide relay; it claims and delivers due outbox rows of every org by row id
|
|
304
|
+
// (kernel-written ids, never caller input), each job carrying its own org in its data
|
|
305
|
+
,
|
|
303
306
|
__param(0, Inject(TransactionHost)),
|
|
304
307
|
__param(1, Inject(KernelDb)),
|
|
305
308
|
__param(2, Inject(KERNEL_LOGGER)),
|
|
@@ -94,6 +94,8 @@ let OutboxService = class OutboxService {
|
|
|
94
94
|
this.deliverAfterCommit(row.id);
|
|
95
95
|
return true;
|
|
96
96
|
}
|
|
97
|
+
// org-filter: by the unique (queue, job_id) of the conflicting insert just above; job ids are
|
|
98
|
+
// kernel-built and the outbox is deployment-wide
|
|
97
99
|
const stored = await this.db
|
|
98
100
|
.selectFrom("outbox")
|
|
99
101
|
.select(["job_name", "data"])
|
|
@@ -89,8 +89,11 @@ export interface SyncJobData {
|
|
|
89
89
|
/**
|
|
90
90
|
* 通讯录同步(`directory@1`):把企业通讯录同步为组织成员。框架无关。
|
|
91
91
|
*
|
|
92
|
-
* -
|
|
93
|
-
*
|
|
92
|
+
* - The maintenance queue's hourly `directory-scan` enqueues one sync per (org, extension) whose
|
|
93
|
+
* extension provides `directory@1`, is enabled in the org and has a valid effective config there
|
|
94
|
+
* (job ids deduplicated by hour bucket, so repeated scans on several replicas run once); manual
|
|
95
|
+
* triggers and `directory_changed` enqueue syncs too. Each call gets the org's own effective
|
|
96
|
+
* config (its copy of the overridable fields, or the platform's), never another org's.
|
|
94
97
|
* - One sync at a time per (org, extension): the `LockService` lock
|
|
95
98
|
* `lock:directory-sync:<org>:<plugin>`, renewed while held. A sync that finds the lock taken sets
|
|
96
99
|
* the dirty flag `capk:directory-sync-dirty:<org>:<plugin>` (1 hour) and ends; after releasing
|
|
@@ -138,9 +141,9 @@ export declare class DirectorySync {
|
|
|
138
141
|
/** 插件提供的 `directory@1`;未加载或不提供时 undefined。 */
|
|
139
142
|
private provider;
|
|
140
143
|
/**
|
|
141
|
-
* The org exists, the extension provides a directory
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
+
* The org exists, the extension provides a directory and is enabled in the org, and its effective
|
|
145
|
+
* deployment config for the org (the platform's, or this org's copy of the overridable fields;
|
|
146
|
+
* never another org's) is valid (layering spec A §6).
|
|
144
147
|
*/
|
|
145
148
|
private eligible;
|
|
146
149
|
/**
|
|
@@ -153,7 +156,7 @@ export declare class DirectorySync {
|
|
|
153
156
|
/**
|
|
154
157
|
* Manual trigger by an admin: re-checks `org.members.manage` live under the org row lock, then that
|
|
155
158
|
* the extension can sync (does not provide a directory -> `extension.not_found`, not enabled ->
|
|
156
|
-
* `extension.not_enabled`,
|
|
159
|
+
* `extension.not_enabled`, its state cannot be read -> `extension.config_invalid`, the extension says
|
|
157
160
|
* the directory is not configured -> `directory.not_configured`, Ruling A28; the effective config
|
|
158
161
|
* is not valid in the org -> `extension.needs_config`, layering spec A §6), and enqueues a sync
|
|
159
162
|
* job with a unique id.
|