@mainsoft/agent-cms 0.7.0 → 0.10.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 (111) hide show
  1. package/CHANGELOG.md +60 -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 +117 -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-EXV6JNLY.js → chunk-AKCXMT3X.js} +15 -22
  17. package/dist/{chunk-QC2M4NZY.js → chunk-BFVBHIHV.js} +72 -1
  18. package/dist/chunk-DSJETZT4.js +493 -0
  19. package/dist/{chunk-IW3D4I7Q.js → chunk-IU2SMWAM.js} +246 -4
  20. package/dist/{chunk-VICZ76TR.js → chunk-KAO3Z3CF.js} +43 -2
  21. package/dist/{chunk-CRDW6Q72.js → chunk-MA6VKJ3F.js} +87 -25
  22. package/dist/{chunk-6K5ZTGHQ.js → chunk-PEQY4N73.js} +16 -0
  23. package/dist/{chunk-DOADAH4L.js → chunk-PGV2QPIL.js} +40 -0
  24. package/dist/{chunk-Y63XQS2J.js → chunk-TOZQYJFG.js} +1 -1
  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
package/dist/config.d.cts CHANGED
@@ -1,12 +1,16 @@
1
1
  import { PgDatabase } from 'drizzle-orm/pg-core';
2
+ import { M as MediaOptions } from './cms-C_vkAxYV.cjs';
2
3
  import { CmsTablesOptions } from './tables.cjs';
4
+ import './storage.cjs';
3
5
  import './types.cjs';
4
6
  import 'zod';
5
7
  import './errors.cjs';
8
+ import './markdown.cjs';
9
+ import './diff.cjs';
6
10
 
7
11
  /**
8
12
  * `agent-cms.config.ts`: what the local CLI commands (`init`, `doctor`,
9
- * `migrate`, `add`) need to know about the app. Loaded with jiti, so it can
13
+ * `migrate`, `add`, `storage`) need to know about the app. Loaded with jiti, so it can
10
14
  * be TypeScript and import the app's own modules.
11
15
  *
12
16
  * import { defineConfig } from "@mainsoft/agent-cms/config";
@@ -20,6 +24,8 @@ interface AgentCmsConfig {
20
24
  db?: () => PgDatabase<any, any, any> | Promise<PgDatabase<any, any, any>>;
21
25
  /** Same options as `cmsTables()` when the app uses a prefix or schema. */
22
26
  tables?: CmsTablesOptions;
27
+ /** The same `media` the app passes to `createCms` (for `agent-cms storage check | cleanup`). */
28
+ media?: MediaOptions | (() => MediaOptions | Promise<MediaOptions>);
23
29
  /** Where `agent-cms add` copies the admin screens. Default: `<components alias>/cms` from components.json. */
24
30
  ui?: {
25
31
  dir?: string;
package/dist/config.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import { PgDatabase } from 'drizzle-orm/pg-core';
2
+ import { M as MediaOptions } from './cms-pqJyowu1.js';
2
3
  import { CmsTablesOptions } from './tables.js';
4
+ import './storage.js';
3
5
  import './types.js';
4
6
  import 'zod';
5
7
  import './errors.js';
8
+ import './markdown.js';
9
+ import './diff.js';
6
10
 
7
11
  /**
8
12
  * `agent-cms.config.ts`: what the local CLI commands (`init`, `doctor`,
9
- * `migrate`, `add`) need to know about the app. Loaded with jiti, so it can
13
+ * `migrate`, `add`, `storage`) need to know about the app. Loaded with jiti, so it can
10
14
  * be TypeScript and import the app's own modules.
11
15
  *
12
16
  * import { defineConfig } from "@mainsoft/agent-cms/config";
@@ -20,6 +24,8 @@ interface AgentCmsConfig {
20
24
  db?: () => PgDatabase<any, any, any> | Promise<PgDatabase<any, any, any>>;
21
25
  /** Same options as `cmsTables()` when the app uses a prefix or schema. */
22
26
  tables?: CmsTablesOptions;
27
+ /** The same `media` the app passes to `createCms` (for `agent-cms storage check | cleanup`). */
28
+ media?: MediaOptions | (() => MediaOptions | Promise<MediaOptions>);
23
29
  /** Where `agent-cms add` copies the admin screens. Default: `<components alias>/cms` from components.json. */
24
30
  ui?: {
25
31
  dir?: string;
@@ -0,0 +1,146 @@
1
+ import { PgDatabase } from 'drizzle-orm/pg-core';
2
+ import { o as CmsRepo, a8 as FindOptions, a9 as DocFilter, y as NewDoc, s as DocPatch, z as NewVersion, T as StoredVersion, aa as VersionPatch, K as KeyRow, x as NewAudit, h as AuditQuery, N as NewAsset, e as AssetQuery, d as AssetPatch, ab as NewComment, ac as NewRelease, ad as ReleasePatch, ae as NewFilter } from './cms-C_vkAxYV.cjs';
3
+ import { CmsTables } from './tables.cjs';
4
+ import { CmsDoc, ReviewMark, KeyScope, AuditEntry, CmsAsset, AssetKind, AssetRef, CmsComment, CmsRelease, SavedFilter, Presence } from './types.cjs';
5
+
6
+ /** `CmsRepo` on Postgres via Drizzle (node-postgres, pglite and other `PgDatabase` drivers with transactions). */
7
+
8
+ type Db = PgDatabase<any, any, any>;
9
+ interface DrizzleRepoOptions {
10
+ /** A table set from `cmsTables({ prefix, schema })`. Default: the `cms_*` tables. */
11
+ tables?: CmsTables;
12
+ }
13
+ declare class DrizzleRepo implements CmsRepo {
14
+ readonly db: Db;
15
+ readonly t: CmsTables;
16
+ constructor(db: Db, o?: DrizzleRepoOptions);
17
+ private toDoc;
18
+ private patchRow;
19
+ private toVersion;
20
+ private toAsset;
21
+ private toComment;
22
+ private toRelease;
23
+ private toFilter;
24
+ private toKey;
25
+ tx<T>(fn: (repo: CmsRepo) => Promise<T>): Promise<T>;
26
+ findDoc(collection: string, slug: string, o?: FindOptions): Promise<CmsDoc | null>;
27
+ findDocById(id: string, o?: FindOptions): Promise<CmsDoc | null>;
28
+ listDocs(f: DocFilter): Promise<CmsDoc[]>;
29
+ insertDoc(doc: NewDoc): Promise<CmsDoc>;
30
+ updateDoc(id: string, p: DocPatch, expectedVersion?: number): Promise<CmsDoc | null>;
31
+ deleteDoc(id: string): Promise<void>;
32
+ insertVersion(v: NewVersion): Promise<void>;
33
+ listVersions(documentId: string): Promise<StoredVersion[]>;
34
+ getVersion(documentId: string, version: number): Promise<StoredVersion | null>;
35
+ setVersionReviewed(documentId: string, version: number, reviewed: ReviewMark[]): Promise<void>;
36
+ updateVersion(documentId: string, version: number, patch: VersionPatch): Promise<void>;
37
+ pruneVersions(documentId: string, keep: number, protect: number[]): Promise<void>;
38
+ insertKey(k: {
39
+ name: string;
40
+ prefix: string;
41
+ hash: string;
42
+ scopes: KeyScope[];
43
+ collections: string[] | null;
44
+ createdBy: string | null;
45
+ expiresAt: string | null;
46
+ }): Promise<KeyRow>;
47
+ listKeys(): Promise<KeyRow[]>;
48
+ findKeyByHash(hash: string): Promise<KeyRow | null>;
49
+ touchKey(id: string, at: string): Promise<void>;
50
+ revokeKey(id: string, at: string): Promise<boolean>;
51
+ addHits(ids: string[], day: string, source: string): Promise<void>;
52
+ hitCounts(sinceDay: string, collection?: string): Promise<Map<string, number>>;
53
+ insertAudit(e: NewAudit): Promise<void>;
54
+ listAudit(q: AuditQuery): Promise<{
55
+ id: string;
56
+ at: string;
57
+ actorKind: AuditEntry["actorKind"];
58
+ actorId: string | null;
59
+ actorLabel: string;
60
+ actorAgent: string | null;
61
+ action: AuditEntry["action"];
62
+ collection: string | null;
63
+ slug: string | null;
64
+ version: number | null;
65
+ outcome: AuditEntry["outcome"];
66
+ via: "rest" | "mcp" | "ai" | "cli" | "app" | null;
67
+ detail: Record<string, unknown>;
68
+ }[]>;
69
+ insertAsset(a: NewAsset): Promise<CmsAsset>;
70
+ findAsset(id: string, o?: FindOptions): Promise<CmsAsset | null>;
71
+ findAssets(ids: readonly string[]): Promise<CmsAsset[]>;
72
+ findAssetByKey(store: string, key: string): Promise<CmsAsset | null>;
73
+ findAssetsByKeys(store: string, keys: readonly string[]): Promise<CmsAsset[]>;
74
+ listAssets(q: AssetQuery): Promise<CmsAsset[]>;
75
+ countAssets(store?: string): Promise<{
76
+ store: string;
77
+ folder: string;
78
+ kind: AssetKind;
79
+ n: number;
80
+ }[]>;
81
+ updateAsset(id: string, patch: AssetPatch): Promise<CmsAsset | null>;
82
+ deleteAsset(id: string): Promise<void>;
83
+ setAssetRefs(documentId: string, refs: readonly Omit<AssetRef, "documentId">[]): Promise<void>;
84
+ listAssetRefs(assetId: string): Promise<{
85
+ assetId: string;
86
+ documentId: string;
87
+ inDraft: boolean;
88
+ inPublished: boolean;
89
+ }[]>;
90
+ insertComment(c: NewComment): Promise<CmsComment>;
91
+ findComment(id: string): Promise<CmsComment | null>;
92
+ listComments(documentId: string): Promise<CmsComment[]>;
93
+ updateComment(id: string, patch: Pick<CmsComment, "resolvedAt" | "resolvedBy">): Promise<CmsComment | null>;
94
+ countComments(documentIds: readonly string[]): Promise<Map<string, number>>;
95
+ insertRelease(n: NewRelease): Promise<CmsRelease>;
96
+ findRelease(id: string): Promise<CmsRelease | null>;
97
+ listReleases(): Promise<CmsRelease[]>;
98
+ updateRelease(id: string, patch: ReleasePatch, expectedState?: CmsRelease["state"]): Promise<CmsRelease | null>;
99
+ deleteRelease(id: string): Promise<void>;
100
+ insertFilter(f: NewFilter): Promise<SavedFilter>;
101
+ findFilter(id: string): Promise<SavedFilter | null>;
102
+ listFilters(collection: string): Promise<SavedFilter[]>;
103
+ deleteFilter(id: string): Promise<void>;
104
+ touchPresence(p: Presence): Promise<void>;
105
+ listPresence(since: string, documentIds?: readonly string[]): Promise<{
106
+ documentId: string;
107
+ actorId: string;
108
+ label: string;
109
+ kind: Presence["kind"];
110
+ agent: string | null;
111
+ cursor: {
112
+ line: number;
113
+ ch: number;
114
+ } | null;
115
+ selection: {
116
+ line: number;
117
+ ch: number;
118
+ } | null;
119
+ seenAt: string;
120
+ }[]>;
121
+ dropPresence(documentId: string, actorId: string): Promise<void>;
122
+ prunePresence(before: string): Promise<void>;
123
+ changeStamp(): Promise<string>;
124
+ getMeta(key: string): Promise<{} | null>;
125
+ setMeta(key: string, value: unknown): Promise<void>;
126
+ /** Raw rows of a SQL query, across drivers (node-postgres returns `{ rows }`, pglite too, postgres.js an array). */
127
+ private rows;
128
+ /** What `agent-cms doctor` checks. Read-only. */
129
+ inspect(): Promise<DoctorReport>;
130
+ }
131
+ interface DoctorReport {
132
+ schemaVersion: number | null;
133
+ expectedSchemaVersion: number;
134
+ missingTables: string[];
135
+ missingColumns: string[];
136
+ /** 0.4.0 columns nothing reads any more. */
137
+ legacyColumns: string[];
138
+ /** A `cms_gaps` table from 0.5.x is still there (move it to the app, then drop it yourself). */
139
+ gapsTable: boolean;
140
+ gapsRows: number | null;
141
+ /** Documents whose published pointer is broken. */
142
+ badPublished: number;
143
+ orphanVersions: number;
144
+ }
145
+
146
+ export { type DoctorReport as D, DrizzleRepo as a, type DrizzleRepoOptions as b };
@@ -0,0 +1,146 @@
1
+ import { PgDatabase } from 'drizzle-orm/pg-core';
2
+ import { o as CmsRepo, a8 as FindOptions, a9 as DocFilter, y as NewDoc, s as DocPatch, z as NewVersion, T as StoredVersion, aa as VersionPatch, K as KeyRow, x as NewAudit, h as AuditQuery, N as NewAsset, e as AssetQuery, d as AssetPatch, ab as NewComment, ac as NewRelease, ad as ReleasePatch, ae as NewFilter } from './cms-pqJyowu1.js';
3
+ import { CmsTables } from './tables.js';
4
+ import { CmsDoc, ReviewMark, KeyScope, AuditEntry, CmsAsset, AssetKind, AssetRef, CmsComment, CmsRelease, SavedFilter, Presence } from './types.js';
5
+
6
+ /** `CmsRepo` on Postgres via Drizzle (node-postgres, pglite and other `PgDatabase` drivers with transactions). */
7
+
8
+ type Db = PgDatabase<any, any, any>;
9
+ interface DrizzleRepoOptions {
10
+ /** A table set from `cmsTables({ prefix, schema })`. Default: the `cms_*` tables. */
11
+ tables?: CmsTables;
12
+ }
13
+ declare class DrizzleRepo implements CmsRepo {
14
+ readonly db: Db;
15
+ readonly t: CmsTables;
16
+ constructor(db: Db, o?: DrizzleRepoOptions);
17
+ private toDoc;
18
+ private patchRow;
19
+ private toVersion;
20
+ private toAsset;
21
+ private toComment;
22
+ private toRelease;
23
+ private toFilter;
24
+ private toKey;
25
+ tx<T>(fn: (repo: CmsRepo) => Promise<T>): Promise<T>;
26
+ findDoc(collection: string, slug: string, o?: FindOptions): Promise<CmsDoc | null>;
27
+ findDocById(id: string, o?: FindOptions): Promise<CmsDoc | null>;
28
+ listDocs(f: DocFilter): Promise<CmsDoc[]>;
29
+ insertDoc(doc: NewDoc): Promise<CmsDoc>;
30
+ updateDoc(id: string, p: DocPatch, expectedVersion?: number): Promise<CmsDoc | null>;
31
+ deleteDoc(id: string): Promise<void>;
32
+ insertVersion(v: NewVersion): Promise<void>;
33
+ listVersions(documentId: string): Promise<StoredVersion[]>;
34
+ getVersion(documentId: string, version: number): Promise<StoredVersion | null>;
35
+ setVersionReviewed(documentId: string, version: number, reviewed: ReviewMark[]): Promise<void>;
36
+ updateVersion(documentId: string, version: number, patch: VersionPatch): Promise<void>;
37
+ pruneVersions(documentId: string, keep: number, protect: number[]): Promise<void>;
38
+ insertKey(k: {
39
+ name: string;
40
+ prefix: string;
41
+ hash: string;
42
+ scopes: KeyScope[];
43
+ collections: string[] | null;
44
+ createdBy: string | null;
45
+ expiresAt: string | null;
46
+ }): Promise<KeyRow>;
47
+ listKeys(): Promise<KeyRow[]>;
48
+ findKeyByHash(hash: string): Promise<KeyRow | null>;
49
+ touchKey(id: string, at: string): Promise<void>;
50
+ revokeKey(id: string, at: string): Promise<boolean>;
51
+ addHits(ids: string[], day: string, source: string): Promise<void>;
52
+ hitCounts(sinceDay: string, collection?: string): Promise<Map<string, number>>;
53
+ insertAudit(e: NewAudit): Promise<void>;
54
+ listAudit(q: AuditQuery): Promise<{
55
+ id: string;
56
+ at: string;
57
+ actorKind: AuditEntry["actorKind"];
58
+ actorId: string | null;
59
+ actorLabel: string;
60
+ actorAgent: string | null;
61
+ action: AuditEntry["action"];
62
+ collection: string | null;
63
+ slug: string | null;
64
+ version: number | null;
65
+ outcome: AuditEntry["outcome"];
66
+ via: "rest" | "mcp" | "ai" | "cli" | "app" | null;
67
+ detail: Record<string, unknown>;
68
+ }[]>;
69
+ insertAsset(a: NewAsset): Promise<CmsAsset>;
70
+ findAsset(id: string, o?: FindOptions): Promise<CmsAsset | null>;
71
+ findAssets(ids: readonly string[]): Promise<CmsAsset[]>;
72
+ findAssetByKey(store: string, key: string): Promise<CmsAsset | null>;
73
+ findAssetsByKeys(store: string, keys: readonly string[]): Promise<CmsAsset[]>;
74
+ listAssets(q: AssetQuery): Promise<CmsAsset[]>;
75
+ countAssets(store?: string): Promise<{
76
+ store: string;
77
+ folder: string;
78
+ kind: AssetKind;
79
+ n: number;
80
+ }[]>;
81
+ updateAsset(id: string, patch: AssetPatch): Promise<CmsAsset | null>;
82
+ deleteAsset(id: string): Promise<void>;
83
+ setAssetRefs(documentId: string, refs: readonly Omit<AssetRef, "documentId">[]): Promise<void>;
84
+ listAssetRefs(assetId: string): Promise<{
85
+ assetId: string;
86
+ documentId: string;
87
+ inDraft: boolean;
88
+ inPublished: boolean;
89
+ }[]>;
90
+ insertComment(c: NewComment): Promise<CmsComment>;
91
+ findComment(id: string): Promise<CmsComment | null>;
92
+ listComments(documentId: string): Promise<CmsComment[]>;
93
+ updateComment(id: string, patch: Pick<CmsComment, "resolvedAt" | "resolvedBy">): Promise<CmsComment | null>;
94
+ countComments(documentIds: readonly string[]): Promise<Map<string, number>>;
95
+ insertRelease(n: NewRelease): Promise<CmsRelease>;
96
+ findRelease(id: string): Promise<CmsRelease | null>;
97
+ listReleases(): Promise<CmsRelease[]>;
98
+ updateRelease(id: string, patch: ReleasePatch, expectedState?: CmsRelease["state"]): Promise<CmsRelease | null>;
99
+ deleteRelease(id: string): Promise<void>;
100
+ insertFilter(f: NewFilter): Promise<SavedFilter>;
101
+ findFilter(id: string): Promise<SavedFilter | null>;
102
+ listFilters(collection: string): Promise<SavedFilter[]>;
103
+ deleteFilter(id: string): Promise<void>;
104
+ touchPresence(p: Presence): Promise<void>;
105
+ listPresence(since: string, documentIds?: readonly string[]): Promise<{
106
+ documentId: string;
107
+ actorId: string;
108
+ label: string;
109
+ kind: Presence["kind"];
110
+ agent: string | null;
111
+ cursor: {
112
+ line: number;
113
+ ch: number;
114
+ } | null;
115
+ selection: {
116
+ line: number;
117
+ ch: number;
118
+ } | null;
119
+ seenAt: string;
120
+ }[]>;
121
+ dropPresence(documentId: string, actorId: string): Promise<void>;
122
+ prunePresence(before: string): Promise<void>;
123
+ changeStamp(): Promise<string>;
124
+ getMeta(key: string): Promise<{} | null>;
125
+ setMeta(key: string, value: unknown): Promise<void>;
126
+ /** Raw rows of a SQL query, across drivers (node-postgres returns `{ rows }`, pglite too, postgres.js an array). */
127
+ private rows;
128
+ /** What `agent-cms doctor` checks. Read-only. */
129
+ inspect(): Promise<DoctorReport>;
130
+ }
131
+ interface DoctorReport {
132
+ schemaVersion: number | null;
133
+ expectedSchemaVersion: number;
134
+ missingTables: string[];
135
+ missingColumns: string[];
136
+ /** 0.4.0 columns nothing reads any more. */
137
+ legacyColumns: string[];
138
+ /** A `cms_gaps` table from 0.5.x is still there (move it to the app, then drop it yourself). */
139
+ gapsTable: boolean;
140
+ gapsRows: number | null;
141
+ /** Documents whose published pointer is broken. */
142
+ badPublished: number;
143
+ orphanVersions: number;
144
+ }
145
+
146
+ export { type DoctorReport as D, DrizzleRepo as a, type DrizzleRepoOptions as b };
package/dist/errors.cjs CHANGED
@@ -73,6 +73,46 @@ var en = {
73
73
  schema_outdated: "The database schema is v{found}, this version needs v{expected}. Run: {command}",
74
74
  conflict_version: "Someone else saved v{current} since you read v{expected}. Reload or merge, then save",
75
75
  slug_taken: "The slug {slug} is already used",
76
+ asset_not_found: "File not found",
77
+ unknown_store: "Unknown file store: {store}",
78
+ forbidden_media: "You are not allowed to do that with files in this store",
79
+ media_disabled: "The media library is off (set media in createCms)",
80
+ asset_type_not_allowed: "This file type is not allowed",
81
+ asset_type_mismatch: "The file content does not match its extension",
82
+ asset_too_large: "The file is too large. The limit is {max}",
83
+ invalid_folder: "That folder name cannot be used",
84
+ upload_incomplete: "The file did not arrive completely. Upload it again",
85
+ import_blocked: "That address cannot be fetched",
86
+ import_failed: "Could not fetch the file ({reason})",
87
+ asset_rejected: "This file did not pass the check",
88
+ asset_missing: "The file {id} does not exist",
89
+ asset_wrong_kind: "The file {id} is not a kind this field takes",
90
+ asset_alt_missing: "The image on line {line} has no alt text",
91
+ asset_alt_empty: "The image has no alt text",
92
+ asset_private_in_public: "A private file is used in a document anyone can read: {id}",
93
+ asset_in_use: "{count} documents use this file",
94
+ folder_not_empty: "The folder is not empty",
95
+ slug_in_trash: "A document with this address is in the trash. Restore it or delete it for good first",
96
+ in_other_release: 'This document is already in the release "{release}"',
97
+ comment_not_found: "Comment not found",
98
+ release_not_found: "Release not found",
99
+ filter_not_found: "Saved filter not found",
100
+ trash_not_found: "Not in the trash",
101
+ review_required: "Publishing here needs a review. Request one instead",
102
+ review_self: "Someone else has to approve your request",
103
+ review_people_only: "Only a person can approve or send back a review",
104
+ forbidden_trash: "Only an admin can delete for good",
105
+ forbidden_filter: "Only an admin can share a filter or remove someone else's",
106
+ comments_off: "This link does not allow comments",
107
+ review_not_requested: "No review was requested for this document",
108
+ not_scheduled: "Nothing is scheduled for this document",
109
+ release_closed: "This release was already published",
110
+ release_empty: "The release has no documents",
111
+ release_blocked: "{count} documents cannot go out, so nothing was published",
112
+ schedule_invalid: "The time must be in the future, and unpublishing must come after publishing",
113
+ comment_invalid: "A comment needs 1 to {max} characters",
114
+ name_invalid: "A name needs 1 to {max} characters",
115
+ too_many_files: "Too many files at once. The limit is {max}",
76
116
  precondition_required: "Send If-Match (or expectedVersion) to change this document",
77
117
  internal: "Something went wrong"
78
118
  };
@@ -85,6 +125,8 @@ var ERROR_CODES = {
85
125
  version_not_found: "not_found",
86
126
  key_not_found: "not_found",
87
127
  route_not_found: "not_found",
128
+ asset_not_found: "not_found",
129
+ unknown_store: "not_found",
88
130
  unknown_collection: "unknown_collection",
89
131
  // access
90
132
  unauthorized: "unauthorized",
@@ -98,6 +140,7 @@ var ERROR_CODES = {
98
140
  forbidden_publish: "forbidden",
99
141
  forbidden_keys: "forbidden",
100
142
  forbidden_audit: "forbidden",
143
+ forbidden_media: "forbidden",
101
144
  key_too_wide: "forbidden",
102
145
  cross_site: "forbidden",
103
146
  // validation
@@ -122,11 +165,49 @@ var ERROR_CODES = {
122
165
  invalid_json: "invalid",
123
166
  body_too_large: "invalid",
124
167
  preview_disabled: "invalid",
168
+ // media
169
+ media_disabled: "invalid",
170
+ asset_type_not_allowed: "invalid",
171
+ asset_type_mismatch: "invalid",
172
+ asset_too_large: "invalid",
173
+ invalid_folder: "invalid",
174
+ upload_incomplete: "invalid",
175
+ import_blocked: "invalid",
176
+ import_failed: "invalid",
177
+ asset_rejected: "invalid",
178
+ asset_missing: "invalid",
179
+ asset_wrong_kind: "invalid",
180
+ asset_alt_missing: "invalid",
181
+ asset_alt_empty: "invalid",
182
+ asset_private_in_public: "invalid",
125
183
  no_public_url: "invalid",
126
184
  schema_outdated: "invalid",
127
185
  // concurrency
128
186
  conflict_version: "conflict",
129
187
  slug_taken: "conflict",
188
+ asset_in_use: "conflict",
189
+ folder_not_empty: "conflict",
190
+ slug_in_trash: "conflict",
191
+ in_other_release: "conflict",
192
+ comment_not_found: "not_found",
193
+ release_not_found: "not_found",
194
+ filter_not_found: "not_found",
195
+ trash_not_found: "not_found",
196
+ review_required: "forbidden",
197
+ review_self: "forbidden",
198
+ review_people_only: "forbidden",
199
+ forbidden_trash: "forbidden",
200
+ forbidden_filter: "forbidden",
201
+ comments_off: "forbidden",
202
+ review_not_requested: "precondition",
203
+ not_scheduled: "precondition",
204
+ release_closed: "precondition",
205
+ release_empty: "precondition",
206
+ release_blocked: "precondition",
207
+ schedule_invalid: "invalid",
208
+ comment_invalid: "invalid",
209
+ name_invalid: "invalid",
210
+ too_many_files: "invalid",
130
211
  precondition_required: "precondition",
131
212
  // anything else
132
213
  internal: "internal"
@@ -168,7 +249,7 @@ var CmsError = class extends Error {
168
249
  current;
169
250
  /** Marks CmsErrors so `isCmsError` works across bundle copies of this class. */
170
251
  isCmsError = true;
171
- /** The wire shape (REST body, MCP error text, AI tool result). */
252
+ /** The wire shape (REST body, MCP error text, `callTool` result). */
172
253
  toJSON() {
173
254
  return {
174
255
  error: this.code,
package/dist/errors.d.cts CHANGED
@@ -13,6 +13,8 @@ declare const ERROR_CODES: {
13
13
  readonly version_not_found: "not_found";
14
14
  readonly key_not_found: "not_found";
15
15
  readonly route_not_found: "not_found";
16
+ readonly asset_not_found: "not_found";
17
+ readonly unknown_store: "not_found";
16
18
  readonly unknown_collection: "unknown_collection";
17
19
  readonly unauthorized: "unauthorized";
18
20
  readonly invalid_key: "unauthorized";
@@ -25,6 +27,7 @@ declare const ERROR_CODES: {
25
27
  readonly forbidden_publish: "forbidden";
26
28
  readonly forbidden_keys: "forbidden";
27
29
  readonly forbidden_audit: "forbidden";
30
+ readonly forbidden_media: "forbidden";
28
31
  readonly key_too_wide: "forbidden";
29
32
  readonly cross_site: "forbidden";
30
33
  readonly invalid: "invalid";
@@ -48,10 +51,47 @@ declare const ERROR_CODES: {
48
51
  readonly invalid_json: "invalid";
49
52
  readonly body_too_large: "invalid";
50
53
  readonly preview_disabled: "invalid";
54
+ readonly media_disabled: "invalid";
55
+ readonly asset_type_not_allowed: "invalid";
56
+ readonly asset_type_mismatch: "invalid";
57
+ readonly asset_too_large: "invalid";
58
+ readonly invalid_folder: "invalid";
59
+ readonly upload_incomplete: "invalid";
60
+ readonly import_blocked: "invalid";
61
+ readonly import_failed: "invalid";
62
+ readonly asset_rejected: "invalid";
63
+ readonly asset_missing: "invalid";
64
+ readonly asset_wrong_kind: "invalid";
65
+ readonly asset_alt_missing: "invalid";
66
+ readonly asset_alt_empty: "invalid";
67
+ readonly asset_private_in_public: "invalid";
51
68
  readonly no_public_url: "invalid";
52
69
  readonly schema_outdated: "invalid";
53
70
  readonly conflict_version: "conflict";
54
71
  readonly slug_taken: "conflict";
72
+ readonly asset_in_use: "conflict";
73
+ readonly folder_not_empty: "conflict";
74
+ readonly slug_in_trash: "conflict";
75
+ readonly in_other_release: "conflict";
76
+ readonly comment_not_found: "not_found";
77
+ readonly release_not_found: "not_found";
78
+ readonly filter_not_found: "not_found";
79
+ readonly trash_not_found: "not_found";
80
+ readonly review_required: "forbidden";
81
+ readonly review_self: "forbidden";
82
+ readonly review_people_only: "forbidden";
83
+ readonly forbidden_trash: "forbidden";
84
+ readonly forbidden_filter: "forbidden";
85
+ readonly comments_off: "forbidden";
86
+ readonly review_not_requested: "precondition";
87
+ readonly not_scheduled: "precondition";
88
+ readonly release_closed: "precondition";
89
+ readonly release_empty: "precondition";
90
+ readonly release_blocked: "precondition";
91
+ readonly schedule_invalid: "invalid";
92
+ readonly comment_invalid: "invalid";
93
+ readonly name_invalid: "invalid";
94
+ readonly too_many_files: "invalid";
55
95
  readonly precondition_required: "precondition";
56
96
  readonly internal: "internal";
57
97
  };
@@ -90,12 +130,12 @@ declare class CmsError extends Error {
90
130
  /** Marks CmsErrors so `isCmsError` works across bundle copies of this class. */
91
131
  readonly isCmsError = true;
92
132
  constructor(code: CmsErrorCode, params?: ErrorParams, o?: CmsErrorOptions);
93
- /** The wire shape (REST body, MCP error text, AI tool result). */
133
+ /** The wire shape (REST body, MCP error text, `callTool` result). */
94
134
  toJSON(): {
95
135
  current?: {} | null | undefined;
96
136
  diagnostics?: Diagnostic[] | undefined;
97
- error: "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "internal" | "version_not_found" | "key_not_found" | "route_not_found" | "invalid_key" | "key_expired" | "preview_invalid" | "preview_expired" | "forbidden_read" | "forbidden_write" | "forbidden_publish" | "forbidden_keys" | "forbidden_audit" | "key_too_wide" | "cross_site" | "invalid_slug" | "invalid_title" | "summary_too_long" | "body_too_long" | "invalid_keywords" | "forbidden_char" | "invalid_category" | "invalid_field" | "unknown_link" | "slug_locked" | "not_published" | "invalid_key_name" | "scopes_required" | "invalid_expiry" | "invalid_anchor" | "invalid_version" | "invalid_request" | "invalid_json" | "body_too_large" | "preview_disabled" | "no_public_url" | "schema_outdated" | "conflict_version" | "slug_taken" | "precondition_required";
98
- kind: "conflict" | "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "precondition" | "internal";
137
+ error: "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "internal" | "version_not_found" | "key_not_found" | "route_not_found" | "asset_not_found" | "unknown_store" | "invalid_key" | "key_expired" | "preview_invalid" | "preview_expired" | "forbidden_read" | "forbidden_write" | "forbidden_publish" | "forbidden_keys" | "forbidden_audit" | "forbidden_media" | "key_too_wide" | "cross_site" | "invalid_slug" | "invalid_title" | "summary_too_long" | "body_too_long" | "invalid_keywords" | "forbidden_char" | "invalid_category" | "invalid_field" | "unknown_link" | "slug_locked" | "not_published" | "invalid_key_name" | "scopes_required" | "invalid_expiry" | "invalid_anchor" | "invalid_version" | "invalid_request" | "invalid_json" | "body_too_large" | "preview_disabled" | "media_disabled" | "asset_type_not_allowed" | "asset_type_mismatch" | "asset_too_large" | "invalid_folder" | "upload_incomplete" | "import_blocked" | "import_failed" | "asset_rejected" | "asset_missing" | "asset_wrong_kind" | "asset_alt_missing" | "asset_alt_empty" | "asset_private_in_public" | "no_public_url" | "schema_outdated" | "conflict_version" | "slug_taken" | "asset_in_use" | "folder_not_empty" | "slug_in_trash" | "in_other_release" | "comment_not_found" | "release_not_found" | "filter_not_found" | "trash_not_found" | "review_required" | "review_self" | "review_people_only" | "forbidden_trash" | "forbidden_filter" | "comments_off" | "review_not_requested" | "not_scheduled" | "release_closed" | "release_empty" | "release_blocked" | "schedule_invalid" | "comment_invalid" | "name_invalid" | "too_many_files" | "precondition_required";
138
+ kind: "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "conflict" | "precondition" | "internal";
99
139
  message: string;
100
140
  params: ErrorParams;
101
141
  };
package/dist/errors.d.ts CHANGED
@@ -13,6 +13,8 @@ declare const ERROR_CODES: {
13
13
  readonly version_not_found: "not_found";
14
14
  readonly key_not_found: "not_found";
15
15
  readonly route_not_found: "not_found";
16
+ readonly asset_not_found: "not_found";
17
+ readonly unknown_store: "not_found";
16
18
  readonly unknown_collection: "unknown_collection";
17
19
  readonly unauthorized: "unauthorized";
18
20
  readonly invalid_key: "unauthorized";
@@ -25,6 +27,7 @@ declare const ERROR_CODES: {
25
27
  readonly forbidden_publish: "forbidden";
26
28
  readonly forbidden_keys: "forbidden";
27
29
  readonly forbidden_audit: "forbidden";
30
+ readonly forbidden_media: "forbidden";
28
31
  readonly key_too_wide: "forbidden";
29
32
  readonly cross_site: "forbidden";
30
33
  readonly invalid: "invalid";
@@ -48,10 +51,47 @@ declare const ERROR_CODES: {
48
51
  readonly invalid_json: "invalid";
49
52
  readonly body_too_large: "invalid";
50
53
  readonly preview_disabled: "invalid";
54
+ readonly media_disabled: "invalid";
55
+ readonly asset_type_not_allowed: "invalid";
56
+ readonly asset_type_mismatch: "invalid";
57
+ readonly asset_too_large: "invalid";
58
+ readonly invalid_folder: "invalid";
59
+ readonly upload_incomplete: "invalid";
60
+ readonly import_blocked: "invalid";
61
+ readonly import_failed: "invalid";
62
+ readonly asset_rejected: "invalid";
63
+ readonly asset_missing: "invalid";
64
+ readonly asset_wrong_kind: "invalid";
65
+ readonly asset_alt_missing: "invalid";
66
+ readonly asset_alt_empty: "invalid";
67
+ readonly asset_private_in_public: "invalid";
51
68
  readonly no_public_url: "invalid";
52
69
  readonly schema_outdated: "invalid";
53
70
  readonly conflict_version: "conflict";
54
71
  readonly slug_taken: "conflict";
72
+ readonly asset_in_use: "conflict";
73
+ readonly folder_not_empty: "conflict";
74
+ readonly slug_in_trash: "conflict";
75
+ readonly in_other_release: "conflict";
76
+ readonly comment_not_found: "not_found";
77
+ readonly release_not_found: "not_found";
78
+ readonly filter_not_found: "not_found";
79
+ readonly trash_not_found: "not_found";
80
+ readonly review_required: "forbidden";
81
+ readonly review_self: "forbidden";
82
+ readonly review_people_only: "forbidden";
83
+ readonly forbidden_trash: "forbidden";
84
+ readonly forbidden_filter: "forbidden";
85
+ readonly comments_off: "forbidden";
86
+ readonly review_not_requested: "precondition";
87
+ readonly not_scheduled: "precondition";
88
+ readonly release_closed: "precondition";
89
+ readonly release_empty: "precondition";
90
+ readonly release_blocked: "precondition";
91
+ readonly schedule_invalid: "invalid";
92
+ readonly comment_invalid: "invalid";
93
+ readonly name_invalid: "invalid";
94
+ readonly too_many_files: "invalid";
55
95
  readonly precondition_required: "precondition";
56
96
  readonly internal: "internal";
57
97
  };
@@ -90,12 +130,12 @@ declare class CmsError extends Error {
90
130
  /** Marks CmsErrors so `isCmsError` works across bundle copies of this class. */
91
131
  readonly isCmsError = true;
92
132
  constructor(code: CmsErrorCode, params?: ErrorParams, o?: CmsErrorOptions);
93
- /** The wire shape (REST body, MCP error text, AI tool result). */
133
+ /** The wire shape (REST body, MCP error text, `callTool` result). */
94
134
  toJSON(): {
95
135
  current?: {} | null | undefined;
96
136
  diagnostics?: Diagnostic[] | undefined;
97
- error: "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "internal" | "version_not_found" | "key_not_found" | "route_not_found" | "invalid_key" | "key_expired" | "preview_invalid" | "preview_expired" | "forbidden_read" | "forbidden_write" | "forbidden_publish" | "forbidden_keys" | "forbidden_audit" | "key_too_wide" | "cross_site" | "invalid_slug" | "invalid_title" | "summary_too_long" | "body_too_long" | "invalid_keywords" | "forbidden_char" | "invalid_category" | "invalid_field" | "unknown_link" | "slug_locked" | "not_published" | "invalid_key_name" | "scopes_required" | "invalid_expiry" | "invalid_anchor" | "invalid_version" | "invalid_request" | "invalid_json" | "body_too_large" | "preview_disabled" | "no_public_url" | "schema_outdated" | "conflict_version" | "slug_taken" | "precondition_required";
98
- kind: "conflict" | "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "precondition" | "internal";
137
+ error: "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "internal" | "version_not_found" | "key_not_found" | "route_not_found" | "asset_not_found" | "unknown_store" | "invalid_key" | "key_expired" | "preview_invalid" | "preview_expired" | "forbidden_read" | "forbidden_write" | "forbidden_publish" | "forbidden_keys" | "forbidden_audit" | "forbidden_media" | "key_too_wide" | "cross_site" | "invalid_slug" | "invalid_title" | "summary_too_long" | "body_too_long" | "invalid_keywords" | "forbidden_char" | "invalid_category" | "invalid_field" | "unknown_link" | "slug_locked" | "not_published" | "invalid_key_name" | "scopes_required" | "invalid_expiry" | "invalid_anchor" | "invalid_version" | "invalid_request" | "invalid_json" | "body_too_large" | "preview_disabled" | "media_disabled" | "asset_type_not_allowed" | "asset_type_mismatch" | "asset_too_large" | "invalid_folder" | "upload_incomplete" | "import_blocked" | "import_failed" | "asset_rejected" | "asset_missing" | "asset_wrong_kind" | "asset_alt_missing" | "asset_alt_empty" | "asset_private_in_public" | "no_public_url" | "schema_outdated" | "conflict_version" | "slug_taken" | "asset_in_use" | "folder_not_empty" | "slug_in_trash" | "in_other_release" | "comment_not_found" | "release_not_found" | "filter_not_found" | "trash_not_found" | "review_required" | "review_self" | "review_people_only" | "forbidden_trash" | "forbidden_filter" | "comments_off" | "review_not_requested" | "not_scheduled" | "release_closed" | "release_empty" | "release_blocked" | "schedule_invalid" | "comment_invalid" | "name_invalid" | "too_many_files" | "precondition_required";
138
+ kind: "not_found" | "unknown_collection" | "forbidden" | "unauthorized" | "invalid" | "conflict" | "precondition" | "internal";
99
139
  message: string;
100
140
  params: ErrorParams;
101
141
  };
package/dist/errors.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  ERROR_KINDS,
5
5
  formatMessage,
6
6
  isCmsError
7
- } from "./chunk-VICZ76TR.js";
8
- import "./chunk-DOADAH4L.js";
7
+ } from "./chunk-KAO3Z3CF.js";
8
+ import "./chunk-PGV2QPIL.js";
9
9
  import "./chunk-2NTK7H4W.js";
10
10
  export {
11
11
  CmsError,