@prismicio/client 7.20.2 → 7.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) 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 +117 -98
  12. package/dist/WriteClient.cjs.map +1 -1
  13. package/dist/WriteClient.d.ts +6 -6
  14. package/dist/WriteClient.js +117 -98
  15. package/dist/WriteClient.js.map +1 -1
  16. package/dist/buildQueryURL.cjs.map +1 -1
  17. package/dist/buildQueryURL.js.map +1 -1
  18. package/dist/createClient.cjs.map +1 -1
  19. package/dist/createClient.d.ts +2 -2
  20. package/dist/createMigration.cjs.map +1 -1
  21. package/dist/createMigration.d.ts +2 -2
  22. package/dist/createMigration.js.map +1 -1
  23. package/dist/createWriteClient.cjs.map +1 -1
  24. package/dist/createWriteClient.d.ts +2 -2
  25. package/dist/errors/ForbiddenError.d.ts +1 -1
  26. package/dist/errors/InvalidDataError.d.ts +1 -1
  27. package/dist/errors/NotFoundError.d.ts +1 -1
  28. package/dist/errors/ParsingError.d.ts +1 -1
  29. package/dist/errors/PreviewTokenExpired.d.ts +1 -1
  30. package/dist/errors/PrismicError.cjs +2 -5
  31. package/dist/errors/PrismicError.cjs.map +1 -1
  32. package/dist/errors/PrismicError.js +2 -5
  33. package/dist/errors/PrismicError.js.map +1 -1
  34. package/dist/errors/RefExpiredError.d.ts +1 -1
  35. package/dist/errors/RefNotFoundError.d.ts +1 -1
  36. package/dist/errors/RepositoryNotFoundError.d.ts +1 -1
  37. package/dist/filter.cjs.map +1 -1
  38. package/dist/filter.js.map +1 -1
  39. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  40. package/dist/getGraphQLEndpoint.js.map +1 -1
  41. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  42. package/dist/getRepositoryEndpoint.js.map +1 -1
  43. package/dist/getRepositoryName.cjs.map +1 -1
  44. package/dist/getRepositoryName.js.map +1 -1
  45. package/dist/getToolbarSrc.cjs.map +1 -1
  46. package/dist/getToolbarSrc.js.map +1 -1
  47. package/dist/helpers/asDate.cjs.map +1 -1
  48. package/dist/helpers/asDate.d.ts +2 -2
  49. package/dist/helpers/asDate.js.map +1 -1
  50. package/dist/helpers/asHTML.cjs +22 -22
  51. package/dist/helpers/asHTML.cjs.map +1 -1
  52. package/dist/helpers/asHTML.d.ts +3 -3
  53. package/dist/helpers/asHTML.js +22 -22
  54. package/dist/helpers/asHTML.js.map +1 -1
  55. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  56. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +1 -1
  57. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  58. package/dist/helpers/asImageSrc.cjs.map +1 -1
  59. package/dist/helpers/asImageSrc.d.ts +1 -1
  60. package/dist/helpers/asImageSrc.js.map +1 -1
  61. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  62. package/dist/helpers/asImageWidthSrcSet.d.ts +1 -1
  63. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  64. package/dist/helpers/asLink.cjs.map +1 -1
  65. package/dist/helpers/asLink.d.ts +4 -4
  66. package/dist/helpers/asLink.js.map +1 -1
  67. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  68. package/dist/helpers/asLinkAttrs.d.ts +5 -5
  69. package/dist/helpers/asLinkAttrs.js.map +1 -1
  70. package/dist/helpers/asText.cjs.map +1 -1
  71. package/dist/helpers/asText.d.ts +1 -1
  72. package/dist/helpers/asText.js.map +1 -1
  73. package/dist/helpers/documentToLinkField.cjs +1 -2
  74. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  75. package/dist/helpers/documentToLinkField.d.ts +2 -2
  76. package/dist/helpers/documentToLinkField.js +1 -2
  77. package/dist/helpers/documentToLinkField.js.map +1 -1
  78. package/dist/helpers/isFilled.cjs.map +1 -1
  79. package/dist/helpers/isFilled.d.ts +21 -21
  80. package/dist/helpers/isFilled.js.map +1 -1
  81. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  82. package/dist/helpers/mapSliceZone.d.ts +1 -1
  83. package/dist/helpers/mapSliceZone.js.map +1 -1
  84. package/dist/index.cjs.map +1 -1
  85. package/dist/index.d.ts +120 -120
  86. package/dist/index.js.map +1 -1
  87. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  88. package/dist/isRepositoryEndpoint.js.map +1 -1
  89. package/dist/isRepositoryName.cjs.map +1 -1
  90. package/dist/isRepositoryName.js.map +1 -1
  91. package/dist/lib/appendFilters.cjs.map +1 -1
  92. package/dist/lib/appendFilters.js.map +1 -1
  93. package/dist/lib/castArray.cjs.map +1 -1
  94. package/dist/lib/castArray.js.map +1 -1
  95. package/dist/lib/castThunk.cjs.map +1 -1
  96. package/dist/lib/castThunk.js.map +1 -1
  97. package/dist/lib/devMsg.cjs.map +1 -1
  98. package/dist/lib/devMsg.js.map +1 -1
  99. package/dist/lib/escapeHTML.cjs.map +1 -1
  100. package/dist/lib/escapeHTML.js.map +1 -1
  101. package/dist/lib/everyTagFilter.cjs.map +1 -1
  102. package/dist/lib/everyTagFilter.js.map +1 -1
  103. package/dist/lib/findMasterRef.cjs.map +1 -1
  104. package/dist/lib/findMasterRef.d.ts +1 -1
  105. package/dist/lib/findMasterRef.js.map +1 -1
  106. package/dist/lib/findRef.cjs.map +1 -1
  107. package/dist/lib/findRef.d.ts +1 -1
  108. package/dist/lib/findRef.js.map +1 -1
  109. package/dist/lib/findRefByID.cjs.map +1 -1
  110. package/dist/lib/findRefByID.d.ts +1 -1
  111. package/dist/lib/findRefByID.js.map +1 -1
  112. package/dist/lib/findRefByLabel.cjs.map +1 -1
  113. package/dist/lib/findRefByLabel.d.ts +1 -1
  114. package/dist/lib/findRefByLabel.js.map +1 -1
  115. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
  116. package/dist/lib/getOptionalLinkProperties.d.ts +1 -1
  117. package/dist/lib/getOptionalLinkProperties.js.map +1 -1
  118. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  119. package/dist/lib/getPreviewCookie.js.map +1 -1
  120. package/dist/lib/isInternalURL.cjs.map +1 -1
  121. package/dist/lib/isInternalURL.js.map +1 -1
  122. package/dist/lib/isMigrationValue.cjs.map +1 -1
  123. package/dist/lib/isMigrationValue.d.ts +8 -8
  124. package/dist/lib/isMigrationValue.js.map +1 -1
  125. package/dist/lib/isValue.cjs.map +1 -1
  126. package/dist/lib/isValue.d.ts +10 -10
  127. package/dist/lib/isValue.js.map +1 -1
  128. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  129. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  130. package/dist/lib/pLimit.cjs +3 -4
  131. package/dist/lib/pLimit.cjs.map +1 -1
  132. package/dist/lib/pLimit.js +3 -4
  133. package/dist/lib/pLimit.js.map +1 -1
  134. package/dist/lib/request.cjs +8 -10
  135. package/dist/lib/request.cjs.map +1 -1
  136. package/dist/lib/request.js +8 -10
  137. package/dist/lib/request.js.map +1 -1
  138. package/dist/lib/resolveMigrationDocumentData.cjs +4 -6
  139. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  140. package/dist/lib/resolveMigrationDocumentData.d.ts +8 -8
  141. package/dist/lib/resolveMigrationDocumentData.js +4 -6
  142. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  143. package/dist/lib/serializerHelpers.cjs +2 -2
  144. package/dist/lib/serializerHelpers.cjs.map +1 -1
  145. package/dist/lib/serializerHelpers.d.ts +3 -3
  146. package/dist/lib/serializerHelpers.js +2 -2
  147. package/dist/lib/serializerHelpers.js.map +1 -1
  148. package/dist/lib/someTagsFilter.cjs.map +1 -1
  149. package/dist/lib/someTagsFilter.js.map +1 -1
  150. package/dist/lib/throttledLog.cjs.map +1 -1
  151. package/dist/lib/throttledLog.js.map +1 -1
  152. package/dist/lib/typeFilter.cjs.map +1 -1
  153. package/dist/lib/typeFilter.js.map +1 -1
  154. package/dist/lib/validateAssetMetadata.cjs.map +1 -1
  155. package/dist/lib/validateAssetMetadata.d.ts +1 -1
  156. package/dist/lib/validateAssetMetadata.js.map +1 -1
  157. package/dist/package.json.cjs +1 -1
  158. package/dist/package.json.js +1 -1
  159. package/dist/richtext/asText.cjs.map +1 -1
  160. package/dist/richtext/asText.d.ts +1 -1
  161. package/dist/richtext/asText.js.map +1 -1
  162. package/dist/richtext/asTree.cjs.map +1 -1
  163. package/dist/richtext/asTree.d.ts +2 -2
  164. package/dist/richtext/asTree.js.map +1 -1
  165. package/dist/richtext/composeSerializers.cjs.map +1 -1
  166. package/dist/richtext/composeSerializers.d.ts +1 -1
  167. package/dist/richtext/composeSerializers.js.map +1 -1
  168. package/dist/richtext/index.d.ts +7 -7
  169. package/dist/richtext/serialize.cjs.map +1 -1
  170. package/dist/richtext/serialize.d.ts +2 -2
  171. package/dist/richtext/serialize.js.map +1 -1
  172. package/dist/richtext/types.d.ts +1 -1
  173. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  174. package/dist/richtext/wrapMapSerializer.d.ts +1 -1
  175. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  176. package/dist/types/api/asset/asset.d.ts +1 -1
  177. package/dist/types/api/integration.d.ts +1 -1
  178. package/dist/types/api/migration/document.d.ts +1 -1
  179. package/dist/types/api/query.d.ts +1 -1
  180. package/dist/types/api/release.d.ts +1 -1
  181. package/dist/types/api/repository.d.ts +1 -1
  182. package/dist/types/migration/Asset.cjs +12 -15
  183. package/dist/types/migration/Asset.cjs.map +1 -1
  184. package/dist/types/migration/Asset.d.ts +7 -7
  185. package/dist/types/migration/Asset.js +12 -15
  186. package/dist/types/migration/Asset.js.map +1 -1
  187. package/dist/types/migration/ContentRelationship.d.ts +3 -3
  188. package/dist/types/migration/Document.cjs +24 -27
  189. package/dist/types/migration/Document.cjs.map +1 -1
  190. package/dist/types/migration/Document.d.ts +9 -9
  191. package/dist/types/migration/Document.js +24 -27
  192. package/dist/types/migration/Document.js.map +1 -1
  193. package/dist/types/migration/Link.d.ts +1 -1
  194. package/dist/types/model/boolean.d.ts +1 -1
  195. package/dist/types/model/color.d.ts +1 -1
  196. package/dist/types/model/contentRelationship.d.ts +3 -2
  197. package/dist/types/model/customType.d.ts +1 -1
  198. package/dist/types/model/date.d.ts +1 -1
  199. package/dist/types/model/embed.d.ts +1 -1
  200. package/dist/types/model/geoPoint.d.ts +1 -1
  201. package/dist/types/model/group.d.ts +1 -1
  202. package/dist/types/model/image.d.ts +1 -1
  203. package/dist/types/model/integration.d.ts +1 -1
  204. package/dist/types/model/keyText.d.ts +1 -1
  205. package/dist/types/model/link.d.ts +1 -1
  206. package/dist/types/model/linkToMedia.d.ts +2 -2
  207. package/dist/types/model/number.d.ts +1 -1
  208. package/dist/types/model/range.d.ts +1 -1
  209. package/dist/types/model/richText.d.ts +1 -1
  210. package/dist/types/model/select.d.ts +1 -1
  211. package/dist/types/model/separator.d.ts +1 -1
  212. package/dist/types/model/sharedSlice.d.ts +2 -2
  213. package/dist/types/model/sharedSliceVariation.d.ts +1 -1
  214. package/dist/types/model/slice.d.ts +3 -3
  215. package/dist/types/model/sliceZone.d.ts +2 -2
  216. package/dist/types/model/table.d.ts +1 -1
  217. package/dist/types/model/timestamp.d.ts +1 -1
  218. package/dist/types/model/title.d.ts +1 -1
  219. package/dist/types/model/types.d.ts +22 -22
  220. package/dist/types/model/uid.d.ts +1 -1
  221. package/dist/types/value/color.d.ts +1 -1
  222. package/dist/types/value/contentRelationship.d.ts +3 -3
  223. package/dist/types/value/date.d.ts +1 -1
  224. package/dist/types/value/document.d.ts +4 -4
  225. package/dist/types/value/embed.d.ts +1 -1
  226. package/dist/types/value/geoPoint.d.ts +1 -1
  227. package/dist/types/value/group.d.ts +1 -1
  228. package/dist/types/value/image.d.ts +1 -1
  229. package/dist/types/value/integration.d.ts +1 -1
  230. package/dist/types/value/keyText.d.ts +1 -1
  231. package/dist/types/value/link.d.ts +5 -5
  232. package/dist/types/value/linkToMedia.d.ts +2 -2
  233. package/dist/types/value/number.d.ts +1 -1
  234. package/dist/types/value/richText.d.ts +3 -3
  235. package/dist/types/value/select.d.ts +1 -1
  236. package/dist/types/value/sharedSlice.d.ts +1 -1
  237. package/dist/types/value/sharedSliceVariation.d.ts +1 -1
  238. package/dist/types/value/slice.d.ts +1 -1
  239. package/dist/types/value/sliceZone.d.ts +3 -3
  240. package/dist/types/value/table.d.ts +2 -2
  241. package/dist/types/value/timestamp.d.ts +2 -2
  242. package/dist/types/value/title.d.ts +2 -2
  243. package/dist/types/value/types.d.ts +18 -18
  244. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  245. package/dist/types/webhook/testTrigger.d.ts +1 -1
  246. package/dist/types/webhook/types.d.ts +2 -2
  247. package/package.json +11 -11
  248. package/src/index.ts +1 -1
  249. package/src/types/migration/Asset.ts +10 -2
  250. package/src/types/model/contentRelationship.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"findMasterRef.cjs","sources":["../../../src/lib/findMasterRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the master ref from a list of given refs.\n *\n * @param refs - A list of refs to search.\n *\n * @returns The master ref from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findMasterRef = (refs: Ref[]): Ref => {\n\treturn findRef(refs, (ref) => ref.isMasterRef)\n}\n"],"names":["findRef"],"mappings":";;;AAaa,MAAA,gBAAgB,CAAC,SAAoB;AACjD,SAAOA,QAAQ,QAAA,MAAM,CAAC,QAAQ,IAAI,WAAW;AAC9C;;"}
1
+ {"version":3,"file":"findMasterRef.cjs","sources":["../../../src/lib/findMasterRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the master ref from a list of given refs.\n *\n * @param refs - A list of refs to search.\n *\n * @returns The master ref from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findMasterRef = (refs: Ref[]): Ref => {\n\treturn findRef(refs, (ref) => ref.isMasterRef)\n}\n"],"names":["findRef"],"mappings":";;;AAaO,MAAM,gBAAgB,CAAC,SAAoB;AACjD,SAAOA,QAAAA,QAAQ,MAAM,CAAC,QAAQ,IAAI,WAAW;AAC9C;;"}
@@ -1,4 +1,4 @@
1
- import type { Ref } from "../types/api/ref";
1
+ import type { Ref } from "../types/api/ref.js";
2
2
  /**
3
3
  * Returns the master ref from a list of given refs.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"findMasterRef.js","sources":["../../../src/lib/findMasterRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the master ref from a list of given refs.\n *\n * @param refs - A list of refs to search.\n *\n * @returns The master ref from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findMasterRef = (refs: Ref[]): Ref => {\n\treturn findRef(refs, (ref) => ref.isMasterRef)\n}\n"],"names":[],"mappings":";AAaa,MAAA,gBAAgB,CAAC,SAAoB;AACjD,SAAO,QAAQ,MAAM,CAAC,QAAQ,IAAI,WAAW;AAC9C;"}
1
+ {"version":3,"file":"findMasterRef.js","sources":["../../../src/lib/findMasterRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the master ref from a list of given refs.\n *\n * @param refs - A list of refs to search.\n *\n * @returns The master ref from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findMasterRef = (refs: Ref[]): Ref => {\n\treturn findRef(refs, (ref) => ref.isMasterRef)\n}\n"],"names":[],"mappings":";AAaO,MAAM,gBAAgB,CAAC,SAAoB;AACjD,SAAO,QAAQ,MAAM,CAAC,QAAQ,IAAI,WAAW;AAC9C;"}
@@ -1 +1 @@
1
- {"version":3,"file":"findRef.cjs","sources":["../../../src/lib/findRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { PrismicError } from \"../errors/PrismicError\"\n\n/**\n * Returns the first ref from a list that passes a filter (a function that\n * returns true).\n *\n * @param refs - A list of refs to search.\n * @param filter - A function that determines if a ref from the list matches the\n * criteria.\n *\n * @returns The first matching ref.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRef = (refs: Ref[], filter: (ref: Ref) => boolean): Ref => {\n\tconst ref = refs.find((ref) => filter(ref))\n\n\tif (!ref) {\n\t\tthrow new PrismicError(\"Ref could not be found.\", undefined, undefined)\n\t}\n\n\treturn ref\n}\n"],"names":["ref","PrismicError"],"mappings":";;;AAgBa,MAAA,UAAU,CAAC,MAAa,WAAsC;AAC1E,QAAM,MAAM,KAAK,KAAK,CAACA,SAAQ,OAAOA,IAAG,CAAC;AAE1C,MAAI,CAAC,KAAK;AACT,UAAM,IAAIC,aAAA,aAAa,2BAA2B,QAAW,MAAS;AAAA,EAAA;AAGhE,SAAA;AACR;;"}
1
+ {"version":3,"file":"findRef.cjs","sources":["../../../src/lib/findRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { PrismicError } from \"../errors/PrismicError\"\n\n/**\n * Returns the first ref from a list that passes a filter (a function that\n * returns true).\n *\n * @param refs - A list of refs to search.\n * @param filter - A function that determines if a ref from the list matches the\n * criteria.\n *\n * @returns The first matching ref.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRef = (refs: Ref[], filter: (ref: Ref) => boolean): Ref => {\n\tconst ref = refs.find((ref) => filter(ref))\n\n\tif (!ref) {\n\t\tthrow new PrismicError(\"Ref could not be found.\", undefined, undefined)\n\t}\n\n\treturn ref\n}\n"],"names":["ref","PrismicError"],"mappings":";;;AAgBO,MAAM,UAAU,CAAC,MAAa,WAAsC;AAC1E,QAAM,MAAM,KAAK,KAAK,CAACA,SAAQ,OAAOA,IAAG,CAAC;AAE1C,MAAI,CAAC,KAAK;AACT,UAAM,IAAIC,aAAAA,aAAa,2BAA2B,QAAW,MAAS;AAAA,EACvE;AAEA,SAAO;AACR;;"}
@@ -1,4 +1,4 @@
1
- import type { Ref } from "../types/api/ref";
1
+ import type { Ref } from "../types/api/ref.js";
2
2
  /**
3
3
  * Returns the first ref from a list that passes a filter (a function that
4
4
  * returns true).
@@ -1 +1 @@
1
- {"version":3,"file":"findRef.js","sources":["../../../src/lib/findRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { PrismicError } from \"../errors/PrismicError\"\n\n/**\n * Returns the first ref from a list that passes a filter (a function that\n * returns true).\n *\n * @param refs - A list of refs to search.\n * @param filter - A function that determines if a ref from the list matches the\n * criteria.\n *\n * @returns The first matching ref.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRef = (refs: Ref[], filter: (ref: Ref) => boolean): Ref => {\n\tconst ref = refs.find((ref) => filter(ref))\n\n\tif (!ref) {\n\t\tthrow new PrismicError(\"Ref could not be found.\", undefined, undefined)\n\t}\n\n\treturn ref\n}\n"],"names":["ref"],"mappings":";AAgBa,MAAA,UAAU,CAAC,MAAa,WAAsC;AAC1E,QAAM,MAAM,KAAK,KAAK,CAACA,SAAQ,OAAOA,IAAG,CAAC;AAE1C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI,aAAa,2BAA2B,QAAW,MAAS;AAAA,EAAA;AAGhE,SAAA;AACR;"}
1
+ {"version":3,"file":"findRef.js","sources":["../../../src/lib/findRef.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { PrismicError } from \"../errors/PrismicError\"\n\n/**\n * Returns the first ref from a list that passes a filter (a function that\n * returns true).\n *\n * @param refs - A list of refs to search.\n * @param filter - A function that determines if a ref from the list matches the\n * criteria.\n *\n * @returns The first matching ref.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRef = (refs: Ref[], filter: (ref: Ref) => boolean): Ref => {\n\tconst ref = refs.find((ref) => filter(ref))\n\n\tif (!ref) {\n\t\tthrow new PrismicError(\"Ref could not be found.\", undefined, undefined)\n\t}\n\n\treturn ref\n}\n"],"names":["ref"],"mappings":";AAgBO,MAAM,UAAU,CAAC,MAAa,WAAsC;AAC1E,QAAM,MAAM,KAAK,KAAK,CAACA,SAAQ,OAAOA,IAAG,CAAC;AAE1C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI,aAAa,2BAA2B,QAAW,MAAS;AAAA,EACvE;AAEA,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"findRefByID.cjs","sources":["../../../src/lib/findRefByID.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching ID.\n *\n * @param refs - A list of refs to search.\n * @param id - The ID of the ref to find.\n *\n * @returns The ref with a matching ID from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByID = (refs: Ref[], id: string): Ref => {\n\treturn findRef(refs, (ref) => ref.id === id)\n}\n"],"names":["findRef"],"mappings":";;;AAca,MAAA,cAAc,CAAC,MAAa,OAAmB;AAC3D,SAAOA,QAAAA,QAAQ,MAAM,CAAC,QAAQ,IAAI,OAAO,EAAE;AAC5C;;"}
1
+ {"version":3,"file":"findRefByID.cjs","sources":["../../../src/lib/findRefByID.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching ID.\n *\n * @param refs - A list of refs to search.\n * @param id - The ID of the ref to find.\n *\n * @returns The ref with a matching ID from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByID = (refs: Ref[], id: string): Ref => {\n\treturn findRef(refs, (ref) => ref.id === id)\n}\n"],"names":["findRef"],"mappings":";;;AAcO,MAAM,cAAc,CAAC,MAAa,OAAmB;AAC3D,SAAOA,QAAAA,QAAQ,MAAM,CAAC,QAAQ,IAAI,OAAO,EAAE;AAC5C;;"}
@@ -1,4 +1,4 @@
1
- import type { Ref } from "../types/api/ref";
1
+ import type { Ref } from "../types/api/ref.js";
2
2
  /**
3
3
  * Returns the ref from a list of given refs with a matching ID.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"findRefByID.js","sources":["../../../src/lib/findRefByID.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching ID.\n *\n * @param refs - A list of refs to search.\n * @param id - The ID of the ref to find.\n *\n * @returns The ref with a matching ID from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByID = (refs: Ref[], id: string): Ref => {\n\treturn findRef(refs, (ref) => ref.id === id)\n}\n"],"names":[],"mappings":";AAca,MAAA,cAAc,CAAC,MAAa,OAAmB;AAC3D,SAAO,QAAQ,MAAM,CAAC,QAAQ,IAAI,OAAO,EAAE;AAC5C;"}
1
+ {"version":3,"file":"findRefByID.js","sources":["../../../src/lib/findRefByID.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching ID.\n *\n * @param refs - A list of refs to search.\n * @param id - The ID of the ref to find.\n *\n * @returns The ref with a matching ID from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByID = (refs: Ref[], id: string): Ref => {\n\treturn findRef(refs, (ref) => ref.id === id)\n}\n"],"names":[],"mappings":";AAcO,MAAM,cAAc,CAAC,MAAa,OAAmB;AAC3D,SAAO,QAAQ,MAAM,CAAC,QAAQ,IAAI,OAAO,EAAE;AAC5C;"}
@@ -1 +1 @@
1
- {"version":3,"file":"findRefByLabel.cjs","sources":["../../../src/lib/findRefByLabel.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching label.\n *\n * @param refs - A list of refs to search.\n * @param id - The label of the ref to find.\n *\n * @returns The ref with a matching label from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByLabel = (refs: Ref[], label: string): Ref => {\n\treturn findRef(refs, (ref) => ref.label === label)\n}\n"],"names":["findRef"],"mappings":";;;AAca,MAAA,iBAAiB,CAAC,MAAa,UAAsB;AACjE,SAAOA,QAAAA,QAAQ,MAAM,CAAC,QAAQ,IAAI,UAAU,KAAK;AAClD;;"}
1
+ {"version":3,"file":"findRefByLabel.cjs","sources":["../../../src/lib/findRefByLabel.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching label.\n *\n * @param refs - A list of refs to search.\n * @param id - The label of the ref to find.\n *\n * @returns The ref with a matching label from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByLabel = (refs: Ref[], label: string): Ref => {\n\treturn findRef(refs, (ref) => ref.label === label)\n}\n"],"names":["findRef"],"mappings":";;;AAcO,MAAM,iBAAiB,CAAC,MAAa,UAAsB;AACjE,SAAOA,QAAAA,QAAQ,MAAM,CAAC,QAAQ,IAAI,UAAU,KAAK;AAClD;;"}
@@ -1,4 +1,4 @@
1
- import type { Ref } from "../types/api/ref";
1
+ import type { Ref } from "../types/api/ref.js";
2
2
  /**
3
3
  * Returns the ref from a list of given refs with a matching label.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"findRefByLabel.js","sources":["../../../src/lib/findRefByLabel.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching label.\n *\n * @param refs - A list of refs to search.\n * @param id - The label of the ref to find.\n *\n * @returns The ref with a matching label from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByLabel = (refs: Ref[], label: string): Ref => {\n\treturn findRef(refs, (ref) => ref.label === label)\n}\n"],"names":[],"mappings":";AAca,MAAA,iBAAiB,CAAC,MAAa,UAAsB;AACjE,SAAO,QAAQ,MAAM,CAAC,QAAQ,IAAI,UAAU,KAAK;AAClD;"}
1
+ {"version":3,"file":"findRefByLabel.js","sources":["../../../src/lib/findRefByLabel.ts"],"sourcesContent":["import type { Ref } from \"../types/api/ref\"\n\nimport { findRef } from \"./findRef\"\n\n/**\n * Returns the ref from a list of given refs with a matching label.\n *\n * @param refs - A list of refs to search.\n * @param id - The label of the ref to find.\n *\n * @returns The ref with a matching label from the list.\n *\n * @throws If a matching ref cannot be found.\n */\nexport const findRefByLabel = (refs: Ref[], label: string): Ref => {\n\treturn findRef(refs, (ref) => ref.label === label)\n}\n"],"names":[],"mappings":";AAcO,MAAM,iBAAiB,CAAC,MAAa,UAAsB;AACjE,SAAO,QAAQ,MAAM,CAAC,QAAQ,IAAI,UAAU,KAAK;AAClD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getOptionalLinkProperties.cjs","sources":["../../../src/lib/getOptionalLinkProperties.ts"],"sourcesContent":["import type { OptionalLinkProperties } from \"../types/value/link\"\n\n/**\n * Returns optional properties only available to link fields. Link fields can\n * have the same shape as content relationship and link to media fields,\n * requiring special treatment to extract link-specific properties.\n *\n * @param input - The content relationship or link to media field from which the\n * link properties will be extracted.\n *\n * @returns Optional link properties that `input` might have.\n */\nexport const getOptionalLinkProperties = (\n\tinput: OptionalLinkProperties,\n): OptionalLinkProperties => {\n\tconst res: OptionalLinkProperties = {}\n\n\tif (\"text\" in input) {\n\t\tres.text = input.text\n\t}\n\n\tif (\"variant\" in input) {\n\t\tres.variant = input.variant\n\t}\n\n\treturn res\n}\n"],"names":[],"mappings":";;AAYa,MAAA,4BAA4B,CACxC,UAC2B;AAC3B,QAAM,MAA8B,CAAA;AAEpC,MAAI,UAAU,OAAO;AACpB,QAAI,OAAO,MAAM;AAAA,EAAA;AAGlB,MAAI,aAAa,OAAO;AACvB,QAAI,UAAU,MAAM;AAAA,EAAA;AAGd,SAAA;AACR;;"}
1
+ {"version":3,"file":"getOptionalLinkProperties.cjs","sources":["../../../src/lib/getOptionalLinkProperties.ts"],"sourcesContent":["import type { OptionalLinkProperties } from \"../types/value/link\"\n\n/**\n * Returns optional properties only available to link fields. Link fields can\n * have the same shape as content relationship and link to media fields,\n * requiring special treatment to extract link-specific properties.\n *\n * @param input - The content relationship or link to media field from which the\n * link properties will be extracted.\n *\n * @returns Optional link properties that `input` might have.\n */\nexport const getOptionalLinkProperties = (\n\tinput: OptionalLinkProperties,\n): OptionalLinkProperties => {\n\tconst res: OptionalLinkProperties = {}\n\n\tif (\"text\" in input) {\n\t\tres.text = input.text\n\t}\n\n\tif (\"variant\" in input) {\n\t\tres.variant = input.variant\n\t}\n\n\treturn res\n}\n"],"names":[],"mappings":";;AAYO,MAAM,4BAA4B,CACxC,UAC2B;AAC3B,QAAM,MAA8B,CAAA;AAEpC,MAAI,UAAU,OAAO;AACpB,QAAI,OAAO,MAAM;AAAA,EAClB;AAEA,MAAI,aAAa,OAAO;AACvB,QAAI,UAAU,MAAM;AAAA,EACrB;AAEA,SAAO;AACR;;"}
@@ -1,4 +1,4 @@
1
- import type { OptionalLinkProperties } from "../types/value/link";
1
+ import type { OptionalLinkProperties } from "../types/value/link.js";
2
2
  /**
3
3
  * Returns optional properties only available to link fields. Link fields can
4
4
  * have the same shape as content relationship and link to media fields,
@@ -1 +1 @@
1
- {"version":3,"file":"getOptionalLinkProperties.js","sources":["../../../src/lib/getOptionalLinkProperties.ts"],"sourcesContent":["import type { OptionalLinkProperties } from \"../types/value/link\"\n\n/**\n * Returns optional properties only available to link fields. Link fields can\n * have the same shape as content relationship and link to media fields,\n * requiring special treatment to extract link-specific properties.\n *\n * @param input - The content relationship or link to media field from which the\n * link properties will be extracted.\n *\n * @returns Optional link properties that `input` might have.\n */\nexport const getOptionalLinkProperties = (\n\tinput: OptionalLinkProperties,\n): OptionalLinkProperties => {\n\tconst res: OptionalLinkProperties = {}\n\n\tif (\"text\" in input) {\n\t\tres.text = input.text\n\t}\n\n\tif (\"variant\" in input) {\n\t\tres.variant = input.variant\n\t}\n\n\treturn res\n}\n"],"names":[],"mappings":"AAYa,MAAA,4BAA4B,CACxC,UAC2B;AAC3B,QAAM,MAA8B,CAAA;AAEpC,MAAI,UAAU,OAAO;AACpB,QAAI,OAAO,MAAM;AAAA,EAAA;AAGlB,MAAI,aAAa,OAAO;AACvB,QAAI,UAAU,MAAM;AAAA,EAAA;AAGd,SAAA;AACR;"}
1
+ {"version":3,"file":"getOptionalLinkProperties.js","sources":["../../../src/lib/getOptionalLinkProperties.ts"],"sourcesContent":["import type { OptionalLinkProperties } from \"../types/value/link\"\n\n/**\n * Returns optional properties only available to link fields. Link fields can\n * have the same shape as content relationship and link to media fields,\n * requiring special treatment to extract link-specific properties.\n *\n * @param input - The content relationship or link to media field from which the\n * link properties will be extracted.\n *\n * @returns Optional link properties that `input` might have.\n */\nexport const getOptionalLinkProperties = (\n\tinput: OptionalLinkProperties,\n): OptionalLinkProperties => {\n\tconst res: OptionalLinkProperties = {}\n\n\tif (\"text\" in input) {\n\t\tres.text = input.text\n\t}\n\n\tif (\"variant\" in input) {\n\t\tres.variant = input.variant\n\t}\n\n\treturn res\n}\n"],"names":[],"mappings":"AAYO,MAAM,4BAA4B,CACxC,UAC2B;AAC3B,QAAM,MAA8B,CAAA;AAEpC,MAAI,UAAU,OAAO;AACpB,QAAI,OAAO,MAAM;AAAA,EAClB;AAEA,MAAI,aAAa,OAAO;AACvB,QAAI,UAAU,MAAM;AAAA,EACrB;AAEA,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPreviewCookie.cjs","sources":["../../../src/lib/getPreviewCookie.ts"],"sourcesContent":["import { preview as previewCookieName } from \"../cookie\"\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\")\n}\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPreviewCookie = (cookieJar: string): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \")\n\n\tlet value: string | undefined\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\")\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\")\n\n\t\tif (name === previewCookieName) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"))\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn value\n}\n"],"names":["cookie","previewCookieName"],"mappings":";;;AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,mBAAmB,CAAC,cAAyC;AACnE,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAWA,YAAU,SAAS;AACvB,UAAA,QAAQA,SAAO,MAAM,GAAG;AACxB,UAAA,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEpD,QAAI,SAASC,OAAAA,SAAmB;AAC/B,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IAAA;AAAA,EACD;AAGM,SAAA;AACR;;"}
1
+ {"version":3,"file":"getPreviewCookie.cjs","sources":["../../../src/lib/getPreviewCookie.ts"],"sourcesContent":["import { preview as previewCookieName } from \"../cookie\"\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\")\n}\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPreviewCookie = (cookieJar: string): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \")\n\n\tlet value: string | undefined\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\")\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\")\n\n\t\tif (name === previewCookieName) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"))\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn value\n}\n"],"names":["cookie","previewCookieName"],"mappings":";;;AAEA,MAAM,YAAY,CAAC,UAAyB;AAC3C,SAAO,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUO,MAAM,mBAAmB,CAAC,cAAyC;AACzE,QAAM,UAAU,UAAU,MAAM,IAAI;AAEpC,MAAI;AAEJ,aAAWA,YAAU,SAAS;AAC7B,UAAM,QAAQA,SAAO,MAAM,GAAG;AAC9B,UAAM,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEpD,QAAI,SAASC,OAAAA,SAAmB;AAC/B,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPreviewCookie.js","sources":["../../../src/lib/getPreviewCookie.ts"],"sourcesContent":["import { preview as previewCookieName } from \"../cookie\"\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\")\n}\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPreviewCookie = (cookieJar: string): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \")\n\n\tlet value: string | undefined\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\")\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\")\n\n\t\tif (name === previewCookieName) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"))\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn value\n}\n"],"names":["previewCookieName"],"mappings":";AAEA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUa,MAAA,mBAAmB,CAAC,cAAyC;AACnE,QAAA,UAAU,UAAU,MAAM,IAAI;AAEhC,MAAA;AAEJ,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AACxB,UAAA,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEpD,QAAI,SAASA,SAAmB;AAC/B,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IAAA;AAAA,EACD;AAGM,SAAA;AACR;"}
1
+ {"version":3,"file":"getPreviewCookie.js","sources":["../../../src/lib/getPreviewCookie.ts"],"sourcesContent":["import { preview as previewCookieName } from \"../cookie\"\n\nconst readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\")\n}\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the\n * cookie.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPreviewCookie = (cookieJar: string): string | undefined => {\n\tconst cookies = cookieJar.split(\"; \")\n\n\tlet value: string | undefined\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\")\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\")\n\n\t\tif (name === previewCookieName) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"))\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn value\n}\n"],"names":["previewCookieName"],"mappings":";AAEA,MAAM,YAAY,CAAC,UAAyB;AAC3C,SAAO,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAUO,MAAM,mBAAmB,CAAC,cAAyC;AACzE,QAAM,UAAU,UAAU,MAAM,IAAI;AAEpC,MAAI;AAEJ,aAAW,UAAU,SAAS;AAC7B,UAAM,QAAQ,OAAO,MAAM,GAAG;AAC9B,UAAM,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAEpD,QAAI,SAASA,SAAmB;AAC/B,cAAQ,UAAU,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;AAC1C;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isInternalURL.cjs","sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport const isInternalURL = (url: string): boolean => {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url)\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"names":[],"mappings":";;AAQa,MAAA,gBAAgB,CAAC,QAAwB;AAC/C,QAAA,aAAa,gBAAgB,KAAK,GAAG;AAC3C,QAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,GAAG;AAE7D,SAAO,cAAc,CAAC;AACvB;;"}
1
+ {"version":3,"file":"isInternalURL.cjs","sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport const isInternalURL = (url: string): boolean => {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url)\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"names":[],"mappings":";;AAQO,MAAM,gBAAgB,CAAC,QAAwB;AACrD,QAAM,aAAa,gBAAgB,KAAK,GAAG;AAC3C,QAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,GAAG;AAE7D,SAAO,cAAc,CAAC;AACvB;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isInternalURL.js","sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport const isInternalURL = (url: string): boolean => {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url)\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"names":[],"mappings":"AAQa,MAAA,gBAAgB,CAAC,QAAwB;AAC/C,QAAA,aAAa,gBAAgB,KAAK,GAAG;AAC3C,QAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,GAAG;AAE7D,SAAO,cAAc,CAAC;AACvB;"}
1
+ {"version":3,"file":"isInternalURL.js","sources":["../../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport const isInternalURL = (url: string): boolean => {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url)\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"names":[],"mappings":"AAQO,MAAM,gBAAgB,CAAC,QAAwB;AACrD,QAAM,aAAa,gBAAgB,KAAK,GAAG;AAC3C,QAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,GAAG;AAE7D,SAAO,cAAc,CAAC;AACvB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isMigrationValue.cjs","sources":["../../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration link to media field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"names":["PrismicMigrationDocument","is.prismicDocument","LinkType","PrismicMigrationAsset","RichTextNodeType"],"mappings":";;;;;;;AA+Ca,MAAA,sBAAsB,CAClC,UACmE;AAElE,SAAA,iBAAiBA,SAAAA,4BACjBC,QAAmB,gBAAA,KAAK,KACvB,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAcC,cAAS,YAC7B,QAAQ,UACP,oBAAoB,MAAM,EAAE,KAAK,OAAO,MAAM,OAAO;AAEzD;AAYa,MAAA,QAAQ,CAAC,UAAgD;AACrE,SACC,iBAAiBC,MAAAA,yBAChB,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAO,OAAO,KAAK,EAAE,MACpB,CAAC,mBAAmB,0BAA0BA,2BAAqB;AAGvE;AAiBa,MAAA,cAAc,CAC1B,UAC2D;AAC3D,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcA,MAAAA,yBACpB,eAAe,SACf,MAAM,cAAcD,KAAAA,SAAS;AAE/B;AAaa,MAAA,cAAc,CAC1B,UACkC;AAClC,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcC,MAAAA,yBACpB,UAAU,SACV,MAAM,SAASC,SAAAA,iBAAiB;AAElC;;;;;"}
1
+ {"version":3,"file":"isMigrationValue.cjs","sources":["../../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration link to media field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"names":["PrismicMigrationDocument","is.prismicDocument","LinkType","PrismicMigrationAsset","RichTextNodeType"],"mappings":";;;;;;;AA+CO,MAAM,sBAAsB,CAClC,UACmE;AACnE,SACC,iBAAiBA,SAAAA,4BACjBC,QAAAA,gBAAmB,KAAK,KACvB,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAcC,cAAS,YAC7B,QAAQ,UACP,oBAAoB,MAAM,EAAE,KAAK,OAAO,MAAM,OAAO;AAEzD;AAYO,MAAM,QAAQ,CAAC,UAAgD;AACrE,SACC,iBAAiBC,MAAAA,yBAChB,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAO,OAAO,KAAK,EAAE,MACpB,CAAC,mBAAmB,0BAA0BA,2BAAqB;AAGvE;AAiBO,MAAM,cAAc,CAC1B,UAC2D;AAC3D,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcA,MAAAA,yBACpB,eAAe,SACf,MAAM,cAAcD,KAAAA,SAAS;AAE/B;AAaO,MAAM,cAAc,CAC1B,UACkC;AAClC,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcC,MAAAA,yBACpB,UAAU,SACV,MAAM,SAASC,SAAAA,iBAAiB;AAElC;;;;;"}
@@ -1,11 +1,11 @@
1
- import type { MigrationImage, MigrationLinkToMedia, MigrationRTImageNode } from "../types/migration/Asset";
2
- import type { MigrationContentRelationship } from "../types/migration/ContentRelationship";
3
- import { type InjectMigrationSpecificTypes } from "../types/migration/Document";
4
- import type { PrismicDocument } from "../types/value/document";
5
- import type { GroupField } from "../types/value/group";
6
- import type { OptionalLinkProperties } from "../types/value/link";
7
- import type { SliceZone } from "../types/value/sliceZone";
8
- import type { AnyRegularField } from "../types/value/types";
1
+ import type { MigrationImage, MigrationLinkToMedia, MigrationRTImageNode } from "../types/migration/Asset.js";
2
+ import type { MigrationContentRelationship } from "../types/migration/ContentRelationship.js";
3
+ import { type InjectMigrationSpecificTypes } from "../types/migration/Document.js";
4
+ import type { PrismicDocument } from "../types/value/document.js";
5
+ import type { GroupField } from "../types/value/group.js";
6
+ import type { OptionalLinkProperties } from "../types/value/link.js";
7
+ import type { SliceZone } from "../types/value/sliceZone.js";
8
+ import type { AnyRegularField } from "../types/value/types.js";
9
9
  /**
10
10
  * Unknown value to check if it's a specific field type.
11
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"isMigrationValue.js","sources":["../../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration link to media field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"names":["is.prismicDocument"],"mappings":";;;;;AA+Ca,MAAA,sBAAsB,CAClC,UACmE;AAElE,SAAA,iBAAiB,4BACjBA,gBAAmB,KAAK,KACvB,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAc,SAAS,YAC7B,QAAQ,UACP,oBAAoB,MAAM,EAAE,KAAK,OAAO,MAAM,OAAO;AAEzD;AAYa,MAAA,QAAQ,CAAC,UAAgD;AACrE,SACC,iBAAiB,yBAChB,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAO,OAAO,KAAK,EAAE,MACpB,CAAC,mBAAmB,0BAA0B,qBAAqB;AAGvE;AAiBa,MAAA,cAAc,CAC1B,UAC2D;AAC3D,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAc,yBACpB,eAAe,SACf,MAAM,cAAc,SAAS;AAE/B;AAaa,MAAA,cAAc,CAC1B,UACkC;AAClC,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAc,yBACpB,UAAU,SACV,MAAM,SAAS,iBAAiB;AAElC;"}
1
+ {"version":3,"file":"isMigrationValue.js","sources":["../../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration link to media field, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"names":["is.prismicDocument"],"mappings":";;;;;AA+CO,MAAM,sBAAsB,CAClC,UACmE;AACnE,SACC,iBAAiB,4BACjBA,gBAAmB,KAAK,KACvB,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAc,SAAS,YAC7B,QAAQ,UACP,oBAAoB,MAAM,EAAE,KAAK,OAAO,MAAM,OAAO;AAEzD;AAYO,MAAM,QAAQ,CAAC,UAAgD;AACrE,SACC,iBAAiB,yBAChB,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAO,OAAO,KAAK,EAAE,MACpB,CAAC,mBAAmB,0BAA0B,qBAAqB;AAGvE;AAiBO,MAAM,cAAc,CAC1B,UAC2D;AAC3D,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAc,yBACpB,eAAe,SACf,MAAM,cAAc,SAAS;AAE/B;AAaO,MAAM,cAAc,CAC1B,UACkC;AAClC,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAc,yBACpB,UAAU,SACV,MAAM,SAAS,iBAAiB;AAElC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isValue.cjs","sources":["../../../src/lib/isValue.ts"],"sourcesContent":["import type { InjectMigrationSpecificTypes } from \"../types/migration/Document\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport type { ImageField } from \"../types/value/image\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { type RTImageNode, RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a link to media field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a link to media field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledLinkToMedia = (\n\tvalue: UnknownValue,\n): value is FilledLinkToMediaField => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Media &&\n\t\t\t\"id\" in value &&\n\t\t\t\"name\" in value &&\n\t\t\t\"kind\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\t\"size\" in value\n\t\t) {\n\t\t\tvalue\n\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is like an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is like an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nconst imageLike = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> | RTImageNode => {\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t(!(\"version\" in value) || typeof value.version === \"object\")\n\t) {\n\t\tif (\n\t\t\t\"id\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\ttypeof value.url === \"string\" &&\n\t\t\t\"dimensions\" in value &&\n\t\t\t\"edit\" in value &&\n\t\t\t\"alt\" in value &&\n\t\t\t\"copyright\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledImage = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> => {\n\tif (\n\t\timageLike(value) &&\n\t\t(!(\"type\" in value) || value.type !== RichTextNodeType.image)\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a rich text image node, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (value: UnknownValue): value is RTImageNode => {\n\tif (\n\t\timageLike(value) &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a content relationship field.\n *\n * @remarks\n * The return value includes `OptionalLinkProperties` because\n * `FilledContentRelationshipField` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a content relationship, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledContentRelationship = (\n\tvalue: UnknownValue,\n): value is FilledContentRelationshipField & OptionalLinkProperties => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t\"type\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\t\"lang\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a Prismic document.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a Prismic document, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const prismicDocument = (\n\tvalue: UnknownValue,\n): value is PrismicDocument => {\n\ttry {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\t\"href\" in value &&\n\t\t\ttypeof value.href === \"string\" &&\n\t\t\tnew URL(value.href) &&\n\t\t\t\"type\" in value &&\n\t\t\t\"lang\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\tArray.isArray(value.tags)\n\t\t)\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":["LinkType","RichTextNodeType"],"mappings":";;;;AAiCa,MAAA,oBAAoB,CAChC,UACoC;AACpC,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAcA,cAAS,SAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,SAAS,SACT,UAAU,OACT;AAGM,aAAA;AAAA,IAAA;AAAA,EACR;AAGM,SAAA;AACR;AAYA,MAAM,YAAY,CACjB,UACwD;AAEvD,MAAA,SACA,OAAO,UAAU,aAChB,EAAE,aAAa,UAAU,OAAO,MAAM,YAAY,WAClD;AACD,QACC,QAAQ,SACR,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,gBAAgB,SAChB,UAAU,SACV,SAAS,SACT,eAAe,OACd;AACM,aAAA;AAAA,IAAA;AAAA,EACR;AAGM,SAAA;AACR;AAYa,MAAA,cAAc,CAC1B,UAC0C;AAEzC,MAAA,UAAU,KAAK,MACd,EAAE,UAAU,UAAU,MAAM,SAASC,0BAAiB,QACtD;AAGM,WAAA;AAAA,EAAA;AAGD,SAAA;AACR;AAYa,MAAA,cAAc,CAAC,UAA6C;AAEvE,MAAA,UAAU,KAAK,KACf,UAAU,SACV,MAAM,SAASA,0BAAiB,OAC/B;AAGM,WAAA;AAAA,EAAA;AAGD,SAAA;AACR;AAiBa,MAAA,4BAA4B,CACxC,UACqE;AACrE,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAcD,KAAAA,SAAS,YAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,UAAU,OACT;AACM,aAAA;AAAA,IAAA;AAAA,EACR;AAGM,SAAA;AACR;AAYa,MAAA,kBAAkB,CAC9B,UAC6B;AACzB,MAAA;AAEF,WAAA,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,IAAI,IAAI,MAAM,IAAI,KAClB,UAAU,SACV,UAAU,SACV,UAAU,SACV,MAAM,QAAQ,MAAM,IAAI;AAAA,EAAA,QAElB;AACA,WAAA;AAAA,EAAA;AAET;;;;;;"}
1
+ {"version":3,"file":"isValue.cjs","sources":["../../../src/lib/isValue.ts"],"sourcesContent":["import type { InjectMigrationSpecificTypes } from \"../types/migration/Document\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport type { ImageField } from \"../types/value/image\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { type RTImageNode, RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a link to media field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a link to media field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledLinkToMedia = (\n\tvalue: UnknownValue,\n): value is FilledLinkToMediaField => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Media &&\n\t\t\t\"id\" in value &&\n\t\t\t\"name\" in value &&\n\t\t\t\"kind\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\t\"size\" in value\n\t\t) {\n\t\t\tvalue\n\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is like an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is like an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nconst imageLike = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> | RTImageNode => {\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t(!(\"version\" in value) || typeof value.version === \"object\")\n\t) {\n\t\tif (\n\t\t\t\"id\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\ttypeof value.url === \"string\" &&\n\t\t\t\"dimensions\" in value &&\n\t\t\t\"edit\" in value &&\n\t\t\t\"alt\" in value &&\n\t\t\t\"copyright\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledImage = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> => {\n\tif (\n\t\timageLike(value) &&\n\t\t(!(\"type\" in value) || value.type !== RichTextNodeType.image)\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a rich text image node, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (value: UnknownValue): value is RTImageNode => {\n\tif (\n\t\timageLike(value) &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a content relationship field.\n *\n * @remarks\n * The return value includes `OptionalLinkProperties` because\n * `FilledContentRelationshipField` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a content relationship, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledContentRelationship = (\n\tvalue: UnknownValue,\n): value is FilledContentRelationshipField & OptionalLinkProperties => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t\"type\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\t\"lang\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a Prismic document.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a Prismic document, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const prismicDocument = (\n\tvalue: UnknownValue,\n): value is PrismicDocument => {\n\ttry {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\t\"href\" in value &&\n\t\t\ttypeof value.href === \"string\" &&\n\t\t\tnew URL(value.href) &&\n\t\t\t\"type\" in value &&\n\t\t\t\"lang\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\tArray.isArray(value.tags)\n\t\t)\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":["LinkType","RichTextNodeType"],"mappings":";;;;AAiCO,MAAM,oBAAoB,CAChC,UACoC;AACpC,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAcA,KAAAA,SAAS,SAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,SAAS,SACT,UAAU,OACT;AAGD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYA,MAAM,YAAY,CACjB,UACwD;AACxD,MACC,SACA,OAAO,UAAU,aAChB,EAAE,aAAa,UAAU,OAAO,MAAM,YAAY,WAClD;AACD,QACC,QAAQ,SACR,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,gBAAgB,SAChB,UAAU,SACV,SAAS,SACT,eAAe,OACd;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYO,MAAM,cAAc,CAC1B,UAC0C;AAC1C,MACC,UAAU,KAAK,MACd,EAAE,UAAU,UAAU,MAAM,SAASC,0BAAiB,QACtD;AAGD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAYO,MAAM,cAAc,CAAC,UAA6C;AACxE,MACC,UAAU,KAAK,KACf,UAAU,SACV,MAAM,SAASA,SAAAA,iBAAiB,OAC/B;AAGD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAiBO,MAAM,4BAA4B,CACxC,UACqE;AACrE,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAcD,KAAAA,SAAS,YAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,UAAU,OACT;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYO,MAAM,kBAAkB,CAC9B,UAC6B;AAC7B,MAAI;AACH,WACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,IAAI,IAAI,MAAM,IAAI,KAClB,UAAU,SACV,UAAU,SACV,UAAU,SACV,MAAM,QAAQ,MAAM,IAAI;AAAA,EAE1B,QAAQ;AACP,WAAO;AAAA,EACR;AACD;;;;;;"}
@@ -1,13 +1,13 @@
1
- import type { InjectMigrationSpecificTypes } from "../types/migration/Document";
2
- import type { FilledContentRelationshipField } from "../types/value/contentRelationship";
3
- import type { PrismicDocument } from "../types/value/document";
4
- import type { GroupField } from "../types/value/group";
5
- import type { ImageField } from "../types/value/image";
6
- import type { OptionalLinkProperties } from "../types/value/link";
7
- import type { FilledLinkToMediaField } from "../types/value/linkToMedia";
8
- import { type RTImageNode } from "../types/value/richText";
9
- import type { SliceZone } from "../types/value/sliceZone";
10
- import type { AnyRegularField } from "../types/value/types";
1
+ import type { InjectMigrationSpecificTypes } from "../types/migration/Document.js";
2
+ import type { FilledContentRelationshipField } from "../types/value/contentRelationship.js";
3
+ import type { PrismicDocument } from "../types/value/document.js";
4
+ import type { GroupField } from "../types/value/group.js";
5
+ import type { ImageField } from "../types/value/image.js";
6
+ import type { OptionalLinkProperties } from "../types/value/link.js";
7
+ import type { FilledLinkToMediaField } from "../types/value/linkToMedia.js";
8
+ import { type RTImageNode } from "../types/value/richText.js";
9
+ import type { SliceZone } from "../types/value/sliceZone.js";
10
+ import type { AnyRegularField } from "../types/value/types.js";
11
11
  /**
12
12
  * Unknown value to check if it's a specific field type.
13
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"isValue.js","sources":["../../../src/lib/isValue.ts"],"sourcesContent":["import type { InjectMigrationSpecificTypes } from \"../types/migration/Document\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport type { ImageField } from \"../types/value/image\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { type RTImageNode, RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a link to media field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a link to media field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledLinkToMedia = (\n\tvalue: UnknownValue,\n): value is FilledLinkToMediaField => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Media &&\n\t\t\t\"id\" in value &&\n\t\t\t\"name\" in value &&\n\t\t\t\"kind\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\t\"size\" in value\n\t\t) {\n\t\t\tvalue\n\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is like an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is like an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nconst imageLike = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> | RTImageNode => {\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t(!(\"version\" in value) || typeof value.version === \"object\")\n\t) {\n\t\tif (\n\t\t\t\"id\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\ttypeof value.url === \"string\" &&\n\t\t\t\"dimensions\" in value &&\n\t\t\t\"edit\" in value &&\n\t\t\t\"alt\" in value &&\n\t\t\t\"copyright\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledImage = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> => {\n\tif (\n\t\timageLike(value) &&\n\t\t(!(\"type\" in value) || value.type !== RichTextNodeType.image)\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a rich text image node, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (value: UnknownValue): value is RTImageNode => {\n\tif (\n\t\timageLike(value) &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a content relationship field.\n *\n * @remarks\n * The return value includes `OptionalLinkProperties` because\n * `FilledContentRelationshipField` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a content relationship, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledContentRelationship = (\n\tvalue: UnknownValue,\n): value is FilledContentRelationshipField & OptionalLinkProperties => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t\"type\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\t\"lang\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a Prismic document.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a Prismic document, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const prismicDocument = (\n\tvalue: UnknownValue,\n): value is PrismicDocument => {\n\ttry {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\t\"href\" in value &&\n\t\t\ttypeof value.href === \"string\" &&\n\t\t\tnew URL(value.href) &&\n\t\t\t\"type\" in value &&\n\t\t\t\"lang\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\tArray.isArray(value.tags)\n\t\t)\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":";;AAiCa,MAAA,oBAAoB,CAChC,UACoC;AACpC,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAc,SAAS,SAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,SAAS,SACT,UAAU,OACT;AAGM,aAAA;AAAA,IAAA;AAAA,EACR;AAGM,SAAA;AACR;AAYA,MAAM,YAAY,CACjB,UACwD;AAEvD,MAAA,SACA,OAAO,UAAU,aAChB,EAAE,aAAa,UAAU,OAAO,MAAM,YAAY,WAClD;AACD,QACC,QAAQ,SACR,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,gBAAgB,SAChB,UAAU,SACV,SAAS,SACT,eAAe,OACd;AACM,aAAA;AAAA,IAAA;AAAA,EACR;AAGM,SAAA;AACR;AAYa,MAAA,cAAc,CAC1B,UAC0C;AAEzC,MAAA,UAAU,KAAK,MACd,EAAE,UAAU,UAAU,MAAM,SAAS,iBAAiB,QACtD;AAGM,WAAA;AAAA,EAAA;AAGD,SAAA;AACR;AAYa,MAAA,cAAc,CAAC,UAA6C;AAEvE,MAAA,UAAU,KAAK,KACf,UAAU,SACV,MAAM,SAAS,iBAAiB,OAC/B;AAGM,WAAA;AAAA,EAAA;AAGD,SAAA;AACR;AAiBa,MAAA,4BAA4B,CACxC,UACqE;AACrE,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAc,SAAS,YAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,UAAU,OACT;AACM,aAAA;AAAA,IAAA;AAAA,EACR;AAGM,SAAA;AACR;AAYa,MAAA,kBAAkB,CAC9B,UAC6B;AACzB,MAAA;AAEF,WAAA,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,IAAI,IAAI,MAAM,IAAI,KAClB,UAAU,SACV,UAAU,SACV,UAAU,SACV,MAAM,QAAQ,MAAM,IAAI;AAAA,EAAA,QAElB;AACA,WAAA;AAAA,EAAA;AAET;"}
1
+ {"version":3,"file":"isValue.js","sources":["../../../src/lib/isValue.ts"],"sourcesContent":["import type { InjectMigrationSpecificTypes } from \"../types/migration/Document\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport type { ImageField } from \"../types/value/image\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { type RTImageNode, RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a link to media field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a link to media field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledLinkToMedia = (\n\tvalue: UnknownValue,\n): value is FilledLinkToMediaField => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Media &&\n\t\t\t\"id\" in value &&\n\t\t\t\"name\" in value &&\n\t\t\t\"kind\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\t\"size\" in value\n\t\t) {\n\t\t\tvalue\n\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is like an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is like an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nconst imageLike = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> | RTImageNode => {\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t(!(\"version\" in value) || typeof value.version === \"object\")\n\t) {\n\t\tif (\n\t\t\t\"id\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\ttypeof value.url === \"string\" &&\n\t\t\t\"dimensions\" in value &&\n\t\t\t\"edit\" in value &&\n\t\t\t\"alt\" in value &&\n\t\t\t\"copyright\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledImage = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> => {\n\tif (\n\t\timageLike(value) &&\n\t\t(!(\"type\" in value) || value.type !== RichTextNodeType.image)\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a rich text image node, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (value: UnknownValue): value is RTImageNode => {\n\tif (\n\t\timageLike(value) &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a content relationship field.\n *\n * @remarks\n * The return value includes `OptionalLinkProperties` because\n * `FilledContentRelationshipField` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a content relationship, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledContentRelationship = (\n\tvalue: UnknownValue,\n): value is FilledContentRelationshipField & OptionalLinkProperties => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t\"type\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\t\"lang\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a Prismic document.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a Prismic document, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const prismicDocument = (\n\tvalue: UnknownValue,\n): value is PrismicDocument => {\n\ttry {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\t\"href\" in value &&\n\t\t\ttypeof value.href === \"string\" &&\n\t\t\tnew URL(value.href) &&\n\t\t\t\"type\" in value &&\n\t\t\t\"lang\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\tArray.isArray(value.tags)\n\t\t)\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":";;AAiCO,MAAM,oBAAoB,CAChC,UACoC;AACpC,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAc,SAAS,SAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,SAAS,SACT,UAAU,OACT;AAGD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYA,MAAM,YAAY,CACjB,UACwD;AACxD,MACC,SACA,OAAO,UAAU,aAChB,EAAE,aAAa,UAAU,OAAO,MAAM,YAAY,WAClD;AACD,QACC,QAAQ,SACR,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,gBAAgB,SAChB,UAAU,SACV,SAAS,SACT,eAAe,OACd;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYO,MAAM,cAAc,CAC1B,UAC0C;AAC1C,MACC,UAAU,KAAK,MACd,EAAE,UAAU,UAAU,MAAM,SAAS,iBAAiB,QACtD;AAGD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAYO,MAAM,cAAc,CAAC,UAA6C;AACxE,MACC,UAAU,KAAK,KACf,UAAU,SACV,MAAM,SAAS,iBAAiB,OAC/B;AAGD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAiBO,MAAM,4BAA4B,CACxC,UACqE;AACrE,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAc,SAAS,YAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,UAAU,OACT;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYO,MAAM,kBAAkB,CAC9B,UAC6B;AAC7B,MAAI;AACH,WACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,IAAI,IAAI,MAAM,IAAI,KAClB,UAAU,SACV,UAAU,SACV,UAAU,SACV,MAAM,QAAQ,MAAM,IAAI;AAAA,EAE1B,QAAQ;AACP,WAAO;AAAA,EACR;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"minifyGraphQLQuery.cjs","sources":["../../../src/lib/minifyGraphQLQuery.ts"],"sourcesContent":["/**\n * Minifies a GraphQL query by removing whitespace where possible.\n *\n * @param query - GraphQL query to minify.\n *\n * @returns A minified version of `query`.\n */\nexport const minifyGraphQLQuery = (query: string): string => {\n\treturn query.replace(\n\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t(_chars, _spaces, brackets) => brackets,\n\t)\n}\n"],"names":[],"mappings":";;AAOa,MAAA,qBAAqB,CAAC,UAAyB;AAC3D,SAAO,MAAM,QACZ,2BACA,CAAC,QAAQ,SAAS,aAAa,QAAQ;AAEzC;;"}
1
+ {"version":3,"file":"minifyGraphQLQuery.cjs","sources":["../../../src/lib/minifyGraphQLQuery.ts"],"sourcesContent":["/**\n * Minifies a GraphQL query by removing whitespace where possible.\n *\n * @param query - GraphQL query to minify.\n *\n * @returns A minified version of `query`.\n */\nexport const minifyGraphQLQuery = (query: string): string => {\n\treturn query.replace(\n\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t(_chars, _spaces, brackets) => brackets,\n\t)\n}\n"],"names":[],"mappings":";;AAOO,MAAM,qBAAqB,CAAC,UAAyB;AAC3D,SAAO,MAAM,QACZ,2BACA,CAAC,QAAQ,SAAS,aAAa,QAAQ;AAEzC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"minifyGraphQLQuery.js","sources":["../../../src/lib/minifyGraphQLQuery.ts"],"sourcesContent":["/**\n * Minifies a GraphQL query by removing whitespace where possible.\n *\n * @param query - GraphQL query to minify.\n *\n * @returns A minified version of `query`.\n */\nexport const minifyGraphQLQuery = (query: string): string => {\n\treturn query.replace(\n\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t(_chars, _spaces, brackets) => brackets,\n\t)\n}\n"],"names":[],"mappings":"AAOa,MAAA,qBAAqB,CAAC,UAAyB;AAC3D,SAAO,MAAM,QACZ,2BACA,CAAC,QAAQ,SAAS,aAAa,QAAQ;AAEzC;"}
1
+ {"version":3,"file":"minifyGraphQLQuery.js","sources":["../../../src/lib/minifyGraphQLQuery.ts"],"sourcesContent":["/**\n * Minifies a GraphQL query by removing whitespace where possible.\n *\n * @param query - GraphQL query to minify.\n *\n * @returns A minified version of `query`.\n */\nexport const minifyGraphQLQuery = (query: string): string => {\n\treturn query.replace(\n\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t(_chars, _spaces, brackets) => brackets,\n\t)\n}\n"],"names":[],"mappings":"AAOO,MAAM,qBAAqB,CAAC,UAAyB;AAC3D,SAAO,MAAM,QACZ,2BACA,CAAC,QAAQ,SAAS,aAAa,QAAQ;AAEzC;"}
@@ -6,9 +6,8 @@ const pLimit = ({ interval } = {}) => {
6
6
  let busy = false;
7
7
  let lastCompletion = 0;
8
8
  const resumeNext = () => {
9
- var _a;
10
9
  if (!busy && queue.length > 0) {
11
- (_a = queue.shift()) == null ? void 0 : _a();
10
+ queue.shift()?.();
12
11
  busy = true;
13
12
  }
14
13
  };
@@ -41,9 +40,9 @@ const pLimit = ({ interval } = {}) => {
41
40
  }
42
41
  })();
43
42
  };
44
- return (function_, ...arguments_) => new Promise((resolve) => {
43
+ return ((function_, ...arguments_) => new Promise((resolve) => {
45
44
  enqueue(function_, resolve, arguments_);
46
- });
45
+ }));
47
46
  };
48
47
  exports.pLimit = pLimit;
49
48
  //# sourceMappingURL=pLimit.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pLimit.cjs","sources":["../../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing\n * arguments on to the `fn` is provided in order to be able to avoid creating\n * unnecessary closures. You probably don't need this optimization unless\n * you're pushing a lot of functions.\n *\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (\n\t\t...arguments_: TArguments\n\t) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and\n * respect a given interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to\n * wait between each promise execution.\n *\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({\n\tinterval,\n}: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"names":[],"mappings":";;AAQA,MAAM,QAAQ,CAAC,OAAe,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AA2BvE,MAAM,SAAS,CAAC,EACtB,SAAQ,IACkB,OAAqB;AAC/C,QAAM,QAAuB,CAAA;AAC7B,MAAI,OAAO;AACX,MAAI,iBAAiB;AAErB,QAAM,aAAa,MAAK;;AACvB,QAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC9B,kBAAM,YAAN;AACO,aAAA;AAAA,IAAA;AAAA,EAET;AAEA,QAAM,OAAO,MAAK;AACV,WAAA;;EAGR;AAEA,QAAM,MAAM,OACX,WACA,SACA,eACG;AACG,UAAA,0BAA0B,KAAK,IAAA,IAAQ;AAEzC,QAAA,YAAY,0BAA0B,UAAU;AAC7C,YAAA,MAAM,WAAW,uBAAuB;AAAA,IAAA;AAE/C,UAAM,UAAU,YAAY,UAAU,GAAG,UAAU;AAEnD,YAAQ,MAAM;AAEV,QAAA;AACG,YAAA;AAAA,IAAA,QACC;AAAA,IAAA;AAER,qBAAiB,KAAK;;EAGvB;AAEA,QAAM,UAAU,CACf,WACA,SACA,eACG;AAGC,QAAA,QAAQ,CAAC,oBAAmB;AAC/B,YAAM,KAAK,eAAe;AAAA,IAAA,CAC1B,EAAE,KAAK,IAAI,KAAK,QAAW,WAAW,SAAS,UAAU,CAAC;AAC1D,KAAC,YAAW;AAKZ,YAAM,QAAQ,QAAO;AAErB,UAAI,CAAC,MAAM;;;IAEX;EAEF;AAEA,SAAQ,CAAC,cAA2B,eACnC,IAAI,QAAiB,CAAC,YAAW;AACxB,YAAA,WAAW,SAAS,UAAU;AAAA,EAAA,CACtC;AACH;;"}
1
+ {"version":3,"file":"pLimit.cjs","sources":["../../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing\n * arguments on to the `fn` is provided in order to be able to avoid creating\n * unnecessary closures. You probably don't need this optimization unless\n * you're pushing a lot of functions.\n *\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (\n\t\t...arguments_: TArguments\n\t) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and\n * respect a given interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to\n * wait between each promise execution.\n *\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({\n\tinterval,\n}: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"names":[],"mappings":";;AAQA,MAAM,QAAQ,CAAC,OAAe,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AA2BvE,MAAM,SAAS,CAAC,EACtB,SAAA,IAC0B,OAAqB;AAC/C,QAAM,QAAuB,CAAA;AAC7B,MAAI,OAAO;AACX,MAAI,iBAAiB;AAErB,QAAM,aAAa,MAAK;AACvB,QAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC9B,YAAM,UAAK;AACX,aAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,OAAO,MAAK;AACjB,WAAO;AAEP,eAAA;AAAA,EACD;AAEA,QAAM,MAAM,OACX,WACA,SACA,eACG;AACH,UAAM,0BAA0B,KAAK,IAAA,IAAQ;AAE7C,QAAI,YAAY,0BAA0B,UAAU;AACnD,YAAM,MAAM,WAAW,uBAAuB;AAAA,IAC/C;AACA,UAAM,UAAU,YAAY,UAAU,GAAG,UAAU,GAAA;AAEnD,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACP,QAAQ;AAAA,IAAC;AAET,qBAAiB,KAAK,IAAA;AAEtB,SAAA;AAAA,EACD;AAEA,QAAM,UAAU,CACf,WACA,SACA,eACG;AAGH,QAAI,QAAQ,CAAC,oBAAmB;AAC/B,YAAM,KAAK,eAAe;AAAA,IAC3B,CAAC,EAAE,KAAK,IAAI,KAAK,QAAW,WAAW,SAAS,UAAU,CAAC;AAC1D,KAAC,YAAW;AAKZ,YAAM,QAAQ,QAAA;AAEd,UAAI,CAAC,MAAM;AACV,mBAAA;AAAA,MACD;AAAA,IACD,GAAA;AAAA,EACD;AAEA,UAAQ,CAAC,cAA2B,eACnC,IAAI,QAAiB,CAAC,YAAW;AAChC,YAAQ,WAAW,SAAS,UAAU;AAAA,EACvC,CAAC;AACH;;"}
@@ -4,9 +4,8 @@ const pLimit = ({ interval } = {}) => {
4
4
  let busy = false;
5
5
  let lastCompletion = 0;
6
6
  const resumeNext = () => {
7
- var _a;
8
7
  if (!busy && queue.length > 0) {
9
- (_a = queue.shift()) == null ? void 0 : _a();
8
+ queue.shift()?.();
10
9
  busy = true;
11
10
  }
12
11
  };
@@ -39,9 +38,9 @@ const pLimit = ({ interval } = {}) => {
39
38
  }
40
39
  })();
41
40
  };
42
- return (function_, ...arguments_) => new Promise((resolve) => {
41
+ return ((function_, ...arguments_) => new Promise((resolve) => {
43
42
  enqueue(function_, resolve, arguments_);
44
- });
43
+ }));
45
44
  };
46
45
  export {
47
46
  pLimit
@@ -1 +1 @@
1
- {"version":3,"file":"pLimit.js","sources":["../../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing\n * arguments on to the `fn` is provided in order to be able to avoid creating\n * unnecessary closures. You probably don't need this optimization unless\n * you're pushing a lot of functions.\n *\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (\n\t\t...arguments_: TArguments\n\t) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and\n * respect a given interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to\n * wait between each promise execution.\n *\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({\n\tinterval,\n}: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"names":[],"mappings":"AAQA,MAAM,QAAQ,CAAC,OAAe,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AA2BvE,MAAM,SAAS,CAAC,EACtB,SAAQ,IACkB,OAAqB;AAC/C,QAAM,QAAuB,CAAA;AAC7B,MAAI,OAAO;AACX,MAAI,iBAAiB;AAErB,QAAM,aAAa,MAAK;AAlCzB;AAmCE,QAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC9B,kBAAM,YAAN;AACO,aAAA;AAAA,IAAA;AAAA,EAET;AAEA,QAAM,OAAO,MAAK;AACV,WAAA;;EAGR;AAEA,QAAM,MAAM,OACX,WACA,SACA,eACG;AACG,UAAA,0BAA0B,KAAK,IAAA,IAAQ;AAEzC,QAAA,YAAY,0BAA0B,UAAU;AAC7C,YAAA,MAAM,WAAW,uBAAuB;AAAA,IAAA;AAE/C,UAAM,UAAU,YAAY,UAAU,GAAG,UAAU;AAEnD,YAAQ,MAAM;AAEV,QAAA;AACG,YAAA;AAAA,IAAA,QACC;AAAA,IAAA;AAER,qBAAiB,KAAK;;EAGvB;AAEA,QAAM,UAAU,CACf,WACA,SACA,eACG;AAGC,QAAA,QAAQ,CAAC,oBAAmB;AAC/B,YAAM,KAAK,eAAe;AAAA,IAAA,CAC1B,EAAE,KAAK,IAAI,KAAK,QAAW,WAAW,SAAS,UAAU,CAAC;AAC1D,KAAC,YAAW;AAKZ,YAAM,QAAQ,QAAO;AAErB,UAAI,CAAC,MAAM;;;IAEX;EAEF;AAEA,SAAQ,CAAC,cAA2B,eACnC,IAAI,QAAiB,CAAC,YAAW;AACxB,YAAA,WAAW,SAAS,UAAU;AAAA,EAAA,CACtC;AACH;"}
1
+ {"version":3,"file":"pLimit.js","sources":["../../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing\n * arguments on to the `fn` is provided in order to be able to avoid creating\n * unnecessary closures. You probably don't need this optimization unless\n * you're pushing a lot of functions.\n *\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (\n\t\t...arguments_: TArguments\n\t) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and\n * respect a given interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to\n * wait between each promise execution.\n *\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({\n\tinterval,\n}: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"names":[],"mappings":"AAQA,MAAM,QAAQ,CAAC,OAAe,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AA2BvE,MAAM,SAAS,CAAC,EACtB,SAAA,IAC0B,OAAqB;AAC/C,QAAM,QAAuB,CAAA;AAC7B,MAAI,OAAO;AACX,MAAI,iBAAiB;AAErB,QAAM,aAAa,MAAK;AACvB,QAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC9B,YAAM,UAAK;AACX,aAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,OAAO,MAAK;AACjB,WAAO;AAEP,eAAA;AAAA,EACD;AAEA,QAAM,MAAM,OACX,WACA,SACA,eACG;AACH,UAAM,0BAA0B,KAAK,IAAA,IAAQ;AAE7C,QAAI,YAAY,0BAA0B,UAAU;AACnD,YAAM,MAAM,WAAW,uBAAuB;AAAA,IAC/C;AACA,UAAM,UAAU,YAAY,UAAU,GAAG,UAAU,GAAA;AAEnD,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACP,QAAQ;AAAA,IAAC;AAET,qBAAiB,KAAK,IAAA;AAEtB,SAAA;AAAA,EACD;AAEA,QAAM,UAAU,CACf,WACA,SACA,eACG;AAGH,QAAI,QAAQ,CAAC,oBAAmB;AAC/B,YAAM,KAAK,eAAe;AAAA,IAC3B,CAAC,EAAE,KAAK,IAAI,KAAK,QAAW,WAAW,SAAS,UAAU,CAAC;AAC1D,KAAC,YAAW;AAKZ,YAAM,QAAQ,QAAA;AAEd,UAAI,CAAC,MAAM;AACV,mBAAA;AAAA,MACD;AAAA,IACD,GAAA;AAAA,EACD;AAEA,UAAQ,CAAC,cAA2B,eACnC,IAAI,QAAiB,CAAC,YAAW;AAChC,YAAQ,WAAW,SAAS,UAAU;AAAA,EACvC,CAAC;AACH;"}
@@ -5,28 +5,26 @@ const DEFAULT_RETRY_AFTER = 1500;
5
5
  const THROTTLED_RUNNERS = {};
6
6
  const DEDUPLICATED_JOBS = {};
7
7
  async function request(url, init, fetchFn) {
8
- var _a, _b;
9
8
  const stringURL = url.toString();
10
9
  let job;
11
- if (init == null ? void 0 : init.body) {
12
- const runner = THROTTLED_RUNNERS[_a = url.hostname] || (THROTTLED_RUNNERS[_a] = pLimit.pLimit({
10
+ if (init?.body) {
11
+ const runner = THROTTLED_RUNNERS[url.hostname] ||= pLimit.pLimit({
13
12
  interval: DEFAULT_RETRY_AFTER
14
- }));
13
+ });
15
14
  job = runner(() => fetchFn(stringURL, init));
16
15
  } else {
17
- const existingJob = (_b = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _b.get(init == null ? void 0 : init.signal);
16
+ const existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal);
18
17
  if (existingJob) {
19
18
  job = existingJob;
20
19
  } else {
21
20
  job = fetchFn(stringURL, init).finally(() => {
22
- var _a2, _b2;
23
- (_a2 = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _a2.delete(init == null ? void 0 : init.signal);
24
- if (((_b2 = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _b2.size) === 0) {
21
+ DEDUPLICATED_JOBS[stringURL]?.delete(init?.signal);
22
+ if (DEDUPLICATED_JOBS[stringURL]?.size === 0) {
25
23
  delete DEDUPLICATED_JOBS[stringURL];
26
24
  }
27
25
  });
28
- const map = DEDUPLICATED_JOBS[stringURL] || (DEDUPLICATED_JOBS[stringURL] = /* @__PURE__ */ new Map());
29
- map.set(init == null ? void 0 : init.signal, job);
26
+ const map = DEDUPLICATED_JOBS[stringURL] ||= /* @__PURE__ */ new Map();
27
+ map.set(init?.signal, job);
30
28
  }
31
29
  }
32
30
  const response = await job;
@@ -1 +1 @@
1
- {"version":3,"file":"request.cjs","sources":["../../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init).finally(() => {\n\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response.clone()\n}\n"],"names":["pLimit","_a","_b"],"mappings":";;;AAOO,MAAM,sBAAsB;AAKnC,MAAM,oBAA4D,CAAA;AAMlE,MAAM,oBAEF,CAAA;AAgGkB,eAAA,QACrB,KACA,MACA,SAAkB;;AAEZ,QAAA,YAAY,IAAI;AAElB,MAAA;AAGJ,MAAI,6BAAM,MAAM;AAEf,UAAM,SAAU,uBAAkB,IAAI,cAAtB,wBAAoCA,OAAAA,OAAO;AAAA,MAC1D,UAAU;AAAA,IAAA,CACV;AAED,UAAM,OAAO,MAAM,QAAQ,WAAW,IAAI,CAAC;AAAA,EAAA,OACrC;AAEN,UAAM,eAAc,uBAAkB,SAAS,MAA3B,mBAA8B,IAAI,6BAAM;AAC5D,QAAI,aAAa;AACV,YAAA;AAAA,IAAA,OACA;AACN,YAAM,QAAQ,WAAW,IAAI,EAAE,QAAQ,MAAK;;AAC3C,SAAAC,MAAA,kBAAkB,SAAS,MAA3B,gBAAAA,IAA8B,OAAO,6BAAM;AAC3C,cAAIC,MAAA,kBAAkB,SAAS,MAA3B,gBAAAA,IAA8B,UAAS,GAAG;AAC7C,iBAAO,kBAAkB,SAAS;AAAA,QAAA;AAAA,MACnC,CACA;AACD,YAAM,MAAO,oFAAqC,IAAK;AACnD,UAAA,IAAI,6BAAM,QAAQ,GAAG;AAAA,IAAA;AAAA,EAC1B;AAGD,QAAM,WAAW,MAAM;AAGnB,MAAA,SAAS,WAAW,KAAK;AAC5B,UAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;AAC7D,UAAM,qBAAqB,OAAO,MAAM,UAAU,IAC/C,sBACA,aAAa;AAEhB,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,kBAAkB,CAAC;AAE/D,WAAA,QAAQ,KAAK,MAAM,OAAO;AAAA,EAAA;AAGlC,SAAO,SAAS,MAAK;AACtB;;;"}
1
+ {"version":3,"file":"request.cjs","sources":["../../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init).finally(() => {\n\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response.clone()\n}\n"],"names":["pLimit"],"mappings":";;;AAOO,MAAM,sBAAsB;AAKnC,MAAM,oBAA4D,CAAA;AAMlE,MAAM,oBAEF,CAAA;AAgGJ,eAAsB,QACrB,KACA,MACA,SAAkB;AAElB,QAAM,YAAY,IAAI,SAAA;AAEtB,MAAI;AAGJ,MAAI,MAAM,MAAM;AAEf,UAAM,SAAU,kBAAkB,IAAI,QAAQ,MAAMA,OAAAA,OAAO;AAAA,MAC1D,UAAU;AAAA,IAAA,CACV;AAED,UAAM,OAAO,MAAM,QAAQ,WAAW,IAAI,CAAC;AAAA,EAC5C,OAAO;AAEN,UAAM,cAAc,kBAAkB,SAAS,GAAG,IAAI,MAAM,MAAM;AAClE,QAAI,aAAa;AAChB,YAAM;AAAA,IACP,OAAO;AACN,YAAM,QAAQ,WAAW,IAAI,EAAE,QAAQ,MAAK;AAC3C,0BAAkB,SAAS,GAAG,OAAO,MAAM,MAAM;AACjD,YAAI,kBAAkB,SAAS,GAAG,SAAS,GAAG;AAC7C,iBAAO,kBAAkB,SAAS;AAAA,QACnC;AAAA,MACD,CAAC;AACD,YAAM,MAAO,kBAAkB,SAAS,0BAAU,IAAA;AAClD,UAAI,IAAI,MAAM,QAAQ,GAAG;AAAA,IAC1B;AAAA,EACD;AAEA,QAAM,WAAW,MAAM;AAGvB,MAAI,SAAS,WAAW,KAAK;AAC5B,UAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;AAC7D,UAAM,qBAAqB,OAAO,MAAM,UAAU,IAC/C,sBACA,aAAa;AAEhB,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,kBAAkB,CAAC;AAEtE,WAAO,QAAQ,KAAK,MAAM,OAAO;AAAA,EAClC;AAEA,SAAO,SAAS,MAAA;AACjB;;;"}
@@ -3,28 +3,26 @@ const DEFAULT_RETRY_AFTER = 1500;
3
3
  const THROTTLED_RUNNERS = {};
4
4
  const DEDUPLICATED_JOBS = {};
5
5
  async function request(url, init, fetchFn) {
6
- var _a, _b;
7
6
  const stringURL = url.toString();
8
7
  let job;
9
- if (init == null ? void 0 : init.body) {
10
- const runner = THROTTLED_RUNNERS[_a = url.hostname] || (THROTTLED_RUNNERS[_a] = pLimit({
8
+ if (init?.body) {
9
+ const runner = THROTTLED_RUNNERS[url.hostname] ||= pLimit({
11
10
  interval: DEFAULT_RETRY_AFTER
12
- }));
11
+ });
13
12
  job = runner(() => fetchFn(stringURL, init));
14
13
  } else {
15
- const existingJob = (_b = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _b.get(init == null ? void 0 : init.signal);
14
+ const existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal);
16
15
  if (existingJob) {
17
16
  job = existingJob;
18
17
  } else {
19
18
  job = fetchFn(stringURL, init).finally(() => {
20
- var _a2, _b2;
21
- (_a2 = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _a2.delete(init == null ? void 0 : init.signal);
22
- if (((_b2 = DEDUPLICATED_JOBS[stringURL]) == null ? void 0 : _b2.size) === 0) {
19
+ DEDUPLICATED_JOBS[stringURL]?.delete(init?.signal);
20
+ if (DEDUPLICATED_JOBS[stringURL]?.size === 0) {
23
21
  delete DEDUPLICATED_JOBS[stringURL];
24
22
  }
25
23
  });
26
- const map = DEDUPLICATED_JOBS[stringURL] || (DEDUPLICATED_JOBS[stringURL] = /* @__PURE__ */ new Map());
27
- map.set(init == null ? void 0 : init.signal, job);
24
+ const map = DEDUPLICATED_JOBS[stringURL] ||= /* @__PURE__ */ new Map();
25
+ map.set(init?.signal, job);
28
26
  }
29
27
  }
30
28
  const response = await job;