@contentstack/studio-client 4.1.0 → 4.2.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/breakpoints/BreakpointManager.js +3 -2
- package/dist/breakpoints/BreakpointManager.js.map +1 -1
- package/dist/breakpoints/breakpoint-origin.js +30 -0
- package/dist/breakpoints/breakpoint-origin.js.map +1 -0
- package/dist/canvas/canvas.type.js +1 -1
- package/dist/canvas/canvas.utils.js +165 -4
- package/dist/canvas/canvas.utils.js.map +1 -1
- package/dist/composable-studio/binding-defect-report.js +106 -0
- package/dist/composable-studio/binding-defect-report.js.map +1 -0
- package/dist/composable-studio/build-scoped-data.js +21 -11
- package/dist/composable-studio/build-scoped-data.js.map +1 -1
- package/dist/composable-studio/collect-data-needs.js +1 -1
- package/dist/composable-studio/data/pre-process-static-values.js +89 -19
- package/dist/composable-studio/data/pre-process-static-values.js.map +1 -1
- package/dist/composable-studio/delivery-setup-check.js +92 -0
- package/dist/composable-studio/delivery-setup-check.js.map +1 -0
- package/dist/composable-studio/resolution-failure-spec.js +53 -0
- package/dist/composable-studio/resolution-failure-spec.js.map +1 -0
- package/dist/composable-studio/resolution-telemetry.js +68 -0
- package/dist/composable-studio/resolution-telemetry.js.map +1 -0
- package/dist/composable-studio/sdk.js +683 -551
- package/dist/composable-studio/sdk.js.map +1 -1
- package/dist/composable-studio/section-binding/compute-all-section-auto-bindings.js +146 -0
- package/dist/composable-studio/section-binding/compute-all-section-auto-bindings.js.map +1 -0
- package/dist/composable-studio/section-binding/constants.js +27 -0
- package/dist/composable-studio/section-binding/constants.js.map +1 -0
- package/dist/composable-studio/section-binding/index.js +20 -0
- package/dist/composable-studio/section-binding/index.js.map +1 -0
- package/dist/composable-studio/section-binding/schema-path.js +112 -0
- package/dist/composable-studio/section-binding/schema-path.js.map +1 -0
- package/dist/composable-studio/section-binding/section-composition-auto-binding.js +815 -0
- package/dist/composable-studio/section-binding/section-composition-auto-binding.js.map +1 -0
- package/dist/composable-studio/section-binding/section-compositions.js +349 -0
- package/dist/composable-studio/section-binding/section-compositions.js.map +1 -0
- package/dist/composable-studio/section-binding/section-internal-ref-introspection.js +72 -0
- package/dist/composable-studio/section-binding/section-internal-ref-introspection.js.map +1 -0
- package/dist/composable-studio/section-binding/self-describe-section-bindings.js +132 -0
- package/dist/composable-studio/section-binding/self-describe-section-bindings.js.map +1 -0
- package/dist/composable-studio/section-binding/serialization.js +33 -0
- package/dist/composable-studio/section-binding/serialization.js.map +1 -0
- package/dist/composable-studio/section-data.js +5 -1
- package/dist/composable-studio/section-data.js.map +1 -1
- package/dist/composable-studio/setup-check-signal.js +48 -0
- package/dist/composable-studio/setup-check-signal.js.map +1 -0
- package/dist/composable-studio/studio-intelligence.manager.js +6 -2
- package/dist/composable-studio/studio-intelligence.manager.js.map +1 -1
- package/dist/config/config.schema.js +97 -104
- package/dist/config/config.schema.js.map +1 -1
- package/dist/config/process-user-config.js +41 -24
- package/dist/config/process-user-config.js.map +1 -1
- package/dist/config/stack-sdk-wrapper.js +22 -4
- package/dist/config/stack-sdk-wrapper.js.map +1 -1
- package/dist/context-menu/context-menu.js +1 -0
- package/dist/context-menu/context-menu.js.map +1 -1
- package/dist/dnd/dnd-manager.js +1 -0
- package/dist/dnd/dnd-manager.js.map +1 -1
- package/dist/editor.d.ts +34 -1
- package/dist/highlight-node/highlight-node-manager.js +89 -14
- package/dist/highlight-node/highlight-node-manager.js.map +1 -1
- package/dist/highlight-node/highlight-node.js +11 -5
- package/dist/highlight-node/highlight-node.js.map +1 -1
- package/dist/highlight-node/history-shortcut.js +78 -0
- package/dist/highlight-node/history-shortcut.js.map +1 -0
- package/dist/index.d.ts +1082 -354
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/query/query-executor.js +51 -9
- package/dist/query/query-executor.js.map +1 -1
- package/dist/renderer-mode.d.ts +68 -0
- package/dist/renderer-mode.js +2 -0
- package/dist/renderer-mode.js.map +1 -0
- package/dist/url-metadata/entry-check-key.js +14 -0
- package/dist/url-metadata/entry-check-key.js.map +1 -0
- package/dist/url-metadata/select-url-winner.js +64 -12
- package/dist/url-metadata/select-url-winner.js.map +1 -1
- package/dist/url-metadata/types.js +10 -1
- package/dist/url-metadata/types.js.map +1 -1
- package/dist/url-metadata/url-pattern-matcher.js +11 -2
- package/dist/url-metadata/url-pattern-matcher.js.map +1 -1
- package/dist/utils/canvas.js +0 -1
- package/dist/utils/canvas.js.map +1 -1
- package/dist/utils/check-bindings.js +5 -3
- package/dist/utils/check-bindings.js.map +1 -1
- package/dist/utils/classify-response-error.js +243 -33
- package/dist/utils/classify-response-error.js.map +1 -1
- package/dist/utils/composable-studio-error.js +7 -0
- package/dist/utils/composable-studio-error.js.map +1 -1
- package/dist/utils/conditionBlock.js +19 -6
- package/dist/utils/conditionBlock.js.map +1 -1
- package/dist/utils/constants.js +7 -2
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/http-error.constants.js +24 -1
- package/dist/utils/http-error.constants.js.map +1 -1
- package/dist/utils/include-path-rules.js +3 -2
- package/dist/utils/include-path-rules.js.map +1 -1
- package/dist/utils/load-error-classifier.js +18 -0
- package/dist/utils/load-error-classifier.js.map +1 -0
- package/dist/utils/parse-ui.js +27 -5
- package/dist/utils/parse-ui.js.map +1 -1
- package/dist/utils/preview-hash-refused.js +75 -0
- package/dist/utils/preview-hash-refused.js.map +1 -0
- package/dist/utils/reference_fetcher.js +79 -12
- package/dist/utils/reference_fetcher.js.map +1 -1
- package/dist/utils/require-stack.js +83 -20
- package/dist/utils/require-stack.js.map +1 -1
- package/dist/utils/serialize-for-inline-script.js +19 -0
- package/dist/utils/serialize-for-inline-script.js.map +1 -0
- package/dist/utils/served-by.js +32 -13
- package/dist/utils/served-by.js.map +1 -1
- package/dist/utils/spec-analyzer.js +24 -1
- package/dist/utils/spec-analyzer.js.map +1 -1
- package/dist/utils/studio-error-codes.js +34 -2
- package/dist/utils/studio-error-codes.js.map +1 -1
- package/dist/utils/studio-error.js +68 -7
- package/dist/utils/studio-error.js.map +1 -1
- package/dist/visual-builder/composition-save-event.js +36 -5
- package/dist/visual-builder/composition-save-event.js.map +1 -1
- package/package.json +12 -8
- package/dist/studio-internal/dist/utils/section-slot-walker.js +0 -63
- package/dist/studio-internal/dist/utils/section-slot-walker.js.map +0 -1
- package/dist/studio-internal/dist/utils/spec-compression.js +0 -43
- package/dist/studio-internal/dist/utils/spec-compression.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_COMPOSITION_TYPE_UID } from '../config/config.constant.js';
|
|
2
|
-
import { getStatusCode, HttpStatus, ContentstackErrorCode, isNetworkError } from './http-error.constants.js';
|
|
2
|
+
import { getStatusCode, HttpStatus, ContentstackErrorCode, isNetworkError, DELIVERY_SDK_UNKNOWN_ERROR } from './http-error.constants.js';
|
|
3
3
|
import { buildStudioErrorContext, createStudioError } from './studio-error.js';
|
|
4
4
|
import { StudioErrorCode } from './studio-error-codes.js';
|
|
5
5
|
|
|
@@ -53,6 +53,37 @@ function contentTypeCauses(config) {
|
|
|
53
53
|
*/
|
|
54
54
|
const ENVIRONMENT_NOT_FOUND_MESSAGE = /^\s*environment was not found/i;
|
|
55
55
|
const LANGUAGE_NOT_FOUND_MESSAGE = /^\s*language was not found/i;
|
|
56
|
+
/**
|
|
57
|
+
* 382 carries two meanings, separated only by `error_message`: a session of
|
|
58
|
+
* another stack, or a hash that is expired or made up. Only the first names an
|
|
59
|
+
* API key, so that is what is matched. Captured from the dev11 preview host.
|
|
60
|
+
*/
|
|
61
|
+
const PREVIEW_STACK_MISMATCH_MESSAGE = /associated with the stack api key/i;
|
|
62
|
+
/**
|
|
63
|
+
* 901 names what it refused and its value, and nothing else does: "… on this
|
|
64
|
+
* branch 'preview'", "… on this language 'xx-yy'". Matched on that phrase so
|
|
65
|
+
* the "Access denied" lead-in can change freely. Verified against a live stack.
|
|
66
|
+
*/
|
|
67
|
+
const DENIED_ON_SCOPE_MESSAGE = /on this (branch|language) '([^']+)'/i;
|
|
68
|
+
/** The stack was given a branch it does not have. */
|
|
69
|
+
function branchNotFound(branch, context, status, errorCode) {
|
|
70
|
+
return createStudioError({
|
|
71
|
+
code: StudioErrorCode.BRANCH_NOT_FOUND,
|
|
72
|
+
headline: `Contentstack has no branch "${branch}" on this stack, or this token cannot read it.`,
|
|
73
|
+
causes: [
|
|
74
|
+
{
|
|
75
|
+
cause: `The branch "${branch}" may be mistyped, or may have been deleted.`,
|
|
76
|
+
fix: "Compare it with the branches in Contentstack, or remove it to read from main.",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
cause: "The branch may exist but sit outside the delivery token's scope. A delivery token is scoped to specific branches.",
|
|
80
|
+
fix: `Check that the delivery token in use covers "${branch}".`,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
context,
|
|
84
|
+
findings: { branch, status, errorCode },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
56
87
|
/**
|
|
57
88
|
* Byte-identical responses, so this ranks and never asserts — one says change a
|
|
58
89
|
* value, the other change the host, and picking wrong edits what was right.
|
|
@@ -103,17 +134,24 @@ function environmentNotFound(context, status, errorCode) {
|
|
|
103
134
|
findings: { environment, status, errorCode },
|
|
104
135
|
});
|
|
105
136
|
}
|
|
106
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Casing leads when there is any: it is the one difference a reader cannot see
|
|
139
|
+
* by looking. A code with no capitals has none to point at, and comparing it
|
|
140
|
+
* with itself would tell the reader two identical values differ.
|
|
141
|
+
*/
|
|
107
142
|
function localeCauses(locale) {
|
|
143
|
+
const notAdded = {
|
|
144
|
+
cause: "The language may never have been added to this stack.",
|
|
145
|
+
fix: "Add it in Contentstack, or ask for one the stack has.",
|
|
146
|
+
};
|
|
147
|
+
if (locale === locale.toLowerCase())
|
|
148
|
+
return [notAdded];
|
|
108
149
|
return [
|
|
109
150
|
{
|
|
110
151
|
cause: `The code may not match the one on the stack — "${locale}" and "${locale.toLowerCase()}" are different values.`,
|
|
111
152
|
fix: "Compare it with the languages in Contentstack, exactly as they are written there.",
|
|
112
153
|
},
|
|
113
|
-
|
|
114
|
-
cause: "The language may never have been added to this stack.",
|
|
115
|
-
fix: "Add it in Contentstack, or ask for one the stack has.",
|
|
116
|
-
},
|
|
154
|
+
notAdded,
|
|
117
155
|
];
|
|
118
156
|
}
|
|
119
157
|
/** The address asked for a language the stack does not have: a missing page. */
|
|
@@ -152,11 +190,20 @@ function localeNotConfigured(locale, context, status, errorCode) {
|
|
|
152
190
|
findings: { locale, localeSource: "configuration", status, errorCode },
|
|
153
191
|
});
|
|
154
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Split on provenance: a configured locale is a setup fault, one from the
|
|
195
|
+
* address is visitor input. Getting it wrong 5xxs anyone who mistypes.
|
|
196
|
+
*/
|
|
197
|
+
function languageRefused(locale, request, context, status, errorCode) {
|
|
198
|
+
return request.localeSource === "url-pattern"
|
|
199
|
+
? urlLocaleNotFound(locale, request.url, context, status, errorCode)
|
|
200
|
+
: localeNotConfigured(locale, context, status, errorCode);
|
|
201
|
+
}
|
|
155
202
|
function classifyResponseError(err, config, request = {}) {
|
|
156
203
|
const status = getStatusCode(err);
|
|
157
204
|
const errorCode = err?.error_code;
|
|
158
205
|
const errorMessage = err?.error_message ?? "";
|
|
159
|
-
const context = buildStudioErrorContext(config, request
|
|
206
|
+
const context = buildStudioErrorContext(config, request);
|
|
160
207
|
// The response is identical whether the key is wrong or the host is for
|
|
161
208
|
// another region, so the two are ranked rather than picked between.
|
|
162
209
|
if (status === HttpStatus.PRECONDITION_FAILED &&
|
|
@@ -169,6 +216,71 @@ function classifyResponseError(err, config, request = {}) {
|
|
|
169
216
|
findings: { status, errorCode },
|
|
170
217
|
});
|
|
171
218
|
}
|
|
219
|
+
// The stack was found and the token was not good for it. The delivery SDK's
|
|
220
|
+
// retry policy loses this status before it reaches here, so today only a
|
|
221
|
+
// request made without the delivery SDK (the setup check) carries it.
|
|
222
|
+
if (status === HttpStatus.UNAUTHORIZED &&
|
|
223
|
+
errorCode === ContentstackErrorCode.INVALID_CREDENTIALS) {
|
|
224
|
+
return createStudioError({
|
|
225
|
+
code: StudioErrorCode.DELIVERY_TOKEN_INVALID,
|
|
226
|
+
headline: `Contentstack refused the delivery token for this API key on ${context.host ?? "this host"}.`,
|
|
227
|
+
causes: [
|
|
228
|
+
{
|
|
229
|
+
cause: "The delivery token may have been revoked, regenerated or mistyped.",
|
|
230
|
+
fix: "Compare it with the stack's delivery tokens in Contentstack.",
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
cause: "The delivery token and the API key may come from different stacks.",
|
|
234
|
+
fix: "Take both from the same stack's settings in Contentstack.",
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
context,
|
|
238
|
+
findings: { status, errorCode },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
// The preview host sends 400/382 for two different refusals, told apart only
|
|
242
|
+
// by `error_message`:
|
|
243
|
+
// - "The requested tracker is associated with the stack API key '…'. You
|
|
244
|
+
// are using a different API key '…'." — the session is another stack's;
|
|
245
|
+
// - "The Live Preview tracker is invalid or no longer exists. …" — the hash
|
|
246
|
+
// itself is expired or made up (an old or copied preview link).
|
|
247
|
+
// Only the first names a stack, so only a message that does is a mismatch.
|
|
248
|
+
// Reading every 382 as one told a visitor's stale link to change the site's
|
|
249
|
+
// API key, and kept the SDK from serving that visitor the published page.
|
|
250
|
+
const isPreviewTrackerRefusal = status === HttpStatus.BAD_REQUEST &&
|
|
251
|
+
errorCode === ContentstackErrorCode.PREVIEW_STACK_MISMATCH;
|
|
252
|
+
if (isPreviewTrackerRefusal &&
|
|
253
|
+
!PREVIEW_STACK_MISMATCH_MESSAGE.test(errorMessage)) {
|
|
254
|
+
return createStudioError({
|
|
255
|
+
code: StudioErrorCode.PREVIEW_HASH_REFUSED,
|
|
256
|
+
headline: "The preview host refused this request's preview hash: it has expired or does not exist.",
|
|
257
|
+
causes: [
|
|
258
|
+
{
|
|
259
|
+
cause: "The address carries a preview link that has expired, was copied from an old preview, or was made up.",
|
|
260
|
+
fix: "Open the page again from Live Preview, the Visual Editor or Studio for a new preview hash.",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
context,
|
|
264
|
+
findings: { status, errorCode },
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
// Contentstack names both stacks in its own reply, so the cause is stated
|
|
268
|
+
// rather than ranked. Without this the 400 reads as an outage and the reader
|
|
269
|
+
// is told to retry a request that can never succeed.
|
|
270
|
+
if (isPreviewTrackerRefusal) {
|
|
271
|
+
return createStudioError({
|
|
272
|
+
code: StudioErrorCode.PREVIEW_STACK_MISMATCH,
|
|
273
|
+
headline: "The live preview session belongs to a different stack from this API key.",
|
|
274
|
+
causes: [
|
|
275
|
+
{
|
|
276
|
+
cause: "The site is connected to a different stack from the Studio project it is being previewed in.",
|
|
277
|
+
fix: "Set the API key, delivery token and environment to the ones of the stack the Studio project is connected to.",
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
context,
|
|
281
|
+
findings: { status, errorCode },
|
|
282
|
+
});
|
|
283
|
+
}
|
|
172
284
|
if (status === HttpStatus.UNPROCESSABLE_ENTITY &&
|
|
173
285
|
errorCode === ContentstackErrorCode.ENTRY_NOT_FOUND) {
|
|
174
286
|
if (ENVIRONMENT_NOT_FOUND_MESSAGE.test(errorMessage)) {
|
|
@@ -176,17 +288,33 @@ function classifyResponseError(err, config, request = {}) {
|
|
|
176
288
|
}
|
|
177
289
|
if (LANGUAGE_NOT_FOUND_MESSAGE.test(errorMessage)) {
|
|
178
290
|
const locale = request.locale ?? context.locale ?? "";
|
|
179
|
-
|
|
180
|
-
// address is visitor input. Getting it wrong 5xxs anyone who mistypes.
|
|
181
|
-
return request.localeSource === "url-pattern"
|
|
182
|
-
? urlLocaleNotFound(locale, request.url, context, status, errorCode)
|
|
183
|
-
: localeNotConfigured(locale, context, status, errorCode);
|
|
291
|
+
return languageRefused(locale, request, context, status, errorCode);
|
|
184
292
|
}
|
|
185
293
|
// Any other 141 is left alone deliberately. A missing entry is the only
|
|
186
294
|
// meaning that occurs in ordinary traffic, so an unrecognised wording is
|
|
187
295
|
// most likely one — and 5xx-ing instead breaks every genuine missing page
|
|
188
296
|
// the day Contentstack rewords a string.
|
|
189
297
|
}
|
|
298
|
+
// The live preview host refuses a missing language as an access error, and
|
|
299
|
+
// both hosts refuse a missing branch the same way. Every request inside
|
|
300
|
+
// Studio's canvas goes to the preview host, so without this the author is
|
|
301
|
+
// told Contentstack is down while their own setup is what failed.
|
|
302
|
+
if (status === HttpStatus.UNPROCESSABLE_ENTITY &&
|
|
303
|
+
errorCode === ContentstackErrorCode.ACCESS_DENIED) {
|
|
304
|
+
const denied = DENIED_ON_SCOPE_MESSAGE.exec(errorMessage);
|
|
305
|
+
const [, scope, value] = denied ?? [];
|
|
306
|
+
if (scope?.toLowerCase() === "branch" && value) {
|
|
307
|
+
return branchNotFound(value, context, status, errorCode);
|
|
308
|
+
}
|
|
309
|
+
// The preview host's wording for what the delivery host sends as 141, so
|
|
310
|
+
// it takes the same provenance split.
|
|
311
|
+
if (scope?.toLowerCase() === "language" && value) {
|
|
312
|
+
// What we sent wins: it keeps the caller's casing, which the casing
|
|
313
|
+
// cause depends on. The reply's copy covers a caller that passed none.
|
|
314
|
+
const locale = request.locale ?? value;
|
|
315
|
+
return languageRefused(locale, request, context, status, errorCode);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
190
318
|
if (status === HttpStatus.UNPROCESSABLE_ENTITY &&
|
|
191
319
|
errorCode === ContentstackErrorCode.CONTENT_TYPE_NOT_FOUND) {
|
|
192
320
|
return createStudioError({
|
|
@@ -228,7 +356,7 @@ function diagnoseUnreadableResponse(err, config, request = {},
|
|
|
228
356
|
notFound) {
|
|
229
357
|
const status = getStatusCode(err);
|
|
230
358
|
const errorCode = err?.error_code;
|
|
231
|
-
const context = buildStudioErrorContext(config, request
|
|
359
|
+
const context = buildStudioErrorContext(config, request);
|
|
232
360
|
// An unplaceable 141 reads as a missing entry, which is the only one of its
|
|
233
361
|
// four meanings that occurs in ordinary traffic. Reporting it as a server
|
|
234
362
|
// error instead would 5xx every genuine missing page the day Contentstack
|
|
@@ -238,14 +366,24 @@ notFound) {
|
|
|
238
366
|
errorCode === ContentstackErrorCode.ENTRY_NOT_FOUND);
|
|
239
367
|
if (readsAsMissing && notFound)
|
|
240
368
|
return notFound();
|
|
241
|
-
|
|
369
|
+
const host = requestHost(context);
|
|
370
|
+
// Status 0 is how the delivery SDK reports that no response arrived at all:
|
|
371
|
+
// `@contentstack/core` builds an APIError with `status: 0` and puts the
|
|
372
|
+
// transport's code in `error_code`. Nothing answered, so Contentstack is not
|
|
373
|
+
// the party to blame.
|
|
374
|
+
if (status === 0 || (status === undefined && isNetworkError(err))) {
|
|
375
|
+
const transportCode = readTransportCode(err);
|
|
242
376
|
return createStudioError({
|
|
243
377
|
code: StudioErrorCode.TRANSPORT_FAILED,
|
|
244
|
-
headline: `The request to ${
|
|
245
|
-
causes: transportCauses(
|
|
378
|
+
headline: `The request to ${host ?? "Contentstack"} got no reply the site could read.`,
|
|
379
|
+
causes: transportCauses(host, transportCode),
|
|
246
380
|
context,
|
|
247
381
|
findings: {
|
|
248
|
-
host
|
|
382
|
+
host,
|
|
383
|
+
transportCode,
|
|
384
|
+
// Stated rather than left for Studio to infer from the code: the advice
|
|
385
|
+
// differs, and a timeout can arrive with no code at all.
|
|
386
|
+
requestedFrom: typeof document === "undefined" ? "server" : "browser",
|
|
249
387
|
detail: err?.message,
|
|
250
388
|
},
|
|
251
389
|
});
|
|
@@ -262,26 +400,98 @@ notFound) {
|
|
|
262
400
|
},
|
|
263
401
|
],
|
|
264
402
|
context,
|
|
265
|
-
findings: { status, errorCode, host
|
|
403
|
+
findings: { status, errorCode, host },
|
|
266
404
|
});
|
|
267
405
|
}
|
|
268
406
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
407
|
+
* A reply the delivery SDK threw away. A refused delivery token comes back as a
|
|
408
|
+
* readable 401, and the delivery SDK reduces it to status 0 and `UNKNOWN_ERROR`, so
|
|
409
|
+
* the refusal looks like no reply at all. Ranked, never asserted: the delivery SDK's
|
|
410
|
+
* own timeout, and a rate limit that outlasts its retries, look the same.
|
|
271
411
|
*/
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
412
|
+
const statuslessRefusalCause = {
|
|
413
|
+
cause: "Contentstack may have refused the delivery token or the API key. The delivery SDK reports that refusal without its status, so it can look like no reply at all.",
|
|
414
|
+
fix: "Compare the delivery token and API key with the stack's tokens in Contentstack, and check that the token covers this environment.",
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* The address the request actually went to. Live preview sends it to the
|
|
418
|
+
* preview host, and naming the delivery host there sends a developer to check
|
|
419
|
+
* a value that played no part.
|
|
420
|
+
*/
|
|
421
|
+
function requestHost(context) {
|
|
422
|
+
return context.servedBy === "preview"
|
|
423
|
+
? (context.previewHost ?? context.host)
|
|
424
|
+
: context.host;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* The transport's own code. Node's (`ENOTFOUND`, `ECONNREFUSED`) on a server,
|
|
428
|
+
* axios's `ERR_NETWORK` in a browser. Core keeps it in `error_code`; an error
|
|
429
|
+
* thrown before core wrapped it still has it in `code`.
|
|
430
|
+
*/
|
|
431
|
+
function readTransportCode(err) {
|
|
432
|
+
const { code, error_code } = (err ?? {});
|
|
433
|
+
const value = error_code ?? code;
|
|
434
|
+
return typeof value === "string" && value ? value : undefined;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* What to check when no reply came back, ordered by what the reader can act on.
|
|
438
|
+
*
|
|
439
|
+
* `transportCode` decides how much we know. A server names the failure: a name
|
|
440
|
+
* that does not resolve is a host to fix, a refused connection is nothing
|
|
441
|
+
* listening there, a timeout is the network. A browser only ever says
|
|
442
|
+
* `ERR_NETWORK`, which also covers a request Contentstack refused with a reply
|
|
443
|
+
* that carries no CORS header — a wrong API key or delivery token reaches the
|
|
444
|
+
* page exactly like a dead host does.
|
|
445
|
+
*/
|
|
446
|
+
function transportCauses(host, transportCode) {
|
|
447
|
+
const where = host ?? "the configured Contentstack address";
|
|
448
|
+
const checkHost = {
|
|
449
|
+
cause: `The address ${where} may be wrong: mistyped, or written with a scheme such as https://.`,
|
|
450
|
+
fix: "Compare it with your stack's region host, written as a bare name such as cdn.contentstack.io.",
|
|
451
|
+
};
|
|
452
|
+
const checkNetwork = {
|
|
453
|
+
cause: `The network between this site and ${where} may have dropped the request.`,
|
|
454
|
+
fix: "Retry. If it keeps happening, check outbound network access and any proxy in front of this site.",
|
|
455
|
+
};
|
|
456
|
+
switch (transportCode) {
|
|
457
|
+
case "ENOTFOUND":
|
|
458
|
+
case "EAI_AGAIN":
|
|
459
|
+
return [checkHost, checkNetwork];
|
|
460
|
+
case "ECONNREFUSED":
|
|
461
|
+
return [
|
|
462
|
+
{
|
|
463
|
+
cause: `Nothing is accepting connections at ${where}.`,
|
|
464
|
+
fix: "Check the address and port, and any proxy that should be answering there.",
|
|
465
|
+
},
|
|
466
|
+
checkHost,
|
|
467
|
+
];
|
|
468
|
+
case "ETIMEDOUT":
|
|
469
|
+
case "ECONNRESET":
|
|
470
|
+
case "ECONNABORTED":
|
|
471
|
+
return [checkNetwork, checkHost];
|
|
472
|
+
case DELIVERY_SDK_UNKNOWN_ERROR:
|
|
473
|
+
// A refused delivery token arrives as this, on a server and in a browser
|
|
474
|
+
// alike — and so does the delivery SDK's own timeout, which a server is
|
|
475
|
+
// more likely to hit. A browser never reports a bad address this way (that
|
|
476
|
+
// is ERR_NETWORK), so there the token and key lead.
|
|
477
|
+
return typeof document === "undefined"
|
|
478
|
+
? [checkNetwork, statuslessRefusalCause, checkHost]
|
|
479
|
+
: [statuslessRefusalCause, checkNetwork, checkHost];
|
|
480
|
+
default:
|
|
481
|
+
// A server sees every status Contentstack sends, so a hidden rejection is
|
|
482
|
+
// not possible there. An unrecognised code is the network or the address.
|
|
483
|
+
if (typeof document === "undefined")
|
|
484
|
+
return [checkNetwork, checkHost];
|
|
485
|
+
// A browser: the transport cannot tell these apart, so all three stay.
|
|
486
|
+
return [
|
|
487
|
+
checkHost,
|
|
488
|
+
{
|
|
489
|
+
cause: "Contentstack may have refused the request, and the browser hid its reply because it carried no CORS header.",
|
|
490
|
+
fix: "Check that the API key and delivery token belong to this stack. The browser's network tab shows the real status.",
|
|
491
|
+
},
|
|
492
|
+
checkNetwork,
|
|
493
|
+
];
|
|
494
|
+
}
|
|
285
495
|
}
|
|
286
496
|
|
|
287
497
|
export { classifyResponseError, diagnoseUnreadableResponse };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classify-response-error.js","sources":["../../src/utils/classify-response-error.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;AAUG;
|
|
1
|
+
{"version":3,"file":"classify-response-error.js","sources":["../../src/utils/classify-response-error.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;AAUG;AAqBH;;;;;;;;;AASG;AACH,SAAS,iBAAiB,CAAC,MAAc,EAAA;AACvC,IAAA,MAAM,YAAY,GAAG;AACnB,QAAA,KAAK,EAAE,2DAA2D;AAClE,QAAA,GAAG,EAAE,oGAAoG;KAC1G;AAED,IAAA,IAAI,MAAM,CAAC,yBAAyB,EAAE;QACpC,OAAO;AACL,YAAA;AACE,gBAAA,KAAK,EAAE,CAAA,SAAA,EAAY,MAAM,CAAC,cAAc,CAAA,oBAAA,CAAsB;AAC9D,gBAAA,GAAG,EAAE,mDAAmD;AACzD,aAAA;YACD,YAAY;SACb;IACH;IAEA,OAAO;AACL,QAAA;YACE,KAAK,EAAE,CAAA,4CAAA,EAA+C,4BAA4B,CAAA,+CAAA,CAAiD;AACnI,YAAA,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AA,MAAM,YAAY,GAAG;QACnB,KAAK,EAAE,CAAA,kCAAA,EAAqC,KAAK,CAAA,8BAAA,CAAgC;AACjF,QAAA,GAAG,EAAE,kGAAkG;KACxG;IAED,QAAQ,aAAa;AACnB,QAAA,KAAK,WAAW;AAChB,QAAA,KAAK,WAAW;AACd,YAAA,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC;AAClC,QAAA,KAAK,cAAc;YACjB,OAAO;AACL,gBAAA;oBACE,KAAK,EAAE,CAAA,oCAAA,EAAuC,KAAK,CAAA,CAAA,CAAG;AACtD,oBAAA,GAAG,EAAE,2EAA2E;AACjF,iBAAA;gBACD,SAAS;aACV;AACH,QAAA,KAAK,WAAW;AAChB,QAAA,KAAK,YAAY;AACjB,QAAA,KAAK,cAAc;AACjB,YAAA,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC;AAClC,QAAA,KAAK,0BAA0B;;;;;YAK7B,OAAO,OAAO,QAAQ,KAAK;AACzB,kBAAE,CAAC,YAAY,EAAE,sBAAsB,EAAE,SAAS;kBAChD,CAAC,sBAAsB,EAAE,YAAY,EAAE,SAAS,CAAC;AACvD,QAAA;;;YAGE,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,gBAAA,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC;;YAErE,OAAO;gBACL,SAAS;AACT,gBAAA;AACE,oBAAA,KAAK,EACH,6GAA6G;AAC/G,oBAAA,GAAG,EAAE,kHAAkH;AACxH,iBAAA;gBACD,YAAY;aACb;;AAEP;;;;"}
|
|
@@ -11,6 +11,13 @@ class ComposableStudioError extends Error {
|
|
|
11
11
|
* `id` is what those sites still carry, and it goes once they have all moved.
|
|
12
12
|
*/
|
|
13
13
|
code;
|
|
14
|
+
/**
|
|
15
|
+
* The one sentence stating what happened, without the code or the causes the
|
|
16
|
+
* message wraps around it. Kept apart so a surface can lay the diagnosis out
|
|
17
|
+
* from its parts instead of cutting the logged text back up. Set together
|
|
18
|
+
* with `code`.
|
|
19
|
+
*/
|
|
20
|
+
headline;
|
|
14
21
|
/**
|
|
15
22
|
* What to do, ordered, most likely first. One entry means we proved the
|
|
16
23
|
* cause; more than one means we are ranking and the reader should work down
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composable-studio-error.js","sources":["../../src/utils/composable-studio-error.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAoCM,MAAO,qBAAsB,SAAQ,KAAK,CAAA;AAC9C,IAAA,OAAO;AAEP;;;;;;;AAOG;AACH,IAAA,IAAI;AAEJ;;;;AAIG;AACH,IAAA,MAAM;;AAGN,IAAA,OAAO;AACP;;;;AAIG;AACH,IAAA,QAAQ;AAER;;;;;AAKG;AACH,IAAA,IAAI,UAAU,GAAA;AACZ,QAAA,OAAO,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS;IACvD;IAEA,WAAA,CAAY,OAAe,EAAE,OAAsC,EAAA;QACjE,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;IACxB;AACD;AACD;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"composable-studio-error.js","sources":["../../src/utils/composable-studio-error.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAoCM,MAAO,qBAAsB,SAAQ,KAAK,CAAA;AAC9C,IAAA,OAAO;AAEP;;;;;;;AAOG;AACH,IAAA,IAAI;AAEJ;;;;;AAKG;AACH,IAAA,QAAQ;AAER;;;;AAIG;AACH,IAAA,MAAM;;AAGN,IAAA,OAAO;AACP;;;;AAIG;AACH,IAAA,QAAQ;AAER;;;;;AAKG;AACH,IAAA,IAAI,UAAU,GAAA;AACZ,QAAA,OAAO,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS;IACvD;IAEA,WAAA,CAAY,OAAe,EAAE,OAAsC,EAAA;QACjE,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;IACxB;AACD;AACD;AACA;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { has, get, isEqual, isPlainObject } from 'lodash-es';
|
|
2
2
|
import { isNotEqual, doesArrayInclude, isLessThanOrEqual, isLessThan, isGreaterThanOrEqual, isGreaterThan } from './condition-block.utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getResolvedBindingString, getRepeaterContextPath } from '@contentstack/studio-registry';
|
|
4
4
|
|
|
5
5
|
const EXISTENCE_OPERATOR_VALUES = new Set(["exists", "notExists"]);
|
|
6
6
|
const EMPTINESS_OPERATOR_VALUES = new Set(["isEmpty", "isNotEmpty"]);
|
|
@@ -40,7 +40,7 @@ const evaluateCondition = (condition, data) => {
|
|
|
40
40
|
if (!condition?.conditionBinding) {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
|
-
const bindingString =
|
|
43
|
+
const bindingString = getResolvedBindingString(condition?.conditionBinding, data);
|
|
44
44
|
// Existence and emptiness mean the same thing for every subject type, so they
|
|
45
45
|
// are answered BEFORE the type switch — otherwise each would need a case in
|
|
46
46
|
// all nine arms, and the array/reference/image arms would swallow them
|
|
@@ -86,7 +86,13 @@ const evaluateCondition = (condition, data) => {
|
|
|
86
86
|
case "endsWith":
|
|
87
87
|
return compareValue.endsWith(conditionValueString);
|
|
88
88
|
case "matches":
|
|
89
|
-
|
|
89
|
+
// A pattern that is not a valid regular expression matches nothing.
|
|
90
|
+
try {
|
|
91
|
+
return new RegExp(condition.value).test(strValue);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
90
96
|
case "eq":
|
|
91
97
|
return isEqual(compareValue, conditionValueString);
|
|
92
98
|
case "neq":
|
|
@@ -143,7 +149,14 @@ const evaluateCondition = (condition, data) => {
|
|
|
143
149
|
return false;
|
|
144
150
|
}
|
|
145
151
|
case "image_extension": {
|
|
146
|
-
|
|
152
|
+
// The bound file: its url / filename, or the string itself. Anything else
|
|
153
|
+
// has no extension to compare.
|
|
154
|
+
const fileName = typeof conditionValue === "string"
|
|
155
|
+
? conditionValue
|
|
156
|
+
: (conditionValue?.filename ?? conditionValue?.url);
|
|
157
|
+
if (typeof fileName !== "string")
|
|
158
|
+
return false;
|
|
159
|
+
const extension = fileName.split(".").pop();
|
|
147
160
|
switch (condition.operator) {
|
|
148
161
|
case "is":
|
|
149
162
|
case "eq":
|
|
@@ -155,7 +168,7 @@ const evaluateCondition = (condition, data) => {
|
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
170
|
case "image_size": {
|
|
158
|
-
const imageSize = parseInt(conditionValue
|
|
171
|
+
const imageSize = parseInt(conditionValue?.file_size || "0");
|
|
159
172
|
return handleNumberComparison(condition.operator, imageSize, condition.value);
|
|
160
173
|
}
|
|
161
174
|
case "reference": {
|
|
@@ -216,7 +229,7 @@ const resolveConditionScope = (condition, data) => {
|
|
|
216
229
|
if (!shouldRender)
|
|
217
230
|
return { shouldRender, scopedData: data };
|
|
218
231
|
const binding = condition?.dataBinding;
|
|
219
|
-
const dataPath = binding &&
|
|
232
|
+
const dataPath = binding && getResolvedBindingString(binding, data);
|
|
220
233
|
const repeaterPath = binding &&
|
|
221
234
|
getRepeaterContextPath(binding.value);
|
|
222
235
|
if (!dataPath || !repeaterPath || dataPath === repeaterPath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditionBlock.js","sources":["../../src/utils/conditionBlock.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAqBA,MAAM,yBAAyB,GAC7B,IAAI,GAAG,CAAoB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAErD,MAAM,yBAAyB,GAC7B,IAAI,GAAG,CAAoB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAEvD;;;;;AAKG;AACH,MAAM,wBAAwB,GAAwB,IAAI,GAAG,CAAS;AACpE,IAAA,GAAG,yBAAyB;AAC5B,IAAA,GAAG,yBAAyB;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AA,KAAK,KAAK;AACR,YAAA,OAAO,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1C,QAAA;AACE,YAAA,OAAO,KAAK;;AAElB;;;;"}
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export { IS_BROWSER } from '@contentstack/studio-messenger';
|
|
1
|
+
export { IS_BROWSER } from '@contentstack/studio-messenger/constants';
|
|
2
2
|
|
|
3
|
+
// From the constants entry, not the package root: the root carries the
|
|
4
|
+
// postMessage bridge (advanced-post-message), and the build leaves a bare import
|
|
5
|
+
// of whatever this re-exports from in every module that imports a constant here.
|
|
3
6
|
const isBrowser = () => {
|
|
4
7
|
return typeof window !== "undefined" && typeof global === "undefined";
|
|
5
8
|
};
|
|
@@ -22,7 +25,7 @@ const isBrowser = () => {
|
|
|
22
25
|
*/
|
|
23
26
|
const INCLUDE_DEPTH_COUNT = 3;
|
|
24
27
|
// SDK Version constants for Studio Intelligence
|
|
25
|
-
const SDK_VERSION = "4.
|
|
28
|
+
const SDK_VERSION = "4.2.0-alpha-d1a6053.0";
|
|
26
29
|
/**
|
|
27
30
|
* Version of the composition spec this SDK writes and reads.
|
|
28
31
|
*
|
|
@@ -56,6 +59,8 @@ const COMPOSABLE_DATA_ATTRIBUTES = {
|
|
|
56
59
|
PERMANENT_DROP_ZONE_DIRECTION: "data-composable-studio-permanent-drop-zone-direction",
|
|
57
60
|
/** Marks the permanent drop zone a drag is currently targeting. */
|
|
58
61
|
PERMANENT_DROP_ZONE_TARGETED: "data-composable-studio-permanent-drop-zone-targeted",
|
|
62
|
+
/** Marks an empty slot's placeholder while the slot or its owner is selected. */
|
|
63
|
+
SLOT_SELECTED: "data-composable-studio-slot-selected",
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
export { COMPOSABLE_DATA_ATTRIBUTES, INCLUDE_DEPTH_COUNT, SCHEMA_VERSION, SDK_VERSION, isBrowser };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/utils/constants.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/utils/constants.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;AACA;AAGO,MAAM,SAAS,GAAG,MAAK;IAC5B,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW;AACvE;AAEA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,mBAAmB,GAAG;AAEnC;MACa,WAAW,GAAG;AAC3B;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,cAAc,GAAG;AAEvB,MAAM,0BAA0B,GAAG;AACxC,IAAA,OAAO,EAAE,gCAAgC;AACzC,IAAA,WAAW,EAAE,oCAAoC;AACjD,IAAA,IAAI,EAAE,6BAA6B;AACnC,IAAA,IAAI,EAAE,6BAA6B;AACnC,IAAA,IAAI,EAAE,6BAA6B;AACnC,IAAA,EAAE,EAAE,2BAA2B;AAC/B,IAAA,QAAQ,EAAE,iCAAiC;AAC3C,IAAA,IAAI,EAAE,WAAW;;AAEjB,IAAA,6BAA6B,EAC3B,sDAAsD;;AAExD,IAAA,4BAA4B,EAC1B,qDAAqD;;AAEvD,IAAA,aAAa,EAAE,sCAAsC;;;;;"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
5
|
const HttpStatus = {
|
|
6
|
+
BAD_REQUEST: 400,
|
|
7
|
+
UNAUTHORIZED: 401,
|
|
6
8
|
PRECONDITION_FAILED: 412,
|
|
7
9
|
NOT_FOUND: 404,
|
|
8
10
|
UNPROCESSABLE_ENTITY: 422};
|
|
@@ -11,6 +13,7 @@ const HttpStatus = {
|
|
|
11
13
|
* @internal
|
|
12
14
|
*/
|
|
13
15
|
const ContentstackErrorCode = {
|
|
16
|
+
INVALID_CREDENTIALS: 105,
|
|
14
17
|
/** No stack answers to this API key on this host. Arrives as 412/109. */
|
|
15
18
|
STACK_NOT_FOUND: 109,
|
|
16
19
|
/** The queried content type is not on the stack. Arrives as 422/118. */
|
|
@@ -21,7 +24,27 @@ const ContentstackErrorCode = {
|
|
|
21
24
|
* The name records the meaning an unmatched instance falls back to.
|
|
22
25
|
*/
|
|
23
26
|
ENTRY_NOT_FOUND: 141,
|
|
27
|
+
/**
|
|
28
|
+
* The live preview session belongs to a different stack from the request's API
|
|
29
|
+
* key. Arrives as 400/382 from the preview host, and its message names both keys.
|
|
30
|
+
*/
|
|
31
|
+
PREVIEW_STACK_MISMATCH: 382,
|
|
32
|
+
/**
|
|
33
|
+
* Overloaded like 141 and separated only by `error_message`, which names what
|
|
34
|
+
* it refused: "…on this branch '<name>'" / "…on this language '<code>'".
|
|
35
|
+
* Arrives as 422/901 from the delivery and preview hosts for a branch the
|
|
36
|
+
* stack does not have, and from the preview host for a missing language.
|
|
37
|
+
*/
|
|
38
|
+
ACCESS_DENIED: 901,
|
|
24
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* The code the delivery SDK puts on an error it could not describe. It is what a
|
|
42
|
+
* refused delivery token (401) arrives as: the delivery SDK retries the 401 like a
|
|
43
|
+
* rate limit, then rejects with the reply body alone, so its error carries status 0
|
|
44
|
+
* and this code. A request that never got a reply carries a network code instead.
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
const DELIVERY_SDK_UNKNOWN_ERROR = "UNKNOWN_ERROR";
|
|
25
48
|
/**
|
|
26
49
|
* Node.js / network error codes that indicate connection failures.
|
|
27
50
|
* @internal
|
|
@@ -67,5 +90,5 @@ function isNetworkError(err) {
|
|
|
67
90
|
return false;
|
|
68
91
|
}
|
|
69
92
|
|
|
70
|
-
export { ContentstackErrorCode, HttpStatus, NETWORK_ERROR_CODES, NETWORK_ERROR_TYPE, NetworkErrorCode, getStatusCode, isNetworkError };
|
|
93
|
+
export { ContentstackErrorCode, DELIVERY_SDK_UNKNOWN_ERROR, HttpStatus, NETWORK_ERROR_CODES, NETWORK_ERROR_TYPE, NetworkErrorCode, getStatusCode, isNetworkError };
|
|
71
94
|
//# sourceMappingURL=http-error.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-error.constants.js","sources":["../../src/utils/http-error.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AAEI,MAAM,UAAU,GAAG;AACxB,
|
|
1
|
+
{"version":3,"file":"http-error.constants.js","sources":["../../src/utils/http-error.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AAEI,MAAM,UAAU,GAAG;AACxB,IAAA,WAAW,EAAE,GAAG;AAChB,IAAA,YAAY,EAAE,GAAG;AACjB,IAAA,mBAAmB,EAAE,GAAG;AACxB,IACA,SAAS,EAAE,GAAG;AACd,IAAA,oBAAoB,EAAE;AAKxB;;;AAGG;AACI,MAAM,qBAAqB,GAAG;AACnC,IACA,mBAAmB,EAAE,GAAG;;AAExB,IAAA,eAAe,EAAE,GAAG;;AAEpB,IAAA,sBAAsB,EAAE,GAAG;AAC3B;;;;AAIG;AACH,IAAA,eAAe,EAAE,GAAG;AACpB;;;AAGG;AACH,IAAA,sBAAsB,EAAE,GAAG;AAC3B;;;;;AAKG;AACH,IAAA,aAAa,EAAE,GAAG;;AAGpB;;;;;;AAMG;AACI,MAAM,0BAA0B,GAAG;AAE1C;;;AAGG;AACI,MAAM,gBAAgB,GAAG;AAC9B,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,SAAS,EAAE,WAAW;;AAGjB,MAAM,mBAAmB,GAAG;AACjC,IAAA,gBAAgB,CAAC,SAAS;AAC1B,IAAA,gBAAgB,CAAC,YAAY;AAC7B,IAAA,gBAAgB,CAAC,SAAS;;AAGrB,MAAM,kBAAkB,GAAG;AAElC;;;AAGG;AACG,SAAU,aAAa,CAAC,GAAQ,EAAA;IACpC,MAAM,IAAI,GAAG,GAAG,EAAE,MAAM,IAAI,GAAG,EAAE,UAAU;AAC3C,IAAA,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS;AAC7E;AAmDA;;;AAGG;AACG,SAAU,cAAc,CAAC,GAAQ,EAAA;AACrC,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,KAAK;AACtB,IAAA,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI;AACtB,IAAA,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI;;AAGtB,IAAA,IACE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,mBAAmB,CAAC,QAAQ,CAAC,IAAW,CAAC;QACtE,IAAI,KAAK,kBAAkB,EAC3B;AACA,QAAA,OAAO,IAAI;IACb;;;AAIA,IAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;AAC5D,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,OAAO,KAAK;AACd;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DATA_SOURCES } from '@contentstack/studio-registry';
|
|
1
|
+
import { DATA_SOURCES, withoutFirstOfTypeSegments } from '@contentstack/studio-registry';
|
|
2
2
|
import { getBindingStringForCS } from './sdk.js';
|
|
3
3
|
|
|
4
4
|
const EMPTY_INDEX = {
|
|
@@ -28,7 +28,8 @@ function indexModularBlocks(ui) {
|
|
|
28
28
|
if (node.type === "repeater" && node.uid) {
|
|
29
29
|
const binding = node.props?.items?.binding;
|
|
30
30
|
if (binding?.type === DATA_SOURCES.TEMPLATE) {
|
|
31
|
-
|
|
31
|
+
// A first-of-type segment names no field (COMS-2484).
|
|
32
|
+
const field = withoutFirstOfTypeSegments(getBindingStringForCS(binding));
|
|
32
33
|
if (field)
|
|
33
34
|
repeaterField.set(node.uid, field);
|
|
34
35
|
}
|