@prismicio/client 6.1.1 → 6.4.0
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/README.md +3 -4
- package/dist/index.cjs +126 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +126 -45
- package/dist/index.js +123 -66
- package/dist/index.js.map +1 -1
- package/package.json +16 -17
- package/src/buildQueryURL.ts +1 -3
- package/src/client.ts +170 -93
- package/src/getGraphQLEndpoint.ts +14 -2
- package/src/getRepositoryEndpoint.ts +25 -0
- package/src/getRepositoryName.ts +23 -0
- package/src/index.ts +13 -3
- package/src/isRepositoryEndpoint.ts +17 -0
- package/src/isRepositoryName.ts +10 -0
- package/src/lib/minifyGraphQLQuery.ts +13 -0
- package/src/types.ts +42 -0
- package/src/getEndpoint.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,27 @@ import * as prismicT from '@prismicio/types';
|
|
|
2
2
|
import * as prismicH from '@prismicio/helpers';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Get a repository's Prismic
|
|
5
|
+
* Get a repository's Prismic Rest API V2 endpoint.
|
|
6
6
|
*
|
|
7
7
|
* @typeParam RepositoryName - Name of the Prismic repository.
|
|
8
8
|
* @param repositoryName - Name of the repository.
|
|
9
9
|
*
|
|
10
|
-
* @returns The repository's Prismic
|
|
10
|
+
* @returns The repository's Prismic Rest API V2 endpoint
|
|
11
|
+
* @throws {@link Error} Thrown if an invalid repository name is provided.
|
|
11
12
|
*/
|
|
12
|
-
declare const
|
|
13
|
+
declare const getRepositoryEndpoint: <RepositoryName extends string>(repositoryName: RepositoryName) => `https://${RepositoryName}.cdn.prismic.io/api/v2`;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get a Prismic repository's name from its standard Prismic Rest API V2 or
|
|
17
|
+
* GraphQL endpoint.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
|
|
20
|
+
* @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
|
|
21
|
+
*
|
|
22
|
+
* @returns The Prismic repository's name.
|
|
23
|
+
* @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is provided.
|
|
24
|
+
*/
|
|
25
|
+
declare const getRepositoryName: (repositoryEndpoint: string) => string;
|
|
13
26
|
|
|
14
27
|
/**
|
|
15
28
|
* Get a repository's Prismic GraphQL endpoint.
|
|
@@ -21,15 +34,50 @@ declare const getEndpoint: <RepositoryName extends string>(repositoryName: Repos
|
|
|
21
34
|
*/
|
|
22
35
|
declare const getGraphQLEndpoint: <RepositoryName extends string>(repositoryName: RepositoryName) => `https://${RepositoryName}.cdn.prismic.io/graphql`;
|
|
23
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Determines if an input is a valid Prismic repository name.
|
|
39
|
+
*
|
|
40
|
+
* @param input - Input to test.
|
|
41
|
+
*
|
|
42
|
+
* @returns `true` if `input` is a valid Prismic repository name, `false` otherwise.
|
|
43
|
+
*/
|
|
44
|
+
declare const isRepositoryName: (input: string) => boolean;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid
|
|
48
|
+
* URL is a valid endpoint to support network proxies.
|
|
49
|
+
*
|
|
50
|
+
* @param input - Input to test.
|
|
51
|
+
*
|
|
52
|
+
* @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false` otherwise.
|
|
53
|
+
*/
|
|
54
|
+
declare const isRepositoryEndpoint: (input: string) => boolean;
|
|
55
|
+
|
|
24
56
|
/**
|
|
25
57
|
* A universal API to make network requests. A subset of the `fetch()` API.
|
|
58
|
+
*
|
|
59
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
|
|
26
60
|
*/
|
|
27
61
|
declare type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
|
|
62
|
+
/**
|
|
63
|
+
* An object that allows you to abort a `fetch()` request if needed via an
|
|
64
|
+
* `AbortController` object
|
|
65
|
+
*
|
|
66
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
67
|
+
*/
|
|
68
|
+
declare type AbortSignalLike = {
|
|
69
|
+
aborted: any;
|
|
70
|
+
addEventListener: any;
|
|
71
|
+
removeEventListener: any;
|
|
72
|
+
dispatchEvent: any;
|
|
73
|
+
onabort: any;
|
|
74
|
+
};
|
|
28
75
|
/**
|
|
29
76
|
* The minimum required properties from RequestInit.
|
|
30
77
|
*/
|
|
31
78
|
interface RequestInitLike {
|
|
32
79
|
headers?: Record<string, string>;
|
|
80
|
+
signal?: AbortSignalLike | null;
|
|
33
81
|
}
|
|
34
82
|
/**
|
|
35
83
|
* The minimum required properties from Response.
|
|
@@ -234,6 +282,19 @@ declare type ClientConfig = {
|
|
|
234
282
|
*/
|
|
235
283
|
fetch?: FetchLike;
|
|
236
284
|
};
|
|
285
|
+
/**
|
|
286
|
+
* Parameters for any client method that use `fetch()`. Only a subset of
|
|
287
|
+
* `fetch()` parameters are exposed.
|
|
288
|
+
*/
|
|
289
|
+
declare type FetchParams = {
|
|
290
|
+
/**
|
|
291
|
+
* An `AbortSignal` provided by an `AbortController`. This allows the network
|
|
292
|
+
* request to be cancelled if necessary.
|
|
293
|
+
*
|
|
294
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
295
|
+
*/
|
|
296
|
+
signal?: AbortSignalLike;
|
|
297
|
+
};
|
|
237
298
|
/**
|
|
238
299
|
* Parameters specific to client methods that fetch all documents. These methods
|
|
239
300
|
* start with `getAll` (for example, `getAllByType`).
|
|
@@ -248,11 +309,11 @@ declare type GetAllParams = {
|
|
|
248
309
|
/**
|
|
249
310
|
* Arguments to determine how the URL for a preview session is resolved.
|
|
250
311
|
*/
|
|
251
|
-
declare type ResolvePreviewArgs = {
|
|
312
|
+
declare type ResolvePreviewArgs<LinkResolverReturnType> = {
|
|
252
313
|
/**
|
|
253
314
|
* A function that maps a Prismic document to a URL within your app.
|
|
254
315
|
*/
|
|
255
|
-
linkResolver?: prismicH.LinkResolverFunction
|
|
316
|
+
linkResolver?: prismicH.LinkResolverFunction<LinkResolverReturnType>;
|
|
256
317
|
/**
|
|
257
318
|
* A fallback URL if the Link Resolver does not return a value.
|
|
258
319
|
*/
|
|
@@ -270,14 +331,24 @@ declare type ResolvePreviewArgs = {
|
|
|
270
331
|
/**
|
|
271
332
|
* Creates a Prismic client that can be used to query a repository.
|
|
272
333
|
*
|
|
273
|
-
* @
|
|
274
|
-
*
|
|
334
|
+
* @example
|
|
335
|
+
*
|
|
336
|
+
* ```ts
|
|
337
|
+
* // With a repository name.
|
|
338
|
+
* createClient("qwerty");
|
|
339
|
+
*
|
|
340
|
+
* // Or with a full Prismic Rest API V2 endpoint.
|
|
341
|
+
* createClient("https://qwerty.cdn.prismic.io/api/v2");
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
|
|
345
|
+
* API V2 endpoint for the repository.
|
|
275
346
|
* @param options - Configuration that determines how content will be queried
|
|
276
347
|
* from the Prismic repository.
|
|
277
348
|
*
|
|
278
349
|
* @returns A client that can query content from the repository.
|
|
279
350
|
*/
|
|
280
|
-
declare const createClient: (
|
|
351
|
+
declare const createClient: (repositoryNameOrEndpoint: string, options?: ClientConfig | undefined) => Client;
|
|
281
352
|
/**
|
|
282
353
|
* A client that allows querying content from a Prismic repository.
|
|
283
354
|
*
|
|
@@ -288,7 +359,7 @@ declare const createClient: (endpoint: string, options?: ClientConfig | undefine
|
|
|
288
359
|
declare class Client {
|
|
289
360
|
/**
|
|
290
361
|
* The Prismic REST API V2 endpoint for the repository (use
|
|
291
|
-
* `prismic.
|
|
362
|
+
* `prismic.getRepositoryEndpoint` for the default endpoint).
|
|
292
363
|
*/
|
|
293
364
|
endpoint: string;
|
|
294
365
|
/**
|
|
@@ -335,14 +406,14 @@ declare class Client {
|
|
|
335
406
|
* such as Node.js, the `fetch` option must be provided as part of the
|
|
336
407
|
* `options` parameter.
|
|
337
408
|
*
|
|
338
|
-
* @param
|
|
339
|
-
*
|
|
409
|
+
* @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
|
|
410
|
+
* API V2 endpoint for the repository.
|
|
340
411
|
* @param options - Configuration that determines how content will be queried
|
|
341
412
|
* from the Prismic repository.
|
|
342
413
|
*
|
|
343
414
|
* @returns A client that can query content from the repository.
|
|
344
415
|
*/
|
|
345
|
-
constructor(
|
|
416
|
+
constructor(repositoryNameOrEndpoint: string, options?: ClientConfig);
|
|
346
417
|
/**
|
|
347
418
|
* Enables the client to automatically query content from a preview session if
|
|
348
419
|
* one is active in browser environments. This is enabled by default in the browser.
|
|
@@ -407,7 +478,7 @@ declare class Client {
|
|
|
407
478
|
*
|
|
408
479
|
* @returns A paginated response containing the result of the query.
|
|
409
480
|
*/
|
|
410
|
-
query<TDocument extends prismicT.PrismicDocument>(predicates: NonNullable<BuildQueryURLArgs["predicates"]>, params?: Partial<Omit<BuildQueryURLArgs, "predicates">>): Promise<prismicT.Query<TDocument>>;
|
|
481
|
+
query<TDocument extends prismicT.PrismicDocument>(predicates: NonNullable<BuildQueryURLArgs["predicates"]>, params?: Partial<Omit<BuildQueryURLArgs, "predicates">> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
411
482
|
/**
|
|
412
483
|
* Queries content from the Prismic repository.
|
|
413
484
|
*
|
|
@@ -422,7 +493,7 @@ declare class Client {
|
|
|
422
493
|
*
|
|
423
494
|
* @returns A paginated response containing the result of the query.
|
|
424
495
|
*/
|
|
425
|
-
get<TDocument extends prismicT.PrismicDocument>(params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
|
|
496
|
+
get<TDocument extends prismicT.PrismicDocument>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
426
497
|
/**
|
|
427
498
|
* Queries content from the Prismic repository and returns only the first
|
|
428
499
|
* result, if any.
|
|
@@ -437,7 +508,7 @@ declare class Client {
|
|
|
437
508
|
* @param params - Parameters to filter, sort, and paginate results. @returns
|
|
438
509
|
* The first result of the query, if any.
|
|
439
510
|
*/
|
|
440
|
-
getFirst<TDocument extends prismicT.PrismicDocument>(params?: Partial<BuildQueryURLArgs>): Promise<TDocument>;
|
|
511
|
+
getFirst<TDocument extends prismicT.PrismicDocument>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
|
|
441
512
|
/**
|
|
442
513
|
* **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
|
|
443
514
|
* require more resources than other methods. Prefer using other methods that
|
|
@@ -459,7 +530,7 @@ declare class Client {
|
|
|
459
530
|
*
|
|
460
531
|
* @returns A list of documents matching the query.
|
|
461
532
|
*/
|
|
462
|
-
dangerouslyGetAll<TDocument extends prismicT.PrismicDocument>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams): Promise<TDocument[]>;
|
|
533
|
+
dangerouslyGetAll<TDocument extends prismicT.PrismicDocument>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
|
|
463
534
|
/**
|
|
464
535
|
* Queries a document from the Prismic repository with a specific ID.
|
|
465
536
|
*
|
|
@@ -480,7 +551,7 @@ declare class Client {
|
|
|
480
551
|
* @returns The document with an ID matching the `id` parameter, if a matching
|
|
481
552
|
* document exists.
|
|
482
553
|
*/
|
|
483
|
-
getByID<TDocument extends prismicT.PrismicDocument>(id: string, params?: Partial<BuildQueryURLArgs>): Promise<TDocument>;
|
|
554
|
+
getByID<TDocument extends prismicT.PrismicDocument>(id: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
|
|
484
555
|
/**
|
|
485
556
|
* Queries documents from the Prismic repository with specific IDs.
|
|
486
557
|
*
|
|
@@ -504,7 +575,7 @@ declare class Client {
|
|
|
504
575
|
* @returns A paginated response containing documents with IDs matching the
|
|
505
576
|
* `ids` parameter.
|
|
506
577
|
*/
|
|
507
|
-
getByIDs<TDocument extends prismicT.PrismicDocument>(ids: string[], params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
|
|
578
|
+
getByIDs<TDocument extends prismicT.PrismicDocument>(ids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
508
579
|
/**
|
|
509
580
|
* Queries all documents from the Prismic repository with specific IDs.
|
|
510
581
|
*
|
|
@@ -529,7 +600,7 @@ declare class Client {
|
|
|
529
600
|
*
|
|
530
601
|
* @returns A list of documents with IDs matching the `ids` parameter.
|
|
531
602
|
*/
|
|
532
|
-
getAllByIDs<TDocument extends prismicT.PrismicDocument>(ids: string[], params?: Partial<BuildQueryURLArgs>): Promise<TDocument[]>;
|
|
603
|
+
getAllByIDs<TDocument extends prismicT.PrismicDocument>(ids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument[]>;
|
|
533
604
|
/**
|
|
534
605
|
* Queries a document from the Prismic repository with a specific UID and Custom Type.
|
|
535
606
|
*
|
|
@@ -551,7 +622,7 @@ declare class Client {
|
|
|
551
622
|
* @returns The document with a UID matching the `uid` parameter, if a
|
|
552
623
|
* matching document exists.
|
|
553
624
|
*/
|
|
554
|
-
getByUID<TDocument extends prismicT.PrismicDocument>(documentType: string, uid: string, params?: Partial<BuildQueryURLArgs>): Promise<TDocument>;
|
|
625
|
+
getByUID<TDocument extends prismicT.PrismicDocument>(documentType: string, uid: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
|
|
555
626
|
/**
|
|
556
627
|
* Queries document from the Prismic repository with specific UIDs and Custom Type.
|
|
557
628
|
*
|
|
@@ -576,7 +647,7 @@ declare class Client {
|
|
|
576
647
|
* @returns A paginated response containing documents with UIDs matching the
|
|
577
648
|
* `uids` parameter.
|
|
578
649
|
*/
|
|
579
|
-
getByUIDs<TDocument extends prismicT.PrismicDocument>(documentType: string, uids: string[], params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
|
|
650
|
+
getByUIDs<TDocument extends prismicT.PrismicDocument>(documentType: string, uids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
580
651
|
/**
|
|
581
652
|
* Queries all documents from the Prismic repository with specific UIDs and Custom Type.
|
|
582
653
|
*
|
|
@@ -602,7 +673,7 @@ declare class Client {
|
|
|
602
673
|
*
|
|
603
674
|
* @returns A list of documents with UIDs matching the `uids` parameter.
|
|
604
675
|
*/
|
|
605
|
-
getAllByUIDs<TDocument extends prismicT.PrismicDocument>(documentType: string, uids: string[], params?: Partial<BuildQueryURLArgs>): Promise<TDocument[]>;
|
|
676
|
+
getAllByUIDs<TDocument extends prismicT.PrismicDocument>(documentType: string, uids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument[]>;
|
|
606
677
|
/**
|
|
607
678
|
* Queries a singleton document from the Prismic repository for a specific Custom Type.
|
|
608
679
|
*
|
|
@@ -623,7 +694,7 @@ declare class Client {
|
|
|
623
694
|
*
|
|
624
695
|
* @returns The singleton document for the Custom Type, if a matching document exists.
|
|
625
696
|
*/
|
|
626
|
-
getSingle<TDocument extends prismicT.PrismicDocument>(documentType: string, params?: Partial<BuildQueryURLArgs>): Promise<TDocument>;
|
|
697
|
+
getSingle<TDocument extends prismicT.PrismicDocument>(documentType: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
|
|
627
698
|
/**
|
|
628
699
|
* Queries documents from the Prismic repository for a specific Custom Type.
|
|
629
700
|
*
|
|
@@ -642,7 +713,7 @@ declare class Client {
|
|
|
642
713
|
*
|
|
643
714
|
* @returns A paginated response containing documents of the Custom Type.
|
|
644
715
|
*/
|
|
645
|
-
getByType<TDocument extends prismicT.PrismicDocument>(documentType: string, params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
|
|
716
|
+
getByType<TDocument extends prismicT.PrismicDocument>(documentType: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
646
717
|
/**
|
|
647
718
|
* Queries all documents from the Prismic repository for a specific Custom Type.
|
|
648
719
|
*
|
|
@@ -660,7 +731,7 @@ declare class Client {
|
|
|
660
731
|
*
|
|
661
732
|
* @returns A list of all documents of the Custom Type.
|
|
662
733
|
*/
|
|
663
|
-
getAllByType<TDocument extends prismicT.PrismicDocument>(documentType: string, params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
|
|
734
|
+
getAllByType<TDocument extends prismicT.PrismicDocument>(documentType: string, params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams): Promise<TDocument[]>;
|
|
664
735
|
/**
|
|
665
736
|
* Queries documents from the Prismic repository with a specific tag.
|
|
666
737
|
*
|
|
@@ -678,7 +749,7 @@ declare class Client {
|
|
|
678
749
|
*
|
|
679
750
|
* @returns A paginated response containing documents with the tag.
|
|
680
751
|
*/
|
|
681
|
-
getByTag<TDocument extends prismicT.PrismicDocument>(tag: string, params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
|
|
752
|
+
getByTag<TDocument extends prismicT.PrismicDocument>(tag: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
682
753
|
/**
|
|
683
754
|
* Queries all documents from the Prismic repository with a specific tag.
|
|
684
755
|
*
|
|
@@ -696,7 +767,7 @@ declare class Client {
|
|
|
696
767
|
*
|
|
697
768
|
* @returns A list of all documents with the tag.
|
|
698
769
|
*/
|
|
699
|
-
getAllByTag<TDocument extends prismicT.PrismicDocument>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
|
|
770
|
+
getAllByTag<TDocument extends prismicT.PrismicDocument>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams): Promise<TDocument[]>;
|
|
700
771
|
/**
|
|
701
772
|
* Queries documents from the Prismic repository with specific tags. A
|
|
702
773
|
* document must be tagged with all of the queried tags to be included.
|
|
@@ -713,7 +784,7 @@ declare class Client {
|
|
|
713
784
|
*
|
|
714
785
|
* @returns A paginated response containing documents with the tags.
|
|
715
786
|
*/
|
|
716
|
-
getByEveryTag<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
|
|
787
|
+
getByEveryTag<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
717
788
|
/**
|
|
718
789
|
* Queries documents from the Prismic repository with specific tags. A
|
|
719
790
|
* document must be tagged with all of the queried tags to be included.
|
|
@@ -732,7 +803,7 @@ declare class Client {
|
|
|
732
803
|
*
|
|
733
804
|
* @returns A list of all documents with the tags.
|
|
734
805
|
*/
|
|
735
|
-
getAllByEveryTag<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
|
|
806
|
+
getAllByEveryTag<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams): Promise<TDocument[]>;
|
|
736
807
|
/**
|
|
737
808
|
* Queries documents from the Prismic repository with specific tags. A
|
|
738
809
|
* document must be tagged with at least one of the queried tags to be included.
|
|
@@ -749,7 +820,7 @@ declare class Client {
|
|
|
749
820
|
*
|
|
750
821
|
* @returns A paginated response containing documents with at least one of the tags.
|
|
751
822
|
*/
|
|
752
|
-
getBySomeTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
|
|
823
|
+
getBySomeTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
|
|
753
824
|
/**
|
|
754
825
|
* Queries documents from the Prismic repository with specific tags. A
|
|
755
826
|
* document must be tagged with at least one of the queried tags to be included.
|
|
@@ -768,14 +839,14 @@ declare class Client {
|
|
|
768
839
|
*
|
|
769
840
|
* @returns A list of all documents with at least one of the tags.
|
|
770
841
|
*/
|
|
771
|
-
getAllBySomeTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
|
|
842
|
+
getAllBySomeTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams): Promise<TDocument[]>;
|
|
772
843
|
/**
|
|
773
844
|
* Returns metadata about the Prismic repository, such as its refs, releases,
|
|
774
845
|
* and custom types.
|
|
775
846
|
*
|
|
776
847
|
* @returns Repository metadata.
|
|
777
848
|
*/
|
|
778
|
-
getRepository(): Promise<prismicT.Repository>;
|
|
849
|
+
getRepository(params?: FetchParams): Promise<prismicT.Repository>;
|
|
779
850
|
/**
|
|
780
851
|
* Returns a list of all refs for the Prismic repository.
|
|
781
852
|
*
|
|
@@ -785,7 +856,7 @@ declare class Client {
|
|
|
785
856
|
*
|
|
786
857
|
* @returns A list of all refs for the Prismic repository.
|
|
787
858
|
*/
|
|
788
|
-
getRefs(): Promise<prismicT.Ref[]>;
|
|
859
|
+
getRefs(params?: FetchParams): Promise<prismicT.Ref[]>;
|
|
789
860
|
/**
|
|
790
861
|
* Returns a ref for the Prismic repository with a matching ID.
|
|
791
862
|
*
|
|
@@ -793,7 +864,7 @@ declare class Client {
|
|
|
793
864
|
*
|
|
794
865
|
* @returns The ref with a matching ID, if it exists.
|
|
795
866
|
*/
|
|
796
|
-
getRefByID(id: string): Promise<prismicT.Ref>;
|
|
867
|
+
getRefByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
|
|
797
868
|
/**
|
|
798
869
|
* Returns a ref for the Prismic repository with a matching label.
|
|
799
870
|
*
|
|
@@ -801,21 +872,21 @@ declare class Client {
|
|
|
801
872
|
*
|
|
802
873
|
* @returns The ref with a matching label, if it exists.
|
|
803
874
|
*/
|
|
804
|
-
getRefByLabel(label: string): Promise<prismicT.Ref>;
|
|
875
|
+
getRefByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
|
|
805
876
|
/**
|
|
806
877
|
* Returns the master ref for the Prismic repository. The master ref points to
|
|
807
878
|
* the repository's latest published content.
|
|
808
879
|
*
|
|
809
880
|
* @returns The repository's master ref.
|
|
810
881
|
*/
|
|
811
|
-
getMasterRef(): Promise<prismicT.Ref>;
|
|
882
|
+
getMasterRef(params?: FetchParams): Promise<prismicT.Ref>;
|
|
812
883
|
/**
|
|
813
884
|
* Returns a list of all Releases for the Prismic repository. Releases are
|
|
814
885
|
* used to group content changes before publishing.
|
|
815
886
|
*
|
|
816
887
|
* @returns A list of all Releases for the Prismic repository.
|
|
817
888
|
*/
|
|
818
|
-
getReleases(): Promise<prismicT.Ref[]>;
|
|
889
|
+
getReleases(params?: FetchParams): Promise<prismicT.Ref[]>;
|
|
819
890
|
/**
|
|
820
891
|
* Returns a Release for the Prismic repository with a matching ID.
|
|
821
892
|
*
|
|
@@ -823,7 +894,7 @@ declare class Client {
|
|
|
823
894
|
*
|
|
824
895
|
* @returns The Release with a matching ID, if it exists.
|
|
825
896
|
*/
|
|
826
|
-
getReleaseByID(id: string): Promise<prismicT.Ref>;
|
|
897
|
+
getReleaseByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
|
|
827
898
|
/**
|
|
828
899
|
* Returns a Release for the Prismic repository with a matching label.
|
|
829
900
|
*
|
|
@@ -831,13 +902,13 @@ declare class Client {
|
|
|
831
902
|
*
|
|
832
903
|
* @returns The ref with a matching label, if it exists.
|
|
833
904
|
*/
|
|
834
|
-
getReleaseByLabel(label: string): Promise<prismicT.Ref>;
|
|
905
|
+
getReleaseByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
|
|
835
906
|
/**
|
|
836
907
|
* Returns a list of all tags used in the Prismic repository.
|
|
837
908
|
*
|
|
838
909
|
* @returns A list of all tags used in the repository.
|
|
839
910
|
*/
|
|
840
|
-
getTags(): Promise<string[]>;
|
|
911
|
+
getTags(params?: FetchParams): Promise<string[]>;
|
|
841
912
|
/**
|
|
842
913
|
* Builds a URL used to query content from the Prismic repository.
|
|
843
914
|
*
|
|
@@ -845,7 +916,7 @@ declare class Client {
|
|
|
845
916
|
*
|
|
846
917
|
* @returns A URL string that can be requested to query content.
|
|
847
918
|
*/
|
|
848
|
-
buildQueryURL(params?: Partial<BuildQueryURLArgs>): Promise<string>;
|
|
919
|
+
buildQueryURL({ signal, ...params }?: Partial<BuildQueryURLArgs> & FetchParams): Promise<string>;
|
|
849
920
|
/**
|
|
850
921
|
* Determines the URL for a previewed document during an active preview
|
|
851
922
|
* session. The result of this method should be used to redirect the user to
|
|
@@ -865,7 +936,7 @@ declare class Client {
|
|
|
865
936
|
* @returns The URL for the previewed document during an active preview
|
|
866
937
|
* session. The user should be redirected to this URL.
|
|
867
938
|
*/
|
|
868
|
-
resolvePreviewURL(args: ResolvePreviewArgs): Promise<string>;
|
|
939
|
+
resolvePreviewURL<LinkResolverReturnType>(args: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams): Promise<string>;
|
|
869
940
|
/**
|
|
870
941
|
* Configures the client to query the latest published content for all future queries.
|
|
871
942
|
*
|
|
@@ -928,10 +999,15 @@ declare class Client {
|
|
|
928
999
|
* @param ref - The ref or a function that returns the ref from which to query content.
|
|
929
1000
|
*/
|
|
930
1001
|
queryContentFromRef(ref: RefStringOrThunk): void;
|
|
1002
|
+
/**
|
|
1003
|
+
* @deprecated Renamed to `graphQLFetch()` (note the capitalization of "QL").
|
|
1004
|
+
*/
|
|
1005
|
+
graphqlFetch: (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
931
1006
|
/**
|
|
932
1007
|
* A `fetch()` function to be used with GraphQL clients configured for
|
|
933
1008
|
* Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
|
|
934
|
-
* and Authorization headers.
|
|
1009
|
+
* and Authorization headers. Queries will automatically be minified by
|
|
1010
|
+
* removing whitespace where possible.
|
|
935
1011
|
*
|
|
936
1012
|
* @example
|
|
937
1013
|
*
|
|
@@ -954,7 +1030,7 @@ declare class Client {
|
|
|
954
1030
|
* @returns The `fetch()` Response for the request.
|
|
955
1031
|
* @experimental
|
|
956
1032
|
*/
|
|
957
|
-
|
|
1033
|
+
graphQLFetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
958
1034
|
/**
|
|
959
1035
|
* Returns a cached version of `getRepository` with a TTL.
|
|
960
1036
|
*
|
|
@@ -1259,6 +1335,11 @@ declare namespace cookie {
|
|
|
1259
1335
|
};
|
|
1260
1336
|
}
|
|
1261
1337
|
|
|
1338
|
+
/**
|
|
1339
|
+
* @deprecated Renamed to `getRepositoryEndpoint`.
|
|
1340
|
+
*/
|
|
1341
|
+
declare const getEndpoint: <RepositoryName extends string>(repositoryName: RepositoryName) => `https://${RepositoryName}.cdn.prismic.io/api/v2`;
|
|
1342
|
+
|
|
1262
1343
|
/**
|
|
1263
1344
|
* @deprecated Renamed to `predicate` (without an "s").
|
|
1264
1345
|
*/
|
|
@@ -1326,4 +1407,4 @@ declare const Predicates: {
|
|
|
1326
1407
|
dateHourBefore: (path: string, hour: number) => string;
|
|
1327
1408
|
};
|
|
1328
1409
|
|
|
1329
|
-
export { BuildQueryURLArgs, Client, ClientConfig, FetchLike, ForbiddenError, HttpRequestLike, NotFoundError, Ordering, ParsingError, Predicates, PrismicError, QueryParams, RequestInitLike, ResponseLike, Route, buildQueryURL, cookie, createClient, getEndpoint, getGraphQLEndpoint, predicate, predicates };
|
|
1410
|
+
export { BuildQueryURLArgs, Client, ClientConfig, FetchLike, ForbiddenError, HttpRequestLike, NotFoundError, Ordering, ParsingError, Predicates, PrismicError, QueryParams, RequestInitLike, ResponseLike, Route, buildQueryURL, cookie, createClient, getEndpoint, getGraphQLEndpoint, getRepositoryEndpoint, getRepositoryName, isRepositoryEndpoint, isRepositoryName, predicate, predicates };
|