@mainsoft/agent-cms 0.6.1 → 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 +65 -0
  2. package/README.md +303 -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-BTO42652.js → chunk-AKCXMT3X.js} +19 -24
  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-QIUXAUQ6.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 +644 -97
  46. package/dist/http.d.cts +59 -2
  47. package/dist/http.d.ts +59 -2
  48. package/dist/http.js +204 -14
  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 +319 -39
  58. package/dist/mcp.d.cts +15 -4
  59. package/dist/mcp.d.ts +15 -4
  60. package/dist/mcp.js +14 -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/client.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { l as PatchOp, b as BulkAction, c as BulkResult, D as DocDiff, A as AgentChange, o as PreviewTtl, m as PreviewLink } from './cms-BPp01z-8.js';
1
+ import { g as AssetView, f as AssetUsage, E as PatchOp, i as BulkAction, j as BulkResult, D as DocDiff, A as AgentChange, I as PreviewTtl, G as PreviewLink, af as CommentThread, ag as TrashRef, ah as TrashItem, ai as ReleaseView, c as AssetListOptions, W as UploadRequest, V as UploadInstructions } from './cms-pqJyowu1.js';
2
+ export { aj as BlockedItem, ak as ScheduledRun } from './cms-pqJyowu1.js';
2
3
  import { ErrorParams, Diagnostic } from './errors.js';
3
- import { DocSummary, DocCounts, CmsDoc, AutosaveState, VersionSummary, CmsVersion, CmsKey, KeyScope, AuditEntry } from './types.js';
4
+ import { Block, TocItem } from './markdown.js';
5
+ import { CmsRelease, DocSummary, DocCounts, CmsDoc, AutosaveState, VersionSummary, CmsVersion, CmsComment, Presence, SavedFilter, CmsKey, KeyScope, AuditEntry } from './types.js';
6
+ import './storage.js';
4
7
  import 'zod';
5
8
  import './diff.js';
6
- import './repo-BWI2Pkrv.js';
7
9
 
8
10
  /** Types the REST client sends and receives (re-exported for the admin screens). Type-only, browser-safe. */
9
11
 
@@ -28,6 +30,30 @@ interface DocInputWire {
28
30
  * cookie. This is what the copied admin screens use.
29
31
  */
30
32
 
33
+ /** What `POST /collections/:c/_preview` answers: the document as it would be, nothing saved. */
34
+ interface DocPreview {
35
+ blocks: Block[];
36
+ toc: TocItem[];
37
+ diagnostics: Diagnostic[];
38
+ diff: string | null;
39
+ publicUrl: string | null;
40
+ assets: Record<string, {
41
+ id: string;
42
+ name: string;
43
+ kind: string;
44
+ url: string;
45
+ alt: string;
46
+ width: number | null;
47
+ height: number | null;
48
+ }>;
49
+ }
50
+ /** The open release a document is in. */
51
+ interface DocRelease {
52
+ id: string;
53
+ name: string;
54
+ state: CmsRelease["state"];
55
+ publishAt: string | null;
56
+ }
31
57
  interface CmsClientOptions {
32
58
  /** The CMS base URL, e.g. https://app.example.com/api/cms */
33
59
  url: string;
@@ -93,6 +119,12 @@ interface Me {
93
119
  };
94
120
  isAdmin: boolean;
95
121
  previewLinks: boolean;
122
+ /** Days something stays in the trash (0: there is no trash). */
123
+ trashDays?: number;
124
+ /** The zone schedules are shown and entered in. */
125
+ timeZone?: string;
126
+ /** The media library, when the app has one and this actor may see it. */
127
+ media?: MediaInfo | null;
96
128
  collections: {
97
129
  slug: string;
98
130
  label: string;
@@ -101,6 +133,60 @@ interface Me {
101
133
  canPublish: boolean;
102
134
  }[];
103
135
  }
136
+
137
+ interface MediaStoreInfo {
138
+ name: string;
139
+ label: string;
140
+ visibility: "public" | "private";
141
+ /** File types the store takes (MIME types, `image/*` groups, `.ext`). */
142
+ accept: readonly string[];
143
+ maxFileSize: number;
144
+ can: {
145
+ write: boolean;
146
+ delete: boolean;
147
+ browse: boolean;
148
+ };
149
+ }
150
+ interface MediaInfo {
151
+ stores: MediaStoreInfo[];
152
+ partSize: number;
153
+ }
154
+ interface FolderTree {
155
+ store: string;
156
+ label: string;
157
+ visibility: "public" | "private";
158
+ total: number;
159
+ folders: {
160
+ path: string;
161
+ count: number;
162
+ }[];
163
+ }
164
+ /** One entry of a bucket listing. `asset` is set when the CMS has a row for the file. */
165
+ interface StoreFile {
166
+ key: string;
167
+ name: string;
168
+ size: number;
169
+ mime: string;
170
+ kind: AssetView["kind"];
171
+ updatedAt: string | null;
172
+ asset: AssetView | null;
173
+ }
174
+ interface StoreListing {
175
+ store: string;
176
+ prefix: string;
177
+ folders: {
178
+ path: string;
179
+ name: string;
180
+ }[];
181
+ files: StoreFile[];
182
+ cursor: string | null;
183
+ }
184
+ type ShareTtl = "1h" | "24h" | "7d";
185
+ type AssetCounts = Record<"all" | "image" | "video" | "audio" | "document" | "other", number>;
186
+ type AssetDetail = AssetView & {
187
+ usage: AssetUsage[];
188
+ usageHidden: number;
189
+ };
104
190
  interface CollectionSchema {
105
191
  slug: string;
106
192
  label: string;
@@ -113,13 +199,24 @@ interface CollectionSchema {
113
199
  label?: string;
114
200
  help?: string;
115
201
  widget?: string;
202
+ accept?: string[];
203
+ maxFileSize?: number;
204
+ store?: string;
116
205
  }>;
206
+ /** Images without alt text stop a save in this collection. */
207
+ requireAlt?: boolean;
117
208
  forbiddenChars: string[];
118
209
  canWrite: boolean;
119
210
  canPublish: boolean;
211
+ /** The collection's review rule, and whether it applies to you. */
212
+ review?: {
213
+ agents?: "required";
214
+ everyone?: "required";
215
+ } | null;
216
+ needsReview?: boolean;
120
217
  }
121
218
  interface ListQuery {
122
- state?: "draft" | "published" | "modified" | "archived";
219
+ state?: "draft" | "published" | "modified" | "archived" | "scheduled" | "review";
123
220
  q?: string;
124
221
  category?: string;
125
222
  by?: "user" | "key" | "system";
@@ -187,7 +284,99 @@ declare function createRestClient(opts: RestClientOptions): {
187
284
  review: (c: string, s: string, hunks: string[] | "all", action?: "accepted" | "reverted") => Promise<{
188
285
  reviewed: number;
189
286
  }>;
190
- previewLink: (c: string, s: string, ttl?: PreviewTtl) => Promise<PreviewLink>;
287
+ previewLink: (c: string, s: string, ttl?: PreviewTtl, o?: {
288
+ comments?: boolean;
289
+ }) => Promise<PreviewLink>;
290
+ /** The working copy plus the open release it is in, if any. */
291
+ getWithRelease: (c: string, s: string) => Promise<{
292
+ doc: CmsDoc;
293
+ release?: DocRelease | null;
294
+ }>;
295
+ preview: (c: string, d: DocInputWire, slug?: string) => Promise<DocPreview>;
296
+ schedule: (c: string, s: string, b: {
297
+ publishAt?: string | null;
298
+ unpublishAt?: string | null;
299
+ expectedVersion?: number;
300
+ }) => Promise<CmsDoc>;
301
+ unschedule: (c: string, s: string) => Promise<CmsDoc>;
302
+ requestReview: (c: string, s: string, note?: string | null) => Promise<CmsDoc>;
303
+ approveReview: (c: string, s: string, o?: {
304
+ publish?: boolean;
305
+ }) => Promise<CmsDoc>;
306
+ rejectReview: (c: string, s: string, note?: string | null) => Promise<CmsDoc>;
307
+ reviewRequests: (collection?: string) => Promise<DocSummary[]>;
308
+ comments: (c: string, s: string) => Promise<CommentThread[]>;
309
+ addComment: (c: string, s: string, b: {
310
+ body: string;
311
+ anchor?: string | null;
312
+ quote?: string | null;
313
+ threadId?: string | null;
314
+ }) => Promise<CmsComment>;
315
+ resolveComment: (c: string, s: string, id: string, resolved?: boolean) => Promise<CmsComment>;
316
+ previewComments: (token: string) => Promise<CommentThread[]>;
317
+ addPreviewComment: (token: string, b: {
318
+ name?: string | null;
319
+ body: string;
320
+ anchor?: string | null;
321
+ quote?: string | null;
322
+ threadId?: string | null;
323
+ }) => Promise<CmsComment>;
324
+ presence: (c: string, s: string, b?: {
325
+ cursor?: Presence["cursor"];
326
+ selection?: Presence["selection"];
327
+ }) => Promise<{
328
+ version: number;
329
+ updatedBy: string | null;
330
+ others: Presence[];
331
+ }>;
332
+ leave: (c: string, s: string) => Promise<{
333
+ ok: true;
334
+ }>;
335
+ presenceIn: (c: string) => Promise<{
336
+ slug: string;
337
+ people: Presence[];
338
+ }[]>;
339
+ labelVersion: (c: string, s: string, n: number, b: {
340
+ label?: string | null;
341
+ pinned?: boolean;
342
+ }) => Promise<CmsVersion>;
343
+ filters: (c: string) => Promise<(SavedFilter & {
344
+ mine: boolean;
345
+ })[]>;
346
+ saveFilter: (c: string, b: {
347
+ name: string;
348
+ query: Record<string, string>;
349
+ shared?: boolean;
350
+ }) => Promise<SavedFilter>;
351
+ removeFilter: (c: string, id: string) => Promise<{
352
+ ok: true;
353
+ }>;
354
+ trash: (kind?: TrashRef["kind"]) => Promise<{
355
+ items: TrashItem[];
356
+ days: number;
357
+ canPurge: boolean;
358
+ }>;
359
+ restoreTrash: (items: TrashRef[]) => Promise<{
360
+ restored: number;
361
+ }>;
362
+ purgeTrash: (items: TrashRef[] | "all") => Promise<{
363
+ purged: number;
364
+ }>;
365
+ releases: () => Promise<CmsRelease[]>;
366
+ release: (id: string) => Promise<ReleaseView>;
367
+ createRelease: (name: string) => Promise<ReleaseView>;
368
+ renameRelease: (id: string, name: string) => Promise<ReleaseView>;
369
+ removeRelease: (id: string) => Promise<{
370
+ ok: true;
371
+ }>;
372
+ addToRelease: (id: string, items: {
373
+ collection: string;
374
+ slug: string;
375
+ action?: "publish" | "unpublish";
376
+ }[]) => Promise<ReleaseView>;
377
+ removeFromRelease: (id: string, documentId: string) => Promise<ReleaseView>;
378
+ publishRelease: (id: string) => Promise<CmsRelease>;
379
+ scheduleRelease: (id: string, publishAt: string | null) => Promise<ReleaseView>;
191
380
  search: (q: string, collections?: string[]) => Promise<{
192
381
  empty: boolean;
193
382
  hits: {
@@ -212,6 +401,119 @@ declare function createRestClient(opts: RestClientOptions): {
212
401
  revokeKey: (id: string) => Promise<{
213
402
  ok: true;
214
403
  }>;
404
+ assets: (q?: Omit<AssetListOptions, "kinds"> & {
405
+ kind?: string;
406
+ }) => Promise<{
407
+ assets: AssetView[];
408
+ cursor: string | null;
409
+ counts: AssetCounts;
410
+ }>;
411
+ assetFolders: () => Promise<FolderTree[]>;
412
+ createAssetFolder: (path: string, store?: string | null) => Promise<{
413
+ store: string;
414
+ path: string;
415
+ }>;
416
+ deleteAssetFolder: (path: string, store?: string | null) => Promise<{
417
+ ok: true;
418
+ }>;
419
+ asset: (id: string) => Promise<AssetDetail>;
420
+ updateAsset: (id: string, patch: {
421
+ alt?: string;
422
+ tags?: string[];
423
+ }) => Promise<AssetView>;
424
+ moveAsset: (id: string, to: {
425
+ folder?: string | null;
426
+ name?: string | null;
427
+ }) => Promise<AssetView>;
428
+ /** Fails with `asset_in_use` (the documents are in `error.current`) unless `confirm` is set. */
429
+ removeAsset: (id: string, o?: {
430
+ confirm?: boolean;
431
+ }) => Promise<{
432
+ ok: true;
433
+ }>;
434
+ importAsset: (b: {
435
+ url: string;
436
+ name?: string | null;
437
+ folder?: string | null;
438
+ store?: string | null;
439
+ alt?: string;
440
+ tags?: string[];
441
+ }) => Promise<AssetView>;
442
+ requestUpload: (b: UploadRequest) => Promise<{
443
+ asset: AssetView;
444
+ upload: UploadInstructions;
445
+ }>;
446
+ uploadStatus: (id: string) => Promise<{
447
+ asset: AssetView;
448
+ partSize: number;
449
+ partCount: number;
450
+ done: number[];
451
+ }>;
452
+ uploadPartUrls: (id: string, parts: number[]) => Promise<{
453
+ partNumber: number;
454
+ url: string;
455
+ }[]>;
456
+ completeUpload: (id: string, meta?: {
457
+ width?: number | null;
458
+ height?: number | null;
459
+ duration?: number | null;
460
+ }) => Promise<AssetView>;
461
+ abortUpload: (id: string) => Promise<{
462
+ ok: true;
463
+ }>;
464
+ /** Store a small picture of the file (WebP, JPEG or PNG, up to 512KB). */
465
+ setAssetThumb(id: string, bytes: Blob | Uint8Array): Promise<AssetView>;
466
+ storeFiles: (store: string, q?: {
467
+ prefix?: string | null;
468
+ q?: string;
469
+ cursor?: string | null;
470
+ limit?: number;
471
+ }) => Promise<StoreListing>;
472
+ registerFile: (store: string, key: string, more?: {
473
+ alt?: string;
474
+ tags?: string[];
475
+ }) => Promise<AssetView>;
476
+ /** Move files and whole folders into the folder `to` ("" = the top). */
477
+ moveFiles: (store: string, b: {
478
+ keys?: string[];
479
+ folders?: string[];
480
+ to: string;
481
+ }) => Promise<{
482
+ moved: number;
483
+ failed: {
484
+ key: string;
485
+ message: string;
486
+ }[];
487
+ }>;
488
+ /** Fails with `asset_in_use` unless `confirm` is set. `check: true` deletes nothing and only counts the files and their uses. */
489
+ removeFiles: (store: string, b: {
490
+ keys?: string[];
491
+ folders?: string[];
492
+ confirm?: boolean;
493
+ check?: boolean;
494
+ }) => Promise<{
495
+ deleted: number;
496
+ files: number;
497
+ used: number;
498
+ documents: AssetUsage[];
499
+ hidden: number;
500
+ }>;
501
+ shareAsset: (id: string, ttl?: ShareTtl) => Promise<{
502
+ url: string;
503
+ expiresAt: string | null;
504
+ }>;
505
+ /** Address of a file by its key (files the CMS has no row for). */
506
+ storeFileUrl: (store: string, key: string, o?: {
507
+ download?: boolean;
508
+ }) => string;
509
+ /** Address of a file through the CMS route (`thumb`: its small picture). */
510
+ fileUrl: (a: {
511
+ id: string;
512
+ name: string;
513
+ }, o?: {
514
+ thumb?: boolean;
515
+ download?: boolean;
516
+ }) => string;
215
517
  audit: (q?: {
216
518
  cursor?: string | null;
217
519
  action?: string;
@@ -225,4 +527,4 @@ declare function createRestClient(opts: RestClientOptions): {
225
527
  };
226
528
  type RestClient = ReturnType<typeof createRestClient>;
227
529
 
228
- export { type CmsClient, type CmsClientOptions, CmsRemoteError, type CollectionSchema, type ListQuery, type Me, type RemoteTool, type RestClient, type RestClientOptions, createCmsClient, createRestClient, isCmsRemoteError };
530
+ export { type AssetCounts, type AssetDetail, AssetUsage, AssetView, type CmsClient, type CmsClientOptions, CmsRemoteError, type CollectionSchema, CommentThread, type DocPreview, type DocRelease, type FolderTree, type ListQuery, type Me, type MediaInfo, type MediaStoreInfo, ReleaseView, type RemoteTool, type RestClient, type RestClientOptions, type ShareTtl, type StoreFile, type StoreListing, TrashItem, TrashRef, createCmsClient, createRestClient, isCmsRemoteError };
package/dist/client.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createCmsClient,
4
4
  createRestClient,
5
5
  isCmsRemoteError
6
- } from "./chunk-QC2M4NZY.js";
6
+ } from "./chunk-BFVBHIHV.js";
7
7
  import "./chunk-2NTK7H4W.js";
8
8
  export {
9
9
  CmsRemoteError,