@prismicio/client 7.21.0-canary.7f2eeca → 7.21.0-canary.bd2c015
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 +34 -80
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +8 -38
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +8 -38
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +34 -80
- package/dist/Client.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 +49 -144
- package/dist/lib/castThunk.cjs +0 -19
- package/dist/lib/castThunk.cjs.map +0 -1
- package/dist/lib/castThunk.js +0 -18
- package/dist/lib/castThunk.js.map +0 -1
package/dist/Client.d.cts
CHANGED
|
@@ -46,11 +46,10 @@ type HttpRequestLike =
|
|
|
46
46
|
query?: Record<string, unknown>;
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
|
-
* A
|
|
50
|
-
*
|
|
51
|
-
* function can optionally be asynchronous.
|
|
49
|
+
* A function that returns a ref string. Used to configure which ref the client
|
|
50
|
+
* queries content from.
|
|
52
51
|
*/
|
|
53
|
-
type
|
|
52
|
+
type GetRef = (params?: Pick<BuildQueryURLArgs, "accessToken"> & FetchParams) => string | undefined | Promise<string | undefined>;
|
|
54
53
|
/**
|
|
55
54
|
* Parameters for any client method that use `fetch()`.
|
|
56
55
|
*/
|
|
@@ -92,7 +91,7 @@ type ClientConfig = {
|
|
|
92
91
|
* may point to the latest version (called the "master ref"), or a preview
|
|
93
92
|
* with draft content.
|
|
94
93
|
*/
|
|
95
|
-
ref?:
|
|
94
|
+
ref?: string | GetRef;
|
|
96
95
|
/**
|
|
97
96
|
* A list of route resolver objects that define how a document's `url`
|
|
98
97
|
* property is resolved.
|
|
@@ -234,11 +233,6 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
234
233
|
* be overridden on each query if needed.
|
|
235
234
|
*/
|
|
236
235
|
defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes">;
|
|
237
|
-
/**
|
|
238
|
-
* The client's ref mode state. This determines which ref is used during
|
|
239
|
-
* queries.
|
|
240
|
-
*/
|
|
241
|
-
private refState;
|
|
242
236
|
/**
|
|
243
237
|
* Creates a Prismic client that can be used to query a repository.
|
|
244
238
|
*
|
|
@@ -278,7 +272,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
278
272
|
*
|
|
279
273
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}
|
|
280
274
|
*/
|
|
281
|
-
enableAutoPreviewsFromReq
|
|
275
|
+
enableAutoPreviewsFromReq(request: HttpRequestLike): void;
|
|
282
276
|
/**
|
|
283
277
|
* Disables the client from automatically querying content from a preview
|
|
284
278
|
* session.
|
|
@@ -696,7 +690,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
696
690
|
*
|
|
697
691
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
|
|
698
692
|
*/
|
|
699
|
-
queryContentFromReleaseByID(
|
|
693
|
+
queryContentFromReleaseByID(id: string): void;
|
|
700
694
|
/**
|
|
701
695
|
* Configures the client to query content from a release with a specific
|
|
702
696
|
* label.
|
|
@@ -709,7 +703,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
709
703
|
*
|
|
710
704
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
|
|
711
705
|
*/
|
|
712
|
-
queryContentFromReleaseByLabel(
|
|
706
|
+
queryContentFromReleaseByLabel(label: string): void;
|
|
713
707
|
/**
|
|
714
708
|
* Configures the client to query content from a specific ref.
|
|
715
709
|
*
|
|
@@ -721,7 +715,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
721
715
|
*
|
|
722
716
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}
|
|
723
717
|
*/
|
|
724
|
-
queryContentFromRef(ref:
|
|
718
|
+
queryContentFromRef(ref: string | GetRef): void;
|
|
725
719
|
/**
|
|
726
720
|
* A preconfigured `fetch()` function for Prismic's GraphQL API that can be
|
|
727
721
|
* provided to GraphQL clients.
|
|
@@ -749,30 +743,6 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
749
743
|
graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
|
|
750
744
|
signal?: AbortSignalLike;
|
|
751
745
|
}): Promise<Response>;
|
|
752
|
-
/**
|
|
753
|
-
* Returns the ref needed to query based on the client's current state. This
|
|
754
|
-
* method may make a network request to fetch a ref or resolve the user's ref
|
|
755
|
-
* thunk.
|
|
756
|
-
*
|
|
757
|
-
* If auto previews are enabled, the preview ref takes priority if available.
|
|
758
|
-
*
|
|
759
|
-
* The following strategies are used depending on the client's state:
|
|
760
|
-
*
|
|
761
|
-
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
762
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
763
|
-
* fetched.
|
|
764
|
-
* - If the user called `queryContentFromReleaseByID`: Use the release's ref.
|
|
765
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
766
|
-
* release is fetched.
|
|
767
|
-
* - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
|
|
768
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
769
|
-
* release is fetched.
|
|
770
|
-
* - If the user called `queryContentFromRef`: Use the provided ref. Fall back
|
|
771
|
-
* to the master ref if the ref is not a string.
|
|
772
|
-
*
|
|
773
|
-
* @returns The ref to use during a query.
|
|
774
|
-
*/
|
|
775
|
-
private getResolvedRefString;
|
|
776
746
|
/**
|
|
777
747
|
* The private implementation of `this.get`. It returns the API response and
|
|
778
748
|
* the URL used to make the request. The URL is sometimes used in the public
|
package/dist/Client.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.cts","names":[],"sources":["../src/Client.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.d.cts","names":[],"sources":["../src/Client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AA+HA;AAsBA;;KApEK,mBAgGiB,CAAA,mBA/FF,eA+FE,EAAA,sBA9FC,UA8FD,CAAA,MAAA,CAAA,CAAA,GA5FrB,OA4FqB,CA5Fb,UA4Fa,EAAA;EAAZ,IAAA,EA5FmB,aA4FnB;CAUiB,CAAA,SAAA,KAAA,GArGvB,UAqGuB,GApGvB,OAoGuB,CApGf,UAoGe,EAAA;EAAZ,IAAA,EApGiB,aAoGjB;CAOb,CAAA;;;;;AAuBG,KA5HO,eAAA;AA4HK;AAAA;AA4CjB;;;AAAyD;EAM/C,OAAA,CAAA,EAAA;IAEM,GAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,IAAA;EAoEM,CAAA;EAAZ,GAAA,CAAA,EAAA,MAAA;;;;MA0C8C;EAoHpB,OAAA,CAAA,EAAA;IAiCP,MAAA,CAAA,EAAA,MAAA;EACV,CAAA;EAAR,KAAA,CAAA,EAhaA,MAgaA,CAAA,MAAA,EAAA,OAAA,CAAA;CAA6B;;;;;KAzZnC,MAAA,GA4ac,CAAA,MAAA,CAAA,EA3aT,IA2aS,CA3aJ,iBA2aI,EAAA,aAAA,CAAA,GA3agC,WA2ahC,EAAA,GAAA,MAAA,GAAA,SAAA,GA1aO,OA0aP,CAAA,MAAA,GAAA,SAAA,CAAA;;;;AACf,KAtaQ,WAAA,GAsaR;EA4BuC;;;;;EAGxC,YAAA,CAAA,EA/ba,eA+bb;EACS;;;;;;;;EAgEsB,MAAA,CAAA,EAtfxB,eAsfwB;CAEf;;;;A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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAoH+B;;;;;;;;;;;;;;;;;;;;;;;;;sBA6B1B,oBACA,KAAK;aAAoC;MAC9C,QAAQ;;;;;;;;;;;;;;;;;;uCAmO0B,cAAc"}
|
package/dist/Client.d.ts
CHANGED
|
@@ -46,11 +46,10 @@ type HttpRequestLike =
|
|
|
46
46
|
query?: Record<string, unknown>;
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
|
-
* A
|
|
50
|
-
*
|
|
51
|
-
* function can optionally be asynchronous.
|
|
49
|
+
* A function that returns a ref string. Used to configure which ref the client
|
|
50
|
+
* queries content from.
|
|
52
51
|
*/
|
|
53
|
-
type
|
|
52
|
+
type GetRef = (params?: Pick<BuildQueryURLArgs, "accessToken"> & FetchParams) => string | undefined | Promise<string | undefined>;
|
|
54
53
|
/**
|
|
55
54
|
* Parameters for any client method that use `fetch()`.
|
|
56
55
|
*/
|
|
@@ -92,7 +91,7 @@ type ClientConfig = {
|
|
|
92
91
|
* may point to the latest version (called the "master ref"), or a preview
|
|
93
92
|
* with draft content.
|
|
94
93
|
*/
|
|
95
|
-
ref?:
|
|
94
|
+
ref?: string | GetRef;
|
|
96
95
|
/**
|
|
97
96
|
* A list of route resolver objects that define how a document's `url`
|
|
98
97
|
* property is resolved.
|
|
@@ -234,11 +233,6 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
234
233
|
* be overridden on each query if needed.
|
|
235
234
|
*/
|
|
236
235
|
defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes">;
|
|
237
|
-
/**
|
|
238
|
-
* The client's ref mode state. This determines which ref is used during
|
|
239
|
-
* queries.
|
|
240
|
-
*/
|
|
241
|
-
private refState;
|
|
242
236
|
/**
|
|
243
237
|
* Creates a Prismic client that can be used to query a repository.
|
|
244
238
|
*
|
|
@@ -278,7 +272,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
278
272
|
*
|
|
279
273
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}
|
|
280
274
|
*/
|
|
281
|
-
enableAutoPreviewsFromReq
|
|
275
|
+
enableAutoPreviewsFromReq(request: HttpRequestLike): void;
|
|
282
276
|
/**
|
|
283
277
|
* Disables the client from automatically querying content from a preview
|
|
284
278
|
* session.
|
|
@@ -696,7 +690,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
696
690
|
*
|
|
697
691
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
|
|
698
692
|
*/
|
|
699
|
-
queryContentFromReleaseByID(
|
|
693
|
+
queryContentFromReleaseByID(id: string): void;
|
|
700
694
|
/**
|
|
701
695
|
* Configures the client to query content from a release with a specific
|
|
702
696
|
* label.
|
|
@@ -709,7 +703,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
709
703
|
*
|
|
710
704
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
|
|
711
705
|
*/
|
|
712
|
-
queryContentFromReleaseByLabel(
|
|
706
|
+
queryContentFromReleaseByLabel(label: string): void;
|
|
713
707
|
/**
|
|
714
708
|
* Configures the client to query content from a specific ref.
|
|
715
709
|
*
|
|
@@ -721,7 +715,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
721
715
|
*
|
|
722
716
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}
|
|
723
717
|
*/
|
|
724
|
-
queryContentFromRef(ref:
|
|
718
|
+
queryContentFromRef(ref: string | GetRef): void;
|
|
725
719
|
/**
|
|
726
720
|
* A preconfigured `fetch()` function for Prismic's GraphQL API that can be
|
|
727
721
|
* provided to GraphQL clients.
|
|
@@ -749,30 +743,6 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
749
743
|
graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
|
|
750
744
|
signal?: AbortSignalLike;
|
|
751
745
|
}): Promise<Response>;
|
|
752
|
-
/**
|
|
753
|
-
* Returns the ref needed to query based on the client's current state. This
|
|
754
|
-
* method may make a network request to fetch a ref or resolve the user's ref
|
|
755
|
-
* thunk.
|
|
756
|
-
*
|
|
757
|
-
* If auto previews are enabled, the preview ref takes priority if available.
|
|
758
|
-
*
|
|
759
|
-
* The following strategies are used depending on the client's state:
|
|
760
|
-
*
|
|
761
|
-
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
762
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
763
|
-
* fetched.
|
|
764
|
-
* - If the user called `queryContentFromReleaseByID`: Use the release's ref.
|
|
765
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
766
|
-
* release is fetched.
|
|
767
|
-
* - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
|
|
768
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
769
|
-
* release is fetched.
|
|
770
|
-
* - If the user called `queryContentFromRef`: Use the provided ref. Fall back
|
|
771
|
-
* to the master ref if the ref is not a string.
|
|
772
|
-
*
|
|
773
|
-
* @returns The ref to use during a query.
|
|
774
|
-
*/
|
|
775
|
-
private getResolvedRefString;
|
|
776
746
|
/**
|
|
777
747
|
* The private implementation of `this.get`. It returns the API response and
|
|
778
748
|
* the URL used to make the request. The URL is sometimes used in the public
|
package/dist/Client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","names":[],"sources":["../src/Client.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.d.ts","names":[],"sources":["../src/Client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AA+HA;AAsBA;;KApEK,mBAgGiB,CAAA,mBA/FF,eA+FE,EAAA,sBA9FC,UA8FD,CAAA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eACA,cACC,QAAQ,oBAAoB,WAAW;;;;;;;;;;;;6BAiBT,kCAEvB,QAAQ,qBAAqB,cACpC,QAAQ,MAAM;;;;;;;;;;;;;gCAgBmB,kCAE1B,QAAQ,KAAK,8BACrB,eACA,cACC,QAAQ;;;;;;;;;;;;kCAiB2B,qCAE5B,QAAQ,qBAAqB,cACpC,QAAQ,MAAM;;;;;;;;;;;;;qCAkBwB,qCAE/B,QAAQ,KAAK,8BACrB,eACA,cACC,QAAQ;;;;;;;;;;;;;kCAkB2B,qCAE5B,QAAQ,qBAAqB,cACpC,QAAQ,MAAM;;;;;;;;;;;;;qCAkBwB,qCAE/B,QAAQ,KAAK,8BACrB,eACA,cACC,QAAQ;;;;;;;;;;;;yBAkBD,KAAK,oCAAoC,cAChD,QAAQ;;;;;;;;;;;;mBAmDY,cAAc,QAAQ;;;;;;;;;;;;kCAiBP,cAAc,QAAQ;;;;;;;;;;;;;wCAkBhB,cAAc,QAAQ;;;;;;;;;;;;wBAiBtC,cAAc,QAAQ;;;;;;;;;;;;uBAiBvB,cAAc,QAAQ;;;;;;;;;;;;sCAiBP,cAAc,QAAQ;;;;;;;;;;;;;4CAkBhB,cAAc,QAAQ;;;;;;;;;;;;mBAiB/C,cAAc;;;;;;;;;;;;;;;;;;MAmClC,QAAQ,qBAAqB,cAAmB;;;;;;;;;;;;;;;kDA6C5C,mBAAmB,0BAA0B,cACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAoH+B;;;;;;;;;;;;;;;;;;;;;;;;;sBA6B1B,oBACA,KAAK;aAAoC;MAC9C,QAAQ;;;;;;;;;;;;;;;;;;uCAmO0B,cAAc"}
|
package/dist/Client.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { filter } from "./filter.js";
|
|
2
2
|
import { appendFilters } from "./lib/appendFilters.js";
|
|
3
|
-
import { castThunk } from "./lib/castThunk.js";
|
|
4
3
|
import { devMsg } from "./lib/devMsg.js";
|
|
5
4
|
import { everyTagFilter } from "./lib/everyTagFilter.js";
|
|
6
5
|
import { PrismicError } from "./errors/PrismicError.js";
|
|
@@ -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,14 +135,9 @@ var Client = class {
|
|
|
158
135
|
* be overridden on each query if needed.
|
|
159
136
|
*/
|
|
160
137
|
defaultParams;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*/
|
|
165
|
-
refState = {
|
|
166
|
-
mode: RefStateMode.Master,
|
|
167
|
-
autoPreviewsEnabled: true
|
|
168
|
-
};
|
|
138
|
+
#getRef;
|
|
139
|
+
#autoPreviews = true;
|
|
140
|
+
#autoPreviewsRequest;
|
|
169
141
|
#cachedRepository;
|
|
170
142
|
#cachedRepositoryExpiration = 0;
|
|
171
143
|
/**
|
|
@@ -225,7 +197,7 @@ var Client = class {
|
|
|
225
197
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}
|
|
226
198
|
*/
|
|
227
199
|
enableAutoPreviews() {
|
|
228
|
-
this
|
|
200
|
+
this.#autoPreviews = true;
|
|
229
201
|
}
|
|
230
202
|
/**
|
|
231
203
|
* Enables the client to automatically query content from a preview session
|
|
@@ -239,9 +211,9 @@ var Client = class {
|
|
|
239
211
|
*
|
|
240
212
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}
|
|
241
213
|
*/
|
|
242
|
-
enableAutoPreviewsFromReq(
|
|
243
|
-
this.
|
|
244
|
-
this
|
|
214
|
+
enableAutoPreviewsFromReq(request$1) {
|
|
215
|
+
this.enableAutoPreviews();
|
|
216
|
+
this.#autoPreviewsRequest = request$1;
|
|
245
217
|
}
|
|
246
218
|
/**
|
|
247
219
|
* Disables the client from automatically querying content from a preview
|
|
@@ -256,7 +228,8 @@ var Client = class {
|
|
|
256
228
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}
|
|
257
229
|
*/
|
|
258
230
|
disableAutoPreviews() {
|
|
259
|
-
this
|
|
231
|
+
this.#autoPreviews = false;
|
|
232
|
+
this.#autoPreviewsRequest = void 0;
|
|
260
233
|
}
|
|
261
234
|
/**
|
|
262
235
|
* Fetches pages based on the `params` argument. Results are paginated.
|
|
@@ -723,7 +696,7 @@ var Client = class {
|
|
|
723
696
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}
|
|
724
697
|
*/
|
|
725
698
|
async buildQueryURL({ signal, fetchOptions,...params } = {}) {
|
|
726
|
-
const ref = params.ref || await this
|
|
699
|
+
const ref = params.ref || await this.#getResolvedRef({
|
|
727
700
|
accessToken: params.accessToken,
|
|
728
701
|
signal,
|
|
729
702
|
fetchOptions
|
|
@@ -764,13 +737,13 @@ var Client = class {
|
|
|
764
737
|
const searchParams = new URLSearchParams(globalThis.location.search);
|
|
765
738
|
documentID = documentID || searchParams.get("documentId");
|
|
766
739
|
previewToken = previewToken || searchParams.get("token");
|
|
767
|
-
} else if (this
|
|
768
|
-
if ("query" in this
|
|
769
|
-
var _this$
|
|
770
|
-
documentID = documentID || ((_this$
|
|
771
|
-
previewToken = previewToken || ((_this$
|
|
772
|
-
} else if ("url" in this
|
|
773
|
-
const searchParams = new URL(this.
|
|
740
|
+
} else if (this.#autoPreviewsRequest) {
|
|
741
|
+
if ("query" in this.#autoPreviewsRequest) {
|
|
742
|
+
var _this$autoPreviewsReq, _this$autoPreviewsReq2;
|
|
743
|
+
documentID = documentID || ((_this$autoPreviewsReq = this.#autoPreviewsRequest.query) === null || _this$autoPreviewsReq === void 0 ? void 0 : _this$autoPreviewsReq.documentId);
|
|
744
|
+
previewToken = previewToken || ((_this$autoPreviewsReq2 = this.#autoPreviewsRequest.query) === null || _this$autoPreviewsReq2 === void 0 ? void 0 : _this$autoPreviewsReq2.token);
|
|
745
|
+
} else if ("url" in this.#autoPreviewsRequest && this.#autoPreviewsRequest.url) {
|
|
746
|
+
const searchParams = new URL(this.#autoPreviewsRequest.url, "missing-host://").searchParams;
|
|
774
747
|
documentID = documentID || searchParams.get("documentId");
|
|
775
748
|
previewToken = previewToken || searchParams.get("token");
|
|
776
749
|
}
|
|
@@ -799,7 +772,7 @@ var Client = class {
|
|
|
799
772
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}
|
|
800
773
|
*/
|
|
801
774
|
queryLatestContent() {
|
|
802
|
-
this
|
|
775
|
+
this.#getRef = void 0;
|
|
803
776
|
}
|
|
804
777
|
/**
|
|
805
778
|
* Configures the client to query content from a release with a specific ID.
|
|
@@ -812,11 +785,9 @@ var Client = class {
|
|
|
812
785
|
*
|
|
813
786
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
|
|
814
787
|
*/
|
|
815
|
-
queryContentFromReleaseByID(
|
|
816
|
-
this
|
|
817
|
-
|
|
818
|
-
mode: RefStateMode.ReleaseID,
|
|
819
|
-
releaseID
|
|
788
|
+
queryContentFromReleaseByID(id) {
|
|
789
|
+
this.#getRef = async (params) => {
|
|
790
|
+
return (await this.getReleaseByID(id, params)).ref;
|
|
820
791
|
};
|
|
821
792
|
}
|
|
822
793
|
/**
|
|
@@ -831,11 +802,9 @@ var Client = class {
|
|
|
831
802
|
*
|
|
832
803
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
|
|
833
804
|
*/
|
|
834
|
-
queryContentFromReleaseByLabel(
|
|
835
|
-
this
|
|
836
|
-
|
|
837
|
-
mode: RefStateMode.ReleaseLabel,
|
|
838
|
-
releaseLabel
|
|
805
|
+
queryContentFromReleaseByLabel(label) {
|
|
806
|
+
this.#getRef = async (params) => {
|
|
807
|
+
return (await this.getReleaseByLabel(label, params)).ref;
|
|
839
808
|
};
|
|
840
809
|
}
|
|
841
810
|
/**
|
|
@@ -850,11 +819,7 @@ var Client = class {
|
|
|
850
819
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}
|
|
851
820
|
*/
|
|
852
821
|
queryContentFromRef(ref) {
|
|
853
|
-
this
|
|
854
|
-
...this.refState,
|
|
855
|
-
mode: RefStateMode.Manual,
|
|
856
|
-
ref
|
|
857
|
-
};
|
|
822
|
+
this.#getRef = typeof ref === "string" ? () => ref : ref;
|
|
858
823
|
}
|
|
859
824
|
/**
|
|
860
825
|
* A preconfigured `fetch()` function for Prismic's GraphQL API that can be
|
|
@@ -882,7 +847,7 @@ var Client = class {
|
|
|
882
847
|
*/
|
|
883
848
|
async graphQLFetch(input, init) {
|
|
884
849
|
const repository = await this.getRepository();
|
|
885
|
-
const ref = await this
|
|
850
|
+
const ref = await this.#getResolvedRef();
|
|
886
851
|
const unsanitizedHeaders = {
|
|
887
852
|
"Prismic-ref": ref,
|
|
888
853
|
Authorization: this.accessToken ? `Token ${this.accessToken}` : "",
|
|
@@ -923,27 +888,16 @@ var Client = class {
|
|
|
923
888
|
*
|
|
924
889
|
* @returns The ref to use during a query.
|
|
925
890
|
*/
|
|
926
|
-
async
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
if ((_this$refState$httpRe3 = this.refState.httpRequest) === null || _this$refState$httpRe3 === void 0 ? void 0 : _this$refState$httpRe3.headers) {
|
|
932
|
-
if ("get" in this.refState.httpRequest.headers && typeof this.refState.httpRequest.headers.get === "function") cookieJar = this.refState.httpRequest.headers.get("cookie");
|
|
933
|
-
else if ("cookie" in this.refState.httpRequest.headers) cookieJar = this.refState.httpRequest.headers.cookie;
|
|
934
|
-
} else if ((_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.cookie) cookieJar = globalThis.document.cookie;
|
|
935
|
-
if (cookieJar) previewRef = getPreviewCookie(cookieJar);
|
|
891
|
+
async #getResolvedRef(params) {
|
|
892
|
+
var _this$getRef;
|
|
893
|
+
if (this.#autoPreviews) {
|
|
894
|
+
var _this$autoPreviewsReq3, _globalThis$document;
|
|
895
|
+
const previewRef = 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) ?? "");
|
|
936
896
|
if (previewRef) return previewRef;
|
|
937
897
|
}
|
|
938
|
-
const
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
else if (refModeType === RefStateMode.ReleaseLabel) return findRefByLabel(repository.refs, this.refState.releaseLabel).ref;
|
|
942
|
-
else if (refModeType === RefStateMode.Manual) {
|
|
943
|
-
const res = await castThunk(this.refState.ref)();
|
|
944
|
-
if (typeof res === "string") return res;
|
|
945
|
-
}
|
|
946
|
-
return findMasterRef(repository.refs).ref;
|
|
898
|
+
const ref = await ((_this$getRef = this.#getRef) === null || _this$getRef === void 0 ? void 0 : _this$getRef.call(this, params));
|
|
899
|
+
if (ref) return ref;
|
|
900
|
+
return (await this.getMasterRef(params)).ref;
|
|
947
901
|
}
|
|
948
902
|
/**
|
|
949
903
|
* The private implementation of `this.get`. It returns the API response and
|