@the-smithy/hearth-schema 0.12.0 → 0.13.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.
package/dist/index.d.ts CHANGED
@@ -35,6 +35,270 @@ declare const formFieldSchema: z.ZodObject<{
35
35
  options: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
36
  placeholder: z.ZodOptional<z.ZodString>;
37
37
  }, z.core.$strip>;
38
+ /** A custom block's key, set when it's created and fixed after (content refers to it): "team-member", "menu-item". */
39
+ declare const customBlockKey: RegExp;
40
+ /** One field of a custom block. Lists hold items made of simple fields (one level deep). */
41
+ declare const customFieldSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
42
+ kind: z.ZodLiteral<"text">;
43
+ name: z.ZodString;
44
+ label: z.ZodString;
45
+ hint: z.ZodOptional<z.ZodString>;
46
+ optional: z.ZodOptional<z.ZodBoolean>;
47
+ }, z.core.$strip>, z.ZodObject<{
48
+ kind: z.ZodLiteral<"textarea">;
49
+ name: z.ZodString;
50
+ label: z.ZodString;
51
+ hint: z.ZodOptional<z.ZodString>;
52
+ optional: z.ZodOptional<z.ZodBoolean>;
53
+ }, z.core.$strip>, z.ZodObject<{
54
+ kind: z.ZodLiteral<"markdown">;
55
+ name: z.ZodString;
56
+ label: z.ZodString;
57
+ hint: z.ZodOptional<z.ZodString>;
58
+ optional: z.ZodOptional<z.ZodBoolean>;
59
+ }, z.core.$strip>, z.ZodObject<{
60
+ kind: z.ZodLiteral<"url">;
61
+ name: z.ZodString;
62
+ label: z.ZodString;
63
+ hint: z.ZodOptional<z.ZodString>;
64
+ optional: z.ZodOptional<z.ZodBoolean>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ kind: z.ZodLiteral<"image">;
67
+ name: z.ZodString;
68
+ label: z.ZodString;
69
+ hint: z.ZodOptional<z.ZodString>;
70
+ optional: z.ZodOptional<z.ZodBoolean>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ kind: z.ZodLiteral<"link">;
73
+ name: z.ZodString;
74
+ label: z.ZodString;
75
+ hint: z.ZodOptional<z.ZodString>;
76
+ optional: z.ZodOptional<z.ZodBoolean>;
77
+ }, z.core.$strip>, z.ZodObject<{
78
+ kind: z.ZodLiteral<"number">;
79
+ name: z.ZodString;
80
+ label: z.ZodString;
81
+ hint: z.ZodOptional<z.ZodString>;
82
+ optional: z.ZodOptional<z.ZodBoolean>;
83
+ }, z.core.$strip>, z.ZodObject<{
84
+ kind: z.ZodLiteral<"boolean">;
85
+ name: z.ZodString;
86
+ label: z.ZodString;
87
+ hint: z.ZodOptional<z.ZodString>;
88
+ optional: z.ZodOptional<z.ZodBoolean>;
89
+ }, z.core.$strip>, z.ZodObject<{
90
+ kind: z.ZodLiteral<"select">;
91
+ options: z.ZodArray<z.ZodObject<{
92
+ value: z.ZodString;
93
+ label: z.ZodString;
94
+ }, z.core.$strip>>;
95
+ name: z.ZodString;
96
+ label: z.ZodString;
97
+ hint: z.ZodOptional<z.ZodString>;
98
+ optional: z.ZodOptional<z.ZodBoolean>;
99
+ }, z.core.$strip>], "kind">, z.ZodObject<{
100
+ kind: z.ZodLiteral<"list">;
101
+ itemLabel: z.ZodString;
102
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
103
+ kind: z.ZodLiteral<"text">;
104
+ name: z.ZodString;
105
+ label: z.ZodString;
106
+ hint: z.ZodOptional<z.ZodString>;
107
+ optional: z.ZodOptional<z.ZodBoolean>;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ kind: z.ZodLiteral<"textarea">;
110
+ name: z.ZodString;
111
+ label: z.ZodString;
112
+ hint: z.ZodOptional<z.ZodString>;
113
+ optional: z.ZodOptional<z.ZodBoolean>;
114
+ }, z.core.$strip>, z.ZodObject<{
115
+ kind: z.ZodLiteral<"markdown">;
116
+ name: z.ZodString;
117
+ label: z.ZodString;
118
+ hint: z.ZodOptional<z.ZodString>;
119
+ optional: z.ZodOptional<z.ZodBoolean>;
120
+ }, z.core.$strip>, z.ZodObject<{
121
+ kind: z.ZodLiteral<"url">;
122
+ name: z.ZodString;
123
+ label: z.ZodString;
124
+ hint: z.ZodOptional<z.ZodString>;
125
+ optional: z.ZodOptional<z.ZodBoolean>;
126
+ }, z.core.$strip>, z.ZodObject<{
127
+ kind: z.ZodLiteral<"image">;
128
+ name: z.ZodString;
129
+ label: z.ZodString;
130
+ hint: z.ZodOptional<z.ZodString>;
131
+ optional: z.ZodOptional<z.ZodBoolean>;
132
+ }, z.core.$strip>, z.ZodObject<{
133
+ kind: z.ZodLiteral<"link">;
134
+ name: z.ZodString;
135
+ label: z.ZodString;
136
+ hint: z.ZodOptional<z.ZodString>;
137
+ optional: z.ZodOptional<z.ZodBoolean>;
138
+ }, z.core.$strip>, z.ZodObject<{
139
+ kind: z.ZodLiteral<"number">;
140
+ name: z.ZodString;
141
+ label: z.ZodString;
142
+ hint: z.ZodOptional<z.ZodString>;
143
+ optional: z.ZodOptional<z.ZodBoolean>;
144
+ }, z.core.$strip>, z.ZodObject<{
145
+ kind: z.ZodLiteral<"boolean">;
146
+ name: z.ZodString;
147
+ label: z.ZodString;
148
+ hint: z.ZodOptional<z.ZodString>;
149
+ optional: z.ZodOptional<z.ZodBoolean>;
150
+ }, z.core.$strip>, z.ZodObject<{
151
+ kind: z.ZodLiteral<"select">;
152
+ options: z.ZodArray<z.ZodObject<{
153
+ value: z.ZodString;
154
+ label: z.ZodString;
155
+ }, z.core.$strip>>;
156
+ name: z.ZodString;
157
+ label: z.ZodString;
158
+ hint: z.ZodOptional<z.ZodString>;
159
+ optional: z.ZodOptional<z.ZodBoolean>;
160
+ }, z.core.$strip>], "kind">>;
161
+ name: z.ZodString;
162
+ label: z.ZodString;
163
+ hint: z.ZodOptional<z.ZodString>;
164
+ optional: z.ZodOptional<z.ZodBoolean>;
165
+ }, z.core.$strip>]>;
166
+ type CustomField = z.infer<typeof customFieldSchema>;
167
+ type CustomFieldKind = CustomField["kind"];
168
+ /** A site's own block type, as the API lists it. */
169
+ declare const customBlockDefinitionSchema: z.ZodObject<{
170
+ key: z.ZodString;
171
+ name: z.ZodString;
172
+ description: z.ZodDefault<z.ZodString>;
173
+ fields: z.ZodArray<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
174
+ kind: z.ZodLiteral<"text">;
175
+ name: z.ZodString;
176
+ label: z.ZodString;
177
+ hint: z.ZodOptional<z.ZodString>;
178
+ optional: z.ZodOptional<z.ZodBoolean>;
179
+ }, z.core.$strip>, z.ZodObject<{
180
+ kind: z.ZodLiteral<"textarea">;
181
+ name: z.ZodString;
182
+ label: z.ZodString;
183
+ hint: z.ZodOptional<z.ZodString>;
184
+ optional: z.ZodOptional<z.ZodBoolean>;
185
+ }, z.core.$strip>, z.ZodObject<{
186
+ kind: z.ZodLiteral<"markdown">;
187
+ name: z.ZodString;
188
+ label: z.ZodString;
189
+ hint: z.ZodOptional<z.ZodString>;
190
+ optional: z.ZodOptional<z.ZodBoolean>;
191
+ }, z.core.$strip>, z.ZodObject<{
192
+ kind: z.ZodLiteral<"url">;
193
+ name: z.ZodString;
194
+ label: z.ZodString;
195
+ hint: z.ZodOptional<z.ZodString>;
196
+ optional: z.ZodOptional<z.ZodBoolean>;
197
+ }, z.core.$strip>, z.ZodObject<{
198
+ kind: z.ZodLiteral<"image">;
199
+ name: z.ZodString;
200
+ label: z.ZodString;
201
+ hint: z.ZodOptional<z.ZodString>;
202
+ optional: z.ZodOptional<z.ZodBoolean>;
203
+ }, z.core.$strip>, z.ZodObject<{
204
+ kind: z.ZodLiteral<"link">;
205
+ name: z.ZodString;
206
+ label: z.ZodString;
207
+ hint: z.ZodOptional<z.ZodString>;
208
+ optional: z.ZodOptional<z.ZodBoolean>;
209
+ }, z.core.$strip>, z.ZodObject<{
210
+ kind: z.ZodLiteral<"number">;
211
+ name: z.ZodString;
212
+ label: z.ZodString;
213
+ hint: z.ZodOptional<z.ZodString>;
214
+ optional: z.ZodOptional<z.ZodBoolean>;
215
+ }, z.core.$strip>, z.ZodObject<{
216
+ kind: z.ZodLiteral<"boolean">;
217
+ name: z.ZodString;
218
+ label: z.ZodString;
219
+ hint: z.ZodOptional<z.ZodString>;
220
+ optional: z.ZodOptional<z.ZodBoolean>;
221
+ }, z.core.$strip>, z.ZodObject<{
222
+ kind: z.ZodLiteral<"select">;
223
+ options: z.ZodArray<z.ZodObject<{
224
+ value: z.ZodString;
225
+ label: z.ZodString;
226
+ }, z.core.$strip>>;
227
+ name: z.ZodString;
228
+ label: z.ZodString;
229
+ hint: z.ZodOptional<z.ZodString>;
230
+ optional: z.ZodOptional<z.ZodBoolean>;
231
+ }, z.core.$strip>], "kind">, z.ZodObject<{
232
+ kind: z.ZodLiteral<"list">;
233
+ itemLabel: z.ZodString;
234
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
235
+ kind: z.ZodLiteral<"text">;
236
+ name: z.ZodString;
237
+ label: z.ZodString;
238
+ hint: z.ZodOptional<z.ZodString>;
239
+ optional: z.ZodOptional<z.ZodBoolean>;
240
+ }, z.core.$strip>, z.ZodObject<{
241
+ kind: z.ZodLiteral<"textarea">;
242
+ name: z.ZodString;
243
+ label: z.ZodString;
244
+ hint: z.ZodOptional<z.ZodString>;
245
+ optional: z.ZodOptional<z.ZodBoolean>;
246
+ }, z.core.$strip>, z.ZodObject<{
247
+ kind: z.ZodLiteral<"markdown">;
248
+ name: z.ZodString;
249
+ label: z.ZodString;
250
+ hint: z.ZodOptional<z.ZodString>;
251
+ optional: z.ZodOptional<z.ZodBoolean>;
252
+ }, z.core.$strip>, z.ZodObject<{
253
+ kind: z.ZodLiteral<"url">;
254
+ name: z.ZodString;
255
+ label: z.ZodString;
256
+ hint: z.ZodOptional<z.ZodString>;
257
+ optional: z.ZodOptional<z.ZodBoolean>;
258
+ }, z.core.$strip>, z.ZodObject<{
259
+ kind: z.ZodLiteral<"image">;
260
+ name: z.ZodString;
261
+ label: z.ZodString;
262
+ hint: z.ZodOptional<z.ZodString>;
263
+ optional: z.ZodOptional<z.ZodBoolean>;
264
+ }, z.core.$strip>, z.ZodObject<{
265
+ kind: z.ZodLiteral<"link">;
266
+ name: z.ZodString;
267
+ label: z.ZodString;
268
+ hint: z.ZodOptional<z.ZodString>;
269
+ optional: z.ZodOptional<z.ZodBoolean>;
270
+ }, z.core.$strip>, z.ZodObject<{
271
+ kind: z.ZodLiteral<"number">;
272
+ name: z.ZodString;
273
+ label: z.ZodString;
274
+ hint: z.ZodOptional<z.ZodString>;
275
+ optional: z.ZodOptional<z.ZodBoolean>;
276
+ }, z.core.$strip>, z.ZodObject<{
277
+ kind: z.ZodLiteral<"boolean">;
278
+ name: z.ZodString;
279
+ label: z.ZodString;
280
+ hint: z.ZodOptional<z.ZodString>;
281
+ optional: z.ZodOptional<z.ZodBoolean>;
282
+ }, z.core.$strip>, z.ZodObject<{
283
+ kind: z.ZodLiteral<"select">;
284
+ options: z.ZodArray<z.ZodObject<{
285
+ value: z.ZodString;
286
+ label: z.ZodString;
287
+ }, z.core.$strip>>;
288
+ name: z.ZodString;
289
+ label: z.ZodString;
290
+ hint: z.ZodOptional<z.ZodString>;
291
+ optional: z.ZodOptional<z.ZodBoolean>;
292
+ }, z.core.$strip>], "kind">>;
293
+ name: z.ZodString;
294
+ label: z.ZodString;
295
+ hint: z.ZodOptional<z.ZodString>;
296
+ optional: z.ZodOptional<z.ZodBoolean>;
297
+ }, z.core.$strip>]>>;
298
+ }, z.core.$strip>;
299
+ type CustomBlockDefinition = z.infer<typeof customBlockDefinitionSchema>;
300
+ /** Validates a custom block's `values` against its definition (the block schema itself can't: it's per site). */
301
+ declare function customValuesSchema(fields: CustomField[]): z.ZodType<Record<string, unknown>>;
38
302
  declare const blockDataSchemas: {
39
303
  readonly hero: z.ZodObject<{
40
304
  eyebrow: z.ZodOptional<z.ZodString>;
@@ -254,6 +518,22 @@ declare const blockDataSchemas: {
254
518
  title: z.ZodString;
255
519
  caption: z.ZodOptional<z.ZodString>;
256
520
  }, z.core.$strip>;
521
+ /**
522
+ * Embed code pasted from another service (a booking widget, a map, a social post). Frontends render `html` only
523
+ * inside a sandboxed iframe (`srcdoc`, scripts allowed, never same-origin), never into the page itself; the SDK's
524
+ * <HearthEmbed> does this.
525
+ */
526
+ readonly embed: z.ZodObject<{
527
+ html: z.ZodString;
528
+ title: z.ZodString;
529
+ height: z.ZodDefault<z.ZodNumber>;
530
+ width: z.ZodDefault<z.ZodEnum<{
531
+ full: "full";
532
+ narrow: "narrow";
533
+ wide: "wide";
534
+ }>>;
535
+ caption: z.ZodOptional<z.ZodString>;
536
+ }, z.core.$strip>;
257
537
  readonly people: z.ZodObject<{
258
538
  eyebrow: z.ZodOptional<z.ZodString>;
259
539
  heading: z.ZodOptional<z.ZodString>;
@@ -326,8 +606,8 @@ declare const blockDataSchemas: {
326
606
  collectionId: z.ZodString;
327
607
  limit: z.ZodDefault<z.ZodNumber>;
328
608
  layout: z.ZodDefault<z.ZodEnum<{
329
- cards: "cards";
330
609
  list: "list";
610
+ cards: "cards";
331
611
  }>>;
332
612
  tag: z.ZodOptional<z.ZodString>;
333
613
  categoryId: z.ZodOptional<z.ZodString>;
@@ -364,6 +644,14 @@ declare const blockDataSchemas: {
364
644
  fundraiserSlug: z.ZodOptional<z.ZodString>;
365
645
  submitLabel: z.ZodDefault<z.ZodString>;
366
646
  }, z.core.$strip>;
647
+ /**
648
+ * One of the site's own block types (Custom blocks in the admin): `block` is its key, `values` its fields' values,
649
+ * as described by the site's custom block definitions (GET /custom-blocks). The site's frontend renders it.
650
+ */
651
+ readonly custom: z.ZodObject<{
652
+ block: z.ZodString;
653
+ values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
654
+ }, z.core.$strip>;
367
655
  };
368
656
  type BlockType = keyof typeof blockDataSchemas;
369
657
  type BlockData<T extends BlockType> = z.infer<(typeof blockDataSchemas)[T]>;
@@ -372,7 +660,7 @@ declare const blockTypes: BlockType[];
372
660
  declare const blockFeature: Partial<Record<BlockType, "events" | "giving">>;
373
661
  declare const blockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
374
662
  id: z.ZodString;
375
- type: z.ZodLiteral<"cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
663
+ type: z.ZodLiteral<"custom" | "cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "embed" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
376
664
  data: z.ZodObject<{
377
665
  eyebrow: z.ZodOptional<z.ZodString>;
378
666
  heading: z.ZodString;
@@ -575,6 +863,16 @@ declare const blockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
575
863
  url: z.ZodString;
576
864
  title: z.ZodString;
577
865
  caption: z.ZodOptional<z.ZodString>;
866
+ }, z.core.$strip> | z.ZodObject<{
867
+ html: z.ZodString;
868
+ title: z.ZodString;
869
+ height: z.ZodDefault<z.ZodNumber>;
870
+ width: z.ZodDefault<z.ZodEnum<{
871
+ full: "full";
872
+ narrow: "narrow";
873
+ wide: "wide";
874
+ }>>;
875
+ caption: z.ZodOptional<z.ZodString>;
578
876
  }, z.core.$strip> | z.ZodObject<{
579
877
  eyebrow: z.ZodOptional<z.ZodString>;
580
878
  heading: z.ZodOptional<z.ZodString>;
@@ -641,8 +939,8 @@ declare const blockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
641
939
  collectionId: z.ZodString;
642
940
  limit: z.ZodDefault<z.ZodNumber>;
643
941
  layout: z.ZodDefault<z.ZodEnum<{
644
- cards: "cards";
645
942
  list: "list";
943
+ cards: "cards";
646
944
  }>>;
647
945
  tag: z.ZodOptional<z.ZodString>;
648
946
  categoryId: z.ZodOptional<z.ZodString>;
@@ -668,10 +966,13 @@ declare const blockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
668
966
  intro: z.ZodOptional<z.ZodString>;
669
967
  fundraiserSlug: z.ZodOptional<z.ZodString>;
670
968
  submitLabel: z.ZodDefault<z.ZodString>;
969
+ }, z.core.$strip> | z.ZodObject<{
970
+ block: z.ZodString;
971
+ values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
671
972
  }, z.core.$strip>;
672
973
  }, z.core.$strip>, ...z.ZodObject<{
673
974
  id: z.ZodString;
674
- type: z.ZodLiteral<"cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
975
+ type: z.ZodLiteral<"custom" | "cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "embed" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
675
976
  data: z.ZodObject<{
676
977
  eyebrow: z.ZodOptional<z.ZodString>;
677
978
  heading: z.ZodString;
@@ -874,6 +1175,16 @@ declare const blockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
874
1175
  url: z.ZodString;
875
1176
  title: z.ZodString;
876
1177
  caption: z.ZodOptional<z.ZodString>;
1178
+ }, z.core.$strip> | z.ZodObject<{
1179
+ html: z.ZodString;
1180
+ title: z.ZodString;
1181
+ height: z.ZodDefault<z.ZodNumber>;
1182
+ width: z.ZodDefault<z.ZodEnum<{
1183
+ full: "full";
1184
+ narrow: "narrow";
1185
+ wide: "wide";
1186
+ }>>;
1187
+ caption: z.ZodOptional<z.ZodString>;
877
1188
  }, z.core.$strip> | z.ZodObject<{
878
1189
  eyebrow: z.ZodOptional<z.ZodString>;
879
1190
  heading: z.ZodOptional<z.ZodString>;
@@ -940,8 +1251,8 @@ declare const blockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
940
1251
  collectionId: z.ZodString;
941
1252
  limit: z.ZodDefault<z.ZodNumber>;
942
1253
  layout: z.ZodDefault<z.ZodEnum<{
943
- cards: "cards";
944
1254
  list: "list";
1255
+ cards: "cards";
945
1256
  }>>;
946
1257
  tag: z.ZodOptional<z.ZodString>;
947
1258
  categoryId: z.ZodOptional<z.ZodString>;
@@ -967,6 +1278,9 @@ declare const blockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
967
1278
  intro: z.ZodOptional<z.ZodString>;
968
1279
  fundraiserSlug: z.ZodOptional<z.ZodString>;
969
1280
  submitLabel: z.ZodDefault<z.ZodString>;
1281
+ }, z.core.$strip> | z.ZodObject<{
1282
+ block: z.ZodString;
1283
+ values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
970
1284
  }, z.core.$strip>;
971
1285
  }, z.core.$strip>[]], "type">;
972
1286
  type Block = {
@@ -994,7 +1308,7 @@ declare const pageContentSchema: z.ZodObject<{
994
1308
  }, z.core.$strip>>;
995
1309
  blocks: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
996
1310
  id: z.ZodString;
997
- type: z.ZodLiteral<"cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
1311
+ type: z.ZodLiteral<"custom" | "cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "embed" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
998
1312
  data: z.ZodObject<{
999
1313
  eyebrow: z.ZodOptional<z.ZodString>;
1000
1314
  heading: z.ZodString;
@@ -1197,6 +1511,16 @@ declare const pageContentSchema: z.ZodObject<{
1197
1511
  url: z.ZodString;
1198
1512
  title: z.ZodString;
1199
1513
  caption: z.ZodOptional<z.ZodString>;
1514
+ }, z.core.$strip> | z.ZodObject<{
1515
+ html: z.ZodString;
1516
+ title: z.ZodString;
1517
+ height: z.ZodDefault<z.ZodNumber>;
1518
+ width: z.ZodDefault<z.ZodEnum<{
1519
+ full: "full";
1520
+ narrow: "narrow";
1521
+ wide: "wide";
1522
+ }>>;
1523
+ caption: z.ZodOptional<z.ZodString>;
1200
1524
  }, z.core.$strip> | z.ZodObject<{
1201
1525
  eyebrow: z.ZodOptional<z.ZodString>;
1202
1526
  heading: z.ZodOptional<z.ZodString>;
@@ -1263,8 +1587,8 @@ declare const pageContentSchema: z.ZodObject<{
1263
1587
  collectionId: z.ZodString;
1264
1588
  limit: z.ZodDefault<z.ZodNumber>;
1265
1589
  layout: z.ZodDefault<z.ZodEnum<{
1266
- cards: "cards";
1267
1590
  list: "list";
1591
+ cards: "cards";
1268
1592
  }>>;
1269
1593
  tag: z.ZodOptional<z.ZodString>;
1270
1594
  categoryId: z.ZodOptional<z.ZodString>;
@@ -1290,10 +1614,13 @@ declare const pageContentSchema: z.ZodObject<{
1290
1614
  intro: z.ZodOptional<z.ZodString>;
1291
1615
  fundraiserSlug: z.ZodOptional<z.ZodString>;
1292
1616
  submitLabel: z.ZodDefault<z.ZodString>;
1617
+ }, z.core.$strip> | z.ZodObject<{
1618
+ block: z.ZodString;
1619
+ values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1293
1620
  }, z.core.$strip>;
1294
1621
  }, z.core.$strip>, ...z.ZodObject<{
1295
1622
  id: z.ZodString;
1296
- type: z.ZodLiteral<"cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
1623
+ type: z.ZodLiteral<"custom" | "cta" | "quote" | "people" | "logos" | "hero" | "richText" | "mediaText" | "stats" | "cardGrid" | "faq" | "pricing" | "projects" | "location" | "schedule" | "gallery" | "video" | "embed" | "form" | "upcomingEvents" | "eventSpotlight" | "collectionList" | "sharedBlock" | "fundraiserSpotlight" | "fundraiserGrid" | "donate">;
1297
1624
  data: z.ZodObject<{
1298
1625
  eyebrow: z.ZodOptional<z.ZodString>;
1299
1626
  heading: z.ZodString;
@@ -1496,6 +1823,16 @@ declare const pageContentSchema: z.ZodObject<{
1496
1823
  url: z.ZodString;
1497
1824
  title: z.ZodString;
1498
1825
  caption: z.ZodOptional<z.ZodString>;
1826
+ }, z.core.$strip> | z.ZodObject<{
1827
+ html: z.ZodString;
1828
+ title: z.ZodString;
1829
+ height: z.ZodDefault<z.ZodNumber>;
1830
+ width: z.ZodDefault<z.ZodEnum<{
1831
+ full: "full";
1832
+ narrow: "narrow";
1833
+ wide: "wide";
1834
+ }>>;
1835
+ caption: z.ZodOptional<z.ZodString>;
1499
1836
  }, z.core.$strip> | z.ZodObject<{
1500
1837
  eyebrow: z.ZodOptional<z.ZodString>;
1501
1838
  heading: z.ZodOptional<z.ZodString>;
@@ -1562,8 +1899,8 @@ declare const pageContentSchema: z.ZodObject<{
1562
1899
  collectionId: z.ZodString;
1563
1900
  limit: z.ZodDefault<z.ZodNumber>;
1564
1901
  layout: z.ZodDefault<z.ZodEnum<{
1565
- cards: "cards";
1566
1902
  list: "list";
1903
+ cards: "cards";
1567
1904
  }>>;
1568
1905
  tag: z.ZodOptional<z.ZodString>;
1569
1906
  categoryId: z.ZodOptional<z.ZodString>;
@@ -1589,6 +1926,9 @@ declare const pageContentSchema: z.ZodObject<{
1589
1926
  intro: z.ZodOptional<z.ZodString>;
1590
1927
  fundraiserSlug: z.ZodOptional<z.ZodString>;
1591
1928
  submitLabel: z.ZodDefault<z.ZodString>;
1929
+ }, z.core.$strip> | z.ZodObject<{
1930
+ block: z.ZodString;
1931
+ values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1592
1932
  }, z.core.$strip>;
1593
1933
  }, z.core.$strip>[]], "type">>;
1594
1934
  categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1644,6 +1984,17 @@ declare const formDefinitionSchema: z.ZodObject<{
1644
1984
  }, z.core.$strip>;
1645
1985
  type FormDefinition = z.infer<typeof formDefinitionSchema>;
1646
1986
 
1987
+ /**
1988
+ * How an Embed block runs: its HTML inside an iframe's `srcdoc` with this sandbox. Scripts, forms and popups work
1989
+ * (booking widgets, maps, social posts), but without `allow-same-origin` the frame is its own opaque origin: it
1990
+ * can't read the page, its cookies or storage, or navigate the page away. Links open in a new tab.
1991
+ */
1992
+ declare const EMBED_SANDBOX = "allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation";
1993
+ /** What the iframe may use beyond that (video players and maps often ask for these). */
1994
+ declare const EMBED_ALLOW = "autoplay; encrypted-media; fullscreen; picture-in-picture; clipboard-write";
1995
+ /** The document an Embed block's iframe shows: the pasted HTML on a blank, borderless page. */
1996
+ declare function embedDocument(html: string): string;
1997
+
1647
1998
  declare const ORGANIZATION_TYPES: readonly ["Organization", "LocalBusiness", "NGO", "Corporation", "EducationalOrganization", "GovernmentOrganization", "MedicalOrganization", "SportsOrganization"];
1648
1999
  declare const SOCIAL_PLATFORMS: readonly ["facebook", "instagram", "linkedin", "x", "youtube", "tiktok", "other"];
1649
2000
  declare const siteSettingsSchema: z.ZodObject<{
@@ -2025,6 +2376,13 @@ type Resolved<T extends BlockType> = T extends "hero" ? {
2025
2376
  data: BlockData<T> & {
2026
2377
  fields: FormField[];
2027
2378
  };
2379
+ } : T extends "custom" ? {
2380
+ id: string;
2381
+ type: T;
2382
+ data: {
2383
+ block: string;
2384
+ values: Record<string, unknown>;
2385
+ };
2028
2386
  } : T extends "donate" ? {
2029
2387
  id: string;
2030
2388
  type: T;
@@ -2114,4 +2472,4 @@ type ApiErrorBody = {
2114
2472
  };
2115
2473
  };
2116
2474
 
2117
- export { type ApiErrorBody, BLOCK_SCHEMA_VERSION, type Block, type BlockData, type BlockOf, type BlockType, type CategoryGroup, type CategoryRef, type Collection, type CollectionEntry, type CollectionRef, type DonationCheckout, type DonationInput, type EntryDetails, type EventCustomFields, type EventRegistration, type EventTicket, type FormDefinition, type FormField, type Fundraiser, type FundraiserDetail, type HearthEvent, type HearthEventDetail, type HearthForm, type ImageRef, type KnownBlock, type LinkRef, ORGANIZATION_TYPES, type Page, type PageContent, type PageMeta, type PageSummary, type RegistrationInput, type RegistrationResult, type ResolvedBlock, SOCIAL_PLATFORMS, type Site, type SiteSettings, type SitemapEntry, type TicketType, type UnknownBlock, type WebhookPayload, blockDataSchemas, blockFeature, blockSchema, blockTypes, formDefinitionSchema, formFieldSchema, pageContentSchema, parseBlocks, parsePageContent, parseSiteSettings, parseTicketTypes, siteSettingsSchema, ticketTypeSchema, ticketTypesSchema, videoEmbedUrl };
2475
+ export { type ApiErrorBody, BLOCK_SCHEMA_VERSION, type Block, type BlockData, type BlockOf, type BlockType, type CategoryGroup, type CategoryRef, type Collection, type CollectionEntry, type CollectionRef, type CustomBlockDefinition, type CustomField, type CustomFieldKind, type DonationCheckout, type DonationInput, EMBED_ALLOW, EMBED_SANDBOX, type EntryDetails, type EventCustomFields, type EventRegistration, type EventTicket, type FormDefinition, type FormField, type Fundraiser, type FundraiserDetail, type HearthEvent, type HearthEventDetail, type HearthForm, type ImageRef, type KnownBlock, type LinkRef, ORGANIZATION_TYPES, type Page, type PageContent, type PageMeta, type PageSummary, type RegistrationInput, type RegistrationResult, type ResolvedBlock, SOCIAL_PLATFORMS, type Site, type SiteSettings, type SitemapEntry, type TicketType, type UnknownBlock, type WebhookPayload, blockDataSchemas, blockFeature, blockSchema, blockTypes, customBlockDefinitionSchema, customBlockKey, customFieldSchema, customValuesSchema, embedDocument, formDefinitionSchema, formFieldSchema, pageContentSchema, parseBlocks, parsePageContent, parseSiteSettings, parseTicketTypes, siteSettingsSchema, ticketTypeSchema, ticketTypesSchema, videoEmbedUrl };
package/dist/index.js CHANGED
@@ -24,6 +24,83 @@ var formFieldSchema = z.object({
24
24
  /** Example text inside the empty input (for a select, the prompt before a choice is made). */
25
25
  placeholder: z.string().max(120).optional()
26
26
  });
27
+ var customBlockKey = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
28
+ var customFieldName = z.string().regex(/^[a-z][a-zA-Z0-9]*$/, "Use letters and numbers, starting with a lowercase letter.");
29
+ var customFieldBase = {
30
+ name: customFieldName,
31
+ label: z.string().trim().min(1, "Give the field a label.").max(60),
32
+ hint: z.string().trim().max(200).optional(),
33
+ optional: z.boolean().optional()
34
+ };
35
+ var customSimpleField = z.discriminatedUnion("kind", [
36
+ z.object({ ...customFieldBase, kind: z.literal("text") }),
37
+ z.object({ ...customFieldBase, kind: z.literal("textarea") }),
38
+ z.object({ ...customFieldBase, kind: z.literal("markdown") }),
39
+ z.object({ ...customFieldBase, kind: z.literal("url") }),
40
+ z.object({ ...customFieldBase, kind: z.literal("image") }),
41
+ z.object({ ...customFieldBase, kind: z.literal("link") }),
42
+ z.object({ ...customFieldBase, kind: z.literal("number") }),
43
+ z.object({ ...customFieldBase, kind: z.literal("boolean") }),
44
+ z.object({
45
+ ...customFieldBase,
46
+ kind: z.literal("select"),
47
+ options: z.array(z.object({ value: z.string().trim().min(1), label: z.string().trim().min(1) })).min(1, "Add at least one choice.").max(50)
48
+ })
49
+ ]);
50
+ var customFieldSchema = z.union([
51
+ customSimpleField,
52
+ z.object({
53
+ ...customFieldBase,
54
+ kind: z.literal("list"),
55
+ itemLabel: z.string().trim().min(1).max(40),
56
+ fields: z.array(customSimpleField).min(1, "Add at least one field to each item.").max(20)
57
+ })
58
+ ]);
59
+ var uniqueNames = (fields) => new Set(fields.map((f) => f.name)).size === fields.length;
60
+ var customBlockDefinitionSchema = z.object({
61
+ key: z.string().regex(customBlockKey, "Use lowercase letters, numbers and dashes."),
62
+ name: z.string().trim().min(1, "Name the block.").max(60),
63
+ description: z.string().trim().max(200).default(""),
64
+ fields: z.array(customFieldSchema).min(1, "Add at least one field.").max(30).refine(uniqueNames, "Two fields share a name.").refine((fs) => fs.every((f) => f.kind !== "list" || uniqueNames(f.fields)), "Two fields in a list share a name.")
65
+ });
66
+ function customValuesSchema(fields) {
67
+ const one = (f) => {
68
+ const required = !f.optional;
69
+ const text = (s) => required ? s.trim().min(1) : s.trim();
70
+ let schema;
71
+ switch (f.kind) {
72
+ case "text":
73
+ case "textarea":
74
+ case "markdown":
75
+ schema = text(z.string());
76
+ break;
77
+ case "url":
78
+ schema = z.string().trim().regex(/^(https?:\/\/|\/)/, "Enter a full link starting with https://, or a path like /about.");
79
+ break;
80
+ case "image":
81
+ schema = image;
82
+ break;
83
+ case "link":
84
+ schema = link;
85
+ break;
86
+ case "number":
87
+ schema = z.number();
88
+ break;
89
+ case "boolean":
90
+ schema = z.boolean();
91
+ break;
92
+ case "select":
93
+ schema = z.enum(f.options.map((o) => o.value));
94
+ break;
95
+ case "list":
96
+ schema = z.array(customValuesSchema(f.fields));
97
+ if (required) schema = schema.min(1);
98
+ break;
99
+ }
100
+ return required && f.kind !== "boolean" ? schema : schema.optional();
101
+ };
102
+ return z.object(Object.fromEntries(fields.map((f) => [f.name, one(f)])));
103
+ }
27
104
  var blockDataSchemas = {
28
105
  hero: z.object({
29
106
  eyebrow: z.string().optional(),
@@ -169,6 +246,20 @@ var blockDataSchemas = {
169
246
  title: z.string().min(1),
170
247
  caption: z.string().optional()
171
248
  }),
249
+ /**
250
+ * Embed code pasted from another service (a booking widget, a map, a social post). Frontends render `html` only
251
+ * inside a sandboxed iframe (`srcdoc`, scripts allowed, never same-origin), never into the page itself; the SDK's
252
+ * <HearthEmbed> does this.
253
+ */
254
+ embed: z.object({
255
+ html: z.string().trim().min(1, "Paste the embed code.").max(5e4, "That's too long for an embed (50,000 characters at most)."),
256
+ /** Describes the embed for screen readers. */
257
+ title: z.string().min(1),
258
+ /** Height of the frame in pixels. */
259
+ height: z.number().int().min(50).max(4e3).default(400),
260
+ width: z.enum(["narrow", "wide", "full"]).default("wide"),
261
+ caption: z.string().optional()
262
+ }),
172
263
  people: z.object({
173
264
  eyebrow: z.string().optional(),
174
265
  heading: z.string().optional(),
@@ -261,6 +352,14 @@ var blockDataSchemas = {
261
352
  /** Donations go to this fundraiser; omit for general donations. */
262
353
  fundraiserSlug: z.string().optional(),
263
354
  submitLabel: z.string().min(1).default("Donate")
355
+ }),
356
+ /**
357
+ * One of the site's own block types (Custom blocks in the admin): `block` is its key, `values` its fields' values,
358
+ * as described by the site's custom block definitions (GET /custom-blocks). The site's frontend renders it.
359
+ */
360
+ custom: z.object({
361
+ block: z.string().regex(customBlockKey, "Choose a custom block."),
362
+ values: z.record(z.string(), z.unknown()).default({})
264
363
  })
265
364
  };
266
365
  var blockTypes = Object.keys(blockDataSchemas);
@@ -373,6 +472,13 @@ var formDefinitionSchema = z.object({
373
472
  ctx.addIssue({ code: "custom", path: ["sendConfirmation"], message: "Add an Email field to send confirmations." });
374
473
  });
375
474
 
475
+ // src/embed.ts
476
+ var EMBED_SANDBOX = "allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation";
477
+ var EMBED_ALLOW = "autoplay; encrypted-media; fullscreen; picture-in-picture; clipboard-write";
478
+ function embedDocument(html) {
479
+ return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><base target="_blank"><style>html,body{margin:0;padding:0}body{font-family:system-ui,sans-serif}img,iframe,video{max-width:100%}</style></head><body>${html}</body></html>`;
480
+ }
481
+
376
482
  // src/site-settings.ts
377
483
  import { z as z2 } from "zod";
378
484
  var link2 = z2.object({ label: z2.string().trim().min(1, "Add link text."), href: z2.string().trim().min(1, "Add where it goes.") });
@@ -480,12 +586,19 @@ function parseTicketTypes(input) {
480
586
  }
481
587
  export {
482
588
  BLOCK_SCHEMA_VERSION,
589
+ EMBED_ALLOW,
590
+ EMBED_SANDBOX,
483
591
  ORGANIZATION_TYPES,
484
592
  SOCIAL_PLATFORMS,
485
593
  blockDataSchemas,
486
594
  blockFeature,
487
595
  blockSchema,
488
596
  blockTypes,
597
+ customBlockDefinitionSchema,
598
+ customBlockKey,
599
+ customFieldSchema,
600
+ customValuesSchema,
601
+ embedDocument,
489
602
  formDefinitionSchema,
490
603
  formFieldSchema,
491
604
  pageContentSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-smithy/hearth-schema",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Content schemas and API types shared by Hearth and its SDK.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",