@prismicio/client 7.7.3 → 7.7.4

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 (304) hide show
  1. package/README.md +3 -3
  2. package/dist/buildQueryURL.cjs.map +1 -1
  3. package/dist/buildQueryURL.d.ts +1 -1
  4. package/dist/buildQueryURL.js.map +1 -1
  5. package/dist/cookie.cjs.map +1 -1
  6. package/dist/cookie.js.map +1 -1
  7. package/dist/createClient.cjs +31 -31
  8. package/dist/createClient.cjs.map +1 -1
  9. package/dist/createClient.d.ts +35 -35
  10. package/dist/createClient.js +31 -31
  11. package/dist/createClient.js.map +1 -1
  12. package/dist/errors/ForbiddenError.cjs.map +1 -1
  13. package/dist/errors/ForbiddenError.js.map +1 -1
  14. package/dist/errors/NotFoundError.cjs.map +1 -1
  15. package/dist/errors/NotFoundError.js.map +1 -1
  16. package/dist/errors/ParsingError.cjs.map +1 -1
  17. package/dist/errors/ParsingError.js.map +1 -1
  18. package/dist/errors/PreviewTokenExpired.cjs.map +1 -1
  19. package/dist/errors/PreviewTokenExpired.js.map +1 -1
  20. package/dist/errors/PrismicError.cjs.map +1 -1
  21. package/dist/errors/PrismicError.js.map +1 -1
  22. package/dist/errors/PrismicRichTextSerializerError.cjs.map +1 -1
  23. package/dist/errors/PrismicRichTextSerializerError.js.map +1 -1
  24. package/dist/errors/RefExpiredError.cjs.map +1 -1
  25. package/dist/errors/RefExpiredError.js.map +1 -1
  26. package/dist/errors/RefNotFoundError.cjs.map +1 -1
  27. package/dist/errors/RefNotFoundError.js.map +1 -1
  28. package/dist/errors/RepositoryNotFoundError.cjs.map +1 -1
  29. package/dist/errors/RepositoryNotFoundError.js.map +1 -1
  30. package/dist/filter.cjs.map +1 -1
  31. package/dist/filter.js.map +1 -1
  32. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  33. package/dist/getGraphQLEndpoint.js.map +1 -1
  34. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  35. package/dist/getRepositoryEndpoint.js.map +1 -1
  36. package/dist/getRepositoryName.cjs.map +1 -1
  37. package/dist/getRepositoryName.js.map +1 -1
  38. package/dist/getToolbarSrc.cjs.map +1 -1
  39. package/dist/getToolbarSrc.js.map +1 -1
  40. package/dist/helpers/asDate.cjs.map +1 -1
  41. package/dist/helpers/asDate.js.map +1 -1
  42. package/dist/helpers/asHTML.cjs.map +1 -1
  43. package/dist/helpers/asHTML.d.ts +2 -2
  44. package/dist/helpers/asHTML.js.map +1 -1
  45. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  46. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -2
  47. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  48. package/dist/helpers/asImageSrc.cjs.map +1 -1
  49. package/dist/helpers/asImageSrc.d.ts +2 -2
  50. package/dist/helpers/asImageSrc.js.map +1 -1
  51. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  52. package/dist/helpers/asImageWidthSrcSet.d.ts +2 -2
  53. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  54. package/dist/helpers/asLink.cjs.map +1 -1
  55. package/dist/helpers/asLink.d.ts +2 -4
  56. package/dist/helpers/asLink.js.map +1 -1
  57. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  58. package/dist/helpers/asLinkAttrs.d.ts +2 -2
  59. package/dist/helpers/asLinkAttrs.js.map +1 -1
  60. package/dist/helpers/asText.cjs.map +1 -1
  61. package/dist/helpers/asText.d.ts +1 -1
  62. package/dist/helpers/asText.js.map +1 -1
  63. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  64. package/dist/helpers/documentToLinkField.js.map +1 -1
  65. package/dist/helpers/isFilled.cjs.map +1 -1
  66. package/dist/helpers/isFilled.js.map +1 -1
  67. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  68. package/dist/helpers/mapSliceZone.d.ts +1 -1
  69. package/dist/helpers/mapSliceZone.js.map +1 -1
  70. package/dist/helpers/unstable_htmlAsRichText.cjs.map +1 -1
  71. package/dist/helpers/unstable_htmlAsRichText.d.ts +4 -4
  72. package/dist/helpers/unstable_htmlAsRichText.js.map +1 -1
  73. package/dist/helpers/unstable_markdownAsRichText.cjs.map +1 -1
  74. package/dist/helpers/unstable_markdownAsRichText.d.ts +2 -2
  75. package/dist/helpers/unstable_markdownAsRichText.js.map +1 -1
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  79. package/dist/isRepositoryEndpoint.js.map +1 -1
  80. package/dist/isRepositoryName.cjs.map +1 -1
  81. package/dist/isRepositoryName.js.map +1 -1
  82. package/dist/lib/RichTextFieldBuilder.cjs.map +1 -1
  83. package/dist/lib/RichTextFieldBuilder.d.ts +1 -1
  84. package/dist/lib/RichTextFieldBuilder.js.map +1 -1
  85. package/dist/lib/appendFilters.cjs.map +1 -1
  86. package/dist/lib/appendFilters.js.map +1 -1
  87. package/dist/lib/castArray.cjs.map +1 -1
  88. package/dist/lib/castArray.js.map +1 -1
  89. package/dist/lib/castThunk.cjs.map +1 -1
  90. package/dist/lib/castThunk.js.map +1 -1
  91. package/dist/lib/devMsg.cjs.map +1 -1
  92. package/dist/lib/devMsg.d.ts +1 -1
  93. package/dist/lib/devMsg.js.map +1 -1
  94. package/dist/lib/escapeHTML.cjs.map +1 -1
  95. package/dist/lib/escapeHTML.js.map +1 -1
  96. package/dist/lib/everyTagFilter.cjs.map +1 -1
  97. package/dist/lib/everyTagFilter.js.map +1 -1
  98. package/dist/lib/filterRichTextField.cjs.map +1 -1
  99. package/dist/lib/filterRichTextField.d.ts +3 -3
  100. package/dist/lib/filterRichTextField.js.map +1 -1
  101. package/dist/lib/findMasterRef.cjs.map +1 -1
  102. package/dist/lib/findMasterRef.d.ts +1 -1
  103. package/dist/lib/findMasterRef.js.map +1 -1
  104. package/dist/lib/findRef.cjs.map +1 -1
  105. package/dist/lib/findRef.d.ts +1 -1
  106. package/dist/lib/findRef.js.map +1 -1
  107. package/dist/lib/findRefByID.cjs.map +1 -1
  108. package/dist/lib/findRefByID.d.ts +1 -1
  109. package/dist/lib/findRefByID.js.map +1 -1
  110. package/dist/lib/findRefByLabel.cjs.map +1 -1
  111. package/dist/lib/findRefByLabel.d.ts +1 -1
  112. package/dist/lib/findRefByLabel.js.map +1 -1
  113. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  114. package/dist/lib/getPreviewCookie.js.map +1 -1
  115. package/dist/lib/hastSerializerHelpers.cjs.map +1 -1
  116. package/dist/lib/hastSerializerHelpers.d.ts +3 -3
  117. package/dist/lib/hastSerializerHelpers.js.map +1 -1
  118. package/dist/lib/hastToRichText.cjs +1 -2
  119. package/dist/lib/hastToRichText.cjs.map +1 -1
  120. package/dist/lib/hastToRichText.d.ts +4 -4
  121. package/dist/lib/hastToRichText.js +1 -2
  122. package/dist/lib/hastToRichText.js.map +1 -1
  123. package/dist/lib/isInternalURL.cjs.map +1 -1
  124. package/dist/lib/isInternalURL.js.map +1 -1
  125. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  126. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  127. package/dist/lib/rehypeRichText.cjs.map +1 -1
  128. package/dist/lib/rehypeRichText.d.ts +5 -5
  129. package/dist/lib/rehypeRichText.js.map +1 -1
  130. package/dist/lib/serializerHelpers.cjs.map +1 -1
  131. package/dist/lib/serializerHelpers.d.ts +2 -2
  132. package/dist/lib/serializerHelpers.js.map +1 -1
  133. package/dist/lib/someTagsFilter.cjs.map +1 -1
  134. package/dist/lib/someTagsFilter.js.map +1 -1
  135. package/dist/lib/typeFilter.cjs.map +1 -1
  136. package/dist/lib/typeFilter.js.map +1 -1
  137. package/dist/package.json.cjs +1 -1
  138. package/dist/package.json.js +1 -1
  139. package/dist/richtext/asText.cjs.map +1 -1
  140. package/dist/richtext/asText.d.ts +1 -1
  141. package/dist/richtext/asText.js.map +1 -1
  142. package/dist/richtext/asTree.cjs.map +1 -1
  143. package/dist/richtext/asTree.d.ts +2 -2
  144. package/dist/richtext/asTree.js.map +1 -1
  145. package/dist/richtext/composeSerializers.cjs.map +1 -1
  146. package/dist/richtext/composeSerializers.d.ts +1 -1
  147. package/dist/richtext/composeSerializers.js.map +1 -1
  148. package/dist/richtext/serialize.cjs.map +1 -1
  149. package/dist/richtext/serialize.d.ts +1 -1
  150. package/dist/richtext/serialize.js.map +1 -1
  151. package/dist/richtext/types.cjs.map +1 -1
  152. package/dist/richtext/types.d.ts +1 -1
  153. package/dist/richtext/types.js.map +1 -1
  154. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  155. package/dist/richtext/wrapMapSerializer.d.ts +1 -1
  156. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  157. package/dist/types/api/query.d.ts +1 -1
  158. package/dist/types/api/release.d.ts +1 -1
  159. package/dist/types/api/repository.d.ts +1 -1
  160. package/dist/types/model/customType.d.ts +1 -1
  161. package/dist/types/model/link.cjs.map +1 -1
  162. package/dist/types/model/link.js.map +1 -1
  163. package/dist/types/model/slice.cjs.map +1 -1
  164. package/dist/types/model/slice.js.map +1 -1
  165. package/dist/types/model/sliceZone.cjs.map +1 -1
  166. package/dist/types/model/sliceZone.js.map +1 -1
  167. package/dist/types/model/title.d.ts +1 -1
  168. package/dist/types/model/types.cjs.map +1 -1
  169. package/dist/types/model/types.js.map +1 -1
  170. package/dist/types/value/document.d.ts +4 -4
  171. package/dist/types/value/embed.cjs.map +1 -1
  172. package/dist/types/value/embed.js.map +1 -1
  173. package/dist/types/value/link.cjs.map +1 -1
  174. package/dist/types/value/link.js.map +1 -1
  175. package/dist/types/value/richText.cjs.map +1 -1
  176. package/dist/types/value/richText.js.map +1 -1
  177. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  178. package/dist/types/webhook/testTrigger.d.ts +1 -1
  179. package/dist/types/webhook/types.cjs.map +1 -1
  180. package/dist/types/webhook/types.d.ts +2 -2
  181. package/dist/types/webhook/types.js.map +1 -1
  182. package/package.json +1 -1
  183. package/src/buildQueryURL.ts +51 -51
  184. package/src/cookie.ts +1 -1
  185. package/src/createClient.ts +293 -293
  186. package/src/errors/ForbiddenError.ts +6 -6
  187. package/src/errors/NotFoundError.ts +1 -1
  188. package/src/errors/ParsingError.ts +8 -8
  189. package/src/errors/PreviewTokenExpired.ts +4 -4
  190. package/src/errors/PrismicError.ts +5 -5
  191. package/src/errors/PrismicRichTextSerializerError.ts +1 -1
  192. package/src/errors/RefExpiredError.ts +4 -4
  193. package/src/errors/RefNotFoundError.ts +4 -4
  194. package/src/errors/RepositoryNotFoundError.ts +1 -1
  195. package/src/filter.ts +22 -22
  196. package/src/getGraphQLEndpoint.ts +5 -5
  197. package/src/getRepositoryEndpoint.ts +5 -5
  198. package/src/getRepositoryName.ts +4 -4
  199. package/src/getToolbarSrc.ts +5 -5
  200. package/src/helpers/asDate.ts +7 -7
  201. package/src/helpers/asHTML.ts +54 -56
  202. package/src/helpers/asImagePixelDensitySrcSet.ts +14 -17
  203. package/src/helpers/asImageSrc.ts +9 -8
  204. package/src/helpers/asImageWidthSrcSet.ts +19 -22
  205. package/src/helpers/asLink.ts +26 -27
  206. package/src/helpers/asLinkAttrs.ts +30 -29
  207. package/src/helpers/asText.ts +15 -15
  208. package/src/helpers/documentToLinkField.ts +6 -6
  209. package/src/helpers/isFilled.ts +53 -53
  210. package/src/helpers/mapSliceZone.ts +34 -34
  211. package/src/helpers/unstable_htmlAsRichText.ts +23 -22
  212. package/src/helpers/unstable_markdownAsRichText.ts +14 -13
  213. package/src/index.ts +119 -119
  214. package/src/isRepositoryEndpoint.ts +4 -4
  215. package/src/isRepositoryName.ts +2 -2
  216. package/src/lib/RichTextFieldBuilder.ts +36 -41
  217. package/src/lib/appendFilters.ts +4 -4
  218. package/src/lib/castArray.ts +2 -2
  219. package/src/lib/castThunk.ts +2 -2
  220. package/src/lib/devMsg.ts +4 -4
  221. package/src/lib/escapeHTML.ts +24 -24
  222. package/src/lib/everyTagFilter.ts +4 -4
  223. package/src/lib/filterRichTextField.ts +31 -31
  224. package/src/lib/findMasterRef.ts +4 -4
  225. package/src/lib/findRef.ts +6 -6
  226. package/src/lib/findRefByID.ts +4 -4
  227. package/src/lib/findRefByLabel.ts +4 -4
  228. package/src/lib/getPreviewCookie.ts +11 -11
  229. package/src/lib/hastSerializerHelpers.ts +41 -37
  230. package/src/lib/hastToRichText.ts +74 -73
  231. package/src/lib/isInternalURL.ts +4 -4
  232. package/src/lib/minifyGraphQLQuery.ts +2 -2
  233. package/src/lib/rehypeRichText.ts +42 -41
  234. package/src/lib/serializerHelpers.ts +53 -54
  235. package/src/lib/someTagsFilter.ts +4 -4
  236. package/src/lib/typeFilter.ts +3 -3
  237. package/src/richtext/asText.ts +5 -5
  238. package/src/richtext/asTree.ts +53 -53
  239. package/src/richtext/composeSerializers.ts +6 -6
  240. package/src/richtext/index.ts +7 -7
  241. package/src/richtext/serialize.ts +11 -11
  242. package/src/richtext/types.ts +38 -38
  243. package/src/richtext/wrapMapSerializer.ts +6 -9
  244. package/src/types/api/query.ts +9 -9
  245. package/src/types/api/ref.ts +5 -5
  246. package/src/types/api/release.ts +2 -2
  247. package/src/types/api/repository.ts +24 -24
  248. package/src/types/api/tags.ts +1 -1
  249. package/src/types/model/boolean.ts +7 -7
  250. package/src/types/model/color.ts +5 -5
  251. package/src/types/model/contentRelationship.ts +9 -9
  252. package/src/types/model/customType.ts +9 -9
  253. package/src/types/model/date.ts +6 -6
  254. package/src/types/model/embed.ts +5 -5
  255. package/src/types/model/geoPoint.ts +4 -4
  256. package/src/types/model/group.ts +6 -6
  257. package/src/types/model/image.ts +9 -9
  258. package/src/types/model/integration.ts +6 -6
  259. package/src/types/model/keyText.ts +5 -5
  260. package/src/types/model/link.ts +8 -8
  261. package/src/types/model/linkToMedia.ts +7 -7
  262. package/src/types/model/number.ts +7 -7
  263. package/src/types/model/range.ts +8 -8
  264. package/src/types/model/richText.ts +16 -16
  265. package/src/types/model/select.ts +7 -7
  266. package/src/types/model/separator.ts +4 -4
  267. package/src/types/model/sharedSlice.ts +7 -7
  268. package/src/types/model/sharedSliceVariation.ts +9 -9
  269. package/src/types/model/slice.ts +12 -12
  270. package/src/types/model/sliceZone.ts +11 -11
  271. package/src/types/model/timestamp.ts +6 -6
  272. package/src/types/model/title.ts +2 -2
  273. package/src/types/model/types.ts +26 -26
  274. package/src/types/model/uid.ts +5 -5
  275. package/src/types/value/boolean.ts +1 -1
  276. package/src/types/value/color.ts +2 -2
  277. package/src/types/value/contentRelationship.ts +15 -15
  278. package/src/types/value/date.ts +2 -2
  279. package/src/types/value/document.ts +23 -23
  280. package/src/types/value/embed.ts +33 -33
  281. package/src/types/value/geoPoint.ts +4 -4
  282. package/src/types/value/group.ts +3 -3
  283. package/src/types/value/image.ts +21 -21
  284. package/src/types/value/integration.ts +2 -2
  285. package/src/types/value/keyText.ts +2 -2
  286. package/src/types/value/link.ts +12 -12
  287. package/src/types/value/linkToMedia.ts +11 -11
  288. package/src/types/value/number.ts +2 -2
  289. package/src/types/value/richText.ts +58 -58
  290. package/src/types/value/select.ts +2 -2
  291. package/src/types/value/sharedSlice.ts +5 -5
  292. package/src/types/value/sharedSliceVariation.ts +5 -5
  293. package/src/types/value/slice.ts +6 -6
  294. package/src/types/value/sliceZone.ts +4 -4
  295. package/src/types/value/timestamp.ts +3 -3
  296. package/src/types/value/title.ts +4 -4
  297. package/src/types/value/types.ts +22 -22
  298. package/src/types/webhook/apiUpdate.ts +18 -18
  299. package/src/types/webhook/testTrigger.ts +2 -2
  300. package/src/types/webhook/types.ts +8 -8
  301. package/dist/_node_modules/hast-util-whitespace/lib/index.cjs +0 -11
  302. package/dist/_node_modules/hast-util-whitespace/lib/index.cjs.map +0 -1
  303. package/dist/_node_modules/hast-util-whitespace/lib/index.js +0 -11
  304. package/dist/_node_modules/hast-util-whitespace/lib/index.js.map +0 -1
package/README.md CHANGED
@@ -15,13 +15,13 @@ The official JavaScript + TypeScript client library for [Prismic][prismic].
15
15
  - Built for browser and server usage.
16
16
 
17
17
  ```typescript
18
- import * as prismic from "@prismicio/client";
18
+ import * as prismic from "@prismicio/client"
19
19
 
20
20
  // Create a client
21
- const client = prismic.createClient("my-repository");
21
+ const client = prismic.createClient("my-repository")
22
22
 
23
23
  // Then query for your content
24
- const blogPosts = await client.getAllByType("blog_post");
24
+ const blogPosts = await client.getAllByType("blog_post")
25
25
  ```
26
26
 
27
27
  ## Install
@@ -1 +1 @@
1
- {"version":3,"file":"buildQueryURL.cjs","sources":["../../src/buildQueryURL.ts"],"sourcesContent":["import { castArray } from \"./lib/castArray\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Create a union of the given object's values, and optionally specify which\n * keys to get the values from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType];\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string;\n\tdirection?: \"asc\" | \"desc\";\n}\n\n/**\n * A `routes` parameter that determines how a document's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example With a document's UID field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * }\n * ```\n *\n * @example With a Content Relationship `parent` field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\t\"parent\": \"parent\"\n * \t}\n * }\n * ```\n */\nexport interface Route {\n\t/**\n\t * The custom type of the document.\n\t */\n\ttype: string;\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only\n\t * defined for the document whose UID matches the given UID.\n\t */\n\tuid?: string;\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is\n\t * only defined for documents whose language matches the given language.\n\t */\n\tlang?: string;\n\n\t/**\n\t * The resolved path of the document with optional placeholders.\n\t */\n\tpath: string;\n\n\t/**\n\t * An object that lists the API IDs of the Content Relationships in the route.\n\t */\n\tresolvers?: Record<string, string>;\n}\n\n/**\n * Parameters for the Prismic REST API V2.\n *\n * {@link https://prismic.io/docs/api}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is\n\t * set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string;\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of documents that the\n\t * API will return for your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number;\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number;\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will\n\t * remove all the documents except for those after the specified document in\n\t * the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string;\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the\n\t * specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[];\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field\n\t * from a linked document and add it to the document response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[];\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve\n\t * and what content to retrieve from Linked Documents / Content\n\t * Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string;\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string;\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You\n\t * can specify as many fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of\n\t * `@prismicio/client@7.0.0`. Please migrate to the more explicit array of\n\t * objects.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * buildQueryURL(endpoint, {\n\t * \torderings: [\n\t * \t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t{ field: \"my.product.title\" },\n\t * \t],\n\t * });\n\t * ```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[];\n\n\t/**\n\t * The `routes` option allows you to define how a document's `url` field is\n\t * resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[];\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string;\n}\n\n/**\n * Arguments for `buildQueryURL` to construct a Query URL.\n */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string;\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string;\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[];\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[];\n};\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API\n * V2 specification for better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const;\n\n/**\n * A valid parameter name for the Prismic REST API V2.\n */\ntype ValidParamName =\n\t| Exclude<\n\t\t\tkeyof QueryParams,\n\t\t\tkeyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams\n\t >\n\t| ValueOf<typeof RENAMED_PARAMS>;\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API.\n * If the value provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n *\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \");\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\"\n\t\t\t\t\t? `{ field: \"${field}\", direction: \"desc\" }`\n\t\t\t\t\t: `{ field: \"${field}\" }`;\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\treturn ordering;\n\t}\n\n\treturn ordering.direction === \"desc\"\n\t\t? `${ordering.field} desc`\n\t\t: ordering.field;\n};\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;\n\n/**\n * Build a Prismic REST API V2 URL to request documents from a repository. The\n * paginated response for this URL includes documents matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a\n * list of available refs.\n *\n * Type the JSON response with `Query`.\n *\n * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n * {@link https://prismic.io/docs/rest-api-technical-reference}\n *\n * @param endpoint - URL to the repository's REST API V2.\n * @param args - Arguments to filter and scope the query.\n *\n * @returns URL that can be used to request documents from the repository.\n */\nexport const buildQueryURL = (\n\tendpoint: string,\n\targs: BuildQueryURLArgs,\n): string => {\n\tconst { filters, predicates, ...params } = args;\n\n\tconst url = new URL(`documents/search`, `${endpoint}/`);\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`);\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`);\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] ||\n\t\t\tk) as ValidParamName;\n\n\t\tlet value = params[k as keyof typeof params];\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name];\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (\n\t\t\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t\t\ttypeof scopedValue === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\");\n\n\t\t\t\tvalue = `[${v}]`;\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]));\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(\n\t\t\t\tname,\n\t\t\t\tcastArray<string | number | Route | Ordering>(value).join(\",\"),\n\t\t\t);\n\t\t}\n\t}\n\n\treturn url.toString();\n};\n"],"names":["devMsg","castArray"],"mappings":";;;;AA0OA,MAAM,iBAAiB;AAAA,EACtB,aAAa;;AAqBd,MAAM,uBAAuB,CAAC,aAAuC;AAEhE,MAAA,OAAO,aAAa,UAAU;AAC7B,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC3C,YAAM,CAAC,OAAO,SAAS,IAAI,SAAS,MAAM,GAAG;AAE7C,YAAM,aACL,cAAc,SACX,aAAa,KAAK,2BAClB,aAAa,KAAK;AAEtB,cAAQ,KACP,uJAAuJ,UAAU,2BAA2BA,cAC3L,uCAAuC,CACvC,EAAE;AAAA,IAEL;AAEO,WAAA;AAAA,EACR;AAEA,SAAO,SAAS,cAAc,SAC3B,GAAG,SAAS,KAAK,UACjB,SAAS;AACb;AAqBa,MAAA,gBAAgB,CAC5B,UACA,SACW;AACX,QAAM,EAAE,SAAS,YAAY,GAAG,WAAW;AAE3C,QAAM,MAAM,IAAI,IAAI,oBAAoB,GAAG,QAAQ,GAAG;AAEtD,MAAI,SAAS;AAER,QAAA,QAAQ,IAAI,aAAa,iBAAiB,CAAC,MAAM,QAAQ,OAAO,GAAG;AACtE,cAAQ,KACP,4FAA4F,OAAO,8FAA8FA,cAChM,0BAA0B,CAC1B,EAAE;AAAA,IAEL;AAGW,eAAA,UAAUC,oBAAU,OAAO,GAAG;AACxC,UAAI,aAAa,OAAO,KAAK,IAAI,MAAM,GAAG;AAAA,IAC3C;AAAA,EACD;AAGA,MAAI,YAAY;AACJ,eAAA,aAAaA,oBAAU,UAAU,GAAG;AAC9C,UAAI,aAAa,OAAO,KAAK,IAAI,SAAS,GAAG;AAAA,IAC9C;AAAA,EACD;AAIA,aAAW,KAAK,QAAQ;AACjB,UAAA,OAAQ,eAAe,CAAgC,KAC5D;AAEG,QAAA,QAAQ,OAAO,CAAwB;AAE3C,QAAI,SAAS,aAAa;AACnB,YAAA,cAAc,OAAO,IAAI;AAE/B,UAAI,eAAe,MAAM;AAExB,YACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,UACtB;AACD,kBAAQ,KACP,iLAAiLD,OAChL,OAAA,uCAAuC,CACvC,EAAE;AAAA,QAEL;AAEA,cAAM,IAAIC,UAAAA,UAAU,WAAW,EAC7B,IAAI,CAAC,aAAa,qBAAqB,QAAQ,CAAC,EAChD,KAAK,GAAG;AAEV,gBAAQ,IAAI,CAAC;AAAA,MACd;AAAA,IAAA,WACU,SAAS,UAAU;AAC7B,UAAI,OAAO,OAAO,IAAI,MAAM,UAAU;AACrC,gBAAQ,KAAK,UAAUA,UAAAA,UAAU,OAAO,IAAI,CAAC,CAAC;AAAA,MAC/C;AAAA,IACD;AAEA,QAAI,SAAS,MAAM;AACd,UAAA,aAAa,IAChB,MACAA,UAAAA,UAA8C,KAAK,EAAE,KAAK,GAAG,CAAC;AAAA,IAEhE;AAAA,EACD;AAEA,SAAO,IAAI;AACZ;;"}
1
+ {"version":3,"file":"buildQueryURL.cjs","sources":["../../src/buildQueryURL.ts"],"sourcesContent":["import { castArray } from \"./lib/castArray\"\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Create a union of the given object's values, and optionally specify which\n * keys to get the values from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType]\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string\n\tdirection?: \"asc\" | \"desc\"\n}\n\n/**\n * A `routes` parameter that determines how a document's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example With a document's UID field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * }\n * ```\n *\n * @example With a Content Relationship `parent` field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\t\"parent\": \"parent\"\n * \t}\n * }\n * ```\n */\nexport interface Route {\n\t/**\n\t * The custom type of the document.\n\t */\n\ttype: string\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only\n\t * defined for the document whose UID matches the given UID.\n\t */\n\tuid?: string\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is\n\t * only defined for documents whose language matches the given language.\n\t */\n\tlang?: string\n\n\t/**\n\t * The resolved path of the document with optional placeholders.\n\t */\n\tpath: string\n\n\t/**\n\t * An object that lists the API IDs of the Content Relationships in the route.\n\t */\n\tresolvers?: Record<string, string>\n}\n\n/**\n * Parameters for the Prismic REST API V2.\n *\n * {@link https://prismic.io/docs/api}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is\n\t * set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of documents that the\n\t * API will return for your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will\n\t * remove all the documents except for those after the specified document in\n\t * the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the\n\t * specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[]\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field\n\t * from a linked document and add it to the document response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[]\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve\n\t * and what content to retrieve from Linked Documents / Content\n\t * Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You\n\t * can specify as many fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of\n\t * `@prismicio/client@7.0.0`. Please migrate to the more explicit array of\n\t * objects.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * buildQueryURL(endpoint, {\n\t * \torderings: [\n\t * \t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t{ field: \"my.product.title\" },\n\t * \t],\n\t * })\n\t * ```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[]\n\n\t/**\n\t * The `routes` option allows you to define how a document's `url` field is\n\t * resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[]\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string\n}\n\n/**\n * Arguments for `buildQueryURL` to construct a Query URL.\n */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[]\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[]\n}\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API\n * V2 specification for better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const\n\n/**\n * A valid parameter name for the Prismic REST API V2.\n */\ntype ValidParamName =\n\t| Exclude<\n\t\t\tkeyof QueryParams,\n\t\t\tkeyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams\n\t >\n\t| ValueOf<typeof RENAMED_PARAMS>\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API.\n * If the value provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n *\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \")\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\"\n\t\t\t\t\t? `{ field: \"${field}\", direction: \"desc\" }`\n\t\t\t\t\t: `{ field: \"${field}\" }`\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\treturn ordering\n\t}\n\n\treturn ordering.direction === \"desc\"\n\t\t? `${ordering.field} desc`\n\t\t: ordering.field\n}\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams\n\n/**\n * Build a Prismic REST API V2 URL to request documents from a repository. The\n * paginated response for this URL includes documents matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a\n * list of available refs.\n *\n * Type the JSON response with `Query`.\n *\n * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n * {@link https://prismic.io/docs/rest-api-technical-reference}\n *\n * @param endpoint - URL to the repository's REST API V2.\n * @param args - Arguments to filter and scope the query.\n *\n * @returns URL that can be used to request documents from the repository.\n */\nexport const buildQueryURL = (\n\tendpoint: string,\n\targs: BuildQueryURLArgs,\n): string => {\n\tconst { filters, predicates, ...params } = args\n\n\tconst url = new URL(`documents/search`, `${endpoint}/`)\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`)\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`)\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] ||\n\t\t\tk) as ValidParamName\n\n\t\tlet value = params[k as keyof typeof params]\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name]\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (\n\t\t\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t\t\ttypeof scopedValue === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\")\n\n\t\t\t\tvalue = `[${v}]`\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]))\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(\n\t\t\t\tname,\n\t\t\t\tcastArray<string | number | Route | Ordering>(value).join(\",\"),\n\t\t\t)\n\t\t}\n\t}\n\n\treturn url.toString()\n}\n"],"names":["devMsg","castArray"],"mappings":";;;;AA0OA,MAAM,iBAAiB;AAAA,EACtB,aAAa;;AAqBd,MAAM,uBAAuB,CAAC,aAAuC;AAEhE,MAAA,OAAO,aAAa,UAAU;AAC7B,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC3C,YAAM,CAAC,OAAO,SAAS,IAAI,SAAS,MAAM,GAAG;AAE7C,YAAM,aACL,cAAc,SACX,aAAa,KAAK,2BAClB,aAAa,KAAK;AAEtB,cAAQ,KACP,uJAAuJ,UAAU,2BAA2BA,cAC3L,uCAAuC,CACvC,EAAE;AAAA,IAEL;AAEO,WAAA;AAAA,EACR;AAEA,SAAO,SAAS,cAAc,SAC3B,GAAG,SAAS,KAAK,UACjB,SAAS;AACb;AAqBa,MAAA,gBAAgB,CAC5B,UACA,SACW;AACX,QAAM,EAAE,SAAS,YAAY,GAAG,WAAW;AAE3C,QAAM,MAAM,IAAI,IAAI,oBAAoB,GAAG,QAAQ,GAAG;AAEtD,MAAI,SAAS;AAER,QAAA,QAAQ,IAAI,aAAa,iBAAiB,CAAC,MAAM,QAAQ,OAAO,GAAG;AACtE,cAAQ,KACP,4FAA4F,OAAO,8FAA8FA,cAChM,0BAA0B,CAC1B,EAAE;AAAA,IAEL;AAGW,eAAA,UAAUC,oBAAU,OAAO,GAAG;AACxC,UAAI,aAAa,OAAO,KAAK,IAAI,MAAM,GAAG;AAAA,IAC3C;AAAA,EACD;AAGA,MAAI,YAAY;AACJ,eAAA,aAAaA,oBAAU,UAAU,GAAG;AAC9C,UAAI,aAAa,OAAO,KAAK,IAAI,SAAS,GAAG;AAAA,IAC9C;AAAA,EACD;AAIA,aAAW,KAAK,QAAQ;AACjB,UAAA,OAAQ,eAAe,CAAgC,KAC5D;AAEG,QAAA,QAAQ,OAAO,CAAwB;AAE3C,QAAI,SAAS,aAAa;AACnB,YAAA,cAAc,OAAO,IAAI;AAE/B,UAAI,eAAe,MAAM;AAExB,YACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,UACtB;AACD,kBAAQ,KACP,iLAAiLD,OAChL,OAAA,uCAAuC,CACvC,EAAE;AAAA,QAEL;AAEA,cAAM,IAAIC,UAAAA,UAAU,WAAW,EAC7B,IAAI,CAAC,aAAa,qBAAqB,QAAQ,CAAC,EAChD,KAAK,GAAG;AAEV,gBAAQ,IAAI,CAAC;AAAA,MACd;AAAA,IAAA,WACU,SAAS,UAAU;AAC7B,UAAI,OAAO,OAAO,IAAI,MAAM,UAAU;AACrC,gBAAQ,KAAK,UAAUA,UAAAA,UAAU,OAAO,IAAI,CAAC,CAAC;AAAA,MAC/C;AAAA,IACD;AAEA,QAAI,SAAS,MAAM;AACd,UAAA,aAAa,IAChB,MACAA,UAAAA,UAA8C,KAAK,EAAE,KAAK,GAAG,CAAC;AAAA,IAEhE;AAAA,EACD;AAEA,SAAO,IAAI;AACZ;;"}
@@ -138,7 +138,7 @@ export interface QueryParams {
138
138
  * { field: "my.product.price", direction: "desc" },
139
139
  * { field: "my.product.title" },
140
140
  * ],
141
- * });
141
+ * })
142
142
  * ```
143
143
  */
144
144
  orderings?: string | Ordering | (string | Ordering)[];
@@ -1 +1 @@
1
- {"version":3,"file":"buildQueryURL.js","sources":["../../src/buildQueryURL.ts"],"sourcesContent":["import { castArray } from \"./lib/castArray\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Create a union of the given object's values, and optionally specify which\n * keys to get the values from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType];\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string;\n\tdirection?: \"asc\" | \"desc\";\n}\n\n/**\n * A `routes` parameter that determines how a document's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example With a document's UID field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * }\n * ```\n *\n * @example With a Content Relationship `parent` field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\t\"parent\": \"parent\"\n * \t}\n * }\n * ```\n */\nexport interface Route {\n\t/**\n\t * The custom type of the document.\n\t */\n\ttype: string;\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only\n\t * defined for the document whose UID matches the given UID.\n\t */\n\tuid?: string;\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is\n\t * only defined for documents whose language matches the given language.\n\t */\n\tlang?: string;\n\n\t/**\n\t * The resolved path of the document with optional placeholders.\n\t */\n\tpath: string;\n\n\t/**\n\t * An object that lists the API IDs of the Content Relationships in the route.\n\t */\n\tresolvers?: Record<string, string>;\n}\n\n/**\n * Parameters for the Prismic REST API V2.\n *\n * {@link https://prismic.io/docs/api}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is\n\t * set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string;\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of documents that the\n\t * API will return for your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number;\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number;\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will\n\t * remove all the documents except for those after the specified document in\n\t * the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string;\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the\n\t * specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[];\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field\n\t * from a linked document and add it to the document response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[];\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve\n\t * and what content to retrieve from Linked Documents / Content\n\t * Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string;\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string;\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You\n\t * can specify as many fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of\n\t * `@prismicio/client@7.0.0`. Please migrate to the more explicit array of\n\t * objects.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * buildQueryURL(endpoint, {\n\t * \torderings: [\n\t * \t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t{ field: \"my.product.title\" },\n\t * \t],\n\t * });\n\t * ```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[];\n\n\t/**\n\t * The `routes` option allows you to define how a document's `url` field is\n\t * resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[];\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string;\n}\n\n/**\n * Arguments for `buildQueryURL` to construct a Query URL.\n */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string;\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string;\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[];\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[];\n};\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API\n * V2 specification for better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const;\n\n/**\n * A valid parameter name for the Prismic REST API V2.\n */\ntype ValidParamName =\n\t| Exclude<\n\t\t\tkeyof QueryParams,\n\t\t\tkeyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams\n\t >\n\t| ValueOf<typeof RENAMED_PARAMS>;\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API.\n * If the value provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n *\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \");\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\"\n\t\t\t\t\t? `{ field: \"${field}\", direction: \"desc\" }`\n\t\t\t\t\t: `{ field: \"${field}\" }`;\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\treturn ordering;\n\t}\n\n\treturn ordering.direction === \"desc\"\n\t\t? `${ordering.field} desc`\n\t\t: ordering.field;\n};\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;\n\n/**\n * Build a Prismic REST API V2 URL to request documents from a repository. The\n * paginated response for this URL includes documents matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a\n * list of available refs.\n *\n * Type the JSON response with `Query`.\n *\n * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n * {@link https://prismic.io/docs/rest-api-technical-reference}\n *\n * @param endpoint - URL to the repository's REST API V2.\n * @param args - Arguments to filter and scope the query.\n *\n * @returns URL that can be used to request documents from the repository.\n */\nexport const buildQueryURL = (\n\tendpoint: string,\n\targs: BuildQueryURLArgs,\n): string => {\n\tconst { filters, predicates, ...params } = args;\n\n\tconst url = new URL(`documents/search`, `${endpoint}/`);\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`);\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`);\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] ||\n\t\t\tk) as ValidParamName;\n\n\t\tlet value = params[k as keyof typeof params];\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name];\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (\n\t\t\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t\t\ttypeof scopedValue === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\");\n\n\t\t\t\tvalue = `[${v}]`;\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]));\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(\n\t\t\t\tname,\n\t\t\t\tcastArray<string | number | Route | Ordering>(value).join(\",\"),\n\t\t\t);\n\t\t}\n\t}\n\n\treturn url.toString();\n};\n"],"names":[],"mappings":";;AA0OA,MAAM,iBAAiB;AAAA,EACtB,aAAa;;AAqBd,MAAM,uBAAuB,CAAC,aAAuC;AAEhE,MAAA,OAAO,aAAa,UAAU;AAC7B,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC3C,YAAM,CAAC,OAAO,SAAS,IAAI,SAAS,MAAM,GAAG;AAE7C,YAAM,aACL,cAAc,SACX,aAAa,KAAK,2BAClB,aAAa,KAAK;AAEtB,cAAQ,KACP,uJAAuJ,UAAU,2BAA2B,OAC3L,uCAAuC,CACvC,EAAE;AAAA,IAEL;AAEO,WAAA;AAAA,EACR;AAEA,SAAO,SAAS,cAAc,SAC3B,GAAG,SAAS,KAAK,UACjB,SAAS;AACb;AAqBa,MAAA,gBAAgB,CAC5B,UACA,SACW;AACX,QAAM,EAAE,SAAS,YAAY,GAAG,WAAW;AAE3C,QAAM,MAAM,IAAI,IAAI,oBAAoB,GAAG,QAAQ,GAAG;AAEtD,MAAI,SAAS;AAER,QAAA,QAAQ,IAAI,aAAa,iBAAiB,CAAC,MAAM,QAAQ,OAAO,GAAG;AACtE,cAAQ,KACP,4FAA4F,OAAO,8FAA8F,OAChM,0BAA0B,CAC1B,EAAE;AAAA,IAEL;AAGW,eAAA,UAAU,UAAU,OAAO,GAAG;AACxC,UAAI,aAAa,OAAO,KAAK,IAAI,MAAM,GAAG;AAAA,IAC3C;AAAA,EACD;AAGA,MAAI,YAAY;AACJ,eAAA,aAAa,UAAU,UAAU,GAAG;AAC9C,UAAI,aAAa,OAAO,KAAK,IAAI,SAAS,GAAG;AAAA,IAC9C;AAAA,EACD;AAIA,aAAW,KAAK,QAAQ;AACjB,UAAA,OAAQ,eAAe,CAAgC,KAC5D;AAEG,QAAA,QAAQ,OAAO,CAAwB;AAE3C,QAAI,SAAS,aAAa;AACnB,YAAA,cAAc,OAAO,IAAI;AAE/B,UAAI,eAAe,MAAM;AAExB,YACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,UACtB;AACD,kBAAQ,KACP,iLAAiL,OAChL,uCAAuC,CACvC,EAAE;AAAA,QAEL;AAEA,cAAM,IAAI,UAAU,WAAW,EAC7B,IAAI,CAAC,aAAa,qBAAqB,QAAQ,CAAC,EAChD,KAAK,GAAG;AAEV,gBAAQ,IAAI,CAAC;AAAA,MACd;AAAA,IAAA,WACU,SAAS,UAAU;AAC7B,UAAI,OAAO,OAAO,IAAI,MAAM,UAAU;AACrC,gBAAQ,KAAK,UAAU,UAAU,OAAO,IAAI,CAAC,CAAC;AAAA,MAC/C;AAAA,IACD;AAEA,QAAI,SAAS,MAAM;AACd,UAAA,aAAa,IAChB,MACA,UAA8C,KAAK,EAAE,KAAK,GAAG,CAAC;AAAA,IAEhE;AAAA,EACD;AAEA,SAAO,IAAI;AACZ;"}
1
+ {"version":3,"file":"buildQueryURL.js","sources":["../../src/buildQueryURL.ts"],"sourcesContent":["import { castArray } from \"./lib/castArray\"\nimport { devMsg } from \"./lib/devMsg\"\n\n/**\n * Create a union of the given object's values, and optionally specify which\n * keys to get the values from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType]\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string\n\tdirection?: \"asc\" | \"desc\"\n}\n\n/**\n * A `routes` parameter that determines how a document's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example With a document's UID field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * }\n * ```\n *\n * @example With a Content Relationship `parent` field.\n *\n * ```ts\n * {\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\t\"parent\": \"parent\"\n * \t}\n * }\n * ```\n */\nexport interface Route {\n\t/**\n\t * The custom type of the document.\n\t */\n\ttype: string\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only\n\t * defined for the document whose UID matches the given UID.\n\t */\n\tuid?: string\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is\n\t * only defined for documents whose language matches the given language.\n\t */\n\tlang?: string\n\n\t/**\n\t * The resolved path of the document with optional placeholders.\n\t */\n\tpath: string\n\n\t/**\n\t * An object that lists the API IDs of the Content Relationships in the route.\n\t */\n\tresolvers?: Record<string, string>\n}\n\n/**\n * Parameters for the Prismic REST API V2.\n *\n * {@link https://prismic.io/docs/api}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is\n\t * set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of documents that the\n\t * API will return for your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will\n\t * remove all the documents except for those after the specified document in\n\t * the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the\n\t * specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[]\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field\n\t * from a linked document and add it to the document response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[]\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve\n\t * and what content to retrieve from Linked Documents / Content\n\t * Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You\n\t * can specify as many fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of\n\t * `@prismicio/client@7.0.0`. Please migrate to the more explicit array of\n\t * objects.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * buildQueryURL(endpoint, {\n\t * \torderings: [\n\t * \t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t{ field: \"my.product.title\" },\n\t * \t],\n\t * })\n\t * ```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[]\n\n\t/**\n\t * The `routes` option allows you to define how a document's `url` field is\n\t * resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[]\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string\n}\n\n/**\n * Arguments for `buildQueryURL` to construct a Query URL.\n */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[]\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[]\n}\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API\n * V2 specification for better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const\n\n/**\n * A valid parameter name for the Prismic REST API V2.\n */\ntype ValidParamName =\n\t| Exclude<\n\t\t\tkeyof QueryParams,\n\t\t\tkeyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams\n\t >\n\t| ValueOf<typeof RENAMED_PARAMS>\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API.\n * If the value provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n *\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \")\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\"\n\t\t\t\t\t? `{ field: \"${field}\", direction: \"desc\" }`\n\t\t\t\t\t: `{ field: \"${field}\" }`\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\treturn ordering\n\t}\n\n\treturn ordering.direction === \"desc\"\n\t\t? `${ordering.field} desc`\n\t\t: ordering.field\n}\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams\n\n/**\n * Build a Prismic REST API V2 URL to request documents from a repository. The\n * paginated response for this URL includes documents matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a\n * list of available refs.\n *\n * Type the JSON response with `Query`.\n *\n * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n * {@link https://prismic.io/docs/rest-api-technical-reference}\n *\n * @param endpoint - URL to the repository's REST API V2.\n * @param args - Arguments to filter and scope the query.\n *\n * @returns URL that can be used to request documents from the repository.\n */\nexport const buildQueryURL = (\n\tendpoint: string,\n\targs: BuildQueryURLArgs,\n): string => {\n\tconst { filters, predicates, ...params } = args\n\n\tconst url = new URL(`documents/search`, `${endpoint}/`)\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`)\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`)\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] ||\n\t\t\tk) as ValidParamName\n\n\t\tlet value = params[k as keyof typeof params]\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name]\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (\n\t\t\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t\t\ttypeof scopedValue === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\")\n\n\t\t\t\tvalue = `[${v}]`\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]))\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(\n\t\t\t\tname,\n\t\t\t\tcastArray<string | number | Route | Ordering>(value).join(\",\"),\n\t\t\t)\n\t\t}\n\t}\n\n\treturn url.toString()\n}\n"],"names":[],"mappings":";;AA0OA,MAAM,iBAAiB;AAAA,EACtB,aAAa;;AAqBd,MAAM,uBAAuB,CAAC,aAAuC;AAEhE,MAAA,OAAO,aAAa,UAAU;AAC7B,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC3C,YAAM,CAAC,OAAO,SAAS,IAAI,SAAS,MAAM,GAAG;AAE7C,YAAM,aACL,cAAc,SACX,aAAa,KAAK,2BAClB,aAAa,KAAK;AAEtB,cAAQ,KACP,uJAAuJ,UAAU,2BAA2B,OAC3L,uCAAuC,CACvC,EAAE;AAAA,IAEL;AAEO,WAAA;AAAA,EACR;AAEA,SAAO,SAAS,cAAc,SAC3B,GAAG,SAAS,KAAK,UACjB,SAAS;AACb;AAqBa,MAAA,gBAAgB,CAC5B,UACA,SACW;AACX,QAAM,EAAE,SAAS,YAAY,GAAG,WAAW;AAE3C,QAAM,MAAM,IAAI,IAAI,oBAAoB,GAAG,QAAQ,GAAG;AAEtD,MAAI,SAAS;AAER,QAAA,QAAQ,IAAI,aAAa,iBAAiB,CAAC,MAAM,QAAQ,OAAO,GAAG;AACtE,cAAQ,KACP,4FAA4F,OAAO,8FAA8F,OAChM,0BAA0B,CAC1B,EAAE;AAAA,IAEL;AAGW,eAAA,UAAU,UAAU,OAAO,GAAG;AACxC,UAAI,aAAa,OAAO,KAAK,IAAI,MAAM,GAAG;AAAA,IAC3C;AAAA,EACD;AAGA,MAAI,YAAY;AACJ,eAAA,aAAa,UAAU,UAAU,GAAG;AAC9C,UAAI,aAAa,OAAO,KAAK,IAAI,SAAS,GAAG;AAAA,IAC9C;AAAA,EACD;AAIA,aAAW,KAAK,QAAQ;AACjB,UAAA,OAAQ,eAAe,CAAgC,KAC5D;AAEG,QAAA,QAAQ,OAAO,CAAwB;AAE3C,QAAI,SAAS,aAAa;AACnB,YAAA,cAAc,OAAO,IAAI;AAE/B,UAAI,eAAe,MAAM;AAExB,YACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,UACtB;AACD,kBAAQ,KACP,iLAAiL,OAChL,uCAAuC,CACvC,EAAE;AAAA,QAEL;AAEA,cAAM,IAAI,UAAU,WAAW,EAC7B,IAAI,CAAC,aAAa,qBAAqB,QAAQ,CAAC,EAChD,KAAK,GAAG;AAEV,gBAAQ,IAAI,CAAC;AAAA,MACd;AAAA,IAAA,WACU,SAAS,UAAU;AAC7B,UAAI,OAAO,OAAO,IAAI,MAAM,UAAU;AACrC,gBAAQ,KAAK,UAAU,UAAU,OAAO,IAAI,CAAC,CAAC;AAAA,MAC/C;AAAA,IACD;AAEA,QAAI,SAAS,MAAM;AACd,UAAA,aAAa,IAChB,MACA,UAA8C,KAAK,EAAE,KAAK,GAAG,CAAC;AAAA,IAEhE;AAAA,EACD;AAEA,SAAO,IAAI;AACZ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.cjs","sources":["../../src/cookie.ts"],"sourcesContent":["/**\n * The well-known name of the cookie used to store a Prismic preview session's\n * ref.\n */\nexport const preview = \"io.prismic.preview\";\n"],"names":[],"mappings":";;AAIO,MAAM,UAAU;;"}
1
+ {"version":3,"file":"cookie.cjs","sources":["../../src/cookie.ts"],"sourcesContent":["/**\n * The well-known name of the cookie used to store a Prismic preview session's\n * ref.\n */\nexport const preview = \"io.prismic.preview\"\n"],"names":[],"mappings":";;AAIO,MAAM,UAAU;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.js","sources":["../../src/cookie.ts"],"sourcesContent":["/**\n * The well-known name of the cookie used to store a Prismic preview session's\n * ref.\n */\nexport const preview = \"io.prismic.preview\";\n"],"names":[],"mappings":"AAIO,MAAM,UAAU;"}
1
+ {"version":3,"file":"cookie.js","sources":["../../src/cookie.ts"],"sourcesContent":["/**\n * The well-known name of the cookie used to store a Prismic preview session's\n * ref.\n */\nexport const preview = \"io.prismic.preview\"\n"],"names":[],"mappings":"AAIO,MAAM,UAAU;"}
@@ -162,7 +162,7 @@ class Client {
162
162
  * @example
163
163
  *
164
164
  * ```ts
165
- * client.enableAutoPreviews();
165
+ * client.enableAutoPreviews()
166
166
  * ```
167
167
  *
168
168
  * @see enableAutoPreviewsFromReq
@@ -182,8 +182,8 @@ class Client {
182
182
  * ```ts
183
183
  * // In an express app
184
184
  * app.get("/", function (req, res) {
185
- * client.enableAutoPreviewsFromReq(req);
186
- * });
185
+ * client.enableAutoPreviewsFromReq(req)
186
+ * })
187
187
  * ```
188
188
  *
189
189
  * @param req - An HTTP server request object containing the request's
@@ -203,7 +203,7 @@ class Client {
203
203
  * @example
204
204
  *
205
205
  * ```ts
206
- * client.disableAutoPreviews();
206
+ * client.disableAutoPreviews()
207
207
  * ```
208
208
  */
209
209
  disableAutoPreviews() {
@@ -215,7 +215,7 @@ class Client {
215
215
  * @example
216
216
  *
217
217
  * ```ts
218
- * const response = await client.get();
218
+ * const response = await client.get()
219
219
  * ```
220
220
  *
221
221
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -235,7 +235,7 @@ class Client {
235
235
  * @example
236
236
  *
237
237
  * ```ts
238
- * const document = await client.getFirst();
238
+ * const document = await client.getFirst()
239
239
  * ```
240
240
  *
241
241
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -271,7 +271,7 @@ class Client {
271
271
  * @example
272
272
  *
273
273
  * ```ts
274
- * const response = await client.dangerouslyGetAll();
274
+ * const response = await client.dangerouslyGetAll()
275
275
  * ```
276
276
  *
277
277
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -311,7 +311,7 @@ class Client {
311
311
  * @example
312
312
  *
313
313
  * ```ts
314
- * const document = await client.getByID("WW4bKScAAMAqmluX");
314
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
315
315
  * ```
316
316
  *
317
317
  * @typeParam TDocument- Type of the Prismic document returned.
@@ -340,7 +340,7 @@ class Client {
340
340
  * const response = await client.getByIDs([
341
341
  * "WW4bKScAAMAqmluX",
342
342
  * "U1kTRgEAAC8A5ldS",
343
- * ]);
343
+ * ])
344
344
  * ```
345
345
  *
346
346
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -372,7 +372,7 @@ class Client {
372
372
  * const response = await client.getAllByIDs([
373
373
  * "WW4bKScAAMAqmluX",
374
374
  * "U1kTRgEAAC8A5ldS",
375
- * ]);
375
+ * ])
376
376
  * ```
377
377
  *
378
378
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -398,7 +398,7 @@ class Client {
398
398
  * @example
399
399
  *
400
400
  * ```ts
401
- * const document = await client.getByUID("blog_post", "my-first-post");
401
+ * const document = await client.getByUID("blog_post", "my-first-post")
402
402
  * ```
403
403
  *
404
404
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -432,7 +432,7 @@ class Client {
432
432
  * const document = await client.getByUIDs("blog_post", [
433
433
  * "my-first-post",
434
434
  * "my-second-post",
435
- * ]);
435
+ * ])
436
436
  * ```
437
437
  *
438
438
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -469,7 +469,7 @@ class Client {
469
469
  * const response = await client.getAllByUIDs([
470
470
  * "my-first-post",
471
471
  * "my-second-post",
472
- * ]);
472
+ * ])
473
473
  * ```
474
474
  *
475
475
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -499,7 +499,7 @@ class Client {
499
499
  * @example
500
500
  *
501
501
  * ```ts
502
- * const document = await client.getSingle("settings");
502
+ * const document = await client.getSingle("settings")
503
503
  * ```
504
504
  *
505
505
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -522,7 +522,7 @@ class Client {
522
522
  * @example
523
523
  *
524
524
  * ```ts
525
- * const response = await client.getByType("blog_post");
525
+ * const response = await client.getByType("blog_post")
526
526
  * ```
527
527
  *
528
528
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -545,7 +545,7 @@ class Client {
545
545
  * @example
546
546
  *
547
547
  * ```ts
548
- * const response = await client.getByType("blog_post");
548
+ * const response = await client.getByType("blog_post")
549
549
  * ```
550
550
  *
551
551
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -567,7 +567,7 @@ class Client {
567
567
  * @example
568
568
  *
569
569
  * ```ts
570
- * const response = await client.getByTag("food");
570
+ * const response = await client.getByTag("food")
571
571
  * ```
572
572
  *
573
573
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -589,7 +589,7 @@ class Client {
589
589
  * @example
590
590
  *
591
591
  * ```ts
592
- * const response = await client.getAllByTag("food");
592
+ * const response = await client.getAllByTag("food")
593
593
  * ```
594
594
  *
595
595
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -609,7 +609,7 @@ class Client {
609
609
  * @example
610
610
  *
611
611
  * ```ts
612
- * const response = await client.getByEveryTag(["food", "fruit"]);
612
+ * const response = await client.getByEveryTag(["food", "fruit"])
613
613
  * ```
614
614
  *
615
615
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -632,7 +632,7 @@ class Client {
632
632
  * @example
633
633
  *
634
634
  * ```ts
635
- * const response = await client.getAllByEveryTag(["food", "fruit"]);
635
+ * const response = await client.getAllByEveryTag(["food", "fruit"])
636
636
  * ```
637
637
  *
638
638
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -653,7 +653,7 @@ class Client {
653
653
  * @example
654
654
  *
655
655
  * ```ts
656
- * const response = await client.getByEveryTag(["food", "fruit"]);
656
+ * const response = await client.getByEveryTag(["food", "fruit"])
657
657
  * ```
658
658
  *
659
659
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -678,7 +678,7 @@ class Client {
678
678
  * @example
679
679
  *
680
680
  * ```ts
681
- * const response = await client.getAllBySomeTags(["food", "fruit"]);
681
+ * const response = await client.getAllBySomeTags(["food", "fruit"])
682
682
  * ```
683
683
  *
684
684
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -880,8 +880,8 @@ class Client {
880
880
  * @example
881
881
  *
882
882
  * ```ts
883
- * await client.queryLatestContent();
884
- * const document = await client.getByID("WW4bKScAAMAqmluX");
883
+ * await client.queryLatestContent()
884
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
885
885
  * ```
886
886
  */
887
887
  queryLatestContent() {
@@ -897,8 +897,8 @@ class Client {
897
897
  * @example
898
898
  *
899
899
  * ```ts
900
- * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa");
901
- * const document = await client.getByID("WW4bKScAAMAqmluX");
900
+ * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa")
901
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
902
902
  * ```
903
903
  *
904
904
  * @param releaseID - The ID of the Release.
@@ -920,8 +920,8 @@ class Client {
920
920
  * @example
921
921
  *
922
922
  * ```ts
923
- * await client.queryContentFromReleaseByLabel("My Release");
924
- * const document = await client.getByID("WW4bKScAAMAqmluX");
923
+ * await client.queryContentFromReleaseByLabel("My Release")
924
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
925
925
  * ```
926
926
  *
927
927
  * @param releaseLabel - The label of the Release.
@@ -943,8 +943,8 @@ class Client {
943
943
  * @example
944
944
  *
945
945
  * ```ts
946
- * await client.queryContentFromRef("my-ref");
947
- * const document = await client.getByID("WW4bKScAAMAqmluX");
946
+ * await client.queryContentFromRef("my-ref")
947
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
948
948
  * ```
949
949
  *
950
950
  * @param ref - The ref or a function that returns the ref from which to query
@@ -975,7 +975,7 @@ class Client {
975
975
  * useGETForQueries: true,
976
976
  * }),
977
977
  * cache: new InMemoryCache(),
978
- * });
978
+ * })
979
979
  * ```
980
980
  *
981
981
  * @param input - The `fetch()` `input` parameter. Only strings are supported.