@contentstack/studio-client 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/breakpoints/BreakpointManager.js +7 -5
- package/dist/breakpoints/BreakpointManager.js.map +1 -1
- package/dist/breakpoints/breakpoint.js +3 -2
- package/dist/breakpoints/breakpoint.js.map +1 -1
- package/dist/canvas/canvas.utils.js +13 -1
- package/dist/canvas/canvas.utils.js.map +1 -1
- package/dist/composable-studio/build-scoped-data.js +53 -31
- package/dist/composable-studio/build-scoped-data.js.map +1 -1
- package/dist/composable-studio/collect-data-needs.js +22 -4
- package/dist/composable-studio/collect-data-needs.js.map +1 -1
- package/dist/composable-studio/sdk.js +1288 -453
- package/dist/composable-studio/sdk.js.map +1 -1
- package/dist/composable-studio/section-data.js +316 -0
- package/dist/composable-studio/section-data.js.map +1 -0
- package/dist/composable-studio/studio-intelligence.manager.js +5 -2
- package/dist/composable-studio/studio-intelligence.manager.js.map +1 -1
- package/dist/config/config.schema.js +45 -8
- package/dist/config/config.schema.js.map +1 -1
- package/dist/config/default-config.js +10 -3
- package/dist/config/default-config.js.map +1 -1
- package/dist/config/process-user-config.js +37 -1
- package/dist/config/process-user-config.js.map +1 -1
- package/dist/config/stack-sdk-wrapper.js +71 -2
- package/dist/config/stack-sdk-wrapper.js.map +1 -1
- package/dist/context-menu/context-menu.js +5 -2
- package/dist/context-menu/context-menu.js.map +1 -1
- package/dist/design/handle-active-style-change.js +3 -2
- package/dist/design/handle-active-style-change.js.map +1 -1
- package/dist/dnd/dnd-event.js +2 -1
- package/dist/dnd/dnd-event.js.map +1 -1
- package/dist/dnd/dnd-manager.js +3 -1
- package/dist/dnd/dnd-manager.js.map +1 -1
- package/dist/editor.d.ts +250 -0
- package/dist/editor.js +11 -0
- package/dist/editor.js.map +1 -0
- package/dist/get-active-node-screenshot/get-node-screenshot-event.js +2 -1
- package/dist/get-active-node-screenshot/get-node-screenshot-event.js.map +1 -1
- package/dist/hidden-element-notification/hidden-element-notification-event.js +2 -1
- package/dist/hidden-element-notification/hidden-element-notification-event.js.map +1 -1
- package/dist/highlight-node/highlight-node-manager.js +225 -15
- package/dist/highlight-node/highlight-node-manager.js.map +1 -1
- package/dist/highlight-node/highlight-node.js +42 -6
- package/dist/highlight-node/highlight-node.js.map +1 -1
- package/dist/highlight-spacing/highlight-spacing-events.js +2 -1
- package/dist/highlight-spacing/highlight-spacing-events.js.map +1 -1
- package/dist/index.d.ts +1334 -467
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/url-change/url-change.js +4 -3
- package/dist/url-change/url-change.js.map +1 -1
- package/dist/url-metadata/build-template-query.js +27 -6
- package/dist/url-metadata/build-template-query.js.map +1 -1
- package/dist/utils/canvas.js +2 -1
- package/dist/utils/canvas.js.map +1 -1
- package/dist/utils/check-bindings.js +233 -0
- package/dist/utils/check-bindings.js.map +1 -0
- package/dist/utils/classify-response-error.js +288 -0
- package/dist/utils/classify-response-error.js.map +1 -0
- package/dist/utils/composable-studio-error.js +36 -20
- package/dist/utils/composable-studio-error.js.map +1 -1
- package/dist/utils/composition-not-found.js +52 -0
- package/dist/utils/composition-not-found.js.map +1 -0
- package/dist/utils/conditionBlock.js +80 -3
- package/dist/utils/conditionBlock.js.map +1 -1
- package/dist/utils/constants.js +21 -2
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/degraded-finding.js +166 -0
- package/dist/utils/degraded-finding.js.map +1 -0
- package/dist/utils/editor-mode.js +1 -1
- package/dist/utils/http-error.constants.js +12 -46
- package/dist/utils/http-error.constants.js.map +1 -1
- package/dist/utils/include-path-rules.js +141 -0
- package/dist/utils/include-path-rules.js.map +1 -0
- package/dist/utils/is-composition-being-edited.js +1 -1
- package/dist/utils/is-inside-iframe.js +1 -1
- package/dist/utils/is-inside-visual-builder-frame.js +1 -1
- package/dist/utils/parse-ui.js +60 -0
- package/dist/utils/parse-ui.js.map +1 -0
- package/dist/utils/query-param.js +1 -1
- package/dist/utils/query-param.js.map +1 -1
- package/dist/utils/query-url-budget.js +79 -0
- package/dist/utils/query-url-budget.js.map +1 -0
- package/dist/utils/reference-stub.js +75 -0
- package/dist/utils/reference-stub.js.map +1 -0
- package/dist/utils/reference_fetcher.js +59 -4
- package/dist/utils/reference_fetcher.js.map +1 -1
- package/dist/utils/require-stack.js +141 -0
- package/dist/utils/require-stack.js.map +1 -0
- package/dist/utils/served-by.js +33 -0
- package/dist/utils/served-by.js.map +1 -0
- package/dist/utils/spec-analyzer.js +2 -2
- package/dist/utils/spec-analyzer.js.map +1 -1
- package/dist/utils/studio-error-codes.js +253 -0
- package/dist/utils/studio-error-codes.js.map +1 -0
- package/dist/utils/studio-error.js +122 -0
- package/dist/utils/studio-error.js.map +1 -0
- package/dist/utils/studio-messaging.js +25 -0
- package/dist/utils/studio-messaging.js.map +1 -0
- package/dist/visual-builder/composition-save-event.js +2 -1
- package/dist/visual-builder/composition-save-event.js.map +1 -1
- package/package.json +19 -7
- package/LICENSE +0 -21
- package/dist/utils/error-messages.default.js +0 -141
- package/dist/utils/error-messages.default.js.map +0 -1
- package/dist/utils/error-messages.js +0 -47
- package/dist/utils/error-messages.js.map +0 -1
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/** Binding `type` for a path into the page's template entry. */
|
|
2
|
+
const TEMPLATE_BINDING_TYPE = "template";
|
|
3
|
+
/**
|
|
4
|
+
* Split a dotted field path into binding-path segments, dropping the array
|
|
5
|
+
* indices and modular-block numeric prefixes that are not data keys. Mirrors
|
|
6
|
+
* `sanitizeFieldPath` in sdk.ts — kept local so this module stays dependency-free
|
|
7
|
+
* and usable from Studio.
|
|
8
|
+
*/
|
|
9
|
+
function splitFieldPath(path) {
|
|
10
|
+
return path
|
|
11
|
+
.split(".")
|
|
12
|
+
.map((seg) => seg.replace(/\[\d+\]$/, "").replace(/^\d+_/, ""))
|
|
13
|
+
.filter((seg) => seg.length > 0 && !/^\d+$/.test(seg) && seg !== "entries");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Nest dotted path segments into the object shape a binding `value.path` uses:
|
|
17
|
+
* `["a", "b"]` → `{ a: { b: {} } }`. An empty path nests to `{}`, which is what
|
|
18
|
+
* a scope-root binding carries.
|
|
19
|
+
*/
|
|
20
|
+
function nestPath(segments) {
|
|
21
|
+
let nested = {};
|
|
22
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
23
|
+
nested = { [segments[i]]: nested };
|
|
24
|
+
}
|
|
25
|
+
return nested;
|
|
26
|
+
}
|
|
27
|
+
/** The inverse of {@link nestPath}: walk the single-key chain back to segments. */
|
|
28
|
+
function flattenPath(path) {
|
|
29
|
+
const segments = [];
|
|
30
|
+
let current = path;
|
|
31
|
+
while (current && typeof current === "object") {
|
|
32
|
+
const keys = Object.keys(current);
|
|
33
|
+
if (keys.length !== 1 || keys[0] === "")
|
|
34
|
+
break;
|
|
35
|
+
// A key may itself be a DOTTED path. Template bindings nest one segment per
|
|
36
|
+
// level (`{ a: { b: {} } }`), but a contentstack binding stores the whole
|
|
37
|
+
// path as a single key (`{ "page_sections.17.keynote_speakers": {} }`).
|
|
38
|
+
// Field uids cannot contain a dot, so splitting is unambiguous — and
|
|
39
|
+
// without it the entire path arrives as one opaque segment.
|
|
40
|
+
for (const part of keys[0].split(".")) {
|
|
41
|
+
if (part)
|
|
42
|
+
segments.push(part);
|
|
43
|
+
}
|
|
44
|
+
current = current[keys[0]];
|
|
45
|
+
}
|
|
46
|
+
return segments;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the template-typed Section data equivalent to a legacy `selectedField`.
|
|
50
|
+
*
|
|
51
|
+
* This is the whole migration: every placement saved before the Section data
|
|
52
|
+
* existed resolves to exactly the binding it behaved as, derived on read. No
|
|
53
|
+
* stored data changes.
|
|
54
|
+
*/
|
|
55
|
+
function synthesizeTemplateRootBinding(selectedField) {
|
|
56
|
+
return {
|
|
57
|
+
type: TEMPLATE_BINDING_TYPE,
|
|
58
|
+
value: { path: nestPath(splitFieldPath(selectedField ?? "")) },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Whether a resolved Section data means "deliberately cleared". */
|
|
62
|
+
function isDataRootCleared(root) {
|
|
63
|
+
return root === null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether a Section data points into the page's template entry — the only kind
|
|
67
|
+
* that extends a page-template prefix. A contentstack / query / repeater-typed
|
|
68
|
+
* root names its own document instead (see ADR 0017's fetch root).
|
|
69
|
+
*/
|
|
70
|
+
function isTemplateRootBinding(root) {
|
|
71
|
+
return !!root && root.type === TEMPLATE_BINDING_TYPE;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The path a Section data addresses **within the scope its placement already
|
|
75
|
+
* inherits** — the page template entry for a `template` root, the live
|
|
76
|
+
* iteration item for a `repeater` one (ADR 0006).
|
|
77
|
+
*
|
|
78
|
+
* This is what the renderer means by `selectedField`: the provider scopes the
|
|
79
|
+
* enclosing repeater item (or the template entry) by it. A root naming ANOTHER
|
|
80
|
+
* document carries its path in the fetch root's `prefix` instead, so it has no
|
|
81
|
+
* scope path — the two are never both in play.
|
|
82
|
+
*
|
|
83
|
+
* The `template`-only version of this test is what left a repeater-relative
|
|
84
|
+
* root unusable: its path (`hero_card` inside the item) was dropped on the way
|
|
85
|
+
* to the renderer, every iteration scoped to the whole item, and the section
|
|
86
|
+
* rendered component defaults.
|
|
87
|
+
*/
|
|
88
|
+
function getRootScopePath(root) {
|
|
89
|
+
if (!root)
|
|
90
|
+
return [];
|
|
91
|
+
if (root.type === TEMPLATE_BINDING_TYPE || root.type === "repeater") {
|
|
92
|
+
return getRootBindingPath(root);
|
|
93
|
+
}
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The dotted path a Section data addresses *within* its document.
|
|
98
|
+
*
|
|
99
|
+
* For a template root this is the old `selectedField`. For a contentstack root
|
|
100
|
+
* the first segment is the `<ct>:<uid>` pool key, which names the **document**
|
|
101
|
+
* rather than a field inside it — callers that need the in-document path must
|
|
102
|
+
* drop it (`dropDocumentSegment`).
|
|
103
|
+
*/
|
|
104
|
+
function getRootBindingPath(root) {
|
|
105
|
+
if (!root)
|
|
106
|
+
return [];
|
|
107
|
+
const value = root.value;
|
|
108
|
+
return flattenPath(value?.path);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The legacy `selectedField` ladder, verbatim: per-instance override → legacy
|
|
112
|
+
* `metadata.selectedField` → the `linked_schemas` default for the page content
|
|
113
|
+
* type → the first schema.
|
|
114
|
+
*
|
|
115
|
+
* Extracted so the Section data resolver and the existing page-template
|
|
116
|
+
* projection read the SAME ladder and cannot drift. Returns the path
|
|
117
|
+
* **unsanitised** — callers that need CDA-safe segments sanitise at the point
|
|
118
|
+
* of use, exactly as they did before the Section data existed.
|
|
119
|
+
*/
|
|
120
|
+
function resolveLegacySelectedField(node, linkedSchemasFor, pageContentTypeUid) {
|
|
121
|
+
return resolveLegacySelectedFieldWithProvenance(node, linkedSchemasFor, pageContentTypeUid).field;
|
|
122
|
+
}
|
|
123
|
+
function resolveLegacySelectedFieldWithProvenance(node, linkedSchemasFor, pageContentTypeUid) {
|
|
124
|
+
const override = node.metadata?.sectionBindingOverride;
|
|
125
|
+
if (typeof override?.selectedField === "string") {
|
|
126
|
+
return { field: override.selectedField, provenance: "override" };
|
|
127
|
+
}
|
|
128
|
+
if (typeof node.metadata?.selectedField === "string") {
|
|
129
|
+
return { field: node.metadata.selectedField, provenance: "legacy" };
|
|
130
|
+
}
|
|
131
|
+
const linked = linkedSchemasFor(node.metadata?.compositionUID) || [];
|
|
132
|
+
const declared = linked.find((s) => s.content_type_uid === pageContentTypeUid)
|
|
133
|
+
?.selected_field ??
|
|
134
|
+
linked[0]?.selected_field ??
|
|
135
|
+
"";
|
|
136
|
+
return { field: declared || "", provenance: "declared" };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Whether a resolved field is rooted at the page entry rather than at an
|
|
140
|
+
* enclosing wrapper section. A page-absolute field must REPLACE the inherited
|
|
141
|
+
* prefix, never be concatenated onto it.
|
|
142
|
+
*
|
|
143
|
+
* A scope-root field ("") is neither — it adds no segment either way — so it is
|
|
144
|
+
* reported as not absolute to keep the inherited prefix intact.
|
|
145
|
+
*/
|
|
146
|
+
function isPageAbsoluteField(field, provenance) {
|
|
147
|
+
if (!field)
|
|
148
|
+
return false;
|
|
149
|
+
return provenance === "declared" || provenance === "legacy";
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolve a section-composition node's effective **Section data**.
|
|
153
|
+
*
|
|
154
|
+
* Resolution order — the existing `selectedField` ladder with one tier added on
|
|
155
|
+
* top, so this is strictly a superset of today's behaviour:
|
|
156
|
+
*
|
|
157
|
+
* 1. `sectionBindingOverride.rootBinding` when the key is PRESENT (including
|
|
158
|
+
* an explicit `null`, which means cleared)
|
|
159
|
+
* 2. otherwise synthesise a template-typed binding from the legacy
|
|
160
|
+
* `selectedField` ladder: override → `metadata.selectedField` →
|
|
161
|
+
* `linked_schemas` default for the page content type → first schema
|
|
162
|
+
*
|
|
163
|
+
* The caller MUST NOT write the result back onto the node. Persisted state is
|
|
164
|
+
* structurally diffed against the save baseline (ADR 0007), so persisting a
|
|
165
|
+
* derived value would mark every pre-existing page dirty the moment it opens,
|
|
166
|
+
* and would freeze a live fallback into a copy.
|
|
167
|
+
*/
|
|
168
|
+
function resolveInstanceRootBinding(node, linkedSchemasFor, pageContentTypeUid) {
|
|
169
|
+
const override = node.metadata?.sectionBindingOverride;
|
|
170
|
+
// Presence, not truthiness — `null` is a real, distinct state.
|
|
171
|
+
if (override && "rootBinding" in override) {
|
|
172
|
+
return override.rootBinding;
|
|
173
|
+
}
|
|
174
|
+
// Seeding from `linked_schemas` only makes sense where a page template entry
|
|
175
|
+
// EXISTS to resolve the derived path against. A freeform composition has no
|
|
176
|
+
// connected content type, so a synthesised template root can never resolve —
|
|
177
|
+
// and worse, it renders in the Section data picker as though the placement were
|
|
178
|
+
// already bound (the label is the last path segment, e.g. "Page Sections"),
|
|
179
|
+
// so an author sees a bound control and no data with nothing to act on.
|
|
180
|
+
//
|
|
181
|
+
// Freeform placements therefore start genuinely EMPTY, which is also what the
|
|
182
|
+
// feature was asked for: the template seeds itself, freeform is picked by the
|
|
183
|
+
// page composer.
|
|
184
|
+
if (!pageContentTypeUid)
|
|
185
|
+
return undefined;
|
|
186
|
+
return synthesizeTemplateRootBinding(resolveLegacySelectedField(node, linkedSchemasFor, pageContentTypeUid));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Which `linked_schemas` entry a placement is bound to.
|
|
190
|
+
*
|
|
191
|
+
* Prefers the persisted `matchedSchemaCt` (the only answer available on a
|
|
192
|
+
* freeform page), falling back to matching the page content type the way the
|
|
193
|
+
* template path always has.
|
|
194
|
+
*/
|
|
195
|
+
function resolveMatchedSchema(node, linkedSchemas, pageContentTypeUid) {
|
|
196
|
+
const linked = linkedSchemas || [];
|
|
197
|
+
if (linked.length === 0)
|
|
198
|
+
return undefined;
|
|
199
|
+
const matchedCt = node.metadata?.sectionBindingOverride?.matchedSchemaCt;
|
|
200
|
+
if (matchedCt) {
|
|
201
|
+
const byMatch = linked.find((s) => s.content_type_uid === matchedCt);
|
|
202
|
+
if (byMatch)
|
|
203
|
+
return byMatch;
|
|
204
|
+
}
|
|
205
|
+
return (linked.find((s) => s.content_type_uid === pageContentTypeUid) ?? linked[0]);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Deep-compare two Section datas. Used by the stamp pass, which must compare a
|
|
209
|
+
* DERIVED binding against a DERIVED binding: comparing a `BindingType` object
|
|
210
|
+
* against a raw `selectedField` string never matches, so every template
|
|
211
|
+
* placement would stamp and every old page would go dirty on open.
|
|
212
|
+
*/
|
|
213
|
+
function sectionDataEqual(a, b) {
|
|
214
|
+
if (a === b)
|
|
215
|
+
return true;
|
|
216
|
+
if (a == null || b == null)
|
|
217
|
+
return a === b;
|
|
218
|
+
if (a.type !== b.type)
|
|
219
|
+
return false;
|
|
220
|
+
return stableStringify(a.value) === stableStringify(b.value);
|
|
221
|
+
}
|
|
222
|
+
function stableStringify(value) {
|
|
223
|
+
if (value === null || typeof value !== "object")
|
|
224
|
+
return JSON.stringify(value);
|
|
225
|
+
if (Array.isArray(value))
|
|
226
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
227
|
+
const keys = Object.keys(value).sort();
|
|
228
|
+
return `{${keys
|
|
229
|
+
.map((k) => `${JSON.stringify(k)}:${stableStringify(value[k])}`)
|
|
230
|
+
.join(",")}}`;
|
|
231
|
+
}
|
|
232
|
+
const TEMPLATE_FETCH_ROOT_KEY = "template";
|
|
233
|
+
const templateFetchRoot = (prefix = []) => ({
|
|
234
|
+
key: TEMPLATE_FETCH_ROOT_KEY,
|
|
235
|
+
prefix,
|
|
236
|
+
});
|
|
237
|
+
/** Whether a fetch-root key names the page template entry. */
|
|
238
|
+
function isTemplateFetchRoot(key) {
|
|
239
|
+
return key === TEMPLATE_FETCH_ROOT_KEY;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Parse a `<ct>:<uid>` fetch-root key back into its parts. Returns null for the
|
|
243
|
+
* template root and for query roots, neither of which is an entry.
|
|
244
|
+
*/
|
|
245
|
+
function parseEntryFetchRootKey(key) {
|
|
246
|
+
if (isTemplateFetchRoot(key) || key.startsWith("query:"))
|
|
247
|
+
return null;
|
|
248
|
+
const idx = key.indexOf(":");
|
|
249
|
+
if (idx <= 0 || idx === key.length - 1)
|
|
250
|
+
return null;
|
|
251
|
+
return {
|
|
252
|
+
contentTypeUid: key.slice(0, idx),
|
|
253
|
+
entryUid: key.slice(idx + 1),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Derive the fetch root a Section data addresses.
|
|
258
|
+
*
|
|
259
|
+
* The first path segment of a non-template binding names the **document**, not
|
|
260
|
+
* a field inside it, so it becomes the key and is dropped from the prefix:
|
|
261
|
+
*
|
|
262
|
+
* { contentstack, path: { "mkt_ct:blt1": { banner: {} } } }
|
|
263
|
+
* → { key: "mkt_ct:blt1", prefix: ["banner"] }
|
|
264
|
+
*
|
|
265
|
+
* A `repeater`-typed root inherits the enclosing document: the repeater re-scopes
|
|
266
|
+
* per iteration at render time, but the includes still belong to whichever
|
|
267
|
+
* document the repeater's own source was fetched from.
|
|
268
|
+
*
|
|
269
|
+
* Returns `inherited` unchanged for a cleared root — there is nothing to fetch,
|
|
270
|
+
* so nothing should be re-anchored.
|
|
271
|
+
*/
|
|
272
|
+
function fetchRootFromBinding(root, inherited) {
|
|
273
|
+
if (!root)
|
|
274
|
+
return inherited;
|
|
275
|
+
const path = getRootBindingPath(root);
|
|
276
|
+
if (root.type === TEMPLATE_BINDING_TYPE) {
|
|
277
|
+
return templateFetchRoot(path);
|
|
278
|
+
}
|
|
279
|
+
if (root.type === "repeater") {
|
|
280
|
+
return inherited;
|
|
281
|
+
}
|
|
282
|
+
// A contentstack binding identifies its document on `value` — NOT in the
|
|
283
|
+
// path. `{ uid, _content_type_uid, path: { "page_sections.17.keynote_speakers": {} } }`
|
|
284
|
+
// means "entry alpha_page:blt… , at that path inside it". Deriving the key
|
|
285
|
+
// from the first path segment instead produced a document key of
|
|
286
|
+
// `page_sections`, so nothing resolved and the section rendered no data.
|
|
287
|
+
const value = (root.value ?? {});
|
|
288
|
+
if (root.type === "contentstack") {
|
|
289
|
+
const ct = value._content_type_uid ?? value.content_type_uid;
|
|
290
|
+
if (ct && value.uid)
|
|
291
|
+
return { key: `${ct}:${value.uid}`, prefix: path };
|
|
292
|
+
// Older/looser shapes put the `ct:uid` composite in the first segment.
|
|
293
|
+
if (path.length === 0)
|
|
294
|
+
return inherited;
|
|
295
|
+
const [documentSegment, ...rest] = path;
|
|
296
|
+
return { key: documentSegment, prefix: rest };
|
|
297
|
+
}
|
|
298
|
+
if (root.type === "contentstack_queries") {
|
|
299
|
+
// A query binding is keyed by its data-source uid, which the picker writes
|
|
300
|
+
// as `queryUID` — NOT `uid`. Reading only `uid` fell through to the loose
|
|
301
|
+
// shape below and produced the key `query:entries` (the path's first
|
|
302
|
+
// segment), so no pooled query ever matched and a query-rooted section
|
|
303
|
+
// rendered component defaults.
|
|
304
|
+
const queryUid = value.queryUID ?? value.uid;
|
|
305
|
+
if (queryUid)
|
|
306
|
+
return { key: `query:${queryUid}`, prefix: path };
|
|
307
|
+
if (path.length === 0)
|
|
308
|
+
return inherited;
|
|
309
|
+
const [documentSegment, ...rest] = path;
|
|
310
|
+
return { key: `query:${documentSegment}`, prefix: rest };
|
|
311
|
+
}
|
|
312
|
+
return inherited;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export { TEMPLATE_BINDING_TYPE, TEMPLATE_FETCH_ROOT_KEY, fetchRootFromBinding, flattenPath, getRootBindingPath, getRootScopePath, isDataRootCleared, isPageAbsoluteField, isTemplateFetchRoot, isTemplateRootBinding, nestPath, parseEntryFetchRootKey, resolveInstanceRootBinding, resolveLegacySelectedField, resolveLegacySelectedFieldWithProvenance, resolveMatchedSchema, sectionDataEqual, splitFieldPath, synthesizeTemplateRootBinding, templateFetchRoot };
|
|
316
|
+
//# sourceMappingURL=section-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-data.js","sources":["../../src/composable-studio/section-data.ts"],"sourcesContent":[null],"names":[],"mappings":"AA8CA;AACO,MAAM,qBAAqB,GAAG;AAErC;;;;;AAKG;AACG,SAAU,cAAc,CAAC,IAAY,EAAA;AACzC,IAAA,OAAO;SACJ,KAAK,CAAC,GAAG;SACT,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;SAC7D,MAAM,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,O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
-
import {
|
|
1
|
+
import { POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger/constants';
|
|
2
|
+
import { sendStudioEvent } from '../utils/studio-messaging.js';
|
|
2
3
|
import { SCHEMA_VERSION, SDK_VERSION } from '../utils/constants.js';
|
|
3
4
|
import 'lodash-es';
|
|
4
5
|
import '@contentstack/studio-registry';
|
|
5
6
|
import '../utils/editor-mode.js';
|
|
7
|
+
import '../utils/studio-error-codes.js';
|
|
8
|
+
import '../utils/composition-not-found.js';
|
|
6
9
|
import '../utils/conditionBlock.js';
|
|
7
10
|
import { clientRendererModeUtil } from '../utils/canvas.js';
|
|
8
11
|
|
|
@@ -67,7 +70,7 @@ class StudioIntelligenceManager {
|
|
|
67
70
|
sdkConfigLocale: config?.locale,
|
|
68
71
|
};
|
|
69
72
|
const result = await Promise.race([
|
|
70
|
-
|
|
73
|
+
sendStudioEvent(POST_MESSAGE_EVENTS.GET_STUDIO_INTELLIGENCE, request),
|
|
71
74
|
this.timeoutPromise(this.TIMEOUT_MS),
|
|
72
75
|
]);
|
|
73
76
|
// Type guard to ensure result is valid StudioIntelligence or null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-intelligence.manager.js","sources":["../../src/composable-studio/studio-intelligence.manager.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studio-intelligence.manager.js","sources":["../../src/composable-studio/studio-intelligence.manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AAWA;;;AAGG;MACU,yBAAyB,CAAA;AAC5B,IAAA,OAAgB,UAAU,GAAG,IAAI;AAEzC;;;AAGG;AACH,IAAA,aAAa,qBAAqB,CAChC,OAAiC,EACjC,MAAY,EAAA;;AAGZ,QAAA,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE,EAAE;AACjD,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,IAAI;YACF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,uBAAuB,CA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,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,SAAS;IAC5D;AAEA;;AAEG;AACK,IAAA,OAAO,iBAAiB,GAAA;QAC9B,OAAO,CAAA,IAAA,EAAO,IAAI,CAAC,GAAG,EAAE,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAE;IACvE;AAEA;;AAEG;IACK,OAAO,cAAc,CAAI,EAAU,EAAA;QACzC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,KAC3B,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,EAAE,EAAE,CAAC,CACvE;IACH;;;;;"}
|
|
@@ -15,15 +15,28 @@ const userConfigSchema = z.object({
|
|
|
15
15
|
* Visual type to be used for storing the UI
|
|
16
16
|
*/
|
|
17
17
|
contentTypeUid: z.string().optional(),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Accepted as given. Whether a stack is usable is settled by the preflight,
|
|
20
|
+
* not here: a missing or malformed stack is recorded at setup and raised at
|
|
21
|
+
* the first call that needs it, so validating it here would throw at setup
|
|
22
|
+
* for a page that may never fetch a composition.
|
|
23
|
+
*
|
|
24
|
+
* The check this replaces applied `in` to the value, which throws a
|
|
25
|
+
* `TypeError` rather than failing validation when nothing was passed.
|
|
26
|
+
*/
|
|
27
|
+
stackSdk: z.custom(),
|
|
26
28
|
locale: z.string().optional(),
|
|
29
|
+
/**
|
|
30
|
+
* Turns on reporting for the failures that do not stop the page — a binding
|
|
31
|
+
* that reads a field which is not there, a query that matched nothing, a
|
|
32
|
+
* reference that came back as a stub.
|
|
33
|
+
*
|
|
34
|
+
* Off by default, and that default is deliberate: those findings are reported
|
|
35
|
+
* in development already, and a customer's production console belongs to
|
|
36
|
+
* them. Switching this on is how a developer diagnoses a deployed site, which
|
|
37
|
+
* has no Studio chrome on it and no other way to say what went wrong.
|
|
38
|
+
*/
|
|
39
|
+
debug: z.boolean().optional(),
|
|
27
40
|
cslp: z
|
|
28
41
|
.object({
|
|
29
42
|
appendTags: z.boolean().optional(),
|
|
@@ -35,6 +48,30 @@ const userConfigSchema = z.object({
|
|
|
35
48
|
position: editButtonInBuilderPosition.optional(),
|
|
36
49
|
})
|
|
37
50
|
.optional(),
|
|
51
|
+
/**
|
|
52
|
+
* Whether this SDK works out `include[]` paths of its own, on top of the set
|
|
53
|
+
* the composition already carries in `data_sources[*].resolvedReferences`.
|
|
54
|
+
*
|
|
55
|
+
* Studio recomputes that set on every save and, having the content type
|
|
56
|
+
* schemas, keeps only paths that end at a reference (ADR 0018). This SDK has
|
|
57
|
+
* no schema, so what it derives cannot be filtered: measured on one page it
|
|
58
|
+
* added 23 paths of which 22 addressed nothing. The Delivery API refuses a
|
|
59
|
+
* request carrying more than 100 include[] paths, so those are not free.
|
|
60
|
+
*
|
|
61
|
+
* Leave it unset and the SDK decides per composition, from the
|
|
62
|
+
* `schema_version` the entry was saved with: derive for anything older than
|
|
63
|
+
* the point the persisted set became authoritative, skip it for anything at or
|
|
64
|
+
* beyond. That matters because a composition saved before the save-time derive
|
|
65
|
+
* existed holds only the author's ticks, and switching derivation off there
|
|
66
|
+
* would leave every bound-but-un-ticked reference unfetched.
|
|
67
|
+
*
|
|
68
|
+
* Set it explicitly to override that judgement in either direction.
|
|
69
|
+
*
|
|
70
|
+
* What the SDK does regardless is COMPOSE: a section's paths are stored
|
|
71
|
+
* relative to its own scope and only the host knows where the section sits, so
|
|
72
|
+
* prefixing them is the one job that cannot move.
|
|
73
|
+
*/
|
|
74
|
+
deriveIncludePaths: z.boolean().optional(),
|
|
38
75
|
fetchComposition: z
|
|
39
76
|
.custom((val) => typeof val === "function", {
|
|
40
77
|
message: "fetchComposition must be a function",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.schema.js","sources":["../../src/config/config.schema.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQO,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC;IAChD,KAAK;IACL,UAAU;IACV,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,cAAc;IACd,eAAe;AAChB,CAAA;AAEM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;AACvC;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"config.schema.js","sources":["../../src/config/config.schema.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQO,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC;IAChD,KAAK;IACL,UAAU;IACV,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,cAAc;IACd,eAAe;AAChB,CAAA;AAEM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;AACvC;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACrC;;;;;;;;AAQG;AACH,IAAA,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAe;AACjC,IAAA,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AAC7B;;;;;;;;;AASG;AACH,IAAA,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;AAC7B,IAAA,IAAI,EAAE;AACH,SAAA,MAAM,CAAC;AACN,QAAA,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;KACnC;AACA,SAAA,QAAQ,EAAE;AACb,IAAA,kBAAkB,EAAE;AACjB,SAAA,MAAM,CAAC;AACN,QAAA,MAAM,EAAE,CAAC,C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I;AACb,IAAA,CAAC,EACD;AACE,QAAA,OAAO,EACL,yGAAyG;KAC5G;AAEF,SAAA,QAAQ,EAAE;AACd,CAAA;;;;"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
function getDefaultConfig() {
|
|
2
2
|
return {
|
|
3
3
|
contentTypeUid: "",
|
|
4
|
+
contentTypeUidWasSupplied: false,
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
* as
|
|
6
|
+
* Absent until a usable stack is supplied. It was an empty object, which
|
|
7
|
+
* every `!config.stackSdk` guard read as a stack, so none of them could
|
|
8
|
+
* fire and a missing stack surfaced as a "not a function" crash instead.
|
|
7
9
|
*/
|
|
8
|
-
stackSdk:
|
|
10
|
+
stackSdk: undefined,
|
|
9
11
|
locale: undefined,
|
|
10
12
|
variantAlias: undefined,
|
|
13
|
+
debug: false,
|
|
11
14
|
cslp: {
|
|
12
15
|
appendTags: false,
|
|
13
16
|
},
|
|
@@ -15,6 +18,10 @@ function getDefaultConfig() {
|
|
|
15
18
|
enable: true,
|
|
16
19
|
position: "bottom",
|
|
17
20
|
},
|
|
21
|
+
// Unset on purpose: the SDK decides per composition from its
|
|
22
|
+
// `schema_version` (ADR 0018). Setting it here would override that for every
|
|
23
|
+
// composition, including the old ones that still need the derivation.
|
|
24
|
+
deriveIncludePaths: undefined,
|
|
18
25
|
};
|
|
19
26
|
}
|
|
20
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-config.js","sources":["../../src/config/default-config.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default-config.js","sources":["../../src/config/default-config.ts"],"sourcesContent":[null],"names":[],"mappings":"SAEgB,gBAAgB,GAAA;IAC9B,OAAO;AACL,QAAA,cAAc,EAAE,EAAE;AAClB,QAAA,yBAAyB,EAAE,KAAK;AAChC;;;;AAIG;AACH,QAAA,QAAQ,EAAE,SAAS;AACnB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,YAAY,EAAE,SAAS;AACvB,QAAA,KAAK,EAAE,KAAK;AACZ,QAAA,IAAI,EAAE;AACJ,YAAA,UAAU,EAAE,KAAK;AAClB,SAAA;AACD,QAAA,kBAAkB,EAAE;AAClB,YAAA,MAAM,EAAE,IAAI;AACZ,YAAA,QAAQ,EAAE,QAAQ;AACnB,SAAA;;;;AAID,QAAA,kBAAkB,EAAE,SAAS;KAC9B;AACH;;;;"}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
import { isObject } from 'lodash-es';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { DEFAULT_COMPOSITION_TYPE_UID } from './config.constant.js';
|
|
3
4
|
import { userConfigSchema } from './config.schema.js';
|
|
4
5
|
import { getDefaultConfig } from './default-config.js';
|
|
5
6
|
import { StackSDK } from './stack-sdk-wrapper.js';
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Whether a value is a Contentstack stack the SDK can query.
|
|
10
|
+
*
|
|
11
|
+
* Three properties rather than one. `livePreviewQuery` alone admits an object
|
|
12
|
+
* the credential accessors then crash on: they read `headers.api_key` on a
|
|
13
|
+
* JavaScript stack and `config.apiKey` on a TypeScript one, so a value carrying
|
|
14
|
+
* neither reintroduces the very `TypeError` this check exists to replace. Every
|
|
15
|
+
* constructed stack of either kind carries one of them.
|
|
16
|
+
*
|
|
17
|
+
* Membership is tested with `in` because these live on the prototype, which is
|
|
18
|
+
* also why the value has to be an object first — `in` throws on anything else.
|
|
19
|
+
*/
|
|
20
|
+
function isContentstackStack(value) {
|
|
21
|
+
if (!isObject(value))
|
|
22
|
+
return false;
|
|
23
|
+
if (!("livePreviewQuery" in value))
|
|
24
|
+
return false;
|
|
25
|
+
return "headers" in value || "config" in value;
|
|
26
|
+
}
|
|
7
27
|
function processUserConfig(userConfig) {
|
|
8
28
|
const config = getDefaultConfig();
|
|
9
29
|
try {
|
|
@@ -18,15 +38,25 @@ function processUserConfig(userConfig) {
|
|
|
18
38
|
issues.join("\n - ") +
|
|
19
39
|
"\n");
|
|
20
40
|
}
|
|
41
|
+
// Anything else is a fault in validation itself. Swallowing it hid the
|
|
42
|
+
// missing-stack case entirely: the check threw a `TypeError`, this branch
|
|
43
|
+
// dropped it, and the defaulted stack then passed every guard downstream.
|
|
44
|
+
throw error;
|
|
21
45
|
}
|
|
46
|
+
config.contentTypeUidWasSupplied = userConfig.contentTypeUid !== undefined;
|
|
22
47
|
config.contentTypeUid =
|
|
23
48
|
userConfig.contentTypeUid ?? DEFAULT_COMPOSITION_TYPE_UID;
|
|
24
|
-
|
|
49
|
+
// A value that is not a stack is left absent rather than wrapped, so the
|
|
50
|
+
// guards downstream see "no stack" instead of a wrapper around nothing.
|
|
51
|
+
if (isContentstackStack(userConfig.stackSdk)) {
|
|
25
52
|
config.stackSdk = new StackSDK(userConfig.stackSdk, userConfig.locale);
|
|
26
53
|
}
|
|
27
54
|
if (userConfig.locale) {
|
|
28
55
|
config.locale = userConfig.locale;
|
|
29
56
|
}
|
|
57
|
+
if (typeof userConfig.debug !== "undefined") {
|
|
58
|
+
config.debug = userConfig.debug;
|
|
59
|
+
}
|
|
30
60
|
if (typeof userConfig.cslp?.appendTags !== "undefined") {
|
|
31
61
|
config.cslp.appendTags = userConfig.cslp.appendTags;
|
|
32
62
|
}
|
|
@@ -45,6 +75,12 @@ function processUserConfig(userConfig) {
|
|
|
45
75
|
if (userConfig.fetchTemplateEntry) {
|
|
46
76
|
config.fetchTemplateEntry = userConfig.fetchTemplateEntry;
|
|
47
77
|
}
|
|
78
|
+
// Checked by type, not truthiness: `false` is the value that matters most here
|
|
79
|
+
// (turn derivation off for an old composition) and a truthiness check would
|
|
80
|
+
// drop it silently, leaving the per-composition default in charge.
|
|
81
|
+
if (typeof userConfig.deriveIncludePaths === "boolean") {
|
|
82
|
+
config.deriveIncludePaths = userConfig.deriveIncludePaths;
|
|
83
|
+
}
|
|
48
84
|
// BYOS state config — passed through as-is so generateSdk can wire the
|
|
49
85
|
// shared state store (getDefaultConfig has no state entry; without this
|
|
50
86
|
// copy the user's getState/setState/variables silently vanish).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-user-config.js","sources":["../../src/config/process-user-config.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-user-config.js","sources":["../../src/config/process-user-config.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAQA;;;;;;;;;;;AAWG;AACH,SAAS,mBAAmB,CAAC,KAAc,EAAA;AACzC,IAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AAClC,IAAA,IAAI,EAAE,kBAAkB,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AAChD,IAAA,OAAO,SAAS,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK;AAChD;AAEM,SAAU,iBAAiB,CAAC,UAAsB,EAAA;AACtD,IAAA,MAAM,MAAM,GAAG,gBAAgB,EAAE;AAEjC,IAAA,IAAI;AACF,QAAA,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC;IACpC;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,KAAK,YAAY,CAAC,CAAC,QAAQ,EAAE;YAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;AACxC,gBAAA,OAAO,CAAA,EAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,GAAA,EAAM,KAAK,CAAC,OAAO,EAAE;AACrD,YAAA,CAAC,CAAC;YAEF,MAAM,IAAI,SAAS,CACjB,qEAAqE;AACnE,gBAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;AACrB,gBAAA,IAAI,CACP;QACH;;;;AAIA,QAAA,MAAM,KAAK;IACb;IAEA,MAAM,CAAC,yBAAyB,GAAG,UAAU,CAAC,cAAc,KAAK,SAAS;AAC1E,IAAA,MAAM,CAAC,cAAc;A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