@prismicio/client 7.21.6 → 7.21.7-canary.673a207

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 (582) hide show
  1. package/dist/Client.cjs +19 -20
  2. package/dist/Client.cjs.map +1 -1
  3. package/dist/Client.d.cts +5 -12
  4. package/dist/Client.d.cts.map +1 -1
  5. package/dist/Client.d.ts +5 -12
  6. package/dist/Client.d.ts.map +1 -1
  7. package/dist/Client.js +8 -9
  8. package/dist/Client.js.map +1 -1
  9. package/dist/Migration.cjs +18 -19
  10. package/dist/Migration.cjs.map +1 -1
  11. package/dist/Migration.d.cts +0 -1
  12. package/dist/Migration.d.cts.map +1 -1
  13. package/dist/Migration.d.ts +0 -1
  14. package/dist/Migration.d.ts.map +1 -1
  15. package/dist/Migration.js +11 -12
  16. package/dist/Migration.js.map +1 -1
  17. package/dist/WriteClient.cjs +19 -23
  18. package/dist/WriteClient.cjs.map +1 -1
  19. package/dist/WriteClient.d.cts +0 -1
  20. package/dist/WriteClient.d.cts.map +1 -1
  21. package/dist/WriteClient.d.ts +0 -1
  22. package/dist/WriteClient.d.ts.map +1 -1
  23. package/dist/WriteClient.js +12 -16
  24. package/dist/WriteClient.js.map +1 -1
  25. package/dist/_virtual/_rolldown/runtime.cjs +13 -0
  26. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.js} +4 -5
  27. package/dist/buildQueryURL.cjs +4 -5
  28. package/dist/buildQueryURL.cjs.map +1 -1
  29. package/dist/buildQueryURL.d.cts.map +1 -1
  30. package/dist/buildQueryURL.d.ts.map +1 -1
  31. package/dist/buildQueryURL.js +2 -3
  32. package/dist/buildQueryURL.js.map +1 -1
  33. package/dist/cookie.cjs +7 -9
  34. package/dist/cookie.cjs.map +1 -1
  35. package/dist/cookie.d.cts.map +1 -1
  36. package/dist/cookie.d.ts.map +1 -1
  37. package/dist/cookie.js +3 -4
  38. package/dist/cookie.js.map +1 -1
  39. package/dist/createClient.cjs +2 -3
  40. package/dist/createClient.cjs.map +1 -1
  41. package/dist/createClient.d.cts +0 -1
  42. package/dist/createClient.d.cts.map +1 -1
  43. package/dist/createClient.d.ts +0 -1
  44. package/dist/createClient.d.ts.map +1 -1
  45. package/dist/createClient.js +1 -2
  46. package/dist/createClient.js.map +1 -1
  47. package/dist/createMigration.cjs +2 -3
  48. package/dist/createMigration.cjs.map +1 -1
  49. package/dist/createMigration.d.cts +0 -1
  50. package/dist/createMigration.d.cts.map +1 -1
  51. package/dist/createMigration.d.ts +0 -1
  52. package/dist/createMigration.d.ts.map +1 -1
  53. package/dist/createMigration.js +1 -2
  54. package/dist/createMigration.js.map +1 -1
  55. package/dist/createWriteClient.cjs +2 -3
  56. package/dist/createWriteClient.cjs.map +1 -1
  57. package/dist/createWriteClient.d.cts +0 -1
  58. package/dist/createWriteClient.d.cts.map +1 -1
  59. package/dist/createWriteClient.d.ts +0 -1
  60. package/dist/createWriteClient.d.ts.map +1 -1
  61. package/dist/createWriteClient.js +1 -2
  62. package/dist/createWriteClient.js.map +1 -1
  63. package/dist/errors.cjs +1 -2
  64. package/dist/errors.cjs.map +1 -1
  65. package/dist/errors.d.cts.map +1 -1
  66. package/dist/errors.d.ts.map +1 -1
  67. package/dist/errors.js +1 -1
  68. package/dist/filter.cjs +1 -2
  69. package/dist/filter.cjs.map +1 -1
  70. package/dist/filter.d.cts.map +1 -1
  71. package/dist/filter.d.ts.map +1 -1
  72. package/dist/filter.js +1 -1
  73. package/dist/getGraphQLEndpoint.cjs +3 -4
  74. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  75. package/dist/getGraphQLEndpoint.d.cts.map +1 -1
  76. package/dist/getGraphQLEndpoint.d.ts.map +1 -1
  77. package/dist/getGraphQLEndpoint.js +1 -2
  78. package/dist/getGraphQLEndpoint.js.map +1 -1
  79. package/dist/getRepositoryEndpoint.cjs +3 -4
  80. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  81. package/dist/getRepositoryEndpoint.d.cts.map +1 -1
  82. package/dist/getRepositoryEndpoint.d.ts.map +1 -1
  83. package/dist/getRepositoryEndpoint.js +1 -2
  84. package/dist/getRepositoryEndpoint.js.map +1 -1
  85. package/dist/getRepositoryName.cjs +2 -3
  86. package/dist/getRepositoryName.cjs.map +1 -1
  87. package/dist/getRepositoryName.d.cts.map +1 -1
  88. package/dist/getRepositoryName.d.ts.map +1 -1
  89. package/dist/getRepositoryName.js +1 -2
  90. package/dist/getRepositoryName.js.map +1 -1
  91. package/dist/getToolbarSrc.cjs +3 -4
  92. package/dist/getToolbarSrc.cjs.map +1 -1
  93. package/dist/getToolbarSrc.d.cts.map +1 -1
  94. package/dist/getToolbarSrc.d.ts.map +1 -1
  95. package/dist/getToolbarSrc.js +1 -2
  96. package/dist/getToolbarSrc.js.map +1 -1
  97. package/dist/helpers/asDate.cjs +1 -2
  98. package/dist/helpers/asDate.cjs.map +1 -1
  99. package/dist/helpers/asDate.d.cts +0 -1
  100. package/dist/helpers/asDate.d.cts.map +1 -1
  101. package/dist/helpers/asDate.d.ts +0 -1
  102. package/dist/helpers/asDate.d.ts.map +1 -1
  103. package/dist/helpers/asDate.js +1 -1
  104. package/dist/helpers/asHTML.cjs +5 -6
  105. package/dist/helpers/asHTML.cjs.map +1 -1
  106. package/dist/helpers/asHTML.d.cts +0 -1
  107. package/dist/helpers/asHTML.d.cts.map +1 -1
  108. package/dist/helpers/asHTML.d.ts +0 -1
  109. package/dist/helpers/asHTML.d.ts.map +1 -1
  110. package/dist/helpers/asHTML.js +1 -2
  111. package/dist/helpers/asHTML.js.map +1 -1
  112. package/dist/helpers/asImagePixelDensitySrcSet.cjs +3 -4
  113. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  114. package/dist/helpers/asImagePixelDensitySrcSet.d.cts +0 -1
  115. package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
  116. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +0 -1
  117. package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
  118. package/dist/helpers/asImagePixelDensitySrcSet.js +2 -3
  119. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  120. package/dist/helpers/asImageSrc.cjs +2 -3
  121. package/dist/helpers/asImageSrc.cjs.map +1 -1
  122. package/dist/helpers/asImageSrc.d.cts +0 -1
  123. package/dist/helpers/asImageSrc.d.cts.map +1 -1
  124. package/dist/helpers/asImageSrc.d.ts +0 -1
  125. package/dist/helpers/asImageSrc.d.ts.map +1 -1
  126. package/dist/helpers/asImageSrc.js +1 -2
  127. package/dist/helpers/asImageSrc.js.map +1 -1
  128. package/dist/helpers/asImageWidthSrcSet.cjs +4 -5
  129. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  130. package/dist/helpers/asImageWidthSrcSet.d.cts +0 -1
  131. package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
  132. package/dist/helpers/asImageWidthSrcSet.d.ts +0 -1
  133. package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
  134. package/dist/helpers/asImageWidthSrcSet.js +3 -4
  135. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  136. package/dist/helpers/asLink.cjs +3 -4
  137. package/dist/helpers/asLink.cjs.map +1 -1
  138. package/dist/helpers/asLink.d.cts +0 -1
  139. package/dist/helpers/asLink.d.cts.map +1 -1
  140. package/dist/helpers/asLink.d.ts +0 -1
  141. package/dist/helpers/asLink.d.ts.map +1 -1
  142. package/dist/helpers/asLink.js +1 -2
  143. package/dist/helpers/asLink.js.map +1 -1
  144. package/dist/helpers/asLinkAttrs.cjs +4 -5
  145. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  146. package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
  147. package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
  148. package/dist/helpers/asLinkAttrs.js +1 -2
  149. package/dist/helpers/asLinkAttrs.js.map +1 -1
  150. package/dist/helpers/asText.cjs +4 -5
  151. package/dist/helpers/asText.cjs.map +1 -1
  152. package/dist/helpers/asText.d.cts +0 -1
  153. package/dist/helpers/asText.d.cts.map +1 -1
  154. package/dist/helpers/asText.d.ts +0 -1
  155. package/dist/helpers/asText.d.ts.map +1 -1
  156. package/dist/helpers/asText.js +5 -6
  157. package/dist/helpers/asText.js.map +1 -1
  158. package/dist/helpers/documentToLinkField.cjs +2 -3
  159. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  160. package/dist/helpers/documentToLinkField.d.cts.map +1 -1
  161. package/dist/helpers/documentToLinkField.d.ts.map +1 -1
  162. package/dist/helpers/documentToLinkField.js +1 -2
  163. package/dist/helpers/documentToLinkField.js.map +1 -1
  164. package/dist/helpers/isFilled.cjs +11 -13
  165. package/dist/helpers/isFilled.cjs.map +1 -1
  166. package/dist/helpers/isFilled.d.cts.map +1 -1
  167. package/dist/helpers/isFilled.d.ts.map +1 -1
  168. package/dist/helpers/isFilled.js +7 -8
  169. package/dist/helpers/isFilled.js.map +1 -1
  170. package/dist/helpers/mapSliceZone.cjs +1 -2
  171. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  172. package/dist/helpers/mapSliceZone.d.cts +0 -1
  173. package/dist/helpers/mapSliceZone.d.cts.map +1 -1
  174. package/dist/helpers/mapSliceZone.d.ts +0 -1
  175. package/dist/helpers/mapSliceZone.d.ts.map +1 -1
  176. package/dist/helpers/mapSliceZone.js +1 -1
  177. package/dist/index.cjs +49 -49
  178. package/dist/index.cjs.map +1 -1
  179. package/dist/index.d.cts.map +1 -1
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js +1 -2
  182. package/dist/index.js.map +1 -1
  183. package/dist/isRepositoryEndpoint.cjs +1 -2
  184. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  185. package/dist/isRepositoryEndpoint.d.cts.map +1 -1
  186. package/dist/isRepositoryEndpoint.d.ts.map +1 -1
  187. package/dist/isRepositoryEndpoint.js +1 -1
  188. package/dist/isRepositoryName.cjs +1 -2
  189. package/dist/isRepositoryName.cjs.map +1 -1
  190. package/dist/isRepositoryName.d.cts.map +1 -1
  191. package/dist/isRepositoryName.d.ts.map +1 -1
  192. package/dist/isRepositoryName.js +1 -1
  193. package/dist/lib/devMsg.cjs +2 -3
  194. package/dist/lib/devMsg.cjs.map +1 -1
  195. package/dist/lib/devMsg.js +1 -2
  196. package/dist/lib/devMsg.js.map +1 -1
  197. package/dist/lib/escapeHTML.cjs +1 -2
  198. package/dist/lib/escapeHTML.cjs.map +1 -1
  199. package/dist/lib/escapeHTML.js +1 -1
  200. package/dist/lib/getOptionalLinkProperties.cjs +1 -2
  201. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
  202. package/dist/lib/getOptionalLinkProperties.js +1 -1
  203. package/dist/lib/getOptionalLinkProperties.js.map +1 -1
  204. package/dist/lib/getPreviewCookie.cjs +3 -4
  205. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  206. package/dist/lib/getPreviewCookie.js +3 -4
  207. package/dist/lib/getPreviewCookie.js.map +1 -1
  208. package/dist/lib/isInternalURL.cjs +1 -2
  209. package/dist/lib/isInternalURL.cjs.map +1 -1
  210. package/dist/lib/isInternalURL.js +1 -1
  211. package/dist/lib/isMigrationValue.cjs +6 -7
  212. package/dist/lib/isMigrationValue.cjs.map +1 -1
  213. package/dist/lib/isMigrationValue.js +1 -2
  214. package/dist/lib/isMigrationValue.js.map +1 -1
  215. package/dist/lib/isValue.cjs +3 -4
  216. package/dist/lib/isValue.cjs.map +1 -1
  217. package/dist/lib/isValue.js +1 -2
  218. package/dist/lib/isValue.js.map +1 -1
  219. package/dist/lib/pLimit.cjs +1 -2
  220. package/dist/lib/pLimit.cjs.map +1 -1
  221. package/dist/lib/pLimit.js +1 -1
  222. package/dist/lib/pLimit.js.map +1 -1
  223. package/dist/lib/request.cjs +8 -8
  224. package/dist/lib/request.cjs.map +1 -1
  225. package/dist/lib/request.d.cts +1 -1
  226. package/dist/lib/request.d.cts.map +1 -1
  227. package/dist/lib/request.d.ts +1 -1
  228. package/dist/lib/request.d.ts.map +1 -1
  229. package/dist/lib/request.js +7 -7
  230. package/dist/lib/request.js.map +1 -1
  231. package/dist/lib/resolveMigrationDocumentData.cjs +18 -19
  232. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  233. package/dist/lib/resolveMigrationDocumentData.js +11 -12
  234. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  235. package/dist/lib/serializerHelpers.cjs +4 -5
  236. package/dist/lib/serializerHelpers.cjs.map +1 -1
  237. package/dist/lib/serializerHelpers.js +1 -2
  238. package/dist/lib/serializerHelpers.js.map +1 -1
  239. package/dist/lib/throttledWarn.cjs +1 -2
  240. package/dist/lib/throttledWarn.cjs.map +1 -1
  241. package/dist/lib/throttledWarn.js +1 -1
  242. package/dist/lib/throttledWarn.js.map +1 -1
  243. package/dist/lib/validateAssetMetadata.cjs +2 -3
  244. package/dist/lib/validateAssetMetadata.cjs.map +1 -1
  245. package/dist/lib/validateAssetMetadata.js +1 -2
  246. package/dist/lib/validateAssetMetadata.js.map +1 -1
  247. package/dist/package.cjs +12 -13
  248. package/dist/package.cjs.map +1 -1
  249. package/dist/package.js +2 -2
  250. package/dist/package.js.map +1 -1
  251. package/dist/richtext/asText.cjs +1 -2
  252. package/dist/richtext/asText.cjs.map +1 -1
  253. package/dist/richtext/asText.d.cts +0 -1
  254. package/dist/richtext/asText.d.cts.map +1 -1
  255. package/dist/richtext/asText.d.ts +0 -1
  256. package/dist/richtext/asText.d.ts.map +1 -1
  257. package/dist/richtext/asText.js +1 -1
  258. package/dist/richtext/asTree.cjs +2 -3
  259. package/dist/richtext/asTree.cjs.map +1 -1
  260. package/dist/richtext/asTree.d.cts +0 -1
  261. package/dist/richtext/asTree.d.cts.map +1 -1
  262. package/dist/richtext/asTree.d.ts +0 -1
  263. package/dist/richtext/asTree.d.ts.map +1 -1
  264. package/dist/richtext/asTree.js +1 -2
  265. package/dist/richtext/asTree.js.map +1 -1
  266. package/dist/richtext/composeSerializers.cjs +1 -2
  267. package/dist/richtext/composeSerializers.cjs.map +1 -1
  268. package/dist/richtext/composeSerializers.d.cts +0 -1
  269. package/dist/richtext/composeSerializers.d.cts.map +1 -1
  270. package/dist/richtext/composeSerializers.d.ts +0 -1
  271. package/dist/richtext/composeSerializers.d.ts.map +1 -1
  272. package/dist/richtext/composeSerializers.js +1 -1
  273. package/dist/richtext/serialize.cjs +2 -3
  274. package/dist/richtext/serialize.cjs.map +1 -1
  275. package/dist/richtext/serialize.d.cts +0 -1
  276. package/dist/richtext/serialize.d.cts.map +1 -1
  277. package/dist/richtext/serialize.d.ts +0 -1
  278. package/dist/richtext/serialize.d.ts.map +1 -1
  279. package/dist/richtext/serialize.js +1 -2
  280. package/dist/richtext/serialize.js.map +1 -1
  281. package/dist/richtext/types.cjs +2 -3
  282. package/dist/richtext/types.cjs.map +1 -1
  283. package/dist/richtext/types.d.cts +0 -1
  284. package/dist/richtext/types.d.cts.map +1 -1
  285. package/dist/richtext/types.d.ts +0 -1
  286. package/dist/richtext/types.d.ts.map +1 -1
  287. package/dist/richtext/types.js +1 -2
  288. package/dist/richtext/types.js.map +1 -1
  289. package/dist/richtext/wrapMapSerializer.cjs +2 -3
  290. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  291. package/dist/richtext/wrapMapSerializer.d.cts +0 -1
  292. package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
  293. package/dist/richtext/wrapMapSerializer.d.ts +0 -1
  294. package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
  295. package/dist/richtext/wrapMapSerializer.js +1 -2
  296. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  297. package/dist/richtext.cjs +8 -8
  298. package/dist/richtext.js +1 -2
  299. package/dist/types/api/asset/asset.d.cts +0 -1
  300. package/dist/types/api/asset/asset.d.cts.map +1 -1
  301. package/dist/types/api/asset/asset.d.ts +0 -1
  302. package/dist/types/api/asset/asset.d.ts.map +1 -1
  303. package/dist/types/api/asset/tag.d.cts.map +1 -1
  304. package/dist/types/api/asset/tag.d.ts.map +1 -1
  305. package/dist/types/api/integration.d.cts +0 -1
  306. package/dist/types/api/integration.d.cts.map +1 -1
  307. package/dist/types/api/integration.d.ts +0 -1
  308. package/dist/types/api/integration.d.ts.map +1 -1
  309. package/dist/types/api/query.d.cts +0 -1
  310. package/dist/types/api/query.d.cts.map +1 -1
  311. package/dist/types/api/query.d.ts +0 -1
  312. package/dist/types/api/query.d.ts.map +1 -1
  313. package/dist/types/api/ref.d.cts.map +1 -1
  314. package/dist/types/api/ref.d.ts.map +1 -1
  315. package/dist/types/api/release.d.cts +0 -1
  316. package/dist/types/api/release.d.cts.map +1 -1
  317. package/dist/types/api/release.d.ts +0 -1
  318. package/dist/types/api/release.d.ts.map +1 -1
  319. package/dist/types/api/repository.d.cts +0 -1
  320. package/dist/types/api/repository.d.cts.map +1 -1
  321. package/dist/types/api/repository.d.ts +0 -1
  322. package/dist/types/api/repository.d.ts.map +1 -1
  323. package/dist/types/api/tags.d.cts.map +1 -1
  324. package/dist/types/api/tags.d.ts.map +1 -1
  325. package/dist/types/migration/Asset.cjs +1 -2
  326. package/dist/types/migration/Asset.cjs.map +1 -1
  327. package/dist/types/migration/Asset.d.cts +0 -1
  328. package/dist/types/migration/Asset.d.cts.map +1 -1
  329. package/dist/types/migration/Asset.d.ts +0 -1
  330. package/dist/types/migration/Asset.d.ts.map +1 -1
  331. package/dist/types/migration/Asset.js +1 -1
  332. package/dist/types/migration/ContentRelationship.d.cts.map +1 -1
  333. package/dist/types/migration/ContentRelationship.d.ts.map +1 -1
  334. package/dist/types/migration/Document.cjs +1 -2
  335. package/dist/types/migration/Document.cjs.map +1 -1
  336. package/dist/types/migration/Document.d.cts +0 -1
  337. package/dist/types/migration/Document.d.cts.map +1 -1
  338. package/dist/types/migration/Document.d.ts +0 -1
  339. package/dist/types/migration/Document.d.ts.map +1 -1
  340. package/dist/types/migration/Document.js +1 -1
  341. package/dist/types/migration/Document.js.map +1 -1
  342. package/dist/types/model/boolean.d.cts +0 -1
  343. package/dist/types/model/boolean.d.cts.map +1 -1
  344. package/dist/types/model/boolean.d.ts +0 -1
  345. package/dist/types/model/boolean.d.ts.map +1 -1
  346. package/dist/types/model/color.d.cts +0 -1
  347. package/dist/types/model/color.d.cts.map +1 -1
  348. package/dist/types/model/color.d.ts +0 -1
  349. package/dist/types/model/color.d.ts.map +1 -1
  350. package/dist/types/model/contentRelationship.d.cts +0 -1
  351. package/dist/types/model/contentRelationship.d.cts.map +1 -1
  352. package/dist/types/model/contentRelationship.d.ts +0 -1
  353. package/dist/types/model/contentRelationship.d.ts.map +1 -1
  354. package/dist/types/model/customType.d.cts +0 -1
  355. package/dist/types/model/customType.d.cts.map +1 -1
  356. package/dist/types/model/customType.d.ts +0 -1
  357. package/dist/types/model/customType.d.ts.map +1 -1
  358. package/dist/types/model/date.d.cts +0 -1
  359. package/dist/types/model/date.d.cts.map +1 -1
  360. package/dist/types/model/date.d.ts +0 -1
  361. package/dist/types/model/date.d.ts.map +1 -1
  362. package/dist/types/model/embed.d.cts +0 -1
  363. package/dist/types/model/embed.d.cts.map +1 -1
  364. package/dist/types/model/embed.d.ts +0 -1
  365. package/dist/types/model/embed.d.ts.map +1 -1
  366. package/dist/types/model/geoPoint.d.cts +0 -1
  367. package/dist/types/model/geoPoint.d.cts.map +1 -1
  368. package/dist/types/model/geoPoint.d.ts +0 -1
  369. package/dist/types/model/geoPoint.d.ts.map +1 -1
  370. package/dist/types/model/group.d.cts +0 -1
  371. package/dist/types/model/group.d.cts.map +1 -1
  372. package/dist/types/model/group.d.ts +0 -1
  373. package/dist/types/model/group.d.ts.map +1 -1
  374. package/dist/types/model/image.d.cts +0 -1
  375. package/dist/types/model/image.d.cts.map +1 -1
  376. package/dist/types/model/image.d.ts +0 -1
  377. package/dist/types/model/image.d.ts.map +1 -1
  378. package/dist/types/model/integration.d.cts +0 -1
  379. package/dist/types/model/integration.d.cts.map +1 -1
  380. package/dist/types/model/integration.d.ts +0 -1
  381. package/dist/types/model/integration.d.ts.map +1 -1
  382. package/dist/types/model/keyText.d.cts +0 -1
  383. package/dist/types/model/keyText.d.cts.map +1 -1
  384. package/dist/types/model/keyText.d.ts +0 -1
  385. package/dist/types/model/keyText.d.ts.map +1 -1
  386. package/dist/types/model/link.cjs +1 -2
  387. package/dist/types/model/link.cjs.map +1 -1
  388. package/dist/types/model/link.d.cts +0 -1
  389. package/dist/types/model/link.d.cts.map +1 -1
  390. package/dist/types/model/link.d.ts +0 -1
  391. package/dist/types/model/link.d.ts.map +1 -1
  392. package/dist/types/model/link.js +1 -1
  393. package/dist/types/model/linkToMedia.d.cts +0 -1
  394. package/dist/types/model/linkToMedia.d.cts.map +1 -1
  395. package/dist/types/model/linkToMedia.d.ts +0 -1
  396. package/dist/types/model/linkToMedia.d.ts.map +1 -1
  397. package/dist/types/model/number.d.cts +0 -1
  398. package/dist/types/model/number.d.cts.map +1 -1
  399. package/dist/types/model/number.d.ts +0 -1
  400. package/dist/types/model/number.d.ts.map +1 -1
  401. package/dist/types/model/range.d.cts +0 -1
  402. package/dist/types/model/range.d.cts.map +1 -1
  403. package/dist/types/model/range.d.ts +0 -1
  404. package/dist/types/model/range.d.ts.map +1 -1
  405. package/dist/types/model/richText.d.cts +0 -1
  406. package/dist/types/model/richText.d.cts.map +1 -1
  407. package/dist/types/model/richText.d.ts +0 -1
  408. package/dist/types/model/richText.d.ts.map +1 -1
  409. package/dist/types/model/select.d.cts +0 -1
  410. package/dist/types/model/select.d.cts.map +1 -1
  411. package/dist/types/model/select.d.ts +0 -1
  412. package/dist/types/model/select.d.ts.map +1 -1
  413. package/dist/types/model/separator.d.cts +0 -1
  414. package/dist/types/model/separator.d.cts.map +1 -1
  415. package/dist/types/model/separator.d.ts +0 -1
  416. package/dist/types/model/separator.d.ts.map +1 -1
  417. package/dist/types/model/sharedSlice.d.cts +0 -1
  418. package/dist/types/model/sharedSlice.d.cts.map +1 -1
  419. package/dist/types/model/sharedSlice.d.ts +0 -1
  420. package/dist/types/model/sharedSlice.d.ts.map +1 -1
  421. package/dist/types/model/sharedSliceVariation.d.cts +0 -1
  422. package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
  423. package/dist/types/model/sharedSliceVariation.d.ts +0 -1
  424. package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
  425. package/dist/types/model/slice.cjs +1 -2
  426. package/dist/types/model/slice.cjs.map +1 -1
  427. package/dist/types/model/slice.d.cts +0 -1
  428. package/dist/types/model/slice.d.cts.map +1 -1
  429. package/dist/types/model/slice.d.ts +0 -1
  430. package/dist/types/model/slice.d.ts.map +1 -1
  431. package/dist/types/model/slice.js +1 -1
  432. package/dist/types/model/sliceZone.cjs +1 -2
  433. package/dist/types/model/sliceZone.cjs.map +1 -1
  434. package/dist/types/model/sliceZone.d.cts +0 -1
  435. package/dist/types/model/sliceZone.d.cts.map +1 -1
  436. package/dist/types/model/sliceZone.d.ts +0 -1
  437. package/dist/types/model/sliceZone.d.ts.map +1 -1
  438. package/dist/types/model/sliceZone.js +1 -1
  439. package/dist/types/model/table.d.cts +0 -1
  440. package/dist/types/model/table.d.cts.map +1 -1
  441. package/dist/types/model/table.d.ts +0 -1
  442. package/dist/types/model/table.d.ts.map +1 -1
  443. package/dist/types/model/timestamp.d.cts +0 -1
  444. package/dist/types/model/timestamp.d.cts.map +1 -1
  445. package/dist/types/model/timestamp.d.ts +0 -1
  446. package/dist/types/model/timestamp.d.ts.map +1 -1
  447. package/dist/types/model/title.d.cts +0 -1
  448. package/dist/types/model/title.d.cts.map +1 -1
  449. package/dist/types/model/title.d.ts +0 -1
  450. package/dist/types/model/title.d.ts.map +1 -1
  451. package/dist/types/model/types.cjs +1 -2
  452. package/dist/types/model/types.cjs.map +1 -1
  453. package/dist/types/model/types.d.cts +0 -1
  454. package/dist/types/model/types.d.cts.map +1 -1
  455. package/dist/types/model/types.d.ts +0 -1
  456. package/dist/types/model/types.d.ts.map +1 -1
  457. package/dist/types/model/types.js +1 -1
  458. package/dist/types/model/uid.d.cts +0 -1
  459. package/dist/types/model/uid.d.cts.map +1 -1
  460. package/dist/types/model/uid.d.ts +0 -1
  461. package/dist/types/model/uid.d.ts.map +1 -1
  462. package/dist/types/value/boolean.d.cts.map +1 -1
  463. package/dist/types/value/boolean.d.ts.map +1 -1
  464. package/dist/types/value/color.d.cts +0 -1
  465. package/dist/types/value/color.d.cts.map +1 -1
  466. package/dist/types/value/color.d.ts +0 -1
  467. package/dist/types/value/color.d.ts.map +1 -1
  468. package/dist/types/value/contentRelationship.d.cts +0 -1
  469. package/dist/types/value/contentRelationship.d.cts.map +1 -1
  470. package/dist/types/value/contentRelationship.d.ts +0 -1
  471. package/dist/types/value/contentRelationship.d.ts.map +1 -1
  472. package/dist/types/value/date.d.cts +0 -1
  473. package/dist/types/value/date.d.cts.map +1 -1
  474. package/dist/types/value/date.d.ts +0 -1
  475. package/dist/types/value/date.d.ts.map +1 -1
  476. package/dist/types/value/document.d.cts +0 -1
  477. package/dist/types/value/document.d.cts.map +1 -1
  478. package/dist/types/value/document.d.ts +0 -1
  479. package/dist/types/value/document.d.ts.map +1 -1
  480. package/dist/types/value/embed.cjs +1 -2
  481. package/dist/types/value/embed.cjs.map +1 -1
  482. package/dist/types/value/embed.d.cts +0 -1
  483. package/dist/types/value/embed.d.cts.map +1 -1
  484. package/dist/types/value/embed.d.ts +0 -1
  485. package/dist/types/value/embed.d.ts.map +1 -1
  486. package/dist/types/value/embed.js +1 -1
  487. package/dist/types/value/geoPoint.d.cts +0 -1
  488. package/dist/types/value/geoPoint.d.cts.map +1 -1
  489. package/dist/types/value/geoPoint.d.ts +0 -1
  490. package/dist/types/value/geoPoint.d.ts.map +1 -1
  491. package/dist/types/value/group.d.cts +0 -1
  492. package/dist/types/value/group.d.cts.map +1 -1
  493. package/dist/types/value/group.d.ts +0 -1
  494. package/dist/types/value/group.d.ts.map +1 -1
  495. package/dist/types/value/image.d.cts +0 -1
  496. package/dist/types/value/image.d.cts.map +1 -1
  497. package/dist/types/value/image.d.ts +0 -1
  498. package/dist/types/value/image.d.ts.map +1 -1
  499. package/dist/types/value/integration.d.cts +0 -1
  500. package/dist/types/value/integration.d.cts.map +1 -1
  501. package/dist/types/value/integration.d.ts +0 -1
  502. package/dist/types/value/integration.d.ts.map +1 -1
  503. package/dist/types/value/keyText.d.cts +0 -1
  504. package/dist/types/value/keyText.d.cts.map +1 -1
  505. package/dist/types/value/keyText.d.ts +0 -1
  506. package/dist/types/value/keyText.d.ts.map +1 -1
  507. package/dist/types/value/link.cjs +1 -2
  508. package/dist/types/value/link.cjs.map +1 -1
  509. package/dist/types/value/link.d.cts +0 -1
  510. package/dist/types/value/link.d.cts.map +1 -1
  511. package/dist/types/value/link.d.ts +0 -1
  512. package/dist/types/value/link.d.ts.map +1 -1
  513. package/dist/types/value/link.js +1 -1
  514. package/dist/types/value/linkToMedia.d.cts +0 -1
  515. package/dist/types/value/linkToMedia.d.cts.map +1 -1
  516. package/dist/types/value/linkToMedia.d.ts +0 -1
  517. package/dist/types/value/linkToMedia.d.ts.map +1 -1
  518. package/dist/types/value/number.d.cts +0 -1
  519. package/dist/types/value/number.d.cts.map +1 -1
  520. package/dist/types/value/number.d.ts +0 -1
  521. package/dist/types/value/number.d.ts.map +1 -1
  522. package/dist/types/value/richText.cjs +1 -2
  523. package/dist/types/value/richText.cjs.map +1 -1
  524. package/dist/types/value/richText.d.cts +0 -1
  525. package/dist/types/value/richText.d.cts.map +1 -1
  526. package/dist/types/value/richText.d.ts +0 -1
  527. package/dist/types/value/richText.d.ts.map +1 -1
  528. package/dist/types/value/richText.js +1 -1
  529. package/dist/types/value/select.d.cts +0 -1
  530. package/dist/types/value/select.d.cts.map +1 -1
  531. package/dist/types/value/select.d.ts +0 -1
  532. package/dist/types/value/select.d.ts.map +1 -1
  533. package/dist/types/value/sharedSlice.d.cts +0 -1
  534. package/dist/types/value/sharedSlice.d.cts.map +1 -1
  535. package/dist/types/value/sharedSlice.d.ts +0 -1
  536. package/dist/types/value/sharedSlice.d.ts.map +1 -1
  537. package/dist/types/value/sharedSliceVariation.d.cts +0 -1
  538. package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
  539. package/dist/types/value/sharedSliceVariation.d.ts +0 -1
  540. package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
  541. package/dist/types/value/slice.d.cts +0 -1
  542. package/dist/types/value/slice.d.cts.map +1 -1
  543. package/dist/types/value/slice.d.ts +0 -1
  544. package/dist/types/value/slice.d.ts.map +1 -1
  545. package/dist/types/value/sliceZone.d.cts +0 -1
  546. package/dist/types/value/sliceZone.d.cts.map +1 -1
  547. package/dist/types/value/sliceZone.d.ts +0 -1
  548. package/dist/types/value/sliceZone.d.ts.map +1 -1
  549. package/dist/types/value/table.d.cts +0 -1
  550. package/dist/types/value/table.d.cts.map +1 -1
  551. package/dist/types/value/table.d.ts +0 -1
  552. package/dist/types/value/table.d.ts.map +1 -1
  553. package/dist/types/value/timestamp.d.cts +0 -1
  554. package/dist/types/value/timestamp.d.cts.map +1 -1
  555. package/dist/types/value/timestamp.d.ts +0 -1
  556. package/dist/types/value/timestamp.d.ts.map +1 -1
  557. package/dist/types/value/title.d.cts +0 -1
  558. package/dist/types/value/title.d.cts.map +1 -1
  559. package/dist/types/value/title.d.ts +0 -1
  560. package/dist/types/value/title.d.ts.map +1 -1
  561. package/dist/types/value/types.d.cts +0 -1
  562. package/dist/types/value/types.d.cts.map +1 -1
  563. package/dist/types/value/types.d.ts +0 -1
  564. package/dist/types/value/types.d.ts.map +1 -1
  565. package/dist/types/webhook/apiUpdate.d.cts +0 -1
  566. package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
  567. package/dist/types/webhook/apiUpdate.d.ts +0 -1
  568. package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
  569. package/dist/types/webhook/testTrigger.d.cts +0 -1
  570. package/dist/types/webhook/testTrigger.d.cts.map +1 -1
  571. package/dist/types/webhook/testTrigger.d.ts +0 -1
  572. package/dist/types/webhook/testTrigger.d.ts.map +1 -1
  573. package/dist/types/webhook/types.cjs +1 -2
  574. package/dist/types/webhook/types.cjs.map +1 -1
  575. package/dist/types/webhook/types.d.cts.map +1 -1
  576. package/dist/types/webhook/types.d.ts.map +1 -1
  577. package/dist/types/webhook/types.js +1 -1
  578. package/package.json +12 -12
  579. package/src/WriteClient.ts +2 -2
  580. package/src/helpers/asImageWidthSrcSet.ts +1 -0
  581. package/src/lib/request.ts +7 -5
  582. package/dist/_virtual/rolldown_runtime.js +0 -13
@@ -1,11 +1,10 @@
1
- const require_richText = require('../types/value/richText.cjs');
2
- const require_link = require('../types/value/link.cjs');
3
- const require_Asset = require('../types/migration/Asset.cjs');
4
- const require_Document = require('../types/migration/Document.cjs');
5
- const require_isFilled = require('../helpers/isFilled.cjs');
6
- const require_isMigrationValue = require('./isMigrationValue.cjs');
7
- const require_getOptionalLinkProperties = require('./getOptionalLinkProperties.cjs');
8
-
1
+ const require_richText = require("../types/value/richText.cjs");
2
+ const require_link = require("../types/value/link.cjs");
3
+ const require_Asset = require("../types/migration/Asset.cjs");
4
+ const require_Document = require("../types/migration/Document.cjs");
5
+ const require_isFilled = require("../helpers/isFilled.cjs");
6
+ const require_isMigrationValue = require("./isMigrationValue.cjs");
7
+ const require_getOptionalLinkProperties = require("./getOptionalLinkProperties.cjs");
9
8
  //#region src/lib/resolveMigrationDocumentData.ts
10
9
  /**
11
10
  * Resolves a migration content relationship to a content relationship field.
@@ -46,9 +45,9 @@ async function resolveMigrationContentRelationship(relation) {
46
45
  *
47
46
  * @returns Resolved image field.
48
47
  */
49
- const resolveMigrationImage = (image$1, migration, withThumbnails) => {
48
+ const resolveMigrationImage = (image, migration, withThumbnails) => {
50
49
  var _migration$_assets$ge;
51
- const { id: master,...thumbnails } = image$1 instanceof require_Asset.PrismicMigrationAsset ? { id: image$1 } : image$1;
50
+ const { id: master, ...thumbnails } = image instanceof require_Asset.PrismicMigrationAsset ? { id: image } : image;
52
51
  const asset = (_migration$_assets$ge = migration._assets.get(master.config.id)) === null || _migration$_assets$ge === void 0 ? void 0 : _migration$_assets$ge.asset;
53
52
  const maybeInitialField = master.originalField;
54
53
  if (asset) {
@@ -89,12 +88,12 @@ const resolveMigrationImage = (image$1, migration, withThumbnails) => {
89
88
  *
90
89
  * @returns Resolved rich text image node.
91
90
  */
92
- const resolveMigrationRTImageNode = async (rtImageNode$1, migration) => {
93
- const image$1 = resolveMigrationImage(rtImageNode$1.id, migration);
94
- if (image$1) {
95
- const linkTo = await resolveMigrationDocumentData(rtImageNode$1.linkTo, migration);
91
+ const resolveMigrationRTImageNode = async (rtImageNode, migration) => {
92
+ const image = resolveMigrationImage(rtImageNode.id, migration);
93
+ if (image) {
94
+ const linkTo = await resolveMigrationDocumentData(rtImageNode.linkTo, migration);
96
95
  return {
97
- ...image$1,
96
+ ...image,
98
97
  type: require_richText.RichTextNodeType.image,
99
98
  linkTo: require_isFilled.link(linkTo) ? linkTo : void 0
100
99
  };
@@ -108,10 +107,10 @@ const resolveMigrationRTImageNode = async (rtImageNode$1, migration) => {
108
107
  *
109
108
  * @returns Resolved link to media field.
110
109
  */
111
- const resolveMigrationLinkToMedia = (linkToMedia$1, migration) => {
110
+ const resolveMigrationLinkToMedia = (linkToMedia, migration) => {
112
111
  var _migration$_assets$ge2;
113
- const asset = (_migration$_assets$ge2 = migration._assets.get(linkToMedia$1.id.config.id)) === null || _migration$_assets$ge2 === void 0 ? void 0 : _migration$_assets$ge2.asset;
114
- const optionalLinkProperties = require_getOptionalLinkProperties.getOptionalLinkProperties(linkToMedia$1);
112
+ const asset = (_migration$_assets$ge2 = migration._assets.get(linkToMedia.id.config.id)) === null || _migration$_assets$ge2 === void 0 ? void 0 : _migration$_assets$ge2.asset;
113
+ const optionalLinkProperties = require_getOptionalLinkProperties.getOptionalLinkProperties(linkToMedia);
115
114
  if (asset) return {
116
115
  ...optionalLinkProperties,
117
116
  id: asset.id,
@@ -149,8 +148,8 @@ async function resolveMigrationDocumentData(input, migration) {
149
148
  }
150
149
  return input;
151
150
  }
152
-
153
151
  //#endregion
154
152
  exports.resolveMigrationContentRelationship = resolveMigrationContentRelationship;
155
153
  exports.resolveMigrationDocumentData = resolveMigrationDocumentData;
154
+
156
155
  //# sourceMappingURL=resolveMigrationDocumentData.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveMigrationDocumentData.cjs","names":["PrismicMigrationDocument","LinkType","getOptionalLinkProperties","image","PrismicMigrationAsset","dimensions: FilledImageFieldImage[\"dimensions\"]","edit: FilledImageFieldImage[\"edit\"]","resolvedThumbnails: Record<string, FilledImageFieldImage>","rtImageNode","RichTextNodeType","linkToMedia","res: Record<PropertyKey, unknown>"],"sources":["../../src/lib/resolveMigrationDocumentData.ts"],"sourcesContent":["import type { MigrationLinkToMediaField } from \"../types/migration/Asset\"\nimport {\n\ttype MigrationImage,\n\ttype MigrationLinkToMedia,\n\ttype MigrationRTImageNode,\n\tPrismicMigrationAsset,\n} from \"../types/migration/Asset\"\nimport type {\n\tMigrationContentRelationship,\n\tMigrationContentRelationshipField,\n} from \"../types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"../types/migration/Document\"\nimport type { MaybeLink } from \"../types/migration/Link\"\nimport type { FilledImageFieldImage } from \"../types/value/image\"\nimport type { LinkField, OptionalLinkProperties } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTImageNode } from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\nimport * as isFilled from \"../helpers/isFilled\"\nimport type { Migration } from \"../Migration\"\n\nimport * as isMigration from \"./isMigrationValue\"\nimport { getOptionalLinkProperties } from \"./getOptionalLinkProperties\"\n\n/**\n * Resolves a migration content relationship to a content relationship field.\n *\n * @param relation - Content relationship to resolve.\n *\n * @returns Resolved content relationship field.\n */\nexport async function resolveMigrationContentRelationship(\n\trelation: MaybeLink<MigrationContentRelationship>,\n): Promise<MigrationContentRelationshipField & OptionalLinkProperties> {\n\tif (typeof relation === \"function\") {\n\t\treturn resolveMigrationContentRelationship(await relation())\n\t}\n\n\tif (relation instanceof PrismicMigrationDocument) {\n\t\treturn relation.document.id\n\t\t\t? { link_type: LinkType.Document, id: relation.document.id }\n\t\t\t: { link_type: LinkType.Any }\n\t}\n\n\tconst optionalLinkProperties =\n\t\trelation && \"link_type\" in relation\n\t\t\t? getOptionalLinkProperties(relation)\n\t\t\t: undefined\n\n\tif (relation) {\n\t\tif (\n\t\t\tisMigration.contentRelationship(relation.id) ||\n\t\t\ttypeof relation.id !== \"string\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\t...(await resolveMigrationContentRelationship(relation.id)),\n\t\t\t}\n\t\t}\n\n\t\t// This is only called when resolveMigrationContentRelationship recursively\n\t\t// calls itself from the statement above and the resolved content relation\n\t\t// is a Prismic document value.\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tlink_type: LinkType.Document,\n\t\t\tid: relation.id,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration image to an image field.\n *\n * @param migrationAsset - Asset to resolve.\n * @param migration - Migration instance.\n * @param withThumbnails - Whether to include thumbnails.\n *\n * @returns Resolved image field.\n */\nexport const resolveMigrationImage = (\n\timage: MigrationImage,\n\tmigration: Migration,\n\twithThumbnails?: boolean,\n): FilledImageFieldImage | undefined => {\n\tconst { id: master, ...thumbnails } =\n\t\timage instanceof PrismicMigrationAsset ? { id: image } : image\n\n\tconst asset = migration._assets.get(master.config.id)?.asset\n\tconst maybeInitialField = master.originalField\n\n\tif (asset) {\n\t\tconst parameters = (maybeInitialField?.url || asset.url).split(\"?\")[1]\n\t\tconst url = `${asset.url.split(\"?\")[0]}${parameters ? `?${parameters}` : \"\"}`\n\t\tconst dimensions: FilledImageFieldImage[\"dimensions\"] = {\n\t\t\twidth: asset.width!,\n\t\t\theight: asset.height!,\n\t\t}\n\t\tconst edit: FilledImageFieldImage[\"edit\"] =\n\t\t\tmaybeInitialField && \"edit\" in maybeInitialField\n\t\t\t\t? maybeInitialField?.edit\n\t\t\t\t: { x: 0, y: 0, zoom: 1, background: \"transparent\" }\n\n\t\t// We give priority to the asset's specific alt text, then the image's general alt text\n\t\tconst alt = master.config.alt || asset.alt || null\n\n\t\tconst resolvedThumbnails: Record<string, FilledImageFieldImage> = {}\n\t\tif (withThumbnails) {\n\t\t\tfor (const [name, thumbnail] of Object.entries(thumbnails)) {\n\t\t\t\tconst resolvedThumbnail = resolveMigrationImage(thumbnail, migration)\n\t\t\t\tif (resolvedThumbnail) {\n\t\t\t\t\tresolvedThumbnails[name] = resolvedThumbnail\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tedit,\n\t\t\talt: alt,\n\t\t\tcopyright: asset.credits || null,\n\t\t\t...resolvedThumbnails,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration rich text image node to a regular rich text image node.\n *\n * @param rtImageNode - Migration rich text image node to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved rich text image node.\n */\nexport const resolveMigrationRTImageNode = async (\n\trtImageNode: MigrationRTImageNode,\n\tmigration: Migration,\n): Promise<RTImageNode | undefined> => {\n\tconst image = resolveMigrationImage(rtImageNode.id, migration)\n\n\tif (image) {\n\t\tconst linkTo = (await resolveMigrationDocumentData(\n\t\t\trtImageNode.linkTo,\n\t\t\tmigration,\n\t\t)) as LinkField\n\n\t\treturn {\n\t\t\t...image,\n\t\t\ttype: RichTextNodeType.image,\n\t\t\tlinkTo: isFilled.link(linkTo) ? linkTo : undefined,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration link to media to a regular link to media field.\n *\n * @param linkToMedia - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved link to media field.\n */\nexport const resolveMigrationLinkToMedia = (\n\tlinkToMedia: MaybeLink<MigrationLinkToMedia>,\n\tmigration: Migration,\n): MigrationLinkToMediaField => {\n\tconst asset = migration._assets.get(linkToMedia.id.config.id)?.asset\n\tconst optionalLinkProperties = getOptionalLinkProperties(linkToMedia)\n\n\tif (asset) {\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tid: asset.id,\n\t\t\tlink_type: LinkType.Media,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration document data to actual data ready to be sent to the\n * Migration API.\n *\n * @param input - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved data.\n */\nexport async function resolveMigrationDocumentData(\n\tinput: unknown,\n\tmigration: Migration,\n): Promise<unknown> {\n\t// Migration fields\n\tif (isMigration.contentRelationship(input)) {\n\t\treturn resolveMigrationContentRelationship(input)\n\t}\n\n\tif (isMigration.image(input)) {\n\t\treturn resolveMigrationImage(input, migration, true)\n\t}\n\n\tif (isMigration.linkToMedia(input)) {\n\t\treturn resolveMigrationLinkToMedia(input, migration)\n\t}\n\n\tif (isMigration.rtImageNode(input)) {\n\t\treturn resolveMigrationRTImageNode(input, migration)\n\t}\n\n\tif (typeof input === \"function\") {\n\t\treturn await resolveMigrationDocumentData(await input(), migration)\n\t}\n\n\t// Object traversing\n\tif (Array.isArray(input)) {\n\t\tconst res = []\n\n\t\tfor (const element of input) {\n\t\t\tres.push(await resolveMigrationDocumentData(element, migration))\n\t\t}\n\n\t\treturn res.filter(Boolean)\n\t}\n\n\tif (input && typeof input === \"object\") {\n\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\tfor (const key in input) {\n\t\t\tres[key] = await resolveMigrationDocumentData(\n\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\tmigration,\n\t\t\t)\n\t\t}\n\n\t\treturn res\n\t}\n\n\t// Primitives\n\treturn input\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,eAAsB,oCACrB,UACsE;AACtE,KAAI,OAAO,aAAa,WACvB,QAAO,oCAAoC,MAAM,U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MACjB,KAAI,OAAO,MAAM,6BAChB,MAAM,MACN,UACA;AAGF,SAAO;;AAIR,QAAO"}
1
+ {"version":3,"file":"resolveMigrationDocumentData.cjs","names":["PrismicMigrationDocument","LinkType","getOptionalLinkProperties","PrismicMigrationAsset","RichTextNodeType"],"sources":["../../src/lib/resolveMigrationDocumentData.ts"],"sourcesContent":["import type { MigrationLinkToMediaField } from \"../types/migration/Asset\"\nimport {\n\ttype MigrationImage,\n\ttype MigrationLinkToMedia,\n\ttype MigrationRTImageNode,\n\tPrismicMigrationAsset,\n} from \"../types/migration/Asset\"\nimport type {\n\tMigrationContentRelationship,\n\tMigrationContentRelationshipField,\n} from \"../types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"../types/migration/Document\"\nimport type { MaybeLink } from \"../types/migration/Link\"\nimport type { FilledImageFieldImage } from \"../types/value/image\"\nimport type { LinkField, OptionalLinkProperties } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTImageNode } from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\nimport * as isFilled from \"../helpers/isFilled\"\nimport type { Migration } from \"../Migration\"\n\nimport * as isMigration from \"./isMigrationValue\"\nimport { getOptionalLinkProperties } from \"./getOptionalLinkProperties\"\n\n/**\n * Resolves a migration content relationship to a content relationship field.\n *\n * @param relation - Content relationship to resolve.\n *\n * @returns Resolved content relationship field.\n */\nexport async function resolveMigrationContentRelationship(\n\trelation: MaybeLink<MigrationContentRelationship>,\n): Promise<MigrationContentRelationshipField & OptionalLinkProperties> {\n\tif (typeof relation === \"function\") {\n\t\treturn resolveMigrationContentRelationship(await relation())\n\t}\n\n\tif (relation instanceof PrismicMigrationDocument) {\n\t\treturn relation.document.id\n\t\t\t? { link_type: LinkType.Document, id: relation.document.id }\n\t\t\t: { link_type: LinkType.Any }\n\t}\n\n\tconst optionalLinkProperties =\n\t\trelation && \"link_type\" in relation\n\t\t\t? getOptionalLinkProperties(relation)\n\t\t\t: undefined\n\n\tif (relation) {\n\t\tif (\n\t\t\tisMigration.contentRelationship(relation.id) ||\n\t\t\ttypeof relation.id !== \"string\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\t...(await resolveMigrationContentRelationship(relation.id)),\n\t\t\t}\n\t\t}\n\n\t\t// This is only called when resolveMigrationContentRelationship recursively\n\t\t// calls itself from the statement above and the resolved content relation\n\t\t// is a Prismic document value.\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tlink_type: LinkType.Document,\n\t\t\tid: relation.id,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration image to an image field.\n *\n * @param migrationAsset - Asset to resolve.\n * @param migration - Migration instance.\n * @param withThumbnails - Whether to include thumbnails.\n *\n * @returns Resolved image field.\n */\nexport const resolveMigrationImage = (\n\timage: MigrationImage,\n\tmigration: Migration,\n\twithThumbnails?: boolean,\n): FilledImageFieldImage | undefined => {\n\tconst { id: master, ...thumbnails } =\n\t\timage instanceof PrismicMigrationAsset ? { id: image } : image\n\n\tconst asset = migration._assets.get(master.config.id)?.asset\n\tconst maybeInitialField = master.originalField\n\n\tif (asset) {\n\t\tconst parameters = (maybeInitialField?.url || asset.url).split(\"?\")[1]\n\t\tconst url = `${asset.url.split(\"?\")[0]}${parameters ? `?${parameters}` : \"\"}`\n\t\tconst dimensions: FilledImageFieldImage[\"dimensions\"] = {\n\t\t\twidth: asset.width!,\n\t\t\theight: asset.height!,\n\t\t}\n\t\tconst edit: FilledImageFieldImage[\"edit\"] =\n\t\t\tmaybeInitialField && \"edit\" in maybeInitialField\n\t\t\t\t? maybeInitialField?.edit\n\t\t\t\t: { x: 0, y: 0, zoom: 1, background: \"transparent\" }\n\n\t\t// We give priority to the asset's specific alt text, then the image's general alt text\n\t\tconst alt = master.config.alt || asset.alt || null\n\n\t\tconst resolvedThumbnails: Record<string, FilledImageFieldImage> = {}\n\t\tif (withThumbnails) {\n\t\t\tfor (const [name, thumbnail] of Object.entries(thumbnails)) {\n\t\t\t\tconst resolvedThumbnail = resolveMigrationImage(thumbnail, migration)\n\t\t\t\tif (resolvedThumbnail) {\n\t\t\t\t\tresolvedThumbnails[name] = resolvedThumbnail\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tedit,\n\t\t\talt: alt,\n\t\t\tcopyright: asset.credits || null,\n\t\t\t...resolvedThumbnails,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration rich text image node to a regular rich text image node.\n *\n * @param rtImageNode - Migration rich text image node to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved rich text image node.\n */\nexport const resolveMigrationRTImageNode = async (\n\trtImageNode: MigrationRTImageNode,\n\tmigration: Migration,\n): Promise<RTImageNode | undefined> => {\n\tconst image = resolveMigrationImage(rtImageNode.id, migration)\n\n\tif (image) {\n\t\tconst linkTo = (await resolveMigrationDocumentData(\n\t\t\trtImageNode.linkTo,\n\t\t\tmigration,\n\t\t)) as LinkField\n\n\t\treturn {\n\t\t\t...image,\n\t\t\ttype: RichTextNodeType.image,\n\t\t\tlinkTo: isFilled.link(linkTo) ? linkTo : undefined,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration link to media to a regular link to media field.\n *\n * @param linkToMedia - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved link to media field.\n */\nexport const resolveMigrationLinkToMedia = (\n\tlinkToMedia: MaybeLink<MigrationLinkToMedia>,\n\tmigration: Migration,\n): MigrationLinkToMediaField => {\n\tconst asset = migration._assets.get(linkToMedia.id.config.id)?.asset\n\tconst optionalLinkProperties = getOptionalLinkProperties(linkToMedia)\n\n\tif (asset) {\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tid: asset.id,\n\t\t\tlink_type: LinkType.Media,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration document data to actual data ready to be sent to the\n * Migration API.\n *\n * @param input - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved data.\n */\nexport async function resolveMigrationDocumentData(\n\tinput: unknown,\n\tmigration: Migration,\n): Promise<unknown> {\n\t// Migration fields\n\tif (isMigration.contentRelationship(input)) {\n\t\treturn resolveMigrationContentRelationship(input)\n\t}\n\n\tif (isMigration.image(input)) {\n\t\treturn resolveMigrationImage(input, migration, true)\n\t}\n\n\tif (isMigration.linkToMedia(input)) {\n\t\treturn resolveMigrationLinkToMedia(input, migration)\n\t}\n\n\tif (isMigration.rtImageNode(input)) {\n\t\treturn resolveMigrationRTImageNode(input, migration)\n\t}\n\n\tif (typeof input === \"function\") {\n\t\treturn await resolveMigrationDocumentData(await input(), migration)\n\t}\n\n\t// Object traversing\n\tif (Array.isArray(input)) {\n\t\tconst res = []\n\n\t\tfor (const element of input) {\n\t\t\tres.push(await resolveMigrationDocumentData(element, migration))\n\t\t}\n\n\t\treturn res.filter(Boolean)\n\t}\n\n\tif (input && typeof input === \"object\") {\n\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\tfor (const key in input) {\n\t\t\tres[key] = await resolveMigrationDocumentData(\n\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\tmigration,\n\t\t\t)\n\t\t}\n\n\t\treturn res\n\t}\n\n\t// Primitives\n\treturn input\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,eAAsB,oCACrB,UACsE;AACtE,KAAI,OAAO,aAAa,WACvB,QAAO,oCAAoC,MAAM,UAAU,CAAC;AAG7D,KAAI,oBAAoBA,iBAAAA,yBACvB,QAAO,SAAS,SAAS,KACtB;EAAE,WAAWC,aAAAA,SAAS;EAAU,IAAI,SAAS,SAAS;EAAI,GAC1D,EAAE,WAAWA,aAAAA,SAAS,KAAK;CAG/B,MAAM,yBACL,YAAY,eAAe,WAC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U,CAAC;AAGjE,SAAO,IAAI,OAAO,QAAQ;;AAG3B,KAAI,SAAS,OAAO,UAAU,UAAU;EACvC,MAAM,MAAoC,EAAE;AAE5C,OAAK,MAAM,OAAO,MACjB,KAAI,OAAO,MAAM,6BAChB,MAAM,MACN,UACA;AAGF,SAAO;;AAIR,QAAO"}
@@ -5,7 +5,6 @@ import { PrismicMigrationDocument } from "../types/migration/Document.js";
5
5
  import { link } from "../helpers/isFilled.js";
6
6
  import { contentRelationship, image, linkToMedia, rtImageNode } from "./isMigrationValue.js";
7
7
  import { getOptionalLinkProperties } from "./getOptionalLinkProperties.js";
8
-
9
8
  //#region src/lib/resolveMigrationDocumentData.ts
10
9
  /**
11
10
  * Resolves a migration content relationship to a content relationship field.
@@ -46,9 +45,9 @@ async function resolveMigrationContentRelationship(relation) {
46
45
  *
47
46
  * @returns Resolved image field.
48
47
  */
49
- const resolveMigrationImage = (image$1, migration, withThumbnails) => {
48
+ const resolveMigrationImage = (image, migration, withThumbnails) => {
50
49
  var _migration$_assets$ge;
51
- const { id: master,...thumbnails } = image$1 instanceof PrismicMigrationAsset ? { id: image$1 } : image$1;
50
+ const { id: master, ...thumbnails } = image instanceof PrismicMigrationAsset ? { id: image } : image;
52
51
  const asset = (_migration$_assets$ge = migration._assets.get(master.config.id)) === null || _migration$_assets$ge === void 0 ? void 0 : _migration$_assets$ge.asset;
53
52
  const maybeInitialField = master.originalField;
54
53
  if (asset) {
@@ -89,12 +88,12 @@ const resolveMigrationImage = (image$1, migration, withThumbnails) => {
89
88
  *
90
89
  * @returns Resolved rich text image node.
91
90
  */
92
- const resolveMigrationRTImageNode = async (rtImageNode$1, migration) => {
93
- const image$1 = resolveMigrationImage(rtImageNode$1.id, migration);
94
- if (image$1) {
95
- const linkTo = await resolveMigrationDocumentData(rtImageNode$1.linkTo, migration);
91
+ const resolveMigrationRTImageNode = async (rtImageNode, migration) => {
92
+ const image = resolveMigrationImage(rtImageNode.id, migration);
93
+ if (image) {
94
+ const linkTo = await resolveMigrationDocumentData(rtImageNode.linkTo, migration);
96
95
  return {
97
- ...image$1,
96
+ ...image,
98
97
  type: RichTextNodeType.image,
99
98
  linkTo: link(linkTo) ? linkTo : void 0
100
99
  };
@@ -108,10 +107,10 @@ const resolveMigrationRTImageNode = async (rtImageNode$1, migration) => {
108
107
  *
109
108
  * @returns Resolved link to media field.
110
109
  */
111
- const resolveMigrationLinkToMedia = (linkToMedia$1, migration) => {
110
+ const resolveMigrationLinkToMedia = (linkToMedia, migration) => {
112
111
  var _migration$_assets$ge2;
113
- const asset = (_migration$_assets$ge2 = migration._assets.get(linkToMedia$1.id.config.id)) === null || _migration$_assets$ge2 === void 0 ? void 0 : _migration$_assets$ge2.asset;
114
- const optionalLinkProperties = getOptionalLinkProperties(linkToMedia$1);
112
+ const asset = (_migration$_assets$ge2 = migration._assets.get(linkToMedia.id.config.id)) === null || _migration$_assets$ge2 === void 0 ? void 0 : _migration$_assets$ge2.asset;
113
+ const optionalLinkProperties = getOptionalLinkProperties(linkToMedia);
115
114
  if (asset) return {
116
115
  ...optionalLinkProperties,
117
116
  id: asset.id,
@@ -149,7 +148,7 @@ async function resolveMigrationDocumentData(input, migration) {
149
148
  }
150
149
  return input;
151
150
  }
152
-
153
151
  //#endregion
154
152
  export { resolveMigrationContentRelationship, resolveMigrationDocumentData };
153
+
155
154
  //# sourceMappingURL=resolveMigrationDocumentData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveMigrationDocumentData.js","names":["isMigration.contentRelationship","image","dimensions: FilledImageFieldImage[\"dimensions\"]","edit: FilledImageFieldImage[\"edit\"]","resolvedThumbnails: Record<string, FilledImageFieldImage>","rtImageNode","isFilled.link","linkToMedia","isMigration.image","isMigration.linkToMedia","isMigration.rtImageNode","res: Record<PropertyKey, unknown>"],"sources":["../../src/lib/resolveMigrationDocumentData.ts"],"sourcesContent":["import type { MigrationLinkToMediaField } from \"../types/migration/Asset\"\nimport {\n\ttype MigrationImage,\n\ttype MigrationLinkToMedia,\n\ttype MigrationRTImageNode,\n\tPrismicMigrationAsset,\n} from \"../types/migration/Asset\"\nimport type {\n\tMigrationContentRelationship,\n\tMigrationContentRelationshipField,\n} from \"../types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"../types/migration/Document\"\nimport type { MaybeLink } from \"../types/migration/Link\"\nimport type { FilledImageFieldImage } from \"../types/value/image\"\nimport type { LinkField, OptionalLinkProperties } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTImageNode } from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\nimport * as isFilled from \"../helpers/isFilled\"\nimport type { Migration } from \"../Migration\"\n\nimport * as isMigration from \"./isMigrationValue\"\nimport { getOptionalLinkProperties } from \"./getOptionalLinkProperties\"\n\n/**\n * Resolves a migration content relationship to a content relationship field.\n *\n * @param relation - Content relationship to resolve.\n *\n * @returns Resolved content relationship field.\n */\nexport async function resolveMigrationContentRelationship(\n\trelation: MaybeLink<MigrationContentRelationship>,\n): Promise<MigrationContentRelationshipField & OptionalLinkProperties> {\n\tif (typeof relation === \"function\") {\n\t\treturn resolveMigrationContentRelationship(await relation())\n\t}\n\n\tif (relation instanceof PrismicMigrationDocument) {\n\t\treturn relation.document.id\n\t\t\t? { link_type: LinkType.Document, id: relation.document.id }\n\t\t\t: { link_type: LinkType.Any }\n\t}\n\n\tconst optionalLinkProperties =\n\t\trelation && \"link_type\" in relation\n\t\t\t? getOptionalLinkProperties(relation)\n\t\t\t: undefined\n\n\tif (relation) {\n\t\tif (\n\t\t\tisMigration.contentRelationship(relation.id) ||\n\t\t\ttypeof relation.id !== \"string\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\t...(await resolveMigrationContentRelationship(relation.id)),\n\t\t\t}\n\t\t}\n\n\t\t// This is only called when resolveMigrationContentRelationship recursively\n\t\t// calls itself from the statement above and the resolved content relation\n\t\t// is a Prismic document value.\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tlink_type: LinkType.Document,\n\t\t\tid: relation.id,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration image to an image field.\n *\n * @param migrationAsset - Asset to resolve.\n * @param migration - Migration instance.\n * @param withThumbnails - Whether to include thumbnails.\n *\n * @returns Resolved image field.\n */\nexport const resolveMigrationImage = (\n\timage: MigrationImage,\n\tmigration: Migration,\n\twithThumbnails?: boolean,\n): FilledImageFieldImage | undefined => {\n\tconst { id: master, ...thumbnails } =\n\t\timage instanceof PrismicMigrationAsset ? { id: image } : image\n\n\tconst asset = migration._assets.get(master.config.id)?.asset\n\tconst maybeInitialField = master.originalField\n\n\tif (asset) {\n\t\tconst parameters = (maybeInitialField?.url || asset.url).split(\"?\")[1]\n\t\tconst url = `${asset.url.split(\"?\")[0]}${parameters ? `?${parameters}` : \"\"}`\n\t\tconst dimensions: FilledImageFieldImage[\"dimensions\"] = {\n\t\t\twidth: asset.width!,\n\t\t\theight: asset.height!,\n\t\t}\n\t\tconst edit: FilledImageFieldImage[\"edit\"] =\n\t\t\tmaybeInitialField && \"edit\" in maybeInitialField\n\t\t\t\t? maybeInitialField?.edit\n\t\t\t\t: { x: 0, y: 0, zoom: 1, background: \"transparent\" }\n\n\t\t// We give priority to the asset's specific alt text, then the image's general alt text\n\t\tconst alt = master.config.alt || asset.alt || null\n\n\t\tconst resolvedThumbnails: Record<string, FilledImageFieldImage> = {}\n\t\tif (withThumbnails) {\n\t\t\tfor (const [name, thumbnail] of Object.entries(thumbnails)) {\n\t\t\t\tconst resolvedThumbnail = resolveMigrationImage(thumbnail, migration)\n\t\t\t\tif (resolvedThumbnail) {\n\t\t\t\t\tresolvedThumbnails[name] = resolvedThumbnail\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tedit,\n\t\t\talt: alt,\n\t\t\tcopyright: asset.credits || null,\n\t\t\t...resolvedThumbnails,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration rich text image node to a regular rich text image node.\n *\n * @param rtImageNode - Migration rich text image node to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved rich text image node.\n */\nexport const resolveMigrationRTImageNode = async (\n\trtImageNode: MigrationRTImageNode,\n\tmigration: Migration,\n): Promise<RTImageNode | undefined> => {\n\tconst image = resolveMigrationImage(rtImageNode.id, migration)\n\n\tif (image) {\n\t\tconst linkTo = (await resolveMigrationDocumentData(\n\t\t\trtImageNode.linkTo,\n\t\t\tmigration,\n\t\t)) as LinkField\n\n\t\treturn {\n\t\t\t...image,\n\t\t\ttype: RichTextNodeType.image,\n\t\t\tlinkTo: isFilled.link(linkTo) ? linkTo : undefined,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration link to media to a regular link to media field.\n *\n * @param linkToMedia - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved link to media field.\n */\nexport const resolveMigrationLinkToMedia = (\n\tlinkToMedia: MaybeLink<MigrationLinkToMedia>,\n\tmigration: Migration,\n): MigrationLinkToMediaField => {\n\tconst asset = migration._assets.get(linkToMedia.id.config.id)?.asset\n\tconst optionalLinkProperties = getOptionalLinkProperties(linkToMedia)\n\n\tif (asset) {\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tid: asset.id,\n\t\t\tlink_type: LinkType.Media,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration document data to actual data ready to be sent to the\n * Migration API.\n *\n * @param input - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved data.\n */\nexport async function resolveMigrationDocumentData(\n\tinput: unknown,\n\tmigration: Migration,\n): Promise<unknown> {\n\t// Migration fields\n\tif (isMigration.contentRelationship(input)) {\n\t\treturn resolveMigrationContentRelationship(input)\n\t}\n\n\tif (isMigration.image(input)) {\n\t\treturn resolveMigrationImage(input, migration, true)\n\t}\n\n\tif (isMigration.linkToMedia(input)) {\n\t\treturn resolveMigrationLinkToMedia(input, migration)\n\t}\n\n\tif (isMigration.rtImageNode(input)) {\n\t\treturn resolveMigrationRTImageNode(input, migration)\n\t}\n\n\tif (typeof input === \"function\") {\n\t\treturn await resolveMigrationDocumentData(await input(), migration)\n\t}\n\n\t// Object traversing\n\tif (Array.isArray(input)) {\n\t\tconst res = []\n\n\t\tfor (const element of input) {\n\t\t\tres.push(await resolveMigrationDocumentData(element, migration))\n\t\t}\n\n\t\treturn res.filter(Boolean)\n\t}\n\n\tif (input && typeof input === \"object\") {\n\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\tfor (const key in input) {\n\t\t\tres[key] = await resolveMigrationDocumentData(\n\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\tmigration,\n\t\t\t)\n\t\t}\n\n\t\treturn res\n\t}\n\n\t// Primitives\n\treturn input\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,eAAsB,oCACrB,UACsE;AACtE,KAAI,OAAO,aAAa,WACvB,QAAO,oCAAoC,MAAM,UAAU,CAAC;AAG7D,KAAI,oBAAoB,yBACvB,QAAO,SAAS,SAAS,KACtB;EAAE,WAAW,SAAS;EAAU,IAAI,SAAS,SAAS;EAAI,GAC1D,EAAE,WAAW,SAAS,KAAK;CAG/B,MAAM,yBACL,YAAY,eAAe,WACxB,0BAA0B,SAAS,GACnC;AAEJ,KAAI,UAAU;AACb,MACCA,oBAAgC,SAAS,GAAG,IAC5C,OAAO,SAAS,OAAO,SAEvB,QAAO;GACN,GAAG;GACH,GAAI,MAAM,oCAAoC,SAAS,GAAG;GAC1D;AAMF,SAAO;GACN,GAAG;GACH,WAAW,SAAS;GACpB,IAAI,SAAS;GACb;;AAGF,QAAO;EACN,GAAG;EACH,WAAW,SAAS;EACpB;;;;;;;;;;;AAYF,MAAa,yBACZ,SACA,WACA,mBACuC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A,cAAY;AAErE,KAAI,MACH,QAAO;EACN,GAAG;EACH,IAAI,MAAM;EACV,WAAW,SAAS;EACpB;AAGF,QAAO;EACN,GAAG;EACH,WAAW,SAAS;EACpB;;;;;;;;;;;AAYF,eAAsB,6BACrB,OACA,WACmB;AAEnB,KAAIP,oBAAgC,MAAM,CACzC,QAAO,oCAAoC,MAAM;AAGlD,KAAIQ,MAAkB,MAAM,CAC3B,QAAO,sBAAsB,OAAO,WAAW,KAAK;AAGrD,KAAIC,YAAwB,MAAM,CACjC,QAAO,4BAA4B,OAAO,UAAU;AAGrD,KAAIC,YAAwB,MAAM,CACjC,QAAO,4BAA4B,OAAO,UAAU;AAGrD,KAAI,OAAO,UAAU,WACpB,QAAO,MAAM,6BAA6B,MAAM,OAAO,EAAE,UAAU;AAIpE,KAAI,MAAM,QAAQ,MAAM,EAAE;EACzB,MAAM,MAAM,EAAE;AAEd,OAAK,MAAM,WAAW,MACrB,KAAI,KAAK,MAAM,6BAA6B,SAAS,UAAU,CAAC;AAGjE,SAAO,IAAI,OAAO,QAAQ;;AAG3B,KAAI,SAAS,OAAO,UAAU,UAAU;EACvC,MAAMC,MAAoC,EAAE;AAE5C,OAAK,MAAM,OAAO,MACjB,KAAI,OAAO,MAAM,6BAChB,MAAM,MACN,UACA;AAGF,SAAO;;AAIR,QAAO"}
1
+ {"version":3,"file":"resolveMigrationDocumentData.js","names":["isMigration.contentRelationship","isFilled.link","isMigration.image","isMigration.linkToMedia","isMigration.rtImageNode"],"sources":["../../src/lib/resolveMigrationDocumentData.ts"],"sourcesContent":["import type { MigrationLinkToMediaField } from \"../types/migration/Asset\"\nimport {\n\ttype MigrationImage,\n\ttype MigrationLinkToMedia,\n\ttype MigrationRTImageNode,\n\tPrismicMigrationAsset,\n} from \"../types/migration/Asset\"\nimport type {\n\tMigrationContentRelationship,\n\tMigrationContentRelationshipField,\n} from \"../types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"../types/migration/Document\"\nimport type { MaybeLink } from \"../types/migration/Link\"\nimport type { FilledImageFieldImage } from \"../types/value/image\"\nimport type { LinkField, OptionalLinkProperties } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTImageNode } from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\nimport * as isFilled from \"../helpers/isFilled\"\nimport type { Migration } from \"../Migration\"\n\nimport * as isMigration from \"./isMigrationValue\"\nimport { getOptionalLinkProperties } from \"./getOptionalLinkProperties\"\n\n/**\n * Resolves a migration content relationship to a content relationship field.\n *\n * @param relation - Content relationship to resolve.\n *\n * @returns Resolved content relationship field.\n */\nexport async function resolveMigrationContentRelationship(\n\trelation: MaybeLink<MigrationContentRelationship>,\n): Promise<MigrationContentRelationshipField & OptionalLinkProperties> {\n\tif (typeof relation === \"function\") {\n\t\treturn resolveMigrationContentRelationship(await relation())\n\t}\n\n\tif (relation instanceof PrismicMigrationDocument) {\n\t\treturn relation.document.id\n\t\t\t? { link_type: LinkType.Document, id: relation.document.id }\n\t\t\t: { link_type: LinkType.Any }\n\t}\n\n\tconst optionalLinkProperties =\n\t\trelation && \"link_type\" in relation\n\t\t\t? getOptionalLinkProperties(relation)\n\t\t\t: undefined\n\n\tif (relation) {\n\t\tif (\n\t\t\tisMigration.contentRelationship(relation.id) ||\n\t\t\ttypeof relation.id !== \"string\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\t...(await resolveMigrationContentRelationship(relation.id)),\n\t\t\t}\n\t\t}\n\n\t\t// This is only called when resolveMigrationContentRelationship recursively\n\t\t// calls itself from the statement above and the resolved content relation\n\t\t// is a Prismic document value.\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tlink_type: LinkType.Document,\n\t\t\tid: relation.id,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration image to an image field.\n *\n * @param migrationAsset - Asset to resolve.\n * @param migration - Migration instance.\n * @param withThumbnails - Whether to include thumbnails.\n *\n * @returns Resolved image field.\n */\nexport const resolveMigrationImage = (\n\timage: MigrationImage,\n\tmigration: Migration,\n\twithThumbnails?: boolean,\n): FilledImageFieldImage | undefined => {\n\tconst { id: master, ...thumbnails } =\n\t\timage instanceof PrismicMigrationAsset ? { id: image } : image\n\n\tconst asset = migration._assets.get(master.config.id)?.asset\n\tconst maybeInitialField = master.originalField\n\n\tif (asset) {\n\t\tconst parameters = (maybeInitialField?.url || asset.url).split(\"?\")[1]\n\t\tconst url = `${asset.url.split(\"?\")[0]}${parameters ? `?${parameters}` : \"\"}`\n\t\tconst dimensions: FilledImageFieldImage[\"dimensions\"] = {\n\t\t\twidth: asset.width!,\n\t\t\theight: asset.height!,\n\t\t}\n\t\tconst edit: FilledImageFieldImage[\"edit\"] =\n\t\t\tmaybeInitialField && \"edit\" in maybeInitialField\n\t\t\t\t? maybeInitialField?.edit\n\t\t\t\t: { x: 0, y: 0, zoom: 1, background: \"transparent\" }\n\n\t\t// We give priority to the asset's specific alt text, then the image's general alt text\n\t\tconst alt = master.config.alt || asset.alt || null\n\n\t\tconst resolvedThumbnails: Record<string, FilledImageFieldImage> = {}\n\t\tif (withThumbnails) {\n\t\t\tfor (const [name, thumbnail] of Object.entries(thumbnails)) {\n\t\t\t\tconst resolvedThumbnail = resolveMigrationImage(thumbnail, migration)\n\t\t\t\tif (resolvedThumbnail) {\n\t\t\t\t\tresolvedThumbnails[name] = resolvedThumbnail\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tedit,\n\t\t\talt: alt,\n\t\t\tcopyright: asset.credits || null,\n\t\t\t...resolvedThumbnails,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration rich text image node to a regular rich text image node.\n *\n * @param rtImageNode - Migration rich text image node to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved rich text image node.\n */\nexport const resolveMigrationRTImageNode = async (\n\trtImageNode: MigrationRTImageNode,\n\tmigration: Migration,\n): Promise<RTImageNode | undefined> => {\n\tconst image = resolveMigrationImage(rtImageNode.id, migration)\n\n\tif (image) {\n\t\tconst linkTo = (await resolveMigrationDocumentData(\n\t\t\trtImageNode.linkTo,\n\t\t\tmigration,\n\t\t)) as LinkField\n\n\t\treturn {\n\t\t\t...image,\n\t\t\ttype: RichTextNodeType.image,\n\t\t\tlinkTo: isFilled.link(linkTo) ? linkTo : undefined,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration link to media to a regular link to media field.\n *\n * @param linkToMedia - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved link to media field.\n */\nexport const resolveMigrationLinkToMedia = (\n\tlinkToMedia: MaybeLink<MigrationLinkToMedia>,\n\tmigration: Migration,\n): MigrationLinkToMediaField => {\n\tconst asset = migration._assets.get(linkToMedia.id.config.id)?.asset\n\tconst optionalLinkProperties = getOptionalLinkProperties(linkToMedia)\n\n\tif (asset) {\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tid: asset.id,\n\t\t\tlink_type: LinkType.Media,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration document data to actual data ready to be sent to the\n * Migration API.\n *\n * @param input - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved data.\n */\nexport async function resolveMigrationDocumentData(\n\tinput: unknown,\n\tmigration: Migration,\n): Promise<unknown> {\n\t// Migration fields\n\tif (isMigration.contentRelationship(input)) {\n\t\treturn resolveMigrationContentRelationship(input)\n\t}\n\n\tif (isMigration.image(input)) {\n\t\treturn resolveMigrationImage(input, migration, true)\n\t}\n\n\tif (isMigration.linkToMedia(input)) {\n\t\treturn resolveMigrationLinkToMedia(input, migration)\n\t}\n\n\tif (isMigration.rtImageNode(input)) {\n\t\treturn resolveMigrationRTImageNode(input, migration)\n\t}\n\n\tif (typeof input === \"function\") {\n\t\treturn await resolveMigrationDocumentData(await input(), migration)\n\t}\n\n\t// Object traversing\n\tif (Array.isArray(input)) {\n\t\tconst res = []\n\n\t\tfor (const element of input) {\n\t\t\tres.push(await resolveMigrationDocumentData(element, migration))\n\t\t}\n\n\t\treturn res.filter(Boolean)\n\t}\n\n\tif (input && typeof input === \"object\") {\n\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\tfor (const key in input) {\n\t\t\tres[key] = await resolveMigrationDocumentData(\n\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\tmigration,\n\t\t\t)\n\t\t}\n\n\t\treturn res\n\t}\n\n\t// Primitives\n\treturn input\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,eAAsB,oCACrB,UACsE;AACtE,KAAI,OAAO,aAAa,WACvB,QAAO,oCAAoC,MAAM,UAAU,CAAC;AAG7D,KAAI,oBAAoB,yBACvB,QAAO,SAAS,SAAS,KACtB;EAAE,WAAW,SAAS;EAAU,IAAI,SAAS,SAAS;EAAI,GAC1D,EAAE,WAAW,SAAS,KAAK;CAG/B,MAAM,yBACL,YAAY,eAAe,WACxB,0BAA0B,SAAS,GACnC,KAAA;AAEJ,KAAI,UAAU;AACb,MACCA,oBAAgC,SAAS,GAAG,IAC5C,OAAO,SAAS,OAAO,SAEvB,QAAO;GACN,GAAG;GACH,GAAI,MAAM,oCAAoC,SAAS,GAAG;GAC1D;AAMF,SAAO;GACN,GAAG;GACH,WAAW,SAAS;GACpB,IAAI,SAAS;GACb;;AAGF,QAAO;EACN,GAAG;EACH,WAAW,SAAS;EACpB;;;;;;;;;;;AAYF,MAAa,yBACZ,OACA,WACA,mBACuC;;CACvC,MAAM,EAAE,IAAI,QAAQ,GAAG,eACtB,iBAAiB,wBAAwB,EAAE,IAAI,OAAO,GAAG;CAE1D,MAAM,SAAA,wBAAQ,UAAU,QAAQ,IAAI,OAAO,OAAO,GAAG,MAAA,QAAA,0BAAA,KAAA,IA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AY;AAErE,KAAI,MACH,QAAO;EACN,GAAG;EACH,IAAI,MAAM;EACV,WAAW,SAAS;EACpB;AAGF,QAAO;EACN,GAAG;EACH,WAAW,SAAS;EACpB;;;;;;;;;;;AAYF,eAAsB,6BACrB,OACA,WACmB;AAEnB,KAAID,oBAAgC,MAAM,CACzC,QAAO,oCAAoC,MAAM;AAGlD,KAAIE,MAAkB,MAAM,CAC3B,QAAO,sBAAsB,OAAO,WAAW,KAAK;AAGrD,KAAIC,YAAwB,MAAM,CACjC,QAAO,4BAA4B,OAAO,UAAU;AAGrD,KAAIC,YAAwB,MAAM,CACjC,QAAO,4BAA4B,OAAO,UAAU;AAGrD,KAAI,OAAO,UAAU,WACpB,QAAO,MAAM,6BAA6B,MAAM,OAAO,EAAE,UAAU;AAIpE,KAAI,MAAM,QAAQ,MAAM,EAAE;EACzB,MAAM,MAAM,EAAE;AAEd,OAAK,MAAM,WAAW,MACrB,KAAI,KAAK,MAAM,6BAA6B,SAAS,UAAU,CAAC;AAGjE,SAAO,IAAI,OAAO,QAAQ;;AAG3B,KAAI,SAAS,OAAO,UAAU,UAAU;EACvC,MAAM,MAAoC,EAAE;AAE5C,OAAK,MAAM,OAAO,MACjB,KAAI,OAAO,MAAM,6BAChB,MAAM,MACN,UACA;AAGF,SAAO;;AAIR,QAAO"}
@@ -1,7 +1,6 @@
1
- const require_link = require('../types/value/link.cjs');
2
- const require_asLink = require('../helpers/asLink.cjs');
3
- const require_escapeHTML = require('./escapeHTML.cjs');
4
-
1
+ const require_link = require("../types/value/link.cjs");
2
+ const require_asLink = require("../helpers/asLink.cjs");
3
+ const require_escapeHTML = require("./escapeHTML.cjs");
5
4
  //#region src/lib/serializerHelpers.ts
6
5
  const formatAttributes = (node, attributes) => {
7
6
  const _attributes = { ...attributes };
@@ -84,7 +83,6 @@ const serializeSpan = () => {
84
83
  return text ? require_escapeHTML.escapeHTML(text).replace(/\n/g, "<br />") : "";
85
84
  };
86
85
  };
87
-
88
86
  //#endregion
89
87
  exports.serializeEmbed = serializeEmbed;
90
88
  exports.serializeHyperlink = serializeHyperlink;
@@ -92,4 +90,5 @@ exports.serializeImage = serializeImage;
92
90
  exports.serializePreFormatted = serializePreFormatted;
93
91
  exports.serializeSpan = serializeSpan;
94
92
  exports.serializeStandardTag = serializeStandardTag;
93
+
95
94
  //# sourceMappingURL=serializerHelpers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"serializerHelpers.cjs","names":["escapeHTML","LinkType","asLink"],"sources":["../../src/lib/serializerHelpers.ts"],"sourcesContent":["import type { RichTextMapSerializer } from \"../richtext/types\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTAnyNode } from \"../types/value/richText\"\n\nimport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLStrictRichTextMapSerializer,\n} from \"../helpers/asHTML\"\nimport type { LinkResolverFunction } from \"../helpers/asLink\"\nimport { asLink } from \"../helpers/asLink\"\n\nimport { escapeHTML } from \"./escapeHTML\"\n\ntype Attributes = Record<string, string | boolean | null | undefined>\nconst formatAttributes = (node: RTAnyNode, attributes: Attributes): string => {\n\tconst _attributes = { ...attributes }\n\n\t// Respect `ltr` and `rtl` direction\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\t_attributes.dir = node.direction\n\t}\n\n\t// Add label to attributes\n\tif (\"data\" in node && \"label\" in node.data && node.data.label) {\n\t\t_attributes.class = _attributes.class\n\t\t\t? `${_attributes.class} ${node.data.label}`\n\t\t\t: node.data.label\n\t}\n\n\tconst result = []\n\n\tfor (const key in _attributes) {\n\t\tconst value = _attributes[key]\n\n\t\tif (value) {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tresult.push(key)\n\t\t\t} else {\n\t\t\t\tresult.push(`${key}=\"${escapeHTML(value)}\"`)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Add a space at the beginning if there's any result\n\tif (result.length) {\n\t\tresult.unshift(\"\")\n\t}\n\n\treturn result.join(\" \")\n}\n\nconst getGeneralAttributes = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[keyof HTMLRichTextMapSerializer],\n): Attributes => {\n\treturn serializerOrShorthand && typeof serializerOrShorthand !== \"function\"\n\t\t? serializerOrShorthand\n\t\t: {}\n}\n\nexport const serializeStandardTag = <\n\tBlockType extends keyof RichTextMapSerializer<string>,\n>(\n\ttag: string,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[BlockType],\n): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn (({ node, children }) => {\n\t\treturn `<${tag}${formatAttributes(\n\t\t\tnode,\n\t\t\tgeneralAttributes,\n\t\t)}>${children}</${tag}>`\n\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n}\n\nexport const serializePreFormatted = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"preformatted\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"preformatted\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\treturn `<pre${formatAttributes(node, generalAttributes)}>${escapeHTML(\n\t\t\tnode.text,\n\t\t)}</pre>`\n\t}\n}\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"image\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"image\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\tsrc: node.url,\n\t\t\talt: node.alt,\n\t\t\tcopyright: node.copyright,\n\t\t}\n\n\t\tlet imageTag = `<img${formatAttributes(node, attributes)} />`\n\n\t\t// If the image has a link, we wrap it with an anchor tag\n\t\tif (node.linkTo) {\n\t\t\timageTag = serializeHyperlink(linkResolver)({\n\t\t\t\ttype: \"hyperlink\",\n\t\t\t\tnode: {\n\t\t\t\t\ttype: \"hyperlink\",\n\t\t\t\t\tdata: node.linkTo,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: 0,\n\t\t\t\t},\n\t\t\t\ttext: \"\",\n\t\t\t\tchildren: imageTag,\n\t\t\t\tkey: \"\",\n\t\t\t})!\n\t\t}\n\n\t\treturn `<p class=\"block-img\">${imageTag}</p>`\n\t}\n}\n\nexport const serializeEmbed = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"embed\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"embed\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\t[\"data-oembed\"]: node.oembed.embed_url,\n\t\t\t[\"data-oembed-type\"]: node.oembed.type,\n\t\t\t[\"data-oembed-provider\"]: node.oembed.provider_name,\n\t\t}\n\n\t\treturn `<div${formatAttributes(node, attributes)}>${node.oembed.html}</div>`\n\t}\n}\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"hyperlink\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"hyperlink\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node, children }): string => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t}\n\n\t\tif (node.data.link_type === LinkType.Web) {\n\t\t\tattributes.href = node.data.url\n\t\t\tattributes.target = node.data.target\n\t\t\tattributes.rel = \"noopener noreferrer\"\n\t\t} else if (node.data.link_type === LinkType.Document) {\n\t\t\tattributes.href = asLink(node.data, { linkResolver })\n\t\t} else if (node.data.link_type === LinkType.Media) {\n\t\t\tattributes.href = node.data.url\n\t\t}\n\n\t\treturn `<a${formatAttributes(node, attributes)}>${children}</a>`\n\t}\n}\n\nexport const serializeSpan = (): NonNullable<\n\tHTMLStrictRichTextMapSerializer[\"span\"]\n> => {\n\treturn ({ text }): string => {\n\t\treturn text ? escapeHTML(text).replace(/\\n/g, \"<br />\") : \"\"\n\t}\n}\n"],"mappings":";;;;;AAcA,MAAM,oBAAoB,MAAiB,eAAmC;CAC7E,MAAM,cAAc,EAAE,GAAG,YAAY;AAGrC,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,aAAY,MAAM,KAAK;AAIxB,KAAI,UAAU,QAAQ,WAAW,KAAK,QAAQ,KAAK,KAAK,MACvD,aAAY,QAAQ,YAAY,QAC7B,GAAG,YAAY,MAAM,GAAG,KAAK,KAAK,UAClC,KAAK,KAAK;CAGd,MAAM,SAAS,EAAE;AAEjB,MAAK,MAAM,OAAO,aAAa;EAC9B,MAAM,QAAQ,YAAY;AAE1B,MAAI,MACH,KAAI,OAAO,UAAU,UACpB,QAAO,KAAK,IAAI;MAEhB,QAAO,KAAK,GAAG,IAAI,IAAIA,8BAAW,MAAM,CAAC,GAAG;;AAM/C,KAAI,OAAO,OACV,QAAO,QAAQ,GAAG;AAGnB,QAAO,OAAO,KAAK,IAAI;;AAGxB,MAAM,wBACL,0BACgB;AAChB,QAAO,yBAAyB,OAAO,0BAA0B,aAC9D,wBACA,EAAE;;AAGN,MAAa,wBAGZ,KACA,0BAC6D;CAC7D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,UAAS,EAAE,MAAM,eAAe;AAC/B,SAAO,IAAI,MAAM,iBAChB,MACA,kBACA,CAAC,GAAG,SAAS,IAAI,IAAI;;;AAIxB,MAAa,yBACZ,0BACkE;CAClE,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,WAAW;AACpB,SAAO,OAAO,iBAAiB,MAAM,kBAAkB,CAAC,GAAGA,8BAC1D,KAAK,KACL,CAAC;;;AAIJ,MAAa,kBACZ,cAIA,0BAC2D;CAC3D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE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","names":["escapeHTML","LinkType","asLink"],"sources":["../../src/lib/serializerHelpers.ts"],"sourcesContent":["import type { RichTextMapSerializer } from \"../richtext/types\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTAnyNode } from \"../types/value/richText\"\n\nimport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLStrictRichTextMapSerializer,\n} from \"../helpers/asHTML\"\nimport type { LinkResolverFunction } from \"../helpers/asLink\"\nimport { asLink } from \"../helpers/asLink\"\n\nimport { escapeHTML } from \"./escapeHTML\"\n\ntype Attributes = Record<string, string | boolean | null | undefined>\nconst formatAttributes = (node: RTAnyNode, attributes: Attributes): string => {\n\tconst _attributes = { ...attributes }\n\n\t// Respect `ltr` and `rtl` direction\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\t_attributes.dir = node.direction\n\t}\n\n\t// Add label to attributes\n\tif (\"data\" in node && \"label\" in node.data && node.data.label) {\n\t\t_attributes.class = _attributes.class\n\t\t\t? `${_attributes.class} ${node.data.label}`\n\t\t\t: node.data.label\n\t}\n\n\tconst result = []\n\n\tfor (const key in _attributes) {\n\t\tconst value = _attributes[key]\n\n\t\tif (value) {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tresult.push(key)\n\t\t\t} else {\n\t\t\t\tresult.push(`${key}=\"${escapeHTML(value)}\"`)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Add a space at the beginning if there's any result\n\tif (result.length) {\n\t\tresult.unshift(\"\")\n\t}\n\n\treturn result.join(\" \")\n}\n\nconst getGeneralAttributes = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[keyof HTMLRichTextMapSerializer],\n): Attributes => {\n\treturn serializerOrShorthand && typeof serializerOrShorthand !== \"function\"\n\t\t? serializerOrShorthand\n\t\t: {}\n}\n\nexport const serializeStandardTag = <\n\tBlockType extends keyof RichTextMapSerializer<string>,\n>(\n\ttag: string,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[BlockType],\n): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn (({ node, children }) => {\n\t\treturn `<${tag}${formatAttributes(\n\t\t\tnode,\n\t\t\tgeneralAttributes,\n\t\t)}>${children}</${tag}>`\n\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n}\n\nexport const serializePreFormatted = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"preformatted\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"preformatted\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\treturn `<pre${formatAttributes(node, generalAttributes)}>${escapeHTML(\n\t\t\tnode.text,\n\t\t)}</pre>`\n\t}\n}\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"image\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"image\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\tsrc: node.url,\n\t\t\talt: node.alt,\n\t\t\tcopyright: node.copyright,\n\t\t}\n\n\t\tlet imageTag = `<img${formatAttributes(node, attributes)} />`\n\n\t\t// If the image has a link, we wrap it with an anchor tag\n\t\tif (node.linkTo) {\n\t\t\timageTag = serializeHyperlink(linkResolver)({\n\t\t\t\ttype: \"hyperlink\",\n\t\t\t\tnode: {\n\t\t\t\t\ttype: \"hyperlink\",\n\t\t\t\t\tdata: node.linkTo,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: 0,\n\t\t\t\t},\n\t\t\t\ttext: \"\",\n\t\t\t\tchildren: imageTag,\n\t\t\t\tkey: \"\",\n\t\t\t})!\n\t\t}\n\n\t\treturn `<p class=\"block-img\">${imageTag}</p>`\n\t}\n}\n\nexport const serializeEmbed = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"embed\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"embed\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\t[\"data-oembed\"]: node.oembed.embed_url,\n\t\t\t[\"data-oembed-type\"]: node.oembed.type,\n\t\t\t[\"data-oembed-provider\"]: node.oembed.provider_name,\n\t\t}\n\n\t\treturn `<div${formatAttributes(node, attributes)}>${node.oembed.html}</div>`\n\t}\n}\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"hyperlink\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"hyperlink\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node, children }): string => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t}\n\n\t\tif (node.data.link_type === LinkType.Web) {\n\t\t\tattributes.href = node.data.url\n\t\t\tattributes.target = node.data.target\n\t\t\tattributes.rel = \"noopener noreferrer\"\n\t\t} else if (node.data.link_type === LinkType.Document) {\n\t\t\tattributes.href = asLink(node.data, { linkResolver })\n\t\t} else if (node.data.link_type === LinkType.Media) {\n\t\t\tattributes.href = node.data.url\n\t\t}\n\n\t\treturn `<a${formatAttributes(node, attributes)}>${children}</a>`\n\t}\n}\n\nexport const serializeSpan = (): NonNullable<\n\tHTMLStrictRichTextMapSerializer[\"span\"]\n> => {\n\treturn ({ text }): string => {\n\t\treturn text ? escapeHTML(text).replace(/\\n/g, \"<br />\") : \"\"\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,oBAAoB,MAAiB,eAAmC;CAC7E,MAAM,cAAc,EAAE,GAAG,YAAY;AAGrC,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,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AAK;IACL;GACD,MAAM;GACN,UAAU;GACV,KAAK;GACL,CAAC;AAGH,SAAO,wBAAwB,SAAS;;;AAI1C,MAAa,kBACZ,0BAC2D;CAC3D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,WAAW;AAQpB,SAAO,OAAO,iBAAiB,MAPZ;GAClB,GAAG;IACF,gBAAgB,KAAK,OAAO;IAC5B,qBAAqB,KAAK,OAAO;IACjC,yBAAyB,KAAK,OAAO;GACtC,CAE+C,CAAC,GAAG,KAAK,OAAO,KAAK;;;AAIvE,MAAa,sBACZ,cAIA,0BAC+D;CAC/D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,MAAM,eAAuB;EACtC,MAAM,aAAa,EAClB,GAAG,mBACH;AAED,MAAI,KAAK,KAAK,cAAcC,aAAAA,SAAS,KAAK;AACzC,cAAW,OAAO,KAAK,KAAK;AAC5B,cAAW,SAAS,KAAK,KAAK;AAC9B,cAAW,MAAM;aACP,KAAK,KAAK,cAAcA,aAAAA,SAAS,SAC3C,YAAW,OAAOC,eAAAA,OAAO,KAAK,MAAM,EAAE,cAAc,CAAC;WAC3C,KAAK,KAAK,cAAcD,aAAAA,SAAS,MAC3C,YAAW,OAAO,KAAK,KAAK;AAG7B,SAAO,KAAK,iBAAiB,MAAM,WAAW,CAAC,GAAG,SAAS;;;AAI7D,MAAa,sBAER;AACJ,SAAQ,EAAE,WAAmB;AAC5B,SAAO,OAAOD,mBAAAA,WAAW,KAAK,CAAC,QAAQ,OAAO,SAAS,GAAG"}
@@ -1,7 +1,6 @@
1
1
  import { LinkType } from "../types/value/link.js";
2
2
  import { asLink } from "../helpers/asLink.js";
3
3
  import { escapeHTML } from "./escapeHTML.js";
4
-
5
4
  //#region src/lib/serializerHelpers.ts
6
5
  const formatAttributes = (node, attributes) => {
7
6
  const _attributes = { ...attributes };
@@ -84,7 +83,7 @@ const serializeSpan = () => {
84
83
  return text ? escapeHTML(text).replace(/\n/g, "<br />") : "";
85
84
  };
86
85
  };
87
-
88
86
  //#endregion
89
87
  export { serializeEmbed, serializeHyperlink, serializeImage, serializePreFormatted, serializeSpan, serializeStandardTag };
88
+
90
89
  //# sourceMappingURL=serializerHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serializerHelpers.js","names":[],"sources":["../../src/lib/serializerHelpers.ts"],"sourcesContent":["import type { RichTextMapSerializer } from \"../richtext/types\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTAnyNode } from \"../types/value/richText\"\n\nimport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLStrictRichTextMapSerializer,\n} from \"../helpers/asHTML\"\nimport type { LinkResolverFunction } from \"../helpers/asLink\"\nimport { asLink } from \"../helpers/asLink\"\n\nimport { escapeHTML } from \"./escapeHTML\"\n\ntype Attributes = Record<string, string | boolean | null | undefined>\nconst formatAttributes = (node: RTAnyNode, attributes: Attributes): string => {\n\tconst _attributes = { ...attributes }\n\n\t// Respect `ltr` and `rtl` direction\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\t_attributes.dir = node.direction\n\t}\n\n\t// Add label to attributes\n\tif (\"data\" in node && \"label\" in node.data && node.data.label) {\n\t\t_attributes.class = _attributes.class\n\t\t\t? `${_attributes.class} ${node.data.label}`\n\t\t\t: node.data.label\n\t}\n\n\tconst result = []\n\n\tfor (const key in _attributes) {\n\t\tconst value = _attributes[key]\n\n\t\tif (value) {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tresult.push(key)\n\t\t\t} else {\n\t\t\t\tresult.push(`${key}=\"${escapeHTML(value)}\"`)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Add a space at the beginning if there's any result\n\tif (result.length) {\n\t\tresult.unshift(\"\")\n\t}\n\n\treturn result.join(\" \")\n}\n\nconst getGeneralAttributes = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[keyof HTMLRichTextMapSerializer],\n): Attributes => {\n\treturn serializerOrShorthand && typeof serializerOrShorthand !== \"function\"\n\t\t? serializerOrShorthand\n\t\t: {}\n}\n\nexport const serializeStandardTag = <\n\tBlockType extends keyof RichTextMapSerializer<string>,\n>(\n\ttag: string,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[BlockType],\n): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn (({ node, children }) => {\n\t\treturn `<${tag}${formatAttributes(\n\t\t\tnode,\n\t\t\tgeneralAttributes,\n\t\t)}>${children}</${tag}>`\n\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n}\n\nexport const serializePreFormatted = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"preformatted\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"preformatted\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\treturn `<pre${formatAttributes(node, generalAttributes)}>${escapeHTML(\n\t\t\tnode.text,\n\t\t)}</pre>`\n\t}\n}\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"image\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"image\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\tsrc: node.url,\n\t\t\talt: node.alt,\n\t\t\tcopyright: node.copyright,\n\t\t}\n\n\t\tlet imageTag = `<img${formatAttributes(node, attributes)} />`\n\n\t\t// If the image has a link, we wrap it with an anchor tag\n\t\tif (node.linkTo) {\n\t\t\timageTag = serializeHyperlink(linkResolver)({\n\t\t\t\ttype: \"hyperlink\",\n\t\t\t\tnode: {\n\t\t\t\t\ttype: \"hyperlink\",\n\t\t\t\t\tdata: node.linkTo,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: 0,\n\t\t\t\t},\n\t\t\t\ttext: \"\",\n\t\t\t\tchildren: imageTag,\n\t\t\t\tkey: \"\",\n\t\t\t})!\n\t\t}\n\n\t\treturn `<p class=\"block-img\">${imageTag}</p>`\n\t}\n}\n\nexport const serializeEmbed = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"embed\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"embed\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\t[\"data-oembed\"]: node.oembed.embed_url,\n\t\t\t[\"data-oembed-type\"]: node.oembed.type,\n\t\t\t[\"data-oembed-provider\"]: node.oembed.provider_name,\n\t\t}\n\n\t\treturn `<div${formatAttributes(node, attributes)}>${node.oembed.html}</div>`\n\t}\n}\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"hyperlink\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"hyperlink\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node, children }): string => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t}\n\n\t\tif (node.data.link_type === LinkType.Web) {\n\t\t\tattributes.href = node.data.url\n\t\t\tattributes.target = node.data.target\n\t\t\tattributes.rel = \"noopener noreferrer\"\n\t\t} else if (node.data.link_type === LinkType.Document) {\n\t\t\tattributes.href = asLink(node.data, { linkResolver })\n\t\t} else if (node.data.link_type === LinkType.Media) {\n\t\t\tattributes.href = node.data.url\n\t\t}\n\n\t\treturn `<a${formatAttributes(node, attributes)}>${children}</a>`\n\t}\n}\n\nexport const serializeSpan = (): NonNullable<\n\tHTMLStrictRichTextMapSerializer[\"span\"]\n> => {\n\treturn ({ text }): string => {\n\t\treturn text ? escapeHTML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GACV,WAAW,KAAK;GAChB,CAEuD,CAAC;AAGzD,MAAI,KAAK,OACR,YAAW,mBAAmB,aAAa,CAAC;GAC3C,MAAM;GACN,MAAM;IACL,MAAM;IACN,MAAM,KAAK;IACX,OAAO;IACP,KAAK;IACL;GACD,MAAM;GACN,UAAU;GACV,KAAK;GACL,CAAC;AAGH,SAAO,wBAAwB,SAAS;;;AAI1C,MAAa,kBACZ,0BAC2D;CAC3D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,WAAW;AAQpB,SAAO,OAAO,iBAAiB,MAPZ;GAClB,GAAG;IACF,gBAAgB,KAAK,OAAO;IAC5B,qBAAqB,KAAK,OAAO;IACjC,yBAAyB,KAAK,OAAO;GACtC,CAE+C,CAAC,GAAG,KAAK,OAAO,KAAK;;;AAIvE,MAAa,sBACZ,cAIA,0BAC+D;CAC/D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,MAAM,eAAuB;EACtC,MAAM,aAAa,EAClB,GAAG,mBACH;AAED,MAAI,KAAK,KAAK,cAAc,SAAS,KAAK;AACzC,cAAW,OAAO,KAAK,KAAK;AAC5B,cAAW,SAAS,KAAK,KAAK;AAC9B,cAAW,MAAM;aACP,KAAK,KAAK,cAAc,SAAS,SAC3C,YAAW,OAAO,OAAO,KAAK,MAAM,EAAE,cAAc,CAAC;WAC3C,KAAK,KAAK,cAAc,SAAS,MAC3C,YAAW,OAAO,KAAK,KAAK;AAG7B,SAAO,KAAK,iBAAiB,MAAM,WAAW,CAAC,GAAG,SAAS;;;AAI7D,MAAa,sBAER;AACJ,SAAQ,EAAE,WAAmB;AAC5B,SAAO,OAAO,WAAW,KAAK,CAAC,QAAQ,OAAO,SAAS,GAAG"}
1
+ {"version":3,"file":"serializerHelpers.js","names":[],"sources":["../../src/lib/serializerHelpers.ts"],"sourcesContent":["import type { RichTextMapSerializer } from \"../richtext/types\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTAnyNode } from \"../types/value/richText\"\n\nimport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLStrictRichTextMapSerializer,\n} from \"../helpers/asHTML\"\nimport type { LinkResolverFunction } from \"../helpers/asLink\"\nimport { asLink } from \"../helpers/asLink\"\n\nimport { escapeHTML } from \"./escapeHTML\"\n\ntype Attributes = Record<string, string | boolean | null | undefined>\nconst formatAttributes = (node: RTAnyNode, attributes: Attributes): string => {\n\tconst _attributes = { ...attributes }\n\n\t// Respect `ltr` and `rtl` direction\n\tif (\"direction\" in node && node.direction === \"rtl\") {\n\t\t_attributes.dir = node.direction\n\t}\n\n\t// Add label to attributes\n\tif (\"data\" in node && \"label\" in node.data && node.data.label) {\n\t\t_attributes.class = _attributes.class\n\t\t\t? `${_attributes.class} ${node.data.label}`\n\t\t\t: node.data.label\n\t}\n\n\tconst result = []\n\n\tfor (const key in _attributes) {\n\t\tconst value = _attributes[key]\n\n\t\tif (value) {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tresult.push(key)\n\t\t\t} else {\n\t\t\t\tresult.push(`${key}=\"${escapeHTML(value)}\"`)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Add a space at the beginning if there's any result\n\tif (result.length) {\n\t\tresult.unshift(\"\")\n\t}\n\n\treturn result.join(\" \")\n}\n\nconst getGeneralAttributes = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[keyof HTMLRichTextMapSerializer],\n): Attributes => {\n\treturn serializerOrShorthand && typeof serializerOrShorthand !== \"function\"\n\t\t? serializerOrShorthand\n\t\t: {}\n}\n\nexport const serializeStandardTag = <\n\tBlockType extends keyof RichTextMapSerializer<string>,\n>(\n\ttag: string,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[BlockType],\n): NonNullable<HTMLStrictRichTextMapSerializer[BlockType]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn (({ node, children }) => {\n\t\treturn `<${tag}${formatAttributes(\n\t\t\tnode,\n\t\t\tgeneralAttributes,\n\t\t)}>${children}</${tag}>`\n\t}) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>\n}\n\nexport const serializePreFormatted = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"preformatted\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"preformatted\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\treturn `<pre${formatAttributes(node, generalAttributes)}>${escapeHTML(\n\t\t\tnode.text,\n\t\t)}</pre>`\n\t}\n}\n\nexport const serializeImage = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"image\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"image\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\tsrc: node.url,\n\t\t\talt: node.alt,\n\t\t\tcopyright: node.copyright,\n\t\t}\n\n\t\tlet imageTag = `<img${formatAttributes(node, attributes)} />`\n\n\t\t// If the image has a link, we wrap it with an anchor tag\n\t\tif (node.linkTo) {\n\t\t\timageTag = serializeHyperlink(linkResolver)({\n\t\t\t\ttype: \"hyperlink\",\n\t\t\t\tnode: {\n\t\t\t\t\ttype: \"hyperlink\",\n\t\t\t\t\tdata: node.linkTo,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: 0,\n\t\t\t\t},\n\t\t\t\ttext: \"\",\n\t\t\t\tchildren: imageTag,\n\t\t\t\tkey: \"\",\n\t\t\t})!\n\t\t}\n\n\t\treturn `<p class=\"block-img\">${imageTag}</p>`\n\t}\n}\n\nexport const serializeEmbed = (\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"embed\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"embed\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node }) => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t\t[\"data-oembed\"]: node.oembed.embed_url,\n\t\t\t[\"data-oembed-type\"]: node.oembed.type,\n\t\t\t[\"data-oembed-provider\"]: node.oembed.provider_name,\n\t\t}\n\n\t\treturn `<div${formatAttributes(node, attributes)}>${node.oembed.html}</div>`\n\t}\n}\n\nexport const serializeHyperlink = (\n\tlinkResolver:\n\t\t| LinkResolverFunction<string | null | undefined>\n\t\t| undefined\n\t\t| null,\n\tserializerOrShorthand?: HTMLRichTextMapSerializer[\"hyperlink\"],\n): NonNullable<HTMLStrictRichTextMapSerializer[\"hyperlink\"]> => {\n\tconst generalAttributes = getGeneralAttributes(serializerOrShorthand)\n\n\treturn ({ node, children }): string => {\n\t\tconst attributes = {\n\t\t\t...generalAttributes,\n\t\t}\n\n\t\tif (node.data.link_type === LinkType.Web) {\n\t\t\tattributes.href = node.data.url\n\t\t\tattributes.target = node.data.target\n\t\t\tattributes.rel = \"noopener noreferrer\"\n\t\t} else if (node.data.link_type === LinkType.Document) {\n\t\t\tattributes.href = asLink(node.data, { linkResolver })\n\t\t} else if (node.data.link_type === LinkType.Media) {\n\t\t\tattributes.href = node.data.url\n\t\t}\n\n\t\treturn `<a${formatAttributes(node, attributes)}>${children}</a>`\n\t}\n}\n\nexport const serializeSpan = (): NonNullable<\n\tHTMLStrictRichTextMapSerializer[\"span\"]\n> => {\n\treturn ({ text }): string => {\n\t\treturn text ? escapeHTML(text).replace(/\\n/g, \"<br />\") : \"\"\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,oBAAoB,MAAiB,eAAmC;CAC7E,MAAM,cAAc,EAAE,GAAG,YAAY;AAGrC,KAAI,eAAe,QAAQ,KAAK,cAAc,MAC7C,aAAY,MAAM,KAAK;AAIxB,KAAI,UAAU,QAAQ,WAAW,KAAK,QAAQ,KAAK,KAAK,MACvD,aAAY,QAAQ,YAAY,QAC7B,GAAG,YAAY,MAAM,GAAG,KAAK,KA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,EAAE,WAAW;AAQpB,SAAO,OAAO,iBAAiB,MAPZ;GAClB,GAAG;IACF,gBAAgB,KAAK,OAAO;IAC5B,qBAAqB,KAAK,OAAO;IACjC,yBAAyB,KAAK,OAAO;GACtC,CAE+C,CAAC,GAAG,KAAK,OAAO,KAAK;;;AAIvE,MAAa,sBACZ,cAIA,0BAC+D;CAC/D,MAAM,oBAAoB,qBAAqB,sBAAsB;AAErE,SAAQ,EAAE,MAAM,eAAuB;EACtC,MAAM,aAAa,EAClB,GAAG,mBACH;AAED,MAAI,KAAK,KAAK,cAAc,SAAS,KAAK;AACzC,cAAW,OAAO,KAAK,KAAK;AAC5B,cAAW,SAAS,KAAK,KAAK;AAC9B,cAAW,MAAM;aACP,KAAK,KAAK,cAAc,SAAS,SAC3C,YAAW,OAAO,OAAO,KAAK,MAAM,EAAE,cAAc,CAAC;WAC3C,KAAK,KAAK,cAAc,SAAS,MAC3C,YAAW,OAAO,KAAK,KAAK;AAG7B,SAAO,KAAK,iBAAiB,MAAM,WAAW,CAAC,GAAG,SAAS;;;AAI7D,MAAa,sBAER;AACJ,SAAQ,EAAE,WAAmB;AAC5B,SAAO,OAAO,WAAW,KAAK,CAAC,QAAQ,OAAO,SAAS,GAAG"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/lib/throttledWarn.ts
3
2
  const THROTTLE_THRESHOLD_MS = 5e3;
4
3
  let lastMessage;
@@ -21,7 +20,7 @@ const throttledWarn = (message) => {
21
20
  lastMessage = message;
22
21
  console.warn(message);
23
22
  };
24
-
25
23
  //#endregion
26
24
  exports.throttledWarn = throttledWarn;
25
+
27
26
  //# sourceMappingURL=throttledWarn.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"throttledWarn.cjs","names":["lastMessage: string | undefined"],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged\n * message and that message was logged within 5 seconds of the current call, the\n * log is ignored. This throttle behavior prevents identical messages from\n * flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (\n\t\tmessage === lastMessage &&\n\t\tDate.now() - lastCalledAt < THROTTLE_THRESHOLD_MS\n\t) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";;AAAA,MAAM,wBAAwB;AAE9B,IAAIA;AACJ,IAAI,eAAe;;;;;;;;;;AAWnB,MAAa,iBAAiB,YAA0B;AACvD,KACC,YAAY,eACZ,KAAK,KAAK,GAAG,eAAe,uBAC3B;AACD,iBAAe,KAAK,KAAK;AAEzB;;AAGD,gBAAe,KAAK,KAAK;AACzB,eAAc;AAEd,SAAQ,KAAK,QAAQ"}
1
+ {"version":3,"file":"throttledWarn.cjs","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged\n * message and that message was logged within 5 seconds of the current call, the\n * log is ignored. This throttle behavior prevents identical messages from\n * flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (\n\t\tmessage === lastMessage &&\n\t\tDate.now() - lastCalledAt < THROTTLE_THRESHOLD_MS\n\t) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;;AAWnB,MAAa,iBAAiB,YAA0B;AACvD,KACC,YAAY,eACZ,KAAK,KAAK,GAAG,eAAe,uBAC3B;AACD,iBAAe,KAAK,KAAK;AAEzB;;AAGD,gBAAe,KAAK,KAAK;AACzB,eAAc;AAEd,SAAQ,KAAK,QAAQ"}
@@ -20,7 +20,7 @@ const throttledWarn = (message) => {
20
20
  lastMessage = message;
21
21
  console.warn(message);
22
22
  };
23
-
24
23
  //#endregion
25
24
  export { throttledWarn };
25
+
26
26
  //# sourceMappingURL=throttledWarn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"throttledWarn.js","names":["lastMessage: string | undefined"],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged\n * message and that message was logged within 5 seconds of the current call, the\n * log is ignored. This throttle behavior prevents identical messages from\n * flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (\n\t\tmessage === lastMessage &&\n\t\tDate.now() - lastCalledAt < THROTTLE_THRESHOLD_MS\n\t) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAIA;AACJ,IAAI,eAAe;;;;;;;;;;AAWnB,MAAa,iBAAiB,YAA0B;AACvD,KACC,YAAY,eACZ,KAAK,KAAK,GAAG,eAAe,uBAC3B;AACD,iBAAe,KAAK,KAAK;AAEzB;;AAGD,gBAAe,KAAK,KAAK;AACzB,eAAc;AAEd,SAAQ,KAAK,QAAQ"}
1
+ {"version":3,"file":"throttledWarn.js","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged\n * message and that message was logged within 5 seconds of the current call, the\n * log is ignored. This throttle behavior prevents identical messages from\n * flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (\n\t\tmessage === lastMessage &&\n\t\tDate.now() - lastCalledAt < THROTTLE_THRESHOLD_MS\n\t) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;;AAWnB,MAAa,iBAAiB,YAA0B;AACvD,KACC,YAAY,eACZ,KAAK,KAAK,GAAG,eAAe,uBAC3B;AACD,iBAAe,KAAK,KAAK;AAEzB;;AAGD,gBAAe,KAAK,KAAK;AACzB,eAAc;AAEd,SAAQ,KAAK,QAAQ"}
@@ -1,5 +1,4 @@
1
- const require_errors = require('../errors.cjs');
2
-
1
+ const require_errors = require("../errors.cjs");
3
2
  //#region src/lib/validateAssetMetadata.ts
4
3
  /**
5
4
  * Max length for asset notes accepted by the API.
@@ -42,7 +41,7 @@ const validateAssetMetadata = ({ notes, credits, alt, tags }) => {
42
41
  tags
43
42
  });
44
43
  };
45
-
46
44
  //#endregion
47
45
  exports.validateAssetMetadata = validateAssetMetadata;
46
+
48
47
  //# sourceMappingURL=validateAssetMetadata.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateAssetMetadata.cjs","names":["errors: string[]","PrismicError"],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;AAOA,MAAM,yBAAyB;;;;AAK/B,MAAM,2BAA2B;;;;AAKjC,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;;;;;;AAU7B,MAAa,yBAAyB,EACrC,OACA,SACA,KACA,WAC8B;CAC9B,MAAMA,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KACN,6BAA6B,uBAAuB,aACpD;AAGF,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KACN,+BAA+B,yBAAyB,aACxD;AAGF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MACH,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBACnD,CAED,QAAO,KACN,oEACA;AAGF,KAAI,OAAO,OACV,OAAM,IAAIC,4BACT,qCAAqC,OAAO,KAAK,KAAK,IACtD,QACA;EAAE;EAAO;EAAS;EAAK;EAAM,CAC7B"}
1
+ {"version":3,"file":"validateAssetMetadata.cjs","names":["PrismicError"],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"mappings":";;;;;AAOA,MAAM,yBAAyB;;;;AAK/B,MAAM,2BAA2B;;;;AAKjC,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;;;;;;AAU7B,MAAa,yBAAyB,EACrC,OACA,SACA,KACA,WAC8B;CAC9B,MAAM,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KACN,6BAA6B,uBAAuB,aACpD;AAGF,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KACN,+BAA+B,yBAAyB,aACxD;AAGF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MACH,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBACnD,CAED,QAAO,KACN,oEACA;AAGF,KAAI,OAAO,OACV,OAAM,IAAIA,eAAAA,aACT,qCAAqC,OAAO,KAAK,KAAK,IACtD,KAAA,GACA;EAAE;EAAO;EAAS;EAAK;EAAM,CAC7B"}
@@ -1,5 +1,4 @@
1
1
  import { PrismicError } from "../errors.js";
2
-
3
2
  //#region src/lib/validateAssetMetadata.ts
4
3
  /**
5
4
  * Max length for asset notes accepted by the API.
@@ -42,7 +41,7 @@ const validateAssetMetadata = ({ notes, credits, alt, tags }) => {
42
41
  tags
43
42
  });
44
43
  };
45
-
46
44
  //#endregion
47
45
  export { validateAssetMetadata };
46
+
48
47
  //# sourceMappingURL=validateAssetMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateAssetMetadata.js","names":["errors: string[]"],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;AAOA,MAAM,yBAAyB;;;;AAK/B,MAAM,2BAA2B;;;;AAKjC,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;;;;;;AAU7B,MAAa,yBAAyB,EACrC,OACA,SACA,KACA,WAC8B;CAC9B,MAAMA,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KACN,6BAA6B,uBAAuB,aACpD;AAGF,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KACN,+BAA+B,yBAAyB,aACxD;AAGF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MACH,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBACnD,CAED,QAAO,KACN,oEACA;AAGF,KAAI,OAAO,OACV,OAAM,IAAI,aACT,qCAAqC,OAAO,KAAK,KAAK,IACtD,QACA;EAAE;EAAO;EAAS;EAAK;EAAM,CAC7B"}
1
+ {"version":3,"file":"validateAssetMetadata.js","names":[],"sources":["../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"mappings":";;;;;AAOA,MAAM,yBAAyB;;;;AAK/B,MAAM,2BAA2B;;;;AAKjC,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;;;;;;AAU7B,MAAa,yBAAyB,EACrC,OACA,SACA,KACA,WAC8B;CAC9B,MAAM,SAAmB,EAAE;AAE3B,KAAI,SAAS,MAAM,SAAS,uBAC3B,QAAO,KACN,6BAA6B,uBAAuB,aACpD;AAGF,KAAI,WAAW,QAAQ,SAAS,yBAC/B,QAAO,KACN,+BAA+B,yBAAyB,aACxD;AAGF,KAAI,OAAO,IAAI,SAAS,qBACvB,QAAO,KAAK,2BAA2B,qBAAqB,aAAa;AAG1E,KACC,QACA,KAAK,UACL,KAAK,MACH,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,qBACnD,CAED,QAAO,KACN,oEACA;AAGF,KAAI,OAAO,OACV,OAAM,IAAI,aACT,qCAAqC,OAAO,KAAK,KAAK,IACtD,KAAA,GACA;EAAE;EAAO;EAAS;EAAK;EAAM,CAC7B"}
package/dist/package.cjs CHANGED
@@ -1,19 +1,18 @@
1
-
2
1
  //#region package.json
3
2
  var name = "@prismicio/client";
4
- var version = "7.21.6";
5
-
3
+ var version = "7.21.7-canary.673a207";
6
4
  //#endregion
7
- Object.defineProperty(exports, 'name', {
8
- enumerable: true,
9
- get: function () {
10
- return name;
11
- }
5
+ Object.defineProperty(exports, "name", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return name;
9
+ }
12
10
  });
13
- Object.defineProperty(exports, 'version', {
14
- enumerable: true,
15
- get: function () {
16
- return version;
17
- }
11
+ Object.defineProperty(exports, "version", {
12
+ enumerable: true,
13
+ get: function() {
14
+ return version;
15
+ }
18
16
  });
17
+
19
18
  //# sourceMappingURL=package.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.cjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@prismicio/client\",\n\t\"version\": \"7.21.6\",\n\t\"description\": \"The official JavaScript + TypeScript client library for Prismic\",\n\t\"keywords\": [\n\t\t\"typescript\",\n\t\t\"client\",\n\t\t\"helpers\",\n\t\t\"types\",\n\t\t\"utils\",\n\t\t\"toolbox\",\n\t\t\"cms\",\n\t\t\"prismic\",\n\t\t\"prismic.io\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"ssh://git@github.com/prismicio/prismic-client.git\"\n\t},\n\t\"license\": \"Apache-2.0\",\n\t\"author\": \"Prismic <contact@prismic.io> (https://prismic.io)\",\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": \"./dist/index.js\",\n\t\t\t\"require\": \"./dist/index.cjs\"\n\t\t},\n\t\t\"./richtext\": {\n\t\t\t\"import\": \"./dist/richtext.js\",\n\t\t\t\"require\": \"./dist/richtext.cjs\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"react-native\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.cts\",\n\t\"typesVersions\": {\n\t\t\"*\": {\n\t\t\t\"*\": [\n\t\t\t\t\"dist/index.d.ts\"\n\t\t\t],\n\t\t\t\"richtext\": [\n\t\t\t\t\"dist/richtext.d.ts\"\n\t\t\t]\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"prepare\": \"npm run build\",\n\t\t\"lint\": \"oxlint --deny-warnings\",\n\t\t\"types\": \"tsc --noEmit\",\n\t\t\"unit\": \"vitest run --coverage\",\n\t\t\"unit:watch\": \"vitest watch\",\n\t\t\"test\": \"npm run lint && npm run types && npm run unit && npm run build\"\n\t},\n\t\"dependencies\": {\n\t\t\"imgix-url-builder\": \"^0.0.6\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@prismicio/e2e-tests-utils\": \"^1.14.0\",\n\t\t\"@prismicio/types-internal\": \"^3.16.1\",\n\t\t\"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n\t\t\"@types/node\": \"^24.10.0\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.6\",\n\t\t\"oxlint\": \"^1.26.0\",\n\t\t\"prettier\": \"^3.6.2\",\n\t\t\"prettier-plugin-jsdoc\": \"1.3.3\",\n\t\t\"tsdown\": \"^0.16.1\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.6\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=14.15.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"],"mappings":";;WACS;cACG"}
1
+ {"version":3,"file":"package.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
package/dist/package.js CHANGED
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.21.6";
4
-
3
+ var version = "7.21.7-canary.673a207";
5
4
  //#endregion
6
5
  export { name, version };
6
+
7
7
  //# sourceMappingURL=package.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@prismicio/client\",\n\t\"version\": \"7.21.6\",\n\t\"description\": \"The official JavaScript + TypeScript client library for Prismic\",\n\t\"keywords\": [\n\t\t\"typescript\",\n\t\t\"client\",\n\t\t\"helpers\",\n\t\t\"types\",\n\t\t\"utils\",\n\t\t\"toolbox\",\n\t\t\"cms\",\n\t\t\"prismic\",\n\t\t\"prismic.io\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"ssh://git@github.com/prismicio/prismic-client.git\"\n\t},\n\t\"license\": \"Apache-2.0\",\n\t\"author\": \"Prismic <contact@prismic.io> (https://prismic.io)\",\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": \"./dist/index.js\",\n\t\t\t\"require\": \"./dist/index.cjs\"\n\t\t},\n\t\t\"./richtext\": {\n\t\t\t\"import\": \"./dist/richtext.js\",\n\t\t\t\"require\": \"./dist/richtext.cjs\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"react-native\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.cts\",\n\t\"typesVersions\": {\n\t\t\"*\": {\n\t\t\t\"*\": [\n\t\t\t\t\"dist/index.d.ts\"\n\t\t\t],\n\t\t\t\"richtext\": [\n\t\t\t\t\"dist/richtext.d.ts\"\n\t\t\t]\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"prepare\": \"npm run build\",\n\t\t\"lint\": \"oxlint --deny-warnings\",\n\t\t\"types\": \"tsc --noEmit\",\n\t\t\"unit\": \"vitest run --coverage\",\n\t\t\"unit:watch\": \"vitest watch\",\n\t\t\"test\": \"npm run lint && npm run types && npm run unit && npm run build\"\n\t},\n\t\"dependencies\": {\n\t\t\"imgix-url-builder\": \"^0.0.6\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@prismicio/e2e-tests-utils\": \"^1.14.0\",\n\t\t\"@prismicio/types-internal\": \"^3.16.1\",\n\t\t\"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n\t\t\"@types/node\": \"^24.10.0\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.6\",\n\t\t\"oxlint\": \"^1.26.0\",\n\t\t\"prettier\": \"^3.6.2\",\n\t\t\"prettier-plugin-jsdoc\": \"1.3.3\",\n\t\t\"tsdown\": \"^0.16.1\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.6\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=14.15.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"],"mappings":";WACS;cACG"}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/richtext/asText.ts
3
2
  /**
4
3
  * Converts a rich text field to a plain text string.
@@ -15,7 +14,7 @@ const asText = (richTextField, separator = " ") => {
15
14
  for (let i = 0; i < richTextField.length; i++) if ("text" in richTextField[i]) result += (result ? separator : "") + richTextField[i].text;
16
15
  return result;
17
16
  };
18
-
19
17
  //#endregion
20
18
  exports.asText = asText;
19
+
21
20
  //# sourceMappingURL=asText.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"asText.cjs","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Converts a rich text field to a plain text string.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param separator - Separator used to join each element. Defaults to a space.\n *\n * @returns Plain text equivalent of the rich text field.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (\n\trichTextField: RichTextField,\n\tseparator = \" \",\n): string => {\n\tlet result = \"\"\n\n\tfor (let i = 0; i < richTextField.length; i++) {\n\t\tif (\"text\" in richTextField[i]) {\n\t\t\tresult +=\n\t\t\t\t(result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,UACZ,eACA,YAAY,QACA;CACZ,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YACE,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIhE,QAAO"}
1
+ {"version":3,"file":"asText.cjs","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":["import type { RTTextNode, RichTextField } from \"../types/value/richText\"\n\n/**\n * Converts a rich text field to a plain text string.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param separator - Separator used to join each element. Defaults to a space.\n *\n * @returns Plain text equivalent of the rich text field.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const asText = (\n\trichTextField: RichTextField,\n\tseparator = \" \",\n): string => {\n\tlet result = \"\"\n\n\tfor (let i = 0; i < richTextField.length; i++) {\n\t\tif (\"text\" in richTextField[i]) {\n\t\t\tresult +=\n\t\t\t\t(result ? separator : \"\") + (richTextField[i] as RTTextNode).text\n\t\t}\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,UACZ,eACA,YAAY,QACA;CACZ,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,IACzC,KAAI,UAAU,cAAc,GAC3B,YACE,SAAS,YAAY,MAAO,cAAc,GAAkB;AAIhE,QAAO"}
@@ -1,7 +1,6 @@
1
1
  import { RichTextField } from "../types/value/richText.cjs";
2
2
 
3
3
  //#region src/richtext/asText.d.ts
4
-
5
4
  /**
6
5
  * Converts a rich text field to a plain text string.
7
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;;;;;;;;cAAa,wBACG"}
1
+ {"version":3,"file":"asText.d.cts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAYA;;;;;;;;cAAa,MAAA,GACZ,aAAA,EAAe,aAAA,EACf,SAAA"}
@@ -1,7 +1,6 @@
1
1
  import { RichTextField } from "../types/value/richText.js";
2
2
 
3
3
  //#region src/richtext/asText.d.ts
4
-
5
4
  /**
6
5
  * Converts a rich text field to a plain text string.
7
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/richtext/asText.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;;;;;;;;cAAa,wBACG"}
1
+ {"version":3,"file":"asText.d.ts","names":[],"sources":["../../src/richtext/asText.ts"],"mappings":";;;;;AAYA;;;;;;;;cAAa,MAAA,GACZ,aAAA,EAAe,aAAA,EACf,SAAA"}
@@ -14,7 +14,7 @@ const asText = (richTextField, separator = " ") => {
14
14
  for (let i = 0; i < richTextField.length; i++) if ("text" in richTextField[i]) result += (result ? separator : "") + richTextField[i].text;
15
15
  return result;
16
16
  };
17
-
18
17
  //#endregion
19
18
  export { asText };
19
+
20
20
  //# sourceMappingURL=asText.js.map