@kaskad/schema 0.0.1 → 0.0.2
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/fesm2022/kaskad-schema.mjs +1368 -0
- package/fesm2022/kaskad-schema.mjs.map +1 -0
- package/package.json +9 -9
- package/types/kaskad-schema.d.ts +125 -0
- package/esm2022/index.js +0 -17
- package/esm2022/index.js.map +0 -1
- package/esm2022/kaskad-schema.js +0 -5
- package/esm2022/kaskad-schema.js.map +0 -1
- package/esm2022/lib/load/load-schema.js +0 -16
- package/esm2022/lib/load/load-schema.js.map +0 -1
- package/esm2022/lib/load/load-templates.js +0 -136
- package/esm2022/lib/load/load-templates.js.map +0 -1
- package/esm2022/lib/load/register-declared-type.js +0 -28
- package/esm2022/lib/load/register-declared-type.js.map +0 -1
- package/esm2022/lib/load/schema-component-extractor.js +0 -101
- package/esm2022/lib/load/schema-component-extractor.js.map +0 -1
- package/esm2022/lib/load/template-registry.js +0 -51
- package/esm2022/lib/load/template-registry.js.map +0 -1
- package/esm2022/lib/types/component-definition.js +0 -1
- package/esm2022/lib/types/component-definition.js.map +0 -1
- package/esm2022/lib/types/component-schema.js +0 -1
- package/esm2022/lib/types/component-schema.js.map +0 -1
- package/esm2022/lib/types/raw-schemas.js +0 -3
- package/esm2022/lib/types/raw-schemas.js.map +0 -1
- package/esm2022/lib/types/template-raw-definition.js +0 -1
- package/esm2022/lib/types/template-raw-definition.js.map +0 -1
- package/esm2022/lib/unfolding/computation/unfold-computation-schema.js +0 -70
- package/esm2022/lib/unfolding/computation/unfold-computation-schema.js.map +0 -1
- package/esm2022/lib/unfolding/computation/unfold-for-new-syntax.js +0 -147
- package/esm2022/lib/unfolding/computation/unfold-for-new-syntax.js.map +0 -1
- package/esm2022/lib/unfolding/computation/unfold-for.js +0 -45
- package/esm2022/lib/unfolding/computation/unfold-for.js.map +0 -1
- package/esm2022/lib/unfolding/computation/unfold-if.js +0 -18
- package/esm2022/lib/unfolding/computation/unfold-if.js.map +0 -1
- package/esm2022/lib/unfolding/computation/unfold-import.js +0 -26
- package/esm2022/lib/unfolding/computation/unfold-import.js.map +0 -1
- package/esm2022/lib/unfolding/computation/unfold-interpolation.js +0 -44
- package/esm2022/lib/unfolding/computation/unfold-interpolation.js.map +0 -1
- package/esm2022/lib/unfolding/parse-binding-shorthand.js +0 -40
- package/esm2022/lib/unfolding/parse-binding-shorthand.js.map +0 -1
- package/esm2022/lib/unfolding/parse-property-key-shorthand.js +0 -9
- package/esm2022/lib/unfolding/parse-property-key-shorthand.js.map +0 -1
- package/esm2022/lib/unfolding/parse-value-type.js +0 -115
- package/esm2022/lib/unfolding/parse-value-type.js.map +0 -1
- package/esm2022/lib/unfolding/to-full-notation.js +0 -124
- package/esm2022/lib/unfolding/to-full-notation.js.map +0 -1
- package/esm2022/lib/unfolding/unfold-flat-wrapper-notation.js +0 -72
- package/esm2022/lib/unfolding/unfold-flat-wrapper-notation.js.map +0 -1
- package/esm2022/lib/unfolding/unfold-node-schema.js +0 -35
- package/esm2022/lib/unfolding/unfold-node-schema.js.map +0 -1
- package/esm2022/lib/unfolding/unfold-property.js +0 -21
- package/esm2022/lib/unfolding/unfold-property.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/index.js +0 -11
- package/esm2022/lib/unfolding/value/handlers/index.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-array.js +0 -9
- package/esm2022/lib/unfolding/value/handlers/unfold-array.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-boolean.js +0 -8
- package/esm2022/lib/unfolding/value/handlers/unfold-boolean.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-command.js +0 -22
- package/esm2022/lib/unfolding/value/handlers/unfold-command.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-component-schema.js +0 -14
- package/esm2022/lib/unfolding/value/handlers/unfold-component-schema.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-component.js +0 -66
- package/esm2022/lib/unfolding/value/handlers/unfold-component.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-map.js +0 -13
- package/esm2022/lib/unfolding/value/handlers/unfold-map.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-number.js +0 -11
- package/esm2022/lib/unfolding/value/handlers/unfold-number.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-object.js +0 -15
- package/esm2022/lib/unfolding/value/handlers/unfold-object.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-set.js +0 -6
- package/esm2022/lib/unfolding/value/handlers/unfold-set.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-shape.js +0 -13
- package/esm2022/lib/unfolding/value/handlers/unfold-shape.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-string.js +0 -8
- package/esm2022/lib/unfolding/value/handlers/unfold-string.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-unknown.js +0 -4
- package/esm2022/lib/unfolding/value/handlers/unfold-unknown.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/unfold-variant-shape.js +0 -61
- package/esm2022/lib/unfolding/value/handlers/unfold-variant-shape.js.map +0 -1
- package/esm2022/lib/unfolding/value/handlers/validate-props.js +0 -20
- package/esm2022/lib/unfolding/value/handlers/validate-props.js.map +0 -1
- package/esm2022/lib/unfolding/value/throw-unfold-value-error.js +0 -11
- package/esm2022/lib/unfolding/value/throw-unfold-value-error.js.map +0 -1
- package/esm2022/lib/unfolding/value/unfold-node-value.js +0 -30
- package/esm2022/lib/unfolding/value/unfold-node-value.js.map +0 -1
- package/esm2022/lib/util/is-object.js +0 -4
- package/esm2022/lib/util/is-object.js.map +0 -1
- package/esm2022/lib/util/stringify-object.js +0 -4
- package/esm2022/lib/util/stringify-object.js.map +0 -1
- package/esm2022/lib/util/unfold-component-definitions.js +0 -21
- package/esm2022/lib/util/unfold-component-definitions.js.map +0 -1
- package/index.d.ts +0 -16
- package/kaskad-schema.d.ts +0 -5
- package/lib/load/load-schema.d.ts +0 -3
- package/lib/load/load-templates.d.ts +0 -2
- package/lib/load/register-declared-type.d.ts +0 -1
- package/lib/load/schema-component-extractor.d.ts +0 -2
- package/lib/load/template-registry.d.ts +0 -16
- package/lib/types/component-definition.d.ts +0 -5
- package/lib/types/component-schema.d.ts +0 -26
- package/lib/types/raw-schemas.d.ts +0 -25
- package/lib/types/template-raw-definition.d.ts +0 -7
- package/lib/unfolding/computation/unfold-computation-schema.d.ts +0 -2
- package/lib/unfolding/computation/unfold-for-new-syntax.d.ts +0 -6
- package/lib/unfolding/computation/unfold-for.d.ts +0 -2
- package/lib/unfolding/computation/unfold-if.d.ts +0 -3
- package/lib/unfolding/computation/unfold-import.d.ts +0 -2
- package/lib/unfolding/computation/unfold-interpolation.d.ts +0 -3
- package/lib/unfolding/parse-binding-shorthand.d.ts +0 -3
- package/lib/unfolding/parse-property-key-shorthand.d.ts +0 -2
- package/lib/unfolding/parse-value-type.d.ts +0 -2
- package/lib/unfolding/to-full-notation.d.ts +0 -8
- package/lib/unfolding/unfold-flat-wrapper-notation.d.ts +0 -13
- package/lib/unfolding/unfold-node-schema.d.ts +0 -3
- package/lib/unfolding/unfold-property.d.ts +0 -2
- package/lib/unfolding/value/handlers/index.d.ts +0 -10
- package/lib/unfolding/value/handlers/unfold-array.d.ts +0 -3
- package/lib/unfolding/value/handlers/unfold-boolean.d.ts +0 -2
- package/lib/unfolding/value/handlers/unfold-command.d.ts +0 -3
- package/lib/unfolding/value/handlers/unfold-component-schema.d.ts +0 -4
- package/lib/unfolding/value/handlers/unfold-component.d.ts +0 -3
- package/lib/unfolding/value/handlers/unfold-map.d.ts +0 -3
- package/lib/unfolding/value/handlers/unfold-number.d.ts +0 -2
- package/lib/unfolding/value/handlers/unfold-object.d.ts +0 -3
- package/lib/unfolding/value/handlers/unfold-set.d.ts +0 -3
- package/lib/unfolding/value/handlers/unfold-shape.d.ts +0 -3
- package/lib/unfolding/value/handlers/unfold-string.d.ts +0 -2
- package/lib/unfolding/value/handlers/unfold-unknown.d.ts +0 -2
- package/lib/unfolding/value/handlers/unfold-variant-shape.d.ts +0 -3
- package/lib/unfolding/value/handlers/validate-props.d.ts +0 -2
- package/lib/unfolding/value/throw-unfold-value-error.d.ts +0 -2
- package/lib/unfolding/value/unfold-node-value.d.ts +0 -8
- package/lib/util/is-object.d.ts +0 -1
- package/lib/util/stringify-object.d.ts +0 -1
- package/lib/util/unfold-component-definitions.d.ts +0 -4
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-boolean.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAc,EAAE,EAAE;IAC9C,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACtC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport const unfoldBoolean = (ctx: UnfoldCtx) => {\n if (typeof ctx.rawValue !== 'boolean') {\n throwUnfoldError(ctx);\n }\n return ctx.rawValue;\n};\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../../util/is-object';
|
|
2
|
-
import { throwUnfoldError } from '../throw-unfold-value-error';
|
|
3
|
-
export function unfoldCommand(ctx) {
|
|
4
|
-
const rawValue = ctx.rawValue;
|
|
5
|
-
if (typeof rawValue === 'string') {
|
|
6
|
-
return { runnerType: 'js', target: rawValue, owner: null };
|
|
7
|
-
}
|
|
8
|
-
if (isObject(rawValue) && 'runnerType' in rawValue && 'target' in rawValue) {
|
|
9
|
-
if (typeof rawValue['runnerType'] !== 'string') {
|
|
10
|
-
throw new Error(`Command schema is invalid. Field "runnerType" must be string.`);
|
|
11
|
-
}
|
|
12
|
-
if (!rawValue['target']) {
|
|
13
|
-
throw new Error(`Command schema is invalid. Field "target" must be defined.`);
|
|
14
|
-
}
|
|
15
|
-
return rawValue;
|
|
16
|
-
}
|
|
17
|
-
if (typeof rawValue === 'function') {
|
|
18
|
-
return { runnerType: 'inline', target: rawValue, owner: null };
|
|
19
|
-
}
|
|
20
|
-
throwUnfoldError(ctx);
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=unfold-command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-command.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,UAAU,aAAa,CAAC,GAAgC;IAC5D,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAE9B,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC7D,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,YAAY,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAC3E,IAAI,OAAO,QAAQ,CAAC,YAAY,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,QAAwB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC1E,CAAC;IAED,gBAAgB,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import { AnyFn, CommandValue, CommandValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldCommand(ctx: UnfoldCtx<CommandValueType>): CommandValue {\n const rawValue = ctx.rawValue;\n\n if (typeof rawValue === 'string') {\n return { runnerType: 'js', target: rawValue, owner: null };\n }\n\n if (isObject(rawValue) && 'runnerType' in rawValue && 'target' in rawValue) {\n if (typeof rawValue['runnerType'] !== 'string') {\n throw new Error(`Command schema is invalid. Field \"runnerType\" must be string.`);\n }\n if (!rawValue['target']) {\n throw new Error(`Command schema is invalid. Field \"target\" must be defined.`);\n }\n return rawValue as CommandValue;\n }\n\n if (typeof rawValue === 'function') {\n return { runnerType: 'inline', target: rawValue as AnyFn, owner: null };\n }\n\n throwUnfoldError(ctx);\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../../util/is-object';
|
|
2
|
-
import { validateProps } from './validate-props';
|
|
3
|
-
export function unfoldComponentSchema(ctx) {
|
|
4
|
-
if (!isObject(ctx.rawValue)) {
|
|
5
|
-
throw new Error('Unfolded component schema type');
|
|
6
|
-
}
|
|
7
|
-
const componentRawSchema = ctx.rawValue;
|
|
8
|
-
if (!componentRawSchema.componentType) {
|
|
9
|
-
componentRawSchema.componentType = 'browser.Element';
|
|
10
|
-
}
|
|
11
|
-
validateProps(componentRawSchema);
|
|
12
|
-
return componentRawSchema;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=unfold-component-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-component-schema.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-component-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,UAAU,qBAAqB,CAAC,GAAwC;IAC5E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,kBAAkB,GAAG,GAAG,CAAC,QAA2B,CAAC;IAE3D,IAAI,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC;QACtC,kBAAkB,CAAC,aAAa,GAAG,iBAAiB,CAAC;IACvD,CAAC;IAED,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAElC,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["import { ComponentSchemaValueType } from '@kaskad/types';\n\nimport { ComponentRecipe } from '../../../types/component-schema';\nimport { isObject } from '../../../util/is-object';\nimport { UnfoldCtx } from '../unfold-node-value';\nimport { validateProps } from './validate-props';\n\nexport function unfoldComponentSchema(ctx: UnfoldCtx<ComponentSchemaValueType>) {\n if (!isObject(ctx.rawValue)) {\n throw new Error('Unfolded component schema type');\n }\n const componentRawSchema = ctx.rawValue as ComponentRecipe;\n\n if (!componentRawSchema.componentType) {\n componentRawSchema.componentType = 'browser.Element';\n }\n\n validateProps(componentRawSchema);\n\n return componentRawSchema;\n}\n"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Delimiters } from '@kaskad/config';
|
|
2
|
-
import { DefinitionStore } from '@kaskad/definition';
|
|
3
|
-
import { isObject } from '../../../util/is-object';
|
|
4
|
-
import { unfoldNodeSchema } from '../../unfold-node-schema';
|
|
5
|
-
import { unfoldProperty } from '../../unfold-property';
|
|
6
|
-
import { throwUnfoldError } from '../throw-unfold-value-error';
|
|
7
|
-
import { validateProps } from './validate-props';
|
|
8
|
-
export function unfoldComponent(ctx) {
|
|
9
|
-
if (typeof ctx.rawValue === 'string' && ctx.rawValue.startsWith('csid-')) {
|
|
10
|
-
return ctx.rawValue;
|
|
11
|
-
}
|
|
12
|
-
if (!isObject(ctx.rawValue)) {
|
|
13
|
-
throwUnfoldError(ctx);
|
|
14
|
-
}
|
|
15
|
-
const componentRawSchema = ctx.rawValue;
|
|
16
|
-
if (!componentRawSchema.componentType) {
|
|
17
|
-
componentRawSchema.componentType = 'browser.Element';
|
|
18
|
-
}
|
|
19
|
-
validateProps(componentRawSchema);
|
|
20
|
-
const properties = DefinitionStore.getInstance().getComputedComponentContract(componentRawSchema.componentType);
|
|
21
|
-
const props = new Map();
|
|
22
|
-
for (const [key, baseSchema] of Object.entries(properties)) {
|
|
23
|
-
if (!(key in componentRawSchema)) {
|
|
24
|
-
props.set(key, baseSchema);
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const unfoldedRawSchema = unfoldNodeSchema(componentRawSchema[key], baseSchema.valueType, [...ctx.nodePath, key]);
|
|
28
|
-
const node = {
|
|
29
|
-
valueType: baseSchema.valueType,
|
|
30
|
-
value: unfoldedRawSchema.value ?? baseSchema.value,
|
|
31
|
-
computation: unfoldedRawSchema.computation || baseSchema.computation,
|
|
32
|
-
binding: unfoldedRawSchema.binding || baseSchema.binding,
|
|
33
|
-
};
|
|
34
|
-
props.set(key, node);
|
|
35
|
-
}
|
|
36
|
-
const variables = new Map();
|
|
37
|
-
for (const [keyEx, schema] of Object.entries(componentRawSchema)) {
|
|
38
|
-
if (!keyEx.startsWith(Delimiters.Variable)) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const variableKeyEx = keyEx.slice(Delimiters.Variable.length);
|
|
42
|
-
const [key, unfolded] = unfoldProperty(variableKeyEx, schema);
|
|
43
|
-
variables.set(key, unfolded);
|
|
44
|
-
}
|
|
45
|
-
const rawHandlers = componentRawSchema.onNodeChange || [];
|
|
46
|
-
const onNodeChange = rawHandlers.map((handler) => {
|
|
47
|
-
if (!handler.selector) {
|
|
48
|
-
throw new Error(`onNodeChange handler "${JSON.stringify(handler)}" is missing required selector.`);
|
|
49
|
-
}
|
|
50
|
-
if (!handler.command) {
|
|
51
|
-
throw new Error(`onNodeChange handler "${JSON.stringify(handler)}" is missing required command.`);
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
selector: handler.selector,
|
|
55
|
-
command: unfoldNodeSchema(handler.command, { type: 'command' }, ctx.nodePath),
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
componentType: componentRawSchema.componentType,
|
|
60
|
-
ref: componentRawSchema.ref || '',
|
|
61
|
-
props,
|
|
62
|
-
variables,
|
|
63
|
-
onNodeChange,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=unfold-component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-component.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,UAAU,eAAe,CAAC,GAAc;IAC5C,IAAI,OAAO,GAAG,CAAC,QAAQ,KA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CAAC;SAC9E,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,aAAa,EAAE,kBAAkB,CAAC,aAAa;QAC/C,GAAG,EAAE,kBAAkB,CAAC,GAAG,IAAI,EAAE;QACjC,KAAK;QACL,SAAS;QACT,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { Delimiters } from '@kaskad/config';\nimport { DefinitionStore } from '@kaskad/definition';\nimport { ComponentNodeValue, NodeChangeHandlerSchema, NodeSchema } from '@kaskad/types';\n\nimport { ComponentRecipe } from '../../../types/component-schema';\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { unfoldProperty } from '../../unfold-property';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\nimport { validateProps } from './validate-props';\n\nexport function unfoldComponent(ctx: UnfoldCtx): ComponentNodeValue {\n if (typeof ctx.rawValue === 'string' && ctx.rawValue.startsWith('csid-')) {\n return ctx.rawValue;\n }\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n const componentRawSchema = ctx.rawValue as ComponentRecipe;\n\n if (!componentRawSchema.componentType) {\n componentRawSchema.componentType = 'browser.Element';\n }\n\n validateProps(componentRawSchema);\n\n const properties = DefinitionStore.getInstance().getComputedComponentContract(componentRawSchema.componentType);\n\n const props = new Map<string, NodeSchema>();\n for (const [key, baseSchema] of Object.entries(properties)) {\n if (!(key in componentRawSchema)) {\n props.set(key, baseSchema);\n continue;\n }\n\n const unfoldedRawSchema = unfoldNodeSchema(componentRawSchema[key], baseSchema.valueType, [...ctx.nodePath, key]);\n\n const node = {\n valueType: baseSchema.valueType,\n value: unfoldedRawSchema.value ?? baseSchema.value,\n computation: unfoldedRawSchema.computation || baseSchema.computation,\n binding: unfoldedRawSchema.binding || baseSchema.binding,\n } as NodeSchema;\n\n props.set(key, node);\n }\n\n const variables = new Map<string, NodeSchema>();\n for (const [keyEx, schema] of Object.entries(componentRawSchema)) {\n if (!keyEx.startsWith(Delimiters.Variable)) {\n continue;\n }\n\n const variableKeyEx = keyEx.slice(Delimiters.Variable.length);\n const [key, unfolded] = unfoldProperty(variableKeyEx, schema);\n variables.set(key, unfolded);\n }\n\n const rawHandlers = componentRawSchema.onNodeChange || [];\n const onNodeChange: NodeChangeHandlerSchema[] = rawHandlers.map((handler) => {\n if (!handler.selector) {\n throw new Error(`onNodeChange handler \"${JSON.stringify(handler)}\" is missing required selector.`);\n }\n if (!handler.command) {\n throw new Error(`onNodeChange handler \"${JSON.stringify(handler)}\" is missing required command.`);\n }\n\n return {\n selector: handler.selector,\n command: unfoldNodeSchema(handler.command, { type: 'command' }, ctx.nodePath),\n };\n });\n\n return {\n componentType: componentRawSchema.componentType,\n ref: componentRawSchema.ref || '',\n props,\n variables,\n onNodeChange,\n };\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../../util/is-object';
|
|
2
|
-
import { unfoldNodeSchema } from '../../unfold-node-schema';
|
|
3
|
-
import { throwUnfoldError } from '../throw-unfold-value-error';
|
|
4
|
-
export function unfoldMap(ctx) {
|
|
5
|
-
if (!isObject(ctx.rawValue)) {
|
|
6
|
-
throwUnfoldError(ctx);
|
|
7
|
-
}
|
|
8
|
-
return Object.entries(ctx.rawValue).reduce((structure, [key, child]) => {
|
|
9
|
-
structure[key] = unfoldNodeSchema(child, ctx.valueType.item, [...ctx.nodePath, key]);
|
|
10
|
-
return structure;
|
|
11
|
-
}, {});
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=unfold-map.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-map.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-map.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,UAAU,SAAS,CAAC,GAA4B;IACpD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAA6B,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACjG,SAAS,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;QACrF,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import { MapValueType, NodeSchema } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldMap(ctx: UnfoldCtx<MapValueType>) {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n return Object.entries(ctx.rawValue).reduce<Record<string, NodeSchema>>((structure, [key, child]) => {\n structure[key] = unfoldNodeSchema(child, ctx.valueType.item, [...ctx.nodePath, key]);\n return structure;\n }, {});\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { throwUnfoldError } from '../throw-unfold-value-error';
|
|
2
|
-
export function unfoldNumber(ctx) {
|
|
3
|
-
if (!isValidNumber(ctx.rawValue)) {
|
|
4
|
-
throwUnfoldError(ctx);
|
|
5
|
-
}
|
|
6
|
-
return ctx.rawValue;
|
|
7
|
-
}
|
|
8
|
-
function isValidNumber(value) {
|
|
9
|
-
return typeof value === 'number' && !isNaN(value);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=unfold-number.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-number.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,UAAU,YAAY,CAAC,GAAc;IACzC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldNumber(ctx: UnfoldCtx) {\n if (!isValidNumber(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n return ctx.rawValue;\n}\n\nfunction isValidNumber(value: unknown) {\n return typeof value === 'number' && !isNaN(value);\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../../util/is-object';
|
|
2
|
-
import { unfoldNodeSchema } from '../../unfold-node-schema';
|
|
3
|
-
import { throwUnfoldError } from '../throw-unfold-value-error';
|
|
4
|
-
export function unfoldObject(ctx) {
|
|
5
|
-
if (!isObject(ctx.rawValue)) {
|
|
6
|
-
throwUnfoldError(ctx);
|
|
7
|
-
}
|
|
8
|
-
const rawObject = ctx.rawValue;
|
|
9
|
-
return Object.entries(ctx.valueType.fields).reduce((structure, [fieldKey, fieldValueType]) => {
|
|
10
|
-
const fieldValue = fieldKey in rawObject ? rawObject[fieldKey] : null;
|
|
11
|
-
structure[fieldKey] = unfoldNodeSchema(fieldValue, fieldValueType, [...ctx.nodePath, fieldKey]);
|
|
12
|
-
return structure;
|
|
13
|
-
}, {});
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=unfold-object.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-object.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-object.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,UAAU,YAAY,CAAC,GAA+B;IAC1D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,QAAmC,CAAC;IAE1D,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,CAChD,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,EAAE,EAAE;QACxC,MAAM,UAAU,GAAG,QAAQ,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACtE,SAAS,CAAC,QAAQ,CAAC,GAAG,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;QAChG,OAAO,SAAS,CAAC;IACnB,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { NodeSchema, ObjectValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldObject(ctx: UnfoldCtx<ObjectValueType>) {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n const rawObject = ctx.rawValue as Record<string, unknown>;\n\n return Object.entries(ctx.valueType.fields).reduce<Record<string, NodeSchema>>(\n (structure, [fieldKey, fieldValueType]) => {\n const fieldValue = fieldKey in rawObject ? rawObject[fieldKey] : null;\n structure[fieldKey] = unfoldNodeSchema(fieldValue, fieldValueType, [...ctx.nodePath, fieldKey]);\n return structure;\n },\n {},\n );\n}\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { unfoldNodeSchema } from '../../unfold-node-schema';
|
|
2
|
-
export function unfoldSet(ctx) {
|
|
3
|
-
const items = ctx.rawValue instanceof Set ? Array.from(ctx.rawValue) : Array.isArray(ctx.rawValue) ? ctx.rawValue : [];
|
|
4
|
-
return items.map((item, index) => unfoldNodeSchema(item, ctx.valueType.item, [...ctx.nodePath, index]));
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=unfold-set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-set.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-set.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,MAAM,UAAU,SAAS,CAAC,GAA4B;IACpD,MAAM,KAAK,GACT,GAAG,CAAC,QAAQ,YAAY,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3G,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["import { SetValueType } from '@kaskad/types';\n\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldSet(ctx: UnfoldCtx<SetValueType>) {\n const items =\n ctx.rawValue instanceof Set ? Array.from(ctx.rawValue) : Array.isArray(ctx.rawValue) ? ctx.rawValue : [];\n\n return items.map((item, index) => unfoldNodeSchema(item, ctx.valueType.item, [...ctx.nodePath, index]));\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DefinitionStore } from '@kaskad/definition';
|
|
2
|
-
import { isObject } from '../../../util/is-object';
|
|
3
|
-
import { throwUnfoldError } from '../throw-unfold-value-error';
|
|
4
|
-
import { unfoldObject } from './unfold-object';
|
|
5
|
-
export function unfoldShape(ctx) {
|
|
6
|
-
if (!isObject(ctx.rawValue)) {
|
|
7
|
-
throwUnfoldError(ctx);
|
|
8
|
-
}
|
|
9
|
-
const rawValue = ctx.rawValue;
|
|
10
|
-
const objectValueType = DefinitionStore.getInstance().getShape(ctx.valueType.shapeType);
|
|
11
|
-
return unfoldObject({ rawValue, valueType: objectValueType, nodePath: ctx.nodePath });
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=unfold-shape.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-shape.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-shape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,WAAW,CAAC,GAA8B;IACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAmC,CAAC;IACzD,MAAM,eAAe,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxF,OAAO,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import { DefinitionStore } from '@kaskad/definition';\nimport { ShapeValue, ShapeValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\nimport { unfoldObject } from './unfold-object';\n\nexport function unfoldShape(ctx: UnfoldCtx<ShapeValueType>): ShapeValue {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n const rawValue = ctx.rawValue as Record<string, unknown>;\n const objectValueType = DefinitionStore.getInstance().getShape(ctx.valueType.shapeType);\n return unfoldObject({ rawValue, valueType: objectValueType, nodePath: ctx.nodePath });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-string.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,UAAU,YAAY,CAAC,GAAc;IACzC,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACrC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtB,CAAC","sourcesContent":["import { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldString(ctx: UnfoldCtx) {\n if (typeof ctx.rawValue !== 'string') {\n throwUnfoldError(ctx);\n }\n return ctx.rawValue;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-unknown.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-unknown.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,GAAc;IAC1C,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtB,CAAC","sourcesContent":["import { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldUnknown(ctx: UnfoldCtx) {\n return ctx.rawValue;\n}\n"]}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { DefinitionStore } from '@kaskad/definition';
|
|
2
|
-
import { isObject } from '../../../util/is-object';
|
|
3
|
-
import { unfoldNodeSchema } from '../../unfold-node-schema';
|
|
4
|
-
import { throwUnfoldError } from '../throw-unfold-value-error';
|
|
5
|
-
function unfoldShortValidatorSyntax(rawValue) {
|
|
6
|
-
if ('validatorType' in rawValue) {
|
|
7
|
-
return rawValue;
|
|
8
|
-
}
|
|
9
|
-
const entries = Object.entries(rawValue);
|
|
10
|
-
const validatorEntries = entries.filter(([key]) => key !== 'message' && key !== 'disabled');
|
|
11
|
-
if (validatorEntries.length === 0) {
|
|
12
|
-
throw new Error(`Validator must have at least one validator type specified. Raw value: ${JSON.stringify(rawValue)}`);
|
|
13
|
-
}
|
|
14
|
-
if (validatorEntries.length > 1) {
|
|
15
|
-
throw new Error(`Validator can only have one validator type specified. Raw value: ${JSON.stringify(rawValue)}`);
|
|
16
|
-
}
|
|
17
|
-
const [validatorType, param] = validatorEntries[0];
|
|
18
|
-
const validator = {
|
|
19
|
-
validatorType,
|
|
20
|
-
params: {},
|
|
21
|
-
message: rawValue['message'] || '',
|
|
22
|
-
disabled: !!rawValue['disabled'],
|
|
23
|
-
};
|
|
24
|
-
if (isObject(param)) {
|
|
25
|
-
validator.params = param;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
validator.params = { [validatorType]: param };
|
|
29
|
-
}
|
|
30
|
-
return validator;
|
|
31
|
-
}
|
|
32
|
-
export function unfoldVariantShape(ctx) {
|
|
33
|
-
if (!isObject(ctx.rawValue)) {
|
|
34
|
-
throwUnfoldError(ctx);
|
|
35
|
-
}
|
|
36
|
-
let rawValue = ctx.rawValue;
|
|
37
|
-
if ('kind' in rawValue && 'fields' in rawValue) {
|
|
38
|
-
const kindKey = `${ctx.valueType.shapeType}Type`;
|
|
39
|
-
const kind = rawValue['kind'];
|
|
40
|
-
const fields = rawValue['fields'];
|
|
41
|
-
return {
|
|
42
|
-
...fields,
|
|
43
|
-
[kindKey]: kind,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const kindKey = `${ctx.valueType.shapeType}Type`;
|
|
47
|
-
if (kindKey === 'validatorType') {
|
|
48
|
-
rawValue = unfoldShortValidatorSyntax(rawValue);
|
|
49
|
-
}
|
|
50
|
-
const kind = rawValue[kindKey];
|
|
51
|
-
if (!kind) {
|
|
52
|
-
throw new Error(`Missing the kind field "${kindKey}"`);
|
|
53
|
-
}
|
|
54
|
-
const objectValueType = DefinitionStore.getInstance().getVariantShape(ctx.valueType.shapeType, kind);
|
|
55
|
-
const objectNode = unfoldNodeSchema(rawValue, objectValueType, ctx.nodePath);
|
|
56
|
-
return {
|
|
57
|
-
...objectNode.value,
|
|
58
|
-
[kindKey]: kind,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=unfold-variant-shape.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-vari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C,CAAC;IAErG,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7E,OAAO;QACL,GAAI,UAAU,CAAC,KAAoC;QACnD,CAAC,OAAO,CAAC,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import { DefinitionStore } from '@kaskad/definition';\nimport { NodeSchema, VariantShapeValue, VariantShapeValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nfunction unfoldShortValidatorSyntax(rawValue: Record<string, unknown>) {\n if ('validatorType' in rawValue) {\n return rawValue;\n }\n\n const entries = Object.entries(rawValue);\n const validatorEntries = entries.filter(([key]) => key !== 'message' && key !== 'disabled');\n\n if (validatorEntries.length === 0) {\n throw new Error(\n `Validator must have at least one validator type specified. Raw value: ${JSON.stringify(rawValue)}`,\n );\n }\n if (validatorEntries.length > 1) {\n throw new Error(`Validator can only have one validator type specified. Raw value: ${JSON.stringify(rawValue)}`);\n }\n\n const [validatorType, param] = validatorEntries[0];\n\n const validator = {\n validatorType,\n params: {},\n message: rawValue['message'] || '',\n disabled: !!rawValue['disabled'],\n };\n\n if (isObject(param)) {\n validator.params = param;\n } else {\n validator.params = { [validatorType]: param };\n }\n\n return validator;\n}\n\nexport function unfoldVariantShape(ctx: UnfoldCtx<VariantShapeValueType>): VariantShapeValue {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n let rawValue = ctx.rawValue as Record<string, unknown>;\n\n if ('kind' in rawValue && 'fields' in rawValue) {\n const kindKey = `${ctx.valueType.shapeType}Type`;\n const kind = rawValue['kind'] as string;\n const fields = rawValue['fields'] as Record<string, unknown>;\n\n return {\n ...fields,\n [kindKey]: kind,\n } as VariantShapeValue;\n }\n\n const kindKey = `${ctx.valueType.shapeType}Type`;\n\n if (kindKey === 'validatorType') {\n rawValue = unfoldShortValidatorSyntax(rawValue);\n }\n\n const kind = rawValue[kindKey] as string;\n\n if (!kind) {\n throw new Error(`Missing the kind field \"${kindKey}\"`);\n }\n\n const objectValueType = DefinitionStore.getInstance().getVariantShape(ctx.valueType.shapeType, kind);\n\n const objectNode = unfoldNodeSchema(rawValue, objectValueType, ctx.nodePath);\n return {\n ...(objectNode.value as Record<string, NodeSchema>),\n [kindKey]: kind,\n };\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Delimiters } from '@kaskad/config';
|
|
2
|
-
import { DefinitionStore } from '@kaskad/definition';
|
|
3
|
-
export function validateProps(rawSchema) {
|
|
4
|
-
const componentDefinitionProps = DefinitionStore.getInstance().getComputedComponentContract(rawSchema.componentType);
|
|
5
|
-
const ignoredSchemaProps = new Set([
|
|
6
|
-
'componentType',
|
|
7
|
-
'onNodeChange',
|
|
8
|
-
'ref',
|
|
9
|
-
'contract',
|
|
10
|
-
'defaultSlot',
|
|
11
|
-
'context',
|
|
12
|
-
'types',
|
|
13
|
-
'importTypes',
|
|
14
|
-
]);
|
|
15
|
-
const invalidProps = Object.keys(rawSchema).filter((prop) => !componentDefinitionProps[prop] && !ignoredSchemaProps.has(prop) && !prop.startsWith(Delimiters.Variable));
|
|
16
|
-
if (invalidProps.length) {
|
|
17
|
-
throw new Error(`Component schema "${rawSchema.componentType}" contains unknown properties: ${invalidProps.join(', ')}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=validate-props.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-props.js","sourceRoot":"","sources":["../../../../../../../../libs/schema/src/lib/unfolding/value/handlers/validate-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,MAAM,UAAU,aAAa,CAAC,SAA0B;IACtD,MAAM,wBAAwB,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,4BAA4B,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACrH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;QACjC,eAAe;QACf,cAAc;QACd,KAAK;QACL,UAAU;QACV,aAAa;QACb,SAAS;QACT,OAAO;QACP,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAChD,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CACpH,CAAC;IAEF,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,qBAAqB,SAAS,CAAC,aAAa,kCAAkC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxG,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { Delimiters } from '@kaskad/config';\nimport { DefinitionStore } from '@kaskad/definition';\n\nimport { ComponentRecipe } from '../../../types/component-schema';\n\nexport function validateProps(rawSchema: ComponentRecipe) {\n const componentDefinitionProps = DefinitionStore.getInstance().getComputedComponentContract(rawSchema.componentType);\n const ignoredSchemaProps = new Set([\n 'componentType',\n 'onNodeChange',\n 'ref',\n 'contract',\n 'defaultSlot',\n 'context',\n 'types',\n 'importTypes',\n ]);\n\n const invalidProps = Object.keys(rawSchema).filter(\n (prop) => !componentDefinitionProps[prop] && !ignoredSchemaProps.has(prop) && !prop.startsWith(Delimiters.Variable),\n );\n\n if (invalidProps.length) {\n throw new Error(\n `Component schema \"${rawSchema.componentType}\" contains unknown properties: ${invalidProps.join(', ')}`,\n );\n }\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { stringifyObject } from '../../util/stringify-object';
|
|
2
|
-
export function throwUnfoldError(ctx) {
|
|
3
|
-
let message = 'Error happened while unfolding node';
|
|
4
|
-
if (ctx.nodePath) {
|
|
5
|
-
message += `\nPath: ${JSON.stringify(ctx.nodePath)}.`;
|
|
6
|
-
}
|
|
7
|
-
message += stringifyObject('ValueType', ctx.valueType);
|
|
8
|
-
message += stringifyObject('Provided value', ctx.rawValue);
|
|
9
|
-
throw new Error(message);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=throw-unfold-value-error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throw-unfold-value-error.js","sourceRoot":"","sources":["../../../../../../../libs/schema/src/lib/unfolding/value/throw-unfold-value-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,MAAM,UAAU,gBAAgB,CAAC,GAAc;IAC7C,IAAI,OAAO,GAAG,qCAAqC,CAAC;IACpD,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,IAAI,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,eAAe,CAAC,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACvD,OAAO,IAAI,eAAe,CAAC,gBAAgB,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE3D,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { stringifyObject } from '../../util/stringify-object';\nimport { UnfoldCtx } from './unfold-node-value';\n\nexport function throwUnfoldError(ctx: UnfoldCtx): never {\n let message = 'Error happened while unfolding node';\n if (ctx.nodePath) {\n message += `\\nPath: ${JSON.stringify(ctx.nodePath)}.`;\n }\n message += stringifyObject('ValueType', ctx.valueType);\n message += stringifyObject('Provided value', ctx.rawValue);\n\n throw new Error(message);\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { unfoldArray, unfoldBoolean, unfoldCommand, unfoldComponent, unfoldComponentSchema, unfoldMap, unfoldNumber, unfoldObject, unfoldString, unfoldUnknown, } from './handlers';
|
|
2
|
-
import { unfoldSet } from './handlers/unfold-set';
|
|
3
|
-
import { unfoldShape } from './handlers/unfold-shape';
|
|
4
|
-
import { unfoldVariantShape } from './handlers/unfold-variant-shape';
|
|
5
|
-
const handlers = {
|
|
6
|
-
unknown: unfoldUnknown,
|
|
7
|
-
number: unfoldNumber,
|
|
8
|
-
string: unfoldString,
|
|
9
|
-
boolean: unfoldBoolean,
|
|
10
|
-
array: unfoldArray,
|
|
11
|
-
map: unfoldMap,
|
|
12
|
-
set: unfoldSet,
|
|
13
|
-
object: unfoldObject,
|
|
14
|
-
shape: unfoldShape,
|
|
15
|
-
variantShape: unfoldVariantShape,
|
|
16
|
-
command: unfoldCommand,
|
|
17
|
-
componentSchema: unfoldComponentSchema,
|
|
18
|
-
component: unfoldComponent,
|
|
19
|
-
};
|
|
20
|
-
export function unfoldValue(ctx) {
|
|
21
|
-
const handler = handlers[ctx.valueType.type];
|
|
22
|
-
if (!handler) {
|
|
23
|
-
throw new Error(`Cannot unfold value "${ctx.rawValue}". Unknown value type '${ctx.valueType.type}'`);
|
|
24
|
-
}
|
|
25
|
-
if (ctx.rawValue === undefined || ctx.rawValue === null) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return handler(ctx);
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=unfold-node-value.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-node-value.js","sourceRoot":"","sources":["../../../../../../../libs/schema/src/lib/unfolding/value/unfold-node-value.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAUrE,MAAM,QAAQ,GAAuC;IACnD,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,WAAW;IAClB,YAAY,EAAE,kBAAkB;IAChC,OAAO,EAAE,aAAa;IACtB,eAAe,EAAE,qBAAqB;IACtC,SAAS,EAAE,eAAe;CAC3B,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,GAAc;IACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAY,CAAC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,CAAC,QAAQ,0BAA0B,GAAG,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;IACvG,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import { NodePath, NodeSchema, ValueType } from '@kaskad/types';\n\nimport {\n unfoldArray,\n unfoldBoolean,\n unfoldCommand,\n unfoldComponent,\n unfoldComponentSchema,\n unfoldMap,\n unfoldNumber,\n unfoldObject,\n unfoldString,\n unfoldUnknown,\n} from './handlers';\nimport { unfoldSet } from './handlers/unfold-set';\nimport { unfoldShape } from './handlers/unfold-shape';\nimport { unfoldVariantShape } from './handlers/unfold-variant-shape';\n\nexport type UnfoldCtx<T extends ValueType = ValueType> = {\n rawValue: unknown;\n valueType: T;\n nodePath: NodePath;\n};\n\nexport type Handler = (ctx: UnfoldCtx) => NodeSchema['value'];\n\nconst handlers: Record<ValueType['type'], unknown> = {\n unknown: unfoldUnknown,\n number: unfoldNumber,\n string: unfoldString,\n boolean: unfoldBoolean,\n array: unfoldArray,\n map: unfoldMap,\n set: unfoldSet,\n object: unfoldObject,\n shape: unfoldShape,\n variantShape: unfoldVariantShape,\n command: unfoldCommand,\n componentSchema: unfoldComponentSchema,\n component: unfoldComponent,\n};\n\nexport function unfoldValue(ctx: UnfoldCtx) {\n const handler = handlers[ctx.valueType.type] as Handler;\n if (!handler) {\n throw new Error(`Cannot unfold value \"${ctx.rawValue}\". Unknown value type '${ctx.valueType.type}'`);\n }\n if (ctx.rawValue === undefined || ctx.rawValue === null) {\n return null;\n }\n return handler(ctx);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-object.js","sourceRoot":"","sources":["../../../../../../libs/schema/src/lib/util/is-object.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,CAAC;AACzG,CAAC","sourcesContent":["export function isObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Set);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-object.js","sourceRoot":"","sources":["../../../../../../libs/schema/src/lib/util/stringify-object.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,IAAa;IAC1D,OAAO,KAAK,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;AACzD,CAAC","sourcesContent":["export function stringifyObject(label: string, data: unknown): string {\n return `\\n${label}:\\n${JSON.stringify(data, null, 2)}`;\n}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { unfoldProperty } from '../unfolding/unfold-property';
|
|
2
|
-
export function unfoldComponentDefinition(rawDefinition) {
|
|
3
|
-
const properties = {};
|
|
4
|
-
for (const entry of Object.entries(rawDefinition.properties)) {
|
|
5
|
-
const [key, prop] = unfoldProperty(...entry);
|
|
6
|
-
properties[key] = prop;
|
|
7
|
-
}
|
|
8
|
-
return {
|
|
9
|
-
traits: rawDefinition.traits,
|
|
10
|
-
properties,
|
|
11
|
-
defaultSlot: rawDefinition.defaultSlot,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function unfoldComponentDefinitions(rawDefinitions) {
|
|
15
|
-
const result = {};
|
|
16
|
-
for (const [componentType, rawDefinition] of Object.entries(rawDefinitions)) {
|
|
17
|
-
result[componentType] = unfoldComponentDefinition(rawDefinition);
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=unfold-component-definitions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unfold-component-definitions.js","sourceRoot":"","sources":["../../../../../../libs/schema/src/lib/util/unfold-component-definitions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,UAAU,yBAAyB,CAAC,aAAqC;IAC7E,MAAM,UAAU,GAA+B,EAAE,CAAC;IAElD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,GAAG,KAAK,CAAC,CAAC;QAC7C,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,OAAO;QACL,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,UAAU;QACV,WAAW,EAAE,aAAa,CAAC,WAAW;KACvC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,cAAsD;IAEtD,MAAM,MAAM,GAAwC,EAAE,CAAC;IAEvD,KAAK,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC5E,MAAM,CAAC,aAAa,CAAC,GAAG,yBAAyB,CAAC,aAAa,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { ComponentDefinition } from '@kaskad/definition';\nimport { NodeSchema } from '@kaskad/types';\n\nimport { ComponentRawDefinition } from '../types/component-definition';\nimport { unfoldProperty } from '../unfolding/unfold-property';\n\nexport function unfoldComponentDefinition(rawDefinition: ComponentRawDefinition): ComponentDefinition {\n const properties: Record<string, NodeSchema> = {};\n\n for (const entry of Object.entries(rawDefinition.properties)) {\n const [key, prop] = unfoldProperty(...entry);\n properties[key] = prop;\n }\n\n return {\n traits: rawDefinition.traits,\n properties,\n defaultSlot: rawDefinition.defaultSlot,\n };\n}\n\nexport function unfoldComponentDefinitions(\n rawDefinitions: Record<string, ComponentRawDefinition>,\n): Record<string, ComponentDefinition> {\n const result: Record<string, ComponentDefinition> = {};\n\n for (const [componentType, rawDefinition] of Object.entries(rawDefinitions)) {\n result[componentType] = unfoldComponentDefinition(rawDefinition);\n }\n\n return result;\n}\n"]}
|
package/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './lib/types/component-schema';
|
|
2
|
-
export * from './lib/types/raw-schemas';
|
|
3
|
-
export * from './lib/types/component-definition';
|
|
4
|
-
export * from './lib/types/template-raw-definition';
|
|
5
|
-
export * from './lib/unfolding/unfold-node-schema';
|
|
6
|
-
export * from './lib/unfolding/unfold-property';
|
|
7
|
-
export * from './lib/unfolding/unfold-flat-wrapper-notation';
|
|
8
|
-
export * from './lib/unfolding/parse-value-type';
|
|
9
|
-
export * from './lib/unfolding/to-full-notation';
|
|
10
|
-
export * from './lib/load/schema-component-extractor';
|
|
11
|
-
export * from './lib/load/template-registry';
|
|
12
|
-
export * from './lib/load/load-templates';
|
|
13
|
-
export * from './lib/load/load-schema';
|
|
14
|
-
export * from './lib/load/register-declared-type';
|
|
15
|
-
export * from './lib/util/unfold-component-definitions';
|
|
16
|
-
export * from './lib/util/is-object';
|
package/kaskad-schema.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function registerDeclaredType(name: string, definition: string | Record<string, string>): void;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TemplateRecipeDefinition } from '../types/template-raw-definition';
|
|
2
|
-
interface TemplateEntry {
|
|
3
|
-
recipe: TemplateRecipeDefinition;
|
|
4
|
-
ownComponentTypes: Set<string>;
|
|
5
|
-
dependencies: Set<string>;
|
|
6
|
-
}
|
|
7
|
-
export declare const templateRegistry: {
|
|
8
|
-
entries: Map<string, TemplateEntry>;
|
|
9
|
-
get(url: string): TemplateEntry | undefined;
|
|
10
|
-
getAggregatedComponentTypes(url: string): Set<string>;
|
|
11
|
-
getAllComponentTypes(): Set<string>;
|
|
12
|
-
set(url: string, recipe: TemplateRecipeDefinition, ownComponentTypes: Set<string>, dependencies?: Set<string>): void;
|
|
13
|
-
has(url: string): boolean;
|
|
14
|
-
reset(): void;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ComponentRef } from '@kaskad/types';
|
|
2
|
-
export type Defer = {
|
|
3
|
-
placeholder?: {
|
|
4
|
-
componentType: string;
|
|
5
|
-
} & {
|
|
6
|
-
[key: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
error?: {
|
|
9
|
-
componentType: string;
|
|
10
|
-
} & {
|
|
11
|
-
[key: string]: unknown;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export interface NodeChangeHandlerRecipe {
|
|
15
|
-
selector: string;
|
|
16
|
-
command: unknown;
|
|
17
|
-
}
|
|
18
|
-
export interface ComponentRecipe {
|
|
19
|
-
ref?: ComponentRef;
|
|
20
|
-
componentType: string;
|
|
21
|
-
onNodeChange?: NodeChangeHandlerRecipe[];
|
|
22
|
-
[propOrVariable: string]: unknown;
|
|
23
|
-
}
|
|
24
|
-
export type TemplateRecipe = Omit<ComponentRecipe, 'componentType'> & {
|
|
25
|
-
templateUrl: string;
|
|
26
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type FormulaComputationRecipe = {
|
|
2
|
-
formula: string;
|
|
3
|
-
};
|
|
4
|
-
export type ForComputationRecipe = {
|
|
5
|
-
items: unknown[];
|
|
6
|
-
as?: {
|
|
7
|
-
item: unknown;
|
|
8
|
-
index: unknown;
|
|
9
|
-
first?: unknown;
|
|
10
|
-
last?: unknown;
|
|
11
|
-
};
|
|
12
|
-
yield: unknown;
|
|
13
|
-
};
|
|
14
|
-
export type IfComputationRecipe = Record<'if' | 'then' | 'else', unknown> | ({
|
|
15
|
-
if: unknown;
|
|
16
|
-
} & Record<string, unknown>);
|
|
17
|
-
export type SwitchComputationRecipe = {
|
|
18
|
-
computationType: 'switch';
|
|
19
|
-
source: unknown;
|
|
20
|
-
cases: {
|
|
21
|
-
equals: unknown;
|
|
22
|
-
then: unknown;
|
|
23
|
-
}[];
|
|
24
|
-
default: unknown;
|
|
25
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ComponentRecipe } from './component-schema';
|
|
2
|
-
export interface TemplateRecipeDefinition extends ComponentRecipe {
|
|
3
|
-
types?: Record<string, string | Record<string, string>>;
|
|
4
|
-
importTypes?: string[];
|
|
5
|
-
contract?: Record<string, string>;
|
|
6
|
-
defaultSlot?: string;
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ComputationSchema } from '@kaskad/types';
|
|
2
|
-
/**
|
|
3
|
-
* Unfolds the new for-loop syntax into a ForComputationSchema
|
|
4
|
-
* Supports: for: "$item@Type of $items" or for: ["$item1@Type1 of $items1", "$item2@Type2 of $items2"]
|
|
5
|
-
*/
|
|
6
|
-
export declare function unfoldForWithNewSyntax(schema: unknown): ComputationSchema | null;
|