@contentstack/studio-registry 1.2.1 → 1.4.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 (33) hide show
  1. package/dist/cjs/index.cjs +313 -72
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/component-registry/registry.constant.js +1 -0
  4. package/dist/esm/component-registry/registry.constant.js.map +1 -1
  5. package/dist/esm/component-registry/registry.js +17 -1
  6. package/dist/esm/component-registry/registry.js.map +1 -1
  7. package/dist/esm/data-binder/cslp.js +4 -1
  8. package/dist/esm/data-binder/cslp.js.map +1 -1
  9. package/dist/esm/data-binder/retrieve-data.js +103 -23
  10. package/dist/esm/data-binder/retrieve-data.js.map +1 -1
  11. package/dist/esm/data-binder/retrieve-data.util.js +50 -51
  12. package/dist/esm/data-binder/retrieve-data.util.js.map +1 -1
  13. package/dist/esm/data-binder/strategies/contentstack.js +19 -0
  14. package/dist/esm/data-binder/strategies/contentstack.js.map +1 -0
  15. package/dist/esm/data-binder/strategies/dataSourceCapabilities.js +12 -0
  16. package/dist/esm/data-binder/strategies/dataSourceCapabilities.js.map +1 -0
  17. package/dist/esm/data-binder/strategies/query.js +17 -0
  18. package/dist/esm/data-binder/strategies/query.js.map +1 -0
  19. package/dist/esm/data-binder/strategies/repeater.js +18 -0
  20. package/dist/esm/data-binder/strategies/repeater.js.map +1 -0
  21. package/dist/esm/data-binder/strategies/template.js +16 -0
  22. package/dist/esm/data-binder/strategies/template.js.map +1 -0
  23. package/dist/esm/data-binder/strategies/utils.js +20 -0
  24. package/dist/esm/data-binder/strategies/utils.js.map +1 -0
  25. package/dist/esm/data-binder/strategy-registry.js +20 -0
  26. package/dist/esm/data-binder/strategy-registry.js.map +1 -0
  27. package/dist/esm/index.d.ts +5 -2
  28. package/dist/esm/index.js +1 -1
  29. package/dist/esm/utils/registry-error-messages.default.js +22 -0
  30. package/dist/esm/utils/registry-error-messages.default.js.map +1 -0
  31. package/dist/esm/utils/registry-error-messages.js +40 -0
  32. package/dist/esm/utils/registry-error-messages.js.map +1 -0
  33. package/package.json +7 -7
@@ -2,6 +2,61 @@
2
2
 
3
3
  var studioMessenger = require('@contentstack/studio-messenger');
4
4
 
5
+ /**
6
+ * Keys for registry error message lookup. Use these constants instead of string literals.
7
+ * @internal
8
+ */
9
+ const RegistryErrorMessageKey = {
10
+ DATA_BINDING_TYPE_MISMATCH: "DATA_BINDING_TYPE_MISMATCH",
11
+ DATA_BINDING_TYPE_MISMATCH_EDITOR: "DATA_BINDING_TYPE_MISMATCH_EDITOR",
12
+ PROP_VALIDATION_FAILED: "PROP_VALIDATION_FAILED",
13
+ };
14
+ /**
15
+ * Default (en) error message templates for studio-registry. Single source of truth.
16
+ * Use getRegistryErrorMessage() with RegistryErrorMessageKey constants.
17
+ * @internal
18
+ */
19
+ const defaultRegistryErrorMessages = {
20
+ [RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH]: 'Data binding type mismatch in component "{component}": Expected prop "{field}" to be {expectedType} but received {receivedType}. Path: {dataPath}',
21
+ [RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH_EDITOR]: "Expected prop type {expectedType} but received {receivedType} in the component registry. Remove the binding and bind with correct data.",
22
+ [RegistryErrorMessageKey.PROP_VALIDATION_FAILED]: 'Prop validation failed for "{prop}" in component "{component}": {validationError}',
23
+ };
24
+
25
+ /**
26
+ * Error message lookup for studio-registry. Messages are defined in registry-error-messages.default.ts.
27
+ * Use getRegistryErrorMessage with RegistryErrorMessageKey constants (no string literals).
28
+ * @internal
29
+ */
30
+ /**
31
+ * Returns the message string for the given key, substituting placeholders with params.
32
+ * Placeholders: {component}, {field}, {expectedType}, {receivedType}, {dataPath}, {prop}, {validationError}
33
+ * @internal
34
+ */
35
+ function getRegistryErrorMessage(key, params) {
36
+ let template = defaultRegistryErrorMessages[key];
37
+ if (template == null) {
38
+ return String(key);
39
+ }
40
+ if (!params) {
41
+ return template;
42
+ }
43
+ const replacements = [
44
+ ["component", params.component],
45
+ ["field", params.field],
46
+ ["expectedType", params.expectedType],
47
+ ["receivedType", params.receivedType],
48
+ ["dataPath", params.dataPath],
49
+ ["prop", params.prop],
50
+ ["validationError", params.validationError],
51
+ ];
52
+ for (const [placeholder, value] of replacements) {
53
+ if (value !== undefined) {
54
+ template = template.replace(new RegExp(`\\{${placeholder}\\}`, "g"), String(value));
55
+ }
56
+ }
57
+ return template;
58
+ }
59
+
5
60
  const DATA_SOURCES_PREFIX = "dataSources";
6
61
  const DATA_SOURCES = {
7
62
  COMPONENT_PROPS: "component_props",
@@ -9,6 +64,7 @@ const DATA_SOURCES = {
9
64
  TEMPLATE: "template",
10
65
  CONTENTSTACK: "contentstack",
11
66
  REPEATER: "repeater",
67
+ QUERY: "contentstack_queries",
12
68
  SYMBOL_PROPS: "symbol_props",
13
69
  };
14
70
  const INTERNAL_COMPONENT_SECTIONS = {
@@ -4234,7 +4290,21 @@ class ComponentRegistry {
4234
4290
  if (!propValidator) {
4235
4291
  return true;
4236
4292
  }
4237
- return propValidator(value);
4293
+ const result = propValidator(value);
4294
+ // Log validation failures
4295
+ if (result !== true) {
4296
+ console.warn(getRegistryErrorMessage(RegistryErrorMessageKey.PROP_VALIDATION_FAILED, {
4297
+ component: componentName,
4298
+ prop: propName,
4299
+ validationError: String(result),
4300
+ }), {
4301
+ component: componentName,
4302
+ prop: propName,
4303
+ value: value,
4304
+ validationError: result,
4305
+ });
4306
+ }
4307
+ return result;
4238
4308
  }
4239
4309
  getComponentName(node) {
4240
4310
  const { type } = node;
@@ -5104,6 +5174,9 @@ class JSONRTERegistry {
5104
5174
  * @returns The path of the CSLP path.
5105
5175
  */
5106
5176
  function getCslpPath(binding) {
5177
+ if (typeof binding !== "string") {
5178
+ return "";
5179
+ }
5107
5180
  const bindingParts = binding.split(".");
5108
5181
  const lastPart = bindingParts.pop();
5109
5182
  const cslpPath = bindingParts.join(".") + ".$." + lastPart;
@@ -5125,6 +5198,14 @@ const getCslpTag = ({ bindedField, data, }) => {
5125
5198
  return cslpValue || {};
5126
5199
  };
5127
5200
 
5201
+ const dataSourceCapabilities = {
5202
+ [DATA_SOURCES.CONTENTSTACK]: { supportsCslp: true },
5203
+ [DATA_SOURCES.COMPONENT_PROPS]: { supportsCslp: true },
5204
+ [DATA_SOURCES.TEMPLATE]: { supportsCslp: true },
5205
+ [DATA_SOURCES.REPEATER]: { supportsCslp: true },
5206
+ [DATA_SOURCES.QUERY]: { supportsCslp: true }, // Verified: Query supports CSLP now
5207
+ };
5208
+
5128
5209
  /**
5129
5210
  * This transforms the provided data into the format defined by the schema.
5130
5211
  *
@@ -5224,6 +5305,92 @@ function removeCurrentBindingKey(entry, bindingMap, currentBindingKey) {
5224
5305
  return [key, newValue];
5225
5306
  }
5226
5307
 
5308
+ class DataSourceStrategyRegistry {
5309
+ static instance;
5310
+ strategies = new Map();
5311
+ constructor() { }
5312
+ static getInstance() {
5313
+ if (!DataSourceStrategyRegistry.instance) {
5314
+ DataSourceStrategyRegistry.instance = new DataSourceStrategyRegistry();
5315
+ }
5316
+ return DataSourceStrategyRegistry.instance;
5317
+ }
5318
+ register(type, strategy) {
5319
+ this.strategies.set(type, strategy);
5320
+ }
5321
+ get(type) {
5322
+ return this.strategies.get(type);
5323
+ }
5324
+ }
5325
+
5326
+ /**
5327
+ * Extracts the binding path string from a Contentstack-like binding object.
5328
+ * Flattens nested path objects into a dot-notation string.
5329
+ */
5330
+ const getBindingStringForCS = (binding) => {
5331
+ //TODO: fix this types and data source uid
5332
+ const path = binding.value.path;
5333
+ const flattenPath = (path) => {
5334
+ if (!path || Object.keys(path).length === 0)
5335
+ return "";
5336
+ const key = Object.keys(path)[0];
5337
+ const value = path[key];
5338
+ const flattenValue = flattenPath(value);
5339
+ return flattenValue ? `${key}.${flattenValue}` : key;
5340
+ };
5341
+ return flattenPath(path);
5342
+ };
5343
+
5344
+ const getContentstackBindingString = (binding) => {
5345
+ // STORED AT dataSources.contentstack.ct_uid:euid.<bindingString>
5346
+ const { _content_type_uid, uid } = binding.value;
5347
+ const entryKey = `${_content_type_uid}:${uid}`;
5348
+ return [
5349
+ DATA_SOURCES_PREFIX,
5350
+ DATA_SOURCES.CONTENTSTACK,
5351
+ entryKey,
5352
+ getBindingStringForCS(binding),
5353
+ ]
5354
+ .filter(Boolean)
5355
+ .join(".");
5356
+ };
5357
+
5358
+ const getQueryBindingString = (binding) => {
5359
+ // STORED AT dataSources.query.<queryUID>.<bindingString>
5360
+ // Binding value structure: { queryUID: string, path: CSBindingPath }
5361
+ const { queryUID } = binding.value;
5362
+ const suffix = getBindingStringForCS(binding);
5363
+ // Keep the full path including "data" and "count" - the schema structure is the source of truth
5364
+ const finalPath = [DATA_SOURCES_PREFIX, DATA_SOURCES.QUERY, queryUID, suffix]
5365
+ .filter(Boolean)
5366
+ .join(".");
5367
+ return finalPath;
5368
+ };
5369
+
5370
+ const getRepeaterBindingString = (binding) => {
5371
+ const { repeaterUID } = binding.value;
5372
+ return [
5373
+ DATA_SOURCES_PREFIX,
5374
+ DATA_SOURCES.REPEATER,
5375
+ repeaterUID,
5376
+ "context",
5377
+ getBindingStringForCS(binding),
5378
+ ]
5379
+ .filter(Boolean)
5380
+ .join(".");
5381
+ };
5382
+
5383
+ const getTemplateBindingString = (binding) => {
5384
+ // STORED AT dataSources.template.<bindingString>
5385
+ return [
5386
+ DATA_SOURCES_PREFIX,
5387
+ DATA_SOURCES.TEMPLATE,
5388
+ getBindingStringForCS(binding),
5389
+ ]
5390
+ .filter(Boolean)
5391
+ .join(".");
5392
+ };
5393
+
5227
5394
  /**
5228
5395
  * Retrieves the default static value for a given property type.
5229
5396
  *
@@ -5296,59 +5463,53 @@ function getPlaceHolderComponent(placeholders, prop, type) {
5296
5463
  : getDefaultPropStaticValue(type);
5297
5464
  return placeholderComponent;
5298
5465
  }
5299
- const getBindingStringForCS = (binding) => {
5300
- //TODO: fix this types and data source uid
5301
- const path = binding.value.path;
5302
- const flattenPath = (path) => {
5303
- if (Object.keys(path).length === 0)
5304
- return "";
5305
- const key = Object.keys(path)[0];
5306
- const value = path[key];
5307
- const flattenValue = flattenPath(value);
5308
- return flattenValue ? `${key}.${flattenValue}` : key;
5309
- };
5310
- return flattenPath(path);
5311
- };
5466
+ // Register default strategies (Side-effect initialization)
5467
+ const registry = DataSourceStrategyRegistry.getInstance();
5468
+ registry.register(DATA_SOURCES.CONTENTSTACK, {
5469
+ getBindingString: (binding) => getContentstackBindingString(binding),
5470
+ });
5471
+ registry.register(DATA_SOURCES.TEMPLATE, {
5472
+ getBindingString: (binding) => getTemplateBindingString(binding),
5473
+ });
5474
+ registry.register(DATA_SOURCES.QUERY, {
5475
+ getBindingString: (binding) => getQueryBindingString(binding),
5476
+ convertPath: (path) => path.split("."),
5477
+ });
5478
+ registry.register(DATA_SOURCES.REPEATER, {
5479
+ getBindingString: (binding) => getRepeaterBindingString(binding),
5480
+ });
5481
+ registry.register(DATA_SOURCES.COMPONENT_PROPS, {
5482
+ getBindingString: (binding) => [DATA_SOURCES.COMPONENT_PROPS, binding.value].filter(Boolean).join("."),
5483
+ });
5484
+ registry.register(DATA_SOURCES.STATIC_VALUE, {
5485
+ getBindingString: (binding) => [DATA_SOURCES.STATIC_VALUE, binding.value].filter(Boolean).join("."),
5486
+ });
5487
+ registry.register(DATA_SOURCES.SYMBOL_PROPS, {
5488
+ getBindingString: (binding) => [DATA_SOURCES.SYMBOL_PROPS, binding.value].filter(Boolean).join("."),
5489
+ });
5312
5490
  const getBindingString = (binding) => {
5313
- if (binding.type === DATA_SOURCES.TEMPLATE) {
5314
- // STORED AT dataSources.template.<bindingString>
5315
- return [
5316
- DATA_SOURCES_PREFIX,
5317
- DATA_SOURCES.TEMPLATE,
5318
- getBindingStringForCS(binding),
5319
- ].join(".");
5320
- }
5321
- if (binding.type === DATA_SOURCES.CONTENTSTACK) {
5322
- // STORED AT dataSources.contentstack.ct_uid:euid.<bindingString>
5323
- const { _content_type_uid, uid } = binding.value;
5324
- const entryKey = `${_content_type_uid}:${uid}`;
5325
- return [
5326
- DATA_SOURCES_PREFIX,
5327
- DATA_SOURCES.CONTENTSTACK,
5328
- entryKey,
5329
- getBindingStringForCS(binding),
5330
- ].join(".");
5331
- }
5332
- if (binding.type === DATA_SOURCES.REPEATER) {
5333
- const { repeaterUID } = binding.value;
5334
- return [
5335
- DATA_SOURCES_PREFIX,
5336
- DATA_SOURCES.REPEATER,
5337
- repeaterUID,
5338
- "context",
5339
- getBindingStringForCS(binding),
5340
- ].join(".");
5341
- }
5342
- if (binding.type === DATA_SOURCES.COMPONENT_PROPS) {
5343
- return [DATA_SOURCES.COMPONENT_PROPS, binding.value].join(".");
5491
+ const strategy = DataSourceStrategyRegistry.getInstance().get(binding.type);
5492
+ if (strategy) {
5493
+ return strategy.getBindingString(binding);
5344
5494
  }
5345
- if (binding.type === DATA_SOURCES.STATIC_VALUE) {
5346
- return [DATA_SOURCES.STATIC_VALUE, binding.value].join(".");
5495
+ // Fallback for simple string bindings
5496
+ return binding.value;
5497
+ };
5498
+ const convertBindingPath = (bindingType, path) => {
5499
+ const strategy = DataSourceStrategyRegistry.getInstance().get(bindingType);
5500
+ if (strategy && strategy.convertPath) {
5501
+ return strategy.convertPath(path);
5347
5502
  }
5348
- if (binding.type === DATA_SOURCES.SYMBOL_PROPS) {
5349
- return [DATA_SOURCES.SYMBOL_PROPS, binding.value].join(".");
5503
+ return path;
5504
+ };
5505
+ const getFlattenedData = (data) => {
5506
+ if (data && typeof data === "object" && !Array.isArray(data)) {
5507
+ const keys = Object.keys(data).filter((key) => key !== "$" && key !== "_metadata");
5508
+ if (keys.length === 1) {
5509
+ return getFlattenedData(data[keys[0]]);
5510
+ }
5350
5511
  }
5351
- return binding.value;
5512
+ return data;
5352
5513
  };
5353
5514
  const resolveMetadataBindings = (node, data) => {
5354
5515
  if (!node.metadata?.bindings)
@@ -5373,7 +5534,7 @@ const getRepeaterContextPath = (binding) => {
5373
5534
  function isDataMatchingPropType(data, type) {
5374
5535
  const dataType = getDataType(data);
5375
5536
  const map = {
5376
- string: dataType === "string",
5537
+ string: dataType === "string" || dataType === "number" || dataType === "boolean",
5377
5538
  boolean: dataType === "boolean",
5378
5539
  number: dataType === "number",
5379
5540
  object: dataType === "object",
@@ -5435,13 +5596,34 @@ function retrievePropValue(args) {
5435
5596
  return;
5436
5597
  }
5437
5598
  const nodePropConfig = nodeProps[field];
5438
- const { binding: bindedField } = nodePropConfig || {};
5599
+ const { binding: bindedField, value: staticValue } = nodePropConfig || {};
5439
5600
  //TODO: Get proper data for design
5440
5601
  const placeholderComponent = getPlaceHolderComponent(placeholders, prop, type);
5441
- const fallbackValue = defaultValue ?? placeholderComponent;
5602
+ const fallbackValue = staticValue !== undefined
5603
+ ? staticValue
5604
+ : (defaultValue ?? placeholderComponent);
5442
5605
  const dataPath = bindedField && getBindingString(bindedField);
5443
5606
  if ((type === "array" || type === "object") && dataPath) {
5444
- const bindedData = get(data, dataPath);
5607
+ let pathForGet = dataPath;
5608
+ // Use strategy-based path conversion (Agnostic)
5609
+ if (bindedField?.type && typeof dataPath === "string") {
5610
+ pathForGet = convertBindingPath(bindedField.type, dataPath);
5611
+ }
5612
+ let bindedData = get(data, pathForGet);
5613
+ // Strictly handle QueryResult { entries: Entry[], count: number } structure.
5614
+ // If we're expecting an array and the bindedData matches the QueryResult pattern,
5615
+ // we extract the entries array.
5616
+ if (type === "array" &&
5617
+ bindedData &&
5618
+ typeof bindedData === "object" &&
5619
+ !Array.isArray(bindedData) &&
5620
+ "entries" in bindedData &&
5621
+ Array.isArray(bindedData.entries)) {
5622
+ bindedData = bindedData.entries;
5623
+ }
5624
+ // Note: If bindedData is a direct array [], it will fall through.
5625
+ // As per the requirement "expects {result: [], count: number} only and no direct []",
5626
+ // we are now enforcing the unwrapping for the expected object structure.
5445
5627
  const bindingMap = nodePropConfig.bindingMap;
5446
5628
  const isBindingMapEmpty = Object.keys(bindingMap || {}).length === 0;
5447
5629
  const transformedData = !isBindingMapEmpty
@@ -5449,11 +5631,23 @@ function retrievePropValue(args) {
5449
5631
  : bindedData;
5450
5632
  resolvedData = transformedData ?? fallbackValue;
5451
5633
  if (type === "array") {
5452
- const cslpObj = getCslpTag({ bindedField: dataPath, data });
5453
- if (cslpObj["data-cslp"]) {
5454
- mappedData[`$${field}Items`] = transformedData.map((_, idx) => {
5455
- return { "data-cslp": `${cslpObj["data-cslp"]}.$${idx}` };
5456
- });
5634
+ const isCSLPAbleType = bindedField?.type &&
5635
+ dataSourceCapabilities[bindedField.type]?.supportsCslp;
5636
+ if (cslp.appendTags &&
5637
+ isCSLPAbleType &&
5638
+ Array.isArray(transformedData)) {
5639
+ const cslpObj = getCslpTag({ bindedField: dataPath, data });
5640
+ if (cslpObj["data-cslp"]) {
5641
+ mappedData[`$${field}Items`] = transformedData.map((_, idx) => {
5642
+ return { "data-cslp": `${cslpObj["data-cslp"]}.$${idx}` };
5643
+ });
5644
+ }
5645
+ }
5646
+ if (isCompositionBeingEdited &&
5647
+ isCSLPAbleType &&
5648
+ Array.isArray(resolvedData) &&
5649
+ resolvedData.length === 0) {
5650
+ resolvedData = [{}];
5457
5651
  }
5458
5652
  }
5459
5653
  }
@@ -5464,6 +5658,7 @@ function retrievePropValue(args) {
5464
5658
  // the binding path will be like: dataSources.repeater.{uid}.context.{fieldName}
5465
5659
  // But context IS the primitive value, so accessing context.fieldName returns undefined.
5466
5660
  // In this case, we should return the context itself.
5661
+ let handledRepeaterContext = false;
5467
5662
  if (dataPath.includes("dataSources.repeater")) {
5468
5663
  const pathParts = dataPath.split(".");
5469
5664
  // Check if path is: dataSources.repeater.{uid}.context.{fieldName}
@@ -5476,8 +5671,35 @@ function retrievePropValue(args) {
5476
5671
  const isPrimitive = typeof contextValue !== "object" || contextValue === null;
5477
5672
  if (isPrimitive) {
5478
5673
  resolvedData = contextValue;
5674
+ handledRepeaterContext = true;
5675
+ }
5676
+ }
5677
+ }
5678
+ }
5679
+ // Unwrap single-key objects (common in Contentstack Modular Blocks)
5680
+ // We only do this if we are not explicitly expecting an object or array.
5681
+ // Skip if we already handled the repeater context case above.
5682
+ if (type !== "object" && type !== "array" && !handledRepeaterContext) {
5683
+ resolvedData = getFlattenedData(resolvedData);
5684
+ // Fallback to static value if the resolved data is still not matching the expected primitive type
5685
+ // This ensures that if a binding returns an object (e.g. during a structural change), we don't crash React
5686
+ // and instead show the static value entered by the user.
5687
+ if (!isDataMatchingPropType(resolvedData, type)) {
5688
+ if (type === "string") {
5689
+ const actualType = getDataType(resolvedData);
5690
+ if (actualType === "object" || actualType === "array") {
5691
+ resolvedData =
5692
+ "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.";
5693
+ }
5694
+ else {
5695
+ resolvedData =
5696
+ staticValue !== undefined ? staticValue : fallbackValue;
5479
5697
  }
5480
5698
  }
5699
+ else {
5700
+ resolvedData =
5701
+ staticValue !== undefined ? staticValue : fallbackValue;
5702
+ }
5481
5703
  }
5482
5704
  }
5483
5705
  if (type === "choice") {
@@ -5490,7 +5712,7 @@ function retrievePropValue(args) {
5490
5712
  }
5491
5713
  }
5492
5714
  else {
5493
- resolvedData = fallbackValue;
5715
+ resolvedData = staticValue !== undefined ? staticValue : fallbackValue;
5494
5716
  // TODO: THIS IS A TEMPORARY FIX TO HANDLE THE CASE WHERE THE DATA TYPE IS NOT MATCHING THE PROP TYPE. WE WILL REMOVE THIS ELSE BLOCK.
5495
5717
  if (type === "choice") {
5496
5718
  if (!prop.multiSelect) {
@@ -5504,24 +5726,41 @@ function retrievePropValue(args) {
5504
5726
  // 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.
5505
5727
  //NOTE: This is the error message that is sent to the parent on the render is it a good idea to send the error message here?
5506
5728
  //or it should happen in the data tab section. might require a revisit.
5507
- if (!isDataMatchingPropType(resolvedData, type) &&
5508
- isCompositionBeingEdited) {
5509
- studioMessenger.composableStudioEventManager?.send(studioMessenger.POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
5510
- propKey: `${node.uid}-${field}`,
5511
- errorMessage: `Expected prop type ${type} but received ${getDataType(resolvedData)} in the component registry. Remove the binding and bind with correct data.`,
5729
+ if (!isDataMatchingPropType(resolvedData, type)) {
5730
+ const receivedType = getDataType(resolvedData);
5731
+ const errorMessage = getRegistryErrorMessage(RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH, {
5732
+ component: node.type,
5733
+ field,
5734
+ expectedType: type,
5735
+ receivedType,
5736
+ dataPath,
5512
5737
  });
5738
+ if (isCompositionBeingEdited) {
5739
+ // In editor mode: Send to Visual Builder
5740
+ studioMessenger.composableStudioEventManager?.send(studioMessenger.POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
5741
+ propKey: `${node.uid}-${field}`,
5742
+ errorMessage: getRegistryErrorMessage(RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH_EDITOR, { expectedType: type, receivedType }),
5743
+ });
5744
+ }
5745
+ else {
5746
+ // In production mode: Console warning
5747
+ console.warn(errorMessage, {
5748
+ component: node.type,
5749
+ componentUid: node.uid,
5750
+ prop: field,
5751
+ expectedType: type,
5752
+ receivedType: getDataType(resolvedData),
5753
+ receivedValue: resolvedData,
5754
+ dataPath: dataPath,
5755
+ });
5756
+ }
5513
5757
  }
5514
5758
  mappedData[field] = resolvedData;
5515
5759
  if (type === "json_rte") {
5516
5760
  mappedData["jsonConfig"] = jsonRTE;
5517
5761
  }
5518
- const cslpAbleTypes = [
5519
- DATA_SOURCES.CONTENTSTACK,
5520
- DATA_SOURCES.COMPONENT_PROPS,
5521
- DATA_SOURCES.TEMPLATE,
5522
- DATA_SOURCES.REPEATER,
5523
- ];
5524
- const isCSLPAbleType = bindedField?.type && cslpAbleTypes.includes(bindedField.type);
5762
+ const isCSLPAbleType = bindedField?.type &&
5763
+ dataSourceCapabilities[bindedField.type]?.supportsCslp;
5525
5764
  if (cslp.appendTags && dataPath && isCSLPAbleType) {
5526
5765
  const cslpValue = getCslpTag({ bindedField: dataPath, data });
5527
5766
  if (cslpValue) {
@@ -5635,12 +5874,14 @@ exports.JSONRTERegistry = JSONRTERegistry;
5635
5874
  exports.STYLE_SECTIONS_OPTIONS = STYLE_SECTIONS_OPTIONS;
5636
5875
  exports.STYLE_SECTION_CATEGORIES = STYLE_SECTION_CATEGORIES;
5637
5876
  exports.SYSTEM_COMPONENTS = SYSTEM_COMPONENTS;
5877
+ exports.convertBindingPath = convertBindingPath;
5638
5878
  exports.getBindingString = getBindingString;
5639
5879
  exports.getCslpPath = getCslpPath;
5640
5880
  exports.getCslpTag = getCslpTag;
5641
5881
  exports.getDataType = getDataType;
5642
5882
  exports.getDefaultPropStaticValue = getDefaultPropStaticValue;
5643
5883
  exports.getDesignClassesNames = getDesignClassesNames;
5884
+ exports.getFlattenedData = getFlattenedData;
5644
5885
  exports.getPlaceHolderComponent = getPlaceHolderComponent;
5645
5886
  exports.getRepeaterBinding = getRepeaterBinding;
5646
5887
  exports.getRepeaterContextPath = getRepeaterContextPath;