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