@datocms/cma-client 5.1.3 → 5.1.4

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 (84) hide show
  1. package/dist/cjs/fieldTypes/lat_lon.js +6 -6
  2. package/dist/cjs/fieldTypes/lat_lon.js.map +1 -1
  3. package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
  4. package/dist/cjs/fieldTypes/single_block.js.map +1 -1
  5. package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
  6. package/dist/cjs/generated/Client.js +1 -1
  7. package/dist/cjs/generated/resources/Item.js +41 -23
  8. package/dist/cjs/generated/resources/Item.js.map +1 -1
  9. package/dist/cjs/generated/resources/ScheduledPublication.js +4 -2
  10. package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
  11. package/dist/cjs/generated/resources/ScheduledUnpublishing.js +4 -2
  12. package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
  13. package/dist/cjs/generated/resources/Upload.js +4 -2
  14. package/dist/cjs/generated/resources/Upload.js.map +1 -1
  15. package/dist/cjs/index.js +1 -0
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
  18. package/dist/cjs/utilities/itemDefinition.js +3 -0
  19. package/dist/cjs/utilities/itemDefinition.js.map +1 -0
  20. package/dist/esm/fieldTypes/lat_lon.d.ts +5 -5
  21. package/dist/esm/fieldTypes/lat_lon.js +3 -3
  22. package/dist/esm/fieldTypes/lat_lon.js.map +1 -1
  23. package/dist/esm/fieldTypes/rich_text.d.ts +8 -7
  24. package/dist/esm/fieldTypes/rich_text.js.map +1 -1
  25. package/dist/esm/fieldTypes/single_block.d.ts +15 -14
  26. package/dist/esm/fieldTypes/single_block.js.map +1 -1
  27. package/dist/esm/fieldTypes/structured_text.d.ts +13 -12
  28. package/dist/esm/fieldTypes/structured_text.js.map +1 -1
  29. package/dist/esm/generated/ApiTypes.d.ts +67 -62
  30. package/dist/esm/generated/Client.js +1 -1
  31. package/dist/esm/generated/RawApiTypes.d.ts +116 -121
  32. package/dist/esm/generated/resources/Field.d.ts +230 -230
  33. package/dist/esm/generated/resources/Item.d.ts +42 -24
  34. package/dist/esm/generated/resources/Item.js +41 -23
  35. package/dist/esm/generated/resources/Item.js.map +1 -1
  36. package/dist/esm/generated/resources/ItemVersion.d.ts +1 -1
  37. package/dist/esm/generated/resources/ScheduledPublication.d.ts +5 -2
  38. package/dist/esm/generated/resources/ScheduledPublication.js +4 -2
  39. package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
  40. package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +5 -2
  41. package/dist/esm/generated/resources/ScheduledUnpublishing.js +4 -2
  42. package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
  43. package/dist/esm/generated/resources/Upload.d.ts +10 -2
  44. package/dist/esm/generated/resources/Upload.js +4 -2
  45. package/dist/esm/generated/resources/Upload.js.map +1 -1
  46. package/dist/esm/index.d.ts +1 -0
  47. package/dist/esm/index.js +1 -0
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/utilities/buildBlockRecord.d.ts +5 -31
  50. package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
  51. package/dist/esm/utilities/itemDefinition.d.ts +74 -0
  52. package/dist/esm/utilities/itemDefinition.js +2 -0
  53. package/dist/esm/utilities/itemDefinition.js.map +1 -0
  54. package/dist/types/fieldTypes/lat_lon.d.ts +5 -5
  55. package/dist/types/fieldTypes/rich_text.d.ts +8 -7
  56. package/dist/types/fieldTypes/single_block.d.ts +15 -14
  57. package/dist/types/fieldTypes/structured_text.d.ts +13 -12
  58. package/dist/types/generated/ApiTypes.d.ts +67 -62
  59. package/dist/types/generated/RawApiTypes.d.ts +116 -121
  60. package/dist/types/generated/resources/Field.d.ts +230 -230
  61. package/dist/types/generated/resources/Item.d.ts +42 -24
  62. package/dist/types/generated/resources/ItemVersion.d.ts +1 -1
  63. package/dist/types/generated/resources/ScheduledPublication.d.ts +5 -2
  64. package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +5 -2
  65. package/dist/types/generated/resources/Upload.d.ts +10 -2
  66. package/dist/types/index.d.ts +1 -0
  67. package/dist/types/utilities/buildBlockRecord.d.ts +5 -31
  68. package/dist/types/utilities/itemDefinition.d.ts +74 -0
  69. package/package.json +5 -5
  70. package/resources.json +564 -0
  71. package/src/fieldTypes/lat_lon.ts +7 -9
  72. package/src/fieldTypes/rich_text.ts +22 -13
  73. package/src/fieldTypes/single_block.ts +42 -32
  74. package/src/fieldTypes/structured_text.ts +60 -23
  75. package/src/generated/ApiTypes.ts +110 -70
  76. package/src/generated/Client.ts +1 -1
  77. package/src/generated/RawApiTypes.ts +160 -138
  78. package/src/generated/resources/Item.ts +360 -108
  79. package/src/generated/resources/ScheduledPublication.ts +31 -11
  80. package/src/generated/resources/ScheduledUnpublishing.ts +31 -11
  81. package/src/generated/resources/Upload.ts +54 -12
  82. package/src/index.ts +1 -0
  83. package/src/utilities/buildBlockRecord.ts +19 -3
  84. package/src/utilities/itemDefinition.ts +229 -0
@@ -2,14 +2,12 @@ import type { LocalizedFieldValue } from '../utilities/fieldValue';
2
2
  import type { MapEditorConfiguration } from './appearance/map';
3
3
  import type { RequiredValidator } from './validators/required';
4
4
 
5
- export type LocationFieldValue = {
5
+ export type LatLonFieldValue = {
6
6
  latitude: number;
7
7
  longitude: number;
8
8
  } | null;
9
9
 
10
- export function isLocationFieldValue(
11
- value: unknown,
12
- ): value is LocationFieldValue {
10
+ export function isLatLonFieldValue(value: unknown): value is LatLonFieldValue {
13
11
  if (value === null) return true;
14
12
  return (
15
13
  typeof value === 'object' &&
@@ -19,22 +17,22 @@ export function isLocationFieldValue(
19
17
  );
20
18
  }
21
19
 
22
- export function isLocalizedLocationFieldValue(
20
+ export function isLocalizedLatLonFieldValue(
23
21
  value: unknown,
24
- ): value is LocalizedFieldValue<LocationFieldValue> {
22
+ ): value is LocalizedFieldValue<LatLonFieldValue> {
25
23
  return (
26
24
  typeof value === 'object' &&
27
25
  value !== null &&
28
- Object.values(value).every(isLocationFieldValue)
26
+ Object.values(value).every(isLatLonFieldValue)
29
27
  );
30
28
  }
31
29
 
32
- export type LocationFieldValidators = {
30
+ export type LatLonFieldValidators = {
33
31
  /** Value must be specified or it won't be valid */
34
32
  required?: RequiredValidator;
35
33
  };
36
34
 
37
- export type LocationFieldAppearance =
35
+ export type LatLonFieldAppearance =
38
36
  | { editor: 'map'; parameters: MapEditorConfiguration }
39
37
  | {
40
38
  /** Plugin ID */
@@ -1,5 +1,6 @@
1
1
  import type * as RawApiTypes from '../generated/RawApiTypes';
2
2
  import type { LocalizedFieldValue } from '../utilities/fieldValue';
3
+ import type { ItemDefinition } from '../utilities/itemDefinition';
3
4
  import type { RichTextEditorConfiguration } from './appearance/rich_text';
4
5
  import {
5
6
  type BlockItemInARequest,
@@ -41,7 +42,7 @@ import type { SizeValidator } from './validators/size';
41
42
  /**
42
43
  * Basic Modular Content field value - array of string block IDs (lightweight references)
43
44
  */
44
- export type RichTextFieldValue = string[] | null;
45
+ export type RichTextFieldValue = string[];
45
46
 
46
47
  /**
47
48
  * =============================================================================
@@ -60,7 +61,9 @@ export type RichTextFieldValue = string[] | null;
60
61
  * - RawApiTypes.Item: Full block object with ID (for updates)
61
62
  * - Omit<RawApiTypes.Item, 'id'>: Block object without ID (for creation)
62
63
  */
63
- export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
64
+ export type RichTextFieldValueAsRequest<
65
+ D extends ItemDefinition = ItemDefinition,
66
+ > = BlockItemInARequest<D>[] | null;
64
67
 
65
68
  /**
66
69
  * =============================================================================
@@ -75,7 +78,9 @@ export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
75
78
  /**
76
79
  * Modular Content field value with nested blocks - array of fully populated block objects
77
80
  */
78
- export type RichTextFieldValueWithNestedBlocks = RawApiTypes.Item[] | null;
81
+ export type RichTextFieldValueWithNestedBlocks<
82
+ D extends ItemDefinition = ItemDefinition,
83
+ > = RawApiTypes.Item<D>[];
79
84
 
80
85
  /**
81
86
  * =============================================================================
@@ -111,9 +116,9 @@ export function isLocalizedRichTextFieldValue(
111
116
  * Type guard for Modular Content field values in API request format.
112
117
  * Allows blocks as string IDs, full objects with IDs, or objects without IDs.
113
118
  */
114
- export function isRichTextFieldValueAsRequest(
115
- value: unknown,
116
- ): value is RichTextFieldValueAsRequest {
119
+ export function isRichTextFieldValueAsRequest<
120
+ D extends ItemDefinition = ItemDefinition,
121
+ >(value: unknown): value is RichTextFieldValueAsRequest<D> {
117
122
  if (value === null) return true;
118
123
 
119
124
  if (!Array.isArray(value)) return false;
@@ -127,9 +132,11 @@ export function isRichTextFieldValueAsRequest(
127
132
  });
128
133
  }
129
134
 
130
- export function isLocalizedRichTextFieldValueAsRequest(
135
+ export function isLocalizedRichTextFieldValueAsRequest<
136
+ D extends ItemDefinition = ItemDefinition,
137
+ >(
131
138
  value: unknown,
132
- ): value is LocalizedFieldValue<RichTextFieldValueAsRequest> {
139
+ ): value is LocalizedFieldValue<RichTextFieldValueAsRequest<D>> {
133
140
  return (
134
141
  typeof value === 'object' &&
135
142
  value !== null &&
@@ -141,9 +148,9 @@ export function isLocalizedRichTextFieldValueAsRequest(
141
148
  * Type guard for Modular Content field values with nested blocks (?nested=true format).
142
149
  * Ensures all blocks are full RawApiTypes.Item objects with complete data.
143
150
  */
144
- export function isRichTextFieldValueWithNestedBlocks(
145
- value: unknown,
146
- ): value is RichTextFieldValueWithNestedBlocks {
151
+ export function isRichTextFieldValueWithNestedBlocks<
152
+ D extends ItemDefinition = ItemDefinition,
153
+ >(value: unknown): value is RichTextFieldValueWithNestedBlocks<D> {
147
154
  if (value === null) return true;
148
155
 
149
156
  if (!Array.isArray(value)) return false;
@@ -154,9 +161,11 @@ export function isRichTextFieldValueWithNestedBlocks(
154
161
  });
155
162
  }
156
163
 
157
- export function isLocalizedRichTextFieldValueWithNestedBlocks(
164
+ export function isLocalizedRichTextFieldValueWithNestedBlocks<
165
+ D extends ItemDefinition = ItemDefinition,
166
+ >(
158
167
  value: unknown,
159
- ): value is LocalizedFieldValue<RichTextFieldValueWithNestedBlocks> {
168
+ ): value is LocalizedFieldValue<RichTextFieldValueWithNestedBlocks<D>> {
160
169
  return (
161
170
  typeof value === 'object' &&
162
171
  value !== null &&
@@ -1,5 +1,6 @@
1
1
  import type * as RawApiTypes from '../generated/RawApiTypes';
2
2
  import type { LocalizedFieldValue } from '../utilities/fieldValue';
3
+ import type { ItemDefinition } from '../utilities/itemDefinition';
3
4
 
4
5
  import type { FramedSingleBlockEditorConfiguration } from './appearance/framed_single_block';
5
6
  import type { FramelessSingleBlockEditorConfiguration } from './appearance/frameless_single_block';
@@ -51,14 +52,15 @@ export type SingleBlockFieldValue = string | null;
51
52
  */
52
53
 
53
54
  /** Represents an existing block in a CMA request */
54
- export type UnchangedBlockInARequest = string;
55
+ export type UnchangedBlockInARequest<
56
+ D extends ItemDefinition = ItemDefinition,
57
+ > = RawApiTypes.Item<D>['id'];
55
58
  /** Represents a block we want to update in a CMA request */
56
- export type UpdatedBlockInARequest = OptionalFields<RawApiTypes.Item, 'meta'>;
59
+ export type UpdatedBlockInARequest<D extends ItemDefinition = ItemDefinition> =
60
+ OptionalFields<RawApiTypes.Item<D>, 'meta'>;
57
61
  /** Represents a new block to create in a CMA request */
58
- export type NewBlockInARequest = OptionalFields<
59
- RawApiTypes.Item,
60
- 'id' | 'meta'
61
- >;
62
+ export type NewBlockInARequest<D extends ItemDefinition = ItemDefinition> =
63
+ OptionalFields<RawApiTypes.Item<D>, 'id' | 'meta'>;
62
64
 
63
65
  /**
64
66
  * Union type representing the different ways a block can be specified in API requests:
@@ -68,10 +70,10 @@ export type NewBlockInARequest = OptionalFields<
68
70
  *
69
71
  * Also, 'meta' can always be omitted
70
72
  */
71
- export type BlockItemInARequest =
73
+ export type BlockItemInARequest<D extends ItemDefinition = ItemDefinition> =
72
74
  | UnchangedBlockInARequest
73
- | UpdatedBlockInARequest
74
- | NewBlockInARequest;
75
+ | UpdatedBlockInARequest<D>
76
+ | NewBlockInARequest<D>;
75
77
 
76
78
  /**
77
79
  * Single Block field value for API requests - allows flexible block representations:
@@ -79,7 +81,9 @@ export type BlockItemInARequest =
79
81
  * - Full block object with ID (to update an existing block)
80
82
  * - Block object without ID (to create a new block)
81
83
  */
82
- export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
84
+ export type SingleBlockFieldValueAsRequest<
85
+ D extends ItemDefinition = ItemDefinition,
86
+ > = BlockItemInARequest<D> | null;
83
87
 
84
88
  /**
85
89
  * =============================================================================
@@ -94,7 +98,9 @@ export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
94
98
  /**
95
99
  * Single Block field value with nested block - fully populated block object
96
100
  */
97
- export type SingleBlockFieldValueWithNestedBlocks = RawApiTypes.Item | null;
101
+ export type SingleBlockFieldValueWithNestedBlocks<
102
+ D extends ItemDefinition = ItemDefinition,
103
+ > = RawApiTypes.Item<D> | null;
98
104
 
99
105
  /**
100
106
  * =============================================================================
@@ -110,17 +116,16 @@ export function isItemId(input: unknown): input is string {
110
116
  return typeof input === 'string';
111
117
  }
112
118
 
113
- export type ItemWithOptionalIdAndMeta = OptionalFields<
114
- RawApiTypes.Item,
115
- 'id' | 'meta'
116
- >;
119
+ export type ItemWithOptionalIdAndMeta<
120
+ D extends ItemDefinition = ItemDefinition,
121
+ > = OptionalFields<RawApiTypes.Item<D>, 'id' | 'meta'>;
117
122
 
118
123
  /**
119
124
  * Validates if the input is a RawApiTypes.Item object (with optional `id` and `meta`)
120
125
  */
121
- export function isItemWithOptionalIdAndMeta(
122
- block: unknown,
123
- ): block is ItemWithOptionalIdAndMeta {
126
+ export function isItemWithOptionalIdAndMeta<
127
+ D extends ItemDefinition = ItemDefinition,
128
+ >(block: unknown): block is ItemWithOptionalIdAndMeta<D> {
124
129
  return (
125
130
  typeof block === 'object' &&
126
131
  block !== null &&
@@ -129,14 +134,15 @@ export function isItemWithOptionalIdAndMeta(
129
134
  );
130
135
  }
131
136
 
132
- export type ItemWithOptionalMeta = OptionalFields<RawApiTypes.Item, 'meta'>;
137
+ export type ItemWithOptionalMeta<D extends ItemDefinition = ItemDefinition> =
138
+ OptionalFields<RawApiTypes.Item<D>, 'meta'>;
133
139
 
134
140
  /**
135
141
  * Validates if the input is a a complete RawApiTypes.Item object with optional `meta`
136
142
  */
137
- export function isItemWithOptionalMeta(
138
- block: unknown,
139
- ): block is ItemWithOptionalMeta {
143
+ export function isItemWithOptionalMeta<
144
+ D extends ItemDefinition = ItemDefinition,
145
+ >(block: unknown): block is ItemWithOptionalMeta<D> {
140
146
  return (
141
147
  isItemWithOptionalIdAndMeta(block) &&
142
148
  'id' in block &&
@@ -174,9 +180,9 @@ export function isLocalizedSingleBlockFieldValue(
174
180
  * Type guard for Single Block field values in API request format.
175
181
  * Allows block as string ID, full object with ID, or object without ID.
176
182
  */
177
- export function isSingleBlockFieldValueAsRequest(
178
- value: unknown,
179
- ): value is SingleBlockFieldValueAsRequest {
183
+ export function isSingleBlockFieldValueAsRequest<
184
+ D extends ItemDefinition = ItemDefinition,
185
+ >(value: unknown): value is SingleBlockFieldValueAsRequest<D> {
180
186
  if (value === null) return true;
181
187
 
182
188
  // String ID - referencing existing block
@@ -186,9 +192,11 @@ export function isSingleBlockFieldValueAsRequest(
186
192
  return isItemWithOptionalIdAndMeta(value);
187
193
  }
188
194
 
189
- export function isLocalizedSingleBlockFieldValueAsRequest(
195
+ export function isLocalizedSingleBlockFieldValueAsRequest<
196
+ D extends ItemDefinition = ItemDefinition,
197
+ >(
190
198
  value: unknown,
191
- ): value is LocalizedFieldValue<SingleBlockFieldValueAsRequest> {
199
+ ): value is LocalizedFieldValue<SingleBlockFieldValueAsRequest<D>> {
192
200
  return (
193
201
  typeof value === 'object' &&
194
202
  value !== null &&
@@ -200,18 +208,20 @@ export function isLocalizedSingleBlockFieldValueAsRequest(
200
208
  * Type guard for Single Block field values with nested blocks (?nested=true format).
201
209
  * Ensures block is a full RawApiTypes.Item object with complete data.
202
210
  */
203
- export function isSingleBlockFieldValueWithNestedBlocks(
204
- value: unknown,
205
- ): value is SingleBlockFieldValueWithNestedBlocks {
211
+ export function isSingleBlockFieldValueWithNestedBlocks<
212
+ D extends ItemDefinition = ItemDefinition,
213
+ >(value: unknown): value is SingleBlockFieldValueWithNestedBlocks<D> {
206
214
  if (value === null) return true;
207
215
 
208
216
  // Must be a full object with ID (nested format always includes complete block objects)
209
217
  return isItemWithOptionalMeta(value);
210
218
  }
211
219
 
212
- export function isLocalizedSingleBlockFieldValueWithNestedBlocks(
220
+ export function isLocalizedSingleBlockFieldValueWithNestedBlocks<
221
+ D extends ItemDefinition = ItemDefinition,
222
+ >(
213
223
  value: unknown,
214
- ): value is LocalizedFieldValue<SingleBlockFieldValueWithNestedBlocks> {
224
+ ): value is LocalizedFieldValue<SingleBlockFieldValueWithNestedBlocks<D>> {
215
225
  return (
216
226
  typeof value === 'object' &&
217
227
  value !== null &&
@@ -10,6 +10,7 @@ import {
10
10
  } from 'datocms-structured-text-utils';
11
11
  import type * as RawApiTypes from '../generated/RawApiTypes';
12
12
  import type { LocalizedFieldValue } from '../utilities/fieldValue';
13
+ import type { ItemDefinition } from '../utilities/itemDefinition';
13
14
  import type { StructuredTextEditorConfiguration } from './appearance/structured_text';
14
15
  import {
15
16
  type BlockItemInARequest,
@@ -56,17 +57,26 @@ import type { StructuredTextLinksValidator } from './validators/structured_text_
56
57
  /**
57
58
  * Variant of 'block' structured text node for API requests
58
59
  */
59
- export type BlockAsRequest = Block<BlockItemInARequest>;
60
+ export type BlockAsRequest<D extends ItemDefinition = ItemDefinition> = Block<
61
+ BlockItemInARequest<D>
62
+ >;
60
63
 
61
64
  /**
62
65
  * Variant of 'inlineBlock' structured text node for API requests
63
66
  */
64
- export type InlineBlockAsRequest = InlineBlock<BlockItemInARequest>;
67
+ export type InlineBlockAsRequest<D extends ItemDefinition = ItemDefinition> =
68
+ InlineBlock<BlockItemInARequest<D>>;
65
69
 
66
70
  /**
67
71
  * Variant of Structured Text document for API requests
68
72
  */
69
- export type DocumentAsRequest = Document<BlockItemInARequest>;
73
+ export type DocumentAsRequest<
74
+ BlockItemDefinition extends ItemDefinition = ItemDefinition,
75
+ InlineBlockItemDefinition extends ItemDefinition = ItemDefinition,
76
+ > = Document<
77
+ BlockItemInARequest<BlockItemDefinition>,
78
+ BlockItemInARequest<InlineBlockItemDefinition>
79
+ >;
70
80
 
71
81
  /**
72
82
  * =============================================================================
@@ -81,17 +91,26 @@ export type DocumentAsRequest = Document<BlockItemInARequest>;
81
91
  /**
82
92
  * Variant of 'block' structured text node for ?nested=true API responses
83
93
  */
84
- export type BlockWithNestedBlocks = Block<RawApiTypes.Item>;
94
+ export type BlockWithNestedBlocks<D extends ItemDefinition = ItemDefinition> =
95
+ Block<RawApiTypes.Item<D>>;
85
96
 
86
97
  /**
87
98
  * Variant of 'inlineBlock' structured text node for ?nested=true API responses
88
99
  */
89
- export type InlineBlockWithNestedBlocks = InlineBlock<RawApiTypes.Item>;
100
+ export type InlineBlockWithNestedBlocks<
101
+ D extends ItemDefinition = ItemDefinition,
102
+ > = InlineBlock<RawApiTypes.Item<D>>;
90
103
 
91
104
  /**
92
105
  * Variant of Structured Text document for ?nested=true API responses
93
106
  */
94
- export type DocumentWithNestedBlocks = Document<RawApiTypes.Item>;
107
+ export type DocumentWithNestedBlocks<
108
+ BlockItemDefinition extends ItemDefinition = ItemDefinition,
109
+ InlineBlockItemDefinition extends ItemDefinition = ItemDefinition,
110
+ > = Document<
111
+ RawApiTypes.Item<BlockItemDefinition>,
112
+ RawApiTypes.Item<InlineBlockItemDefinition>
113
+ >;
95
114
 
96
115
  /**
97
116
  * =============================================================================
@@ -104,21 +123,29 @@ export type DocumentWithNestedBlocks = Document<RawApiTypes.Item>;
104
123
  * Can be null (empty field) or a document with blocks as string IDs
105
124
  */
106
125
  export type StructuredTextFieldValue = Document | null;
107
- export type StructuredTextFieldValueAsRequest = DocumentAsRequest | null;
108
- export type StructuredTextFieldValueWithNestedBlocks =
109
- DocumentWithNestedBlocks | null;
126
+ export type StructuredTextFieldValueAsRequest<
127
+ BlockItemDefinition extends ItemDefinition = ItemDefinition,
128
+ InlineBlockItemDefinition extends ItemDefinition = ItemDefinition,
129
+ > = DocumentAsRequest<BlockItemDefinition, InlineBlockItemDefinition> | null;
130
+ export type StructuredTextFieldValueWithNestedBlocks<
131
+ BlockItemDefinition extends ItemDefinition = ItemDefinition,
132
+ InlineBlockItemDefinition extends ItemDefinition = ItemDefinition,
133
+ > = DocumentWithNestedBlocks<
134
+ BlockItemDefinition,
135
+ InlineBlockItemDefinition
136
+ > | null;
110
137
 
111
138
  /**
112
139
  * Utility function to validate all block/inlineBlock nodes in a structured text document tree.
113
140
  * Calls the provided callback for each block/inlineBlock node found and returns true only if all pass.
114
141
  */
115
- function validateAllBlockNodes<T>(
116
- node: Node<T>,
117
- callback: (node: Block<T> | InlineBlock<T>) => boolean,
142
+ function validateAllBlockNodes<B, I>(
143
+ node: Node<B, I>,
144
+ callback: (node: Block<B> | InlineBlock<I>) => boolean,
118
145
  ): boolean {
119
146
  return everyNode(node, (currentNode) => {
120
147
  // If this is a block or inlineBlock node, validate it with the callback
121
- if (isBlock<T>(currentNode) || isInlineBlock<T>(currentNode)) {
148
+ if (isBlock(currentNode) || isInlineBlock(currentNode)) {
122
149
  return callback(currentNode);
123
150
  }
124
151
  // For all other node types, they're valid by default
@@ -135,7 +162,7 @@ export function isStructuredTextFieldValue(
135
162
  ): value is StructuredTextFieldValue {
136
163
  if (value === null) return true;
137
164
 
138
- if (!isDocument<unknown>(value)) {
165
+ if (!isDocument<unknown, unknown>(value)) {
139
166
  return false;
140
167
  }
141
168
 
@@ -159,9 +186,15 @@ export function isLocalizedStructuredTextFieldValue(
159
186
  * Type guard for structured text field values in API request format.
160
187
  * Allows blocks as string IDs, full objects with IDs, or objects without IDs.
161
188
  */
162
- export function isStructuredTextFieldValueAsRequest(
189
+ export function isStructuredTextFieldValueAsRequest<
190
+ BlockItemDefinition extends ItemDefinition = ItemDefinition,
191
+ InlineBlockItemDefinition extends ItemDefinition = ItemDefinition,
192
+ >(
163
193
  value: unknown,
164
- ): value is StructuredTextFieldValueAsRequest {
194
+ ): value is StructuredTextFieldValueAsRequest<
195
+ BlockItemDefinition,
196
+ InlineBlockItemDefinition
197
+ > {
165
198
  if (value === null) return true;
166
199
 
167
200
  if (!isDocument<unknown>(value)) {
@@ -180,9 +213,11 @@ export function isStructuredTextFieldValueAsRequest(
180
213
  });
181
214
  }
182
215
 
183
- export function isLocalizedStructuredTextFieldValueAsRequest(
216
+ export function isLocalizedStructuredTextFieldValueAsRequest<
217
+ D extends ItemDefinition = ItemDefinition,
218
+ >(
184
219
  value: unknown,
185
- ): value is LocalizedFieldValue<StructuredTextFieldValueAsRequest> {
220
+ ): value is LocalizedFieldValue<StructuredTextFieldValueAsRequest<D>> {
186
221
  return (
187
222
  typeof value === 'object' &&
188
223
  value !== null &&
@@ -194,9 +229,9 @@ export function isLocalizedStructuredTextFieldValueAsRequest(
194
229
  * Type guard for structured text field values with nested blocks (?nested=true format).
195
230
  * Ensures all block/inlineBlock nodes have full RawApiTypes.Item objects.
196
231
  */
197
- export function isStructuredTextFieldValueWithNestedBlocks(
198
- value: unknown,
199
- ): value is StructuredTextFieldValueWithNestedBlocks {
232
+ export function isStructuredTextFieldValueWithNestedBlocks<
233
+ D extends ItemDefinition = ItemDefinition,
234
+ >(value: unknown): value is StructuredTextFieldValueWithNestedBlocks<D> {
200
235
  if (value === null) return true;
201
236
 
202
237
  if (!isDocument<unknown>(value)) {
@@ -212,9 +247,11 @@ export function isStructuredTextFieldValueWithNestedBlocks(
212
247
  });
213
248
  }
214
249
 
215
- export function isLocalizedStructuredTextFieldValueWithNestedBlocks(
250
+ export function isLocalizedStructuredTextFieldValueWithNestedBlocks<
251
+ D extends ItemDefinition = ItemDefinition,
252
+ >(
216
253
  value: unknown,
217
- ): value is LocalizedFieldValue<StructuredTextFieldValueWithNestedBlocks> {
254
+ ): value is LocalizedFieldValue<StructuredTextFieldValueWithNestedBlocks<D>> {
218
255
  return (
219
256
  typeof value === 'object' &&
220
257
  value !== null &&