@datocms/cma-client 5.1.0 → 5.1.2

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 (329) hide show
  1. package/dist/cjs/fieldTypes/rich_text.js +7 -7
  2. package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
  3. package/dist/cjs/fieldTypes/single_block.js +21 -19
  4. package/dist/cjs/fieldTypes/single_block.js.map +1 -1
  5. package/dist/cjs/fieldTypes/structured_text.js +12 -24
  6. package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
  7. package/dist/cjs/generated/{SchemaTypes.js → ApiTypes.js} +1 -1
  8. package/dist/cjs/generated/ApiTypes.js.map +1 -0
  9. package/dist/cjs/generated/Client.js +1 -1
  10. package/dist/cjs/generated/{SimpleSchemaTypes.js → RawApiTypes.js} +1 -1
  11. package/dist/cjs/generated/RawApiTypes.js.map +1 -0
  12. package/dist/cjs/generated/resources/AccessToken.js.map +1 -1
  13. package/dist/cjs/generated/resources/AuditLogEvent.js.map +1 -1
  14. package/dist/cjs/generated/resources/BuildEvent.js.map +1 -1
  15. package/dist/cjs/generated/resources/BuildTrigger.js.map +1 -1
  16. package/dist/cjs/generated/resources/EditingSession.js.map +1 -1
  17. package/dist/cjs/generated/resources/EmojiSuggestions.js.map +1 -1
  18. package/dist/cjs/generated/resources/Environment.js.map +1 -1
  19. package/dist/cjs/generated/resources/Field.js.map +1 -1
  20. package/dist/cjs/generated/resources/Fieldset.js.map +1 -1
  21. package/dist/cjs/generated/resources/Item.js.map +1 -1
  22. package/dist/cjs/generated/resources/ItemType.js.map +1 -1
  23. package/dist/cjs/generated/resources/ItemTypeFilter.js.map +1 -1
  24. package/dist/cjs/generated/resources/ItemVersion.js.map +1 -1
  25. package/dist/cjs/generated/resources/JobResult.js.map +1 -1
  26. package/dist/cjs/generated/resources/MaintenanceMode.js.map +1 -1
  27. package/dist/cjs/generated/resources/MenuItem.js.map +1 -1
  28. package/dist/cjs/generated/resources/Plugin.js.map +1 -1
  29. package/dist/cjs/generated/resources/PublicInfo.js.map +1 -1
  30. package/dist/cjs/generated/resources/Role.js.map +1 -1
  31. package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
  32. package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
  33. package/dist/cjs/generated/resources/SchemaMenuItem.js.map +1 -1
  34. package/dist/cjs/generated/resources/SearchResult.js.map +1 -1
  35. package/dist/cjs/generated/resources/Session.js.map +1 -1
  36. package/dist/cjs/generated/resources/Site.js.map +1 -1
  37. package/dist/cjs/generated/resources/SiteInvitation.js.map +1 -1
  38. package/dist/cjs/generated/resources/SsoGroup.js.map +1 -1
  39. package/dist/cjs/generated/resources/SsoSettings.js.map +1 -1
  40. package/dist/cjs/generated/resources/SsoUser.js.map +1 -1
  41. package/dist/cjs/generated/resources/SubscriptionLimit.js.map +1 -1
  42. package/dist/cjs/generated/resources/Upload.js.map +1 -1
  43. package/dist/cjs/generated/resources/UploadCollection.js.map +1 -1
  44. package/dist/cjs/generated/resources/UploadFilter.js.map +1 -1
  45. package/dist/cjs/generated/resources/UploadRequest.js.map +1 -1
  46. package/dist/cjs/generated/resources/UploadSmartTag.js.map +1 -1
  47. package/dist/cjs/generated/resources/UploadTag.js.map +1 -1
  48. package/dist/cjs/generated/resources/UploadTrack.js.map +1 -1
  49. package/dist/cjs/generated/resources/UsageCounter.js.map +1 -1
  50. package/dist/cjs/generated/resources/User.js.map +1 -1
  51. package/dist/cjs/generated/resources/Webhook.js.map +1 -1
  52. package/dist/cjs/generated/resources/WebhookCall.js.map +1 -1
  53. package/dist/cjs/generated/resources/WhiteLabelSettings.js.map +1 -1
  54. package/dist/cjs/generated/resources/Workflow.js.map +1 -1
  55. package/dist/cjs/index.js +2 -5
  56. package/dist/cjs/index.js.map +1 -1
  57. package/dist/cjs/resources/Role.js.map +1 -1
  58. package/dist/cjs/utilities/blocks.js +7 -7
  59. package/dist/cjs/utilities/blocks.js.map +1 -1
  60. package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
  61. package/dist/cjs/utilities/fieldValue.js +253 -0
  62. package/dist/cjs/utilities/fieldValue.js.map +1 -0
  63. package/dist/cjs/utilities/fieldsContainingReferences.js.map +1 -1
  64. package/dist/cjs/utilities/recursiveBlocks.js +18 -19
  65. package/dist/cjs/utilities/recursiveBlocks.js.map +1 -1
  66. package/dist/cjs/utilities/schemaRepository.js.map +1 -1
  67. package/dist/esm/fieldTypes/rich_text.d.ts +7 -7
  68. package/dist/esm/fieldTypes/rich_text.js +6 -6
  69. package/dist/esm/fieldTypes/rich_text.js.map +1 -1
  70. package/dist/esm/fieldTypes/single_block.d.ts +30 -24
  71. package/dist/esm/fieldTypes/single_block.js +16 -14
  72. package/dist/esm/fieldTypes/single_block.js.map +1 -1
  73. package/dist/esm/fieldTypes/structured_text.d.ts +20 -85
  74. package/dist/esm/fieldTypes/structured_text.js +11 -23
  75. package/dist/esm/fieldTypes/structured_text.js.map +1 -1
  76. package/dist/esm/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +13 -8
  77. package/dist/esm/generated/ApiTypes.js +2 -0
  78. package/dist/esm/generated/ApiTypes.js.map +1 -0
  79. package/dist/esm/generated/Client.d.ts +1 -1
  80. package/dist/esm/generated/Client.js +1 -1
  81. package/dist/esm/generated/{SchemaTypes.d.ts → RawApiTypes.d.ts} +13 -8
  82. package/dist/esm/generated/RawApiTypes.js +2 -0
  83. package/dist/esm/generated/RawApiTypes.js.map +1 -0
  84. package/dist/esm/generated/resources/AccessToken.d.ts +14 -14
  85. package/dist/esm/generated/resources/AccessToken.js.map +1 -1
  86. package/dist/esm/generated/resources/AuditLogEvent.d.ts +4 -4
  87. package/dist/esm/generated/resources/AuditLogEvent.js.map +1 -1
  88. package/dist/esm/generated/resources/BuildEvent.d.ts +8 -8
  89. package/dist/esm/generated/resources/BuildEvent.js.map +1 -1
  90. package/dist/esm/generated/resources/BuildTrigger.d.ts +16 -16
  91. package/dist/esm/generated/resources/BuildTrigger.js.map +1 -1
  92. package/dist/esm/generated/resources/DailyUsage.d.ts +4 -4
  93. package/dist/esm/generated/resources/EditingSession.d.ts +7 -7
  94. package/dist/esm/generated/resources/EditingSession.js.map +1 -1
  95. package/dist/esm/generated/resources/EmojiSuggestions.d.ts +4 -4
  96. package/dist/esm/generated/resources/EmojiSuggestions.js.map +1 -1
  97. package/dist/esm/generated/resources/Environment.d.ts +14 -14
  98. package/dist/esm/generated/resources/Environment.js.map +1 -1
  99. package/dist/esm/generated/resources/Field.d.ts +213 -213
  100. package/dist/esm/generated/resources/Field.js.map +1 -1
  101. package/dist/esm/generated/resources/Fieldset.d.ts +12 -12
  102. package/dist/esm/generated/resources/Fieldset.js.map +1 -1
  103. package/dist/esm/generated/resources/Item.d.ts +36 -36
  104. package/dist/esm/generated/resources/Item.js.map +1 -1
  105. package/dist/esm/generated/resources/ItemType.d.ts +15 -15
  106. package/dist/esm/generated/resources/ItemType.js.map +1 -1
  107. package/dist/esm/generated/resources/ItemTypeFilter.d.ts +12 -12
  108. package/dist/esm/generated/resources/ItemTypeFilter.js.map +1 -1
  109. package/dist/esm/generated/resources/ItemVersion.d.ts +10 -10
  110. package/dist/esm/generated/resources/ItemVersion.js.map +1 -1
  111. package/dist/esm/generated/resources/JobResult.d.ts +4 -4
  112. package/dist/esm/generated/resources/JobResult.js.map +1 -1
  113. package/dist/esm/generated/resources/MaintenanceMode.d.ts +8 -8
  114. package/dist/esm/generated/resources/MaintenanceMode.js.map +1 -1
  115. package/dist/esm/generated/resources/MenuItem.d.ts +14 -14
  116. package/dist/esm/generated/resources/MenuItem.js.map +1 -1
  117. package/dist/esm/generated/resources/Plugin.d.ts +14 -14
  118. package/dist/esm/generated/resources/Plugin.js.map +1 -1
  119. package/dist/esm/generated/resources/PublicInfo.d.ts +4 -4
  120. package/dist/esm/generated/resources/PublicInfo.js.map +1 -1
  121. package/dist/esm/generated/resources/Role.d.ts +14 -14
  122. package/dist/esm/generated/resources/Role.js.map +1 -1
  123. package/dist/esm/generated/resources/ScheduledPublication.d.ts +6 -6
  124. package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
  125. package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +6 -6
  126. package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
  127. package/dist/esm/generated/resources/SchemaMenuItem.d.ts +14 -14
  128. package/dist/esm/generated/resources/SchemaMenuItem.js.map +1 -1
  129. package/dist/esm/generated/resources/SearchResult.d.ts +6 -6
  130. package/dist/esm/generated/resources/SearchResult.js.map +1 -1
  131. package/dist/esm/generated/resources/Session.d.ts +4 -4
  132. package/dist/esm/generated/resources/Session.js.map +1 -1
  133. package/dist/esm/generated/resources/Site.d.ts +24 -24
  134. package/dist/esm/generated/resources/Site.js.map +1 -1
  135. package/dist/esm/generated/resources/SiteInvitation.d.ts +14 -14
  136. package/dist/esm/generated/resources/SiteInvitation.js.map +1 -1
  137. package/dist/esm/generated/resources/SsoGroup.d.ts +10 -10
  138. package/dist/esm/generated/resources/SsoGroup.js.map +1 -1
  139. package/dist/esm/generated/resources/SsoSettings.d.ts +8 -8
  140. package/dist/esm/generated/resources/SsoSettings.js.map +1 -1
  141. package/dist/esm/generated/resources/SsoUser.d.ts +10 -10
  142. package/dist/esm/generated/resources/SsoUser.js.map +1 -1
  143. package/dist/esm/generated/resources/SubscriptionFeature.d.ts +4 -4
  144. package/dist/esm/generated/resources/SubscriptionLimit.d.ts +6 -6
  145. package/dist/esm/generated/resources/SubscriptionLimit.js.map +1 -1
  146. package/dist/esm/generated/resources/Upload.d.ts +22 -22
  147. package/dist/esm/generated/resources/Upload.js.map +1 -1
  148. package/dist/esm/generated/resources/UploadCollection.d.ts +14 -14
  149. package/dist/esm/generated/resources/UploadCollection.js.map +1 -1
  150. package/dist/esm/generated/resources/UploadFilter.d.ts +12 -12
  151. package/dist/esm/generated/resources/UploadFilter.js.map +1 -1
  152. package/dist/esm/generated/resources/UploadRequest.d.ts +4 -4
  153. package/dist/esm/generated/resources/UploadRequest.js.map +1 -1
  154. package/dist/esm/generated/resources/UploadSmartTag.d.ts +6 -6
  155. package/dist/esm/generated/resources/UploadSmartTag.js.map +1 -1
  156. package/dist/esm/generated/resources/UploadTag.d.ts +8 -8
  157. package/dist/esm/generated/resources/UploadTag.js.map +1 -1
  158. package/dist/esm/generated/resources/UploadTrack.d.ts +10 -10
  159. package/dist/esm/generated/resources/UploadTrack.js.map +1 -1
  160. package/dist/esm/generated/resources/UsageCounter.d.ts +4 -4
  161. package/dist/esm/generated/resources/UsageCounter.js.map +1 -1
  162. package/dist/esm/generated/resources/User.d.ts +12 -12
  163. package/dist/esm/generated/resources/User.js.map +1 -1
  164. package/dist/esm/generated/resources/Webhook.d.ts +12 -12
  165. package/dist/esm/generated/resources/Webhook.js.map +1 -1
  166. package/dist/esm/generated/resources/WebhookCall.d.ts +9 -9
  167. package/dist/esm/generated/resources/WebhookCall.js.map +1 -1
  168. package/dist/esm/generated/resources/WhiteLabelSettings.d.ts +6 -6
  169. package/dist/esm/generated/resources/WhiteLabelSettings.js.map +1 -1
  170. package/dist/esm/generated/resources/Workflow.d.ts +11 -11
  171. package/dist/esm/generated/resources/Workflow.js.map +1 -1
  172. package/dist/esm/index.d.ts +5 -4
  173. package/dist/esm/index.js +1 -4
  174. package/dist/esm/index.js.map +1 -1
  175. package/dist/esm/resources/Role.d.ts +4 -4
  176. package/dist/esm/resources/Role.js.map +1 -1
  177. package/dist/esm/utilities/blocks.d.ts +17 -17
  178. package/dist/esm/utilities/blocks.js +3 -3
  179. package/dist/esm/utilities/blocks.js.map +1 -1
  180. package/dist/esm/utilities/buildBlockRecord.d.ts +5 -5
  181. package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
  182. package/dist/esm/utilities/fieldValue.d.ts +166 -0
  183. package/dist/esm/utilities/fieldValue.js +237 -0
  184. package/dist/esm/utilities/fieldValue.js.map +1 -0
  185. package/dist/esm/utilities/fieldsContainingReferences.d.ts +4 -4
  186. package/dist/esm/utilities/fieldsContainingReferences.js.map +1 -1
  187. package/dist/esm/utilities/recursiveBlocks.d.ts +13 -10
  188. package/dist/esm/utilities/recursiveBlocks.js +19 -20
  189. package/dist/esm/utilities/recursiveBlocks.js.map +1 -1
  190. package/dist/esm/utilities/schemaRepository.d.ts +29 -26
  191. package/dist/esm/utilities/schemaRepository.js.map +1 -1
  192. package/dist/types/fieldTypes/rich_text.d.ts +7 -7
  193. package/dist/types/fieldTypes/single_block.d.ts +30 -24
  194. package/dist/types/fieldTypes/structured_text.d.ts +20 -85
  195. package/dist/types/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +13 -8
  196. package/dist/types/generated/Client.d.ts +1 -1
  197. package/dist/types/generated/{SchemaTypes.d.ts → RawApiTypes.d.ts} +13 -8
  198. package/dist/types/generated/resources/AccessToken.d.ts +14 -14
  199. package/dist/types/generated/resources/AuditLogEvent.d.ts +4 -4
  200. package/dist/types/generated/resources/BuildEvent.d.ts +8 -8
  201. package/dist/types/generated/resources/BuildTrigger.d.ts +16 -16
  202. package/dist/types/generated/resources/DailyUsage.d.ts +4 -4
  203. package/dist/types/generated/resources/EditingSession.d.ts +7 -7
  204. package/dist/types/generated/resources/EmojiSuggestions.d.ts +4 -4
  205. package/dist/types/generated/resources/Environment.d.ts +14 -14
  206. package/dist/types/generated/resources/Field.d.ts +213 -213
  207. package/dist/types/generated/resources/Fieldset.d.ts +12 -12
  208. package/dist/types/generated/resources/Item.d.ts +36 -36
  209. package/dist/types/generated/resources/ItemType.d.ts +15 -15
  210. package/dist/types/generated/resources/ItemTypeFilter.d.ts +12 -12
  211. package/dist/types/generated/resources/ItemVersion.d.ts +10 -10
  212. package/dist/types/generated/resources/JobResult.d.ts +4 -4
  213. package/dist/types/generated/resources/MaintenanceMode.d.ts +8 -8
  214. package/dist/types/generated/resources/MenuItem.d.ts +14 -14
  215. package/dist/types/generated/resources/Plugin.d.ts +14 -14
  216. package/dist/types/generated/resources/PublicInfo.d.ts +4 -4
  217. package/dist/types/generated/resources/Role.d.ts +14 -14
  218. package/dist/types/generated/resources/ScheduledPublication.d.ts +6 -6
  219. package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +6 -6
  220. package/dist/types/generated/resources/SchemaMenuItem.d.ts +14 -14
  221. package/dist/types/generated/resources/SearchResult.d.ts +6 -6
  222. package/dist/types/generated/resources/Session.d.ts +4 -4
  223. package/dist/types/generated/resources/Site.d.ts +24 -24
  224. package/dist/types/generated/resources/SiteInvitation.d.ts +14 -14
  225. package/dist/types/generated/resources/SsoGroup.d.ts +10 -10
  226. package/dist/types/generated/resources/SsoSettings.d.ts +8 -8
  227. package/dist/types/generated/resources/SsoUser.d.ts +10 -10
  228. package/dist/types/generated/resources/SubscriptionFeature.d.ts +4 -4
  229. package/dist/types/generated/resources/SubscriptionLimit.d.ts +6 -6
  230. package/dist/types/generated/resources/Upload.d.ts +22 -22
  231. package/dist/types/generated/resources/UploadCollection.d.ts +14 -14
  232. package/dist/types/generated/resources/UploadFilter.d.ts +12 -12
  233. package/dist/types/generated/resources/UploadRequest.d.ts +4 -4
  234. package/dist/types/generated/resources/UploadSmartTag.d.ts +6 -6
  235. package/dist/types/generated/resources/UploadTag.d.ts +8 -8
  236. package/dist/types/generated/resources/UploadTrack.d.ts +10 -10
  237. package/dist/types/generated/resources/UsageCounter.d.ts +4 -4
  238. package/dist/types/generated/resources/User.d.ts +12 -12
  239. package/dist/types/generated/resources/Webhook.d.ts +12 -12
  240. package/dist/types/generated/resources/WebhookCall.d.ts +9 -9
  241. package/dist/types/generated/resources/WhiteLabelSettings.d.ts +6 -6
  242. package/dist/types/generated/resources/Workflow.d.ts +11 -11
  243. package/dist/types/index.d.ts +5 -4
  244. package/dist/types/resources/Role.d.ts +4 -4
  245. package/dist/types/utilities/blocks.d.ts +17 -17
  246. package/dist/types/utilities/buildBlockRecord.d.ts +5 -5
  247. package/dist/types/utilities/fieldValue.d.ts +166 -0
  248. package/dist/types/utilities/fieldsContainingReferences.d.ts +4 -4
  249. package/dist/types/utilities/recursiveBlocks.d.ts +13 -10
  250. package/dist/types/utilities/schemaRepository.d.ts +29 -26
  251. package/package.json +5 -5
  252. package/src/fieldTypes/rich_text.ts +14 -14
  253. package/src/fieldTypes/single_block.ts +48 -33
  254. package/src/fieldTypes/structured_text.ts +37 -153
  255. package/src/generated/{SimpleSchemaTypes.ts → ApiTypes.ts} +44 -9
  256. package/src/generated/Client.ts +2 -2
  257. package/src/generated/{SchemaTypes.ts → RawApiTypes.ts} +44 -9
  258. package/src/generated/resources/AccessToken.ts +32 -34
  259. package/src/generated/resources/AuditLogEvent.ts +8 -8
  260. package/src/generated/resources/BuildEvent.ts +16 -18
  261. package/src/generated/resources/BuildTrigger.ts +30 -30
  262. package/src/generated/resources/DailyUsage.ts +5 -5
  263. package/src/generated/resources/EditingSession.ts +12 -12
  264. package/src/generated/resources/EmojiSuggestions.ts +7 -7
  265. package/src/generated/resources/Environment.ts +33 -39
  266. package/src/generated/resources/Field.ts +40 -54
  267. package/src/generated/resources/Fieldset.ts +28 -36
  268. package/src/generated/resources/Item.ts +99 -126
  269. package/src/generated/resources/ItemType.ts +37 -45
  270. package/src/generated/resources/ItemTypeFilter.ts +26 -26
  271. package/src/generated/resources/ItemVersion.ts +22 -26
  272. package/src/generated/resources/JobResult.ts +6 -8
  273. package/src/generated/resources/MaintenanceMode.ts +13 -13
  274. package/src/generated/resources/MenuItem.ts +34 -44
  275. package/src/generated/resources/Plugin.ts +30 -42
  276. package/src/generated/resources/PublicInfo.ts +5 -7
  277. package/src/generated/resources/Role.ts +29 -44
  278. package/src/generated/resources/ScheduledPublication.ts +13 -13
  279. package/src/generated/resources/ScheduledUnpublishing.ts +13 -13
  280. package/src/generated/resources/SchemaMenuItem.ts +34 -34
  281. package/src/generated/resources/SearchResult.ts +12 -12
  282. package/src/generated/resources/Session.ts +8 -10
  283. package/src/generated/resources/Site.ts +43 -47
  284. package/src/generated/resources/SiteInvitation.ts +30 -30
  285. package/src/generated/resources/SsoGroup.ts +20 -24
  286. package/src/generated/resources/SsoSettings.ts +14 -16
  287. package/src/generated/resources/SsoUser.ts +18 -22
  288. package/src/generated/resources/SubscriptionFeature.ts +5 -5
  289. package/src/generated/resources/SubscriptionLimit.ts +9 -9
  290. package/src/generated/resources/Upload.ts +57 -73
  291. package/src/generated/resources/UploadCollection.ts +34 -34
  292. package/src/generated/resources/UploadFilter.ts +26 -26
  293. package/src/generated/resources/UploadRequest.ts +8 -8
  294. package/src/generated/resources/UploadSmartTag.ts +12 -12
  295. package/src/generated/resources/UploadTag.ts +18 -20
  296. package/src/generated/resources/UploadTrack.ts +25 -29
  297. package/src/generated/resources/UsageCounter.ts +8 -8
  298. package/src/generated/resources/User.ts +28 -39
  299. package/src/generated/resources/Webhook.ts +26 -34
  300. package/src/generated/resources/WebhookCall.ts +17 -19
  301. package/src/generated/resources/WhiteLabelSettings.ts +11 -11
  302. package/src/generated/resources/Workflow.ts +23 -29
  303. package/src/index.ts +7 -4
  304. package/src/resources/Role.ts +6 -6
  305. package/src/utilities/blocks.ts +36 -36
  306. package/src/utilities/buildBlockRecord.ts +4 -4
  307. package/src/utilities/{fieldValueLocalization.ts → fieldValue.ts} +161 -147
  308. package/src/utilities/fieldsContainingReferences.ts +4 -4
  309. package/src/utilities/recursiveBlocks.ts +47 -44
  310. package/src/utilities/schemaRepository.ts +53 -56
  311. package/dist/cjs/generated/SchemaTypes.js.map +0 -1
  312. package/dist/cjs/generated/SimpleSchemaTypes.js.map +0 -1
  313. package/dist/cjs/utilities/fieldValueLocalization.js +0 -218
  314. package/dist/cjs/utilities/fieldValueLocalization.js.map +0 -1
  315. package/dist/cjs/utilities/structuredText.js +0 -371
  316. package/dist/cjs/utilities/structuredText.js.map +0 -1
  317. package/dist/esm/generated/SchemaTypes.js +0 -2
  318. package/dist/esm/generated/SchemaTypes.js.map +0 -1
  319. package/dist/esm/generated/SimpleSchemaTypes.js +0 -2
  320. package/dist/esm/generated/SimpleSchemaTypes.js.map +0 -1
  321. package/dist/esm/utilities/fieldValueLocalization.d.ts +0 -123
  322. package/dist/esm/utilities/fieldValueLocalization.js +0 -204
  323. package/dist/esm/utilities/fieldValueLocalization.js.map +0 -1
  324. package/dist/esm/utilities/structuredText.d.ts +0 -177
  325. package/dist/esm/utilities/structuredText.js +0 -354
  326. package/dist/esm/utilities/structuredText.js.map +0 -1
  327. package/dist/types/utilities/fieldValueLocalization.d.ts +0 -123
  328. package/dist/types/utilities/structuredText.d.ts +0 -177
  329. package/src/utilities/structuredText.ts +0 -590
@@ -21,10 +21,10 @@
21
21
  * All functions come in both sync and async variants to support different use cases,
22
22
  * particularly useful when block transformations require async operations like API calls.
23
23
  */
24
+ import { type TreePath } from 'datocms-structured-text-utils';
24
25
  import type { BlockItemInARequest } from '../fieldTypes';
25
- import type * as SchemaTypes from '../generated/SchemaTypes';
26
- import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
27
- import { type TreePath } from './structuredText';
26
+ import type * as ApiTypes from '../generated/ApiTypes';
27
+ import type * as RawApiTypes from '../generated/RawApiTypes';
28
28
  /**
29
29
  * Visit every block in a field value, calling the visitor function for each block found.
30
30
  * Supports rich text, single block, and structured text field types.
@@ -33,7 +33,7 @@ import { type TreePath } from './structuredText';
33
33
  * @param value - The field value containing blocks to visit
34
34
  * @param visitor - Synchronous function called for each block. Receives the block item and its path
35
35
  */
36
- export declare function nonRecursiveVisitBlocksInFieldValue(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => void): void;
36
+ export declare function nonRecursiveVisitBlocksInFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => void): void;
37
37
  /**
38
38
  * Visit every block in a field value, calling the visitor function for each block found.
39
39
  * Supports rich text, single block, and structured text field types.
@@ -43,7 +43,7 @@ export declare function nonRecursiveVisitBlocksInFieldValue(field: SchemaTypes.F
43
43
  * @param visitor - Asynchronous function called for each block. Receives the block item and its path
44
44
  * @returns Promise that resolves when all blocks have been visited
45
45
  */
46
- export declare function nonRecursiveVisitBlocksInFieldValueAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => Promise<void>): Promise<void>;
46
+ export declare function nonRecursiveVisitBlocksInFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => Promise<void>): Promise<void>;
47
47
  /**
48
48
  * Transform blocks in a field value by applying a mapping function to each block.
49
49
  * Creates a new field value structure with transformed blocks while preserving the original structure.
@@ -54,7 +54,7 @@ export declare function nonRecursiveVisitBlocksInFieldValueAsync(field: SchemaTy
54
54
  * @param mapper - Synchronous function that transforms each block. Receives block item and path, returns new block
55
55
  * @returns The new field value with transformed blocks
56
56
  */
57
- export declare function nonRecursiveMapBlocksInFieldValue(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => BlockItemInARequest): unknown;
57
+ export declare function nonRecursiveMapBlocksInFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => BlockItemInARequest): unknown;
58
58
  /**
59
59
  * Transform blocks in a field value by applying a mapping function to each block.
60
60
  * Creates a new field value structure with transformed blocks while preserving the original structure.
@@ -65,7 +65,7 @@ export declare function nonRecursiveMapBlocksInFieldValue(field: SchemaTypes.Fie
65
65
  * @param mapper - Asynchronous function that transforms each block. Receives block item and path, returns new block
66
66
  * @returns Promise that resolves to the new field value with transformed blocks
67
67
  */
68
- export declare function nonRecursiveMapBlocksInFieldValueAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => Promise<BlockItemInARequest>): Promise<unknown>;
68
+ export declare function nonRecursiveMapBlocksInFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => Promise<BlockItemInARequest>): Promise<unknown>;
69
69
  /**
70
70
  * Find all blocks that match the predicate function.
71
71
  * Searches through all blocks in the field value and returns all matches.
@@ -75,7 +75,7 @@ export declare function nonRecursiveMapBlocksInFieldValueAsync(field: SchemaType
75
75
  * @param predicate - Synchronous function that tests each block. Should return true for matching blocks
76
76
  * @returns Array of objects, each containing a matching block and its path
77
77
  */
78
- export declare function nonRecursiveFindAllBlocksInFieldValue(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): Array<{
78
+ export declare function nonRecursiveFindAllBlocksInFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): Array<{
79
79
  item: BlockItemInARequest;
80
80
  path: TreePath;
81
81
  }>;
@@ -88,7 +88,7 @@ export declare function nonRecursiveFindAllBlocksInFieldValue(field: SchemaTypes
88
88
  * @param predicate - Asynchronous function that tests each block. Should return true for matching blocks
89
89
  * @returns Promise that resolves to an array of objects, each containing a matching block and its path
90
90
  */
91
- export declare function nonRecursiveFindAllBlocksInFieldValueAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<Array<{
91
+ export declare function nonRecursiveFindAllBlocksInFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<Array<{
92
92
  item: BlockItemInARequest;
93
93
  path: TreePath;
94
94
  }>>;
@@ -102,7 +102,7 @@ export declare function nonRecursiveFindAllBlocksInFieldValueAsync(field: Schema
102
102
  * @param predicate - Synchronous function that tests each block. Blocks returning false are removed
103
103
  * @returns The new field value with filtered blocks
104
104
  */
105
- export declare function nonRecursiveFilterBlocksInFieldValue(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): unknown;
105
+ export declare function nonRecursiveFilterBlocksInFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): unknown;
106
106
  /**
107
107
  * Filter blocks in a field value, removing those that don't match the predicate.
108
108
  * Creates a new field value containing only blocks that pass the predicate test.
@@ -113,7 +113,7 @@ export declare function nonRecursiveFilterBlocksInFieldValue(field: SchemaTypes.
113
113
  * @param predicate - Asynchronous function that tests each block. Blocks returning false are removed
114
114
  * @returns Promise that resolves to the new field value with filtered blocks
115
115
  */
116
- export declare function nonRecursiveFilterBlocksInFieldValueAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<unknown>;
116
+ export declare function nonRecursiveFilterBlocksInFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<unknown>;
117
117
  /**
118
118
  * Reduce all blocks in a field value to a single value by applying a reducer function.
119
119
  * Processes each block in the field value and accumulates the results into a single value.
@@ -125,7 +125,7 @@ export declare function nonRecursiveFilterBlocksInFieldValueAsync(field: SchemaT
125
125
  * @param initialValue - The initial value for the accumulator
126
126
  * @returns The final accumulated value
127
127
  */
128
- export declare function nonRecursiveReduceBlocksInFieldValue<R>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => R, initialValue: R): R;
128
+ export declare function nonRecursiveReduceBlocksInFieldValue<R>(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => R, initialValue: R): R;
129
129
  /**
130
130
  * Reduce all blocks in a field value to a single value by applying a reducer function.
131
131
  * Processes each block in the field value and accumulates the results into a single value.
@@ -137,7 +137,7 @@ export declare function nonRecursiveReduceBlocksInFieldValue<R>(field: SchemaTyp
137
137
  * @param initialValue - The initial value for the accumulator
138
138
  * @returns Promise that resolves to the final accumulated value
139
139
  */
140
- export declare function nonRecursiveReduceBlocksInFieldValueAsync<R>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => Promise<R>, initialValue: R): Promise<R>;
140
+ export declare function nonRecursiveReduceBlocksInFieldValueAsync<R>(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => Promise<R>, initialValue: R): Promise<R>;
141
141
  /**
142
142
  * Check if any block in the field value matches the predicate function.
143
143
  * Returns true as soon as the first matching block is found (short-circuit evaluation).
@@ -147,7 +147,7 @@ export declare function nonRecursiveReduceBlocksInFieldValueAsync<R>(field: Sche
147
147
  * @param predicate - Synchronous function that tests each block. Should return true for matching blocks
148
148
  * @returns True if any block matches, false otherwise
149
149
  */
150
- export declare function nonRecursiveSomeBlocksInFieldValue(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): boolean;
150
+ export declare function nonRecursiveSomeBlocksInFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): boolean;
151
151
  /**
152
152
  * Check if any block in the field value matches the predicate function.
153
153
  * Returns true as soon as the first matching block is found (short-circuit evaluation).
@@ -157,7 +157,7 @@ export declare function nonRecursiveSomeBlocksInFieldValue(field: SchemaTypes.Fi
157
157
  * @param predicate - Asynchronous function that tests each block. Should return true for matching blocks
158
158
  * @returns Promise that resolves to true if any block matches, false otherwise
159
159
  */
160
- export declare function nonRecursiveSomeBlocksInFieldValueAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
160
+ export declare function nonRecursiveSomeBlocksInFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
161
161
  /**
162
162
  * Check if every block in the field value matches the predicate function.
163
163
  * Returns false as soon as the first non-matching block is found (short-circuit evaluation).
@@ -167,7 +167,7 @@ export declare function nonRecursiveSomeBlocksInFieldValueAsync(field: SchemaTyp
167
167
  * @param predicate - Synchronous function that tests each block. Should return true for valid blocks
168
168
  * @returns True if all blocks match, false otherwise
169
169
  */
170
- export declare function nonRecursiveEveryBlockInFieldValue(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): boolean;
170
+ export declare function nonRecursiveEveryBlockInFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean): boolean;
171
171
  /**
172
172
  * Check if every block in the field value matches the predicate function.
173
173
  * Returns false as soon as the first non-matching block is found (short-circuit evaluation).
@@ -177,4 +177,4 @@ export declare function nonRecursiveEveryBlockInFieldValue(field: SchemaTypes.Fi
177
177
  * @param predicate - Asynchronous function that tests each block. Should return true for valid blocks
178
178
  * @returns Promise that resolves to true if all blocks match, false otherwise
179
179
  */
180
- export declare function nonRecursiveEveryBlockInFieldValueAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
180
+ export declare function nonRecursiveEveryBlockInFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => Promise<boolean>): Promise<boolean>;
@@ -1,6 +1,6 @@
1
- import type * as SchemaTypes from '../generated/SchemaTypes';
2
- import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
3
- export declare function buildBlockRecord(body: SimpleSchemaTypes.ItemUpdateSchema): {
1
+ import type * as ApiTypes from '../generated/ApiTypes';
2
+ import type * as RawApiTypes from '../generated/RawApiTypes';
3
+ export declare function buildBlockRecord(body: ApiTypes.ItemUpdateSchema): {
4
4
  type: "item";
5
5
  id: string;
6
6
  attributes?: {
@@ -23,10 +23,10 @@ export declare function buildBlockRecord(body: SimpleSchemaTypes.ItemUpdateSchem
23
23
  } | undefined;
24
24
  relationships?: {
25
25
  item_type?: {
26
- data: SchemaTypes.ItemTypeData;
26
+ data: RawApiTypes.ItemTypeData;
27
27
  } | undefined;
28
28
  creator?: {
29
- data: SchemaTypes.UserData | SchemaTypes.SsoUserData | SchemaTypes.AccessTokenData | SchemaTypes.AccountData | SchemaTypes.OrganizationData;
29
+ data: RawApiTypes.UserData | RawApiTypes.SsoUserData | RawApiTypes.AccessTokenData | RawApiTypes.AccountData | RawApiTypes.OrganizationData;
30
30
  } | undefined;
31
31
  } | undefined;
32
32
  };
@@ -0,0 +1,166 @@
1
+ import type * as ApiTypes from '../generated/ApiTypes';
2
+ import type * as RawApiTypes from '../generated/RawApiTypes';
3
+ /**
4
+ * Represents a localized field value in DatoCMS.
5
+ *
6
+ * In DatoCMS, fields can be localized. In this scenario, their value contains values
7
+ * for various locales structured as an object, such as
8
+ * `{ "en": "Hello", "it": "Ciao" }`
9
+ */
10
+ export type LocalizedFieldValue = Record<string, unknown>;
11
+ /**
12
+ * Determines whether a DatoCMS field is localized or not.
13
+ *
14
+ * This function handles both full Schema field objects and simplified Schema field objects
15
+ * by checking the appropriate property based on the object structure.
16
+ *
17
+ * @param field - The DatoCMS field definition (either full or simple schema)
18
+ * @returns true if the field is localized, false otherwise
19
+ */
20
+ export declare function isLocalized(field: RawApiTypes.Field | ApiTypes.Field): boolean;
21
+ /**
22
+ * A normalized entry that represents a single value from either a localized or non-localized field.
23
+ *
24
+ * For localized fields, each locale produces one entry with `locale` set to the locale code (e.g., "en", "it").
25
+ * For non-localized fields, there's one entry with `locale` set to `undefined`.
26
+ *
27
+ * This uniform structure allows the same processing logic to work with both field types.
28
+ */
29
+ export type FieldValueEntry = {
30
+ locale: string | undefined;
31
+ value: unknown;
32
+ };
33
+ export type PossiblyLocalizedEntry = FieldValueEntry;
34
+ /**
35
+ * Converts a field value (localized or non-localized) into a uniform array of entries.
36
+ *
37
+ * This function normalizes the handling of field values by converting them into a consistent
38
+ * array format, regardless of whether the field is localized or not.
39
+ *
40
+ * @param field - The DatoCMS field definition that determines localization behavior
41
+ * @param value - The field value to convert (either a localized object or direct value)
42
+ * @returns Array of entries where each entry contains a locale (string for localized, undefined for non-localized) and the corresponding value
43
+ */
44
+ export declare function fieldValueToEntries(field: RawApiTypes.Field | ApiTypes.Field, value: unknown): FieldValueEntry[];
45
+ /**
46
+ * Converts an array of possibly localized entries back into the appropriate field value format.
47
+ *
48
+ * This function is the inverse of `fieldValueToPossiblyLocalizedEntries`. It takes a uniform
49
+ * array of entries and converts them back to either a localized object or a direct value,
50
+ * depending on the field's localization setting.
51
+ *
52
+ * @param field - The DatoCMS field definition that determines the output format
53
+ * @param possiblyLocalizedEntries - Array of entries to convert back to field value format
54
+ * @returns Either a localized object (for localized fields) or the direct value (for non-localized fields)
55
+ */
56
+ export declare function entriesToFieldValue(field: RawApiTypes.Field | ApiTypes.Field, possiblyLocalizedEntries: FieldValueEntry[]): any;
57
+ /**
58
+ * Maps field values using a provided mapping function.
59
+ * For localized fields, applies the mapping function to each locale value.
60
+ * For non-localized fields, applies the mapping function directly to the value.
61
+ *
62
+ * @template T - The type that the mapping function returns
63
+ * @param field - The DatoCMS field definition
64
+ * @param value - The field value (either localized object or direct value)
65
+ * @param mapFn - The function to apply to each locale value or the direct value
66
+ * @returns The mapped value with the same structure as the input
67
+ */
68
+ export declare function mapFieldValue<T>(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => T): any;
69
+ /**
70
+ * Maps field values using a provided mapping function (async version).
71
+ * For localized fields, applies the mapping function to each locale value.
72
+ * For non-localized fields, applies the mapping function directly to the value.
73
+ *
74
+ * @template T - The type that the mapping function returns
75
+ * @param field - The DatoCMS field definition
76
+ * @param value - The field value (either localized object or direct value)
77
+ * @param mapFn - The function to apply to each locale value or the direct value
78
+ * @returns The mapped value with the same structure as the input
79
+ */
80
+ export declare function mapFieldValueAsync<T>(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => Promise<T>): Promise<any>;
81
+ /**
82
+ * Filters field values using a provided filter function.
83
+ * For localized fields, filters each locale value.
84
+ * For non-localized fields, returns the value if the filter passes, otherwise undefined.
85
+ *
86
+ * @param field - The DatoCMS field definition
87
+ * @param value - The field value (either localized object or direct value)
88
+ * @param filterFn - The function to test each locale value or the direct value
89
+ * @returns The filtered value with the same structure as the input
90
+ */
91
+ export declare function filterFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => boolean): any;
92
+ /**
93
+ * Filters field values using a provided filter function (async version).
94
+ * For localized fields, filters each locale value.
95
+ * For non-localized fields, returns the value if the filter passes, otherwise undefined.
96
+ *
97
+ * @param field - The DatoCMS field definition
98
+ * @param value - The field value (either localized object or direct value)
99
+ * @param filterFn - The function to test each locale value or the direct value
100
+ * @returns The filtered value with the same structure as the input
101
+ */
102
+ export declare function filterFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<any>;
103
+ /**
104
+ * Tests whether at least one field value passes the test implemented by the provided function.
105
+ * For localized fields, tests each locale value.
106
+ * For non-localized fields, tests the direct value.
107
+ *
108
+ * @param field - The DatoCMS field definition
109
+ * @param value - The field value (either localized object or direct value)
110
+ * @param testFn - The function to test each locale value or the direct value
111
+ * @returns true if at least one value passes the test, false otherwise
112
+ */
113
+ export declare function someFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => boolean): boolean;
114
+ /**
115
+ * Tests whether at least one field value passes the test implemented by the provided function (async version).
116
+ * For localized fields, tests each locale value.
117
+ * For non-localized fields, tests the direct value.
118
+ *
119
+ * @param field - The DatoCMS field definition
120
+ * @param value - The field value (either localized object or direct value)
121
+ * @param testFn - The function to test each locale value or the direct value
122
+ * @returns true if at least one value passes the test, false otherwise
123
+ */
124
+ export declare function someFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<boolean>;
125
+ /**
126
+ * Tests whether all field values pass the test implemented by the provided function.
127
+ * For localized fields, tests each locale value.
128
+ * For non-localized fields, tests the direct value.
129
+ *
130
+ * @param field - The DatoCMS field definition
131
+ * @param value - The field value (either localized object or direct value)
132
+ * @param testFn - The function to test each locale value or the direct value
133
+ * @returns true if all values pass the test, false otherwise
134
+ */
135
+ export declare function everyFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => boolean): boolean;
136
+ /**
137
+ * Tests whether all field values pass the test implemented by the provided function (async version).
138
+ * For localized fields, tests each locale value.
139
+ * For non-localized fields, tests the direct value.
140
+ *
141
+ * @param field - The DatoCMS field definition
142
+ * @param value - The field value (either localized object or direct value)
143
+ * @param testFn - The function to test each locale value or the direct value
144
+ * @returns true if all values pass the test, false otherwise
145
+ */
146
+ export declare function everyFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<boolean>;
147
+ /**
148
+ * Visits each field value with the provided function.
149
+ * For localized fields, visits each locale value.
150
+ * For non-localized fields, visits the direct value.
151
+ *
152
+ * @param field - The DatoCMS field definition
153
+ * @param value - The field value (either localized object or direct value)
154
+ * @param visitFn - The function to call for each locale value or the direct value
155
+ */
156
+ export declare function visitFieldValue(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, visitFn: (locale: string | undefined, localeValue: unknown) => void): void;
157
+ /**
158
+ * Visits each field value with the provided function (async version).
159
+ * For localized fields, visits each locale value.
160
+ * For non-localized fields, visits the direct value.
161
+ *
162
+ * @param field - The DatoCMS field definition
163
+ * @param value - The field value (either localized object or direct value)
164
+ * @param visitFn - The function to call for each locale value or the direct value
165
+ */
166
+ export declare function visitFieldValueAsync(field: RawApiTypes.Field | ApiTypes.Field, value: unknown, visitFn: (locale: string | undefined, localeValue: unknown) => Promise<void>): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type * as SchemaTypes from '../generated/SchemaTypes';
2
- import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
3
- export declare function modelIdsReferencedInField(field: SchemaTypes.Field | SimpleSchemaTypes.Field): string[];
4
- export declare function blockModelIdsReferencedInField(field: SchemaTypes.Field | SimpleSchemaTypes.Field): string[];
1
+ import type * as ApiTypes from '../generated/ApiTypes';
2
+ import type * as RawApiTypes from '../generated/RawApiTypes';
3
+ export declare function modelIdsReferencedInField(field: RawApiTypes.Field | ApiTypes.Field): string[];
4
+ export declare function blockModelIdsReferencedInField(field: RawApiTypes.Field | ApiTypes.Field): string[];
@@ -1,15 +1,18 @@
1
1
  import { type BlockItemInARequest } from '../fieldTypes';
2
- import type * as SchemaTypes from '../generated/SchemaTypes';
3
- import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
2
+ import type * as ApiTypes from '../generated/ApiTypes';
3
+ import type * as RawApiTypes from '../generated/RawApiTypes';
4
4
  import type { SchemaRepository } from './schemaRepository';
5
- import type { TreePath } from './structuredText';
6
- export declare function visitBlocksInFieldValues(schemaRepository: SchemaRepository, field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => void | Promise<void>, path?: TreePath): Promise<void>;
7
- export declare function findAllBlocksInFieldValues(schemaRepository: SchemaRepository, field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<Array<{
5
+ /**
6
+ * Path through a field value (ie. ['content', 0, 'attributes', 'title'])
7
+ */
8
+ export type TreePath = readonly (string | number)[];
9
+ export declare function visitBlocksInFieldValues(schemaRepository: SchemaRepository, field: RawApiTypes.Field | ApiTypes.Field, value: unknown, visitor: (item: BlockItemInARequest, path: TreePath) => void | Promise<void>, path?: TreePath): Promise<void>;
10
+ export declare function findAllBlocksInFieldValues(schemaRepository: SchemaRepository, field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<Array<{
8
11
  item: BlockItemInARequest;
9
12
  path: TreePath;
10
13
  }>>;
11
- export declare function filterBlocksInFieldValues(schemaRepository: SchemaRepository, field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<unknown>;
12
- export declare function reduceBlocksInFieldValues<R>(schemaRepository: SchemaRepository, field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => R | Promise<R>, initialValue: R, path?: TreePath): Promise<R>;
13
- export declare function someBlocksInFieldValues(schemaRepository: SchemaRepository, field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
14
- export declare function everyBlockInFieldValues(schemaRepository: SchemaRepository, field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
15
- export declare function mapBlocksInFieldValues(schemaRepository: SchemaRepository, field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => BlockItemInARequest | Promise<BlockItemInARequest>, path?: TreePath): Promise<unknown>;
14
+ export declare function filterBlocksInFieldValues(schemaRepository: SchemaRepository, field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<unknown>;
15
+ export declare function reduceBlocksInFieldValues<R>(schemaRepository: SchemaRepository, field: RawApiTypes.Field | ApiTypes.Field, value: unknown, reducer: (accumulator: R, item: BlockItemInARequest, path: TreePath) => R | Promise<R>, initialValue: R, path?: TreePath): Promise<R>;
16
+ export declare function someBlocksInFieldValues(schemaRepository: SchemaRepository, field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
17
+ export declare function everyBlockInFieldValues(schemaRepository: SchemaRepository, field: RawApiTypes.Field | ApiTypes.Field, value: unknown, predicate: (item: BlockItemInARequest, path: TreePath) => boolean | Promise<boolean>, path?: TreePath): Promise<boolean>;
18
+ export declare function mapBlocksInFieldValues(schemaRepository: SchemaRepository, field: RawApiTypes.Field | ApiTypes.Field, value: unknown, mapper: (item: BlockItemInARequest, path: TreePath) => BlockItemInARequest | Promise<BlockItemInARequest>, path?: TreePath): Promise<unknown>;
@@ -1,24 +1,27 @@
1
- import type * as SchemaTypes from '../generated/SchemaTypes';
2
- import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
1
+ import type * as ApiTypes from '../generated/ApiTypes';
2
+ import type * as RawApiTypes from '../generated/RawApiTypes';
3
3
  interface GenericClient {
4
4
  itemTypes: {
5
5
  rawList(): Promise<{
6
- data: SchemaTypes.ItemType[];
6
+ data: RawApiTypes.ItemType[];
7
7
  }>;
8
8
  };
9
9
  fields: {
10
10
  rawList(itemTypeId: string): Promise<{
11
- data: SchemaTypes.Field[];
11
+ data: RawApiTypes.Field[];
12
+ }>;
13
+ rawReferencing(itemTypeId: string): Promise<{
14
+ data: RawApiTypes.Field[];
12
15
  }>;
13
16
  };
14
17
  fieldsets: {
15
18
  rawList(itemTypeId: string): Promise<{
16
- data: SchemaTypes.Fieldset[];
19
+ data: RawApiTypes.Fieldset[];
17
20
  }>;
18
21
  };
19
22
  plugins: {
20
23
  rawList(): Promise<{
21
- data: SchemaTypes.Plugin[];
24
+ data: RawApiTypes.Plugin[];
22
25
  }>;
23
26
  };
24
27
  }
@@ -51,88 +54,88 @@ export declare class SchemaRepository {
51
54
  * Gets all item types from the DatoCMS project.
52
55
  * @returns Promise that resolves to an array of all item types
53
56
  */
54
- getAllItemTypes(): Promise<SimpleSchemaTypes.ItemType[]>;
57
+ getAllItemTypes(): Promise<ApiTypes.ItemType[]>;
55
58
  /**
56
59
  * Gets all item types from the DatoCMS project.
57
60
  * @returns Promise that resolves to an array of all item types
58
61
  */
59
- getAllRawItemTypes(): Promise<SchemaTypes.ItemType[]>;
62
+ getAllRawItemTypes(): Promise<RawApiTypes.ItemType[]>;
60
63
  /**
61
64
  * Gets all item types that are models (not modular blocks).
62
65
  * @returns Promise that resolves to an array of model item types
63
66
  */
64
- getAllModels(): Promise<SimpleSchemaTypes.ItemType[]>;
67
+ getAllModels(): Promise<ApiTypes.ItemType[]>;
65
68
  /**
66
69
  * Gets all item types that are models (not modular blocks).
67
70
  * @returns Promise that resolves to an array of model item types
68
71
  */
69
- getAllRawModels(): Promise<SchemaTypes.ItemType[]>;
72
+ getAllRawModels(): Promise<RawApiTypes.ItemType[]>;
70
73
  /**
71
74
  * Gets all item types that are modular blocks.
72
75
  * @returns Promise that resolves to an array of block model item types
73
76
  */
74
- getAllBlockModels(): Promise<SimpleSchemaTypes.ItemType[]>;
77
+ getAllBlockModels(): Promise<ApiTypes.ItemType[]>;
75
78
  /**
76
79
  * Gets all item types that are modular blocks.
77
80
  * @returns Promise that resolves to an array of block model item types
78
81
  */
79
- getAllRawBlockModels(): Promise<SchemaTypes.ItemType[]>;
82
+ getAllRawBlockModels(): Promise<RawApiTypes.ItemType[]>;
80
83
  /**
81
84
  * Gets an item type by its API key.
82
85
  * @param apiKey - The API key of the item type to retrieve
83
86
  * @returns Promise that resolves to the item type
84
87
  * @throws Error if the item type is not found
85
88
  */
86
- getItemTypeByApiKey(apiKey: string): Promise<SimpleSchemaTypes.ItemType>;
89
+ getItemTypeByApiKey(apiKey: string): Promise<ApiTypes.ItemType>;
87
90
  /**
88
91
  * Gets an item type by its API key.
89
92
  * @param apiKey - The API key of the item type to retrieve
90
93
  * @returns Promise that resolves to the item type
91
94
  * @throws Error if the item type is not found
92
95
  */
93
- getRawItemTypeByApiKey(apiKey: string): Promise<SchemaTypes.ItemType>;
96
+ getRawItemTypeByApiKey(apiKey: string): Promise<RawApiTypes.ItemType>;
94
97
  /**
95
98
  * Gets an item type by its ID.
96
99
  * @param id - The ID of the item type to retrieve
97
100
  * @returns Promise that resolves to the item type
98
101
  * @throws Error if the item type is not found
99
102
  */
100
- getItemTypeById(id: string): Promise<SimpleSchemaTypes.ItemType>;
103
+ getItemTypeById(id: string): Promise<ApiTypes.ItemType>;
101
104
  /**
102
105
  * Gets an item type by its ID.
103
106
  * @param id - The ID of the item type to retrieve
104
107
  * @returns Promise that resolves to the item type
105
108
  * @throws Error if the item type is not found
106
109
  */
107
- getRawItemTypeById(id: string): Promise<SchemaTypes.ItemType>;
110
+ getRawItemTypeById(id: string): Promise<RawApiTypes.ItemType>;
108
111
  /**
109
112
  * Gets all fields for a given item type.
110
113
  * Fields are cached after the first request for performance.
111
114
  * @param itemType - The item type to get fields for
112
115
  * @returns Promise that resolves to an array of fields
113
116
  */
114
- getItemTypeFields(itemType: SimpleSchemaTypes.ItemType | SchemaTypes.ItemType): Promise<SimpleSchemaTypes.Field[]>;
117
+ getItemTypeFields(itemType: ApiTypes.ItemType | RawApiTypes.ItemType): Promise<ApiTypes.Field[]>;
115
118
  /**
116
119
  * Gets all fields for a given item type.
117
120
  * Fields are cached after the first request for performance.
118
121
  * @param itemType - The item type to get fields for
119
122
  * @returns Promise that resolves to an array of fields
120
123
  */
121
- getRawItemTypeFields(itemType: SchemaTypes.ItemType): Promise<SchemaTypes.Field[]>;
124
+ getRawItemTypeFields(itemType: RawApiTypes.ItemType): Promise<RawApiTypes.Field[]>;
122
125
  /**
123
126
  * Gets all fieldsets for a given item type.
124
127
  * Fieldsets are cached after the first request for performance.
125
128
  * @param itemType - The item type to get fieldsets for
126
129
  * @returns Promise that resolves to an array of fieldsets
127
130
  */
128
- getItemTypeFieldsets(itemType: SimpleSchemaTypes.ItemType | SchemaTypes.ItemType): Promise<SimpleSchemaTypes.Fieldset[]>;
131
+ getItemTypeFieldsets(itemType: ApiTypes.ItemType | RawApiTypes.ItemType): Promise<ApiTypes.Fieldset[]>;
129
132
  /**
130
133
  * Gets all fieldsets for a given item type.
131
134
  * Fieldsets are cached after the first request for performance.
132
135
  * @param itemType - The item type to get fieldsets for
133
136
  * @returns Promise that resolves to an array of fieldsets
134
137
  */
135
- getRawItemTypeFieldsets(itemType: SchemaTypes.ItemType): Promise<SchemaTypes.Fieldset[]>;
138
+ getRawItemTypeFieldsets(itemType: RawApiTypes.ItemType): Promise<RawApiTypes.Fieldset[]>;
136
139
  /**
137
140
  * Loads and caches all plugins from the DatoCMS API.
138
141
  * This method is called lazily and caches the result for subsequent calls.
@@ -143,39 +146,39 @@ export declare class SchemaRepository {
143
146
  * Gets all plugins from the DatoCMS project.
144
147
  * @returns Promise that resolves to an array of all plugins
145
148
  */
146
- getAllPlugins(): Promise<SimpleSchemaTypes.Plugin[]>;
149
+ getAllPlugins(): Promise<ApiTypes.Plugin[]>;
147
150
  /**
148
151
  * Gets all plugins from the DatoCMS project.
149
152
  * @returns Promise that resolves to an array of all plugins
150
153
  */
151
- getAllRawPlugins(): Promise<SchemaTypes.Plugin[]>;
154
+ getAllRawPlugins(): Promise<RawApiTypes.Plugin[]>;
152
155
  /**
153
156
  * Gets a plugin by its ID.
154
157
  * @param id - The ID of the plugin to retrieve
155
158
  * @returns Promise that resolves to the plugin
156
159
  * @throws Error if the plugin is not found
157
160
  */
158
- getPluginById(id: string): Promise<SimpleSchemaTypes.Plugin>;
161
+ getPluginById(id: string): Promise<ApiTypes.Plugin>;
159
162
  /**
160
163
  * Gets a plugin by its ID.
161
164
  * @param id - The ID of the plugin to retrieve
162
165
  * @returns Promise that resolves to the plugin
163
166
  * @throws Error if the plugin is not found
164
167
  */
165
- getRawPluginById(id: string): Promise<SchemaTypes.Plugin>;
168
+ getRawPluginById(id: string): Promise<RawApiTypes.Plugin>;
166
169
  /**
167
170
  * Gets a plugin by its package name.
168
171
  * @param packageName - The package name of the plugin to retrieve
169
172
  * @returns Promise that resolves to the plugin
170
173
  * @throws Error if the plugin is not found
171
174
  */
172
- getPluginByPackageName(packageName: string): Promise<SimpleSchemaTypes.Plugin>;
175
+ getPluginByPackageName(packageName: string): Promise<ApiTypes.Plugin>;
173
176
  /**
174
177
  * Gets a plugin by its package name.
175
178
  * @param packageName - The package name of the plugin to retrieve
176
179
  * @returns Promise that resolves to the plugin
177
180
  * @throws Error if the plugin is not found
178
181
  */
179
- getRawPluginByPackageName(packageName: string): Promise<SchemaTypes.Plugin>;
182
+ getRawPluginByPackageName(packageName: string): Promise<RawApiTypes.Plugin>;
180
183
  }
181
184
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datocms/cma-client",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
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.0",
41
- "datocms-structured-text-utils": "^5.0.0",
40
+ "@datocms/rest-client-utils": "^5.1.2",
41
+ "datocms-structured-text-utils": "^5.1.0",
42
42
  "uuid": "^9.0.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@datocms/dashboard-client": "^5.1.0",
45
+ "@datocms/dashboard-client": "^5.1.2",
46
46
  "@types/uuid": "^9.0.7"
47
47
  },
48
- "gitHead": "ccc646f22202e951675e695fd4e5be2cfde4e9a5"
48
+ "gitHead": "f4f7e2dcb5508f3d4680d242a9805c826706b855"
49
49
  }