@contentstack/studio-registry 1.3.0 → 1.5.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/cjs/index.cjs +529 -84
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/component-registry/registry-options-processor.js +27 -0
- package/dist/esm/component-registry/registry-options-processor.js.map +1 -1
- package/dist/esm/component-registry/registry.constant.js +3 -0
- package/dist/esm/component-registry/registry.constant.js.map +1 -1
- package/dist/esm/component-registry/registry.js +171 -4
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/component-registry/singleton.js +59 -0
- package/dist/esm/component-registry/singleton.js.map +1 -0
- package/dist/esm/data-binder/cslp.js +4 -1
- package/dist/esm/data-binder/cslp.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.js +107 -30
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.util.js +70 -52
- package/dist/esm/data-binder/retrieve-data.util.js.map +1 -1
- package/dist/esm/data-binder/strategies/contentstack.js +19 -0
- package/dist/esm/data-binder/strategies/contentstack.js.map +1 -0
- package/dist/esm/data-binder/strategies/dataSourceCapabilities.js +12 -0
- package/dist/esm/data-binder/strategies/dataSourceCapabilities.js.map +1 -0
- package/dist/esm/data-binder/strategies/query.js +17 -0
- package/dist/esm/data-binder/strategies/query.js.map +1 -0
- package/dist/esm/data-binder/strategies/repeater.js +18 -0
- package/dist/esm/data-binder/strategies/repeater.js.map +1 -0
- package/dist/esm/data-binder/strategies/template.js +16 -0
- package/dist/esm/data-binder/strategies/template.js.map +1 -0
- package/dist/esm/data-binder/strategies/utils.js +20 -0
- package/dist/esm/data-binder/strategies/utils.js.map +1 -0
- package/dist/esm/data-binder/strategy-registry.js +20 -0
- package/dist/esm/data-binder/strategy-registry.js.map +1 -0
- package/dist/esm/index.d.ts +132 -3
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +13 -10
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
|
|
2
2
|
import { get } from 'lodash-es';
|
|
3
|
-
import { DATA_SOURCES } from '../component-registry/registry.constant.js';
|
|
4
3
|
import { getCslpTag } from './cslp.js';
|
|
5
4
|
import { getDataInSchemaFormat } from './handle-binding-map.util.js';
|
|
5
|
+
import { isKnownType, getSlotData, getPlaceHolderComponent, getBindingString, convertBindingPath, getFlattenedData, normalizeSingleSelectChoiceValue, isDataMatchingPropType, getDataType } from './retrieve-data.util.js';
|
|
6
|
+
import { dataSourceCapabilities } from './strategies/dataSourceCapabilities.js';
|
|
6
7
|
import { getRegistryErrorMessage } from '../utils/registry-error-messages.js';
|
|
7
|
-
import { isKnownType, getSlotData, getPlaceHolderComponent, getBindingString, isDataMatchingPropType, getDataType } from './retrieve-data.util.js';
|
|
8
8
|
import { RegistryErrorMessageKey } from '../utils/registry-error-messages.default.js';
|
|
9
9
|
|
|
10
10
|
// Responsible for resolving props to values
|
|
@@ -46,13 +46,34 @@ function retrievePropValue(args) {
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
const nodePropConfig = nodeProps[field];
|
|
49
|
-
const { binding: bindedField } = nodePropConfig || {};
|
|
49
|
+
const { binding: bindedField, value: staticValue } = nodePropConfig || {};
|
|
50
50
|
//TODO: Get proper data for design
|
|
51
51
|
const placeholderComponent = getPlaceHolderComponent(placeholders, prop, type);
|
|
52
|
-
const fallbackValue =
|
|
52
|
+
const fallbackValue = staticValue !== undefined
|
|
53
|
+
? staticValue
|
|
54
|
+
: (defaultValue ?? placeholderComponent);
|
|
53
55
|
const dataPath = bindedField && getBindingString(bindedField);
|
|
54
56
|
if ((type === "array" || type === "object") && dataPath) {
|
|
55
|
-
|
|
57
|
+
let pathForGet = dataPath;
|
|
58
|
+
// Use strategy-based path conversion (Agnostic)
|
|
59
|
+
if (bindedField?.type && typeof dataPath === "string") {
|
|
60
|
+
pathForGet = convertBindingPath(bindedField.type, dataPath);
|
|
61
|
+
}
|
|
62
|
+
let bindedData = get(data, pathForGet);
|
|
63
|
+
// Strictly handle QueryResult { entries: Entry[], count: number } structure.
|
|
64
|
+
// If we're expecting an array and the bindedData matches the QueryResult pattern,
|
|
65
|
+
// we extract the entries array.
|
|
66
|
+
if (type === "array" &&
|
|
67
|
+
bindedData &&
|
|
68
|
+
typeof bindedData === "object" &&
|
|
69
|
+
!Array.isArray(bindedData) &&
|
|
70
|
+
"entries" in bindedData &&
|
|
71
|
+
Array.isArray(bindedData.entries)) {
|
|
72
|
+
bindedData = bindedData.entries;
|
|
73
|
+
}
|
|
74
|
+
// Note: If bindedData is a direct array [], it will fall through.
|
|
75
|
+
// As per the requirement "expects {result: [], count: number} only and no direct []",
|
|
76
|
+
// we are now enforcing the unwrapping for the expected object structure.
|
|
56
77
|
const bindingMap = nodePropConfig.bindingMap;
|
|
57
78
|
const isBindingMapEmpty = Object.keys(bindingMap || {}).length === 0;
|
|
58
79
|
const transformedData = !isBindingMapEmpty
|
|
@@ -60,21 +81,35 @@ function retrievePropValue(args) {
|
|
|
60
81
|
: bindedData;
|
|
61
82
|
resolvedData = transformedData ?? fallbackValue;
|
|
62
83
|
if (type === "array") {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
84
|
+
const isCSLPAbleType = bindedField?.type &&
|
|
85
|
+
dataSourceCapabilities[bindedField.type]?.supportsCslp;
|
|
86
|
+
if (cslp.appendTags &&
|
|
87
|
+
isCSLPAbleType &&
|
|
88
|
+
Array.isArray(transformedData)) {
|
|
89
|
+
const cslpObj = getCslpTag({ bindedField: dataPath, data });
|
|
90
|
+
if (cslpObj["data-cslp"]) {
|
|
91
|
+
mappedData[`$${field}Items`] = transformedData.map((_, idx) => {
|
|
92
|
+
return { "data-cslp": `${cslpObj["data-cslp"]}.$${idx}` };
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (isCompositionBeingEdited &&
|
|
97
|
+
isCSLPAbleType &&
|
|
98
|
+
Array.isArray(resolvedData) &&
|
|
99
|
+
resolvedData.length === 0) {
|
|
100
|
+
resolvedData = [{}];
|
|
68
101
|
}
|
|
69
102
|
}
|
|
70
103
|
}
|
|
71
|
-
else if (dataPath
|
|
104
|
+
else if (dataPath &&
|
|
105
|
+
!(type === "choice" && bindedField?.type === "static_value")) {
|
|
72
106
|
resolvedData = get(data, dataPath, fallbackValue);
|
|
73
107
|
// Handle primitive values in repeater context
|
|
74
108
|
// When the array contains primitives (strings, numbers, etc.) instead of objects,
|
|
75
109
|
// the binding path will be like: dataSources.repeater.{uid}.context.{fieldName}
|
|
76
110
|
// But context IS the primitive value, so accessing context.fieldName returns undefined.
|
|
77
111
|
// In this case, we should return the context itself.
|
|
112
|
+
let handledRepeaterContext = false;
|
|
78
113
|
if (dataPath.includes("dataSources.repeater")) {
|
|
79
114
|
const pathParts = dataPath.split(".");
|
|
80
115
|
// Check if path is: dataSources.repeater.{uid}.context.{fieldName}
|
|
@@ -87,29 +122,76 @@ function retrievePropValue(args) {
|
|
|
87
122
|
const isPrimitive = typeof contextValue !== "object" || contextValue === null;
|
|
88
123
|
if (isPrimitive) {
|
|
89
124
|
resolvedData = contextValue;
|
|
125
|
+
handledRepeaterContext = true;
|
|
90
126
|
}
|
|
91
127
|
}
|
|
92
128
|
}
|
|
93
129
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
130
|
+
// Unwrap single-key objects (common in Contentstack Modular Blocks)
|
|
131
|
+
// We only do this if we are not explicitly expecting an object or array.
|
|
132
|
+
// Skip if we already handled the repeater context case above.
|
|
133
|
+
if (type !== "object" && type !== "array" && !handledRepeaterContext) {
|
|
134
|
+
resolvedData = getFlattenedData(resolvedData);
|
|
135
|
+
resolvedData = normalizeSingleSelectChoiceValue(resolvedData, prop);
|
|
136
|
+
// Fallback to static value if the resolved data is still not matching the expected primitive type
|
|
137
|
+
// This ensures that if a binding returns an object (e.g. during a structural change), we don't crash React
|
|
138
|
+
// and instead show the static value entered by the user.
|
|
139
|
+
if (!isDataMatchingPropType(resolvedData, type)) {
|
|
140
|
+
if (type === "string") {
|
|
141
|
+
const actualType = getDataType(resolvedData);
|
|
142
|
+
if (actualType === "object" || actualType === "array") {
|
|
143
|
+
resolvedData =
|
|
144
|
+
"This content may not display correctly in this view. Please contact your development team to update the component so it can support this type of content.";
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
resolvedData =
|
|
148
|
+
staticValue !== undefined ? staticValue : fallbackValue;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
resolvedData =
|
|
153
|
+
staticValue !== undefined ? staticValue : fallbackValue;
|
|
99
154
|
}
|
|
100
155
|
}
|
|
101
156
|
}
|
|
157
|
+
// Normalize data type: convert arrays to single values for single-select props
|
|
158
|
+
if (type === "choice" &&
|
|
159
|
+
!prop.multiSelect &&
|
|
160
|
+
Array.isArray(resolvedData)) {
|
|
161
|
+
// Single-select props (choice, etc.) should receive single values, not arrays
|
|
162
|
+
resolvedData = resolvedData[0];
|
|
163
|
+
}
|
|
102
164
|
}
|
|
103
165
|
else {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
166
|
+
// For choice props, explicitly retrieve saved values from static content store
|
|
167
|
+
if (type === "choice" && bindedField?.type === "static_value") {
|
|
168
|
+
const staticContentKey = bindedField.value; // e.g., "B575hDbLkWhPSfB-alignment"
|
|
169
|
+
// Try to find the saved value in the static content store
|
|
170
|
+
let savedValue = undefined;
|
|
171
|
+
// Check if we have access to the static_value from data
|
|
172
|
+
if (data.static_value && typeof data.static_value === "object") {
|
|
173
|
+
// Look for the value directly by key
|
|
174
|
+
if (typeof staticContentKey === "string") {
|
|
175
|
+
savedValue = data.static_value[staticContentKey];
|
|
111
176
|
}
|
|
112
177
|
}
|
|
178
|
+
if (savedValue !== undefined) {
|
|
179
|
+
resolvedData = savedValue;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
resolvedData =
|
|
183
|
+
staticValue !== undefined ? staticValue : fallbackValue;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
resolvedData = staticValue !== undefined ? staticValue : fallbackValue;
|
|
188
|
+
}
|
|
189
|
+
// Normalize data type: convert arrays to single values for single-select props
|
|
190
|
+
if (type === "choice" &&
|
|
191
|
+
!prop.multiSelect &&
|
|
192
|
+
Array.isArray(resolvedData)) {
|
|
193
|
+
// Single-select props (choice, etc.) should receive single values, not arrays
|
|
194
|
+
resolvedData = resolvedData[0];
|
|
113
195
|
}
|
|
114
196
|
}
|
|
115
197
|
// TODO: @ravencolevol: In case of the missing string value, we are providing a placeholder component, failing this check. We have to revisit the placeholder component logic.
|
|
@@ -148,13 +230,8 @@ function retrievePropValue(args) {
|
|
|
148
230
|
if (type === "json_rte") {
|
|
149
231
|
mappedData["jsonConfig"] = jsonRTE;
|
|
150
232
|
}
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
DATA_SOURCES.COMPONENT_PROPS,
|
|
154
|
-
DATA_SOURCES.TEMPLATE,
|
|
155
|
-
DATA_SOURCES.REPEATER,
|
|
156
|
-
];
|
|
157
|
-
const isCSLPAbleType = bindedField?.type && cslpAbleTypes.includes(bindedField.type);
|
|
233
|
+
const isCSLPAbleType = bindedField?.type &&
|
|
234
|
+
dataSourceCapabilities[bindedField.type]?.supportsCslp;
|
|
158
235
|
if (cslp.appendTags && dataPath && isCSLPAbleType) {
|
|
159
236
|
const cslpValue = getCslpTag({ bindedField: dataPath, data });
|
|
160
237
|
if (cslpValue) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieve-data.js","sources":["../../../src/data-binder/retrieve-data.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;
|
|
1
|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, DATA_SOURCES_PREFIX } from '../component-registry/registry.constant.js';
|
|
2
1
|
import { get, set } from 'lodash-es';
|
|
2
|
+
import { DATA_SOURCES, DATA_SOURCES_PREFIX } from '../component-registry/registry.constant.js';
|
|
3
|
+
import { getContentstackBindingString } from './strategies/contentstack.js';
|
|
4
|
+
import { getQueryBindingString } from './strategies/query.js';
|
|
5
|
+
import { getRepeaterBindingString } from './strategies/repeater.js';
|
|
6
|
+
import { getTemplateBindingString } from './strategies/template.js';
|
|
7
|
+
import { DataSourceStrategyRegistry } from './strategy-registry.js';
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* Retrieves the default static value for a given property type.
|
|
@@ -73,60 +78,68 @@ function getPlaceHolderComponent(placeholders, prop, type) {
|
|
|
73
78
|
: getDefaultPropStaticValue(type);
|
|
74
79
|
return placeholderComponent;
|
|
75
80
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
// Register default strategies (Side-effect initialization)
|
|
82
|
+
const registry = DataSourceStrategyRegistry.getInstance();
|
|
83
|
+
registry.register(DATA_SOURCES.CONTENTSTACK, {
|
|
84
|
+
getBindingString: (binding) => getContentstackBindingString(binding),
|
|
85
|
+
});
|
|
86
|
+
registry.register(DATA_SOURCES.TEMPLATE, {
|
|
87
|
+
getBindingString: (binding) => getTemplateBindingString(binding),
|
|
88
|
+
});
|
|
89
|
+
registry.register(DATA_SOURCES.QUERY, {
|
|
90
|
+
getBindingString: (binding) => getQueryBindingString(binding),
|
|
91
|
+
convertPath: (path) => path.split("."),
|
|
92
|
+
});
|
|
93
|
+
registry.register(DATA_SOURCES.REPEATER, {
|
|
94
|
+
getBindingString: (binding) => getRepeaterBindingString(binding),
|
|
95
|
+
});
|
|
96
|
+
registry.register(DATA_SOURCES.COMPONENT_PROPS, {
|
|
97
|
+
getBindingString: (binding) => [DATA_SOURCES.COMPONENT_PROPS, binding.value].filter(Boolean).join("."),
|
|
98
|
+
});
|
|
99
|
+
registry.register(DATA_SOURCES.STATIC_VALUE, {
|
|
100
|
+
getBindingString: (binding) => [DATA_SOURCES.STATIC_VALUE, binding.value].filter(Boolean).join("."),
|
|
101
|
+
});
|
|
102
|
+
registry.register(DATA_SOURCES.SYMBOL_PROPS, {
|
|
103
|
+
getBindingString: (binding) => [DATA_SOURCES.SYMBOL_PROPS, binding.value].filter(Boolean).join("."),
|
|
104
|
+
});
|
|
89
105
|
const getBindingString = (binding) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return
|
|
93
|
-
DATA_SOURCES_PREFIX,
|
|
94
|
-
DATA_SOURCES.TEMPLATE,
|
|
95
|
-
getBindingStringForCS(binding),
|
|
96
|
-
].join(".");
|
|
106
|
+
const strategy = DataSourceStrategyRegistry.getInstance().get(binding.type);
|
|
107
|
+
if (strategy) {
|
|
108
|
+
return strategy.getBindingString(binding);
|
|
97
109
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
entryKey,
|
|
106
|
-
getBindingStringForCS(binding),
|
|
107
|
-
].join(".");
|
|
108
|
-
}
|
|
109
|
-
if (binding.type === DATA_SOURCES.REPEATER) {
|
|
110
|
-
const { repeaterUID } = binding.value;
|
|
111
|
-
return [
|
|
112
|
-
DATA_SOURCES_PREFIX,
|
|
113
|
-
DATA_SOURCES.REPEATER,
|
|
114
|
-
repeaterUID,
|
|
115
|
-
"context",
|
|
116
|
-
getBindingStringForCS(binding),
|
|
117
|
-
].join(".");
|
|
110
|
+
// Fallback for simple string bindings
|
|
111
|
+
return binding.value;
|
|
112
|
+
};
|
|
113
|
+
const convertBindingPath = (bindingType, path) => {
|
|
114
|
+
const strategy = DataSourceStrategyRegistry.getInstance().get(bindingType);
|
|
115
|
+
if (strategy && strategy.convertPath) {
|
|
116
|
+
return strategy.convertPath(path);
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
return path;
|
|
119
|
+
};
|
|
120
|
+
const getFlattenedData = (data) => {
|
|
121
|
+
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
122
|
+
const keys = Object.keys(data).filter((key) => key !== "$" && key !== "_metadata");
|
|
123
|
+
if (keys.length === 1) {
|
|
124
|
+
return getFlattenedData(data[keys[0]]);
|
|
125
|
+
}
|
|
121
126
|
}
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
return data;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Composition/static data often stores single-select choice as `string[]` (one element).
|
|
131
|
+
* `isDataMatchingPropType` treats `choice` as a `string` or `string[]` (multi-select);
|
|
132
|
+
* single-select stored as `string[]` must still be unwrapped here before the type-mismatch fallback.
|
|
133
|
+
*/
|
|
134
|
+
function normalizeSingleSelectChoiceValue(resolvedData, prop) {
|
|
135
|
+
if (prop.type !== "choice" || ("multiSelect" in prop && prop.multiSelect)) {
|
|
136
|
+
return resolvedData;
|
|
124
137
|
}
|
|
125
|
-
if (
|
|
126
|
-
return [
|
|
138
|
+
if (Array.isArray(resolvedData)) {
|
|
139
|
+
return resolvedData[0];
|
|
127
140
|
}
|
|
128
|
-
return
|
|
129
|
-
}
|
|
141
|
+
return resolvedData;
|
|
142
|
+
}
|
|
130
143
|
const resolveMetadataBindings = (node, data) => {
|
|
131
144
|
if (!node.metadata?.bindings)
|
|
132
145
|
return;
|
|
@@ -149,13 +162,18 @@ const getRepeaterContextPath = (binding) => {
|
|
|
149
162
|
};
|
|
150
163
|
function isDataMatchingPropType(data, type) {
|
|
151
164
|
const dataType = getDataType(data);
|
|
165
|
+
if (type === "choice") {
|
|
166
|
+
return (dataType === "string" ||
|
|
167
|
+
(dataType === "array" &&
|
|
168
|
+
Array.isArray(data) &&
|
|
169
|
+
data.every((item) => typeof item === "string")));
|
|
170
|
+
}
|
|
152
171
|
const map = {
|
|
153
|
-
string: dataType === "string",
|
|
172
|
+
string: dataType === "string" || dataType === "number" || dataType === "boolean",
|
|
154
173
|
boolean: dataType === "boolean",
|
|
155
174
|
number: dataType === "number",
|
|
156
175
|
object: dataType === "object",
|
|
157
176
|
array: dataType === "array",
|
|
158
|
-
choice: dataType === "string",
|
|
159
177
|
href: dataType === "string",
|
|
160
178
|
imageurl: dataType === "string",
|
|
161
179
|
datestring: dataType === "string",
|
|
@@ -173,5 +191,5 @@ function getDataType(data) {
|
|
|
173
191
|
return typeof data;
|
|
174
192
|
}
|
|
175
193
|
|
|
176
|
-
export { getBindingString, getDataType, getDefaultPropStaticValue, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, resolveMetadataBindings };
|
|
194
|
+
export { convertBindingPath, getBindingString, getDataType, getDefaultPropStaticValue, getFlattenedData, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, resolveMetadataBindings };
|
|
177
195
|
//# sourceMappingURL=retrieve-data.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieve-data.util.js","sources":["../../../src/data-binder/retrieve-data.util.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retrieve-data.util.js","sources":["../../../src/data-binder/retrieve-data.util.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AA6BA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,yBAAyB,CACvC,IAAQ,EAAA;AAER,IAAA,MAAM,aAAa,GAAG;AACpB,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,MAAM,EAAE,CAAC;;AAET,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,IAAI,EAAE,EAAE;AACR,QAAA,QAA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';
|
|
2
|
+
import { getBindingStringForCS } from './utils.js';
|
|
3
|
+
|
|
4
|
+
const getContentstackBindingString = (binding) => {
|
|
5
|
+
// STORED AT dataSources.contentstack.ct_uid:euid.<bindingString>
|
|
6
|
+
const { _content_type_uid, uid } = binding.value;
|
|
7
|
+
const entryKey = `${_content_type_uid}:${uid}`;
|
|
8
|
+
return [
|
|
9
|
+
DATA_SOURCES_PREFIX,
|
|
10
|
+
DATA_SOURCES.CONTENTSTACK,
|
|
11
|
+
entryKey,
|
|
12
|
+
getBindingStringForCS(binding),
|
|
13
|
+
]
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.join(".");
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { getContentstackBindingString };
|
|
19
|
+
//# sourceMappingURL=contentstack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentstack.js","sources":["../../../../src/data-binder/strategies/contentstack.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQO,MAAM,4BAA4B,GAAG,CAAC,OAAoB,KAAY;;IAE3E,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,KAAiC;AAC5E,IAAA,MAAM,QAAQ,GAAG,CAAA,EAAG,iBAAiB,CAAA,CAAA,EAAI,GAAG,EAAE;IAC9C,OAAO;QACL,mBAAmB;AACnB,QAAA,YAAY,CAAC,YAAY;QACzB,QAAQ;QACR,qBAAqB,CAAC,OAAO,CAAC;AAC/B;SACE,MAAM,CAAC,OAAO;SACd,IAAI,CAAC,GAAG,CAAC;AACd;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DATA_SOURCES } from '../../component-registry/registry.constant.js';
|
|
2
|
+
|
|
3
|
+
const dataSourceCapabilities = {
|
|
4
|
+
[DATA_SOURCES.CONTENTSTACK]: { supportsCslp: true },
|
|
5
|
+
[DATA_SOURCES.COMPONENT_PROPS]: { supportsCslp: true },
|
|
6
|
+
[DATA_SOURCES.TEMPLATE]: { supportsCslp: true },
|
|
7
|
+
[DATA_SOURCES.REPEATER]: { supportsCslp: true },
|
|
8
|
+
[DATA_SOURCES.QUERY]: { supportsCslp: true }, // Verified: Query supports CSLP now
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { dataSourceCapabilities };
|
|
12
|
+
//# sourceMappingURL=dataSourceCapabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataSourceCapabilities.js","sources":["../../../../src/data-binder/strategies/dataSourceCapabilities.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAMO,MAAM,sBAAsB,GAAyC;IAC1E,CAAC,YAAY,CAAC,YAAY,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;IACnD,CAAC,YAAY,CAAC,eAAe,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;IACtD,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;IAC/C,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;IAC/C,CAAC,YAAY,CAAC,KAAK,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DATA_SOURCES_PREFIX, DATA_SOURCES } from '../../component-registry/registry.constant.js';
|
|
2
|
+
import { getBindingStringForCS } from './utils.js';
|
|
3
|
+
|
|
4
|
+
const getQueryBindingString = (binding) => {
|
|
5
|
+
// STORED AT dataSources.query.<queryUID>.<bindingString>
|
|
6
|
+
// Binding value structure: { queryUID: string, path: CSBindingPath }
|
|
7
|
+
const { queryUID } = binding.value;
|
|
8
|
+
const suffix = getBindingStringForCS(binding);
|
|
9
|
+
// Keep the full path including "data" and "count" - the schema structure is the source of truth
|
|
10
|
+
const finalPath = [DATA_SOURCES_PREFIX, DATA_SOURCES.QUERY, queryUID, suffix]
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.join(".");
|
|
13
|
+
return finalPath;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { getQueryBindingString };
|
|
17
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sources":["../../../../src/data-binder/strategies/query.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAOO,MAAM,qBAAqB,GAAG,CAAC,OAAoB,KAAY;;;AAGpE,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAY;AACzC,IAAA,MAAM,MAAM,GAAG,qBAAqB,CAAC,OAAO,CAAC;;AAG7C,IAAA,MAAM,SAAS,GAAG,CAAC,mBAAmB,EAAE,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM;SACzE,MAAM,CAAC,OAAO;SACd,IAAI,CAAC,GAAG,CAAC;AAEZ,IAAA,OAAO,SAAS;AAClB;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DATA_SOURCES_PREFIX, DATA_SOURCES } from '../../component-registry/registry.constant.js';
|
|
2
|
+
import { getBindingStringForCS } from './utils.js';
|
|
3
|
+
|
|
4
|
+
const getRepeaterBindingString = (binding) => {
|
|
5
|
+
const { repeaterUID } = binding.value;
|
|
6
|
+
return [
|
|
7
|
+
DATA_SOURCES_PREFIX,
|
|
8
|
+
DATA_SOURCES.REPEATER,
|
|
9
|
+
repeaterUID,
|
|
10
|
+
"context",
|
|
11
|
+
getBindingStringForCS(binding),
|
|
12
|
+
]
|
|
13
|
+
.filter(Boolean)
|
|
14
|
+
.join(".");
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { getRepeaterBindingString };
|
|
18
|
+
//# sourceMappingURL=repeater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeater.js","sources":["../../../../src/data-binder/strategies/repeater.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQO,MAAM,wBAAwB,GAAG,CAAC,OAAoB,KAAY;AACvE,IAAA,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,KAA6B;IAC7D,OAAO;QACL,mBAAmB;AACnB,QAAA,YAAY,CAAC,QAAQ;QACrB,WAAW;QACX,SAAS;QACT,qBAAqB,CAAC,OAAO,CAAC;AAC/B;SACE,MAAM,CAAC,OAAO;SACd,IAAI,CAAC,GAAG,CAAC;AACd;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DATA_SOURCES_PREFIX, DATA_SOURCES } from '../../component-registry/registry.constant.js';
|
|
2
|
+
import { getBindingStringForCS } from './utils.js';
|
|
3
|
+
|
|
4
|
+
const getTemplateBindingString = (binding) => {
|
|
5
|
+
// STORED AT dataSources.template.<bindingString>
|
|
6
|
+
return [
|
|
7
|
+
DATA_SOURCES_PREFIX,
|
|
8
|
+
DATA_SOURCES.TEMPLATE,
|
|
9
|
+
getBindingStringForCS(binding),
|
|
10
|
+
]
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.join(".");
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { getTemplateBindingString };
|
|
16
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sources":["../../../../src/data-binder/strategies/template.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAOO,MAAM,wBAAwB,GAAG,CAAC,OAAoB,KAAY;;IAEvE,OAAO;QACL,mBAAmB;AACnB,QAAA,YAAY,CAAC,QAAQ;QACrB,qBAAqB,CAAC,OAAO,CAAC;AAC/B;SACE,MAAM,CAAC,OAAO;SACd,IAAI,CAAC,GAAG,CAAC;AACd;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the binding path string from a Contentstack-like binding object.
|
|
3
|
+
* Flattens nested path objects into a dot-notation string.
|
|
4
|
+
*/
|
|
5
|
+
const getBindingStringForCS = (binding) => {
|
|
6
|
+
//TODO: fix this types and data source uid
|
|
7
|
+
const path = binding.value.path;
|
|
8
|
+
const flattenPath = (path) => {
|
|
9
|
+
if (!path || Object.keys(path).length === 0)
|
|
10
|
+
return "";
|
|
11
|
+
const key = Object.keys(path)[0];
|
|
12
|
+
const value = path[key];
|
|
13
|
+
const flattenValue = flattenPath(value);
|
|
14
|
+
return flattenValue ? `${key}.${flattenValue}` : key;
|
|
15
|
+
};
|
|
16
|
+
return flattenPath(path);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { getBindingStringForCS };
|
|
20
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/data-binder/strategies/utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;AAGG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAoB,KAAY;;AAEpE,IAAA,MAAM,IAAI,GAAI,OAAO,CAAC,KAAa,CAAC,IAAI;AACxC,IAAA,MAAM,WAAW,GAAG,CAAC,IAAS,KAAY;AACxC,QAAA,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,EAAE;QACtD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChC,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC;AACvB,QAAA,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC;AACvC,QAAA,OAAO,YAAY,GAAG,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE,GAAG,GAAG;AACtD,IAAA,CAAC;AACD,IAAA,OAAO,WAAW,CAAC,IAAI,CAAC;AAC1B;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class DataSourceStrategyRegistry {
|
|
2
|
+
static instance;
|
|
3
|
+
strategies = new Map();
|
|
4
|
+
constructor() { }
|
|
5
|
+
static getInstance() {
|
|
6
|
+
if (!DataSourceStrategyRegistry.instance) {
|
|
7
|
+
DataSourceStrategyRegistry.instance = new DataSourceStrategyRegistry();
|
|
8
|
+
}
|
|
9
|
+
return DataSourceStrategyRegistry.instance;
|
|
10
|
+
}
|
|
11
|
+
register(type, strategy) {
|
|
12
|
+
this.strategies.set(type, strategy);
|
|
13
|
+
}
|
|
14
|
+
get(type) {
|
|
15
|
+
return this.strategies.get(type);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { DataSourceStrategyRegistry };
|
|
20
|
+
//# sourceMappingURL=strategy-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-registry.js","sources":["../../../src/data-binder/strategy-registry.ts"],"sourcesContent":[null],"names":[],"mappings":"MAOa,0BAA0B,CAAA;IAC7B,OAAO,QAAQ;AACf,IAAA,UAAU,GAAoC,IAAI,GAAG,EAAE;AAE/D,IAAA,WAAA,GAAA,EAAuB;AAEhB,IAAA,OAAO,WAAW,GAAA;AACvB,QAAA,IAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE;AACxC,YAAA,0BAA0B,CAAC,QAAQ,GAAG,IAAI,0BAA0B,EAAE;QACxE;QACA,OAAO,0BAA0B,CAAC,QAAQ;IAC5C;IAEO,QAAQ,CAAC,IAAY,EAAE,QAA4B,EAAA;QACxD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC;IACrC;AAEO,IAAA,GAAG,CAAC,IAAY,EAAA;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;IAClC;AACD;;;;"}
|