@prismicio/client 7.21.0-alpha.0 → 7.21.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (480) hide show
  1. package/dist/index.cjs +3880 -92
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +4424 -0
  4. package/dist/index.d.mts +4424 -0
  5. package/dist/index.d.ts +4349 -128
  6. package/dist/index.mjs +3837 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/richtext/index.cjs +244 -0
  9. package/dist/richtext/index.cjs.map +1 -0
  10. package/dist/richtext/index.d.cts +78 -0
  11. package/dist/richtext/index.d.mts +78 -0
  12. package/dist/richtext/index.d.ts +78 -7
  13. package/dist/richtext/index.mjs +237 -0
  14. package/dist/richtext/index.mjs.map +1 -0
  15. package/dist/shared/client.TSGr56lO.d.cts +899 -0
  16. package/dist/shared/client.TSGr56lO.d.mts +899 -0
  17. package/dist/shared/client.TSGr56lO.d.ts +899 -0
  18. package/package.json +19 -42
  19. package/src/buildQueryURL.ts +29 -21
  20. package/src/createClient.ts +11 -8
  21. package/src/getRepositoryEndpoint.ts +9 -2
  22. package/src/helpers/asDate.ts +11 -4
  23. package/src/helpers/asHTML.ts +34 -26
  24. package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
  25. package/src/helpers/asImageSrc.ts +11 -10
  26. package/src/helpers/asImageWidthSrcSet.ts +18 -17
  27. package/src/helpers/asLink.ts +33 -32
  28. package/src/helpers/asLinkAttrs.ts +6 -9
  29. package/src/helpers/asText.ts +20 -10
  30. package/src/helpers/isFilled.ts +15 -14
  31. package/src/helpers/mapSliceZone.ts +10 -10
  32. package/src/index.ts +2 -2
  33. package/src/isRepositoryEndpoint.ts +2 -2
  34. package/src/richtext/asText.ts +5 -5
  35. package/src/richtext/serialize.ts +8 -8
  36. package/src/richtext/types.ts +6 -6
  37. package/src/types/migration/Asset.ts +10 -2
  38. package/src/types/model/types.ts +0 -2
  39. package/dist/Client.cjs +0 -1274
  40. package/dist/Client.cjs.map +0 -1
  41. package/dist/Client.d.ts +0 -981
  42. package/dist/Client.js +0 -1274
  43. package/dist/Client.js.map +0 -1
  44. package/dist/Migration.cjs +0 -315
  45. package/dist/Migration.cjs.map +0 -1
  46. package/dist/Migration.d.ts +0 -213
  47. package/dist/Migration.js +0 -315
  48. package/dist/Migration.js.map +0 -1
  49. package/dist/WriteClient.cjs +0 -560
  50. package/dist/WriteClient.cjs.map +0 -1
  51. package/dist/WriteClient.d.ts +0 -281
  52. package/dist/WriteClient.js +0 -560
  53. package/dist/WriteClient.js.map +0 -1
  54. package/dist/buildQueryURL.cjs +0 -66
  55. package/dist/buildQueryURL.cjs.map +0 -1
  56. package/dist/buildQueryURL.d.ts +0 -209
  57. package/dist/buildQueryURL.js +0 -66
  58. package/dist/buildQueryURL.js.map +0 -1
  59. package/dist/cookie.cjs +0 -5
  60. package/dist/cookie.cjs.map +0 -1
  61. package/dist/cookie.d.ts +0 -5
  62. package/dist/cookie.js +0 -5
  63. package/dist/cookie.js.map +0 -1
  64. package/dist/createClient.cjs +0 -6
  65. package/dist/createClient.cjs.map +0 -1
  66. package/dist/createClient.d.ts +0 -32
  67. package/dist/createClient.js +0 -6
  68. package/dist/createClient.js.map +0 -1
  69. package/dist/createMigration.cjs +0 -6
  70. package/dist/createMigration.cjs.map +0 -1
  71. package/dist/createMigration.d.ts +0 -24
  72. package/dist/createMigration.js +0 -6
  73. package/dist/createMigration.js.map +0 -1
  74. package/dist/createWriteClient.cjs +0 -6
  75. package/dist/createWriteClient.cjs.map +0 -1
  76. package/dist/createWriteClient.d.ts +0 -32
  77. package/dist/createWriteClient.js +0 -6
  78. package/dist/createWriteClient.js.map +0 -1
  79. package/dist/errors/ForbiddenError.cjs +0 -7
  80. package/dist/errors/ForbiddenError.cjs.map +0 -1
  81. package/dist/errors/ForbiddenError.d.ts +0 -11
  82. package/dist/errors/ForbiddenError.js +0 -7
  83. package/dist/errors/ForbiddenError.js.map +0 -1
  84. package/dist/errors/InvalidDataError.cjs +0 -7
  85. package/dist/errors/InvalidDataError.cjs.map +0 -1
  86. package/dist/errors/InvalidDataError.d.ts +0 -3
  87. package/dist/errors/InvalidDataError.js +0 -7
  88. package/dist/errors/InvalidDataError.js.map +0 -1
  89. package/dist/errors/NotFoundError.cjs +0 -7
  90. package/dist/errors/NotFoundError.cjs.map +0 -1
  91. package/dist/errors/NotFoundError.d.ts +0 -3
  92. package/dist/errors/NotFoundError.js +0 -7
  93. package/dist/errors/NotFoundError.js.map +0 -1
  94. package/dist/errors/ParsingError.cjs +0 -7
  95. package/dist/errors/ParsingError.cjs.map +0 -1
  96. package/dist/errors/ParsingError.d.ts +0 -14
  97. package/dist/errors/ParsingError.js +0 -7
  98. package/dist/errors/ParsingError.js.map +0 -1
  99. package/dist/errors/PreviewTokenExpired.cjs +0 -7
  100. package/dist/errors/PreviewTokenExpired.cjs.map +0 -1
  101. package/dist/errors/PreviewTokenExpired.d.ts +0 -8
  102. package/dist/errors/PreviewTokenExpired.js +0 -7
  103. package/dist/errors/PreviewTokenExpired.js.map +0 -1
  104. package/dist/errors/PrismicError.cjs +0 -16
  105. package/dist/errors/PrismicError.cjs.map +0 -1
  106. package/dist/errors/PrismicError.d.ts +0 -5
  107. package/dist/errors/PrismicError.js +0 -16
  108. package/dist/errors/PrismicError.js.map +0 -1
  109. package/dist/errors/RefExpiredError.cjs +0 -7
  110. package/dist/errors/RefExpiredError.cjs.map +0 -1
  111. package/dist/errors/RefExpiredError.d.ts +0 -8
  112. package/dist/errors/RefExpiredError.js +0 -7
  113. package/dist/errors/RefExpiredError.js.map +0 -1
  114. package/dist/errors/RefNotFoundError.cjs +0 -7
  115. package/dist/errors/RefNotFoundError.cjs.map +0 -1
  116. package/dist/errors/RefNotFoundError.d.ts +0 -8
  117. package/dist/errors/RefNotFoundError.js +0 -7
  118. package/dist/errors/RefNotFoundError.js.map +0 -1
  119. package/dist/errors/RepositoryNotFoundError.cjs +0 -7
  120. package/dist/errors/RepositoryNotFoundError.cjs.map +0 -1
  121. package/dist/errors/RepositoryNotFoundError.d.ts +0 -3
  122. package/dist/errors/RepositoryNotFoundError.js +0 -7
  123. package/dist/errors/RepositoryNotFoundError.js.map +0 -1
  124. package/dist/filter.cjs +0 -247
  125. package/dist/filter.cjs.map +0 -1
  126. package/dist/filter.d.ts +0 -209
  127. package/dist/filter.js +0 -247
  128. package/dist/filter.js.map +0 -1
  129. package/dist/getGraphQLEndpoint.cjs +0 -13
  130. package/dist/getGraphQLEndpoint.cjs.map +0 -1
  131. package/dist/getGraphQLEndpoint.d.ts +0 -10
  132. package/dist/getGraphQLEndpoint.js +0 -13
  133. package/dist/getGraphQLEndpoint.js.map +0 -1
  134. package/dist/getRepositoryEndpoint.cjs +0 -13
  135. package/dist/getRepositoryEndpoint.cjs.map +0 -1
  136. package/dist/getRepositoryEndpoint.d.ts +0 -12
  137. package/dist/getRepositoryEndpoint.js +0 -13
  138. package/dist/getRepositoryEndpoint.js.map +0 -1
  139. package/dist/getRepositoryName.cjs +0 -17
  140. package/dist/getRepositoryName.cjs.map +0 -1
  141. package/dist/getRepositoryName.d.ts +0 -12
  142. package/dist/getRepositoryName.js +0 -17
  143. package/dist/getRepositoryName.js.map +0 -1
  144. package/dist/getToolbarSrc.cjs +0 -13
  145. package/dist/getToolbarSrc.cjs.map +0 -1
  146. package/dist/getToolbarSrc.d.ts +0 -34
  147. package/dist/getToolbarSrc.js +0 -13
  148. package/dist/getToolbarSrc.js.map +0 -1
  149. package/dist/helpers/asDate.cjs +0 -14
  150. package/dist/helpers/asDate.cjs.map +0 -1
  151. package/dist/helpers/asDate.d.ts +0 -17
  152. package/dist/helpers/asDate.js +0 -14
  153. package/dist/helpers/asDate.js.map +0 -1
  154. package/dist/helpers/asHTML.cjs +0 -86
  155. package/dist/helpers/asHTML.cjs.map +0 -1
  156. package/dist/helpers/asHTML.d.ts +0 -141
  157. package/dist/helpers/asHTML.js +0 -86
  158. package/dist/helpers/asHTML.js.map +0 -1
  159. package/dist/helpers/asImagePixelDensitySrcSet.cjs +0 -21
  160. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +0 -1
  161. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +0 -53
  162. package/dist/helpers/asImagePixelDensitySrcSet.js +0 -21
  163. package/dist/helpers/asImagePixelDensitySrcSet.js.map +0 -1
  164. package/dist/helpers/asImageSrc.cjs +0 -13
  165. package/dist/helpers/asImageSrc.cjs.map +0 -1
  166. package/dist/helpers/asImageSrc.d.ts +0 -28
  167. package/dist/helpers/asImageSrc.js +0 -13
  168. package/dist/helpers/asImageSrc.js.map +0 -1
  169. package/dist/helpers/asImageWidthSrcSet.cjs +0 -45
  170. package/dist/helpers/asImageWidthSrcSet.cjs.map +0 -1
  171. package/dist/helpers/asImageWidthSrcSet.d.ts +0 -61
  172. package/dist/helpers/asImageWidthSrcSet.js +0 -45
  173. package/dist/helpers/asImageWidthSrcSet.js.map +0 -1
  174. package/dist/helpers/asLink.cjs +0 -47
  175. package/dist/helpers/asLink.cjs.map +0 -1
  176. package/dist/helpers/asLink.d.ts +0 -77
  177. package/dist/helpers/asLink.js +0 -47
  178. package/dist/helpers/asLink.js.map +0 -1
  179. package/dist/helpers/asLinkAttrs.cjs +0 -28
  180. package/dist/helpers/asLinkAttrs.cjs.map +0 -1
  181. package/dist/helpers/asLinkAttrs.d.ts +0 -50
  182. package/dist/helpers/asLinkAttrs.js +0 -28
  183. package/dist/helpers/asLinkAttrs.js.map +0 -1
  184. package/dist/helpers/asText.cjs +0 -21
  185. package/dist/helpers/asText.cjs.map +0 -1
  186. package/dist/helpers/asText.d.ts +0 -47
  187. package/dist/helpers/asText.js +0 -21
  188. package/dist/helpers/asText.js.map +0 -1
  189. package/dist/helpers/documentToLinkField.cjs +0 -27
  190. package/dist/helpers/documentToLinkField.cjs.map +0 -1
  191. package/dist/helpers/documentToLinkField.d.ts +0 -17
  192. package/dist/helpers/documentToLinkField.js +0 -27
  193. package/dist/helpers/documentToLinkField.js.map +0 -1
  194. package/dist/helpers/isFilled.cjs +0 -77
  195. package/dist/helpers/isFilled.cjs.map +0 -1
  196. package/dist/helpers/isFilled.d.ts +0 -190
  197. package/dist/helpers/isFilled.js +0 -77
  198. package/dist/helpers/isFilled.js.map +0 -1
  199. package/dist/helpers/mapSliceZone.cjs +0 -42
  200. package/dist/helpers/mapSliceZone.cjs.map +0 -1
  201. package/dist/helpers/mapSliceZone.d.ts +0 -136
  202. package/dist/helpers/mapSliceZone.js +0 -42
  203. package/dist/helpers/mapSliceZone.js.map +0 -1
  204. package/dist/index.js +0 -97
  205. package/dist/index.js.map +0 -1
  206. package/dist/isRepositoryEndpoint.cjs +0 -12
  207. package/dist/isRepositoryEndpoint.cjs.map +0 -1
  208. package/dist/isRepositoryEndpoint.d.ts +0 -10
  209. package/dist/isRepositoryEndpoint.js +0 -12
  210. package/dist/isRepositoryEndpoint.js.map +0 -1
  211. package/dist/isRepositoryName.cjs +0 -7
  212. package/dist/isRepositoryName.cjs.map +0 -1
  213. package/dist/isRepositoryName.d.ts +0 -9
  214. package/dist/isRepositoryName.js +0 -7
  215. package/dist/isRepositoryName.js.map +0 -1
  216. package/dist/lib/appendFilters.cjs +0 -11
  217. package/dist/lib/appendFilters.cjs.map +0 -1
  218. package/dist/lib/appendFilters.d.ts +0 -18
  219. package/dist/lib/appendFilters.js +0 -11
  220. package/dist/lib/appendFilters.js.map +0 -1
  221. package/dist/lib/castArray.cjs +0 -7
  222. package/dist/lib/castArray.cjs.map +0 -1
  223. package/dist/lib/castArray.d.ts +0 -12
  224. package/dist/lib/castArray.js +0 -7
  225. package/dist/lib/castArray.js.map +0 -1
  226. package/dist/lib/castThunk.cjs +0 -7
  227. package/dist/lib/castThunk.cjs.map +0 -1
  228. package/dist/lib/castThunk.d.ts +0 -11
  229. package/dist/lib/castThunk.js +0 -7
  230. package/dist/lib/castThunk.js.map +0 -1
  231. package/dist/lib/devMsg.cjs +0 -8
  232. package/dist/lib/devMsg.cjs.map +0 -1
  233. package/dist/lib/devMsg.d.ts +0 -16
  234. package/dist/lib/devMsg.js +0 -8
  235. package/dist/lib/devMsg.js.map +0 -1
  236. package/dist/lib/escapeHTML.cjs +0 -43
  237. package/dist/lib/escapeHTML.cjs.map +0 -1
  238. package/dist/lib/escapeHTML.d.ts +0 -1
  239. package/dist/lib/escapeHTML.js +0 -43
  240. package/dist/lib/escapeHTML.js.map +0 -1
  241. package/dist/lib/everyTagFilter.cjs +0 -9
  242. package/dist/lib/everyTagFilter.cjs.map +0 -1
  243. package/dist/lib/everyTagFilter.d.ts +0 -9
  244. package/dist/lib/everyTagFilter.js +0 -9
  245. package/dist/lib/everyTagFilter.js.map +0 -1
  246. package/dist/lib/findMasterRef.cjs +0 -8
  247. package/dist/lib/findMasterRef.cjs.map +0 -1
  248. package/dist/lib/findMasterRef.d.ts +0 -11
  249. package/dist/lib/findMasterRef.js +0 -8
  250. package/dist/lib/findMasterRef.js.map +0 -1
  251. package/dist/lib/findRef.cjs +0 -12
  252. package/dist/lib/findRef.cjs.map +0 -1
  253. package/dist/lib/findRef.d.ts +0 -14
  254. package/dist/lib/findRef.js +0 -12
  255. package/dist/lib/findRef.js.map +0 -1
  256. package/dist/lib/findRefByID.cjs +0 -8
  257. package/dist/lib/findRefByID.cjs.map +0 -1
  258. package/dist/lib/findRefByID.d.ts +0 -12
  259. package/dist/lib/findRefByID.js +0 -8
  260. package/dist/lib/findRefByID.js.map +0 -1
  261. package/dist/lib/findRefByLabel.cjs +0 -8
  262. package/dist/lib/findRefByLabel.cjs.map +0 -1
  263. package/dist/lib/findRefByLabel.d.ts +0 -12
  264. package/dist/lib/findRefByLabel.js +0 -8
  265. package/dist/lib/findRefByLabel.js.map +0 -1
  266. package/dist/lib/getOptionalLinkProperties.cjs +0 -14
  267. package/dist/lib/getOptionalLinkProperties.cjs.map +0 -1
  268. package/dist/lib/getOptionalLinkProperties.d.ts +0 -12
  269. package/dist/lib/getOptionalLinkProperties.js +0 -14
  270. package/dist/lib/getOptionalLinkProperties.js.map +0 -1
  271. package/dist/lib/getPreviewCookie.cjs +0 -21
  272. package/dist/lib/getPreviewCookie.cjs.map +0 -1
  273. package/dist/lib/getPreviewCookie.d.ts +0 -9
  274. package/dist/lib/getPreviewCookie.js +0 -21
  275. package/dist/lib/getPreviewCookie.js.map +0 -1
  276. package/dist/lib/isInternalURL.cjs +0 -9
  277. package/dist/lib/isInternalURL.cjs.map +0 -1
  278. package/dist/lib/isInternalURL.d.ts +0 -8
  279. package/dist/lib/isInternalURL.js +0 -9
  280. package/dist/lib/isInternalURL.js.map +0 -1
  281. package/dist/lib/isMigrationValue.cjs +0 -24
  282. package/dist/lib/isMigrationValue.cjs.map +0 -1
  283. package/dist/lib/isMigrationValue.d.ts +0 -71
  284. package/dist/lib/isMigrationValue.js +0 -24
  285. package/dist/lib/isMigrationValue.js.map +0 -1
  286. package/dist/lib/isValue.cjs +0 -53
  287. package/dist/lib/isValue.cjs.map +0 -1
  288. package/dist/lib/isValue.d.ts +0 -78
  289. package/dist/lib/isValue.js +0 -53
  290. package/dist/lib/isValue.js.map +0 -1
  291. package/dist/lib/minifyGraphQLQuery.cjs +0 -7
  292. package/dist/lib/minifyGraphQLQuery.cjs.map +0 -1
  293. package/dist/lib/minifyGraphQLQuery.d.ts +0 -8
  294. package/dist/lib/minifyGraphQLQuery.js +0 -7
  295. package/dist/lib/minifyGraphQLQuery.js.map +0 -1
  296. package/dist/lib/pLimit.cjs +0 -49
  297. package/dist/lib/pLimit.cjs.map +0 -1
  298. package/dist/lib/pLimit.d.ts +0 -22
  299. package/dist/lib/pLimit.js +0 -49
  300. package/dist/lib/pLimit.js.map +0 -1
  301. package/dist/lib/request.cjs +0 -43
  302. package/dist/lib/request.cjs.map +0 -1
  303. package/dist/lib/request.d.ts +0 -73
  304. package/dist/lib/request.js +0 -43
  305. package/dist/lib/request.js.map +0 -1
  306. package/dist/lib/resolveMigrationDocumentData.cjs +0 -134
  307. package/dist/lib/resolveMigrationDocumentData.cjs.map +0 -1
  308. package/dist/lib/resolveMigrationDocumentData.d.ts +0 -54
  309. package/dist/lib/resolveMigrationDocumentData.js +0 -134
  310. package/dist/lib/resolveMigrationDocumentData.js.map +0 -1
  311. package/dist/lib/serializerHelpers.cjs +0 -113
  312. package/dist/lib/serializerHelpers.cjs.map +0 -1
  313. package/dist/lib/serializerHelpers.d.ts +0 -9
  314. package/dist/lib/serializerHelpers.js +0 -113
  315. package/dist/lib/serializerHelpers.js.map +0 -1
  316. package/dist/lib/someTagsFilter.cjs +0 -9
  317. package/dist/lib/someTagsFilter.cjs.map +0 -1
  318. package/dist/lib/someTagsFilter.d.ts +0 -9
  319. package/dist/lib/someTagsFilter.js +0 -9
  320. package/dist/lib/someTagsFilter.js.map +0 -1
  321. package/dist/lib/throttledLog.cjs +0 -17
  322. package/dist/lib/throttledLog.cjs.map +0 -1
  323. package/dist/lib/throttledLog.d.ts +0 -15
  324. package/dist/lib/throttledLog.js +0 -17
  325. package/dist/lib/throttledLog.js.map +0 -1
  326. package/dist/lib/typeFilter.cjs +0 -8
  327. package/dist/lib/typeFilter.cjs.map +0 -1
  328. package/dist/lib/typeFilter.d.ts +0 -8
  329. package/dist/lib/typeFilter.js +0 -8
  330. package/dist/lib/typeFilter.js.map +0 -1
  331. package/dist/lib/validateAssetMetadata.cjs +0 -28
  332. package/dist/lib/validateAssetMetadata.cjs.map +0 -1
  333. package/dist/lib/validateAssetMetadata.d.ts +0 -10
  334. package/dist/lib/validateAssetMetadata.js +0 -28
  335. package/dist/lib/validateAssetMetadata.js.map +0 -1
  336. package/dist/package.json.cjs +0 -7
  337. package/dist/package.json.cjs.map +0 -1
  338. package/dist/package.json.js +0 -7
  339. package/dist/package.json.js.map +0 -1
  340. package/dist/richtext/asText.cjs +0 -13
  341. package/dist/richtext/asText.cjs.map +0 -1
  342. package/dist/richtext/asText.d.ts +0 -12
  343. package/dist/richtext/asText.js +0 -13
  344. package/dist/richtext/asText.js.map +0 -1
  345. package/dist/richtext/asTree.cjs +0 -123
  346. package/dist/richtext/asTree.cjs.map +0 -1
  347. package/dist/richtext/asTree.d.ts +0 -14
  348. package/dist/richtext/asTree.js +0 -123
  349. package/dist/richtext/asTree.js.map +0 -1
  350. package/dist/richtext/composeSerializers.cjs +0 -17
  351. package/dist/richtext/composeSerializers.cjs.map +0 -1
  352. package/dist/richtext/composeSerializers.d.ts +0 -16
  353. package/dist/richtext/composeSerializers.js +0 -17
  354. package/dist/richtext/composeSerializers.js.map +0 -1
  355. package/dist/richtext/serialize.cjs +0 -19
  356. package/dist/richtext/serialize.cjs.map +0 -1
  357. package/dist/richtext/serialize.d.ts +0 -19
  358. package/dist/richtext/serialize.js +0 -19
  359. package/dist/richtext/serialize.js.map +0 -1
  360. package/dist/richtext/types.cjs +0 -11
  361. package/dist/richtext/types.cjs.map +0 -1
  362. package/dist/richtext/types.d.ts +0 -71
  363. package/dist/richtext/types.js +0 -11
  364. package/dist/richtext/types.js.map +0 -1
  365. package/dist/richtext/wrapMapSerializer.cjs +0 -24
  366. package/dist/richtext/wrapMapSerializer.cjs.map +0 -1
  367. package/dist/richtext/wrapMapSerializer.d.ts +0 -15
  368. package/dist/richtext/wrapMapSerializer.js +0 -24
  369. package/dist/richtext/wrapMapSerializer.js.map +0 -1
  370. package/dist/richtext.cjs +0 -15
  371. package/dist/richtext.cjs.map +0 -1
  372. package/dist/richtext.js +0 -15
  373. package/dist/richtext.js.map +0 -1
  374. package/dist/types/api/asset/asset.d.ts +0 -177
  375. package/dist/types/api/asset/tag.d.ts +0 -53
  376. package/dist/types/api/integration.d.ts +0 -28
  377. package/dist/types/api/migration/document.d.ts +0 -60
  378. package/dist/types/api/query.d.ts +0 -43
  379. package/dist/types/api/ref.d.ts +0 -32
  380. package/dist/types/api/release.d.ts +0 -11
  381. package/dist/types/api/repository.d.ts +0 -109
  382. package/dist/types/api/tags.d.ts +0 -9
  383. package/dist/types/migration/Asset.cjs +0 -33
  384. package/dist/types/migration/Asset.cjs.map +0 -1
  385. package/dist/types/migration/Asset.d.ts +0 -108
  386. package/dist/types/migration/Asset.js +0 -33
  387. package/dist/types/migration/Asset.js.map +0 -1
  388. package/dist/types/migration/ContentRelationship.d.ts +0 -16
  389. package/dist/types/migration/Document.cjs +0 -47
  390. package/dist/types/migration/Document.cjs.map +0 -1
  391. package/dist/types/migration/Document.d.ts +0 -94
  392. package/dist/types/migration/Document.js +0 -47
  393. package/dist/types/migration/Document.js.map +0 -1
  394. package/dist/types/migration/Link.d.ts +0 -19
  395. package/dist/types/model/boolean.d.ts +0 -15
  396. package/dist/types/model/color.d.ts +0 -13
  397. package/dist/types/model/contentRelationship.d.ts +0 -52
  398. package/dist/types/model/customType.d.ts +0 -48
  399. package/dist/types/model/date.d.ts +0 -14
  400. package/dist/types/model/embed.d.ts +0 -13
  401. package/dist/types/model/geoPoint.d.ts +0 -12
  402. package/dist/types/model/group.d.ts +0 -23
  403. package/dist/types/model/image.d.ts +0 -31
  404. package/dist/types/model/integration.d.ts +0 -14
  405. package/dist/types/model/keyText.d.ts +0 -13
  406. package/dist/types/model/link.cjs +0 -9
  407. package/dist/types/model/link.cjs.map +0 -1
  408. package/dist/types/model/link.d.ts +0 -28
  409. package/dist/types/model/link.js +0 -9
  410. package/dist/types/model/link.js.map +0 -1
  411. package/dist/types/model/linkToMedia.d.ts +0 -17
  412. package/dist/types/model/number.d.ts +0 -15
  413. package/dist/types/model/range.d.ts +0 -14
  414. package/dist/types/model/richText.d.ts +0 -37
  415. package/dist/types/model/select.d.ts +0 -18
  416. package/dist/types/model/separator.d.ts +0 -10
  417. package/dist/types/model/sharedSlice.d.ts +0 -16
  418. package/dist/types/model/sharedSliceVariation.d.ts +0 -19
  419. package/dist/types/model/slice.cjs +0 -8
  420. package/dist/types/model/slice.cjs.map +0 -1
  421. package/dist/types/model/slice.d.ts +0 -33
  422. package/dist/types/model/slice.js +0 -8
  423. package/dist/types/model/slice.js.map +0 -1
  424. package/dist/types/model/sliceZone.cjs +0 -8
  425. package/dist/types/model/sliceZone.cjs.map +0 -1
  426. package/dist/types/model/sliceZone.d.ts +0 -41
  427. package/dist/types/model/sliceZone.js +0 -8
  428. package/dist/types/model/sliceZone.js.map +0 -1
  429. package/dist/types/model/table.d.ts +0 -12
  430. package/dist/types/model/timestamp.d.ts +0 -14
  431. package/dist/types/model/title.d.ts +0 -7
  432. package/dist/types/model/types.cjs +0 -39
  433. package/dist/types/model/types.cjs.map +0 -1
  434. package/dist/types/model/types.d.ts +0 -77
  435. package/dist/types/model/types.js +0 -39
  436. package/dist/types/model/types.js.map +0 -1
  437. package/dist/types/model/uid.d.ts +0 -13
  438. package/dist/types/value/boolean.d.ts +0 -6
  439. package/dist/types/value/color.d.ts +0 -9
  440. package/dist/types/value/contentRelationship.d.ts +0 -31
  441. package/dist/types/value/date.d.ts +0 -9
  442. package/dist/types/value/document.d.ts +0 -114
  443. package/dist/types/value/embed.cjs +0 -10
  444. package/dist/types/value/embed.cjs.map +0 -1
  445. package/dist/types/value/embed.d.ts +0 -168
  446. package/dist/types/value/embed.js +0 -10
  447. package/dist/types/value/embed.js.map +0 -1
  448. package/dist/types/value/geoPoint.d.ts +0 -12
  449. package/dist/types/value/group.d.ts +0 -13
  450. package/dist/types/value/image.d.ts +0 -47
  451. package/dist/types/value/integration.d.ts +0 -16
  452. package/dist/types/value/keyText.d.ts +0 -9
  453. package/dist/types/value/link.cjs +0 -10
  454. package/dist/types/value/link.cjs.map +0 -1
  455. package/dist/types/value/link.d.ts +0 -68
  456. package/dist/types/value/link.js +0 -10
  457. package/dist/types/value/link.js.map +0 -1
  458. package/dist/types/value/linkToMedia.d.ts +0 -28
  459. package/dist/types/value/number.d.ts +0 -9
  460. package/dist/types/value/richText.cjs +0 -25
  461. package/dist/types/value/richText.cjs.map +0 -1
  462. package/dist/types/value/richText.d.ts +0 -215
  463. package/dist/types/value/richText.js +0 -25
  464. package/dist/types/value/richText.js.map +0 -1
  465. package/dist/types/value/select.d.ts +0 -10
  466. package/dist/types/value/sharedSlice.d.ts +0 -11
  467. package/dist/types/value/sharedSliceVariation.d.ts +0 -10
  468. package/dist/types/value/slice.d.ts +0 -13
  469. package/dist/types/value/sliceZone.d.ts +0 -12
  470. package/dist/types/value/table.d.ts +0 -91
  471. package/dist/types/value/timestamp.d.ts +0 -8
  472. package/dist/types/value/title.d.ts +0 -12
  473. package/dist/types/value/types.d.ts +0 -58
  474. package/dist/types/webhook/apiUpdate.d.ts +0 -52
  475. package/dist/types/webhook/testTrigger.d.ts +0 -9
  476. package/dist/types/webhook/types.cjs +0 -8
  477. package/dist/types/webhook/types.cjs.map +0 -1
  478. package/dist/types/webhook/types.d.ts +0 -18
  479. package/dist/types/webhook/types.js +0 -8
  480. package/dist/types/webhook/types.js.map +0 -1
@@ -1,73 +0,0 @@
1
- /**
2
- * The default number of milliseconds to wait before retrying a rate-limited
3
- * `fetch()` request (429 response code). The default value is only used if the
4
- * response does not include a `retry-after` header.
5
- */
6
- export declare const DEFAULT_RETRY_AFTER = 1500;
7
- /**
8
- * A universal API to make network requests. A subset of the `fetch()` API.
9
- *
10
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
11
- */
12
- export type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
13
- /**
14
- * An object that allows you to abort a `fetch()` request if needed via an
15
- * `AbortController` object
16
- *
17
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
18
- */
19
- export type AbortSignalLike = any;
20
- /**
21
- * A subset of RequestInit properties to configure a `fetch()` request.
22
- */
23
- export interface RequestInitLike extends Pick<RequestInit, "cache"> {
24
- /**
25
- * The HTTP method to use for the request.
26
- */
27
- method?: string;
28
- /**
29
- * The request body to send with the request.
30
- */
31
- body?: any | FormData | string;
32
- /**
33
- * An object literal to set the `fetch()` request's headers.
34
- */
35
- headers?: Record<string, string>;
36
- /**
37
- * An AbortSignal to set the `fetch()` request's signal.
38
- *
39
- * See:
40
- * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
41
- */
42
- signal?: AbortSignalLike;
43
- }
44
- /**
45
- * The minimum required properties from Response.
46
- */
47
- export interface ResponseLike {
48
- ok: boolean;
49
- status: number;
50
- headers: HeadersLike;
51
- url: string;
52
- json(): Promise<any>;
53
- text(): Promise<string>;
54
- blob(): Promise<Blob>;
55
- clone(): ResponseLike;
56
- }
57
- /**
58
- * The minimum required properties from Headers.
59
- */
60
- export interface HeadersLike {
61
- get(name: string): string | null;
62
- }
63
- /**
64
- * Makes an HTTP request with automatic retry for rate limits and request
65
- * deduplication.
66
- *
67
- * @param url - The URL to request.
68
- * @param init - Fetch options.
69
- * @param fetchFn - The fetch function to use.
70
- *
71
- * @returns The response from the fetch request.
72
- */
73
- export declare function request(url: URL, init: RequestInitLike | undefined, fetchFn: FetchLike): Promise<ResponseLike>;
@@ -1,43 +0,0 @@
1
- import { pLimit } from "./pLimit.js";
2
- const DEFAULT_RETRY_AFTER = 1500;
3
- const THROTTLED_RUNNERS = {};
4
- const DEDUPLICATED_JOBS = {};
5
- async function request(url, init, fetchFn) {
6
- var _a, _b;
7
- const stringURL = url.toString();
8
- let job;
9
- if (init == null ? void 0 : init.body) {
10
- const runner = THROTTLED_RUNNERS[_a = url.hostname] || (THROTTLED_RUNNERS[_a] = pLimit({
11
- interval: DEFAULT_RETRY_AFTER
12
- }));
13
- job = runner(() => fetchFn(stringURL, init));
14
- } else {
15
- const existingJob = (_b = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _b.get(init == null ? void 0 : init.signal);
16
- if (existingJob) {
17
- job = existingJob;
18
- } else {
19
- job = fetchFn(stringURL, init).finally(() => {
20
- var _a2, _b2;
21
- (_a2 = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _a2.delete(init == null ? void 0 : init.signal);
22
- if (((_b2 = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _b2.size) === 0) {
23
- delete DEDUPLICATED_JOBS[stringURL];
24
- }
25
- });
26
- const map = DEDUPLICATED_JOBS[stringURL] || (DEDUPLICATED_JOBS[stringURL] = /* @__PURE__ */ new Map());
27
- map.set(init == null ? void 0 : init.signal, job);
28
- }
29
- }
30
- const response = await job;
31
- if (response.status === 429) {
32
- const retryAfter = Number(response.headers.get("retry-after"));
33
- const resolvedRetryAfter = Number.isNaN(retryAfter) ? DEFAULT_RETRY_AFTER : retryAfter * 1e3;
34
- await new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter));
35
- return request(url, init, fetchFn);
36
- }
37
- return response.clone();
38
- }
39
- export {
40
- DEFAULT_RETRY_AFTER,
41
- request
42
- };
43
- //# sourceMappingURL=request.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request.js","sources":["../../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init).finally(() => {\n\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response.clone()\n}\n"],"names":["_a","_b"],"mappings":";AAOO,MAAM,sBAAsB;AAKnC,MAAM,oBAA4D,CAAA;AAMlE,MAAM,oBAEF,CAAA;AAgGkB,eAAA,QACrB,KACA,MACA,SAAkB;;AAEZ,QAAA,YAAY,IAAI;AAElB,MAAA;AAGJ,MAAI,6BAAM,MAAM;AAEf,UAAM,SAAU,uBAAkB,IAAI,cAAtB,wBAAoC,OAAO;AAAA,MAC1D,UAAU;AAAA,IAAA,CACV;AAED,UAAM,OAAO,MAAM,QAAQ,WAAW,IAAI,CAAC;AAAA,EAAA,OACrC;AAEN,UAAM,eAAc,uBAAkB,SAAS,MAA3B,mBAA8B,IAAI,6BAAM;AAC5D,QAAI,aAAa;AACV,YAAA;AAAA,IAAA,OACA;AACN,YAAM,QAAQ,WAAW,IAAI,EAAE,QAAQ,MAAK;;AAC3C,SAAAA,MAAA,kBAAkB,SAAS,MAA3B,gBAAAA,IAA8B,OAAO,6BAAM;AAC3C,cAAIC,MAAA,kBAAkB,SAAS,MAA3B,gBAAAA,IAA8B,UAAS,GAAG;AAC7C,iBAAO,kBAAkB,SAAS;AAAA,QAAA;AAAA,MACnC,CACA;AACD,YAAM,MAAO,oFAAqC,IAAK;AACnD,UAAA,IAAI,6BAAM,QAAQ,GAAG;AAAA,IAAA;AAAA,EAC1B;AAGD,QAAM,WAAW,MAAM;AAGnB,MAAA,SAAS,WAAW,KAAK;AAC5B,UAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;AAC7D,UAAM,qBAAqB,OAAO,MAAM,UAAU,IAC/C,sBACA,aAAa;AAEhB,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,kBAAkB,CAAC;AAE/D,WAAA,QAAQ,KAAK,MAAM,OAAO;AAAA,EAAA;AAGlC,SAAO,SAAS,MAAK;AACtB;"}
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Asset = require("../types/migration/Asset.cjs");
4
- const Document = require("../types/migration/Document.cjs");
5
- const link = require("../types/value/link.cjs");
6
- const richText = require("../types/value/richText.cjs");
7
- const isFilled = require("../helpers/isFilled.cjs");
8
- const isMigrationValue = require("./isMigrationValue.cjs");
9
- const getOptionalLinkProperties = require("./getOptionalLinkProperties.cjs");
10
- async function resolveMigrationContentRelationship(relation) {
11
- if (typeof relation === "function") {
12
- return resolveMigrationContentRelationship(await relation());
13
- }
14
- if (relation instanceof Document.PrismicMigrationDocument) {
15
- return relation.document.id ? { link_type: link.LinkType.Document, id: relation.document.id } : { link_type: link.LinkType.Any };
16
- }
17
- const optionalLinkProperties = relation && "link_type" in relation ? getOptionalLinkProperties.getOptionalLinkProperties(relation) : void 0;
18
- if (relation) {
19
- if (isMigrationValue.contentRelationship(relation.id) || typeof relation.id !== "string") {
20
- return {
21
- ...optionalLinkProperties,
22
- ...await resolveMigrationContentRelationship(relation.id)
23
- };
24
- }
25
- return {
26
- ...optionalLinkProperties,
27
- link_type: link.LinkType.Document,
28
- id: relation.id
29
- };
30
- }
31
- return {
32
- ...optionalLinkProperties,
33
- link_type: link.LinkType.Any
34
- };
35
- }
36
- const resolveMigrationImage = (image, migration, withThumbnails) => {
37
- var _a;
38
- const { id: master, ...thumbnails } = image instanceof Asset.PrismicMigrationAsset ? { id: image } : image;
39
- const asset = (_a = migration._assets.get(master.config.id)) == null ? void 0 : _a.asset;
40
- const maybeInitialField = master.originalField;
41
- if (asset) {
42
- const parameters = ((maybeInitialField == null ? void 0 : maybeInitialField.url) || asset.url).split("?")[1];
43
- const url = `${asset.url.split("?")[0]}${parameters ? `?${parameters}` : ""}`;
44
- const dimensions = {
45
- width: asset.width,
46
- height: asset.height
47
- };
48
- const edit = maybeInitialField && "edit" in maybeInitialField ? maybeInitialField == null ? void 0 : maybeInitialField.edit : { x: 0, y: 0, zoom: 1, background: "transparent" };
49
- const alt = master.config.alt || asset.alt || null;
50
- const resolvedThumbnails = {};
51
- if (withThumbnails) {
52
- for (const [name, thumbnail] of Object.entries(thumbnails)) {
53
- const resolvedThumbnail = resolveMigrationImage(thumbnail, migration);
54
- if (resolvedThumbnail) {
55
- resolvedThumbnails[name] = resolvedThumbnail;
56
- }
57
- }
58
- }
59
- return {
60
- id: asset.id,
61
- url,
62
- dimensions,
63
- edit,
64
- alt,
65
- copyright: asset.credits || null,
66
- ...resolvedThumbnails
67
- };
68
- }
69
- };
70
- const resolveMigrationRTImageNode = async (rtImageNode, migration) => {
71
- const image = resolveMigrationImage(rtImageNode.id, migration);
72
- if (image) {
73
- const linkTo = await resolveMigrationDocumentData(rtImageNode.linkTo, migration);
74
- return {
75
- ...image,
76
- type: richText.RichTextNodeType.image,
77
- linkTo: isFilled.link(linkTo) ? linkTo : void 0
78
- };
79
- }
80
- };
81
- const resolveMigrationLinkToMedia = (linkToMedia, migration) => {
82
- var _a;
83
- const asset = (_a = migration._assets.get(linkToMedia.id.config.id)) == null ? void 0 : _a.asset;
84
- const optionalLinkProperties = getOptionalLinkProperties.getOptionalLinkProperties(linkToMedia);
85
- if (asset) {
86
- return {
87
- ...optionalLinkProperties,
88
- id: asset.id,
89
- link_type: link.LinkType.Media
90
- };
91
- }
92
- return {
93
- ...optionalLinkProperties,
94
- link_type: link.LinkType.Any
95
- };
96
- };
97
- async function resolveMigrationDocumentData(input, migration) {
98
- if (isMigrationValue.contentRelationship(input)) {
99
- return resolveMigrationContentRelationship(input);
100
- }
101
- if (isMigrationValue.image(input)) {
102
- return resolveMigrationImage(input, migration, true);
103
- }
104
- if (isMigrationValue.linkToMedia(input)) {
105
- return resolveMigrationLinkToMedia(input, migration);
106
- }
107
- if (isMigrationValue.rtImageNode(input)) {
108
- return resolveMigrationRTImageNode(input, migration);
109
- }
110
- if (typeof input === "function") {
111
- return await resolveMigrationDocumentData(await input(), migration);
112
- }
113
- if (Array.isArray(input)) {
114
- const res = [];
115
- for (const element of input) {
116
- res.push(await resolveMigrationDocumentData(element, migration));
117
- }
118
- return res.filter(Boolean);
119
- }
120
- if (input && typeof input === "object") {
121
- const res = {};
122
- for (const key in input) {
123
- res[key] = await resolveMigrationDocumentData(input[key], migration);
124
- }
125
- return res;
126
- }
127
- return input;
128
- }
129
- exports.resolveMigrationContentRelationship = resolveMigrationContentRelationship;
130
- exports.resolveMigrationDocumentData = resolveMigrationDocumentData;
131
- exports.resolveMigrationImage = resolveMigrationImage;
132
- exports.resolveMigrationLinkToMedia = resolveMigrationLinkToMedia;
133
- exports.resolveMigrationRTImageNode = resolveMigrationRTImageNode;
134
- //# sourceMappingURL=resolveMigrationDocumentData.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveMigrationDocumentData.cjs","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"],"names":["PrismicMigrationDocument","LinkType","getOptionalLinkProperties","isMigration.contentRelationship","PrismicMigrationAsset","RichTextNodeType","isFilled.link","isMigration.image","isMigration.linkToMedia","isMigration.rtImageNode"],"mappings":";;;;;;;;;AAgCA,eAAsB,oCACrB,UAAiD;AAE7C,MAAA,OAAO,aAAa,YAAY;AAC5B,WAAA,oCAAoC,MAAM,UAAU;AAAA,EAAA;AAG5D,MAAI,oBAAoBA,SAAAA,0BAA0B;AACjD,WAAO,SAAS,SAAS,KACtB,EAAE,WAAWC,KAAS,SAAA,UAAU,IAAI,SAAS,SAAS,GAAI,IAC1D,EAAE,WAAWA,cAAS;;AAG1B,QAAM,yBACL,YAAY,eAAe,WACxBC,0BAA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AAS,SAAS;AAAA,EAAA;AAI/D,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,UAAM,MAAM,CAAA;AAEZ,eAAW,WAAW,OAAO;AAC5B,UAAI,KAAK,MAAM,6BAA6B,SAAS,SAAS,CAAC;AAAA,IAAA;AAGzD,WAAA,IAAI,OAAO,OAAO;AAAA,EAAA;AAGtB,MAAA,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,MAAoC,CAAA;AAE1C,eAAW,OAAO,OAAO;AACxB,UAAI,GAAG,IAAI,MAAM,6BAChB,MAAM,GAAyB,GAC/B,SAAS;AAAA,IAAA;AAIJ,WAAA;AAAA,EAAA;AAID,SAAA;AACR;;;;;;"}
@@ -1,54 +0,0 @@
1
- import type { MigrationLinkToMediaField } from "../types/migration/Asset";
2
- import { type MigrationImage, type MigrationLinkToMedia, type MigrationRTImageNode } from "../types/migration/Asset";
3
- import type { MigrationContentRelationship, MigrationContentRelationshipField } from "../types/migration/ContentRelationship";
4
- import type { MaybeLink } from "../types/migration/Link";
5
- import type { FilledImageFieldImage } from "../types/value/image";
6
- import type { OptionalLinkProperties } from "../types/value/link";
7
- import type { RTImageNode } from "../types/value/richText";
8
- import type { Migration } from "../Migration";
9
- /**
10
- * Resolves a migration content relationship to a content relationship field.
11
- *
12
- * @param relation - Content relationship to resolve.
13
- *
14
- * @returns Resolved content relationship field.
15
- */
16
- export declare function resolveMigrationContentRelationship(relation: MaybeLink<MigrationContentRelationship>): Promise<MigrationContentRelationshipField & OptionalLinkProperties>;
17
- /**
18
- * Resolves a migration image to an image field.
19
- *
20
- * @param migrationAsset - Asset to resolve.
21
- * @param migration - Migration instance.
22
- * @param withThumbnails - Whether to include thumbnails.
23
- *
24
- * @returns Resolved image field.
25
- */
26
- export declare const resolveMigrationImage: (image: MigrationImage, migration: Migration, withThumbnails?: boolean) => FilledImageFieldImage | undefined;
27
- /**
28
- * Resolves a migration rich text image node to a regular rich text image node.
29
- *
30
- * @param rtImageNode - Migration rich text image node to resolve.
31
- * @param migration - Migration instance.
32
- *
33
- * @returns Resolved rich text image node.
34
- */
35
- export declare const resolveMigrationRTImageNode: (rtImageNode: MigrationRTImageNode, migration: Migration) => Promise<RTImageNode | undefined>;
36
- /**
37
- * Resolves a migration link to media to a regular link to media field.
38
- *
39
- * @param linkToMedia - Migration link to media to resolve.
40
- * @param migration - Migration instance.
41
- *
42
- * @returns Resolved link to media field.
43
- */
44
- export declare const resolveMigrationLinkToMedia: (linkToMedia: MaybeLink<MigrationLinkToMedia>, migration: Migration) => MigrationLinkToMediaField;
45
- /**
46
- * Resolves a migration document data to actual data ready to be sent to the
47
- * Migration API.
48
- *
49
- * @param input - Migration link to media to resolve.
50
- * @param migration - Migration instance.
51
- *
52
- * @returns Resolved data.
53
- */
54
- export declare function resolveMigrationDocumentData(input: unknown, migration: Migration): Promise<unknown>;
@@ -1,134 +0,0 @@
1
- import { PrismicMigrationAsset } from "../types/migration/Asset.js";
2
- import { PrismicMigrationDocument } from "../types/migration/Document.js";
3
- import { LinkType } from "../types/value/link.js";
4
- import { RichTextNodeType } from "../types/value/richText.js";
5
- import { link } from "../helpers/isFilled.js";
6
- import { contentRelationship, image, linkToMedia, rtImageNode } from "./isMigrationValue.js";
7
- import { getOptionalLinkProperties } from "./getOptionalLinkProperties.js";
8
- async function resolveMigrationContentRelationship(relation) {
9
- if (typeof relation === "function") {
10
- return resolveMigrationContentRelationship(await relation());
11
- }
12
- if (relation instanceof PrismicMigrationDocument) {
13
- return relation.document.id ? { link_type: LinkType.Document, id: relation.document.id } : { link_type: LinkType.Any };
14
- }
15
- const optionalLinkProperties = relation && "link_type" in relation ? getOptionalLinkProperties(relation) : void 0;
16
- if (relation) {
17
- if (contentRelationship(relation.id) || typeof relation.id !== "string") {
18
- return {
19
- ...optionalLinkProperties,
20
- ...await resolveMigrationContentRelationship(relation.id)
21
- };
22
- }
23
- return {
24
- ...optionalLinkProperties,
25
- link_type: LinkType.Document,
26
- id: relation.id
27
- };
28
- }
29
- return {
30
- ...optionalLinkProperties,
31
- link_type: LinkType.Any
32
- };
33
- }
34
- const resolveMigrationImage = (image2, migration, withThumbnails) => {
35
- var _a;
36
- const { id: master, ...thumbnails } = image2 instanceof PrismicMigrationAsset ? { id: image2 } : image2;
37
- const asset = (_a = migration._assets.get(master.config.id)) == null ? void 0 : _a.asset;
38
- const maybeInitialField = master.originalField;
39
- if (asset) {
40
- const parameters = ((maybeInitialField == null ? void 0 : maybeInitialField.url) || asset.url).split("?")[1];
41
- const url = `${asset.url.split("?")[0]}${parameters ? `?${parameters}` : ""}`;
42
- const dimensions = {
43
- width: asset.width,
44
- height: asset.height
45
- };
46
- const edit = maybeInitialField && "edit" in maybeInitialField ? maybeInitialField == null ? void 0 : maybeInitialField.edit : { x: 0, y: 0, zoom: 1, background: "transparent" };
47
- const alt = master.config.alt || asset.alt || null;
48
- const resolvedThumbnails = {};
49
- if (withThumbnails) {
50
- for (const [name, thumbnail] of Object.entries(thumbnails)) {
51
- const resolvedThumbnail = resolveMigrationImage(thumbnail, migration);
52
- if (resolvedThumbnail) {
53
- resolvedThumbnails[name] = resolvedThumbnail;
54
- }
55
- }
56
- }
57
- return {
58
- id: asset.id,
59
- url,
60
- dimensions,
61
- edit,
62
- alt,
63
- copyright: asset.credits || null,
64
- ...resolvedThumbnails
65
- };
66
- }
67
- };
68
- const resolveMigrationRTImageNode = async (rtImageNode2, migration) => {
69
- const image2 = resolveMigrationImage(rtImageNode2.id, migration);
70
- if (image2) {
71
- const linkTo = await resolveMigrationDocumentData(rtImageNode2.linkTo, migration);
72
- return {
73
- ...image2,
74
- type: RichTextNodeType.image,
75
- linkTo: link(linkTo) ? linkTo : void 0
76
- };
77
- }
78
- };
79
- const resolveMigrationLinkToMedia = (linkToMedia2, migration) => {
80
- var _a;
81
- const asset = (_a = migration._assets.get(linkToMedia2.id.config.id)) == null ? void 0 : _a.asset;
82
- const optionalLinkProperties = getOptionalLinkProperties(linkToMedia2);
83
- if (asset) {
84
- return {
85
- ...optionalLinkProperties,
86
- id: asset.id,
87
- link_type: LinkType.Media
88
- };
89
- }
90
- return {
91
- ...optionalLinkProperties,
92
- link_type: LinkType.Any
93
- };
94
- };
95
- async function resolveMigrationDocumentData(input, migration) {
96
- if (contentRelationship(input)) {
97
- return resolveMigrationContentRelationship(input);
98
- }
99
- if (image(input)) {
100
- return resolveMigrationImage(input, migration, true);
101
- }
102
- if (linkToMedia(input)) {
103
- return resolveMigrationLinkToMedia(input, migration);
104
- }
105
- if (rtImageNode(input)) {
106
- return resolveMigrationRTImageNode(input, migration);
107
- }
108
- if (typeof input === "function") {
109
- return await resolveMigrationDocumentData(await input(), migration);
110
- }
111
- if (Array.isArray(input)) {
112
- const res = [];
113
- for (const element of input) {
114
- res.push(await resolveMigrationDocumentData(element, migration));
115
- }
116
- return res.filter(Boolean);
117
- }
118
- if (input && typeof input === "object") {
119
- const res = {};
120
- for (const key in input) {
121
- res[key] = await resolveMigrationDocumentData(input[key], migration);
122
- }
123
- return res;
124
- }
125
- return input;
126
- }
127
- export {
128
- resolveMigrationContentRelationship,
129
- resolveMigrationDocumentData,
130
- resolveMigrationImage,
131
- resolveMigrationLinkToMedia,
132
- resolveMigrationRTImageNode
133
- };
134
- //# sourceMappingURL=resolveMigrationDocumentData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveMigrationDocumentData.js","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"],"names":["isMigration.contentRelationship","image","rtImageNode","isFilled.link","linkToMedia","isMigration.image","isMigration.linkToMedia","isMigration.rtImageNode"],"mappings":";;;;;;;AAgCA,eAAsB,oCACrB,UAAiD;AAE7C,MAAA,OAAO,aAAa,YAAY;AAC5B,WAAA,oCAAoC,MAAM,UAAU;AAAA,EAAA;AAG5D,MAAI,oBAAoB,0BAA0B;AACjD,WAAO,SAAS,SAAS,KACtB,EAAE,WAAW,SAAS,UAAU,IAAI,SAAS,SAAS,GAAI,IAC1D,EAAE,WAAW,SAAS;;AAG1B,QAAM,yBACL,YAAY,eAAe,WACxB,0BAA0B,QAAQ,IAClC;AAEJ,MAAI,UAAU;AAEZ,QAAAA,oBAAgC,SAAS,EAAE,KAC3C,OAAO,SAAS,OAAO,UACtB;AACM,aAAA;AAAA,QACN,GAAG;AAAA,QACH,GAAI,MAAM,oCAAoC,SAAS,EAAE;AAAA;;AAOpD,WAAA;AAAA,MACN,GAAG;AAAA,MACH,WAAW,SAAS;AAAA,MACpB,IAAI,SAAS;AAAA;;AAIR,SAAA;AAAA,IACN,GAAG;AAAA,IACH,WAAW,SAAS;AAAA;AAEtB;AAWO,MAAM,wBAAwB,CACpCC,QACA,WACA,mBACsC;;AAChC,QAAA,EAAE,IAAI,QAAQ,GAAG,WACtB,IAAAA,kBAAiB,wBAAwB,EAAE,IAAIA,OAAA,IAAUA;AAE1D,QAAM,SAAQ,eAAU,QAAQ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,MAA9C,mBAAiD;AACzD,QAAA,yBAAyB,0BAA0BA,YAAW;AAEpE,MAAI,OAAO;AACH,WAAA;AAAA,MACN,GAAG;AAAA,MACH,IAAI,MAAM;AAAA,MACV,WAAW,SAAS;AAAA;;AAIf,SAAA;AAAA,IACN,GAAG;AAAA,IACH,WAAW,SAAS;AAAA;AAEtB;AAWsB,eAAA,6BACrB,OACA,WAAoB;AAGhB,MAAAJ,oBAAgC,KAAK,GAAG;AAC3C,WAAO,oCAAoC,KAAK;AAAA,EAAA;AAG7C,MAAAK,MAAkB,KAAK,GAAG;AACtB,WAAA,sBAAsB,OAAO,WAAW,IAAI;AAAA,EAAA;AAGhD,MAAAC,YAAwB,KAAK,GAAG;AAC5B,WAAA,4BAA4B,OAAO,SAAS;AAAA,EAAA;AAGhD,MAAAC,YAAwB,KAAK,GAAG;AAC5B,WAAA,4BAA4B,OAAO,SAAS;AAAA,EAAA;AAGhD,MAAA,OAAO,UAAU,YAAY;AAChC,WAAO,MAAM,6BAA6B,MAAM,MAAA,GAAS,SAAS;AAAA,EAAA;AAI/D,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,UAAM,MAAM,CAAA;AAEZ,eAAW,WAAW,OAAO;AAC5B,UAAI,KAAK,MAAM,6BAA6B,SAAS,SAAS,CAAC;AAAA,IAAA;AAGzD,WAAA,IAAI,OAAO,OAAO;AAAA,EAAA;AAGtB,MAAA,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,MAAoC,CAAA;AAE1C,eAAW,OAAO,OAAO;AACxB,UAAI,GAAG,IAAI,MAAM,6BAChB,MAAM,GAAyB,GAC/B,SAAS;AAAA,IAAA;AAIJ,WAAA;AAAA,EAAA;AAID,SAAA;AACR;"}
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const link = require("../types/value/link.cjs");
4
- const asLink = require("../helpers/asLink.cjs");
5
- const escapeHTML = require("./escapeHTML.cjs");
6
- const formatAttributes = (node, attributes) => {
7
- const _attributes = { ...attributes };
8
- if ("direction" in node && node.direction === "rtl") {
9
- _attributes.dir = node.direction;
10
- }
11
- if ("data" in node && "label" in node.data && node.data.label) {
12
- _attributes.class = _attributes.class ? `${_attributes.class} ${node.data.label}` : node.data.label;
13
- }
14
- const result = [];
15
- for (const key in _attributes) {
16
- const value = _attributes[key];
17
- if (value) {
18
- if (typeof value === "boolean") {
19
- result.push(key);
20
- } else {
21
- result.push(`${key}="${escapeHTML.escapeHTML(value)}"`);
22
- }
23
- }
24
- }
25
- if (result.length) {
26
- result.unshift("");
27
- }
28
- return result.join(" ");
29
- };
30
- const getGeneralAttributes = (serializerOrShorthand) => {
31
- return serializerOrShorthand && typeof serializerOrShorthand !== "function" ? serializerOrShorthand : {};
32
- };
33
- const serializeStandardTag = (tag, serializerOrShorthand) => {
34
- const generalAttributes = getGeneralAttributes(serializerOrShorthand);
35
- return ({ node, children }) => {
36
- return `<${tag}${formatAttributes(node, generalAttributes)}>${children}</${tag}>`;
37
- };
38
- };
39
- const serializePreFormatted = (serializerOrShorthand) => {
40
- const generalAttributes = getGeneralAttributes(serializerOrShorthand);
41
- return ({ node }) => {
42
- return `<pre${formatAttributes(node, generalAttributes)}>${escapeHTML.escapeHTML(node.text)}</pre>`;
43
- };
44
- };
45
- const serializeImage = (linkResolver, serializerOrShorthand) => {
46
- const generalAttributes = getGeneralAttributes(serializerOrShorthand);
47
- return ({ node }) => {
48
- const attributes = {
49
- ...generalAttributes,
50
- src: node.url,
51
- alt: node.alt,
52
- copyright: node.copyright
53
- };
54
- let imageTag = `<img${formatAttributes(node, attributes)} />`;
55
- if (node.linkTo) {
56
- imageTag = serializeHyperlink(linkResolver)({
57
- type: "hyperlink",
58
- node: {
59
- type: "hyperlink",
60
- data: node.linkTo,
61
- start: 0,
62
- end: 0
63
- },
64
- text: "",
65
- children: imageTag,
66
- key: ""
67
- });
68
- }
69
- return `<p class="block-img">${imageTag}</p>`;
70
- };
71
- };
72
- const serializeEmbed = (serializerOrShorthand) => {
73
- const generalAttributes = getGeneralAttributes(serializerOrShorthand);
74
- return ({ node }) => {
75
- const attributes = {
76
- ...generalAttributes,
77
- ["data-oembed"]: node.oembed.embed_url,
78
- ["data-oembed-type"]: node.oembed.type,
79
- ["data-oembed-provider"]: node.oembed.provider_name
80
- };
81
- return `<div${formatAttributes(node, attributes)}>${node.oembed.html}</div>`;
82
- };
83
- };
84
- const serializeHyperlink = (linkResolver, serializerOrShorthand) => {
85
- const generalAttributes = getGeneralAttributes(serializerOrShorthand);
86
- return ({ node, children }) => {
87
- const attributes = {
88
- ...generalAttributes
89
- };
90
- if (node.data.link_type === link.LinkType.Web) {
91
- attributes.href = node.data.url;
92
- attributes.target = node.data.target;
93
- attributes.rel = "noopener noreferrer";
94
- } else if (node.data.link_type === link.LinkType.Document) {
95
- attributes.href = asLink.asLink(node.data, { linkResolver });
96
- } else if (node.data.link_type === link.LinkType.Media) {
97
- attributes.href = node.data.url;
98
- }
99
- return `<a${formatAttributes(node, attributes)}>${children}</a>`;
100
- };
101
- };
102
- const serializeSpan = () => {
103
- return ({ text }) => {
104
- return text ? escapeHTML.escapeHTML(text).replace(/\n/g, "<br />") : "";
105
- };
106
- };
107
- exports.serializeEmbed = serializeEmbed;
108
- exports.serializeHyperlink = serializeHyperlink;
109
- exports.serializeImage = serializeImage;
110
- exports.serializePreFormatted = serializePreFormatted;
111
- exports.serializeSpan = serializeSpan;
112
- exports.serializeStandardTag = serializeStandardTag;
113
- //# sourceMappingURL=serializerHelpers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializerHelpers.cjs","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"],"names":["escapeHTML","LinkType","asLink"],"mappings":";;;;;AAcA,MAAM,mBAAmB,CAAC,MAAiB,eAAkC;AACtE,QAAA,cAAc,EAAE,GAAG;AAGzB,MAAI,eAAe,QAAQ,KAAK,cAAc,OAAO;AACpD,gBAAY,MAAM,KAAK;AAAA,EAAA;AAIxB,MAAI,UAAU,QAAQ,WAAW,KAAK,QAAQ,KAAK,KAAK,OAAO;AAC9D,gBAAY,QAAQ,YAAY,QAC7B,GAAG,YAAY,KAAK,IAAI,KAAK,KAAK,KAAK,KACvC,KAAK,KAAK;AAAA,EAAA;AAGd,QAAM,SAAS,CAAA;A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AAE,QAAQ,OAAO,QAAQ,IAAI;AAAA,EAC3D;AACD;;;;;;;"}
@@ -1,9 +0,0 @@
1
- import type { RichTextMapSerializer } from "../richtext/types";
2
- import type { HTMLRichTextMapSerializer, HTMLStrictRichTextMapSerializer } from "../helpers/asHTML";
3
- import type { LinkResolverFunction } from "../helpers/asLink";
4
- export declare const serializeStandardTag: <BlockType extends keyof RichTextMapSerializer<string>>(tag: string, serializerOrShorthand?: HTMLRichTextMapSerializer[BlockType]) => NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>;
5
- export declare const serializePreFormatted: (serializerOrShorthand?: HTMLRichTextMapSerializer["preformatted"]) => NonNullable<HTMLStrictRichTextMapSerializer["preformatted"]>;
6
- export declare const serializeImage: (linkResolver: LinkResolverFunction<string | null | undefined> | undefined | null, serializerOrShorthand?: HTMLRichTextMapSerializer["image"]) => NonNullable<HTMLStrictRichTextMapSerializer["image"]>;
7
- export declare const serializeEmbed: (serializerOrShorthand?: HTMLRichTextMapSerializer["embed"]) => NonNullable<HTMLStrictRichTextMapSerializer["embed"]>;
8
- export declare const serializeHyperlink: (linkResolver: LinkResolverFunction<string | null | undefined> | undefined | null, serializerOrShorthand?: HTMLRichTextMapSerializer["hyperlink"]) => NonNullable<HTMLStrictRichTextMapSerializer["hyperlink"]>;
9
- export declare const serializeSpan: () => NonNullable<HTMLStrictRichTextMapSerializer["span"]>;