@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.
Files changed (122) hide show
  1. package/dist/breakpoints/BreakpointManager.js +3 -2
  2. package/dist/breakpoints/BreakpointManager.js.map +1 -1
  3. package/dist/breakpoints/breakpoint-origin.js +30 -0
  4. package/dist/breakpoints/breakpoint-origin.js.map +1 -0
  5. package/dist/canvas/canvas.type.js +1 -1
  6. package/dist/canvas/canvas.utils.js +165 -4
  7. package/dist/canvas/canvas.utils.js.map +1 -1
  8. package/dist/composable-studio/binding-defect-report.js +106 -0
  9. package/dist/composable-studio/binding-defect-report.js.map +1 -0
  10. package/dist/composable-studio/build-scoped-data.js +21 -11
  11. package/dist/composable-studio/build-scoped-data.js.map +1 -1
  12. package/dist/composable-studio/collect-data-needs.js +1 -1
  13. package/dist/composable-studio/data/pre-process-static-values.js +89 -19
  14. package/dist/composable-studio/data/pre-process-static-values.js.map +1 -1
  15. package/dist/composable-studio/delivery-setup-check.js +92 -0
  16. package/dist/composable-studio/delivery-setup-check.js.map +1 -0
  17. package/dist/composable-studio/resolution-failure-spec.js +53 -0
  18. package/dist/composable-studio/resolution-failure-spec.js.map +1 -0
  19. package/dist/composable-studio/resolution-telemetry.js +68 -0
  20. package/dist/composable-studio/resolution-telemetry.js.map +1 -0
  21. package/dist/composable-studio/sdk.js +683 -551
  22. package/dist/composable-studio/sdk.js.map +1 -1
  23. package/dist/composable-studio/section-binding/compute-all-section-auto-bindings.js +146 -0
  24. package/dist/composable-studio/section-binding/compute-all-section-auto-bindings.js.map +1 -0
  25. package/dist/composable-studio/section-binding/constants.js +27 -0
  26. package/dist/composable-studio/section-binding/constants.js.map +1 -0
  27. package/dist/composable-studio/section-binding/index.js +20 -0
  28. package/dist/composable-studio/section-binding/index.js.map +1 -0
  29. package/dist/composable-studio/section-binding/schema-path.js +112 -0
  30. package/dist/composable-studio/section-binding/schema-path.js.map +1 -0
  31. package/dist/composable-studio/section-binding/section-composition-auto-binding.js +815 -0
  32. package/dist/composable-studio/section-binding/section-composition-auto-binding.js.map +1 -0
  33. package/dist/composable-studio/section-binding/section-compositions.js +349 -0
  34. package/dist/composable-studio/section-binding/section-compositions.js.map +1 -0
  35. package/dist/composable-studio/section-binding/section-internal-ref-introspection.js +72 -0
  36. package/dist/composable-studio/section-binding/section-internal-ref-introspection.js.map +1 -0
  37. package/dist/composable-studio/section-binding/self-describe-section-bindings.js +132 -0
  38. package/dist/composable-studio/section-binding/self-describe-section-bindings.js.map +1 -0
  39. package/dist/composable-studio/section-binding/serialization.js +33 -0
  40. package/dist/composable-studio/section-binding/serialization.js.map +1 -0
  41. package/dist/composable-studio/section-data.js +5 -1
  42. package/dist/composable-studio/section-data.js.map +1 -1
  43. package/dist/composable-studio/setup-check-signal.js +48 -0
  44. package/dist/composable-studio/setup-check-signal.js.map +1 -0
  45. package/dist/composable-studio/studio-intelligence.manager.js +6 -2
  46. package/dist/composable-studio/studio-intelligence.manager.js.map +1 -1
  47. package/dist/config/config.schema.js +97 -104
  48. package/dist/config/config.schema.js.map +1 -1
  49. package/dist/config/process-user-config.js +41 -24
  50. package/dist/config/process-user-config.js.map +1 -1
  51. package/dist/config/stack-sdk-wrapper.js +22 -4
  52. package/dist/config/stack-sdk-wrapper.js.map +1 -1
  53. package/dist/context-menu/context-menu.js +1 -0
  54. package/dist/context-menu/context-menu.js.map +1 -1
  55. package/dist/dnd/dnd-manager.js +1 -0
  56. package/dist/dnd/dnd-manager.js.map +1 -1
  57. package/dist/editor.d.ts +34 -1
  58. package/dist/highlight-node/highlight-node-manager.js +89 -14
  59. package/dist/highlight-node/highlight-node-manager.js.map +1 -1
  60. package/dist/highlight-node/highlight-node.js +11 -5
  61. package/dist/highlight-node/highlight-node.js.map +1 -1
  62. package/dist/highlight-node/history-shortcut.js +78 -0
  63. package/dist/highlight-node/history-shortcut.js.map +1 -0
  64. package/dist/index.d.ts +1082 -354
  65. package/dist/index.js +18 -6
  66. package/dist/index.js.map +1 -1
  67. package/dist/query/query-executor.js +51 -9
  68. package/dist/query/query-executor.js.map +1 -1
  69. package/dist/renderer-mode.d.ts +68 -0
  70. package/dist/renderer-mode.js +2 -0
  71. package/dist/renderer-mode.js.map +1 -0
  72. package/dist/url-metadata/entry-check-key.js +14 -0
  73. package/dist/url-metadata/entry-check-key.js.map +1 -0
  74. package/dist/url-metadata/select-url-winner.js +64 -12
  75. package/dist/url-metadata/select-url-winner.js.map +1 -1
  76. package/dist/url-metadata/types.js +10 -1
  77. package/dist/url-metadata/types.js.map +1 -1
  78. package/dist/url-metadata/url-pattern-matcher.js +11 -2
  79. package/dist/url-metadata/url-pattern-matcher.js.map +1 -1
  80. package/dist/utils/canvas.js +0 -1
  81. package/dist/utils/canvas.js.map +1 -1
  82. package/dist/utils/check-bindings.js +5 -3
  83. package/dist/utils/check-bindings.js.map +1 -1
  84. package/dist/utils/classify-response-error.js +243 -33
  85. package/dist/utils/classify-response-error.js.map +1 -1
  86. package/dist/utils/composable-studio-error.js +7 -0
  87. package/dist/utils/composable-studio-error.js.map +1 -1
  88. package/dist/utils/conditionBlock.js +19 -6
  89. package/dist/utils/conditionBlock.js.map +1 -1
  90. package/dist/utils/constants.js +7 -2
  91. package/dist/utils/constants.js.map +1 -1
  92. package/dist/utils/http-error.constants.js +24 -1
  93. package/dist/utils/http-error.constants.js.map +1 -1
  94. package/dist/utils/include-path-rules.js +3 -2
  95. package/dist/utils/include-path-rules.js.map +1 -1
  96. package/dist/utils/load-error-classifier.js +18 -0
  97. package/dist/utils/load-error-classifier.js.map +1 -0
  98. package/dist/utils/parse-ui.js +27 -5
  99. package/dist/utils/parse-ui.js.map +1 -1
  100. package/dist/utils/preview-hash-refused.js +75 -0
  101. package/dist/utils/preview-hash-refused.js.map +1 -0
  102. package/dist/utils/reference_fetcher.js +79 -12
  103. package/dist/utils/reference_fetcher.js.map +1 -1
  104. package/dist/utils/require-stack.js +83 -20
  105. package/dist/utils/require-stack.js.map +1 -1
  106. package/dist/utils/serialize-for-inline-script.js +19 -0
  107. package/dist/utils/serialize-for-inline-script.js.map +1 -0
  108. package/dist/utils/served-by.js +32 -13
  109. package/dist/utils/served-by.js.map +1 -1
  110. package/dist/utils/spec-analyzer.js +24 -1
  111. package/dist/utils/spec-analyzer.js.map +1 -1
  112. package/dist/utils/studio-error-codes.js +34 -2
  113. package/dist/utils/studio-error-codes.js.map +1 -1
  114. package/dist/utils/studio-error.js +68 -7
  115. package/dist/utils/studio-error.js.map +1 -1
  116. package/dist/visual-builder/composition-save-event.js +36 -5
  117. package/dist/visual-builder/composition-save-event.js.map +1 -1
  118. package/package.json +12 -8
  119. package/dist/studio-internal/dist/utils/section-slot-walker.js +0 -63
  120. package/dist/studio-internal/dist/utils/section-slot-walker.js.map +0 -1
  121. package/dist/studio-internal/dist/utils/spec-compression.js +0 -43
  122. package/dist/studio-internal/dist/utils/spec-compression.js.map +0 -1
@@ -0,0 +1,146 @@
1
+ import { MAX_SECTION_BINDING_PASSES } from './constants.js';
2
+ import { mergeSectionAutoBindings, computeSectionAutoBinding, applyInheritedFetchRoot, applyInstanceBindingOverride } from './section-composition-auto-binding.js';
3
+ import { findSectionCompositionInstances } from './section-compositions.js';
4
+
5
+ /**
6
+ * Store-free port of Studio `src/services/deriveSectionScoping.ts`
7
+ * (`computeAllSectionAutoBindings` + `getAbsentSectionBindings`).
8
+ *
9
+ * Deviations from Studio, all forced by having no editor store:
10
+ * - The content-type map is a parameter (Studio reads
11
+ * `store.canvas.contentTypeUIDToCT()`); build it with `buildContentTypeMap`,
12
+ * which replicates that selector exactly.
13
+ * - The result is merged with `existingBindings` (default `{}`) instead of
14
+ * `store.canvas.sectionAutoBindings()`. With `{}` the merge is a shallow
15
+ * copy — identical to Studio's save path, which resets the store bindings to
16
+ * `{}` before computing.
17
+ * - The absent-section bindings are computed per call unless the caller
18
+ * passes them (`absentBindings`) — Studio memoises them across calls on
19
+ * their real inputs, which a store-free function cannot do safely.
20
+ */
21
+ /**
22
+ * Studio's `store.canvas.contentTypeUIDToCT()` selector, verbatim: later
23
+ * entries with the same uid overwrite earlier ones.
24
+ */
25
+ function buildContentTypeMap(contentTypes) {
26
+ const contentTypeUIDToCT = new Map();
27
+ (contentTypes ?? []).forEach((ct) => {
28
+ contentTypeUIDToCT.set(ct.uid, ct);
29
+ });
30
+ return contentTypeUIDToCT;
31
+ }
32
+ /**
33
+ * Auto-bindings for catalog sections that are NOT on the page. Reads only the
34
+ * section catalog, the page's connected content type and the content-type map —
35
+ * never the tree, so a caller can memoise it on those three inputs and pass the
36
+ * result to `computeAllSectionAutoBindings`.
37
+ */
38
+ function getAbsentSectionBindings(normalizedSections, pageConnectedContentTypeUid, contentTypeMap) {
39
+ const byUid = {};
40
+ for (const section of normalizedSections) {
41
+ const result = computeSectionAutoBinding(section.linked_schemas, pageConnectedContentTypeUid, contentTypeMap, undefined, section.ui);
42
+ if (result)
43
+ byUid[section.uid] = result;
44
+ }
45
+ return byUid;
46
+ }
47
+ /**
48
+ * The canonical section auto-binding computation — Studio's
49
+ * `computeAllSectionAutoBindings` with the store reads lifted to parameters.
50
+ *
51
+ * `absentBindings` must be `getAbsentSectionBindings` of the same sections,
52
+ * page content type and content-type map; omitted, it is computed here.
53
+ */
54
+ function computeAllSectionAutoBindings(normalizedSections, pageConnectedContentTypeUid, contentTypeMap, editorUI, existingBindings = {}, absentBindings = getAbsentSectionBindings(normalizedSections, pageConnectedContentTypeUid, contentTypeMap)) {
55
+ const sectionsByUid = Object.fromEntries(normalizedSections.map((s) => [s.uid, s.ui]));
56
+ const sectionEntriesByUid = Object.fromEntries(normalizedSections.map((s) => [
57
+ s.uid,
58
+ { linked_schemas: s.linked_schemas },
59
+ ]));
60
+ // Resolve bindings for a given instance list. Used twice in the two-pass
61
+ // walk below: the first pass uses the walker's authored-path output to seed
62
+ // best-effort bindings; the second pass re-walks with those bindings folded
63
+ // into the slot recursion so inner sections in section-slots inherit the
64
+ // OUTER's RESOLVED selectedField (which can differ from the authored value
65
+ // in cross-CT reference-target matches).
66
+ const resolveBindings = (instances) => {
67
+ const bindings = {};
68
+ // Index the instances by composition once instead of re-filtering the whole list
69
+ // for every section in the catalog (was O(catalog x instances) per pass).
70
+ const instancesByComposition = new Map();
71
+ for (const instance of instances) {
72
+ const bucket = instancesByComposition.get(instance.compositionUid);
73
+ if (bucket)
74
+ bucket.push(instance);
75
+ else
76
+ instancesByComposition.set(instance.compositionUid, [instance]);
77
+ }
78
+ normalizedSections.forEach((section) => {
79
+ const sectionInstances = instancesByComposition.get(section.uid);
80
+ if (!sectionInstances || sectionInstances.length === 0) {
81
+ // Tree-independent: computed once per call (or passed in).
82
+ const result = absentBindings[section.uid];
83
+ if (result)
84
+ bindings[section.uid] = result;
85
+ return;
86
+ }
87
+ sectionInstances.forEach((instance) => {
88
+ const result = computeSectionAutoBinding(section.linked_schemas, pageConnectedContentTypeUid, contentTypeMap, instance.contextSchemaPath, section.ui);
89
+ // Fold in the per-instance override persisted on the node's
90
+ // `metadata.sectionBindingOverride`. An explicit Section data
91
+ // (`rootBinding`, ADR 0016) is authoritative and applies even when the
92
+ // auto-binder has no answer; a legacy bare `selectedField` stays only
93
+ // while it is still among the auto-binder's matches (the page CT schema
94
+ // may have changed since it was saved). See `applyInstanceBindingOverride`.
95
+ const binding = applyInheritedFetchRoot(applyInstanceBindingOverride(result, instance.overrideBinding), instance.inheritedFetchRoot);
96
+ if (binding)
97
+ bindings[instance.nodeUid] = binding;
98
+ });
99
+ });
100
+ return bindings;
101
+ };
102
+ if (!editorUI) {
103
+ return mergeSectionAutoBindings(resolveBindings([]), existingBindings);
104
+ }
105
+ // Fixpoint walk over the tree. Each pass re-walks folding the PREVIOUS
106
+ // pass's resolved selectedFields into the slot recursion, so an outer
107
+ // section's RESOLVED binding becomes the next-inner section's slot-context
108
+ // prefix. Pass 1 resolves the outermost level; pass N resolves the Nth nested
109
+ // level (section dropped in a slot of a section dropped in a slot of …). The
110
+ // walk converges as soon as no resolved selectedField changes between passes
111
+ // — the common same-CT case converges after a single pass — and is bounded by
112
+ // MAX_SECTION_BINDING_PASSES so deeper nesting needs only a constant bump.
113
+ const authoredByCompUid = {};
114
+ for (const section of normalizedSections) {
115
+ authoredByCompUid[section.uid] =
116
+ section.linked_schemas?.[0]?.selected_field;
117
+ }
118
+ let resolvedSelectedFieldByNodeUid;
119
+ let bindings = {};
120
+ for (let pass = 0; pass < MAX_SECTION_BINDING_PASSES; pass++) {
121
+ const instances = findSectionCompositionInstances(editorUI, undefined, sectionsByUid, sectionEntriesByUid, resolvedSelectedFieldByNodeUid);
122
+ bindings = resolveBindings(instances);
123
+ // Derive the next resolved map and detect change vs the map used for THIS
124
+ // pass (the first pass compares against the authored selected_field). When
125
+ // nothing changed, deeper passes cannot alter any slot path → converged.
126
+ const nextResolved = {};
127
+ let changed = false;
128
+ for (const inst of instances) {
129
+ const resolved = bindings[inst.nodeUid]?.selectedField;
130
+ if (resolved == null)
131
+ continue;
132
+ nextResolved[inst.nodeUid] = resolved;
133
+ const prev = resolvedSelectedFieldByNodeUid?.[inst.nodeUid] ??
134
+ authoredByCompUid[inst.compositionUid];
135
+ if (resolved !== prev)
136
+ changed = true;
137
+ }
138
+ if (!changed)
139
+ break;
140
+ resolvedSelectedFieldByNodeUid = nextResolved;
141
+ }
142
+ return mergeSectionAutoBindings(bindings, existingBindings);
143
+ }
144
+
145
+ export { buildContentTypeMap, computeAllSectionAutoBindings, getAbsentSectionBindings };
146
+ //# sourceMappingURL=compute-all-section-auto-bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-all-section-auto-bindings.js","sources":["../../../src/composable-studio/section-binding/compute-all-section-auto-bindings.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;AAeG;AAiBH;;;AAGG;AACG,SAAU,mBAAmB,CACjC,YAA2D,EAAA;AAE3D,IAAA,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAuB;IACzD,CAAC,YAAY,IAA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@ -0,0 +1,27 @@
1
+ /**
2
+ * Maximum nesting depth at which section bindings are structurally resolved by
3
+ * the fixpoint loop in `computeAllSectionAutoBindings`. This is an INTENTIONAL
4
+ * product-scope limit, not a runaway guard: we only auto-resolve a section's
5
+ * binding structure up to 2 levels of section-in-section nesting.
6
+ *
7
+ * Each pass propagates resolved `selectedField`s exactly one nesting level
8
+ * deeper (an outer section's RESOLVED binding becomes the next-inner section's
9
+ * slot-context prefix), and the loop also short-circuits early via
10
+ * `if (!changed) break` once a pass changes nothing. So a flat page settles in
11
+ * a single pass; 2 passes covers the supported outer→inner nesting. Sections
12
+ * nested deeper than this are deliberately left to fall back to their authored
13
+ * defaults rather than being structurally re-resolved.
14
+ *
15
+ * Do NOT raise this to "support deeper nesting" without a product decision —
16
+ * deeper resolution is out of scope by design.
17
+ */
18
+ const MAX_SECTION_BINDING_PASSES = 2;
19
+ /** How many reference hops the binder follows when matching a section's fields to the page's. */
20
+ const MAX_REFERENCE_TRAVERSAL_DEPTH = 3;
21
+ /** Subset of Studio's `DATA_SOURCES` the binder compares against. */
22
+ const DATA_SOURCES = {
23
+ TEMPLATE: "template",
24
+ };
25
+
26
+ export { DATA_SOURCES, MAX_REFERENCE_TRAVERSAL_DEPTH, MAX_SECTION_BINDING_PASSES };
27
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../src/composable-studio/section-binding/constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,0BAA0B,GAAG;AAC1C;AACO,MAAM,6BAA6B,GAAG;AAM7C;AACO,MAAM,YAAY,GAAG;AAC1B,IAAA,QAAQ,EAAE,UAAU;;;;;"}
@@ -0,0 +1,20 @@
1
+ import { computeAllSectionAutoBindings, buildContentTypeMap } from './compute-all-section-auto-bindings.js';
2
+ export { getAbsentSectionBindings } from './compute-all-section-auto-bindings.js';
3
+ import { normalizeSectionComposition } from './section-compositions.js';
4
+ export { findSectionCompositionInstances, getSlotDefaultSectionUids, indexSectionSlotsContext } from './section-compositions.js';
5
+
6
+ /**
7
+ * Studio's `computeAllSectionAutoBindings`, store-free: identical inputs yield
8
+ * identical results. Keyed by section-composition NODE uid for placed sections
9
+ * and by section composition uid for catalog sections not on the page.
10
+ */
11
+ function computeSectionAutoBindings(params) {
12
+ const normalizedSections = params.sections.map((section) => normalizeSectionComposition({
13
+ ...section,
14
+ linked_schemas: section.linked_schemas,
15
+ }));
16
+ return computeAllSectionAutoBindings(normalizedSections, params.pageContentTypeUid || null, buildContentTypeMap(params.contentTypes), params.ui ?? undefined);
17
+ }
18
+
19
+ export { buildContentTypeMap, computeAllSectionAutoBindings, computeSectionAutoBindings, normalizeSectionComposition };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/composable-studio/section-binding/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AA2FA;;;;AAIG;AACG,SAAU,0BAA0B,CACxC,MAAwC,EAAA;AAExC,IAAA,MAAM,kBAAkB,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,KACrD,2BAA2B,CAAC;AAC1B,QAAA,GAAG,OAAO;QACV,cAAc,EAAE,OAAO,CAAC,cAA0C;AACnE,KAAA,CAAC,CACH;IACD,OAAO,6BAA6B,CAClC,kBAAkB,EAClB,MAAM,CAAC,kBAAkB,IAAI,IAAI,EACjC,mBAAmB,CAAC,MAAM,CAAC,YAAwC,CAAC,EACnE,MAAM,CAAC,EAA8B,IAAI,SAAS,CACpD;AACH;;;;"}
@@ -0,0 +1,112 @@
1
+ // This function is traveller over the CS Schema
2
+ const schemaTraveller = (schema, visitors) => {
3
+ let hasExited = false;
4
+ let returnValue;
5
+ const exit = (_returnValue) => {
6
+ hasExited = true;
7
+ returnValue = _returnValue;
8
+ };
9
+ const traveller = (schema, path) => {
10
+ if (hasExited)
11
+ return;
12
+ const fields = Array.isArray(schema) ? schema : [schema];
13
+ for (const field of fields) {
14
+ const { data_type, uid } = field;
15
+ const callback = Object.prototype.hasOwnProperty.call(visitors, data_type)
16
+ ? visitors[data_type]
17
+ : visitors["default"];
18
+ callback(field, path.concat(uid), {
19
+ exit,
20
+ enter: (schema, path) => traveller(schema, path),
21
+ });
22
+ if (hasExited)
23
+ return;
24
+ }
25
+ };
26
+ traveller(schema, []);
27
+ return returnValue;
28
+ };
29
+ const getSchemaFieldForPath = (schema, path) => {
30
+ const pathArray = getSchemaPath(path);
31
+ let currIdx = 0;
32
+ const hasSameUID = (path) => path[currIdx] === pathArray[currIdx];
33
+ const visitors = {
34
+ default: (field, path, options) => {
35
+ if (!hasSameUID(path))
36
+ return;
37
+ const { exit } = options;
38
+ if (currIdx === pathArray.length - 1) {
39
+ exit(field);
40
+ }
41
+ else {
42
+ currIdx++;
43
+ }
44
+ },
45
+ blocks: (field, path, options) => {
46
+ if (!hasSameUID(path))
47
+ return;
48
+ const { enter, exit } = options;
49
+ if (currIdx === pathArray.length - 1) {
50
+ exit(field);
51
+ return;
52
+ }
53
+ currIdx++;
54
+ for (const block of field.blocks) {
55
+ const { uid, schema } = block;
56
+ if (uid !== pathArray[currIdx])
57
+ continue;
58
+ currIdx++; // consume block UID before entering block schema
59
+ return enter(schema, path.concat(uid));
60
+ }
61
+ },
62
+ group: (field, path, options) => {
63
+ if (!hasSameUID(path))
64
+ return;
65
+ const { enter, exit } = options;
66
+ if (currIdx === pathArray.length - 1) {
67
+ exit(field);
68
+ return;
69
+ }
70
+ currIdx++;
71
+ enter(field.schema, path);
72
+ },
73
+ global_field: (field, path, options) => {
74
+ if (!hasSameUID(path))
75
+ return;
76
+ const { enter, exit } = options;
77
+ if (currIdx === pathArray.length - 1) {
78
+ exit(field);
79
+ return;
80
+ }
81
+ currIdx++;
82
+ enter(field.schema, path);
83
+ },
84
+ };
85
+ const result = schemaTraveller(schema, visitors);
86
+ return result;
87
+ };
88
+ /**
89
+ This function is used to get the schema path from the field path
90
+ Example:
91
+ fieldPath: ["title", "page_components", "0"]
92
+ schemaPath: ["title", "page_components"]
93
+ */
94
+ const getSchemaPath = (_path) => {
95
+ const path = Array.isArray(_path) ? _path : _path.split(".");
96
+ return path
97
+ .map((segment) => {
98
+ // Handle composite UIDs (e.g., "0_block_1") by stripping the numeric index prefix
99
+ if (segment.includes("_")) {
100
+ const parts = segment.split("_");
101
+ const prefix = parts[0];
102
+ if (!Number.isNaN(Number(prefix)) && prefix !== "") {
103
+ return parts.slice(1).join("_");
104
+ }
105
+ }
106
+ return segment;
107
+ })
108
+ .filter((str) => Number.isNaN(Number(str)));
109
+ };
110
+
111
+ export { getSchemaFieldForPath, getSchemaPath, schemaTraveller };
112
+ //# sourceMappingURL=schema-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-path.js","sources":["../../../src/composable-studio/section-binding/schema-path.ts"],"sourcesContent":[null],"names":[],"mappings":"AAyBA;MACa,eAAe,GAAG,CAAC,MAAgB,EAAE,QAAkB,KAAI;IACtE,IAAI,SAAS,GAAG,KAAK;AACrB,IAAA,IAAI,WAAW;AACf,IAAA,MAAM,IAAI,GAAG,CAAC,YAAqB,KAAI;QACrC,SAAS,GAAG,IAAI;QAChB,WAAW,GAAG,YAAY;AAC5B,IAAA,CAAC;AACD,IAAA,MAAM,SAAS,GAAG,CAAC,MAAgB,EAAE,IAAc,KAAI;AACrD,QAAA,IAAI,SAAS;YAAE;AACf,QAAA,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC;AACxD,QAAA,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;AAC1B,YAAA,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,KAAK;AAChC,YAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS;AACvE,kBAAE,QAAQ,CAAC,SA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