@prismicio/client 7.21.0-pr.416.a60d634 → 7.21.0-pr.417.960f871

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.cjs CHANGED
@@ -166,14 +166,8 @@ var Client = class {
166
166
  mode: RefStateMode.Master,
167
167
  autoPreviewsEnabled: true
168
168
  };
169
- /**
170
- * Cached repository value.
171
- */
172
- cachedRepository;
173
- /**
174
- * Timestamp at which the cached repository data is considered stale.
175
- */
176
- cachedRepositoryExpiration = 0;
169
+ #cachedRepository;
170
+ #cachedRepositoryExpiration = 0;
177
171
  /**
178
172
  * Creates a Prismic client that can be used to query a repository.
179
173
  *
@@ -220,7 +214,11 @@ var Client = class {
220
214
  this.graphQLFetch = this.graphQLFetch.bind(this);
221
215
  }
222
216
  /**
223
- * Enables the client to automatically query content from a preview session.
217
+ * Enables the client to automatically query content from a preview session if
218
+ * one is active in browser environments. This is enabled by default in the
219
+ * browser.
220
+ *
221
+ * For server environments, use `enableAutoPreviewsFromReq`.
224
222
  *
225
223
  * @example
226
224
  *
@@ -228,22 +226,29 @@ var Client = class {
228
226
  * client.enableAutoPreviews()
229
227
  * ```
230
228
  *
231
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}
229
+ * @see enableAutoPreviewsFromReq
232
230
  */
233
231
  enableAutoPreviews() {
234
232
  this.refState.autoPreviewsEnabled = true;
235
233
  }
236
234
  /**
237
- * Enables the client to automatically query content from a preview session
238
- * using an HTTP request object.
235
+ * Enables the client to automatically query content from a preview session if
236
+ * one is active in server environments. This is disabled by default on the
237
+ * server.
238
+ *
239
+ * For browser environments, use `enableAutoPreviews`.
239
240
  *
240
241
  * @example
241
242
  *
242
243
  * ```ts
243
- * client.enableAutoPreviewsFromReq(req)
244
+ * // In an express app
245
+ * app.get("/", function (req, res) {
246
+ * client.enableAutoPreviewsFromReq(req)
247
+ * })
244
248
  * ```
245
249
  *
246
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}
250
+ * @param req - An HTTP server request object containing the request's
251
+ * cookies.
247
252
  */
248
253
  enableAutoPreviewsFromReq(req) {
249
254
  this.refState.httpRequest = req;
@@ -251,44 +256,54 @@ var Client = class {
251
256
  }
252
257
  /**
253
258
  * Disables the client from automatically querying content from a preview
254
- * session.
259
+ * session if one is active.
260
+ *
261
+ * Automatic preview content querying is enabled by default unless this method
262
+ * is called.
255
263
  *
256
264
  * @example
257
265
  *
258
266
  * ```ts
259
267
  * client.disableAutoPreviews()
260
268
  * ```
261
- *
262
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}
263
269
  */
264
270
  disableAutoPreviews() {
265
271
  this.refState.autoPreviewsEnabled = false;
266
272
  }
267
273
  /**
268
- * Fetches pages based on the `params` argument. Results are paginated.
274
+ * Queries content from the Prismic repository.
269
275
  *
270
276
  * @example
271
277
  *
272
278
  * ```ts
273
- * const response = await client.get({ pageSize: 10 })
279
+ * const response = await client.get()
274
280
  * ```
275
281
  *
276
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#get}
282
+ * @typeParam TDocument - Type of Prismic documents returned.
283
+ *
284
+ * @param params - Parameters to filter, sort, and paginate results.
285
+ *
286
+ * @returns A paginated response containing the result of the query.
277
287
  */
278
288
  async get(params) {
279
289
  const { data } = await this._get(params);
280
290
  return data;
281
291
  }
282
292
  /**
283
- * Fetches the first page returned based on the `params` argument.
293
+ * Queries content from the Prismic repository and returns only the first
294
+ * result, if any.
284
295
  *
285
296
  * @example
286
297
  *
287
298
  * ```ts
288
- * const page = await client.getFirst()
299
+ * const document = await client.getFirst()
289
300
  * ```
290
301
  *
291
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getfirst}
302
+ * @typeParam TDocument - Type of the Prismic document returned.
303
+ *
304
+ * @param params - Parameters to filter, sort, and paginate results.
305
+ *
306
+ * @returns The first result of the query, if any.
292
307
  */
293
308
  async getFirst(params) {
294
309
  const actualParams = { ...params };
@@ -302,16 +317,27 @@ var Client = class {
302
317
  throw new require_NotFoundError.NotFoundError("No documents were returned", url, void 0);
303
318
  }
304
319
  /**
305
- * Fetches all pages based on the `params` argument. This method may make
306
- * multiple network requests to fetch all matching pages.
320
+ * **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
321
+ * require more resources than other methods. Prefer using other methods that
322
+ * filter by filters such as `getAllByType`.
323
+ *
324
+ * Queries content from the Prismic repository and returns all matching
325
+ * content. If no filters are provided, all documents will be fetched.
326
+ *
327
+ * This method may make multiple network requests to query all matching
328
+ * content.
307
329
  *
308
330
  * @example
309
331
  *
310
332
  * ```ts
311
- * const pages = await client.dangerouslyGetAll()
333
+ * const response = await client.dangerouslyGetAll()
312
334
  * ```
313
335
  *
314
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#dangerouslygetall}
336
+ * @typeParam TDocument - Type of Prismic documents returned.
337
+ *
338
+ * @param params - Parameters to filter, sort, and paginate results.
339
+ *
340
+ * @returns A list of documents matching the query.
315
341
  */
316
342
  async dangerouslyGetAll(params = {}) {
317
343
  var _this$defaultParams2;
@@ -334,21 +360,39 @@ var Client = class {
334
360
  return documents.slice(0, limit);
335
361
  }
336
362
  /**
337
- * Fetches a page with a specific ID.
363
+ * Queries a document from the Prismic repository with a specific ID.
364
+ *
365
+ * @remarks
366
+ * A document's UID is different from its ID. An ID is automatically generated
367
+ * for all documents and is made available on its `id` property. A UID is
368
+ * provided in the Prismic editor and is unique among all documents of its
369
+ * custom type.
338
370
  *
339
371
  * @example
340
372
  *
341
373
  * ```ts
342
- * const page = await client.getByID("WW4bKScAAMAqmluX")
374
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
343
375
  * ```
344
376
  *
345
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyid}
377
+ * @typeParam TDocument- Type of the Prismic document returned.
378
+ *
379
+ * @param id - ID of the document.
380
+ * @param params - Parameters to filter, sort, and paginate the results.
381
+ *
382
+ * @returns The document with an ID matching the `id` parameter, if a matching
383
+ * document exists.
346
384
  */
347
385
  async getByID(id, params) {
348
386
  return await this.getFirst(require_appendFilters.appendFilters(params, require_filter.filter.at("document.id", id)));
349
387
  }
350
388
  /**
351
- * Fetches pages with specific IDs. Results are paginated.
389
+ * Queries documents from the Prismic repository with specific IDs.
390
+ *
391
+ * @remarks
392
+ * A document's UID is different from its ID. An ID is automatically generated
393
+ * for all documents and is made available on its `id` property. A UID is
394
+ * provided in the Prismic editor and is unique among all documents of its
395
+ * custom type.
352
396
  *
353
397
  * @example
354
398
  *
@@ -359,95 +403,172 @@ var Client = class {
359
403
  * ])
360
404
  * ```
361
405
  *
362
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyids}
406
+ * @typeParam TDocument - Type of Prismic documents returned.
407
+ *
408
+ * @param ids - A list of document IDs.
409
+ * @param params - Parameters to filter, sort, and paginate the results.
410
+ *
411
+ * @returns A paginated response containing documents with IDs matching the
412
+ * `ids` parameter.
363
413
  */
364
414
  async getByIDs(ids, params) {
365
415
  return await this.get(require_appendFilters.appendFilters(params, require_filter.filter.in("document.id", ids)));
366
416
  }
367
417
  /**
368
- * Fetches pages with specific IDs. This method may make multiple network
369
- * requests to fetch all matching pages.
418
+ * Queries all documents from the Prismic repository with specific IDs.
419
+ *
420
+ * This method may make multiple network requests to query all matching
421
+ * content.
422
+ *
423
+ * @remarks
424
+ * A document's UID is different from its ID. An ID is automatically generated
425
+ * for all documents and is made available on its `id` property. A UID is
426
+ * provided in the Prismic editor and is unique among all documents of its
427
+ * custom type.
370
428
  *
371
429
  * @example
372
430
  *
373
431
  * ```ts
374
- * const pages = await client.getAllByIDs([
432
+ * const response = await client.getAllByIDs([
375
433
  * "WW4bKScAAMAqmluX",
376
434
  * "U1kTRgEAAC8A5ldS",
377
435
  * ])
378
436
  * ```
379
437
  *
380
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyids}
438
+ * @typeParam TDocument - Type of Prismic documents returned.
439
+ *
440
+ * @param ids - A list of document IDs.
441
+ * @param params - Parameters to filter, sort, and paginate the results.
442
+ *
443
+ * @returns A list of documents with IDs matching the `ids` parameter.
381
444
  */
382
445
  async getAllByIDs(ids, params) {
383
446
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_filter.filter.in("document.id", ids)));
384
447
  }
385
448
  /**
386
- * Fetches a page with a specific UID and type.
449
+ * Queries a document from the Prismic repository with a specific UID and
450
+ * custom type.
451
+ *
452
+ * @remarks
453
+ * A document's UID is different from its ID. An ID is automatically generated
454
+ * for all documents and is made available on its `id` property. A UID is
455
+ * provided in the Prismic editor and is unique among all documents of its
456
+ * custom type.
387
457
  *
388
458
  * @example
389
459
  *
390
460
  * ```ts
391
- * const page = await client.getByUID("blog_post", "my-first-post")
461
+ * const document = await client.getByUID("blog_post", "my-first-post")
392
462
  * ```
393
463
  *
394
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuid}
464
+ * @typeParam TDocument - Type of the Prismic document returned.
465
+ *
466
+ * @param documentType - The API ID of the document's custom type.
467
+ * @param uid - UID of the document.
468
+ * @param params - Parameters to filter, sort, and paginate the results.
469
+ *
470
+ * @returns The document with a UID matching the `uid` parameter, if a
471
+ * matching document exists.
395
472
  */
396
473
  async getByUID(documentType, uid, params) {
397
474
  return await this.getFirst(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.at(`my.${documentType}.uid`, uid)]));
398
475
  }
399
476
  /**
400
- * Fetches pages with specific UIDs and a specific type. Results are
401
- * paginated.
477
+ * Queries document from the Prismic repository with specific UIDs and Custom
478
+ * Type.
479
+ *
480
+ * @remarks
481
+ * A document's UID is different from its ID. An ID is automatically generated
482
+ * for all documents and is made available on its `id` property. A UID is
483
+ * provided in the Prismic editor and is unique among all documents of its
484
+ * custom type.
402
485
  *
403
486
  * @example
404
487
  *
405
488
  * ```ts
406
- * const response = await client.getByUIDs("blog_post", [
489
+ * const document = await client.getByUIDs("blog_post", [
407
490
  * "my-first-post",
408
491
  * "my-second-post",
409
492
  * ])
410
493
  * ```
411
494
  *
412
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuids}
495
+ * @typeParam TDocument - Type of the Prismic document returned.
496
+ *
497
+ * @param documentType - The API ID of the document's custom type.
498
+ * @param uids - A list of document UIDs.
499
+ * @param params - Parameters to filter, sort, and paginate the results.
500
+ *
501
+ * @returns A paginated response containing documents with UIDs matching the
502
+ * `uids` parameter.
413
503
  */
414
504
  async getByUIDs(documentType, uids, params) {
415
505
  return await this.get(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)]));
416
506
  }
417
507
  /**
418
- * Fetches pages with specific UIDs and a specific type. This method may make
419
- * multiple network requests to fetch all matching pages.
508
+ * Queries all documents from the Prismic repository with specific UIDs and
509
+ * custom type.
510
+ *
511
+ * This method may make multiple network requests to query all matching
512
+ * content.
513
+ *
514
+ * @remarks
515
+ * A document's UID is different from its ID. An ID is automatically generated
516
+ * for all documents and is made available on its `id` property. A UID is
517
+ * provided in the Prismic editor and is unique among all documents of its
518
+ * custom type.
420
519
  *
421
520
  * @example
422
521
  *
423
522
  * ```ts
424
- * const pages = await client.getAllByUIDs("blog_post", [
523
+ * const response = await client.getAllByUIDs([
425
524
  * "my-first-post",
426
525
  * "my-second-post",
427
526
  * ])
428
527
  * ```
429
528
  *
430
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyuids}
529
+ * @typeParam TDocument - Type of Prismic documents returned.
530
+ *
531
+ * @param documentType - The API ID of the document's custom type.
532
+ * @param uids - A list of document UIDs.
533
+ * @param params - Parameters to filter, sort, and paginate the results.
534
+ *
535
+ * @returns A list of documents with UIDs matching the `uids` parameter.
431
536
  */
432
537
  async getAllByUIDs(documentType, uids, params) {
433
538
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)]));
434
539
  }
435
540
  /**
436
- * Fetches a specific single type page.
541
+ * Queries a singleton document from the Prismic repository for a specific
542
+ * custom type.
543
+ *
544
+ * @remarks
545
+ * A singleton document is one that is configured in Prismic to only allow one
546
+ * instance. For example, a repository may be configured to contain just one
547
+ * Settings document. This is in contrast to a repeatable custom type which
548
+ * allows multiple instances of itself.
437
549
  *
438
550
  * @example
439
551
  *
440
552
  * ```ts
441
- * const page = await client.getSingle("settings")
553
+ * const document = await client.getSingle("settings")
442
554
  * ```
443
555
  *
444
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getsingle}
556
+ * @typeParam TDocument - Type of the Prismic document returned.
557
+ *
558
+ * @param documentType - The API ID of the singleton custom type.
559
+ * @param params - Parameters to filter, sort, and paginate the results.
560
+ *
561
+ * @returns The singleton document for the custom type, if a matching document
562
+ * exists.
445
563
  */
446
564
  async getSingle(documentType, params) {
447
565
  return await this.getFirst(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
448
566
  }
449
567
  /**
450
- * Fetches pages with a specific type. Results are paginated.
568
+ * Queries documents from the Prismic repository for a specific custom type.
569
+ *
570
+ * Use `getAllByType` instead if you need to query all documents for a
571
+ * specific custom type.
451
572
  *
452
573
  * @example
453
574
  *
@@ -455,132 +576,189 @@ var Client = class {
455
576
  * const response = await client.getByType("blog_post")
456
577
  * ```
457
578
  *
458
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytype}
579
+ * @typeParam TDocument - Type of Prismic documents returned.
580
+ *
581
+ * @param documentType - The API ID of the custom type.
582
+ * @param params - Parameters to filter, sort, and paginate the results.
583
+ *
584
+ * @returns A paginated response containing documents of the custom type.
459
585
  */
460
586
  async getByType(documentType, params) {
461
587
  return await this.get(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
462
588
  }
463
589
  /**
464
- * Fetches pages with a specific type. This method may make multiple network
465
- * requests to fetch all matching documents.
590
+ * Queries all documents from the Prismic repository for a specific Custom
591
+ * Type.
592
+ *
593
+ * This method may make multiple network requests to query all matching
594
+ * content.
466
595
  *
467
596
  * @example
468
597
  *
469
598
  * ```ts
470
- * const pages = await client.getAllByType("blog_post")
599
+ * const response = await client.getByType("blog_post")
471
600
  * ```
472
601
  *
473
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytype}
602
+ * @typeParam TDocument - Type of Prismic documents returned.
603
+ *
604
+ * @param documentType - The API ID of the custom type.
605
+ * @param params - Parameters to filter, sort, and paginate the results.
606
+ *
607
+ * @returns A list of all documents of the custom type.
474
608
  */
475
609
  async getAllByType(documentType, params) {
476
610
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
477
611
  }
478
612
  /**
479
- * Fetches pages with a specific tag. Results are paginated.
613
+ * Queries documents from the Prismic repository with a specific tag.
614
+ *
615
+ * Use `getAllByTag` instead if you need to query all documents with a
616
+ * specific tag.
480
617
  *
481
618
  * @example
482
619
  *
483
620
  * ```ts
484
- * const response = await client.getByTag("featured")
621
+ * const response = await client.getByTag("food")
485
622
  * ```
486
623
  *
487
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytag}
624
+ * @typeParam TDocument - Type of Prismic documents returned.
625
+ *
626
+ * @param tag - The tag that must be included on a document.
627
+ * @param params - Parameters to filter, sort, and paginate the results.
628
+ *
629
+ * @returns A paginated response containing documents with the tag.
488
630
  */
489
631
  async getByTag(tag, params) {
490
632
  return await this.get(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tag)));
491
633
  }
492
634
  /**
493
- * Fetches pages with a specific tag. This method may make multiple network
494
- * requests to fetch all matching documents.
635
+ * Queries all documents from the Prismic repository with a specific tag.
636
+ *
637
+ * This method may make multiple network requests to query all matching
638
+ * content.
495
639
  *
496
640
  * @example
497
641
  *
498
642
  * ```ts
499
- * const pages = await client.getAllByTag("featured")
643
+ * const response = await client.getAllByTag("food")
500
644
  * ```
501
645
  *
502
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytag}
646
+ * @typeParam TDocument - Type of Prismic documents returned.
647
+ *
648
+ * @param tag - The tag that must be included on a document.
649
+ * @param params - Parameters to filter, sort, and paginate the results.
650
+ *
651
+ * @returns A list of all documents with the tag.
503
652
  */
504
653
  async getAllByTag(tag, params) {
505
654
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tag)));
506
655
  }
507
656
  /**
508
- * Fetches pages with every tag from a list of tags. Results are paginated.
657
+ * Queries documents from the Prismic repository with specific tags. A
658
+ * document must be tagged with all of the queried tags to be included.
509
659
  *
510
660
  * @example
511
661
  *
512
662
  * ```ts
513
- * const response = await client.getByEveryTag(["featured", "homepage"])
663
+ * const response = await client.getByEveryTag(["food", "fruit"])
514
664
  * ```
515
665
  *
516
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyeverytag}
666
+ * @typeParam TDocument - Type of Prismic documents returned.
667
+ *
668
+ * @param tags - A list of tags that must be included on a document.
669
+ * @param params - Parameters to filter, sort, and paginate the results.
670
+ *
671
+ * @returns A paginated response containing documents with the tags.
517
672
  */
518
673
  async getByEveryTag(tags, params) {
519
674
  return await this.get(require_appendFilters.appendFilters(params, require_everyTagFilter.everyTagFilter(tags)));
520
675
  }
521
676
  /**
522
- * Fetches pages with every tag from a list of tags. This method may make
523
- * multiple network requests to fetch all matching pages.
677
+ * Queries documents from the Prismic repository with specific tags. A
678
+ * document must be tagged with all of the queried tags to be included.
679
+ *
680
+ * This method may make multiple network requests to query all matching
681
+ * content.
524
682
  *
525
683
  * @example
526
684
  *
527
685
  * ```ts
528
- * const pages = await client.getAllByEveryTag(["featured", "homepage"])
686
+ * const response = await client.getAllByEveryTag(["food", "fruit"])
529
687
  * ```
530
688
  *
531
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyeverytag}
689
+ * @typeParam TDocument - Type of Prismic documents returned.
690
+ *
691
+ * @param tags - A list of tags that must be included on a document.
692
+ * @param params - Parameters to filter, sort, and paginate the results.
693
+ *
694
+ * @returns A list of all documents with the tags.
532
695
  */
533
696
  async getAllByEveryTag(tags, params) {
534
697
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_everyTagFilter.everyTagFilter(tags)));
535
698
  }
536
699
  /**
537
- * Fetches pages with at least one tag from a list of tags. Results are
538
- * paginated.
700
+ * Queries documents from the Prismic repository with specific tags. A
701
+ * document must be tagged with at least one of the queried tags to be
702
+ * included.
539
703
  *
540
704
  * @example
541
705
  *
542
706
  * ```ts
543
- * const response = await client.getBySomeTags(["featured", "homepage"])
707
+ * const response = await client.getByEveryTag(["food", "fruit"])
544
708
  * ```
545
709
  *
546
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbysometags}
710
+ * @typeParam TDocument - Type of Prismic documents returned.
711
+ *
712
+ * @param tags - A list of tags that must be included on a document.
713
+ * @param params - Parameters to filter, sort, and paginate the results.
714
+ *
715
+ * @returns A paginated response containing documents with at least one of the
716
+ * tags.
547
717
  */
548
718
  async getBySomeTags(tags, params) {
549
719
  return await this.get(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tags)));
550
720
  }
551
721
  /**
552
- * Fetches pages with at least one tag from a list of tags. This method may
553
- * make multiple network requests to fetch all matching documents.
722
+ * Queries documents from the Prismic repository with specific tags. A
723
+ * document must be tagged with at least one of the queried tags to be
724
+ * included.
725
+ *
726
+ * This method may make multiple network requests to query all matching
727
+ * content.
554
728
  *
555
729
  * @example
556
730
  *
557
731
  * ```ts
558
- * const pages = await client.getAllBySomeTags(["featured", "homepage"])
732
+ * const response = await client.getAllBySomeTags(["food", "fruit"])
559
733
  * ```
560
734
  *
561
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbysometags}
735
+ * @typeParam TDocument - Type of Prismic documents returned.
736
+ *
737
+ * @param tags - A list of tags that must be included on a document.
738
+ * @param params - Parameters to filter, sort, and paginate the results.
739
+ *
740
+ * @returns A list of all documents with at least one of the tags.
562
741
  */
563
742
  async getAllBySomeTags(tags, params) {
564
743
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tags)));
565
744
  }
566
745
  /**
567
- * Fetches metadata about the client's Prismic repository.
746
+ * Returns metadata about the Prismic repository, such as its refs, releases,
747
+ * and custom types.
568
748
  *
569
- * @example
570
- *
571
- * ```ts
572
- * const repository = await client.getRepository()
573
- * ```
574
- *
575
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}
749
+ * @returns Repository metadata.
576
750
  */
577
751
  async getRepository(params) {
752
+ if (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) return this.#cachedRepository;
578
753
  const url = new URL(this.documentAPIEndpoint);
579
754
  const accessToken = (params === null || params === void 0 ? void 0 : params.accessToken) || this.accessToken;
580
755
  if (accessToken) url.searchParams.set("access_token", accessToken);
581
756
  const response = await this.#request(url, params);
582
757
  switch (response.status) {
583
- case 200: return await response.json();
758
+ case 200:
759
+ this.#cachedRepository = await response.json();
760
+ this.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
761
+ return this.#cachedRepository;
584
762
  case 401: {
585
763
  const json = await response.json();
586
764
  throw new require_ForbiddenError.ForbiddenError(json.error, url.toString(), json);
@@ -590,138 +768,97 @@ var Client = class {
590
768
  }
591
769
  }
592
770
  /**
593
- * Fetches the repository's active refs.
771
+ * Returns a list of all refs for the Prismic repository.
594
772
  *
595
- * @example
596
- *
597
- * ```ts
598
- * const refs = await client.getRefs()
599
- * ```
773
+ * Refs are used to identify which version of the repository's content should
774
+ * be queried. All repositories will have at least one ref pointing to the
775
+ * latest published content called the "master ref".
600
776
  *
601
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefs}
777
+ * @returns A list of all refs for the Prismic repository.
602
778
  */
603
779
  async getRefs(params) {
604
780
  return (await this.getRepository(params)).refs;
605
781
  }
606
782
  /**
607
- * Fetches a ref by its ID.
783
+ * Returns a ref for the Prismic repository with a matching ID.
608
784
  *
609
- * @example
785
+ * @param id - ID of the ref.
610
786
  *
611
- * ```ts
612
- * const ref = await client.getRefByID("YhE3YhEAACIA4321")
613
- * ```
614
- *
615
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbyid}
787
+ * @returns The ref with a matching ID, if it exists.
616
788
  */
617
789
  async getRefByID(id, params) {
618
790
  return require_findRefByID.findRefByID(await this.getRefs(params), id);
619
791
  }
620
792
  /**
621
- * Fetches a ref by its label. A release ref's label is its name shown in the
622
- * Page Builder.
793
+ * Returns a ref for the Prismic repository with a matching label.
623
794
  *
624
- * @example
795
+ * @param label - Label of the ref.
625
796
  *
626
- * ```ts
627
- * const ref = await client.getRefByLabel("My Release")
628
- * ```
629
- *
630
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbylabel}
797
+ * @returns The ref with a matching label, if it exists.
631
798
  */
632
799
  async getRefByLabel(label, params) {
633
800
  return require_findRefByLabel.findRefByLabel(await this.getRefs(params), label);
634
801
  }
635
802
  /**
636
- * Fetches the repository's master ref.
803
+ * Returns the master ref for the Prismic repository. The master ref points to
804
+ * the repository's latest published content.
637
805
  *
638
- * @example
639
- *
640
- * ```ts
641
- * const masterRef = await client.getMasterRef()
642
- * ```
643
- *
644
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getmasterref}
806
+ * @returns The repository's master ref.
645
807
  */
646
808
  async getMasterRef(params) {
647
809
  return require_findMasterRef.findMasterRef(await this.getRefs(params));
648
810
  }
649
811
  /**
650
- * Fetches the repository's active releases.
651
- *
652
- * @example
653
- *
654
- * ```ts
655
- * const releases = await client.getReleases()
656
- * ```
812
+ * Returns a list of all Releases for the Prismic repository. Releases are
813
+ * used to group content changes before publishing.
657
814
  *
658
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleases}
815
+ * @returns A list of all Releases for the Prismic repository.
659
816
  */
660
817
  async getReleases(params) {
661
818
  return (await this.getRefs(params)).filter((ref) => !ref.isMasterRef);
662
819
  }
663
820
  /**
664
- * Fetches a release with a specific ID.
665
- *
666
- * @example
821
+ * Returns a Release for the Prismic repository with a matching ID.
667
822
  *
668
- * ```ts
669
- * const release = await client.getReleaseByID("YhE3YhEAACIA4321")
670
- * ```
823
+ * @param id - ID of the Release.
671
824
  *
672
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebyid}
825
+ * @returns The Release with a matching ID, if it exists.
673
826
  */
674
827
  async getReleaseByID(id, params) {
675
828
  return require_findRefByID.findRefByID(await this.getReleases(params), id);
676
829
  }
677
830
  /**
678
- * Fetches a release by its label. A release ref's label is its name shown in
679
- * the Page Builder.
831
+ * Returns a Release for the Prismic repository with a matching label.
680
832
  *
681
- * @example
682
- *
683
- * ```ts
684
- * const release = await client.getReleaseByLabel("My Release")
685
- * ```
833
+ * @param label - Label of the ref.
686
834
  *
687
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebylabel}
835
+ * @returns The ref with a matching label, if it exists.
688
836
  */
689
837
  async getReleaseByLabel(label, params) {
690
838
  return require_findRefByLabel.findRefByLabel(await this.getReleases(params), label);
691
839
  }
692
840
  /**
693
- * Fetches the repository's page tags.
841
+ * Returns a list of all tags used in the Prismic repository.
694
842
  *
695
- * @example
696
- *
697
- * ```ts
698
- * const tags = await client.getTags()
699
- * ```
700
- *
701
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#gettags}
843
+ * @returns A list of all tags used in the repository.
702
844
  */
703
845
  async getTags(params) {
704
- const form = (await this.getCachedRepository(params)).forms.tags;
846
+ const repository = await this.getRepository(params);
847
+ const form = repository.forms.tags;
705
848
  if (form) {
706
849
  const url = new URL(form.action);
707
850
  if (this.accessToken) url.searchParams.set("access_token", this.accessToken);
708
851
  const response = await this.#request(url, params);
709
852
  if (response.ok) return await response.json();
710
853
  }
711
- return (await this.getRepository(params)).tags;
854
+ return repository.tags;
712
855
  }
713
856
  /**
714
- * Builds a Content API query URL with a set of parameters.
857
+ * Builds a URL used to query content from the Prismic repository.
715
858
  *
716
- * @example
859
+ * @param params - Parameters to filter, sort, and paginate the results.
717
860
  *
718
- * ```ts
719
- * const url = await client.buildQueryURL({
720
- * filters: [filter.at("document.type", "blog_post")],
721
- * })
722
- * ```
723
- *
724
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}
861
+ * @returns A URL string that can be requested to query content.
725
862
  */
726
863
  async buildQueryURL({ signal, fetchOptions,...params } = {}) {
727
864
  const ref = params.ref || await this.getResolvedRefString({
@@ -729,7 +866,7 @@ var Client = class {
729
866
  signal,
730
867
  fetchOptions
731
868
  });
732
- const integrationFieldsRef = params.integrationFieldsRef || (await this.getCachedRepository({
869
+ const integrationFieldsRef = params.integrationFieldsRef || (await this.getRepository({
733
870
  accessToken: params.accessToken,
734
871
  signal,
735
872
  fetchOptions
@@ -745,18 +882,23 @@ var Client = class {
745
882
  });
746
883
  }
747
884
  /**
748
- * Fetches a previewed page's URL using a preview token and page ID.
885
+ * Determines the URL for a previewed document during an active preview
886
+ * session. The result of this method should be used to redirect the user to
887
+ * the document's URL.
749
888
  *
750
889
  * @example
751
890
  *
752
891
  * ```ts
753
- * const url = await client.resolvePreviewURL({
754
- * linkResolver,
755
- * defaultURL: "/",
756
- * })
892
+ * const url = client.resolvePreviewURL({
893
+ * linkResolver: (document) => `/${document.uid}`
894
+ * defaultURL: '/'
895
+ * })
757
896
  * ```
758
897
  *
759
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#resolvepreviewurl}
898
+ * @param args - Arguments to configure the URL resolving.
899
+ *
900
+ * @returns The URL for the previewed document during an active preview
901
+ * session. The user should be redirected to this URL.
760
902
  */
761
903
  async resolvePreviewURL(args) {
762
904
  let documentID = args.documentID;
@@ -788,30 +930,37 @@ var Client = class {
788
930
  return args.defaultURL;
789
931
  }
790
932
  /**
791
- * Configures the client to query the latest published content. This is the
792
- * client's default mode.
933
+ * Configures the client to query the latest published content for all future
934
+ * queries.
935
+ *
936
+ * If the `ref` parameter is provided during a query, it takes priority for
937
+ * that query.
793
938
  *
794
939
  * @example
795
940
  *
796
941
  * ```ts
797
- * client.queryLatestContent()
942
+ * await client.queryLatestContent()
943
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
798
944
  * ```
799
- *
800
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}
801
945
  */
802
946
  queryLatestContent() {
803
947
  this.refState.mode = RefStateMode.Master;
804
948
  }
805
949
  /**
806
- * Configures the client to query content from a release with a specific ID.
950
+ * Configures the client to query content from a specific Release identified
951
+ * by its ID for all future queries.
952
+ *
953
+ * If the `ref` parameter is provided during a query, it takes priority for
954
+ * that query.
807
955
  *
808
956
  * @example
809
957
  *
810
958
  * ```ts
811
- * client.queryContentFromReleaseByID("YhE3YhEAACIA4321")
959
+ * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa")
960
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
812
961
  * ```
813
962
  *
814
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
963
+ * @param releaseID - The ID of the Release.
815
964
  */
816
965
  queryContentFromReleaseByID(releaseID) {
817
966
  this.refState = {
@@ -821,16 +970,20 @@ var Client = class {
821
970
  };
822
971
  }
823
972
  /**
824
- * Configures the client to query content from a release with a specific
825
- * label.
973
+ * Configures the client to query content from a specific Release identified
974
+ * by its label for all future queries.
975
+ *
976
+ * If the `ref` parameter is provided during a query, it takes priority for
977
+ * that query.
826
978
  *
827
979
  * @example
828
980
  *
829
981
  * ```ts
830
- * client.queryContentFromReleaseByLabel("My Release")
982
+ * await client.queryContentFromReleaseByLabel("My Release")
983
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
831
984
  * ```
832
985
  *
833
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
986
+ * @param releaseLabel - The label of the Release.
834
987
  */
835
988
  queryContentFromReleaseByLabel(releaseLabel) {
836
989
  this.refState = {
@@ -840,15 +993,21 @@ var Client = class {
840
993
  };
841
994
  }
842
995
  /**
843
- * Configures the client to query content from a specific ref.
996
+ * Configures the client to query content from a specific ref. The ref can be
997
+ * provided as a string or a function.
998
+ *
999
+ * If a function is provided, the ref is fetched lazily before each query. The
1000
+ * function may also be asynchronous.
844
1001
  *
845
1002
  * @example
846
1003
  *
847
1004
  * ```ts
848
- * client.queryContentFromRef("my-ref")
1005
+ * await client.queryContentFromRef("my-ref")
1006
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
849
1007
  * ```
850
1008
  *
851
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}
1009
+ * @param ref - The ref or a function that returns the ref from which to query
1010
+ * content.
852
1011
  */
853
1012
  queryContentFromRef(ref) {
854
1013
  this.refState = {
@@ -858,18 +1017,17 @@ var Client = class {
858
1017
  };
859
1018
  }
860
1019
  /**
861
- * A preconfigured `fetch()` function for Prismic's GraphQL API that can be
862
- * provided to GraphQL clients.
1020
+ * A `fetch()` function to be used with GraphQL clients configured for
1021
+ * Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
1022
+ * and Authorization headers. Queries will automatically be minified by
1023
+ * removing whitespace where possible.
863
1024
  *
864
1025
  * @example
865
1026
  *
866
1027
  * ```ts
867
- * import { createClient, getGraphQLEndpoint } from "@prismicio/client"
868
- *
869
- * const client = createClient("example-prismic-repo")
870
1028
  * const graphQLClient = new ApolloClient({
871
1029
  * link: new HttpLink({
872
- * uri: getGraphQLEndpoint(client.repositoryName),
1030
+ * uri: prismic.getGraphQLEndpoint(repositoryName),
873
1031
  * // Provide `client.graphQLFetch` as the fetch implementation.
874
1032
  * fetch: client.graphQLFetch,
875
1033
  * // Using GET is required.
@@ -879,17 +1037,23 @@ var Client = class {
879
1037
  * })
880
1038
  * ```
881
1039
  *
882
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#graphqlfetch}
1040
+ * @param input - The `fetch()` `input` parameter. Only strings are supported.
1041
+ * @param init - The `fetch()` `init` parameter. Only plain objects are
1042
+ * supported.
1043
+ *
1044
+ * @returns The `fetch()` Response for the request.
1045
+ *
1046
+ * @experimental
883
1047
  */
884
1048
  async graphQLFetch(input, init) {
885
- const cachedRepository = await this.getCachedRepository();
1049
+ const repository = await this.getRepository();
886
1050
  const ref = await this.getResolvedRefString();
887
1051
  const unsanitizedHeaders = {
888
1052
  "Prismic-ref": ref,
889
1053
  Authorization: this.accessToken ? `Token ${this.accessToken}` : "",
890
1054
  ...init ? init.headers : {}
891
1055
  };
892
- if (cachedRepository.integrationFieldsRef) unsanitizedHeaders["Prismic-integration-field-ref"] = cachedRepository.integrationFieldsRef;
1056
+ if (repository.integrationFieldsRef) unsanitizedHeaders["Prismic-integration-field-ref"] = repository.integrationFieldsRef;
893
1057
  const headers = {};
894
1058
  for (const key in unsanitizedHeaders) if (unsanitizedHeaders[key]) headers[key.toLowerCase()] = unsanitizedHeaders[key];
895
1059
  const url = new URL(input);
@@ -902,18 +1066,6 @@ var Client = class {
902
1066
  });
903
1067
  }
904
1068
  /**
905
- * Returns a cached version of `getRepository` with a TTL.
906
- *
907
- * @returns Cached repository metadata.
908
- */
909
- async getCachedRepository(params) {
910
- if (!this.cachedRepository || Date.now() >= this.cachedRepositoryExpiration) {
911
- this.cachedRepository = await this.getRepository(params);
912
- this.cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
913
- }
914
- return this.cachedRepository;
915
- }
916
- /**
917
1069
  * Returns the ref needed to query based on the client's current state. This
918
1070
  * method may make a network request to fetch a ref or resolve the user's ref
919
1071
  * thunk.
@@ -948,15 +1100,15 @@ var Client = class {
948
1100
  if (cookieJar) previewRef = require_getPreviewCookie.getPreviewCookie(cookieJar);
949
1101
  if (previewRef) return previewRef;
950
1102
  }
951
- const cachedRepository = await this.getCachedRepository(params);
1103
+ const repository = await this.getRepository(params);
952
1104
  const refModeType = this.refState.mode;
953
- if (refModeType === RefStateMode.ReleaseID) return require_findRefByID.findRefByID(cachedRepository.refs, this.refState.releaseID).ref;
954
- else if (refModeType === RefStateMode.ReleaseLabel) return require_findRefByLabel.findRefByLabel(cachedRepository.refs, this.refState.releaseLabel).ref;
1105
+ if (refModeType === RefStateMode.ReleaseID) return require_findRefByID.findRefByID(repository.refs, this.refState.releaseID).ref;
1106
+ else if (refModeType === RefStateMode.ReleaseLabel) return require_findRefByLabel.findRefByLabel(repository.refs, this.refState.releaseLabel).ref;
955
1107
  else if (refModeType === RefStateMode.Manual) {
956
1108
  const res = await require_castThunk.castThunk(this.refState.ref)();
957
1109
  if (typeof res === "string") return res;
958
1110
  }
959
- return require_findMasterRef.findMasterRef(cachedRepository.refs).ref;
1111
+ return require_findMasterRef.findMasterRef(repository.refs).ref;
960
1112
  }
961
1113
  /**
962
1114
  * The private implementation of `this.get`. It returns the API response and
@@ -1012,8 +1164,8 @@ var Client = class {
1012
1164
  } catch (error) {
1013
1165
  var _error$message$match;
1014
1166
  if (!(error instanceof require_RefNotFoundError.RefNotFoundError || error instanceof require_RefExpiredError.RefExpiredError) || attemptCount >= MAX_INVALID_REF_RETRY_ATTEMPTS - 1) throw error;
1015
- if (!(params === null || params === void 0 ? void 0 : params.ref)) this.cachedRepository = void 0;
1016
- const masterRef = (_error$message$match = error.message.match(/Master ref is: (?<ref>.*)$/)) === null || _error$message$match === void 0 || (_error$message$match = _error$message$match.groups) === null || _error$message$match === void 0 ? void 0 : _error$message$match.ref;
1167
+ if (!(params === null || params === void 0 ? void 0 : params.ref)) this.#cachedRepository = void 0;
1168
+ const masterRef = (_error$message$match = error.message.match(/master ref is: (?<ref>.*)$/i)) === null || _error$message$match === void 0 || (_error$message$match = _error$message$match.groups) === null || _error$message$match === void 0 ? void 0 : _error$message$match.ref;
1017
1169
  if (!masterRef) throw error;
1018
1170
  require_throttledLog.throttledLog(`[@prismicio/client] The ref (${new URL(url).searchParams.get("ref")}) was ${error instanceof require_RefNotFoundError.RefNotFoundError ? "invalid" : "expired"}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`, { level: "warn" });
1019
1171
  return await this._get({