@prismicio/client 7.21.0-alpha.1 → 7.21.0

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 (281) 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 +113 -98
  12. package/dist/WriteClient.cjs.map +1 -1
  13. package/dist/WriteClient.d.ts +6 -6
  14. package/dist/WriteClient.js +113 -98
  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 +2 -0
  90. package/dist/index.cjs.map +1 -1
  91. package/dist/index.d.ts +121 -120
  92. package/dist/index.js +2 -0
  93. package/dist/index.js.map +1 -1
  94. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  95. package/dist/isRepositoryEndpoint.d.ts +2 -2
  96. package/dist/isRepositoryEndpoint.js.map +1 -1
  97. package/dist/isRepositoryName.cjs.map +1 -1
  98. package/dist/isRepositoryName.js.map +1 -1
  99. package/dist/lib/appendFilters.cjs.map +1 -1
  100. package/dist/lib/appendFilters.js.map +1 -1
  101. package/dist/lib/castArray.cjs.map +1 -1
  102. package/dist/lib/castArray.js.map +1 -1
  103. package/dist/lib/castThunk.cjs.map +1 -1
  104. package/dist/lib/castThunk.js.map +1 -1
  105. package/dist/lib/devMsg.cjs.map +1 -1
  106. package/dist/lib/devMsg.js.map +1 -1
  107. package/dist/lib/escapeHTML.cjs.map +1 -1
  108. package/dist/lib/escapeHTML.js.map +1 -1
  109. package/dist/lib/everyTagFilter.cjs.map +1 -1
  110. package/dist/lib/everyTagFilter.js.map +1 -1
  111. package/dist/lib/findMasterRef.cjs.map +1 -1
  112. package/dist/lib/findMasterRef.d.ts +1 -1
  113. package/dist/lib/findMasterRef.js.map +1 -1
  114. package/dist/lib/findRef.cjs.map +1 -1
  115. package/dist/lib/findRef.d.ts +1 -1
  116. package/dist/lib/findRef.js.map +1 -1
  117. package/dist/lib/findRefByID.cjs.map +1 -1
  118. package/dist/lib/findRefByID.d.ts +1 -1
  119. package/dist/lib/findRefByID.js.map +1 -1
  120. package/dist/lib/findRefByLabel.cjs.map +1 -1
  121. package/dist/lib/findRefByLabel.d.ts +1 -1
  122. package/dist/lib/findRefByLabel.js.map +1 -1
  123. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
  124. package/dist/lib/getOptionalLinkProperties.d.ts +1 -1
  125. package/dist/lib/getOptionalLinkProperties.js.map +1 -1
  126. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  127. package/dist/lib/getPreviewCookie.js.map +1 -1
  128. package/dist/lib/isInternalURL.cjs.map +1 -1
  129. package/dist/lib/isInternalURL.js.map +1 -1
  130. package/dist/lib/isMigrationValue.cjs.map +1 -1
  131. package/dist/lib/isMigrationValue.d.ts +8 -8
  132. package/dist/lib/isMigrationValue.js.map +1 -1
  133. package/dist/lib/isValue.cjs.map +1 -1
  134. package/dist/lib/isValue.d.ts +10 -10
  135. package/dist/lib/isValue.js.map +1 -1
  136. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  137. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  138. package/dist/lib/pLimit.cjs +3 -4
  139. package/dist/lib/pLimit.cjs.map +1 -1
  140. package/dist/lib/pLimit.js +3 -4
  141. package/dist/lib/pLimit.js.map +1 -1
  142. package/dist/lib/request.cjs +8 -10
  143. package/dist/lib/request.cjs.map +1 -1
  144. package/dist/lib/request.js +8 -10
  145. package/dist/lib/request.js.map +1 -1
  146. package/dist/lib/resolveMigrationDocumentData.cjs +4 -6
  147. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  148. package/dist/lib/resolveMigrationDocumentData.d.ts +8 -8
  149. package/dist/lib/resolveMigrationDocumentData.js +4 -6
  150. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  151. package/dist/lib/serializerHelpers.cjs +2 -2
  152. package/dist/lib/serializerHelpers.cjs.map +1 -1
  153. package/dist/lib/serializerHelpers.d.ts +3 -3
  154. package/dist/lib/serializerHelpers.js +2 -2
  155. package/dist/lib/serializerHelpers.js.map +1 -1
  156. package/dist/lib/someTagsFilter.cjs.map +1 -1
  157. package/dist/lib/someTagsFilter.js.map +1 -1
  158. package/dist/lib/throttledLog.cjs.map +1 -1
  159. package/dist/lib/throttledLog.js.map +1 -1
  160. package/dist/lib/typeFilter.cjs.map +1 -1
  161. package/dist/lib/typeFilter.js.map +1 -1
  162. package/dist/lib/validateAssetMetadata.cjs.map +1 -1
  163. package/dist/lib/validateAssetMetadata.d.ts +1 -1
  164. package/dist/lib/validateAssetMetadata.js.map +1 -1
  165. package/dist/package.json.cjs +1 -1
  166. package/dist/package.json.js +1 -1
  167. package/dist/richtext/asText.cjs.map +1 -1
  168. package/dist/richtext/asText.d.ts +6 -6
  169. package/dist/richtext/asText.js.map +1 -1
  170. package/dist/richtext/asTree.cjs.map +1 -1
  171. package/dist/richtext/asTree.d.ts +2 -2
  172. package/dist/richtext/asTree.js.map +1 -1
  173. package/dist/richtext/composeSerializers.cjs.map +1 -1
  174. package/dist/richtext/composeSerializers.d.ts +1 -1
  175. package/dist/richtext/composeSerializers.js.map +1 -1
  176. package/dist/richtext/index.d.ts +7 -7
  177. package/dist/richtext/serialize.cjs.map +1 -1
  178. package/dist/richtext/serialize.d.ts +10 -10
  179. package/dist/richtext/serialize.js.map +1 -1
  180. package/dist/richtext/types.cjs.map +1 -1
  181. package/dist/richtext/types.d.ts +7 -7
  182. package/dist/richtext/types.js.map +1 -1
  183. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  184. package/dist/richtext/wrapMapSerializer.d.ts +1 -1
  185. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  186. package/dist/types/api/asset/asset.d.ts +1 -1
  187. package/dist/types/api/integration.d.ts +1 -1
  188. package/dist/types/api/migration/document.d.ts +1 -1
  189. package/dist/types/api/query.d.ts +1 -1
  190. package/dist/types/api/release.d.ts +1 -1
  191. package/dist/types/api/repository.d.ts +1 -1
  192. package/dist/types/migration/Asset.cjs +12 -15
  193. package/dist/types/migration/Asset.cjs.map +1 -1
  194. package/dist/types/migration/Asset.d.ts +7 -7
  195. package/dist/types/migration/Asset.js +12 -15
  196. package/dist/types/migration/Asset.js.map +1 -1
  197. package/dist/types/migration/ContentRelationship.d.ts +3 -3
  198. package/dist/types/migration/Document.cjs +24 -27
  199. package/dist/types/migration/Document.cjs.map +1 -1
  200. package/dist/types/migration/Document.d.ts +9 -9
  201. package/dist/types/migration/Document.js +24 -27
  202. package/dist/types/migration/Document.js.map +1 -1
  203. package/dist/types/migration/Link.d.ts +1 -1
  204. package/dist/types/model/boolean.d.ts +1 -1
  205. package/dist/types/model/color.d.ts +1 -1
  206. package/dist/types/model/contentRelationship.d.ts +3 -2
  207. package/dist/types/model/customType.d.ts +1 -1
  208. package/dist/types/model/date.d.ts +1 -1
  209. package/dist/types/model/embed.d.ts +1 -1
  210. package/dist/types/model/geoPoint.d.ts +1 -1
  211. package/dist/types/model/group.d.ts +1 -1
  212. package/dist/types/model/image.d.ts +1 -1
  213. package/dist/types/model/integration.d.ts +1 -1
  214. package/dist/types/model/keyText.d.ts +1 -1
  215. package/dist/types/model/link.d.ts +1 -1
  216. package/dist/types/model/linkToMedia.d.ts +2 -2
  217. package/dist/types/model/number.d.ts +1 -1
  218. package/dist/types/model/range.d.ts +1 -1
  219. package/dist/types/model/richText.d.ts +1 -1
  220. package/dist/types/model/select.d.ts +1 -1
  221. package/dist/types/model/separator.d.ts +1 -1
  222. package/dist/types/model/sharedSlice.d.ts +2 -2
  223. package/dist/types/model/sharedSliceVariation.d.ts +1 -1
  224. package/dist/types/model/slice.d.ts +3 -3
  225. package/dist/types/model/sliceZone.d.ts +2 -2
  226. package/dist/types/model/table.d.ts +1 -1
  227. package/dist/types/model/timestamp.d.ts +1 -1
  228. package/dist/types/model/title.d.ts +1 -1
  229. package/dist/types/model/types.cjs.map +1 -1
  230. package/dist/types/model/types.d.ts +22 -23
  231. package/dist/types/model/types.js.map +1 -1
  232. package/dist/types/model/uid.d.ts +1 -1
  233. package/dist/types/value/color.d.ts +1 -1
  234. package/dist/types/value/contentRelationship.d.ts +3 -3
  235. package/dist/types/value/date.d.ts +1 -1
  236. package/dist/types/value/document.d.ts +4 -4
  237. package/dist/types/value/embed.d.ts +1 -1
  238. package/dist/types/value/geoPoint.d.ts +1 -1
  239. package/dist/types/value/group.d.ts +1 -1
  240. package/dist/types/value/image.d.ts +1 -1
  241. package/dist/types/value/integration.d.ts +1 -1
  242. package/dist/types/value/keyText.d.ts +1 -1
  243. package/dist/types/value/link.d.ts +5 -5
  244. package/dist/types/value/linkToMedia.d.ts +2 -2
  245. package/dist/types/value/number.d.ts +1 -1
  246. package/dist/types/value/richText.d.ts +3 -3
  247. package/dist/types/value/select.d.ts +1 -1
  248. package/dist/types/value/sharedSlice.d.ts +1 -1
  249. package/dist/types/value/sharedSliceVariation.d.ts +1 -1
  250. package/dist/types/value/slice.d.ts +1 -1
  251. package/dist/types/value/sliceZone.d.ts +3 -3
  252. package/dist/types/value/table.d.ts +2 -2
  253. package/dist/types/value/timestamp.d.ts +2 -2
  254. package/dist/types/value/title.d.ts +2 -2
  255. package/dist/types/value/types.d.ts +18 -18
  256. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  257. package/dist/types/webhook/testTrigger.d.ts +1 -1
  258. package/dist/types/webhook/types.d.ts +2 -2
  259. package/package.json +11 -11
  260. package/src/WriteClient.ts +21 -32
  261. package/src/buildQueryURL.ts +29 -21
  262. package/src/createClient.ts +11 -8
  263. package/src/getRepositoryEndpoint.ts +9 -2
  264. package/src/helpers/asDate.ts +11 -4
  265. package/src/helpers/asHTML.ts +34 -26
  266. package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
  267. package/src/helpers/asImageSrc.ts +11 -10
  268. package/src/helpers/asImageWidthSrcSet.ts +18 -17
  269. package/src/helpers/asLink.ts +33 -32
  270. package/src/helpers/asLinkAttrs.ts +6 -9
  271. package/src/helpers/asText.ts +20 -10
  272. package/src/helpers/isFilled.ts +15 -14
  273. package/src/helpers/mapSliceZone.ts +10 -10
  274. package/src/index.ts +3 -2
  275. package/src/isRepositoryEndpoint.ts +2 -2
  276. package/src/richtext/asText.ts +5 -5
  277. package/src/richtext/serialize.ts +8 -8
  278. package/src/richtext/types.ts +6 -6
  279. package/src/types/migration/Asset.ts +10 -2
  280. package/src/types/model/contentRelationship.ts +1 -0
  281. package/src/types/model/types.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.cjs","sources":["../../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAgBa,MAAA,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AACtC,YAAA,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACT,cAAA,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AACT,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IACD;AAAA,EAEF;AACD;;"}
1
+ {"version":3,"file":"composeSerializers.cjs","sources":["../../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAgBO,MAAM,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAC5C,YAAM,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACf,cAAM,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AAChB,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;;"}
@@ -1,4 +1,4 @@
1
- import type { RichTextFunctionSerializer } from "./types";
1
+ import type { RichTextFunctionSerializer } from "./types.js";
2
2
  /**
3
3
  * Takes an array of serializers and returns a serializer applying provided
4
4
  * serializers sequentially until a result is returned
@@ -1 +1 @@
1
- {"version":3,"file":"composeSerializers.js","sources":["../../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAgBa,MAAA,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AACtC,YAAA,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACT,cAAA,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AACT,iBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IACD;AAAA,EAEF;AACD;"}
1
+ {"version":3,"file":"composeSerializers.js","sources":["../../../src/richtext/composeSerializers.ts"],"sourcesContent":["import type { RichTextFunctionSerializer } from \"./types\"\n\n/**\n * Takes an array of serializers and returns a serializer applying provided\n * serializers sequentially until a result is returned\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of serializers\n *\n * @param serializers - Serializers to compose\n *\n * @returns Composed serializer\n */\nexport const composeSerializers = <SerializerReturnType>(\n\t...serializers: (\n\t\t| RichTextFunctionSerializer<SerializerReturnType>\n\t\t| undefined\n\t)[]\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (...args) => {\n\t\tfor (let i = 0; i < serializers.length; i++) {\n\t\t\tconst serializer = serializers[i]\n\n\t\t\tif (serializer) {\n\t\t\t\tconst res = serializer(...args)\n\n\t\t\t\tif (res != null) {\n\t\t\t\t\treturn res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAgBO,MAAM,qBAAqB,IAC9B,gBAIkD;AACrD,SAAO,IAAI,SAAQ;AAClB,aAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAC5C,YAAM,aAAa,YAAY,CAAC;AAEhC,UAAI,YAAY;AACf,cAAM,MAAM,WAAW,GAAG,IAAI;AAE9B,YAAI,OAAO,MAAM;AAChB,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;"}
@@ -1,7 +1,7 @@
1
- export { asTree } from "./asTree";
2
- export { asText } from "./asText";
3
- export { serialize } from "./serialize";
4
- export { wrapMapSerializer } from "./wrapMapSerializer";
5
- export { composeSerializers } from "./composeSerializers";
6
- export { RichTextNodeType as Element } from "../types/value/richText";
7
- export type { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction, } from "./types";
1
+ export { asTree } from "./asTree.js";
2
+ export { asText } from "./asText.js";
3
+ export { serialize } from "./serialize.js";
4
+ export { wrapMapSerializer } from "./wrapMapSerializer.js";
5
+ export { composeSerializers } from "./composeSerializers.js";
6
+ export { RichTextNodeType as Element } from "../types/value/richText.js";
7
+ export type { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction, } from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.cjs","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text or title field with a given serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the serializer\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param serializer - A function serializer to apply\n *\n * @returns An array of serialized nodes\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":["asTree"],"mappings":";;;AAqBa,MAAA,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACNA,OAAA,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAChC,UAAA,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAAA;AAAA,EAC5C;AAGM,SAAA;AACR;;"}
1
+ {"version":3,"file":"serialize.cjs","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level\n * packages. Most users aren't expected to use this function directly.\n *\n * @typeParam SerializerReturnType - Return type of the serializer.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n *\n * @returns An array of serialized nodes.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":["asTree"],"mappings":";;;AAqBO,MAAM,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACNA,OAAAA,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,UAAM,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAC5C;AAAA,EACD;AAEA,SAAO;AACR;;"}
@@ -1,19 +1,19 @@
1
- import type { RichTextField } from "../types/value/richText";
2
- import type { RichTextFunctionSerializer } from "./types";
1
+ import type { RichTextField } from "../types/value/richText.js";
2
+ import type { RichTextFunctionSerializer } from "./types.js";
3
3
  /**
4
- * Serializes a rich text or title field with a given serializer
4
+ * Serializes a rich text field with a given serializer.
5
5
  *
6
6
  * @remarks
7
- * This is a low level helper mainly intended to be used by higher level
8
- * packages Most users aren't expected to this function directly
7
+ * This is a low-level helper mainly intended to be used by higher-level
8
+ * packages. Most users aren't expected to use this function directly.
9
9
  *
10
- * @typeParam SerializerReturnType - Return type of the serializer
10
+ * @typeParam SerializerReturnType - Return type of the serializer.
11
11
  *
12
- * @param richTextField - A rich text or title field from Prismic
13
- * @param serializer - A function serializer to apply
12
+ * @param richTextField - A rich text field from Prismic.
13
+ * @param serializer - A function serializer to apply.
14
14
  *
15
- * @returns An array of serialized nodes
15
+ * @returns An array of serialized nodes.
16
16
  *
17
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
17
+ * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
18
18
  */
19
19
  export declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.js","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text or title field with a given serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the serializer\n *\n * @param richTextField - A rich text or title field from Prismic\n * @param serializer - A function serializer to apply\n *\n * @returns An array of serialized nodes\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":[],"mappings":";AAqBa,MAAA,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACN,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAChC,UAAA,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAAA;AAAA,EAC5C;AAGM,SAAA;AACR;"}
1
+ {"version":3,"file":"serialize.js","sources":["../../../src/richtext/serialize.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\nimport type { RichTextFunctionSerializer, TreeNode } from \"./types\"\n\nimport { asTree } from \"./asTree\"\n\n/**\n * Serializes a rich text field with a given serializer.\n *\n * @remarks\n * This is a low-level helper mainly intended to be used by higher-level\n * packages. Most users aren't expected to use this function directly.\n *\n * @typeParam SerializerReturnType - Return type of the serializer.\n *\n * @param richTextField - A rich text field from Prismic.\n * @param serializer - A function serializer to apply.\n *\n * @returns An array of serialized nodes.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const serialize = <SerializerReturnType>(\n\trichTextField: RichTextField,\n\tserializer: RichTextFunctionSerializer<SerializerReturnType>,\n): SerializerReturnType[] => {\n\treturn serializeTreeNodes<SerializerReturnType>(\n\t\tasTree(richTextField).children,\n\t\tserializer,\n\t)\n}\n\nconst serializeTreeNodes = <T>(\n\tnodes: TreeNode[],\n\tserializer: RichTextFunctionSerializer<T>,\n): T[] => {\n\tconst serializedTreeNodes: T[] = []\n\n\tfor (let i = 0; i < nodes.length; i++) {\n\t\tconst treeNode = nodes[i]\n\t\tconst serializedTreeNode = serializer(\n\t\t\ttreeNode.type,\n\t\t\ttreeNode.node,\n\t\t\ttreeNode.text,\n\t\t\tserializeTreeNodes(treeNode.children, serializer),\n\t\t\ttreeNode.key,\n\t\t)\n\n\t\tif (serializedTreeNode != null) {\n\t\t\tserializedTreeNodes.push(serializedTreeNode)\n\t\t}\n\t}\n\n\treturn serializedTreeNodes\n}\n"],"names":[],"mappings":";AAqBO,MAAM,YAAY,CACxB,eACA,eAC2B;AAC3B,SAAO,mBACN,OAAO,aAAa,EAAE,UACtB,UAAU;AAEZ;AAEA,MAAM,qBAAqB,CAC1B,OACA,eACQ;AACR,QAAM,sBAA2B,CAAA;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,UAAM,WAAW,MAAM,CAAC;AACxB,UAAM,qBAAqB,WAC1B,SAAS,MACT,SAAS,MACT,SAAS,MACT,mBAAmB,SAAS,UAAU,UAAU,GAChD,SAAS,GAAG;AAGb,QAAI,sBAAsB,MAAM;AAC/B,0BAAoB,KAAK,kBAAkB;AAAA,IAC5C;AAAA,EACD;AAEA,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text or title field with a map\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}\n *\n * @typeParam ReturnType - Return type of the map serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":["RichTextNodeType"],"mappings":";;;AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAACA,SAAAA,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAACA,SAAAA,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAACA,SAAAA,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAACA,SAAAA,iBAAiB,KAAK,GAAG;;;"}
1
+ {"version":3,"file":"types.cjs","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map.\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}.\n *\n * @typeParam ReturnType - Return type of the map serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":["RichTextNodeType"],"mappings":";;;AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAACA,SAAAA,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAACA,SAAAA,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAACA,SAAAA,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAACA,SAAAA,iBAAiB,KAAK,GAAG;;;"}
@@ -1,10 +1,10 @@
1
- import type { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, RichTextNodeTypes } from "../types/value/richText";
1
+ import type { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, RichTextNodeTypes } from "../types/value/richText.js";
2
2
  /**
3
3
  * Serializes a node from a rich text or title field with a function
4
4
  *
5
- * @typeParam ReturnType - Return type of the function serializer
5
+ * @typeParam ReturnType - Return type of the function serializer.
6
6
  *
7
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
7
+ * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
8
8
  */
9
9
  export type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeTypes, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
10
10
  /**
@@ -21,15 +21,15 @@ export type RichTextMapSerializerFunction<ReturnType, Node extends RTAnyNode = R
21
21
  key: string;
22
22
  }) => ReturnType | null | undefined;
23
23
  /**
24
- * Serializes a node from a rich text or title field with a map
24
+ * Serializes a node from a rich text field with a map.
25
25
  *
26
26
  * @remarks
27
27
  * This type of serializer needs to be processed through
28
- * {@link wrapMapSerializer} before being used with {@link serialize}
28
+ * {@link wrapMapSerializer} before being used with {@link serialize}.
29
29
  *
30
- * @typeParam ReturnType - Return type of the map serializer
30
+ * @typeParam ReturnType - Return type of the map serializer.
31
31
  *
32
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
32
+ * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
33
33
  */
34
34
  export type RichTextMapSerializer<ReturnType> = {
35
35
  heading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text or title field with a map\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}\n *\n * @typeParam ReturnType - Return type of the map serializer\n *\n * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":[],"mappings":";AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAAC,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAAC,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAAC,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAAC,iBAAiB,KAAK,GAAG;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those\n * handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map.\n *\n * @remarks\n * This type of serializer needs to be processed through\n * {@link wrapMapSerializer} before being used with {@link serialize}.\n *\n * @typeParam ReturnType - Return type of the map serializer.\n *\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading1Node,\n\t\tundefined\n\t>\n\theading2?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading2Node,\n\t\tundefined\n\t>\n\theading3?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading3Node,\n\t\tundefined\n\t>\n\theading4?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading4Node,\n\t\tundefined\n\t>\n\theading5?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading5Node,\n\t\tundefined\n\t>\n\theading6?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTHeading6Node,\n\t\tundefined\n\t>\n\tparagraph?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTParagraphNode,\n\t\tundefined\n\t>\n\tpreformatted?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTPreformattedNode,\n\t\tundefined\n\t>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTListItemNode,\n\t\tundefined\n\t>\n\toListItem?: RichTextMapSerializerFunction<\n\t\tReturnType,\n\t\tRTOListItemNode,\n\t\tundefined\n\t>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"names":[],"mappings":";AAoJO,MAAM,2BAA2B;AAAA,EACvC,CAAC,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAAC,iBAAiB,SAAS,GAAG;AAAA,EAC9B,CAAC,iBAAiB,IAAI,GAAG;AAAA,EACzB,CAAC,iBAAiB,KAAK,GAAG;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrapMapSerializer.cjs","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["RichTextReversedNodeType"],"mappings":";;;AAgBa,MAAA,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACEA,MACA,yBAAA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,EAEH;AACD;;"}
1
+ {"version":3,"file":"wrapMapSerializer.cjs","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["RichTextReversedNodeType"],"mappings":";;;AAgBO,MAAM,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACEA,MAAAA,yBACA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IACF;AAAA,EACD;AACD;;"}
@@ -1,4 +1,4 @@
1
- import type { RichTextFunctionSerializer, RichTextMapSerializer } from "./types";
1
+ import type { RichTextFunctionSerializer, RichTextMapSerializer } from "./types.js";
2
2
  /**
3
3
  * Wraps a map serializer into a regular function serializer
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"wrapMapSerializer.js","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAgBa,MAAA,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACE,yBACA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IAAA;AAAA,EAEH;AACD;"}
1
+ {"version":3,"file":"wrapMapSerializer.js","sources":["../../../src/richtext/wrapMapSerializer.ts"],"sourcesContent":["import type { RichTextFunctionSerializer, RichTextMapSerializer } from \"./types\"\nimport { RichTextReversedNodeType } from \"./types\"\n\n/**\n * Wraps a map serializer into a regular function serializer\n *\n * @remarks\n * This is a low level helper mainly intended to be used by higher level\n * packages Most users aren't expected to this function directly\n *\n * @typeParam SerializerReturnType - Return type of the map serializer\n *\n * @param mapSerializer - Map serializer to wrap\n *\n * @returns A regular function serializer\n */\nexport const wrapMapSerializer = <SerializerReturnType>(\n\tmapSerializer: RichTextMapSerializer<SerializerReturnType>,\n): RichTextFunctionSerializer<SerializerReturnType> => {\n\treturn (type, node, text, children, key) => {\n\t\tconst tagSerializer: RichTextMapSerializer<SerializerReturnType>[keyof RichTextMapSerializer<SerializerReturnType>] =\n\t\t\tmapSerializer[\n\t\t\t\t(RichTextReversedNodeType[\n\t\t\t\t\ttype as keyof typeof RichTextReversedNodeType\n\t\t\t\t] || type) as keyof RichTextMapSerializer<SerializerReturnType>\n\t\t\t]\n\n\t\tif (tagSerializer) {\n\t\t\treturn tagSerializer({\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttype,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tnode,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\ttext,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tchildren,\n\t\t\t\t// @ts-expect-error cannot type check here\n\t\t\t\tkey,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAgBO,MAAM,oBAAoB,CAChC,kBACqD;AACrD,SAAO,CAAC,MAAM,MAAM,MAAM,UAAU,QAAO;AAC1C,UAAM,gBACL,cACE,yBACA,IAA6C,KACzC,IAA0D;AAGjE,QAAI,eAAe;AAClB,aAAO,cAAc;AAAA;AAAA,QAEpB;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA;AAAA,QAEA;AAAA,MAAA,CACA;AAAA,IACF;AAAA,EACD;AACD;"}
@@ -1,4 +1,4 @@
1
- import type { AssetTag } from "./tag";
1
+ import type { AssetTag } from "./tag.js";
2
2
  /**
3
3
  * Asset types.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IntegrationFieldData } from "../value/integration";
1
+ import type { IntegrationFieldData } from "../value/integration.js";
2
2
  /**
3
3
  * A catalog item from an integration field.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { PrismicDocument, PrismicDocumentWithUID } from "../../value/document";
1
+ import type { PrismicDocument, PrismicDocumentWithUID } from "../../value/document.js";
2
2
  /**
3
3
  * An object representing the parameters required when creating a document
4
4
  * through the Migration API.
@@ -1,4 +1,4 @@
1
- import type { PrismicDocument } from "../value/document";
1
+ import type { PrismicDocument } from "../value/document.js";
2
2
  /**
3
3
  * A query response from the Prismic REST API V2. The response contains
4
4
  * paginated metadata and a list of matching results for the query.
@@ -1,4 +1,4 @@
1
- import type { Ref } from "./ref";
1
+ import type { Ref } from "./ref.js";
2
2
  /**
3
3
  * Metadata for a Release.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { Ref } from "./ref";
1
+ import type { Ref } from "./ref.js";
2
2
  /**
3
3
  * Repository metadata returned from the Prismic REST API V2. This data can be
4
4
  * fetched by sending a `GET` a request to a repository's `/api/v2` endpoint.
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
3
  class PrismicMigrationAsset {
4
+ /**
5
+ * Asset object from Prismic, available once created.
6
+ */
7
+ asset;
8
+ /**
9
+ * Configuration of the asset.
10
+ */
11
+ config;
12
+ /**
13
+ * The initial field value this migration field was created with.
14
+ */
15
+ originalField;
7
16
  /**
8
17
  * Creates a migration asset used with the Prismic Migration API.
9
18
  *
@@ -13,18 +22,6 @@ class PrismicMigrationAsset {
13
22
  * @returns A migration asset instance.
14
23
  */
15
24
  constructor(config, initialField) {
16
- /**
17
- * Asset object from Prismic, available once created.
18
- */
19
- __publicField(this, "asset");
20
- /**
21
- * Configuration of the asset.
22
- */
23
- __publicField(this, "config");
24
- /**
25
- * The initial field value this migration field was created with.
26
- */
27
- __publicField(this, "originalField");
28
25
  this.config = config;
29
26
  this.originalField = initialField;
30
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Asset.cjs","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;;;;MA2Ga,sBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BjC,YACC,QACA,cAGc;AA5Bf;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAoBC,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EAAA;AAEtB;;"}
1
+ {"version":3,"file":"Asset.cjs","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;MAmHa,sBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,YACC,QACA,cAGc;AAEd,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACtB;AACA;;"}
@@ -1,8 +1,8 @@
1
- import type { Asset } from "../api/asset/asset";
2
- import type { FilledImageFieldImage } from "../value/image";
3
- import type { LinkToMediaField } from "../value/linkToMedia";
4
- import { type RTImageNode } from "../value/richText";
5
- import type { InjectMigrationSpecificTypes } from "./Document";
1
+ import type { Asset } from "../api/asset/asset.js";
2
+ import type { FilledImageFieldImage } from "../value/image.js";
3
+ import type { LinkToMediaField } from "../value/linkToMedia.js";
4
+ import { type RTImageNode } from "../value/richText.js";
5
+ import type { InjectMigrationSpecificTypes } from "./Document.js";
6
6
  /**
7
7
  * An asset to be uploaded to Prismic media library.
8
8
  */
@@ -15,11 +15,11 @@ export type MigrationAssetConfig = {
15
15
  * `file` property. It is mainly used for deduplication within a `Migration`
16
16
  * instance.
17
17
  */
18
- id: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0];
18
+ id: string | URL | File | NonNullable<ConstructorParameters<typeof File>[0]>[0];
19
19
  /**
20
20
  * File to be uploaded as an asset.
21
21
  */
22
- file: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0];
22
+ file: string | URL | File | NonNullable<ConstructorParameters<typeof File>[0]>[0];
23
23
  /**
24
24
  * Filename of the asset.
25
25
  */
@@ -1,7 +1,16 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
1
  class PrismicMigrationAsset {
2
+ /**
3
+ * Asset object from Prismic, available once created.
4
+ */
5
+ asset;
6
+ /**
7
+ * Configuration of the asset.
8
+ */
9
+ config;
10
+ /**
11
+ * The initial field value this migration field was created with.
12
+ */
13
+ originalField;
5
14
  /**
6
15
  * Creates a migration asset used with the Prismic Migration API.
7
16
  *
@@ -11,18 +20,6 @@ class PrismicMigrationAsset {
11
20
  * @returns A migration asset instance.
12
21
  */
13
22
  constructor(config, initialField) {
14
- /**
15
- * Asset object from Prismic, available once created.
16
- */
17
- __publicField(this, "asset");
18
- /**
19
- * Configuration of the asset.
20
- */
21
- __publicField(this, "config");
22
- /**
23
- * The initial field value this migration field was created with.
24
- */
25
- __publicField(this, "originalField");
26
23
  this.config = config;
27
24
  this.originalField = initialField;
28
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Asset.js","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;;MA2Ga,sBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BjC,YACC,QACA,cAGc;AA5Bf;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAoBC,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EAAA;AAEtB;"}
1
+ {"version":3,"file":"Asset.js","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile:\n\t\t| string\n\t\t| URL\n\t\t| File\n\t\t| NonNullable<ConstructorParameters<typeof File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":"MAmHa,sBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,YACC,QACA,cAGc;AAEd,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACtB;AACA;"}
@@ -1,6 +1,6 @@
1
- import type { ContentRelationshipField, EmptyContentRelationshipField, FilledContentRelationshipField } from "../value/contentRelationship";
2
- import type { PrismicDocument } from "../value/document";
3
- import type { PrismicMigrationDocument } from "./Document";
1
+ import type { ContentRelationshipField, EmptyContentRelationshipField, FilledContentRelationshipField } from "../value/contentRelationship.js";
2
+ import type { PrismicDocument } from "../value/document.js";
3
+ import type { PrismicMigrationDocument } from "./Document.js";
4
4
  type ValueOrThunk<T> = T | (() => Promise<T> | T);
5
5
  /**
6
6
  * A content relationship field in a migration.
@@ -1,9 +1,28 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
3
  class PrismicMigrationDocument {
4
+ /**
5
+ * The document to be sent to the Migration API.
6
+ */
7
+ document;
8
+ /**
9
+ * The name of the document displayed in the editor.
10
+ */
11
+ title;
12
+ /**
13
+ * The link to the master language document to relate the document to if any.
14
+ */
15
+ masterLanguageDocument;
16
+ /**
17
+ * Original Prismic document when the migration document came from another
18
+ * Prismic repository.
19
+ *
20
+ * @remarks
21
+ * When migrating a document from another repository, one might want to alter
22
+ * it with migration specific types, hence accepting an
23
+ * `ExistingPrismicDocument` instead of a regular `PrismicDocument`.
24
+ */
25
+ originalPrismicDocument;
7
26
  /**
8
27
  * Creates a Prismic migration document instance.
9
28
  *
@@ -15,32 +34,10 @@ class PrismicMigrationDocument {
15
34
  * @returns A Prismic migration document instance.
16
35
  */
17
36
  constructor(document, title, params) {
18
- /**
19
- * The document to be sent to the Migration API.
20
- */
21
- __publicField(this, "document");
22
- /**
23
- * The name of the document displayed in the editor.
24
- */
25
- __publicField(this, "title");
26
- /**
27
- * The link to the master language document to relate the document to if any.
28
- */
29
- __publicField(this, "masterLanguageDocument");
30
- /**
31
- * Original Prismic document when the migration document came from another
32
- * Prismic repository.
33
- *
34
- * @remarks
35
- * When migrating a document from another repository, one might want to alter
36
- * it with migration specific types, hence accepting an
37
- * `ExistingPrismicDocument` instead of a regular `PrismicDocument`.
38
- */
39
- __publicField(this, "originalPrismicDocument");
40
37
  this.document = document;
41
38
  this.title = title;
42
- this.masterLanguageDocument = params == null ? void 0 : params.masterLanguageDocument;
43
- this.originalPrismicDocument = params == null ? void 0 : params.originalPrismicDocument;
39
+ this.masterLanguageDocument = params?.masterLanguageDocument;
40
+ this.originalPrismicDocument = params?.originalPrismicDocument;
44
41
  }
45
42
  }
46
43
  exports.PrismicMigrationDocument = PrismicMigrationDocument;
@@ -1 +1 @@
1
- {"version":3,"file":"Document.cjs","sources":["../../../../src/types/migration/Document.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../value/contentRelationship\"\nimport type { PrismicDocument, PrismicDocumentWithUID } from \"../value/document\"\nimport type { AnyOEmbed, EmbedField, OEmbedExtra } from \"../value/embed\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { FilledLinkToMediaField } from \"../value/linkToMedia\"\nimport type { RTImageNode } from \"../value/richText\"\nimport type { SharedSlice } from \"../value/sharedSlice\"\n\nimport type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./Asset\"\nimport type { MigrationContentRelationship } from \"./ContentRelationship\"\n\n/**\n * A utility type that extends any fields in a record with their migration\n * fields equivalent.\n *\n * @typeParam T - Type of the record to extend.\n */\nexport type InjectMigrationSpecificTypes<T> = T extends RTImageNode\n\t?\n\t\t\t| T\n\t\t\t| (Omit<T, \"linkTo\"> & InjectMigrationSpecificTypes<Pick<T, \"linkTo\">>)\n\t\t\t| MigrationRTImageNode\n\t\t\t| undefined\n\t: T extends FilledImageFieldImage\n\t\t? T | MigrationImage | undefined\n\t\t: T extends FilledLinkToMediaField\n\t\t\t? T | MigrationLinkToMedia | undefined\n\t\t\t: T extends FilledContentRelationshipField\n\t\t\t\t? T | MigrationContentRelationship\n\t\t\t\t: T extends EmbedField<AnyOEmbed & OEmbedExtra, \"filled\">\n\t\t\t\t\t? T | Pick<T, \"embed_url\">\n\t\t\t\t\t: T extends SharedSlice\n\t\t\t\t\t\t?\n\t\t\t\t\t\t\t\t| T\n\t\t\t\t\t\t\t\t| InjectMigrationSpecificTypes<\n\t\t\t\t\t\t\t\t\t\tOmit<T, \"id\" | \"slice_label\" | \"version\">\n\t\t\t\t\t\t\t\t >\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\tT extends Record<any, any>\n\t\t\t\t\t\t\t? { [P in keyof T]: InjectMigrationSpecificTypes<T[P]> }\n\t\t\t\t\t\t\t: T extends Array<infer U>\n\t\t\t\t\t\t\t\t? Array<InjectMigrationSpecificTypes<U>>\n\t\t\t\t\t\t\t\t: T\n\n/**\n * A utility type that ties the type and data of a Prismic document, creating a\n * strict union.\n */\ntype TiedDocumentTypeAndData<TDocument extends PrismicDocument> =\n\tTDocument extends PrismicDocument<infer TData, infer TType>\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Type of the document.\n\t\t\t\t */\n\t\t\t\ttype: TType\n\n\t\t\t\t/**\n\t\t\t\t * Data contained in the document.\n\t\t\t\t */\n\t\t\t\tdata: InjectMigrationSpecificTypes<TData>\n\t\t\t} & (TDocument extends PrismicDocumentWithUID\n\t\t\t\t? Pick<TDocument, \"uid\">\n\t\t\t\t: Partial<Pick<TDocument, \"uid\">>)\n\t\t: never\n\n/**\n * A pending Prismic document to be created with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type PendingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Pick<TDocument, \"lang\"> &\n\tPartial<Pick<TDocument, \"tags\">> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * An existing Prismic document to be updated with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type ExistingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Omit<TDocument, \"uid\" | \"type\" | \"data\"> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * A Prismic document to be sent to the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type MigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = PendingPrismicDocument<TDocument> | ExistingPrismicDocument<TDocument>\n\n/**\n * A Prismic migration document instance.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport class PrismicMigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> {\n\t/**\n\t * The document to be sent to the Migration API.\n\t */\n\tdocument: MigrationDocument<TDocument> & Partial<Pick<TDocument, \"id\">>\n\n\t/**\n\t * The name of the document displayed in the editor.\n\t */\n\ttitle?: string\n\n\t/**\n\t * The link to the master language document to relate the document to if any.\n\t */\n\tmasterLanguageDocument?: MigrationContentRelationship\n\n\t/**\n\t * Original Prismic document when the migration document came from another\n\t * Prismic repository.\n\t *\n\t * @remarks\n\t * When migrating a document from another repository, one might want to alter\n\t * it with migration specific types, hence accepting an\n\t * `ExistingPrismicDocument` instead of a regular `PrismicDocument`.\n\t */\n\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\n\t/**\n\t * Creates a Prismic migration document instance.\n\t *\n\t * @param document - The document to be sent to the Migration API.\n\t * @param title - The name of the document displayed in the editor.\n\t * @param params - Parameters to create/update the document with on the\n\t * Migration API.\n\t *\n\t * @returns A Prismic migration document instance.\n\t */\n\tconstructor(\n\t\tdocument: MigrationDocument<TDocument>,\n\t\ttitle?: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\t\t},\n\t) {\n\t\tthis.document = document\n\t\tthis.title = title\n\t\tthis.masterLanguageDocument = params?.masterLanguageDocument\n\t\tthis.originalPrismicDocument = params?.originalPrismicDocument\n\t}\n}\n"],"names":[],"mappings":";;;;;MAwGa,yBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuCpC,YACC,UACA,OACA,QAGC;AAvCF;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAWA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBC,SAAK,WAAW;AAChB,SAAK,QAAQ;AACb,SAAK,yBAAyB,iCAAQ;AACtC,SAAK,0BAA0B,iCAAQ;AAAA,EAAA;AAExC;;"}
1
+ {"version":3,"file":"Document.cjs","sources":["../../../../src/types/migration/Document.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../value/contentRelationship\"\nimport type { PrismicDocument, PrismicDocumentWithUID } from \"../value/document\"\nimport type { AnyOEmbed, EmbedField, OEmbedExtra } from \"../value/embed\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { FilledLinkToMediaField } from \"../value/linkToMedia\"\nimport type { RTImageNode } from \"../value/richText\"\nimport type { SharedSlice } from \"../value/sharedSlice\"\n\nimport type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./Asset\"\nimport type { MigrationContentRelationship } from \"./ContentRelationship\"\n\n/**\n * A utility type that extends any fields in a record with their migration\n * fields equivalent.\n *\n * @typeParam T - Type of the record to extend.\n */\nexport type InjectMigrationSpecificTypes<T> = T extends RTImageNode\n\t?\n\t\t\t| T\n\t\t\t| (Omit<T, \"linkTo\"> & InjectMigrationSpecificTypes<Pick<T, \"linkTo\">>)\n\t\t\t| MigrationRTImageNode\n\t\t\t| undefined\n\t: T extends FilledImageFieldImage\n\t\t? T | MigrationImage | undefined\n\t\t: T extends FilledLinkToMediaField\n\t\t\t? T | MigrationLinkToMedia | undefined\n\t\t\t: T extends FilledContentRelationshipField\n\t\t\t\t? T | MigrationContentRelationship\n\t\t\t\t: T extends EmbedField<AnyOEmbed & OEmbedExtra, \"filled\">\n\t\t\t\t\t? T | Pick<T, \"embed_url\">\n\t\t\t\t\t: T extends SharedSlice\n\t\t\t\t\t\t?\n\t\t\t\t\t\t\t\t| T\n\t\t\t\t\t\t\t\t| InjectMigrationSpecificTypes<\n\t\t\t\t\t\t\t\t\t\tOmit<T, \"id\" | \"slice_label\" | \"version\">\n\t\t\t\t\t\t\t\t >\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\tT extends Record<any, any>\n\t\t\t\t\t\t\t? { [P in keyof T]: InjectMigrationSpecificTypes<T[P]> }\n\t\t\t\t\t\t\t: T extends Array<infer U>\n\t\t\t\t\t\t\t\t? Array<InjectMigrationSpecificTypes<U>>\n\t\t\t\t\t\t\t\t: T\n\n/**\n * A utility type that ties the type and data of a Prismic document, creating a\n * strict union.\n */\ntype TiedDocumentTypeAndData<TDocument extends PrismicDocument> =\n\tTDocument extends PrismicDocument<infer TData, infer TType>\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Type of the document.\n\t\t\t\t */\n\t\t\t\ttype: TType\n\n\t\t\t\t/**\n\t\t\t\t * Data contained in the document.\n\t\t\t\t */\n\t\t\t\tdata: InjectMigrationSpecificTypes<TData>\n\t\t\t} & (TDocument extends PrismicDocumentWithUID\n\t\t\t\t? Pick<TDocument, \"uid\">\n\t\t\t\t: Partial<Pick<TDocument, \"uid\">>)\n\t\t: never\n\n/**\n * A pending Prismic document to be created with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type PendingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Pick<TDocument, \"lang\"> &\n\tPartial<Pick<TDocument, \"tags\">> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * An existing Prismic document to be updated with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type ExistingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Omit<TDocument, \"uid\" | \"type\" | \"data\"> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * A Prismic document to be sent to the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type MigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = PendingPrismicDocument<TDocument> | ExistingPrismicDocument<TDocument>\n\n/**\n * A Prismic migration document instance.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport class PrismicMigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> {\n\t/**\n\t * The document to be sent to the Migration API.\n\t */\n\tdocument: MigrationDocument<TDocument> & Partial<Pick<TDocument, \"id\">>\n\n\t/**\n\t * The name of the document displayed in the editor.\n\t */\n\ttitle?: string\n\n\t/**\n\t * The link to the master language document to relate the document to if any.\n\t */\n\tmasterLanguageDocument?: MigrationContentRelationship\n\n\t/**\n\t * Original Prismic document when the migration document came from another\n\t * Prismic repository.\n\t *\n\t * @remarks\n\t * When migrating a document from another repository, one might want to alter\n\t * it with migration specific types, hence accepting an\n\t * `ExistingPrismicDocument` instead of a regular `PrismicDocument`.\n\t */\n\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\n\t/**\n\t * Creates a Prismic migration document instance.\n\t *\n\t * @param document - The document to be sent to the Migration API.\n\t * @param title - The name of the document displayed in the editor.\n\t * @param params - Parameters to create/update the document with on the\n\t * Migration API.\n\t *\n\t * @returns A Prismic migration document instance.\n\t */\n\tconstructor(\n\t\tdocument: MigrationDocument<TDocument>,\n\t\ttitle?: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\t\t},\n\t) {\n\t\tthis.document = document\n\t\tthis.title = title\n\t\tthis.masterLanguageDocument = params?.masterLanguageDocument\n\t\tthis.originalPrismicDocument = params?.originalPrismicDocument\n\t}\n}\n"],"names":[],"mappings":";;MAwGa,yBAAwB;AAAA;AAAA;AAAA;AAAA,EAMpC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,YACC,UACA,OACA,QAGC;AAED,SAAK,WAAW;AAChB,SAAK,QAAQ;AACb,SAAK,yBAAyB,QAAQ;AACtC,SAAK,0BAA0B,QAAQ;AAAA,EACxC;AACA;;"}
@@ -1,12 +1,12 @@
1
- import type { FilledContentRelationshipField } from "../value/contentRelationship";
2
- import type { PrismicDocument, PrismicDocumentWithUID } from "../value/document";
3
- import type { AnyOEmbed, EmbedField, OEmbedExtra } from "../value/embed";
4
- import type { FilledImageFieldImage } from "../value/image";
5
- import type { FilledLinkToMediaField } from "../value/linkToMedia";
6
- import type { RTImageNode } from "../value/richText";
7
- import type { SharedSlice } from "../value/sharedSlice";
8
- import type { MigrationImage, MigrationLinkToMedia, MigrationRTImageNode } from "./Asset";
9
- import type { MigrationContentRelationship } from "./ContentRelationship";
1
+ import type { FilledContentRelationshipField } from "../value/contentRelationship.js";
2
+ import type { PrismicDocument, PrismicDocumentWithUID } from "../value/document.js";
3
+ import type { AnyOEmbed, EmbedField, OEmbedExtra } from "../value/embed.js";
4
+ import type { FilledImageFieldImage } from "../value/image.js";
5
+ import type { FilledLinkToMediaField } from "../value/linkToMedia.js";
6
+ import type { RTImageNode } from "../value/richText.js";
7
+ import type { SharedSlice } from "../value/sharedSlice.js";
8
+ import type { MigrationImage, MigrationLinkToMedia, MigrationRTImageNode } from "./Asset.js";
9
+ import type { MigrationContentRelationship } from "./ContentRelationship.js";
10
10
  /**
11
11
  * A utility type that extends any fields in a record with their migration
12
12
  * fields equivalent.