@datocms/cma-client 5.1.11 → 5.1.13

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 (118) hide show
  1. package/README.md +313 -178
  2. package/dist/cjs/fieldTypes/file.js +6 -6
  3. package/dist/cjs/fieldTypes/gallery.js +7 -7
  4. package/dist/cjs/fieldTypes/rich_text.js +14 -12
  5. package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
  6. package/dist/cjs/fieldTypes/schema.js +3 -0
  7. package/dist/cjs/fieldTypes/schema.js.map +1 -0
  8. package/dist/cjs/fieldTypes/single_block.js +13 -12
  9. package/dist/cjs/fieldTypes/single_block.js.map +1 -1
  10. package/dist/cjs/fieldTypes/structured_text.js +13 -12
  11. package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
  12. package/dist/cjs/generated/Client.js +1 -1
  13. package/dist/cjs/generated/resources/Item.js.map +1 -1
  14. package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
  15. package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
  16. package/dist/cjs/generated/resources/Upload.js.map +1 -1
  17. package/dist/cjs/index.js +1 -0
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/cjs/utilities/buildBlockRecord.js +1 -46
  20. package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
  21. package/dist/cjs/utilities/duplicateBlockRecord.js +50 -0
  22. package/dist/cjs/utilities/duplicateBlockRecord.js.map +1 -0
  23. package/dist/cjs/utilities/inspectItem.js +50 -20
  24. package/dist/cjs/utilities/inspectItem.js.map +1 -1
  25. package/dist/cjs/utilities/nonRecursiveBlocks.js +1 -170
  26. package/dist/cjs/utilities/nonRecursiveBlocks.js.map +1 -1
  27. package/dist/cjs/utilities/recursiveBlocks.js +52 -112
  28. package/dist/cjs/utilities/recursiveBlocks.js.map +1 -1
  29. package/dist/esm/fieldTypes/file.d.ts +3 -3
  30. package/dist/esm/fieldTypes/file.js +3 -3
  31. package/dist/esm/fieldTypes/gallery.d.ts +5 -5
  32. package/dist/esm/fieldTypes/gallery.js +5 -5
  33. package/dist/esm/fieldTypes/rich_text.d.ts +8 -9
  34. package/dist/esm/fieldTypes/rich_text.js +9 -7
  35. package/dist/esm/fieldTypes/rich_text.js.map +1 -1
  36. package/dist/esm/fieldTypes/schema.d.ts +59 -0
  37. package/dist/esm/fieldTypes/schema.js +2 -0
  38. package/dist/esm/fieldTypes/schema.js.map +1 -0
  39. package/dist/esm/fieldTypes/single_block.d.ts +30 -15
  40. package/dist/esm/fieldTypes/single_block.js +8 -7
  41. package/dist/esm/fieldTypes/single_block.js.map +1 -1
  42. package/dist/esm/fieldTypes/structured_text.d.ts +14 -15
  43. package/dist/esm/fieldTypes/structured_text.js +8 -7
  44. package/dist/esm/fieldTypes/structured_text.js.map +1 -1
  45. package/dist/esm/generated/ApiTypes.d.ts +94 -980
  46. package/dist/esm/generated/Client.js +1 -1
  47. package/dist/esm/generated/RawApiTypes.d.ts +160 -999
  48. package/dist/esm/generated/resources/Field.d.ts +300 -300
  49. package/dist/esm/generated/resources/Item.d.ts +34 -34
  50. package/dist/esm/generated/resources/Item.js.map +1 -1
  51. package/dist/esm/generated/resources/ItemVersion.d.ts +3 -1
  52. package/dist/esm/generated/resources/ScheduledPublication.d.ts +3 -3
  53. package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
  54. package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +3 -3
  55. package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
  56. package/dist/esm/generated/resources/Upload.d.ts +6 -6
  57. package/dist/esm/generated/resources/Upload.js.map +1 -1
  58. package/dist/esm/index.d.ts +1 -0
  59. package/dist/esm/index.js +1 -0
  60. package/dist/esm/index.js.map +1 -1
  61. package/dist/esm/utilities/buildBlockRecord.d.ts +11 -5
  62. package/dist/esm/utilities/buildBlockRecord.js +0 -44
  63. package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
  64. package/dist/esm/utilities/duplicateBlockRecord.d.ts +6 -0
  65. package/dist/esm/utilities/duplicateBlockRecord.js +46 -0
  66. package/dist/esm/utilities/duplicateBlockRecord.js.map +1 -0
  67. package/dist/esm/utilities/inspectItem.d.ts +3 -3
  68. package/dist/esm/utilities/inspectItem.js +28 -21
  69. package/dist/esm/utilities/inspectItem.js.map +1 -1
  70. package/dist/esm/utilities/itemDefinition.d.ts +25 -27
  71. package/dist/esm/utilities/nonRecursiveBlocks.d.ts +10 -75
  72. package/dist/esm/utilities/nonRecursiveBlocks.js +1 -164
  73. package/dist/esm/utilities/nonRecursiveBlocks.js.map +1 -1
  74. package/dist/esm/utilities/recursiveBlocks.d.ts +53 -23
  75. package/dist/esm/utilities/recursiveBlocks.js +52 -112
  76. package/dist/esm/utilities/recursiveBlocks.js.map +1 -1
  77. package/dist/types/fieldTypes/file.d.ts +3 -3
  78. package/dist/types/fieldTypes/gallery.d.ts +5 -5
  79. package/dist/types/fieldTypes/rich_text.d.ts +8 -9
  80. package/dist/types/fieldTypes/schema.d.ts +59 -0
  81. package/dist/types/fieldTypes/single_block.d.ts +30 -15
  82. package/dist/types/fieldTypes/structured_text.d.ts +14 -15
  83. package/dist/types/generated/ApiTypes.d.ts +94 -980
  84. package/dist/types/generated/RawApiTypes.d.ts +160 -999
  85. package/dist/types/generated/resources/Field.d.ts +300 -300
  86. package/dist/types/generated/resources/Item.d.ts +34 -34
  87. package/dist/types/generated/resources/ItemVersion.d.ts +3 -1
  88. package/dist/types/generated/resources/ScheduledPublication.d.ts +3 -3
  89. package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +3 -3
  90. package/dist/types/generated/resources/Upload.d.ts +6 -6
  91. package/dist/types/index.d.ts +1 -0
  92. package/dist/types/utilities/buildBlockRecord.d.ts +11 -5
  93. package/dist/types/utilities/duplicateBlockRecord.d.ts +6 -0
  94. package/dist/types/utilities/inspectItem.d.ts +3 -3
  95. package/dist/types/utilities/itemDefinition.d.ts +25 -27
  96. package/dist/types/utilities/nonRecursiveBlocks.d.ts +10 -75
  97. package/dist/types/utilities/recursiveBlocks.d.ts +53 -23
  98. package/package.json +4 -4
  99. package/src/fieldTypes/file.ts +6 -6
  100. package/src/fieldTypes/gallery.ts +10 -10
  101. package/src/fieldTypes/rich_text.ts +26 -24
  102. package/src/fieldTypes/schema.ts +657 -0
  103. package/src/fieldTypes/single_block.ts +61 -38
  104. package/src/fieldTypes/structured_text.ts +57 -51
  105. package/src/generated/ApiTypes.ts +221 -1880
  106. package/src/generated/Client.ts +1 -1
  107. package/src/generated/RawApiTypes.ts +276 -2113
  108. package/src/generated/resources/Item.ts +93 -187
  109. package/src/generated/resources/ScheduledPublication.ts +4 -15
  110. package/src/generated/resources/ScheduledUnpublishing.ts +4 -15
  111. package/src/generated/resources/Upload.ts +9 -32
  112. package/src/index.ts +1 -0
  113. package/src/utilities/buildBlockRecord.ts +16 -56
  114. package/src/utilities/duplicateBlockRecord.ts +53 -0
  115. package/src/utilities/inspectItem.ts +64 -52
  116. package/src/utilities/itemDefinition.ts +109 -98
  117. package/src/utilities/nonRecursiveBlocks.ts +25 -279
  118. package/src/utilities/recursiveBlocks.ts +337 -72
@@ -22,17 +22,8 @@
22
22
  * particularly useful when block transformations require async operations like API calls.
23
23
  */
24
24
  import { type TreePath } from 'datocms-structured-text-utils';
25
- import type { BlockItemInARequest } from '../fieldTypes';
25
+ import type { BlockInRequest } from '../fieldTypes';
26
26
  import type * as ApiTypes from '../generated/ApiTypes';
27
- /**
28
- * Visit every block in a field value, calling the visitor function for each block found.
29
- * Supports rich text, single block, and structured text field types.
30
- *
31
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
32
- * @param nonLocalizedFieldValue - The non-localized field value containing blocks to visit
33
- * @param visitor - Synchronous function called for each block. Receives the block item and its path
34
- */
35
- export declare function nonRecursiveVisitBlocksInNonLocalizedFieldValue(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => void): void;
36
27
  /**
37
28
  * Visit every block in a field value, calling the visitor function for each block found.
38
29
  * Supports rich text, single block, and structured text field types.
@@ -42,7 +33,7 @@ export declare function nonRecursiveVisitBlocksInNonLocalizedFieldValue(fieldTyp
42
33
  * @param visitor - Asynchronous function called for each block. Receives the block item and its path
43
34
  * @returns Promise that resolves when all blocks have been visited
44
35
  */
45
- export declare function nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => Promise<void>): Promise<void>;
36
+ export declare function nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, visitor: (item: BlockInRequest, path: TreePath) => Promise<void>): Promise<void>;
46
37
  /**
47
38
  * Transform blocks in a field value by applying a mapping function to each block.
48
39
  * Creates a new field value structure with transformed blocks while preserving the original structure.
@@ -53,7 +44,7 @@ export declare function nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fie
53
44
  * @param mapper - Synchronous function that transforms each block. Receives block item and path, returns new block
54
45
  * @returns The new field value with transformed blocks
55
46
  */
56
- export declare function nonRecursiveMapBlocksInNonLocalizedFieldValue(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => BlockItemInARequest): unknown;
47
+ export declare function nonRecursiveMapBlocksInNonLocalizedFieldValue(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, mapper: (item: BlockInRequest, path: TreePath) => BlockInRequest): unknown;
57
48
  /**
58
49
  * Transform blocks in a field value by applying a mapping function to each block.
59
50
  * Creates a new field value structure with transformed blocks while preserving the original structure.
@@ -64,20 +55,7 @@ export declare function nonRecursiveMapBlocksInNonLocalizedFieldValue(fieldType:
64
55
  * @param mapper - Asynchronous function that transforms each block. Receives block item and path, returns new block
65
56
  * @returns Promise that resolves to the new field value with transformed blocks
66
57
  */
67
- export declare function nonRecursiveMapBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => Promise<BlockItemInARequest>): Promise<unknown>;
68
- /**
69
- * Find all blocks that match the predicate function.
70
- * Searches through all blocks in the non-localized field value and returns all matches.
71
- *
72
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
73
- * @param nonLocalizedFieldValue - The non-localized field value containing blocks to search
74
- * @param predicate - Synchronous function that tests each block. Should return true for matching blocks
75
- * @returns Array of objects, each containing a matching block and its path
76
- */
77
- export declare function nonRecursiveFindAllBlocksInNonLocalizedFieldValue(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): Array<{
78
- item: BlockItemInARequest;
79
- path: TreePath;
80
- }>;
58
+ export declare function nonRecursiveMapBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, mapper: (item: BlockInRequest, path: TreePath) => Promise<BlockInRequest>): Promise<unknown>;
81
59
  /**
82
60
  * Find all blocks that match the predicate function.
83
61
  * Searches through all blocks in the non-localized field value and returns all matches.
@@ -87,21 +65,10 @@ export declare function nonRecursiveFindAllBlocksInNonLocalizedFieldValue(fieldT
87
65
  * @param predicate - Asynchronous function that tests each block. Should return true for matching blocks
88
66
  * @returns Promise that resolves to an array of objects, each containing a matching block and its path
89
67
  */
90
- export declare function nonRecursiveFindAllBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<Array<{
91
- item: BlockItemInARequest;
68
+ export declare function nonRecursiveFindAllBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockInRequest, path: TreePath) => Promise<boolean>): Promise<Array<{
69
+ item: BlockInRequest;
92
70
  path: TreePath;
93
71
  }>>;
94
- /**
95
- * Filter blocks in a field value, removing those that don't match the predicate.
96
- * Creates a new field value containing only blocks that pass the predicate test.
97
- * Preserves the original field value structure and hierarchy.
98
- *
99
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
100
- * @param nonLocalizedFieldValue - The non-localized field value containing blocks to filter
101
- * @param predicate - Synchronous function that tests each block. Blocks returning false are removed
102
- * @returns The new field value with filtered blocks
103
- */
104
- export declare function nonRecursiveFilterBlocksInNonLocalizedFieldValue(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): unknown;
105
72
  /**
106
73
  * Filter blocks in a field value, removing those that don't match the predicate.
107
74
  * Creates a new field value containing only blocks that pass the predicate test.
@@ -112,19 +79,7 @@ export declare function nonRecursiveFilterBlocksInNonLocalizedFieldValue(fieldTy
112
79
  * @param predicate - Asynchronous function that tests each block. Blocks returning false are removed
113
80
  * @returns Promise that resolves to the new field value with filtered blocks
114
81
  */
115
- export declare function nonRecursiveFilterBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<unknown>;
116
- /**
117
- * Reduce all blocks in a field value to a single value by applying a reducer function.
118
- * Processes each block in the non-localized field value and accumulates the results into a single value.
119
- *
120
- * @template R - The type of the accumulated result
121
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
122
- * @param nonLocalizedFieldValue - The non-localized field value containing blocks to reduce
123
- * @param reducer - Synchronous function that processes each block and updates the accumulator
124
- * @param initialValue - The initial value for the accumulator
125
- * @returns The final accumulated value
126
- */
127
- export declare function nonRecursiveReduceBlocksInNonLocalizedFieldValue<R>(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => R, initialValue: R): R;
82
+ export declare function nonRecursiveFilterBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockInRequest, path: TreePath) => Promise<boolean>): Promise<unknown>;
128
83
  /**
129
84
  * Reduce all blocks in a field value to a single value by applying a reducer function.
130
85
  * Processes each block in the non-localized field value and accumulates the results into a single value.
@@ -136,17 +91,7 @@ export declare function nonRecursiveReduceBlocksInNonLocalizedFieldValue<R>(fiel
136
91
  * @param initialValue - The initial value for the accumulator
137
92
  * @returns Promise that resolves to the final accumulated value
138
93
  */
139
- export declare function nonRecursiveReduceBlocksInNonLocalizedFieldValueAsync<R>(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => Promise<R>, initialValue: R): Promise<R>;
140
- /**
141
- * Check if any block in the non-localized field value matches the predicate function.
142
- * Returns true as soon as the first matching block is found (short-circuit evaluation).
143
- *
144
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
145
- * @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
146
- * @param predicate - Synchronous function that tests each block. Should return true for matching blocks
147
- * @returns True if any block matches, false otherwise
148
- */
149
- export declare function nonRecursiveSomeBlocksInNonLocalizedFieldValue(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): boolean;
94
+ export declare function nonRecursiveReduceBlocksInNonLocalizedFieldValueAsync<R>(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, reducer: (accumulator: R, item: BlockInRequest, path: TreePath) => Promise<R>, initialValue: R): Promise<R>;
150
95
  /**
151
96
  * Check if any block in the non-localized field value matches the predicate function.
152
97
  * Returns true as soon as the first matching block is found (short-circuit evaluation).
@@ -156,17 +101,7 @@ export declare function nonRecursiveSomeBlocksInNonLocalizedFieldValue(fieldType
156
101
  * @param predicate - Asynchronous function that tests each block. Should return true for matching blocks
157
102
  * @returns Promise that resolves to true if any block matches, false otherwise
158
103
  */
159
- export declare function nonRecursiveSomeBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
160
- /**
161
- * Check if every block in the non-localized field value matches the predicate function.
162
- * Returns false as soon as the first non-matching block is found (short-circuit evaluation).
163
- *
164
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
165
- * @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
166
- * @param predicate - Synchronous function that tests each block. Should return true for valid blocks
167
- * @returns True if all blocks match, false otherwise
168
- */
169
- export declare function nonRecursiveEveryBlockInNonLocalizedFieldValue(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): boolean;
104
+ export declare function nonRecursiveSomeBlocksInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockInRequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
170
105
  /**
171
106
  * Check if every block in the non-localized field value matches the predicate function.
172
107
  * Returns false as soon as the first non-matching block is found (short-circuit evaluation).
@@ -176,4 +111,4 @@ export declare function nonRecursiveEveryBlockInNonLocalizedFieldValue(fieldType
176
111
  * @param predicate - Asynchronous function that tests each block. Should return true for valid blocks
177
112
  * @returns Promise that resolves to true if all blocks match, false otherwise
178
113
  */
179
- export declare function nonRecursiveEveryBlockInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
114
+ export declare function nonRecursiveEveryBlockInNonLocalizedFieldValueAsync(fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockInRequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
@@ -1,36 +1,47 @@
1
- import { type BlockItemInARequest } from '../fieldTypes';
1
+ import { type BlockInRequest, type RichTextFieldValue, type RichTextFieldValueInNestedResponse, type RichTextFieldValueInRequest, type SingleBlockFieldValue, type SingleBlockFieldValueInNestedResponse, type SingleBlockFieldValueInRequest, type StructuredTextFieldValue, type StructuredTextFieldValueInNestedResponse, type StructuredTextFieldValueInRequest } from '../fieldTypes';
2
2
  import type * as ApiTypes from '../generated/ApiTypes';
3
+ import type { ExtractNestedBlocksFromFieldValue } from './itemDefinition';
3
4
  import type { SchemaRepository } from './schemaRepository';
5
+ type RecognizableFieldValue = RichTextFieldValueInNestedResponse | SingleBlockFieldValueInNestedResponse | StructuredTextFieldValueInNestedResponse | RichTextFieldValueInRequest | SingleBlockFieldValueInRequest | StructuredTextFieldValueInRequest | RichTextFieldValue | SingleBlockFieldValue | StructuredTextFieldValue;
4
6
  /**
5
7
  * Path through a non-localized field value (ie. ['content', 0, 'attributes', 'title'])
6
8
  */
7
9
  export type TreePath = readonly (string | number)[];
10
+ /**
11
+ * Traversal direction for recursive operations
12
+ */
13
+ export type TraversalDirection = 'top-down' | 'bottom-up';
8
14
  /**
9
15
  * Recursively visit every block in a non-localized field value and all nested blocks within those blocks.
10
16
  * This function traverses not only the direct blocks in the non-localized field value but also recursively
11
17
  * visits blocks contained within the attributes of each block, creating a complete traversal
12
18
  * of the entire block hierarchy.
13
19
  *
14
- * @param schemaRepository - Repository for accessing DatoCMS schema information to resolve block structures
15
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
16
20
  * @param nonLocalizedFieldValue - The non-localized field value containing blocks to visit
21
+ * @param fieldType - The type field (determines how the value is processed)
22
+ * @param schemaRepository - Repository for accessing DatoCMS schema information (to resolve block structures)
17
23
  * @param visitor - Asynchronous function called for each block found, including nested blocks
18
24
  * @returns Promise that resolves when all blocks and nested blocks have been visited
19
25
  */
20
- export declare function visitBlocksInNonLocalizedFieldValue(schemaRepository: SchemaRepository, fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => void | Promise<void>, path?: TreePath): Promise<void>;
26
+ export declare function visitBlocksInNonLocalizedFieldValue<T extends RecognizableFieldValue>(nonLocalizedFieldValue: T, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, visitor: (item: ExtractNestedBlocksFromFieldValue<T>, path: TreePath) => void | Promise<void>, path?: TreePath): Promise<void>;
27
+ export declare function visitBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue: unknown, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, visitor: (item: BlockInRequest, path: TreePath) => void | Promise<void>, path?: TreePath): Promise<void>;
21
28
  /**
22
29
  * Recursively find all blocks that match the predicate function in a non-localized field value.
23
30
  * Searches through all direct blocks and recursively through nested blocks within
24
31
  * the attributes of each block, returning all matches found throughout the hierarchy.
25
32
  *
26
- * @param schemaRepository - Repository for accessing DatoCMS schema information to resolve block structures
27
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
28
33
  * @param nonLocalizedFieldValue - The non-localized field value containing blocks to search
34
+ * @param fieldType - The type field (determines how the value is processed)
35
+ * @param schemaRepository - Repository for accessing DatoCMS schema information (to resolve block structures)
29
36
  * @param predicate - Asynchronous function that tests each block, including nested ones
30
37
  * @returns Promise that resolves to an array of objects, each containing a matching block and its full path
31
38
  */
32
- export declare function findAllBlocksInNonLocalizedFieldValue(schemaRepository: SchemaRepository, fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<Array<{
33
- item: BlockItemInARequest;
39
+ export declare function findAllBlocksInNonLocalizedFieldValue<T extends RecognizableFieldValue>(nonLocalizedFieldValue: T, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: ExtractNestedBlocksFromFieldValue<T>, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<Array<{
40
+ item: ExtractNestedBlocksFromFieldValue<T>;
41
+ path: TreePath;
42
+ }>>;
43
+ export declare function findAllBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue: unknown, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: BlockInRequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<Array<{
44
+ item: BlockInRequest;
34
45
  path: TreePath;
35
46
  }>>;
36
47
  /**
@@ -39,63 +50,82 @@ export declare function findAllBlocksInNonLocalizedFieldValue(schemaRepository:
39
50
  * including recursive filtering of nested blocks within block attributes. The filtering
40
51
  * preserves the original non-localized field value structure and hierarchy.
41
52
  *
42
- * @param schemaRepository - Repository for accessing DatoCMS schema information to resolve block structures
43
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
44
53
  * @param nonLocalizedFieldValue - The non-localized field value containing blocks to filter
54
+ * @param fieldType - The type field (determines how the value is processed)
55
+ * @param schemaRepository - Repository for accessing DatoCMS schema information (to resolve block structures)
45
56
  * @param predicate - Asynchronous function that tests each block, including nested ones
57
+ * @param options - Optional configuration object
58
+ * @param options.traversalDirection - Direction of traversal: 'top-down' (default) applies predicate before processing children, 'bottom-up' processes children first
46
59
  * @returns Promise that resolves to the new non-localized field value with recursively filtered blocks
47
60
  */
48
- export declare function filterBlocksInNonLocalizedFieldValue(schemaRepository: SchemaRepository, fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<unknown>;
61
+ export declare function filterBlocksInNonLocalizedFieldValue<T extends RecognizableFieldValue>(nonLocalizedFieldValue: T, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: ExtractNestedBlocksFromFieldValue<T>, path: TreePath) => boolean | Promise<boolean>, options?: {
62
+ traversalDirection?: TraversalDirection;
63
+ }, path?: TreePath): Promise<T>;
64
+ export declare function filterBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue: unknown, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: BlockInRequest, path: TreePath) => boolean | Promise<boolean>, options?: {
65
+ traversalDirection?: TraversalDirection;
66
+ }, path?: TreePath): Promise<unknown>;
49
67
  /**
50
68
  * Recursively reduce all blocks in a non-localized field value to a single value by applying a reducer function.
51
69
  * Processes each direct block and recursively processes nested blocks within block attributes,
52
70
  * accumulating results from the entire block hierarchy into a single value.
53
71
  *
54
72
  * @template R - The type of the accumulated result
55
- * @param schemaRepository - Repository for accessing DatoCMS schema information to resolve block structures
56
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
57
73
  * @param nonLocalizedFieldValue - The non-localized field value containing blocks to reduce
74
+ * @param fieldType - The type field (determines how the value is processed)
75
+ * @param schemaRepository - Repository for accessing DatoCMS schema information (to resolve block structures)
58
76
  * @param reducer - Asynchronous function that processes each block and updates the accumulator
59
77
  * @param initialNonLocalizedFieldValue - The initial value for the accumulator
60
78
  * @returns Promise that resolves to the final accumulated value from all blocks in the hierarchy
61
79
  */
62
- export declare function reduceBlocksInNonLocalizedFieldValue<R>(schemaRepository: SchemaRepository, fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => R | Promise<R>, initialValue: R, path?: TreePath): Promise<R>;
80
+ export declare function reduceBlocksInNonLocalizedFieldValue<T, R>(nonLocalizedFieldValue: T, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, reducer: (accumulator: R, item: ExtractNestedBlocksFromFieldValue<T>, path: TreePath) => R | Promise<R>, initialValue: R, path?: TreePath): Promise<R>;
81
+ export declare function reduceBlocksInNonLocalizedFieldValue<R>(nonLocalizedFieldValue: unknown, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, reducer: (accumulator: R, item: BlockInRequest, path: TreePath) => R | Promise<R>, initialValue: R, path?: TreePath): Promise<R>;
63
82
  /**
64
83
  * Recursively check if any block in the non-localized field value matches the predicate function.
65
84
  * Tests both direct blocks and recursively tests nested blocks within block attributes.
66
85
  * Returns true as soon as the first matching block is found anywhere in the hierarchy
67
86
  * (short-circuit evaluation).
68
87
  *
69
- * @param schemaRepository - Repository for accessing DatoCMS schema information to resolve block structures
70
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
71
88
  * @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
89
+ * @param fieldType - The type field (determines how the value is processed)
90
+ * @param schemaRepository - Repository for accessing DatoCMS schema information (to resolve block structures)
72
91
  * @param predicate - Asynchronous function that tests each block, including nested ones
73
92
  * @returns Promise that resolves to true if any block in the hierarchy matches, false otherwise
74
93
  */
75
- export declare function someBlocksInNonLocalizedFieldValue(schemaRepository: SchemaRepository, fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
94
+ export declare function someBlocksInNonLocalizedFieldValue<T extends RecognizableFieldValue>(nonLocalizedFieldValue: T, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: ExtractNestedBlocksFromFieldValue<T>, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
95
+ export declare function someBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue: unknown, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: BlockInRequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
76
96
  /**
77
97
  * Recursively check if every block in the non-localized field value matches the predicate function.
78
98
  * Tests both direct blocks and recursively tests nested blocks within block attributes.
79
99
  * Returns false as soon as the first non-matching block is found anywhere in the hierarchy
80
100
  * (short-circuit evaluation).
81
101
  *
82
- * @param schemaRepository - Repository for accessing DatoCMS schema information to resolve block structures
83
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
84
102
  * @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
103
+ * @param fieldType - The type field (determines how the value is processed)
104
+ * @param schemaRepository - Repository for accessing DatoCMS schema information (to resolve block structures)
85
105
  * @param predicate - Asynchronous function that tests each block, including nested ones
86
106
  * @returns Promise that resolves to true if all blocks in the hierarchy match, false otherwise
87
107
  */
88
- export declare function everyBlockInNonLocalizedFieldValue(schemaRepository: SchemaRepository, fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
108
+ export declare function everyBlockInNonLocalizedFieldValue<T extends RecognizableFieldValue>(nonLocalizedFieldValue: T, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: ExtractNestedBlocksFromFieldValue<T>, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
109
+ export declare function everyBlockInNonLocalizedFieldValue(nonLocalizedFieldValue: unknown, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, predicate: (item: BlockInRequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
110
+ type FieldValueInRequest<T> = T extends RichTextFieldValueInNestedResponse<infer D> ? RichTextFieldValueInRequest<D> : T extends SingleBlockFieldValueInNestedResponse<infer D> ? SingleBlockFieldValueInRequest<D> : T extends StructuredTextFieldValueInNestedResponse<infer DB, infer DI> ? StructuredTextFieldValueInRequest<DB, DI> : T extends StructuredTextFieldValueInNestedResponse<infer DB> ? StructuredTextFieldValueInRequest<DB> : T;
89
111
  /**
90
112
  * Recursively transform blocks in a non-localized field value by applying a mapping function to each block.
91
113
  * Creates a new non-localized field value structure with transformed blocks while preserving the original
92
114
  * structure. Applies the mapping function to both direct blocks and recursively to nested
93
115
  * blocks within block attributes throughout the entire hierarchy.
94
116
  *
95
- * @param schemaRepository - Repository for accessing DatoCMS schema information to resolve block structures
96
- * @param fieldType - The type of DatoCMS field definition that determines how the value is processed
97
117
  * @param nonLocalizedFieldValue - The non-localized field value containing blocks to transform
118
+ * @param fieldType - The type field (determines how the value is processed)
119
+ * @param schemaRepository - Repository for accessing DatoCMS schema information (to resolve block structures)
98
120
  * @param mapper - Asynchronous function that transforms each block, including nested ones
121
+ * @param options - Optional configuration object
122
+ * @param options.traversalDirection - Direction of traversal: 'top-down' (default) applies mapper before processing children, 'bottom-up' processes children first
99
123
  * @returns Promise that resolves to the new non-localized field value with recursively transformed blocks
100
124
  */
101
- export declare function mapBlocksInNonLocalizedFieldValue(schemaRepository: SchemaRepository, fieldType: ApiTypes.Field['field_type'], nonLocalizedFieldValue: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => BlockItemInARequest | Promise<BlockItemInARequest>, path?: TreePath): Promise<unknown>;
125
+ export declare function mapBlocksInNonLocalizedFieldValue<T extends RecognizableFieldValue>(nonLocalizedFieldValue: T, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, mapper: (item: ExtractNestedBlocksFromFieldValue<T>, path: TreePath) => BlockInRequest | Promise<BlockInRequest>, options?: {
126
+ traversalDirection?: TraversalDirection;
127
+ }, path?: TreePath): Promise<FieldValueInRequest<T>>;
128
+ export declare function mapBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue: unknown, fieldType: ApiTypes.Field['field_type'], schemaRepository: SchemaRepository, mapper: (item: BlockInRequest, path: TreePath) => BlockInRequest | Promise<BlockInRequest>, options?: {
129
+ traversalDirection?: TraversalDirection;
130
+ }, path?: TreePath): Promise<unknown>;
131
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datocms/cma-client",
3
- "version": "5.1.11",
3
+ "version": "5.1.13",
4
4
  "description": "JS client for DatoCMS REST Content Management API",
5
5
  "keywords": [
6
6
  "datocms",
@@ -37,13 +37,13 @@
37
37
  "url": "https://github.com/datocms/js-rest-api-clients/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@datocms/rest-client-utils": "^5.1.6",
40
+ "@datocms/rest-client-utils": "^5.1.13",
41
41
  "datocms-structured-text-utils": "^5.1.4",
42
42
  "uuid": "^9.0.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@datocms/dashboard-client": "^5.1.10",
45
+ "@datocms/dashboard-client": "^5.1.13",
46
46
  "@types/uuid": "^9.0.7"
47
47
  },
48
- "gitHead": "e809594f4faa92ee8cb1943de52278f9030b09d7"
48
+ "gitHead": "966b5835bf69f9e87b34f2075a8596c9208e07c0"
49
49
  }
@@ -66,7 +66,7 @@ export type FileFieldValue = {
66
66
  /**
67
67
  * File field value for API requests - metadata fields are optional
68
68
  */
69
- export type FileFieldValueAsRequest = {
69
+ export type FileFieldValueInRequest = {
70
70
  upload_id: string;
71
71
  alt?: string | null;
72
72
  title?: string | null;
@@ -103,9 +103,9 @@ export function isFileFieldValue(value: unknown): value is FileFieldValue {
103
103
  * Type guard for File field values in API request format.
104
104
  * Allows metadata fields to be optional or omitted.
105
105
  */
106
- export function isFileFieldValueAsRequest(
106
+ export function isFileFieldValueInRequest(
107
107
  value: unknown,
108
- ): value is FileFieldValueAsRequest {
108
+ ): value is FileFieldValueInRequest {
109
109
  if (value === null) return true;
110
110
  return typeof value === 'object' && value !== null && 'upload_id' in value;
111
111
  }
@@ -118,12 +118,12 @@ export function isLocalizedFileFieldValue(
118
118
  );
119
119
  }
120
120
 
121
- export function isLocalizedFileFieldValueAsRequest(
121
+ export function isLocalizedFileFieldValueInRequest(
122
122
  value: unknown,
123
- ): value is LocalizedFieldValue<FileFieldValueAsRequest> {
123
+ ): value is LocalizedFieldValue<FileFieldValueInRequest> {
124
124
  return (
125
125
  isLocalizedFieldValue(value) &&
126
- Object.values(value).every(isFileFieldValueAsRequest)
126
+ Object.values(value).every(isFileFieldValueInRequest)
127
127
  );
128
128
  }
129
129
 
@@ -5,9 +5,9 @@ import {
5
5
  import type { GalleryEditorConfiguration } from './appearance/gallery';
6
6
  import {
7
7
  type FileFieldValue,
8
- type FileFieldValueAsRequest,
8
+ type FileFieldValueInRequest,
9
9
  isFileFieldValue,
10
- isFileFieldValueAsRequest,
10
+ isFileFieldValueInRequest,
11
11
  } from './file';
12
12
  import type { ExtensionValidator } from './validators/extension';
13
13
  import type { FileSizeValidator } from './validators/file_size';
@@ -25,7 +25,7 @@ import type { SizeValidator } from './validators/size';
25
25
  * Individual gallery item types - extracted from File field types
26
26
  */
27
27
  export type GalleryItem = NonNullable<FileFieldValue>;
28
- export type GalleryItemAsRequest = NonNullable<FileFieldValueAsRequest>;
28
+ export type GalleryItemInRequest = NonNullable<FileFieldValueInRequest>;
29
29
 
30
30
  /**
31
31
  * Gallery field value - response format with all metadata fields present
@@ -35,7 +35,7 @@ export type GalleryFieldValue = Array<GalleryItem>;
35
35
  /**
36
36
  * Gallery field value for API requests - metadata fields are optional
37
37
  */
38
- export type GalleryFieldValueAsRequest = Array<GalleryItemAsRequest>;
38
+ export type GalleryFieldValueInRequest = Array<GalleryItemInRequest>;
39
39
 
40
40
  /**
41
41
  * Type guard for Gallery field values - validates each item using File field validation
@@ -49,10 +49,10 @@ export function isGalleryFieldValue(
49
49
  /**
50
50
  * Type guard for Gallery field values in API request format
51
51
  */
52
- export function isGalleryFieldValueAsRequest(
52
+ export function isGalleryFieldValueInRequest(
53
53
  value: unknown,
54
- ): value is GalleryFieldValueAsRequest {
55
- return Array.isArray(value) && value.every(isFileFieldValueAsRequest);
54
+ ): value is GalleryFieldValueInRequest {
55
+ return Array.isArray(value) && value.every(isFileFieldValueInRequest);
56
56
  }
57
57
 
58
58
  export function isLocalizedGalleryFieldValue(
@@ -64,12 +64,12 @@ export function isLocalizedGalleryFieldValue(
64
64
  );
65
65
  }
66
66
 
67
- export function isLocalizedGalleryFieldValueAsRequest(
67
+ export function isLocalizedGalleryFieldValueInRequest(
68
68
  value: unknown,
69
- ): value is LocalizedFieldValue<GalleryFieldValueAsRequest> {
69
+ ): value is LocalizedFieldValue<GalleryFieldValueInRequest> {
70
70
  return (
71
71
  isLocalizedFieldValue(value) &&
72
- Object.values(value).every(isGalleryFieldValueAsRequest)
72
+ Object.values(value).every(isGalleryFieldValueInRequest)
73
73
  );
74
74
  }
75
75
 
@@ -1,12 +1,13 @@
1
- import type * as RawApiTypes from '../generated/RawApiTypes';
2
- import type { ItemDefinition } from '../utilities/itemDefinition';
1
+ import { isValidId } from '../utilities/id';
2
+ import type { ItemTypeDefinition } from '../utilities/itemDefinition';
3
3
  import {
4
4
  type LocalizedFieldValue,
5
5
  isLocalizedFieldValue,
6
6
  } from '../utilities/normalizedFieldValues';
7
7
  import type { RichTextEditorConfiguration } from './appearance/rich_text';
8
8
  import {
9
- type BlockItemInARequest,
9
+ type BlockInNestedResponse,
10
+ type BlockInRequest,
10
11
  isItemId,
11
12
  isItemWithOptionalIdAndMeta,
12
13
  isItemWithOptionalMeta,
@@ -64,9 +65,9 @@ export type RichTextFieldValue = string[];
64
65
  * - RawApiTypes.Item: Full block object with ID (for updates)
65
66
  * - Omit<RawApiTypes.Item, 'id'>: Block object without ID (for creation)
66
67
  */
67
- export type RichTextFieldValueAsRequest<
68
- D extends ItemDefinition = ItemDefinition,
69
- > = BlockItemInARequest<D>[] | null;
68
+ export type RichTextFieldValueInRequest<
69
+ D extends ItemTypeDefinition = ItemTypeDefinition,
70
+ > = BlockInRequest<D>[] | null;
70
71
 
71
72
  /**
72
73
  * =============================================================================
@@ -81,9 +82,9 @@ export type RichTextFieldValueAsRequest<
81
82
  /**
82
83
  * Modular Content field value with nested blocks - array of fully populated block objects
83
84
  */
84
- export type RichTextFieldValueWithNestedBlocks<
85
- D extends ItemDefinition = ItemDefinition,
86
- > = RawApiTypes.Item<D>[];
85
+ export type RichTextFieldValueInNestedResponse<
86
+ D extends ItemTypeDefinition = ItemTypeDefinition,
87
+ > = BlockInNestedResponse<D>[];
87
88
 
88
89
  /**
89
90
  * =============================================================================
@@ -99,7 +100,8 @@ export function isRichTextFieldValue(
99
100
  value: unknown,
100
101
  ): value is RichTextFieldValue {
101
102
  return (
102
- Array.isArray(value) && value.every((block) => typeof block === 'string')
103
+ Array.isArray(value) &&
104
+ value.every((block) => typeof block === 'string' && isValidId(block))
103
105
  );
104
106
  }
105
107
 
@@ -116,9 +118,9 @@ export function isLocalizedRichTextFieldValue(
116
118
  * Type guard for Modular Content field values in API request format.
117
119
  * Allows blocks as string IDs, full objects with IDs, or objects without IDs.
118
120
  */
119
- export function isRichTextFieldValueAsRequest<
120
- D extends ItemDefinition = ItemDefinition,
121
- >(value: unknown): value is RichTextFieldValueAsRequest<D> {
121
+ export function isRichTextFieldValueInRequest<
122
+ D extends ItemTypeDefinition = ItemTypeDefinition,
123
+ >(value: unknown): value is RichTextFieldValueInRequest<D> {
122
124
  if (value === null) return true;
123
125
 
124
126
  if (!Array.isArray(value)) return false;
@@ -132,14 +134,14 @@ export function isRichTextFieldValueAsRequest<
132
134
  });
133
135
  }
134
136
 
135
- export function isLocalizedRichTextFieldValueAsRequest<
136
- D extends ItemDefinition = ItemDefinition,
137
+ export function isLocalizedRichTextFieldValueInRequest<
138
+ D extends ItemTypeDefinition = ItemTypeDefinition,
137
139
  >(
138
140
  value: unknown,
139
- ): value is LocalizedFieldValue<RichTextFieldValueAsRequest<D>> {
141
+ ): value is LocalizedFieldValue<RichTextFieldValueInRequest<D>> {
140
142
  return (
141
143
  isLocalizedFieldValue(value) &&
142
- Object.values(value).every(isRichTextFieldValueAsRequest)
144
+ Object.values(value).every(isRichTextFieldValueInRequest)
143
145
  );
144
146
  }
145
147
 
@@ -147,9 +149,9 @@ export function isLocalizedRichTextFieldValueAsRequest<
147
149
  * Type guard for Modular Content field values with nested blocks (?nested=true format).
148
150
  * Ensures all blocks are full RawApiTypes.Item objects with complete data.
149
151
  */
150
- export function isRichTextFieldValueWithNestedBlocks<
151
- D extends ItemDefinition = ItemDefinition,
152
- >(value: unknown): value is RichTextFieldValueWithNestedBlocks<D> {
152
+ export function isRichTextFieldValueInNestedResponse<
153
+ D extends ItemTypeDefinition = ItemTypeDefinition,
154
+ >(value: unknown): value is RichTextFieldValueInNestedResponse<D> {
153
155
  if (!Array.isArray(value)) return false;
154
156
 
155
157
  return value.every((block) => {
@@ -158,14 +160,14 @@ export function isRichTextFieldValueWithNestedBlocks<
158
160
  });
159
161
  }
160
162
 
161
- export function isLocalizedRichTextFieldValueWithNestedBlocks<
162
- D extends ItemDefinition = ItemDefinition,
163
+ export function isLocalizedRichTextFieldValueInNestedResponse<
164
+ D extends ItemTypeDefinition = ItemTypeDefinition,
163
165
  >(
164
166
  value: unknown,
165
- ): value is LocalizedFieldValue<RichTextFieldValueWithNestedBlocks<D>> {
167
+ ): value is LocalizedFieldValue<RichTextFieldValueInNestedResponse<D>> {
166
168
  return (
167
169
  isLocalizedFieldValue(value) &&
168
- Object.values(value).every(isRichTextFieldValueWithNestedBlocks)
170
+ Object.values(value).every(isRichTextFieldValueInNestedResponse)
169
171
  );
170
172
  }
171
173