storyblok 4.23.0 → 4.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2,11 +2,11 @@ import "dotenv/config";
2
2
  import { Command } from "commander";
3
3
  import "@storyblok/management-api-client";
4
4
  //#region src/generated/overlay/types.gen.d.ts
5
- type RichTextDoc = RichTextFieldValueRoot;
5
+ type RichTextDoc = RichTextFieldValue2;
6
6
  /**
7
7
  * Rich text field type - structured rich text document (ProseMirror/Tiptap format)
8
8
  */
9
- type RichTextFieldValueRoot = {
9
+ type RichTextFieldValue2 = {
10
10
  /**
11
11
  * Root node type — always "doc"
12
12
  */
@@ -19,12 +19,12 @@ type RichTextFieldValueRoot = {
19
19
  /**
20
20
  * A rich text document node
21
21
  */
22
- type RichTextFieldValueRichTextNode = RichTextFieldValueParagraphNode | RichTextFieldValueTextNode | RichTextFieldValueHeadingNode | RichTextFieldValueBlockquoteNode | RichTextFieldValueBulletListNode | RichTextFieldValueOrderedListNode | RichTextFieldValueListItemNode | RichTextFieldValueCodeBlockNode | RichTextFieldValueHardBreakNode | RichTextFieldValueHorizontalRuleNode | RichTextFieldValueImageNode | RichTextFieldValueEmojiNode | RichTextFieldValueTableNode | RichTextFieldValueTableRowNode | RichTextFieldValueTableCellNode | RichTextFieldValueTableHeaderNode | RichTextFieldValueBlockNode;
22
+ type RichTextFieldValueRichTextNode = ParagraphNode | TextNode | HeadingNode | BlockquoteNode | BulletListNode | OrderedListNode | ListItemNode | CodeBlockNode | HardBreakNode | HorizontalRuleNode | ImageNode | EmojiNode | TableNode | TableRowNode | TableCellNode | TableHeaderNode | BlockNode;
23
23
  /**
24
24
  * Inline formatting mark applied to a text node
25
25
  */
26
- type RichTextFieldValueRichTextMark = RichTextFieldValueLinkMark | RichTextFieldValueBoldMark | RichTextFieldValueItalicMark | RichTextFieldValueStrikeMark | RichTextFieldValueUnderlineMark | RichTextFieldValueCodeMark | RichTextFieldValueSuperscriptMark | RichTextFieldValueSubscriptMark | RichTextFieldValueHighlightMark | RichTextFieldValueTextStyleMark | RichTextFieldValueAnchorMark | RichTextFieldValueStyledMark;
27
- type RichTextFieldValueParagraphNode = {
26
+ type RichTextFieldValueRichTextMark = LinkMark | BoldMark | ItalicMark | StrikeMark | UnderlineMark | CodeMark | SuperscriptMark | SubscriptMark | HighlightMark | TextStyleMark | AnchorMark | StyledMark;
27
+ type ParagraphNode = {
28
28
  type: 'paragraph';
29
29
  attrs?: {
30
30
  /**
@@ -39,7 +39,7 @@ type RichTextFieldValueParagraphNode = {
39
39
  content?: Array<RichTextFieldValueRichTextNode>;
40
40
  marks?: Array<RichTextFieldValueRichTextMark>;
41
41
  };
42
- type RichTextFieldValueTextNode = {
42
+ type TextNode = {
43
43
  type: 'text';
44
44
  /**
45
45
  * The text content
@@ -47,7 +47,7 @@ type RichTextFieldValueTextNode = {
47
47
  text: string;
48
48
  marks?: Array<RichTextFieldValueRichTextMark>;
49
49
  };
50
- type RichTextFieldValueHeadingNode = {
50
+ type HeadingNode = {
51
51
  type: 'heading';
52
52
  attrs: {
53
53
  /**
@@ -66,7 +66,7 @@ type RichTextFieldValueHeadingNode = {
66
66
  content?: Array<RichTextFieldValueRichTextNode>;
67
67
  marks?: Array<RichTextFieldValueRichTextMark>;
68
68
  };
69
- type RichTextFieldValueBlockquoteNode = {
69
+ type BlockquoteNode = {
70
70
  type: 'blockquote';
71
71
  attrs?: {
72
72
  /**
@@ -77,12 +77,12 @@ type RichTextFieldValueBlockquoteNode = {
77
77
  content?: Array<RichTextFieldValueRichTextNode>;
78
78
  marks?: Array<RichTextFieldValueRichTextMark>;
79
79
  };
80
- type RichTextFieldValueBulletListNode = {
80
+ type BulletListNode = {
81
81
  type: 'bullet_list';
82
82
  content?: Array<RichTextFieldValueRichTextNode>;
83
83
  marks?: Array<RichTextFieldValueRichTextMark>;
84
84
  };
85
- type RichTextFieldValueOrderedListNode = {
85
+ type OrderedListNode = {
86
86
  type: 'ordered_list';
87
87
  attrs: {
88
88
  /**
@@ -93,7 +93,7 @@ type RichTextFieldValueOrderedListNode = {
93
93
  content?: Array<RichTextFieldValueRichTextNode>;
94
94
  marks?: Array<RichTextFieldValueRichTextMark>;
95
95
  };
96
- type RichTextFieldValueListItemNode = {
96
+ type ListItemNode = {
97
97
  type: 'list_item';
98
98
  attrs?: {
99
99
  /**
@@ -104,7 +104,7 @@ type RichTextFieldValueListItemNode = {
104
104
  content?: Array<RichTextFieldValueRichTextNode>;
105
105
  marks?: Array<RichTextFieldValueRichTextMark>;
106
106
  };
107
- type RichTextFieldValueCodeBlockNode = {
107
+ type CodeBlockNode = {
108
108
  type: 'code_block';
109
109
  attrs: {
110
110
  /**
@@ -119,13 +119,13 @@ type RichTextFieldValueCodeBlockNode = {
119
119
  content?: Array<RichTextFieldValueRichTextNode>;
120
120
  marks?: Array<RichTextFieldValueRichTextMark>;
121
121
  };
122
- type RichTextFieldValueHardBreakNode = {
122
+ type HardBreakNode = {
123
123
  type: 'hard_break';
124
124
  };
125
- type RichTextFieldValueHorizontalRuleNode = {
125
+ type HorizontalRuleNode = {
126
126
  type: 'horizontal_rule';
127
127
  };
128
- type RichTextFieldValueImageNode = {
128
+ type ImageNode = {
129
129
  type: 'image';
130
130
  attrs: {
131
131
  /**
@@ -151,11 +151,11 @@ type RichTextFieldValueImageNode = {
151
151
  title?: string | null;
152
152
  source?: string | null;
153
153
  copyright?: string | null;
154
- [key: string]: string | null | string | null | string | null | string | null | string | null | undefined;
154
+ [key: string]: string | null | undefined;
155
155
  } | null;
156
156
  };
157
157
  };
158
- type RichTextFieldValueEmojiNode = {
158
+ type EmojiNode = {
159
159
  type: 'emoji';
160
160
  attrs: {
161
161
  /**
@@ -172,15 +172,15 @@ type RichTextFieldValueEmojiNode = {
172
172
  fallbackImage: string;
173
173
  };
174
174
  };
175
- type RichTextFieldValueTableNode = {
175
+ type TableNode = {
176
176
  type: 'table';
177
177
  content?: Array<RichTextFieldValueRichTextNode>;
178
178
  };
179
- type RichTextFieldValueTableRowNode = {
179
+ type TableRowNode = {
180
180
  type: 'tableRow';
181
181
  content?: Array<RichTextFieldValueRichTextNode>;
182
182
  };
183
- type RichTextFieldValueTableCellNode = {
183
+ type TableCellNode = {
184
184
  type: 'tableCell';
185
185
  attrs: {
186
186
  colspan?: number;
@@ -193,7 +193,7 @@ type RichTextFieldValueTableCellNode = {
193
193
  };
194
194
  content?: Array<RichTextFieldValueRichTextNode>;
195
195
  };
196
- type RichTextFieldValueTableHeaderNode = {
196
+ type TableHeaderNode = {
197
197
  type: 'tableHeader';
198
198
  attrs: {
199
199
  colspan?: number;
@@ -205,7 +205,7 @@ type RichTextFieldValueTableHeaderNode = {
205
205
  };
206
206
  content?: Array<RichTextFieldValueRichTextNode>;
207
207
  };
208
- type RichTextFieldValueBlockNode = {
208
+ type BlockNode = {
209
209
  type: 'blok';
210
210
  attrs: {
211
211
  /**
@@ -215,10 +215,10 @@ type RichTextFieldValueBlockNode = {
215
215
  /**
216
216
  * Array of embedded component instances
217
217
  */
218
- body: Array<BlockContentInputRoot> | null;
218
+ body: Array<BlockContentInput2> | null;
219
219
  };
220
220
  };
221
- type RichTextFieldValueLinkMark = {
221
+ type LinkMark = {
222
222
  type: 'link';
223
223
  /**
224
224
  * Link attributes
@@ -252,28 +252,28 @@ type RichTextFieldValueLinkMark = {
252
252
  } | null;
253
253
  };
254
254
  };
255
- type RichTextFieldValueBoldMark = {
255
+ type BoldMark = {
256
256
  type: 'bold';
257
257
  };
258
- type RichTextFieldValueItalicMark = {
258
+ type ItalicMark = {
259
259
  type: 'italic';
260
260
  };
261
- type RichTextFieldValueStrikeMark = {
261
+ type StrikeMark = {
262
262
  type: 'strike';
263
263
  };
264
- type RichTextFieldValueUnderlineMark = {
264
+ type UnderlineMark = {
265
265
  type: 'underline';
266
266
  };
267
- type RichTextFieldValueCodeMark = {
267
+ type CodeMark = {
268
268
  type: 'code';
269
269
  };
270
- type RichTextFieldValueSuperscriptMark = {
270
+ type SuperscriptMark = {
271
271
  type: 'superscript';
272
272
  };
273
- type RichTextFieldValueSubscriptMark = {
273
+ type SubscriptMark = {
274
274
  type: 'subscript';
275
275
  };
276
- type RichTextFieldValueHighlightMark = {
276
+ type HighlightMark = {
277
277
  type: 'highlight';
278
278
  attrs: {
279
279
  /**
@@ -282,7 +282,7 @@ type RichTextFieldValueHighlightMark = {
282
282
  color: string | null;
283
283
  };
284
284
  };
285
- type RichTextFieldValueTextStyleMark = {
285
+ type TextStyleMark = {
286
286
  type: 'textStyle';
287
287
  attrs: {
288
288
  color?: string | null;
@@ -290,7 +290,7 @@ type RichTextFieldValueTextStyleMark = {
290
290
  class?: string | null;
291
291
  };
292
292
  };
293
- type RichTextFieldValueAnchorMark = {
293
+ type AnchorMark = {
294
294
  type: 'anchor';
295
295
  attrs: {
296
296
  /**
@@ -299,7 +299,7 @@ type RichTextFieldValueAnchorMark = {
299
299
  id: string;
300
300
  };
301
301
  };
302
- type RichTextFieldValueStyledMark = {
302
+ type StyledMark = {
303
303
  type: 'styled';
304
304
  attrs: {
305
305
  /**
@@ -311,7 +311,7 @@ type RichTextFieldValueStyledMark = {
311
311
  /**
312
312
  * Content object for creating or updating a component instance. Contains a component technical name and dynamic fields whose values depend on the component's schema field types. The _uid is optional — Storyblok will auto-generate one if not provided.
313
313
  */
314
- type BlockContentInputRoot = {
314
+ type BlockContentInput2 = {
315
315
  /**
316
316
  * Unique identifier for this component instance (auto-generated when omitted)
317
317
  */
@@ -324,12 +324,12 @@ type BlockContentInputRoot = {
324
324
  * Storyblok editor markup string for inline editing (present in draft/preview mode)
325
325
  */
326
326
  _editable?: string;
327
- [key: string]: null | string | number | boolean | Array<string | AssetFieldValueRoot | BlockContentInputRoot> | AssetFieldValueRoot | MultilinkFieldValueRoot | TableFieldValueRoot | RichTextFieldValueRoot | PluginFieldValueRoot | string | undefined;
327
+ [key: string]: null | string | number | boolean | Array<string | AssetFieldValue2 | BlockContentInput2> | AssetFieldValue2 | MultilinkFieldValue2 | TableFieldValue2 | RichTextFieldValue2 | PluginFieldValue2 | undefined;
328
328
  };
329
329
  /**
330
330
  * Asset field type - single asset (image, video, audio, or document)
331
331
  */
332
- type AssetFieldValueRoot = {
332
+ type AssetFieldValue2 = {
333
333
  /**
334
334
  * Identifies this as an asset field
335
335
  */
@@ -380,11 +380,11 @@ type AssetFieldValueRoot = {
380
380
  /**
381
381
  * Multilink field type - link to internal stories, external URLs, emails, or assets.
382
382
  */
383
- type MultilinkFieldValueRoot = MultilinkFieldValueStoryLink | MultilinkFieldValueUrlLink | MultilinkFieldValueEmailLink | MultilinkFieldValueAssetLink;
383
+ type MultilinkFieldValue2 = StoryLink | UrlLink | EmailLink | AssetLink;
384
384
  /**
385
385
  * Table field type - structured table data
386
386
  */
387
- type TableFieldValueRoot = {
387
+ type TableFieldValue2 = {
388
388
  /**
389
389
  * Table header cells
390
390
  */
@@ -418,7 +418,7 @@ type TableFieldValueRoot = {
418
418
  /**
419
419
  * Plugin/Custom field type - field plugin with custom structure
420
420
  */
421
- type PluginFieldValueRoot = {
421
+ type PluginFieldValue2 = {
422
422
  /**
423
423
  * Technical name of the field plugin
424
424
  */
@@ -427,12 +427,12 @@ type PluginFieldValueRoot = {
427
427
  * Unique identifier for this plugin field instance
428
428
  */
429
429
  _uid?: string;
430
- [key: string]: unknown | string | undefined;
430
+ [key: string]: unknown;
431
431
  };
432
432
  /**
433
433
  * Link to an internal Storyblok story.
434
434
  */
435
- type MultilinkFieldValueStoryLink = MultilinkFieldValueSharedLink & {
435
+ type StoryLink = SharedLink & {
436
436
  linktype: 'story';
437
437
  /**
438
438
  * Anchor/fragment identifier for the story link
@@ -452,7 +452,7 @@ type MultilinkFieldValueStoryLink = MultilinkFieldValueSharedLink & {
452
452
  /**
453
453
  * Link to an external URL.
454
454
  */
455
- type MultilinkFieldValueUrlLink = MultilinkFieldValueSharedLink & {
455
+ type UrlLink = SharedLink & {
456
456
  linktype: 'url';
457
457
  /**
458
458
  * Link relationship attribute
@@ -468,7 +468,7 @@ type MultilinkFieldValueUrlLink = MultilinkFieldValueSharedLink & {
468
468
  /**
469
469
  * Link to an email address.
470
470
  */
471
- type MultilinkFieldValueEmailLink = MultilinkFieldValueSharedLink & {
471
+ type EmailLink = SharedLink & {
472
472
  linktype: 'email';
473
473
  /**
474
474
  * Email address
@@ -478,10 +478,10 @@ type MultilinkFieldValueEmailLink = MultilinkFieldValueSharedLink & {
478
478
  /**
479
479
  * Link to a Storyblok asset.
480
480
  */
481
- type MultilinkFieldValueAssetLink = MultilinkFieldValueSharedLink & {
481
+ type AssetLink = SharedLink & {
482
482
  linktype: 'asset';
483
483
  };
484
- type MultilinkFieldValueSharedLink = {
484
+ type SharedLink = {
485
485
  /**
486
486
  * Identifies this as a multilink field
487
487
  */
package/dist/index.mjs CHANGED
@@ -11672,6 +11672,35 @@ function assertUniqueIdentities(components, datasources) {
11672
11672
  collect("datasource slug", datasources.map((datasource) => datasource.slug));
11673
11673
  if (collisions.length > 0) throw new CommandError(`Duplicate schema definitions: ${collisions.join(", ")}. Each block name, datasource name, and datasource slug must be unique; rename or remove the duplicate before pushing.`);
11674
11674
  }
11675
+ /**
11676
+ * Fails the load when a block declares a field the wire form cannot carry.
11677
+ *
11678
+ * A field is keyed on the wire by its `name` and identified by its `type`, so
11679
+ * one missing either is unpushable: the mapping drops a nameless field outright,
11680
+ * and a typeless one reaches the Management API as an empty object, which the
11681
+ * API discards on the way in. Either way the field is gone from the pushed
11682
+ * component and nothing reports it. `defineField` rejects both at compile time;
11683
+ * this catches a schema authored in plain JavaScript or assembled at runtime.
11684
+ * `schema validate` reports the same fields as `invalid_field` /
11685
+ * `missing_field_name` / `missing_field_type`.
11686
+ */
11687
+ function assertPushableFields(components) {
11688
+ const problems = [];
11689
+ for (const component of components) {
11690
+ const blockLabel = typeof component.name === "string" ? `block "${component.name}"` : "an unnamed block";
11691
+ (Array.isArray(component.fields) ? component.fields : []).forEach((field, index) => {
11692
+ if (!isRecord(field)) {
11693
+ problems.push(`the entry at index ${index} in ${blockLabel} is not an object`);
11694
+ return;
11695
+ }
11696
+ const hasName = typeof field.name === "string" && field.name !== "";
11697
+ const fieldLabel = hasName ? `field "${String(field.name)}" in ${blockLabel}` : `the field at index ${index} in ${blockLabel}`;
11698
+ if (!hasName) problems.push(`${fieldLabel} has no "name"`);
11699
+ if (typeof field.type !== "string" || field.type.trim() === "") problems.push(`${fieldLabel} has no "type"`);
11700
+ });
11701
+ }
11702
+ if (problems.length > 0) throw new CommandError(`Schema fields that cannot be pushed: ${problems.join(", ")}. Run \`storyblok schema validate\` for the full report.`);
11703
+ }
11675
11704
  const toArray = (value) => Array.isArray(value) ? value : [];
11676
11705
  /**
11677
11706
  * Classifies a module's exports into wire components, datasources, and folders,
@@ -11682,6 +11711,7 @@ const toArray = (value) => Array.isArray(value) ? value : [];
11682
11711
  function classifyExports(moduleExports) {
11683
11712
  const { components, datasources, folders } = collectSchemaExports(moduleExports);
11684
11713
  assertUniqueIdentities(components, datasources);
11714
+ assertPushableFields(components);
11685
11715
  const registered = folders.map((folder) => folder.path);
11686
11716
  const derived = [];
11687
11717
  for (const component of components) {