@mainsoft/agent-cms 0.7.0 → 0.10.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 (111) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +291 -32
  3. package/TODO.md +72 -26
  4. package/UPGRADE-0.10.md +36 -0
  5. package/UPGRADE-0.8.md +118 -0
  6. package/dist/agent.cjs +39 -17
  7. package/dist/agent.d.cts +2 -2
  8. package/dist/agent.d.ts +2 -2
  9. package/dist/agent.js +9 -7
  10. package/dist/bin.js +4528 -355
  11. package/dist/{chunk-OQ55GEF3.js → chunk-3OPKTBEI.js} +1 -1
  12. package/dist/chunk-6PB4ZCHH.js +328 -0
  13. package/dist/chunk-7SCYDG2G.js +2943 -0
  14. package/dist/chunk-7WJIIJCI.js +544 -0
  15. package/dist/chunk-7Y6TU2UA.js +150 -0
  16. package/dist/{chunk-QC2M4NZY.js → chunk-BFVBHIHV.js} +72 -1
  17. package/dist/chunk-DSJETZT4.js +493 -0
  18. package/dist/{chunk-IW3D4I7Q.js → chunk-IU2SMWAM.js} +246 -4
  19. package/dist/{chunk-VICZ76TR.js → chunk-KAO3Z3CF.js} +43 -2
  20. package/dist/{chunk-CRDW6Q72.js → chunk-MA6VKJ3F.js} +87 -25
  21. package/dist/{chunk-6K5ZTGHQ.js → chunk-PEQY4N73.js} +16 -0
  22. package/dist/{chunk-DOADAH4L.js → chunk-PGV2QPIL.js} +40 -0
  23. package/dist/{chunk-Y63XQS2J.js → chunk-QMPSOLLH.js} +1 -1
  24. package/dist/{chunk-EXV6JNLY.js → chunk-ZCUJ4MPT.js} +15 -22
  25. package/dist/cli.cjs +4528 -355
  26. package/dist/cli.d.cts +19 -3
  27. package/dist/cli.d.ts +19 -3
  28. package/dist/cli.js +206 -16
  29. package/dist/client.cjs +72 -1
  30. package/dist/client.d.cts +308 -6
  31. package/dist/client.d.ts +308 -6
  32. package/dist/client.js +1 -1
  33. package/dist/cms-C_vkAxYV.d.cts +1537 -0
  34. package/dist/cms-pqJyowu1.d.ts +1537 -0
  35. package/dist/config.d.cts +7 -1
  36. package/dist/config.d.ts +7 -1
  37. package/dist/drizzle-repo-CviH3EX7.d.cts +146 -0
  38. package/dist/drizzle-repo-DWLD0rWe.d.ts +146 -0
  39. package/dist/errors.cjs +82 -1
  40. package/dist/errors.d.cts +43 -3
  41. package/dist/errors.d.ts +43 -3
  42. package/dist/errors.js +2 -2
  43. package/dist/frontmatter.d.cts +5 -4
  44. package/dist/frontmatter.d.ts +5 -4
  45. package/dist/http.cjs +640 -94
  46. package/dist/http.d.cts +51 -2
  47. package/dist/http.d.ts +51 -2
  48. package/dist/http.js +203 -13
  49. package/dist/index.cjs +3759 -575
  50. package/dist/index.d.cts +8 -8
  51. package/dist/index.d.ts +8 -8
  52. package/dist/index.js +226 -30
  53. package/dist/markdown.cjs +89 -25
  54. package/dist/markdown.d.cts +57 -3
  55. package/dist/markdown.d.ts +57 -3
  56. package/dist/markdown.js +5 -1
  57. package/dist/mcp.cjs +314 -37
  58. package/dist/mcp.d.cts +3 -2
  59. package/dist/mcp.d.ts +3 -2
  60. package/dist/mcp.js +12 -9
  61. package/dist/messages/en.cjs +40 -0
  62. package/dist/messages/en.js +1 -1
  63. package/dist/messages/ko.cjs +40 -0
  64. package/dist/messages/ko.js +40 -0
  65. package/dist/registry/cms-audit.json +1 -1
  66. package/dist/registry/cms-doc-editor.json +15 -4
  67. package/dist/registry/cms-doc-list.json +2 -1
  68. package/dist/registry/cms-files.json +29 -0
  69. package/dist/registry/cms-lib.json +3 -3
  70. package/dist/registry/cms-media-picker.json +29 -0
  71. package/dist/registry/cms-media.json +28 -0
  72. package/dist/registry/cms-preview-comments.json +24 -0
  73. package/dist/registry/cms-releases.json +28 -0
  74. package/dist/registry/cms-shell.json +2 -2
  75. package/dist/registry/cms-trash.json +24 -0
  76. package/dist/registry/cms-versions.json +2 -1
  77. package/dist/registry/registry.json +163 -3
  78. package/dist/storage-s3.cjs +168 -0
  79. package/dist/storage-s3.d.cts +53 -0
  80. package/dist/storage-s3.d.ts +53 -0
  81. package/dist/storage-s3.js +143 -0
  82. package/dist/storage.cjs +373 -0
  83. package/dist/storage.d.cts +183 -0
  84. package/dist/storage.d.ts +183 -0
  85. package/dist/storage.js +49 -0
  86. package/dist/tables.cjs +251 -3
  87. package/dist/tables.d.cts +4965 -681
  88. package/dist/tables.d.ts +4965 -681
  89. package/dist/tables.js +14 -2
  90. package/dist/tools.cjs +331 -20
  91. package/dist/tools.d.cts +54 -7
  92. package/dist/tools.d.ts +54 -7
  93. package/dist/tools.js +16 -7
  94. package/dist/types.cjs +99 -1
  95. package/dist/types.d.cts +205 -5
  96. package/dist/types.d.ts +205 -5
  97. package/dist/types.js +5 -3
  98. package/package.json +32 -22
  99. package/dist/ai.cjs +0 -555
  100. package/dist/ai.d.cts +0 -48
  101. package/dist/ai.d.ts +0 -48
  102. package/dist/ai.js +0 -73
  103. package/dist/chunk-52NUUZC7.js +0 -1446
  104. package/dist/chunk-IGL2V6US.js +0 -324
  105. package/dist/chunk-QQV6VLYJ.js +0 -204
  106. package/dist/cms-BPp01z-8.d.ts +0 -411
  107. package/dist/cms-D6D89-qZ.d.cts +0 -411
  108. package/dist/drizzle-repo-B1rt7r4j.d.ts +0 -90
  109. package/dist/drizzle-repo-Cn-kL2FK.d.cts +0 -90
  110. package/dist/repo-BWI2Pkrv.d.ts +0 -162
  111. package/dist/repo-CeDxUxO6.d.cts +0 -162
@@ -1,162 +0,0 @@
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 };
@@ -1,162 +0,0 @@
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 };