@cogenta/blocks 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/action.d.ts +35 -0
  2. package/dist/action.d.ts.map +1 -0
  3. package/dist/action.js +24 -0
  4. package/dist/action.js.map +1 -0
  5. package/dist/define-block.d.ts +12 -0
  6. package/dist/define-block.d.ts.map +1 -0
  7. package/dist/define-block.js +59 -0
  8. package/dist/define-block.js.map +1 -0
  9. package/dist/errors.d.ts +14 -0
  10. package/dist/errors.d.ts.map +1 -0
  11. package/dist/errors.js +52 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/field.d.ts +165 -0
  14. package/dist/field.d.ts.map +1 -0
  15. package/dist/field.js +156 -0
  16. package/dist/field.js.map +1 -0
  17. package/dist/index.d.ts +13 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +13 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/migrate.d.ts +64 -0
  22. package/dist/migrate.d.ts.map +1 -0
  23. package/dist/migrate.js +113 -0
  24. package/dist/migrate.js.map +1 -0
  25. package/dist/plain-text.d.ts +13 -0
  26. package/dist/plain-text.d.ts.map +1 -0
  27. package/dist/plain-text.js +23 -0
  28. package/dist/plain-text.js.map +1 -0
  29. package/dist/registry.d.ts +33 -0
  30. package/dist/registry.d.ts.map +1 -0
  31. package/dist/registry.js +73 -0
  32. package/dist/registry.js.map +1 -0
  33. package/dist/rich-text.d.ts +67 -0
  34. package/dist/rich-text.d.ts.map +1 -0
  35. package/dist/rich-text.js +60 -0
  36. package/dist/rich-text.js.map +1 -0
  37. package/dist/types.d.ts +75 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/types.js +13 -0
  40. package/dist/types.js.map +1 -0
  41. package/dist/validate.d.ts +40 -0
  42. package/dist/validate.d.ts.map +1 -0
  43. package/dist/validate.js +108 -0
  44. package/dist/validate.js.map +1 -0
  45. package/dist/version.d.ts +11 -0
  46. package/dist/version.d.ts.map +1 -0
  47. package/dist/version.js +23 -0
  48. package/dist/version.js.map +1 -0
  49. package/dist/vocabulary.d.ts +472 -0
  50. package/dist/vocabulary.d.ts.map +1 -0
  51. package/dist/vocabulary.js +309 -0
  52. package/dist/vocabulary.js.map +1 -0
  53. package/package.json +44 -0
@@ -0,0 +1,108 @@
1
+ import { isCogentaError } from '@cogenta/core';
2
+ import { z } from 'zod';
3
+ import { invalidBlock } from './errors.js';
4
+ import { vocabularyRegistry } from './registry.js';
5
+ /**
6
+ * Validation at write time (spec L1, "Blocs").
7
+ *
8
+ * A block is checked before it is stored, never on the way out. Bad data that
9
+ * reaches the database has already been copied into a version, a translation
10
+ * and a search index by the time a renderer notices.
11
+ */
12
+ /** Just enough to know whose rules to apply, and which block to name in an error. */
13
+ const envelopeSchema = z.object({
14
+ _key: z.string().min(1),
15
+ _type: z.string().min(1),
16
+ _version: z.string().min(1),
17
+ });
18
+ function readType(input) {
19
+ if (typeof input !== 'object' || input === null)
20
+ return undefined;
21
+ const type = input._type;
22
+ return typeof type === 'string' ? type : undefined;
23
+ }
24
+ function readKey(input) {
25
+ if (typeof input !== 'object' || input === null)
26
+ return undefined;
27
+ const key = input._key;
28
+ return typeof key === 'string' ? key : undefined;
29
+ }
30
+ /** Runs one definition's validator, or throws an error naming block and field. */
31
+ function check(definition, input) {
32
+ const result = definition.validator.safeParse(input);
33
+ if (!result.success)
34
+ throw invalidBlock(definition.name, readKey(input), result.error);
35
+ return result.data;
36
+ }
37
+ /**
38
+ * Validates against one known definition, keeping the block's precise type.
39
+ *
40
+ * The assertion is the counterpart of the one in `defineBlock`: the validator
41
+ * was built from `definition.schema`, so what it returns is exactly the data
42
+ * that schema describes — a fact the compiler cannot re-derive here.
43
+ */
44
+ export function parseBlockWith(definition, input) {
45
+ return check(definition, input);
46
+ }
47
+ /** Stamps the envelope on freshly authored data, so `_version` is never guessed. */
48
+ export function createBlock(definition, key, data) {
49
+ return parseBlockWith(definition, {
50
+ ...data,
51
+ _key: key,
52
+ _type: definition.name,
53
+ _version: definition.version,
54
+ });
55
+ }
56
+ /**
57
+ * Validates one block, looking its definition up by `_type`.
58
+ *
59
+ * Throws a `CogentaError` naming the block and the offending field. An unknown
60
+ * `_type` is a `BLOCK_UNKNOWN`, not a validation failure: the fix is to
61
+ * register the block, not to edit the content.
62
+ */
63
+ export function parseBlock(input, registry = vocabularyRegistry) {
64
+ const envelope = envelopeSchema.safeParse(input);
65
+ if (!envelope.success) {
66
+ throw invalidBlock(readType(input) ?? '(unnamed)', readKey(input), envelope.error);
67
+ }
68
+ const definition = registry.mustGet(envelope.data._type);
69
+ return check(definition, input);
70
+ }
71
+ /** For an admin that would rather show the problem than crash on it. */
72
+ export function safeParseBlock(input, registry = vocabularyRegistry) {
73
+ try {
74
+ return { ok: true, block: parseBlock(input, registry) };
75
+ }
76
+ catch (error) {
77
+ // Only CogentaError is thrown above; anything else is a bug worth surfacing.
78
+ if (isCogentaError(error))
79
+ return { ok: false, error };
80
+ throw error;
81
+ }
82
+ }
83
+ /**
84
+ * Validates a whole block zone, and refuses duplicate `_key`s.
85
+ *
86
+ * A repeated key is not cosmetic: comments, diffs and the RAG index are all
87
+ * addressed by key, so two blocks sharing one silently merge in every one of
88
+ * those views.
89
+ */
90
+ export function parseBlocks(inputs, registry = vocabularyRegistry) {
91
+ const blocks = inputs.map((input) => parseBlock(input, registry));
92
+ const seen = new Set();
93
+ for (const block of blocks) {
94
+ if (seen.has(block._key)) {
95
+ throw invalidBlock(block._type, block._key, new z.ZodError([
96
+ {
97
+ code: 'custom',
98
+ path: ['_key'],
99
+ message: `duplicate block key "${block._key}" in the same zone`,
100
+ input: block._key,
101
+ },
102
+ ]));
103
+ }
104
+ seen.add(block._key);
105
+ }
106
+ return blocks;
107
+ }
108
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAq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CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,6EAA6E;QAC7E,IAAI,cAAc,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;QACtD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,MAA0B,EAC1B,QAAQ,GAAkB,kBAAkB;IAE5C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;IACjE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,YAAY,CAChB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,IAAI,EACV,IAAI,CAAC,CAAC,QAAQ,CAAC;gBACb;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MAAM,CAAC;oBACd,OAAO,EAAE,wBAAwB,KAAK,CAAC,IAAI,oBAAoB;oBAC/D,KAAK,EAAE,KAAK,CAAC,IAAI;iBAClB;aACF,CAAC,CACH,CAAA;QACH,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The three-number subset of semver a block version uses.
3
+ *
4
+ * Written here rather than pulled in: a comparison of three integers does not
5
+ * justify a dependency (rule R9), and block versions are produced by this
6
+ * project only, so pre-release and build metadata never appear.
7
+ */
8
+ export declare function isBlockVersion(value: string): boolean;
9
+ /** `-1`, `0` or `1`. Throws nothing: callers validate the strings first. */
10
+ export declare function compareBlockVersions(a: string, b: string): number;
11
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAQjE"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The three-number subset of semver a block version uses.
3
+ *
4
+ * Written here rather than pulled in: a comparison of three integers does not
5
+ * justify a dependency (rule R9), and block versions are produced by this
6
+ * project only, so pre-release and build metadata never appear.
7
+ */
8
+ const VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
9
+ export function isBlockVersion(value) {
10
+ return VERSION.test(value);
11
+ }
12
+ /** `-1`, `0` or `1`. Throws nothing: callers validate the strings first. */
13
+ export function compareBlockVersions(a, b) {
14
+ const left = a.split('.');
15
+ const right = b.split('.');
16
+ for (let i = 0; i < 3; i += 1) {
17
+ const diff = Number(left[i] ?? 0) - Number(right[i] ?? 0);
18
+ if (diff !== 0)
19
+ return diff < 0 ? -1 : 1;
20
+ }
21
+ return 0;
22
+ }
23
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,GAAG,4CAA4C,CAAA;AAE5D,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC5B,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,oBAAoB,CAAC,CAAS,EAAE,CAAS;IACvD,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACzB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;QACzD,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC"}
@@ -0,0 +1,472 @@
1
+ import { z } from 'zod';
2
+ import type { BlockValue } from './types.js';
3
+ export declare const heroBlock: import("./types.js").BlockDefinition<"hero", {
4
+ /** The short line above the title. Semantic, not decorative: it says what kind of page this is. */
5
+ readonly eyebrow: import("./field.js").BlockField<"text", string, false>;
6
+ readonly title: import("./field.js").BlockField<"text", string, true>;
7
+ readonly subtitle: import("./field.js").BlockField<"text", string, false>;
8
+ readonly media: import("./field.js").BlockField<"media", string, false>;
9
+ readonly actions: import("./field.js").BlockField<"json", {
10
+ label: string;
11
+ target: {
12
+ href: string;
13
+ } | {
14
+ collection: string;
15
+ id: string;
16
+ };
17
+ emphasis?: "primary" | "secondary" | undefined;
18
+ }[], false>;
19
+ }>;
20
+ export declare const proseBlock: import("./types.js").BlockDefinition<"prose", {
21
+ readonly body: import("./field.js").BlockField<"richText", ({
22
+ _key: string;
23
+ _type: "block";
24
+ style: "blockquote" | "h2" | "h3" | "h4" | "normal";
25
+ listItem?: "bullet" | "number" | undefined;
26
+ level?: number | undefined;
27
+ children: {
28
+ _key: string;
29
+ _type: "span";
30
+ text: string;
31
+ marks: string[];
32
+ }[];
33
+ markDefs: ({
34
+ _key: string;
35
+ _type: "link";
36
+ href: string;
37
+ rel?: string | undefined;
38
+ } | {
39
+ _key: string;
40
+ _type: "internalLink";
41
+ collection: string;
42
+ id: string;
43
+ })[];
44
+ } | {
45
+ _key: string;
46
+ _type: "media";
47
+ id: string;
48
+ caption?: string | undefined;
49
+ })[], true>;
50
+ }>;
51
+ export declare const mediaFigureBlock: import("./types.js").BlockDefinition<"mediaFigure", {
52
+ readonly media: import("./field.js").BlockField<"media", string, true>;
53
+ readonly caption: import("./field.js").BlockField<"text", string, false>;
54
+ readonly credit: import("./field.js").BlockField<"text", string, false>;
55
+ readonly ratio: import("./field.js").BlockField<"select", "16:9" | "1:1" | "21:9" | "3:2" | "4:3" | "original", false>;
56
+ /**
57
+ * `start` and `end` rather than `left` and `right`: the contract's intent is
58
+ * where the figure sits in the reading flow, which mirrors in right-to-left
59
+ * locales. `left` would be a layout instruction the theme cannot honour.
60
+ */
61
+ readonly align: import("./field.js").BlockField<"select", "center" | "end" | "full" | "start" | "wide", false>;
62
+ }>;
63
+ /** `icon` names a symbol the theme's icon set resolves. It is never markup. */
64
+ declare const featureItemSchema: z.ZodObject<{
65
+ _key: z.ZodString;
66
+ icon: z.ZodOptional<z.ZodString>;
67
+ title: z.ZodString;
68
+ text: z.ZodOptional<z.ZodString>;
69
+ link: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
70
+ href: z.ZodString;
71
+ }, z.core.$strict>, z.ZodObject<{
72
+ collection: z.ZodString;
73
+ id: z.ZodString;
74
+ }, z.core.$strict>]>>;
75
+ }, z.core.$strict>;
76
+ export type FeatureItem = z.infer<typeof featureItemSchema>;
77
+ export declare const featureGridBlock: import("./types.js").BlockDefinition<"featureGrid", {
78
+ readonly title: import("./field.js").BlockField<"text", string, false>;
79
+ readonly items: import("./field.js").BlockField<"json", {
80
+ _key: string;
81
+ icon?: string | undefined;
82
+ title: string;
83
+ text?: string | undefined;
84
+ link?: {
85
+ href: string;
86
+ } | {
87
+ collection: string;
88
+ id: string;
89
+ } | undefined;
90
+ }[], true>;
91
+ }>;
92
+ export declare const ctaBlock: import("./types.js").BlockDefinition<"cta", {
93
+ readonly title: import("./field.js").BlockField<"text", string, true>;
94
+ readonly text: import("./field.js").BlockField<"text", string, false>;
95
+ readonly actions: import("./field.js").BlockField<"json", {
96
+ label: string;
97
+ target: {
98
+ href: string;
99
+ } | {
100
+ collection: string;
101
+ id: string;
102
+ };
103
+ emphasis?: "primary" | "secondary" | undefined;
104
+ }[], true>;
105
+ }>;
106
+ declare const galleryItemSchema: z.ZodObject<{
107
+ _key: z.ZodString;
108
+ media: z.ZodString;
109
+ }, z.core.$strict>;
110
+ export type GalleryItem = z.infer<typeof galleryItemSchema>;
111
+ export declare const galleryBlock: import("./types.js").BlockDefinition<"gallery", {
112
+ readonly items: import("./field.js").BlockField<"json", {
113
+ _key: string;
114
+ media: string;
115
+ }[], true>;
116
+ /**
117
+ * Required rather than defaulted: a gallery read as a carousel and a gallery
118
+ * read as a grid are different editorial choices, and leaving it implicit
119
+ * makes the rendering depend on which theme is installed.
120
+ */
121
+ readonly layout: import("./field.js").BlockField<"select", "carousel" | "grid" | "masonry", true>;
122
+ }>;
123
+ export declare const quoteBlock: import("./types.js").BlockDefinition<"quote", {
124
+ readonly text: import("./field.js").BlockField<"text", string, true>;
125
+ readonly author: import("./field.js").BlockField<"text", string, false>;
126
+ readonly role: import("./field.js").BlockField<"text", string, false>;
127
+ readonly avatar: import("./field.js").BlockField<"media", string, false>;
128
+ }>;
129
+ /**
130
+ * `answer` is rich text, not plain text: an answer that cannot carry a link or
131
+ * a list gets written as HTML by the first editor who needs one, which rule R3
132
+ * then has to refuse. Giving it the structured form removes the temptation.
133
+ */
134
+ declare const faqItemSchema: z.ZodObject<{
135
+ _key: z.ZodString;
136
+ question: z.ZodString;
137
+ answer: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
138
+ _key: z.ZodString;
139
+ _type: z.ZodLiteral<"block">;
140
+ style: z.ZodEnum<{
141
+ blockquote: "blockquote";
142
+ h2: "h2";
143
+ h3: "h3";
144
+ h4: "h4";
145
+ normal: "normal";
146
+ }>;
147
+ listItem: z.ZodOptional<z.ZodEnum<{
148
+ bullet: "bullet";
149
+ number: "number";
150
+ }>>;
151
+ level: z.ZodOptional<z.ZodNumber>;
152
+ children: z.ZodArray<z.ZodObject<{
153
+ _key: z.ZodString;
154
+ _type: z.ZodLiteral<"span">;
155
+ text: z.ZodString;
156
+ marks: z.ZodDefault<z.ZodArray<z.ZodString>>;
157
+ }, z.core.$strict>>;
158
+ markDefs: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
159
+ _key: z.ZodString;
160
+ _type: z.ZodLiteral<"link">;
161
+ href: z.ZodString;
162
+ rel: z.ZodOptional<z.ZodString>;
163
+ }, z.core.$strict>, z.ZodObject<{
164
+ _key: z.ZodString;
165
+ _type: z.ZodLiteral<"internalLink">;
166
+ collection: z.ZodString;
167
+ id: z.ZodString;
168
+ }, z.core.$strict>], "_type">>>;
169
+ }, z.core.$strict>, z.ZodObject<{
170
+ _key: z.ZodString;
171
+ _type: z.ZodLiteral<"media">;
172
+ id: z.ZodString;
173
+ caption: z.ZodOptional<z.ZodString>;
174
+ }, z.core.$strict>], "_type">>;
175
+ }, z.core.$strict>;
176
+ export type FaqItem = z.infer<typeof faqItemSchema>;
177
+ export declare const faqBlock: import("./types.js").BlockDefinition<"faq", {
178
+ readonly title: import("./field.js").BlockField<"text", string, false>;
179
+ readonly items: import("./field.js").BlockField<"json", {
180
+ _key: string;
181
+ question: string;
182
+ answer: ({
183
+ _key: string;
184
+ _type: "block";
185
+ style: "blockquote" | "h2" | "h3" | "h4" | "normal";
186
+ listItem?: "bullet" | "number" | undefined;
187
+ level?: number | undefined;
188
+ children: {
189
+ _key: string;
190
+ _type: "span";
191
+ text: string;
192
+ marks: string[];
193
+ }[];
194
+ markDefs: ({
195
+ _key: string;
196
+ _type: "link";
197
+ href: string;
198
+ rel?: string | undefined;
199
+ } | {
200
+ _key: string;
201
+ _type: "internalLink";
202
+ collection: string;
203
+ id: string;
204
+ })[];
205
+ } | {
206
+ _key: string;
207
+ _type: "media";
208
+ id: string;
209
+ caption?: string | undefined;
210
+ })[];
211
+ }[], true>;
212
+ }>;
213
+ /**
214
+ * `value` is text, not a number, so `10k+`, `~3` and `1,2` survive as written.
215
+ * Storing a number would force this package to decide on locale formatting,
216
+ * abbreviation and precision — decisions that belong to the editor.
217
+ */
218
+ declare const statItemSchema: z.ZodObject<{
219
+ _key: z.ZodString;
220
+ value: z.ZodString;
221
+ unit: z.ZodOptional<z.ZodString>;
222
+ label: z.ZodString;
223
+ }, z.core.$strict>;
224
+ export type StatItem = z.infer<typeof statItemSchema>;
225
+ export declare const statsBlock: import("./types.js").BlockDefinition<"stats", {
226
+ readonly title: import("./field.js").BlockField<"text", string, false>;
227
+ readonly items: import("./field.js").BlockField<"json", {
228
+ _key: string;
229
+ value: string;
230
+ unit?: string | undefined;
231
+ label: string;
232
+ }[], true>;
233
+ }>;
234
+ declare const logoItemSchema: z.ZodObject<{
235
+ _key: z.ZodString;
236
+ media: z.ZodString;
237
+ name: z.ZodString;
238
+ url: z.ZodOptional<z.ZodURL>;
239
+ }, z.core.$strict>;
240
+ export type LogoItem = z.infer<typeof logoItemSchema>;
241
+ export declare const logosBlock: import("./types.js").BlockDefinition<"logos", {
242
+ readonly title: import("./field.js").BlockField<"text", string, false>;
243
+ readonly items: import("./field.js").BlockField<"json", {
244
+ _key: string;
245
+ media: string;
246
+ name: string;
247
+ url?: string | undefined;
248
+ }[], true>;
249
+ }>;
250
+ /** Mirrors contract A's index form: field first, direction second. */
251
+ declare const sortSchema: z.ZodObject<{
252
+ field: z.ZodString;
253
+ direction: z.ZodEnum<{
254
+ asc: "asc";
255
+ desc: "desc";
256
+ }>;
257
+ }, z.core.$strict>;
258
+ export type CollectionSort = z.infer<typeof sortSchema>;
259
+ export declare const collectionListBlock: import("./types.js").BlockDefinition<"collectionList", {
260
+ readonly title: import("./field.js").BlockField<"text", string, false>;
261
+ readonly collection: import("./field.js").BlockField<"text", string, true>;
262
+ readonly filter: import("./field.js").BlockField<"json", Record<string, unknown>, false>;
263
+ readonly sort: import("./field.js").BlockField<"json", {
264
+ field: string;
265
+ direction: "asc" | "desc";
266
+ }, false>;
267
+ readonly limit: import("./field.js").BlockField<"number", number, false>;
268
+ readonly layout: import("./field.js").BlockField<"select", "carousel" | "grid" | "list", true>;
269
+ }>;
270
+ export declare const embedBlock: import("./types.js").BlockDefinition<"embed", {
271
+ /** Named, not sniffed from the URL: the theme picks a renderer from it. */
272
+ readonly provider: import("./field.js").BlockField<"select", "bluesky" | "dailymotion" | "mastodon" | "other" | "soundcloud" | "spotify" | "vimeo" | "youtube", true>;
273
+ readonly url: import("./field.js").BlockField<"text", string, true>;
274
+ readonly ratio: import("./field.js").BlockField<"select", "16:9" | "1:1" | "21:9" | "3:2" | "4:3" | "original", false>;
275
+ /**
276
+ * Required rather than defaulted to `true`. Whether a third party may be
277
+ * contacted before the visitor consents is a legal decision; an implicit
278
+ * default hides it, and the wrong implicit default is a GDPR breach.
279
+ */
280
+ readonly consentRequired: import("./field.js").BlockField<"boolean", boolean, true>;
281
+ }>;
282
+ /** The twelve, in the order contract B lists them. */
283
+ export declare const VOCABULARY: readonly [import("./types.js").BlockDefinition<"hero", {
284
+ /** The short line above the title. Semantic, not decorative: it says what kind of page this is. */
285
+ readonly eyebrow: import("./field.js").BlockField<"text", string, false>;
286
+ readonly title: import("./field.js").BlockField<"text", string, true>;
287
+ readonly subtitle: import("./field.js").BlockField<"text", string, false>;
288
+ readonly media: import("./field.js").BlockField<"media", string, false>;
289
+ readonly actions: import("./field.js").BlockField<"json", {
290
+ label: string;
291
+ target: {
292
+ href: string;
293
+ } | {
294
+ collection: string;
295
+ id: string;
296
+ };
297
+ emphasis?: "primary" | "secondary" | undefined;
298
+ }[], false>;
299
+ }>, import("./types.js").BlockDefinition<"prose", {
300
+ readonly body: import("./field.js").BlockField<"richText", ({
301
+ _key: string;
302
+ _type: "block";
303
+ style: "blockquote" | "h2" | "h3" | "h4" | "normal";
304
+ listItem?: "bullet" | "number" | undefined;
305
+ level?: number | undefined;
306
+ children: {
307
+ _key: string;
308
+ _type: "span";
309
+ text: string;
310
+ marks: string[];
311
+ }[];
312
+ markDefs: ({
313
+ _key: string;
314
+ _type: "link";
315
+ href: string;
316
+ rel?: string | undefined;
317
+ } | {
318
+ _key: string;
319
+ _type: "internalLink";
320
+ collection: string;
321
+ id: string;
322
+ })[];
323
+ } | {
324
+ _key: string;
325
+ _type: "media";
326
+ id: string;
327
+ caption?: string | undefined;
328
+ })[], true>;
329
+ }>, import("./types.js").BlockDefinition<"mediaFigure", {
330
+ readonly media: import("./field.js").BlockField<"media", string, true>;
331
+ readonly caption: import("./field.js").BlockField<"text", string, false>;
332
+ readonly credit: import("./field.js").BlockField<"text", string, false>;
333
+ readonly ratio: import("./field.js").BlockField<"select", "16:9" | "1:1" | "21:9" | "3:2" | "4:3" | "original", false>;
334
+ /**
335
+ * `start` and `end` rather than `left` and `right`: the contract's intent is
336
+ * where the figure sits in the reading flow, which mirrors in right-to-left
337
+ * locales. `left` would be a layout instruction the theme cannot honour.
338
+ */
339
+ readonly align: import("./field.js").BlockField<"select", "center" | "end" | "full" | "start" | "wide", false>;
340
+ }>, import("./types.js").BlockDefinition<"featureGrid", {
341
+ readonly title: import("./field.js").BlockField<"text", string, false>;
342
+ readonly items: import("./field.js").BlockField<"json", {
343
+ _key: string;
344
+ icon?: string | undefined;
345
+ title: string;
346
+ text?: string | undefined;
347
+ link?: {
348
+ href: string;
349
+ } | {
350
+ collection: string;
351
+ id: string;
352
+ } | undefined;
353
+ }[], true>;
354
+ }>, import("./types.js").BlockDefinition<"cta", {
355
+ readonly title: import("./field.js").BlockField<"text", string, true>;
356
+ readonly text: import("./field.js").BlockField<"text", string, false>;
357
+ readonly actions: import("./field.js").BlockField<"json", {
358
+ label: string;
359
+ target: {
360
+ href: string;
361
+ } | {
362
+ collection: string;
363
+ id: string;
364
+ };
365
+ emphasis?: "primary" | "secondary" | undefined;
366
+ }[], true>;
367
+ }>, import("./types.js").BlockDefinition<"gallery", {
368
+ readonly items: import("./field.js").BlockField<"json", {
369
+ _key: string;
370
+ media: string;
371
+ }[], true>;
372
+ /**
373
+ * Required rather than defaulted: a gallery read as a carousel and a gallery
374
+ * read as a grid are different editorial choices, and leaving it implicit
375
+ * makes the rendering depend on which theme is installed.
376
+ */
377
+ readonly layout: import("./field.js").BlockField<"select", "carousel" | "grid" | "masonry", true>;
378
+ }>, import("./types.js").BlockDefinition<"quote", {
379
+ readonly text: import("./field.js").BlockField<"text", string, true>;
380
+ readonly author: import("./field.js").BlockField<"text", string, false>;
381
+ readonly role: import("./field.js").BlockField<"text", string, false>;
382
+ readonly avatar: import("./field.js").BlockField<"media", string, false>;
383
+ }>, import("./types.js").BlockDefinition<"faq", {
384
+ readonly title: import("./field.js").BlockField<"text", string, false>;
385
+ readonly items: import("./field.js").BlockField<"json", {
386
+ _key: string;
387
+ question: string;
388
+ answer: ({
389
+ _key: string;
390
+ _type: "block";
391
+ style: "blockquote" | "h2" | "h3" | "h4" | "normal";
392
+ listItem?: "bullet" | "number" | undefined;
393
+ level?: number | undefined;
394
+ children: {
395
+ _key: string;
396
+ _type: "span";
397
+ text: string;
398
+ marks: string[];
399
+ }[];
400
+ markDefs: ({
401
+ _key: string;
402
+ _type: "link";
403
+ href: string;
404
+ rel?: string | undefined;
405
+ } | {
406
+ _key: string;
407
+ _type: "internalLink";
408
+ collection: string;
409
+ id: string;
410
+ })[];
411
+ } | {
412
+ _key: string;
413
+ _type: "media";
414
+ id: string;
415
+ caption?: string | undefined;
416
+ })[];
417
+ }[], true>;
418
+ }>, import("./types.js").BlockDefinition<"stats", {
419
+ readonly title: import("./field.js").BlockField<"text", string, false>;
420
+ readonly items: import("./field.js").BlockField<"json", {
421
+ _key: string;
422
+ value: string;
423
+ unit?: string | undefined;
424
+ label: string;
425
+ }[], true>;
426
+ }>, import("./types.js").BlockDefinition<"logos", {
427
+ readonly title: import("./field.js").BlockField<"text", string, false>;
428
+ readonly items: import("./field.js").BlockField<"json", {
429
+ _key: string;
430
+ media: string;
431
+ name: string;
432
+ url?: string | undefined;
433
+ }[], true>;
434
+ }>, import("./types.js").BlockDefinition<"collectionList", {
435
+ readonly title: import("./field.js").BlockField<"text", string, false>;
436
+ readonly collection: import("./field.js").BlockField<"text", string, true>;
437
+ readonly filter: import("./field.js").BlockField<"json", Record<string, unknown>, false>;
438
+ readonly sort: import("./field.js").BlockField<"json", {
439
+ field: string;
440
+ direction: "asc" | "desc";
441
+ }, false>;
442
+ readonly limit: import("./field.js").BlockField<"number", number, false>;
443
+ readonly layout: import("./field.js").BlockField<"select", "carousel" | "grid" | "list", true>;
444
+ }>, import("./types.js").BlockDefinition<"embed", {
445
+ /** Named, not sniffed from the URL: the theme picks a renderer from it. */
446
+ readonly provider: import("./field.js").BlockField<"select", "bluesky" | "dailymotion" | "mastodon" | "other" | "soundcloud" | "spotify" | "vimeo" | "youtube", true>;
447
+ readonly url: import("./field.js").BlockField<"text", string, true>;
448
+ readonly ratio: import("./field.js").BlockField<"select", "16:9" | "1:1" | "21:9" | "3:2" | "4:3" | "original", false>;
449
+ /**
450
+ * Required rather than defaulted to `true`. Whether a third party may be
451
+ * contacted before the visitor consents is a legal decision; an implicit
452
+ * default hides it, and the wrong implicit default is a GDPR breach.
453
+ */
454
+ readonly consentRequired: import("./field.js").BlockField<"boolean", boolean, true>;
455
+ }>];
456
+ export declare const VOCABULARY_NAMES: ("collectionList" | "cta" | "embed" | "faq" | "featureGrid" | "gallery" | "hero" | "logos" | "mediaFigure" | "prose" | "quote" | "stats")[];
457
+ export type HeroBlock = BlockValue<typeof heroBlock>;
458
+ export type ProseBlock = BlockValue<typeof proseBlock>;
459
+ export type MediaFigureBlock = BlockValue<typeof mediaFigureBlock>;
460
+ export type FeatureGridBlock = BlockValue<typeof featureGridBlock>;
461
+ export type CtaBlock = BlockValue<typeof ctaBlock>;
462
+ export type GalleryBlock = BlockValue<typeof galleryBlock>;
463
+ export type QuoteBlock = BlockValue<typeof quoteBlock>;
464
+ export type FaqBlock = BlockValue<typeof faqBlock>;
465
+ export type StatsBlock = BlockValue<typeof statsBlock>;
466
+ export type LogosBlock = BlockValue<typeof logosBlock>;
467
+ export type CollectionListBlock = BlockValue<typeof collectionListBlock>;
468
+ export type EmbedBlock = BlockValue<typeof embedBlock>;
469
+ /** Every block of the vocabulary, as a discriminated union on `_type`. */
470
+ export type VocabularyBlock = HeroBlock | ProseBlock | MediaFigureBlock | FeatureGridBlock | CtaBlock | GalleryBlock | QuoteBlock | FaqBlock | StatsBlock | LogosBlock | CollectionListBlock | EmbedBlock;
471
+ export {};
472
+ //# sourceMappingURL=vocabulary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocabulary.d.ts","sourceRoot":"","sources":["../src/vocabulary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AA8B5C,eAAO,MAAM,SAAS;IAOlB,mGAAmG;;;;;;;;;;;;;;;EAOrG,CAAA;AAMF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWrB,CAAA;AAMF,eAAO,MAAM,gBAAgB;;;;;IAWzB;;;;OAIG;;EAGL,CAAA;AAMF,+EAA+E;AAC/E,QAAA,MAAM,iBAAiB;;;;;;;;;;;kBAMrB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAU3B,CAAA;AAMF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;EAWnB,CAAA;AAMF,QAAA,MAAM,iBAAiB;;;kBAGrB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO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