@teleporthq/teleport-uidl-validator 0.18.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/LICENSE +21 -0
- package/README.md +14 -0
- package/__tests__/parser/componennt-with-referenced-styles.json +111 -0
- package/__tests__/parser/component-parsing.ts +116 -0
- package/__tests__/parser/component-referenced.ts +50 -0
- package/__tests__/parser/component-with-primitive-values.json +61 -0
- package/__tests__/parser/component-with-proper-values.json +97 -0
- package/__tests__/parser/component-with-reusalble-styles.json +117 -0
- package/__tests__/validator/component-element-with-empty-name.json +36 -0
- package/__tests__/validator/component-invalid-sample.json +184 -0
- package/__tests__/validator/component-uidl-with-event-modifier-undefined.json +45 -0
- package/__tests__/validator/component-uidl-with-null-undefined.json +24 -0
- package/__tests__/validator/index.ts +216 -0
- package/__tests__/validator/old-project-invalid-sample.json +317 -0
- package/__tests__/validator/project-invalid-sample-no-route.json +667 -0
- package/__tests__/validator/project-invalid-sample.json +671 -0
- package/__tests__/validator/project-sample.json +667 -0
- package/dist/cjs/decoders/component-decoder.d.ts +4 -0
- package/dist/cjs/decoders/component-decoder.js +30 -0
- package/dist/cjs/decoders/component-decoder.js.map +1 -0
- package/dist/cjs/decoders/custom-combinators.d.ts +8 -0
- package/dist/cjs/decoders/custom-combinators.js +59 -0
- package/dist/cjs/decoders/custom-combinators.js.map +1 -0
- package/dist/cjs/decoders/index.d.ts +2 -0
- package/dist/cjs/decoders/index.js +9 -0
- package/dist/cjs/decoders/index.js.map +1 -0
- package/dist/cjs/decoders/project-decoder.d.ts +5 -0
- package/dist/cjs/decoders/project-decoder.js +38 -0
- package/dist/cjs/decoders/project-decoder.js.map +1 -0
- package/dist/cjs/decoders/utils.d.ts +59 -0
- package/dist/cjs/decoders/utils.js +305 -0
- package/dist/cjs/decoders/utils.js.map +1 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/parser/index.d.ts +10 -0
- package/dist/cjs/parser/index.js +156 -0
- package/dist/cjs/parser/index.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/cjs/validator/index.d.ts +15 -0
- package/dist/cjs/validator/index.js +94 -0
- package/dist/cjs/validator/index.js.map +1 -0
- package/dist/cjs/validator/utils.d.ts +16 -0
- package/dist/cjs/validator/utils.js +373 -0
- package/dist/cjs/validator/utils.js.map +1 -0
- package/dist/esm/decoders/component-decoder.d.ts +4 -0
- package/dist/esm/decoders/component-decoder.js +27 -0
- package/dist/esm/decoders/component-decoder.js.map +1 -0
- package/dist/esm/decoders/custom-combinators.d.ts +8 -0
- package/dist/esm/decoders/custom-combinators.js +56 -0
- package/dist/esm/decoders/custom-combinators.js.map +1 -0
- package/dist/esm/decoders/index.d.ts +2 -0
- package/dist/esm/decoders/index.js +3 -0
- package/dist/esm/decoders/index.js.map +1 -0
- package/dist/esm/decoders/project-decoder.d.ts +5 -0
- package/dist/esm/decoders/project-decoder.js +35 -0
- package/dist/esm/decoders/project-decoder.js.map +1 -0
- package/dist/esm/decoders/utils.d.ts +59 -0
- package/dist/esm/decoders/utils.js +301 -0
- package/dist/esm/decoders/utils.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/parser/index.d.ts +10 -0
- package/dist/esm/parser/index.js +151 -0
- package/dist/esm/parser/index.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/validator/index.d.ts +15 -0
- package/dist/esm/validator/index.js +73 -0
- package/dist/esm/validator/index.js.map +1 -0
- package/dist/esm/validator/utils.d.ts +16 -0
- package/dist/esm/validator/utils.js +359 -0
- package/dist/esm/validator/utils.js.map +1 -0
- package/package.json +32 -0
- package/src/decoders/component-decoder.ts +48 -0
- package/src/decoders/custom-combinators.ts +59 -0
- package/src/decoders/index.ts +2 -0
- package/src/decoders/project-decoder.ts +40 -0
- package/src/decoders/utils.ts +571 -0
- package/src/index.ts +9 -0
- package/src/parser/index.ts +227 -0
- package/src/validator/index.ts +105 -0
- package/src/validator/utils.ts +463 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
2
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
3
|
+
to[j] = from[i];
|
|
4
|
+
return to;
|
|
5
|
+
};
|
|
6
|
+
import { ProjectValidationError, ComponentValidationError, } from '@teleporthq/teleport-types';
|
|
7
|
+
import { componentUIDLDecoder, rootComponentUIDLDecoder, projectUIDLDecoder } from '../decoders';
|
|
8
|
+
import * as utils from './utils';
|
|
9
|
+
var Validator = /** @class */ (function () {
|
|
10
|
+
function Validator() {
|
|
11
|
+
}
|
|
12
|
+
Validator.prototype.validateComponentSchema = function (input) {
|
|
13
|
+
try {
|
|
14
|
+
var cleanedUIDL = utils.validateNulls(input);
|
|
15
|
+
var uidl = componentUIDLDecoder.runWithException(cleanedUIDL);
|
|
16
|
+
return { valid: true, errorMsg: '', componentUIDL: uidl };
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
var errorMsg = utils.formatErrors([{ kind: e.kind, message: e.message, at: e.at }]);
|
|
20
|
+
throw new ComponentValidationError("Component - " + (input === null || input === void 0 ? void 0 : input.name) + " \n\n " + errorMsg);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
Validator.prototype.validateRootComponentSchema = function (input) {
|
|
24
|
+
try {
|
|
25
|
+
var cleanedUIDL = utils.validateNulls(input);
|
|
26
|
+
var uidl = rootComponentUIDLDecoder.runWithException(cleanedUIDL);
|
|
27
|
+
return { valid: true, errorMsg: '', componentUIDL: uidl };
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
var errorMsg = utils.formatErrors([{ kind: e.kind, message: e.message, at: e.at }]);
|
|
31
|
+
throw new ComponentValidationError("Component - " + (input === null || input === void 0 ? void 0 : input.name) + "\n\n " + errorMsg);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
Validator.prototype.validateProjectSchema = function (input) {
|
|
35
|
+
try {
|
|
36
|
+
var cleanedUIDL = utils.validateNulls(input);
|
|
37
|
+
var uidl = projectUIDLDecoder.runWithException(cleanedUIDL);
|
|
38
|
+
return { valid: true, errorMsg: '', projectUIDL: uidl };
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
var errorMsg = utils.formatErrors([{ kind: e.kind, message: e.message, at: e.at }]);
|
|
42
|
+
throw new ProjectValidationError(input.name + "\n\n " + errorMsg);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
Validator.prototype.validateComponentContent = function (input) {
|
|
46
|
+
var errorsInDefinitions = utils.checkDynamicDefinitions(input);
|
|
47
|
+
var errorsWithLocalVariables = utils.checkForLocalVariables(input);
|
|
48
|
+
utils.checkForDuplicateDefinitions(input);
|
|
49
|
+
var errors = __spreadArray(__spreadArray([], errorsInDefinitions), errorsWithLocalVariables);
|
|
50
|
+
if (errors.length > 0) {
|
|
51
|
+
throw new ComponentValidationError("UIDL Component Content Validation Error. Please check the following: \n" + errors);
|
|
52
|
+
}
|
|
53
|
+
return { valid: true, errorMsg: '' };
|
|
54
|
+
};
|
|
55
|
+
Validator.prototype.validateProjectContent = function (input) {
|
|
56
|
+
var errorsOnRouteNode = utils.checkRouteDefinition(input) || [];
|
|
57
|
+
var allErrors = errorsOnRouteNode;
|
|
58
|
+
if (errorsOnRouteNode.length === 0) {
|
|
59
|
+
var errorsInStyleSet = utils.checkProjectStyleSet(input);
|
|
60
|
+
var errorsInRootComponent = utils.checkRootComponent(input);
|
|
61
|
+
var errorsWithComponentNaming = utils.checkComponentNaming(input);
|
|
62
|
+
var errorsWtihComponentExistence = utils.checkComponentExistenceAndReferences(input);
|
|
63
|
+
allErrors = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], errorsOnRouteNode), errorsWtihComponentExistence), errorsWithComponentNaming), errorsInRootComponent), errorsInStyleSet);
|
|
64
|
+
}
|
|
65
|
+
if (allErrors.length > 0) {
|
|
66
|
+
throw new ProjectValidationError("UIDL Project Content Validation Error. Please check the following: " + allErrors);
|
|
67
|
+
}
|
|
68
|
+
return { valid: true, errorMsg: '' };
|
|
69
|
+
};
|
|
70
|
+
return Validator;
|
|
71
|
+
}());
|
|
72
|
+
export default Validator;
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validator/index.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,EAGL,sBAAsB,EACtB,wBAAwB,GAGzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChG,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAShC;IAAA;IAsFA,CAAC;IArFQ,2CAAuB,GAA9B,UAA+B,KAA8B;QAC3D,IAAI;YACF,IAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;YAC9C,IAAM,IAAI,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;YAE/D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAA;SAC1D;QAAC,OAAO,CAAC,EAAE;YACV,IAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;YACrF,MAAM,IAAI,wBAAwB,CAAC,kBAAe,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,oBAC3D,QAA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,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IACtC,CAAC;IACH,gBAAC;AAAD,CAAC,AAtFD,IAsFC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProjectUIDL, ComponentUIDL, UIDLStaticValue, UIDLStyleSetTokenReference } from '@teleporthq/teleport-types';
|
|
2
|
+
export declare const checkForDuplicateDefinitions: (input: ComponentUIDL) => void;
|
|
3
|
+
export declare const checkForLocalVariables: (input: ComponentUIDL) => string[];
|
|
4
|
+
export declare const checkDynamicDefinitions: (input: Record<string, unknown>) => string[];
|
|
5
|
+
export declare const checkRouteDefinition: (input: ProjectUIDL) => string[];
|
|
6
|
+
export declare const checkComponentExistenceAndReferences: (input: ProjectUIDL) => string[];
|
|
7
|
+
export declare const checkComponentNaming: (input: ProjectUIDL) => string[];
|
|
8
|
+
export declare const checkProjectStyleSet: (input: ProjectUIDL) => string[];
|
|
9
|
+
export declare const checStylekContentForErrors: (content: Record<string, UIDLStaticValue | UIDLStyleSetTokenReference>) => string[];
|
|
10
|
+
export declare const checkRootComponent: (input: ProjectUIDL) => string[];
|
|
11
|
+
export declare const formatErrors: (errors: Array<{
|
|
12
|
+
kind: string;
|
|
13
|
+
at: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}>) => string;
|
|
16
|
+
export declare const validateNulls: (uidl: Record<string, unknown>) => any;
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
2
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
3
|
+
to[j] = from[i];
|
|
4
|
+
return to;
|
|
5
|
+
};
|
|
6
|
+
import { UIDLUtils } from '@teleporthq/teleport-shared';
|
|
7
|
+
import { ComponentValidationError, } from '@teleporthq/teleport-types';
|
|
8
|
+
// Prop definitions and state definitions should have different keys
|
|
9
|
+
export var checkForDuplicateDefinitions = function (input) {
|
|
10
|
+
var props = Object.keys(input.propDefinitions || {});
|
|
11
|
+
var states = Object.keys(input.stateDefinitions || {});
|
|
12
|
+
var imports = Object.keys(input.importDefinitions || {});
|
|
13
|
+
props
|
|
14
|
+
.filter(function (x) { return states.includes(x) || imports.includes(x); })
|
|
15
|
+
.forEach(function (duplicate) {
|
|
16
|
+
return console.warn("\n\"" + duplicate + "\" is defined both as a prop and as a state. If you are using VUE Code Generators this can cause bad behavior.");
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
// In "repeat" node:
|
|
20
|
+
// If index is used, "useIndex" must be declared in "meta"
|
|
21
|
+
// If custom local variable is used, it's name must be specified inside "meta" as "iteratorName"
|
|
22
|
+
export var checkForLocalVariables = function (input) {
|
|
23
|
+
var errors = [];
|
|
24
|
+
UIDLUtils.traverseRepeats(input.node, function (repeatContent) {
|
|
25
|
+
UIDLUtils.traverseNodes(repeatContent.node, function (childNode) {
|
|
26
|
+
if (childNode.type === 'dynamic' && childNode.content.referenceType === 'local') {
|
|
27
|
+
if (childNode.content.id === 'index') {
|
|
28
|
+
if (!repeatContent.meta.useIndex) {
|
|
29
|
+
var errorMsg = "\nIndex variable is used but the \"useIndex\" meta information is false.";
|
|
30
|
+
errors.push(errorMsg);
|
|
31
|
+
}
|
|
32
|
+
// we are dealing with local index here
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!validLocalVariableUsage(childNode.content.id, repeatContent.meta.iteratorName)) {
|
|
36
|
+
var errorMsg = "\n\"" + childNode.content.id + "\" is used in the \"repeat\" structure but the iterator name has this value: \"" + repeatContent.meta.iteratorName + "\"";
|
|
37
|
+
errors.push(errorMsg);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
return errors;
|
|
43
|
+
};
|
|
44
|
+
var validLocalVariableUsage = function (dynamicId, repeatIteratorName) {
|
|
45
|
+
var iteratorName = repeatIteratorName || 'item';
|
|
46
|
+
if (!dynamicId.includes('.')) {
|
|
47
|
+
return dynamicId === iteratorName;
|
|
48
|
+
}
|
|
49
|
+
var dynamicIdRoot = dynamicId.split('.')[0];
|
|
50
|
+
return dynamicIdRoot === iteratorName;
|
|
51
|
+
};
|
|
52
|
+
/* All referenced props, states and importRefs should be previously defined in the
|
|
53
|
+
"propDefinitions" and "stateDefinitions" and "importDefinitions" sections
|
|
54
|
+
If props or states are defined and not used, a warning witll be displayed */
|
|
55
|
+
export var checkDynamicDefinitions = function (input) {
|
|
56
|
+
var _a;
|
|
57
|
+
var propKeys = Object.keys(input.propDefinitions || {});
|
|
58
|
+
var stateKeys = Object.keys(input.stateDefinitions || {});
|
|
59
|
+
var importKeys = Object.keys(input.importDefinitions || {});
|
|
60
|
+
var componentStyleSetKyes = Object.keys(input.styleSetDefinitions || {});
|
|
61
|
+
var importDefinitions = ((_a = input === null || input === void 0 ? void 0 : input.importDefinitions) !== null && _a !== void 0 ? _a : {});
|
|
62
|
+
if (Object.keys(importKeys).length > 0) {
|
|
63
|
+
importKeys = importKeys.reduce(function (acc, importRef) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
if ((_b = (_a = importDefinitions[importRef]) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.importJustPath) {
|
|
66
|
+
return acc;
|
|
67
|
+
}
|
|
68
|
+
acc.push(importRef);
|
|
69
|
+
return acc;
|
|
70
|
+
}, []);
|
|
71
|
+
}
|
|
72
|
+
var usedPropKeys = [];
|
|
73
|
+
var usedStateKeys = [];
|
|
74
|
+
var usedImportKeys = [];
|
|
75
|
+
var errors = [];
|
|
76
|
+
UIDLUtils.traverseNodes(input.node, function (node) {
|
|
77
|
+
var _a, _b, _c, _d;
|
|
78
|
+
if (node.type === 'element') {
|
|
79
|
+
Object.keys(((_a = node.content) === null || _a === void 0 ? void 0 : _a.events) || {}).forEach(function (eventKey) {
|
|
80
|
+
node.content.events[eventKey].forEach(function (event) {
|
|
81
|
+
if (event.type === 'stateChange' && !stateKeys.includes(event.modifies)) {
|
|
82
|
+
var errorMsg = "\"" + event.modifies + "\" is used in events, but not defined. Please add it in stateDefinitions";
|
|
83
|
+
errors.push(errorMsg);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (event.type === 'propCall' && !propKeys.includes(event.calls)) {
|
|
87
|
+
errors.push("\"" + event.calls + "\" is used in events, but missing from propDefinitons. Please add it in propDefinitions ");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
var dynamicVariants_1 = [];
|
|
93
|
+
Object.values(((_b = node.content) === null || _b === void 0 ? void 0 : _b.referencedStyles) || {}).forEach(function (styleRef) {
|
|
94
|
+
if (styleRef.content.mapType === 'component-referenced' &&
|
|
95
|
+
styleRef.content.content.type === 'dynamic') {
|
|
96
|
+
if (styleRef.content.content.content.referenceType === 'prop') {
|
|
97
|
+
var referencedProp = styleRef.content.content.content.id;
|
|
98
|
+
if (!dynamicPathExistsInDefinitions(referencedProp, propKeys)) {
|
|
99
|
+
var errorMsg = "\"" + referencedProp + "\" is used but not defined. Please add it in propDefinitions";
|
|
100
|
+
errors.push(errorMsg);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
dynamicVariants_1.push(referencedProp);
|
|
104
|
+
usedPropKeys.push(referencedProp);
|
|
105
|
+
}
|
|
106
|
+
if (styleRef.content.content.content.referenceType === 'comp') {
|
|
107
|
+
var compStyleRefId = styleRef.content.content.content.id;
|
|
108
|
+
if (!componentStyleSetKyes.includes(compStyleRefId)) {
|
|
109
|
+
errors.push(compStyleRefId + " is used, but not defined in Component Style Sheet in " + input.name + ". Please add it in StyleSetDefinitions of the component");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
if (dynamicVariants_1.length > 1) {
|
|
115
|
+
errors.push("Node " + (((_c = node.content) === null || _c === void 0 ? void 0 : _c.name) || ((_d = node.content) === null || _d === void 0 ? void 0 : _d.key)) + " is using multiple dynamic variants using propDefinitions.\n We can have only one dynamic variant at once");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (node.type === 'dynamic' && node.content.referenceType === 'prop') {
|
|
119
|
+
if (!dynamicPathExistsInDefinitions(node.content.id, propKeys)) {
|
|
120
|
+
var errorMsg = "\"" + node.content.id + "\" is used but not defined. Please add it in propDefinitions";
|
|
121
|
+
errors.push(errorMsg);
|
|
122
|
+
}
|
|
123
|
+
// for member expression we check the root
|
|
124
|
+
// if value has no `.` it will be checked as it is
|
|
125
|
+
var dynamicIdRoot = node.content.id.split('.')[0];
|
|
126
|
+
usedPropKeys.push(dynamicIdRoot);
|
|
127
|
+
}
|
|
128
|
+
if (node.type === 'dynamic' && node.content.referenceType === 'state') {
|
|
129
|
+
if (!dynamicPathExistsInDefinitions(node.content.id, stateKeys)) {
|
|
130
|
+
var errorMsg = "\n\"" + node.content.id + "\" is used but not defined. Please add it in stateDefinitions";
|
|
131
|
+
errors.push(errorMsg);
|
|
132
|
+
}
|
|
133
|
+
// for member expression we check the root
|
|
134
|
+
// if value has no `.` it will be checked as it is
|
|
135
|
+
var dynamicIdRoot = node.content.id.split('.')[0];
|
|
136
|
+
usedStateKeys.push(dynamicIdRoot);
|
|
137
|
+
}
|
|
138
|
+
if (node.type === 'import') {
|
|
139
|
+
if (!dynamicPathExistsInDefinitions(node.content.id, importKeys)) {
|
|
140
|
+
var errorMsg = "\n\"" + node.content.id + "\" is used but not defined. Please add it in importDefinitions";
|
|
141
|
+
errors.push(errorMsg);
|
|
142
|
+
}
|
|
143
|
+
// for member expression we check the root
|
|
144
|
+
// if value has no `.` it will be checked as it is
|
|
145
|
+
var dynamicIdRoot = node.content.id.split('.')[0];
|
|
146
|
+
usedImportKeys.push(dynamicIdRoot);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
propKeys
|
|
150
|
+
.filter(function (x) { return !usedPropKeys.includes(x); })
|
|
151
|
+
.forEach(function (diff) {
|
|
152
|
+
return console.warn("\"" + diff + "\" is defined in propDefinitions but it is not used in the UIDL.");
|
|
153
|
+
});
|
|
154
|
+
stateKeys
|
|
155
|
+
.filter(function (x) { return !usedStateKeys.includes(x); })
|
|
156
|
+
.forEach(function (diff) {
|
|
157
|
+
return console.warn("\"" + diff + "\" is defined in stateDefinitions but it is not used in the UIDL.");
|
|
158
|
+
});
|
|
159
|
+
importKeys
|
|
160
|
+
.filter(function (x) { return !usedImportKeys.includes(x); })
|
|
161
|
+
.forEach(function (diff) {
|
|
162
|
+
return console.warn("\"" + diff + "\" is defined in importDefinitions but it is not used in the UIDL.");
|
|
163
|
+
});
|
|
164
|
+
return errors;
|
|
165
|
+
};
|
|
166
|
+
var dynamicPathExistsInDefinitions = function (path, defKeys) {
|
|
167
|
+
if (!path.includes('.')) {
|
|
168
|
+
// prop/state is a scalar value, not a dot notation
|
|
169
|
+
return defKeys.includes(path);
|
|
170
|
+
}
|
|
171
|
+
// TODO: Expand validation logic to check if the path exists on the prop/state definition
|
|
172
|
+
// ex: if prop reference is `user.name`, we should check that prop type is object and has a valid field name
|
|
173
|
+
var rootIdentifier = path.split('.')[0];
|
|
174
|
+
return defKeys.includes(rootIdentifier);
|
|
175
|
+
};
|
|
176
|
+
// A projectUIDL must contain "route" key
|
|
177
|
+
export var checkRouteDefinition = function (input) {
|
|
178
|
+
var errors = [];
|
|
179
|
+
var keys = Object.keys(input.root.stateDefinitions || {});
|
|
180
|
+
if (!keys.includes('route')) {
|
|
181
|
+
var errorMsg = 'Route is not defined in stateDefinitions';
|
|
182
|
+
errors.push(errorMsg);
|
|
183
|
+
}
|
|
184
|
+
return errors;
|
|
185
|
+
};
|
|
186
|
+
// All referenced components inside of the projectUIDL should be defined
|
|
187
|
+
// in the components section and all the project-referenced styles and tokens
|
|
188
|
+
export var checkComponentExistenceAndReferences = function (input) {
|
|
189
|
+
var _a, _b, _c, _d;
|
|
190
|
+
var errors = [];
|
|
191
|
+
var components = Object.keys(input.components || {});
|
|
192
|
+
var styleSetDefinitions = Object.keys(((_a = input.root) === null || _a === void 0 ? void 0 : _a.styleSetDefinitions) || {});
|
|
193
|
+
var tokens = Object.keys(((_c = (_b = input.root) === null || _b === void 0 ? void 0 : _b.designLanguage) === null || _c === void 0 ? void 0 : _c.tokens) || {});
|
|
194
|
+
var nodesToParse = __spreadArray([
|
|
195
|
+
input.root.node
|
|
196
|
+
], Object.values(input.components || {}).map(function (component) { return component.node; }));
|
|
197
|
+
var usedReferencedStyles = [];
|
|
198
|
+
if ((_d = input.root) === null || _d === void 0 ? void 0 : _d.styleSetDefinitions) {
|
|
199
|
+
Object.values(input.root.styleSetDefinitions || {}).forEach(function (style) {
|
|
200
|
+
var content = style.content, _a = style.conditions, conditions = _a === void 0 ? [] : _a;
|
|
201
|
+
errors.push.apply(errors, checkForTokensInstyles(content, tokens));
|
|
202
|
+
conditions.forEach(function (condition) {
|
|
203
|
+
if (condition === null || condition === void 0 ? void 0 : condition.content) {
|
|
204
|
+
errors.push.apply(errors, checkForTokensInstyles(condition.content, tokens));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
nodesToParse.forEach(function (node) {
|
|
210
|
+
UIDLUtils.traverseElements(node, function (element) {
|
|
211
|
+
/* Checking for project-referenced styles */
|
|
212
|
+
if (element === null || element === void 0 ? void 0 : element.referencedStyles) {
|
|
213
|
+
var _a = checkForReferencedStylesUsed(element.referencedStyles, styleSetDefinitions, tokens), errorsInRferences = _a.errorsInRferences, usedStyleRefrences = _a.usedStyleRefrences;
|
|
214
|
+
errors.push.apply(errors, errorsInRferences);
|
|
215
|
+
usedReferencedStyles = __spreadArray(__spreadArray([], usedReferencedStyles), usedStyleRefrences);
|
|
216
|
+
}
|
|
217
|
+
/* Checking for token references used in styles */
|
|
218
|
+
if (element === null || element === void 0 ? void 0 : element.style) {
|
|
219
|
+
errors.push.apply(errors, checkForTokensInstyles(element.style, tokens));
|
|
220
|
+
}
|
|
221
|
+
if (element.dependency &&
|
|
222
|
+
element.dependency.type === 'local' &&
|
|
223
|
+
!components.includes(element.semanticType)) {
|
|
224
|
+
var errorMsg = "\nThe component \"" + element.semanticType + "\" is not defined in the UIDL's component section.";
|
|
225
|
+
errors.push(errorMsg);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
styleSetDefinitions.forEach(function (key) {
|
|
230
|
+
if (!usedReferencedStyles.includes(key)) {
|
|
231
|
+
console.warn(key + " styleSet is defined but not used in the project.");
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return errors;
|
|
235
|
+
};
|
|
236
|
+
var checkForReferencedStylesUsed = function (referencedStyles, styleSetDefinitions, tokens) {
|
|
237
|
+
var errorsInRferences = [];
|
|
238
|
+
var usedStyleRefrences = [];
|
|
239
|
+
Object.values(referencedStyles || {}).forEach(function (styleRef) {
|
|
240
|
+
var mapType = styleRef.content.mapType;
|
|
241
|
+
if (mapType === 'inlined') {
|
|
242
|
+
errorsInRferences.push.apply(errorsInRferences, checkForTokensInstyles(styleRef.content.styles, tokens));
|
|
243
|
+
}
|
|
244
|
+
if (mapType === 'project-referenced') {
|
|
245
|
+
var referenceId = styleRef.content.referenceId;
|
|
246
|
+
usedStyleRefrences.push(referenceId);
|
|
247
|
+
if (!styleSetDefinitions.includes(referenceId)) {
|
|
248
|
+
errorsInRferences.push("\n " + referenceId + " is missing from the styleSetDefinitions, please check the reference id.");
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return {
|
|
253
|
+
errorsInRferences: errorsInRferences,
|
|
254
|
+
usedStyleRefrences: usedStyleRefrences,
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
var checkForTokensInstyles = function (styles, tokens) {
|
|
258
|
+
var errors = [];
|
|
259
|
+
Object.values(styles || {}).forEach(function (style) {
|
|
260
|
+
if (style.type === 'dynamic' &&
|
|
261
|
+
style.content.referenceType === 'token' &&
|
|
262
|
+
!tokens.includes(style.content.id)) {
|
|
263
|
+
errors.push("\nToken " + style.content.id + " is missing from the project UIDL.");
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
return errors;
|
|
267
|
+
};
|
|
268
|
+
// All components should have the same key as the value of their name key
|
|
269
|
+
// Example:
|
|
270
|
+
// "components": {
|
|
271
|
+
// "OneComponent": {
|
|
272
|
+
// "name": "OneComponent",
|
|
273
|
+
// ..
|
|
274
|
+
// }
|
|
275
|
+
// }
|
|
276
|
+
export var checkComponentNaming = function (input) {
|
|
277
|
+
var errors = [];
|
|
278
|
+
var namesUsed = Object.keys(input.components || {});
|
|
279
|
+
var diffs = namesUsed.filter(function (name) { return input.components[name].name !== name; });
|
|
280
|
+
if (diffs.length > 0) {
|
|
281
|
+
var errorMsg = "\nThe following components have different name than their key: " + diffs;
|
|
282
|
+
errors.push(errorMsg);
|
|
283
|
+
}
|
|
284
|
+
return errors;
|
|
285
|
+
};
|
|
286
|
+
export var checkProjectStyleSet = function (input) {
|
|
287
|
+
var errors = [];
|
|
288
|
+
var styleSet = input.root.styleSetDefinitions;
|
|
289
|
+
if (styleSet) {
|
|
290
|
+
Object.values(styleSet).forEach(function (styleSetObj) {
|
|
291
|
+
var content = styleSetObj.content, _a = styleSetObj.conditions, conditions = _a === void 0 ? [] : _a;
|
|
292
|
+
Object.values(conditions).forEach(function (style) {
|
|
293
|
+
errors.push.apply(errors, checStylekContentForErrors(style.content));
|
|
294
|
+
});
|
|
295
|
+
errors.push.apply(errors, checStylekContentForErrors(content));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return errors;
|
|
299
|
+
};
|
|
300
|
+
export var checStylekContentForErrors = function (content) {
|
|
301
|
+
var errors = [];
|
|
302
|
+
Object.values(content).forEach(function (styleContent) {
|
|
303
|
+
if (styleContent.type === 'dynamic' && styleContent.content.referenceType !== 'token') {
|
|
304
|
+
errors.push("Dynamic nodes in styleSetDefinitions supports only tokens");
|
|
305
|
+
}
|
|
306
|
+
if (styleContent.type === 'static' &&
|
|
307
|
+
typeof styleContent.content !== 'string' &&
|
|
308
|
+
typeof styleContent.content !== 'number') {
|
|
309
|
+
errors.push("Project Style sheet / styleSetDefinitions only support styles with static \n content and dynamic tokens, received " + styleContent);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
return errors;
|
|
313
|
+
};
|
|
314
|
+
// The "root" node should contain only elements of type "conditional"
|
|
315
|
+
export var checkRootComponent = function (input) {
|
|
316
|
+
var errors = [];
|
|
317
|
+
var routeNaming = [];
|
|
318
|
+
var rootNode = input.root.node.content;
|
|
319
|
+
rootNode.children.forEach(function (child) {
|
|
320
|
+
if (child.type !== 'conditional') {
|
|
321
|
+
var errorMsg = "\nRoot Node contains elements of type \"" + child.type + "\". It should contain only elements of type \"conditional\"";
|
|
322
|
+
errors.push(errorMsg);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
routeNaming.push(child.content.value.toString());
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
var routeValues = input.root.stateDefinitions.route.values;
|
|
329
|
+
if (!routeValues || routeValues.length <= 0) {
|
|
330
|
+
errors.push('\nThe `route` state definition from the root node does not contain the possible route values');
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
input.root.stateDefinitions.route.values
|
|
334
|
+
.filter(function (route) { return !routeNaming.includes(route.value.toString()); })
|
|
335
|
+
.forEach(function (route) {
|
|
336
|
+
var errorMsg = "\nRoot Node contains a route that don't have a specified state: " + route.value + ".";
|
|
337
|
+
errors.push(errorMsg);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
return errors;
|
|
341
|
+
};
|
|
342
|
+
// The errors should be displayed in a human-readeable way
|
|
343
|
+
export var formatErrors = function (errors) {
|
|
344
|
+
var listOfErrors = [];
|
|
345
|
+
errors.forEach(function (error) {
|
|
346
|
+
var message = "\n - Path " + error.at + ": " + error.message + ". \n is a " + error.kind + " \n";
|
|
347
|
+
listOfErrors.push(message);
|
|
348
|
+
});
|
|
349
|
+
return "UIDL Format Validation Error. Please check the following: " + listOfErrors;
|
|
350
|
+
};
|
|
351
|
+
export var validateNulls = function (uidl) {
|
|
352
|
+
return JSON.parse(JSON.stringify(uidl), function (key, value) {
|
|
353
|
+
if (value === undefined || value == null) {
|
|
354
|
+
throw new ComponentValidationError("Validation error, Received " + value + " at " + key);
|
|
355
|
+
}
|
|
356
|
+
return value;
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/validator/utils.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAEvD,OAAO,EAaL,wBAAwB,GACzB,MAAM,4BAA4B,CAAA;AAEnC,oEAAoE;AACpE,MAAM,CAAC,IAAM,4BAA4B,GAAG,UAAC,KAAoB;IAC/D,IAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,EAAE,CAAC,CAAA;IACtD,IAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAA;IACxD,IAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAA;IAE1D,KAAK;SACF,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAzC,CAAyC,CAAC;SACxD,OAAO,CAAC,UAAC,SAAS;QACjB,OAAA,OAAO,CAAC,IAAI,CACV,SAAM,SAAS,mHAA+G,CAC/H;IAFD,CAEC,CACF,CAAA;AACL,CAAC,CAAA;AAED,oBAAoB;AACpB,0DAA0D;AAC1D,gGAAgG;AAChG,MAAM,CAAC,IAAM,sBAAsB,GAAG,UAAC,KAAoB;IACzD,IAAM,M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AACpF,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,aAAa,GAAG,UAAC,IAA6B;IACzD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,UAAC,GAAG,EAAE,KAAK;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,IAAI,IAAI,EAAE;YACxC,MAAM,IAAI,wBAAwB,CAAC,gCAA8B,KAAK,YAAO,GAAK,CAAC,CAAA;SACpF;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teleporthq/teleport-uidl-validator",
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "A module that offers validation and parsing for non-standard UIDL structures",
|
|
5
|
+
"author": "teleportHQ",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://teleporthq.io/",
|
|
8
|
+
"main": "dist/cjs/index.js",
|
|
9
|
+
"module": "dist/esm/index.js",
|
|
10
|
+
"types": "dist/cjs/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+ssh://git@github.com/teleporthq/teleport-code-generators.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/teleporthq/teleport-code-generators/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "rimraf dist",
|
|
24
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@mojotech/json-type-validation": "^3.1.0",
|
|
28
|
+
"@teleporthq/teleport-shared": "^0.18.0",
|
|
29
|
+
"@teleporthq/teleport-types": "^0.18.0"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "7b47f013bf1889e19b31875a8f3abdc43b22615a"
|
|
32
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
object,
|
|
3
|
+
string,
|
|
4
|
+
dict,
|
|
5
|
+
withDefault,
|
|
6
|
+
Decoder,
|
|
7
|
+
optional,
|
|
8
|
+
} from '@mojotech/json-type-validation'
|
|
9
|
+
import { VComponentUIDL, VRootComponentUIDL } from '@teleporthq/teleport-types'
|
|
10
|
+
import {
|
|
11
|
+
styleSetDefinitionDecoder,
|
|
12
|
+
propDefinitionsDecoder,
|
|
13
|
+
stateDefinitionsDecoder,
|
|
14
|
+
outputOptionsDecoder,
|
|
15
|
+
elementNodeDecoder,
|
|
16
|
+
componentSeoDecoder,
|
|
17
|
+
externaldependencyDecoder,
|
|
18
|
+
peerDependencyDecoder,
|
|
19
|
+
designTokensDecoder,
|
|
20
|
+
} from './utils'
|
|
21
|
+
|
|
22
|
+
export const componentUIDLDecoder: Decoder<VComponentUIDL> = object({
|
|
23
|
+
name: withDefault('MyComponent', string()),
|
|
24
|
+
node: elementNodeDecoder,
|
|
25
|
+
stateDefinitions: optional(dict(stateDefinitionsDecoder)),
|
|
26
|
+
propDefinitions: optional(dict(propDefinitionsDecoder)),
|
|
27
|
+
styleSetDefinitions: optional(dict(styleSetDefinitionDecoder)),
|
|
28
|
+
importDefinitions: optional(dict(externaldependencyDecoder)),
|
|
29
|
+
outputOptions: optional(outputOptionsDecoder),
|
|
30
|
+
seo: optional(componentSeoDecoder),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export const rootComponentUIDLDecoder: Decoder<VRootComponentUIDL> = object({
|
|
34
|
+
name: withDefault('App', string()),
|
|
35
|
+
node: elementNodeDecoder,
|
|
36
|
+
stateDefinitions: dict(stateDefinitionsDecoder),
|
|
37
|
+
propDefinitions: optional(dict(propDefinitionsDecoder)),
|
|
38
|
+
importDefinitions: optional(dict(externaldependencyDecoder)),
|
|
39
|
+
peerDefinitions: optional(dict(peerDependencyDecoder)),
|
|
40
|
+
styleSetDefinitions: optional(dict(styleSetDefinitionDecoder)),
|
|
41
|
+
outputOptions: optional(outputOptionsDecoder),
|
|
42
|
+
seo: optional(componentSeoDecoder),
|
|
43
|
+
designLanguage: optional(
|
|
44
|
+
object({
|
|
45
|
+
tokens: optional(designTokensDecoder),
|
|
46
|
+
})
|
|
47
|
+
),
|
|
48
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* tslint:disable member-ordering */
|
|
2
|
+
import { Result, DecoderError } from '@mojotech/json-type-validation'
|
|
3
|
+
|
|
4
|
+
/* These are some custom combinators that comes in handy for us,
|
|
5
|
+
instead of parsing and cross-checking regex again. The combinators,
|
|
6
|
+
can used inside a existing Decoder, since we did not implement any run()
|
|
7
|
+
runWithException() etc */
|
|
8
|
+
|
|
9
|
+
type DecodeResult<A> = Result.Result<A, Partial<DecoderError>>
|
|
10
|
+
export class CustomCombinators<A> {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
private constructor(private decode: (json: string) => DecodeResult<A>) {}
|
|
13
|
+
|
|
14
|
+
static isValidComponentName(): CustomCombinators<string> {
|
|
15
|
+
return new CustomCombinators<string>((json: string) => {
|
|
16
|
+
const componentNameRegex = new RegExp('^[A-Z]+[a-zA-Z0-9]*$')
|
|
17
|
+
if (json && typeof json === 'string' && componentNameRegex.test(json)) {
|
|
18
|
+
return Result.ok(json)
|
|
19
|
+
} else if (json.length === 0) {
|
|
20
|
+
throw new Error(`Component Name cannot be empty`)
|
|
21
|
+
}
|
|
22
|
+
throw new Error(`Invalid Component name, got ${json}`)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static isValidNavLink(): CustomCombinators<string> {
|
|
27
|
+
return new CustomCombinators<string>((json: string) => {
|
|
28
|
+
const navLinkRegex = new RegExp('/[a-zA-Z0-9-_]*$')
|
|
29
|
+
if (json && typeof json === 'string' && navLinkRegex.test(json)) {
|
|
30
|
+
return Result.ok(json)
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`Invalid link attribute, received ${json}`)
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static isValidFileName(): CustomCombinators<string> {
|
|
37
|
+
return new CustomCombinators<string>((json: string) => {
|
|
38
|
+
const fileNameRegex = new RegExp('^[a-zA-Z0-9-_.]*$')
|
|
39
|
+
if (json && typeof json === 'string' && fileNameRegex.test(json)) {
|
|
40
|
+
return Result.ok(json)
|
|
41
|
+
} else if (json.length === 0) {
|
|
42
|
+
throw new Error(`File Name cannot be empty`)
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Invalid File name, received ${json}`)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static isValidElementName(): CustomCombinators<string> {
|
|
49
|
+
return new CustomCombinators<string>((json: string) => {
|
|
50
|
+
const fileNameRegex = new RegExp('^[a-zA-Z]+[a-zA-Z0-9-_]*$')
|
|
51
|
+
if (json && typeof json === 'string' && fileNameRegex.test(json)) {
|
|
52
|
+
return Result.ok(json)
|
|
53
|
+
} else if (json.length === 0) {
|
|
54
|
+
throw new Error(`Name attribute cannot be empty`)
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Invalid name attribute, received ${json}`)
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|