@prismicio/client 7.21.0-pr.416.a60d634 → 7.21.0-pr.418.2f07951

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