@jini-ai/cms 0.3.10 → 0.4.0
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/CHANGELOG.md +59 -0
- package/README.md +47 -19
- package/dist/content-types/agent-tools.d.ts +3 -56
- package/dist/content-types/agent-tools.js +22 -6
- package/dist/content-types/cleanup.d.ts +18 -13
- package/dist/content-types/cleanup.js +16 -11
- package/dist/content-types/errors.d.ts +57 -24
- package/dist/content-types/errors.js +56 -39
- package/dist/content-types/field-defs.d.ts +8 -4
- package/dist/content-types/field-defs.js +19 -14
- package/dist/content-types/index-provisioning.d.ts +61 -47
- package/dist/content-types/index-provisioning.js +90 -66
- package/dist/content-types/index.d.ts +4 -3
- package/dist/content-types/lifecycle-dispatch.d.ts +11 -5
- package/dist/content-types/lifecycle-dispatch.js +5 -4
- package/dist/content-types/lifecycle.d.ts +23 -18
- package/dist/content-types/lifecycle.js +71 -64
- package/dist/content-types/repo.memory.d.ts +5 -4
- package/dist/content-types/repo.memory.js +3 -2
- package/dist/content-types/tool-registrations.d.ts +6 -8
- package/dist/content-types/tool-registrations.js +24 -28
- package/dist/content-types/types.d.ts +17 -13
- package/dist/content-types/types.js +11 -5
- package/dist/content-types/write-service.d.ts +20 -22
- package/dist/content-types/write-service.js +78 -75
- package/dist/core/authorization.d.ts +15 -0
- package/dist/core/authorization.js +2 -0
- package/dist/core/commands/change-set.d.ts +15 -7
- package/dist/core/commands/command.d.ts +45 -26
- package/dist/core/commands/command.js +73 -63
- package/dist/core/entity-liveness.d.ts +11 -7
- package/dist/core/entity-liveness.js +5 -4
- package/dist/core/index.d.ts +12 -5
- package/dist/core/index.js +10 -4
- package/dist/core/ports.d.ts +25 -24
- package/dist/core/ports.js +1 -0
- package/dist/core/tools/args.d.ts +49 -0
- package/dist/core/tools/args.js +46 -0
- package/dist/core/tools/index.d.ts +3 -0
- package/dist/core/tools/index.js +3 -0
- package/dist/entries/agent-tools.d.ts +1 -73
- package/dist/entries/agent-tools.js +19 -13
- package/dist/entries/errors.d.ts +28 -14
- package/dist/entries/errors.js +17 -11
- package/dist/entries/field-validation.d.ts +5 -3
- package/dist/entries/field-validation.js +7 -5
- package/dist/entries/index.d.ts +2 -2
- package/dist/entries/lifecycle-dispatch.d.ts +5 -2
- package/dist/entries/lifecycle-dispatch.js +2 -1
- package/dist/entries/list.d.ts +4 -2
- package/dist/entries/list.js +4 -3
- package/dist/entries/repo.memory.d.ts +12 -10
- package/dist/entries/repo.memory.js +11 -10
- package/dist/entries/tool-registrations.d.ts +6 -8
- package/dist/entries/tool-registrations.js +42 -41
- package/dist/entries/types.d.ts +0 -7
- package/dist/entries/write-service.d.ts +28 -29
- package/dist/entries/write-service.js +114 -105
- package/dist/http/settings/cms-adapter.d.ts +20 -0
- package/dist/http/settings/cms-adapter.js +124 -0
- package/dist/http/settings/contracts.d.ts +135 -0
- package/dist/http/settings/contracts.js +2 -0
- package/dist/http/settings/http.d.ts +10 -0
- package/dist/http/settings/http.js +211 -0
- package/dist/http/settings/index.d.ts +5 -0
- package/dist/http/settings/index.js +4 -0
- package/dist/http/settings/shared.d.ts +68 -0
- package/dist/http/settings/shared.js +54 -0
- package/dist/http/settings/stream.d.ts +24 -0
- package/dist/http/settings/stream.js +147 -0
- package/dist/media/agent-tools.d.ts +1 -66
- package/dist/media/agent-tools.js +5 -1
- package/dist/media/blob-gc-lock.d.ts +6 -2
- package/dist/media/blob-gc-lock.js +4 -2
- package/dist/media/blob-gc.d.ts +64 -51
- package/dist/media/blob-gc.js +62 -52
- package/dist/media/blob-key.d.ts +1 -1
- package/dist/media/content-type-sniffer.d.ts +3 -1
- package/dist/media/content-type-sniffer.js +1 -1
- package/dist/media/html-attributes.d.ts +9 -5
- package/dist/media/html-attributes.js +8 -6
- package/dist/media/image-transformer.js +1 -1
- package/dist/media/image-transformer.sharp.d.ts +6 -0
- package/dist/media/image-transformer.sharp.js +12 -6
- package/dist/media/import/fetch-image.d.ts +24 -0
- package/dist/media/import/fetch-image.js +137 -0
- package/dist/media/import/index.d.ts +3 -0
- package/dist/media/import/index.js +3 -0
- package/dist/media/import/ports.d.ts +38 -0
- package/dist/media/index.d.ts +7 -1
- package/dist/media/index.js +1 -0
- package/dist/media/media-service.d.ts +14 -10
- package/dist/media/media-service.js +57 -52
- package/dist/media/ports.d.ts +3 -2
- package/dist/media/rendition-service.d.ts +3 -3
- package/dist/media/rendition-service.js +38 -37
- package/dist/media/repo.memory.d.ts +18 -7
- package/dist/media/repo.memory.js +12 -6
- package/dist/media/tool-registrations.d.ts +16 -15
- package/dist/media/tool-registrations.js +84 -72
- package/dist/media/transform-lock.d.ts +22 -12
- package/dist/media/transform-lock.js +14 -13
- package/dist/media/transform-registry.d.ts +3 -3
- package/dist/media/transform-registry.js +19 -18
- package/dist/media/transform-types.d.ts +8 -3
- package/dist/media/transform-types.js +10 -5
- package/dist/media/types.d.ts +21 -4
- package/dist/media/types.js +15 -2
- package/dist/navigation/agent-tools.d.ts +1 -80
- package/dist/navigation/agent-tools.js +15 -3
- package/dist/navigation/contracts.d.ts +1 -1
- package/dist/navigation/index.d.ts +2 -2
- package/dist/navigation/menu-service.d.ts +57 -40
- package/dist/navigation/menu-service.js +80 -69
- package/dist/navigation/ports.d.ts +1 -1
- package/dist/navigation/read-model.d.ts +3 -1
- package/dist/navigation/read-model.js +2 -2
- package/dist/navigation/reconcile.d.ts +2 -2
- package/dist/navigation/reconcile.js +2 -1
- package/dist/navigation/repo.memory.d.ts +7 -3
- package/dist/navigation/repo.memory.js +4 -2
- package/dist/navigation/resolver.d.ts +4 -1
- package/dist/navigation/resolver.js +1 -1
- package/dist/navigation/tool-registrations.d.ts +6 -8
- package/dist/navigation/tool-registrations.js +44 -42
- package/dist/navigation/types.d.ts +1 -1
- package/dist/presentation/presentation.d.ts +11 -3
- package/dist/presentation/presentation.js +13 -6
- package/dist/presentation/repo.memory.d.ts +6 -2
- package/dist/presentation/repo.memory.js +3 -2
- package/dist/settings/agent-tools.d.ts +2 -75
- package/dist/settings/agent-tools.js +49 -45
- package/dist/settings/agent-value-write-tools.d.ts +22 -0
- package/dist/settings/agent-value-write-tools.js +154 -0
- package/dist/settings/agent-writable-preferences.js +8 -20
- package/dist/settings/agent-write-denylist.d.ts +19 -0
- package/dist/settings/agent-write-denylist.js +15 -0
- package/dist/settings/change-feed.d.ts +11 -2
- package/dist/settings/change-feed.js +4 -4
- package/dist/settings/definitions-dispatch.d.ts +8 -3
- package/dist/settings/definitions-dispatch.js +5 -5
- package/dist/settings/dictionaries/index.d.ts +5 -2
- package/dist/settings/dictionaries/index.js +2 -2
- package/dist/settings/dictionaries/settings-dialog.ar.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.bn.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.de.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.es.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.fa.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.fr.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.hi.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.hu.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.id.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.it.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.ja.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.ko.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.pl.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.pt-BR.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.ru.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.th.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.tr.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.uk.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.ur.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.zh-CN.js +0 -1
- package/dist/settings/dictionaries/settings-dialog.zh-TW.js +0 -1
- package/dist/settings/ensure-definitions.d.ts +5 -5
- package/dist/settings/errors.d.ts +7 -1
- package/dist/settings/errors.js +7 -1
- package/dist/settings/index.d.ts +4 -1
- package/dist/settings/index.js +1 -0
- package/dist/settings/ports.d.ts +6 -5
- package/dist/settings/principal-lookup.d.ts +9 -0
- package/dist/settings/principal-lookup.js +2 -0
- package/dist/settings/purge-service.d.ts +5 -4
- package/dist/settings/purge-service.js +3 -2
- package/dist/settings/settings.d.ts +22 -7
- package/dist/settings/settings.js +47 -26
- package/dist/settings/tool-registrations.d.ts +25 -32
- package/dist/settings/tool-registrations.js +66 -56
- package/dist/settings/types.d.ts +1 -1
- package/dist/settings/ui-tab-definitions.d.ts +1 -1
- package/dist/settings/write-service.d.ts +32 -26
- package/dist/settings/write-service.js +26 -20
- package/dist/taxonomy/agent-tools.d.ts +1 -66
- package/dist/taxonomy/agent-tools.js +25 -15
- package/dist/taxonomy/content-lookup.js +1 -1
- package/dist/taxonomy/index.d.ts +2 -2
- package/dist/taxonomy/merge-term.d.ts +7 -4
- package/dist/taxonomy/merge-term.js +7 -5
- package/dist/taxonomy/repo.memory.d.ts +42 -19
- package/dist/taxonomy/repo.memory.js +14 -12
- package/dist/taxonomy/validation-chain.d.ts +39 -18
- package/dist/taxonomy/validation-chain.js +35 -25
- package/dist/taxonomy/write-service.d.ts +106 -45
- package/dist/taxonomy/write-service.js +221 -179
- package/dist/trash/adapters/record-store.d.ts +52 -0
- package/dist/trash/adapters/record-store.js +36 -0
- package/dist/trash/cursor.d.ts +20 -0
- package/dist/trash/cursor.js +36 -0
- package/dist/trash/follow-ups.d.ts +76 -0
- package/dist/trash/follow-ups.js +46 -0
- package/dist/trash/index.d.ts +8 -0
- package/dist/trash/index.js +8 -0
- package/dist/trash/ports.d.ts +308 -0
- package/dist/trash/ports.js +2 -0
- package/dist/trash/repo.memory.d.ts +50 -0
- package/dist/trash/repo.memory.js +114 -0
- package/dist/trash/sweeper.d.ts +77 -0
- package/dist/trash/sweeper.js +127 -0
- package/dist/trash/write-service.d.ts +100 -0
- package/dist/trash/write-service.js +242 -0
- package/dist/workspace/agent-tools.d.ts +1 -59
- package/dist/workspace/agent-tools.js +27 -12
- package/dist/workspace/create.d.ts +31 -6
- package/dist/workspace/create.js +18 -5
- package/dist/workspace/delete.d.ts +18 -13
- package/dist/workspace/delete.js +20 -12
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/repo.memory.d.ts +19 -4
- package/dist/workspace/repo.memory.js +26 -4
- package/dist/workspace/tool-registrations.d.ts +2 -2
- package/dist/workspace/tool-registrations.js +13 -13
- package/dist/workspace/update.d.ts +6 -5
- package/dist/workspace/update.js +9 -8
- package/package.json +44 -38
- package/dist/identity/admin-crud-service.d.ts +0 -280
- package/dist/identity/admin-crud-service.js +0 -468
- package/dist/identity/agent-tool-input.d.ts +0 -58
- package/dist/identity/agent-tool-input.js +0 -126
- package/dist/identity/agent-tools.d.ts +0 -101
- package/dist/identity/agent-tools.js +0 -290
- package/dist/identity/auth-service.d.ts +0 -118
- package/dist/identity/auth-service.js +0 -170
- package/dist/identity/authorize.d.ts +0 -90
- package/dist/identity/authorize.js +0 -94
- package/dist/identity/grant-service.d.ts +0 -198
- package/dist/identity/grant-service.js +0 -361
- package/dist/identity/hasher.d.ts +0 -39
- package/dist/identity/hasher.js +0 -39
- package/dist/identity/index.d.ts +0 -62
- package/dist/identity/index.js +0 -54
- package/dist/identity/password-policy.d.ts +0 -57
- package/dist/identity/password-policy.js +0 -66
- package/dist/identity/permission-migrations.d.ts +0 -86
- package/dist/identity/permission-migrations.js +0 -67
- package/dist/identity/permissions.d.ts +0 -35
- package/dist/identity/permissions.js +0 -603
- package/dist/identity/ports.d.ts +0 -201
- package/dist/identity/repo.memory.d.ts +0 -164
- package/dist/identity/repo.memory.js +0 -224
- package/dist/identity/seed.d.ts +0 -54
- package/dist/identity/seed.js +0 -429
- package/dist/identity/tool-registrations.d.ts +0 -50
- package/dist/identity/tool-registrations.js +0 -419
- package/dist/identity/types.d.ts +0 -185
- package/dist/identity/types.js +0 -64
- package/dist/identity/username.d.ts +0 -12
- package/dist/identity/username.js +0 -14
- /package/dist/{identity → media/import}/ports.js +0 -0
package/dist/workspace/update.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { validateWorkspaceNameAndSlug, WorkspaceConflictError, WorkspaceNotFoundError, WorkspaceValidationError, } from "./create.js";
|
|
2
2
|
/**
|
|
3
|
-
* Execute `UPDATE_WORKSPACE
|
|
4
|
-
* (
|
|
3
|
+
* Execute `UPDATE_WORKSPACE`. At least one of `name`/`slug` must be present in the input
|
|
4
|
+
* ( — an empty-object update is rejected, not a silent no-op, so a client-side bug that drops
|
|
5
5
|
* both fields fails loudly instead of masquerading as a successful save). When only one field is
|
|
6
6
|
* given, the other keeps its current stored value; both are re-validated together through
|
|
7
7
|
* `validateWorkspaceNameAndSlug` either way, so a `slug`-only update still catches a blank stored
|
|
@@ -9,29 +9,30 @@ import { validateWorkspaceNameAndSlug, WorkspaceConflictError, WorkspaceNotFound
|
|
|
9
9
|
* rejects that, but re-validating both together — rather than only the changed field — keeps this
|
|
10
10
|
* function's invariant identical to `createWorkspace`'s with no special-cased partial path).
|
|
11
11
|
*
|
|
12
|
-
* The slug-uniqueness check excludes the row being updated (
|
|
12
|
+
* The slug-uniqueness check excludes the row being updated ( — a workspace is never "in
|
|
13
13
|
* conflict with itself"): `findBySlug` naturally excludes it whenever the row's own `id` matches,
|
|
14
14
|
* since that's a no-op rename, not a collision with a *different* row.
|
|
15
15
|
*
|
|
16
16
|
* @complexity O(1) — one lookup by id, one lookup by slug, one write.
|
|
17
17
|
* @overallScore 100
|
|
18
|
+
* See docs/decisions/DR-007-workspace-and-owner-floors.md.
|
|
18
19
|
*/
|
|
19
20
|
export async function updateWorkspace(required) {
|
|
20
21
|
const { deps, input } = required;
|
|
21
22
|
if (input.name === undefined && input.slug === undefined) {
|
|
22
|
-
throw new WorkspaceValidationError("at least one of name or slug is required");
|
|
23
|
+
throw new WorkspaceValidationError({ message: "at least one of name or slug is required" });
|
|
23
24
|
}
|
|
24
|
-
const existing = await deps.repo.findById(input.id);
|
|
25
|
+
const existing = await deps.repo.findById({ id: input.id });
|
|
25
26
|
if (!existing)
|
|
26
|
-
throw new WorkspaceNotFoundError(`workspace '${input.id}' was not found`);
|
|
27
|
+
throw new WorkspaceNotFoundError({ message: `workspace '${input.id}' was not found` });
|
|
27
28
|
const { name, slug } = validateWorkspaceNameAndSlug({
|
|
28
29
|
name: input.name ?? existing.name,
|
|
29
30
|
slug: input.slug ?? existing.slug,
|
|
30
31
|
});
|
|
31
32
|
if (slug !== existing.slug) {
|
|
32
|
-
const collision = await deps.repo.findBySlug(slug);
|
|
33
|
+
const collision = await deps.repo.findBySlug({ slug: slug });
|
|
33
34
|
if (collision && collision.id !== existing.id) {
|
|
34
|
-
throw new WorkspaceConflictError(`slug '${slug}' already exists`);
|
|
35
|
+
throw new WorkspaceConflictError({ message: `slug '${slug}' already exists` });
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
const updated = { ...existing, name, slug };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/cms",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Content-model capability for Jini-hosted products: framework-free contracts, ports, and domain services in `/core` and per-domain subpaths; Node-bound
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Content-model capability for Jini-hosted products: framework-free contracts, ports, and domain services in `/core` and per-domain subpaths; Node-bound adapters in domain-specific subpaths.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -15,24 +15,22 @@
|
|
|
15
15
|
"entries": {
|
|
16
16
|
".": "universal",
|
|
17
17
|
"./core": "universal",
|
|
18
|
-
"./identity": "node",
|
|
19
|
-
"./server": "node",
|
|
20
|
-
"./identity/hasher": "node",
|
|
21
18
|
"./navigation": "universal",
|
|
22
|
-
"./media": "
|
|
19
|
+
"./media": "node",
|
|
23
20
|
"./settings": "universal",
|
|
24
21
|
"./workspace": "universal",
|
|
25
22
|
"./entries": "universal",
|
|
26
23
|
"./content-types": "universal",
|
|
27
24
|
"./taxonomy": "universal",
|
|
28
|
-
"./
|
|
29
|
-
"./
|
|
25
|
+
"./presentation": "universal",
|
|
26
|
+
"./media/import": "universal",
|
|
27
|
+
"./core/tools": "universal",
|
|
28
|
+
"./http/settings": "node",
|
|
29
|
+
"./trash": "universal"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"type": "module",
|
|
33
|
-
"sideEffects":
|
|
34
|
-
"./dist/identity/permissions.js"
|
|
35
|
-
],
|
|
33
|
+
"sideEffects": false,
|
|
36
34
|
"main": "./dist/core/index.js",
|
|
37
35
|
"types": "./dist/core/index.d.ts",
|
|
38
36
|
"exports": {
|
|
@@ -46,21 +44,6 @@
|
|
|
46
44
|
"import": "./dist/core/index.js",
|
|
47
45
|
"default": "./dist/core/index.js"
|
|
48
46
|
},
|
|
49
|
-
"./server": {
|
|
50
|
-
"types": "./dist/server/index.d.ts",
|
|
51
|
-
"import": "./dist/server/index.js",
|
|
52
|
-
"default": "./dist/server/index.js"
|
|
53
|
-
},
|
|
54
|
-
"./identity": {
|
|
55
|
-
"types": "./dist/identity/index.d.ts",
|
|
56
|
-
"import": "./dist/identity/index.js",
|
|
57
|
-
"default": "./dist/identity/index.js"
|
|
58
|
-
},
|
|
59
|
-
"./identity/hasher": {
|
|
60
|
-
"types": "./dist/identity/hasher.d.ts",
|
|
61
|
-
"import": "./dist/identity/hasher.js",
|
|
62
|
-
"default": "./dist/identity/hasher.js"
|
|
63
|
-
},
|
|
64
47
|
"./navigation": {
|
|
65
48
|
"types": "./dist/navigation/index.d.ts",
|
|
66
49
|
"import": "./dist/navigation/index.js",
|
|
@@ -96,19 +79,39 @@
|
|
|
96
79
|
"import": "./dist/taxonomy/index.js",
|
|
97
80
|
"default": "./dist/taxonomy/index.js"
|
|
98
81
|
},
|
|
99
|
-
"./widgets": {
|
|
100
|
-
"types": "./dist/widgets/index.d.ts",
|
|
101
|
-
"import": "./dist/widgets/index.js",
|
|
102
|
-
"default": "./dist/widgets/index.js"
|
|
103
|
-
},
|
|
104
82
|
"./presentation": {
|
|
105
83
|
"types": "./dist/presentation/index.d.ts",
|
|
106
84
|
"import": "./dist/presentation/index.js",
|
|
107
85
|
"default": "./dist/presentation/index.js"
|
|
86
|
+
},
|
|
87
|
+
"./core/tools": {
|
|
88
|
+
"types": "./dist/core/tools/index.d.ts",
|
|
89
|
+
"import": "./dist/core/tools/index.js",
|
|
90
|
+
"default": "./dist/core/tools/index.js"
|
|
91
|
+
},
|
|
92
|
+
"./media/import": {
|
|
93
|
+
"types": "./dist/media/import/index.d.ts",
|
|
94
|
+
"import": "./dist/media/import/index.js",
|
|
95
|
+
"default": "./dist/media/import/index.js"
|
|
96
|
+
},
|
|
97
|
+
"./http/settings": {
|
|
98
|
+
"types": "./dist/http/settings/index.d.ts",
|
|
99
|
+
"import": "./dist/http/settings/index.js",
|
|
100
|
+
"default": "./dist/http/settings/index.js"
|
|
101
|
+
},
|
|
102
|
+
"./trash": {
|
|
103
|
+
"types": "./dist/trash/index.d.ts",
|
|
104
|
+
"import": "./dist/trash/index.js",
|
|
105
|
+
"default": "./dist/trash/index.js"
|
|
108
106
|
}
|
|
109
107
|
},
|
|
110
108
|
"files": [
|
|
111
109
|
"dist",
|
|
110
|
+
"README.md",
|
|
111
|
+
"CHANGELOG.md",
|
|
112
|
+
"LICENSE",
|
|
113
|
+
"!forms/**",
|
|
114
|
+
"!dist/identity/**",
|
|
112
115
|
"!dist/**/*.test.js",
|
|
113
116
|
"!dist/**/*.test.d.ts",
|
|
114
117
|
"!dist/**/*.test.js.map",
|
|
@@ -122,21 +125,24 @@
|
|
|
122
125
|
},
|
|
123
126
|
"devDependencies": {
|
|
124
127
|
"@vitest/coverage-v8": "^2.1.9",
|
|
125
|
-
"
|
|
126
|
-
"
|
|
128
|
+
"sharp": "^0.35.3",
|
|
129
|
+
"express": "^4.21.0",
|
|
130
|
+
"@types/express": "^4.17.21",
|
|
131
|
+
"typescript": "^5.6.0",
|
|
132
|
+
"@jini-ai/http-kit": "0.4.0"
|
|
127
133
|
},
|
|
128
134
|
"dependencies": {
|
|
129
|
-
"@jini-ai/core": "0.
|
|
135
|
+
"@jini-ai/core": "0.4.0"
|
|
130
136
|
},
|
|
131
137
|
"peerDependencies": {
|
|
132
|
-
"
|
|
133
|
-
"
|
|
138
|
+
"sharp": "^0.35.3",
|
|
139
|
+
"express": "^4.21.0"
|
|
134
140
|
},
|
|
135
141
|
"peerDependenciesMeta": {
|
|
136
|
-
"
|
|
142
|
+
"sharp": {
|
|
137
143
|
"optional": true
|
|
138
144
|
},
|
|
139
|
-
"
|
|
145
|
+
"express": {
|
|
140
146
|
"optional": true
|
|
141
147
|
}
|
|
142
148
|
},
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import type { UUID } from "../core/ports.js";
|
|
2
|
-
import type { AuthServiceDeps } from "./auth-service.js";
|
|
3
|
-
import { type PolicyPermissionRecord, type PolicyRecord, type PrincipalRecord, type RoleRecord, type UserRecord } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* @file An amendment that completes the users/roles/policies admin CRUD surface
|
|
6
|
-
* (feature.spec.md REQ-11/REQ-15..19).
|
|
7
|
-
*
|
|
8
|
-
* Purpose:
|
|
9
|
-
* Two of these nine transitions (`disablePrincipal`, `writePolicyPermission`) were fully specified
|
|
10
|
-
* since v0.5.0/v0.5.3 but never implemented — this file is their first implementation, not a
|
|
11
|
-
* re-specification (AC-32). The other seven (`enablePrincipal`, `updateUser`,
|
|
12
|
-
* `resetUserPassword`, `updateRole`, `updatePolicy`, `deleteRole`, `deletePolicy`) are new
|
|
13
|
-
* transitions this amendment adds. Grouped in one file, separate from `grant-service.ts`'s
|
|
14
|
-
* "human grant-writing transitions" (`CREATE_*`/`ASSIGN_ROLE`/`ATTACH_POLICY`) because most of
|
|
15
|
-
* these are plain CRUD, not grant-writing — `writePolicyPermission` is the one exception (it IS
|
|
16
|
-
* INV-07-clamped) and reuses `grant-service.ts`'s exported `assertGrantClamp` rather than
|
|
17
|
-
* duplicating it.
|
|
18
|
-
*
|
|
19
|
-
* Architectural role:
|
|
20
|
-
* Ordinary core functions — same shape as `grant-service.ts`: one exported async
|
|
21
|
-
* function per transition, plain `Error` subclasses for control flow, the caller-permission gate
|
|
22
|
-
* enforced here (not pushed to the route layer).
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* `DISABLE_PRINCIPAL` (feature.spec.md REQ-11, state.spec §3, AC-08/AC-21/AC-27). Gated by
|
|
26
|
-
* `user.manage`. Refuses the seeded owner unconditionally (REQ-13's CLI/core resolution target —
|
|
27
|
-
* disabling it would strand the CLI-only management plane) and refuses any disable that would drop
|
|
28
|
-
* the workspace's active owner-`*` count to zero (INV-08) — both checked, and the status update
|
|
29
|
-
* performed, inside this one function body with no `await` yielded to another caller in between
|
|
30
|
-
* (this codebase's established "atomic by construction" reasoning for a single-connection,
|
|
31
|
-
* single-event-loop composition — same as `features/workspace/delete.ts`'s INV-03 guard).
|
|
32
|
-
*
|
|
33
|
-
* `input.seededOwnerPrincipalId` is the caller's job to resolve (`await deps.ownerPrincipalId` at
|
|
34
|
-
* the route layer, mirroring `identityReady`'s existing await-before-use convention) — this
|
|
35
|
-
* function takes the already-resolved id so it stays a plain, directly-testable function.
|
|
36
|
-
*
|
|
37
|
-
* @complexity O(n) in the workspace's principal count (one `list()` call to count active owner-`*`
|
|
38
|
-
* holders) — bounded by the same operator-managed-roster assumption `identity/INFO.md` already
|
|
39
|
-
* makes for `PrincipalRepoPort.list()`.
|
|
40
|
-
* @overallScore 100
|
|
41
|
-
*/
|
|
42
|
-
export declare function disablePrincipal(required: {
|
|
43
|
-
deps: AuthServiceDeps;
|
|
44
|
-
input: {
|
|
45
|
-
workspaceId: UUID;
|
|
46
|
-
callerPrincipalId: UUID;
|
|
47
|
-
principalId: UUID;
|
|
48
|
-
seededOwnerPrincipalId: UUID;
|
|
49
|
-
};
|
|
50
|
-
}): Promise<{
|
|
51
|
-
principal: PrincipalRecord;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* `ENABLE_PRINCIPAL` (feature.spec.md REQ-15, AC-27, EC-14). Gated by `user.manage`. Target must be
|
|
55
|
-
* `kind='user'` — a `system`/`api_key` target is rejected `VALIDATION_ERROR` (mirrors AC-25b's
|
|
56
|
-
* human-only scoping; re-activating the disabled legacy `user-local` stub or an api_key principal
|
|
57
|
-
* outside `ISSUE_API_KEY`'s own lifecycle is never a valid call). Already-active is idempotent
|
|
58
|
-
* (mirrors `disablePrincipal`'s own already-disabled no-op above).
|
|
59
|
-
*
|
|
60
|
-
* @complexity O(1) — one lookup, one save.
|
|
61
|
-
* @overallScore 100
|
|
62
|
-
*/
|
|
63
|
-
export declare function enablePrincipal(required: {
|
|
64
|
-
deps: AuthServiceDeps;
|
|
65
|
-
input: {
|
|
66
|
-
workspaceId: UUID;
|
|
67
|
-
callerPrincipalId: UUID;
|
|
68
|
-
principalId: UUID;
|
|
69
|
-
};
|
|
70
|
-
}): Promise<{
|
|
71
|
-
principal: PrincipalRecord;
|
|
72
|
-
}>;
|
|
73
|
-
/**
|
|
74
|
-
* `UPDATE_USER` (feature.spec.md REQ-16, AC-28). Gated by `user.manage` **or** `member.manage`
|
|
75
|
-
* (mirrors `CREATE_USER`'s admin-onboarding gate) — `email` only; `username`/`password` are not
|
|
76
|
-
* this transition's concern (OQ-09 / REQ-17 respectively). An absent or empty-string `email`
|
|
77
|
-
* clears the stored value to `undefined` (EC-17 — no distinct "blank but present" state).
|
|
78
|
-
*
|
|
79
|
-
* @complexity O(1) — one lookup, one save.
|
|
80
|
-
* @overallScore 100
|
|
81
|
-
*/
|
|
82
|
-
export declare function updateUser(required: {
|
|
83
|
-
deps: AuthServiceDeps;
|
|
84
|
-
input: {
|
|
85
|
-
workspaceId: UUID;
|
|
86
|
-
callerPrincipalId: UUID;
|
|
87
|
-
principalId: UUID;
|
|
88
|
-
email?: string | undefined;
|
|
89
|
-
};
|
|
90
|
-
}): Promise<{
|
|
91
|
-
user: UserRecord;
|
|
92
|
-
}>;
|
|
93
|
-
/**
|
|
94
|
-
* `RESET_USER_PASSWORD` (feature.spec.md REQ-17, AC-29, EC-16). Gated by **`user.manage`** only
|
|
95
|
-
* (stricter than `updateUser` — resetting a credential is at least as sensitive as disabling the
|
|
96
|
-
* account, REQ-17's own reasoning). Hashes the new password identically to `CREATE_USER` (argon2id,
|
|
97
|
-
* INV-05), then revokes every one of the target's active sessions (idempotent no-op if it has none,
|
|
98
|
-
* EC-16) — a reset that left old sessions alive would not actually contain a compromised account.
|
|
99
|
-
*
|
|
100
|
-
* Refuses a THIRD PARTY resetting the seeded owner's password (REQ-11/REQ-13's reasoning, same
|
|
101
|
-
* `OwnerRequiredError` `disablePrincipal` uses): `user.manage` is independently grantable and not
|
|
102
|
-
* owner-exclusive (`permissions.ts` — "Create/disable operator users and principals"), so without
|
|
103
|
-
* this check a caller holding only that one delegated permission could set a password of their own
|
|
104
|
-
* choosing on the seeded owner's account and log in as owner — a full takeover from a routine
|
|
105
|
-
* delegation. Checked before the password-policy validation so the refusal doesn't depend on the
|
|
106
|
-
* caller supplying a well-formed password first.
|
|
107
|
-
*
|
|
108
|
-
* Deliberately NOT unconditional the way `disablePrincipal`'s owner check is: the owner resetting
|
|
109
|
-
* ITS OWN password (`callerPrincipalId === principalId === seededOwnerPrincipalId`) is refused
|
|
110
|
-
* nothing — that self-service path is real, shipped infrastructure
|
|
111
|
-
* (`reset-admin-password-self-verified.ts`, driven by both the `TOVU_ADMIN_RESET_PASSWORD`
|
|
112
|
-
* boot-time incident-recovery hook and the `backfill-reset-admin-password.ts` CLI script), added
|
|
113
|
-
* specifically to let an operator recover a locked-out owner account out-of-band. Disabling has no
|
|
114
|
-
* legitimate self-case (an owner disabling itself only ever stands the workspace down), so
|
|
115
|
-
* `disablePrincipal` can refuse unconditionally; a credential rotation the owner performs on itself
|
|
116
|
-
* is ordinary hygiene and the documented recovery path, so only a MISMATCHED caller — the actual
|
|
117
|
-
* escalation shape — is refused here.
|
|
118
|
-
*
|
|
119
|
-
* Deliberately NOT INV-08-clamped (unlike `disablePrincipal`'s second guard): a reset changes a
|
|
120
|
-
* credential, it never changes `status`, so it can never drop the workspace's active owner-`*`
|
|
121
|
-
* count — INV-08's headcount guard has nothing to protect here.
|
|
122
|
-
*
|
|
123
|
-
* `input.seededOwnerPrincipalId` is the caller's job to resolve (`await deps.ownerPrincipalId` at
|
|
124
|
-
* the route layer, mirroring `disablePrincipal`'s own contract above) — this function takes the
|
|
125
|
-
* already-resolved id so it stays a plain, directly-testable function.
|
|
126
|
-
*
|
|
127
|
-
* @complexity O(s) in the target's session count, s = active session rows to revoke — bounded by
|
|
128
|
-
* the same operator-managed-roster scale assumption every other identity list call here makes.
|
|
129
|
-
* @overallScore 100
|
|
130
|
-
*/
|
|
131
|
-
export declare function resetUserPassword(required: {
|
|
132
|
-
deps: AuthServiceDeps;
|
|
133
|
-
input: {
|
|
134
|
-
workspaceId: UUID;
|
|
135
|
-
callerPrincipalId: UUID;
|
|
136
|
-
principalId: UUID;
|
|
137
|
-
password: string;
|
|
138
|
-
seededOwnerPrincipalId: UUID;
|
|
139
|
-
};
|
|
140
|
-
}): Promise<{
|
|
141
|
-
user: UserRecord;
|
|
142
|
-
}>;
|
|
143
|
-
/**
|
|
144
|
-
* `UPDATE_ROLE` (feature.spec.md REQ-18, AC-30). Gated by `role.manage`. A built-in target is
|
|
145
|
-
* refused `VALIDATION_ERROR` — extends INV-06's existing undeletable/immutable/un-attachable-to
|
|
146
|
-
* rule to also cover un-renameable (same escalation shape: relabeling `viewer` to read as trusted
|
|
147
|
-
* is a social-engineering variant of what INV-06 already blocks structurally).
|
|
148
|
-
*
|
|
149
|
-
* @complexity O(1) — one lookup, one save.
|
|
150
|
-
* @overallScore 100
|
|
151
|
-
*/
|
|
152
|
-
export declare function updateRole(required: {
|
|
153
|
-
deps: AuthServiceDeps;
|
|
154
|
-
input: {
|
|
155
|
-
workspaceId: UUID;
|
|
156
|
-
callerPrincipalId: UUID;
|
|
157
|
-
roleId: UUID;
|
|
158
|
-
name: string;
|
|
159
|
-
};
|
|
160
|
-
}): Promise<{
|
|
161
|
-
role: RoleRecord;
|
|
162
|
-
}>;
|
|
163
|
-
/**
|
|
164
|
-
* `UPDATE_POLICY` (feature.spec.md REQ-18, AC-30). Gated by `role.manage`. A built-in or
|
|
165
|
-
* `is_frozen` target is refused `VALIDATION_ERROR` — the frozen-policy half mirrors
|
|
166
|
-
* `WRITE_POLICY_PERMISSION`'s existing refusal (AC-26): an issuance snapshot's identity is as
|
|
167
|
-
* immutable as its permission set. At least one of `name`/`description` must be present.
|
|
168
|
-
*
|
|
169
|
-
* @complexity O(1) — one lookup, one save.
|
|
170
|
-
* @overallScore 100
|
|
171
|
-
*/
|
|
172
|
-
export declare function updatePolicy(required: {
|
|
173
|
-
deps: AuthServiceDeps;
|
|
174
|
-
input: {
|
|
175
|
-
workspaceId: UUID;
|
|
176
|
-
callerPrincipalId: UUID;
|
|
177
|
-
policyId: UUID;
|
|
178
|
-
name?: string | undefined;
|
|
179
|
-
description?: string | undefined;
|
|
180
|
-
};
|
|
181
|
-
}): Promise<{
|
|
182
|
-
policy: PolicyRecord;
|
|
183
|
-
}>;
|
|
184
|
-
/**
|
|
185
|
-
* `DELETE_ROLE` (feature.spec.md REQ-19/INV-09, AC-31, EC-15). Gated by `role.manage`. A built-in
|
|
186
|
-
* target is refused `VALIDATION_ERROR` (checked before the reference count, matching AC-31's
|
|
187
|
-
* stated precedence). A still-referenced target (≥1 `principal_roles` row) is refused
|
|
188
|
-
* `IdentityConflictError` (409 `RESOURCE_CONFLICT`) — the reference check and the delete happen in
|
|
189
|
-
* this one function body with no yielded `await` in between (INV-09's atomicity, same reasoning as
|
|
190
|
-
* `disablePrincipal`'s owner-count guard above).
|
|
191
|
-
*
|
|
192
|
-
* @complexity O(a) in the role's assignment count (`principalRoles.listByRoleId`) — bounded by the
|
|
193
|
-
* same operator-managed-roster assumption every other identity list call makes.
|
|
194
|
-
* @overallScore 100
|
|
195
|
-
*/
|
|
196
|
-
export declare function deleteRole(required: {
|
|
197
|
-
deps: AuthServiceDeps;
|
|
198
|
-
input: {
|
|
199
|
-
workspaceId: UUID;
|
|
200
|
-
callerPrincipalId: UUID;
|
|
201
|
-
roleId: UUID;
|
|
202
|
-
};
|
|
203
|
-
}): Promise<void>;
|
|
204
|
-
/**
|
|
205
|
-
* `DELETE_POLICY` (feature.spec.md REQ-19/INV-09, AC-31, EC-15). Gated by `role.manage`. A
|
|
206
|
-
* built-in or `is_frozen` target is refused `VALIDATION_ERROR` (checked before the reference
|
|
207
|
-
* count). A still-referenced target (≥1 `role_policies` or `principal_policies` row) is refused
|
|
208
|
-
* `IdentityConflictError`. On success, cascades to the policy's OWN `policy_permissions` rows only
|
|
209
|
-
* (never a different policy's) before deleting the policy row itself.
|
|
210
|
-
*
|
|
211
|
-
* @complexity O(r + p) — role-reference count + principal-reference count, both bounded by the same
|
|
212
|
-
* operator-managed-roster assumption every other identity list call makes.
|
|
213
|
-
* @overallScore 100
|
|
214
|
-
*/
|
|
215
|
-
export declare function deletePolicy(required: {
|
|
216
|
-
deps: AuthServiceDeps;
|
|
217
|
-
input: {
|
|
218
|
-
workspaceId: UUID;
|
|
219
|
-
callerPrincipalId: UUID;
|
|
220
|
-
policyId: UUID;
|
|
221
|
-
};
|
|
222
|
-
}): Promise<void>;
|
|
223
|
-
/**
|
|
224
|
-
* `WRITE_POLICY_PERMISSION` (feature.spec.md INV-07, state.spec §3, AC-10/AC-24/AC-26). First HTTP
|
|
225
|
-
* implementation of a transition specified since v0.5.3 (AC-32 — this is a route, not a
|
|
226
|
-
* re-specification). Gated by `role.manage`. Refuses an unregistered permission
|
|
227
|
-
* (`PermissionUnknownError`, REQ-03), a built-in or `is_frozen` parent policy (INV-06/AC-26), and
|
|
228
|
-
* (via the shared `assertGrantClamp`) a permission the caller does not itself hold unconstrained
|
|
229
|
-
* (INV-07, `GrantExceedsIssuerError`).
|
|
230
|
-
*
|
|
231
|
-
* @complexity O(assertGrantClamp) — see that function's own doc (resolveEffectivePermissions +
|
|
232
|
-
* O(1) local filtering, one permission).
|
|
233
|
-
* @overallScore 100
|
|
234
|
-
*/
|
|
235
|
-
export declare function writePolicyPermission(required: {
|
|
236
|
-
deps: AuthServiceDeps;
|
|
237
|
-
input: {
|
|
238
|
-
workspaceId: UUID;
|
|
239
|
-
callerPrincipalId: UUID;
|
|
240
|
-
policyId: UUID;
|
|
241
|
-
permission: string;
|
|
242
|
-
resourceType?: string | null;
|
|
243
|
-
constraintJson?: string | null;
|
|
244
|
-
};
|
|
245
|
-
}): Promise<{
|
|
246
|
-
policyPermission: PolicyPermissionRecord;
|
|
247
|
-
}>;
|
|
248
|
-
/**
|
|
249
|
-
* `REMOVE_POLICY_PERMISSION` (OQ-10) — the inverse of {@link writePolicyPermission}, and the
|
|
250
|
-
* transition whose absence made a policy's permission set append-only: the only way to shrink one
|
|
251
|
-
* was `deletePolicy` + recreate, which INV-09 blocks outright the moment anything references the
|
|
252
|
-
* policy.
|
|
253
|
-
*
|
|
254
|
-
* Gated by `role.manage`, the same permission `writePolicyPermission` and `deletePolicy` require.
|
|
255
|
-
* Deliberately NOT clamped by `assertGrantClamp` (INV-07): the clamp exists to stop a caller
|
|
256
|
-
* conferring authority it does not itself hold, and removal confers nothing — it is a strict
|
|
257
|
-
* de-escalation. Requiring the clamp here would mean an admin who cannot grant `content.write`
|
|
258
|
-
* also cannot take it back, which is the wrong direction for a safety rule. This is strictly less
|
|
259
|
-
* powerful than the already-unclamped `deletePolicy`, which drops EVERY permission row the policy
|
|
260
|
-
* has.
|
|
261
|
-
*
|
|
262
|
-
* Refuses a built-in or `is_frozen` parent policy (INV-06/AC-26), checked BEFORE the row lookup so
|
|
263
|
-
* a frozen policy reports why it is frozen rather than leaking whether the row exists. A row that
|
|
264
|
-
* is absent — or that exists but belongs to a DIFFERENT policy — is one and the same
|
|
265
|
-
* `IdentityNotFoundError`: membership is proven from `listByPolicyId`'s result, so a caller can
|
|
266
|
-
* never delete across a policy boundary by guessing an id.
|
|
267
|
-
*
|
|
268
|
-
* @complexity O(n) in the policy's own permission-row count (one `listByPolicyId`) — bounded by the
|
|
269
|
-
* same operator-managed-roster assumption every other identity list call makes.
|
|
270
|
-
*/
|
|
271
|
-
export declare function removePolicyPermission(required: {
|
|
272
|
-
deps: AuthServiceDeps;
|
|
273
|
-
input: {
|
|
274
|
-
workspaceId: UUID;
|
|
275
|
-
callerPrincipalId: UUID;
|
|
276
|
-
policyId: UUID;
|
|
277
|
-
policyPermissionId: UUID;
|
|
278
|
-
};
|
|
279
|
-
}): Promise<void>;
|
|
280
|
-
//# sourceMappingURL=admin-crud-service.d.ts.map
|