@cmssy/core 10.2.0 → 10.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/dist/{content-client-D0EdiqbQ.d.cts → content-client-CJQ-nafm.d.cts} +15 -2
- package/dist/{content-client-D0EdiqbQ.d.ts → content-client-CJQ-nafm.d.ts} +15 -2
- package/dist/{csp-DlAEXYjA.d.cts → csp-BityT_ug.d.cts} +1 -1
- package/dist/{csp-Blh6P15m.d.ts → csp-DJ17P3PN.d.ts} +1 -1
- package/dist/index.cjs +17 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +17 -4
- package/dist/internal/locale.cjs +17 -4
- package/dist/internal/locale.d.cts +3 -3
- package/dist/internal/locale.d.ts +3 -3
- package/dist/internal/locale.js +17 -4
- package/dist/internal.cjs +29 -14
- package/dist/internal.d.cts +7 -15
- package/dist/internal.d.ts +7 -15
- package/dist/internal.js +30 -14
- package/dist/{locale-rhYcXU5z.d.cts → locale-C7sA46qu.d.cts} +1 -1
- package/dist/{locale-XintNd0n.d.ts → locale-Ox_qVlNy.d.ts} +1 -1
- package/dist/preflight.d.cts +1 -1
- package/dist/preflight.d.ts +1 -1
- package/package.json +2 -2
|
@@ -3,15 +3,28 @@ import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, Cmss
|
|
|
3
3
|
/** HTTP-level failure from the cmssy API, with a machine-readable status. */
|
|
4
4
|
declare class CmssyRequestError extends Error {
|
|
5
5
|
readonly status: number;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
8
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
9
|
+
* long instead of guessing.
|
|
10
|
+
*/
|
|
11
|
+
readonly retryAfterMs?: number;
|
|
12
|
+
constructor(message: string, status: number, retryAfterMs?: number);
|
|
7
13
|
}
|
|
8
14
|
interface RetryPolicy {
|
|
9
15
|
/** Additional attempts after the first request (default 3). */
|
|
10
16
|
maxRetries?: number;
|
|
11
17
|
/** Exponential backoff base in ms: base * 2^attempt (default 300). */
|
|
12
18
|
baseDelayMs?: number;
|
|
13
|
-
/** Upper bound for
|
|
19
|
+
/** Upper bound for a guessed backoff wait (default 3000). */
|
|
14
20
|
maxDelayMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Upper bound for a wait the server asked for by `Retry-After` (default
|
|
23
|
+
* 10000). Beyond it there is nothing to gain from holding a render open, so
|
|
24
|
+
* the request fails immediately and carries `retryAfterMs` - the caller is in
|
|
25
|
+
* a better position to decide between stale content and an error page.
|
|
26
|
+
*/
|
|
27
|
+
maxRetryAfterMs?: number;
|
|
15
28
|
/** HTTP statuses that trigger a retry (default [429, 503]). */
|
|
16
29
|
retryStatuses?: number[];
|
|
17
30
|
}
|
|
@@ -3,15 +3,28 @@ import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, Cmss
|
|
|
3
3
|
/** HTTP-level failure from the cmssy API, with a machine-readable status. */
|
|
4
4
|
declare class CmssyRequestError extends Error {
|
|
5
5
|
readonly status: number;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
8
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
9
|
+
* long instead of guessing.
|
|
10
|
+
*/
|
|
11
|
+
readonly retryAfterMs?: number;
|
|
12
|
+
constructor(message: string, status: number, retryAfterMs?: number);
|
|
7
13
|
}
|
|
8
14
|
interface RetryPolicy {
|
|
9
15
|
/** Additional attempts after the first request (default 3). */
|
|
10
16
|
maxRetries?: number;
|
|
11
17
|
/** Exponential backoff base in ms: base * 2^attempt (default 300). */
|
|
12
18
|
baseDelayMs?: number;
|
|
13
|
-
/** Upper bound for
|
|
19
|
+
/** Upper bound for a guessed backoff wait (default 3000). */
|
|
14
20
|
maxDelayMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Upper bound for a wait the server asked for by `Retry-After` (default
|
|
23
|
+
* 10000). Beyond it there is nothing to gain from holding a render open, so
|
|
24
|
+
* the request fails immediately and carries `retryAfterMs` - the caller is in
|
|
25
|
+
* a better position to decide between stale content and an error page.
|
|
26
|
+
*/
|
|
27
|
+
maxRetryAfterMs?: number;
|
|
15
28
|
/** HTTP statuses that trigger a retry (default [429, 503]). */
|
|
16
29
|
retryStatuses?: number[];
|
|
17
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
-
import { G as GraphqlRequestOptions } from './locale-
|
|
2
|
+
import { G as GraphqlRequestOptions } from './locale-C7sA46qu.cjs';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
|
|
5
5
|
declare function isDevelopment(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
-
import { G as GraphqlRequestOptions } from './locale-
|
|
2
|
+
import { G as GraphqlRequestOptions } from './locale-Ox_qVlNy.js';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
|
|
5
5
|
declare function isDevelopment(): boolean;
|
package/dist/index.cjs
CHANGED
|
@@ -64,10 +64,17 @@ Set the listed environment variables (e.g. in .env.local) and restart the dev se
|
|
|
64
64
|
// src/data/http.ts
|
|
65
65
|
var CmssyRequestError = class extends Error {
|
|
66
66
|
status;
|
|
67
|
-
|
|
67
|
+
/**
|
|
68
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
69
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
70
|
+
* long instead of guessing.
|
|
71
|
+
*/
|
|
72
|
+
retryAfterMs;
|
|
73
|
+
constructor(message, status, retryAfterMs2) {
|
|
68
74
|
super(message);
|
|
69
75
|
this.name = "CmssyRequestError";
|
|
70
76
|
this.status = status;
|
|
77
|
+
if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
|
|
71
78
|
}
|
|
72
79
|
};
|
|
73
80
|
var DEFAULT_RETRY_STATUSES = [429, 503];
|
|
@@ -104,14 +111,17 @@ async function fetchWithRetry(doFetch, url, init, retry) {
|
|
|
104
111
|
const maxRetries = retry.maxRetries ?? 3;
|
|
105
112
|
const baseDelayMs = retry.baseDelayMs ?? 300;
|
|
106
113
|
const maxDelayMs = retry.maxDelayMs ?? 3e3;
|
|
114
|
+
const maxRetryAfterMs = retry.maxRetryAfterMs ?? 1e4;
|
|
107
115
|
const retryStatuses = retry.retryStatuses ?? DEFAULT_RETRY_STATUSES;
|
|
108
116
|
let response = await doFetch(url, init);
|
|
109
117
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
110
118
|
if (response.ok || !retryStatuses.includes(response.status)) {
|
|
111
119
|
return response;
|
|
112
120
|
}
|
|
121
|
+
const asked = retryAfterMs(response);
|
|
122
|
+
if (asked !== null && asked > maxRetryAfterMs) return response;
|
|
113
123
|
const backoff = baseDelayMs * 2 ** attempt;
|
|
114
|
-
const wait = Math.min(
|
|
124
|
+
const wait = asked !== null ? asked : Math.min(backoff, maxDelayMs);
|
|
115
125
|
await sleep(wait, init.signal);
|
|
116
126
|
response = await doFetch(url, init);
|
|
117
127
|
}
|
|
@@ -145,9 +155,12 @@ async function postGraphql(url, query, variables, options) {
|
|
|
145
155
|
} catch {
|
|
146
156
|
detail = "";
|
|
147
157
|
}
|
|
158
|
+
const asked = retryAfterMs(response);
|
|
159
|
+
const wait = asked !== null ? ` - retry after ${Math.ceil(asked / 1e3)}s` : "";
|
|
148
160
|
throw new CmssyRequestError(
|
|
149
|
-
`cmssy: ${options.label} failed (${response.status})${detail}`,
|
|
150
|
-
response.status
|
|
161
|
+
`cmssy: ${options.label} failed (${response.status})${detail}${wait}`,
|
|
162
|
+
response.status,
|
|
163
|
+
asked ?? void 0
|
|
151
164
|
);
|
|
152
165
|
}
|
|
153
166
|
let json;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-
|
|
2
|
-
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-
|
|
3
|
-
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-BityT_ug.cjs';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-C7sA46qu.cjs';
|
|
3
|
+
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-CJQ-nafm.cjs';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
5
|
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
6
|
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-
|
|
2
|
-
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-
|
|
3
|
-
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-DJ17P3PN.js';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-Ox_qVlNy.js';
|
|
3
|
+
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-CJQ-nafm.js';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
5
|
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
6
|
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
package/dist/index.js
CHANGED
|
@@ -62,10 +62,17 @@ Set the listed environment variables (e.g. in .env.local) and restart the dev se
|
|
|
62
62
|
// src/data/http.ts
|
|
63
63
|
var CmssyRequestError = class extends Error {
|
|
64
64
|
status;
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
67
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
68
|
+
* long instead of guessing.
|
|
69
|
+
*/
|
|
70
|
+
retryAfterMs;
|
|
71
|
+
constructor(message, status, retryAfterMs2) {
|
|
66
72
|
super(message);
|
|
67
73
|
this.name = "CmssyRequestError";
|
|
68
74
|
this.status = status;
|
|
75
|
+
if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
|
|
69
76
|
}
|
|
70
77
|
};
|
|
71
78
|
var DEFAULT_RETRY_STATUSES = [429, 503];
|
|
@@ -102,14 +109,17 @@ async function fetchWithRetry(doFetch, url, init, retry) {
|
|
|
102
109
|
const maxRetries = retry.maxRetries ?? 3;
|
|
103
110
|
const baseDelayMs = retry.baseDelayMs ?? 300;
|
|
104
111
|
const maxDelayMs = retry.maxDelayMs ?? 3e3;
|
|
112
|
+
const maxRetryAfterMs = retry.maxRetryAfterMs ?? 1e4;
|
|
105
113
|
const retryStatuses = retry.retryStatuses ?? DEFAULT_RETRY_STATUSES;
|
|
106
114
|
let response = await doFetch(url, init);
|
|
107
115
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
108
116
|
if (response.ok || !retryStatuses.includes(response.status)) {
|
|
109
117
|
return response;
|
|
110
118
|
}
|
|
119
|
+
const asked = retryAfterMs(response);
|
|
120
|
+
if (asked !== null && asked > maxRetryAfterMs) return response;
|
|
111
121
|
const backoff = baseDelayMs * 2 ** attempt;
|
|
112
|
-
const wait = Math.min(
|
|
122
|
+
const wait = asked !== null ? asked : Math.min(backoff, maxDelayMs);
|
|
113
123
|
await sleep(wait, init.signal);
|
|
114
124
|
response = await doFetch(url, init);
|
|
115
125
|
}
|
|
@@ -143,9 +153,12 @@ async function postGraphql(url, query, variables, options) {
|
|
|
143
153
|
} catch {
|
|
144
154
|
detail = "";
|
|
145
155
|
}
|
|
156
|
+
const asked = retryAfterMs(response);
|
|
157
|
+
const wait = asked !== null ? ` - retry after ${Math.ceil(asked / 1e3)}s` : "";
|
|
146
158
|
throw new CmssyRequestError(
|
|
147
|
-
`cmssy: ${options.label} failed (${response.status})${detail}`,
|
|
148
|
-
response.status
|
|
159
|
+
`cmssy: ${options.label} failed (${response.status})${detail}${wait}`,
|
|
160
|
+
response.status,
|
|
161
|
+
asked ?? void 0
|
|
149
162
|
);
|
|
150
163
|
}
|
|
151
164
|
let json;
|
package/dist/internal/locale.cjs
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
// src/data/http.ts
|
|
4
4
|
var CmssyRequestError = class extends Error {
|
|
5
5
|
status;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
8
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
9
|
+
* long instead of guessing.
|
|
10
|
+
*/
|
|
11
|
+
retryAfterMs;
|
|
12
|
+
constructor(message, status, retryAfterMs2) {
|
|
7
13
|
super(message);
|
|
8
14
|
this.name = "CmssyRequestError";
|
|
9
15
|
this.status = status;
|
|
16
|
+
if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
|
|
10
17
|
}
|
|
11
18
|
};
|
|
12
19
|
var DEFAULT_RETRY_STATUSES = [429, 503];
|
|
@@ -43,14 +50,17 @@ async function fetchWithRetry(doFetch, url, init, retry) {
|
|
|
43
50
|
const maxRetries = retry.maxRetries ?? 3;
|
|
44
51
|
const baseDelayMs = retry.baseDelayMs ?? 300;
|
|
45
52
|
const maxDelayMs = retry.maxDelayMs ?? 3e3;
|
|
53
|
+
const maxRetryAfterMs = retry.maxRetryAfterMs ?? 1e4;
|
|
46
54
|
const retryStatuses = retry.retryStatuses ?? DEFAULT_RETRY_STATUSES;
|
|
47
55
|
let response = await doFetch(url, init);
|
|
48
56
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
49
57
|
if (response.ok || !retryStatuses.includes(response.status)) {
|
|
50
58
|
return response;
|
|
51
59
|
}
|
|
60
|
+
const asked = retryAfterMs(response);
|
|
61
|
+
if (asked !== null && asked > maxRetryAfterMs) return response;
|
|
52
62
|
const backoff = baseDelayMs * 2 ** attempt;
|
|
53
|
-
const wait = Math.min(
|
|
63
|
+
const wait = asked !== null ? asked : Math.min(backoff, maxDelayMs);
|
|
54
64
|
await sleep(wait, init.signal);
|
|
55
65
|
response = await doFetch(url, init);
|
|
56
66
|
}
|
|
@@ -84,9 +94,12 @@ async function postGraphql(url, query, variables, options) {
|
|
|
84
94
|
} catch {
|
|
85
95
|
detail = "";
|
|
86
96
|
}
|
|
97
|
+
const asked = retryAfterMs(response);
|
|
98
|
+
const wait = asked !== null ? ` - retry after ${Math.ceil(asked / 1e3)}s` : "";
|
|
87
99
|
throw new CmssyRequestError(
|
|
88
|
-
`cmssy: ${options.label} failed (${response.status})${detail}`,
|
|
89
|
-
response.status
|
|
100
|
+
`cmssy: ${options.label} failed (${response.status})${detail}${wait}`,
|
|
101
|
+
response.status,
|
|
102
|
+
asked ?? void 0
|
|
90
103
|
);
|
|
91
104
|
}
|
|
92
105
|
let json;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { G as GraphqlRequestOptions } from '../locale-
|
|
2
|
-
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from '../locale-
|
|
1
|
+
import { G as GraphqlRequestOptions } from '../locale-C7sA46qu.cjs';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from '../locale-C7sA46qu.cjs';
|
|
3
3
|
import { CmssySiteLocales, CmssyClientConfig } from '@cmssy/types';
|
|
4
4
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
5
|
-
import '../content-client-
|
|
5
|
+
import '../content-client-CJQ-nafm.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Maps a workspace site config to its locale set. The single place that
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { G as GraphqlRequestOptions } from '../locale-
|
|
2
|
-
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from '../locale-
|
|
1
|
+
import { G as GraphqlRequestOptions } from '../locale-Ox_qVlNy.js';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from '../locale-Ox_qVlNy.js';
|
|
3
3
|
import { CmssySiteLocales, CmssyClientConfig } from '@cmssy/types';
|
|
4
4
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
5
|
-
import '../content-client-
|
|
5
|
+
import '../content-client-CJQ-nafm.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Maps a workspace site config to its locale set. The single place that
|
package/dist/internal/locale.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// src/data/http.ts
|
|
2
2
|
var CmssyRequestError = class extends Error {
|
|
3
3
|
status;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
6
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
7
|
+
* long instead of guessing.
|
|
8
|
+
*/
|
|
9
|
+
retryAfterMs;
|
|
10
|
+
constructor(message, status, retryAfterMs2) {
|
|
5
11
|
super(message);
|
|
6
12
|
this.name = "CmssyRequestError";
|
|
7
13
|
this.status = status;
|
|
14
|
+
if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
|
|
8
15
|
}
|
|
9
16
|
};
|
|
10
17
|
var DEFAULT_RETRY_STATUSES = [429, 503];
|
|
@@ -41,14 +48,17 @@ async function fetchWithRetry(doFetch, url, init, retry) {
|
|
|
41
48
|
const maxRetries = retry.maxRetries ?? 3;
|
|
42
49
|
const baseDelayMs = retry.baseDelayMs ?? 300;
|
|
43
50
|
const maxDelayMs = retry.maxDelayMs ?? 3e3;
|
|
51
|
+
const maxRetryAfterMs = retry.maxRetryAfterMs ?? 1e4;
|
|
44
52
|
const retryStatuses = retry.retryStatuses ?? DEFAULT_RETRY_STATUSES;
|
|
45
53
|
let response = await doFetch(url, init);
|
|
46
54
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
47
55
|
if (response.ok || !retryStatuses.includes(response.status)) {
|
|
48
56
|
return response;
|
|
49
57
|
}
|
|
58
|
+
const asked = retryAfterMs(response);
|
|
59
|
+
if (asked !== null && asked > maxRetryAfterMs) return response;
|
|
50
60
|
const backoff = baseDelayMs * 2 ** attempt;
|
|
51
|
-
const wait = Math.min(
|
|
61
|
+
const wait = asked !== null ? asked : Math.min(backoff, maxDelayMs);
|
|
52
62
|
await sleep(wait, init.signal);
|
|
53
63
|
response = await doFetch(url, init);
|
|
54
64
|
}
|
|
@@ -82,9 +92,12 @@ async function postGraphql(url, query, variables, options) {
|
|
|
82
92
|
} catch {
|
|
83
93
|
detail = "";
|
|
84
94
|
}
|
|
95
|
+
const asked = retryAfterMs(response);
|
|
96
|
+
const wait = asked !== null ? ` - retry after ${Math.ceil(asked / 1e3)}s` : "";
|
|
85
97
|
throw new CmssyRequestError(
|
|
86
|
-
`cmssy: ${options.label} failed (${response.status})${detail}`,
|
|
87
|
-
response.status
|
|
98
|
+
`cmssy: ${options.label} failed (${response.status})${detail}${wait}`,
|
|
99
|
+
response.status,
|
|
100
|
+
asked ?? void 0
|
|
88
101
|
);
|
|
89
102
|
}
|
|
90
103
|
let json;
|
package/dist/internal.cjs
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
// src/data/http.ts
|
|
4
4
|
var CmssyRequestError = class extends Error {
|
|
5
5
|
status;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
8
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
9
|
+
* long instead of guessing.
|
|
10
|
+
*/
|
|
11
|
+
retryAfterMs;
|
|
12
|
+
constructor(message, status, retryAfterMs2) {
|
|
7
13
|
super(message);
|
|
8
14
|
this.name = "CmssyRequestError";
|
|
9
15
|
this.status = status;
|
|
16
|
+
if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
|
|
10
17
|
}
|
|
11
18
|
};
|
|
12
19
|
var DEFAULT_RETRY_STATUSES = [429, 503];
|
|
@@ -43,14 +50,17 @@ async function fetchWithRetry(doFetch, url, init, retry) {
|
|
|
43
50
|
const maxRetries = retry.maxRetries ?? 3;
|
|
44
51
|
const baseDelayMs = retry.baseDelayMs ?? 300;
|
|
45
52
|
const maxDelayMs = retry.maxDelayMs ?? 3e3;
|
|
53
|
+
const maxRetryAfterMs = retry.maxRetryAfterMs ?? 1e4;
|
|
46
54
|
const retryStatuses = retry.retryStatuses ?? DEFAULT_RETRY_STATUSES;
|
|
47
55
|
let response = await doFetch(url, init);
|
|
48
56
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
49
57
|
if (response.ok || !retryStatuses.includes(response.status)) {
|
|
50
58
|
return response;
|
|
51
59
|
}
|
|
60
|
+
const asked = retryAfterMs(response);
|
|
61
|
+
if (asked !== null && asked > maxRetryAfterMs) return response;
|
|
52
62
|
const backoff = baseDelayMs * 2 ** attempt;
|
|
53
|
-
const wait = Math.min(
|
|
63
|
+
const wait = asked !== null ? asked : Math.min(backoff, maxDelayMs);
|
|
54
64
|
await sleep(wait, init.signal);
|
|
55
65
|
response = await doFetch(url, init);
|
|
56
66
|
}
|
|
@@ -84,9 +94,12 @@ async function postGraphql(url, query, variables, options) {
|
|
|
84
94
|
} catch {
|
|
85
95
|
detail = "";
|
|
86
96
|
}
|
|
97
|
+
const asked = retryAfterMs(response);
|
|
98
|
+
const wait = asked !== null ? ` - retry after ${Math.ceil(asked / 1e3)}s` : "";
|
|
87
99
|
throw new CmssyRequestError(
|
|
88
|
-
`cmssy: ${options.label} failed (${response.status})${detail}`,
|
|
89
|
-
response.status
|
|
100
|
+
`cmssy: ${options.label} failed (${response.status})${detail}${wait}`,
|
|
101
|
+
response.status,
|
|
102
|
+
asked ?? void 0
|
|
90
103
|
);
|
|
91
104
|
}
|
|
92
105
|
let json;
|
|
@@ -819,14 +832,6 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
819
832
|
}
|
|
820
833
|
|
|
821
834
|
// src/block-context.ts
|
|
822
|
-
function blockPageOf(page) {
|
|
823
|
-
if (!page?.slug) return void 0;
|
|
824
|
-
return {
|
|
825
|
-
id: page.id,
|
|
826
|
-
slug: page.slug,
|
|
827
|
-
pageType: page.pageType ?? null
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
835
|
function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
|
|
831
836
|
return {
|
|
832
837
|
locale: {
|
|
@@ -838,7 +843,18 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
838
843
|
forms,
|
|
839
844
|
...extra?.auth ? { auth: extra.auth } : {},
|
|
840
845
|
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
841
|
-
|
|
846
|
+
// Identity only, and only when the page has one. A page fetched by an older
|
|
847
|
+
// SDK has no slug, and then a block gets no `page` at all rather than one
|
|
848
|
+
// with a hole in it: "I don't know where I am" has to stay distinguishable
|
|
849
|
+
// from "I am at /".
|
|
850
|
+
...extra?.page?.slug ? {
|
|
851
|
+
page: {
|
|
852
|
+
id: extra.page.id,
|
|
853
|
+
slug: extra.page.slug,
|
|
854
|
+
pageType: extra.page.pageType ?? null
|
|
855
|
+
}
|
|
856
|
+
} : {},
|
|
857
|
+
...extra?.app ? { app: extra.app } : {}
|
|
842
858
|
};
|
|
843
859
|
}
|
|
844
860
|
|
|
@@ -945,7 +961,6 @@ exports.RECORDS_BY_IDS_QUERY = RECORDS_BY_IDS_QUERY;
|
|
|
945
961
|
exports.SITE_CONFIG_QUERY = SITE_CONFIG_QUERY;
|
|
946
962
|
exports.SUBMIT_FORM_MUTATION = SUBMIT_FORM_MUTATION;
|
|
947
963
|
exports.asBucket = asBucket;
|
|
948
|
-
exports.blockPageOf = blockPageOf;
|
|
949
964
|
exports.buildBlockContext = buildBlockContext;
|
|
950
965
|
exports.buildLocaleSwitchHref = buildLocaleSwitchHref;
|
|
951
966
|
exports.cachedWorkspaceId = cachedWorkspaceId;
|
package/dist/internal.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-
|
|
2
|
-
import {
|
|
1
|
+
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-CJQ-nafm.cjs';
|
|
2
|
+
import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
|
|
3
3
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
4
|
-
import { G as GraphqlRequestOptions } from './locale-
|
|
5
|
-
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-
|
|
6
|
-
import { Q as QueryScopedOptions } from './csp-
|
|
7
|
-
export { m as cmssyCspHeaders, o as isDevelopment, q as resolveInitialTarget, t as toCspOrigin } from './csp-
|
|
4
|
+
import { G as GraphqlRequestOptions } from './locale-C7sA46qu.cjs';
|
|
5
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-C7sA46qu.cjs';
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-BityT_ug.cjs';
|
|
7
|
+
export { m as cmssyCspHeaders, o as isDevelopment, q as resolveInitialTarget, t as toCspOrigin } from './csp-BityT_ug.cjs';
|
|
8
8
|
export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath } from './internal/locale.cjs';
|
|
9
9
|
|
|
10
10
|
declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
|
@@ -13,14 +13,6 @@ declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: Stri
|
|
|
13
13
|
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
|
|
14
14
|
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* The identity half of a fetched page, for `context.page`.
|
|
18
|
-
*
|
|
19
|
-
* A page fetched by an older SDK - or by a consumer that builds `CmssyPageData`
|
|
20
|
-
* itself - has no slug, and then a block gets no `page` at all rather than one
|
|
21
|
-
* with a hole in it: `context.page ? … : …` is a question a block can answer.
|
|
22
|
-
*/
|
|
23
|
-
declare function blockPageOf(page: CmssyPageData | null | undefined): CmssyBlockPage | undefined;
|
|
24
16
|
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
25
17
|
|
|
26
18
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
@@ -70,4 +62,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
70
62
|
|
|
71
63
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
72
64
|
|
|
73
|
-
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket,
|
|
65
|
+
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-
|
|
2
|
-
import {
|
|
1
|
+
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-CJQ-nafm.js';
|
|
2
|
+
import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
|
|
3
3
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
4
|
-
import { G as GraphqlRequestOptions } from './locale-
|
|
5
|
-
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-
|
|
6
|
-
import { Q as QueryScopedOptions } from './csp-
|
|
7
|
-
export { m as cmssyCspHeaders, o as isDevelopment, q as resolveInitialTarget, t as toCspOrigin } from './csp-
|
|
4
|
+
import { G as GraphqlRequestOptions } from './locale-Ox_qVlNy.js';
|
|
5
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-Ox_qVlNy.js';
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-DJ17P3PN.js';
|
|
7
|
+
export { m as cmssyCspHeaders, o as isDevelopment, q as resolveInitialTarget, t as toCspOrigin } from './csp-DJ17P3PN.js';
|
|
8
8
|
export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath } from './internal/locale.js';
|
|
9
9
|
|
|
10
10
|
declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
|
@@ -13,14 +13,6 @@ declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: Stri
|
|
|
13
13
|
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
|
|
14
14
|
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* The identity half of a fetched page, for `context.page`.
|
|
18
|
-
*
|
|
19
|
-
* A page fetched by an older SDK - or by a consumer that builds `CmssyPageData`
|
|
20
|
-
* itself - has no slug, and then a block gets no `page` at all rather than one
|
|
21
|
-
* with a hole in it: `context.page ? … : …` is a question a block can answer.
|
|
22
|
-
*/
|
|
23
|
-
declare function blockPageOf(page: CmssyPageData | null | undefined): CmssyBlockPage | undefined;
|
|
24
16
|
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
25
17
|
|
|
26
18
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
@@ -70,4 +62,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
70
62
|
|
|
71
63
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
72
64
|
|
|
73
|
-
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket,
|
|
65
|
+
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// src/data/http.ts
|
|
2
2
|
var CmssyRequestError = class extends Error {
|
|
3
3
|
status;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
6
|
+
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
7
|
+
* long instead of guessing.
|
|
8
|
+
*/
|
|
9
|
+
retryAfterMs;
|
|
10
|
+
constructor(message, status, retryAfterMs2) {
|
|
5
11
|
super(message);
|
|
6
12
|
this.name = "CmssyRequestError";
|
|
7
13
|
this.status = status;
|
|
14
|
+
if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
|
|
8
15
|
}
|
|
9
16
|
};
|
|
10
17
|
var DEFAULT_RETRY_STATUSES = [429, 503];
|
|
@@ -41,14 +48,17 @@ async function fetchWithRetry(doFetch, url, init, retry) {
|
|
|
41
48
|
const maxRetries = retry.maxRetries ?? 3;
|
|
42
49
|
const baseDelayMs = retry.baseDelayMs ?? 300;
|
|
43
50
|
const maxDelayMs = retry.maxDelayMs ?? 3e3;
|
|
51
|
+
const maxRetryAfterMs = retry.maxRetryAfterMs ?? 1e4;
|
|
44
52
|
const retryStatuses = retry.retryStatuses ?? DEFAULT_RETRY_STATUSES;
|
|
45
53
|
let response = await doFetch(url, init);
|
|
46
54
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
47
55
|
if (response.ok || !retryStatuses.includes(response.status)) {
|
|
48
56
|
return response;
|
|
49
57
|
}
|
|
58
|
+
const asked = retryAfterMs(response);
|
|
59
|
+
if (asked !== null && asked > maxRetryAfterMs) return response;
|
|
50
60
|
const backoff = baseDelayMs * 2 ** attempt;
|
|
51
|
-
const wait = Math.min(
|
|
61
|
+
const wait = asked !== null ? asked : Math.min(backoff, maxDelayMs);
|
|
52
62
|
await sleep(wait, init.signal);
|
|
53
63
|
response = await doFetch(url, init);
|
|
54
64
|
}
|
|
@@ -82,9 +92,12 @@ async function postGraphql(url, query, variables, options) {
|
|
|
82
92
|
} catch {
|
|
83
93
|
detail = "";
|
|
84
94
|
}
|
|
95
|
+
const asked = retryAfterMs(response);
|
|
96
|
+
const wait = asked !== null ? ` - retry after ${Math.ceil(asked / 1e3)}s` : "";
|
|
85
97
|
throw new CmssyRequestError(
|
|
86
|
-
`cmssy: ${options.label} failed (${response.status})${detail}`,
|
|
87
|
-
response.status
|
|
98
|
+
`cmssy: ${options.label} failed (${response.status})${detail}${wait}`,
|
|
99
|
+
response.status,
|
|
100
|
+
asked ?? void 0
|
|
88
101
|
);
|
|
89
102
|
}
|
|
90
103
|
let json;
|
|
@@ -817,14 +830,6 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
817
830
|
}
|
|
818
831
|
|
|
819
832
|
// src/block-context.ts
|
|
820
|
-
function blockPageOf(page) {
|
|
821
|
-
if (!page?.slug) return void 0;
|
|
822
|
-
return {
|
|
823
|
-
id: page.id,
|
|
824
|
-
slug: page.slug,
|
|
825
|
-
pageType: page.pageType ?? null
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
833
|
function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
|
|
829
834
|
return {
|
|
830
835
|
locale: {
|
|
@@ -836,7 +841,18 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
836
841
|
forms,
|
|
837
842
|
...extra?.auth ? { auth: extra.auth } : {},
|
|
838
843
|
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
839
|
-
|
|
844
|
+
// Identity only, and only when the page has one. A page fetched by an older
|
|
845
|
+
// SDK has no slug, and then a block gets no `page` at all rather than one
|
|
846
|
+
// with a hole in it: "I don't know where I am" has to stay distinguishable
|
|
847
|
+
// from "I am at /".
|
|
848
|
+
...extra?.page?.slug ? {
|
|
849
|
+
page: {
|
|
850
|
+
id: extra.page.id,
|
|
851
|
+
slug: extra.page.slug,
|
|
852
|
+
pageType: extra.page.pageType ?? null
|
|
853
|
+
}
|
|
854
|
+
} : {},
|
|
855
|
+
...extra?.app ? { app: extra.app } : {}
|
|
840
856
|
};
|
|
841
857
|
}
|
|
842
858
|
|
|
@@ -935,4 +951,4 @@ function cmssyCspHeaders(options) {
|
|
|
935
951
|
};
|
|
936
952
|
}
|
|
937
953
|
|
|
938
|
-
export { CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket,
|
|
954
|
+
export { CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeRelationContent, normalizeSlug, resolveApiUrl, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchLike, R as RetryPolicy } from './content-client-
|
|
1
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-CJQ-nafm.cjs';
|
|
2
2
|
import { CmssyClientConfig, CmssyLocaleContext } from '@cmssy/types';
|
|
3
3
|
|
|
4
4
|
interface GraphqlRequestOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchLike, R as RetryPolicy } from './content-client-
|
|
1
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-CJQ-nafm.js';
|
|
2
2
|
import { CmssyClientConfig, CmssyLocaleContext } from '@cmssy/types';
|
|
3
3
|
|
|
4
4
|
interface GraphqlRequestOptions {
|
package/dist/preflight.d.cts
CHANGED
package/dist/preflight.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/core",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.0",
|
|
4
4
|
"description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "^2.1.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@cmssy/types": "0.
|
|
65
|
+
"@cmssy/types": "0.31.0",
|
|
66
66
|
"jose": "^6.2.3"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|