@prismicio/client 6.7.3 → 6.9.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.
package/dist/client.d.ts CHANGED
@@ -1,929 +1,943 @@
1
- import * as prismicT from "@prismicio/types";
2
- import * as prismicH from "@prismicio/helpers";
3
- import { AbortSignalLike, FetchLike, HttpRequestLike, ExtractDocumentType } from "./types";
4
- import { BuildQueryURLArgs } from "./buildQueryURL";
5
- /**
6
- * The number of milliseconds in which repository metadata is considered valid.
7
- * A ref can be invalidated quickly depending on how frequently content is
8
- * updated in the Prismic repository. As such, repository's metadata can only be
9
- * considered valid for a short amount of time.
10
- */
11
- export declare const REPOSITORY_CACHE_TTL = 5000;
12
- /**
13
- * The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,
14
- * `getAllByType`, `getAllByTag`) will wait between individual page requests.
15
- *
16
- * This is done to ensure API performance is sustainable and reduces the chance
17
- * of a failed API request due to overloading.
18
- */
19
- export declare const GET_ALL_QUERY_DELAY = 500;
20
- /**
21
- * A ref or a function that returns a ref. If a static ref is known, one can be
22
- * given. If the ref must be fetched on-demand, a function can be provided. This
23
- * function can optionally be asynchronous.
24
- */
25
- type RefStringOrThunk = string | (() => string | undefined | Promise<string | undefined>);
26
- /**
27
- * Configuration for clients that determine how content is queried.
28
- */
29
- export type ClientConfig = {
30
- /**
31
- * The secure token for accessing the Prismic repository. This is only
32
- * required if the repository is set to private.
33
- */
34
- accessToken?: string;
35
- /**
36
- * A string representing a version of the Prismic repository's content. This
37
- * may point to the latest version (called the "master ref"), or a preview
38
- * with draft content.
39
- */
40
- ref?: RefStringOrThunk;
41
- /**
42
- * A list of Route Resolver objects that define how a document's `url` field
43
- * is resolved.
44
- *
45
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
46
- */
47
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
48
- /**
49
- * The `brokenRoute` option allows you to define the route populated in the
50
- * `url` property for broken Link or Content Relationship fields. A broken
51
- * link is a Link or Content Relationship field whose linked document has been
52
- * unpublished or deleted.
53
- *
54
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
55
- */
56
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
57
- /**
58
- * Default parameters that will be sent with each query. These parameters can
59
- * be overridden on each query if needed.
60
- */
61
- defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes" | "brokenRoute">;
62
- /**
63
- * The function used to make network requests to the Prismic REST API. In
64
- * environments where a global `fetch` function does not exist, such as
65
- * Node.js, this function must be provided.
66
- */
67
- fetch?: FetchLike;
68
- };
69
- /**
70
- * Parameters for any client method that use `fetch()`. Only a subset of
71
- * `fetch()` parameters are exposed.
72
- */
73
- type FetchParams = {
74
- /**
75
- * An `AbortSignal` provided by an `AbortController`. This allows the network
76
- * request to be cancelled if necessary.
77
- *
78
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
79
- */
80
- signal?: AbortSignalLike;
81
- };
82
- /**
83
- * Parameters specific to client methods that fetch all documents. These methods
84
- * start with `getAll` (for example, `getAllByType`).
85
- */
86
- type GetAllParams = {
87
- /**
88
- * Limit the number of documents queried. If a number is not provided, there
89
- * will be no limit and all matching documents will be returned.
90
- */
91
- limit?: number;
92
- };
93
- /**
94
- * Arguments to determine how the URL for a preview session is resolved.
95
- */
96
- type ResolvePreviewArgs<LinkResolverReturnType> = {
97
- /**
98
- * A function that maps a Prismic document to a URL within your app.
99
- */
100
- linkResolver?: prismicH.LinkResolverFunction<LinkResolverReturnType>;
101
- /**
102
- * A fallback URL if the Link Resolver does not return a value.
103
- */
104
- defaultURL: string;
105
- /**
106
- * The preview token (also known as a ref) that will be used to query preview
107
- * content from the Prismic repository.
108
- */
109
- previewToken?: string;
110
- /**
111
- * The previewed document that will be used to determine the destination URL.
112
- */
113
- documentID?: string;
114
- };
115
- /**
116
- * Type definitions for the `createClient()` function. May be augmented by
117
- * third-party libraries.
118
- */
119
- export interface CreateClient {
120
- <TDocuments extends prismicT.PrismicDocument>(...args: ConstructorParameters<typeof Client>): Client<TDocuments>;
121
- }
122
- /**
123
- * Creates a Prismic client that can be used to query a repository.
124
- *
125
- * @example
126
- *
127
- * ```ts
128
- * // With a repository name.
129
- * createClient("qwerty");
130
- *
131
- * // Or with a full Prismic Rest API V2 endpoint.
132
- * createClient("https://qwerty.cdn.prismic.io/api/v2");
133
- * ```
134
- *
135
- * @typeParam TDocuments - A map of Prismic document type IDs mapped to their
136
- * TypeScript type.
137
- * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
138
- * API V2 endpoint for the repository.
139
- * @param options - Configuration that determines how content will be queried
140
- * from the Prismic repository.
141
- *
142
- * @returns A client that can query content from the repository.
143
- */
144
- export declare const createClient: CreateClient;
145
- /**
146
- * A client that allows querying content from a Prismic repository.
147
- *
148
- * If used in an environment where a global `fetch` function is unavailable,
149
- * such as Node.js, the `fetch` option must be provided as part of the `options`
150
- * parameter.
151
- *
152
- * @typeParam TDocuments - Document types that are registered for the Prismic
153
- * repository. Query methods will automatically be typed based on this type.
154
- */
155
- export declare class Client<TDocuments extends prismicT.PrismicDocument = prismicT.PrismicDocument> {
156
- /**
157
- * The Prismic REST API V2 endpoint for the repository (use
158
- * `prismic.getRepositoryEndpoint` for the default endpoint).
159
- */
160
- endpoint: string;
161
- /**
162
- * The secure token for accessing the API (only needed if your repository is
163
- * set to private).
164
- *
165
- * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
166
- */
167
- accessToken?: string;
168
- /**
169
- * A list of Route Resolver objects that define how a document's `url` field
170
- * is resolved.
171
- *
172
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
173
- */
174
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
175
- /**
176
- * The `brokenRoute` option allows you to define the route populated in the
177
- * `url` property for broken Link or Content Relationship fields. A broken
178
- * link is a Link or Content Relationship field whose linked document has been
179
- * unpublished or deleted.
180
- *
181
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
182
- */
183
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
184
- /**
185
- * The function used to make network requests to the Prismic REST API. In
186
- * environments where a global `fetch` function does not exist, such as
187
- * Node.js, this function must be provided.
188
- */
189
- fetchFn: FetchLike;
190
- /**
191
- * Default parameters that will be sent with each query. These parameters can
192
- * be overridden on each query if needed.
193
- */
194
- defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes">;
195
- /**
196
- * The client's ref mode state. This determines which ref is used during
197
- * queries.
198
- */
199
- private refState;
200
- /**
201
- * Cached repository value.
202
- */
203
- private cachedRepository;
204
- /**
205
- * Timestamp at which the cached repository data is considered stale.
206
- */
207
- private cachedRepositoryExpiration;
208
- /**
209
- * Creates a Prismic client that can be used to query a repository.
210
- *
211
- * If used in an environment where a global `fetch` function is unavailable,
212
- * such as Node.js, the `fetch` option must be provided as part of the
213
- * `options` parameter.
214
- *
215
- * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
216
- * API V2 endpoint for the repository.
217
- * @param options - Configuration that determines how content will be queried
218
- * from the Prismic repository.
219
- *
220
- * @returns A client that can query content from the repository.
221
- */
222
- constructor(repositoryNameOrEndpoint: string, options?: ClientConfig);
223
- /**
224
- * Enables the client to automatically query content from a preview session if
225
- * one is active in browser environments. This is enabled by default in the
226
- * browser.
227
- *
228
- * For server environments, use `enableAutoPreviewsFromReq`.
229
- *
230
- * @example
231
- *
232
- * ```ts
233
- * client.enableAutoPreviews();
234
- * ```
235
- *
236
- * @see enableAutoPreviewsFromReq
237
- */
238
- enableAutoPreviews(): void;
239
- /**
240
- * Enables the client to automatically query content from a preview session if
241
- * one is active in server environments. This is disabled by default on the
242
- * server.
243
- *
244
- * For browser environments, use `enableAutoPreviews`.
245
- *
246
- * @example
247
- *
248
- * ```ts
249
- * // In an express app
250
- * app.get("/", function (req, res) {
251
- * client.enableAutoPreviewsFromReq(req);
252
- * });
253
- * ```
254
- *
255
- * @param req - An HTTP server request object containing the request's
256
- * cookies.
257
- */
258
- enableAutoPreviewsFromReq<R extends HttpRequestLike>(req: R): void;
259
- /**
260
- * Disables the client from automatically querying content from a preview
261
- * session if one is active.
262
- *
263
- * Automatic preview content querying is enabled by default unless this method
264
- * is called.
265
- *
266
- * @example
267
- *
268
- * ```ts
269
- * client.disableAutoPreviews();
270
- * ```
271
- */
272
- disableAutoPreviews(): void;
273
- /**
274
- * Queries content from the Prismic repository.
275
- *
276
- * @deprecated Use `get` instead.
277
- * @example
278
- *
279
- * ```ts
280
- * const response = await client.query(
281
- * prismic.predicate.at("document.type", "page"),
282
- * );
283
- * ```
284
- *
285
- * @typeParam TDocument - Type of Prismic documents returned.
286
- * @param params - Parameters to filter, sort, and paginate results.
287
- *
288
- * @returns A paginated response containing the result of the query.
289
- */
290
- query<TDocument extends TDocuments>(predicates: NonNullable<BuildQueryURLArgs["predicates"]>, params?: Partial<Omit<BuildQueryURLArgs, "predicates">> & FetchParams): Promise<prismicT.Query<TDocument>>;
291
- /**
292
- * Queries content from the Prismic repository.
293
- *
294
- * @example
295
- *
296
- * ```ts
297
- * const response = await client.get();
298
- * ```
299
- *
300
- * @typeParam TDocument - Type of Prismic documents returned.
301
- * @param params - Parameters to filter, sort, and paginate results.
302
- *
303
- * @returns A paginated response containing the result of the query.
304
- */
305
- get<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
306
- /**
307
- * Queries content from the Prismic repository and returns only the first
308
- * result, if any.
309
- *
310
- * @example
311
- *
312
- * ```ts
313
- * const document = await client.getFirst();
314
- * ```
315
- *
316
- * @typeParam TDocument - Type of the Prismic document returned.
317
- * @param params - Parameters to filter, sort, and paginate results. @returns
318
- * The first result of the query, if any.
319
- */
320
- getFirst<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
321
- /**
322
- * **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
323
- * require more resources than other methods. Prefer using other methods that
324
- * filter by predicates such as `getAllByType`.
325
- *
326
- * Queries content from the Prismic repository and returns all matching
327
- * content. If no predicates are provided, all documents will be fetched.
328
- *
329
- * This method may make multiple network requests to query all matching
330
- * content.
331
- *
332
- * @example
333
- *
334
- * ```ts
335
- * const response = await client.dangerouslyGetAll();
336
- * ```
337
- *
338
- * @typeParam TDocument - Type of Prismic documents returned.
339
- * @param params - Parameters to filter, sort, and paginate results.
340
- *
341
- * @returns A list of documents matching the query.
342
- */
343
- dangerouslyGetAll<TDocument extends TDocuments>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
344
- /**
345
- * Queries a document from the Prismic repository with a specific ID.
346
- *
347
- * @remarks
348
- * A document's UID is different from its ID. An ID is automatically generated
349
- * for all documents and is made available on its `id` property. A UID is
350
- * provided in the Prismic editor and is unique among all documents of its
351
- * Custom Type.
352
- * @example
353
- *
354
- * ```ts
355
- * const document = await client.getByID("WW4bKScAAMAqmluX");
356
- * ```
357
- *
358
- * @typeParam TDocument- Type of the Prismic document returned.
359
- * @param id - ID of the document.
360
- * @param params - Parameters to filter, sort, and paginate the results.
361
- *
362
- * @returns The document with an ID matching the `id` parameter, if a matching
363
- * document exists.
364
- */
365
- getByID<TDocument extends TDocuments>(id: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
366
- /**
367
- * Queries documents from the Prismic repository with specific IDs.
368
- *
369
- * @remarks
370
- * A document's UID is different from its ID. An ID is automatically generated
371
- * for all documents and is made available on its `id` property. A UID is
372
- * provided in the Prismic editor and is unique among all documents of its
373
- * Custom Type.
374
- * @example
375
- *
376
- * ```ts
377
- * const response = await client.getByIDs([
378
- * "WW4bKScAAMAqmluX",
379
- * "U1kTRgEAAC8A5ldS",
380
- * ]);
381
- * ```
382
- *
383
- * @typeParam TDocument - Type of Prismic documents returned.
384
- * @param ids - A list of document IDs.
385
- * @param params - Parameters to filter, sort, and paginate the results.
386
- *
387
- * @returns A paginated response containing documents with IDs matching the
388
- * `ids` parameter.
389
- */
390
- getByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
391
- /**
392
- * Queries all documents from the Prismic repository with specific IDs.
393
- *
394
- * This method may make multiple network requests to query all matching
395
- * content.
396
- *
397
- * @remarks
398
- * A document's UID is different from its ID. An ID is automatically generated
399
- * for all documents and is made available on its `id` property. A UID is
400
- * provided in the Prismic editor and is unique among all documents of its
401
- * Custom Type.
402
- * @example
403
- *
404
- * ```ts
405
- * const response = await client.getAllByIDs([
406
- * "WW4bKScAAMAqmluX",
407
- * "U1kTRgEAAC8A5ldS",
408
- * ]);
409
- * ```
410
- *
411
- * @typeParam TDocument - Type of Prismic documents returned.
412
- * @param ids - A list of document IDs.
413
- * @param params - Parameters to filter, sort, and paginate the results.
414
- *
415
- * @returns A list of documents with IDs matching the `ids` parameter.
416
- */
417
- getAllByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<TDocument[]>;
418
- /**
419
- * Queries a document from the Prismic repository with a specific UID and
420
- * Custom Type.
421
- *
422
- * @remarks
423
- * A document's UID is different from its ID. An ID is automatically generated
424
- * for all documents and is made available on its `id` property. A UID is
425
- * provided in the Prismic editor and is unique among all documents of its
426
- * Custom Type.
427
- * @example
428
- *
429
- * ```ts
430
- * const document = await client.getByUID("blog_post", "my-first-post");
431
- * ```
432
- *
433
- * @typeParam TDocument - Type of the Prismic document returned.
434
- * @param documentType - The API ID of the document's Custom Type.
435
- * @param uid - UID of the document.
436
- * @param params - Parameters to filter, sort, and paginate the results.
437
- *
438
- * @returns The document with a UID matching the `uid` parameter, if a
439
- * matching document exists.
440
- */
441
- getByUID<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uid: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
442
- /**
443
- * Queries document from the Prismic repository with specific UIDs and Custom
444
- * Type.
445
- *
446
- * @remarks
447
- * A document's UID is different from its ID. An ID is automatically generated
448
- * for all documents and is made available on its `id` property. A UID is
449
- * provided in the Prismic editor and is unique among all documents of its
450
- * Custom Type.
451
- * @example
452
- *
453
- * ```ts
454
- * const document = await client.getByUIDs("blog_post", [
455
- * "my-first-post",
456
- * "my-second-post",
457
- * ]);
458
- * ```
459
- *
460
- * @typeParam TDocument - Type of the Prismic document returned.
461
- * @param documentType - The API ID of the document's Custom Type.
462
- * @param uids - A list of document UIDs.
463
- * @param params - Parameters to filter, sort, and paginate the results.
464
- *
465
- * @returns A paginated response containing documents with UIDs matching the
466
- * `uids` parameter.
467
- */
468
- getByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>>;
469
- /**
470
- * Queries all documents from the Prismic repository with specific UIDs and
471
- * Custom Type.
472
- *
473
- * This method may make multiple network requests to query all matching
474
- * content.
475
- *
476
- * @remarks
477
- * A document's UID is different from its ID. An ID is automatically generated
478
- * for all documents and is made available on its `id` property. A UID is
479
- * provided in the Prismic editor and is unique among all documents of its
480
- * Custom Type.
481
- * @example
482
- *
483
- * ```ts
484
- * const response = await client.getAllByUIDs([
485
- * "my-first-post",
486
- * "my-second-post",
487
- * ]);
488
- * ```
489
- *
490
- * @typeParam TDocument - Type of Prismic documents returned.
491
- * @param documentType - The API ID of the document's Custom Type.
492
- * @param uids - A list of document UIDs.
493
- * @param params - Parameters to filter, sort, and paginate the results.
494
- *
495
- * @returns A list of documents with UIDs matching the `uids` parameter.
496
- */
497
- getAllByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
498
- /**
499
- * Queries a singleton document from the Prismic repository for a specific
500
- * Custom Type.
501
- *
502
- * @remarks
503
- * A singleton document is one that is configured in Prismic to only allow one
504
- * instance. For example, a repository may be configured to contain just one
505
- * Settings document. This is in contrast to a repeatable Custom Type which
506
- * allows multiple instances of itself.
507
- * @example
508
- *
509
- * ```ts
510
- * const document = await client.getSingle("settings");
511
- * ```
512
- *
513
- * @typeParam TDocument - Type of the Prismic document returned.
514
- * @param documentType - The API ID of the singleton Custom Type.
515
- * @param params - Parameters to filter, sort, and paginate the results.
516
- *
517
- * @returns The singleton document for the Custom Type, if a matching document
518
- * exists.
519
- */
520
- getSingle<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
521
- /**
522
- * Queries documents from the Prismic repository for a specific Custom Type.
523
- *
524
- * Use `getAllByType` instead if you need to query all documents for a
525
- * specific Custom Type.
526
- *
527
- * @example
528
- *
529
- * ```ts
530
- * const response = await client.getByType("blog_post");
531
- * ```
532
- *
533
- * @typeParam TDocument - Type of Prismic documents returned.
534
- * @param documentType - The API ID of the Custom Type.
535
- * @param params - Parameters to filter, sort, and paginate the results.
536
- *
537
- * @returns A paginated response containing documents of the Custom Type.
538
- */
539
- getByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>>;
540
- /**
541
- * Queries all documents from the Prismic repository for a specific Custom
542
- * Type.
543
- *
544
- * This method may make multiple network requests to query all matching
545
- * content.
546
- *
547
- * @example
548
- *
549
- * ```ts
550
- * const response = await client.getByType("blog_post");
551
- * ```
552
- *
553
- * @typeParam TDocument - Type of Prismic documents returned.
554
- * @param documentType - The API ID of the Custom Type.
555
- * @param params - Parameters to filter, sort, and paginate the results.
556
- *
557
- * @returns A list of all documents of the Custom Type.
558
- */
559
- getAllByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
560
- /**
561
- * Queries documents from the Prismic repository with a specific tag.
562
- *
563
- * Use `getAllByTag` instead if you need to query all documents with a
564
- * specific tag.
565
- *
566
- * @example
567
- *
568
- * ```ts
569
- * const response = await client.getByTag("food");
570
- * ```
571
- *
572
- * @typeParam TDocument - Type of Prismic documents returned.
573
- * @param tag - The tag that must be included on a document.
574
- * @param params - Parameters to filter, sort, and paginate the results.
575
- *
576
- * @returns A paginated response containing documents with the tag.
577
- */
578
- getByTag<TDocument extends TDocuments>(tag: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
579
- /**
580
- * Queries all documents from the Prismic repository with a specific tag.
581
- *
582
- * This method may make multiple network requests to query all matching
583
- * content.
584
- *
585
- * @example
586
- *
587
- * ```ts
588
- * const response = await client.getAllByTag("food");
589
- * ```
590
- *
591
- * @typeParam TDocument - Type of Prismic documents returned.
592
- * @param tag - The tag that must be included on a document.
593
- * @param params - Parameters to filter, sort, and paginate the results.
594
- *
595
- * @returns A list of all documents with the tag.
596
- */
597
- getAllByTag<TDocument extends TDocuments>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
598
- /**
599
- * Queries documents from the Prismic repository with specific tags. A
600
- * document must be tagged with all of the queried tags to be included.
601
- *
602
- * @example
603
- *
604
- * ```ts
605
- * const response = await client.getByEveryTag(["food", "fruit"]);
606
- * ```
607
- *
608
- * @typeParam TDocument - Type of Prismic documents returned.
609
- * @param tags - A list of tags that must be included on a document.
610
- * @param params - Parameters to filter, sort, and paginate the results.
611
- *
612
- * @returns A paginated response containing documents with the tags.
613
- */
614
- getByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
615
- /**
616
- * Queries documents from the Prismic repository with specific tags. A
617
- * document must be tagged with all of the queried tags to be included.
618
- *
619
- * This method may make multiple network requests to query all matching
620
- * content.
621
- *
622
- * @example
623
- *
624
- * ```ts
625
- * const response = await client.getAllByEveryTag(["food", "fruit"]);
626
- * ```
627
- *
628
- * @typeParam TDocument - Type of Prismic documents returned.
629
- * @param tags - A list of tags that must be included on a document.
630
- * @param params - Parameters to filter, sort, and paginate the results.
631
- *
632
- * @returns A list of all documents with the tags.
633
- */
634
- getAllByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
635
- /**
636
- * Queries documents from the Prismic repository with specific tags. A
637
- * document must be tagged with at least one of the queried tags to be
638
- * included.
639
- *
640
- * @example
641
- *
642
- * ```ts
643
- * const response = await client.getByEveryTag(["food", "fruit"]);
644
- * ```
645
- *
646
- * @typeParam TDocument - Type of Prismic documents returned.
647
- * @param tags - A list of tags that must be included on a document.
648
- * @param params - Parameters to filter, sort, and paginate the results.
649
- *
650
- * @returns A paginated response containing documents with at least one of the
651
- * tags.
652
- */
653
- getBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
654
- /**
655
- * Queries documents from the Prismic repository with specific tags. A
656
- * document must be tagged with at least one of the queried tags to be
657
- * included.
658
- *
659
- * This method may make multiple network requests to query all matching
660
- * content.
661
- *
662
- * @example
663
- *
664
- * ```ts
665
- * const response = await client.getAllBySomeTags(["food", "fruit"]);
666
- * ```
667
- *
668
- * @typeParam TDocument - Type of Prismic documents returned.
669
- * @param tags - A list of tags that must be included on a document.
670
- * @param params - Parameters to filter, sort, and paginate the results.
671
- *
672
- * @returns A list of all documents with at least one of the tags.
673
- */
674
- getAllBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
675
- /**
676
- * Returns metadata about the Prismic repository, such as its refs, releases,
677
- * and custom types.
678
- *
679
- * @returns Repository metadata.
680
- */
681
- getRepository(params?: FetchParams): Promise<prismicT.Repository>;
682
- /**
683
- * Returns a list of all refs for the Prismic repository.
684
- *
685
- * Refs are used to identify which version of the repository's content should
686
- * be queried. All repositories will have at least one ref pointing to the
687
- * latest published content called the "master ref".
688
- *
689
- * @returns A list of all refs for the Prismic repository.
690
- */
691
- getRefs(params?: FetchParams): Promise<prismicT.Ref[]>;
692
- /**
693
- * Returns a ref for the Prismic repository with a matching ID.
694
- *
695
- * @param id - ID of the ref.
696
- *
697
- * @returns The ref with a matching ID, if it exists.
698
- */
699
- getRefByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
700
- /**
701
- * Returns a ref for the Prismic repository with a matching label.
702
- *
703
- * @param label - Label of the ref.
704
- *
705
- * @returns The ref with a matching label, if it exists.
706
- */
707
- getRefByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
708
- /**
709
- * Returns the master ref for the Prismic repository. The master ref points to
710
- * the repository's latest published content.
711
- *
712
- * @returns The repository's master ref.
713
- */
714
- getMasterRef(params?: FetchParams): Promise<prismicT.Ref>;
715
- /**
716
- * Returns a list of all Releases for the Prismic repository. Releases are
717
- * used to group content changes before publishing.
718
- *
719
- * @returns A list of all Releases for the Prismic repository.
720
- */
721
- getReleases(params?: FetchParams): Promise<prismicT.Ref[]>;
722
- /**
723
- * Returns a Release for the Prismic repository with a matching ID.
724
- *
725
- * @param id - ID of the Release.
726
- *
727
- * @returns The Release with a matching ID, if it exists.
728
- */
729
- getReleaseByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
730
- /**
731
- * Returns a Release for the Prismic repository with a matching label.
732
- *
733
- * @param label - Label of the ref.
734
- *
735
- * @returns The ref with a matching label, if it exists.
736
- */
737
- getReleaseByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
738
- /**
739
- * Returns a list of all tags used in the Prismic repository.
740
- *
741
- * @returns A list of all tags used in the repository.
742
- */
743
- getTags(params?: FetchParams): Promise<string[]>;
744
- /**
745
- * Builds a URL used to query content from the Prismic repository.
746
- *
747
- * @param params - Parameters to filter, sort, and paginate the results.
748
- *
749
- * @returns A URL string that can be requested to query content.
750
- */
751
- buildQueryURL({ signal, ...params }?: Partial<BuildQueryURLArgs> & FetchParams): Promise<string>;
752
- /**
753
- * Determines the URL for a previewed document during an active preview
754
- * session. The result of this method should be used to redirect the user to
755
- * the document's URL.
756
- *
757
- * @example
758
- *
759
- * ```ts
760
- * const url = client.resolvePreviewURL({
761
- * linkResolver: (document) => `/${document.uid}`
762
- * defaultURL: '/'
763
- * })
764
- * ```
765
- *
766
- * @param args - Arguments to configure the URL resolving.
767
- *
768
- * @returns The URL for the previewed document during an active preview
769
- * session. The user should be redirected to this URL.
770
- */
771
- resolvePreviewURL<LinkResolverReturnType>(args: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams): Promise<string>;
772
- /**
773
- * Configures the client to query the latest published content for all future
774
- * queries.
775
- *
776
- * If the `ref` parameter is provided during a query, it takes priority for
777
- * that query.
778
- *
779
- * @example
780
- *
781
- * ```ts
782
- * await client.queryLatestContent();
783
- * const document = await client.getByID("WW4bKScAAMAqmluX");
784
- * ```
785
- */
786
- queryLatestContent(): void;
787
- /**
788
- * Configures the client to query content from a specific Release identified
789
- * by its ID for all future queries.
790
- *
791
- * If the `ref` parameter is provided during a query, it takes priority for
792
- * that query.
793
- *
794
- * @example
795
- *
796
- * ```ts
797
- * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa");
798
- * const document = await client.getByID("WW4bKScAAMAqmluX");
799
- * ```
800
- *
801
- * @param releaseID - The ID of the Release.
802
- */
803
- queryContentFromReleaseByID(releaseID: string): void;
804
- /**
805
- * Configures the client to query content from a specific Release identified
806
- * by its label for all future queries.
807
- *
808
- * If the `ref` parameter is provided during a query, it takes priority for
809
- * that query.
810
- *
811
- * @example
812
- *
813
- * ```ts
814
- * await client.queryContentFromReleaseByLabel("My Release");
815
- * const document = await client.getByID("WW4bKScAAMAqmluX");
816
- * ```
817
- *
818
- * @param releaseLabel - The label of the Release.
819
- */
820
- queryContentFromReleaseByLabel(releaseLabel: string): void;
821
- /**
822
- * Configures the client to query content from a specific ref. The ref can be
823
- * provided as a string or a function.
824
- *
825
- * If a function is provided, the ref is fetched lazily before each query. The
826
- * function may also be asynchronous.
827
- *
828
- * @example
829
- *
830
- * ```ts
831
- * await client.queryContentFromRef("my-ref");
832
- * const document = await client.getByID("WW4bKScAAMAqmluX");
833
- * ```
834
- *
835
- * @param ref - The ref or a function that returns the ref from which to query
836
- * content.
837
- */
838
- queryContentFromRef(ref: RefStringOrThunk): void;
839
- /**
840
- * @deprecated Renamed to `graphQLFetch()` (note the capitalization of "QL").
841
- */
842
- graphqlFetch: (input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
843
- signal?: AbortSignalLike;
844
- }) => Promise<Response>;
845
- /**
846
- * A `fetch()` function to be used with GraphQL clients configured for
847
- * Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
848
- * and Authorization headers. Queries will automatically be minified by
849
- * removing whitespace where possible.
850
- *
851
- * @example
852
- *
853
- * ```ts
854
- * const graphqlClient = new ApolloClient({
855
- * link: new HttpLink({
856
- * uri: prismic.getGraphQLEndpoint(repositoryName),
857
- * // Provide `client.graphqlFetch` as the fetch implementation.
858
- * fetch: client.graphqlFetch,
859
- * // Using GET is required.
860
- * useGETForQueries: true,
861
- * }),
862
- * cache: new InMemoryCache(),
863
- * });
864
- * ```
865
- *
866
- * @param input - The `fetch()` `input` parameter. Only strings are supported.
867
- * @param init - The `fetch()` `init` parameter. Only plain objects are
868
- * supported.
869
- *
870
- * @returns The `fetch()` Response for the request.
871
- * @experimental
872
- */
873
- graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
874
- signal?: AbortSignalLike;
875
- }): Promise<Response>;
876
- /**
877
- * Returns a cached version of `getRepository` with a TTL.
878
- *
879
- * @returns Cached repository metadata.
880
- */
881
- private getCachedRepository;
882
- /**
883
- * Returns a cached Prismic repository form. Forms are used to determine API
884
- * endpoints for types of repository data.
885
- *
886
- * @param name - Name of the form.
887
- *
888
- * @returns The repository form.
889
- * @throws If a matching form cannot be found.
890
- */
891
- private getCachedRepositoryForm;
892
- /**
893
- * Returns the ref needed to query based on the client's current state. This
894
- * method may make a network request to fetch a ref or resolve the user's ref
895
- * thunk.
896
- *
897
- * If auto previews are enabled, the preview ref takes priority if available.
898
- *
899
- * The following strategies are used depending on the client's state:
900
- *
901
- * - If the user called `queryLatestContent`: Use the repository's master ref.
902
- * The ref is cached for 5 seconds. After 5 seconds, a new master ref is
903
- * fetched.
904
- * - If the user called `queryContentFromReleaseByID`: Use the release's ref.
905
- * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
906
- * release is fetched.
907
- * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
908
- * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
909
- * release is fetched.
910
- * - If the user called `queryContentFromRef`: Use the provided ref. Fall back
911
- * to the master ref if the ref is not a string.
912
- *
913
- * @returns The ref to use during a query.
914
- */
915
- private getResolvedRefString;
916
- /**
917
- * Performs a network request using the configured `fetch` function. It
918
- * assumes all successful responses will have a JSON content type. It also
919
- * normalizes unsuccessful network requests.
920
- *
921
- * @typeParam T - The JSON response.
922
- * @param url - URL to the resource to fetch.
923
- * @param params - Prismic REST API parameters for the network request.
924
- *
925
- * @returns The JSON response from the network request.
926
- */
927
- private fetch;
928
- }
929
- export {};
1
+ import * as prismicT from "@prismicio/types";
2
+ import * as prismicH from "@prismicio/helpers";
3
+ import { AbortSignalLike, FetchLike, HttpRequestLike, ExtractDocumentType, RequestInitLike } from "./types";
4
+ import { BuildQueryURLArgs } from "./buildQueryURL";
5
+ /**
6
+ * The number of milliseconds in which repository metadata is considered valid.
7
+ * A ref can be invalidated quickly depending on how frequently content is
8
+ * updated in the Prismic repository. As such, repository's metadata can only be
9
+ * considered valid for a short amount of time.
10
+ */
11
+ export declare const REPOSITORY_CACHE_TTL = 5000;
12
+ /**
13
+ * The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,
14
+ * `getAllByType`, `getAllByTag`) will wait between individual page requests.
15
+ *
16
+ * This is done to ensure API performance is sustainable and reduces the chance
17
+ * of a failed API request due to overloading.
18
+ */
19
+ export declare const GET_ALL_QUERY_DELAY = 500;
20
+ /**
21
+ * A ref or a function that returns a ref. If a static ref is known, one can be
22
+ * given. If the ref must be fetched on-demand, a function can be provided. This
23
+ * function can optionally be asynchronous.
24
+ */
25
+ type RefStringOrThunk = string | (() => string | undefined | Promise<string | undefined>);
26
+ /**
27
+ * Configuration for clients that determine how content is queried.
28
+ */
29
+ export type ClientConfig = {
30
+ /**
31
+ * The secure token for accessing the Prismic repository. This is only
32
+ * required if the repository is set to private.
33
+ */
34
+ accessToken?: string;
35
+ /**
36
+ * A string representing a version of the Prismic repository's content. This
37
+ * may point to the latest version (called the "master ref"), or a preview
38
+ * with draft content.
39
+ */
40
+ ref?: RefStringOrThunk;
41
+ /**
42
+ * A list of Route Resolver objects that define how a document's `url` field
43
+ * is resolved.
44
+ *
45
+ * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
46
+ */
47
+ routes?: NonNullable<BuildQueryURLArgs["routes"]>;
48
+ /**
49
+ * The `brokenRoute` option allows you to define the route populated in the
50
+ * `url` property for broken Link or Content Relationship fields. A broken
51
+ * link is a Link or Content Relationship field whose linked document has been
52
+ * unpublished or deleted.
53
+ *
54
+ * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
55
+ */
56
+ brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
57
+ /**
58
+ * Default parameters that will be sent with each query. These parameters can
59
+ * be overridden on each query if needed.
60
+ */
61
+ defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes" | "brokenRoute">;
62
+ /**
63
+ * The function used to make network requests to the Prismic REST API. In
64
+ * environments where a global `fetch` function does not exist, such as
65
+ * Node.js, this function must be provided.
66
+ */
67
+ fetch?: FetchLike;
68
+ /**
69
+ * Options provided to the client's `fetch()` on all network requests. These
70
+ * options will be merged with internally required options. They can also be
71
+ * overriden on a per-query basis using the query's `fetchOptions` parameter.
72
+ */
73
+ fetchOptions?: RequestInitLike;
74
+ };
75
+ /**
76
+ * Parameters for any client method that use `fetch()`.
77
+ */
78
+ type FetchParams = {
79
+ /**
80
+ * Options provided to the client's `fetch()` on all network requests. These
81
+ * options will be merged with internally required options. They can also be
82
+ * overriden on a per-query basis using the query's `fetchOptions` parameter.
83
+ */
84
+ fetchOptions?: RequestInitLike;
85
+ /**
86
+ * An `AbortSignal` provided by an `AbortController`. This allows the network
87
+ * request to be cancelled if necessary.
88
+ *
89
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
90
+ *
91
+ * @deprecated Move the `signal` parameter into `fetchOptions.signal`.
92
+ */
93
+ signal?: AbortSignalLike;
94
+ };
95
+ /**
96
+ * Parameters specific to client methods that fetch all documents. These methods
97
+ * start with `getAll` (for example, `getAllByType`).
98
+ */
99
+ type GetAllParams = {
100
+ /**
101
+ * Limit the number of documents queried. If a number is not provided, there
102
+ * will be no limit and all matching documents will be returned.
103
+ */
104
+ limit?: number;
105
+ };
106
+ /**
107
+ * Arguments to determine how the URL for a preview session is resolved.
108
+ */
109
+ type ResolvePreviewArgs<LinkResolverReturnType> = {
110
+ /**
111
+ * A function that maps a Prismic document to a URL within your app.
112
+ */
113
+ linkResolver?: prismicH.LinkResolverFunction<LinkResolverReturnType>;
114
+ /**
115
+ * A fallback URL if the Link Resolver does not return a value.
116
+ */
117
+ defaultURL: string;
118
+ /**
119
+ * The preview token (also known as a ref) that will be used to query preview
120
+ * content from the Prismic repository.
121
+ */
122
+ previewToken?: string;
123
+ /**
124
+ * The previewed document that will be used to determine the destination URL.
125
+ */
126
+ documentID?: string;
127
+ };
128
+ /**
129
+ * Type definitions for the `createClient()` function. May be augmented by
130
+ * third-party libraries.
131
+ */
132
+ export interface CreateClient {
133
+ <TDocuments extends prismicT.PrismicDocument>(...args: ConstructorParameters<typeof Client>): Client<TDocuments>;
134
+ }
135
+ /**
136
+ * Creates a Prismic client that can be used to query a repository.
137
+ *
138
+ * @example
139
+ *
140
+ * ```ts
141
+ * // With a repository name.
142
+ * createClient("qwerty");
143
+ *
144
+ * // Or with a full Prismic Rest API V2 endpoint.
145
+ * createClient("https://qwerty.cdn.prismic.io/api/v2");
146
+ * ```
147
+ *
148
+ * @typeParam TDocuments - A map of Prismic document type IDs mapped to their
149
+ * TypeScript type.
150
+ * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
151
+ * API V2 endpoint for the repository.
152
+ * @param options - Configuration that determines how content will be queried
153
+ * from the Prismic repository.
154
+ *
155
+ * @returns A client that can query content from the repository.
156
+ */
157
+ export declare const createClient: CreateClient;
158
+ /**
159
+ * A client that allows querying content from a Prismic repository.
160
+ *
161
+ * If used in an environment where a global `fetch` function is unavailable,
162
+ * such as Node.js, the `fetch` option must be provided as part of the `options`
163
+ * parameter.
164
+ *
165
+ * @typeParam TDocuments - Document types that are registered for the Prismic
166
+ * repository. Query methods will automatically be typed based on this type.
167
+ */
168
+ export declare class Client<TDocuments extends prismicT.PrismicDocument = prismicT.PrismicDocument> {
169
+ /**
170
+ * The Prismic REST API V2 endpoint for the repository (use
171
+ * `prismic.getRepositoryEndpoint` for the default endpoint).
172
+ */
173
+ endpoint: string;
174
+ /**
175
+ * The secure token for accessing the API (only needed if your repository is
176
+ * set to private).
177
+ *
178
+ * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
179
+ */
180
+ accessToken?: string;
181
+ /**
182
+ * A list of Route Resolver objects that define how a document's `url` field
183
+ * is resolved.
184
+ *
185
+ * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
186
+ */
187
+ routes?: NonNullable<BuildQueryURLArgs["routes"]>;
188
+ /**
189
+ * The `brokenRoute` option allows you to define the route populated in the
190
+ * `url` property for broken Link or Content Relationship fields. A broken
191
+ * link is a Link or Content Relationship field whose linked document has been
192
+ * unpublished or deleted.
193
+ *
194
+ * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
195
+ */
196
+ brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
197
+ /**
198
+ * The function used to make network requests to the Prismic REST API. In
199
+ * environments where a global `fetch` function does not exist, such as
200
+ * Node.js, this function must be provided.
201
+ */
202
+ fetchFn: FetchLike;
203
+ fetchOptions?: RequestInitLike;
204
+ /**
205
+ * Default parameters that will be sent with each query. These parameters can
206
+ * be overridden on each query if needed.
207
+ */
208
+ defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes">;
209
+ /**
210
+ * The client's ref mode state. This determines which ref is used during
211
+ * queries.
212
+ */
213
+ private refState;
214
+ /**
215
+ * Cached repository value.
216
+ */
217
+ private cachedRepository;
218
+ /**
219
+ * Timestamp at which the cached repository data is considered stale.
220
+ */
221
+ private cachedRepositoryExpiration;
222
+ /**
223
+ * Creates a Prismic client that can be used to query a repository.
224
+ *
225
+ * If used in an environment where a global `fetch` function is unavailable,
226
+ * such as Node.js, the `fetch` option must be provided as part of the
227
+ * `options` parameter.
228
+ *
229
+ * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
230
+ * API V2 endpoint for the repository.
231
+ * @param options - Configuration that determines how content will be queried
232
+ * from the Prismic repository.
233
+ *
234
+ * @returns A client that can query content from the repository.
235
+ */
236
+ constructor(repositoryNameOrEndpoint: string, options?: ClientConfig);
237
+ /**
238
+ * Enables the client to automatically query content from a preview session if
239
+ * one is active in browser environments. This is enabled by default in the
240
+ * browser.
241
+ *
242
+ * For server environments, use `enableAutoPreviewsFromReq`.
243
+ *
244
+ * @example
245
+ *
246
+ * ```ts
247
+ * client.enableAutoPreviews();
248
+ * ```
249
+ *
250
+ * @see enableAutoPreviewsFromReq
251
+ */
252
+ enableAutoPreviews(): void;
253
+ /**
254
+ * Enables the client to automatically query content from a preview session if
255
+ * one is active in server environments. This is disabled by default on the
256
+ * server.
257
+ *
258
+ * For browser environments, use `enableAutoPreviews`.
259
+ *
260
+ * @example
261
+ *
262
+ * ```ts
263
+ * // In an express app
264
+ * app.get("/", function (req, res) {
265
+ * client.enableAutoPreviewsFromReq(req);
266
+ * });
267
+ * ```
268
+ *
269
+ * @param req - An HTTP server request object containing the request's
270
+ * cookies.
271
+ */
272
+ enableAutoPreviewsFromReq<R extends HttpRequestLike>(req: R): void;
273
+ /**
274
+ * Disables the client from automatically querying content from a preview
275
+ * session if one is active.
276
+ *
277
+ * Automatic preview content querying is enabled by default unless this method
278
+ * is called.
279
+ *
280
+ * @example
281
+ *
282
+ * ```ts
283
+ * client.disableAutoPreviews();
284
+ * ```
285
+ */
286
+ disableAutoPreviews(): void;
287
+ /**
288
+ * Queries content from the Prismic repository.
289
+ *
290
+ * @deprecated Use `get` instead.
291
+ * @example
292
+ *
293
+ * ```ts
294
+ * const response = await client.query(
295
+ * prismic.predicate.at("document.type", "page"),
296
+ * );
297
+ * ```
298
+ *
299
+ * @typeParam TDocument - Type of Prismic documents returned.
300
+ * @param params - Parameters to filter, sort, and paginate results.
301
+ *
302
+ * @returns A paginated response containing the result of the query.
303
+ */
304
+ query<TDocument extends TDocuments>(predicates: NonNullable<BuildQueryURLArgs["predicates"]>, params?: Partial<Omit<BuildQueryURLArgs, "predicates">> & FetchParams): Promise<prismicT.Query<TDocument>>;
305
+ /**
306
+ * Queries content from the Prismic repository.
307
+ *
308
+ * @example
309
+ *
310
+ * ```ts
311
+ * const response = await client.get();
312
+ * ```
313
+ *
314
+ * @typeParam TDocument - Type of Prismic documents returned.
315
+ * @param params - Parameters to filter, sort, and paginate results.
316
+ *
317
+ * @returns A paginated response containing the result of the query.
318
+ */
319
+ get<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
320
+ /**
321
+ * Queries content from the Prismic repository and returns only the first
322
+ * result, if any.
323
+ *
324
+ * @example
325
+ *
326
+ * ```ts
327
+ * const document = await client.getFirst();
328
+ * ```
329
+ *
330
+ * @typeParam TDocument - Type of the Prismic document returned.
331
+ * @param params - Parameters to filter, sort, and paginate results. @returns
332
+ * The first result of the query, if any.
333
+ */
334
+ getFirst<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
335
+ /**
336
+ * **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
337
+ * require more resources than other methods. Prefer using other methods that
338
+ * filter by predicates such as `getAllByType`.
339
+ *
340
+ * Queries content from the Prismic repository and returns all matching
341
+ * content. If no predicates are provided, all documents will be fetched.
342
+ *
343
+ * This method may make multiple network requests to query all matching
344
+ * content.
345
+ *
346
+ * @example
347
+ *
348
+ * ```ts
349
+ * const response = await client.dangerouslyGetAll();
350
+ * ```
351
+ *
352
+ * @typeParam TDocument - Type of Prismic documents returned.
353
+ * @param params - Parameters to filter, sort, and paginate results.
354
+ *
355
+ * @returns A list of documents matching the query.
356
+ */
357
+ dangerouslyGetAll<TDocument extends TDocuments>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
358
+ /**
359
+ * Queries a document from the Prismic repository with a specific ID.
360
+ *
361
+ * @remarks
362
+ * A document's UID is different from its ID. An ID is automatically generated
363
+ * for all documents and is made available on its `id` property. A UID is
364
+ * provided in the Prismic editor and is unique among all documents of its
365
+ * Custom Type.
366
+ * @example
367
+ *
368
+ * ```ts
369
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
370
+ * ```
371
+ *
372
+ * @typeParam TDocument- Type of the Prismic document returned.
373
+ * @param id - ID of the document.
374
+ * @param params - Parameters to filter, sort, and paginate the results.
375
+ *
376
+ * @returns The document with an ID matching the `id` parameter, if a matching
377
+ * document exists.
378
+ */
379
+ getByID<TDocument extends TDocuments>(id: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
380
+ /**
381
+ * Queries documents from the Prismic repository with specific IDs.
382
+ *
383
+ * @remarks
384
+ * A document's UID is different from its ID. An ID is automatically generated
385
+ * for all documents and is made available on its `id` property. A UID is
386
+ * provided in the Prismic editor and is unique among all documents of its
387
+ * Custom Type.
388
+ * @example
389
+ *
390
+ * ```ts
391
+ * const response = await client.getByIDs([
392
+ * "WW4bKScAAMAqmluX",
393
+ * "U1kTRgEAAC8A5ldS",
394
+ * ]);
395
+ * ```
396
+ *
397
+ * @typeParam TDocument - Type of Prismic documents returned.
398
+ * @param ids - A list of document IDs.
399
+ * @param params - Parameters to filter, sort, and paginate the results.
400
+ *
401
+ * @returns A paginated response containing documents with IDs matching the
402
+ * `ids` parameter.
403
+ */
404
+ getByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
405
+ /**
406
+ * Queries all documents from the Prismic repository with specific IDs.
407
+ *
408
+ * This method may make multiple network requests to query all matching
409
+ * content.
410
+ *
411
+ * @remarks
412
+ * A document's UID is different from its ID. An ID is automatically generated
413
+ * for all documents and is made available on its `id` property. A UID is
414
+ * provided in the Prismic editor and is unique among all documents of its
415
+ * Custom Type.
416
+ * @example
417
+ *
418
+ * ```ts
419
+ * const response = await client.getAllByIDs([
420
+ * "WW4bKScAAMAqmluX",
421
+ * "U1kTRgEAAC8A5ldS",
422
+ * ]);
423
+ * ```
424
+ *
425
+ * @typeParam TDocument - Type of Prismic documents returned.
426
+ * @param ids - A list of document IDs.
427
+ * @param params - Parameters to filter, sort, and paginate the results.
428
+ *
429
+ * @returns A list of documents with IDs matching the `ids` parameter.
430
+ */
431
+ getAllByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<TDocument[]>;
432
+ /**
433
+ * Queries a document from the Prismic repository with a specific UID and
434
+ * Custom Type.
435
+ *
436
+ * @remarks
437
+ * A document's UID is different from its ID. An ID is automatically generated
438
+ * for all documents and is made available on its `id` property. A UID is
439
+ * provided in the Prismic editor and is unique among all documents of its
440
+ * Custom Type.
441
+ * @example
442
+ *
443
+ * ```ts
444
+ * const document = await client.getByUID("blog_post", "my-first-post");
445
+ * ```
446
+ *
447
+ * @typeParam TDocument - Type of the Prismic document returned.
448
+ * @param documentType - The API ID of the document's Custom Type.
449
+ * @param uid - UID of the document.
450
+ * @param params - Parameters to filter, sort, and paginate the results.
451
+ *
452
+ * @returns The document with a UID matching the `uid` parameter, if a
453
+ * matching document exists.
454
+ */
455
+ getByUID<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uid: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
456
+ /**
457
+ * Queries document from the Prismic repository with specific UIDs and Custom
458
+ * Type.
459
+ *
460
+ * @remarks
461
+ * A document's UID is different from its ID. An ID is automatically generated
462
+ * for all documents and is made available on its `id` property. A UID is
463
+ * provided in the Prismic editor and is unique among all documents of its
464
+ * Custom Type.
465
+ * @example
466
+ *
467
+ * ```ts
468
+ * const document = await client.getByUIDs("blog_post", [
469
+ * "my-first-post",
470
+ * "my-second-post",
471
+ * ]);
472
+ * ```
473
+ *
474
+ * @typeParam TDocument - Type of the Prismic document returned.
475
+ * @param documentType - The API ID of the document's Custom Type.
476
+ * @param uids - A list of document UIDs.
477
+ * @param params - Parameters to filter, sort, and paginate the results.
478
+ *
479
+ * @returns A paginated response containing documents with UIDs matching the
480
+ * `uids` parameter.
481
+ */
482
+ getByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>>;
483
+ /**
484
+ * Queries all documents from the Prismic repository with specific UIDs and
485
+ * Custom Type.
486
+ *
487
+ * This method may make multiple network requests to query all matching
488
+ * content.
489
+ *
490
+ * @remarks
491
+ * A document's UID is different from its ID. An ID is automatically generated
492
+ * for all documents and is made available on its `id` property. A UID is
493
+ * provided in the Prismic editor and is unique among all documents of its
494
+ * Custom Type.
495
+ * @example
496
+ *
497
+ * ```ts
498
+ * const response = await client.getAllByUIDs([
499
+ * "my-first-post",
500
+ * "my-second-post",
501
+ * ]);
502
+ * ```
503
+ *
504
+ * @typeParam TDocument - Type of Prismic documents returned.
505
+ * @param documentType - The API ID of the document's Custom Type.
506
+ * @param uids - A list of document UIDs.
507
+ * @param params - Parameters to filter, sort, and paginate the results.
508
+ *
509
+ * @returns A list of documents with UIDs matching the `uids` parameter.
510
+ */
511
+ getAllByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
512
+ /**
513
+ * Queries a singleton document from the Prismic repository for a specific
514
+ * Custom Type.
515
+ *
516
+ * @remarks
517
+ * A singleton document is one that is configured in Prismic to only allow one
518
+ * instance. For example, a repository may be configured to contain just one
519
+ * Settings document. This is in contrast to a repeatable Custom Type which
520
+ * allows multiple instances of itself.
521
+ * @example
522
+ *
523
+ * ```ts
524
+ * const document = await client.getSingle("settings");
525
+ * ```
526
+ *
527
+ * @typeParam TDocument - Type of the Prismic document returned.
528
+ * @param documentType - The API ID of the singleton Custom Type.
529
+ * @param params - Parameters to filter, sort, and paginate the results.
530
+ *
531
+ * @returns The singleton document for the Custom Type, if a matching document
532
+ * exists.
533
+ */
534
+ getSingle<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
535
+ /**
536
+ * Queries documents from the Prismic repository for a specific Custom Type.
537
+ *
538
+ * Use `getAllByType` instead if you need to query all documents for a
539
+ * specific Custom Type.
540
+ *
541
+ * @example
542
+ *
543
+ * ```ts
544
+ * const response = await client.getByType("blog_post");
545
+ * ```
546
+ *
547
+ * @typeParam TDocument - Type of Prismic documents returned.
548
+ * @param documentType - The API ID of the Custom Type.
549
+ * @param params - Parameters to filter, sort, and paginate the results.
550
+ *
551
+ * @returns A paginated response containing documents of the Custom Type.
552
+ */
553
+ getByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>>;
554
+ /**
555
+ * Queries all documents from the Prismic repository for a specific Custom
556
+ * Type.
557
+ *
558
+ * This method may make multiple network requests to query all matching
559
+ * content.
560
+ *
561
+ * @example
562
+ *
563
+ * ```ts
564
+ * const response = await client.getByType("blog_post");
565
+ * ```
566
+ *
567
+ * @typeParam TDocument - Type of Prismic documents returned.
568
+ * @param documentType - The API ID of the Custom Type.
569
+ * @param params - Parameters to filter, sort, and paginate the results.
570
+ *
571
+ * @returns A list of all documents of the Custom Type.
572
+ */
573
+ getAllByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
574
+ /**
575
+ * Queries documents from the Prismic repository with a specific tag.
576
+ *
577
+ * Use `getAllByTag` instead if you need to query all documents with a
578
+ * specific tag.
579
+ *
580
+ * @example
581
+ *
582
+ * ```ts
583
+ * const response = await client.getByTag("food");
584
+ * ```
585
+ *
586
+ * @typeParam TDocument - Type of Prismic documents returned.
587
+ * @param tag - The tag that must be included on a document.
588
+ * @param params - Parameters to filter, sort, and paginate the results.
589
+ *
590
+ * @returns A paginated response containing documents with the tag.
591
+ */
592
+ getByTag<TDocument extends TDocuments>(tag: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
593
+ /**
594
+ * Queries all documents from the Prismic repository with a specific tag.
595
+ *
596
+ * This method may make multiple network requests to query all matching
597
+ * content.
598
+ *
599
+ * @example
600
+ *
601
+ * ```ts
602
+ * const response = await client.getAllByTag("food");
603
+ * ```
604
+ *
605
+ * @typeParam TDocument - Type of Prismic documents returned.
606
+ * @param tag - The tag that must be included on a document.
607
+ * @param params - Parameters to filter, sort, and paginate the results.
608
+ *
609
+ * @returns A list of all documents with the tag.
610
+ */
611
+ getAllByTag<TDocument extends TDocuments>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
612
+ /**
613
+ * Queries documents from the Prismic repository with specific tags. A
614
+ * document must be tagged with all of the queried tags to be included.
615
+ *
616
+ * @example
617
+ *
618
+ * ```ts
619
+ * const response = await client.getByEveryTag(["food", "fruit"]);
620
+ * ```
621
+ *
622
+ * @typeParam TDocument - Type of Prismic documents returned.
623
+ * @param tags - A list of tags that must be included on a document.
624
+ * @param params - Parameters to filter, sort, and paginate the results.
625
+ *
626
+ * @returns A paginated response containing documents with the tags.
627
+ */
628
+ getByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
629
+ /**
630
+ * Queries documents from the Prismic repository with specific tags. A
631
+ * document must be tagged with all of the queried tags to be included.
632
+ *
633
+ * This method may make multiple network requests to query all matching
634
+ * content.
635
+ *
636
+ * @example
637
+ *
638
+ * ```ts
639
+ * const response = await client.getAllByEveryTag(["food", "fruit"]);
640
+ * ```
641
+ *
642
+ * @typeParam TDocument - Type of Prismic documents returned.
643
+ * @param tags - A list of tags that must be included on a document.
644
+ * @param params - Parameters to filter, sort, and paginate the results.
645
+ *
646
+ * @returns A list of all documents with the tags.
647
+ */
648
+ getAllByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
649
+ /**
650
+ * Queries documents from the Prismic repository with specific tags. A
651
+ * document must be tagged with at least one of the queried tags to be
652
+ * included.
653
+ *
654
+ * @example
655
+ *
656
+ * ```ts
657
+ * const response = await client.getByEveryTag(["food", "fruit"]);
658
+ * ```
659
+ *
660
+ * @typeParam TDocument - Type of Prismic documents returned.
661
+ * @param tags - A list of tags that must be included on a document.
662
+ * @param params - Parameters to filter, sort, and paginate the results.
663
+ *
664
+ * @returns A paginated response containing documents with at least one of the
665
+ * tags.
666
+ */
667
+ getBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
668
+ /**
669
+ * Queries documents from the Prismic repository with specific tags. A
670
+ * document must be tagged with at least one of the queried tags to be
671
+ * included.
672
+ *
673
+ * This method may make multiple network requests to query all matching
674
+ * content.
675
+ *
676
+ * @example
677
+ *
678
+ * ```ts
679
+ * const response = await client.getAllBySomeTags(["food", "fruit"]);
680
+ * ```
681
+ *
682
+ * @typeParam TDocument - Type of Prismic documents returned.
683
+ * @param tags - A list of tags that must be included on a document.
684
+ * @param params - Parameters to filter, sort, and paginate the results.
685
+ *
686
+ * @returns A list of all documents with at least one of the tags.
687
+ */
688
+ getAllBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
689
+ /**
690
+ * Returns metadata about the Prismic repository, such as its refs, releases,
691
+ * and custom types.
692
+ *
693
+ * @returns Repository metadata.
694
+ */
695
+ getRepository(params?: FetchParams): Promise<prismicT.Repository>;
696
+ /**
697
+ * Returns a list of all refs for the Prismic repository.
698
+ *
699
+ * Refs are used to identify which version of the repository's content should
700
+ * be queried. All repositories will have at least one ref pointing to the
701
+ * latest published content called the "master ref".
702
+ *
703
+ * @returns A list of all refs for the Prismic repository.
704
+ */
705
+ getRefs(params?: FetchParams): Promise<prismicT.Ref[]>;
706
+ /**
707
+ * Returns a ref for the Prismic repository with a matching ID.
708
+ *
709
+ * @param id - ID of the ref.
710
+ *
711
+ * @returns The ref with a matching ID, if it exists.
712
+ */
713
+ getRefByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
714
+ /**
715
+ * Returns a ref for the Prismic repository with a matching label.
716
+ *
717
+ * @param label - Label of the ref.
718
+ *
719
+ * @returns The ref with a matching label, if it exists.
720
+ */
721
+ getRefByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
722
+ /**
723
+ * Returns the master ref for the Prismic repository. The master ref points to
724
+ * the repository's latest published content.
725
+ *
726
+ * @returns The repository's master ref.
727
+ */
728
+ getMasterRef(params?: FetchParams): Promise<prismicT.Ref>;
729
+ /**
730
+ * Returns a list of all Releases for the Prismic repository. Releases are
731
+ * used to group content changes before publishing.
732
+ *
733
+ * @returns A list of all Releases for the Prismic repository.
734
+ */
735
+ getReleases(params?: FetchParams): Promise<prismicT.Ref[]>;
736
+ /**
737
+ * Returns a Release for the Prismic repository with a matching ID.
738
+ *
739
+ * @param id - ID of the Release.
740
+ *
741
+ * @returns The Release with a matching ID, if it exists.
742
+ */
743
+ getReleaseByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
744
+ /**
745
+ * Returns a Release for the Prismic repository with a matching label.
746
+ *
747
+ * @param label - Label of the ref.
748
+ *
749
+ * @returns The ref with a matching label, if it exists.
750
+ */
751
+ getReleaseByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
752
+ /**
753
+ * Returns a list of all tags used in the Prismic repository.
754
+ *
755
+ * @returns A list of all tags used in the repository.
756
+ */
757
+ getTags(params?: FetchParams): Promise<string[]>;
758
+ /**
759
+ * Builds a URL used to query content from the Prismic repository.
760
+ *
761
+ * @param params - Parameters to filter, sort, and paginate the results.
762
+ *
763
+ * @returns A URL string that can be requested to query content.
764
+ */
765
+ buildQueryURL({ signal, fetchOptions, ...params }?: Partial<BuildQueryURLArgs> & FetchParams): Promise<string>;
766
+ /**
767
+ * Determines the URL for a previewed document during an active preview
768
+ * session. The result of this method should be used to redirect the user to
769
+ * the document's URL.
770
+ *
771
+ * @example
772
+ *
773
+ * ```ts
774
+ * const url = client.resolvePreviewURL({
775
+ * linkResolver: (document) => `/${document.uid}`
776
+ * defaultURL: '/'
777
+ * })
778
+ * ```
779
+ *
780
+ * @param args - Arguments to configure the URL resolving.
781
+ *
782
+ * @returns The URL for the previewed document during an active preview
783
+ * session. The user should be redirected to this URL.
784
+ */
785
+ resolvePreviewURL<LinkResolverReturnType>(args: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams): Promise<string>;
786
+ /**
787
+ * Configures the client to query the latest published content for all future
788
+ * queries.
789
+ *
790
+ * If the `ref` parameter is provided during a query, it takes priority for
791
+ * that query.
792
+ *
793
+ * @example
794
+ *
795
+ * ```ts
796
+ * await client.queryLatestContent();
797
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
798
+ * ```
799
+ */
800
+ queryLatestContent(): void;
801
+ /**
802
+ * Configures the client to query content from a specific Release identified
803
+ * by its ID for all future queries.
804
+ *
805
+ * If the `ref` parameter is provided during a query, it takes priority for
806
+ * that query.
807
+ *
808
+ * @example
809
+ *
810
+ * ```ts
811
+ * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa");
812
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
813
+ * ```
814
+ *
815
+ * @param releaseID - The ID of the Release.
816
+ */
817
+ queryContentFromReleaseByID(releaseID: string): void;
818
+ /**
819
+ * Configures the client to query content from a specific Release identified
820
+ * by its label for all future queries.
821
+ *
822
+ * If the `ref` parameter is provided during a query, it takes priority for
823
+ * that query.
824
+ *
825
+ * @example
826
+ *
827
+ * ```ts
828
+ * await client.queryContentFromReleaseByLabel("My Release");
829
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
830
+ * ```
831
+ *
832
+ * @param releaseLabel - The label of the Release.
833
+ */
834
+ queryContentFromReleaseByLabel(releaseLabel: string): void;
835
+ /**
836
+ * Configures the client to query content from a specific ref. The ref can be
837
+ * provided as a string or a function.
838
+ *
839
+ * If a function is provided, the ref is fetched lazily before each query. The
840
+ * function may also be asynchronous.
841
+ *
842
+ * @example
843
+ *
844
+ * ```ts
845
+ * await client.queryContentFromRef("my-ref");
846
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
847
+ * ```
848
+ *
849
+ * @param ref - The ref or a function that returns the ref from which to query
850
+ * content.
851
+ */
852
+ queryContentFromRef(ref: RefStringOrThunk): void;
853
+ /**
854
+ * @deprecated Renamed to `graphQLFetch()` (note the capitalization of "QL").
855
+ */
856
+ graphqlFetch: (input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
857
+ signal?: AbortSignalLike;
858
+ }) => Promise<Response>;
859
+ /**
860
+ * A `fetch()` function to be used with GraphQL clients configured for
861
+ * Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
862
+ * and Authorization headers. Queries will automatically be minified by
863
+ * removing whitespace where possible.
864
+ *
865
+ * @example
866
+ *
867
+ * ```ts
868
+ * const graphqlClient = new ApolloClient({
869
+ * link: new HttpLink({
870
+ * uri: prismic.getGraphQLEndpoint(repositoryName),
871
+ * // Provide `client.graphqlFetch` as the fetch implementation.
872
+ * fetch: client.graphqlFetch,
873
+ * // Using GET is required.
874
+ * useGETForQueries: true,
875
+ * }),
876
+ * cache: new InMemoryCache(),
877
+ * });
878
+ * ```
879
+ *
880
+ * @param input - The `fetch()` `input` parameter. Only strings are supported.
881
+ * @param init - The `fetch()` `init` parameter. Only plain objects are
882
+ * supported.
883
+ *
884
+ * @returns The `fetch()` Response for the request.
885
+ * @experimental
886
+ */
887
+ graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
888
+ signal?: AbortSignalLike;
889
+ }): Promise<Response>;
890
+ /**
891
+ * Returns a cached version of `getRepository` with a TTL.
892
+ *
893
+ * @returns Cached repository metadata.
894
+ */
895
+ private getCachedRepository;
896
+ /**
897
+ * Returns a cached Prismic repository form. Forms are used to determine API
898
+ * endpoints for types of repository data.
899
+ *
900
+ * @param name - Name of the form.
901
+ *
902
+ * @returns The repository form.
903
+ * @throws If a matching form cannot be found.
904
+ */
905
+ private getCachedRepositoryForm;
906
+ /**
907
+ * Returns the ref needed to query based on the client's current state. This
908
+ * method may make a network request to fetch a ref or resolve the user's ref
909
+ * thunk.
910
+ *
911
+ * If auto previews are enabled, the preview ref takes priority if available.
912
+ *
913
+ * The following strategies are used depending on the client's state:
914
+ *
915
+ * - If the user called `queryLatestContent`: Use the repository's master ref.
916
+ * The ref is cached for 5 seconds. After 5 seconds, a new master ref is
917
+ * fetched.
918
+ * - If the user called `queryContentFromReleaseByID`: Use the release's ref.
919
+ * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
920
+ * release is fetched.
921
+ * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
922
+ * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
923
+ * release is fetched.
924
+ * - If the user called `queryContentFromRef`: Use the provided ref. Fall back
925
+ * to the master ref if the ref is not a string.
926
+ *
927
+ * @returns The ref to use during a query.
928
+ */
929
+ private getResolvedRefString;
930
+ /**
931
+ * Performs a network request using the configured `fetch` function. It
932
+ * assumes all successful responses will have a JSON content type. It also
933
+ * normalizes unsuccessful network requests.
934
+ *
935
+ * @typeParam T - The JSON response.
936
+ * @param url - URL to the resource to fetch.
937
+ * @param params - Prismic REST API parameters for the network request.
938
+ *
939
+ * @returns The JSON response from the network request.
940
+ */
941
+ private fetch;
942
+ }
943
+ export {};