@prismicio/client 6.7.3 → 6.9.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/dist/ForbiddenError.d.ts +11 -11
- package/dist/NotFoundError.d.ts +3 -3
- package/dist/ParsingError.d.ts +12 -12
- package/dist/PrismicError.d.ts +5 -5
- package/dist/buildQueryURL.d.ts +130 -130
- package/dist/client.cjs +30 -6
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +943 -929
- package/dist/client.js +30 -6
- package/dist/client.js.map +1 -1
- package/dist/cookie.d.ts +5 -5
- package/dist/getGraphQLEndpoint.d.ts +9 -9
- package/dist/getRepositoryEndpoint.d.ts +10 -10
- package/dist/getRepositoryName.d.ts +13 -13
- package/dist/index.d.ts +88 -88
- package/dist/isRepositoryEndpoint.d.ts +10 -10
- package/dist/isRepositoryName.d.ts +9 -9
- package/dist/lib/appendPredicates.d.ts +18 -18
- package/dist/lib/castArray.d.ts +11 -11
- package/dist/lib/castThunk.d.ts +10 -10
- package/dist/lib/findMasterRef.d.ts +10 -10
- package/dist/lib/findRef.d.ts +13 -13
- package/dist/lib/findRefByID.d.ts +11 -11
- package/dist/lib/findRefByLabel.d.ts +11 -11
- package/dist/lib/getPreviewCookie.d.ts +9 -9
- package/dist/lib/minifyGraphQLQuery.d.ts +8 -8
- package/dist/lib/orElseThrow.d.ts +11 -11
- package/dist/predicate.d.ts +209 -209
- package/dist/types.d.ts +165 -156
- package/package.json +4 -4
- package/src/client.ts +66 -6
- package/src/types.ts +20 -5
package/dist/ForbiddenError.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PrismicError } from "./PrismicError";
|
|
2
|
-
type ForbiddenErrorRepositoryAPIResponse = {
|
|
3
|
-
type: string;
|
|
4
|
-
message: string;
|
|
5
|
-
};
|
|
6
|
-
type ForbiddenErrorQueryAPIResponse = {
|
|
7
|
-
error: string;
|
|
8
|
-
};
|
|
9
|
-
export declare class ForbiddenError extends PrismicError<ForbiddenErrorRepositoryAPIResponse | ForbiddenErrorQueryAPIResponse> {
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
1
|
+
import { PrismicError } from "./PrismicError";
|
|
2
|
+
type ForbiddenErrorRepositoryAPIResponse = {
|
|
3
|
+
type: string;
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
type ForbiddenErrorQueryAPIResponse = {
|
|
7
|
+
error: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class ForbiddenError extends PrismicError<ForbiddenErrorRepositoryAPIResponse | ForbiddenErrorQueryAPIResponse> {
|
|
10
|
+
}
|
|
11
|
+
export {};
|
package/dist/NotFoundError.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PrismicError } from "./PrismicError";
|
|
2
|
-
export declare class NotFoundError extends PrismicError<undefined> {
|
|
3
|
-
}
|
|
1
|
+
import { PrismicError } from "./PrismicError";
|
|
2
|
+
export declare class NotFoundError extends PrismicError<undefined> {
|
|
3
|
+
}
|
package/dist/ParsingError.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { PrismicError } from "./PrismicError";
|
|
2
|
-
type ParsingErrorAPIResponse = {
|
|
3
|
-
type: "parsing-error";
|
|
4
|
-
message: string;
|
|
5
|
-
line: number;
|
|
6
|
-
column: number;
|
|
7
|
-
id: number;
|
|
8
|
-
location: string;
|
|
9
|
-
};
|
|
10
|
-
export declare class ParsingError extends PrismicError<ParsingErrorAPIResponse> {
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
1
|
+
import { PrismicError } from "./PrismicError";
|
|
2
|
+
type ParsingErrorAPIResponse = {
|
|
3
|
+
type: "parsing-error";
|
|
4
|
+
message: string;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
id: number;
|
|
8
|
+
location: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class ParsingError extends PrismicError<ParsingErrorAPIResponse> {
|
|
11
|
+
}
|
|
12
|
+
export {};
|
package/dist/PrismicError.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare class PrismicError<Response> extends Error {
|
|
2
|
-
url?: string;
|
|
3
|
-
response: Response;
|
|
4
|
-
constructor(message: string | undefined, url: string | undefined, response: Response);
|
|
5
|
-
}
|
|
1
|
+
export declare class PrismicError<Response> extends Error {
|
|
2
|
+
url?: string;
|
|
3
|
+
response: Response;
|
|
4
|
+
constructor(message: string | undefined, url: string | undefined, response: Response);
|
|
5
|
+
}
|
package/dist/buildQueryURL.d.ts
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import { Ordering, Route } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Parameters for the Prismic REST API V2.
|
|
4
|
-
*
|
|
5
|
-
* {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
|
|
6
|
-
*/
|
|
7
|
-
export interface QueryParams {
|
|
8
|
-
/**
|
|
9
|
-
* The secure token for accessing the API (only needed if your repository is
|
|
10
|
-
* set to private).
|
|
11
|
-
*
|
|
12
|
-
* {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
|
|
13
|
-
*/
|
|
14
|
-
accessToken?: string;
|
|
15
|
-
/**
|
|
16
|
-
* The `pageSize` parameter defines the maximum number of documents that the
|
|
17
|
-
* API will return for your query.
|
|
18
|
-
*
|
|
19
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#pagesize}
|
|
20
|
-
*/
|
|
21
|
-
pageSize?: number;
|
|
22
|
-
/**
|
|
23
|
-
* The `page` parameter defines the pagination for the result of your query.
|
|
24
|
-
*
|
|
25
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#page}
|
|
26
|
-
*/
|
|
27
|
-
page?: number;
|
|
28
|
-
/**
|
|
29
|
-
* The `after` parameter can be used along with the orderings option. It will
|
|
30
|
-
* remove all the documents except for those after the specified document in
|
|
31
|
-
* the list.
|
|
32
|
-
*
|
|
33
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#after}
|
|
34
|
-
*/
|
|
35
|
-
after?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The `fetch` parameter is used to make queries faster by only retrieving the
|
|
38
|
-
* specified field(s).
|
|
39
|
-
*
|
|
40
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#fetch}
|
|
41
|
-
*/
|
|
42
|
-
fetch?: string | string[];
|
|
43
|
-
/**
|
|
44
|
-
* The `fetchLinks` parameter allows you to retrieve a specific content field
|
|
45
|
-
* from a linked document and add it to the document response object.
|
|
46
|
-
*
|
|
47
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#fetchlinks}
|
|
48
|
-
*/
|
|
49
|
-
fetchLinks?: string | string[];
|
|
50
|
-
/**
|
|
51
|
-
* The `graphQuery` parameter allows you to specify which fields to retrieve
|
|
52
|
-
* and what content to retrieve from Linked Documents / Content
|
|
53
|
-
* Relationships.
|
|
54
|
-
*
|
|
55
|
-
* {@link https://prismic.io/docs/technologies/graphquery-rest-api}
|
|
56
|
-
*/
|
|
57
|
-
graphQuery?: string;
|
|
58
|
-
/**
|
|
59
|
-
* The `lang` option defines the language code for the results of your query.
|
|
60
|
-
*
|
|
61
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#lang}
|
|
62
|
-
*/
|
|
63
|
-
lang?: string;
|
|
64
|
-
/**
|
|
65
|
-
* The `orderings` parameter orders the results by the specified field(s). You
|
|
66
|
-
* can specify as many fields as you want.
|
|
67
|
-
*
|
|
68
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#orderings}
|
|
69
|
-
*/
|
|
70
|
-
orderings?: Ordering | string | (Ordering | string)[];
|
|
71
|
-
/**
|
|
72
|
-
* The `routes` option allows you to define how a document's `url` field is
|
|
73
|
-
* resolved.
|
|
74
|
-
*
|
|
75
|
-
* {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
76
|
-
*/
|
|
77
|
-
routes?: Route | string | (Route | string)[];
|
|
78
|
-
/**
|
|
79
|
-
* The `brokenRoute` option allows you to define the route populated in the
|
|
80
|
-
* `url` property for broken Link or Content Relationship fields. A broken
|
|
81
|
-
* link is a Link or Content Relationship field whose linked document has been
|
|
82
|
-
* unpublished or deleted.
|
|
83
|
-
*
|
|
84
|
-
* {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
85
|
-
*/
|
|
86
|
-
brokenRoute?: string;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Arguments for `buildQueryURL` to construct a Query URL.
|
|
90
|
-
*/
|
|
91
|
-
type BuildQueryURLParams = {
|
|
92
|
-
/**
|
|
93
|
-
* Ref used to query documents.
|
|
94
|
-
*
|
|
95
|
-
* {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
|
|
96
|
-
*/
|
|
97
|
-
ref: string;
|
|
98
|
-
/**
|
|
99
|
-
* Ref used to populate Integration Fields with the latest content.
|
|
100
|
-
*
|
|
101
|
-
* {@link https://prismic.io/docs/core-concepts/integration-fields}
|
|
102
|
-
*/
|
|
103
|
-
integrationFieldsRef?: string;
|
|
104
|
-
/**
|
|
105
|
-
* One or more predicates to filter documents for the query.
|
|
106
|
-
*
|
|
107
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api}
|
|
108
|
-
*/
|
|
109
|
-
predicates?: string | string[];
|
|
110
|
-
};
|
|
111
|
-
export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
112
|
-
/**
|
|
113
|
-
* Build a Prismic REST API V2 URL to request documents from a repository. The
|
|
114
|
-
* paginated response for this URL includes documents matching the parameters.
|
|
115
|
-
*
|
|
116
|
-
* A ref is required to make a request. Request the `endpoint` URL to retrieve a
|
|
117
|
-
* list of available refs.
|
|
118
|
-
*
|
|
119
|
-
* Type the JSON response with `Query`.
|
|
120
|
-
*
|
|
121
|
-
* {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
|
|
122
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api}
|
|
123
|
-
*
|
|
124
|
-
* @param endpoint - URL to the repository's REST API V2.
|
|
125
|
-
* @param args - Arguments to filter and scope the query.
|
|
126
|
-
*
|
|
127
|
-
* @returns URL that can be used to request documents from the repository.
|
|
128
|
-
*/
|
|
129
|
-
export declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
|
|
130
|
-
export {};
|
|
1
|
+
import { Ordering, Route } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for the Prismic REST API V2.
|
|
4
|
+
*
|
|
5
|
+
* {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
|
|
6
|
+
*/
|
|
7
|
+
export interface QueryParams {
|
|
8
|
+
/**
|
|
9
|
+
* The secure token for accessing the API (only needed if your repository is
|
|
10
|
+
* set to private).
|
|
11
|
+
*
|
|
12
|
+
* {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
|
|
13
|
+
*/
|
|
14
|
+
accessToken?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The `pageSize` parameter defines the maximum number of documents that the
|
|
17
|
+
* API will return for your query.
|
|
18
|
+
*
|
|
19
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#pagesize}
|
|
20
|
+
*/
|
|
21
|
+
pageSize?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The `page` parameter defines the pagination for the result of your query.
|
|
24
|
+
*
|
|
25
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#page}
|
|
26
|
+
*/
|
|
27
|
+
page?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The `after` parameter can be used along with the orderings option. It will
|
|
30
|
+
* remove all the documents except for those after the specified document in
|
|
31
|
+
* the list.
|
|
32
|
+
*
|
|
33
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#after}
|
|
34
|
+
*/
|
|
35
|
+
after?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The `fetch` parameter is used to make queries faster by only retrieving the
|
|
38
|
+
* specified field(s).
|
|
39
|
+
*
|
|
40
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#fetch}
|
|
41
|
+
*/
|
|
42
|
+
fetch?: string | string[];
|
|
43
|
+
/**
|
|
44
|
+
* The `fetchLinks` parameter allows you to retrieve a specific content field
|
|
45
|
+
* from a linked document and add it to the document response object.
|
|
46
|
+
*
|
|
47
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#fetchlinks}
|
|
48
|
+
*/
|
|
49
|
+
fetchLinks?: string | string[];
|
|
50
|
+
/**
|
|
51
|
+
* The `graphQuery` parameter allows you to specify which fields to retrieve
|
|
52
|
+
* and what content to retrieve from Linked Documents / Content
|
|
53
|
+
* Relationships.
|
|
54
|
+
*
|
|
55
|
+
* {@link https://prismic.io/docs/technologies/graphquery-rest-api}
|
|
56
|
+
*/
|
|
57
|
+
graphQuery?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The `lang` option defines the language code for the results of your query.
|
|
60
|
+
*
|
|
61
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#lang}
|
|
62
|
+
*/
|
|
63
|
+
lang?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The `orderings` parameter orders the results by the specified field(s). You
|
|
66
|
+
* can specify as many fields as you want.
|
|
67
|
+
*
|
|
68
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#orderings}
|
|
69
|
+
*/
|
|
70
|
+
orderings?: Ordering | string | (Ordering | string)[];
|
|
71
|
+
/**
|
|
72
|
+
* The `routes` option allows you to define how a document's `url` field is
|
|
73
|
+
* resolved.
|
|
74
|
+
*
|
|
75
|
+
* {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
76
|
+
*/
|
|
77
|
+
routes?: Route | string | (Route | string)[];
|
|
78
|
+
/**
|
|
79
|
+
* The `brokenRoute` option allows you to define the route populated in the
|
|
80
|
+
* `url` property for broken Link or Content Relationship fields. A broken
|
|
81
|
+
* link is a Link or Content Relationship field whose linked document has been
|
|
82
|
+
* unpublished or deleted.
|
|
83
|
+
*
|
|
84
|
+
* {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
85
|
+
*/
|
|
86
|
+
brokenRoute?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Arguments for `buildQueryURL` to construct a Query URL.
|
|
90
|
+
*/
|
|
91
|
+
type BuildQueryURLParams = {
|
|
92
|
+
/**
|
|
93
|
+
* Ref used to query documents.
|
|
94
|
+
*
|
|
95
|
+
* {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
|
|
96
|
+
*/
|
|
97
|
+
ref: string;
|
|
98
|
+
/**
|
|
99
|
+
* Ref used to populate Integration Fields with the latest content.
|
|
100
|
+
*
|
|
101
|
+
* {@link https://prismic.io/docs/core-concepts/integration-fields}
|
|
102
|
+
*/
|
|
103
|
+
integrationFieldsRef?: string;
|
|
104
|
+
/**
|
|
105
|
+
* One or more predicates to filter documents for the query.
|
|
106
|
+
*
|
|
107
|
+
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api}
|
|
108
|
+
*/
|
|
109
|
+
predicates?: string | string[];
|
|
110
|
+
};
|
|
111
|
+
export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
112
|
+
/**
|
|
113
|
+
* Build a Prismic REST API V2 URL to request documents from a repository. The
|
|
114
|
+
* paginated response for this URL includes documents matching the parameters.
|
|
115
|
+
*
|
|
116
|
+
* A ref is required to make a request. Request the `endpoint` URL to retrieve a
|
|
117
|
+
* list of available refs.
|
|
118
|
+
*
|
|
119
|
+
* Type the JSON response with `Query`.
|
|
120
|
+
*
|
|
121
|
+
* {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
|
|
122
|
+
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api}
|
|
123
|
+
*
|
|
124
|
+
* @param endpoint - URL to the repository's REST API V2.
|
|
125
|
+
* @param args - Arguments to filter and scope the query.
|
|
126
|
+
*
|
|
127
|
+
* @returns URL that can be used to request documents from the repository.
|
|
128
|
+
*/
|
|
129
|
+
export declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
|
|
130
|
+
export {};
|
package/dist/client.cjs
CHANGED
|
@@ -43,6 +43,7 @@ const prismicH__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismicH);
|
|
|
43
43
|
const MAX_PAGE_SIZE = 100;
|
|
44
44
|
const REPOSITORY_CACHE_TTL = 5e3;
|
|
45
45
|
const GET_ALL_QUERY_DELAY = 500;
|
|
46
|
+
const DEFUALT_RETRY_AFTER_MS = 1e3;
|
|
46
47
|
var RefStateMode;
|
|
47
48
|
(function(RefStateMode2) {
|
|
48
49
|
RefStateMode2["Master"] = "Master";
|
|
@@ -61,6 +62,7 @@ class Client {
|
|
|
61
62
|
__publicField(this, "routes");
|
|
62
63
|
__publicField(this, "brokenRoute");
|
|
63
64
|
__publicField(this, "fetchFn");
|
|
65
|
+
__publicField(this, "fetchOptions");
|
|
64
66
|
__publicField(this, "defaultParams");
|
|
65
67
|
__publicField(this, "refState", {
|
|
66
68
|
mode: RefStateMode.Master,
|
|
@@ -80,6 +82,7 @@ class Client {
|
|
|
80
82
|
this.accessToken = options.accessToken;
|
|
81
83
|
this.routes = options.routes;
|
|
82
84
|
this.brokenRoute = options.brokenRoute;
|
|
85
|
+
this.fetchOptions = options.fetchOptions;
|
|
83
86
|
this.defaultParams = options.defaultParams;
|
|
84
87
|
if (options.ref) {
|
|
85
88
|
this.queryContentFromRef(options.ref);
|
|
@@ -249,9 +252,9 @@ class Client {
|
|
|
249
252
|
return repository.tags;
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
|
-
async buildQueryURL({ signal, ...params } = {}) {
|
|
253
|
-
const ref = params.ref || await this.getResolvedRefString();
|
|
254
|
-
const integrationFieldsRef = params.integrationFieldsRef || (await this.getCachedRepository({ signal })).integrationFieldsRef || void 0;
|
|
255
|
+
async buildQueryURL({ signal, fetchOptions, ...params } = {}) {
|
|
256
|
+
const ref = params.ref || await this.getResolvedRefString({ signal, fetchOptions });
|
|
257
|
+
const integrationFieldsRef = params.integrationFieldsRef || (await this.getCachedRepository({ signal, fetchOptions })).integrationFieldsRef || void 0;
|
|
255
258
|
return buildQueryURL.buildQueryURL(this.endpoint, {
|
|
256
259
|
...this.defaultParams,
|
|
257
260
|
...params,
|
|
@@ -282,9 +285,10 @@ class Client {
|
|
|
282
285
|
}
|
|
283
286
|
if (documentID != null && previewToken != null) {
|
|
284
287
|
const document = await this.getByID(documentID, {
|
|
285
|
-
signal: args.signal,
|
|
286
288
|
ref: previewToken,
|
|
287
|
-
lang: "*"
|
|
289
|
+
lang: "*",
|
|
290
|
+
signal: args.signal,
|
|
291
|
+
fetchOptions: args.fetchOptions
|
|
288
292
|
});
|
|
289
293
|
const url = prismicH__namespace.asLink(document, args.linkResolver);
|
|
290
294
|
if (typeof url === "string") {
|
|
@@ -401,8 +405,15 @@ class Client {
|
|
|
401
405
|
return findMasterRef.findMasterRef(cachedRepository.refs).ref;
|
|
402
406
|
}
|
|
403
407
|
async fetch(url, params = {}) {
|
|
408
|
+
var _a, _b, _c, _d;
|
|
404
409
|
const res = await this.fetchFn(url, {
|
|
405
|
-
|
|
410
|
+
...this.fetchOptions,
|
|
411
|
+
...params.fetchOptions,
|
|
412
|
+
headers: {
|
|
413
|
+
...(_a = this.fetchOptions) == null ? void 0 : _a.headers,
|
|
414
|
+
...(_b = params.fetchOptions) == null ? void 0 : _b.headers
|
|
415
|
+
},
|
|
416
|
+
signal: ((_c = params.fetchOptions) == null ? void 0 : _c.signal) || params.signal || ((_d = this.fetchOptions) == null ? void 0 : _d.signal)
|
|
406
417
|
});
|
|
407
418
|
let json;
|
|
408
419
|
try {
|
|
@@ -425,6 +436,19 @@ class Client {
|
|
|
425
436
|
case 403: {
|
|
426
437
|
throw new ForbiddenError.ForbiddenError("error" in json ? json.error : json.message, url, json);
|
|
427
438
|
}
|
|
439
|
+
case 429: {
|
|
440
|
+
const parsedRetryAfter = Number(res.headers.get("retry-after"));
|
|
441
|
+
const delay = Number.isNaN(parsedRetryAfter) ? DEFUALT_RETRY_AFTER_MS : parsedRetryAfter;
|
|
442
|
+
return await new Promise((resolve, reject) => {
|
|
443
|
+
setTimeout(async () => {
|
|
444
|
+
try {
|
|
445
|
+
resolve(await this.fetch(url, params));
|
|
446
|
+
} catch (error) {
|
|
447
|
+
reject(error);
|
|
448
|
+
}
|
|
449
|
+
}, delay);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
428
452
|
}
|
|
429
453
|
throw new PrismicError.PrismicError(void 0, url, json);
|
|
430
454
|
}
|