@mainsoft/agent-cms 0.0.0-stage → 0.6.1

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 (108) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +21 -0
  3. package/README.md +347 -2
  4. package/TODO.md +178 -0
  5. package/UPGRADE-0.6.md +236 -0
  6. package/dist/agent.cjs +250 -0
  7. package/dist/agent.d.cts +88 -0
  8. package/dist/agent.d.ts +88 -0
  9. package/dist/agent.js +24 -0
  10. package/dist/ai.cjs +555 -0
  11. package/dist/ai.d.cts +48 -0
  12. package/dist/ai.d.ts +48 -0
  13. package/dist/ai.js +73 -0
  14. package/dist/bin.js +1556 -0
  15. package/dist/chunk-2NTK7H4W.js +10 -0
  16. package/dist/chunk-52NUUZC7.js +1446 -0
  17. package/dist/chunk-6K5ZTGHQ.js +30 -0
  18. package/dist/chunk-AKN7SUXU.js +281 -0
  19. package/dist/chunk-BTO42652.js +249 -0
  20. package/dist/chunk-CRDW6Q72.js +188 -0
  21. package/dist/chunk-DD56PTZ4.js +78 -0
  22. package/dist/chunk-DOADAH4L.js +52 -0
  23. package/dist/chunk-IGL2V6US.js +324 -0
  24. package/dist/chunk-IW3D4I7Q.js +317 -0
  25. package/dist/chunk-OQ55GEF3.js +6 -0
  26. package/dist/chunk-QC2M4NZY.js +158 -0
  27. package/dist/chunk-QIUXAUQ6.js +6 -0
  28. package/dist/chunk-QQV6VLYJ.js +204 -0
  29. package/dist/chunk-T66ZKBHF.js +25 -0
  30. package/dist/chunk-VICZ76TR.js +118 -0
  31. package/dist/cli.cjs +1596 -0
  32. package/dist/cli.d.cts +89 -0
  33. package/dist/cli.d.ts +89 -0
  34. package/dist/cli.js +534 -0
  35. package/dist/client.cjs +185 -0
  36. package/dist/client.d.cts +228 -0
  37. package/dist/client.d.ts +228 -0
  38. package/dist/client.js +13 -0
  39. package/dist/cms-BPp01z-8.d.ts +411 -0
  40. package/dist/cms-D6D89-qZ.d.cts +411 -0
  41. package/dist/config.cjs +61 -0
  42. package/dist/config.d.cts +36 -0
  43. package/dist/config.d.ts +36 -0
  44. package/dist/config.js +11 -0
  45. package/dist/diff.cjs +316 -0
  46. package/dist/diff.d.cts +122 -0
  47. package/dist/diff.d.ts +122 -0
  48. package/dist/diff.js +29 -0
  49. package/dist/drizzle-repo-B1rt7r4j.d.ts +90 -0
  50. package/dist/drizzle-repo-Cn-kL2FK.d.cts +90 -0
  51. package/dist/errors.cjs +193 -0
  52. package/dist/errors.d.cts +109 -0
  53. package/dist/errors.d.ts +109 -0
  54. package/dist/errors.js +16 -0
  55. package/dist/frontmatter.cjs +103 -0
  56. package/dist/frontmatter.d.cts +32 -0
  57. package/dist/frontmatter.d.ts +32 -0
  58. package/dist/frontmatter.js +9 -0
  59. package/dist/http.cjs +1104 -0
  60. package/dist/http.d.cts +67 -0
  61. package/dist/http.d.ts +67 -0
  62. package/dist/http.js +321 -0
  63. package/dist/index.cjs +3066 -0
  64. package/dist/index.d.cts +19 -0
  65. package/dist/index.d.ts +19 -0
  66. package/dist/index.js +263 -0
  67. package/dist/markdown.cjs +220 -0
  68. package/dist/markdown.d.cts +88 -0
  69. package/dist/markdown.d.ts +88 -0
  70. package/dist/markdown.js +23 -0
  71. package/dist/mcp.cjs +649 -0
  72. package/dist/mcp.d.cts +33 -0
  73. package/dist/mcp.d.ts +33 -0
  74. package/dist/mcp.js +24 -0
  75. package/dist/messages/en.cjs +76 -0
  76. package/dist/messages/en.d.cts +7 -0
  77. package/dist/messages/en.d.ts +7 -0
  78. package/dist/messages/en.js +7 -0
  79. package/dist/messages/ko.cjs +76 -0
  80. package/dist/messages/ko.d.cts +7 -0
  81. package/dist/messages/ko.d.ts +7 -0
  82. package/dist/messages/ko.js +53 -0
  83. package/dist/registry/cms-audit.json +25 -0
  84. package/dist/registry/cms-command.json +23 -0
  85. package/dist/registry/cms-doc-editor.json +36 -0
  86. package/dist/registry/cms-doc-list.json +29 -0
  87. package/dist/registry/cms-empty.json +22 -0
  88. package/dist/registry/cms-keys.json +29 -0
  89. package/dist/registry/cms-lib.json +33 -0
  90. package/dist/registry/cms-merge.json +26 -0
  91. package/dist/registry/cms-shell.json +22 -0
  92. package/dist/registry/cms-versions.json +26 -0
  93. package/dist/registry/registry.json +255 -0
  94. package/dist/repo-BWI2Pkrv.d.ts +162 -0
  95. package/dist/repo-CeDxUxO6.d.cts +162 -0
  96. package/dist/tables.cjs +356 -0
  97. package/dist/tables.d.cts +3515 -0
  98. package/dist/tables.d.ts +3515 -0
  99. package/dist/tables.js +35 -0
  100. package/dist/tools.cjs +420 -0
  101. package/dist/tools.d.cts +27 -0
  102. package/dist/tools.d.ts +27 -0
  103. package/dist/tools.js +18 -0
  104. package/dist/types.cjs +226 -0
  105. package/dist/types.d.cts +286 -0
  106. package/dist/types.d.ts +286 -0
  107. package/dist/types.js +28 -0
  108. package/package.json +277 -4
@@ -0,0 +1,255 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry.json",
3
+ "name": "agent-cms",
4
+ "homepage": "https://github.com/mainsoft-2024/agent-cms",
5
+ "items": [
6
+ {
7
+ "name": "cms-lib",
8
+ "type": "registry:lib",
9
+ "title": "agent-cms client and helpers",
10
+ "description": "CmsProvider and useCms (REST client, UI strings in English and Korean), small hooks, shared parts (state badge, copy box, confirm dialog, page header, markdown preview).",
11
+ "dependencies": [
12
+ "@mainsoft/agent-cms",
13
+ "lucide-react"
14
+ ],
15
+ "registryDependencies": [
16
+ "badge",
17
+ "button",
18
+ "dialog"
19
+ ],
20
+ "files": [
21
+ {
22
+ "path": "registry/cms/use-cms.ts",
23
+ "type": "registry:lib"
24
+ },
25
+ {
26
+ "path": "registry/cms/cms-messages.ts",
27
+ "type": "registry:lib"
28
+ },
29
+ {
30
+ "path": "registry/cms/cms-parts.tsx",
31
+ "type": "registry:lib"
32
+ }
33
+ ]
34
+ },
35
+ {
36
+ "name": "cms-shell",
37
+ "type": "registry:component",
38
+ "title": "Admin layout",
39
+ "description": "Sidebar with collections, API keys and audit log, plus extraNav for your app's own screens. A sheet menu under 768px.",
40
+ "dependencies": [
41
+ "@mainsoft/agent-cms",
42
+ "lucide-react"
43
+ ],
44
+ "registryDependencies": [
45
+ "sheet",
46
+ "cms-lib"
47
+ ],
48
+ "files": [
49
+ {
50
+ "path": "registry/cms/cms-shell.tsx",
51
+ "type": "registry:component"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "name": "cms-empty",
57
+ "type": "registry:component",
58
+ "title": "Empty collection",
59
+ "description": "New document, and how to write with an agent instead (CLI one-liner, MCP URL, API key link).",
60
+ "dependencies": [
61
+ "@mainsoft/agent-cms",
62
+ "lucide-react"
63
+ ],
64
+ "registryDependencies": [
65
+ "button",
66
+ "cms-lib"
67
+ ],
68
+ "files": [
69
+ {
70
+ "path": "registry/cms/cms-empty.tsx",
71
+ "type": "registry:component"
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "name": "cms-doc-list",
77
+ "type": "registry:component",
78
+ "title": "Document list",
79
+ "description": "State tabs with counts, category and author filters, search, 7-day views, selection with bulk publish, unpublish, hide, unhide and delete. Cards with long-press selection on phones.",
80
+ "dependencies": [
81
+ "@mainsoft/agent-cms",
82
+ "lucide-react"
83
+ ],
84
+ "registryDependencies": [
85
+ "button",
86
+ "checkbox",
87
+ "dialog",
88
+ "dropdown-menu",
89
+ "input",
90
+ "select",
91
+ "table",
92
+ "cms-lib",
93
+ "cms-empty"
94
+ ],
95
+ "files": [
96
+ {
97
+ "path": "registry/cms/cms-doc-list.tsx",
98
+ "type": "registry:component"
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "name": "cms-merge",
104
+ "type": "registry:component",
105
+ "title": "Merge after a conflict",
106
+ "description": "Three-way merge when someone saved first: what merged automatically, and theirs, mine or both for each conflict.",
107
+ "dependencies": [
108
+ "@mainsoft/agent-cms",
109
+ "lucide-react"
110
+ ],
111
+ "registryDependencies": [
112
+ "badge",
113
+ "button",
114
+ "label",
115
+ "radio-group",
116
+ "table",
117
+ "cms-lib"
118
+ ],
119
+ "files": [
120
+ {
121
+ "path": "registry/cms/cms-merge.tsx",
122
+ "type": "registry:component"
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ "name": "cms-doc-editor",
128
+ "type": "registry:component",
129
+ "title": "Document editor",
130
+ "description": "Info form generated from the collection schema, markdown with live preview, autosave and restore, problems on the fields, agent change review (accept, revert), save, publish, preview links.",
131
+ "dependencies": [
132
+ "@mainsoft/agent-cms",
133
+ "lucide-react"
134
+ ],
135
+ "registryDependencies": [
136
+ "button",
137
+ "checkbox",
138
+ "dialog",
139
+ "dropdown-menu",
140
+ "input",
141
+ "label",
142
+ "select",
143
+ "tabs",
144
+ "textarea",
145
+ "cms-lib",
146
+ "cms-merge"
147
+ ],
148
+ "files": [
149
+ {
150
+ "path": "registry/cms/cms-doc-editor.tsx",
151
+ "type": "registry:component"
152
+ },
153
+ {
154
+ "path": "registry/cms/cms-field-form.tsx",
155
+ "type": "registry:component"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "name": "cms-versions",
161
+ "type": "registry:component",
162
+ "title": "Version history",
163
+ "description": "Versions with author, note and changed fields; compare any two side by side or unified with word highlights; restore or publish a version.",
164
+ "dependencies": [
165
+ "@mainsoft/agent-cms",
166
+ "lucide-react"
167
+ ],
168
+ "registryDependencies": [
169
+ "badge",
170
+ "button",
171
+ "dialog",
172
+ "label",
173
+ "select",
174
+ "cms-lib"
175
+ ],
176
+ "files": [
177
+ {
178
+ "path": "registry/cms/cms-versions.tsx",
179
+ "type": "registry:component"
180
+ }
181
+ ]
182
+ },
183
+ {
184
+ "name": "cms-keys",
185
+ "type": "registry:component",
186
+ "title": "API keys",
187
+ "description": "Keys with scopes, collections, last use and expiry; revoke; create with the secret shown once and MCP and CLI setup to copy.",
188
+ "dependencies": [
189
+ "@mainsoft/agent-cms",
190
+ "lucide-react"
191
+ ],
192
+ "registryDependencies": [
193
+ "badge",
194
+ "button",
195
+ "checkbox",
196
+ "dialog",
197
+ "input",
198
+ "label",
199
+ "table",
200
+ "tabs",
201
+ "cms-lib"
202
+ ],
203
+ "files": [
204
+ {
205
+ "path": "registry/cms/cms-keys.tsx",
206
+ "type": "registry:component"
207
+ }
208
+ ]
209
+ },
210
+ {
211
+ "name": "cms-audit",
212
+ "type": "registry:component",
213
+ "title": "Audit log",
214
+ "description": "Who did what through which channel, filtered by action, who and result.",
215
+ "dependencies": [
216
+ "@mainsoft/agent-cms",
217
+ "lucide-react"
218
+ ],
219
+ "registryDependencies": [
220
+ "badge",
221
+ "button",
222
+ "select",
223
+ "table",
224
+ "cms-lib"
225
+ ],
226
+ "files": [
227
+ {
228
+ "path": "registry/cms/cms-audit.tsx",
229
+ "type": "registry:component"
230
+ }
231
+ ]
232
+ },
233
+ {
234
+ "name": "cms-command",
235
+ "type": "registry:component",
236
+ "title": "Command menu",
237
+ "description": "Cmd+K or Ctrl+K: find documents (drafts included) across collections and open, publish or start a new one.",
238
+ "dependencies": [
239
+ "@mainsoft/agent-cms",
240
+ "lucide-react"
241
+ ],
242
+ "registryDependencies": [
243
+ "command",
244
+ "dialog",
245
+ "cms-lib"
246
+ ],
247
+ "files": [
248
+ {
249
+ "path": "registry/cms/cms-command.tsx",
250
+ "type": "registry:component"
251
+ }
252
+ ]
253
+ }
254
+ ]
255
+ }
@@ -0,0 +1,162 @@
1
+ import { CmsDoc, DocStatus, CmsVersion, ReviewMark, KeyScope, CmsKey, AuditEntry } from './types.js';
2
+
3
+ /**
4
+ * Storage behind the CMS. `cms.ts` holds every rule (states, access, versions,
5
+ * validation) and talks only to this interface, so the rules are tested
6
+ * against `MemoryRepo` and run in production on `DrizzleRepo`.
7
+ */
8
+
9
+ type DocPatch = Partial<Omit<CmsDoc, "id" | "collection" | "createdAt">>;
10
+ type NewDoc = Omit<CmsDoc, "id" | "createdAt" | "updatedAt" | "republishedAt" | "autosave"> & {
11
+ id?: string;
12
+ createdAt?: string;
13
+ updatedAt?: string;
14
+ republishedAt?: string | null;
15
+ autosave?: CmsDoc["autosave"];
16
+ };
17
+ type StoredVersion = Omit<CmsVersion, "published">;
18
+ type NewVersion = Omit<CmsVersion, "id" | "createdAt" | "published" | "reviewed" | "changed"> & {
19
+ createdAt?: string;
20
+ changed?: CmsVersion["changed"];
21
+ };
22
+ interface KeyRow extends CmsKey {
23
+ hash: string;
24
+ createdBy: string | null;
25
+ }
26
+ interface AuditQuery {
27
+ /** Entries strictly older than this cursor (from the previous page). */
28
+ before?: string | null;
29
+ limit: number;
30
+ action?: string;
31
+ outcome?: AuditEntry["outcome"];
32
+ actorKind?: AuditEntry["actorKind"];
33
+ }
34
+ interface CmsRepo {
35
+ /** Run `fn` atomically (one DB transaction). */
36
+ tx<T>(fn: (repo: CmsRepo) => Promise<T>): Promise<T>;
37
+ findDoc(collection: string, slug: string): Promise<CmsDoc | null>;
38
+ findDocById(id: string): Promise<CmsDoc | null>;
39
+ listDocs(filter: {
40
+ collection?: string;
41
+ statuses?: DocStatus[];
42
+ published?: boolean;
43
+ }): Promise<CmsDoc[]>;
44
+ insertDoc(doc: NewDoc): Promise<CmsDoc>;
45
+ /** Returns null when `expectedVersion` is given and the row moved on. */
46
+ updateDoc(id: string, patch: DocPatch, expectedVersion?: number): Promise<CmsDoc | null>;
47
+ deleteDoc(id: string): Promise<void>;
48
+ insertVersion(v: NewVersion): Promise<void>;
49
+ listVersions(documentId: string): Promise<StoredVersion[]>;
50
+ getVersion(documentId: string, version: number): Promise<StoredVersion | null>;
51
+ setVersionReviewed(documentId: string, version: number, reviewed: ReviewMark[]): Promise<void>;
52
+ /** Delete all but the newest `keep` versions, never one in `protect`. */
53
+ pruneVersions(documentId: string, keep: number, protect: number[]): Promise<void>;
54
+ insertKey(k: {
55
+ name: string;
56
+ prefix: string;
57
+ hash: string;
58
+ scopes: KeyScope[];
59
+ collections: string[] | null;
60
+ createdBy: string | null;
61
+ expiresAt: string | null;
62
+ }): Promise<KeyRow>;
63
+ listKeys(): Promise<KeyRow[]>;
64
+ findKeyByHash(hash: string): Promise<KeyRow | null>;
65
+ touchKey(id: string, at: string): Promise<void>;
66
+ revokeKey(id: string, at: string): Promise<boolean>;
67
+ addHits(documentIds: string[], day: string, source: string): Promise<void>;
68
+ /** Hits per document since `sinceDay` (inclusive); only documents of `collection` when given. */
69
+ hitCounts(sinceDay: string, collection?: string): Promise<Map<string, number>>;
70
+ insertAudit(e: Omit<AuditEntry, "id">): Promise<void>;
71
+ /** Newest first. */
72
+ listAudit(q: AuditQuery): Promise<AuditEntry[]>;
73
+ /** Changes whenever any document changes (for cross-process index refresh). */
74
+ changeStamp(): Promise<string>;
75
+ getMeta(key: string): Promise<unknown>;
76
+ setMeta(key: string, value: unknown): Promise<void>;
77
+ }
78
+ /** In-memory repo for tests and examples. Starts at the current schema version. */
79
+ declare class MemoryRepo implements CmsRepo {
80
+ docs: Map<string, CmsDoc>;
81
+ versions: StoredVersion[];
82
+ keys: KeyRow[];
83
+ hits: Map<string, number>;
84
+ audit: AuditEntry[];
85
+ meta: Map<string, unknown>;
86
+ private seq;
87
+ private id;
88
+ tx<T>(fn: (repo: CmsRepo) => Promise<T>): Promise<T>;
89
+ findDoc(collection: string, slug: string): Promise<CmsDoc | null>;
90
+ findDocById(id: string): Promise<CmsDoc | null>;
91
+ listDocs(f: {
92
+ collection?: string;
93
+ statuses?: DocStatus[];
94
+ published?: boolean;
95
+ }): Promise<CmsDoc[]>;
96
+ insertDoc(doc: NewDoc): Promise<CmsDoc>;
97
+ updateDoc(id: string, patch: DocPatch, expectedVersion?: number): Promise<CmsDoc | null>;
98
+ deleteDoc(id: string): Promise<void>;
99
+ insertVersion(v: NewVersion): Promise<void>;
100
+ listVersions(documentId: string): Promise<StoredVersion[]>;
101
+ getVersion(documentId: string, version: number): Promise<StoredVersion | null>;
102
+ setVersionReviewed(documentId: string, version: number, reviewed: ReviewMark[]): Promise<void>;
103
+ pruneVersions(documentId: string, keep: number, protect: number[]): Promise<void>;
104
+ insertKey(k: {
105
+ name: string;
106
+ prefix: string;
107
+ hash: string;
108
+ scopes: KeyScope[];
109
+ collections: string[] | null;
110
+ createdBy: string | null;
111
+ expiresAt: string | null;
112
+ }): Promise<{
113
+ hash: string;
114
+ createdBy: string | null;
115
+ id: string;
116
+ name: string;
117
+ prefix: string;
118
+ scopes: KeyScope[];
119
+ collections: string[] | null;
120
+ lastUsedAt: string | null;
121
+ revokedAt: string | null;
122
+ expiresAt: string | null;
123
+ createdAt: string;
124
+ }>;
125
+ listKeys(): Promise<{
126
+ hash: string;
127
+ createdBy: string | null;
128
+ id: string;
129
+ name: string;
130
+ prefix: string;
131
+ scopes: KeyScope[];
132
+ collections: string[] | null;
133
+ lastUsedAt: string | null;
134
+ revokedAt: string | null;
135
+ expiresAt: string | null;
136
+ createdAt: string;
137
+ }[]>;
138
+ findKeyByHash(hash: string): Promise<{
139
+ hash: string;
140
+ createdBy: string | null;
141
+ id: string;
142
+ name: string;
143
+ prefix: string;
144
+ scopes: KeyScope[];
145
+ collections: string[] | null;
146
+ lastUsedAt: string | null;
147
+ revokedAt: string | null;
148
+ expiresAt: string | null;
149
+ createdAt: string;
150
+ } | null>;
151
+ touchKey(id: string, at: string): Promise<void>;
152
+ revokeKey(id: string, at: string): Promise<boolean>;
153
+ addHits(ids: string[], day: string, source: string): Promise<void>;
154
+ hitCounts(sinceDay: string, collection?: string): Promise<Map<string, number>>;
155
+ insertAudit(e: Omit<AuditEntry, "id">): Promise<void>;
156
+ listAudit(q: AuditQuery): Promise<AuditEntry[]>;
157
+ changeStamp(): Promise<string>;
158
+ getMeta(key: string): Promise<{} | null>;
159
+ setMeta(key: string, value: unknown): Promise<void>;
160
+ }
161
+
162
+ export { type AuditQuery as A, type CmsRepo as C, type DocPatch as D, type KeyRow as K, MemoryRepo as M, type NewDoc as N, type StoredVersion as S, type NewVersion as a };
@@ -0,0 +1,162 @@
1
+ import { CmsDoc, DocStatus, CmsVersion, ReviewMark, KeyScope, CmsKey, AuditEntry } from './types.cjs';
2
+
3
+ /**
4
+ * Storage behind the CMS. `cms.ts` holds every rule (states, access, versions,
5
+ * validation) and talks only to this interface, so the rules are tested
6
+ * against `MemoryRepo` and run in production on `DrizzleRepo`.
7
+ */
8
+
9
+ type DocPatch = Partial<Omit<CmsDoc, "id" | "collection" | "createdAt">>;
10
+ type NewDoc = Omit<CmsDoc, "id" | "createdAt" | "updatedAt" | "republishedAt" | "autosave"> & {
11
+ id?: string;
12
+ createdAt?: string;
13
+ updatedAt?: string;
14
+ republishedAt?: string | null;
15
+ autosave?: CmsDoc["autosave"];
16
+ };
17
+ type StoredVersion = Omit<CmsVersion, "published">;
18
+ type NewVersion = Omit<CmsVersion, "id" | "createdAt" | "published" | "reviewed" | "changed"> & {
19
+ createdAt?: string;
20
+ changed?: CmsVersion["changed"];
21
+ };
22
+ interface KeyRow extends CmsKey {
23
+ hash: string;
24
+ createdBy: string | null;
25
+ }
26
+ interface AuditQuery {
27
+ /** Entries strictly older than this cursor (from the previous page). */
28
+ before?: string | null;
29
+ limit: number;
30
+ action?: string;
31
+ outcome?: AuditEntry["outcome"];
32
+ actorKind?: AuditEntry["actorKind"];
33
+ }
34
+ interface CmsRepo {
35
+ /** Run `fn` atomically (one DB transaction). */
36
+ tx<T>(fn: (repo: CmsRepo) => Promise<T>): Promise<T>;
37
+ findDoc(collection: string, slug: string): Promise<CmsDoc | null>;
38
+ findDocById(id: string): Promise<CmsDoc | null>;
39
+ listDocs(filter: {
40
+ collection?: string;
41
+ statuses?: DocStatus[];
42
+ published?: boolean;
43
+ }): Promise<CmsDoc[]>;
44
+ insertDoc(doc: NewDoc): Promise<CmsDoc>;
45
+ /** Returns null when `expectedVersion` is given and the row moved on. */
46
+ updateDoc(id: string, patch: DocPatch, expectedVersion?: number): Promise<CmsDoc | null>;
47
+ deleteDoc(id: string): Promise<void>;
48
+ insertVersion(v: NewVersion): Promise<void>;
49
+ listVersions(documentId: string): Promise<StoredVersion[]>;
50
+ getVersion(documentId: string, version: number): Promise<StoredVersion | null>;
51
+ setVersionReviewed(documentId: string, version: number, reviewed: ReviewMark[]): Promise<void>;
52
+ /** Delete all but the newest `keep` versions, never one in `protect`. */
53
+ pruneVersions(documentId: string, keep: number, protect: number[]): Promise<void>;
54
+ insertKey(k: {
55
+ name: string;
56
+ prefix: string;
57
+ hash: string;
58
+ scopes: KeyScope[];
59
+ collections: string[] | null;
60
+ createdBy: string | null;
61
+ expiresAt: string | null;
62
+ }): Promise<KeyRow>;
63
+ listKeys(): Promise<KeyRow[]>;
64
+ findKeyByHash(hash: string): Promise<KeyRow | null>;
65
+ touchKey(id: string, at: string): Promise<void>;
66
+ revokeKey(id: string, at: string): Promise<boolean>;
67
+ addHits(documentIds: string[], day: string, source: string): Promise<void>;
68
+ /** Hits per document since `sinceDay` (inclusive); only documents of `collection` when given. */
69
+ hitCounts(sinceDay: string, collection?: string): Promise<Map<string, number>>;
70
+ insertAudit(e: Omit<AuditEntry, "id">): Promise<void>;
71
+ /** Newest first. */
72
+ listAudit(q: AuditQuery): Promise<AuditEntry[]>;
73
+ /** Changes whenever any document changes (for cross-process index refresh). */
74
+ changeStamp(): Promise<string>;
75
+ getMeta(key: string): Promise<unknown>;
76
+ setMeta(key: string, value: unknown): Promise<void>;
77
+ }
78
+ /** In-memory repo for tests and examples. Starts at the current schema version. */
79
+ declare class MemoryRepo implements CmsRepo {
80
+ docs: Map<string, CmsDoc>;
81
+ versions: StoredVersion[];
82
+ keys: KeyRow[];
83
+ hits: Map<string, number>;
84
+ audit: AuditEntry[];
85
+ meta: Map<string, unknown>;
86
+ private seq;
87
+ private id;
88
+ tx<T>(fn: (repo: CmsRepo) => Promise<T>): Promise<T>;
89
+ findDoc(collection: string, slug: string): Promise<CmsDoc | null>;
90
+ findDocById(id: string): Promise<CmsDoc | null>;
91
+ listDocs(f: {
92
+ collection?: string;
93
+ statuses?: DocStatus[];
94
+ published?: boolean;
95
+ }): Promise<CmsDoc[]>;
96
+ insertDoc(doc: NewDoc): Promise<CmsDoc>;
97
+ updateDoc(id: string, patch: DocPatch, expectedVersion?: number): Promise<CmsDoc | null>;
98
+ deleteDoc(id: string): Promise<void>;
99
+ insertVersion(v: NewVersion): Promise<void>;
100
+ listVersions(documentId: string): Promise<StoredVersion[]>;
101
+ getVersion(documentId: string, version: number): Promise<StoredVersion | null>;
102
+ setVersionReviewed(documentId: string, version: number, reviewed: ReviewMark[]): Promise<void>;
103
+ pruneVersions(documentId: string, keep: number, protect: number[]): Promise<void>;
104
+ insertKey(k: {
105
+ name: string;
106
+ prefix: string;
107
+ hash: string;
108
+ scopes: KeyScope[];
109
+ collections: string[] | null;
110
+ createdBy: string | null;
111
+ expiresAt: string | null;
112
+ }): Promise<{
113
+ hash: string;
114
+ createdBy: string | null;
115
+ id: string;
116
+ name: string;
117
+ prefix: string;
118
+ scopes: KeyScope[];
119
+ collections: string[] | null;
120
+ lastUsedAt: string | null;
121
+ revokedAt: string | null;
122
+ expiresAt: string | null;
123
+ createdAt: string;
124
+ }>;
125
+ listKeys(): Promise<{
126
+ hash: string;
127
+ createdBy: string | null;
128
+ id: string;
129
+ name: string;
130
+ prefix: string;
131
+ scopes: KeyScope[];
132
+ collections: string[] | null;
133
+ lastUsedAt: string | null;
134
+ revokedAt: string | null;
135
+ expiresAt: string | null;
136
+ createdAt: string;
137
+ }[]>;
138
+ findKeyByHash(hash: string): Promise<{
139
+ hash: string;
140
+ createdBy: string | null;
141
+ id: string;
142
+ name: string;
143
+ prefix: string;
144
+ scopes: KeyScope[];
145
+ collections: string[] | null;
146
+ lastUsedAt: string | null;
147
+ revokedAt: string | null;
148
+ expiresAt: string | null;
149
+ createdAt: string;
150
+ } | null>;
151
+ touchKey(id: string, at: string): Promise<void>;
152
+ revokeKey(id: string, at: string): Promise<boolean>;
153
+ addHits(ids: string[], day: string, source: string): Promise<void>;
154
+ hitCounts(sinceDay: string, collection?: string): Promise<Map<string, number>>;
155
+ insertAudit(e: Omit<AuditEntry, "id">): Promise<void>;
156
+ listAudit(q: AuditQuery): Promise<AuditEntry[]>;
157
+ changeStamp(): Promise<string>;
158
+ getMeta(key: string): Promise<{} | null>;
159
+ setMeta(key: string, value: unknown): Promise<void>;
160
+ }
161
+
162
+ export { type AuditQuery as A, type CmsRepo as C, type DocPatch as D, type KeyRow as K, MemoryRepo as M, type NewDoc as N, type StoredVersion as S, type NewVersion as a };