@datocms/cma-client 5.1.1 → 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 (325) hide show
  1. package/dist/cjs/fieldTypes/rich_text.js +4 -4
  2. package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
  3. package/dist/cjs/fieldTypes/single_block.js +19 -17
  4. package/dist/cjs/fieldTypes/single_block.js.map +1 -1
  5. package/dist/cjs/fieldTypes/structured_text.js +9 -21
  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/{fieldValueLocalization.js → fieldValue.js} +52 -52
  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 +6 -6
  68. package/dist/esm/fieldTypes/rich_text.js +5 -5
  69. package/dist/esm/fieldTypes/rich_text.js.map +1 -1
  70. package/dist/esm/fieldTypes/single_block.d.ts +29 -23
  71. package/dist/esm/fieldTypes/single_block.js +15 -13
  72. package/dist/esm/fieldTypes/single_block.js.map +1 -1
  73. package/dist/esm/fieldTypes/structured_text.d.ts +18 -83
  74. package/dist/esm/fieldTypes/structured_text.js +10 -22
  75. package/dist/esm/fieldTypes/structured_text.js.map +1 -1
  76. package/dist/esm/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +2 -2
  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} +2 -2
  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/{types/utilities/fieldValueLocalization.d.ts → esm/utilities/fieldValue.d.ts} +29 -28
  183. package/dist/esm/utilities/{fieldValueLocalization.js → fieldValue.js} +39 -39
  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 +6 -6
  193. package/dist/types/fieldTypes/single_block.d.ts +29 -23
  194. package/dist/types/fieldTypes/structured_text.d.ts +18 -83
  195. package/dist/types/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +2 -2
  196. package/dist/types/generated/Client.d.ts +1 -1
  197. package/dist/types/generated/{SchemaTypes.d.ts → RawApiTypes.d.ts} +2 -2
  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/{esm/utilities/fieldValueLocalization.d.ts → types/utilities/fieldValue.d.ts} +29 -28
  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 +12 -12
  253. package/src/fieldTypes/single_block.ts +46 -31
  254. package/src/fieldTypes/structured_text.ts +33 -149
  255. package/src/generated/{SimpleSchemaTypes.ts → ApiTypes.ts} +2 -2
  256. package/src/generated/Client.ts +2 -2
  257. package/src/generated/{SchemaTypes.ts → RawApiTypes.ts} +2 -2
  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 +30 -30
  306. package/src/utilities/buildBlockRecord.ts +4 -4
  307. package/src/utilities/{fieldValueLocalization.ts → fieldValue.ts} +58 -73
  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.map +0 -1
  314. package/dist/cjs/utilities/structuredText.js +0 -371
  315. package/dist/cjs/utilities/structuredText.js.map +0 -1
  316. package/dist/esm/generated/SchemaTypes.js +0 -2
  317. package/dist/esm/generated/SchemaTypes.js.map +0 -1
  318. package/dist/esm/generated/SimpleSchemaTypes.js +0 -2
  319. package/dist/esm/generated/SimpleSchemaTypes.js.map +0 -1
  320. package/dist/esm/utilities/fieldValueLocalization.js.map +0 -1
  321. package/dist/esm/utilities/structuredText.d.ts +0 -177
  322. package/dist/esm/utilities/structuredText.js +0 -354
  323. package/dist/esm/utilities/structuredText.js.map +0 -1
  324. package/dist/types/utilities/structuredText.d.ts +0 -177
  325. package/src/utilities/structuredText.ts +0 -590
@@ -1,354 +0,0 @@
1
- /**
2
- * Tree manipulation utilities for DatoCMS structured text documents.
3
- *
4
- * Provides a set of low-level utilities for visiting, transforming, and querying
5
- * structured text trees. Works with all tree variants (regular, request, nested).
6
- */
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- /**
17
- * Check if a value has children property that is an array
18
- */
19
- function hasChildren(node) {
20
- return (typeof node === 'object' &&
21
- node !== null &&
22
- 'children' in node &&
23
- Array.isArray(node.children));
24
- }
25
- /**
26
- * Visit every node in the Structured Text tree, calling the visitor function for each.
27
- * Uses pre-order traversal (parent is visited before its children).
28
- *
29
- * @template T - The type of the root node in the Structured Text tree
30
- * @param node - The root node to start visiting from
31
- * @param visitor - Synchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
32
- */
33
- export function forEachNode(node, visitor, parent = null, path = []) {
34
- // Visit current node
35
- visitor(node, parent, path);
36
- // Recursively visit children
37
- if (hasChildren(node)) {
38
- for (let index = 0; index < node.children.length; index++) {
39
- const child = node.children[index];
40
- forEachNode(child, visitor, node, [
41
- ...path,
42
- 'children',
43
- index,
44
- ]);
45
- }
46
- }
47
- }
48
- /**
49
- * Visit every node in the Structured Text tree, calling the visitor function for each.
50
- * Uses pre-order traversal (parent is visited before its children).
51
- *
52
- * @template T - The type of the root node in the Structured Text tree
53
- * @param node - The root node to start visiting from
54
- * @param visitor - Asynchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
55
- * @returns Promise that resolves when all nodes have been visited
56
- */
57
- export function forEachNodeAsync(node, visitor, parent = null, path = []) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- // Visit current node
60
- yield visitor(node, parent, path);
61
- // Recursively visit children
62
- if (hasChildren(node)) {
63
- for (let index = 0; index < node.children.length; index++) {
64
- const child = node.children[index];
65
- yield forEachNodeAsync(child, visitor, node, [
66
- ...path,
67
- 'children',
68
- index,
69
- ]);
70
- }
71
- }
72
- });
73
- }
74
- /**
75
- * Transform nodes in the Structured Text tree by applying a mapping function.
76
- * Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
77
- *
78
- * @template T - The type of nodes in the input Structured Text tree
79
- * @template R - The type of nodes in the output tree
80
- * @param node - The root node to start mapping from
81
- * @param mapper - Synchronous function that transforms each node. Receives the node, its parent, and path
82
- * @returns The transformed tree
83
- */
84
- export function mapNodes(node, mapper, parent = null, path = []) {
85
- // Transform current node
86
- const transformedNode = mapper(node, parent, path);
87
- // If the original node has children, recursively transform them
88
- if (hasChildren(node) &&
89
- typeof transformedNode === 'object' &&
90
- transformedNode !== null) {
91
- const transformedChildren = node.children.map((child, index) => mapNodes(child, mapper, node, [
92
- ...path,
93
- 'children',
94
- index,
95
- ]));
96
- return Object.assign(Object.assign({}, transformedNode), { children: transformedChildren });
97
- }
98
- return transformedNode;
99
- }
100
- /**
101
- * Transform nodes in the Structured Text tree by applying a mapping function.
102
- * Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
103
- *
104
- * @template T - The type of nodes in the input Structured Text tree
105
- * @template R - The type of nodes in the output tree
106
- * @param node - The root node to start mapping from
107
- * @param mapper - Asynchronous function that transforms each node. Receives the node, its parent, and path
108
- * @returns Promise that resolves to the transformed tree
109
- */
110
- export function mapNodesAsync(node, mapper, parent = null, path = []) {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- // Transform current node
113
- const transformedNode = yield mapper(node, parent, path);
114
- // If the original node has children, recursively transform them
115
- if (hasChildren(node) &&
116
- typeof transformedNode === 'object' &&
117
- transformedNode !== null) {
118
- const transformedChildren = yield Promise.all(node.children.map((child, index) => mapNodesAsync(child, mapper, node, [
119
- ...path,
120
- 'children',
121
- index,
122
- ])));
123
- return Object.assign(Object.assign({}, transformedNode), { children: transformedChildren });
124
- }
125
- return transformedNode;
126
- });
127
- }
128
- /**
129
- * Find all nodes that match the predicate function using depth-first search.
130
- * Returns an array containing all matching nodes along with their paths through the Structured Text tree.
131
- *
132
- * @template T - The type of nodes in the Structured Text tree
133
- * @param node - The root node to start searching from
134
- * @param predicate - Synchronous function that tests each node. Should return true for desired nodes
135
- * @returns Array of objects, each containing a matching node and its path
136
- */
137
- export function findAllNodes(node, predicate, parent = null, path = []) {
138
- const results = [];
139
- forEachNode(node, (currentNode, currentParent, currentPath) => {
140
- if (predicate(currentNode, currentParent, currentPath)) {
141
- results.push({ node: currentNode, path: currentPath });
142
- }
143
- }, parent, path);
144
- return results;
145
- }
146
- /**
147
- * Find all nodes that match the predicate function using depth-first search.
148
- * Returns an array containing all matching nodes along with their paths through the Structured Text tree.
149
- *
150
- * @template T - The type of nodes in the Structured Text tree
151
- * @param node - The root node to start searching from
152
- * @param predicate - Asynchronous function that tests each node. Should return true for desired nodes
153
- * @returns Promise that resolves to an array of objects, each containing a matching node and its path
154
- */
155
- export function findAllNodesAsync(node, predicate, parent = null, path = []) {
156
- return __awaiter(this, void 0, void 0, function* () {
157
- const results = [];
158
- yield forEachNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
159
- if (yield predicate(currentNode, currentParent, currentPath)) {
160
- results.push({ node: currentNode, path: currentPath });
161
- }
162
- }), parent, path);
163
- return results;
164
- });
165
- }
166
- /**
167
- * Filter nodes in the Structured Text tree, removing those that don't match the predicate.
168
- * Creates a new tree structure containing only nodes that pass the predicate test.
169
- * Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
170
- *
171
- * @template T - The type of nodes in the Structured Text tree
172
- * @param node - The root node to start filtering from
173
- * @param predicate - Synchronous function that tests each node. Nodes returning false are removed
174
- * @returns The filtered tree, or null if root node is filtered out
175
- */
176
- export function filterNodes(node, predicate, parent = null, path = []) {
177
- // If current node doesn't match predicate, return null
178
- if (!predicate(node, parent, path)) {
179
- return null;
180
- }
181
- // If node has no children, return it as-is
182
- if (!hasChildren(node)) {
183
- return node;
184
- }
185
- // Filter children recursively
186
- const childrenResults = node.children.map((child, index) => filterNodes(child, predicate, node, [
187
- ...path,
188
- 'children',
189
- index,
190
- ]));
191
- const filteredChildren = childrenResults.filter((child) => child !== null);
192
- return Object.assign(Object.assign({}, node), { children: filteredChildren });
193
- }
194
- /**
195
- * Filter nodes in the Structured Text tree, removing those that don't match the predicate.
196
- * Creates a new tree structure containing only nodes that pass the predicate test.
197
- * Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
198
- *
199
- * @template T - The type of nodes in the Structured Text tree
200
- * @param node - The root node to start filtering from
201
- * @param predicate - Asynchronous function that tests each node. Nodes returning false are removed
202
- * @returns Promise that resolves to the filtered tree, or null if root node is filtered out
203
- */
204
- export function filterNodesAsync(node, predicate, parent = null, path = []) {
205
- return __awaiter(this, void 0, void 0, function* () {
206
- // If current node doesn't match predicate, return null
207
- if (!(yield predicate(node, parent, path))) {
208
- return null;
209
- }
210
- // If node has no children, return it as-is
211
- if (!hasChildren(node)) {
212
- return node;
213
- }
214
- // Filter children recursively
215
- const childrenResults = yield Promise.all(node.children.map((child, index) => filterNodesAsync(child, predicate, node, [
216
- ...path,
217
- 'children',
218
- index,
219
- ])));
220
- const filteredChildren = childrenResults.filter((child) => child !== null);
221
- return Object.assign(Object.assign({}, node), { children: filteredChildren });
222
- });
223
- }
224
- /**
225
- * Reduce the Structured Text tree to a single value by applying a reducer function to each node.
226
- * Uses pre-order traversal (parent is processed before its children).
227
- * The reducer function is called for each node with the current accumulator value.
228
- *
229
- * @template T - The type of nodes in the Structured Text tree
230
- * @template R - The type of the accumulated result
231
- * @param node - The root node to start reducing from
232
- * @param reducer - Synchronous function that processes each node and updates the accumulator
233
- * @param initialValue - The initial value for the accumulator
234
- * @returns The final accumulated value
235
- */
236
- export function reduceNodes(node, reducer, initialValue, parent = null, path = []) {
237
- let accumulator = initialValue;
238
- forEachNode(node, (currentNode, currentParent, currentPath) => {
239
- accumulator = reducer(accumulator, currentNode, currentParent, currentPath);
240
- }, parent, path);
241
- return accumulator;
242
- }
243
- /**
244
- * Reduce the Structured Text tree to a single value by applying a reducer function to each node.
245
- * Uses pre-order traversal (parent is processed before its children).
246
- * The reducer function is called for each node with the current accumulator value.
247
- *
248
- * @template T - The type of nodes in the Structured Text tree
249
- * @template R - The type of the accumulated result
250
- * @param node - The root node to start reducing from
251
- * @param reducer - Asynchronous function that processes each node and updates the accumulator
252
- * @param initialValue - The initial value for the accumulator
253
- * @returns Promise that resolves to the final accumulated value
254
- */
255
- export function reduceNodesAsync(node, reducer, initialValue, parent = null, path = []) {
256
- return __awaiter(this, void 0, void 0, function* () {
257
- let accumulator = initialValue;
258
- yield forEachNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
259
- accumulator = yield reducer(accumulator, currentNode, currentParent, currentPath);
260
- }), parent, path);
261
- return accumulator;
262
- });
263
- }
264
- /**
265
- * Check if any node in the Structured Text tree matches the predicate function.
266
- * Returns true as soon as the first matching node is found (short-circuit evaluation).
267
- *
268
- * @template T - The type of nodes in the Structured Text tree
269
- * @param node - The root node to start searching from
270
- * @param predicate - Synchronous function that tests each node. Should return true for matching nodes
271
- * @returns True if any node matches, false otherwise
272
- */
273
- export function someNode(node, predicate, parent = null, path = []) {
274
- // Check current node
275
- if (predicate(node, parent, path)) {
276
- return true;
277
- }
278
- // Recursively check children
279
- if (hasChildren(node)) {
280
- for (let index = 0; index < node.children.length; index++) {
281
- const child = node.children[index];
282
- if (someNode(child, predicate, node, [
283
- ...path,
284
- 'children',
285
- index,
286
- ])) {
287
- return true;
288
- }
289
- }
290
- }
291
- return false;
292
- }
293
- /**
294
- * Check if any node in the Structured Text tree matches the predicate function.
295
- * Returns true as soon as the first matching node is found (short-circuit evaluation).
296
- *
297
- * @template T - The type of nodes in the Structured Text tree
298
- * @param node - The root node to start searching from
299
- * @param predicate - Asynchronous function that tests each node. Should return true for matching nodes
300
- * @returns Promise that resolves to true if any node matches, false otherwise
301
- */
302
- export function someNodeAsync(node, predicate, parent = null, path = []) {
303
- return __awaiter(this, void 0, void 0, function* () {
304
- // Check current node
305
- if (yield predicate(node, parent, path)) {
306
- return true;
307
- }
308
- // Recursively check children
309
- if (hasChildren(node)) {
310
- for (let index = 0; index < node.children.length; index++) {
311
- const child = node.children[index];
312
- if (yield someNodeAsync(child, predicate, node, [
313
- ...path,
314
- 'children',
315
- index,
316
- ])) {
317
- return true;
318
- }
319
- }
320
- }
321
- return false;
322
- });
323
- }
324
- /**
325
- * Check if every node in the Structured Text tree matches the predicate function.
326
- * Returns false as soon as the first non-matching node is found (short-circuit evaluation).
327
- *
328
- * @template T - The type of nodes in the Structured Text tree
329
- * @param node - The root node to start testing from
330
- * @param predicate - Synchronous function that tests each node. Should return true for valid nodes
331
- * @returns True if all nodes match, false otherwise
332
- */
333
- export function everyNode(node, predicate, parent = null, path = []) {
334
- return !someNode(node, (currentNode, currentParent, currentPath) => {
335
- return !predicate(currentNode, currentParent, currentPath);
336
- }, parent, path);
337
- }
338
- /**
339
- * Check if every node in the Structured Text tree matches the predicate function.
340
- * Returns false as soon as the first non-matching node is found (short-circuit evaluation).
341
- *
342
- * @template T - The type of nodes in the Structured Text tree
343
- * @param node - The root node to start testing from
344
- * @param predicate - Asynchronous function that tests each node. Should return true for valid nodes
345
- * @returns Promise that resolves to true if all nodes match, false otherwise
346
- */
347
- export function everyNodeAsync(node, predicate, parent = null, path = []) {
348
- return __awaiter(this, void 0, void 0, function* () {
349
- return !(yield someNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
350
- return !(yield predicate(currentNode, currentParent, currentPath));
351
- }), parent, path));
352
- });
353
- }
354
- //# sourceMappingURL=structuredText.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"structuredText.js","sourceRoot":"","sources":["../../../src/utilities/structuredText.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;AAqDH;;GAEG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,UAAU,IAAI,IAAI;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,IAAO,EACP,OAA+B,EAC/B,SAAmC,IAAI,EACvC,OAAiB,EAAE;IAEnB,qBAAqB;IACrB,OAAO,CAAC,IAAyB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEjD,6BAA6B;IAC7B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;QACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACzD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACnC,WAAW,CAAC,KAAU,EAAE,OAAO,EAAE,IAAyB,EAAE;gBAC1D,GAAG,IAAI;gBACP,UAAU;gBACV,KAAK;aACN,CAAC,CAAC;SACJ;KACF;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAgB,gBAAgB,CACpC,IAAO,EACP,OAAwC,EACxC,SAAmC,IAAI,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AAK,EAAE,EAAE;gBACzD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACnC,IACE,MAAM,aAAa,CAAC,KAAU,EAAE,SAAS,EAAE,IAAyB,EAAE;oBACpE,GAAG,IAAI;oBACP,UAAU;oBACV,KAAK;iBACN,CAAC,EACF;oBACA,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,IAAO,EACP,SAAoC,EACpC,SAAmC,IAAI,EACvC,OAAiB,EAAE;IAEnB,OAAO,CAAC,QAAQ,CACd,IAAI,EACJ,CACE,WAA8B,EAC9B,aAAuC,EACvC,WAAqB,EACrB,EAAE;QACF,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC,EACD,MAAM,EACN,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAgB,cAAc,CAClC,IAAO,EACP,SAA6C,EAC7C,SAAmC,IAAI,EACvC,OAAiB,EAAE;;QAEnB,OAAO,CAAC,CAAC,MAAM,aAAa,CAC1B,IAAI,EACJ,CACE,WAA8B,EAC9B,aAAuC,EACvC,WAAqB,EACrB,EAAE;YACF,OAAO,CAAC,CAAC,MAAM,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;QACrE,CAAC,CAAA,EACD,MAAM,EACN,IAAI,CACL,CAAC,CAAC;IACL,CAAC;CAAA"}
@@ -1,177 +0,0 @@
1
- /**
2
- * Tree manipulation utilities for DatoCMS structured text documents.
3
- *
4
- * Provides a set of low-level utilities for visiting, transforming, and querying
5
- * structured text trees. Works with all tree variants (regular, request, nested).
6
- */
7
- /**
8
- * Recursively extract all possible node types that can appear in a tree structure
9
- */
10
- type AllNodesInTree<T, Depth extends number = 10> = Depth extends 0 ? T extends readonly unknown[] ? never : T : T extends readonly (infer U)[] ? AllNodesInTree<U, Prev<Depth>> : T extends {
11
- children: infer Children;
12
- } ? T | AllNodesInTree<Children, Prev<Depth>> : T;
13
- type Prev<T extends number> = T extends 0 ? 0 : T extends 1 ? 0 : T extends 2 ? 1 : T extends 3 ? 2 : T extends 4 ? 3 : T extends 5 ? 4 : T extends 6 ? 5 : T extends 7 ? 6 : T extends 8 ? 7 : T extends 9 ? 8 : T extends 10 ? 9 : number;
14
- /**
15
- * Path through the Structured Text tree structure
16
- */
17
- export type TreePath = readonly (string | number)[];
18
- /**
19
- * Generic predicate function type for Structured Text tree node filtering
20
- */
21
- export type NodePredicate<T, R> = (node: AllNodesInTree<T>, parent: AllNodesInTree<T> | null, path: TreePath) => R;
22
- /**
23
- * Visit every node in the Structured Text tree, calling the visitor function for each.
24
- * Uses pre-order traversal (parent is visited before its children).
25
- *
26
- * @template T - The type of the root node in the Structured Text tree
27
- * @param node - The root node to start visiting from
28
- * @param visitor - Synchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
29
- */
30
- export declare function forEachNode<T>(node: T, visitor: NodePredicate<T, void>, parent?: AllNodesInTree<T> | null, path?: TreePath): void;
31
- /**
32
- * Visit every node in the Structured Text tree, calling the visitor function for each.
33
- * Uses pre-order traversal (parent is visited before its children).
34
- *
35
- * @template T - The type of the root node in the Structured Text tree
36
- * @param node - The root node to start visiting from
37
- * @param visitor - Asynchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
38
- * @returns Promise that resolves when all nodes have been visited
39
- */
40
- export declare function forEachNodeAsync<T>(node: T, visitor: NodePredicate<T, Promise<void>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<void>;
41
- /**
42
- * Transform nodes in the Structured Text tree by applying a mapping function.
43
- * Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
44
- *
45
- * @template T - The type of nodes in the input Structured Text tree
46
- * @template R - The type of nodes in the output tree
47
- * @param node - The root node to start mapping from
48
- * @param mapper - Synchronous function that transforms each node. Receives the node, its parent, and path
49
- * @returns The transformed tree
50
- */
51
- export declare function mapNodes<T, R>(node: T, mapper: NodePredicate<T, R>, parent?: AllNodesInTree<T> | null, path?: TreePath): R;
52
- /**
53
- * Transform nodes in the Structured Text tree by applying a mapping function.
54
- * Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
55
- *
56
- * @template T - The type of nodes in the input Structured Text tree
57
- * @template R - The type of nodes in the output tree
58
- * @param node - The root node to start mapping from
59
- * @param mapper - Asynchronous function that transforms each node. Receives the node, its parent, and path
60
- * @returns Promise that resolves to the transformed tree
61
- */
62
- export declare function mapNodesAsync<T, R>(node: T, mapper: NodePredicate<T, Promise<R>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<R>;
63
- /**
64
- * Find all nodes that match the predicate function using depth-first search.
65
- * Returns an array containing all matching nodes along with their paths through the Structured Text tree.
66
- *
67
- * @template T - The type of nodes in the Structured Text tree
68
- * @param node - The root node to start searching from
69
- * @param predicate - Synchronous function that tests each node. Should return true for desired nodes
70
- * @returns Array of objects, each containing a matching node and its path
71
- */
72
- export declare function findAllNodes<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): Array<{
73
- node: AllNodesInTree<T>;
74
- path: TreePath;
75
- }>;
76
- /**
77
- * Find all nodes that match the predicate function using depth-first search.
78
- * Returns an array containing all matching nodes along with their paths through the Structured Text tree.
79
- *
80
- * @template T - The type of nodes in the Structured Text tree
81
- * @param node - The root node to start searching from
82
- * @param predicate - Asynchronous function that tests each node. Should return true for desired nodes
83
- * @returns Promise that resolves to an array of objects, each containing a matching node and its path
84
- */
85
- export declare function findAllNodesAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<Array<{
86
- node: AllNodesInTree<T>;
87
- path: TreePath;
88
- }>>;
89
- /**
90
- * Filter nodes in the Structured Text tree, removing those that don't match the predicate.
91
- * Creates a new tree structure containing only nodes that pass the predicate test.
92
- * Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
93
- *
94
- * @template T - The type of nodes in the Structured Text tree
95
- * @param node - The root node to start filtering from
96
- * @param predicate - Synchronous function that tests each node. Nodes returning false are removed
97
- * @returns The filtered tree, or null if root node is filtered out
98
- */
99
- export declare function filterNodes<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): T | null;
100
- /**
101
- * Filter nodes in the Structured Text tree, removing those that don't match the predicate.
102
- * Creates a new tree structure containing only nodes that pass the predicate test.
103
- * Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
104
- *
105
- * @template T - The type of nodes in the Structured Text tree
106
- * @param node - The root node to start filtering from
107
- * @param predicate - Asynchronous function that tests each node. Nodes returning false are removed
108
- * @returns Promise that resolves to the filtered tree, or null if root node is filtered out
109
- */
110
- export declare function filterNodesAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<T | null>;
111
- /**
112
- * Reduce the Structured Text tree to a single value by applying a reducer function to each node.
113
- * Uses pre-order traversal (parent is processed before its children).
114
- * The reducer function is called for each node with the current accumulator value.
115
- *
116
- * @template T - The type of nodes in the Structured Text tree
117
- * @template R - The type of the accumulated result
118
- * @param node - The root node to start reducing from
119
- * @param reducer - Synchronous function that processes each node and updates the accumulator
120
- * @param initialValue - The initial value for the accumulator
121
- * @returns The final accumulated value
122
- */
123
- export declare function reduceNodes<T, R>(node: T, reducer: (accumulator: R, node: AllNodesInTree<T>, parent: AllNodesInTree<T> | null, path: TreePath) => R, initialValue: R, parent?: AllNodesInTree<T> | null, path?: TreePath): R;
124
- /**
125
- * Reduce the Structured Text tree to a single value by applying a reducer function to each node.
126
- * Uses pre-order traversal (parent is processed before its children).
127
- * The reducer function is called for each node with the current accumulator value.
128
- *
129
- * @template T - The type of nodes in the Structured Text tree
130
- * @template R - The type of the accumulated result
131
- * @param node - The root node to start reducing from
132
- * @param reducer - Asynchronous function that processes each node and updates the accumulator
133
- * @param initialValue - The initial value for the accumulator
134
- * @returns Promise that resolves to the final accumulated value
135
- */
136
- export declare function reduceNodesAsync<T, R>(node: T, reducer: (accumulator: R, node: AllNodesInTree<T>, parent: AllNodesInTree<T> | null, path: TreePath) => Promise<R>, initialValue: R, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<R>;
137
- /**
138
- * Check if any node in the Structured Text tree matches the predicate function.
139
- * Returns true as soon as the first matching node is found (short-circuit evaluation).
140
- *
141
- * @template T - The type of nodes in the Structured Text tree
142
- * @param node - The root node to start searching from
143
- * @param predicate - Synchronous function that tests each node. Should return true for matching nodes
144
- * @returns True if any node matches, false otherwise
145
- */
146
- export declare function someNode<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): boolean;
147
- /**
148
- * Check if any node in the Structured Text tree matches the predicate function.
149
- * Returns true as soon as the first matching node is found (short-circuit evaluation).
150
- *
151
- * @template T - The type of nodes in the Structured Text tree
152
- * @param node - The root node to start searching from
153
- * @param predicate - Asynchronous function that tests each node. Should return true for matching nodes
154
- * @returns Promise that resolves to true if any node matches, false otherwise
155
- */
156
- export declare function someNodeAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<boolean>;
157
- /**
158
- * Check if every node in the Structured Text tree matches the predicate function.
159
- * Returns false as soon as the first non-matching node is found (short-circuit evaluation).
160
- *
161
- * @template T - The type of nodes in the Structured Text tree
162
- * @param node - The root node to start testing from
163
- * @param predicate - Synchronous function that tests each node. Should return true for valid nodes
164
- * @returns True if all nodes match, false otherwise
165
- */
166
- export declare function everyNode<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): boolean;
167
- /**
168
- * Check if every node in the Structured Text tree matches the predicate function.
169
- * Returns false as soon as the first non-matching node is found (short-circuit evaluation).
170
- *
171
- * @template T - The type of nodes in the Structured Text tree
172
- * @param node - The root node to start testing from
173
- * @param predicate - Asynchronous function that tests each node. Should return true for valid nodes
174
- * @returns Promise that resolves to true if all nodes match, false otherwise
175
- */
176
- export declare function everyNodeAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<boolean>;
177
- export {};