@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.
- package/dist/cjs/index.cjs +313 -72
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/component-registry/registry.constant.js +1 -0
- package/dist/esm/component-registry/registry.constant.js.map +1 -1
- package/dist/esm/component-registry/registry.js +17 -1
- package/dist/esm/component-registry/registry.js.map +1 -1
- 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 +103 -23
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.util.js +50 -51
- 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 +5 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/registry-error-messages.default.js +22 -0
- package/dist/esm/utils/registry-error-messages.default.js.map +1 -0
- package/dist/esm/utils/registry-error-messages.js +40 -0
- package/dist/esm/utils/registry-error-messages.js.map +1 -0
- package/package.json +7 -7
|
@@ -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;;;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodePropType, NodePropTypes, Node, NodePropStaticValueTypes, BindableNodePropType, NodePropsWithSlot
|
|
1
|
+
import { NodePropType, NodePropTypes, Node, BindingType, NodePropStaticValueTypes, BindableNodePropType, NodePropsWithSlot } from '@contentstack/studio-internal';
|
|
2
2
|
import { Properties } from 'csstype';
|
|
3
3
|
import { IJsonToHtmlOptions } from '@contentstack/json-rte-serializer';
|
|
4
4
|
import * as React from 'react';
|
|
@@ -97,6 +97,7 @@ declare const DATA_SOURCES: {
|
|
|
97
97
|
readonly TEMPLATE: "template";
|
|
98
98
|
readonly CONTENTSTACK: "contentstack";
|
|
99
99
|
readonly REPEATER: "repeater";
|
|
100
|
+
readonly QUERY: "contentstack_queries";
|
|
100
101
|
readonly SYMBOL_PROPS: "symbol_props";
|
|
101
102
|
};
|
|
102
103
|
declare const INTERNAL_COMPONENT_SECTIONS: {
|
|
@@ -1145,6 +1146,8 @@ declare function isKnownType(type: string): type is PropType;
|
|
|
1145
1146
|
declare function getSlotData<T>({ nodeProps, field, node, getSlots, }: GetSlotDataArgs<T>): T | null;
|
|
1146
1147
|
declare function getPlaceHolderComponent<T>(placeholders: PlaceHolders<T>, prop: PropInput, type: BindableNodePropType): any;
|
|
1147
1148
|
declare const getBindingString: (binding: BindingType) => string;
|
|
1149
|
+
declare const convertBindingPath: (bindingType: string, path: string) => string | string[];
|
|
1150
|
+
declare const getFlattenedData: (data: any) => any;
|
|
1148
1151
|
declare const resolveMetadataBindings: (node: Node, data: ComposableStudioData) => void;
|
|
1149
1152
|
declare const getRepeaterContextPath: (binding: RepeaterBindingValue) => string;
|
|
1150
1153
|
declare function isDataMatchingPropType(data: unknown, type: BindableNodePropType): boolean;
|
|
@@ -1193,5 +1196,5 @@ declare class BreakpointRegistry {
|
|
|
1193
1196
|
declare const getSymbolUIDFromNode: (symbol: Node) => string;
|
|
1194
1197
|
declare const getSymbolUIDFromUID: (uid: string) => string;
|
|
1195
1198
|
|
|
1196
|
-
export { ALLOWED_DESIGN_VALUES_LEVELS, BUILT_IN_COMPONENTS, BreakpointRegistry, ComponentRegistry, DATA_SOURCES, DATA_SOURCES_PREFIX, DEFAULT_DESIGN_TOKENS, DesignRegistry, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, JSONRTERegistry, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS, getBindingString, getCslpPath, getCslpTag, getDataType, getDefaultPropStaticValue, getDesignClassesNames, getPlaceHolderComponent, getRepeaterBinding, getRepeaterContextPath, getSlotData, getSymbolUIDFromNode, getSymbolUIDFromUID, isDataMatchingPropType, isKnownType, resolveMetadataBindings, retrievePropValue };
|
|
1199
|
+
export { ALLOWED_DESIGN_VALUES_LEVELS, BUILT_IN_COMPONENTS, BreakpointRegistry, ComponentRegistry, DATA_SOURCES, DATA_SOURCES_PREFIX, DEFAULT_DESIGN_TOKENS, DesignRegistry, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, JSONRTERegistry, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS, convertBindingPath, getBindingString, getCslpPath, getCslpTag, getDataType, getDefaultPropStaticValue, getDesignClassesNames, getFlattenedData, getPlaceHolderComponent, getRepeaterBinding, getRepeaterContextPath, getSlotData, getSymbolUIDFromNode, getSymbolUIDFromUID, isDataMatchingPropType, isKnownType, resolveMetadataBindings, retrievePropValue };
|
|
1197
1200
|
export type { AllowedDesignValues, AllowedDesignValuesLevel, AnyProp, ArrayProp, BooleanProp, Breakpoint, BreakpointInput, CSBindingPath, CSDataSources, ChoiceProp, ComponentRegistryOptions, ComponentType, ComposableStudioData, ContentstackBindingValue, CssVariablesToDesignTokens, CssVariablesToValue, DataSourceItem, DataSources, DateStringProp, DefaultBreakpoint, DesignClassValue, DesignClasses, DesignClassesInput, DesignClassesNames, DesignTokenCssVariable, DesignTokens, DesignTokensInput, DesignTokensInputKeys, DesignTokensOptions, DesignTokensOptionsInput, GetSlots, GetSlotsParams, GlobalDesignTokens, HrefProp, ICSEntryReference, ImageUrlProp, InternalComponentRegistryOptions, JSONRTERegistryOptions, JsonRTEProp, LengthToken, NodeProps, NumberProp, ObjectInput, ObjectProp, PlaceHolders, PreProcessedBreakpoint, PreProcessedDesignTokenInput, PropBase, PropInput, PropType, PropTypeOfNoOptionsRequired, PropValidator, Props, PropsWithNoOptionsRequired, RawStaticValue, RegisterComponentOptionsInput, RegisterComponentSchema, RegisterComponentSchemaInput, RegisterInternalComponentOptionsInput, Registry, RepeaterBindingValue, SectionDesignTokens, SlotProp, StaticValue, StaticValueItem, StaticValueUid, StringProp, StudioSpecData, StyleGroupOptions, StyleSectionCategoriesOptions, StyleSectionOptions, StyleSections, TemplateBindingValue };
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { getDesignClassesNames } from './design-registry/design-classes.js';
|
|
|
5
5
|
export { ALLOWED_DESIGN_VALUES_LEVELS, DEFAULT_DESIGN_TOKENS } from './design-registry/constants.js';
|
|
6
6
|
export { JSONRTERegistry } from './json-rte-registry/index.js';
|
|
7
7
|
export { retrievePropValue } from './data-binder/retrieve-data.js';
|
|
8
|
-
export { getBindingString, getDataType, getDefaultPropStaticValue, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, resolveMetadataBindings } from './data-binder/retrieve-data.util.js';
|
|
8
|
+
export { convertBindingPath, getBindingString, getDataType, getDefaultPropStaticValue, getFlattenedData, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, resolveMetadataBindings } from './data-binder/retrieve-data.util.js';
|
|
9
9
|
export { getCslpPath, getCslpTag, getRepeaterBinding } from './data-binder/cslp.js';
|
|
10
10
|
export { BreakpointRegistry } from './breakpoint-registry/index.js';
|
|
11
11
|
export { getSymbolUIDFromNode, getSymbolUIDFromUID } from './utils/symbols.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys for registry error message lookup. Use these constants instead of string literals.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
const RegistryErrorMessageKey = {
|
|
6
|
+
DATA_BINDING_TYPE_MISMATCH: "DATA_BINDING_TYPE_MISMATCH",
|
|
7
|
+
DATA_BINDING_TYPE_MISMATCH_EDITOR: "DATA_BINDING_TYPE_MISMATCH_EDITOR",
|
|
8
|
+
PROP_VALIDATION_FAILED: "PROP_VALIDATION_FAILED",
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Default (en) error message templates for studio-registry. Single source of truth.
|
|
12
|
+
* Use getRegistryErrorMessage() with RegistryErrorMessageKey constants.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
const defaultRegistryErrorMessages = {
|
|
16
|
+
[RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH]: 'Data binding type mismatch in component "{component}": Expected prop "{field}" to be {expectedType} but received {receivedType}. Path: {dataPath}',
|
|
17
|
+
[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.",
|
|
18
|
+
[RegistryErrorMessageKey.PROP_VALIDATION_FAILED]: 'Prop validation failed for "{prop}" in component "{component}": {validationError}',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { RegistryErrorMessageKey, defaultRegistryErrorMessages };
|
|
22
|
+
//# sourceMappingURL=registry-error-messages.default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-error-messages.default.js","sources":["../../../src/utils/registry-error-messages.default.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AACI,MAAM,uBAAuB,GAAG;AACrC,IAAA,0BAA0B,EAAE,4BAA4B;AACxD,IAAA,iCAAiC,EAAE,mCAAmC;AACtE,IAAA,sBAAsB,EAAE,wBAAwB;;AAKlD;;;;AAIG;AACI,MAAM,4BAA4B,GAGrC;AACF,IAAA,CAAC,uBAAuB,CAAC,0BAA0B,GACjD,mJAAmJ;AACrJ,IAAA,CAAC,uBAAuB,CAAC,iCAAiC,GACxD,yIAAyI;AAC3I,IAAA,CAAC,uBAAuB,CAAC,sBAAsB,GAC7C,mFAAmF;;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defaultRegistryErrorMessages } from './registry-error-messages.default.js';
|
|
2
|
+
export { RegistryErrorMessageKey } from './registry-error-messages.default.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Error message lookup for studio-registry. Messages are defined in registry-error-messages.default.ts.
|
|
6
|
+
* Use getRegistryErrorMessage with RegistryErrorMessageKey constants (no string literals).
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Returns the message string for the given key, substituting placeholders with params.
|
|
11
|
+
* Placeholders: {component}, {field}, {expectedType}, {receivedType}, {dataPath}, {prop}, {validationError}
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function getRegistryErrorMessage(key, params) {
|
|
15
|
+
let template = defaultRegistryErrorMessages[key];
|
|
16
|
+
if (template == null) {
|
|
17
|
+
return String(key);
|
|
18
|
+
}
|
|
19
|
+
if (!params) {
|
|
20
|
+
return template;
|
|
21
|
+
}
|
|
22
|
+
const replacements = [
|
|
23
|
+
["component", params.component],
|
|
24
|
+
["field", params.field],
|
|
25
|
+
["expectedType", params.expectedType],
|
|
26
|
+
["receivedType", params.receivedType],
|
|
27
|
+
["dataPath", params.dataPath],
|
|
28
|
+
["prop", params.prop],
|
|
29
|
+
["validationError", params.validationError],
|
|
30
|
+
];
|
|
31
|
+
for (const [placeholder, value] of replacements) {
|
|
32
|
+
if (value !== undefined) {
|
|
33
|
+
template = template.replace(new RegExp(`\\{${placeholder}\\}`, "g"), String(value));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return template;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { getRegistryErrorMessage };
|
|
40
|
+
//# sourceMappingURL=registry-error-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-error-messages.js","sources":["../../../src/utils/registry-error-messages.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;AAIG;AAoBH;;;;AAIG;AACG,SAAU,uBAAuB,CACrC,GAAgC,EAChC,MAAmC,EAAA;AAEnC,IAAA,IAAI,QAAQ,GAAG,4BAA4B,CAAC,GAAG,CAAC;AAChD,IAAA,IAAI,QAAQ,IAAI,IAAI,EAAE;AACpB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB;IACA,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,MAAM,YAAY,GAAmC;AACnD,QAAA,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC;AAC/B,QAAA,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;AACvB,QAAA,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC;AACrC,QAAA,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC;AACrC,QAAA,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC;AAC7B,QAAA,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;AACrB,QAAA,CAAC,iBAAiB,EAAE,MAAM,CAAC,eAAe,CAAC;KAC5C;IACD,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE;AAC/C,QAAA,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,QAAQ,GAAG,QAAQ,CAAC,OAAO,CACzB,IAAI,MAAM,CAAC,CAAA,GAAA,EAAM,WAAW,KAAK,EAAE,GAAG,CAAC,EACvC,MAAM,CAAC,KAAK,CAAC,CACd;QACH;IACF;AACA,IAAA,OAAO,QAAQ;AACjB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/studio-registry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "This package houses all the registry related to the visual builder",
|
|
5
5
|
"main": "dist/cjs/index.cjs",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@contentstack/common-config": "^1.1.
|
|
19
|
-
"@contentstack/studio-internal": "^1.
|
|
18
|
+
"@contentstack/common-config": "^1.1.6",
|
|
19
|
+
"@contentstack/studio-internal": "^1.2.0",
|
|
20
20
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
21
21
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
22
|
-
"@rollup/plugin-terser": "^0.
|
|
22
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
23
23
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
24
24
|
"happy-dom": "^20.0.1",
|
|
25
25
|
"rollup": "^4.46.2",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@contentstack/json-rte-serializer": "^3.0.4",
|
|
56
|
-
"@contentstack/studio-message-types": "^1.
|
|
57
|
-
"@contentstack/studio-messenger": "^1.
|
|
56
|
+
"@contentstack/studio-message-types": "^1.2.0",
|
|
57
|
+
"@contentstack/studio-messenger": "^1.3.0",
|
|
58
58
|
"csstype": "^3.1.3",
|
|
59
59
|
"lodash-es": "^4.17.23"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "9ff4f8381cb17d0e06ad91be106e1f4628de55fd"
|
|
62
62
|
}
|