@prismicio/client 7.0.0 → 7.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/buildQueryURL.cjs.map +1 -1
  2. package/dist/buildQueryURL.d.ts +11 -10
  3. package/dist/buildQueryURL.js.map +1 -1
  4. package/dist/createClient.cjs +39 -6
  5. package/dist/createClient.cjs.map +1 -1
  6. package/dist/createClient.d.ts +68 -21
  7. package/dist/createClient.js +39 -6
  8. package/dist/createClient.js.map +1 -1
  9. package/dist/filter.cjs +38 -38
  10. package/dist/filter.cjs.map +1 -1
  11. package/dist/filter.d.ts +38 -38
  12. package/dist/filter.js +38 -38
  13. package/dist/filter.js.map +1 -1
  14. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  15. package/dist/getGraphQLEndpoint.d.ts +1 -0
  16. package/dist/getGraphQLEndpoint.js.map +1 -1
  17. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  18. package/dist/getRepositoryEndpoint.d.ts +2 -0
  19. package/dist/getRepositoryEndpoint.js.map +1 -1
  20. package/dist/getRepositoryName.cjs.map +1 -1
  21. package/dist/getRepositoryName.d.ts +1 -0
  22. package/dist/getRepositoryName.js.map +1 -1
  23. package/dist/getToolbarSrc.cjs.map +1 -1
  24. package/dist/getToolbarSrc.d.ts +1 -1
  25. package/dist/getToolbarSrc.js.map +1 -1
  26. package/dist/helpers/asDate.cjs.map +1 -1
  27. package/dist/helpers/asDate.d.ts +1 -0
  28. package/dist/helpers/asDate.js.map +1 -1
  29. package/dist/helpers/asHTML.cjs.map +1 -1
  30. package/dist/helpers/asHTML.d.ts +21 -15
  31. package/dist/helpers/asHTML.js.map +1 -1
  32. package/dist/helpers/asLink.cjs.map +1 -1
  33. package/dist/helpers/asLink.d.ts +24 -15
  34. package/dist/helpers/asLink.js.map +1 -1
  35. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  36. package/dist/helpers/asLinkAttrs.d.ts +9 -4
  37. package/dist/helpers/asLinkAttrs.js.map +1 -1
  38. package/dist/helpers/asText.cjs.map +1 -1
  39. package/dist/helpers/asText.d.ts +11 -7
  40. package/dist/helpers/asText.js.map +1 -1
  41. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  42. package/dist/helpers/documentToLinkField.d.ts +2 -0
  43. package/dist/helpers/documentToLinkField.js.map +1 -1
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/lib/appendFilters.cjs.map +1 -1
  48. package/dist/lib/appendFilters.d.ts +4 -4
  49. package/dist/lib/appendFilters.js.map +1 -1
  50. package/dist/lib/castArray.cjs.map +1 -1
  51. package/dist/lib/castArray.d.ts +1 -0
  52. package/dist/lib/castArray.js.map +1 -1
  53. package/dist/lib/castThunk.cjs.map +1 -1
  54. package/dist/lib/castThunk.d.ts +2 -1
  55. package/dist/lib/castThunk.js.map +1 -1
  56. package/dist/lib/everyTagFilter.cjs.map +1 -1
  57. package/dist/lib/everyTagFilter.d.ts +2 -2
  58. package/dist/lib/everyTagFilter.js.map +1 -1
  59. package/dist/lib/findMasterRef.cjs.map +1 -1
  60. package/dist/lib/findMasterRef.d.ts +1 -0
  61. package/dist/lib/findMasterRef.js.map +1 -1
  62. package/dist/lib/findRef.cjs.map +1 -1
  63. package/dist/lib/findRef.d.ts +3 -2
  64. package/dist/lib/findRef.js.map +1 -1
  65. package/dist/lib/findRefByID.cjs.map +1 -1
  66. package/dist/lib/findRefByID.d.ts +1 -0
  67. package/dist/lib/findRefByID.js.map +1 -1
  68. package/dist/lib/findRefByLabel.cjs.map +1 -1
  69. package/dist/lib/findRefByLabel.d.ts +1 -0
  70. package/dist/lib/findRefByLabel.js.map +1 -1
  71. package/dist/package.json.cjs +1 -1
  72. package/dist/package.json.js +1 -1
  73. package/dist/types/api/query.d.ts +1 -0
  74. package/dist/types/api/release.d.ts +1 -0
  75. package/dist/types/api/tags.d.ts +1 -0
  76. package/dist/types/model/contentRelationship.d.ts +1 -2
  77. package/dist/types/model/link.cjs.map +1 -1
  78. package/dist/types/model/link.d.ts +2 -4
  79. package/dist/types/model/link.js.map +1 -1
  80. package/dist/types/model/linkToMedia.d.ts +1 -2
  81. package/dist/types/value/color.d.ts +1 -0
  82. package/dist/types/value/date.d.ts +1 -0
  83. package/dist/types/value/embed.cjs.map +1 -1
  84. package/dist/types/value/embed.d.ts +1 -0
  85. package/dist/types/value/embed.js.map +1 -1
  86. package/dist/types/value/geoPoint.d.ts +1 -0
  87. package/dist/types/value/image.d.ts +2 -0
  88. package/dist/types/value/integration.d.ts +1 -0
  89. package/dist/types/value/keyText.d.ts +1 -0
  90. package/dist/types/value/number.d.ts +1 -0
  91. package/dist/types/value/select.d.ts +1 -0
  92. package/dist/types/value/types.d.ts +1 -0
  93. package/package.json +3 -3
  94. package/src/buildQueryURL.ts +11 -10
  95. package/src/createClient.ts +85 -28
  96. package/src/filter.ts +42 -42
  97. package/src/getGraphQLEndpoint.ts +1 -0
  98. package/src/getRepositoryEndpoint.ts +2 -0
  99. package/src/getRepositoryName.ts +1 -0
  100. package/src/getToolbarSrc.ts +1 -1
  101. package/src/helpers/asDate.ts +1 -0
  102. package/src/helpers/asHTML.ts +23 -17
  103. package/src/helpers/asLink.ts +24 -15
  104. package/src/helpers/asLinkAttrs.ts +9 -4
  105. package/src/helpers/asText.ts +11 -7
  106. package/src/helpers/documentToLinkField.ts +2 -0
  107. package/src/index.ts +1 -0
  108. package/src/lib/appendFilters.ts +4 -4
  109. package/src/lib/castArray.ts +1 -0
  110. package/src/lib/castThunk.ts +9 -2
  111. package/src/lib/everyTagFilter.ts +2 -2
  112. package/src/lib/findMasterRef.ts +1 -0
  113. package/src/lib/findRef.ts +3 -2
  114. package/src/lib/findRefByID.ts +1 -0
  115. package/src/lib/findRefByLabel.ts +1 -0
  116. package/src/types/api/query.ts +1 -0
  117. package/src/types/api/release.ts +1 -0
  118. package/src/types/api/tags.ts +1 -0
  119. package/src/types/model/contentRelationship.ts +1 -2
  120. package/src/types/model/link.ts +2 -4
  121. package/src/types/model/linkToMedia.ts +1 -2
  122. package/src/types/value/color.ts +1 -0
  123. package/src/types/value/date.ts +1 -0
  124. package/src/types/value/embed.ts +1 -0
  125. package/src/types/value/geoPoint.ts +1 -0
  126. package/src/types/value/image.ts +2 -0
  127. package/src/types/value/integration.ts +1 -0
  128. package/src/types/value/keyText.ts +1 -0
  129. package/src/types/value/number.ts +1 -0
  130. package/src/types/value/select.ts +1 -0
  131. package/src/types/value/types.ts +1 -0
@@ -56,7 +56,8 @@ export interface RequestInitLike extends Pick<RequestInit, "cache"> {
56
56
  /**
57
57
  * An AbortSignal to set the `fetch()` request's signal.
58
58
  *
59
- * See: \<https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\>
59
+ * See:
60
+ * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
60
61
  */
61
62
  signal?: AbortSignalLike;
62
63
  }
@@ -96,6 +97,16 @@ export type HttpRequestLike = /**
96
97
  * function can optionally be asynchronous.
97
98
  */
98
99
  type RefStringOrThunk = string | (() => string | undefined | Promise<string | undefined>);
100
+ /**
101
+ * Options or a function that returns options provided to the client's `fetch()`
102
+ * on all network requests. These options will be merged with internally
103
+ * required options. They can also be overriden on a per-query basis using the
104
+ * query's `fetchOptions` parameter.
105
+ *
106
+ * If the options must be determined on-demand, a function can be provided. This
107
+ * function can be asynchronous.
108
+ */
109
+ export type RequestInitLikeOrThunk = RequestInitLike | ((url: string, init?: RequestInitLike) => RequestInitLike | undefined | Promise<RequestInitLike | undefined>);
99
110
  /**
100
111
  * Configuration for clients that determine how content is queried.
101
112
  */
@@ -112,8 +123,8 @@ export type ClientConfig = {
112
123
  */
113
124
  ref?: RefStringOrThunk;
114
125
  /**
115
- * A list of route resolver objects that define how a document's `url` property
116
- * is resolved.
126
+ * A list of route resolver objects that define how a document's `url`
127
+ * property is resolved.
117
128
  *
118
129
  * {@link https://prismic.io/docs/route-resolver}
119
130
  */
@@ -139,37 +150,41 @@ export type ClientConfig = {
139
150
  */
140
151
  fetch?: FetchLike;
141
152
  /**
142
- * Options provided to the client's `fetch()` on all network requests.
143
- * These options will be merged with internally required options. They
144
- * can also be overriden on a per-query basis using the query's
145
- * `fetchOptions` parameter.
153
+ * Options or a function that returns options provided to the client's
154
+ * `fetch()` on all network requests. These options will be merged with
155
+ * internally required options. They can also be overriden on a per-query
156
+ * basis using the query's `fetchOptions` parameter.
157
+ *
158
+ * If the options must be determined on-demand, a function can be provided.
159
+ * This function can be asynchronous.
160
+ *
161
+ * @experimental
146
162
  */
147
- fetchOptions?: RequestInitLike;
163
+ fetchOptions?: RequestInitLikeOrThunk;
148
164
  };
149
165
  /**
150
166
  * Parameters for any client method that use `fetch()`.
151
167
  */
152
168
  type FetchParams = {
153
169
  /**
154
- * Options provided to the client's `fetch()` on all network requests.
155
- * These options will be merged with internally required options. They
156
- * can also be overriden on a per-query basis using the query's
157
- * `fetchOptions` parameter.
170
+ * Options or a function that returns options provided to the client's
171
+ * `fetch()` on all network requests. These options will be merged with
172
+ * internally required options. They can also be overriden on a per-query
173
+ * basis using the query's `fetchOptions` parameter.
174
+ *
175
+ * If the options must be determined on-demand, a function can be provided.
176
+ * This function can be asynchronous.
177
+ *
178
+ * @experimental
158
179
  */
159
- fetchOptions?: RequestInitLike;
180
+ fetchOptions?: RequestInitLikeOrThunk;
160
181
  /**
161
182
  * An `AbortSignal` provided by an `AbortController`. This allows the network
162
183
  * request to be cancelled if necessary.
163
184
  *
164
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
165
- *
166
185
  * @deprecated Move the `signal` parameter into `fetchOptions.signal`:
167
186
  *
168
- * ```typescript
169
- * client.getByUID("page", "home",{
170
- * fetchOptions: { signal }
171
- * });
172
- * ```
187
+ * @see \<https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\>
173
188
  */
174
189
  signal?: AbortSignalLike;
175
190
  };
@@ -281,7 +296,18 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
281
296
  * Node.js, this function must be provided.
282
297
  */
283
298
  fetchFn: FetchLike;
284
- fetchOptions?: RequestInitLike;
299
+ /**
300
+ * Options or a function that returns options provided to the client's
301
+ * `fetch()` on all network requests. These options will be merged with
302
+ * internally required options. They can also be overriden on a per-query
303
+ * basis using the query's `fetchOptions` parameter.
304
+ *
305
+ * If the options must be determined on-demand, a function can be provided.
306
+ * This function can be asynchronous.
307
+ *
308
+ * @experimental
309
+ */
310
+ fetchOptions?: RequestInitLikeOrThunk;
285
311
  /**
286
312
  * Default parameters that will be sent with each query. These parameters can
287
313
  * be overridden on each query if needed.
@@ -379,6 +405,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
379
405
  * ```
380
406
  *
381
407
  * @typeParam TDocument - Type of Prismic documents returned.
408
+ *
382
409
  * @param params - Parameters to filter, sort, and paginate results.
383
410
  *
384
411
  * @returns A paginated response containing the result of the query.
@@ -395,6 +422,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
395
422
  * ```
396
423
  *
397
424
  * @typeParam TDocument - Type of the Prismic document returned.
425
+ *
398
426
  * @param params - Parameters to filter, sort, and paginate results. @returns
399
427
  * The first result of the query, if any.
400
428
  */
@@ -417,6 +445,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
417
445
  * ```
418
446
  *
419
447
  * @typeParam TDocument - Type of Prismic documents returned.
448
+ *
420
449
  * @param params - Parameters to filter, sort, and paginate results.
421
450
  *
422
451
  * @returns A list of documents matching the query.
@@ -437,6 +466,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
437
466
  * ```
438
467
  *
439
468
  * @typeParam TDocument- Type of the Prismic document returned.
469
+ *
440
470
  * @param id - ID of the document.
441
471
  * @param params - Parameters to filter, sort, and paginate the results.
442
472
  *
@@ -462,6 +492,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
462
492
  * ```
463
493
  *
464
494
  * @typeParam TDocument - Type of Prismic documents returned.
495
+ *
465
496
  * @param ids - A list of document IDs.
466
497
  * @param params - Parameters to filter, sort, and paginate the results.
467
498
  *
@@ -490,6 +521,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
490
521
  * ```
491
522
  *
492
523
  * @typeParam TDocument - Type of Prismic documents returned.
524
+ *
493
525
  * @param ids - A list of document IDs.
494
526
  * @param params - Parameters to filter, sort, and paginate the results.
495
527
  *
@@ -512,6 +544,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
512
544
  * ```
513
545
  *
514
546
  * @typeParam TDocument - Type of the Prismic document returned.
547
+ *
515
548
  * @param documentType - The API ID of the document's custom type.
516
549
  * @param uid - UID of the document.
517
550
  * @param params - Parameters to filter, sort, and paginate the results.
@@ -539,6 +572,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
539
572
  * ```
540
573
  *
541
574
  * @typeParam TDocument - Type of the Prismic document returned.
575
+ *
542
576
  * @param documentType - The API ID of the document's custom type.
543
577
  * @param uids - A list of document UIDs.
544
578
  * @param params - Parameters to filter, sort, and paginate the results.
@@ -569,6 +603,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
569
603
  * ```
570
604
  *
571
605
  * @typeParam TDocument - Type of Prismic documents returned.
606
+ *
572
607
  * @param documentType - The API ID of the document's custom type.
573
608
  * @param uids - A list of document UIDs.
574
609
  * @param params - Parameters to filter, sort, and paginate the results.
@@ -592,6 +627,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
592
627
  * ```
593
628
  *
594
629
  * @typeParam TDocument - Type of the Prismic document returned.
630
+ *
595
631
  * @param documentType - The API ID of the singleton custom type.
596
632
  * @param params - Parameters to filter, sort, and paginate the results.
597
633
  *
@@ -612,6 +648,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
612
648
  * ```
613
649
  *
614
650
  * @typeParam TDocument - Type of Prismic documents returned.
651
+ *
615
652
  * @param documentType - The API ID of the custom type.
616
653
  * @param params - Parameters to filter, sort, and paginate the results.
617
654
  *
@@ -632,6 +669,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
632
669
  * ```
633
670
  *
634
671
  * @typeParam TDocument - Type of Prismic documents returned.
672
+ *
635
673
  * @param documentType - The API ID of the custom type.
636
674
  * @param params - Parameters to filter, sort, and paginate the results.
637
675
  *
@@ -651,6 +689,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
651
689
  * ```
652
690
  *
653
691
  * @typeParam TDocument - Type of Prismic documents returned.
692
+ *
654
693
  * @param tag - The tag that must be included on a document.
655
694
  * @param params - Parameters to filter, sort, and paginate the results.
656
695
  *
@@ -670,6 +709,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
670
709
  * ```
671
710
  *
672
711
  * @typeParam TDocument - Type of Prismic documents returned.
712
+ *
673
713
  * @param tag - The tag that must be included on a document.
674
714
  * @param params - Parameters to filter, sort, and paginate the results.
675
715
  *
@@ -687,6 +727,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
687
727
  * ```
688
728
  *
689
729
  * @typeParam TDocument - Type of Prismic documents returned.
730
+ *
690
731
  * @param tags - A list of tags that must be included on a document.
691
732
  * @param params - Parameters to filter, sort, and paginate the results.
692
733
  *
@@ -707,6 +748,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
707
748
  * ```
708
749
  *
709
750
  * @typeParam TDocument - Type of Prismic documents returned.
751
+ *
710
752
  * @param tags - A list of tags that must be included on a document.
711
753
  * @param params - Parameters to filter, sort, and paginate the results.
712
754
  *
@@ -725,6 +767,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
725
767
  * ```
726
768
  *
727
769
  * @typeParam TDocument - Type of Prismic documents returned.
770
+ *
728
771
  * @param tags - A list of tags that must be included on a document.
729
772
  * @param params - Parameters to filter, sort, and paginate the results.
730
773
  *
@@ -747,6 +790,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
747
790
  * ```
748
791
  *
749
792
  * @typeParam TDocument - Type of Prismic documents returned.
793
+ *
750
794
  * @param tags - A list of tags that must be included on a document.
751
795
  * @param params - Parameters to filter, sort, and paginate the results.
752
796
  *
@@ -943,6 +987,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
943
987
  * supported.
944
988
  *
945
989
  * @returns The `fetch()` Response for the request.
990
+ *
946
991
  * @experimental
947
992
  */
948
993
  graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
@@ -961,6 +1006,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
961
1006
  * @param name - Name of the form.
962
1007
  *
963
1008
  * @returns The repository form.
1009
+ *
964
1010
  * @throws If a matching form cannot be found.
965
1011
  */
966
1012
  private getCachedRepositoryForm;
@@ -994,6 +1040,7 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
994
1040
  * normalizes unsuccessful network requests.
995
1041
  *
996
1042
  * @typeParam T - The JSON response.
1043
+ *
997
1044
  * @param url - URL to the resource to fetch.
998
1045
  * @param params - Prismic REST API parameters for the network request.
999
1046
  *
@@ -86,6 +86,17 @@ class Client {
86
86
  * Node.js, this function must be provided.
87
87
  */
88
88
  __publicField(this, "fetchFn");
89
+ /**
90
+ * Options or a function that returns options provided to the client's
91
+ * `fetch()` on all network requests. These options will be merged with
92
+ * internally required options. They can also be overriden on a per-query
93
+ * basis using the query's `fetchOptions` parameter.
94
+ *
95
+ * If the options must be determined on-demand, a function can be provided.
96
+ * This function can be asynchronous.
97
+ *
98
+ * @experimental
99
+ */
89
100
  __publicField(this, "fetchOptions");
90
101
  /**
91
102
  * Default parameters that will be sent with each query. These parameters can
@@ -215,6 +226,7 @@ class Client {
215
226
  * ```
216
227
  *
217
228
  * @typeParam TDocument - Type of Prismic documents returned.
229
+ *
218
230
  * @param params - Parameters to filter, sort, and paginate results.
219
231
  *
220
232
  * @returns A paginated response containing the result of the query.
@@ -234,6 +246,7 @@ class Client {
234
246
  * ```
235
247
  *
236
248
  * @typeParam TDocument - Type of the Prismic document returned.
249
+ *
237
250
  * @param params - Parameters to filter, sort, and paginate results. @returns
238
251
  * The first result of the query, if any.
239
252
  */
@@ -269,6 +282,7 @@ class Client {
269
282
  * ```
270
283
  *
271
284
  * @typeParam TDocument - Type of Prismic documents returned.
285
+ *
272
286
  * @param params - Parameters to filter, sort, and paginate results.
273
287
  *
274
288
  * @returns A list of documents matching the query.
@@ -307,6 +321,7 @@ class Client {
307
321
  * ```
308
322
  *
309
323
  * @typeParam TDocument- Type of the Prismic document returned.
324
+ *
310
325
  * @param id - ID of the document.
311
326
  * @param params - Parameters to filter, sort, and paginate the results.
312
327
  *
@@ -334,6 +349,7 @@ class Client {
334
349
  * ```
335
350
  *
336
351
  * @typeParam TDocument - Type of Prismic documents returned.
352
+ *
337
353
  * @param ids - A list of document IDs.
338
354
  * @param params - Parameters to filter, sort, and paginate the results.
339
355
  *
@@ -364,6 +380,7 @@ class Client {
364
380
  * ```
365
381
  *
366
382
  * @typeParam TDocument - Type of Prismic documents returned.
383
+ *
367
384
  * @param ids - A list of document IDs.
368
385
  * @param params - Parameters to filter, sort, and paginate the results.
369
386
  *
@@ -388,6 +405,7 @@ class Client {
388
405
  * ```
389
406
  *
390
407
  * @typeParam TDocument - Type of the Prismic document returned.
408
+ *
391
409
  * @param documentType - The API ID of the document's custom type.
392
410
  * @param uid - UID of the document.
393
411
  * @param params - Parameters to filter, sort, and paginate the results.
@@ -420,6 +438,7 @@ class Client {
420
438
  * ```
421
439
  *
422
440
  * @typeParam TDocument - Type of the Prismic document returned.
441
+ *
423
442
  * @param documentType - The API ID of the document's custom type.
424
443
  * @param uids - A list of document UIDs.
425
444
  * @param params - Parameters to filter, sort, and paginate the results.
@@ -455,6 +474,7 @@ class Client {
455
474
  * ```
456
475
  *
457
476
  * @typeParam TDocument - Type of Prismic documents returned.
477
+ *
458
478
  * @param documentType - The API ID of the document's custom type.
459
479
  * @param uids - A list of document UIDs.
460
480
  * @param params - Parameters to filter, sort, and paginate the results.
@@ -483,6 +503,7 @@ class Client {
483
503
  * ```
484
504
  *
485
505
  * @typeParam TDocument - Type of the Prismic document returned.
506
+ *
486
507
  * @param documentType - The API ID of the singleton custom type.
487
508
  * @param params - Parameters to filter, sort, and paginate the results.
488
509
  *
@@ -505,6 +526,7 @@ class Client {
505
526
  * ```
506
527
  *
507
528
  * @typeParam TDocument - Type of Prismic documents returned.
529
+ *
508
530
  * @param documentType - The API ID of the custom type.
509
531
  * @param params - Parameters to filter, sort, and paginate the results.
510
532
  *
@@ -527,6 +549,7 @@ class Client {
527
549
  * ```
528
550
  *
529
551
  * @typeParam TDocument - Type of Prismic documents returned.
552
+ *
530
553
  * @param documentType - The API ID of the custom type.
531
554
  * @param params - Parameters to filter, sort, and paginate the results.
532
555
  *
@@ -548,6 +571,7 @@ class Client {
548
571
  * ```
549
572
  *
550
573
  * @typeParam TDocument - Type of Prismic documents returned.
574
+ *
551
575
  * @param tag - The tag that must be included on a document.
552
576
  * @param params - Parameters to filter, sort, and paginate the results.
553
577
  *
@@ -569,6 +593,7 @@ class Client {
569
593
  * ```
570
594
  *
571
595
  * @typeParam TDocument - Type of Prismic documents returned.
596
+ *
572
597
  * @param tag - The tag that must be included on a document.
573
598
  * @param params - Parameters to filter, sort, and paginate the results.
574
599
  *
@@ -588,6 +613,7 @@ class Client {
588
613
  * ```
589
614
  *
590
615
  * @typeParam TDocument - Type of Prismic documents returned.
616
+ *
591
617
  * @param tags - A list of tags that must be included on a document.
592
618
  * @param params - Parameters to filter, sort, and paginate the results.
593
619
  *
@@ -610,6 +636,7 @@ class Client {
610
636
  * ```
611
637
  *
612
638
  * @typeParam TDocument - Type of Prismic documents returned.
639
+ *
613
640
  * @param tags - A list of tags that must be included on a document.
614
641
  * @param params - Parameters to filter, sort, and paginate the results.
615
642
  *
@@ -630,6 +657,7 @@ class Client {
630
657
  * ```
631
658
  *
632
659
  * @typeParam TDocument - Type of Prismic documents returned.
660
+ *
633
661
  * @param tags - A list of tags that must be included on a document.
634
662
  * @param params - Parameters to filter, sort, and paginate the results.
635
663
  *
@@ -654,6 +682,7 @@ class Client {
654
682
  * ```
655
683
  *
656
684
  * @typeParam TDocument - Type of Prismic documents returned.
685
+ *
657
686
  * @param tags - A list of tags that must be included on a document.
658
687
  * @param params - Parameters to filter, sort, and paginate the results.
659
688
  *
@@ -954,6 +983,7 @@ class Client {
954
983
  * supported.
955
984
  *
956
985
  * @returns The `fetch()` Response for the request.
986
+ *
957
987
  * @experimental
958
988
  */
959
989
  async graphQLFetch(input, init) {
@@ -1019,6 +1049,7 @@ class Client {
1019
1049
  * @param name - Name of the form.
1020
1050
  *
1021
1051
  * @returns The repository form.
1052
+ *
1022
1053
  * @throws If a matching form cannot be found.
1023
1054
  */
1024
1055
  async getCachedRepositoryForm(name, params) {
@@ -1093,21 +1124,23 @@ class Client {
1093
1124
  * normalizes unsuccessful network requests.
1094
1125
  *
1095
1126
  * @typeParam T - The JSON response.
1127
+ *
1096
1128
  * @param url - URL to the resource to fetch.
1097
1129
  * @param params - Prismic REST API parameters for the network request.
1098
1130
  *
1099
1131
  * @returns The JSON response from the network request.
1100
1132
  */
1101
1133
  async fetch(url, params = {}) {
1102
- var _a, _b, _c, _d;
1134
+ const paramsFetchOptions = await castThunk(params.fetchOptions)(url);
1135
+ const thisFetchOptions = await castThunk(this.fetchOptions)(url, paramsFetchOptions);
1103
1136
  const requestInit = {
1104
- ...this.fetchOptions,
1105
- ...params.fetchOptions,
1137
+ ...paramsFetchOptions,
1138
+ ...thisFetchOptions,
1106
1139
  headers: {
1107
- ...(_a = this.fetchOptions) == null ? void 0 : _a.headers,
1108
- ...(_b = params.fetchOptions) == null ? void 0 : _b.headers
1140
+ ...paramsFetchOptions == null ? void 0 : paramsFetchOptions.headers,
1141
+ ...thisFetchOptions == null ? void 0 : thisFetchOptions.headers
1109
1142
  },
1110
- signal: ((_c = params.fetchOptions) == null ? void 0 : _c.signal) || params.signal || ((_d = this.fetchOptions) == null ? void 0 : _d.signal)
1143
+ signal: (paramsFetchOptions == null ? void 0 : paramsFetchOptions.signal) || params.signal || (thisFetchOptions == null ? void 0 : thisFetchOptions.signal)
1111
1144
  };
1112
1145
  let job;
1113
1146
  if (this.fetchJobs[url] && this.fetchJobs[url].has(requestInit.signal)) {