@thebes/cadmus 0.3.0 → 0.4.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.
@@ -1,4 +1,4 @@
1
- import { at as LocalApi } from "../index-BRZrCTsN.cjs";
1
+ import { xt as LocalApi } from "../index-CWrSoiPh.cjs";
2
2
  import { Context, Hono } from "hono";
3
3
 
4
4
  //#region src/hono/client.d.ts
@@ -1,4 +1,4 @@
1
- import { at as LocalApi } from "../index-BRZrCTsN.js";
1
+ import { xt as LocalApi } from "../index-CWrSoiPh.js";
2
2
  import { Context, Hono } from "hono";
3
3
 
4
4
  //#region src/hono/client.d.ts
@@ -180,6 +180,72 @@ declare class CadmusApiError extends CadmusError {
180
180
  constructor(message: string, status: number, body: unknown);
181
181
  }
182
182
  //#endregion
183
+ //#region src/cms/patch.d.ts
184
+ /**
185
+ * Patch model + field-level diff (issue #14) — adopts Sanity's mutation/patch
186
+ * idea (pattern, not code): represent a content change as a small set of
187
+ * field operations, and compute a field-level diff between two document
188
+ * snapshots. Underpins version-history display (what changed between two
189
+ * versions) and the content-migration runner (#18), which expresses a
190
+ * transform's effect as a {@link Patch} and applies it.
191
+ *
192
+ * Scope: operations are keyed by **top-level field** (a document's own
193
+ * fields), matching "field-level diff" — a changed `blocks` array reads as
194
+ * one changed field, not a deep per-node diff. Deep/array-aware diffing is a
195
+ * deliberate later extension, not built here.
196
+ */
197
+ /** A single field operation. `set` writes a value; `unset` removes the field. */
198
+ type PatchOp = {
199
+ op: "set";
200
+ path: string;
201
+ value: JsonValue;
202
+ } | {
203
+ op: "unset";
204
+ path: string;
205
+ };
206
+ /** An ordered set of field operations transforming one document into another. */
207
+ type Patch = PatchOp[];
208
+ type FieldChangeKind = "added" | "removed" | "changed";
209
+ /** One field's difference between two document snapshots. */
210
+ interface FieldChange {
211
+ /** Top-level field key. */
212
+ path: string;
213
+ kind: FieldChangeKind;
214
+ /** Value in the "before" snapshot (absent for `added`). */
215
+ before?: JsonValue;
216
+ /** Value in the "after" snapshot (absent for `removed`). */
217
+ after?: JsonValue;
218
+ }
219
+ type Doc$1 = Record<string, JsonValue>;
220
+ interface DiffOptions {
221
+ /**
222
+ * Restrict the diff to these field keys. Omit to diff the union of both
223
+ * documents' own keys. Useful for ignoring bookkeeping columns
224
+ * (`id`/`createdAt`/`publishedVersionId`) in a version-history view.
225
+ */
226
+ fields?: readonly string[];
227
+ /** Field keys to skip (e.g. `["id", "createdAt"]`). */
228
+ ignore?: readonly string[];
229
+ }
230
+ /**
231
+ * Field-level diff between two document snapshots — the per-field
232
+ * added/removed/changed list a version-history UI renders. Values are
233
+ * compared structurally (deep-equal), so a field only shows as `changed`
234
+ * when its content actually differs.
235
+ */
236
+ declare function diffDocuments(before: Doc$1, after: Doc$1, options?: DiffOptions): FieldChange[];
237
+ /**
238
+ * The {@link Patch} that transforms `before` into `after`: `set` for each
239
+ * added/changed field, `unset` for each removed field. `applyPatch(before,
240
+ * computePatch(before, after))` deep-equals `after`.
241
+ */
242
+ declare function computePatch(before: Doc$1, after: Doc$1): Patch;
243
+ /**
244
+ * Apply a {@link Patch} to a document, returning a new document (the input is
245
+ * never mutated). Unknown ops are ignored defensively.
246
+ */
247
+ declare function applyPatch(doc: Doc$1, patch: Patch): Doc$1;
248
+ //#endregion
183
249
  //#region src/cms/localApi.d.ts
184
250
  type AnyTable$1 = SQLiteTableWithColumns<any>;
185
251
  /**
@@ -322,6 +388,13 @@ interface VersionedLocalApi<TTable extends AnyTable$1, TVersionsTable extends An
322
388
  publish(context: TContext, versionId: number): Promise<InferSelectModel<TTable>>;
323
389
  /** Clears the main row's published pointer; the row's data is untouched. */
324
390
  unpublish(context: TContext, id: number): Promise<InferSelectModel<TTable>>;
391
+ /**
392
+ * Field-level diff (issue #14) between two version snapshots' `versionData`
393
+ * — the per-field added/removed/changed list a version-history UI renders.
394
+ * Both versions must belong to the same parent. Bookkeeping keys
395
+ * (`id`/`createdAt`/`status`/`publishedVersionId`) are ignored.
396
+ */
397
+ diffVersions(context: TContext, fromVersionId: number, toVersionId: number): Promise<FieldChange[]>;
325
398
  }
326
399
  declare function createVersionedLocalApi<TTable extends AnyTable$1, TVersionsTable extends AnyTable$1, TContext = unknown>(db: BaseSQLiteDatabase<"async", unknown>, table: TTable, versionsTable: TVersionsTable, config: CollectionConfig, registry?: CmsRegistry): VersionedLocalApi<TTable, TVersionsTable, TContext>;
327
400
  //#endregion
@@ -495,12 +568,42 @@ declare function validateDocument(config: CollectionConfig, doc: Record<string,
495
568
  declare function assertValid(config: CollectionConfig, doc: Record<string, unknown>, options: ValidateDocumentOptions): Promise<ValidationViolation[]>;
496
569
  //#endregion
497
570
  //#region src/cms/types.d.ts
571
+ /**
572
+ * Editor-only presentation hints for a single field (issue #16 follow-on) —
573
+ * the field-level counterpart to {@link CollectionAdminConfig}. Purely about
574
+ * how the studio renders the field; absent → sensible defaults (a humanized
575
+ * key for the label, no help text, full width, always shown, editable). None
576
+ * of this touches the DB schema or the Local API.
577
+ */
578
+ interface FieldAdminConfig {
579
+ /** Human-friendly label; defaults to a humanized field key (`metaDescription` → "Meta description"). */
580
+ label?: string;
581
+ /** Help text rendered beneath the label. */
582
+ description?: string;
583
+ /** Placeholder for text-like inputs. */
584
+ placeholder?: string;
585
+ /** Groups the field into a titled fieldset in the editor, in first-seen order. */
586
+ group?: string;
587
+ /** Editor column width on >= md screens. Defaults to "full". */
588
+ width?: "full" | "half";
589
+ /**
590
+ * Show the field only when this predicate — given the whole in-progress
591
+ * form value — returns true (Payload's `admin.condition`). A function, so
592
+ * it's evaluated by the studio directly from the imported config, not from
593
+ * a serialized meta payload.
594
+ */
595
+ condition?: (values: Record<string, unknown>) => boolean;
596
+ /** Render the field read-only in the editor. */
597
+ readOnly?: boolean;
598
+ }
498
599
  interface BaseFieldConfig {
499
600
  /** column name override; defaults to the config key */
500
601
  name?: string;
501
602
  required?: boolean;
502
603
  unique?: boolean;
503
604
  defaultValue?: unknown;
605
+ /** Editor-only presentation hints — see {@link FieldAdminConfig}. */
606
+ admin?: FieldAdminConfig;
504
607
  /**
505
608
  * Chainable validation rules (issue #16), Sanity's `defineField`
506
609
  * `validation` analogue: `validation: (rule) => rule.required().min(2)`.
@@ -599,6 +702,16 @@ interface ArrayFieldConfig extends BaseFieldConfig {
599
702
  discriminator?: {
600
703
  key: string;
601
704
  variants: Record<string, Record<string, FieldConfig>>;
705
+ /**
706
+ * Optional per-variant presentation for the studio's "Add block" picker
707
+ * (the visual block builder). `label` defaults to a humanized variant
708
+ * name; `icon` is an opaque CSS class the studio applies to an `<i>`
709
+ * (e.g. a Phosphor `"ph ph-image"`), keeping cadmea icon-library-agnostic.
710
+ */
711
+ variantsAdmin?: Record<string, {
712
+ label?: string;
713
+ icon?: string;
714
+ }>;
602
715
  };
603
716
  }
604
717
  interface UploadFieldConfig extends BaseFieldConfig {
@@ -987,6 +1100,62 @@ interface CollectionMeta {
987
1100
  }
988
1101
  declare function getCollectionsMeta(config: CmsConfig): CollectionMeta[];
989
1102
  //#endregion
1103
+ //#region src/cms/migrate.d.ts
1104
+ /**
1105
+ * Content-migration runner (issue #18) — adopts Sanity's `sanity/migrate`
1106
+ * idea (pattern, not code): a versioned, repeatable transform over a
1107
+ * collection's stored documents, for reshaping content when a block/field
1108
+ * type changes (distinct from Drizzle *schema* migrations, which only touch
1109
+ * columns — this reshapes the JSON content inside them).
1110
+ *
1111
+ * A migration declares a per-document `document(doc)` transform; the runner
1112
+ * streams every document, computes the {@link Patch} from old→new (reusing
1113
+ * #14's patch model), and either reports it (`dryRun`) or applies it via the
1114
+ * collection's Local API. Idempotent by construction: a transform that's
1115
+ * already been applied produces an empty patch, so re-running changes
1116
+ * nothing.
1117
+ */
1118
+ type Doc = Record<string, JsonValue>;
1119
+ interface Migration<TDoc extends Doc = Doc> {
1120
+ /** Stable identifier — name the checked-in migration file after this. */
1121
+ name: string;
1122
+ /**
1123
+ * Transform one document. Return the reshaped document, or `undefined`
1124
+ * (or the unchanged doc) to leave it as-is. Must be pure and idempotent —
1125
+ * applying it twice yields the same result as once.
1126
+ */
1127
+ document: (doc: TDoc) => TDoc | undefined | Promise<TDoc | undefined>;
1128
+ }
1129
+ /** Identity helper — gives a migration definition its type + a greppable call site. */
1130
+ declare function defineMigration<TDoc extends Doc = Doc>(migration: Migration<TDoc>): Migration<TDoc>;
1131
+ interface MigrationChange {
1132
+ id: number;
1133
+ patch: Patch;
1134
+ }
1135
+ interface MigrationResult {
1136
+ migration: string;
1137
+ dryRun: boolean;
1138
+ scanned: number;
1139
+ changed: number;
1140
+ /** Per-document patches (always populated — the dry-run report). */
1141
+ changes: MigrationChange[];
1142
+ errors: string[];
1143
+ }
1144
+ interface RunMigrationOptions<TContext> {
1145
+ api: LocalApi<any, TContext>;
1146
+ /** Context passed to the Local API's read/update (access + hooks). */
1147
+ context: TContext;
1148
+ /** When true, compute + report patches but write nothing. Default false. */
1149
+ dryRun?: boolean;
1150
+ }
1151
+ /**
1152
+ * Run a migration over every document in a collection. Reads all documents
1153
+ * through `api.find`, applies `migration.document`, and (unless `dryRun`)
1154
+ * writes the resulting patch through `api.update`. Returns a report of what
1155
+ * changed — run it `dryRun` first, then apply.
1156
+ */
1157
+ declare function runMigration<TContext>(migration: Migration, options: RunMigrationOptions<TContext>): Promise<MigrationResult>;
1158
+ //#endregion
990
1159
  //#region src/cms/schema-gen.d.ts
991
1160
  declare function generateSchemaSource(config: CmsConfig): string;
992
1161
  //#endregion
@@ -1070,6 +1239,69 @@ interface BuildStudioStructureOptions {
1070
1239
  */
1071
1240
  declare function buildStudioStructure(config: CmsConfig, options?: BuildStudioStructureOptions): StudioStructureGroup[];
1072
1241
  //#endregion
1242
+ //#region src/cms/visual-editing.d.ts
1243
+ /**
1244
+ * Visual editing / click-to-edit (issue #15) — adopts Sanity's
1245
+ * Presentation/visual-editing idea (pattern, not code): the rendered page
1246
+ * (in a preview context) tags editable regions with the source field they
1247
+ * came from, and an overlay turns those regions into click targets that tell
1248
+ * the studio which field to focus.
1249
+ *
1250
+ * This module ships the two reusable, framework-agnostic primitives:
1251
+ * 1. **Encoding** — `editAttr({ collection, id, field })` produces a data
1252
+ * attribute the server renderer spreads onto an element; `decodeEditRef`
1253
+ * reads it back. Pure, testable.
1254
+ * 2. **Overlay** — `mountVisualEditing()` (browser-only; references `document`
1255
+ * lazily, so importing it server-side is harmless) highlights tagged
1256
+ * elements on hover and, on click, calls `onSelect` and `postMessage`s the
1257
+ * ref to the parent window (the studio shell hosting the preview iframe).
1258
+ *
1259
+ * The studio side listens for that message and navigates to
1260
+ * `/admin/<collection>/<id>` (and may focus `<field>`); that wiring is
1261
+ * consumer-side and not prescribed here.
1262
+ */
1263
+ /** A reference from a rendered region back to the field that produced it. */
1264
+ interface EditRef {
1265
+ collection: string;
1266
+ id: number;
1267
+ field: string;
1268
+ }
1269
+ /** The data attribute editable regions are tagged with. */
1270
+ declare const EDIT_ATTR = "data-cadmus-edit";
1271
+ /** `postMessage` payload type for a click-to-edit selection. */
1272
+ declare const VISUAL_EDIT_MESSAGE = "cadmus:visual-edit";
1273
+ declare function encodeEditRef(ref: EditRef): string;
1274
+ /** Parse an {@link EditRef} string, or null if malformed. */
1275
+ declare function decodeEditRef(value: string): EditRef | null;
1276
+ /**
1277
+ * Attribute object to spread onto a rendered element so the overlay can map
1278
+ * it back to its source field, e.g. `<h1 {...editAttr({collection:'pages',
1279
+ * id, field:'title'})}>`.
1280
+ */
1281
+ declare function editAttr(ref: EditRef): Record<string, string>;
1282
+ interface VisualEditingMessage {
1283
+ type: typeof VISUAL_EDIT_MESSAGE;
1284
+ ref: EditRef;
1285
+ }
1286
+ interface VisualEditingOptions {
1287
+ /** Called with the decoded ref when an editable region is clicked. */
1288
+ onSelect?: (ref: EditRef, element: Element) => void;
1289
+ /**
1290
+ * Origin to `postMessage` the selection to the parent window. Default
1291
+ * `"*"`. Set to the studio origin in production.
1292
+ */
1293
+ targetOrigin?: string;
1294
+ /** Outline color for the hover highlight. Default a teal accent. */
1295
+ highlightColor?: string;
1296
+ }
1297
+ /**
1298
+ * Mount the click-to-edit overlay. Browser-only — call from a preview page's
1299
+ * client script. Highlights `[data-cadmus-edit]` elements on hover and, on
1300
+ * click, calls `onSelect` and posts a {@link VisualEditingMessage} to the
1301
+ * parent window. Returns a cleanup function that removes the listeners.
1302
+ */
1303
+ declare function mountVisualEditing(options?: VisualEditingOptions): () => void;
1304
+ //#endregion
1073
1305
  //#region src/cms/webhooks.d.ts
1074
1306
  interface WebhookConfig {
1075
1307
  /** Endpoint this webhook POSTs to on every matching event. */
@@ -1108,5 +1340,5 @@ declare function createWebhookHook(queue: Queue<WebhookMessage>, config: Webhook
1108
1340
  */
1109
1341
  declare function deliverWebhookMessage(message: WebhookMessage): Promise<void>;
1110
1342
  //#endregion
1111
- export { ValidationSeverity as $, CollectionConfig as A, RichTextFieldConfig as B, ArrayFieldConfig as C, CadmusValidationError as Ct, CmsConfig as D, StringBlockRenderer as Dt, CheckboxFieldConfig as E, PortableBlockLike as Et, JsonFieldConfig as F, flattenFields as G, TextFieldConfig as H, JsonValue as I, CustomValidatorResult as J, nestDoc as K, NumberFieldConfig as L, DateFieldConfig as M, FieldConfig as N, CollectionAccess as O, createBlockRegistry as Ot, GroupFieldConfig as P, ValidationFieldContext as Q, RelationshipDepth as R, AccessFn as S, CadmusStorageError as St, CadmeaPlugin as T, BlockRegistry as Tt, UploadFieldConfig as U, SelectFieldConfig as V, flattenDoc as W, ValidateDocumentOptions as X, Rule as Y, ValidationBuilder as Z, collectionSearchTableSQL as _, CadmusEmailError as _t, BuildStudioStructureOptions as a, LocalApi as at, extractSearchText as b, CadmusRateLimitError as bt, StudioStructureItem as c, createLocalApi as ct, CollectionMeta as d, CadmusAccessDeniedError as dt, assertValid as et, getCollectionsMeta as f, CadmusApiError as ft, collectionSearchTableName as g, CadmusDbError as gt, cmsConfigToSchema as h, CadmusCmsError as ht, deliverWebhookMessage as i, CmsRegistry as it, CollectionHooks as j, CollectionAdminConfig as k, renderBlocksToString as kt, buildStudioStructure as l, createVersionedLocalApi as lt, defineCollection as m, CadmusCacheError as mt, WebhookMessage as n, rule as nt, DEFAULT_STUDIO_GROUP as o, VersionedLocalApi as ot, defineCmsConfig as p, CadmusAuthError as pt, CustomValidator as q, createWebhookHook as r, validateDocument as rt, StudioStructureGroup as s, can as st, WebhookConfig as t, defineField as tt, generateSchemaSource as u, getRegisteredApi as ut, collectionToTable as v, CadmusError as vt, BaseFieldConfig as w, ValidationViolation as wt, relationshipJoinTables as x, CadmusSessionError as xt, collectionVersionsTable as y, CadmusQueueError as yt, RelationshipFieldConfig as z };
1112
- //# sourceMappingURL=index-BRZrCTsN.d.cts.map
1343
+ export { NumberFieldConfig as $, renderBlocksToString as $t, cmsConfigToSchema as A, Patch as At, CadmeaPlugin as B, CadmusDbError as Bt, RunMigrationOptions as C, can as Ct, getCollectionsMeta as D, DiffOptions as Dt, CollectionMeta as E, getRegisteredApi as Et, extractSearchText as F, CadmusAccessDeniedError as Ft, CollectionConfig as G, CadmusSessionError as Gt, CmsConfig as H, CadmusError as Ht, relationshipJoinTables as I, CadmusApiError as It, FieldAdminConfig as J, ValidationViolation as Jt, CollectionHooks as K, CadmusStorageError as Kt, AccessFn as L, CadmusAuthError as Lt, collectionSearchTableSQL as M, applyPatch as Mt, collectionToTable as N, computePatch as Nt, defineCmsConfig as O, FieldChange as Ot, collectionVersionsTable as P, diffDocuments as Pt, JsonValue as Q, createBlockRegistry as Qt, ArrayFieldConfig as R, CadmusCacheError as Rt, MigrationResult as S, VersionedLocalApi as St, runMigration as T, createVersionedLocalApi as Tt, CollectionAccess as U, CadmusQueueError as Ut, CheckboxFieldConfig as V, CadmusEmailError as Vt, CollectionAdminConfig as W, CadmusRateLimitError as Wt, GroupFieldConfig as X, PortableBlockLike as Xt, FieldConfig as Y, BlockRegistry as Yt, JsonFieldConfig as Z, StringBlockRenderer as Zt, StudioStructureItem as _, defineField as _t, EDIT_ATTR as a, UploadFieldConfig as at, Migration as b, CmsRegistry as bt, VisualEditingMessage as c, nestDoc as ct, editAttr as d, Rule as dt, RelationshipDepth as et, encodeEditRef as f, ValidateDocumentOptions as ft, StudioStructureGroup as g, assertValid as gt, DEFAULT_STUDIO_GROUP as h, ValidationSeverity as ht, deliverWebhookMessage as i, TextFieldConfig as it, collectionSearchTableName as j, PatchOp as jt, defineCollection as k, FieldChangeKind as kt, VisualEditingOptions as l, CustomValidator as lt, BuildStudioStructureOptions as m, ValidationFieldContext as mt, WebhookMessage as n, RichTextFieldConfig as nt, EditRef as o, flattenDoc as ot, mountVisualEditing as p, ValidationBuilder as pt, DateFieldConfig as q, CadmusValidationError as qt, createWebhookHook as r, SelectFieldConfig as rt, VISUAL_EDIT_MESSAGE as s, flattenFields as st, WebhookConfig as t, RelationshipFieldConfig as tt, decodeEditRef as u, CustomValidatorResult as ut, buildStudioStructure as v, rule as vt, defineMigration as w, createLocalApi as wt, MigrationChange as x, LocalApi as xt, generateSchemaSource as y, validateDocument as yt, BaseFieldConfig as z, CadmusCmsError as zt };
1344
+ //# sourceMappingURL=index-CWrSoiPh.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CWrSoiPh.d.cts","names":[],"sources":["../src/cms/blocks.ts","../src/errors.ts","../src/cms/patch.ts","../src/cms/localApi.ts","../src/cms/validation.ts","../src/cms/types.ts","../src/cms/codegen.ts","../src/cms/defineCollection.ts","../src/cms/meta.ts","../src/cms/migrate.ts","../src/cms/schema-gen.ts","../src/cms/structure.ts","../src/cms/visual-editing.ts","../src/cms/webhooks.ts"],"mappings":";;;;;;;;AAuBA;;;;AACM;AAGN;;;;;;;;;;UAJiB,iBAAA;EACf,IAAI;AAAA;AAAA,UAGW,aAAA;EAcQ;EAZvB,QAAA,CAAS,IAAA,UAAc,QAAA,EAAU,SAAA,GAAY,aAAA,CAAc,SAAA;EAY3B;EAVhC,YAAA,CAAa,SAAA,EAAW,MAAA,SAAe,SAAA,IAAa,aAAA,CAAc,SAAA;EAFlE;EAIA,GAAA,CAAI,IAAA,WAAe,S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;EbDQ;EaGnB,SAAA;AAAA;;;;;;;;iBAUc,iBAAA,CACd,KAAA,EAAO,KAAA,CAAM,cAAA,GACb,MAAA,EAAQ,aAAA,GACP,WAAA,CAAY,eAAA;;;;;;;iBA0EO,qBAAA,CACpB,OAAA,EAAS,cAAA,GACR,OAAO"}
@@ -180,6 +180,72 @@ declare class CadmusApiError extends CadmusError {
180
180
  constructor(message: string, status: number, body: unknown);
181
181
  }
182
182
  //#endregion
183
+ //#region src/cms/patch.d.ts
184
+ /**
185
+ * Patch model + field-level diff (issue #14) — adopts Sanity's mutation/patch
186
+ * idea (pattern, not code): represent a content change as a small set of
187
+ * field operations, and compute a field-level diff between two document
188
+ * snapshots. Underpins version-history display (what changed between two
189
+ * versions) and the content-migration runner (#18), which expresses a
190
+ * transform's effect as a {@link Patch} and applies it.
191
+ *
192
+ * Scope: operations are keyed by **top-level field** (a document's own
193
+ * fields), matching "field-level diff" — a changed `blocks` array reads as
194
+ * one changed field, not a deep per-node diff. Deep/array-aware diffing is a
195
+ * deliberate later extension, not built here.
196
+ */
197
+ /** A single field operation. `set` writes a value; `unset` removes the field. */
198
+ type PatchOp = {
199
+ op: "set";
200
+ path: string;
201
+ value: JsonValue;
202
+ } | {
203
+ op: "unset";
204
+ path: string;
205
+ };
206
+ /** An ordered set of field operations transforming one document into another. */
207
+ type Patch = PatchOp[];
208
+ type FieldChangeKind = "added" | "removed" | "changed";
209
+ /** One field's difference between two document snapshots. */
210
+ interface FieldChange {
211
+ /** Top-level field key. */
212
+ path: string;
213
+ kind: FieldChangeKind;
214
+ /** Value in the "before" snapshot (absent for `added`). */
215
+ before?: JsonValue;
216
+ /** Value in the "after" snapshot (absent for `removed`). */
217
+ after?: JsonValue;
218
+ }
219
+ type Doc$1 = Record<string, JsonValue>;
220
+ interface DiffOptions {
221
+ /**
222
+ * Restrict the diff to these field keys. Omit to diff the union of both
223
+ * documents' own keys. Useful for ignoring bookkeeping columns
224
+ * (`id`/`createdAt`/`publishedVersionId`) in a version-history view.
225
+ */
226
+ fields?: readonly string[];
227
+ /** Field keys to skip (e.g. `["id", "createdAt"]`). */
228
+ ignore?: readonly string[];
229
+ }
230
+ /**
231
+ * Field-level diff between two document snapshots — the per-field
232
+ * added/removed/changed list a version-history UI renders. Values are
233
+ * compared structurally (deep-equal), so a field only shows as `changed`
234
+ * when its content actually differs.
235
+ */
236
+ declare function diffDocuments(before: Doc$1, after: Doc$1, options?: DiffOptions): FieldChange[];
237
+ /**
238
+ * The {@link Patch} that transforms `before` into `after`: `set` for each
239
+ * added/changed field, `unset` for each removed field. `applyPatch(before,
240
+ * computePatch(before, after))` deep-equals `after`.
241
+ */
242
+ declare function computePatch(before: Doc$1, after: Doc$1): Patch;
243
+ /**
244
+ * Apply a {@link Patch} to a document, returning a new document (the input is
245
+ * never mutated). Unknown ops are ignored defensively.
246
+ */
247
+ declare function applyPatch(doc: Doc$1, patch: Patch): Doc$1;
248
+ //#endregion
183
249
  //#region src/cms/localApi.d.ts
184
250
  type AnyTable$1 = SQLiteTableWithColumns<any>;
185
251
  /**
@@ -322,6 +388,13 @@ interface VersionedLocalApi<TTable extends AnyTable$1, TVersionsTable extends An
322
388
  publish(context: TContext, versionId: number): Promise<InferSelectModel<TTable>>;
323
389
  /** Clears the main row's published pointer; the row's data is untouched. */
324
390
  unpublish(context: TContext, id: number): Promise<InferSelectModel<TTable>>;
391
+ /**
392
+ * Field-level diff (issue #14) between two version snapshots' `versionData`
393
+ * — the per-field added/removed/changed list a version-history UI renders.
394
+ * Both versions must belong to the same parent. Bookkeeping keys
395
+ * (`id`/`createdAt`/`status`/`publishedVersionId`) are ignored.
396
+ */
397
+ diffVersions(context: TContext, fromVersionId: number, toVersionId: number): Promise<FieldChange[]>;
325
398
  }
326
399
  declare function createVersionedLocalApi<TTable extends AnyTable$1, TVersionsTable extends AnyTable$1, TContext = unknown>(db: BaseSQLiteDatabase<"async", unknown>, table: TTable, versionsTable: TVersionsTable, config: CollectionConfig, registry?: CmsRegistry): VersionedLocalApi<TTable, TVersionsTable, TContext>;
327
400
  //#endregion
@@ -495,12 +568,42 @@ declare function validateDocument(config: CollectionConfig, doc: Record<string,
495
568
  declare function assertValid(config: CollectionConfig, doc: Record<string, unknown>, options: ValidateDocumentOptions): Promise<ValidationViolation[]>;
496
569
  //#endregion
497
570
  //#region src/cms/types.d.ts
571
+ /**
572
+ * Editor-only presentation hints for a single field (issue #16 follow-on) —
573
+ * the field-level counterpart to {@link CollectionAdminConfig}. Purely about
574
+ * how the studio renders the field; absent → sensible defaults (a humanized
575
+ * key for the label, no help text, full width, always shown, editable). None
576
+ * of this touches the DB schema or the Local API.
577
+ */
578
+ interface FieldAdminConfig {
579
+ /** Human-friendly label; defaults to a humanized field key (`metaDescription` → "Meta description"). */
580
+ label?: string;
581
+ /** Help text rendered beneath the label. */
582
+ description?: string;
583
+ /** Placeholder for text-like inputs. */
584
+ placeholder?: string;
585
+ /** Groups the field into a titled fieldset in the editor, in first-seen order. */
586
+ group?: string;
587
+ /** Editor column width on >= md screens. Defaults to "full". */
588
+ width?: "full" | "half";
589
+ /**
590
+ * Show the field only when this predicate — given the whole in-progress
591
+ * form value — returns true (Payload's `admin.condition`). A function, so
592
+ * it's evaluated by the studio directly from the imported config, not from
593
+ * a serialized meta payload.
594
+ */
595
+ condition?: (values: Record<string, unknown>) => boolean;
596
+ /** Render the field read-only in the editor. */
597
+ readOnly?: boolean;
598
+ }
498
599
  interface BaseFieldConfig {
499
600
  /** column name override; defaults to the config key */
500
601
  name?: string;
501
602
  required?: boolean;
502
603
  unique?: boolean;
503
604
  defaultValue?: unknown;
605
+ /** Editor-only presentation hints — see {@link FieldAdminConfig}. */
606
+ admin?: FieldAdminConfig;
504
607
  /**
505
608
  * Chainable validation rules (issue #16), Sanity's `defineField`
506
609
  * `validation` analogue: `validation: (rule) => rule.required().min(2)`.
@@ -599,6 +702,16 @@ interface ArrayFieldConfig extends BaseFieldConfig {
599
702
  discriminator?: {
600
703
  key: string;
601
704
  variants: Record<string, Record<string, FieldConfig>>;
705
+ /**
706
+ * Optional per-variant presentation for the studio's "Add block" picker
707
+ * (the visual block builder). `label` defaults to a humanized variant
708
+ * name; `icon` is an opaque CSS class the studio applies to an `<i>`
709
+ * (e.g. a Phosphor `"ph ph-image"`), keeping cadmea icon-library-agnostic.
710
+ */
711
+ variantsAdmin?: Record<string, {
712
+ label?: string;
713
+ icon?: string;
714
+ }>;
602
715
  };
603
716
  }
604
717
  interface UploadFieldConfig extends BaseFieldConfig {
@@ -987,6 +1100,62 @@ interface CollectionMeta {
987
1100
  }
988
1101
  declare function getCollectionsMeta(config: CmsConfig): CollectionMeta[];
989
1102
  //#endregion
1103
+ //#region src/cms/migrate.d.ts
1104
+ /**
1105
+ * Content-migration runner (issue #18) — adopts Sanity's `sanity/migrate`
1106
+ * idea (pattern, not code): a versioned, repeatable transform over a
1107
+ * collection's stored documents, for reshaping content when a block/field
1108
+ * type changes (distinct from Drizzle *schema* migrations, which only touch
1109
+ * columns — this reshapes the JSON content inside them).
1110
+ *
1111
+ * A migration declares a per-document `document(doc)` transform; the runner
1112
+ * streams every document, computes the {@link Patch} from old→new (reusing
1113
+ * #14's patch model), and either reports it (`dryRun`) or applies it via the
1114
+ * collection's Local API. Idempotent by construction: a transform that's
1115
+ * already been applied produces an empty patch, so re-running changes
1116
+ * nothing.
1117
+ */
1118
+ type Doc = Record<string, JsonValue>;
1119
+ interface Migration<TDoc extends Doc = Doc> {
1120
+ /** Stable identifier — name the checked-in migration file after this. */
1121
+ name: string;
1122
+ /**
1123
+ * Transform one document. Return the reshaped document, or `undefined`
1124
+ * (or the unchanged doc) to leave it as-is. Must be pure and idempotent —
1125
+ * applying it twice yields the same result as once.
1126
+ */
1127
+ document: (doc: TDoc) => TDoc | undefined | Promise<TDoc | undefined>;
1128
+ }
1129
+ /** Identity helper — gives a migration definition its type + a greppable call site. */
1130
+ declare function defineMigration<TDoc extends Doc = Doc>(migration: Migration<TDoc>): Migration<TDoc>;
1131
+ interface MigrationChange {
1132
+ id: number;
1133
+ patch: Patch;
1134
+ }
1135
+ interface MigrationResult {
1136
+ migration: string;
1137
+ dryRun: boolean;
1138
+ scanned: number;
1139
+ changed: number;
1140
+ /** Per-document patches (always populated — the dry-run report). */
1141
+ changes: MigrationChange[];
1142
+ errors: string[];
1143
+ }
1144
+ interface RunMigrationOptions<TContext> {
1145
+ api: LocalApi<any, TContext>;
1146
+ /** Context passed to the Local API's read/update (access + hooks). */
1147
+ context: TContext;
1148
+ /** When true, compute + report patches but write nothing. Default false. */
1149
+ dryRun?: boolean;
1150
+ }
1151
+ /**
1152
+ * Run a migration over every document in a collection. Reads all documents
1153
+ * through `api.find`, applies `migration.document`, and (unless `dryRun`)
1154
+ * writes the resulting patch through `api.update`. Returns a report of what
1155
+ * changed — run it `dryRun` first, then apply.
1156
+ */
1157
+ declare function runMigration<TContext>(migration: Migration, options: RunMigrationOptions<TContext>): Promise<MigrationResult>;
1158
+ //#endregion
990
1159
  //#region src/cms/schema-gen.d.ts
991
1160
  declare function generateSchemaSource(config: CmsConfig): string;
992
1161
  //#endregion
@@ -1070,6 +1239,69 @@ interface BuildStudioStructureOptions {
1070
1239
  */
1071
1240
  declare function buildStudioStructure(config: CmsConfig, options?: BuildStudioStructureOptions): StudioStructureGroup[];
1072
1241
  //#endregion
1242
+ //#region src/cms/visual-editing.d.ts
1243
+ /**
1244
+ * Visual editing / click-to-edit (issue #15) — adopts Sanity's
1245
+ * Presentation/visual-editing idea (pattern, not code): the rendered page
1246
+ * (in a preview context) tags editable regions with the source field they
1247
+ * came from, and an overlay turns those regions into click targets that tell
1248
+ * the studio which field to focus.
1249
+ *
1250
+ * This module ships the two reusable, framework-agnostic primitives:
1251
+ * 1. **Encoding** — `editAttr({ collection, id, field })` produces a data
1252
+ * attribute the server renderer spreads onto an element; `decodeEditRef`
1253
+ * reads it back. Pure, testable.
1254
+ * 2. **Overlay** — `mountVisualEditing()` (browser-only; references `document`
1255
+ * lazily, so importing it server-side is harmless) highlights tagged
1256
+ * elements on hover and, on click, calls `onSelect` and `postMessage`s the
1257
+ * ref to the parent window (the studio shell hosting the preview iframe).
1258
+ *
1259
+ * The studio side listens for that message and navigates to
1260
+ * `/admin/<collection>/<id>` (and may focus `<field>`); that wiring is
1261
+ * consumer-side and not prescribed here.
1262
+ */
1263
+ /** A reference from a rendered region back to the field that produced it. */
1264
+ interface EditRef {
1265
+ collection: string;
1266
+ id: number;
1267
+ field: string;
1268
+ }
1269
+ /** The data attribute editable regions are tagged with. */
1270
+ declare const EDIT_ATTR = "data-cadmus-edit";
1271
+ /** `postMessage` payload type for a click-to-edit selection. */
1272
+ declare const VISUAL_EDIT_MESSAGE = "cadmus:visual-edit";
1273
+ declare function encodeEditRef(ref: EditRef): string;
1274
+ /** Parse an {@link EditRef} string, or null if malformed. */
1275
+ declare function decodeEditRef(value: string): EditRef | null;
1276
+ /**
1277
+ * Attribute object to spread onto a rendered element so the overlay can map
1278
+ * it back to its source field, e.g. `<h1 {...editAttr({collection:'pages',
1279
+ * id, field:'title'})}>`.
1280
+ */
1281
+ declare function editAttr(ref: EditRef): Record<string, string>;
1282
+ interface VisualEditingMessage {
1283
+ type: typeof VISUAL_EDIT_MESSAGE;
1284
+ ref: EditRef;
1285
+ }
1286
+ interface VisualEditingOptions {
1287
+ /** Called with the decoded ref when an editable region is clicked. */
1288
+ onSelect?: (ref: EditRef, element: Element) => void;
1289
+ /**
1290
+ * Origin to `postMessage` the selection to the parent window. Default
1291
+ * `"*"`. Set to the studio origin in production.
1292
+ */
1293
+ targetOrigin?: string;
1294
+ /** Outline color for the hover highlight. Default a teal accent. */
1295
+ highlightColor?: string;
1296
+ }
1297
+ /**
1298
+ * Mount the click-to-edit overlay. Browser-only — call from a preview page's
1299
+ * client script. Highlights `[data-cadmus-edit]` elements on hover and, on
1300
+ * click, calls `onSelect` and posts a {@link VisualEditingMessage} to the
1301
+ * parent window. Returns a cleanup function that removes the listeners.
1302
+ */
1303
+ declare function mountVisualEditing(options?: VisualEditingOptions): () => void;
1304
+ //#endregion
1073
1305
  //#region src/cms/webhooks.d.ts
1074
1306
  interface WebhookConfig {
1075
1307
  /** Endpoint this webhook POSTs to on every matching event. */
@@ -1108,5 +1340,5 @@ declare function createWebhookHook(queue: Queue<WebhookMessage>, config: Webhook
1108
1340
  */
1109
1341
  declare function deliverWebhookMessage(message: WebhookMessage): Promise<void>;
1110
1342
  //#endregion
1111
- export { ValidationSeverity as $, CollectionConfig as A, RichTextFieldConfig as B, ArrayFieldConfig as C, CadmusValidationError as Ct, CmsConfig as D, StringBlockRenderer as Dt, CheckboxFieldConfig as E, PortableBlockLike as Et, JsonFieldConfig as F, flattenFields as G, TextFieldConfig as H, JsonValue as I, CustomValidatorResult as J, nestDoc as K, NumberFieldConfig as L, DateFieldConfig as M, FieldConfig as N, CollectionAccess as O, createBlockRegistry as Ot, GroupFieldConfig as P, ValidationFieldContext as Q, RelationshipDepth as R, AccessFn as S, CadmusStorageError as St, CadmeaPlugin as T, BlockRegistry as Tt, UploadFieldConfig as U, SelectFieldConfig as V, flattenDoc as W, ValidateDocumentOptions as X, Rule as Y, ValidationBuilder as Z, collectionSearchTableSQL as _, CadmusEmailError as _t, BuildStudioStructureOptions as a, LocalApi as at, extractSearchText as b, CadmusRateLimitError as bt, StudioStructureItem as c, createLocalApi as ct, CollectionMeta as d, CadmusAccessDeniedError as dt, assertValid as et, getCollectionsMeta as f, CadmusApiError as ft, collectionSearchTableName as g, CadmusDbError as gt, cmsConfigToSchema as h, CadmusCmsError as ht, deliverWebhookMessage as i, CmsRegistry as it, CollectionHooks as j, CollectionAdminConfig as k, renderBlocksToString as kt, buildStudioStructure as l, createVersionedLocalApi as lt, defineCollection as m, CadmusCacheError as mt, WebhookMessage as n, rule as nt, DEFAULT_STUDIO_GROUP as o, VersionedLocalApi as ot, defineCmsConfig as p, CadmusAuthError as pt, CustomValidator as q, createWebhookHook as r, validateDocument as rt, StudioStructureGroup as s, can as st, WebhookConfig as t, defineField as tt, generateSchemaSource as u, getRegisteredApi as ut, collectionToTable as v, CadmusError as vt, BaseFieldConfig as w, ValidationViolation as wt, relationshipJoinTables as x, CadmusSessionError as xt, collectionVersionsTable as y, CadmusQueueError as yt, RelationshipFieldConfig as z };
1112
- //# sourceMappingURL=index-BRZrCTsN.d.ts.map
1343
+ export { NumberFieldConfig as $, renderBlocksToString as $t, cmsConfigToSchema as A, Patch as At, CadmeaPlugin as B, CadmusDbError as Bt, RunMigrationOptions as C, can as Ct, getCollectionsMeta as D, DiffOptions as Dt, CollectionMeta as E, getRegisteredApi as Et, extractSearchText as F, CadmusAccessDeniedError as Ft, CollectionConfig as G, CadmusSessionError as Gt, CmsConfig as H, CadmusError as Ht, relationshipJoinTables as I, CadmusApiError as It, FieldAdminConfig as J, ValidationViolation as Jt, CollectionHooks as K, CadmusStorageError as Kt, AccessFn as L, CadmusAuthError as Lt, collectionSearchTableSQL as M, applyPatch as Mt, collectionToTable as N, computePatch as Nt, defineCmsConfig as O, FieldChange as Ot, collectionVersionsTable as P, diffDocuments as Pt, JsonValue as Q, createBlockRegistry as Qt, ArrayFieldConfig as R, CadmusCacheError as Rt, MigrationResult as S, VersionedLocalApi as St, runMigration as T, createVersionedLocalApi as Tt, CollectionAccess as U, CadmusQueueError as Ut, CheckboxFieldConfig as V, CadmusEmailError as Vt, CollectionAdminConfig as W, CadmusRateLimitError as Wt, GroupFieldConfig as X, PortableBlockLike as Xt, FieldConfig as Y, BlockRegistry as Yt, JsonFieldConfig as Z, StringBlockRenderer as Zt, StudioStructureItem as _, defineField as _t, EDIT_ATTR as a, UploadFieldConfig as at, Migration as b, CmsRegistry as bt, VisualEditingMessage as c, nestDoc as ct, editAttr as d, Rule as dt, RelationshipDepth as et, encodeEditRef as f, ValidateDocumentOptions as ft, StudioStructureGroup as g, assertValid as gt, DEFAULT_STUDIO_GROUP as h, ValidationSeverity as ht, deliverWebhookMessage as i, TextFieldConfig as it, collectionSearchTableName as j, PatchOp as jt, defineCollection as k, FieldChangeKind as kt, VisualEditingOptions as l, CustomValidator as lt, BuildStudioStructureOptions as m, ValidationFieldContext as mt, WebhookMessage as n, RichTextFieldConfig as nt, EditRef as o, flattenDoc as ot, mountVisualEditing as p, ValidationBuilder as pt, DateFieldConfig as q, CadmusValidationError as qt, createWebhookHook as r, SelectFieldConfig as rt, VISUAL_EDIT_MESSAGE as s, flattenFields as st, WebhookConfig as t, RelationshipFieldConfig as tt, decodeEditRef as u, CustomValidatorResult as ut, buildStudioStructure as v, rule as vt, defineMigration as w, createLocalApi as wt, MigrationChange as x, LocalApi as xt, generateSchemaSource as y, validateDocument as yt, BaseFieldConfig as z, CadmusCmsError as zt };
1344
+ //# sourceMappingURL=index-CWrSoiPh.d.ts.map