@kaskad/types 0.0.6 → 0.0.8
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.
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
const NodeTypes = [
|
|
2
|
-
'unknown',
|
|
3
|
-
'string',
|
|
4
|
-
'number',
|
|
5
|
-
'boolean',
|
|
6
|
-
'array',
|
|
7
|
-
'object',
|
|
8
|
-
'map',
|
|
9
|
-
'set',
|
|
10
|
-
'component',
|
|
11
|
-
'componentSchema',
|
|
12
|
-
'command',
|
|
13
|
-
'shape',
|
|
14
|
-
'variantShape',
|
|
15
|
-
];
|
|
16
|
-
|
|
17
1
|
// Type guards for built-in computation schemas
|
|
18
2
|
function isFormulaComputation(schema) {
|
|
19
3
|
return schema.computationType === 'formula';
|
|
@@ -59,5 +43,5 @@ function findChildValueType(valueType, path) {
|
|
|
59
43
|
* Generated bundle index. Do not edit.
|
|
60
44
|
*/
|
|
61
45
|
|
|
62
|
-
export {
|
|
46
|
+
export { findChildValueType, isForComputation, isFormulaComputation, isIfComputation, isSwitchComputation, isTemplateComputation };
|
|
63
47
|
//# sourceMappingURL=kaskad-types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kaskad-types.mjs","sources":["../../../../libs/types/src/lib/
|
|
1
|
+
{"version":3,"file":"kaskad-types.mjs","sources":["../../../../libs/types/src/lib/computation-schema.ts","../../../../libs/types/src/lib/util/find-child-value-type.ts","../../../../libs/types/src/kaskad-types.ts"],"sourcesContent":["import { ComponentRef } from './branded';\nimport { ComponentSchemaNodeSchema, NodeSchema } from './node-schema';\nimport { ValueType } from './value-type';\n\nexport interface ComputationSchema {\n readonly computationType: string;\n}\n\nexport interface TemplateComputationSchema extends ComputationSchema {\n readonly computationType: 'template';\n readonly path: string;\n readonly ref?: ComponentRef;\n readonly defer: {\n placeholder: NodeSchema;\n error: NodeSchema;\n } | null;\n readonly contractVariables: Record<string, unknown>;\n}\n\nexport interface FormulaComputationSchema extends ComputationSchema {\n readonly computationType: 'formula';\n readonly formula: string;\n}\n\nexport interface IfComputationSchema extends ComputationSchema {\n readonly computationType: 'if';\n readonly if: NodeSchema;\n readonly then: NodeSchema;\n readonly else: NodeSchema;\n}\n\nexport interface DimensionSchema {\n items: NodeSchema;\n itemsType: ValueType;\n item: NodeSchema;\n index: NodeSchema;\n first: NodeSchema;\n last: NodeSchema;\n trackBy: NodeSchema;\n}\n\nexport interface ForComputationSchema extends ComputationSchema {\n readonly computationType: 'for';\n readonly dimensions: DimensionSchema[];\n readonly yield: NodeSchema;\n}\n\nexport interface SwitchComputationSchema extends ComputationSchema {\n readonly computationType: 'switch';\n readonly source: NodeSchema;\n readonly cases: { equals: unknown; then: ComponentSchemaNodeSchema }[];\n readonly default: ComponentSchemaNodeSchema;\n}\n\n// Type guards for built-in computation schemas\nexport function isFormulaComputation(schema: ComputationSchema): schema is FormulaComputationSchema {\n return schema.computationType === 'formula';\n}\n\nexport function isIfComputation(schema: ComputationSchema): schema is IfComputationSchema {\n return schema.computationType === 'if';\n}\n\nexport function isForComputation(schema: ComputationSchema): schema is ForComputationSchema {\n return schema.computationType === 'for';\n}\n\nexport function isTemplateComputation(schema: ComputationSchema): schema is TemplateComputationSchema {\n return schema.computationType === 'template';\n}\n\nexport function isSwitchComputation(schema: ComputationSchema): schema is SwitchComputationSchema {\n return schema.computationType === 'switch';\n}\n","import { ValueType } from '../value-type';\n\nexport function findChildValueType(valueType: ValueType, path: string[]): ValueType {\n if (!path.length) {\n return valueType;\n }\n\n const [head, ...tail] = path;\n\n switch (valueType.type) {\n case 'array': {\n return findChildValueType(valueType.item, tail);\n }\n case 'object': {\n const found = valueType.fields[head];\n if (!found) {\n throw new Error(`Field ${head} not found in object description.`);\n }\n return findChildValueType(found, tail);\n }\n case 'map': {\n return findChildValueType(valueType.item, tail);\n }\n default:\n return valueType;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":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kaskad-types.d.ts
CHANGED
|
@@ -51,7 +51,6 @@ interface VariantShapeValueType {
|
|
|
51
51
|
}
|
|
52
52
|
type ValueType = UnknownValueType | StringValueType | NumberValueType | BooleanValueType | ArrayValueType | ObjectValueType | MapValueType | SetValueType | ComponentValueType | ComponentSchemaValueType | CommandValueType | ShapeValueType | VariantShapeValueType;
|
|
53
53
|
type NodeType = ValueType['type'];
|
|
54
|
-
declare const NodeTypes: NodeType[];
|
|
55
54
|
|
|
56
55
|
/**
|
|
57
56
|
* Mirror binding: bidirectional sync between a node and a parent variable.
|
|
@@ -210,5 +209,5 @@ interface NodePosition {
|
|
|
210
209
|
|
|
211
210
|
declare function findChildValueType(valueType: ValueType, path: string[]): ValueType;
|
|
212
211
|
|
|
213
|
-
export {
|
|
212
|
+
export { findChildValueType, isForComputation, isFormulaComputation, isIfComputation, isSwitchComputation, isTemplateComputation };
|
|
214
213
|
export type { AnyFn, ArrayBindingSchema, ArrayNodeSchema, ArrayValueType, BindingSchema, BindingType, BooleanNodeSchema, BooleanValueType, CommandNodeSchema, CommandValue, CommandValueType, ComponentId, ComponentNodeInlineValue, ComponentNodeSchema, ComponentNodeValue, ComponentRef, ComponentSchemaNodeSchema, ComponentSchemaValueType, ComponentValueType, ComputationSchema, DimensionSchema, ForComputationSchema, FormulaComputationSchema, IfComputationSchema, LeafNodeSchema, MapNodeSchema, MapValueType, MirrorBindingSchema, NodeChangeHandlerSchema, NodePath, NodePathSegment, NodePosition, NodeSchema, NodeSchemaBase, NodeType, NumberNodeSchema, NumberValueType, ObjectBindingSchema, ObjectNodeSchema, ObjectValueType, RefSpaceId, SelectionBindingSchema, SetNodeSchema, SetValueType, ShapeNodeSchema, ShapeValue, ShapeValueType, StringNodeSchema, StringValueType, SwitchComputationSchema, TemplateComputationSchema, UnknownNodeSchema, UnknownValueType, ValueType, VariantShapeNodeSchema, VariantShapeValue, VariantShapeValueType };
|