@contentstack/studio-client 3.1.0 → 3.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.
@@ -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,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,SAAS,CAAC;AAC/E;AAEA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,QAAkB,EAAA;IACzC,IAAI,MAAM,GAA4B,EAAE;AACxC,IAAA,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE;IACpC;AACA,IAAA,OAAO,MAAM;AACf;AAEA;AACM,SAAU,WAAW,CACzB,IAAgD,EAAA;IAEhD,MAAM,QAAQ,GAAa,EAAE;IAC7B,IAAI,OAAO,GAA+C,IAAI;AAC9D,I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,KAAK,CAAC;AAAE,YAAA,OAAO,SAAS;QACvC,MAAM,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI;QACvC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE;IAC/C;AAEA,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAsB,EAAE;;;;;;QAMxC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG;AAC5C,QAAA,IAAI,QAAQ;YAAE,OAAO,EAAE,GAAG,EAAE,CAAA,MAAA,EAAS,QAAQ,CAAA,CAAE,EAAE,MAAM,EAAE,IAAI,EAAE;AAC/D,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,SAAS;QACvC,MAAM,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI;QACvC,OAAO,EAAE,GAAG,EAAE,CAAA,MAAA,EAAS,eAAe,CAAA,CAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IAC1D;AAEA,IAAA,OAAO,SAAS;AAClB;;;;"}
@@ -5,6 +5,12 @@ import '@contentstack/studio-registry';
5
5
  import '../utils/editor-mode.js';
6
6
  import '../utils/conditionBlock.js';
7
7
 
8
+ // Measured against cdn.contentstack.io: 15,092 bytes of request URI comes back
9
+ // 200, 15,292 comes back 431, and 16,469 comes back 414. So the first failure is
10
+ // a 431 at roughly 15.3KB, about a kilobyte earlier than the 414 the old note
11
+ // here described. Stay well under it — the count below is an estimate, and being
12
+ // optimistic costs the whole request.
13
+ const MAX_REQUEST_URL_CHARS = 12000;
8
14
  class StackSDK {
9
15
  sdk;
10
16
  _locale;
@@ -33,7 +39,35 @@ class StackSDK {
33
39
  }
34
40
  ctQuery(contentTypeUid, options = {}) {
35
41
  const references = options.references || [];
36
- const only = options.only || [];
42
+ let only = options.only || [];
43
+ // A 414 surfaces as a fallback fetch with no includes, i.e. uid stubs.
44
+ // include[] is correctness, only[] is payload size — so when the two
45
+ // together exceed the cap, drop only[] and accept a larger response.
46
+ if (only.length > 0) {
47
+ const includeChars = references.reduce((n, r) => n + encodeURIComponent(r).length + 14, // include%5B%5D= + &
48
+ 0);
49
+ const onlyChars = only.reduce((n, [ref, field]) => n +
50
+ encodeURIComponent(ref).length +
51
+ encodeURIComponent(field).length +
52
+ 20, // only%5B..%5D%5B%5D= + &
53
+ 0);
54
+ const queryChars = options.query
55
+ ? encodeURIComponent(JSON.stringify(options.query)).length + 7
56
+ : 0;
57
+ const APPROX_BASE_CHARS = 500; // host, path, env/locale/branch params
58
+ if (APPROX_BASE_CHARS + includeChars + onlyChars + queryChars >
59
+ MAX_REQUEST_URL_CHARS) {
60
+ // Nothing is wrong from the reader's point of view — the page still
61
+ // renders, it just fetches more than it needs. A consuming site does not
62
+ // want that in its production logs on every render.
63
+ if (process.env.NODE_ENV === "development") {
64
+ console.warn(`[studio-sdk] Skipping only[] projections for ${contentTypeUid}: ` +
65
+ `estimated request URL exceeds ${MAX_REQUEST_URL_CHARS} chars ` +
66
+ `(includes: ${references.length}, only rows: ${only.length}).`);
67
+ }
68
+ only = [];
69
+ }
70
+ }
37
71
  const variantAlias = options.variantAlias;
38
72
  const locale = options.locale; // Get locale from options, not from instance
39
73
  const branch = options.branch;
@@ -1 +1 @@
1
- {"version":3,"file":"stack-sdk-wrapper.js","sources":["../../src/config/stack-sdk-wrapper.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;MAQa,QAAQ,CAAA;AACnB,IAAA,GAAG;AACK,IAAA,OAAO;IAEf,WAAA,CAAY,GAAsB,EAAE,MAAe,EAAA;AACjD,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;AACd,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;QAErB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;QACtD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAA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