@prismicio/client 7.21.0-canary.7f2eeca → 7.21.0-canary.85959a7

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
@@ -214,7 +214,11 @@ var Client = class {
214
214
  this.graphQLFetch = this.graphQLFetch.bind(this);
215
215
  }
216
216
  /**
217
- * 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`.
218
222
  *
219
223
  * @example
220
224
  *
@@ -222,22 +226,29 @@ var Client = class {
222
226
  * client.enableAutoPreviews()
223
227
  * ```
224
228
  *
225
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}
229
+ * @see enableAutoPreviewsFromReq
226
230
  */
227
231
  enableAutoPreviews() {
228
232
  this.refState.autoPreviewsEnabled = true;
229
233
  }
230
234
  /**
231
- * Enables the client to automatically query content from a preview session
232
- * 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`.
233
240
  *
234
241
  * @example
235
242
  *
236
243
  * ```ts
237
- * client.enableAutoPreviewsFromReq(req)
244
+ * // In an express app
245
+ * app.get("/", function (req, res) {
246
+ * client.enableAutoPreviewsFromReq(req)
247
+ * })
238
248
  * ```
239
249
  *
240
- * @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.
241
252
  */
242
253
  enableAutoPreviewsFromReq(req) {
243
254
  this.refState.httpRequest = req;
@@ -245,44 +256,54 @@ var Client = class {
245
256
  }
246
257
  /**
247
258
  * Disables the client from automatically querying content from a preview
248
- * session.
259
+ * session if one is active.
260
+ *
261
+ * Automatic preview content querying is enabled by default unless this method
262
+ * is called.
249
263
  *
250
264
  * @example
251
265
  *
252
266
  * ```ts
253
267
  * client.disableAutoPreviews()
254
268
  * ```
255
- *
256
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}
257
269
  */
258
270
  disableAutoPreviews() {
259
271
  this.refState.autoPreviewsEnabled = false;
260
272
  }
261
273
  /**
262
- * Fetches pages based on the `params` argument. Results are paginated.
274
+ * Queries content from the Prismic repository.
263
275
  *
264
276
  * @example
265
277
  *
266
278
  * ```ts
267
- * const response = await client.get({ pageSize: 10 })
279
+ * const response = await client.get()
268
280
  * ```
269
281
  *
270
- * @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.
271
287
  */
272
288
  async get(params) {
273
289
  const { data } = await this._get(params);
274
290
  return data;
275
291
  }
276
292
  /**
277
- * 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.
278
295
  *
279
296
  * @example
280
297
  *
281
298
  * ```ts
282
- * const page = await client.getFirst()
299
+ * const document = await client.getFirst()
283
300
  * ```
284
301
  *
285
- * @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.
286
307
  */
287
308
  async getFirst(params) {
288
309
  const actualParams = { ...params };
@@ -296,16 +317,27 @@ var Client = class {
296
317
  throw new require_NotFoundError.NotFoundError("No documents were returned", url, void 0);
297
318
  }
298
319
  /**
299
- * Fetches all pages based on the `params` argument. This method may make
300
- * 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.
301
329
  *
302
330
  * @example
303
331
  *
304
332
  * ```ts
305
- * const pages = await client.dangerouslyGetAll()
333
+ * const response = await client.dangerouslyGetAll()
306
334
  * ```
307
335
  *
308
- * @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.
309
341
  */
310
342
  async dangerouslyGetAll(params = {}) {
311
343
  var _this$defaultParams2;
@@ -328,21 +360,39 @@ var Client = class {
328
360
  return documents.slice(0, limit);
329
361
  }
330
362
  /**
331
- * 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.
332
370
  *
333
371
  * @example
334
372
  *
335
373
  * ```ts
336
- * const page = await client.getByID("WW4bKScAAMAqmluX")
374
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
337
375
  * ```
338
376
  *
339
- * @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.
340
384
  */
341
385
  async getByID(id, params) {
342
386
  return await this.getFirst(require_appendFilters.appendFilters(params, require_filter.filter.at("document.id", id)));
343
387
  }
344
388
  /**
345
- * 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.
346
396
  *
347
397
  * @example
348
398
  *
@@ -353,95 +403,172 @@ var Client = class {
353
403
  * ])
354
404
  * ```
355
405
  *
356
- * @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.
357
413
  */
358
414
  async getByIDs(ids, params) {
359
415
  return await this.get(require_appendFilters.appendFilters(params, require_filter.filter.in("document.id", ids)));
360
416
  }
361
417
  /**
362
- * Fetches pages with specific IDs. This method may make multiple network
363
- * 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.
364
428
  *
365
429
  * @example
366
430
  *
367
431
  * ```ts
368
- * const pages = await client.getAllByIDs([
432
+ * const response = await client.getAllByIDs([
369
433
  * "WW4bKScAAMAqmluX",
370
434
  * "U1kTRgEAAC8A5ldS",
371
435
  * ])
372
436
  * ```
373
437
  *
374
- * @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.
375
444
  */
376
445
  async getAllByIDs(ids, params) {
377
446
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_filter.filter.in("document.id", ids)));
378
447
  }
379
448
  /**
380
- * 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.
381
457
  *
382
458
  * @example
383
459
  *
384
460
  * ```ts
385
- * const page = await client.getByUID("blog_post", "my-first-post")
461
+ * const document = await client.getByUID("blog_post", "my-first-post")
386
462
  * ```
387
463
  *
388
- * @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.
389
472
  */
390
473
  async getByUID(documentType, uid, params) {
391
474
  return await this.getFirst(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.at(`my.${documentType}.uid`, uid)]));
392
475
  }
393
476
  /**
394
- * Fetches pages with specific UIDs and a specific type. Results are
395
- * 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.
396
485
  *
397
486
  * @example
398
487
  *
399
488
  * ```ts
400
- * const response = await client.getByUIDs("blog_post", [
489
+ * const document = await client.getByUIDs("blog_post", [
401
490
  * "my-first-post",
402
491
  * "my-second-post",
403
492
  * ])
404
493
  * ```
405
494
  *
406
- * @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.
407
503
  */
408
504
  async getByUIDs(documentType, uids, params) {
409
505
  return await this.get(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)]));
410
506
  }
411
507
  /**
412
- * Fetches pages with specific UIDs and a specific type. This method may make
413
- * 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.
414
519
  *
415
520
  * @example
416
521
  *
417
522
  * ```ts
418
- * const pages = await client.getAllByUIDs("blog_post", [
523
+ * const response = await client.getAllByUIDs([
419
524
  * "my-first-post",
420
525
  * "my-second-post",
421
526
  * ])
422
527
  * ```
423
528
  *
424
- * @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.
425
536
  */
426
537
  async getAllByUIDs(documentType, uids, params) {
427
538
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)]));
428
539
  }
429
540
  /**
430
- * 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.
431
549
  *
432
550
  * @example
433
551
  *
434
552
  * ```ts
435
- * const page = await client.getSingle("settings")
553
+ * const document = await client.getSingle("settings")
436
554
  * ```
437
555
  *
438
- * @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.
439
563
  */
440
564
  async getSingle(documentType, params) {
441
565
  return await this.getFirst(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
442
566
  }
443
567
  /**
444
- * 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.
445
572
  *
446
573
  * @example
447
574
  *
@@ -449,124 +576,177 @@ var Client = class {
449
576
  * const response = await client.getByType("blog_post")
450
577
  * ```
451
578
  *
452
- * @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.
453
585
  */
454
586
  async getByType(documentType, params) {
455
587
  return await this.get(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
456
588
  }
457
589
  /**
458
- * Fetches pages with a specific type. This method may make multiple network
459
- * 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.
460
595
  *
461
596
  * @example
462
597
  *
463
598
  * ```ts
464
- * const pages = await client.getAllByType("blog_post")
599
+ * const response = await client.getByType("blog_post")
465
600
  * ```
466
601
  *
467
- * @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.
468
608
  */
469
609
  async getAllByType(documentType, params) {
470
610
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
471
611
  }
472
612
  /**
473
- * 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.
474
617
  *
475
618
  * @example
476
619
  *
477
620
  * ```ts
478
- * const response = await client.getByTag("featured")
621
+ * const response = await client.getByTag("food")
479
622
  * ```
480
623
  *
481
- * @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.
482
630
  */
483
631
  async getByTag(tag, params) {
484
632
  return await this.get(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tag)));
485
633
  }
486
634
  /**
487
- * Fetches pages with a specific tag. This method may make multiple network
488
- * 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.
489
639
  *
490
640
  * @example
491
641
  *
492
642
  * ```ts
493
- * const pages = await client.getAllByTag("featured")
643
+ * const response = await client.getAllByTag("food")
494
644
  * ```
495
645
  *
496
- * @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.
497
652
  */
498
653
  async getAllByTag(tag, params) {
499
654
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tag)));
500
655
  }
501
656
  /**
502
- * 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.
503
659
  *
504
660
  * @example
505
661
  *
506
662
  * ```ts
507
- * const response = await client.getByEveryTag(["featured", "homepage"])
663
+ * const response = await client.getByEveryTag(["food", "fruit"])
508
664
  * ```
509
665
  *
510
- * @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.
511
672
  */
512
673
  async getByEveryTag(tags, params) {
513
674
  return await this.get(require_appendFilters.appendFilters(params, require_everyTagFilter.everyTagFilter(tags)));
514
675
  }
515
676
  /**
516
- * Fetches pages with every tag from a list of tags. This method may make
517
- * 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.
518
682
  *
519
683
  * @example
520
684
  *
521
685
  * ```ts
522
- * const pages = await client.getAllByEveryTag(["featured", "homepage"])
686
+ * const response = await client.getAllByEveryTag(["food", "fruit"])
523
687
  * ```
524
688
  *
525
- * @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.
526
695
  */
527
696
  async getAllByEveryTag(tags, params) {
528
697
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_everyTagFilter.everyTagFilter(tags)));
529
698
  }
530
699
  /**
531
- * Fetches pages with at least one tag from a list of tags. Results are
532
- * 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.
533
703
  *
534
704
  * @example
535
705
  *
536
706
  * ```ts
537
- * const response = await client.getBySomeTags(["featured", "homepage"])
707
+ * const response = await client.getByEveryTag(["food", "fruit"])
538
708
  * ```
539
709
  *
540
- * @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.
541
717
  */
542
718
  async getBySomeTags(tags, params) {
543
719
  return await this.get(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tags)));
544
720
  }
545
721
  /**
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.
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.
548
728
  *
549
729
  * @example
550
730
  *
551
731
  * ```ts
552
- * const pages = await client.getAllBySomeTags(["featured", "homepage"])
732
+ * const response = await client.getAllBySomeTags(["food", "fruit"])
553
733
  * ```
554
734
  *
555
- * @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.
556
741
  */
557
742
  async getAllBySomeTags(tags, params) {
558
743
  return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tags)));
559
744
  }
560
745
  /**
561
- * Fetches metadata about the client's Prismic repository.
746
+ * Returns metadata about the Prismic repository, such as its refs, releases,
747
+ * and custom types.
562
748
  *
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}
749
+ * @returns Repository metadata.
570
750
  */
571
751
  async getRepository(params) {
572
752
  if (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) return this.#cachedRepository;
@@ -588,115 +768,79 @@ var Client = class {
588
768
  }
589
769
  }
590
770
  /**
591
- * Fetches the repository's active refs.
771
+ * Returns a list of all refs for the Prismic repository.
592
772
  *
593
- * @example
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".
594
776
  *
595
- * ```ts
596
- * const refs = await client.getRefs()
597
- * ```
598
- *
599
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefs}
777
+ * @returns A list of all refs for the Prismic repository.
600
778
  */
601
779
  async getRefs(params) {
602
780
  return (await this.getRepository(params)).refs;
603
781
  }
604
782
  /**
605
- * Fetches a ref by its ID.
606
- *
607
- * @example
783
+ * Returns a ref for the Prismic repository with a matching ID.
608
784
  *
609
- * ```ts
610
- * const ref = await client.getRefByID("YhE3YhEAACIA4321")
611
- * ```
785
+ * @param id - ID of the ref.
612
786
  *
613
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbyid}
787
+ * @returns The ref with a matching ID, if it exists.
614
788
  */
615
789
  async getRefByID(id, params) {
616
790
  return require_findRefByID.findRefByID(await this.getRefs(params), id);
617
791
  }
618
792
  /**
619
- * Fetches a ref by its label. A release ref's label is its name shown in the
620
- * Page Builder.
621
- *
622
- * @example
793
+ * Returns a ref for the Prismic repository with a matching label.
623
794
  *
624
- * ```ts
625
- * const ref = await client.getRefByLabel("My Release")
626
- * ```
795
+ * @param label - Label of the ref.
627
796
  *
628
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbylabel}
797
+ * @returns The ref with a matching label, if it exists.
629
798
  */
630
799
  async getRefByLabel(label, params) {
631
800
  return require_findRefByLabel.findRefByLabel(await this.getRefs(params), label);
632
801
  }
633
802
  /**
634
- * Fetches the repository's master ref.
635
- *
636
- * @example
637
- *
638
- * ```ts
639
- * const masterRef = await client.getMasterRef()
640
- * ```
803
+ * Returns the master ref for the Prismic repository. The master ref points to
804
+ * the repository's latest published content.
641
805
  *
642
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getmasterref}
806
+ * @returns The repository's master ref.
643
807
  */
644
808
  async getMasterRef(params) {
645
809
  return require_findMasterRef.findMasterRef(await this.getRefs(params));
646
810
  }
647
811
  /**
648
- * Fetches the repository's active releases.
649
- *
650
- * @example
812
+ * Returns a list of all Releases for the Prismic repository. Releases are
813
+ * used to group content changes before publishing.
651
814
  *
652
- * ```ts
653
- * const releases = await client.getReleases()
654
- * ```
655
- *
656
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleases}
815
+ * @returns A list of all Releases for the Prismic repository.
657
816
  */
658
817
  async getReleases(params) {
659
818
  return (await this.getRefs(params)).filter((ref) => !ref.isMasterRef);
660
819
  }
661
820
  /**
662
- * Fetches a release with a specific ID.
663
- *
664
- * @example
821
+ * Returns a Release for the Prismic repository with a matching ID.
665
822
  *
666
- * ```ts
667
- * const release = await client.getReleaseByID("YhE3YhEAACIA4321")
668
- * ```
823
+ * @param id - ID of the Release.
669
824
  *
670
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebyid}
825
+ * @returns The Release with a matching ID, if it exists.
671
826
  */
672
827
  async getReleaseByID(id, params) {
673
828
  return require_findRefByID.findRefByID(await this.getReleases(params), id);
674
829
  }
675
830
  /**
676
- * Fetches a release by its label. A release ref's label is its name shown in
677
- * the Page Builder.
678
- *
679
- * @example
831
+ * Returns a Release for the Prismic repository with a matching label.
680
832
  *
681
- * ```ts
682
- * const release = await client.getReleaseByLabel("My Release")
683
- * ```
833
+ * @param label - Label of the ref.
684
834
  *
685
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebylabel}
835
+ * @returns The ref with a matching label, if it exists.
686
836
  */
687
837
  async getReleaseByLabel(label, params) {
688
838
  return require_findRefByLabel.findRefByLabel(await this.getReleases(params), label);
689
839
  }
690
840
  /**
691
- * Fetches the repository's page tags.
692
- *
693
- * @example
694
- *
695
- * ```ts
696
- * const tags = await client.getTags()
697
- * ```
841
+ * Returns a list of all tags used in the Prismic repository.
698
842
  *
699
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#gettags}
843
+ * @returns A list of all tags used in the repository.
700
844
  */
701
845
  async getTags(params) {
702
846
  const repository = await this.getRepository(params);
@@ -710,17 +854,11 @@ var Client = class {
710
854
  return repository.tags;
711
855
  }
712
856
  /**
713
- * Builds a Content API query URL with a set of parameters.
857
+ * Builds a URL used to query content from the Prismic repository.
714
858
  *
715
- * @example
716
- *
717
- * ```ts
718
- * const url = await client.buildQueryURL({
719
- * filters: [filter.at("document.type", "blog_post")],
720
- * })
721
- * ```
859
+ * @param params - Parameters to filter, sort, and paginate the results.
722
860
  *
723
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}
861
+ * @returns A URL string that can be requested to query content.
724
862
  */
725
863
  async buildQueryURL({ signal, fetchOptions,...params } = {}) {
726
864
  const ref = params.ref || await this.getResolvedRefString({
@@ -744,18 +882,23 @@ var Client = class {
744
882
  });
745
883
  }
746
884
  /**
747
- * 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.
748
888
  *
749
889
  * @example
750
890
  *
751
891
  * ```ts
752
- * const url = await client.resolvePreviewURL({
753
- * linkResolver,
754
- * defaultURL: "/",
755
- * })
892
+ * const url = client.resolvePreviewURL({
893
+ * linkResolver: (document) => `/${document.uid}`
894
+ * defaultURL: '/'
895
+ * })
756
896
  * ```
757
897
  *
758
- * @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.
759
902
  */
760
903
  async resolvePreviewURL(args) {
761
904
  let documentID = args.documentID;
@@ -787,30 +930,37 @@ var Client = class {
787
930
  return args.defaultURL;
788
931
  }
789
932
  /**
790
- * Configures the client to query the latest published content. This is the
791
- * 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.
792
938
  *
793
939
  * @example
794
940
  *
795
941
  * ```ts
796
- * client.queryLatestContent()
942
+ * await client.queryLatestContent()
943
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
797
944
  * ```
798
- *
799
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}
800
945
  */
801
946
  queryLatestContent() {
802
947
  this.refState.mode = RefStateMode.Master;
803
948
  }
804
949
  /**
805
- * 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.
806
955
  *
807
956
  * @example
808
957
  *
809
958
  * ```ts
810
- * client.queryContentFromReleaseByID("YhE3YhEAACIA4321")
959
+ * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa")
960
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
811
961
  * ```
812
962
  *
813
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
963
+ * @param releaseID - The ID of the Release.
814
964
  */
815
965
  queryContentFromReleaseByID(releaseID) {
816
966
  this.refState = {
@@ -820,16 +970,20 @@ var Client = class {
820
970
  };
821
971
  }
822
972
  /**
823
- * Configures the client to query content from a release with a specific
824
- * 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.
825
978
  *
826
979
  * @example
827
980
  *
828
981
  * ```ts
829
- * client.queryContentFromReleaseByLabel("My Release")
982
+ * await client.queryContentFromReleaseByLabel("My Release")
983
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
830
984
  * ```
831
985
  *
832
- * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
986
+ * @param releaseLabel - The label of the Release.
833
987
  */
834
988
  queryContentFromReleaseByLabel(releaseLabel) {
835
989
  this.refState = {
@@ -839,15 +993,21 @@ var Client = class {
839
993
  };
840
994
  }
841
995
  /**
842
- * 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.
843
1001
  *
844
1002
  * @example
845
1003
  *
846
1004
  * ```ts
847
- * client.queryContentFromRef("my-ref")
1005
+ * await client.queryContentFromRef("my-ref")
1006
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
848
1007
  * ```
849
1008
  *
850
- * @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.
851
1011
  */
852
1012
  queryContentFromRef(ref) {
853
1013
  this.refState = {
@@ -857,18 +1017,17 @@ var Client = class {
857
1017
  };
858
1018
  }
859
1019
  /**
860
- * A preconfigured `fetch()` function for Prismic's GraphQL API that can be
861
- * 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.
862
1024
  *
863
1025
  * @example
864
1026
  *
865
1027
  * ```ts
866
- * import { createClient, getGraphQLEndpoint } from "@prismicio/client"
867
- *
868
- * const client = createClient("example-prismic-repo")
869
1028
  * const graphQLClient = new ApolloClient({
870
1029
  * link: new HttpLink({
871
- * uri: getGraphQLEndpoint(client.repositoryName),
1030
+ * uri: prismic.getGraphQLEndpoint(repositoryName),
872
1031
  * // Provide `client.graphQLFetch` as the fetch implementation.
873
1032
  * fetch: client.graphQLFetch,
874
1033
  * // Using GET is required.
@@ -878,7 +1037,13 @@ var Client = class {
878
1037
  * })
879
1038
  * ```
880
1039
  *
881
- * @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
882
1047
  */
883
1048
  async graphQLFetch(input, init) {
884
1049
  const repository = await this.getRepository();