@prismicio/client 7.21.0-canary.248534d → 7.21.0-canary.7f2eeca

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