@lacecms/content 0.1.0-alpha.8 → 0.1.0-rc2

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 (153) hide show
  1. package/dist/blocks/built-ins.d.ts +562 -0
  2. package/dist/blocks/built-ins.d.ts.map +1 -0
  3. package/dist/blocks/built-ins.js +302 -0
  4. package/dist/blocks/built-ins.js.map +1 -0
  5. package/dist/blocks/definition.d.ts +21 -0
  6. package/dist/blocks/definition.d.ts.map +1 -0
  7. package/dist/blocks/definition.js +159 -0
  8. package/dist/blocks/definition.js.map +1 -0
  9. package/dist/blocks/errors.d.ts +7 -0
  10. package/dist/blocks/errors.d.ts.map +1 -0
  11. package/dist/blocks/errors.js +12 -0
  12. package/dist/blocks/errors.js.map +1 -0
  13. package/dist/blocks/fields.d.ts +3 -0
  14. package/dist/blocks/fields.d.ts.map +1 -0
  15. package/dist/blocks/fields.js +38 -0
  16. package/dist/blocks/fields.js.map +1 -0
  17. package/dist/blocks/grammar.d.ts +23 -0
  18. package/dist/blocks/grammar.d.ts.map +1 -0
  19. package/dist/blocks/grammar.js +38 -0
  20. package/dist/blocks/grammar.js.map +1 -0
  21. package/dist/blocks/list-layout.d.ts +89 -0
  22. package/dist/blocks/list-layout.d.ts.map +1 -0
  23. package/dist/blocks/list-layout.js +146 -0
  24. package/dist/blocks/list-layout.js.map +1 -0
  25. package/dist/blocks/migration.d.ts +26 -0
  26. package/dist/blocks/migration.d.ts.map +1 -0
  27. package/dist/blocks/migration.js +126 -0
  28. package/dist/blocks/migration.js.map +1 -0
  29. package/dist/blocks/registry.d.ts +6 -0
  30. package/dist/blocks/registry.d.ts.map +1 -0
  31. package/dist/blocks/registry.js +23 -0
  32. package/dist/blocks/registry.js.map +1 -0
  33. package/dist/blocks/settings.d.ts +9 -0
  34. package/dist/blocks/settings.d.ts.map +1 -0
  35. package/dist/blocks/settings.js +63 -0
  36. package/dist/blocks/settings.js.map +1 -0
  37. package/dist/blocks/types.d.ts +77 -0
  38. package/dist/blocks/types.d.ts.map +1 -0
  39. package/dist/blocks/types.js +2 -0
  40. package/dist/blocks/types.js.map +1 -0
  41. package/dist/entries/aggregate.d.ts +76 -0
  42. package/dist/entries/aggregate.d.ts.map +1 -0
  43. package/dist/entries/aggregate.js +161 -0
  44. package/dist/entries/aggregate.js.map +1 -0
  45. package/dist/entries/canonical-json.d.ts +14 -0
  46. package/dist/entries/canonical-json.d.ts.map +1 -0
  47. package/dist/entries/canonical-json.js +43 -0
  48. package/dist/entries/canonical-json.js.map +1 -0
  49. package/dist/entries/list-query-policy.d.ts.map +1 -0
  50. package/dist/entries/list-query-policy.js.map +1 -0
  51. package/dist/fields/builders.d.ts +35 -0
  52. package/dist/fields/builders.d.ts.map +1 -0
  53. package/dist/fields/builders.js +15 -0
  54. package/dist/fields/builders.js.map +1 -0
  55. package/dist/fields/capabilities.d.ts +157 -0
  56. package/dist/fields/capabilities.d.ts.map +1 -0
  57. package/dist/fields/capabilities.js +131 -0
  58. package/dist/fields/capabilities.js.map +1 -0
  59. package/dist/fields/definitions.d.ts +255 -0
  60. package/dist/fields/definitions.d.ts.map +1 -0
  61. package/dist/fields/definitions.js +42 -0
  62. package/dist/fields/definitions.js.map +1 -0
  63. package/dist/fields/descriptor-record.d.ts +3 -0
  64. package/dist/fields/descriptor-record.d.ts.map +1 -0
  65. package/dist/fields/descriptor-record.js +18 -0
  66. package/dist/fields/descriptor-record.js.map +1 -0
  67. package/dist/fields/filter-values.d.ts +34 -0
  68. package/dist/fields/filter-values.d.ts.map +1 -0
  69. package/dist/fields/filter-values.js +109 -0
  70. package/dist/fields/filter-values.js.map +1 -0
  71. package/dist/{internal-links.d.ts → fields/internal-link-tokens.d.ts} +1 -1
  72. package/dist/fields/internal-link-tokens.d.ts.map +1 -0
  73. package/dist/{internal-links.js → fields/internal-link-tokens.js} +8 -3
  74. package/dist/fields/internal-link-tokens.js.map +1 -0
  75. package/dist/fields/layout.d.ts +6 -0
  76. package/dist/fields/layout.d.ts.map +1 -0
  77. package/dist/fields/layout.js +45 -0
  78. package/dist/fields/layout.js.map +1 -0
  79. package/dist/fields/metadata.d.ts +4 -0
  80. package/dist/fields/metadata.d.ts.map +1 -0
  81. package/dist/fields/metadata.js +6 -0
  82. package/dist/fields/metadata.js.map +1 -0
  83. package/dist/fields/normalization.d.ts +5 -0
  84. package/dist/fields/normalization.d.ts.map +1 -0
  85. package/dist/fields/normalization.js +148 -0
  86. package/dist/fields/normalization.js.map +1 -0
  87. package/dist/fields/rich-text.d.ts +56 -0
  88. package/dist/fields/rich-text.d.ts.map +1 -0
  89. package/dist/fields/rich-text.js +169 -0
  90. package/dist/fields/rich-text.js.map +1 -0
  91. package/dist/fields/scalar-builders.d.ts +30 -0
  92. package/dist/fields/scalar-builders.d.ts.map +1 -0
  93. package/dist/fields/scalar-builders.js +310 -0
  94. package/dist/fields/scalar-builders.js.map +1 -0
  95. package/dist/{schema-path.d.ts → fields/schema-path.d.ts} +1 -1
  96. package/dist/fields/schema-path.d.ts.map +1 -0
  97. package/dist/{schema-path.js → fields/schema-path.js} +5 -5
  98. package/dist/fields/schema-path.js.map +1 -0
  99. package/dist/fields/validation.d.ts +40 -0
  100. package/dist/fields/validation.d.ts.map +1 -0
  101. package/dist/fields/validation.js +203 -0
  102. package/dist/fields/validation.js.map +1 -0
  103. package/dist/{video-embeds.d.ts → fields/video-embeds.d.ts} +3 -0
  104. package/dist/fields/video-embeds.d.ts.map +1 -0
  105. package/dist/{video-embeds.js → fields/video-embeds.js} +4 -0
  106. package/dist/fields/video-embeds.js.map +1 -0
  107. package/dist/fields/visibility.d.ts +12 -0
  108. package/dist/fields/visibility.d.ts.map +1 -0
  109. package/dist/fields/visibility.js +69 -0
  110. package/dist/fields/visibility.js.map +1 -0
  111. package/dist/index.d.ts +45 -1023
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +37 -2106
  114. package/dist/index.js.map +1 -1
  115. package/dist/references/field-paths.d.ts +6 -0
  116. package/dist/references/field-paths.d.ts.map +1 -0
  117. package/dist/references/field-paths.js +19 -0
  118. package/dist/references/field-paths.js.map +1 -0
  119. package/dist/references/internal-links.d.ts +30 -0
  120. package/dist/references/internal-links.d.ts.map +1 -0
  121. package/dist/references/internal-links.js +54 -0
  122. package/dist/references/internal-links.js.map +1 -0
  123. package/dist/references/media.d.ts +23 -0
  124. package/dist/references/media.d.ts.map +1 -0
  125. package/dist/references/media.js +76 -0
  126. package/dist/references/media.js.map +1 -0
  127. package/dist/shared/errors.d.ts +34 -0
  128. package/dist/shared/errors.d.ts.map +1 -0
  129. package/dist/shared/errors.js +61 -0
  130. package/dist/shared/errors.js.map +1 -0
  131. package/dist/shared/identifiers.d.ts +38 -0
  132. package/dist/shared/identifiers.d.ts.map +1 -0
  133. package/dist/shared/identifiers.js +80 -0
  134. package/dist/shared/identifiers.js.map +1 -0
  135. package/dist/shared/json.d.ts +20 -0
  136. package/dist/shared/json.d.ts.map +1 -0
  137. package/dist/shared/json.js +155 -0
  138. package/dist/shared/json.js.map +1 -0
  139. package/dist/shared/objects.d.ts +7 -0
  140. package/dist/shared/objects.d.ts.map +1 -0
  141. package/dist/shared/objects.js +20 -0
  142. package/dist/shared/objects.js.map +1 -0
  143. package/package.json +1 -1
  144. package/dist/internal-links.d.ts.map +0 -1
  145. package/dist/internal-links.js.map +0 -1
  146. package/dist/list-query-policy.d.ts.map +0 -1
  147. package/dist/list-query-policy.js.map +0 -1
  148. package/dist/schema-path.d.ts.map +0 -1
  149. package/dist/schema-path.js.map +0 -1
  150. package/dist/video-embeds.d.ts.map +0 -1
  151. package/dist/video-embeds.js.map +0 -1
  152. /package/dist/{list-query-policy.d.ts → entries/list-query-policy.d.ts} +0 -0
  153. /package/dist/{list-query-policy.js → entries/list-query-policy.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,1024 +1,46 @@
1
- import type { EmbedProvider } from "./video-embeds.js";
2
- import * as v from "valibot";
3
- export * from "./internal-links.js";
4
- export * from "./video-embeds.js";
5
- export * from "./list-query-policy.js";
6
- /** A JSON primitive that can be transported between Lace runtimes. */
7
- export type JsonPrimitive = boolean | null | number | string;
8
- /** A portable JSON value. Field descriptors never retain executable values. */
9
- export type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
10
- /** A portable JSON object. */
11
- export interface JsonObject {
12
- readonly [key: string]: JsonValue;
13
- }
14
- /** Field kinds available in the first Lace content-model DSL. */
15
- export type FieldType = "boolean" | "date" | "datetime" | "media" | "group" | "list" | "number" | "richText" | "select" | "text" | "textarea" | "url";
16
- /** Options common to every field builder. */
17
- export interface CommonFieldOptions<Value> {
18
- readonly defaultValue?: Value;
19
- readonly description?: string;
20
- readonly label?: string;
21
- /**
22
- * Temporary synchronization hint naming the field's former key in a content
23
- * model. Configuration moves it out of the field definition; block fields
24
- * reject it.
25
- */
26
- readonly renamedFrom?: string;
27
- readonly required?: boolean;
28
- }
29
- /** A prompt on controls with an editable empty text surface. */
30
- export interface PlaceholderFieldOptions<Value> extends CommonFieldOptions<Value> {
31
- readonly placeholder?: string;
32
- }
33
- /** Provider restrictions on otherwise ordinary safe URL fields. */
34
- export interface UrlFieldOptions extends PlaceholderFieldOptions<string> {
35
- readonly embedProviders?: readonly EmbedProvider[];
36
- }
37
- /** String-length constraints supported by text and textarea fields. */
38
- export interface StringFieldOptions extends PlaceholderFieldOptions<string> {
39
- readonly maxLength?: number;
40
- readonly minLength?: number;
41
- }
42
- /** Numeric bounds supported by number fields. */
43
- export interface NumberFieldOptions extends PlaceholderFieldOptions<number> {
44
- readonly max?: number;
45
- readonly min?: number;
46
- }
47
- /** Options supported by boolean fields. */
48
- export type BooleanFieldOptions = CommonFieldOptions<boolean>;
49
- /** Options supported by date, datetime, URL, and media fields. */
50
- export type StringValueFieldOptions = CommonFieldOptions<string>;
51
- /** Options supported by a safe Tiptap rich-text field. */
52
- export interface RichTextFieldOptions extends PlaceholderFieldOptions<SafeRichTextDocument> {
53
- }
54
- /** Decorative rectangles in a fixed 12 by 12 logical canvas. */
55
- export interface ChoiceDiagram {
56
- readonly cells: readonly {
57
- readonly x: number;
58
- readonly y: number;
59
- readonly width: number;
60
- readonly height: number;
61
- }[];
62
- }
63
- /** Portable select hints; options remain the source of authored values. */
64
- export interface SelectPresentation {
65
- readonly control: "cards";
66
- readonly choices: readonly {
67
- readonly value: string;
68
- readonly label: string;
69
- readonly description?: string;
70
- readonly diagram?: ChoiceDiagram;
71
- }[];
72
- }
73
- /** Options supported by select fields. */
74
- export interface SelectFieldOptions<Choices extends readonly string[]> extends PlaceholderFieldOptions<NoInfer<Choices[number]>> {
75
- readonly options: Choices;
76
- readonly presentation?: SelectPresentation;
77
- }
78
- type RequiredFrom<Options> = "required" extends keyof Options ? Options extends {
79
- readonly required: infer Required extends boolean;
80
- } ? Required : boolean : false;
81
- type PropertyFrom<Options, Key extends string> = Key extends keyof Options ? Options extends {
82
- readonly [Name in Key]: infer Value;
83
- } ? {
84
- readonly [Name in Key]: Value;
85
- } : Options extends {
86
- readonly [Name in Key]?: infer Value;
87
- } ? {
88
- readonly [Name in Key]?: Value;
89
- } : {} : {};
90
- type DefaultFrom<Options> = PropertyFrom<Options, "defaultValue">;
91
- type LabelAndDescriptionFrom<Options> = PropertyFrom<Options, "label"> & PropertyFrom<Options, "description"> & PropertyFrom<Options, "placeholder">;
92
- type CommonDefinition<Type extends FieldType, Options> = {
93
- readonly required: RequiredFrom<Options>;
94
- readonly type: Type;
95
- } & DefaultFrom<Options> & LabelAndDescriptionFrom<Options>;
96
- type StringConstraintsFrom<Options> = PropertyFrom<Options, "minLength"> & PropertyFrom<Options, "maxLength">;
97
- type NumberConstraintsFrom<Options> = PropertyFrom<Options, "min"> & PropertyFrom<Options, "max">;
98
- /** A text-field descriptor. */
99
- export type TextFieldDefinition<Options extends StringFieldOptions = StringFieldOptions> = CommonDefinition<"text", Options> & StringConstraintsFrom<Options>;
100
- /** A textarea-field descriptor. */
101
- export type TextareaFieldDefinition<Options extends StringFieldOptions = StringFieldOptions> = CommonDefinition<"textarea", Options> & StringConstraintsFrom<Options>;
102
- /** A rich-text-field descriptor. */
103
- export type RichTextFieldDefinition<Options extends RichTextFieldOptions = RichTextFieldOptions> = CommonDefinition<"richText", Options>;
104
- /** A number-field descriptor. */
105
- export type NumberFieldDefinition<Options extends NumberFieldOptions = NumberFieldOptions> = CommonDefinition<"number", Options> & NumberConstraintsFrom<Options>;
106
- /** A boolean-field descriptor. */
107
- export type BooleanFieldDefinition<Options extends BooleanFieldOptions = BooleanFieldOptions> = CommonDefinition<"boolean", Options>;
108
- /** A date-field descriptor. */
109
- export type DateFieldDefinition<Options extends StringValueFieldOptions = StringValueFieldOptions> = CommonDefinition<"date", Options>;
110
- /** A datetime-field descriptor. */
111
- export type DatetimeFieldDefinition<Options extends StringValueFieldOptions = StringValueFieldOptions> = CommonDefinition<"datetime", Options>;
112
- /** A URL-field descriptor. */
113
- export type UrlFieldDefinition<Options extends UrlFieldOptions = UrlFieldOptions> = CommonDefinition<"url", Options> & PropertyFrom<Options, "embedProviders">;
114
- /** A media-field descriptor that stores a media identifier. */
115
- export type MediaFieldDefinition<Options extends StringValueFieldOptions = StringValueFieldOptions> = CommonDefinition<"media", Options>;
116
- /** A select-field descriptor. */
117
- export type SelectFieldDefinition<Choices extends readonly string[] = readonly string[], Options extends SelectFieldOptions<Choices> = SelectFieldOptions<Choices>> = CommonDefinition<"select", Options> & {
118
- readonly options: Choices;
119
- } & PropertyFrom<Options, "presentation">;
120
- /** Ordered presentation of immediate sibling fields; never content data. */
121
- export interface FormLayout<Key extends string = string> {
122
- readonly mode: "sections" | "tabs";
123
- readonly groups: readonly {
124
- readonly key: string;
125
- readonly label: string;
126
- readonly description?: string;
127
- readonly fields: readonly Key[];
128
- }[];
129
- }
130
- /** Validates, detaches and freezes optional sibling layout metadata. */
131
- export declare function normalizeFormLayout<Key extends string>(value: unknown, fields: Readonly<Record<Key, unknown>>, path?: string): FormLayout<Key> | undefined;
132
- /** Sibling field order used by rendering and validation summaries. */
133
- export declare function formFieldKeys(fields: Readonly<Record<string, unknown>>, layout?: FormLayout): readonly string[];
134
- /** A finite group of named child descriptors. */
135
- export interface GroupFieldDefinition {
136
- readonly layout?: FormLayout;
137
- readonly type: "group";
138
- readonly fields: ModelFieldDefinitions;
139
- readonly required: boolean;
140
- readonly label?: string;
141
- readonly description?: string;
142
- readonly defaultValue?: JsonObject;
143
- }
144
- /** A list item cannot itself be a list. */
145
- export type ListItemDefinition = Exclude<FieldDefinition, ListFieldDefinition>;
146
- /** A homogeneous ordered list; omitted bounds mean 0 and 100. */
147
- export interface ListFieldDefinition {
148
- readonly type: "list";
149
- readonly item: ListItemDefinition;
150
- readonly required: boolean;
151
- readonly label?: string;
152
- readonly description?: string;
153
- readonly defaultValue?: readonly JsonValue[];
154
- readonly minItems?: number;
155
- readonly maxItems?: number;
156
- /** Immediate text/textarea/select/URL child used for an item summary. */
157
- readonly itemLabel?: string;
158
- }
159
- /** A draft starting value can omit required group descendants. */
160
- export type DraftFieldValue<Definition extends FieldDefinition> = Definition extends {
161
- readonly type: "group";
162
- readonly fields: infer Fields extends ModelFieldDefinitions;
163
- } ? string extends keyof Fields ? JsonObject : {
164
- readonly [Key in keyof Fields]?: DraftFieldValue<Fields[Key]>;
165
- } : Definition extends {
166
- readonly type: "list";
167
- readonly item: infer Item extends ListItemDefinition;
168
- } ? readonly DraftFieldValue<Item>[] : FieldValue<Definition>;
169
- /** Maximum containers along a descriptor branch. */
170
- export declare const MAX_FIELD_CONTAINER_DEPTH = 6;
171
- /** Maximum directly nested groups. */
172
- export declare const MAX_CONSECUTIVE_GROUPS = 2;
173
- /** Maximum items in any one list. */
174
- export declare const MAX_LIST_ITEMS = 100;
175
- /** Maximum sum of list lengths in a snapshot. */
176
- export declare const MAX_SNAPSHOT_LIST_ITEMS = 500;
177
- /** The discriminated union of all currently supported field descriptors. */
178
- export type FieldDefinition = GroupFieldDefinition | ListFieldDefinition | BooleanFieldDefinition | DateFieldDefinition | DatetimeFieldDefinition | MediaFieldDefinition | NumberFieldDefinition | RichTextFieldDefinition | SelectFieldDefinition | TextareaFieldDefinition | TextFieldDefinition | UrlFieldDefinition;
179
- /** The submitted value type associated with a field descriptor. */
180
- export type FieldValue<Definition extends FieldDefinition> = Definition extends {
181
- readonly type: "boolean";
182
- } ? boolean : Definition extends {
183
- readonly type: "number";
184
- } ? number : Definition extends {
185
- readonly type: "richText";
186
- } ? SafeRichTextDocument : Definition extends {
187
- readonly type: "select";
188
- } ? Definition extends {
189
- readonly options: readonly (infer Choice)[];
190
- } ? Choice : never : Definition extends {
191
- readonly type: "group";
192
- readonly fields: infer Fields extends ModelFieldDefinitions;
193
- } ? string extends keyof Fields ? JsonObject : BlockDataValues<Fields> : Definition extends {
194
- readonly type: "list";
195
- readonly item: infer Item extends ListItemDefinition;
196
- } ? readonly FieldValue<Item>[] : string;
197
- /** Whether a descriptor makes a model property required through `required` or a default. */
198
- export type FieldIsRequired<Definition extends FieldDefinition> = Definition extends {
199
- readonly defaultValue: unknown;
200
- } ? true : Definition extends {
201
- readonly required: true;
202
- } ? true : false;
203
- /** Serializable form metadata has the same safe data shape as a field descriptor. */
204
- export type FieldMetadata = FieldDefinition;
205
- /** Thrown when a field builder receives a non-portable or contradictory option. */
206
- export declare class FieldConfigurationError extends Error {
207
- constructor(message: string);
208
- }
209
- /** Builders for portable Lace field descriptors. */
210
- export declare const field: {
211
- /** Define named child fields stored as one plain object. */
212
- readonly group: <const Options extends {
213
- readonly fields: ModelFieldDefinitions;
214
- }>(options: Options & CommonFieldOptions<NoInfer<{ readonly [Key in keyof Options["fields"]]?: DraftFieldValue<Options["fields"][Key]>; }>> & {
215
- readonly layout?: FormLayout<keyof Options["fields"] & string>;
216
- }) => CommonDefinition<"group", Options> & PropertyFrom<Options, "layout"> & {
217
- readonly fields: Options["fields"];
218
- };
219
- /** Define an ordered array of scalar or group values. */
220
- readonly list: <const Options extends {
221
- readonly item: ListItemDefinition;
222
- readonly minItems?: number;
223
- readonly maxItems?: number;
224
- readonly itemLabel?: string;
225
- }>(options: Options & CommonFieldOptions<NoInfer<readonly DraftFieldValue<Options["item"]>[]>>) => CommonDefinition<"list", Options> & {
226
- readonly item: Options["item"];
227
- } & PropertyFrom<Options, "minItems"> & PropertyFrom<Options, "maxItems"> & PropertyFrom<Options, "itemLabel">;
228
- /** Define a single-line text field. */
229
- readonly text: <const Options extends StringFieldOptions = StringFieldOptions>(options?: Options) => TextFieldDefinition<Options>;
230
- /** Define a multiline text field. */
231
- readonly textarea: <const Options extends StringFieldOptions = StringFieldOptions>(options?: Options) => TextareaFieldDefinition<Options>;
232
- /** Define a safe Tiptap JSON field. */
233
- readonly richText: <const Options extends RichTextFieldOptions = RichTextFieldOptions>(options?: Options) => RichTextFieldDefinition<Options>;
234
- /** Define a finite numeric field. */
235
- readonly number: <const Options extends NumberFieldOptions = NumberFieldOptions>(options?: Options) => NumberFieldDefinition<Options>;
236
- /** Define a boolean field. */
237
- readonly boolean: <const Options extends BooleanFieldOptions = BooleanFieldOptions>(options?: Options) => BooleanFieldDefinition<Options>;
238
- /** Define a date string field. */
239
- readonly date: <const Options extends StringValueFieldOptions = StringValueFieldOptions>(options?: Options) => DateFieldDefinition<Options>;
240
- /** Define a datetime string field. */
241
- readonly datetime: <const Options extends StringValueFieldOptions = StringValueFieldOptions>(options?: Options) => DatetimeFieldDefinition<Options>;
242
- /** Define a select field with a non-empty unique list of string choices. */
243
- readonly select: <const Options extends {
244
- readonly options: readonly [string, ...string[]];
245
- }>(options: Options & SelectFieldOptions<Options["options"]>) => SelectFieldDefinition<Options["options"], Options & SelectFieldOptions<Options["options"]>>;
246
- /** Define a safe URL field, optionally restricted to supported video providers. */
247
- readonly url: <const Options extends UrlFieldOptions = UrlFieldOptions>(options?: Options) => UrlFieldDefinition<Options>;
248
- /** Define a field holding a media identifier. */
249
- readonly media: <const Options extends StringValueFieldOptions = StringValueFieldOptions>(options?: Options) => MediaFieldDefinition<Options>;
250
- };
251
- /**
252
- * Project a field descriptor into a detached, immutable JSON-safe admin form
253
- * representation. Runtime schemas and callbacks are deliberately absent.
254
- */
255
- export declare function toFieldMetadata(definition: FieldDefinition): FieldMetadata;
256
- /** Validates and detaches a descriptor, including forged JSON/configuration input. */
257
- export declare function normalizeFieldDefinition(value: unknown): FieldDefinition;
258
- /** A mark permitted in Lace rich-text documents. */
259
- export type SafeRichTextMark = {
260
- readonly type: "bold" | "code" | "italic" | "strike";
261
- } | {
262
- readonly attrs: {
263
- readonly href: string;
264
- readonly target?: "_blank";
265
- readonly rel?: "nofollow";
266
- };
267
- readonly type: "link";
268
- };
269
- /** A node permitted in Lace rich-text documents. */
270
- export type SafeRichTextNode = {
271
- readonly type: "hardBreak" | "horizontalRule";
272
- } | {
273
- readonly content?: readonly {
274
- readonly text: string;
275
- readonly type: "text";
276
- }[];
277
- readonly type: "codeBlock";
278
- } | {
279
- readonly marks?: readonly SafeRichTextMark[];
280
- readonly text: string;
281
- readonly type: "text";
282
- } | {
283
- readonly content?: readonly SafeRichTextNode[];
284
- readonly type: "paragraph";
285
- } | {
286
- readonly attrs: {
287
- readonly level: 1 | 2 | 3 | 4;
288
- };
289
- readonly content?: readonly SafeRichTextNode[];
290
- readonly type: "heading";
291
- } | {
292
- readonly content: readonly SafeRichTextNode[];
293
- readonly type: "bulletList" | "orderedList";
294
- } | {
295
- readonly content: readonly SafeRichTextNode[];
296
- readonly type: "listItem";
297
- } | {
298
- readonly content: readonly SafeRichTextNode[];
299
- readonly type: "blockquote";
300
- };
301
- /** The closed, safe Tiptap document representation supported by Lace. */
302
- export interface SafeRichTextDocument {
303
- readonly content: readonly SafeRichTextNode[];
304
- readonly type: "doc";
305
- }
306
- /** A stable path segment for validation errors. */
307
- export type ValidationPathSegment = number | string;
308
- /** A portable validation error that callers can associate with form values. */
309
- export interface ContentValidationIssue {
310
- readonly code: string;
311
- readonly message: string;
312
- readonly path: readonly ValidationPathSegment[];
313
- }
314
- /** Thrown when submitted content fails a portable validation contract. */
315
- export declare class ContentValidationError extends Error {
316
- readonly issues: readonly ContentValidationIssue[];
317
- constructor(issues: readonly ContentValidationIssue[]);
318
- }
319
- /** Returns whether a URL is permitted as an href, including rich-text links. */
320
- export declare function isSafeUrl(value: unknown): value is string;
321
- /** Ordinary URL fields support safe manual URLs and canonical entry tokens. */
322
- export declare function isUrlFieldTarget(value: unknown): value is string;
323
- /** Validates and returns a closed, safe rich-text document. */
324
- export declare function validateRichTextDocument(value: unknown): SafeRichTextDocument;
325
- /** A total handler map for every supported field definition. */
326
- export type FieldDefinitionVisitor<Result> = {
327
- readonly [Type in FieldType]: (definition: Extract<FieldDefinition, {
328
- readonly type: Type;
329
- }>) => Result;
330
- };
331
- /** Visits a field descriptor exhaustively. */
332
- export declare function visitFieldDefinition<Result>(definition: FieldDefinition, visitor: FieldDefinitionVisitor<Result>): Result;
333
- /** A Valibot runtime schema compiled from a field definition. */
334
- export type CompiledFieldSchema<Definition extends FieldDefinition> = v.BaseSchema<unknown, FieldValue<Definition>, v.BaseIssue<unknown>>;
335
- /** Compiles a field definition with the same normalization as aggregate validation. */
336
- export declare function compileFieldSchema<Definition extends FieldDefinition>(definition: Definition, mode?: ContentValidationMode): CompiledFieldSchema<Definition>;
337
- /** Validates and normalizes one present value; absence is handled by its field map. */
338
- export declare function validateFieldValue<Definition extends FieldDefinition>(definition: Definition, value: unknown, path?: readonly ValidationPathSegment[], mode?: ContentValidationMode): FieldValue<Definition>;
339
- /** A model field map accepted by the draft and publish validators. */
340
- export type ModelFieldDefinitions = Readonly<Record<string, FieldDefinition>>;
341
- /** Portable normalized values, including incomplete draft groups. */
342
- export type ModelFieldValues = JsonObject;
343
- /** The validation state of a content snapshot. */
344
- export type ContentValidationMode = "draft" | "publish";
345
- /** Validates field data for either an incomplete draft or a publish candidate. */
346
- export declare function validateModelFields(definitions: ModelFieldDefinitions, value: unknown, mode: ContentValidationMode, path?: readonly ValidationPathSegment[]): ModelFieldValues;
347
- /** Checks already normalized model/block values against one snapshot-wide budget. */
348
- export declare function validateSnapshotListBudget(fields: ModelFieldDefinitions, values: JsonObject, blocks: readonly {
349
- readonly fields: ModelFieldDefinitions;
350
- readonly data: JsonObject;
351
- readonly path: readonly ValidationPathSegment[];
352
- }[]): void;
353
- /** A declared media leaf with a typed relative path. */
354
- export interface FieldMediaReference {
355
- readonly mediaId: string;
356
- readonly path: readonly ValidationPathSegment[];
357
- }
358
- /** A declared ordinary URL leaf, relative to its field map. */
359
- export interface FieldInternalLinkReference {
360
- readonly targetId: string;
361
- readonly path: readonly ValidationPathSegment[];
362
- }
363
- /** Discover references only in normalized ordinary URL descriptors. */
364
- export declare function collectFieldInternalLinks(definitions: ModelFieldDefinitions, values: JsonObject): readonly FieldInternalLinkReference[];
365
- /** A source-scoped reference tuple, ready for persistence and public manifests. */
366
- export interface InternalLinkReference {
367
- readonly sourceKey: string;
368
- readonly area: "fields" | "data";
369
- readonly pointer: string;
370
- readonly targetId: string;
371
- readonly delivered: boolean;
372
- }
373
- /** The local manifest location delivered to site consumers. */
374
- export type PublicInternalLinkReference = Omit<InternalLinkReference, "delivered">;
375
- /** Collect and bound every declared internal URL in one normalized snapshot. */
376
- export declare function collectSnapshotInternalLinks(fields: ModelFieldDefinitions, values: JsonObject, blocks: readonly {
377
- readonly key: string;
378
- readonly fields: ModelFieldDefinitions;
379
- readonly data: JsonObject;
380
- readonly hidden?: boolean;
381
- }[]): readonly InternalLinkReference[];
382
- /** Finds declared media leaves only; ordinary strings never become references. */
383
- export declare function collectFieldMedia(definitions: ModelFieldDefinitions, values: JsonObject): readonly FieldMediaReference[];
384
- /**
385
- * Removes one media item from declared media leaves: a matching media value is
386
- * dropped from its object, and a matching element of a list of media is removed
387
- * from the list. Every other value is kept; the input is returned unchanged when
388
- * nothing matches.
389
- */
390
- export declare function detachFieldMedia(definitions: ModelFieldDefinitions, values: JsonObject, mediaId: string): JsonObject;
391
- /** Keeps legacy scalar keys; nested locations are relative JSON Pointers. */
392
- export declare function encodeFieldPath(path: readonly ValidationPathSegment[]): string;
393
- /** Reads a stored reference path; numeric tokens are list indices under the field-key grammar. */
394
- export declare function decodeFieldPath(path: string): readonly ValidationPathSegment[];
395
- /** Maximum length of a block anchor. */
396
- export declare const MAX_BLOCK_ANCHOR_LENGTH = 64;
397
- /** Maximum length of a normalized block class name. */
398
- export declare const MAX_BLOCK_CLASS_NAME_LENGTH = 256;
399
- /** Maximum number of class tokens in a block class name. */
400
- export declare const MAX_BLOCK_CLASS_TOKENS = 16;
401
- /** Maximum length of one block class token. */
402
- export declare const MAX_BLOCK_CLASS_TOKEN_LENGTH = 64;
403
- /** Whether a value is a block anchor: a lowercase letter, then lowercase letters, digits and hyphens. */
404
- export declare function isBlockAnchor(value: unknown): value is string;
405
- /**
406
- * Normalizes a block class name: whitespace-separated class tokens, repeats
407
- * dropped, joined with single spaces. Returns `undefined` for a non-string,
408
- * blank or invalid value.
409
- */
410
- export declare function normalizeBlockClassName(value: unknown): string | undefined;
411
- /** Thrown when a block definition or registry is not portable or internally consistent. */
412
- export declare class BlockConfigurationError extends Error {
413
- constructor(message: string);
414
- }
415
- /** The stored data and settings a block migration step receives. */
416
- export interface BlockMigrationInput {
417
- readonly data: JsonObject;
418
- readonly settings: JsonObject;
419
- }
420
- /** A migration step's result; leaving out `settings` keeps the input settings. */
421
- export interface BlockMigrationOutput {
422
- readonly data: JsonObject;
423
- readonly settings?: JsonObject;
424
- }
425
- /**
426
- * A pure, synchronous step that turns the stored data and settings of the
427
- * previous block version into those of its target version.
428
- */
429
- export type BlockMigration = (block: BlockMigrationInput) => BlockMigrationOutput;
430
- /** Migrations keyed by target version; the keys form one range ending at the block version. */
431
- export type BlockMigrations = Readonly<Record<number, BlockMigration>>;
432
- /** Field types a block setting may use; every setting declares a default. */
433
- export declare const BLOCK_SETTING_FIELD_TYPES: readonly ["boolean", "number", "select", "text"];
434
- /** The settings of a block that declares none. */
435
- export type NoBlockSettings = Readonly<Record<never, FieldDefinition>>;
436
- /** Bounded presentation rules over unconditional sibling select settings. */
437
- export type SettingsVisibility<Key extends string = string> = Readonly<Partial<Record<Key, {
438
- readonly setting: Key;
439
- readonly values: readonly string[];
440
- }>>>;
441
- /** Validates and detaches settings-only visibility metadata. */
442
- export declare function normalizeSettingsVisibility<Key extends string>(value: unknown, settings: Readonly<Record<Key, FieldDefinition>>, path?: string): SettingsVisibility<Key> | undefined;
443
- /** Input accepted by the portable block-definition DSL. */
444
- export interface BlockDefinitionInput<Fields extends ModelFieldDefinitions = ModelFieldDefinitions, Settings extends ModelFieldDefinitions = ModelFieldDefinitions> {
445
- readonly defaultValue?: unknown;
446
- readonly description?: string;
447
- readonly fields: Fields;
448
- readonly layout?: FormLayout<keyof Fields & string>;
449
- readonly settingsLayout?: FormLayout<keyof Settings & string>;
450
- readonly settingsVisibility?: SettingsVisibility<keyof Settings & string>;
451
- readonly label?: string;
452
- /** Data and settings migrations from earlier versions, keyed by target version. */
453
- readonly migrations?: BlockMigrations;
454
- /** Presentational settings: `select`, `boolean`, `number` or `text` fields with defaults. */
455
- readonly settings?: Settings;
456
- readonly type: string;
457
- readonly version: number;
458
- }
459
- /** The data shape inferred from a block's field definitions. */
460
- export type BlockDataValues<Fields extends ModelFieldDefinitions> = Readonly<{
461
- [Key in keyof Fields as FieldIsRequired<Fields[Key]> extends true ? Key : never]: FieldValue<Fields[Key]>;
462
- } & {
463
- readonly [Key in keyof Fields as FieldIsRequired<Fields[Key]> extends true ? never : Key]?: FieldValue<Fields[Key]>;
464
- }>;
465
- /** The settings record of a block; every setting has a default, so every key is present. */
466
- export type BlockSettingsValues<Settings extends ModelFieldDefinitions> = Readonly<{
467
- [Key in keyof Settings]: FieldValue<Settings[Key]>;
468
- }>;
469
- /** A detached JSON-safe representation of a block definition. */
470
- export interface BlockMetadata<Fields extends ModelFieldDefinitions = ModelFieldDefinitions, Settings extends ModelFieldDefinitions = ModelFieldDefinitions> {
471
- readonly defaultValue?: BlockDataValues<Fields>;
472
- readonly description?: string;
473
- readonly fields: Fields;
474
- readonly layout?: FormLayout<keyof Fields & string>;
475
- readonly settingsLayout?: FormLayout<keyof Settings & string>;
476
- readonly settingsVisibility?: SettingsVisibility<keyof Settings & string>;
477
- readonly label?: string;
478
- /** Declared settings; absent when the block declares none. */
479
- readonly settings?: Settings;
480
- readonly type: string;
481
- readonly version: number;
482
- }
483
- /** An executable block definition retained only in the runtime projection. */
484
- export interface BlockDefinition<Fields extends ModelFieldDefinitions = ModelFieldDefinitions, Settings extends ModelFieldDefinitions = ModelFieldDefinitions> extends BlockMetadata<Fields, Settings> {
485
- /** Runtime-only migrations keyed by target version; never part of metadata. */
486
- readonly migrations?: BlockMigrations;
487
- readonly validate: (value: unknown, mode: ContentValidationMode) => BlockDataValues<Fields>;
488
- }
489
- /** Defines a versioned block using only portable field descriptors. */
490
- export declare function defineBlock<const Fields extends ModelFieldDefinitions, const Settings extends ModelFieldDefinitions = NoBlockSettings>(input: BlockDefinitionInput<Fields, Settings>): BlockDefinition<Fields, Settings>;
491
- /** Projects a block definition into detached, JSON-safe metadata. */
492
- export declare function toBlockMetadata(definition: BlockDefinition): BlockMetadata;
493
- /** A registry of the current executable definition for every allowed block type. */
494
- export interface BlockRegistry {
495
- readonly blocks: readonly BlockDefinition[];
496
- readonly get: (type: string) => BlockDefinition | undefined;
497
- }
498
- /** Creates a registry and rejects duplicate current block types. */
499
- export declare function defineBlockRegistry(blocks: readonly BlockDefinition[]): BlockRegistry;
500
- /** Projects a registry to immutable JSON-safe metadata for admin and public clients. */
501
- export declare function toBlockRegistryMetadata(registry: BlockRegistry): readonly BlockMetadata[];
502
- /** Validates one block's field record, applying its whole-record default first. */
503
- export declare function validateBlockData<Fields extends ModelFieldDefinitions>(definition: BlockDefinition<Fields>, value: unknown, mode: ContentValidationMode, path?: readonly ValidationPathSegment[]): BlockDataValues<Fields>;
504
- /**
505
- * Validates a block's settings record against its declared settings, filling
506
- * every default; a block that declares none accepts only `{}`.
507
- */
508
- export declare function validateBlockSettings(definition: Pick<BlockMetadata, "settings">, value: unknown, path?: readonly ValidationPathSegment[]): JsonObject;
509
- /** Why stored block data could not be migrated to the current block version. */
510
- export type BlockMigrationErrorCode = "invalid_result" | "migration_failed" | "missing_step" | "version_ahead";
511
- /** Thrown when stored block data cannot be migrated to its definition's version. */
512
- export declare class BlockMigrationError extends Error {
513
- readonly code: BlockMigrationErrorCode;
514
- readonly blockType: string;
515
- readonly fromVersion: number;
516
- readonly toVersion: number;
517
- /** Target version of the failing step, for failed or invalid steps. */
518
- readonly step?: number | undefined;
519
- constructor(code: BlockMigrationErrorCode, blockType: string, fromVersion: number, toVersion: number, message: string,
520
- /** Target version of the failing step, for failed or invalid steps. */
521
- step?: number | undefined, options?: {
522
- readonly cause?: unknown;
523
- });
524
- }
525
- /**
526
- * Migrates stored block data and settings from `fromVersion` to the
527
- * definition's version by composing its declared migrations in ascending
528
- * order. Each step receives a detached, frozen copy. The result is not
529
- * validated against the definition.
530
- */
531
- export declare function migrateBlockData(definition: BlockDefinition, block: BlockMigrationInput, fromVersion: number): BlockMigrationInput;
532
- /**
533
- * Resolves the alt text of one media usage: a non-blank usage alt (such as the
534
- * `image` block's `alt`), then a non-blank media alt, then an empty string.
535
- */
536
- export declare function effectiveAltText(usageAlt: string | null | undefined, mediaAlt: string | null | undefined): string;
537
- /** Shared presentation rules for the independent scalar list settings. */
538
- export declare function listLayoutSettingsVisibility(): SettingsVisibility<"layoutMode" | "layoutWrap" | "layoutPreset">;
539
- /** Shared scalar settings for one explicitly adopted list, in any block. */
540
- export declare function listLayoutSettings(): {
541
- layoutMode: SelectFieldDefinition<readonly ["flex-row", "flex-column", "grid"], {
542
- readonly options: readonly ["flex-row", "flex-column", "grid"];
543
- readonly required: true;
544
- readonly defaultValue: "grid";
545
- readonly label: "Arrangement";
546
- readonly presentation: {
547
- readonly control: "cards";
548
- readonly choices: readonly [{
549
- readonly value: "flex-row";
550
- readonly label: "Horizontal";
551
- readonly description: "Items flow across rows.";
552
- readonly diagram: ChoiceDiagram;
553
- }, {
554
- readonly value: "flex-column";
555
- readonly label: "Vertical";
556
- readonly description: "Items flow down columns. Wrapping needs a height set in site CSS.";
557
- readonly diagram: ChoiceDiagram;
558
- }, {
559
- readonly value: "grid";
560
- readonly label: "Grid";
561
- readonly description: "Items use the selected grid preset.";
562
- readonly diagram: ChoiceDiagram;
563
- }];
564
- };
565
- } & SelectFieldOptions<readonly ["flex-row", "flex-column", "grid"]>>;
566
- layoutWrap: BooleanFieldDefinition<{
567
- readonly defaultValue: true;
568
- readonly label: "Wrap items";
569
- readonly description: "Applies to horizontal and vertical flex lists. Vertical wrapping requires a height set in site CSS.";
570
- }>;
571
- layoutPreset: SelectFieldDefinition<readonly ["auto", "columns-2", "columns-3", "columns-4", "narrow-wide", "wide-narrow", "featured-first"], {
572
- readonly options: readonly ["auto", "columns-2", "columns-3", "columns-4", "narrow-wide", "wide-narrow", "featured-first"];
573
- readonly required: true;
574
- readonly defaultValue: "auto";
575
- readonly label: "Grid preset";
576
- readonly description: "Applies when Grid is selected. Schematics show composition; your site controls styling.";
577
- readonly presentation: {
578
- readonly control: "cards";
579
- readonly choices: readonly [{
580
- readonly value: "auto";
581
- readonly label: "Auto";
582
- readonly description: "As many equal columns as fit.";
583
- readonly diagram: ChoiceDiagram;
584
- }, {
585
- readonly value: "columns-2";
586
- readonly label: "Two columns";
587
- readonly description: "Two equal columns from 32rem.";
588
- readonly diagram: ChoiceDiagram;
589
- }, {
590
- readonly value: "columns-3";
591
- readonly label: "Three columns";
592
- readonly description: "Two from 32rem, three from 48rem.";
593
- readonly diagram: ChoiceDiagram;
594
- }, {
595
- readonly value: "columns-4";
596
- readonly label: "Four columns";
597
- readonly description: "Two from 32rem, three from 48rem, four from 64rem.";
598
- readonly diagram: ChoiceDiagram;
599
- }, {
600
- readonly value: "narrow-wide";
601
- readonly label: "Narrow + wide";
602
- readonly description: "Alternating 1:2 columns from 32rem.";
603
- readonly diagram: ChoiceDiagram;
604
- }, {
605
- readonly value: "wide-narrow";
606
- readonly label: "Wide + narrow";
607
- readonly description: "Alternating 2:1 columns from 32rem.";
608
- readonly diagram: ChoiceDiagram;
609
- }, {
610
- readonly value: "featured-first";
611
- readonly label: "Featured first";
612
- readonly description: "First item spans two columns from 32rem.";
613
- readonly diagram: ChoiceDiagram;
614
- }];
615
- };
616
- } & SelectFieldOptions<readonly ["auto", "columns-2", "columns-3", "columns-4", "narrow-wide", "wide-narrow", "featured-first"]>>;
617
- };
618
- /** Starter blocks implemented exclusively through the public block and field DSL. */
619
- export declare const builtInBlocks: {
620
- cta: BlockDefinition<{
621
- readonly actionLabel: {
622
- readonly required: true;
623
- readonly type: "text";
624
- };
625
- readonly actionUrl: {
626
- readonly required: true;
627
- readonly type: "url";
628
- };
629
- readonly body: {
630
- readonly required: false;
631
- readonly type: "richText";
632
- };
633
- readonly heading: {
634
- readonly required: true;
635
- readonly type: "text";
636
- };
637
- }, Readonly<Record<never, FieldDefinition>>>;
638
- gallery: BlockDefinition<{
639
- readonly images: {
640
- readonly required: false;
641
- readonly type: "list";
642
- } & {
643
- readonly defaultValue: readonly [];
644
- } & {
645
- readonly label: "Images";
646
- } & {
647
- readonly item: {
648
- readonly required: false;
649
- readonly type: "group";
650
- } & {
651
- readonly fields: {
652
- readonly media: MediaFieldDefinition<{
653
- readonly label: "Image";
654
- readonly required: true;
655
- }>;
656
- readonly alt: TextFieldDefinition<{
657
- readonly description: "Leave empty to use the media item's alt text.";
658
- readonly label: "Alt text";
659
- }>;
660
- readonly caption: TextFieldDefinition<{
661
- readonly description: "Leave empty to use the media item's caption.";
662
- readonly label: "Caption";
663
- }>;
664
- readonly link: UrlFieldDefinition<{
665
- readonly description: "Selecting the image opens this link instead of the full-screen view.";
666
- readonly label: "Link";
667
- }>;
668
- };
669
- };
670
- } & {
671
- readonly minItems: 1;
672
- } & {
673
- readonly maxItems: 50;
674
- } & {
675
- readonly itemLabel: "caption";
676
- };
677
- readonly title: TextFieldDefinition<{
678
- readonly label: "Title";
679
- }>;
680
- }, {
681
- readonly layoutMode: SelectFieldDefinition<readonly ["flex-row", "flex-column", "grid"], {
682
- readonly options: readonly ["flex-row", "flex-column", "grid"];
683
- readonly required: true;
684
- readonly defaultValue: "grid";
685
- readonly label: "Arrangement";
686
- readonly presentation: {
687
- readonly control: "cards";
688
- readonly choices: readonly [{
689
- readonly value: "flex-row";
690
- readonly label: "Horizontal";
691
- readonly description: "Items flow across rows.";
692
- readonly diagram: ChoiceDiagram;
693
- }, {
694
- readonly value: "flex-column";
695
- readonly label: "Vertical";
696
- readonly description: "Items flow down columns. Wrapping needs a height set in site CSS.";
697
- readonly diagram: ChoiceDiagram;
698
- }, {
699
- readonly value: "grid";
700
- readonly label: "Grid";
701
- readonly description: "Items use the selected grid preset.";
702
- readonly diagram: ChoiceDiagram;
703
- }];
704
- };
705
- } & SelectFieldOptions<readonly ["flex-row", "flex-column", "grid"]>>;
706
- readonly layoutWrap: BooleanFieldDefinition<{
707
- readonly defaultValue: true;
708
- readonly label: "Wrap items";
709
- readonly description: "Applies to horizontal and vertical flex lists. Vertical wrapping requires a height set in site CSS.";
710
- }>;
711
- readonly layoutPreset: SelectFieldDefinition<readonly ["auto", "columns-2", "columns-3", "columns-4", "narrow-wide", "wide-narrow", "featured-first"], {
712
- readonly options: readonly ["auto", "columns-2", "columns-3", "columns-4", "narrow-wide", "wide-narrow", "featured-first"];
713
- readonly required: true;
714
- readonly defaultValue: "auto";
715
- readonly label: "Grid preset";
716
- readonly description: "Applies when Grid is selected. Schematics show composition; your site controls styling.";
717
- readonly presentation: {
718
- readonly control: "cards";
719
- readonly choices: readonly [{
720
- readonly value: "auto";
721
- readonly label: "Auto";
722
- readonly description: "As many equal columns as fit.";
723
- readonly diagram: ChoiceDiagram;
724
- }, {
725
- readonly value: "columns-2";
726
- readonly label: "Two columns";
727
- readonly description: "Two equal columns from 32rem.";
728
- readonly diagram: ChoiceDiagram;
729
- }, {
730
- readonly value: "columns-3";
731
- readonly label: "Three columns";
732
- readonly description: "Two from 32rem, three from 48rem.";
733
- readonly diagram: ChoiceDiagram;
734
- }, {
735
- readonly value: "columns-4";
736
- readonly label: "Four columns";
737
- readonly description: "Two from 32rem, three from 48rem, four from 64rem.";
738
- readonly diagram: ChoiceDiagram;
739
- }, {
740
- readonly value: "narrow-wide";
741
- readonly label: "Narrow + wide";
742
- readonly description: "Alternating 1:2 columns from 32rem.";
743
- readonly diagram: ChoiceDiagram;
744
- }, {
745
- readonly value: "wide-narrow";
746
- readonly label: "Wide + narrow";
747
- readonly description: "Alternating 2:1 columns from 32rem.";
748
- readonly diagram: ChoiceDiagram;
749
- }, {
750
- readonly value: "featured-first";
751
- readonly label: "Featured first";
752
- readonly description: "First item spans two columns from 32rem.";
753
- readonly diagram: ChoiceDiagram;
754
- }];
755
- };
756
- } & SelectFieldOptions<readonly ["auto", "columns-2", "columns-3", "columns-4", "narrow-wide", "wide-narrow", "featured-first"]>>;
757
- readonly lightbox: BooleanFieldDefinition<{
758
- readonly defaultValue: false;
759
- readonly description: "Opens the original image full screen when it is selected.";
760
- readonly label: "Open full screen";
761
- }>;
762
- }>;
763
- hero: BlockDefinition<{
764
- readonly body: {
765
- readonly required: false;
766
- readonly type: "richText";
767
- };
768
- readonly eyebrow: {
769
- readonly required: false;
770
- readonly type: "text";
771
- };
772
- readonly heading: {
773
- readonly required: true;
774
- readonly type: "text";
775
- };
776
- readonly image: {
777
- readonly required: false;
778
- readonly type: "media";
779
- };
780
- readonly primaryActionLabel: {
781
- readonly required: false;
782
- readonly type: "text";
783
- };
784
- readonly primaryActionUrl: {
785
- readonly required: false;
786
- readonly type: "url";
787
- };
788
- }, Readonly<Record<never, FieldDefinition>>>;
789
- image: BlockDefinition<{
790
- readonly media: {
791
- readonly required: true;
792
- readonly type: "media";
793
- };
794
- readonly alt: {
795
- readonly required: false;
796
- readonly type: "text";
797
- };
798
- readonly caption: {
799
- readonly required: false;
800
- readonly type: "text";
801
- };
802
- readonly link: UrlFieldDefinition<{
803
- readonly description: "Selecting the image opens this link instead of the full-screen view.";
804
- readonly label: "Link";
805
- }>;
806
- }, {
807
- readonly lightbox: BooleanFieldDefinition<{
808
- readonly defaultValue: false;
809
- readonly description: "Opens the original image full screen when it is selected.";
810
- readonly label: "Open full screen";
811
- }>;
812
- }>;
813
- link: BlockDefinition<{
814
- readonly label: TextFieldDefinition<{
815
- readonly label: "Label";
816
- readonly minLength: 1;
817
- readonly maxLength: 200;
818
- readonly required: true;
819
- }>;
820
- readonly url: UrlFieldDefinition<{
821
- readonly label: "Destination";
822
- readonly required: true;
823
- }>;
824
- }, {
825
- readonly appearance: SelectFieldDefinition<readonly ["button", "text"], {
826
- readonly label: "Appearance";
827
- readonly options: readonly ["button", "text"];
828
- readonly defaultValue: "button";
829
- readonly required: true;
830
- } & SelectFieldOptions<readonly ["button", "text"]>>;
831
- readonly newTab: BooleanFieldDefinition<{
832
- readonly label: "Open in new tab";
833
- readonly defaultValue: false;
834
- readonly required: true;
835
- }>;
836
- }>;
837
- navigation: BlockDefinition<{
838
- readonly links: {
839
- readonly required: false;
840
- readonly type: "list";
841
- } & {
842
- readonly defaultValue: readonly [];
843
- } & {
844
- readonly label: "Links";
845
- } & {
846
- readonly item: {
847
- readonly required: false;
848
- readonly type: "group";
849
- } & {
850
- readonly fields: {
851
- readonly children: {
852
- readonly required: false;
853
- readonly type: "list";
854
- } & {
855
- readonly label: "Submenu links";
856
- } & {
857
- readonly item: {
858
- readonly required: false;
859
- readonly type: "group";
860
- } & {
861
- readonly fields: {
862
- readonly label: TextFieldDefinition<{
863
- readonly label: "Label";
864
- readonly required: true;
865
- }>;
866
- readonly url: UrlFieldDefinition<{
867
- readonly label: "URL";
868
- readonly required: true;
869
- }>;
870
- };
871
- };
872
- } & {
873
- readonly maxItems: 20;
874
- } & {
875
- readonly itemLabel: "label";
876
- };
877
- readonly label: TextFieldDefinition<{
878
- readonly label: "Label";
879
- readonly required: true;
880
- }>;
881
- readonly url: UrlFieldDefinition<{
882
- readonly description: "Optional when the link has submenu links.";
883
- readonly label: "URL";
884
- }>;
885
- };
886
- };
887
- } & {
888
- readonly minItems: 1;
889
- } & {
890
- readonly maxItems: 20;
891
- } & {
892
- readonly itemLabel: "label";
893
- };
894
- readonly name: TextFieldDefinition<{
895
- readonly description: "Read by screen readers, for example Main or On this page.";
896
- readonly label: "Navigation name";
897
- }>;
898
- }, Readonly<Record<never, FieldDefinition>>>;
899
- quote: BlockDefinition<{
900
- readonly attribution: {
901
- readonly required: false;
902
- readonly type: "text";
903
- };
904
- readonly quote: {
905
- readonly required: true;
906
- readonly type: "text";
907
- };
908
- }, Readonly<Record<never, FieldDefinition>>>;
909
- richText: BlockDefinition<{
910
- readonly content: {
911
- readonly required: true;
912
- readonly type: "richText";
913
- };
914
- }, Readonly<Record<never, FieldDefinition>>>;
915
- videoEmbed: BlockDefinition<{
916
- readonly url: UrlFieldDefinition<{
917
- readonly required: true;
918
- readonly embedProviders: readonly ["youtube", "vimeo"];
919
- readonly label: "Video URL";
920
- readonly description: "Paste a YouTube or Vimeo video link, not iframe code.";
921
- }>;
922
- readonly title: TextFieldDefinition<{
923
- readonly required: true;
924
- readonly minLength: 1;
925
- readonly label: "Title";
926
- readonly description: "Names the video for visitors using assistive technology.";
927
- }>;
928
- readonly poster: MediaFieldDefinition<{
929
- readonly label: "Preview image";
930
- readonly description: "Optional. Load the video player only when a visitor selects this preview.";
931
- }>;
932
- readonly caption: TextFieldDefinition<{
933
- readonly label: "Caption";
934
- }>;
935
- }, Readonly<Record<never, FieldDefinition>>>;
936
- };
937
- /** Maximum title length shared by draft, publish, REST, and admin validation. */
938
- export declare const MAX_TITLE_LENGTH = 200;
939
- /** Maximum slug length shared by publish, REST, and admin validation. */
940
- export declare const MAX_SLUG_LENGTH = 100;
941
- /** Maximum flat top-level block count for one entry. */
942
- export declare const MAX_TOP_LEVEL_BLOCKS = 200;
943
- /** Maximum UTF-8 bytes in fields JSON or a single block data JSON value. */
944
- export declare const MAX_JSON_BYTES = 1000000;
945
- /** Model kinds: routed singletons, routed lists, and route-less singletons. */
946
- export type ContentModelKind = "collection" | "global" | "page";
947
- /** A block-like value whose data can be limited before the Step 3 block registry exists. */
948
- export interface EntryBlockData {
949
- readonly data: JsonValue;
950
- }
951
- /** System data validated alongside a model field record. */
952
- export interface EntryPayloadInput {
953
- readonly blocks: readonly EntryBlockData[];
954
- readonly fields: JsonObject;
955
- readonly kind: ContentModelKind;
956
- readonly slug?: string;
957
- readonly title: string;
958
- }
959
- /** Returns canonical JSON with recursively sorted object keys. */
960
- export declare function canonicalizeJson(value: JsonValue): string;
961
- /** Gets the UTF-8 byte count of portable JSON through canonical serialization. */
962
- export declare function canonicalJsonByteLength(value: JsonValue): number;
963
- /** Minimal portable shape used by the SHA-256 helper. */
964
- export interface WebCryptoLike {
965
- readonly subtle: {
966
- digest(algorithm: "SHA-256", data: Uint8Array): Promise<ArrayBuffer>;
967
- };
968
- }
969
- /** Hashes canonical JSON UTF-8 bytes with Web Crypto SHA-256 as lowercase hexadecimal. */
970
- export declare function sha256CanonicalJson(value: JsonValue, webCrypto?: WebCryptoLike): Promise<string>;
971
- /** Validates system entry data and shared payload limits for a draft or publish candidate. */
972
- export declare function validateEntryPayload(input: EntryPayloadInput, mode: ContentValidationMode): EntryPayloadInput;
973
- /** Model information required to validate a complete entry aggregate. */
974
- export interface EntryAggregateModel {
975
- readonly blocks: readonly string[];
976
- readonly fields: ModelFieldDefinitions;
977
- readonly kind: ContentModelKind;
978
- }
979
- /** One ordered, typed block submitted as part of an entry aggregate. */
980
- export interface EntryAggregateBlock {
981
- readonly anchor?: string;
982
- readonly className?: string;
983
- readonly data: JsonObject;
984
- readonly hidden?: boolean;
985
- readonly key: string;
986
- readonly schemaVersion: number;
987
- readonly settings?: JsonObject;
988
- readonly type: string;
989
- }
990
- /** A validated block: normalized data, settings with defaults, and the envelope. */
991
- export interface ValidatedEntryAggregateBlock {
992
- readonly anchor?: string;
993
- readonly className?: string;
994
- readonly data: ModelFieldValues;
995
- readonly hidden: boolean;
996
- readonly key: string;
997
- readonly schemaVersion: number;
998
- readonly settings: JsonObject;
999
- readonly type: string;
1000
- }
1001
- /** A full draft or publish candidate validated against a model and its registry. */
1002
- export interface EntryAggregateInput {
1003
- readonly blocks: readonly EntryAggregateBlock[];
1004
- readonly fields: JsonObject;
1005
- readonly kind: ContentModelKind;
1006
- readonly slug?: string;
1007
- readonly title: string;
1008
- }
1009
- /** The normalized form of a valid entry aggregate. */
1010
- export interface ValidatedEntryAggregate {
1011
- readonly blocks: readonly ValidatedEntryAggregateBlock[];
1012
- readonly fields: ModelFieldValues;
1013
- readonly kind: ContentModelKind;
1014
- readonly slug?: string;
1015
- readonly title: string;
1016
- }
1017
- /** Validates all system, model-field, and ordered block data for one content entry. */
1018
- export declare function validateEntryAggregate(input: EntryAggregateInput, model: EntryAggregateModel, registry: BlockRegistry, mode: ContentValidationMode): ValidatedEntryAggregate;
1019
- export { parseSchemaPath, encodeSchemaPath, schemaFieldAt } from "./schema-path.js";
1020
- /** Raw UTF-16 units: the existing text/textarea length contract, without trimming. */
1021
- export declare function textLength(value: string): number;
1022
- /** Trimmed Unicode code points: the existing SEO title/description contract. */
1023
- export declare function seoTextLength(value: string): number;
1
+ export { LaceError, InvariantError } from "./shared/errors.js";
2
+ export * from "./shared/objects.js";
3
+ export * from "./shared/identifiers.js";
4
+ export type { ValidationPathSegment, ContentValidationIssue } from "./shared/errors.js";
5
+ export { FieldConfigurationError, ContentValidationError } from "./shared/errors.js";
6
+ export type { JsonPrimitive, JsonValue, JsonObject } from "./shared/json.js";
7
+ export { isPortableJsonValue } from "./shared/json.js";
8
+ export * from "./fields/video-embeds.js";
9
+ export * from "./fields/internal-link-tokens.js";
10
+ export { parseSchemaPath, encodeSchemaPath, schemaFieldAt } from "./fields/schema-path.js";
11
+ export type { FieldType, FieldSortFamily, FieldFilterKind, FieldValueKind, FieldTypeCapability, ListQueryableFieldType, SearchableFieldType, SeoTextFieldType, ItemLabelFieldType, PlaceholderFieldType, } from "./fields/capabilities.js";
12
+ export { fieldTypeCapabilities, FIELD_FILTER_OPERATIONS, fieldTypesWith, } from "./fields/capabilities.js";
13
+ export type { FieldFilterValueFailure, FieldFilterValueOptions } from "./fields/filter-values.js";
14
+ export { FIELD_PRESENCE_OPERATIONS, MAX_FILTER_SELECT_VALUES, MAX_FILTER_TEXT_LENGTH, fieldFilterValueFailure, filterInstant, } from "./fields/filter-values.js";
15
+ export type { SafeRichTextMark, SafeRichTextNode, SafeRichTextDocument, } from "./fields/rich-text.js";
16
+ export { isSafeUrl, isUrlFieldTarget, validateRichTextDocument } from "./fields/rich-text.js";
17
+ export type { CommonFieldOptions, PlaceholderFieldOptions, UrlFieldOptions, StringFieldOptions, NumberFieldOptions, BooleanFieldOptions, StringValueFieldOptions, RichTextFieldOptions, ChoiceDiagram, SelectPresentation, SelectFieldOptions, TextFieldDefinition, TextareaFieldDefinition, RichTextFieldDefinition, NumberFieldDefinition, BooleanFieldDefinition, DateFieldDefinition, DatetimeFieldDefinition, UrlFieldDefinition, MediaFieldDefinition, SelectFieldDefinition, FormLayout, FieldVisibilityRule, FieldVisibility, GroupFieldDefinition, ListItemDefinition, ListFieldDefinition, DraftFieldValue, FieldDefinition, FieldValue, FieldIsRequired, FieldMetadata, FieldDefinitionVisitor, ModelFieldDefinitions, ModelFieldValues, FieldVisibilityTargets, BlockDataValues, } from "./fields/definitions.js";
18
+ export { FIELD_KEY_PATTERN, FIELD_KEY_SOURCE, MAX_FIELD_CONTAINER_DEPTH, MAX_CONSECUTIVE_GROUPS, MAX_LIST_ITEMS, MAX_SNAPSHOT_LIST_ITEMS, visitFieldDefinition, } from "./fields/definitions.js";
19
+ export { normalizeFormLayout, formFieldKeys } from "./fields/layout.js";
20
+ export { normalizeFieldVisibility, effectiveVisibilityValues, isFieldVisible, } from "./fields/visibility.js";
21
+ export type { CompiledFieldSchema, ContentValidationMode } from "./fields/validation.js";
22
+ export { compileFieldSchema, validateFieldValue, validateModelFields, publishedFieldValues, declaresFieldVisibility, validateSnapshotListBudget, textLength, seoTextLength, } from "./fields/validation.js";
23
+ export { field } from "./fields/builders.js";
24
+ export { toFieldMetadata } from "./fields/metadata.js";
25
+ export { normalizeFieldDefinition } from "./fields/normalization.js";
26
+ export { encodeFieldPath, decodeFieldPath } from "./references/field-paths.js";
27
+ export type { FieldMediaReference } from "./references/media.js";
28
+ export { collectFieldMedia, detachFieldMedia, effectiveAltText } from "./references/media.js";
29
+ export type { FieldInternalLinkReference, InternalLinkReference, PublicInternalLinkReference, } from "./references/internal-links.js";
30
+ export { collectFieldInternalLinks, collectSnapshotInternalLinks, } from "./references/internal-links.js";
31
+ export type { BlockMigrationInput, BlockMigrationOutput, BlockMigration, BlockMigrations, NoBlockSettings, SettingsVisibility, BlockDefinitionInput, BlockSettingsValues, BlockMetadata, BlockDefinition, BlockRegistry, } from "./blocks/types.js";
32
+ export type { BlockMigrationErrorCode } from "./blocks/migration.js";
33
+ export { BLOCK_TYPE_PATTERN, BLOCK_TYPE_SOURCE, MAX_BLOCK_ANCHOR_LENGTH, MAX_BLOCK_CLASS_NAME_LENGTH, MAX_BLOCK_CLASS_TOKENS, MAX_BLOCK_CLASS_TOKEN_LENGTH, isBlockAnchor, normalizeBlockClassName, } from "./blocks/grammar.js";
34
+ export { publishedBlockData, defineBlock, toBlockMetadata, validateBlockData, validateBlockSettings, } from "./blocks/definition.js";
35
+ export { BlockConfigurationError } from "./blocks/errors.js";
36
+ export { BLOCK_SETTING_FIELD_TYPES, normalizeSettingsVisibility } from "./blocks/settings.js";
37
+ export { defineBlockRegistry, toBlockRegistryMetadata } from "./blocks/registry.js";
38
+ export { BlockMigrationError, migrateBlockData } from "./blocks/migration.js";
39
+ export { listLayoutSettingsVisibility, listLayoutSettings } from "./blocks/list-layout.js";
40
+ export { builtInBlocks } from "./blocks/built-ins.js";
41
+ export * from "./entries/list-query-policy.js";
42
+ export type { WebCryptoLike } from "./entries/canonical-json.js";
43
+ export { canonicalizeJson, canonicalJsonByteLength, sha256CanonicalJson, } from "./entries/canonical-json.js";
44
+ export type { EntryBlockData, EntryPayloadInput, EntryAggregateModel, EntryAggregateBlock, ValidatedEntryAggregateBlock, EntryAggregateInput, ValidatedEntryAggregate, } from "./entries/aggregate.js";
45
+ export { MAX_TITLE_LENGTH, MAX_TOP_LEVEL_BLOCKS, MAX_DRAFT_MEDIA_REFERENCES, MAX_JSON_BYTES, validateEntryPayload, validateEntryAggregate, } from "./entries/aggregate.js";
1024
46
  //# sourceMappingURL=index.d.ts.map