@prismicio/client 7.20.2-alpha.0 → 7.20.3

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 (276) hide show
  1. package/dist/Client.cjs +120 -132
  2. package/dist/Client.cjs.map +1 -1
  3. package/dist/Client.d.ts +7 -7
  4. package/dist/Client.js +120 -132
  5. package/dist/Client.js.map +1 -1
  6. package/dist/Migration.cjs +83 -101
  7. package/dist/Migration.cjs.map +1 -1
  8. package/dist/Migration.d.ts +9 -9
  9. package/dist/Migration.js +83 -101
  10. package/dist/Migration.js.map +1 -1
  11. package/dist/WriteClient.cjs +115 -92
  12. package/dist/WriteClient.cjs.map +1 -1
  13. package/dist/WriteClient.d.ts +6 -6
  14. package/dist/WriteClient.js +115 -92
  15. package/dist/WriteClient.js.map +1 -1
  16. package/dist/buildQueryURL.cjs.map +1 -1
  17. package/dist/buildQueryURL.d.ts +29 -21
  18. package/dist/buildQueryURL.js.map +1 -1
  19. package/dist/createClient.cjs.map +1 -1
  20. package/dist/createClient.d.ts +13 -10
  21. package/dist/createClient.js.map +1 -1
  22. package/dist/createMigration.cjs.map +1 -1
  23. package/dist/createMigration.d.ts +2 -2
  24. package/dist/createMigration.js.map +1 -1
  25. package/dist/createWriteClient.cjs.map +1 -1
  26. package/dist/createWriteClient.d.ts +2 -2
  27. package/dist/errors/ForbiddenError.d.ts +1 -1
  28. package/dist/errors/InvalidDataError.d.ts +1 -1
  29. package/dist/errors/NotFoundError.d.ts +1 -1
  30. package/dist/errors/ParsingError.d.ts +1 -1
  31. package/dist/errors/PreviewTokenExpired.d.ts +1 -1
  32. package/dist/errors/PrismicError.cjs +2 -5
  33. package/dist/errors/PrismicError.cjs.map +1 -1
  34. package/dist/errors/PrismicError.js +2 -5
  35. package/dist/errors/PrismicError.js.map +1 -1
  36. package/dist/errors/RefExpiredError.d.ts +1 -1
  37. package/dist/errors/RefNotFoundError.d.ts +1 -1
  38. package/dist/errors/RepositoryNotFoundError.d.ts +1 -1
  39. package/dist/filter.cjs.map +1 -1
  40. package/dist/filter.js.map +1 -1
  41. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  42. package/dist/getGraphQLEndpoint.js.map +1 -1
  43. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  44. package/dist/getRepositoryEndpoint.d.ts +9 -2
  45. package/dist/getRepositoryEndpoint.js.map +1 -1
  46. package/dist/getRepositoryName.cjs.map +1 -1
  47. package/dist/getRepositoryName.js.map +1 -1
  48. package/dist/getToolbarSrc.cjs.map +1 -1
  49. package/dist/getToolbarSrc.js.map +1 -1
  50. package/dist/helpers/asDate.cjs.map +1 -1
  51. package/dist/helpers/asDate.d.ts +13 -6
  52. package/dist/helpers/asDate.js.map +1 -1
  53. package/dist/helpers/asHTML.cjs +22 -22
  54. package/dist/helpers/asHTML.cjs.map +1 -1
  55. package/dist/helpers/asHTML.d.ts +37 -29
  56. package/dist/helpers/asHTML.js +22 -22
  57. package/dist/helpers/asHTML.js.map +1 -1
  58. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  59. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +17 -16
  60. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  61. package/dist/helpers/asImageSrc.cjs.map +1 -1
  62. package/dist/helpers/asImageSrc.d.ts +12 -11
  63. package/dist/helpers/asImageSrc.js.map +1 -1
  64. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  65. package/dist/helpers/asImageWidthSrcSet.d.ts +19 -18
  66. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  67. package/dist/helpers/asLink.cjs.map +1 -1
  68. package/dist/helpers/asLink.d.ts +36 -35
  69. package/dist/helpers/asLink.js.map +1 -1
  70. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  71. package/dist/helpers/asLinkAttrs.d.ts +11 -14
  72. package/dist/helpers/asLinkAttrs.js.map +1 -1
  73. package/dist/helpers/asText.cjs.map +1 -1
  74. package/dist/helpers/asText.d.ts +21 -11
  75. package/dist/helpers/asText.js.map +1 -1
  76. package/dist/helpers/documentToLinkField.cjs +1 -2
  77. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  78. package/dist/helpers/documentToLinkField.d.ts +2 -2
  79. package/dist/helpers/documentToLinkField.js +1 -2
  80. package/dist/helpers/documentToLinkField.js.map +1 -1
  81. package/dist/helpers/isFilled.cjs +1 -1
  82. package/dist/helpers/isFilled.cjs.map +1 -1
  83. package/dist/helpers/isFilled.d.ts +35 -34
  84. package/dist/helpers/isFilled.js +1 -1
  85. package/dist/helpers/isFilled.js.map +1 -1
  86. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  87. package/dist/helpers/mapSliceZone.d.ts +11 -11
  88. package/dist/helpers/mapSliceZone.js.map +1 -1
  89. package/dist/index.cjs.map +1 -1
  90. package/dist/index.d.ts +120 -120
  91. package/dist/index.js.map +1 -1
  92. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  93. package/dist/isRepositoryEndpoint.d.ts +2 -2
  94. package/dist/isRepositoryEndpoint.js.map +1 -1
  95. package/dist/isRepositoryName.cjs.map +1 -1
  96. package/dist/isRepositoryName.js.map +1 -1
  97. package/dist/lib/appendFilters.cjs.map +1 -1
  98. package/dist/lib/appendFilters.js.map +1 -1
  99. package/dist/lib/castArray.cjs.map +1 -1
  100. package/dist/lib/castArray.js.map +1 -1
  101. package/dist/lib/castThunk.cjs.map +1 -1
  102. package/dist/lib/castThunk.js.map +1 -1
  103. package/dist/lib/devMsg.cjs.map +1 -1
  104. package/dist/lib/devMsg.js.map +1 -1
  105. package/dist/lib/escapeHTML.cjs.map +1 -1
  106. package/dist/lib/escapeHTML.js.map +1 -1
  107. package/dist/lib/everyTagFilter.cjs.map +1 -1
  108. package/dist/lib/everyTagFilter.js.map +1 -1
  109. package/dist/lib/findMasterRef.cjs.map +1 -1
  110. package/dist/lib/findMasterRef.d.ts +1 -1
  111. package/dist/lib/findMasterRef.js.map +1 -1
  112. package/dist/lib/findRef.cjs.map +1 -1
  113. package/dist/lib/findRef.d.ts +1 -1
  114. package/dist/lib/findRef.js.map +1 -1
  115. package/dist/lib/findRefByID.cjs.map +1 -1
  116. package/dist/lib/findRefByID.d.ts +1 -1
  117. package/dist/lib/findRefByID.js.map +1 -1
  118. package/dist/lib/findRefByLabel.cjs.map +1 -1
  119. package/dist/lib/findRefByLabel.d.ts +1 -1
  120. package/dist/lib/findRefByLabel.js.map +1 -1
  121. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
  122. package/dist/lib/getOptionalLinkProperties.d.ts +1 -1
  123. package/dist/lib/getOptionalLinkProperties.js.map +1 -1
  124. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  125. package/dist/lib/getPreviewCookie.js.map +1 -1
  126. package/dist/lib/isInternalURL.cjs.map +1 -1
  127. package/dist/lib/isInternalURL.js.map +1 -1
  128. package/dist/lib/isMigrationValue.cjs.map +1 -1
  129. package/dist/lib/isMigrationValue.d.ts +8 -8
  130. package/dist/lib/isMigrationValue.js.map +1 -1
  131. package/dist/lib/isValue.cjs.map +1 -1
  132. package/dist/lib/isValue.d.ts +10 -10
  133. package/dist/lib/isValue.js.map +1 -1
  134. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  135. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  136. package/dist/lib/pLimit.cjs +3 -4
  137. package/dist/lib/pLimit.cjs.map +1 -1
  138. package/dist/lib/pLimit.js +3 -4
  139. package/dist/lib/pLimit.js.map +1 -1
  140. package/dist/lib/request.cjs +8 -10
  141. package/dist/lib/request.cjs.map +1 -1
  142. package/dist/lib/request.js +8 -10
  143. package/dist/lib/request.js.map +1 -1
  144. package/dist/lib/resolveMigrationDocumentData.cjs +4 -6
  145. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  146. package/dist/lib/resolveMigrationDocumentData.d.ts +8 -8
  147. package/dist/lib/resolveMigrationDocumentData.js +4 -6
  148. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  149. package/dist/lib/serializerHelpers.cjs +2 -2
  150. package/dist/lib/serializerHelpers.cjs.map +1 -1
  151. package/dist/lib/serializerHelpers.d.ts +3 -3
  152. package/dist/lib/serializerHelpers.js +2 -2
  153. package/dist/lib/serializerHelpers.js.map +1 -1
  154. package/dist/lib/someTagsFilter.cjs.map +1 -1
  155. package/dist/lib/someTagsFilter.js.map +1 -1
  156. package/dist/lib/throttledLog.cjs.map +1 -1
  157. package/dist/lib/throttledLog.js.map +1 -1
  158. package/dist/lib/typeFilter.cjs.map +1 -1
  159. package/dist/lib/typeFilter.js.map +1 -1
  160. package/dist/lib/validateAssetMetadata.cjs.map +1 -1
  161. package/dist/lib/validateAssetMetadata.d.ts +1 -1
  162. package/dist/lib/validateAssetMetadata.js.map +1 -1
  163. package/dist/package.json.cjs +1 -1
  164. package/dist/package.json.js +1 -1
  165. package/dist/richtext/asText.cjs.map +1 -1
  166. package/dist/richtext/asText.d.ts +6 -6
  167. package/dist/richtext/asText.js.map +1 -1
  168. package/dist/richtext/asTree.cjs.map +1 -1
  169. package/dist/richtext/asTree.d.ts +2 -2
  170. package/dist/richtext/asTree.js.map +1 -1
  171. package/dist/richtext/composeSerializers.cjs.map +1 -1
  172. package/dist/richtext/composeSerializers.d.ts +1 -1
  173. package/dist/richtext/composeSerializers.js.map +1 -1
  174. package/dist/richtext/index.d.ts +7 -7
  175. package/dist/richtext/serialize.cjs.map +1 -1
  176. package/dist/richtext/serialize.d.ts +10 -10
  177. package/dist/richtext/serialize.js.map +1 -1
  178. package/dist/richtext/types.cjs.map +1 -1
  179. package/dist/richtext/types.d.ts +7 -7
  180. package/dist/richtext/types.js.map +1 -1
  181. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  182. package/dist/richtext/wrapMapSerializer.d.ts +1 -1
  183. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  184. package/dist/types/api/asset/asset.d.ts +1 -1
  185. package/dist/types/api/integration.d.ts +1 -1
  186. package/dist/types/api/migration/document.d.ts +1 -1
  187. package/dist/types/api/query.d.ts +1 -1
  188. package/dist/types/api/release.d.ts +1 -1
  189. package/dist/types/api/repository.d.ts +1 -1
  190. package/dist/types/migration/Asset.cjs +12 -15
  191. package/dist/types/migration/Asset.cjs.map +1 -1
  192. package/dist/types/migration/Asset.d.ts +7 -7
  193. package/dist/types/migration/Asset.js +12 -15
  194. package/dist/types/migration/Asset.js.map +1 -1
  195. package/dist/types/migration/ContentRelationship.d.ts +3 -3
  196. package/dist/types/migration/Document.cjs +24 -27
  197. package/dist/types/migration/Document.cjs.map +1 -1
  198. package/dist/types/migration/Document.d.ts +9 -9
  199. package/dist/types/migration/Document.js +24 -27
  200. package/dist/types/migration/Document.js.map +1 -1
  201. package/dist/types/migration/Link.d.ts +1 -1
  202. package/dist/types/model/boolean.d.ts +1 -1
  203. package/dist/types/model/color.d.ts +1 -1
  204. package/dist/types/model/contentRelationship.d.ts +3 -2
  205. package/dist/types/model/customType.d.ts +1 -1
  206. package/dist/types/model/date.d.ts +1 -1
  207. package/dist/types/model/embed.d.ts +1 -1
  208. package/dist/types/model/geoPoint.d.ts +1 -1
  209. package/dist/types/model/group.d.ts +1 -1
  210. package/dist/types/model/image.d.ts +1 -1
  211. package/dist/types/model/integration.d.ts +1 -1
  212. package/dist/types/model/keyText.d.ts +1 -1
  213. package/dist/types/model/link.d.ts +1 -1
  214. package/dist/types/model/linkToMedia.d.ts +2 -2
  215. package/dist/types/model/number.d.ts +1 -1
  216. package/dist/types/model/range.d.ts +1 -1
  217. package/dist/types/model/richText.d.ts +1 -1
  218. package/dist/types/model/select.d.ts +1 -1
  219. package/dist/types/model/separator.d.ts +1 -1
  220. package/dist/types/model/sharedSlice.d.ts +2 -2
  221. package/dist/types/model/sharedSliceVariation.d.ts +1 -1
  222. package/dist/types/model/slice.d.ts +3 -3
  223. package/dist/types/model/sliceZone.d.ts +2 -2
  224. package/dist/types/model/table.d.ts +1 -1
  225. package/dist/types/model/timestamp.d.ts +1 -1
  226. package/dist/types/model/title.d.ts +1 -1
  227. package/dist/types/model/types.d.ts +22 -22
  228. package/dist/types/model/uid.d.ts +1 -1
  229. package/dist/types/value/color.d.ts +1 -1
  230. package/dist/types/value/contentRelationship.d.ts +3 -3
  231. package/dist/types/value/date.d.ts +1 -1
  232. package/dist/types/value/document.d.ts +4 -4
  233. package/dist/types/value/embed.d.ts +1 -1
  234. package/dist/types/value/geoPoint.d.ts +1 -1
  235. package/dist/types/value/group.d.ts +1 -1
  236. package/dist/types/value/image.d.ts +1 -1
  237. package/dist/types/value/integration.d.ts +1 -1
  238. package/dist/types/value/keyText.d.ts +1 -1
  239. package/dist/types/value/link.d.ts +5 -5
  240. package/dist/types/value/linkToMedia.d.ts +2 -2
  241. package/dist/types/value/number.d.ts +1 -1
  242. package/dist/types/value/richText.d.ts +3 -3
  243. package/dist/types/value/select.d.ts +1 -1
  244. package/dist/types/value/sharedSlice.d.ts +1 -1
  245. package/dist/types/value/sharedSliceVariation.d.ts +1 -1
  246. package/dist/types/value/slice.d.ts +1 -1
  247. package/dist/types/value/sliceZone.d.ts +3 -3
  248. package/dist/types/value/table.d.ts +2 -2
  249. package/dist/types/value/timestamp.d.ts +2 -2
  250. package/dist/types/value/title.d.ts +2 -2
  251. package/dist/types/value/types.d.ts +18 -18
  252. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  253. package/dist/types/webhook/testTrigger.d.ts +1 -1
  254. package/dist/types/webhook/types.d.ts +2 -2
  255. package/package.json +11 -11
  256. package/src/WriteClient.ts +32 -21
  257. package/src/buildQueryURL.ts +29 -21
  258. package/src/createClient.ts +11 -8
  259. package/src/getRepositoryEndpoint.ts +9 -2
  260. package/src/helpers/asDate.ts +11 -4
  261. package/src/helpers/asHTML.ts +34 -26
  262. package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
  263. package/src/helpers/asImageSrc.ts +11 -10
  264. package/src/helpers/asImageWidthSrcSet.ts +18 -17
  265. package/src/helpers/asLink.ts +33 -32
  266. package/src/helpers/asLinkAttrs.ts +6 -9
  267. package/src/helpers/asText.ts +20 -10
  268. package/src/helpers/isFilled.ts +15 -14
  269. package/src/helpers/mapSliceZone.ts +10 -10
  270. package/src/index.ts +2 -2
  271. package/src/isRepositoryEndpoint.ts +2 -2
  272. package/src/richtext/asText.ts +5 -5
  273. package/src/richtext/serialize.ts +8 -8
  274. package/src/richtext/types.ts +6 -6
  275. package/src/types/migration/Asset.ts +10 -2
  276. package/src/types/model/contentRelationship.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Migration.cjs","sources":["../../src/Migration.ts"],"sourcesContent":["import * as is from \"./lib/isValue\"\nimport { getOptionalLinkProperties } from \"./lib/getOptionalLinkProperties\"\nimport { validateAssetMetadata } from \"./lib/validateAssetMetadata\"\n\nimport type { Asset } from \"./types/api/asset/asset\"\nimport type {\n\tMigrationAssetConfig,\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"./types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"./types/migration/Document\"\nimport type {\n\tExistingPrismicDocument,\n\tPendingPrismicDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\nimport type { FilledImageFieldImage } from \"./types/value/image\"\nimport { type FilledLinkToWebField, LinkType } from \"./types/value/link\"\nimport type { FilledLinkToMediaField } from \"./types/value/linkToMedia\"\nimport { RichTextNodeType } from \"./types/value/richText\"\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * A helper that allows preparing your migration to Prismic.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class Migration<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * Assets registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_assets: Map<MigrationAssetConfig[\"file\"], PrismicMigrationAsset> = new Map()\n\n\t/**\n\t * Documents registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_documents: PrismicMigrationDocument<TDocuments>[] = []\n\n\t/**\n\t * Registers an asset to be created in the migration from an asset object.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param asset - An asset object from Prismic Asset API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(asset: Asset): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from an image or link to\n\t * media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param imageOrLinkToMediaField - An image or link to media field from\n\t * Prismic Document API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(\n\t\timageOrLinkToMediaField: FilledImageFieldImage | FilledLinkToMediaField,\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param file - The URL or content of the file to be created.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfile: MigrationAssetConfig[\"file\"],\n\t\tfilename: MigrationAssetConfig[\"filename\"],\n\t\tparams?: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t},\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file, an asset\n\t * object, or an image or link to media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfileOrAssetOrField:\n\t\t\t| MigrationAssetConfig[\"file\"]\n\t\t\t| Asset\n\t\t\t| FilledImageFieldImage\n\t\t\t| FilledLinkToMediaField,\n\t\tfilename?: MigrationAssetConfig[\"filename\"],\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t}: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t} = {},\n\t): PrismicMigrationAsset {\n\t\tlet config: MigrationAssetConfig\n\t\tlet maybeInitialField: FilledImageFieldImage | undefined\n\t\tif (typeof fileOrAssetOrField === \"object\" && \"url\" in fileOrAssetOrField) {\n\t\t\tif (\n\t\t\t\t\"dimensions\" in fileOrAssetOrField ||\n\t\t\t\t\"link_type\" in fileOrAssetOrField\n\t\t\t) {\n\t\t\t\tconst url = fileOrAssetOrField.url.split(\"?\")[0]\n\t\t\t\tconst filename =\n\t\t\t\t\t\"name\" in fileOrAssetOrField\n\t\t\t\t\t\t? fileOrAssetOrField.name\n\t\t\t\t\t\t: url.split(\"/\").pop()!.split(\"_\").pop()!\n\t\t\t\tconst credits =\n\t\t\t\t\t\"copyright\" in fileOrAssetOrField && fileOrAssetOrField.copyright\n\t\t\t\t\t\t? fileOrAssetOrField.copyright\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst alt =\n\t\t\t\t\t\"alt\" in fileOrAssetOrField && fileOrAssetOrField.alt\n\t\t\t\t\t\t? fileOrAssetOrField.alt\n\t\t\t\t\t\t: undefined\n\n\t\t\t\tif (\"dimensions\" in fileOrAssetOrField) {\n\t\t\t\t\tmaybeInitialField = fileOrAssetOrField\n\t\t\t\t}\n\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: url,\n\t\t\t\t\tfilename,\n\t\t\t\t\tnotes: undefined,\n\t\t\t\t\tcredits,\n\t\t\t\t\talt,\n\t\t\t\t\ttags: undefined,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: fileOrAssetOrField.url,\n\t\t\t\t\tfilename: fileOrAssetOrField.filename,\n\t\t\t\t\tnotes: fileOrAssetOrField.notes,\n\t\t\t\t\tcredits: fileOrAssetOrField.credits,\n\t\t\t\t\talt: fileOrAssetOrField.alt,\n\t\t\t\t\ttags: fileOrAssetOrField.tags?.map(({ name }) => name),\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = {\n\t\t\t\tid: fileOrAssetOrField,\n\t\t\t\tfile: fileOrAssetOrField,\n\t\t\t\tfilename: filename!,\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\ttags,\n\t\t\t}\n\t\t}\n\n\t\tvalidateAssetMetadata(config)\n\n\t\t// We create a detached instance of the asset each time to serialize it properly\n\t\tconst migrationAsset = new PrismicMigrationAsset(config, maybeInitialField)\n\n\t\tconst maybeAsset = this._assets.get(config.id)\n\t\tif (maybeAsset) {\n\t\t\t// Consolidate existing asset with new asset value if possible\n\t\t\tmaybeAsset.config.notes = maybeAsset.config.notes || config.notes\n\t\t\tmaybeAsset.config.credits = maybeAsset.config.credits || config.credits\n\t\t\tmaybeAsset.config.alt = maybeAsset.config.alt || config.alt\n\t\t\tmaybeAsset.config.tags = Array.from(\n\t\t\t\tnew Set([...(maybeAsset.config.tags || []), ...(config.tags || [])]),\n\t\t\t)\n\t\t} else {\n\t\t\tthis._assets.set(config.id, migrationAsset)\n\t\t}\n\n\t\treturn migrationAsset\n\t}\n\n\t/**\n\t * Registers a document to be created in the migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of the Prismic document to create.\n\t *\n\t * @param document - The document to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t * @param params - Document master language document ID.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<PendingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t},\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title, params)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers an existing document to be updated in the migration.\n\t *\n\t * @remarks\n\t * This method does not update the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be updated when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t *\n\t * @param document - The document to update.\n\t * @param title - The title of the document to update which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tupdateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\t// Title is optional for existing documents as we might not want to update it.\n\t\ttitle?: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers a document from another Prismic repository to be created in the\n\t * migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param document - The document from Prismic to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocumentFromPrismic<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument(\n\t\t\tthis.#migratePrismicDocumentData({\n\t\t\t\ttype: document.type,\n\t\t\t\tlang: document.lang,\n\t\t\t\tuid: document.uid,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}) as PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\t\ttitle,\n\t\t\t{ originalPrismicDocument: document },\n\t\t)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Queries a document from the migration instance with a specific UID and\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getByUID(\"blog_post\", \"my-first-post\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the document's custom type.\n\t * @param uid - The UID of the document.\n\t *\n\t * @returns The migration document instance with a UID matching the `uid`\n\t * parameter, if a matching document is found.\n\t */\n\tgetByUID<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t\tuid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type && doc.document.uid === uid,\n\t\t)\n\t}\n\n\t/**\n\t * Queries a singleton document from the migration instance for a specific\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getSingle(\"settings\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the singleton custom type.\n\t *\n\t * @returns The migration document instance for the custom type, if a matching\n\t * document is found.\n\t */\n\tgetSingle<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type,\n\t\t)\n\t}\n\n\t/**\n\t * Migrates a Prismic document data from another repository so that it can be\n\t * created through the current repository's Migration API.\n\t *\n\t * @param input - The Prismic document data to migrate.\n\t *\n\t * @returns The migrated Prismic document data.\n\t */\n\t#migratePrismicDocumentData(input: unknown): unknown {\n\t\tif (is.filledContentRelationship(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\tif (input.isBroken) {\n\t\t\t\treturn {\n\t\t\t\t\t...optionalLinkProperties,\n\t\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\t\t// ID needs to be 16 characters long to be considered valid by the API\n\t\t\t\t\tid: \"_____broken_____\",\n\t\t\t\t\tisBroken: true,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\tid: () => this._getByOriginalID(input.id),\n\t\t\t}\n\t\t}\n\n\t\tif (is.filledLinkToMedia(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Media,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\t\t}\n\n\t\tif (is.rtImageNode(input)) {\n\t\t\t// Rich text image nodes\n\t\t\tconst rtImageNode: MigrationRTImageNode = {\n\t\t\t\ttype: RichTextNodeType.image,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tif (input.linkTo) {\n\t\t\t\trtImageNode.linkTo = this.#migratePrismicDocumentData(input.linkTo) as\n\t\t\t\t\t| MigrationContentRelationship\n\t\t\t\t\t| MigrationLinkToMedia\n\t\t\t\t\t| FilledLinkToWebField\n\t\t\t}\n\n\t\t\treturn rtImageNode\n\t\t}\n\n\t\tif (is.filledImage(input)) {\n\t\t\tconst image: MigrationImage = {\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tid: _id,\n\t\t\t\turl: _url,\n\t\t\t\tdimensions: _dimensions,\n\t\t\t\tedit: _edit,\n\t\t\t\talt: _alt,\n\t\t\t\tcopyright: _copyright,\n\t\t\t\t...thumbnails\n\t\t\t} = input\n\n\t\t\tfor (const name in thumbnails) {\n\t\t\t\tif (is.filledImage(thumbnails[name])) {\n\t\t\t\t\timage[name] = this.createAsset(thumbnails[name])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn image\n\t\t}\n\n\t\tif (Array.isArray(input)) {\n\t\t\treturn input.map((element) => this.#migratePrismicDocumentData(element))\n\t\t}\n\n\t\tif (input && typeof input === \"object\") {\n\t\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\t\tfor (const key in input) {\n\t\t\t\tres[key] = this.#migratePrismicDocumentData(\n\t\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn res\n\t\t}\n\n\t\treturn input\n\t}\n\n\t/**\n\t * Queries a document from the migration instance for a specific original ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration._getByOriginalID(\"YhdrDxIAACgAcp_b\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param id - The original ID of the Prismic document.\n\t *\n\t * @returns The migration document instance for the original ID, if a matching\n\t * document is found.\n\t *\n\t * @internal\n\t */\n\t_getByOriginalID<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.originalPrismicDocument?.id === id,\n\t\t)\n\t}\n}\n"],"names":["filename","credits","alt","validateAssetMetadata","PrismicMigrationAsset","PrismicMigrationDocument","is.filledContentRelationship","getOptionalLinkProperties","LinkType","is.filledLinkToMedia","is.rtImageNode","RichTextNodeType","is.filledImage"],"mappings":";;;;;;;;;;;;;;;;;;;MA8Ca,UAAS;AAAA;;AAMrB;AAAA;AAAA;AAAA;AAAA;AAAA,uDAAwE,IAAG;AAO3E;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAqD;;;;;;;;;;;;;EA0ErD,YACC,oBAKA,UACA,EACC,OACA,SACA,KACA,KAMG,IAAA,IAAE;;AAEF,QAAA;AACA,QAAA;AACJ,QAAI,OAAO,uBAAuB,YAAY,SAAS,oBAAoB;AAEzE,UAAA,gBAAgB,sBAChB,eAAe,oBACd;AACD,cAAM,MAAM,mBAAmB,IAAI,MAAM,GAAG,EAAE,CAAC;AAC/C,cAAMA,YACL,UAAU,qBACP,mBAAmB,OACnB,IAAI,MAAM,GAAG,EAAE,IAAM,EAAC,MAAM,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MAC7B,IAAI,KAAK,YAAY,KAAK;AAAA;AAG3B,UAAM,EACL,IAAI,KACJ,KAAK,MACL,YAAY,aACZ,MAAM,OACN,KAAK,MACL,WAAW,YACX,GAAG,eACA;AAEJ,eAAW,QAAQ,YAAY;AAC9B,UAAIA,oBAAe,WAAW,IAAI,CAAC,GAAG;AACrC,cAAM,IAAI,IAAI,KAAK,YAAY,WAAW,IAAI,CAAC;AAAA,MAAA;AAAA,IAChD;AAGM,WAAA;AAAA,EAAA;AAGJ,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,MAAM,IAAI,CAAC,YAAY,sBAAK,qDAAL,WAAiC,QAAQ;AAAA,EAAA;AAGpE,MAAA,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,MAAoC,CAAA;AAE1C,eAAW,OAAO,OAAO;AACxB,UAAI,GAAG,IAAI,sBAAK,qDAAL,WACV,MAAM,GAAyB;AAAA,IAAC;AAI3B,WAAA;AAAA,EAAA;AAGD,SAAA;AAAA;;"}
1
+ {"version":3,"file":"Migration.cjs","sources":["../../src/Migration.ts"],"sourcesContent":["import * as is from \"./lib/isValue\"\nimport { getOptionalLinkProperties } from \"./lib/getOptionalLinkProperties\"\nimport { validateAssetMetadata } from \"./lib/validateAssetMetadata\"\n\nimport type { Asset } from \"./types/api/asset/asset\"\nimport type {\n\tMigrationAssetConfig,\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"./types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"./types/migration/Document\"\nimport type {\n\tExistingPrismicDocument,\n\tPendingPrismicDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\nimport type { FilledImageFieldImage } from \"./types/value/image\"\nimport { type FilledLinkToWebField, LinkType } from \"./types/value/link\"\nimport type { FilledLinkToMediaField } from \"./types/value/linkToMedia\"\nimport { RichTextNodeType } from \"./types/value/richText\"\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * A helper that allows preparing your migration to Prismic.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class Migration<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * Assets registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_assets: Map<MigrationAssetConfig[\"file\"], PrismicMigrationAsset> = new Map()\n\n\t/**\n\t * Documents registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_documents: PrismicMigrationDocument<TDocuments>[] = []\n\n\t/**\n\t * Registers an asset to be created in the migration from an asset object.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param asset - An asset object from Prismic Asset API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(asset: Asset): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from an image or link to\n\t * media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param imageOrLinkToMediaField - An image or link to media field from\n\t * Prismic Document API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(\n\t\timageOrLinkToMediaField: FilledImageFieldImage | FilledLinkToMediaField,\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param file - The URL or content of the file to be created.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfile: MigrationAssetConfig[\"file\"],\n\t\tfilename: MigrationAssetConfig[\"filename\"],\n\t\tparams?: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t},\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file, an asset\n\t * object, or an image or link to media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfileOrAssetOrField:\n\t\t\t| MigrationAssetConfig[\"file\"]\n\t\t\t| Asset\n\t\t\t| FilledImageFieldImage\n\t\t\t| FilledLinkToMediaField,\n\t\tfilename?: MigrationAssetConfig[\"filename\"],\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t}: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t} = {},\n\t): PrismicMigrationAsset {\n\t\tlet config: MigrationAssetConfig\n\t\tlet maybeInitialField: FilledImageFieldImage | undefined\n\t\tif (typeof fileOrAssetOrField === \"object\" && \"url\" in fileOrAssetOrField) {\n\t\t\tif (\n\t\t\t\t\"dimensions\" in fileOrAssetOrField ||\n\t\t\t\t\"link_type\" in fileOrAssetOrField\n\t\t\t) {\n\t\t\t\tconst url = fileOrAssetOrField.url.split(\"?\")[0]\n\t\t\t\tconst filename =\n\t\t\t\t\t\"name\" in fileOrAssetOrField\n\t\t\t\t\t\t? fileOrAssetOrField.name\n\t\t\t\t\t\t: url.split(\"/\").pop()!.split(\"_\").pop()!\n\t\t\t\tconst credits =\n\t\t\t\t\t\"copyright\" in fileOrAssetOrField && fileOrAssetOrField.copyright\n\t\t\t\t\t\t? fileOrAssetOrField.copyright\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst alt =\n\t\t\t\t\t\"alt\" in fileOrAssetOrField && fileOrAssetOrField.alt\n\t\t\t\t\t\t? fileOrAssetOrField.alt\n\t\t\t\t\t\t: undefined\n\n\t\t\t\tif (\"dimensions\" in fileOrAssetOrField) {\n\t\t\t\t\tmaybeInitialField = fileOrAssetOrField\n\t\t\t\t}\n\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: url,\n\t\t\t\t\tfilename,\n\t\t\t\t\tnotes: undefined,\n\t\t\t\t\tcredits,\n\t\t\t\t\talt,\n\t\t\t\t\ttags: undefined,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: fileOrAssetOrField.url,\n\t\t\t\t\tfilename: fileOrAssetOrField.filename,\n\t\t\t\t\tnotes: fileOrAssetOrField.notes,\n\t\t\t\t\tcredits: fileOrAssetOrField.credits,\n\t\t\t\t\talt: fileOrAssetOrField.alt,\n\t\t\t\t\ttags: fileOrAssetOrField.tags?.map(({ name }) => name),\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = {\n\t\t\t\tid: fileOrAssetOrField,\n\t\t\t\tfile: fileOrAssetOrField,\n\t\t\t\tfilename: filename!,\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\ttags,\n\t\t\t}\n\t\t}\n\n\t\tvalidateAssetMetadata(config)\n\n\t\t// We create a detached instance of the asset each time to serialize it properly\n\t\tconst migrationAsset = new PrismicMigrationAsset(config, maybeInitialField)\n\n\t\tconst maybeAsset = this._assets.get(config.id)\n\t\tif (maybeAsset) {\n\t\t\t// Consolidate existing asset with new asset value if possible\n\t\t\tmaybeAsset.config.notes = maybeAsset.config.notes || config.notes\n\t\t\tmaybeAsset.config.credits = maybeAsset.config.credits || config.credits\n\t\t\tmaybeAsset.config.alt = maybeAsset.config.alt || config.alt\n\t\t\tmaybeAsset.config.tags = Array.from(\n\t\t\t\tnew Set([...(maybeAsset.config.tags || []), ...(config.tags || [])]),\n\t\t\t)\n\t\t} else {\n\t\t\tthis._assets.set(config.id, migrationAsset)\n\t\t}\n\n\t\treturn migrationAsset\n\t}\n\n\t/**\n\t * Registers a document to be created in the migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of the Prismic document to create.\n\t *\n\t * @param document - The document to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t * @param params - Document master language document ID.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<PendingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t},\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title, params)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers an existing document to be updated in the migration.\n\t *\n\t * @remarks\n\t * This method does not update the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be updated when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t *\n\t * @param document - The document to update.\n\t * @param title - The title of the document to update which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tupdateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\t// Title is optional for existing documents as we might not want to update it.\n\t\ttitle?: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers a document from another Prismic repository to be created in the\n\t * migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param document - The document from Prismic to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocumentFromPrismic<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument(\n\t\t\tthis.#migratePrismicDocumentData({\n\t\t\t\ttype: document.type,\n\t\t\t\tlang: document.lang,\n\t\t\t\tuid: document.uid,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}) as PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\t\ttitle,\n\t\t\t{ originalPrismicDocument: document },\n\t\t)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Queries a document from the migration instance with a specific UID and\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getByUID(\"blog_post\", \"my-first-post\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the document's custom type.\n\t * @param uid - The UID of the document.\n\t *\n\t * @returns The migration document instance with a UID matching the `uid`\n\t * parameter, if a matching document is found.\n\t */\n\tgetByUID<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t\tuid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type && doc.document.uid === uid,\n\t\t)\n\t}\n\n\t/**\n\t * Queries a singleton document from the migration instance for a specific\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getSingle(\"settings\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the singleton custom type.\n\t *\n\t * @returns The migration document instance for the custom type, if a matching\n\t * document is found.\n\t */\n\tgetSingle<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type,\n\t\t)\n\t}\n\n\t/**\n\t * Migrates a Prismic document data from another repository so that it can be\n\t * created through the current repository's Migration API.\n\t *\n\t * @param input - The Prismic document data to migrate.\n\t *\n\t * @returns The migrated Prismic document data.\n\t */\n\t#migratePrismicDocumentData(input: unknown): unknown {\n\t\tif (is.filledContentRelationship(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\tif (input.isBroken) {\n\t\t\t\treturn {\n\t\t\t\t\t...optionalLinkProperties,\n\t\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\t\t// ID needs to be 16 characters long to be considered valid by the API\n\t\t\t\t\tid: \"_____broken_____\",\n\t\t\t\t\tisBroken: true,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\tid: () => this._getByOriginalID(input.id),\n\t\t\t}\n\t\t}\n\n\t\tif (is.filledLinkToMedia(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Media,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\t\t}\n\n\t\tif (is.rtImageNode(input)) {\n\t\t\t// Rich text image nodes\n\t\t\tconst rtImageNode: MigrationRTImageNode = {\n\t\t\t\ttype: RichTextNodeType.image,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tif (input.linkTo) {\n\t\t\t\trtImageNode.linkTo = this.#migratePrismicDocumentData(input.linkTo) as\n\t\t\t\t\t| MigrationContentRelationship\n\t\t\t\t\t| MigrationLinkToMedia\n\t\t\t\t\t| FilledLinkToWebField\n\t\t\t}\n\n\t\t\treturn rtImageNode\n\t\t}\n\n\t\tif (is.filledImage(input)) {\n\t\t\tconst image: MigrationImage = {\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tid: _id,\n\t\t\t\turl: _url,\n\t\t\t\tdimensions: _dimensions,\n\t\t\t\tedit: _edit,\n\t\t\t\talt: _alt,\n\t\t\t\tcopyright: _copyright,\n\t\t\t\t...thumbnails\n\t\t\t} = input\n\n\t\t\tfor (const name in thumbnails) {\n\t\t\t\tif (is.filledImage(thumbnails[name])) {\n\t\t\t\t\timage[name] = this.createAsset(thumbnails[name])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn image\n\t\t}\n\n\t\tif (Array.isArray(input)) {\n\t\t\treturn input.map((element) => this.#migratePrismicDocumentData(element))\n\t\t}\n\n\t\tif (input && typeof input === \"object\") {\n\t\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\t\tfor (const key in input) {\n\t\t\t\tres[key] = this.#migratePrismicDocumentData(\n\t\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn res\n\t\t}\n\n\t\treturn input\n\t}\n\n\t/**\n\t * Queries a document from the migration instance for a specific original ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration._getByOriginalID(\"YhdrDxIAACgAcp_b\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param id - The original ID of the Prismic document.\n\t *\n\t * @returns The migration document instance for the original ID, if a matching\n\t * document is found.\n\t *\n\t * @internal\n\t */\n\t_getByOriginalID<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.originalPrismicDocument?.id === id,\n\t\t)\n\t}\n}\n"],"names":["filename","credits","alt","validateAssetMetadata","PrismicMigrationAsset","PrismicMigrationDocument","is.filledContentRelationship","getOptionalLinkProperties","LinkType","is.filledLinkToMedia","is.rtImageNode","RichTextNodeType","is.filledImage"],"mappings":";;;;;;;;;MA8Ca,UAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrB,8BAAwE,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxE,aAAqD,CAAA;AAAA;AAAA;AAAA;AAA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
- import { PrismicMigrationAsset } from "./types/migration/Asset";
4
- import type { MigrationContentRelationship } from "./types/migration/ContentRelationship";
5
- import { PrismicMigrationDocument } from "./types/migration/Document";
6
- import type { ExistingPrismicDocument, PendingPrismicDocument } from "./types/migration/Document";
7
- import type { PrismicDocument } from "./types/value/document";
8
- import type { FilledImageFieldImage } from "./types/value/image";
9
- import type { FilledLinkToMediaField } from "./types/value/linkToMedia";
1
+ import type { Asset } from "./types/api/asset/asset.js";
2
+ import type { MigrationAssetConfig } from "./types/migration/Asset.js";
3
+ import { PrismicMigrationAsset } from "./types/migration/Asset.js";
4
+ import type { MigrationContentRelationship } from "./types/migration/ContentRelationship.js";
5
+ import { PrismicMigrationDocument } from "./types/migration/Document.js";
6
+ import type { ExistingPrismicDocument, PendingPrismicDocument } from "./types/migration/Document.js";
7
+ import type { PrismicDocument } from "./types/value/document.js";
8
+ import type { FilledImageFieldImage } from "./types/value/image.js";
9
+ import type { FilledLinkToMediaField } from "./types/value/linkToMedia.js";
10
10
  /**
11
11
  * Extracts one or more Prismic document types that match a given Prismic
12
12
  * document type. If no matches are found, no extraction is performed and the
package/dist/Migration.js CHANGED
@@ -1,13 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
9
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
10
- var _Migration_instances, migratePrismicDocumentData_fn;
11
1
  import { filledContentRelationship, filledLinkToMedia, rtImageNode, filledImage } from "./lib/isValue.js";
12
2
  import { getOptionalLinkProperties } from "./lib/getOptionalLinkProperties.js";
13
3
  import { validateAssetMetadata } from "./lib/validateAssetMetadata.js";
@@ -16,21 +6,18 @@ import { PrismicMigrationDocument } from "./types/migration/Document.js";
16
6
  import { LinkType } from "./types/value/link.js";
17
7
  import { RichTextNodeType } from "./types/value/richText.js";
18
8
  class Migration {
19
- constructor() {
20
- __privateAdd(this, _Migration_instances);
21
- /**
22
- * Assets registered in the migration.
23
- *
24
- * @internal
25
- */
26
- __publicField(this, "_assets", /* @__PURE__ */ new Map());
27
- /**
28
- * Documents registered in the migration.
29
- *
30
- * @internal
31
- */
32
- __publicField(this, "_documents", []);
33
- }
9
+ /**
10
+ * Assets registered in the migration.
11
+ *
12
+ * @internal
13
+ */
14
+ _assets = /* @__PURE__ */ new Map();
15
+ /**
16
+ * Documents registered in the migration.
17
+ *
18
+ * @internal
19
+ */
20
+ _documents = [];
34
21
  /**
35
22
  * Registers an asset to be created in the migration from a file, an asset
36
23
  * object, or an image or link to media field.
@@ -43,7 +30,6 @@ class Migration {
43
30
  * @returns A migration asset field instance.
44
31
  */
45
32
  createAsset(fileOrAssetOrField, filename, { notes, credits, alt, tags } = {}) {
46
- var _a;
47
33
  let config;
48
34
  let maybeInitialField;
49
35
  if (typeof fileOrAssetOrField === "object" && "url" in fileOrAssetOrField) {
@@ -72,7 +58,7 @@ class Migration {
72
58
  notes: fileOrAssetOrField.notes,
73
59
  credits: fileOrAssetOrField.credits,
74
60
  alt: fileOrAssetOrField.alt,
75
- tags: (_a = fileOrAssetOrField.tags) == null ? void 0 : _a.map(({ name }) => name)
61
+ tags: fileOrAssetOrField.tags?.map(({ name }) => name)
76
62
  };
77
63
  }
78
64
  } else {
@@ -158,7 +144,7 @@ class Migration {
158
144
  * @returns A migration document instance.
159
145
  */
160
146
  createDocumentFromPrismic(document, title) {
161
- const doc = new PrismicMigrationDocument(__privateMethod(this, _Migration_instances, migratePrismicDocumentData_fn).call(this, {
147
+ const doc = new PrismicMigrationDocument(this.#migratePrismicDocumentData({
162
148
  type: document.type,
163
149
  lang: document.lang,
164
150
  uid: document.uid,
@@ -213,6 +199,74 @@ class Migration {
213
199
  getSingle(type) {
214
200
  return this._documents.find((doc) => doc.document.type === type);
215
201
  }
202
+ /**
203
+ * Migrates a Prismic document data from another repository so that it can be
204
+ * created through the current repository's Migration API.
205
+ *
206
+ * @param input - The Prismic document data to migrate.
207
+ *
208
+ * @returns The migrated Prismic document data.
209
+ */
210
+ #migratePrismicDocumentData(input) {
211
+ if (filledContentRelationship(input)) {
212
+ const optionalLinkProperties = getOptionalLinkProperties(input);
213
+ if (input.isBroken) {
214
+ return {
215
+ ...optionalLinkProperties,
216
+ link_type: LinkType.Document,
217
+ // ID needs to be 16 characters long to be considered valid by the API
218
+ id: "_____broken_____",
219
+ isBroken: true
220
+ };
221
+ }
222
+ return {
223
+ ...optionalLinkProperties,
224
+ link_type: LinkType.Document,
225
+ id: () => this._getByOriginalID(input.id)
226
+ };
227
+ }
228
+ if (filledLinkToMedia(input)) {
229
+ const optionalLinkProperties = getOptionalLinkProperties(input);
230
+ return {
231
+ ...optionalLinkProperties,
232
+ link_type: LinkType.Media,
233
+ id: this.createAsset(input)
234
+ };
235
+ }
236
+ if (rtImageNode(input)) {
237
+ const rtImageNode2 = {
238
+ type: RichTextNodeType.image,
239
+ id: this.createAsset(input)
240
+ };
241
+ if (input.linkTo) {
242
+ rtImageNode2.linkTo = this.#migratePrismicDocumentData(input.linkTo);
243
+ }
244
+ return rtImageNode2;
245
+ }
246
+ if (filledImage(input)) {
247
+ const image = {
248
+ id: this.createAsset(input)
249
+ };
250
+ const { id: _id, url: _url, dimensions: _dimensions, edit: _edit, alt: _alt, copyright: _copyright, ...thumbnails } = input;
251
+ for (const name in thumbnails) {
252
+ if (filledImage(thumbnails[name])) {
253
+ image[name] = this.createAsset(thumbnails[name]);
254
+ }
255
+ }
256
+ return image;
257
+ }
258
+ if (Array.isArray(input)) {
259
+ return input.map((element) => this.#migratePrismicDocumentData(element));
260
+ }
261
+ if (input && typeof input === "object") {
262
+ const res = {};
263
+ for (const key in input) {
264
+ res[key] = this.#migratePrismicDocumentData(input[key]);
265
+ }
266
+ return res;
267
+ }
268
+ return input;
269
+ }
216
270
  /**
217
271
  * Queries a document from the migration instance for a specific original ID.
218
272
  *
@@ -234,81 +288,9 @@ class Migration {
234
288
  * @internal
235
289
  */
236
290
  _getByOriginalID(id) {
237
- return this._documents.find((doc) => {
238
- var _a;
239
- return ((_a = doc.originalPrismicDocument) == null ? void 0 : _a.id) === id;
240
- });
291
+ return this._documents.find((doc) => doc.originalPrismicDocument?.id === id);
241
292
  }
242
293
  }
243
- _Migration_instances = new WeakSet();
244
- /**
245
- * Migrates a Prismic document data from another repository so that it can be
246
- * created through the current repository's Migration API.
247
- *
248
- * @param input - The Prismic document data to migrate.
249
- *
250
- * @returns The migrated Prismic document data.
251
- */
252
- migratePrismicDocumentData_fn = function(input) {
253
- if (filledContentRelationship(input)) {
254
- const optionalLinkProperties = getOptionalLinkProperties(input);
255
- if (input.isBroken) {
256
- return {
257
- ...optionalLinkProperties,
258
- link_type: LinkType.Document,
259
- // ID needs to be 16 characters long to be considered valid by the API
260
- id: "_____broken_____",
261
- isBroken: true
262
- };
263
- }
264
- return {
265
- ...optionalLinkProperties,
266
- link_type: LinkType.Document,
267
- id: () => this._getByOriginalID(input.id)
268
- };
269
- }
270
- if (filledLinkToMedia(input)) {
271
- const optionalLinkProperties = getOptionalLinkProperties(input);
272
- return {
273
- ...optionalLinkProperties,
274
- link_type: LinkType.Media,
275
- id: this.createAsset(input)
276
- };
277
- }
278
- if (rtImageNode(input)) {
279
- const rtImageNode2 = {
280
- type: RichTextNodeType.image,
281
- id: this.createAsset(input)
282
- };
283
- if (input.linkTo) {
284
- rtImageNode2.linkTo = __privateMethod(this, _Migration_instances, migratePrismicDocumentData_fn).call(this, input.linkTo);
285
- }
286
- return rtImageNode2;
287
- }
288
- if (filledImage(input)) {
289
- const image = {
290
- id: this.createAsset(input)
291
- };
292
- const { id: _id, url: _url, dimensions: _dimensions, edit: _edit, alt: _alt, copyright: _copyright, ...thumbnails } = input;
293
- for (const name in thumbnails) {
294
- if (filledImage(thumbnails[name])) {
295
- image[name] = this.createAsset(thumbnails[name]);
296
- }
297
- }
298
- return image;
299
- }
300
- if (Array.isArray(input)) {
301
- return input.map((element) => __privateMethod(this, _Migration_instances, migratePrismicDocumentData_fn).call(this, element));
302
- }
303
- if (input && typeof input === "object") {
304
- const res = {};
305
- for (const key in input) {
306
- res[key] = __privateMethod(this, _Migration_instances, migratePrismicDocumentData_fn).call(this, input[key]);
307
- }
308
- return res;
309
- }
310
- return input;
311
- };
312
294
  export {
313
295
  Migration
314
296
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Migration.js","sources":["../../src/Migration.ts"],"sourcesContent":["import * as is from \"./lib/isValue\"\nimport { getOptionalLinkProperties } from \"./lib/getOptionalLinkProperties\"\nimport { validateAssetMetadata } from \"./lib/validateAssetMetadata\"\n\nimport type { Asset } from \"./types/api/asset/asset\"\nimport type {\n\tMigrationAssetConfig,\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"./types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"./types/migration/Document\"\nimport type {\n\tExistingPrismicDocument,\n\tPendingPrismicDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\nimport type { FilledImageFieldImage } from \"./types/value/image\"\nimport { type FilledLinkToWebField, LinkType } from \"./types/value/link\"\nimport type { FilledLinkToMediaField } from \"./types/value/linkToMedia\"\nimport { RichTextNodeType } from \"./types/value/richText\"\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * A helper that allows preparing your migration to Prismic.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class Migration<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * Assets registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_assets: Map<MigrationAssetConfig[\"file\"], PrismicMigrationAsset> = new Map()\n\n\t/**\n\t * Documents registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_documents: PrismicMigrationDocument<TDocuments>[] = []\n\n\t/**\n\t * Registers an asset to be created in the migration from an asset object.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param asset - An asset object from Prismic Asset API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(asset: Asset): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from an image or link to\n\t * media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param imageOrLinkToMediaField - An image or link to media field from\n\t * Prismic Document API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(\n\t\timageOrLinkToMediaField: FilledImageFieldImage | FilledLinkToMediaField,\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param file - The URL or content of the file to be created.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfile: MigrationAssetConfig[\"file\"],\n\t\tfilename: MigrationAssetConfig[\"filename\"],\n\t\tparams?: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t},\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file, an asset\n\t * object, or an image or link to media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfileOrAssetOrField:\n\t\t\t| MigrationAssetConfig[\"file\"]\n\t\t\t| Asset\n\t\t\t| FilledImageFieldImage\n\t\t\t| FilledLinkToMediaField,\n\t\tfilename?: MigrationAssetConfig[\"filename\"],\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t}: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t} = {},\n\t): PrismicMigrationAsset {\n\t\tlet config: MigrationAssetConfig\n\t\tlet maybeInitialField: FilledImageFieldImage | undefined\n\t\tif (typeof fileOrAssetOrField === \"object\" && \"url\" in fileOrAssetOrField) {\n\t\t\tif (\n\t\t\t\t\"dimensions\" in fileOrAssetOrField ||\n\t\t\t\t\"link_type\" in fileOrAssetOrField\n\t\t\t) {\n\t\t\t\tconst url = fileOrAssetOrField.url.split(\"?\")[0]\n\t\t\t\tconst filename =\n\t\t\t\t\t\"name\" in fileOrAssetOrField\n\t\t\t\t\t\t? fileOrAssetOrField.name\n\t\t\t\t\t\t: url.split(\"/\").pop()!.split(\"_\").pop()!\n\t\t\t\tconst credits =\n\t\t\t\t\t\"copyright\" in fileOrAssetOrField && fileOrAssetOrField.copyright\n\t\t\t\t\t\t? fileOrAssetOrField.copyright\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst alt =\n\t\t\t\t\t\"alt\" in fileOrAssetOrField && fileOrAssetOrField.alt\n\t\t\t\t\t\t? fileOrAssetOrField.alt\n\t\t\t\t\t\t: undefined\n\n\t\t\t\tif (\"dimensions\" in fileOrAssetOrField) {\n\t\t\t\t\tmaybeInitialField = fileOrAssetOrField\n\t\t\t\t}\n\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: url,\n\t\t\t\t\tfilename,\n\t\t\t\t\tnotes: undefined,\n\t\t\t\t\tcredits,\n\t\t\t\t\talt,\n\t\t\t\t\ttags: undefined,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: fileOrAssetOrField.url,\n\t\t\t\t\tfilename: fileOrAssetOrField.filename,\n\t\t\t\t\tnotes: fileOrAssetOrField.notes,\n\t\t\t\t\tcredits: fileOrAssetOrField.credits,\n\t\t\t\t\talt: fileOrAssetOrField.alt,\n\t\t\t\t\ttags: fileOrAssetOrField.tags?.map(({ name }) => name),\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = {\n\t\t\t\tid: fileOrAssetOrField,\n\t\t\t\tfile: fileOrAssetOrField,\n\t\t\t\tfilename: filename!,\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\ttags,\n\t\t\t}\n\t\t}\n\n\t\tvalidateAssetMetadata(config)\n\n\t\t// We create a detached instance of the asset each time to serialize it properly\n\t\tconst migrationAsset = new PrismicMigrationAsset(config, maybeInitialField)\n\n\t\tconst maybeAsset = this._assets.get(config.id)\n\t\tif (maybeAsset) {\n\t\t\t// Consolidate existing asset with new asset value if possible\n\t\t\tmaybeAsset.config.notes = maybeAsset.config.notes || config.notes\n\t\t\tmaybeAsset.config.credits = maybeAsset.config.credits || config.credits\n\t\t\tmaybeAsset.config.alt = maybeAsset.config.alt || config.alt\n\t\t\tmaybeAsset.config.tags = Array.from(\n\t\t\t\tnew Set([...(maybeAsset.config.tags || []), ...(config.tags || [])]),\n\t\t\t)\n\t\t} else {\n\t\t\tthis._assets.set(config.id, migrationAsset)\n\t\t}\n\n\t\treturn migrationAsset\n\t}\n\n\t/**\n\t * Registers a document to be created in the migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of the Prismic document to create.\n\t *\n\t * @param document - The document to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t * @param params - Document master language document ID.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<PendingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t},\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title, params)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers an existing document to be updated in the migration.\n\t *\n\t * @remarks\n\t * This method does not update the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be updated when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t *\n\t * @param document - The document to update.\n\t * @param title - The title of the document to update which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tupdateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\t// Title is optional for existing documents as we might not want to update it.\n\t\ttitle?: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers a document from another Prismic repository to be created in the\n\t * migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param document - The document from Prismic to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocumentFromPrismic<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument(\n\t\t\tthis.#migratePrismicDocumentData({\n\t\t\t\ttype: document.type,\n\t\t\t\tlang: document.lang,\n\t\t\t\tuid: document.uid,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}) as PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\t\ttitle,\n\t\t\t{ originalPrismicDocument: document },\n\t\t)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Queries a document from the migration instance with a specific UID and\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getByUID(\"blog_post\", \"my-first-post\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the document's custom type.\n\t * @param uid - The UID of the document.\n\t *\n\t * @returns The migration document instance with a UID matching the `uid`\n\t * parameter, if a matching document is found.\n\t */\n\tgetByUID<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t\tuid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type && doc.document.uid === uid,\n\t\t)\n\t}\n\n\t/**\n\t * Queries a singleton document from the migration instance for a specific\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getSingle(\"settings\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the singleton custom type.\n\t *\n\t * @returns The migration document instance for the custom type, if a matching\n\t * document is found.\n\t */\n\tgetSingle<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type,\n\t\t)\n\t}\n\n\t/**\n\t * Migrates a Prismic document data from another repository so that it can be\n\t * created through the current repository's Migration API.\n\t *\n\t * @param input - The Prismic document data to migrate.\n\t *\n\t * @returns The migrated Prismic document data.\n\t */\n\t#migratePrismicDocumentData(input: unknown): unknown {\n\t\tif (is.filledContentRelationship(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\tif (input.isBroken) {\n\t\t\t\treturn {\n\t\t\t\t\t...optionalLinkProperties,\n\t\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\t\t// ID needs to be 16 characters long to be considered valid by the API\n\t\t\t\t\tid: \"_____broken_____\",\n\t\t\t\t\tisBroken: true,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\tid: () => this._getByOriginalID(input.id),\n\t\t\t}\n\t\t}\n\n\t\tif (is.filledLinkToMedia(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Media,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\t\t}\n\n\t\tif (is.rtImageNode(input)) {\n\t\t\t// Rich text image nodes\n\t\t\tconst rtImageNode: MigrationRTImageNode = {\n\t\t\t\ttype: RichTextNodeType.image,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tif (input.linkTo) {\n\t\t\t\trtImageNode.linkTo = this.#migratePrismicDocumentData(input.linkTo) as\n\t\t\t\t\t| MigrationContentRelationship\n\t\t\t\t\t| MigrationLinkToMedia\n\t\t\t\t\t| FilledLinkToWebField\n\t\t\t}\n\n\t\t\treturn rtImageNode\n\t\t}\n\n\t\tif (is.filledImage(input)) {\n\t\t\tconst image: MigrationImage = {\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tid: _id,\n\t\t\t\turl: _url,\n\t\t\t\tdimensions: _dimensions,\n\t\t\t\tedit: _edit,\n\t\t\t\talt: _alt,\n\t\t\t\tcopyright: _copyright,\n\t\t\t\t...thumbnails\n\t\t\t} = input\n\n\t\t\tfor (const name in thumbnails) {\n\t\t\t\tif (is.filledImage(thumbnails[name])) {\n\t\t\t\t\timage[name] = this.createAsset(thumbnails[name])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn image\n\t\t}\n\n\t\tif (Array.isArray(input)) {\n\t\t\treturn input.map((element) => this.#migratePrismicDocumentData(element))\n\t\t}\n\n\t\tif (input && typeof input === \"object\") {\n\t\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\t\tfor (const key in input) {\n\t\t\t\tres[key] = this.#migratePrismicDocumentData(\n\t\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn res\n\t\t}\n\n\t\treturn input\n\t}\n\n\t/**\n\t * Queries a document from the migration instance for a specific original ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration._getByOriginalID(\"YhdrDxIAACgAcp_b\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param id - The original ID of the Prismic document.\n\t *\n\t * @returns The migration document instance for the original ID, if a matching\n\t * document is found.\n\t *\n\t * @internal\n\t */\n\t_getByOriginalID<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.originalPrismicDocument?.id === id,\n\t\t)\n\t}\n}\n"],"names":["filename","credits","alt","is.filledContentRelationship","is.filledLinkToMedia","is.rtImageNode","rtImageNode","is.filledImage"],"mappings":";;;;;;;;;;;;;;;;;MA8Ca,UAAS;AAAA;;AAMrB;AAAA;AAAA;AAAA;AAAA;AAAA,uDAAwE,IAAG;AAO3E;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAqD;;;;;;;;;;;;;EA0ErD,YACC,oBAKA,UACA,EACC,OACA,SACA,KACA,KAMG,IAAA,IAAE;;AAEF,QAAA;AACA,QAAA;AACJ,QAAI,OAAO,uBAAuB,YAAY,SAAS,oBAAoB;AAEzE,UAAA,gBAAgB,sBAChB,eAAe,oBACd;AACD,cAAM,MAAM,mBAAmB,IAAI,MAAM,GAAG,EAAE,CAAC;AAC/C,cAA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AA,MAC7B,IAAI,KAAK,YAAY,KAAK;AAAA;AAG3B,UAAM,EACL,IAAI,KACJ,KAAK,MACL,YAAY,aACZ,MAAM,OACN,KAAK,MACL,WAAW,YACX,GAAG,eACA;AAEJ,eAAW,QAAQ,YAAY;AAC9B,UAAIA,YAAe,WAAW,IAAI,CAAC,GAAG;AACrC,cAAM,IAAI,IAAI,KAAK,YAAY,WAAW,IAAI,CAAC;AAAA,MAAA;AAAA,IAChD;AAGM,WAAA;AAAA,EAAA;AAGJ,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,MAAM,IAAI,CAAC,YAAY,sBAAK,qDAAL,WAAiC,QAAQ;AAAA,EAAA;AAGpE,MAAA,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,MAAoC,CAAA;AAE1C,eAAW,OAAO,OAAO;AACxB,UAAI,GAAG,IAAI,sBAAK,qDAAL,WACV,MAAM,GAAyB;AAAA,IAAC;AAI3B,WAAA;AAAA,EAAA;AAGD,SAAA;AAAA;"}
1
+ {"version":3,"file":"Migration.js","sources":["../../src/Migration.ts"],"sourcesContent":["import * as is from \"./lib/isValue\"\nimport { getOptionalLinkProperties } from \"./lib/getOptionalLinkProperties\"\nimport { validateAssetMetadata } from \"./lib/validateAssetMetadata\"\n\nimport type { Asset } from \"./types/api/asset/asset\"\nimport type {\n\tMigrationAssetConfig,\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"./types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"./types/migration/Document\"\nimport type {\n\tExistingPrismicDocument,\n\tPendingPrismicDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\nimport type { FilledImageFieldImage } from \"./types/value/image\"\nimport { type FilledLinkToWebField, LinkType } from \"./types/value/link\"\nimport type { FilledLinkToMediaField } from \"./types/value/linkToMedia\"\nimport { RichTextNodeType } from \"./types/value/richText\"\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * A helper that allows preparing your migration to Prismic.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class Migration<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * Assets registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_assets: Map<MigrationAssetConfig[\"file\"], PrismicMigrationAsset> = new Map()\n\n\t/**\n\t * Documents registered in the migration.\n\t *\n\t * @internal\n\t */\n\t_documents: PrismicMigrationDocument<TDocuments>[] = []\n\n\t/**\n\t * Registers an asset to be created in the migration from an asset object.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param asset - An asset object from Prismic Asset API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(asset: Asset): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from an image or link to\n\t * media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param imageOrLinkToMediaField - An image or link to media field from\n\t * Prismic Document API.\n\t *\n\t * @returns A migration asset field instance.\n\t *\n\t * @internal\n\t */\n\tcreateAsset(\n\t\timageOrLinkToMediaField: FilledImageFieldImage | FilledLinkToMediaField,\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param file - The URL or content of the file to be created.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfile: MigrationAssetConfig[\"file\"],\n\t\tfilename: MigrationAssetConfig[\"filename\"],\n\t\tparams?: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t},\n\t): PrismicMigrationAsset\n\n\t/**\n\t * Registers an asset to be created in the migration from a file, an asset\n\t * object, or an image or link to media field.\n\t *\n\t * @remarks\n\t * This method does not create the asset in Prismic media library right away.\n\t * Instead, it registers it in your migration. The asset will be created when\n\t * the migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @returns A migration asset field instance.\n\t */\n\tcreateAsset(\n\t\tfileOrAssetOrField:\n\t\t\t| MigrationAssetConfig[\"file\"]\n\t\t\t| Asset\n\t\t\t| FilledImageFieldImage\n\t\t\t| FilledLinkToMediaField,\n\t\tfilename?: MigrationAssetConfig[\"filename\"],\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t}: {\n\t\t\tnotes?: string\n\t\t\tcredits?: string\n\t\t\talt?: string\n\t\t\ttags?: string[]\n\t\t} = {},\n\t): PrismicMigrationAsset {\n\t\tlet config: MigrationAssetConfig\n\t\tlet maybeInitialField: FilledImageFieldImage | undefined\n\t\tif (typeof fileOrAssetOrField === \"object\" && \"url\" in fileOrAssetOrField) {\n\t\t\tif (\n\t\t\t\t\"dimensions\" in fileOrAssetOrField ||\n\t\t\t\t\"link_type\" in fileOrAssetOrField\n\t\t\t) {\n\t\t\t\tconst url = fileOrAssetOrField.url.split(\"?\")[0]\n\t\t\t\tconst filename =\n\t\t\t\t\t\"name\" in fileOrAssetOrField\n\t\t\t\t\t\t? fileOrAssetOrField.name\n\t\t\t\t\t\t: url.split(\"/\").pop()!.split(\"_\").pop()!\n\t\t\t\tconst credits =\n\t\t\t\t\t\"copyright\" in fileOrAssetOrField && fileOrAssetOrField.copyright\n\t\t\t\t\t\t? fileOrAssetOrField.copyright\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst alt =\n\t\t\t\t\t\"alt\" in fileOrAssetOrField && fileOrAssetOrField.alt\n\t\t\t\t\t\t? fileOrAssetOrField.alt\n\t\t\t\t\t\t: undefined\n\n\t\t\t\tif (\"dimensions\" in fileOrAssetOrField) {\n\t\t\t\t\tmaybeInitialField = fileOrAssetOrField\n\t\t\t\t}\n\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: url,\n\t\t\t\t\tfilename,\n\t\t\t\t\tnotes: undefined,\n\t\t\t\t\tcredits,\n\t\t\t\t\talt,\n\t\t\t\t\ttags: undefined,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconfig = {\n\t\t\t\t\tid: fileOrAssetOrField.id,\n\t\t\t\t\tfile: fileOrAssetOrField.url,\n\t\t\t\t\tfilename: fileOrAssetOrField.filename,\n\t\t\t\t\tnotes: fileOrAssetOrField.notes,\n\t\t\t\t\tcredits: fileOrAssetOrField.credits,\n\t\t\t\t\talt: fileOrAssetOrField.alt,\n\t\t\t\t\ttags: fileOrAssetOrField.tags?.map(({ name }) => name),\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = {\n\t\t\t\tid: fileOrAssetOrField,\n\t\t\t\tfile: fileOrAssetOrField,\n\t\t\t\tfilename: filename!,\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\ttags,\n\t\t\t}\n\t\t}\n\n\t\tvalidateAssetMetadata(config)\n\n\t\t// We create a detached instance of the asset each time to serialize it properly\n\t\tconst migrationAsset = new PrismicMigrationAsset(config, maybeInitialField)\n\n\t\tconst maybeAsset = this._assets.get(config.id)\n\t\tif (maybeAsset) {\n\t\t\t// Consolidate existing asset with new asset value if possible\n\t\t\tmaybeAsset.config.notes = maybeAsset.config.notes || config.notes\n\t\t\tmaybeAsset.config.credits = maybeAsset.config.credits || config.credits\n\t\t\tmaybeAsset.config.alt = maybeAsset.config.alt || config.alt\n\t\t\tmaybeAsset.config.tags = Array.from(\n\t\t\t\tnew Set([...(maybeAsset.config.tags || []), ...(config.tags || [])]),\n\t\t\t)\n\t\t} else {\n\t\t\tthis._assets.set(config.id, migrationAsset)\n\t\t}\n\n\t\treturn migrationAsset\n\t}\n\n\t/**\n\t * Registers a document to be created in the migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of the Prismic document to create.\n\t *\n\t * @param document - The document to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t * @param params - Document master language document ID.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<PendingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t},\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title, params)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers an existing document to be updated in the migration.\n\t *\n\t * @remarks\n\t * This method does not update the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be updated when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t *\n\t * @param document - The document to update.\n\t * @param title - The title of the document to update which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tupdateDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\t// Title is optional for existing documents as we might not want to update it.\n\t\ttitle?: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument<\n\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t>(document, title)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Registers a document from another Prismic repository to be created in the\n\t * migration.\n\t *\n\t * @remarks\n\t * This method does not create the document in Prismic right away. Instead, it\n\t * registers it in your migration. The document will be created when the\n\t * migration is executed through the `writeClient.migrate()` method.\n\t *\n\t * @param document - The document from Prismic to create.\n\t * @param title - The title of the document to create which will be displayed\n\t * in the editor.\n\t *\n\t * @returns A migration document instance.\n\t */\n\tcreateDocumentFromPrismic<TType extends TDocuments[\"type\"]>(\n\t\tdocument: ExtractDocumentType<ExistingPrismicDocument<TDocuments>, TType>,\n\t\ttitle: string,\n\t): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> {\n\t\tconst doc = new PrismicMigrationDocument(\n\t\t\tthis.#migratePrismicDocumentData({\n\t\t\t\ttype: document.type,\n\t\t\t\tlang: document.lang,\n\t\t\t\tuid: document.uid,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}) as PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\t\ttitle,\n\t\t\t{ originalPrismicDocument: document },\n\t\t)\n\n\t\tthis._documents.push(doc)\n\n\t\treturn doc\n\t}\n\n\t/**\n\t * Queries a document from the migration instance with a specific UID and\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getByUID(\"blog_post\", \"my-first-post\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the document's custom type.\n\t * @param uid - The UID of the document.\n\t *\n\t * @returns The migration document instance with a UID matching the `uid`\n\t * parameter, if a matching document is found.\n\t */\n\tgetByUID<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t\tuid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type && doc.document.uid === uid,\n\t\t)\n\t}\n\n\t/**\n\t * Queries a singleton document from the migration instance for a specific\n\t * custom type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration.getSingle(\"settings\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param type - The API ID of the singleton custom type.\n\t *\n\t * @returns The migration document instance for the custom type, if a matching\n\t * document is found.\n\t */\n\tgetSingle<TType extends TDocuments[\"type\"]>(\n\t\ttype: TType,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.document.type === type,\n\t\t)\n\t}\n\n\t/**\n\t * Migrates a Prismic document data from another repository so that it can be\n\t * created through the current repository's Migration API.\n\t *\n\t * @param input - The Prismic document data to migrate.\n\t *\n\t * @returns The migrated Prismic document data.\n\t */\n\t#migratePrismicDocumentData(input: unknown): unknown {\n\t\tif (is.filledContentRelationship(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\tif (input.isBroken) {\n\t\t\t\treturn {\n\t\t\t\t\t...optionalLinkProperties,\n\t\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\t\t// ID needs to be 16 characters long to be considered valid by the API\n\t\t\t\t\tid: \"_____broken_____\",\n\t\t\t\t\tisBroken: true,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Document,\n\t\t\t\tid: () => this._getByOriginalID(input.id),\n\t\t\t}\n\t\t}\n\n\t\tif (is.filledLinkToMedia(input)) {\n\t\t\tconst optionalLinkProperties = getOptionalLinkProperties(input)\n\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\tlink_type: LinkType.Media,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\t\t}\n\n\t\tif (is.rtImageNode(input)) {\n\t\t\t// Rich text image nodes\n\t\t\tconst rtImageNode: MigrationRTImageNode = {\n\t\t\t\ttype: RichTextNodeType.image,\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tif (input.linkTo) {\n\t\t\t\trtImageNode.linkTo = this.#migratePrismicDocumentData(input.linkTo) as\n\t\t\t\t\t| MigrationContentRelationship\n\t\t\t\t\t| MigrationLinkToMedia\n\t\t\t\t\t| FilledLinkToWebField\n\t\t\t}\n\n\t\t\treturn rtImageNode\n\t\t}\n\n\t\tif (is.filledImage(input)) {\n\t\t\tconst image: MigrationImage = {\n\t\t\t\tid: this.createAsset(input),\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tid: _id,\n\t\t\t\turl: _url,\n\t\t\t\tdimensions: _dimensions,\n\t\t\t\tedit: _edit,\n\t\t\t\talt: _alt,\n\t\t\t\tcopyright: _copyright,\n\t\t\t\t...thumbnails\n\t\t\t} = input\n\n\t\t\tfor (const name in thumbnails) {\n\t\t\t\tif (is.filledImage(thumbnails[name])) {\n\t\t\t\t\timage[name] = this.createAsset(thumbnails[name])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn image\n\t\t}\n\n\t\tif (Array.isArray(input)) {\n\t\t\treturn input.map((element) => this.#migratePrismicDocumentData(element))\n\t\t}\n\n\t\tif (input && typeof input === \"object\") {\n\t\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\t\tfor (const key in input) {\n\t\t\t\tres[key] = this.#migratePrismicDocumentData(\n\t\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn res\n\t\t}\n\n\t\treturn input\n\t}\n\n\t/**\n\t * Queries a document from the migration instance for a specific original ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const contentRelationship = migration.createContentRelationship(() =>\n\t * \tmigration._getByOriginalID(\"YhdrDxIAACgAcp_b\"),\n\t * )\n\t * ```\n\t *\n\t * @typeParam TType - Type of the Prismic document returned.\n\t *\n\t * @param id - The original ID of the Prismic document.\n\t *\n\t * @returns The migration document instance for the original ID, if a matching\n\t * document is found.\n\t *\n\t * @internal\n\t */\n\t_getByOriginalID<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t):\n\t\t| PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>>\n\t\t| undefined {\n\t\treturn this._documents.find(\n\t\t\t(\n\t\t\t\tdoc,\n\t\t\t): doc is PrismicMigrationDocument<\n\t\t\t\tExtractDocumentType<TDocuments, TType>\n\t\t\t> => doc.originalPrismicDocument?.id === id,\n\t\t)\n\t}\n}\n"],"names":["filename","credits","alt","is.filledContentRelationship","is.filledLinkToMedia","is.rtImageNode","rtImageNode","is.filledImage"],"mappings":";;;;;;;MA8Ca,UAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrB,8BAAwE,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxE,aAAqD,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0ErD,YACC,oBA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