@datocms/cma-client 5.1.10 → 5.1.12

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 (253) hide show
  1. package/README.md +569 -0
  2. package/dist/cjs/fieldTypes/boolean.js +2 -2
  3. package/dist/cjs/fieldTypes/boolean.js.map +1 -1
  4. package/dist/cjs/fieldTypes/color.js +2 -2
  5. package/dist/cjs/fieldTypes/color.js.map +1 -1
  6. package/dist/cjs/fieldTypes/date.js +2 -3
  7. package/dist/cjs/fieldTypes/date.js.map +1 -1
  8. package/dist/cjs/fieldTypes/date_time.js +2 -2
  9. package/dist/cjs/fieldTypes/date_time.js.map +1 -1
  10. package/dist/cjs/fieldTypes/file.js +33 -5
  11. package/dist/cjs/fieldTypes/file.js.map +1 -1
  12. package/dist/cjs/fieldTypes/float.js +2 -2
  13. package/dist/cjs/fieldTypes/float.js.map +1 -1
  14. package/dist/cjs/fieldTypes/gallery.js +20 -5
  15. package/dist/cjs/fieldTypes/gallery.js.map +1 -1
  16. package/dist/cjs/fieldTypes/index.js +2 -2
  17. package/dist/cjs/fieldTypes/index.js.map +1 -1
  18. package/dist/cjs/fieldTypes/integer.js +2 -2
  19. package/dist/cjs/fieldTypes/integer.js.map +1 -1
  20. package/dist/cjs/fieldTypes/json.js +2 -3
  21. package/dist/cjs/fieldTypes/json.js.map +1 -1
  22. package/dist/cjs/fieldTypes/lat_lon.js +2 -2
  23. package/dist/cjs/fieldTypes/lat_lon.js.map +1 -1
  24. package/dist/cjs/fieldTypes/link.js +4 -4
  25. package/dist/cjs/fieldTypes/link.js.map +1 -1
  26. package/dist/cjs/fieldTypes/links.js +5 -3
  27. package/dist/cjs/fieldTypes/links.js.map +1 -1
  28. package/dist/cjs/fieldTypes/rich_text.js +18 -18
  29. package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
  30. package/dist/cjs/fieldTypes/schema.js +3 -0
  31. package/dist/cjs/fieldTypes/schema.js.map +1 -0
  32. package/dist/cjs/fieldTypes/seo.js +2 -3
  33. package/dist/cjs/fieldTypes/seo.js.map +1 -1
  34. package/dist/cjs/fieldTypes/single_block.js +20 -19
  35. package/dist/cjs/fieldTypes/single_block.js.map +1 -1
  36. package/dist/cjs/fieldTypes/slug.js +2 -3
  37. package/dist/cjs/fieldTypes/slug.js.map +1 -1
  38. package/dist/cjs/fieldTypes/string.js +2 -2
  39. package/dist/cjs/fieldTypes/string.js.map +1 -1
  40. package/dist/cjs/fieldTypes/structured_text.js +17 -18
  41. package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
  42. package/dist/cjs/fieldTypes/text.js +2 -3
  43. package/dist/cjs/fieldTypes/text.js.map +1 -1
  44. package/dist/cjs/fieldTypes/video.js +2 -2
  45. package/dist/cjs/fieldTypes/video.js.map +1 -1
  46. package/dist/cjs/generated/Client.js +1 -1
  47. package/dist/cjs/generated/resources/Item.js.map +1 -1
  48. package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
  49. package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
  50. package/dist/cjs/generated/resources/Upload.js.map +1 -1
  51. package/dist/cjs/index.js +5 -4
  52. package/dist/cjs/index.js.map +1 -1
  53. package/dist/cjs/utilities/buildBlockRecord.js +1 -45
  54. package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
  55. package/dist/cjs/utilities/duplicateBlockRecord.js +49 -0
  56. package/dist/cjs/utilities/duplicateBlockRecord.js.map +1 -0
  57. package/dist/cjs/utilities/inspectItem.js +427 -0
  58. package/dist/cjs/utilities/inspectItem.js.map +1 -0
  59. package/dist/cjs/utilities/{blocks.js → nonRecursiveBlocks.js} +60 -234
  60. package/dist/cjs/utilities/nonRecursiveBlocks.js.map +1 -0
  61. package/dist/cjs/utilities/{fieldValue.js → normalizedFieldValues.js} +53 -41
  62. package/dist/cjs/utilities/normalizedFieldValues.js.map +1 -0
  63. package/dist/cjs/utilities/recursiveBlocks.js +73 -92
  64. package/dist/cjs/utilities/recursiveBlocks.js.map +1 -1
  65. package/dist/cjs/utilities/schemaRepository.js +2 -2
  66. package/dist/esm/fieldTypes/boolean.d.ts +1 -1
  67. package/dist/esm/fieldTypes/boolean.js +2 -2
  68. package/dist/esm/fieldTypes/boolean.js.map +1 -1
  69. package/dist/esm/fieldTypes/color.d.ts +1 -1
  70. package/dist/esm/fieldTypes/color.js +2 -2
  71. package/dist/esm/fieldTypes/color.js.map +1 -1
  72. package/dist/esm/fieldTypes/date.d.ts +1 -1
  73. package/dist/esm/fieldTypes/date.js +2 -3
  74. package/dist/esm/fieldTypes/date.js.map +1 -1
  75. package/dist/esm/fieldTypes/date_time.d.ts +1 -1
  76. package/dist/esm/fieldTypes/date_time.js +2 -2
  77. package/dist/esm/fieldTypes/date_time.js.map +1 -1
  78. package/dist/esm/fieldTypes/file.d.ts +68 -1
  79. package/dist/esm/fieldTypes/file.js +29 -3
  80. package/dist/esm/fieldTypes/file.js.map +1 -1
  81. package/dist/esm/fieldTypes/float.d.ts +1 -1
  82. package/dist/esm/fieldTypes/float.js +2 -2
  83. package/dist/esm/fieldTypes/float.js.map +1 -1
  84. package/dist/esm/fieldTypes/gallery.d.ts +27 -11
  85. package/dist/esm/fieldTypes/gallery.js +17 -4
  86. package/dist/esm/fieldTypes/gallery.js.map +1 -1
  87. package/dist/esm/fieldTypes/index.d.ts +2 -2
  88. package/dist/esm/fieldTypes/index.js +2 -2
  89. package/dist/esm/fieldTypes/index.js.map +1 -1
  90. package/dist/esm/fieldTypes/integer.d.ts +1 -1
  91. package/dist/esm/fieldTypes/integer.js +2 -2
  92. package/dist/esm/fieldTypes/integer.js.map +1 -1
  93. package/dist/esm/fieldTypes/json.d.ts +1 -1
  94. package/dist/esm/fieldTypes/json.js +2 -3
  95. package/dist/esm/fieldTypes/json.js.map +1 -1
  96. package/dist/esm/fieldTypes/lat_lon.d.ts +1 -1
  97. package/dist/esm/fieldTypes/lat_lon.js +2 -2
  98. package/dist/esm/fieldTypes/lat_lon.js.map +1 -1
  99. package/dist/esm/fieldTypes/link.d.ts +1 -1
  100. package/dist/esm/fieldTypes/link.js +4 -4
  101. package/dist/esm/fieldTypes/link.js.map +1 -1
  102. package/dist/esm/fieldTypes/links.d.ts +1 -1
  103. package/dist/esm/fieldTypes/links.js +5 -3
  104. package/dist/esm/fieldTypes/links.js.map +1 -1
  105. package/dist/esm/fieldTypes/rich_text.d.ts +9 -10
  106. package/dist/esm/fieldTypes/rich_text.js +13 -13
  107. package/dist/esm/fieldTypes/rich_text.js.map +1 -1
  108. package/dist/esm/fieldTypes/schema.d.ts +59 -0
  109. package/dist/esm/fieldTypes/schema.js +2 -0
  110. package/dist/esm/fieldTypes/schema.js.map +1 -0
  111. package/dist/esm/fieldTypes/seo.d.ts +1 -1
  112. package/dist/esm/fieldTypes/seo.js +2 -3
  113. package/dist/esm/fieldTypes/seo.js.map +1 -1
  114. package/dist/esm/fieldTypes/single_block.d.ts +31 -16
  115. package/dist/esm/fieldTypes/single_block.js +15 -14
  116. package/dist/esm/fieldTypes/single_block.js.map +1 -1
  117. package/dist/esm/fieldTypes/slug.d.ts +1 -1
  118. package/dist/esm/fieldTypes/slug.js +2 -3
  119. package/dist/esm/fieldTypes/slug.js.map +1 -1
  120. package/dist/esm/fieldTypes/string.d.ts +1 -1
  121. package/dist/esm/fieldTypes/string.js +2 -2
  122. package/dist/esm/fieldTypes/string.js.map +1 -1
  123. package/dist/esm/fieldTypes/structured_text.d.ts +15 -16
  124. package/dist/esm/fieldTypes/structured_text.js +12 -13
  125. package/dist/esm/fieldTypes/structured_text.js.map +1 -1
  126. package/dist/esm/fieldTypes/text.d.ts +1 -1
  127. package/dist/esm/fieldTypes/text.js +2 -3
  128. package/dist/esm/fieldTypes/text.js.map +1 -1
  129. package/dist/esm/fieldTypes/video.d.ts +1 -1
  130. package/dist/esm/fieldTypes/video.js +2 -2
  131. package/dist/esm/fieldTypes/video.js.map +1 -1
  132. package/dist/esm/generated/ApiTypes.d.ts +90 -980
  133. package/dist/esm/generated/Client.js +1 -1
  134. package/dist/esm/generated/RawApiTypes.d.ts +156 -999
  135. package/dist/esm/generated/resources/Field.d.ts +200 -200
  136. package/dist/esm/generated/resources/Item.d.ts +34 -34
  137. package/dist/esm/generated/resources/Item.js.map +1 -1
  138. package/dist/esm/generated/resources/ItemVersion.d.ts +3 -1
  139. package/dist/esm/generated/resources/ScheduledPublication.d.ts +3 -3
  140. package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
  141. package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +3 -3
  142. package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
  143. package/dist/esm/generated/resources/Upload.d.ts +6 -6
  144. package/dist/esm/generated/resources/Upload.js.map +1 -1
  145. package/dist/esm/index.d.ts +5 -4
  146. package/dist/esm/index.js +5 -4
  147. package/dist/esm/index.js.map +1 -1
  148. package/dist/esm/utilities/buildBlockRecord.d.ts +3 -5
  149. package/dist/esm/utilities/buildBlockRecord.js +0 -43
  150. package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
  151. package/dist/esm/utilities/duplicateBlockRecord.d.ts +6 -0
  152. package/dist/esm/utilities/duplicateBlockRecord.js +45 -0
  153. package/dist/esm/utilities/duplicateBlockRecord.js.map +1 -0
  154. package/dist/esm/utilities/inspectItem.d.ts +8 -0
  155. package/dist/esm/utilities/inspectItem.js +400 -0
  156. package/dist/esm/utilities/inspectItem.js.map +1 -0
  157. package/dist/esm/utilities/itemDefinition.d.ts +45 -23
  158. package/dist/esm/utilities/nonRecursiveBlocks.d.ts +114 -0
  159. package/dist/esm/utilities/{blocks.js → nonRecursiveBlocks.js} +52 -220
  160. package/dist/esm/utilities/nonRecursiveBlocks.js.map +1 -0
  161. package/dist/{types/utilities/fieldValue.d.ts → esm/utilities/normalizedFieldValues.d.ts} +15 -14
  162. package/dist/esm/utilities/{fieldValue.js → normalizedFieldValues.js} +39 -28
  163. package/dist/esm/utilities/normalizedFieldValues.js.map +1 -0
  164. package/dist/esm/utilities/recursiveBlocks.d.ts +124 -11
  165. package/dist/esm/utilities/recursiveBlocks.js +65 -84
  166. package/dist/esm/utilities/recursiveBlocks.js.map +1 -1
  167. package/dist/esm/utilities/schemaRepository.d.ts +2 -2
  168. package/dist/esm/utilities/schemaRepository.js +2 -2
  169. package/dist/types/fieldTypes/boolean.d.ts +1 -1
  170. package/dist/types/fieldTypes/color.d.ts +1 -1
  171. package/dist/types/fieldTypes/date.d.ts +1 -1
  172. package/dist/types/fieldTypes/date_time.d.ts +1 -1
  173. package/dist/types/fieldTypes/file.d.ts +68 -1
  174. package/dist/types/fieldTypes/float.d.ts +1 -1
  175. package/dist/types/fieldTypes/gallery.d.ts +27 -11
  176. package/dist/types/fieldTypes/index.d.ts +2 -2
  177. package/dist/types/fieldTypes/integer.d.ts +1 -1
  178. package/dist/types/fieldTypes/json.d.ts +1 -1
  179. package/dist/types/fieldTypes/lat_lon.d.ts +1 -1
  180. package/dist/types/fieldTypes/link.d.ts +1 -1
  181. package/dist/types/fieldTypes/links.d.ts +1 -1
  182. package/dist/types/fieldTypes/rich_text.d.ts +9 -10
  183. package/dist/types/fieldTypes/schema.d.ts +59 -0
  184. package/dist/types/fieldTypes/seo.d.ts +1 -1
  185. package/dist/types/fieldTypes/single_block.d.ts +31 -16
  186. package/dist/types/fieldTypes/slug.d.ts +1 -1
  187. package/dist/types/fieldTypes/string.d.ts +1 -1
  188. package/dist/types/fieldTypes/structured_text.d.ts +15 -16
  189. package/dist/types/fieldTypes/text.d.ts +1 -1
  190. package/dist/types/fieldTypes/video.d.ts +1 -1
  191. package/dist/types/generated/ApiTypes.d.ts +90 -980
  192. package/dist/types/generated/RawApiTypes.d.ts +156 -999
  193. package/dist/types/generated/resources/Field.d.ts +200 -200
  194. package/dist/types/generated/resources/Item.d.ts +34 -34
  195. package/dist/types/generated/resources/ItemVersion.d.ts +3 -1
  196. package/dist/types/generated/resources/ScheduledPublication.d.ts +3 -3
  197. package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +3 -3
  198. package/dist/types/generated/resources/Upload.d.ts +6 -6
  199. package/dist/types/index.d.ts +5 -4
  200. package/dist/types/utilities/buildBlockRecord.d.ts +3 -5
  201. package/dist/types/utilities/duplicateBlockRecord.d.ts +6 -0
  202. package/dist/types/utilities/inspectItem.d.ts +8 -0
  203. package/dist/types/utilities/itemDefinition.d.ts +45 -23
  204. package/dist/types/utilities/nonRecursiveBlocks.d.ts +114 -0
  205. package/dist/{esm/utilities/fieldValue.d.ts → types/utilities/normalizedFieldValues.d.ts} +15 -14
  206. package/dist/types/utilities/recursiveBlocks.d.ts +124 -11
  207. package/dist/types/utilities/schemaRepository.d.ts +2 -2
  208. package/package.json +4 -4
  209. package/src/fieldTypes/boolean.ts +5 -3
  210. package/src/fieldTypes/color.ts +5 -3
  211. package/src/fieldTypes/date.ts +5 -4
  212. package/src/fieldTypes/date_time.ts +5 -3
  213. package/src/fieldTypes/file.ts +98 -4
  214. package/src/fieldTypes/float.ts +5 -3
  215. package/src/fieldTypes/gallery.ts +53 -20
  216. package/src/fieldTypes/index.ts +2 -3
  217. package/src/fieldTypes/integer.ts +5 -3
  218. package/src/fieldTypes/json.ts +5 -4
  219. package/src/fieldTypes/lat_lon.ts +5 -3
  220. package/src/fieldTypes/link.ts +7 -5
  221. package/src/fieldTypes/links.ts +8 -4
  222. package/src/fieldTypes/rich_text.ts +33 -31
  223. package/src/fieldTypes/schema.ts +657 -0
  224. package/src/fieldTypes/seo.ts +5 -4
  225. package/src/fieldTypes/single_block.ts +71 -46
  226. package/src/fieldTypes/slug.ts +5 -4
  227. package/src/fieldTypes/string.ts +5 -3
  228. package/src/fieldTypes/structured_text.ts +64 -58
  229. package/src/fieldTypes/text.ts +5 -4
  230. package/src/fieldTypes/video.ts +5 -3
  231. package/src/generated/ApiTypes.ts +217 -1880
  232. package/src/generated/Client.ts +1 -1
  233. package/src/generated/RawApiTypes.ts +272 -2113
  234. package/src/generated/resources/Item.ts +93 -187
  235. package/src/generated/resources/ScheduledPublication.ts +4 -15
  236. package/src/generated/resources/ScheduledUnpublishing.ts +4 -15
  237. package/src/generated/resources/Upload.ts +9 -32
  238. package/src/index.ts +5 -4
  239. package/src/utilities/buildBlockRecord.ts +4 -59
  240. package/src/utilities/duplicateBlockRecord.ts +52 -0
  241. package/src/utilities/inspectItem.ts +602 -0
  242. package/src/utilities/itemDefinition.ts +130 -92
  243. package/src/utilities/nonRecursiveBlocks.ts +406 -0
  244. package/src/utilities/{fieldValue.ts → normalizedFieldValues.ts} +70 -30
  245. package/src/utilities/recursiveBlocks.ts +484 -204
  246. package/src/utilities/schemaRepository.ts +2 -2
  247. package/dist/cjs/utilities/blocks.js.map +0 -1
  248. package/dist/cjs/utilities/fieldValue.js.map +0 -1
  249. package/dist/esm/utilities/blocks.d.ts +0 -180
  250. package/dist/esm/utilities/blocks.js.map +0 -1
  251. package/dist/esm/utilities/fieldValue.js.map +0 -1
  252. package/dist/types/utilities/blocks.d.ts +0 -180
  253. package/src/utilities/blocks.ts +0 -626
@@ -8,11 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { isItemWithOptionalIdAndMeta, } from '../fieldTypes';
11
- import { nonRecursiveFilterBlocksInFieldValueAsync, nonRecursiveFindAllBlocksInFieldValueAsync, nonRecursiveMapBlocksInFieldValueAsync, nonRecursiveReduceBlocksInFieldValueAsync, nonRecursiveSomeBlocksInFieldValueAsync, nonRecursiveVisitBlocksInFieldValueAsync, } from './blocks';
12
- import { mapFieldValueAsync, visitFieldValueAsync } from './fieldValue';
13
- export function visitBlocksInFieldValues(schemaRepository, field, value, visitor, path = []) {
11
+ import { nonRecursiveFilterBlocksInNonLocalizedFieldValueAsync, nonRecursiveFindAllBlocksInNonLocalizedFieldValueAsync, nonRecursiveMapBlocksInNonLocalizedFieldValueAsync, nonRecursiveReduceBlocksInNonLocalizedFieldValueAsync, nonRecursiveSomeBlocksInNonLocalizedFieldValueAsync, nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync, } from './nonRecursiveBlocks';
12
+ export function visitBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, visitor, path = []) {
14
13
  return __awaiter(this, void 0, void 0, function* () {
15
- yield nonRecursiveVisitBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
14
+ yield nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
16
15
  yield visitor(block, [...path, ...innerPath]);
17
16
  if (!isItemWithOptionalIdAndMeta(block)) {
18
17
  return;
@@ -20,104 +19,89 @@ export function visitBlocksInFieldValues(schemaRepository, field, value, visitor
20
19
  const itemType = yield schemaRepository.getRawItemTypeById(block.relationships.item_type.data.id);
21
20
  const fields = yield schemaRepository.getRawItemTypeFields(itemType);
22
21
  for (const field of fields) {
23
- yield visitFieldValueAsync(field, block.attributes[field.attributes.api_key], (locale, valueForLocale) => visitBlocksInFieldValues(schemaRepository, field, valueForLocale, visitor, [
24
- ...path,
25
- ...innerPath,
26
- 'attributes',
27
- field.attributes.api_key,
28
- ...(locale ? [locale] : []),
29
- ]));
22
+ yield visitBlocksInNonLocalizedFieldValue(block.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, visitor, [...path, ...innerPath, 'attributes', field.attributes.api_key]);
30
23
  }
31
24
  }));
32
25
  });
33
26
  }
34
- export function findAllBlocksInFieldValues(schemaRepository, field, value, predicate, path = []) {
27
+ export function findAllBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, predicate, path = []) {
35
28
  return __awaiter(this, void 0, void 0, function* () {
36
29
  const results = [];
37
- const directMatches = yield nonRecursiveFindAllBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () { return yield predicate(block, [...path, ...innerPath]); }));
30
+ const directMatches = yield nonRecursiveFindAllBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () { return yield predicate(block, [...path, ...innerPath]); }));
38
31
  results.push(...directMatches.map(({ item, path: innerPath }) => ({
39
32
  item,
40
33
  path: [...path, ...innerPath],
41
34
  })));
42
- yield nonRecursiveVisitBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
35
+ yield nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
43
36
  if (!isItemWithOptionalIdAndMeta(block)) {
44
37
  return;
45
38
  }
46
39
  const itemType = yield schemaRepository.getRawItemTypeById(block.relationships.item_type.data.id);
47
40
  const fields = yield schemaRepository.getRawItemTypeFields(itemType);
48
41
  for (const field of fields) {
49
- yield visitFieldValueAsync(field, block.attributes[field.attributes.api_key], (locale, valueForLocale) => __awaiter(this, void 0, void 0, function* () {
50
- const nestedResults = yield findAllBlocksInFieldValues(schemaRepository, field, valueForLocale, predicate, [
51
- ...path,
52
- ...innerPath,
53
- 'attributes',
54
- field.attributes.api_key,
55
- ...(locale ? [locale] : []),
56
- ]);
57
- results.push(...nestedResults);
58
- }));
42
+ const nestedResults = yield findAllBlocksInNonLocalizedFieldValue(block.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, predicate, [...path, ...innerPath, 'attributes', field.attributes.api_key]);
43
+ results.push(...nestedResults);
59
44
  }
60
45
  }));
61
46
  return results;
62
47
  });
63
48
  }
64
- export function filterBlocksInFieldValues(schemaRepository, field, value, predicate, path = []) {
49
+ export function filterBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, predicate, options = {}, path = []) {
65
50
  return __awaiter(this, void 0, void 0, function* () {
66
- return nonRecursiveFilterBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
51
+ const { traversalDirection = 'top-down' } = options;
52
+ const mapperFunc = (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
67
53
  const blockPath = [...path, ...innerPath];
68
- const passes = yield predicate(block, blockPath);
69
- if (!passes) {
70
- return false;
71
- }
72
54
  if (!isItemWithOptionalIdAndMeta(block)) {
73
- return true;
55
+ return block;
74
56
  }
75
57
  const itemType = yield schemaRepository.getRawItemTypeById(block.relationships.item_type.data.id);
76
58
  const fields = yield schemaRepository.getRawItemTypeFields(itemType);
59
+ if (traversalDirection === 'top-down') {
60
+ const blockCopy = Object.assign(Object.assign({}, block), { attributes: Object.assign({}, block.attributes) });
61
+ for (const field of fields) {
62
+ blockCopy.attributes[field.attributes.api_key] =
63
+ yield filterBlocksInNonLocalizedFieldValue(blockCopy.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, predicate, options, [...blockPath, 'attributes', field.attributes.api_key]);
64
+ }
65
+ return blockCopy;
66
+ }
67
+ const blockCopy = Object.assign(Object.assign({}, block), { attributes: Object.assign({}, block.attributes) });
77
68
  for (const field of fields) {
78
- block.attributes[field.attributes.api_key] = yield mapFieldValueAsync(field, block.attributes[field.attributes.api_key], (locale, valueForLocale) => filterBlocksInFieldValues(schemaRepository, field, valueForLocale, predicate, [
79
- ...blockPath,
80
- 'attributes',
81
- field.attributes.api_key,
82
- ...(locale ? [locale] : []),
83
- ]));
69
+ blockCopy.attributes[field.attributes.api_key] =
70
+ yield filterBlocksInNonLocalizedFieldValue(blockCopy.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, predicate, options, [...blockPath, 'attributes', field.attributes.api_key]);
84
71
  }
85
- return true;
72
+ return blockCopy;
73
+ });
74
+ const mappedValue = yield nonRecursiveMapBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, mapperFunc);
75
+ return nonRecursiveFilterBlocksInNonLocalizedFieldValueAsync(fieldType, mappedValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
76
+ const blockPath = [...path, ...innerPath];
77
+ return yield predicate(block, blockPath);
86
78
  }));
87
79
  });
88
80
  }
89
- export function reduceBlocksInFieldValues(schemaRepository, field, value, reducer, initialValue, path = []) {
81
+ export function reduceBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, reducer, initialValue, path = []) {
90
82
  return __awaiter(this, void 0, void 0, function* () {
91
- let accumulator = yield nonRecursiveReduceBlocksInFieldValueAsync(field, value, (acc, block, innerPath) => __awaiter(this, void 0, void 0, function* () { return yield reducer(acc, block, [...path, ...innerPath]); }), initialValue);
92
- yield nonRecursiveVisitBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
83
+ let accumulator = yield nonRecursiveReduceBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (acc, block, innerPath) => __awaiter(this, void 0, void 0, function* () { return yield reducer(acc, block, [...path, ...innerPath]); }), initialValue);
84
+ yield nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
93
85
  if (!isItemWithOptionalIdAndMeta(block)) {
94
86
  return;
95
87
  }
96
88
  const itemType = yield schemaRepository.getRawItemTypeById(block.relationships.item_type.data.id);
97
89
  const fields = yield schemaRepository.getRawItemTypeFields(itemType);
98
90
  for (const field of fields) {
99
- yield visitFieldValueAsync(field, block.attributes[field.attributes.api_key], (locale, valueForLocale) => __awaiter(this, void 0, void 0, function* () {
100
- accumulator = yield reduceBlocksInFieldValues(schemaRepository, field, valueForLocale, reducer, accumulator, [
101
- ...path,
102
- ...innerPath,
103
- 'attributes',
104
- field.attributes.api_key,
105
- ...(locale ? [locale] : []),
106
- ]);
107
- }));
91
+ accumulator = yield reduceBlocksInNonLocalizedFieldValue(block.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, reducer, accumulator, [...path, ...innerPath, 'attributes', field.attributes.api_key]);
108
92
  }
109
93
  }));
110
94
  return accumulator;
111
95
  });
112
96
  }
113
- export function someBlocksInFieldValues(schemaRepository, field, value, predicate, path = []) {
97
+ export function someBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, predicate, path = []) {
114
98
  return __awaiter(this, void 0, void 0, function* () {
115
- const directMatch = yield nonRecursiveSomeBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () { return yield predicate(block, [...path, ...innerPath]); }));
99
+ const directMatch = yield nonRecursiveSomeBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () { return yield predicate(block, [...path, ...innerPath]); }));
116
100
  if (directMatch) {
117
101
  return true;
118
102
  }
119
103
  let found = false;
120
- yield nonRecursiveVisitBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
104
+ yield nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
121
105
  if (found || !isItemWithOptionalIdAndMeta(block)) {
122
106
  return;
123
107
  }
@@ -126,50 +110,47 @@ export function someBlocksInFieldValues(schemaRepository, field, value, predicat
126
110
  for (const field of fields) {
127
111
  if (found)
128
112
  break;
129
- yield visitFieldValueAsync(field, block.attributes[field.attributes.api_key], (locale, valueForLocale) => __awaiter(this, void 0, void 0, function* () {
130
- if (found)
131
- return;
132
- const nestedMatch = yield someBlocksInFieldValues(schemaRepository, field, valueForLocale, predicate, [
133
- ...path,
134
- ...innerPath,
135
- 'attributes',
136
- field.attributes.api_key,
137
- ...(locale ? [locale] : []),
138
- ]);
139
- if (nestedMatch) {
140
- found = true;
141
- }
142
- }));
113
+ const nestedMatch = yield someBlocksInNonLocalizedFieldValue(block.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, predicate, [...path, ...innerPath, 'attributes', field.attributes.api_key]);
114
+ if (nestedMatch) {
115
+ found = true;
116
+ }
143
117
  }
144
118
  }));
145
119
  return found;
146
120
  });
147
121
  }
148
- export function everyBlockInFieldValues(schemaRepository, field, value, predicate, path = []) {
122
+ export function everyBlockInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, predicate, path = []) {
149
123
  return __awaiter(this, void 0, void 0, function* () {
150
- return !(yield someBlocksInFieldValues(schemaRepository, field, value, (item, path) => __awaiter(this, void 0, void 0, function* () { return !(yield predicate(item, path)); }), path));
124
+ return !(yield someBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, (item, path) => __awaiter(this, void 0, void 0, function* () { return !(yield predicate(item, path)); }), path));
151
125
  });
152
126
  }
153
- export function mapBlocksInFieldValues(schemaRepository, field, value, mapper, path = []) {
127
+ export function mapBlocksInNonLocalizedFieldValue(nonLocalizedFieldValue, fieldType, schemaRepository, mapper, options = {}, path = []) {
154
128
  return __awaiter(this, void 0, void 0, function* () {
155
- return nonRecursiveMapBlocksInFieldValueAsync(field, value, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
156
- const newBlock = yield mapper(block, [...path, ...innerPath]);
157
- if (!isItemWithOptionalIdAndMeta(newBlock)) {
158
- return newBlock;
129
+ const { traversalDirection = 'top-down' } = options;
130
+ return nonRecursiveMapBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (block, innerPath) => __awaiter(this, void 0, void 0, function* () {
131
+ const blockPath = [...path, ...innerPath];
132
+ if (!isItemWithOptionalIdAndMeta(block)) {
133
+ return yield mapper(block, blockPath);
159
134
  }
160
- const itemType = yield schemaRepository.getRawItemTypeById(newBlock.relationships.item_type.data.id);
135
+ const itemType = yield schemaRepository.getRawItemTypeById(block.relationships.item_type.data.id);
161
136
  const fields = yield schemaRepository.getRawItemTypeFields(itemType);
137
+ if (traversalDirection === 'top-down') {
138
+ const newBlock = yield mapper(block, blockPath);
139
+ if (!isItemWithOptionalIdAndMeta(newBlock)) {
140
+ return newBlock;
141
+ }
142
+ for (const field of fields) {
143
+ newBlock.attributes[field.attributes.api_key] =
144
+ yield mapBlocksInNonLocalizedFieldValue(newBlock.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, mapper, options, [...blockPath, 'attributes', field.attributes.api_key]);
145
+ }
146
+ return newBlock;
147
+ }
148
+ const blockCopy = Object.assign({}, block);
162
149
  for (const field of fields) {
163
- newBlock.attributes[field.attributes.api_key] =
164
- yield mapFieldValueAsync(field, newBlock.attributes[field.attributes.api_key], (locale, valueForLocale) => mapBlocksInFieldValues(schemaRepository, field, valueForLocale, mapper, [
165
- ...path,
166
- ...innerPath,
167
- 'attributes',
168
- field.attributes.api_key,
169
- ...(locale ? [locale] : []),
170
- ]));
150
+ blockCopy.attributes[field.attributes.api_key] =
151
+ yield mapBlocksInNonLocalizedFieldValue(blockCopy.attributes[field.attributes.api_key], field.attributes.field_type, schemaRepository, mapper, options, [...blockPath, 'attributes', field.attributes.api_key]);
171
152
  }
172
- return newBlock;
153
+ return yield mapper(blockCopy, blockPath);
173
154
  }));
174
155
  });
175
156
  }
@@ -1 +1 @@
1
- {"version":3,"file":"recursiveBlocks.js","sourceRoot":"","sources":["../../../src/utilities/recursiveBlocks.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,yCAAyC,EACzC,0CAA0C,EAC1C,sCAAsC,EACtC,yCAAyC,EACzC,uCAAuC,EACvC,wCAAwC,GACzC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAQxE,MAAM,UAAgB,wBAAwB,CAC5C,gBAAkC,EAClC,KAAyC,EACzC,KAAc,EACd,OAA4E,EAC5E,OAAiB,EAAE;;QAEnB,MAAM,wCAAwC,CAC5C,KAAK,EACL,KAAK,EACL,CAAO,KAAK,EAAE,SAAS,EAAE,EAAE;YACzB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;YAE9C,IAAI,CAAC,2BAA2B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BACrC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBAEhD,IAAI,CAAC,2BAA2B,CAAC,QAAQ,CAAC,EAAE;oBAC1C,OAAO,QAAQ,CAAC;iBACjB;gBAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;oBAC1B,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;wBAC3C,MAAM,iCAAiC,CACrC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAC7C,KAAK,CAAC,UAAU,CAAC,UAAU,EAC3B,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,CAAC,GAAG,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CACvD,CAAC;iBACL;gBAED,OAAO,QAAQ,CAAC;aACjB;YAED,MAAM,SAAS,qBAAQ,KAAK,CAAE,CAAC;YAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;oBAC5C,MAAM,iCAAiC,CACrC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAC9C,KAAK,CAAC,UAAU,CAAC,UAAU,EAC3B,gBAAgB,EAEhB,MAAM,EACN,OAAO,EACP,CAAC,GAAG,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CACvD,CAAC;aACL;YAED,OAAO,MAAM,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC,CAAA,CACF,CAAC;IACJ,CAAC;CAAA"}
@@ -41,7 +41,7 @@ interface GenericClient {
41
41
  * - **Caching schema entities**: Automatically caches item types, fields, fieldsets,
42
42
  * and plugins after the first API request, returning cached results on subsequent calls
43
43
  * - **Complex traversal operations**: Essential when using utilities like
44
- * `mapBlocksInFieldValues()` that need to repeatedly lookup block models and fields
44
+ * `mapBlocksInNonLocalizedFieldValue()` that need to repeatedly lookup block models and fields
45
45
  * while traversing nested content structures
46
46
  * - **Bulk operations**: Ideal for scripts that process multiple records of different
47
47
  * types and need efficient access to schema information
@@ -73,7 +73,7 @@ interface GenericClient {
73
73
  * const sameBlogPost = await schemaRepository.getItemTypeByApiKey('blog_post');
74
74
  *
75
75
  * // Pass the repository to utilities that need schema information
76
- * await mapBlocksInFieldValues(schemaRepository, record, (block) => {
76
+ * await mapBlocksInNonLocalizedFieldValue(schemaRepository, record, (block) => {
77
77
  * // The utility will use the cached schema data internally
78
78
  * });
79
79
  * ```
@@ -24,7 +24,7 @@ import { deserializeResponseBody } from '@datocms/rest-client-utils';
24
24
  * - **Caching schema entities**: Automatically caches item types, fields, fieldsets,
25
25
  * and plugins after the first API request, returning cached results on subsequent calls
26
26
  * - **Complex traversal operations**: Essential when using utilities like
27
- * `mapBlocksInFieldValues()` that need to repeatedly lookup block models and fields
27
+ * `mapBlocksInNonLocalizedFieldValue()` that need to repeatedly lookup block models and fields
28
28
  * while traversing nested content structures
29
29
  * - **Bulk operations**: Ideal for scripts that process multiple records of different
30
30
  * types and need efficient access to schema information
@@ -56,7 +56,7 @@ import { deserializeResponseBody } from '@datocms/rest-client-utils';
56
56
  * const sameBlogPost = await schemaRepository.getItemTypeByApiKey('blog_post');
57
57
  *
58
58
  * // Pass the repository to utilities that need schema information
59
- * await mapBlocksInFieldValues(schemaRepository, record, (block) => {
59
+ * await mapBlocksInNonLocalizedFieldValue(schemaRepository, record, (block) => {
60
60
  * // The utility will use the cached schema data internally
61
61
  * });
62
62
  * ```
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { BooleanEditorConfiguration } from './appearance/boolean';
3
3
  import type { BooleanRadioGroupEditorConfiguration } from './appearance/boolean_radio_group';
4
4
  export type BooleanFieldValue = boolean | null;
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { ColorPickerEditorConfiguration } from './appearance/color_picker';
3
3
  import type { RequiredValidator } from './validators/required';
4
4
  export type ColorFieldValue = {
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { DatePickerEditorConfiguration } from './appearance/date_picker';
3
3
  import type { DateRangeValidator } from './validators/date_range';
4
4
  import type { RequiredValidator } from './validators/required';
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { DateTimePickerEditorConfiguration } from './appearance/date_time_picker';
3
3
  import type { DateTimeRangeValidator } from './validators/date_time_range';
4
4
  import type { RequiredValidator } from './validators/required';
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { FileEditorConfiguration } from './appearance/file';
3
3
  import type { ExtensionValidator } from './validators/extension';
4
4
  import type { FileSizeValidator } from './validators/file_size';
@@ -6,7 +6,59 @@ import type { ImageAspectRatioValidator } from './validators/image_aspect_ratio'
6
6
  import type { ImageDimensionsValidator } from './validators/image_dimensions';
7
7
  import type { RequiredValidator } from './validators/required';
8
8
  import type { RequiredAltTitleValidator } from './validators/required_alt_title';
9
+ /**
10
+ * FILE FIELD TYPE SYSTEM FOR DATOCMS
11
+ *
12
+ * This module defines a comprehensive type system for handling DatoCMS File fields,
13
+ * which contain file uploads with optional metadata like alt text, title, custom data, and focal points.
14
+ *
15
+ * The challenge we're solving:
16
+ * - DatoCMS File fields can have optional metadata fields (alt, title, custom_data, focal_point)
17
+ * - For API requests, all these fields are optional and can be omitted
18
+ * - For API responses, DatoCMS provides default values for missing fields:
19
+ * - alt: null
20
+ * - title: null
21
+ * - custom_data: {}
22
+ * - focal_point: null
23
+ * - This creates a need for different type variants for the same conceptual data structure
24
+ *
25
+ * This module provides separate types for:
26
+ * 1. API request format (optional metadata fields)
27
+ * 2. API response format (all fields present with defaults)
28
+ */
29
+ /**
30
+ * =============================================================================
31
+ * BASIC FILE TYPE - Default API response format
32
+ * =============================================================================
33
+ *
34
+ * The standard File field value with all metadata fields present and default values applied.
35
+ * This is what you get from API responses where DatoCMS has applied default values.
36
+ */
37
+ /**
38
+ * Basic File field value - all metadata fields present with defaults applied
39
+ */
9
40
  export type FileFieldValue = {
41
+ upload_id: string;
42
+ alt: string | null;
43
+ title: string | null;
44
+ custom_data: Record<string, unknown>;
45
+ focal_point: {
46
+ x: number;
47
+ y: number;
48
+ } | null;
49
+ } | null;
50
+ /**
51
+ * =============================================================================
52
+ * REQUEST VARIANT - Type for sending data TO the DatoCMS API
53
+ * =============================================================================
54
+ *
55
+ * When making API requests, metadata fields are optional and can be omitted.
56
+ * DatoCMS will apply default values for any missing fields in the response.
57
+ */
58
+ /**
59
+ * File field value for API requests - metadata fields are optional
60
+ */
61
+ export type FileFieldValueInRequest = {
10
62
  upload_id: string;
11
63
  alt?: string | null;
12
64
  title?: string | null;
@@ -16,8 +68,23 @@ export type FileFieldValue = {
16
68
  y: number;
17
69
  } | null;
18
70
  } | null;
71
+ /**
72
+ * =============================================================================
73
+ * TYPE GUARDS - Runtime validation functions
74
+ * =============================================================================
75
+ */
76
+ /**
77
+ * Type guard for basic File field values (response format with all fields present).
78
+ * Validates that all required metadata fields are present.
79
+ */
19
80
  export declare function isFileFieldValue(value: unknown): value is FileFieldValue;
81
+ /**
82
+ * Type guard for File field values in API request format.
83
+ * Allows metadata fields to be optional or omitted.
84
+ */
85
+ export declare function isFileFieldValueInRequest(value: unknown): value is FileFieldValueInRequest;
20
86
  export declare function isLocalizedFileFieldValue(value: unknown): value is LocalizedFieldValue<FileFieldValue>;
87
+ export declare function isLocalizedFileFieldValueInRequest(value: unknown): value is LocalizedFieldValue<FileFieldValueInRequest>;
21
88
  export type FileFieldValidators = {
22
89
  /** Value must be specified or it won't be valid */
23
90
  required?: RequiredValidator;
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { FloatEditorConfiguration } from './appearance/float';
3
3
  import type { NumberRangeValidator } from './validators/number_range';
4
4
  import type { RequiredValidator } from './validators/required';
@@ -1,23 +1,39 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { GalleryEditorConfiguration } from './appearance/gallery';
3
+ import { type FileFieldValue, type FileFieldValueInRequest } from './file';
3
4
  import type { ExtensionValidator } from './validators/extension';
4
5
  import type { FileSizeValidator } from './validators/file_size';
5
6
  import type { ImageAspectRatioValidator } from './validators/image_aspect_ratio';
6
7
  import type { ImageDimensionsValidator } from './validators/image_dimensions';
7
8
  import type { RequiredAltTitleValidator } from './validators/required_alt_title';
8
9
  import type { SizeValidator } from './validators/size';
9
- export type GalleryFieldValue = Array<{
10
- upload_id: string;
11
- alt?: string | null;
12
- title?: string | null;
13
- custom_data?: Record<string, unknown>;
14
- focal_point?: {
15
- x: number;
16
- y: number;
17
- } | null;
18
- }>;
10
+ /**
11
+ * Gallery field type system - similar to File field but for arrays.
12
+ * See file.ts for detailed explanation of request/response duality.
13
+ */
14
+ /**
15
+ * Individual gallery item types - extracted from File field types
16
+ */
17
+ export type GalleryItem = NonNullable<FileFieldValue>;
18
+ export type GalleryItemInRequest = NonNullable<FileFieldValueInRequest>;
19
+ /**
20
+ * Gallery field value - response format with all metadata fields present
21
+ */
22
+ export type GalleryFieldValue = Array<GalleryItem>;
23
+ /**
24
+ * Gallery field value for API requests - metadata fields are optional
25
+ */
26
+ export type GalleryFieldValueInRequest = Array<GalleryItemInRequest>;
27
+ /**
28
+ * Type guard for Gallery field values - validates each item using File field validation
29
+ */
19
30
  export declare function isGalleryFieldValue(value: unknown): value is GalleryFieldValue;
31
+ /**
32
+ * Type guard for Gallery field values in API request format
33
+ */
34
+ export declare function isGalleryFieldValueInRequest(value: unknown): value is GalleryFieldValueInRequest;
20
35
  export declare function isLocalizedGalleryFieldValue(value: unknown): value is LocalizedFieldValue<GalleryFieldValue>;
36
+ export declare function isLocalizedGalleryFieldValueInRequest(value: unknown): value is LocalizedFieldValue<GalleryFieldValueInRequest>;
21
37
  export type GalleryFieldValidators = {
22
38
  /** Only accept a number of items within the specified range */
23
39
  size?: SizeValidator;
@@ -1,3 +1,4 @@
1
+ export * from './appearance';
1
2
  export * from './boolean';
2
3
  export * from './color';
3
4
  export * from './date';
@@ -17,6 +18,5 @@ export * from './slug';
17
18
  export * from './string';
18
19
  export * from './structured_text';
19
20
  export * from './text';
20
- export * from './video';
21
- export * from './appearance';
22
21
  export * from './validators';
22
+ export * from './video';
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { IntegerEditorConfiguration } from './appearance/integer';
3
3
  import type { NumberRangeValidator } from './validators/number_range';
4
4
  import type { RequiredValidator } from './validators/required';
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { JsonEditorConfiguration } from './appearance/json';
3
3
  import type { StringCheckboxGroupEditorConfiguration } from './appearance/string_checkbox_group';
4
4
  import type { StringMultiSelectEditorConfiguration } from './appearance/string_multi_select';
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { MapEditorConfiguration } from './appearance/map';
3
3
  import type { RequiredValidator } from './validators/required';
4
4
  export type LatLonFieldValue = {
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { LinkEmbedEditorConfiguration } from './appearance/link_embed';
3
3
  import type { LinkSelectEditorConfiguration } from './appearance/link_select';
4
4
  import type { ItemItemTypeValidator } from './validators/item_item_type';
@@ -1,4 +1,4 @@
1
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
2
2
  import type { LinksEmbedEditorConfiguration } from './appearance/links_embed';
3
3
  import type { LinksSelectEditorConfiguration } from './appearance/links_select';
4
4
  import type { ItemsItemTypeValidator } from './validators/items_item_type';
@@ -1,8 +1,7 @@
1
- import type * as RawApiTypes from '../generated/RawApiTypes';
2
- import type { LocalizedFieldValue } from '../utilities/fieldValue';
3
- import type { ItemDefinition } from '../utilities/itemDefinition';
1
+ import type { ItemTypeDefinition } from '../utilities/itemDefinition';
2
+ import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
4
3
  import type { RichTextEditorConfiguration } from './appearance/rich_text';
5
- import { type BlockItemInARequest } from './single_block';
4
+ import { type BlockInNestedResponse, type BlockInRequest } from './single_block';
6
5
  import type { RichTextBlocksValidator } from './validators/rich_text_blocks';
7
6
  import type { SizeValidator } from './validators/size';
8
7
  /**
@@ -51,7 +50,7 @@ export type RichTextFieldValue = string[];
51
50
  * - RawApiTypes.Item: Full block object with ID (for updates)
52
51
  * - Omit<RawApiTypes.Item, 'id'>: Block object without ID (for creation)
53
52
  */
54
- export type RichTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinition> = BlockItemInARequest<D>[] | null;
53
+ export type RichTextFieldValueInRequest<D extends ItemTypeDefinition = ItemTypeDefinition> = BlockInRequest<D>[] | null;
55
54
  /**
56
55
  * =============================================================================
57
56
  * NESTED VARIANT - Type for API responses with ?nested=true parameter
@@ -64,7 +63,7 @@ export type RichTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinitio
64
63
  /**
65
64
  * Modular Content field value with nested blocks - array of fully populated block objects
66
65
  */
67
- export type RichTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition> = RawApiTypes.Item<D>[];
66
+ export type RichTextFieldValueInNestedResponse<D extends ItemTypeDefinition = ItemTypeDefinition> = BlockInNestedResponse<D>[];
68
67
  /**
69
68
  * =============================================================================
70
69
  * TYPE GUARDS - Runtime validation functions
@@ -80,14 +79,14 @@ export declare function isLocalizedRichTextFieldValue(value: unknown): value is
80
79
  * Type guard for Modular Content field values in API request format.
81
80
  * Allows blocks as string IDs, full objects with IDs, or objects without IDs.
82
81
  */
83
- export declare function isRichTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinition>(value: unknown): value is RichTextFieldValueAsRequest<D>;
84
- export declare function isLocalizedRichTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<RichTextFieldValueAsRequest<D>>;
82
+ export declare function isRichTextFieldValueInRequest<D extends ItemTypeDefinition = ItemTypeDefinition>(value: unknown): value is RichTextFieldValueInRequest<D>;
83
+ export declare function isLocalizedRichTextFieldValueInRequest<D extends ItemTypeDefinition = ItemTypeDefinition>(value: unknown): value is LocalizedFieldValue<RichTextFieldValueInRequest<D>>;
85
84
  /**
86
85
  * Type guard for Modular Content field values with nested blocks (?nested=true format).
87
86
  * Ensures all blocks are full RawApiTypes.Item objects with complete data.
88
87
  */
89
- export declare function isRichTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is RichTextFieldValueWithNestedBlocks<D>;
90
- export declare function isLocalizedRichTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<RichTextFieldValueWithNestedBlocks<D>>;
88
+ export declare function isRichTextFieldValueInNestedResponse<D extends ItemTypeDefinition = ItemTypeDefinition>(value: unknown): value is RichTextFieldValueInNestedResponse<D>;
89
+ export declare function isLocalizedRichTextFieldValueInNestedResponse<D extends ItemTypeDefinition = ItemTypeDefinition>(value: unknown): value is LocalizedFieldValue<RichTextFieldValueInNestedResponse<D>>;
91
90
  export type RichTextFieldValidators = {
92
91
  /** Only accept references to block records of the specified block models */
93
92
  rich_text_blocks: RichTextBlocksValidator;