@jini-ai/cms 0.3.11 → 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.
Files changed (258) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +47 -19
  3. package/dist/content-types/agent-tools.d.ts +3 -56
  4. package/dist/content-types/agent-tools.js +22 -6
  5. package/dist/content-types/cleanup.d.ts +18 -13
  6. package/dist/content-types/cleanup.js +16 -11
  7. package/dist/content-types/errors.d.ts +57 -24
  8. package/dist/content-types/errors.js +56 -39
  9. package/dist/content-types/field-defs.d.ts +8 -4
  10. package/dist/content-types/field-defs.js +19 -14
  11. package/dist/content-types/index-provisioning.d.ts +61 -47
  12. package/dist/content-types/index-provisioning.js +90 -66
  13. package/dist/content-types/index.d.ts +4 -3
  14. package/dist/content-types/lifecycle-dispatch.d.ts +11 -5
  15. package/dist/content-types/lifecycle-dispatch.js +5 -4
  16. package/dist/content-types/lifecycle.d.ts +23 -18
  17. package/dist/content-types/lifecycle.js +71 -64
  18. package/dist/content-types/repo.memory.d.ts +5 -4
  19. package/dist/content-types/repo.memory.js +3 -2
  20. package/dist/content-types/tool-registrations.d.ts +6 -8
  21. package/dist/content-types/tool-registrations.js +24 -28
  22. package/dist/content-types/types.d.ts +17 -13
  23. package/dist/content-types/types.js +11 -5
  24. package/dist/content-types/write-service.d.ts +20 -22
  25. package/dist/content-types/write-service.js +78 -75
  26. package/dist/core/authorization.d.ts +15 -0
  27. package/dist/core/authorization.js +2 -0
  28. package/dist/core/commands/change-set.d.ts +15 -7
  29. package/dist/core/commands/command.d.ts +45 -26
  30. package/dist/core/commands/command.js +73 -63
  31. package/dist/core/entity-liveness.d.ts +11 -7
  32. package/dist/core/entity-liveness.js +5 -4
  33. package/dist/core/index.d.ts +12 -5
  34. package/dist/core/index.js +10 -4
  35. package/dist/core/ports.d.ts +25 -24
  36. package/dist/core/ports.js +1 -0
  37. package/dist/core/tools/args.d.ts +49 -0
  38. package/dist/core/tools/args.js +46 -0
  39. package/dist/core/tools/index.d.ts +3 -0
  40. package/dist/core/tools/index.js +3 -0
  41. package/dist/entries/agent-tools.d.ts +1 -73
  42. package/dist/entries/agent-tools.js +19 -13
  43. package/dist/entries/errors.d.ts +28 -14
  44. package/dist/entries/errors.js +17 -11
  45. package/dist/entries/field-validation.d.ts +5 -3
  46. package/dist/entries/field-validation.js +7 -5
  47. package/dist/entries/index.d.ts +2 -2
  48. package/dist/entries/lifecycle-dispatch.d.ts +5 -2
  49. package/dist/entries/lifecycle-dispatch.js +2 -1
  50. package/dist/entries/list.d.ts +4 -2
  51. package/dist/entries/list.js +4 -3
  52. package/dist/entries/repo.memory.d.ts +12 -10
  53. package/dist/entries/repo.memory.js +11 -10
  54. package/dist/entries/tool-registrations.d.ts +6 -8
  55. package/dist/entries/tool-registrations.js +42 -41
  56. package/dist/entries/types.d.ts +0 -7
  57. package/dist/entries/write-service.d.ts +28 -29
  58. package/dist/entries/write-service.js +114 -105
  59. package/dist/http/settings/cms-adapter.d.ts +20 -0
  60. package/dist/http/settings/cms-adapter.js +124 -0
  61. package/dist/http/settings/contracts.d.ts +135 -0
  62. package/dist/http/settings/contracts.js +2 -0
  63. package/dist/http/settings/http.d.ts +10 -0
  64. package/dist/http/settings/http.js +211 -0
  65. package/dist/http/settings/index.d.ts +5 -0
  66. package/dist/http/settings/index.js +4 -0
  67. package/dist/http/settings/shared.d.ts +68 -0
  68. package/dist/http/settings/shared.js +54 -0
  69. package/dist/http/settings/stream.d.ts +24 -0
  70. package/dist/http/settings/stream.js +147 -0
  71. package/dist/media/agent-tools.d.ts +1 -66
  72. package/dist/media/agent-tools.js +5 -1
  73. package/dist/media/blob-gc-lock.d.ts +6 -2
  74. package/dist/media/blob-gc-lock.js +4 -2
  75. package/dist/media/blob-gc.d.ts +64 -51
  76. package/dist/media/blob-gc.js +62 -52
  77. package/dist/media/blob-key.d.ts +1 -1
  78. package/dist/media/content-type-sniffer.d.ts +3 -1
  79. package/dist/media/content-type-sniffer.js +1 -1
  80. package/dist/media/html-attributes.d.ts +9 -5
  81. package/dist/media/html-attributes.js +8 -6
  82. package/dist/media/image-transformer.js +1 -1
  83. package/dist/media/image-transformer.sharp.d.ts +6 -0
  84. package/dist/media/image-transformer.sharp.js +12 -6
  85. package/dist/media/import/fetch-image.d.ts +24 -0
  86. package/dist/media/import/fetch-image.js +137 -0
  87. package/dist/media/import/index.d.ts +3 -0
  88. package/dist/media/import/index.js +3 -0
  89. package/dist/media/import/ports.d.ts +38 -0
  90. package/dist/media/index.d.ts +7 -1
  91. package/dist/media/index.js +1 -0
  92. package/dist/media/media-service.d.ts +14 -10
  93. package/dist/media/media-service.js +57 -52
  94. package/dist/media/ports.d.ts +3 -2
  95. package/dist/media/rendition-service.d.ts +3 -3
  96. package/dist/media/rendition-service.js +38 -37
  97. package/dist/media/repo.memory.d.ts +18 -7
  98. package/dist/media/repo.memory.js +12 -6
  99. package/dist/media/tool-registrations.d.ts +16 -15
  100. package/dist/media/tool-registrations.js +84 -72
  101. package/dist/media/transform-lock.d.ts +22 -12
  102. package/dist/media/transform-lock.js +14 -13
  103. package/dist/media/transform-registry.d.ts +3 -3
  104. package/dist/media/transform-registry.js +19 -18
  105. package/dist/media/transform-types.d.ts +8 -3
  106. package/dist/media/transform-types.js +10 -5
  107. package/dist/media/types.d.ts +21 -4
  108. package/dist/media/types.js +15 -2
  109. package/dist/navigation/agent-tools.d.ts +1 -80
  110. package/dist/navigation/agent-tools.js +15 -3
  111. package/dist/navigation/contracts.d.ts +1 -1
  112. package/dist/navigation/index.d.ts +2 -2
  113. package/dist/navigation/menu-service.d.ts +57 -40
  114. package/dist/navigation/menu-service.js +80 -69
  115. package/dist/navigation/ports.d.ts +1 -1
  116. package/dist/navigation/read-model.d.ts +3 -1
  117. package/dist/navigation/read-model.js +2 -2
  118. package/dist/navigation/reconcile.d.ts +2 -2
  119. package/dist/navigation/reconcile.js +2 -1
  120. package/dist/navigation/repo.memory.d.ts +7 -3
  121. package/dist/navigation/repo.memory.js +4 -2
  122. package/dist/navigation/resolver.d.ts +4 -1
  123. package/dist/navigation/resolver.js +1 -1
  124. package/dist/navigation/tool-registrations.d.ts +6 -8
  125. package/dist/navigation/tool-registrations.js +44 -42
  126. package/dist/navigation/types.d.ts +1 -1
  127. package/dist/presentation/presentation.d.ts +11 -3
  128. package/dist/presentation/presentation.js +13 -6
  129. package/dist/presentation/repo.memory.d.ts +6 -2
  130. package/dist/presentation/repo.memory.js +3 -2
  131. package/dist/settings/agent-tools.d.ts +2 -75
  132. package/dist/settings/agent-tools.js +49 -45
  133. package/dist/settings/agent-value-write-tools.d.ts +22 -0
  134. package/dist/settings/agent-value-write-tools.js +154 -0
  135. package/dist/settings/agent-writable-preferences.js +8 -20
  136. package/dist/settings/agent-write-denylist.d.ts +19 -0
  137. package/dist/settings/agent-write-denylist.js +15 -0
  138. package/dist/settings/change-feed.d.ts +11 -2
  139. package/dist/settings/change-feed.js +4 -4
  140. package/dist/settings/definitions-dispatch.d.ts +8 -3
  141. package/dist/settings/definitions-dispatch.js +5 -5
  142. package/dist/settings/dictionaries/index.d.ts +5 -2
  143. package/dist/settings/dictionaries/index.js +2 -2
  144. package/dist/settings/dictionaries/settings-dialog.ar.js +0 -1
  145. package/dist/settings/dictionaries/settings-dialog.bn.js +0 -1
  146. package/dist/settings/dictionaries/settings-dialog.de.js +0 -1
  147. package/dist/settings/dictionaries/settings-dialog.es.js +0 -1
  148. package/dist/settings/dictionaries/settings-dialog.fa.js +0 -1
  149. package/dist/settings/dictionaries/settings-dialog.fr.js +0 -1
  150. package/dist/settings/dictionaries/settings-dialog.hi.js +0 -1
  151. package/dist/settings/dictionaries/settings-dialog.hu.js +0 -1
  152. package/dist/settings/dictionaries/settings-dialog.id.js +0 -1
  153. package/dist/settings/dictionaries/settings-dialog.it.js +0 -1
  154. package/dist/settings/dictionaries/settings-dialog.ja.js +0 -1
  155. package/dist/settings/dictionaries/settings-dialog.ko.js +0 -1
  156. package/dist/settings/dictionaries/settings-dialog.pl.js +0 -1
  157. package/dist/settings/dictionaries/settings-dialog.pt-BR.js +0 -1
  158. package/dist/settings/dictionaries/settings-dialog.ru.js +0 -1
  159. package/dist/settings/dictionaries/settings-dialog.th.js +0 -1
  160. package/dist/settings/dictionaries/settings-dialog.tr.js +0 -1
  161. package/dist/settings/dictionaries/settings-dialog.uk.js +0 -1
  162. package/dist/settings/dictionaries/settings-dialog.ur.js +0 -1
  163. package/dist/settings/dictionaries/settings-dialog.zh-CN.js +0 -1
  164. package/dist/settings/dictionaries/settings-dialog.zh-TW.js +0 -1
  165. package/dist/settings/ensure-definitions.d.ts +5 -5
  166. package/dist/settings/errors.d.ts +7 -1
  167. package/dist/settings/errors.js +7 -1
  168. package/dist/settings/index.d.ts +4 -1
  169. package/dist/settings/index.js +1 -0
  170. package/dist/settings/ports.d.ts +6 -5
  171. package/dist/settings/principal-lookup.d.ts +9 -0
  172. package/dist/settings/principal-lookup.js +2 -0
  173. package/dist/settings/purge-service.d.ts +5 -4
  174. package/dist/settings/purge-service.js +3 -2
  175. package/dist/settings/settings.d.ts +22 -7
  176. package/dist/settings/settings.js +47 -26
  177. package/dist/settings/tool-registrations.d.ts +25 -32
  178. package/dist/settings/tool-registrations.js +66 -56
  179. package/dist/settings/types.d.ts +1 -1
  180. package/dist/settings/ui-tab-definitions.d.ts +1 -1
  181. package/dist/settings/write-service.d.ts +32 -26
  182. package/dist/settings/write-service.js +26 -20
  183. package/dist/taxonomy/agent-tools.d.ts +1 -66
  184. package/dist/taxonomy/agent-tools.js +25 -15
  185. package/dist/taxonomy/content-lookup.js +1 -1
  186. package/dist/taxonomy/index.d.ts +2 -2
  187. package/dist/taxonomy/merge-term.d.ts +7 -4
  188. package/dist/taxonomy/merge-term.js +7 -5
  189. package/dist/taxonomy/repo.memory.d.ts +42 -19
  190. package/dist/taxonomy/repo.memory.js +14 -12
  191. package/dist/taxonomy/validation-chain.d.ts +39 -18
  192. package/dist/taxonomy/validation-chain.js +35 -25
  193. package/dist/taxonomy/write-service.d.ts +103 -44
  194. package/dist/taxonomy/write-service.js +221 -179
  195. package/dist/trash/adapters/record-store.d.ts +52 -0
  196. package/dist/trash/adapters/record-store.js +36 -0
  197. package/dist/trash/cursor.d.ts +20 -0
  198. package/dist/trash/cursor.js +36 -0
  199. package/dist/trash/follow-ups.d.ts +76 -0
  200. package/dist/trash/follow-ups.js +46 -0
  201. package/dist/trash/index.d.ts +8 -0
  202. package/dist/trash/index.js +8 -0
  203. package/dist/trash/ports.d.ts +308 -0
  204. package/dist/trash/ports.js +2 -0
  205. package/dist/trash/repo.memory.d.ts +50 -0
  206. package/dist/trash/repo.memory.js +114 -0
  207. package/dist/trash/sweeper.d.ts +77 -0
  208. package/dist/trash/sweeper.js +127 -0
  209. package/dist/trash/write-service.d.ts +100 -0
  210. package/dist/trash/write-service.js +242 -0
  211. package/dist/workspace/agent-tools.d.ts +1 -59
  212. package/dist/workspace/agent-tools.js +27 -12
  213. package/dist/workspace/create.d.ts +31 -6
  214. package/dist/workspace/create.js +18 -5
  215. package/dist/workspace/delete.d.ts +18 -13
  216. package/dist/workspace/delete.js +20 -12
  217. package/dist/workspace/index.d.ts +1 -1
  218. package/dist/workspace/repo.memory.d.ts +19 -4
  219. package/dist/workspace/repo.memory.js +26 -4
  220. package/dist/workspace/tool-registrations.d.ts +2 -2
  221. package/dist/workspace/tool-registrations.js +13 -13
  222. package/dist/workspace/update.d.ts +6 -5
  223. package/dist/workspace/update.js +9 -8
  224. package/package.json +44 -38
  225. package/dist/identity/admin-crud-service.d.ts +0 -280
  226. package/dist/identity/admin-crud-service.js +0 -468
  227. package/dist/identity/agent-tool-input.d.ts +0 -58
  228. package/dist/identity/agent-tool-input.js +0 -126
  229. package/dist/identity/agent-tools.d.ts +0 -101
  230. package/dist/identity/agent-tools.js +0 -290
  231. package/dist/identity/auth-service.d.ts +0 -118
  232. package/dist/identity/auth-service.js +0 -170
  233. package/dist/identity/authorize.d.ts +0 -90
  234. package/dist/identity/authorize.js +0 -94
  235. package/dist/identity/grant-service.d.ts +0 -198
  236. package/dist/identity/grant-service.js +0 -361
  237. package/dist/identity/hasher.d.ts +0 -39
  238. package/dist/identity/hasher.js +0 -39
  239. package/dist/identity/index.d.ts +0 -62
  240. package/dist/identity/index.js +0 -54
  241. package/dist/identity/password-policy.d.ts +0 -57
  242. package/dist/identity/password-policy.js +0 -66
  243. package/dist/identity/permission-migrations.d.ts +0 -86
  244. package/dist/identity/permission-migrations.js +0 -67
  245. package/dist/identity/permissions.d.ts +0 -35
  246. package/dist/identity/permissions.js +0 -603
  247. package/dist/identity/ports.d.ts +0 -201
  248. package/dist/identity/repo.memory.d.ts +0 -164
  249. package/dist/identity/repo.memory.js +0 -224
  250. package/dist/identity/seed.d.ts +0 -54
  251. package/dist/identity/seed.js +0 -429
  252. package/dist/identity/tool-registrations.d.ts +0 -50
  253. package/dist/identity/tool-registrations.js +0 -419
  254. package/dist/identity/types.d.ts +0 -185
  255. package/dist/identity/types.js +0 -64
  256. package/dist/identity/username.d.ts +0 -12
  257. package/dist/identity/username.js +0 -14
  258. /package/dist/{identity → media/import}/ports.js +0 -0
@@ -1,201 +0,0 @@
1
- /**
2
- * @file Port contracts for the `identity` library.
3
- *
4
- * Purpose:
5
- * Dependency-inversion seams (port/adapter rule-of-two) for the identity/RBAC
6
- * tables, plus `PasswordHasherPort` — the hashing seam behind which argon2id
7
- * lives (feature.spec.md Dependencies table: "behind a HasherPort, rule-of-two
8
- * candidate"). Only an in-memory adapter for each repo port ships this pass
9
- * (matches the disclosed precedent set by members/navigation/integrations/
10
- * analytics — see `src/server/deps.ts` comments); a SQLite adapter is a later
11
- * step, not a gap introduced here.
12
- *
13
- * `authorize()` itself is deliberately NOT a port (one
14
- * evaluator) — see `authorize.ts`. `AuthorizeDeps` there is a plain repo bag,
15
- * not declared here.
16
- *
17
- * Interfaces and types only — no feature logic.
18
- */
19
- import type { ISODateTime, UUID } from "../core/ports.js";
20
- import type { PolicyPermissionRecord, PolicyRecord, PrincipalPolicyRecord, PrincipalRecord, PrincipalRoleRecord, RolePolicyRecord, RoleRecord, SessionRecord, UserRecord } from "./types.js";
21
- export interface PrincipalRepoPort {
22
- findById(required: {
23
- workspaceId: UUID;
24
- id: UUID;
25
- }): Promise<PrincipalRecord | null>;
26
- list(required: {
27
- workspaceId: UUID;
28
- }): Promise<PrincipalRecord[]>;
29
- save(record: PrincipalRecord): Promise<void>;
30
- }
31
- export interface UserRepoPort {
32
- findByPrincipalId(required: {
33
- workspaceId: UUID;
34
- principalId: UUID;
35
- }): Promise<UserRecord | null>;
36
- /** `username` must already be normalized (NFC + lowercase) by the caller. */
37
- findByUsername(required: {
38
- workspaceId: UUID;
39
- username: string;
40
- }): Promise<UserRecord | null>;
41
- /** All `users` rows in the workspace (Users admin screen listing). Not paginated in v1 — matches `PrincipalRepoPort.list`/`RoleRepoPort.list`/`PolicyRepoPort.list`. */
42
- list(required: {
43
- workspaceId: UUID;
44
- }): Promise<UserRecord[]>;
45
- save(record: UserRecord): Promise<void>;
46
- }
47
- export interface SessionRepoPort {
48
- findById(required: {
49
- workspaceId: UUID;
50
- id: UUID;
51
- }): Promise<SessionRecord | null>;
52
- findByTokenHash(required: {
53
- workspaceId: UUID;
54
- tokenHash: string;
55
- }): Promise<SessionRecord | null>;
56
- save(record: SessionRecord): Promise<void>;
57
- /** Server-side revocation (logout, disable-cascade). Idempotent. */
58
- revoke(required: {
59
- workspaceId: UUID;
60
- id: UUID;
61
- revokedAt: ISODateTime;
62
- }): Promise<void>;
63
- /** REQ-17 — every session bound to a principal, active or not (`RESET_USER_PASSWORD`
64
- * revokes each active one; unlike `DISABLE_PRINCIPAL`, which needs no session enumeration because
65
- * `validateSession`'s status check already invalidates every session for a disabled principal). */
66
- listByPrincipalId(required: {
67
- workspaceId: UUID;
68
- principalId: UUID;
69
- }): Promise<SessionRecord[]>;
70
- }
71
- export interface RoleRepoPort {
72
- findById(required: {
73
- workspaceId: UUID;
74
- id: UUID;
75
- }): Promise<RoleRecord | null>;
76
- findByName(required: {
77
- workspaceId: UUID;
78
- name: string;
79
- }): Promise<RoleRecord | null>;
80
- list(required: {
81
- workspaceId: UUID;
82
- }): Promise<RoleRecord[]>;
83
- save(record: RoleRecord): Promise<void>;
84
- /** REQ-19 (INV-09). Callers must apply the is_builtin + zero-reference guards
85
- * themselves (see `admin-crud-service.ts`'s `deleteRole`) — this method performs the row deletion
86
- * only, no business rule (mirrors `WorkspaceRepoPort.delete`'s convention). */
87
- delete(required: {
88
- workspaceId: UUID;
89
- id: UUID;
90
- }): Promise<void>;
91
- }
92
- export interface PolicyRepoPort {
93
- findById(required: {
94
- workspaceId: UUID;
95
- id: UUID;
96
- }): Promise<PolicyRecord | null>;
97
- findByName(required: {
98
- workspaceId: UUID;
99
- name: string;
100
- }): Promise<PolicyRecord | null>;
101
- list(required: {
102
- workspaceId: UUID;
103
- }): Promise<PolicyRecord[]>;
104
- save(record: PolicyRecord): Promise<void>;
105
- /** REQ-19 (INV-09). See `RoleRepoPort.delete`'s doc — same "no business rule here"
106
- * contract. */
107
- delete(required: {
108
- workspaceId: UUID;
109
- id: UUID;
110
- }): Promise<void>;
111
- }
112
- export interface PolicyPermissionRepoPort {
113
- listByPolicyId(required: {
114
- workspaceId: UUID;
115
- policyId: UUID;
116
- }): Promise<PolicyPermissionRecord[]>;
117
- save(record: PolicyPermissionRecord): Promise<void>;
118
- /** REQ-19 — cascades a `DELETE_POLICY` to the deleted policy's OWN
119
- * `policy_permissions` rows only (never a different policy's rows, state.spec §3's `DELETE_POLICY`
120
- * row). */
121
- deleteByPolicyId(required: {
122
- workspaceId: UUID;
123
- policyId: UUID;
124
- }): Promise<void>;
125
- /** OQ-10 — removes ONE permission row by its own id, the inverse of `save`. Deliberately keyed by
126
- * `id` alone (plus the workspace scope every port call carries): `removePolicyPermission` proves
127
- * the row belongs to the named policy via `listByPolicyId` BEFORE calling this, so a
128
- * policy-scoped delete signature here would only duplicate a check the caller has already done
129
- * against rows it is holding. */
130
- delete(required: {
131
- workspaceId: UUID;
132
- id: UUID;
133
- }): Promise<void>;
134
- }
135
- export interface RolePolicyRepoPort {
136
- listByRoleId(required: {
137
- workspaceId: UUID;
138
- roleId: UUID;
139
- }): Promise<RolePolicyRecord[]>;
140
- save(record: RolePolicyRecord): Promise<void>;
141
- /** REQ-19 — the policy-side reference check `deletePolicy` needs (F-053-02: no
142
- * writer creates such a row for a non-built-in policy today, but the guard checks for real —
143
- * defensive against that constraint ever being lifted, not a assumption baked into the guard). */
144
- listByPolicyId(required: {
145
- workspaceId: UUID;
146
- policyId: UUID;
147
- }): Promise<RolePolicyRecord[]>;
148
- }
149
- export interface PrincipalRoleRepoPort {
150
- listByPrincipalId(required: {
151
- workspaceId: UUID;
152
- principalId: UUID;
153
- }): Promise<PrincipalRoleRecord[]>;
154
- save(record: PrincipalRoleRecord): Promise<void>;
155
- /** REQ-19 — the reference check `deleteRole` needs (INV-09). */
156
- listByRoleId(required: {
157
- workspaceId: UUID;
158
- roleId: UUID;
159
- }): Promise<PrincipalRoleRecord[]>;
160
- }
161
- export interface PrincipalPolicyRepoPort {
162
- listByPrincipalId(required: {
163
- workspaceId: UUID;
164
- principalId: UUID;
165
- }): Promise<PrincipalPolicyRecord[]>;
166
- save(record: PrincipalPolicyRecord): Promise<void>;
167
- /** REQ-19 — the reference check `deletePolicy` needs (INV-09); this is the
168
- * reference source that matters in practice (`ATTACH_POLICY` does write these rows for
169
- * non-built-in policies, unlike `role_policies`). */
170
- listByPolicyId(required: {
171
- workspaceId: UUID;
172
- policyId: UUID;
173
- }): Promise<PrincipalPolicyRecord[]>;
174
- }
175
- /**
176
- * The nine identity repo ports, bagged for the functions in this library that
177
- * need several of them at once (`authorize`, seeding, the auth service).
178
- * Composition roots (`server/app.ts` / `server/deps.ts`) assemble this from
179
- * individual `RouteDeps` fields.
180
- */
181
- export interface IdentityRepos {
182
- principals: PrincipalRepoPort;
183
- users: UserRepoPort;
184
- sessions: SessionRepoPort;
185
- roles: RoleRepoPort;
186
- policies: PolicyRepoPort;
187
- policyPermissions: PolicyPermissionRepoPort;
188
- rolePolicies: RolePolicyRepoPort;
189
- principalRoles: PrincipalRoleRepoPort;
190
- principalPolicies: PrincipalPolicyRepoPort;
191
- }
192
- /**
193
- * Password hashing seam (INV-05). `argon2` (native argon2id bindings) is the
194
- * v1 adapter — see `hasher.ts`. Declared as a port per the spec's own
195
- * "rule-of-two candidate" language; only one real adapter exists this pass.
196
- */
197
- export interface PasswordHasherPort {
198
- hash(password: string): Promise<string>;
199
- verify(hash: string, password: string): Promise<boolean>;
200
- }
201
- //# sourceMappingURL=ports.d.ts.map
@@ -1,164 +0,0 @@
1
- import type { PolicyPermissionRecord, PolicyRecord, PrincipalPolicyRecord, PrincipalRecord, PrincipalRoleRecord, RolePolicyRecord, RoleRecord, SessionRecord, UserRecord } from "./types.js";
2
- import type { PolicyPermissionRepoPort, PolicyRepoPort, PrincipalPolicyRepoPort, PrincipalRepoPort, PrincipalRoleRepoPort, RolePolicyRepoPort, RoleRepoPort, SessionRepoPort, UserRepoPort } from "./ports.js";
3
- /**
4
- * @file In-memory adapters for the `identity` repo ports.
5
- *
6
- * Purpose:
7
- * Test/dev implementations of the nine identity repo ports. Mirrors the exact
8
- * style of `src/features/post/repo.memory.ts` / `src/members/repo.memory.ts`:
9
- * constructor takes seed rows, methods filter/mutate an internal array. No
10
- * business rules live here — that belongs to `authorize.ts`/`auth-service.ts`/
11
- * `seed.ts`.
12
- *
13
- * Architectural role:
14
- * The only adapter this pass — a SQLite adapter is a later step (see
15
- * `ports.ts` header and `server/deps.ts` comments), matching the disclosed
16
- * precedent of members/navigation/integrations/analytics.
17
- */
18
- export declare class InMemoryPrincipalRepo implements PrincipalRepoPort {
19
- private rows;
20
- constructor(initialRows?: PrincipalRecord[]);
21
- findById(required: {
22
- workspaceId: string;
23
- id: string;
24
- }): Promise<PrincipalRecord | null>;
25
- list(required: {
26
- workspaceId: string;
27
- }): Promise<PrincipalRecord[]>;
28
- save(record: PrincipalRecord): Promise<void>;
29
- }
30
- export declare class InMemoryUserRepo implements UserRepoPort {
31
- private rows;
32
- constructor(initialRows?: UserRecord[]);
33
- findByPrincipalId(required: {
34
- workspaceId: string;
35
- principalId: string;
36
- }): Promise<UserRecord | null>;
37
- findByUsername(required: {
38
- workspaceId: string;
39
- username: string;
40
- }): Promise<UserRecord | null>;
41
- list(required: {
42
- workspaceId: string;
43
- }): Promise<UserRecord[]>;
44
- save(record: UserRecord): Promise<void>;
45
- }
46
- export declare class InMemorySessionRepo implements SessionRepoPort {
47
- private rows;
48
- constructor(initialRows?: SessionRecord[]);
49
- findById(required: {
50
- workspaceId: string;
51
- id: string;
52
- }): Promise<SessionRecord | null>;
53
- findByTokenHash(required: {
54
- workspaceId: string;
55
- tokenHash: string;
56
- }): Promise<SessionRecord | null>;
57
- save(record: SessionRecord): Promise<void>;
58
- revoke(required: {
59
- workspaceId: string;
60
- id: string;
61
- revokedAt: string;
62
- }): Promise<void>;
63
- listByPrincipalId(required: {
64
- workspaceId: string;
65
- principalId: string;
66
- }): Promise<SessionRecord[]>;
67
- }
68
- export declare class InMemoryRoleRepo implements RoleRepoPort {
69
- private rows;
70
- constructor(initialRows?: RoleRecord[]);
71
- findById(required: {
72
- workspaceId: string;
73
- id: string;
74
- }): Promise<RoleRecord | null>;
75
- findByName(required: {
76
- workspaceId: string;
77
- name: string;
78
- }): Promise<RoleRecord | null>;
79
- list(required: {
80
- workspaceId: string;
81
- }): Promise<RoleRecord[]>;
82
- save(record: RoleRecord): Promise<void>;
83
- delete(required: {
84
- workspaceId: string;
85
- id: string;
86
- }): Promise<void>;
87
- }
88
- export declare class InMemoryPolicyRepo implements PolicyRepoPort {
89
- private rows;
90
- constructor(initialRows?: PolicyRecord[]);
91
- findById(required: {
92
- workspaceId: string;
93
- id: string;
94
- }): Promise<PolicyRecord | null>;
95
- findByName(required: {
96
- workspaceId: string;
97
- name: string;
98
- }): Promise<PolicyRecord | null>;
99
- list(required: {
100
- workspaceId: string;
101
- }): Promise<PolicyRecord[]>;
102
- save(record: PolicyRecord): Promise<void>;
103
- delete(required: {
104
- workspaceId: string;
105
- id: string;
106
- }): Promise<void>;
107
- }
108
- export declare class InMemoryPolicyPermissionRepo implements PolicyPermissionRepoPort {
109
- private rows;
110
- constructor(initialRows?: PolicyPermissionRecord[]);
111
- listByPolicyId(required: {
112
- workspaceId: string;
113
- policyId: string;
114
- }): Promise<PolicyPermissionRecord[]>;
115
- save(record: PolicyPermissionRecord): Promise<void>;
116
- deleteByPolicyId(required: {
117
- workspaceId: string;
118
- policyId: string;
119
- }): Promise<void>;
120
- delete(required: {
121
- workspaceId: string;
122
- id: string;
123
- }): Promise<void>;
124
- }
125
- export declare class InMemoryRolePolicyRepo implements RolePolicyRepoPort {
126
- private rows;
127
- constructor(initialRows?: RolePolicyRecord[]);
128
- listByRoleId(required: {
129
- workspaceId: string;
130
- roleId: string;
131
- }): Promise<RolePolicyRecord[]>;
132
- listByPolicyId(required: {
133
- workspaceId: string;
134
- policyId: string;
135
- }): Promise<RolePolicyRecord[]>;
136
- save(record: RolePolicyRecord): Promise<void>;
137
- }
138
- export declare class InMemoryPrincipalRoleRepo implements PrincipalRoleRepoPort {
139
- private rows;
140
- constructor(initialRows?: PrincipalRoleRecord[]);
141
- listByPrincipalId(required: {
142
- workspaceId: string;
143
- principalId: string;
144
- }): Promise<PrincipalRoleRecord[]>;
145
- listByRoleId(required: {
146
- workspaceId: string;
147
- roleId: string;
148
- }): Promise<PrincipalRoleRecord[]>;
149
- save(record: PrincipalRoleRecord): Promise<void>;
150
- }
151
- export declare class InMemoryPrincipalPolicyRepo implements PrincipalPolicyRepoPort {
152
- private rows;
153
- constructor(initialRows?: PrincipalPolicyRecord[]);
154
- listByPrincipalId(required: {
155
- workspaceId: string;
156
- principalId: string;
157
- }): Promise<PrincipalPolicyRecord[]>;
158
- listByPolicyId(required: {
159
- workspaceId: string;
160
- policyId: string;
161
- }): Promise<PrincipalPolicyRecord[]>;
162
- save(record: PrincipalPolicyRecord): Promise<void>;
163
- }
164
- //# sourceMappingURL=repo.memory.d.ts.map
@@ -1,224 +0,0 @@
1
- /**
2
- * @file In-memory adapters for the `identity` repo ports.
3
- *
4
- * Purpose:
5
- * Test/dev implementations of the nine identity repo ports. Mirrors the exact
6
- * style of `src/features/post/repo.memory.ts` / `src/members/repo.memory.ts`:
7
- * constructor takes seed rows, methods filter/mutate an internal array. No
8
- * business rules live here — that belongs to `authorize.ts`/`auth-service.ts`/
9
- * `seed.ts`.
10
- *
11
- * Architectural role:
12
- * The only adapter this pass — a SQLite adapter is a later step (see
13
- * `ports.ts` header and `server/deps.ts` comments), matching the disclosed
14
- * precedent of members/navigation/integrations/analytics.
15
- */
16
- export class InMemoryPrincipalRepo {
17
- rows;
18
- constructor(initialRows = []) {
19
- this.rows = [...initialRows];
20
- }
21
- async findById(required) {
22
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
23
- }
24
- async list(required) {
25
- return this.rows.filter((row) => row.workspaceId === required.workspaceId);
26
- }
27
- async save(record) {
28
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
29
- if (index === -1) {
30
- this.rows.push(record);
31
- return;
32
- }
33
- this.rows[index] = record;
34
- }
35
- }
36
- export class InMemoryUserRepo {
37
- rows;
38
- constructor(initialRows = []) {
39
- this.rows = [...initialRows];
40
- }
41
- async findByPrincipalId(required) {
42
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId) ?? null);
43
- }
44
- async findByUsername(required) {
45
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.username === required.username) ?? null);
46
- }
47
- async list(required) {
48
- return this.rows.filter((row) => row.workspaceId === required.workspaceId);
49
- }
50
- async save(record) {
51
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.principalId === record.principalId);
52
- if (index === -1) {
53
- this.rows.push(record);
54
- return;
55
- }
56
- this.rows[index] = record;
57
- }
58
- }
59
- export class InMemorySessionRepo {
60
- rows;
61
- constructor(initialRows = []) {
62
- this.rows = [...initialRows];
63
- }
64
- async findById(required) {
65
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
66
- }
67
- async findByTokenHash(required) {
68
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.tokenHash === required.tokenHash) ?? null);
69
- }
70
- async save(record) {
71
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
72
- if (index === -1) {
73
- this.rows.push(record);
74
- return;
75
- }
76
- this.rows[index] = record;
77
- }
78
- async revoke(required) {
79
- const row = this.rows.find((candidate) => candidate.workspaceId === required.workspaceId && candidate.id === required.id);
80
- if (row)
81
- row.revokedAt = required.revokedAt;
82
- }
83
- async listByPrincipalId(required) {
84
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId);
85
- }
86
- }
87
- export class InMemoryRoleRepo {
88
- rows;
89
- constructor(initialRows = []) {
90
- this.rows = [...initialRows];
91
- }
92
- async findById(required) {
93
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
94
- }
95
- async findByName(required) {
96
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.name === required.name) ??
97
- null);
98
- }
99
- async list(required) {
100
- return this.rows.filter((row) => row.workspaceId === required.workspaceId);
101
- }
102
- async save(record) {
103
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
104
- if (index === -1) {
105
- this.rows.push(record);
106
- return;
107
- }
108
- this.rows[index] = record;
109
- }
110
- async delete(required) {
111
- this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.id === required.id));
112
- }
113
- }
114
- export class InMemoryPolicyRepo {
115
- rows;
116
- constructor(initialRows = []) {
117
- this.rows = [...initialRows];
118
- }
119
- async findById(required) {
120
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.id === required.id) ?? null);
121
- }
122
- async findByName(required) {
123
- return (this.rows.find((row) => row.workspaceId === required.workspaceId && row.name === required.name) ??
124
- null);
125
- }
126
- async list(required) {
127
- return this.rows.filter((row) => row.workspaceId === required.workspaceId);
128
- }
129
- async save(record) {
130
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
131
- if (index === -1) {
132
- this.rows.push(record);
133
- return;
134
- }
135
- this.rows[index] = record;
136
- }
137
- async delete(required) {
138
- this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.id === required.id));
139
- }
140
- }
141
- export class InMemoryPolicyPermissionRepo {
142
- rows;
143
- constructor(initialRows = []) {
144
- this.rows = [...initialRows];
145
- }
146
- async listByPolicyId(required) {
147
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.policyId === required.policyId);
148
- }
149
- async save(record) {
150
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
151
- if (index === -1) {
152
- this.rows.push(record);
153
- return;
154
- }
155
- this.rows[index] = record;
156
- }
157
- async deleteByPolicyId(required) {
158
- this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.policyId === required.policyId));
159
- }
160
- async delete(required) {
161
- this.rows = this.rows.filter((row) => !(row.workspaceId === required.workspaceId && row.id === required.id));
162
- }
163
- }
164
- export class InMemoryRolePolicyRepo {
165
- rows;
166
- constructor(initialRows = []) {
167
- this.rows = [...initialRows];
168
- }
169
- async listByRoleId(required) {
170
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.roleId === required.roleId);
171
- }
172
- async listByPolicyId(required) {
173
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.policyId === required.policyId);
174
- }
175
- async save(record) {
176
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
177
- if (index === -1) {
178
- this.rows.push(record);
179
- return;
180
- }
181
- this.rows[index] = record;
182
- }
183
- }
184
- export class InMemoryPrincipalRoleRepo {
185
- rows;
186
- constructor(initialRows = []) {
187
- this.rows = [...initialRows];
188
- }
189
- async listByPrincipalId(required) {
190
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId);
191
- }
192
- async listByRoleId(required) {
193
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.roleId === required.roleId);
194
- }
195
- async save(record) {
196
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
197
- if (index === -1) {
198
- this.rows.push(record);
199
- return;
200
- }
201
- this.rows[index] = record;
202
- }
203
- }
204
- export class InMemoryPrincipalPolicyRepo {
205
- rows;
206
- constructor(initialRows = []) {
207
- this.rows = [...initialRows];
208
- }
209
- async listByPrincipalId(required) {
210
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId);
211
- }
212
- async listByPolicyId(required) {
213
- return this.rows.filter((row) => row.workspaceId === required.workspaceId && row.policyId === required.policyId);
214
- }
215
- async save(record) {
216
- const index = this.rows.findIndex((row) => row.workspaceId === record.workspaceId && row.id === record.id);
217
- if (index === -1) {
218
- this.rows.push(record);
219
- return;
220
- }
221
- this.rows[index] = record;
222
- }
223
- }
224
- //# sourceMappingURL=repo.memory.js.map
@@ -1,54 +0,0 @@
1
- import type { ClockPort, IdGeneratorPort, UUID } from "../core/ports.js";
2
- import type { IdentityRepos, PasswordHasherPort } from "./ports.js";
3
- export interface SeedIdentityDeps {
4
- repos: IdentityRepos;
5
- hasher: PasswordHasherPort;
6
- clock: ClockPort;
7
- idGen: IdGeneratorPort;
8
- }
9
- export interface SeedIdentityInput {
10
- workspaceId: UUID;
11
- /** Defaults to `"admin"`. A username is not a secret, so a library default costs nothing here. */
12
- ownerUsername?: string | undefined;
13
- /**
14
- * Required, and deliberately without a default.
15
- *
16
- * This function mints the first credential that can administer a workspace. A library-supplied
17
- * fallback would mean every host that forgot to pass one shipped the *same* owner password, and
18
- * the omission would look like working code rather than a misconfiguration. Where the value comes
19
- * from — an environment variable, an operator prompt, a secret store, a generated string — is a
20
- * decision only the host can make, because only the host knows its deployment model. Making this
21
- * required turns "forgot to decide" into a compile error instead of a shared default credential.
22
- */
23
- ownerPassword: string;
24
- ownerEmail?: string | undefined;
25
- }
26
- export interface SeedIdentityResult {
27
- ownerPrincipalId: UUID;
28
- systemPrincipalId: UUID;
29
- }
30
- /**
31
- * Seed first-boot identity data.
32
- *
33
- * Idempotent in two distinct senses, and both are load-bearing:
34
- * - A seed that RAN TO COMPLETION is a no-op — the owner-username lookup below early-returns after
35
- * a single confirming read (`ensureOwnerRoleBinding`) and writes nothing. (This path does not
36
- * reconcile a built-in policy whose permission list has since grown; that is the host's job — see
37
- * the host's `applyBuiltinRoleGrants` / `migrateDeprecatedPermissionGrants`, chained onto
38
- * `identityReady`.)
39
- * - "Ran to completion" is judged on the owner user AND its role link, not the user alone. The link
40
- * is the seed's last write, so the user is not on its own evidence the seed finished — see
41
- * `ensureOwnerRoleBinding` for what an interrupt between those two writes costs.
42
- * - A seed that was INTERRUPTED is resumed, not replayed: every step converges onto the rows a
43
- * previous attempt already wrote and fills in only what is missing. See the block comment above
44
- * `ensureBuiltinRole` for why this function must survive being killed halfway.
45
- *
46
- * @complexity O(1) — fixed small number of inserts (4 roles/policies, ~2
47
- * dozen policy_permissions, 3 principals, 1 user, 1 role assignment).
48
- * @overallScore 100
49
- */
50
- export declare function seedIdentity(required: {
51
- deps: SeedIdentityDeps;
52
- input: SeedIdentityInput;
53
- }): Promise<SeedIdentityResult>;
54
- //# sourceMappingURL=seed.d.ts.map