@prismicio/client 7.21.0-alpha.2 → 7.21.0-canary.147e3f2

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 (697) hide show
  1. package/dist/Client.cjs +926 -0
  2. package/dist/Client.cjs.map +1 -0
  3. package/dist/Client.d.cts +704 -0
  4. package/dist/Client.d.cts.map +1 -0
  5. package/dist/Client.d.ts +704 -0
  6. package/dist/Client.d.ts.map +1 -0
  7. package/dist/Client.js +926 -0
  8. package/dist/Client.js.map +1 -0
  9. package/dist/Migration.cjs +284 -0
  10. package/dist/Migration.cjs.map +1 -0
  11. package/dist/Migration.d.cts +216 -0
  12. package/dist/Migration.d.cts.map +1 -0
  13. package/dist/Migration.d.ts +216 -0
  14. package/dist/Migration.d.ts.map +1 -0
  15. package/dist/Migration.js +284 -0
  16. package/dist/Migration.js.map +1 -0
  17. package/dist/WriteClient.cjs +488 -0
  18. package/dist/WriteClient.cjs.map +1 -0
  19. package/dist/WriteClient.d.cts +262 -0
  20. package/dist/WriteClient.d.cts.map +1 -0
  21. package/dist/WriteClient.d.ts +262 -0
  22. package/dist/WriteClient.d.ts.map +1 -0
  23. package/dist/WriteClient.js +488 -0
  24. package/dist/WriteClient.js.map +1 -0
  25. package/dist/_virtual/rolldown_runtime.cjs +14 -0
  26. package/dist/_virtual/rolldown_runtime.js +13 -0
  27. package/dist/buildQueryURL.cjs +96 -0
  28. package/dist/buildQueryURL.cjs.map +1 -0
  29. package/dist/buildQueryURL.d.cts +212 -0
  30. package/dist/buildQueryURL.d.cts.map +1 -0
  31. package/dist/buildQueryURL.d.ts +212 -0
  32. package/dist/buildQueryURL.d.ts.map +1 -0
  33. package/dist/buildQueryURL.js +96 -0
  34. package/dist/buildQueryURL.js.map +1 -0
  35. package/dist/cookie.cjs +19 -0
  36. package/dist/cookie.cjs.map +1 -0
  37. package/dist/cookie.d.cts +11 -0
  38. package/dist/cookie.d.cts.map +1 -0
  39. package/dist/cookie.d.ts +11 -0
  40. package/dist/cookie.d.ts.map +1 -0
  41. package/dist/cookie.js +13 -0
  42. package/dist/cookie.js.map +1 -0
  43. package/dist/createClient.cjs +33 -0
  44. package/dist/createClient.cjs.map +1 -0
  45. package/dist/createClient.d.cts +41 -0
  46. package/dist/createClient.d.cts.map +1 -0
  47. package/dist/createClient.d.ts +41 -0
  48. package/dist/createClient.d.ts.map +1 -0
  49. package/dist/createClient.js +33 -0
  50. package/dist/createClient.js.map +1 -0
  51. package/dist/createMigration.cjs +22 -0
  52. package/dist/createMigration.cjs.map +1 -0
  53. package/dist/createMigration.d.cts +30 -0
  54. package/dist/createMigration.d.cts.map +1 -0
  55. package/dist/createMigration.d.ts +30 -0
  56. package/dist/createMigration.d.ts.map +1 -0
  57. package/dist/createMigration.js +22 -0
  58. package/dist/createMigration.js.map +1 -0
  59. package/dist/createWriteClient.cjs +30 -0
  60. package/dist/createWriteClient.cjs.map +1 -0
  61. package/dist/createWriteClient.d.cts +38 -0
  62. package/dist/createWriteClient.d.cts.map +1 -0
  63. package/dist/createWriteClient.d.ts +38 -0
  64. package/dist/createWriteClient.d.ts.map +1 -0
  65. package/dist/createWriteClient.js +30 -0
  66. package/dist/createWriteClient.js.map +1 -0
  67. package/dist/errors.cjs +31 -0
  68. package/dist/errors.cjs.map +1 -0
  69. package/dist/errors.d.cts +46 -0
  70. package/dist/errors.d.cts.map +1 -0
  71. package/dist/errors.d.ts +46 -0
  72. package/dist/errors.d.ts.map +1 -0
  73. package/dist/errors.js +22 -0
  74. package/dist/errors.js.map +1 -0
  75. package/dist/filter.cjs +104 -0
  76. package/dist/filter.cjs.map +1 -0
  77. package/dist/filter.d.cts +213 -0
  78. package/dist/filter.d.cts.map +1 -0
  79. package/dist/filter.d.ts +213 -0
  80. package/dist/filter.d.ts.map +1 -0
  81. package/dist/filter.js +103 -0
  82. package/dist/filter.js.map +1 -0
  83. package/dist/getGraphQLEndpoint.cjs +21 -0
  84. package/dist/getGraphQLEndpoint.cjs.map +1 -0
  85. package/dist/getGraphQLEndpoint.d.cts +14 -0
  86. package/dist/getGraphQLEndpoint.d.cts.map +1 -0
  87. package/dist/getGraphQLEndpoint.d.ts +14 -0
  88. package/dist/getGraphQLEndpoint.d.ts.map +1 -0
  89. package/dist/getGraphQLEndpoint.js +21 -0
  90. package/dist/getGraphQLEndpoint.js.map +1 -0
  91. package/dist/getRepositoryEndpoint.cjs +30 -0
  92. package/dist/getRepositoryEndpoint.cjs.map +1 -0
  93. package/dist/getRepositoryEndpoint.d.cts +23 -0
  94. package/dist/getRepositoryEndpoint.d.cts.map +1 -0
  95. package/dist/getRepositoryEndpoint.d.ts +23 -0
  96. package/dist/getRepositoryEndpoint.d.ts.map +1 -0
  97. package/dist/getRepositoryEndpoint.js +30 -0
  98. package/dist/getRepositoryEndpoint.js.map +1 -0
  99. package/dist/getRepositoryName.cjs +25 -0
  100. package/dist/getRepositoryName.cjs.map +1 -0
  101. package/dist/getRepositoryName.d.cts +16 -0
  102. package/dist/getRepositoryName.d.cts.map +1 -0
  103. package/dist/getRepositoryName.d.ts +16 -0
  104. package/dist/getRepositoryName.d.ts.map +1 -0
  105. package/dist/getRepositoryName.js +25 -0
  106. package/dist/getRepositoryName.js.map +1 -0
  107. package/dist/getToolbarSrc.cjs +45 -0
  108. package/dist/getToolbarSrc.cjs.map +1 -0
  109. package/dist/getToolbarSrc.d.cts +38 -0
  110. package/dist/getToolbarSrc.d.cts.map +1 -0
  111. package/dist/getToolbarSrc.d.ts +38 -0
  112. package/dist/getToolbarSrc.d.ts.map +1 -0
  113. package/dist/getToolbarSrc.js +45 -0
  114. package/dist/getToolbarSrc.js.map +1 -0
  115. package/dist/helpers/asDate.cjs +39 -0
  116. package/dist/helpers/asDate.cjs.map +1 -0
  117. package/dist/helpers/asDate.d.cts +29 -0
  118. package/dist/helpers/asDate.d.cts.map +1 -0
  119. package/dist/helpers/asDate.d.ts +29 -0
  120. package/dist/helpers/asDate.d.ts.map +1 -0
  121. package/dist/helpers/asDate.js +38 -0
  122. package/dist/helpers/asDate.js.map +1 -0
  123. package/dist/helpers/asHTML.cjs +83 -0
  124. package/dist/helpers/asHTML.cjs.map +1 -0
  125. package/dist/helpers/asHTML.d.cts +147 -0
  126. package/dist/helpers/asHTML.d.cts.map +1 -0
  127. package/dist/helpers/asHTML.d.ts +147 -0
  128. package/dist/helpers/asHTML.d.ts.map +1 -0
  129. package/dist/helpers/asHTML.js +83 -0
  130. package/dist/helpers/asHTML.js.map +1 -0
  131. package/dist/helpers/asImagePixelDensitySrcSet.cjs +60 -0
  132. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -0
  133. package/dist/helpers/asImagePixelDensitySrcSet.d.cts +59 -0
  134. package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -0
  135. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +59 -0
  136. package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -0
  137. package/dist/helpers/asImagePixelDensitySrcSet.js +60 -0
  138. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -0
  139. package/dist/helpers/asImageSrc.cjs +33 -0
  140. package/dist/helpers/asImageSrc.cjs.map +1 -0
  141. package/dist/helpers/asImageSrc.d.cts +34 -0
  142. package/dist/helpers/asImageSrc.d.cts.map +1 -0
  143. package/dist/helpers/asImageSrc.d.ts +34 -0
  144. package/dist/helpers/asImageSrc.d.ts.map +1 -0
  145. package/dist/helpers/asImageSrc.js +33 -0
  146. package/dist/helpers/asImageSrc.js.map +1 -0
  147. package/dist/helpers/asImageWidthSrcSet.cjs +79 -0
  148. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -0
  149. package/dist/helpers/asImageWidthSrcSet.d.cts +67 -0
  150. package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -0
  151. package/dist/helpers/asImageWidthSrcSet.d.ts +67 -0
  152. package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -0
  153. package/dist/helpers/asImageWidthSrcSet.js +79 -0
  154. package/dist/helpers/asImageWidthSrcSet.js.map +1 -0
  155. package/dist/helpers/asLink.cjs +29 -0
  156. package/dist/helpers/asLink.cjs.map +1 -0
  157. package/dist/helpers/asLink.d.cts +83 -0
  158. package/dist/helpers/asLink.d.cts.map +1 -0
  159. package/dist/helpers/asLink.d.ts +83 -0
  160. package/dist/helpers/asLink.d.ts.map +1 -0
  161. package/dist/helpers/asLink.js +29 -0
  162. package/dist/helpers/asLink.js.map +1 -0
  163. package/dist/helpers/asLinkAttrs.cjs +47 -0
  164. package/dist/helpers/asLinkAttrs.cjs.map +1 -0
  165. package/dist/helpers/asLinkAttrs.d.cts +51 -0
  166. package/dist/helpers/asLinkAttrs.d.cts.map +1 -0
  167. package/dist/helpers/asLinkAttrs.d.ts +51 -0
  168. package/dist/helpers/asLinkAttrs.d.ts.map +1 -0
  169. package/dist/helpers/asLinkAttrs.js +47 -0
  170. package/dist/helpers/asLinkAttrs.js.map +1 -0
  171. package/dist/helpers/asText.cjs +16 -0
  172. package/dist/helpers/asText.cjs.map +1 -0
  173. package/dist/helpers/asText.d.cts +62 -0
  174. package/dist/helpers/asText.d.cts.map +1 -0
  175. package/dist/helpers/asText.d.ts +62 -0
  176. package/dist/helpers/asText.d.ts.map +1 -0
  177. package/dist/helpers/asText.js +16 -0
  178. package/dist/helpers/asText.js.map +1 -0
  179. package/dist/helpers/documentToLinkField.cjs +33 -0
  180. package/dist/helpers/documentToLinkField.cjs.map +1 -0
  181. package/dist/helpers/documentToLinkField.d.cts +21 -0
  182. package/dist/helpers/documentToLinkField.d.cts.map +1 -0
  183. package/dist/helpers/documentToLinkField.d.ts +21 -0
  184. package/dist/helpers/documentToLinkField.d.ts.map +1 -0
  185. package/dist/helpers/documentToLinkField.js +33 -0
  186. package/dist/helpers/documentToLinkField.js.map +1 -0
  187. package/dist/helpers/isFilled.cjs +250 -0
  188. package/dist/helpers/isFilled.cjs.map +1 -0
  189. package/dist/helpers/isFilled.d.cts +199 -0
  190. package/dist/helpers/isFilled.d.cts.map +1 -0
  191. package/dist/helpers/isFilled.d.ts +199 -0
  192. package/dist/helpers/isFilled.d.ts.map +1 -0
  193. package/dist/helpers/isFilled.js +243 -0
  194. package/dist/helpers/isFilled.js.map +1 -0
  195. package/dist/helpers/mapSliceZone.cjs +53 -0
  196. package/dist/helpers/mapSliceZone.cjs.map +1 -0
  197. package/dist/helpers/mapSliceZone.d.cts +139 -0
  198. package/dist/helpers/mapSliceZone.d.cts.map +1 -0
  199. package/dist/helpers/mapSliceZone.d.ts +139 -0
  200. package/dist/helpers/mapSliceZone.d.ts.map +1 -0
  201. package/dist/helpers/mapSliceZone.js +52 -0
  202. package/dist/helpers/mapSliceZone.js.map +1 -0
  203. package/dist/index.cjs +109 -3882
  204. package/dist/index.cjs.map +1 -1
  205. package/dist/index.d.cts +143 -4394
  206. package/dist/index.d.cts.map +1 -0
  207. package/dist/index.d.ts +143 -4394
  208. package/dist/index.d.ts.map +1 -0
  209. package/dist/index.js +55 -0
  210. package/dist/index.js.map +1 -0
  211. package/dist/isRepositoryEndpoint.cjs +23 -0
  212. package/dist/isRepositoryEndpoint.cjs.map +1 -0
  213. package/dist/isRepositoryEndpoint.d.cts +14 -0
  214. package/dist/isRepositoryEndpoint.d.cts.map +1 -0
  215. package/dist/isRepositoryEndpoint.d.ts +14 -0
  216. package/dist/isRepositoryEndpoint.d.ts.map +1 -0
  217. package/dist/isRepositoryEndpoint.js +22 -0
  218. package/dist/isRepositoryEndpoint.js.map +1 -0
  219. package/dist/isRepositoryName.cjs +17 -0
  220. package/dist/isRepositoryName.cjs.map +1 -0
  221. package/dist/isRepositoryName.d.cts +13 -0
  222. package/dist/isRepositoryName.d.cts.map +1 -0
  223. package/dist/isRepositoryName.d.ts +13 -0
  224. package/dist/isRepositoryName.d.ts.map +1 -0
  225. package/dist/isRepositoryName.js +16 -0
  226. package/dist/isRepositoryName.js.map +1 -0
  227. package/dist/lib/devMsg.cjs +25 -0
  228. package/dist/lib/devMsg.cjs.map +1 -0
  229. package/dist/lib/devMsg.js +25 -0
  230. package/dist/lib/devMsg.js.map +1 -0
  231. package/dist/lib/escapeHTML.cjs +40 -0
  232. package/dist/lib/escapeHTML.cjs.map +1 -0
  233. package/dist/lib/escapeHTML.js +39 -0
  234. package/dist/lib/escapeHTML.js.map +1 -0
  235. package/dist/lib/getOptionalLinkProperties.cjs +22 -0
  236. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -0
  237. package/dist/lib/getOptionalLinkProperties.js +21 -0
  238. package/dist/lib/getOptionalLinkProperties.js.map +1 -0
  239. package/dist/lib/getPreviewCookie.cjs +30 -0
  240. package/dist/lib/getPreviewCookie.cjs.map +1 -0
  241. package/dist/lib/getPreviewCookie.js +30 -0
  242. package/dist/lib/getPreviewCookie.js.map +1 -0
  243. package/dist/lib/isInternalURL.cjs +18 -0
  244. package/dist/lib/isInternalURL.cjs.map +1 -0
  245. package/dist/lib/isInternalURL.js +17 -0
  246. package/dist/lib/isInternalURL.js.map +1 -0
  247. package/dist/lib/isMigrationValue.cjs +77 -0
  248. package/dist/lib/isMigrationValue.cjs.map +1 -0
  249. package/dist/lib/isMigrationValue.js +74 -0
  250. package/dist/lib/isMigrationValue.js.map +1 -0
  251. package/dist/lib/isValue.cjs +110 -0
  252. package/dist/lib/isValue.cjs.map +1 -0
  253. package/dist/lib/isValue.js +106 -0
  254. package/dist/lib/isValue.js.map +1 -0
  255. package/dist/lib/pLimit.cjs +55 -0
  256. package/dist/lib/pLimit.cjs.map +1 -0
  257. package/dist/lib/pLimit.js +54 -0
  258. package/dist/lib/pLimit.js.map +1 -0
  259. package/dist/lib/request.cjs +60 -0
  260. package/dist/lib/request.cjs.map +1 -0
  261. package/dist/lib/request.d.cts +61 -0
  262. package/dist/lib/request.d.cts.map +1 -0
  263. package/dist/lib/request.d.ts +61 -0
  264. package/dist/lib/request.d.ts.map +1 -0
  265. package/dist/lib/request.js +60 -0
  266. package/dist/lib/request.js.map +1 -0
  267. package/dist/lib/resolveMigrationDocumentData.cjs +156 -0
  268. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -0
  269. package/dist/lib/resolveMigrationDocumentData.js +155 -0
  270. package/dist/lib/resolveMigrationDocumentData.js.map +1 -0
  271. package/dist/lib/serializerHelpers.cjs +95 -0
  272. package/dist/lib/serializerHelpers.cjs.map +1 -0
  273. package/dist/lib/serializerHelpers.js +90 -0
  274. package/dist/lib/serializerHelpers.js.map +1 -0
  275. package/dist/lib/throttledWarn.cjs +27 -0
  276. package/dist/lib/throttledWarn.cjs.map +1 -0
  277. package/dist/lib/throttledWarn.js +26 -0
  278. package/dist/lib/throttledWarn.js.map +1 -0
  279. package/dist/lib/validateAssetMetadata.cjs +48 -0
  280. package/dist/lib/validateAssetMetadata.cjs.map +1 -0
  281. package/dist/lib/validateAssetMetadata.js +48 -0
  282. package/dist/lib/validateAssetMetadata.js.map +1 -0
  283. package/dist/package.cjs +19 -0
  284. package/dist/package.cjs.map +1 -0
  285. package/dist/package.js +7 -0
  286. package/dist/package.js.map +1 -0
  287. package/dist/richtext/asText.cjs +21 -0
  288. package/dist/richtext/asText.cjs.map +1 -0
  289. package/dist/richtext/asText.d.cts +18 -0
  290. package/dist/richtext/asText.d.cts.map +1 -0
  291. package/dist/richtext/asText.d.ts +18 -0
  292. package/dist/richtext/asText.d.ts.map +1 -0
  293. package/dist/richtext/asText.js +20 -0
  294. package/dist/richtext/asText.js.map +1 -0
  295. package/dist/richtext/asTree.cjs +122 -0
  296. package/dist/richtext/asTree.cjs.map +1 -0
  297. package/dist/richtext/asTree.d.cts +20 -0
  298. package/dist/richtext/asTree.d.cts.map +1 -0
  299. package/dist/richtext/asTree.d.ts +20 -0
  300. package/dist/richtext/asTree.d.ts.map +1 -0
  301. package/dist/richtext/asTree.js +122 -0
  302. package/dist/richtext/asTree.js.map +1 -0
  303. package/dist/richtext/composeSerializers.cjs +31 -0
  304. package/dist/richtext/composeSerializers.cjs.map +1 -0
  305. package/dist/richtext/composeSerializers.d.cts +22 -0
  306. package/dist/richtext/composeSerializers.d.cts.map +1 -0
  307. package/dist/richtext/composeSerializers.d.ts +22 -0
  308. package/dist/richtext/composeSerializers.d.ts.map +1 -0
  309. package/dist/richtext/composeSerializers.js +30 -0
  310. package/dist/richtext/composeSerializers.js.map +1 -0
  311. package/dist/richtext/serialize.cjs +35 -0
  312. package/dist/richtext/serialize.cjs.map +1 -0
  313. package/dist/richtext/serialize.d.cts +25 -0
  314. package/dist/richtext/serialize.d.cts.map +1 -0
  315. package/dist/richtext/serialize.d.ts +25 -0
  316. package/dist/richtext/serialize.d.ts.map +1 -0
  317. package/dist/richtext/serialize.js +35 -0
  318. package/dist/richtext/serialize.js.map +1 -0
  319. package/dist/richtext/types.cjs +13 -0
  320. package/dist/richtext/types.cjs.map +1 -0
  321. package/dist/richtext/types.d.cts +71 -0
  322. package/dist/richtext/types.d.cts.map +1 -0
  323. package/dist/richtext/types.d.ts +71 -0
  324. package/dist/richtext/types.d.ts.map +1 -0
  325. package/dist/richtext/types.js +13 -0
  326. package/dist/richtext/types.js.map +1 -0
  327. package/dist/richtext/wrapMapSerializer.cjs +32 -0
  328. package/dist/richtext/wrapMapSerializer.cjs.map +1 -0
  329. package/dist/richtext/wrapMapSerializer.d.cts +21 -0
  330. package/dist/richtext/wrapMapSerializer.d.cts.map +1 -0
  331. package/dist/richtext/wrapMapSerializer.d.ts +21 -0
  332. package/dist/richtext/wrapMapSerializer.d.ts.map +1 -0
  333. package/dist/richtext/wrapMapSerializer.js +32 -0
  334. package/dist/richtext/wrapMapSerializer.js.map +1 -0
  335. package/dist/richtext.cjs +13 -0
  336. package/dist/richtext.d.cts +8 -0
  337. package/dist/richtext.d.ts +8 -0
  338. package/dist/richtext.js +8 -0
  339. package/dist/types/api/asset/asset.d.cts +97 -0
  340. package/dist/types/api/asset/asset.d.cts.map +1 -0
  341. package/dist/types/api/asset/asset.d.ts +97 -0
  342. package/dist/types/api/asset/asset.d.ts.map +1 -0
  343. package/dist/types/api/asset/tag.d.cts +35 -0
  344. package/dist/types/api/asset/tag.d.cts.map +1 -0
  345. package/dist/types/api/asset/tag.d.ts +35 -0
  346. package/dist/types/api/asset/tag.d.ts.map +1 -0
  347. package/dist/types/api/integration.d.cts +34 -0
  348. package/dist/types/api/integration.d.cts.map +1 -0
  349. package/dist/types/api/integration.d.ts +34 -0
  350. package/dist/types/api/integration.d.ts.map +1 -0
  351. package/dist/types/api/query.d.cts +49 -0
  352. package/dist/types/api/query.d.cts.map +1 -0
  353. package/dist/types/api/query.d.ts +49 -0
  354. package/dist/types/api/query.d.ts.map +1 -0
  355. package/dist/types/api/ref.d.cts +36 -0
  356. package/dist/types/api/ref.d.cts.map +1 -0
  357. package/dist/types/api/ref.d.ts +36 -0
  358. package/dist/types/api/ref.d.ts.map +1 -0
  359. package/dist/types/api/release.d.cts +17 -0
  360. package/dist/types/api/release.d.cts.map +1 -0
  361. package/dist/types/api/release.d.ts +17 -0
  362. package/dist/types/api/release.d.ts.map +1 -0
  363. package/dist/types/api/repository.d.cts +115 -0
  364. package/dist/types/api/repository.d.cts.map +1 -0
  365. package/dist/types/api/repository.d.ts +115 -0
  366. package/dist/types/api/repository.d.ts.map +1 -0
  367. package/dist/types/api/tags.d.cts +13 -0
  368. package/dist/types/api/tags.d.cts.map +1 -0
  369. package/dist/types/api/tags.d.ts +13 -0
  370. package/dist/types/api/tags.d.ts.map +1 -0
  371. package/dist/types/migration/Asset.cjs +35 -0
  372. package/dist/types/migration/Asset.cjs.map +1 -0
  373. package/dist/types/migration/Asset.d.cts +109 -0
  374. package/dist/types/migration/Asset.d.cts.map +1 -0
  375. package/dist/types/migration/Asset.d.ts +109 -0
  376. package/dist/types/migration/Asset.d.ts.map +1 -0
  377. package/dist/types/migration/Asset.js +34 -0
  378. package/dist/types/migration/Asset.js.map +1 -0
  379. package/dist/types/migration/ContentRelationship.d.cts +15 -0
  380. package/dist/types/migration/ContentRelationship.d.cts.map +1 -0
  381. package/dist/types/migration/ContentRelationship.d.ts +15 -0
  382. package/dist/types/migration/ContentRelationship.d.ts.map +1 -0
  383. package/dist/types/migration/Document.cjs +51 -0
  384. package/dist/types/migration/Document.cjs.map +1 -0
  385. package/dist/types/migration/Document.d.cts +97 -0
  386. package/dist/types/migration/Document.d.cts.map +1 -0
  387. package/dist/types/migration/Document.d.ts +97 -0
  388. package/dist/types/migration/Document.d.ts.map +1 -0
  389. package/dist/types/migration/Document.js +50 -0
  390. package/dist/types/migration/Document.js.map +1 -0
  391. package/dist/types/model/boolean.d.cts +21 -0
  392. package/dist/types/model/boolean.d.cts.map +1 -0
  393. package/dist/types/model/boolean.d.ts +21 -0
  394. package/dist/types/model/boolean.d.ts.map +1 -0
  395. package/dist/types/model/color.d.cts +19 -0
  396. package/dist/types/model/color.d.cts.map +1 -0
  397. package/dist/types/model/color.d.ts +19 -0
  398. package/dist/types/model/color.d.ts.map +1 -0
  399. package/dist/types/model/contentRelationship.d.cts +59 -0
  400. package/dist/types/model/contentRelationship.d.cts.map +1 -0
  401. package/dist/types/model/contentRelationship.d.ts +59 -0
  402. package/dist/types/model/contentRelationship.d.ts.map +1 -0
  403. package/dist/types/model/customType.d.cts +54 -0
  404. package/dist/types/model/customType.d.cts.map +1 -0
  405. package/dist/types/model/customType.d.ts +54 -0
  406. package/dist/types/model/customType.d.ts.map +1 -0
  407. package/dist/types/model/date.d.cts +20 -0
  408. package/dist/types/model/date.d.cts.map +1 -0
  409. package/dist/types/model/date.d.ts +20 -0
  410. package/dist/types/model/date.d.ts.map +1 -0
  411. package/dist/types/model/embed.d.cts +19 -0
  412. package/dist/types/model/embed.d.cts.map +1 -0
  413. package/dist/types/model/embed.d.ts +19 -0
  414. package/dist/types/model/embed.d.ts.map +1 -0
  415. package/dist/types/model/geoPoint.d.cts +18 -0
  416. package/dist/types/model/geoPoint.d.cts.map +1 -0
  417. package/dist/types/model/geoPoint.d.ts +18 -0
  418. package/dist/types/model/geoPoint.d.ts.map +1 -0
  419. package/dist/types/model/group.d.cts +29 -0
  420. package/dist/types/model/group.d.cts.map +1 -0
  421. package/dist/types/model/group.d.ts +29 -0
  422. package/dist/types/model/group.d.ts.map +1 -0
  423. package/dist/types/model/image.d.cts +37 -0
  424. package/dist/types/model/image.d.cts.map +1 -0
  425. package/dist/types/model/image.d.ts +37 -0
  426. package/dist/types/model/image.d.ts.map +1 -0
  427. package/dist/types/model/integration.d.cts +20 -0
  428. package/dist/types/model/integration.d.cts.map +1 -0
  429. package/dist/types/model/integration.d.ts +20 -0
  430. package/dist/types/model/integration.d.ts.map +1 -0
  431. package/dist/types/model/keyText.d.cts +19 -0
  432. package/dist/types/model/keyText.d.cts.map +1 -0
  433. package/dist/types/model/keyText.d.ts +19 -0
  434. package/dist/types/model/keyText.d.ts.map +1 -0
  435. package/dist/types/model/link.cjs +16 -0
  436. package/dist/types/model/link.cjs.map +1 -0
  437. package/dist/types/model/link.d.cts +34 -0
  438. package/dist/types/model/link.d.cts.map +1 -0
  439. package/dist/types/model/link.d.ts +34 -0
  440. package/dist/types/model/link.d.ts.map +1 -0
  441. package/dist/types/model/link.js +15 -0
  442. package/dist/types/model/link.js.map +1 -0
  443. package/dist/types/model/linkToMedia.d.cts +23 -0
  444. package/dist/types/model/linkToMedia.d.cts.map +1 -0
  445. package/dist/types/model/linkToMedia.d.ts +23 -0
  446. package/dist/types/model/linkToMedia.d.ts.map +1 -0
  447. package/dist/types/model/number.d.cts +21 -0
  448. package/dist/types/model/number.d.cts.map +1 -0
  449. package/dist/types/model/number.d.ts +21 -0
  450. package/dist/types/model/number.d.ts.map +1 -0
  451. package/dist/types/model/range.d.cts +20 -0
  452. package/dist/types/model/range.d.cts.map +1 -0
  453. package/dist/types/model/range.d.ts +20 -0
  454. package/dist/types/model/range.d.ts.map +1 -0
  455. package/dist/types/model/richText.d.cts +43 -0
  456. package/dist/types/model/richText.d.cts.map +1 -0
  457. package/dist/types/model/richText.d.ts +43 -0
  458. package/dist/types/model/richText.d.ts.map +1 -0
  459. package/dist/types/model/select.d.cts +24 -0
  460. package/dist/types/model/select.d.cts.map +1 -0
  461. package/dist/types/model/select.d.ts +24 -0
  462. package/dist/types/model/select.d.ts.map +1 -0
  463. package/dist/types/model/separator.d.cts +16 -0
  464. package/dist/types/model/separator.d.cts.map +1 -0
  465. package/dist/types/model/separator.d.ts +16 -0
  466. package/dist/types/model/separator.d.ts.map +1 -0
  467. package/dist/types/model/sharedSlice.d.cts +22 -0
  468. package/dist/types/model/sharedSlice.d.cts.map +1 -0
  469. package/dist/types/model/sharedSlice.d.ts +22 -0
  470. package/dist/types/model/sharedSlice.d.ts.map +1 -0
  471. package/dist/types/model/sharedSliceVariation.d.cts +25 -0
  472. package/dist/types/model/sharedSliceVariation.d.cts.map +1 -0
  473. package/dist/types/model/sharedSliceVariation.d.ts +25 -0
  474. package/dist/types/model/sharedSliceVariation.d.ts.map +1 -0
  475. package/dist/types/model/slice.cjs +15 -0
  476. package/dist/types/model/slice.cjs.map +1 -0
  477. package/dist/types/model/slice.d.cts +39 -0
  478. package/dist/types/model/slice.d.cts.map +1 -0
  479. package/dist/types/model/slice.d.ts +39 -0
  480. package/dist/types/model/slice.d.ts.map +1 -0
  481. package/dist/types/model/slice.js +14 -0
  482. package/dist/types/model/slice.js.map +1 -0
  483. package/dist/types/model/sliceZone.cjs +15 -0
  484. package/dist/types/model/sliceZone.cjs.map +1 -0
  485. package/dist/types/model/sliceZone.d.cts +47 -0
  486. package/dist/types/model/sliceZone.d.cts.map +1 -0
  487. package/dist/types/model/sliceZone.d.ts +47 -0
  488. package/dist/types/model/sliceZone.d.ts.map +1 -0
  489. package/dist/types/model/sliceZone.js +14 -0
  490. package/dist/types/model/sliceZone.js.map +1 -0
  491. package/dist/types/model/table.d.cts +18 -0
  492. package/dist/types/model/table.d.cts.map +1 -0
  493. package/dist/types/model/table.d.ts +18 -0
  494. package/dist/types/model/table.d.ts.map +1 -0
  495. package/dist/types/model/timestamp.d.cts +20 -0
  496. package/dist/types/model/timestamp.d.cts.map +1 -0
  497. package/dist/types/model/timestamp.d.ts +20 -0
  498. package/dist/types/model/timestamp.d.ts.map +1 -0
  499. package/dist/types/model/title.d.cts +13 -0
  500. package/dist/types/model/title.d.cts.map +1 -0
  501. package/dist/types/model/title.d.ts +13 -0
  502. package/dist/types/model/title.d.ts.map +1 -0
  503. package/dist/types/model/types.cjs +32 -0
  504. package/dist/types/model/types.cjs.map +1 -0
  505. package/dist/types/model/types.d.cts +82 -0
  506. package/dist/types/model/types.d.cts.map +1 -0
  507. package/dist/types/model/types.d.ts +82 -0
  508. package/dist/types/model/types.d.ts.map +1 -0
  509. package/dist/types/model/types.js +31 -0
  510. package/dist/types/model/types.js.map +1 -0
  511. package/dist/types/model/uid.d.cts +19 -0
  512. package/dist/types/model/uid.d.cts.map +1 -0
  513. package/dist/types/model/uid.d.ts +19 -0
  514. package/dist/types/model/uid.d.ts.map +1 -0
  515. package/dist/types/value/boolean.d.cts +10 -0
  516. package/dist/types/value/boolean.d.cts.map +1 -0
  517. package/dist/types/value/boolean.d.ts +10 -0
  518. package/dist/types/value/boolean.d.ts.map +1 -0
  519. package/dist/types/value/color.d.cts +15 -0
  520. package/dist/types/value/color.d.cts.map +1 -0
  521. package/dist/types/value/color.d.ts +15 -0
  522. package/dist/types/value/color.d.ts.map +1 -0
  523. package/dist/types/value/contentRelationship.d.cts +37 -0
  524. package/dist/types/value/contentRelationship.d.cts.map +1 -0
  525. package/dist/types/value/contentRelationship.d.ts +37 -0
  526. package/dist/types/value/contentRelationship.d.ts.map +1 -0
  527. package/dist/types/value/date.d.cts +15 -0
  528. package/dist/types/value/date.d.cts.map +1 -0
  529. package/dist/types/value/date.d.ts +15 -0
  530. package/dist/types/value/date.d.ts.map +1 -0
  531. package/dist/types/value/document.d.cts +120 -0
  532. package/dist/types/value/document.d.cts.map +1 -0
  533. package/dist/types/value/document.d.ts +120 -0
  534. package/dist/types/value/document.d.ts.map +1 -0
  535. package/dist/types/value/embed.cjs +17 -0
  536. package/dist/types/value/embed.cjs.map +1 -0
  537. package/dist/types/value/embed.d.cts +173 -0
  538. package/dist/types/value/embed.d.cts.map +1 -0
  539. package/dist/types/value/embed.d.ts +173 -0
  540. package/dist/types/value/embed.d.ts.map +1 -0
  541. package/dist/types/value/embed.js +16 -0
  542. package/dist/types/value/embed.js.map +1 -0
  543. package/dist/types/value/geoPoint.d.cts +18 -0
  544. package/dist/types/value/geoPoint.d.cts.map +1 -0
  545. package/dist/types/value/geoPoint.d.ts +18 -0
  546. package/dist/types/value/geoPoint.d.ts.map +1 -0
  547. package/dist/types/value/group.d.cts +19 -0
  548. package/dist/types/value/group.d.cts.map +1 -0
  549. package/dist/types/value/group.d.ts +19 -0
  550. package/dist/types/value/group.d.ts.map +1 -0
  551. package/dist/types/value/image.d.cts +53 -0
  552. package/dist/types/value/image.d.cts.map +1 -0
  553. package/dist/types/value/image.d.ts +53 -0
  554. package/dist/types/value/image.d.ts.map +1 -0
  555. package/dist/types/value/integration.d.cts +22 -0
  556. package/dist/types/value/integration.d.cts.map +1 -0
  557. package/dist/types/value/integration.d.ts +22 -0
  558. package/dist/types/value/integration.d.ts.map +1 -0
  559. package/dist/types/value/keyText.d.cts +15 -0
  560. package/dist/types/value/keyText.d.cts.map +1 -0
  561. package/dist/types/value/keyText.d.ts +15 -0
  562. package/dist/types/value/keyText.d.ts.map +1 -0
  563. package/dist/types/value/link.cjs +15 -0
  564. package/dist/types/value/link.cjs.map +1 -0
  565. package/dist/types/value/link.d.cts +74 -0
  566. package/dist/types/value/link.d.cts.map +1 -0
  567. package/dist/types/value/link.d.ts +74 -0
  568. package/dist/types/value/link.d.ts.map +1 -0
  569. package/dist/types/value/link.js +14 -0
  570. package/dist/types/value/link.js.map +1 -0
  571. package/dist/types/value/linkToMedia.d.cts +33 -0
  572. package/dist/types/value/linkToMedia.d.cts.map +1 -0
  573. package/dist/types/value/linkToMedia.d.ts +33 -0
  574. package/dist/types/value/linkToMedia.d.ts.map +1 -0
  575. package/dist/types/value/number.d.cts +15 -0
  576. package/dist/types/value/number.d.cts.map +1 -0
  577. package/dist/types/value/number.d.ts +15 -0
  578. package/dist/types/value/number.d.ts.map +1 -0
  579. package/dist/types/value/richText.cjs +32 -0
  580. package/dist/types/value/richText.cjs.map +1 -0
  581. package/dist/types/value/richText.d.cts +221 -0
  582. package/dist/types/value/richText.d.cts.map +1 -0
  583. package/dist/types/value/richText.d.ts +221 -0
  584. package/dist/types/value/richText.d.ts.map +1 -0
  585. package/dist/types/value/richText.js +31 -0
  586. package/dist/types/value/richText.js.map +1 -0
  587. package/dist/types/value/select.d.cts +16 -0
  588. package/dist/types/value/select.d.cts.map +1 -0
  589. package/dist/types/value/select.d.ts +16 -0
  590. package/dist/types/value/select.d.ts.map +1 -0
  591. package/dist/types/value/sharedSlice.d.cts +17 -0
  592. package/dist/types/value/sharedSlice.d.cts.map +1 -0
  593. package/dist/types/value/sharedSlice.d.ts +17 -0
  594. package/dist/types/value/sharedSlice.d.ts.map +1 -0
  595. package/dist/types/value/sharedSliceVariation.d.cts +16 -0
  596. package/dist/types/value/sharedSliceVariation.d.cts.map +1 -0
  597. package/dist/types/value/sharedSliceVariation.d.ts +16 -0
  598. package/dist/types/value/sharedSliceVariation.d.ts.map +1 -0
  599. package/dist/types/value/slice.d.cts +19 -0
  600. package/dist/types/value/slice.d.cts.map +1 -0
  601. package/dist/types/value/slice.d.ts +19 -0
  602. package/dist/types/value/slice.d.ts.map +1 -0
  603. package/dist/types/value/sliceZone.d.cts +18 -0
  604. package/dist/types/value/sliceZone.d.cts.map +1 -0
  605. package/dist/types/value/sliceZone.d.ts +18 -0
  606. package/dist/types/value/sliceZone.d.ts.map +1 -0
  607. package/dist/types/value/table.d.cts +97 -0
  608. package/dist/types/value/table.d.cts.map +1 -0
  609. package/dist/types/value/table.d.ts +97 -0
  610. package/dist/types/value/table.d.ts.map +1 -0
  611. package/dist/types/value/timestamp.d.cts +13 -0
  612. package/dist/types/value/timestamp.d.cts.map +1 -0
  613. package/dist/types/value/timestamp.d.ts +13 -0
  614. package/dist/types/value/timestamp.d.ts.map +1 -0
  615. package/dist/types/value/title.d.cts +16 -0
  616. package/dist/types/value/title.d.cts.map +1 -0
  617. package/dist/types/value/title.d.ts +16 -0
  618. package/dist/types/value/title.d.ts.map +1 -0
  619. package/dist/types/value/types.d.cts +61 -0
  620. package/dist/types/value/types.d.cts.map +1 -0
  621. package/dist/types/value/types.d.ts +61 -0
  622. package/dist/types/value/types.d.ts.map +1 -0
  623. package/dist/types/webhook/apiUpdate.d.cts +57 -0
  624. package/dist/types/webhook/apiUpdate.d.cts.map +1 -0
  625. package/dist/types/webhook/apiUpdate.d.ts +57 -0
  626. package/dist/types/webhook/apiUpdate.d.ts.map +1 -0
  627. package/dist/types/webhook/testTrigger.d.cts +15 -0
  628. package/dist/types/webhook/testTrigger.d.cts.map +1 -0
  629. package/dist/types/webhook/testTrigger.d.ts +15 -0
  630. package/dist/types/webhook/testTrigger.d.ts.map +1 -0
  631. package/dist/types/webhook/types.cjs +15 -0
  632. package/dist/types/webhook/types.cjs.map +1 -0
  633. package/dist/types/webhook/types.d.cts +23 -0
  634. package/dist/types/webhook/types.d.cts.map +1 -0
  635. package/dist/types/webhook/types.d.ts +23 -0
  636. package/dist/types/webhook/types.d.ts.map +1 -0
  637. package/dist/types/webhook/types.js +14 -0
  638. package/dist/types/webhook/types.js.map +1 -0
  639. package/package.json +29 -35
  640. package/src/Client.ts +682 -1028
  641. package/src/WriteClient.ts +44 -46
  642. package/src/buildQueryURL.ts +14 -20
  643. package/src/createClient.ts +1 -1
  644. package/src/errors.ts +94 -0
  645. package/src/getGraphQLEndpoint.ts +1 -1
  646. package/src/getRepositoryEndpoint.ts +1 -1
  647. package/src/getRepositoryName.ts +1 -1
  648. package/src/getToolbarSrc.ts +1 -1
  649. package/src/helpers/asHTML.ts +4 -4
  650. package/src/helpers/asImageWidthSrcSet.ts +1 -5
  651. package/src/helpers/asLink.ts +0 -3
  652. package/src/helpers/asLinkAttrs.ts +0 -4
  653. package/src/helpers/mapSliceZone.ts +5 -5
  654. package/src/index.ts +11 -8
  655. package/src/lib/isValue.ts +0 -6
  656. package/src/lib/pLimit.ts +1 -1
  657. package/src/lib/request.ts +3 -3
  658. package/src/lib/{throttledLog.ts → throttledWarn.ts} +3 -14
  659. package/src/lib/validateAssetMetadata.ts +1 -1
  660. package/src/types/migration/Document.ts +1 -1
  661. package/src/types/model/contentRelationship.ts +1 -0
  662. package/src/types/value/date.ts +1 -1
  663. package/src/types/value/document.ts +3 -3
  664. package/src/types/value/timestamp.ts +1 -5
  665. package/dist/index.d.mts +0 -4424
  666. package/dist/index.mjs +0 -3837
  667. package/dist/index.mjs.map +0 -1
  668. package/dist/richtext/index.cjs +0 -244
  669. package/dist/richtext/index.cjs.map +0 -1
  670. package/dist/richtext/index.d.cts +0 -78
  671. package/dist/richtext/index.d.mts +0 -78
  672. package/dist/richtext/index.d.ts +0 -78
  673. package/dist/richtext/index.mjs +0 -237
  674. package/dist/richtext/index.mjs.map +0 -1
  675. package/dist/shared/client.TSGr56lO.d.cts +0 -899
  676. package/dist/shared/client.TSGr56lO.d.mts +0 -899
  677. package/dist/shared/client.TSGr56lO.d.ts +0 -899
  678. package/src/errors/ForbiddenError.ts +0 -16
  679. package/src/errors/InvalidDataError.ts +0 -5
  680. package/src/errors/NotFoundError.ts +0 -5
  681. package/src/errors/ParsingError.ts +0 -16
  682. package/src/errors/PreviewTokenExpired.ts +0 -12
  683. package/src/errors/PrismicError.ts +0 -15
  684. package/src/errors/RefExpiredError.ts +0 -14
  685. package/src/errors/RefNotFoundError.ts +0 -14
  686. package/src/errors/RepositoryNotFoundError.ts +0 -5
  687. package/src/lib/appendFilters.ts +0 -26
  688. package/src/lib/castArray.ts +0 -14
  689. package/src/lib/castThunk.ts +0 -13
  690. package/src/lib/everyTagFilter.ts +0 -15
  691. package/src/lib/findMasterRef.ts +0 -16
  692. package/src/lib/findRef.ts +0 -25
  693. package/src/lib/findRefByID.ts +0 -17
  694. package/src/lib/findRefByLabel.ts +0 -17
  695. package/src/lib/minifyGraphQLQuery.ts +0 -13
  696. package/src/lib/someTagsFilter.ts +0 -15
  697. package/src/lib/typeFilter.ts +0 -12
@@ -0,0 +1,96 @@
1
+ const require_package = require('./package.cjs');
2
+ const require_devMsg = require('./lib/devMsg.cjs');
3
+
4
+ //#region src/buildQueryURL.ts
5
+ /**
6
+ * The query parameter used to indicate if the client is in development mode to
7
+ * the API.
8
+ */
9
+ const PRISMIC_DEV_PARAM = "x-d";
10
+ /** The query parameter used to indicate the version of the client to the API. */
11
+ const PRISMIC_CLIENT_VERSION_PARAM = "x-c";
12
+ /**
13
+ * Parameters in this map have been renamed from the official Prismic REST API
14
+ * V2 specification for better developer ergonomics.
15
+ *
16
+ * These parameters are renamed to their mapped value.
17
+ */
18
+ const RENAMED_PARAMS = { accessToken: "access_token" };
19
+ /**
20
+ * Converts an Ordering to a string that is compatible with Prismic's REST API.
21
+ * If the value provided is already a string, no conversion is performed.
22
+ *
23
+ * @param ordering - Ordering to convert.
24
+ *
25
+ * @returns String representation of the Ordering.
26
+ */
27
+ const castOrderingToString = (ordering) => {
28
+ if (typeof ordering === "string") {
29
+ if (process.env.NODE_ENV === "development") {
30
+ const [field, direction] = ordering.split(" ");
31
+ const objectForm = direction === "desc" ? `{ field: "${field}", direction: "desc" }` : `{ field: "${field}" }`;
32
+ console.warn(`[@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 ${require_devMsg.devMsg("orderings-must-be-an-array-of-objects")}`);
33
+ }
34
+ return ordering;
35
+ }
36
+ return ordering.direction === "desc" ? `${ordering.field} desc` : ordering.field;
37
+ };
38
+ /**
39
+ * Builds a Prismic Content API URL to request pages from a repository. The
40
+ * paginated response for this URL includes pages matching the parameters.
41
+ *
42
+ * A ref is required to make a request. Request the `endpoint` URL to retrieve a
43
+ * list of available refs.
44
+ *
45
+ * Type the JSON response with `Query`.
46
+ *
47
+ * @example
48
+ *
49
+ * ```ts
50
+ * const url = buildQueryURL("https://my-repo.cdn.prismic.io/api/v2", {
51
+ * ref: "my-ref",
52
+ * filters: [filter.at("document.type", "blog_post")],
53
+ * })
54
+ * ```
55
+ *
56
+ * @param endpoint - URL to the repository's Content API.
57
+ * @param args - Arguments to filter and scope the query.
58
+ *
59
+ * @returns URL that can be used to request pages from the repository.
60
+ *
61
+ * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
62
+ */
63
+ const buildQueryURL = (endpoint, args) => {
64
+ const { filters, predicates,...params } = args;
65
+ if (!endpoint.endsWith("/")) endpoint += "/";
66
+ const url = new URL(`documents/search`, endpoint);
67
+ if (filters) {
68
+ if (process.env.NODE_ENV === "development" && !Array.isArray(filters)) console.warn(`[@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 ${require_devMsg.devMsg("filters-must-be-an-array")}`);
69
+ for (const filter of castArray(filters)) url.searchParams.append("q", `[${filter}]`);
70
+ }
71
+ if (predicates) for (const predicate of castArray(predicates)) url.searchParams.append("q", `[${predicate}]`);
72
+ for (const k in params) {
73
+ const name = RENAMED_PARAMS[k] || k;
74
+ let value = params[k];
75
+ if (name === "orderings") {
76
+ const scopedValue = params[name];
77
+ if (scopedValue != null) {
78
+ if (process.env.NODE_ENV === "development" && typeof scopedValue === "string") console.warn(`[@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 ${require_devMsg.devMsg("orderings-must-be-an-array-of-objects")}`);
79
+ value = `[${castArray(scopedValue).map((ordering) => castOrderingToString(ordering)).join(",")}]`;
80
+ }
81
+ } else if (name === "routes") {
82
+ if (typeof params[name] === "object") value = JSON.stringify(castArray(params[name]));
83
+ }
84
+ if (value != null) url.searchParams.set(name, castArray(value).join(","));
85
+ }
86
+ url.searchParams.set(PRISMIC_CLIENT_VERSION_PARAM, `js-${require_package.version}`);
87
+ if (process.env.NODE_ENV === "development") url.searchParams.set(PRISMIC_DEV_PARAM, "1");
88
+ return url.toString();
89
+ };
90
+ function castArray(a) {
91
+ return Array.isArray(a) ? a : [a];
92
+ }
93
+
94
+ //#endregion
95
+ exports.buildQueryURL = buildQueryURL;
96
+ //# sourceMappingURL=buildQueryURL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildQueryURL.cjs","names":["devMsg","version"],"sources":["../src/buildQueryURL.ts"],"sourcesContent":["import { devMsg } from \"./lib/devMsg\"\n\nimport { version } from \"../package.json\"\n\n/**\n * The query parameter used to indicate if the client is in development mode to\n * the API.\n */\nconst PRISMIC_DEV_PARAM = \"x-d\"\n\n/** The query parameter used to indicate the version of the client to the API. */\nconst PRISMIC_CLIENT_VERSION_PARAM = \"x-c\"\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 page's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example With a page'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/** The custom type of the page. */\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 page 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 pages whose language matches the given language.\n\t */\n\tlang?: string\n\n\t/** The resolved path of the page with optional placeholders. */\n\tpath: string\n\n\t/** An object that lists the API IDs of the Content Relationships in the route. */\n\tresolvers?: Record<string, string>\n}\n\n/**\n * Parameters for the Prismic Content API.\n *\n * @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}\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 pages that the API\n\t * 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 pages except for those after the specified page in the\n\t * 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 page and add it to the page 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 page'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 page 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/** Arguments for `buildQueryURL` to construct a Query URL. */\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/** A valid parameter name for the Prismic REST API V2. */\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 * Builds a Prismic Content API URL to request pages from a repository. The\n * paginated response for this URL includes pages 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 * @example\n *\n * ```ts\n * const url = buildQueryURL(\"https://my-repo.cdn.prismic.io/api/v2\", {\n * \tref: \"my-ref\",\n * \tfilters: [filter.at(\"document.type\", \"blog_post\")],\n * })\n * ```\n *\n * @param endpoint - URL to the repository's Content API.\n * @param args - Arguments to filter and scope the query.\n *\n * @returns URL that can be used to request pages from the repository.\n *\n * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}\n */\nexport const buildQueryURL = (\n\tendpoint: string,\n\targs: BuildQueryURLArgs,\n): string => {\n\tconst { filters, predicates, ...params } = args\n\n\tif (!endpoint.endsWith(\"/\")) {\n\t\tendpoint += \"/\"\n\t}\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\turl.searchParams.set(PRISMIC_CLIENT_VERSION_PARAM, `js-${version}`)\n\n\tif (process.env.NODE_ENV === \"development\") {\n\t\turl.searchParams.set(PRISMIC_DEV_PARAM, \"1\")\n\t}\n\n\treturn url.toString()\n}\n\nfunction castArray<A>(a: A | A[]): A[] {\n\treturn Array.isArray(a) ? a : [a]\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,oBAAoB;;AAG1B,MAAM,+BAA+B;;;;;;;AAiOrC,MAAM,iBAAiB,EACtB,aAAa,gBACb;;;;;;;;;AAkBD,MAAM,wBAAwB,aAAwC;AAErE,KAAI,OAAO,aAAa,UAAU;AACjC,MAAI,QAAQ,IAAI,aAAa,eAAe;GAC3C,MAAM,CAAC,OAAO,aAAa,SAAS,MAAM,IAAI;GAE9C,MAAM,aACL,cAAc,SACX,aAAa,MAAM,0BACnB,aAAa,MAAM;AAEvB,WAAQ,KACP,uJAAuJ,WAAW,0BAA0BA,sBAC3L,wCACA,GACD;;AAGF,SAAO;;AAGR,QAAO,SAAS,cAAc,SAC3B,GAAG,SAAS,MAAM,SAClB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Bb,MAAa,iBACZ,UACA,SACY;CACZ,MAAM,EAAE,SAAS,WAAY,GAAG,WAAW;AAE3C,KAAI,CAAC,SAAS,SAAS,IAAI,CAC1B,aAAY;CAEb,MAAM,MAAM,IAAI,IAAI,oBAAoB,SAAS;AAEjD,KAAI,SAAS;AAEZ,MAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,MAAM,QAAQ,QAAQ,CACpE,SAAQ,KACP,4FAA4F,QAAQ,6FAA6FA,sBAChM,2BACA,GACD;AAIF,OAAK,MAAM,UAAU,UAAU,QAAQ,CACtC,KAAI,aAAa,OAAO,KAAK,IAAI,OAAO,GAAG;;AAK7C,KAAI,WACH,MAAK,MAAM,aAAa,UAAU,WAAW,CAC5C,KAAI,aAAa,OAAO,KAAK,IAAI,UAAU,GAAG;AAMhD,MAAK,MAAM,KAAK,QAAQ;EACvB,MAAM,OAAQ,eAAe,MAC5B;EAED,IAAI,QAAQ,OAAO;AAEnB,MAAI,SAAS,aAAa;GACzB,MAAM,cAAc,OAAO;AAE3B,OAAI,eAAe,MAAM;AAExB,QACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,SAEvB,SAAQ,KACP,iLAAiLA,sBAChL,wCACA,GACD;AAOF,YAAQ,IAJE,UAAU,YAAY,CAC9B,KAAK,aAAa,qBAAqB,SAAS,CAAC,CACjD,KAAK,IAAI,CAEG;;aAEL,SAAS,UACnB;OAAI,OAAO,OAAO,UAAU,SAC3B,SAAQ,KAAK,UAAU,UAAU,OAAO,MAAM,CAAC;;AAIjD,MAAI,SAAS,KACZ,KAAI,aAAa,IAChB,MACA,UAA8C,MAAM,CAAC,KAAK,IAAI,CAC9D;;AAIH,KAAI,aAAa,IAAI,8BAA8B,MAAMC,0BAAU;AAEnE,KAAI,QAAQ,IAAI,aAAa,cAC5B,KAAI,aAAa,IAAI,mBAAmB,IAAI;AAG7C,QAAO,IAAI,UAAU;;AAGtB,SAAS,UAAa,GAAiB;AACtC,QAAO,MAAM,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE"}
@@ -0,0 +1,212 @@
1
+ //#region src/buildQueryURL.d.ts
2
+ /**
3
+ * An `orderings` parameter that orders the results by the specified field.
4
+ *
5
+ * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}
6
+ */
7
+ interface Ordering {
8
+ field: string;
9
+ direction?: "asc" | "desc";
10
+ }
11
+ /**
12
+ * A `routes` parameter that determines how a page's URL field is resolved.
13
+ *
14
+ * {@link https://prismic.io/docs/route-resolver}
15
+ *
16
+ * @example With a page's UID field.
17
+ *
18
+ * ```ts
19
+ * {
20
+ * "type": "page",
21
+ * "path": "/:uid"
22
+ * }
23
+ * ```
24
+ *
25
+ * @example With a Content Relationship `parent` field.
26
+ *
27
+ * ```ts
28
+ * {
29
+ * "type": "page",
30
+ * "path": "/:parent?/:uid",
31
+ * "resolvers": {
32
+ * "parent": "parent"
33
+ * }
34
+ * }
35
+ * ```
36
+ */
37
+ interface Route {
38
+ /** The custom type of the page. */
39
+ type: string;
40
+ /**
41
+ * A specific UID to which this route definition is scoped. The route is only
42
+ * defined for the page whose UID matches the given UID.
43
+ */
44
+ uid?: string;
45
+ /**
46
+ * A specific language to which this route definition is scoped. The route is
47
+ * only defined for pages whose language matches the given language.
48
+ */
49
+ lang?: string;
50
+ /** The resolved path of the page with optional placeholders. */
51
+ path: string;
52
+ /** An object that lists the API IDs of the Content Relationships in the route. */
53
+ resolvers?: Record<string, string>;
54
+ }
55
+ /**
56
+ * Parameters for the Prismic Content API.
57
+ *
58
+ * @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}
59
+ */
60
+ interface QueryParams {
61
+ /**
62
+ * The secure token for accessing the API (only needed if your repository is
63
+ * set to private).
64
+ *
65
+ * {@link https://prismic.io/docs/access-token}
66
+ */
67
+ accessToken?: string;
68
+ /**
69
+ * The `pageSize` parameter defines the maximum number of pages that the API
70
+ * will return for your query.
71
+ *
72
+ * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}
73
+ */
74
+ pageSize?: number;
75
+ /**
76
+ * The `page` parameter defines the pagination for the result of your query.
77
+ *
78
+ * {@link https://prismic.io/docs/rest-api-technical-reference#page}
79
+ */
80
+ page?: number;
81
+ /**
82
+ * The `after` parameter can be used along with the orderings option. It will
83
+ * remove all the pages except for those after the specified page in the
84
+ * list.
85
+ *
86
+ * {@link https://prismic.io/docs/rest-api-technical-reference#after}
87
+ */
88
+ after?: string;
89
+ /**
90
+ * The `fetch` parameter is used to make queries faster by only retrieving the
91
+ * specified field(s).
92
+ *
93
+ * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}
94
+ */
95
+ fetch?: string | string[];
96
+ /**
97
+ * The `fetchLinks` parameter allows you to retrieve a specific content field
98
+ * from a linked page and add it to the page response object.
99
+ *
100
+ * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}
101
+ */
102
+ fetchLinks?: string | string[];
103
+ /**
104
+ * The `graphQuery` parameter allows you to specify which fields to retrieve
105
+ * and what content to retrieve from Linked Documents / Content
106
+ * Relationships.
107
+ *
108
+ * {@link https://prismic.io/docs/graphquery-rest-api}
109
+ */
110
+ graphQuery?: string;
111
+ /**
112
+ * The `lang` option defines the language code for the results of your query.
113
+ *
114
+ * {@link https://prismic.io/docs/rest-api-technical-reference#lang}
115
+ */
116
+ lang?: string;
117
+ /**
118
+ * The `orderings` parameter orders the results by the specified field(s). You
119
+ * can specify as many fields as you want.
120
+ *
121
+ * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}
122
+ *
123
+ * @remarks
124
+ * Strings and arrays of strings are deprecated as of
125
+ * `@prismicio/client@7.0.0`. Please migrate to the more explicit array of
126
+ * objects.
127
+ *
128
+ * @example
129
+ *
130
+ * ```typescript
131
+ * buildQueryURL(endpoint, {
132
+ * orderings: [
133
+ * { field: "my.product.price", direction: "desc" },
134
+ * { field: "my.product.title" },
135
+ * ],
136
+ * })
137
+ * ```
138
+ */
139
+ orderings?: string | Ordering | (string | Ordering)[];
140
+ /**
141
+ * The `routes` option allows you to define how a page's `url` field is
142
+ * resolved.
143
+ *
144
+ * {@link https://prismic.io/docs/route-resolver}
145
+ */
146
+ routes?: Route | string | (Route | string)[];
147
+ /**
148
+ * The `brokenRoute` option allows you to define the route populated in the
149
+ * `url` property for broken link or content relationship fields. A broken
150
+ * link is a link or content relationship field whose linked page has been
151
+ * unpublished or deleted.
152
+ *
153
+ * {@link https://prismic.io/docs/route-resolver}
154
+ */
155
+ brokenRoute?: string;
156
+ }
157
+ /** Arguments for `buildQueryURL` to construct a Query URL. */
158
+ type BuildQueryURLParams = {
159
+ /**
160
+ * Ref used to query documents.
161
+ *
162
+ * {@link https://prismic.io/docs/api#refs-and-the-entry-api}
163
+ */
164
+ ref: string;
165
+ /**
166
+ * Ref used to populate integration fields with the latest content.
167
+ *
168
+ * {@link https://prismic.io/docs/integration-fields}
169
+ */
170
+ integrationFieldsRef?: string;
171
+ /**
172
+ * One or more filters to filter documents for the query.
173
+ *
174
+ * {@link https://prismic.io/docs/rest-api-technical-reference#q}
175
+ */
176
+ filters?: string | string[];
177
+ /**
178
+ * @deprecated Renamed to `filters`. Ensure the value is an array of filters,
179
+ * not a single, non-array filter.
180
+ */
181
+ predicates?: string | string[];
182
+ };
183
+ type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
184
+ /**
185
+ * Builds a Prismic Content API URL to request pages from a repository. The
186
+ * paginated response for this URL includes pages matching the parameters.
187
+ *
188
+ * A ref is required to make a request. Request the `endpoint` URL to retrieve a
189
+ * list of available refs.
190
+ *
191
+ * Type the JSON response with `Query`.
192
+ *
193
+ * @example
194
+ *
195
+ * ```ts
196
+ * const url = buildQueryURL("https://my-repo.cdn.prismic.io/api/v2", {
197
+ * ref: "my-ref",
198
+ * filters: [filter.at("document.type", "blog_post")],
199
+ * })
200
+ * ```
201
+ *
202
+ * @param endpoint - URL to the repository's Content API.
203
+ * @param args - Arguments to filter and scope the query.
204
+ *
205
+ * @returns URL that can be used to request pages from the repository.
206
+ *
207
+ * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
208
+ */
209
+ declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
210
+ //#endregion
211
+ export { BuildQueryURLArgs, Ordering, QueryParams, Route, buildQueryURL };
212
+ //# sourceMappingURL=buildQueryURL.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildQueryURL.d.cts","names":[],"sources":["../src/buildQueryURL.ts"],"sourcesContent":[],"mappings":";;AAgCA;AA+BA;AA4BA;;AAwF2C,UAnJ1B,QAAA,CAmJ0B;EAQjC,KAAA,EAAA,MAAA;EAAkB,SAAA,CAAA,EAAA,KAAA,GAAA,MAAA;;AAW3B;AAoFD;AA2BA;;;;;;;;;;;;;;;;;;;;;;;;UAtPiB,KAAA;;;;;;;;;;;;;;;;cAoBJ;;;;;;;UAQI,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAwFK,qBAAqB;;;;;;;WAQjC,kBAAkB;;;;;;;;;;;;KAcvB,mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAiFO,iBAAA,GAAoB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;cA2BjC,wCAEN"}
@@ -0,0 +1,212 @@
1
+ //#region src/buildQueryURL.d.ts
2
+ /**
3
+ * An `orderings` parameter that orders the results by the specified field.
4
+ *
5
+ * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}
6
+ */
7
+ interface Ordering {
8
+ field: string;
9
+ direction?: "asc" | "desc";
10
+ }
11
+ /**
12
+ * A `routes` parameter that determines how a page's URL field is resolved.
13
+ *
14
+ * {@link https://prismic.io/docs/route-resolver}
15
+ *
16
+ * @example With a page's UID field.
17
+ *
18
+ * ```ts
19
+ * {
20
+ * "type": "page",
21
+ * "path": "/:uid"
22
+ * }
23
+ * ```
24
+ *
25
+ * @example With a Content Relationship `parent` field.
26
+ *
27
+ * ```ts
28
+ * {
29
+ * "type": "page",
30
+ * "path": "/:parent?/:uid",
31
+ * "resolvers": {
32
+ * "parent": "parent"
33
+ * }
34
+ * }
35
+ * ```
36
+ */
37
+ interface Route {
38
+ /** The custom type of the page. */
39
+ type: string;
40
+ /**
41
+ * A specific UID to which this route definition is scoped. The route is only
42
+ * defined for the page whose UID matches the given UID.
43
+ */
44
+ uid?: string;
45
+ /**
46
+ * A specific language to which this route definition is scoped. The route is
47
+ * only defined for pages whose language matches the given language.
48
+ */
49
+ lang?: string;
50
+ /** The resolved path of the page with optional placeholders. */
51
+ path: string;
52
+ /** An object that lists the API IDs of the Content Relationships in the route. */
53
+ resolvers?: Record<string, string>;
54
+ }
55
+ /**
56
+ * Parameters for the Prismic Content API.
57
+ *
58
+ * @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}
59
+ */
60
+ interface QueryParams {
61
+ /**
62
+ * The secure token for accessing the API (only needed if your repository is
63
+ * set to private).
64
+ *
65
+ * {@link https://prismic.io/docs/access-token}
66
+ */
67
+ accessToken?: string;
68
+ /**
69
+ * The `pageSize` parameter defines the maximum number of pages that the API
70
+ * will return for your query.
71
+ *
72
+ * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}
73
+ */
74
+ pageSize?: number;
75
+ /**
76
+ * The `page` parameter defines the pagination for the result of your query.
77
+ *
78
+ * {@link https://prismic.io/docs/rest-api-technical-reference#page}
79
+ */
80
+ page?: number;
81
+ /**
82
+ * The `after` parameter can be used along with the orderings option. It will
83
+ * remove all the pages except for those after the specified page in the
84
+ * list.
85
+ *
86
+ * {@link https://prismic.io/docs/rest-api-technical-reference#after}
87
+ */
88
+ after?: string;
89
+ /**
90
+ * The `fetch` parameter is used to make queries faster by only retrieving the
91
+ * specified field(s).
92
+ *
93
+ * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}
94
+ */
95
+ fetch?: string | string[];
96
+ /**
97
+ * The `fetchLinks` parameter allows you to retrieve a specific content field
98
+ * from a linked page and add it to the page response object.
99
+ *
100
+ * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}
101
+ */
102
+ fetchLinks?: string | string[];
103
+ /**
104
+ * The `graphQuery` parameter allows you to specify which fields to retrieve
105
+ * and what content to retrieve from Linked Documents / Content
106
+ * Relationships.
107
+ *
108
+ * {@link https://prismic.io/docs/graphquery-rest-api}
109
+ */
110
+ graphQuery?: string;
111
+ /**
112
+ * The `lang` option defines the language code for the results of your query.
113
+ *
114
+ * {@link https://prismic.io/docs/rest-api-technical-reference#lang}
115
+ */
116
+ lang?: string;
117
+ /**
118
+ * The `orderings` parameter orders the results by the specified field(s). You
119
+ * can specify as many fields as you want.
120
+ *
121
+ * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}
122
+ *
123
+ * @remarks
124
+ * Strings and arrays of strings are deprecated as of
125
+ * `@prismicio/client@7.0.0`. Please migrate to the more explicit array of
126
+ * objects.
127
+ *
128
+ * @example
129
+ *
130
+ * ```typescript
131
+ * buildQueryURL(endpoint, {
132
+ * orderings: [
133
+ * { field: "my.product.price", direction: "desc" },
134
+ * { field: "my.product.title" },
135
+ * ],
136
+ * })
137
+ * ```
138
+ */
139
+ orderings?: string | Ordering | (string | Ordering)[];
140
+ /**
141
+ * The `routes` option allows you to define how a page's `url` field is
142
+ * resolved.
143
+ *
144
+ * {@link https://prismic.io/docs/route-resolver}
145
+ */
146
+ routes?: Route | string | (Route | string)[];
147
+ /**
148
+ * The `brokenRoute` option allows you to define the route populated in the
149
+ * `url` property for broken link or content relationship fields. A broken
150
+ * link is a link or content relationship field whose linked page has been
151
+ * unpublished or deleted.
152
+ *
153
+ * {@link https://prismic.io/docs/route-resolver}
154
+ */
155
+ brokenRoute?: string;
156
+ }
157
+ /** Arguments for `buildQueryURL` to construct a Query URL. */
158
+ type BuildQueryURLParams = {
159
+ /**
160
+ * Ref used to query documents.
161
+ *
162
+ * {@link https://prismic.io/docs/api#refs-and-the-entry-api}
163
+ */
164
+ ref: string;
165
+ /**
166
+ * Ref used to populate integration fields with the latest content.
167
+ *
168
+ * {@link https://prismic.io/docs/integration-fields}
169
+ */
170
+ integrationFieldsRef?: string;
171
+ /**
172
+ * One or more filters to filter documents for the query.
173
+ *
174
+ * {@link https://prismic.io/docs/rest-api-technical-reference#q}
175
+ */
176
+ filters?: string | string[];
177
+ /**
178
+ * @deprecated Renamed to `filters`. Ensure the value is an array of filters,
179
+ * not a single, non-array filter.
180
+ */
181
+ predicates?: string | string[];
182
+ };
183
+ type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
184
+ /**
185
+ * Builds a Prismic Content API URL to request pages from a repository. The
186
+ * paginated response for this URL includes pages matching the parameters.
187
+ *
188
+ * A ref is required to make a request. Request the `endpoint` URL to retrieve a
189
+ * list of available refs.
190
+ *
191
+ * Type the JSON response with `Query`.
192
+ *
193
+ * @example
194
+ *
195
+ * ```ts
196
+ * const url = buildQueryURL("https://my-repo.cdn.prismic.io/api/v2", {
197
+ * ref: "my-ref",
198
+ * filters: [filter.at("document.type", "blog_post")],
199
+ * })
200
+ * ```
201
+ *
202
+ * @param endpoint - URL to the repository's Content API.
203
+ * @param args - Arguments to filter and scope the query.
204
+ *
205
+ * @returns URL that can be used to request pages from the repository.
206
+ *
207
+ * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
208
+ */
209
+ declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
210
+ //#endregion
211
+ export { BuildQueryURLArgs, Ordering, QueryParams, Route, buildQueryURL };
212
+ //# sourceMappingURL=buildQueryURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildQueryURL.d.ts","names":[],"sources":["../src/buildQueryURL.ts"],"sourcesContent":[],"mappings":";;AAgCA;AA+BA;AA4BA;;AAwF2C,UAnJ1B,QAAA,CAmJ0B;EAQjC,KAAA,EAAA,MAAA;EAAkB,SAAA,CAAA,EAAA,KAAA,GAAA,MAAA;;AAW3B;AAoFD;AA2BA;;;;;;;;;;;;;;;;;;;;;;;;UAtPiB,KAAA;;;;;;;;;;;;;;;;cAoBJ;;;;;;;UAQI,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAwFK,qBAAqB;;;;;;;WAQjC,kBAAkB;;;;;;;;;;;;KAcvB,mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAiFO,iBAAA,GAAoB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;cA2BjC,wCAEN"}
@@ -0,0 +1,96 @@
1
+ import { version } from "./package.js";
2
+ import { devMsg } from "./lib/devMsg.js";
3
+
4
+ //#region src/buildQueryURL.ts
5
+ /**
6
+ * The query parameter used to indicate if the client is in development mode to
7
+ * the API.
8
+ */
9
+ const PRISMIC_DEV_PARAM = "x-d";
10
+ /** The query parameter used to indicate the version of the client to the API. */
11
+ const PRISMIC_CLIENT_VERSION_PARAM = "x-c";
12
+ /**
13
+ * Parameters in this map have been renamed from the official Prismic REST API
14
+ * V2 specification for better developer ergonomics.
15
+ *
16
+ * These parameters are renamed to their mapped value.
17
+ */
18
+ const RENAMED_PARAMS = { accessToken: "access_token" };
19
+ /**
20
+ * Converts an Ordering to a string that is compatible with Prismic's REST API.
21
+ * If the value provided is already a string, no conversion is performed.
22
+ *
23
+ * @param ordering - Ordering to convert.
24
+ *
25
+ * @returns String representation of the Ordering.
26
+ */
27
+ const castOrderingToString = (ordering) => {
28
+ if (typeof ordering === "string") {
29
+ if (process.env.NODE_ENV === "development") {
30
+ const [field, direction] = ordering.split(" ");
31
+ const objectForm = direction === "desc" ? `{ field: "${field}", direction: "desc" }` : `{ field: "${field}" }`;
32
+ console.warn(`[@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("orderings-must-be-an-array-of-objects")}`);
33
+ }
34
+ return ordering;
35
+ }
36
+ return ordering.direction === "desc" ? `${ordering.field} desc` : ordering.field;
37
+ };
38
+ /**
39
+ * Builds a Prismic Content API URL to request pages from a repository. The
40
+ * paginated response for this URL includes pages matching the parameters.
41
+ *
42
+ * A ref is required to make a request. Request the `endpoint` URL to retrieve a
43
+ * list of available refs.
44
+ *
45
+ * Type the JSON response with `Query`.
46
+ *
47
+ * @example
48
+ *
49
+ * ```ts
50
+ * const url = buildQueryURL("https://my-repo.cdn.prismic.io/api/v2", {
51
+ * ref: "my-ref",
52
+ * filters: [filter.at("document.type", "blog_post")],
53
+ * })
54
+ * ```
55
+ *
56
+ * @param endpoint - URL to the repository's Content API.
57
+ * @param args - Arguments to filter and scope the query.
58
+ *
59
+ * @returns URL that can be used to request pages from the repository.
60
+ *
61
+ * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
62
+ */
63
+ const buildQueryURL = (endpoint, args) => {
64
+ const { filters, predicates,...params } = args;
65
+ if (!endpoint.endsWith("/")) endpoint += "/";
66
+ const url = new URL(`documents/search`, endpoint);
67
+ if (filters) {
68
+ if (process.env.NODE_ENV === "development" && !Array.isArray(filters)) console.warn(`[@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("filters-must-be-an-array")}`);
69
+ for (const filter of castArray(filters)) url.searchParams.append("q", `[${filter}]`);
70
+ }
71
+ if (predicates) for (const predicate of castArray(predicates)) url.searchParams.append("q", `[${predicate}]`);
72
+ for (const k in params) {
73
+ const name = RENAMED_PARAMS[k] || k;
74
+ let value = params[k];
75
+ if (name === "orderings") {
76
+ const scopedValue = params[name];
77
+ if (scopedValue != null) {
78
+ if (process.env.NODE_ENV === "development" && typeof scopedValue === "string") console.warn(`[@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("orderings-must-be-an-array-of-objects")}`);
79
+ value = `[${castArray(scopedValue).map((ordering) => castOrderingToString(ordering)).join(",")}]`;
80
+ }
81
+ } else if (name === "routes") {
82
+ if (typeof params[name] === "object") value = JSON.stringify(castArray(params[name]));
83
+ }
84
+ if (value != null) url.searchParams.set(name, castArray(value).join(","));
85
+ }
86
+ url.searchParams.set(PRISMIC_CLIENT_VERSION_PARAM, `js-${version}`);
87
+ if (process.env.NODE_ENV === "development") url.searchParams.set(PRISMIC_DEV_PARAM, "1");
88
+ return url.toString();
89
+ };
90
+ function castArray(a) {
91
+ return Array.isArray(a) ? a : [a];
92
+ }
93
+
94
+ //#endregion
95
+ export { buildQueryURL };
96
+ //# sourceMappingURL=buildQueryURL.js.map