@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,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
3
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
4
|
+
to[j] = from[i];
|
|
5
|
+
return to;
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.validateNulls = exports.formatErrors = exports.checkRootComponent = exports.checStylekContentForErrors = exports.checkProjectStyleSet = exports.checkComponentNaming = exports.checkComponentExistenceAndReferences = exports.checkRouteDefinition = exports.checkDynamicDefinitions = exports.checkForLocalVariables = exports.checkForDuplicateDefinitions = void 0;
|
|
9
|
+
var teleport_shared_1 = require("@teleporthq/teleport-shared");
|
|
10
|
+
var teleport_types_1 = require("@teleporthq/teleport-types");
|
|
11
|
+
// Prop definitions and state definitions should have different keys
|
|
12
|
+
var checkForDuplicateDefinitions = function (input) {
|
|
13
|
+
var props = Object.keys(input.propDefinitions || {});
|
|
14
|
+
var states = Object.keys(input.stateDefinitions || {});
|
|
15
|
+
var imports = Object.keys(input.importDefinitions || {});
|
|
16
|
+
props
|
|
17
|
+
.filter(function (x) { return states.includes(x) || imports.includes(x); })
|
|
18
|
+
.forEach(function (duplicate) {
|
|
19
|
+
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.");
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.checkForDuplicateDefinitions = checkForDuplicateDefinitions;
|
|
23
|
+
// In "repeat" node:
|
|
24
|
+
// If index is used, "useIndex" must be declared in "meta"
|
|
25
|
+
// If custom local variable is used, it's name must be specified inside "meta" as "iteratorName"
|
|
26
|
+
var checkForLocalVariables = function (input) {
|
|
27
|
+
var errors = [];
|
|
28
|
+
teleport_shared_1.UIDLUtils.traverseRepeats(input.node, function (repeatContent) {
|
|
29
|
+
teleport_shared_1.UIDLUtils.traverseNodes(repeatContent.node, function (childNode) {
|
|
30
|
+
if (childNode.type === 'dynamic' && childNode.content.referenceType === 'local') {
|
|
31
|
+
if (childNode.content.id === 'index') {
|
|
32
|
+
if (!repeatContent.meta.useIndex) {
|
|
33
|
+
var errorMsg = "\nIndex variable is used but the \"useIndex\" meta information is false.";
|
|
34
|
+
errors.push(errorMsg);
|
|
35
|
+
}
|
|
36
|
+
// we are dealing with local index here
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!validLocalVariableUsage(childNode.content.id, repeatContent.meta.iteratorName)) {
|
|
40
|
+
var errorMsg = "\n\"" + childNode.content.id + "\" is used in the \"repeat\" structure but the iterator name has this value: \"" + repeatContent.meta.iteratorName + "\"";
|
|
41
|
+
errors.push(errorMsg);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return errors;
|
|
47
|
+
};
|
|
48
|
+
exports.checkForLocalVariables = checkForLocalVariables;
|
|
49
|
+
var validLocalVariableUsage = function (dynamicId, repeatIteratorName) {
|
|
50
|
+
var iteratorName = repeatIteratorName || 'item';
|
|
51
|
+
if (!dynamicId.includes('.')) {
|
|
52
|
+
return dynamicId === iteratorName;
|
|
53
|
+
}
|
|
54
|
+
var dynamicIdRoot = dynamicId.split('.')[0];
|
|
55
|
+
return dynamicIdRoot === iteratorName;
|
|
56
|
+
};
|
|
57
|
+
/* All referenced props, states and importRefs should be previously defined in the
|
|
58
|
+
"propDefinitions" and "stateDefinitions" and "importDefinitions" sections
|
|
59
|
+
If props or states are defined and not used, a warning witll be displayed */
|
|
60
|
+
var checkDynamicDefinitions = function (input) {
|
|
61
|
+
var _a;
|
|
62
|
+
var propKeys = Object.keys(input.propDefinitions || {});
|
|
63
|
+
var stateKeys = Object.keys(input.stateDefinitions || {});
|
|
64
|
+
var importKeys = Object.keys(input.importDefinitions || {});
|
|
65
|
+
var componentStyleSetKyes = Object.keys(input.styleSetDefinitions || {});
|
|
66
|
+
var importDefinitions = ((_a = input === null || input === void 0 ? void 0 : input.importDefinitions) !== null && _a !== void 0 ? _a : {});
|
|
67
|
+
if (Object.keys(importKeys).length > 0) {
|
|
68
|
+
importKeys = importKeys.reduce(function (acc, importRef) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if ((_b = (_a = importDefinitions[importRef]) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.importJustPath) {
|
|
71
|
+
return acc;
|
|
72
|
+
}
|
|
73
|
+
acc.push(importRef);
|
|
74
|
+
return acc;
|
|
75
|
+
}, []);
|
|
76
|
+
}
|
|
77
|
+
var usedPropKeys = [];
|
|
78
|
+
var usedStateKeys = [];
|
|
79
|
+
var usedImportKeys = [];
|
|
80
|
+
var errors = [];
|
|
81
|
+
teleport_shared_1.UIDLUtils.traverseNodes(input.node, function (node) {
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
|
+
if (node.type === 'element') {
|
|
84
|
+
Object.keys(((_a = node.content) === null || _a === void 0 ? void 0 : _a.events) || {}).forEach(function (eventKey) {
|
|
85
|
+
node.content.events[eventKey].forEach(function (event) {
|
|
86
|
+
if (event.type === 'stateChange' && !stateKeys.includes(event.modifies)) {
|
|
87
|
+
var errorMsg = "\"" + event.modifies + "\" is used in events, but not defined. Please add it in stateDefinitions";
|
|
88
|
+
errors.push(errorMsg);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (event.type === 'propCall' && !propKeys.includes(event.calls)) {
|
|
92
|
+
errors.push("\"" + event.calls + "\" is used in events, but missing from propDefinitons. Please add it in propDefinitions ");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
var dynamicVariants_1 = [];
|
|
98
|
+
Object.values(((_b = node.content) === null || _b === void 0 ? void 0 : _b.referencedStyles) || {}).forEach(function (styleRef) {
|
|
99
|
+
if (styleRef.content.mapType === 'component-referenced' &&
|
|
100
|
+
styleRef.content.content.type === 'dynamic') {
|
|
101
|
+
if (styleRef.content.content.content.referenceType === 'prop') {
|
|
102
|
+
var referencedProp = styleRef.content.content.content.id;
|
|
103
|
+
if (!dynamicPathExistsInDefinitions(referencedProp, propKeys)) {
|
|
104
|
+
var errorMsg = "\"" + referencedProp + "\" is used but not defined. Please add it in propDefinitions";
|
|
105
|
+
errors.push(errorMsg);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
dynamicVariants_1.push(referencedProp);
|
|
109
|
+
usedPropKeys.push(referencedProp);
|
|
110
|
+
}
|
|
111
|
+
if (styleRef.content.content.content.referenceType === 'comp') {
|
|
112
|
+
var compStyleRefId = styleRef.content.content.content.id;
|
|
113
|
+
if (!componentStyleSetKyes.includes(compStyleRefId)) {
|
|
114
|
+
errors.push(compStyleRefId + " is used, but not defined in Component Style Sheet in " + input.name + ". Please add it in StyleSetDefinitions of the component");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (dynamicVariants_1.length > 1) {
|
|
120
|
+
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");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (node.type === 'dynamic' && node.content.referenceType === 'prop') {
|
|
124
|
+
if (!dynamicPathExistsInDefinitions(node.content.id, propKeys)) {
|
|
125
|
+
var errorMsg = "\"" + node.content.id + "\" is used but not defined. Please add it in propDefinitions";
|
|
126
|
+
errors.push(errorMsg);
|
|
127
|
+
}
|
|
128
|
+
// for member expression we check the root
|
|
129
|
+
// if value has no `.` it will be checked as it is
|
|
130
|
+
var dynamicIdRoot = node.content.id.split('.')[0];
|
|
131
|
+
usedPropKeys.push(dynamicIdRoot);
|
|
132
|
+
}
|
|
133
|
+
if (node.type === 'dynamic' && node.content.referenceType === 'state') {
|
|
134
|
+
if (!dynamicPathExistsInDefinitions(node.content.id, stateKeys)) {
|
|
135
|
+
var errorMsg = "\n\"" + node.content.id + "\" is used but not defined. Please add it in stateDefinitions";
|
|
136
|
+
errors.push(errorMsg);
|
|
137
|
+
}
|
|
138
|
+
// for member expression we check the root
|
|
139
|
+
// if value has no `.` it will be checked as it is
|
|
140
|
+
var dynamicIdRoot = node.content.id.split('.')[0];
|
|
141
|
+
usedStateKeys.push(dynamicIdRoot);
|
|
142
|
+
}
|
|
143
|
+
if (node.type === 'import') {
|
|
144
|
+
if (!dynamicPathExistsInDefinitions(node.content.id, importKeys)) {
|
|
145
|
+
var errorMsg = "\n\"" + node.content.id + "\" is used but not defined. Please add it in importDefinitions";
|
|
146
|
+
errors.push(errorMsg);
|
|
147
|
+
}
|
|
148
|
+
// for member expression we check the root
|
|
149
|
+
// if value has no `.` it will be checked as it is
|
|
150
|
+
var dynamicIdRoot = node.content.id.split('.')[0];
|
|
151
|
+
usedImportKeys.push(dynamicIdRoot);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
propKeys
|
|
155
|
+
.filter(function (x) { return !usedPropKeys.includes(x); })
|
|
156
|
+
.forEach(function (diff) {
|
|
157
|
+
return console.warn("\"" + diff + "\" is defined in propDefinitions but it is not used in the UIDL.");
|
|
158
|
+
});
|
|
159
|
+
stateKeys
|
|
160
|
+
.filter(function (x) { return !usedStateKeys.includes(x); })
|
|
161
|
+
.forEach(function (diff) {
|
|
162
|
+
return console.warn("\"" + diff + "\" is defined in stateDefinitions but it is not used in the UIDL.");
|
|
163
|
+
});
|
|
164
|
+
importKeys
|
|
165
|
+
.filter(function (x) { return !usedImportKeys.includes(x); })
|
|
166
|
+
.forEach(function (diff) {
|
|
167
|
+
return console.warn("\"" + diff + "\" is defined in importDefinitions but it is not used in the UIDL.");
|
|
168
|
+
});
|
|
169
|
+
return errors;
|
|
170
|
+
};
|
|
171
|
+
exports.checkDynamicDefinitions = checkDynamicDefinitions;
|
|
172
|
+
var dynamicPathExistsInDefinitions = function (path, defKeys) {
|
|
173
|
+
if (!path.includes('.')) {
|
|
174
|
+
// prop/state is a scalar value, not a dot notation
|
|
175
|
+
return defKeys.includes(path);
|
|
176
|
+
}
|
|
177
|
+
// TODO: Expand validation logic to check if the path exists on the prop/state definition
|
|
178
|
+
// ex: if prop reference is `user.name`, we should check that prop type is object and has a valid field name
|
|
179
|
+
var rootIdentifier = path.split('.')[0];
|
|
180
|
+
return defKeys.includes(rootIdentifier);
|
|
181
|
+
};
|
|
182
|
+
// A projectUIDL must contain "route" key
|
|
183
|
+
var checkRouteDefinition = function (input) {
|
|
184
|
+
var errors = [];
|
|
185
|
+
var keys = Object.keys(input.root.stateDefinitions || {});
|
|
186
|
+
if (!keys.includes('route')) {
|
|
187
|
+
var errorMsg = 'Route is not defined in stateDefinitions';
|
|
188
|
+
errors.push(errorMsg);
|
|
189
|
+
}
|
|
190
|
+
return errors;
|
|
191
|
+
};
|
|
192
|
+
exports.checkRouteDefinition = checkRouteDefinition;
|
|
193
|
+
// All referenced components inside of the projectUIDL should be defined
|
|
194
|
+
// in the components section and all the project-referenced styles and tokens
|
|
195
|
+
var checkComponentExistenceAndReferences = function (input) {
|
|
196
|
+
var _a, _b, _c, _d;
|
|
197
|
+
var errors = [];
|
|
198
|
+
var components = Object.keys(input.components || {});
|
|
199
|
+
var styleSetDefinitions = Object.keys(((_a = input.root) === null || _a === void 0 ? void 0 : _a.styleSetDefinitions) || {});
|
|
200
|
+
var tokens = Object.keys(((_c = (_b = input.root) === null || _b === void 0 ? void 0 : _b.designLanguage) === null || _c === void 0 ? void 0 : _c.tokens) || {});
|
|
201
|
+
var nodesToParse = __spreadArray([
|
|
202
|
+
input.root.node
|
|
203
|
+
], Object.values(input.components || {}).map(function (component) { return component.node; }));
|
|
204
|
+
var usedReferencedStyles = [];
|
|
205
|
+
if ((_d = input.root) === null || _d === void 0 ? void 0 : _d.styleSetDefinitions) {
|
|
206
|
+
Object.values(input.root.styleSetDefinitions || {}).forEach(function (style) {
|
|
207
|
+
var content = style.content, _a = style.conditions, conditions = _a === void 0 ? [] : _a;
|
|
208
|
+
errors.push.apply(errors, checkForTokensInstyles(content, tokens));
|
|
209
|
+
conditions.forEach(function (condition) {
|
|
210
|
+
if (condition === null || condition === void 0 ? void 0 : condition.content) {
|
|
211
|
+
errors.push.apply(errors, checkForTokensInstyles(condition.content, tokens));
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
nodesToParse.forEach(function (node) {
|
|
217
|
+
teleport_shared_1.UIDLUtils.traverseElements(node, function (element) {
|
|
218
|
+
/* Checking for project-referenced styles */
|
|
219
|
+
if (element === null || element === void 0 ? void 0 : element.referencedStyles) {
|
|
220
|
+
var _a = checkForReferencedStylesUsed(element.referencedStyles, styleSetDefinitions, tokens), errorsInRferences = _a.errorsInRferences, usedStyleRefrences = _a.usedStyleRefrences;
|
|
221
|
+
errors.push.apply(errors, errorsInRferences);
|
|
222
|
+
usedReferencedStyles = __spreadArray(__spreadArray([], usedReferencedStyles), usedStyleRefrences);
|
|
223
|
+
}
|
|
224
|
+
/* Checking for token references used in styles */
|
|
225
|
+
if (element === null || element === void 0 ? void 0 : element.style) {
|
|
226
|
+
errors.push.apply(errors, checkForTokensInstyles(element.style, tokens));
|
|
227
|
+
}
|
|
228
|
+
if (element.dependency &&
|
|
229
|
+
element.dependency.type === 'local' &&
|
|
230
|
+
!components.includes(element.semanticType)) {
|
|
231
|
+
var errorMsg = "\nThe component \"" + element.semanticType + "\" is not defined in the UIDL's component section.";
|
|
232
|
+
errors.push(errorMsg);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
styleSetDefinitions.forEach(function (key) {
|
|
237
|
+
if (!usedReferencedStyles.includes(key)) {
|
|
238
|
+
console.warn(key + " styleSet is defined but not used in the project.");
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return errors;
|
|
242
|
+
};
|
|
243
|
+
exports.checkComponentExistenceAndReferences = checkComponentExistenceAndReferences;
|
|
244
|
+
var checkForReferencedStylesUsed = function (referencedStyles, styleSetDefinitions, tokens) {
|
|
245
|
+
var errorsInRferences = [];
|
|
246
|
+
var usedStyleRefrences = [];
|
|
247
|
+
Object.values(referencedStyles || {}).forEach(function (styleRef) {
|
|
248
|
+
var mapType = styleRef.content.mapType;
|
|
249
|
+
if (mapType === 'inlined') {
|
|
250
|
+
errorsInRferences.push.apply(errorsInRferences, checkForTokensInstyles(styleRef.content.styles, tokens));
|
|
251
|
+
}
|
|
252
|
+
if (mapType === 'project-referenced') {
|
|
253
|
+
var referenceId = styleRef.content.referenceId;
|
|
254
|
+
usedStyleRefrences.push(referenceId);
|
|
255
|
+
if (!styleSetDefinitions.includes(referenceId)) {
|
|
256
|
+
errorsInRferences.push("\n " + referenceId + " is missing from the styleSetDefinitions, please check the reference id.");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
errorsInRferences: errorsInRferences,
|
|
262
|
+
usedStyleRefrences: usedStyleRefrences,
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
var checkForTokensInstyles = function (styles, tokens) {
|
|
266
|
+
var errors = [];
|
|
267
|
+
Object.values(styles || {}).forEach(function (style) {
|
|
268
|
+
if (style.type === 'dynamic' &&
|
|
269
|
+
style.content.referenceType === 'token' &&
|
|
270
|
+
!tokens.includes(style.content.id)) {
|
|
271
|
+
errors.push("\nToken " + style.content.id + " is missing from the project UIDL.");
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return errors;
|
|
275
|
+
};
|
|
276
|
+
// All components should have the same key as the value of their name key
|
|
277
|
+
// Example:
|
|
278
|
+
// "components": {
|
|
279
|
+
// "OneComponent": {
|
|
280
|
+
// "name": "OneComponent",
|
|
281
|
+
// ..
|
|
282
|
+
// }
|
|
283
|
+
// }
|
|
284
|
+
var checkComponentNaming = function (input) {
|
|
285
|
+
var errors = [];
|
|
286
|
+
var namesUsed = Object.keys(input.components || {});
|
|
287
|
+
var diffs = namesUsed.filter(function (name) { return input.components[name].name !== name; });
|
|
288
|
+
if (diffs.length > 0) {
|
|
289
|
+
var errorMsg = "\nThe following components have different name than their key: " + diffs;
|
|
290
|
+
errors.push(errorMsg);
|
|
291
|
+
}
|
|
292
|
+
return errors;
|
|
293
|
+
};
|
|
294
|
+
exports.checkComponentNaming = checkComponentNaming;
|
|
295
|
+
var checkProjectStyleSet = function (input) {
|
|
296
|
+
var errors = [];
|
|
297
|
+
var styleSet = input.root.styleSetDefinitions;
|
|
298
|
+
if (styleSet) {
|
|
299
|
+
Object.values(styleSet).forEach(function (styleSetObj) {
|
|
300
|
+
var content = styleSetObj.content, _a = styleSetObj.conditions, conditions = _a === void 0 ? [] : _a;
|
|
301
|
+
Object.values(conditions).forEach(function (style) {
|
|
302
|
+
errors.push.apply(errors, exports.checStylekContentForErrors(style.content));
|
|
303
|
+
});
|
|
304
|
+
errors.push.apply(errors, exports.checStylekContentForErrors(content));
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return errors;
|
|
308
|
+
};
|
|
309
|
+
exports.checkProjectStyleSet = checkProjectStyleSet;
|
|
310
|
+
var checStylekContentForErrors = function (content) {
|
|
311
|
+
var errors = [];
|
|
312
|
+
Object.values(content).forEach(function (styleContent) {
|
|
313
|
+
if (styleContent.type === 'dynamic' && styleContent.content.referenceType !== 'token') {
|
|
314
|
+
errors.push("Dynamic nodes in styleSetDefinitions supports only tokens");
|
|
315
|
+
}
|
|
316
|
+
if (styleContent.type === 'static' &&
|
|
317
|
+
typeof styleContent.content !== 'string' &&
|
|
318
|
+
typeof styleContent.content !== 'number') {
|
|
319
|
+
errors.push("Project Style sheet / styleSetDefinitions only support styles with static \n content and dynamic tokens, received " + styleContent);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
return errors;
|
|
323
|
+
};
|
|
324
|
+
exports.checStylekContentForErrors = checStylekContentForErrors;
|
|
325
|
+
// The "root" node should contain only elements of type "conditional"
|
|
326
|
+
var checkRootComponent = function (input) {
|
|
327
|
+
var errors = [];
|
|
328
|
+
var routeNaming = [];
|
|
329
|
+
var rootNode = input.root.node.content;
|
|
330
|
+
rootNode.children.forEach(function (child) {
|
|
331
|
+
if (child.type !== 'conditional') {
|
|
332
|
+
var errorMsg = "\nRoot Node contains elements of type \"" + child.type + "\". It should contain only elements of type \"conditional\"";
|
|
333
|
+
errors.push(errorMsg);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
routeNaming.push(child.content.value.toString());
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
var routeValues = input.root.stateDefinitions.route.values;
|
|
340
|
+
if (!routeValues || routeValues.length <= 0) {
|
|
341
|
+
errors.push('\nThe `route` state definition from the root node does not contain the possible route values');
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
input.root.stateDefinitions.route.values
|
|
345
|
+
.filter(function (route) { return !routeNaming.includes(route.value.toString()); })
|
|
346
|
+
.forEach(function (route) {
|
|
347
|
+
var errorMsg = "\nRoot Node contains a route that don't have a specified state: " + route.value + ".";
|
|
348
|
+
errors.push(errorMsg);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
return errors;
|
|
352
|
+
};
|
|
353
|
+
exports.checkRootComponent = checkRootComponent;
|
|
354
|
+
// The errors should be displayed in a human-readeable way
|
|
355
|
+
var formatErrors = function (errors) {
|
|
356
|
+
var listOfErrors = [];
|
|
357
|
+
errors.forEach(function (error) {
|
|
358
|
+
var message = "\n - Path " + error.at + ": " + error.message + ". \n is a " + error.kind + " \n";
|
|
359
|
+
listOfErrors.push(message);
|
|
360
|
+
});
|
|
361
|
+
return "UIDL Format Validation Error. Please check the following: " + listOfErrors;
|
|
362
|
+
};
|
|
363
|
+
exports.formatErrors = formatErrors;
|
|
364
|
+
var validateNulls = function (uidl) {
|
|
365
|
+
return JSON.parse(JSON.stringify(uidl), function (key, value) {
|
|
366
|
+
if (value === undefined || value == null) {
|
|
367
|
+
throw new teleport_types_1.ComponentValidationError("Validation error, Received " + value + " at " + key);
|
|
368
|
+
}
|
|
369
|
+
return value;
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
exports.validateNulls = validateNulls;
|
|
373
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/validator/utils.ts"],"names":[],"mappings":";;;;;;;;AAAA,+DAAuD;AAEvD,6DAcmC;AAEnC,oEAAoE;AAC7D,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;AAZY,QAAA,4BAA4B,gCAYxC;AAED,oBAAoB;AACpB,0DAA0D;AAC1D,gGAAgG;AACzF,IAAM,sBAAsB,GAAG,UAAC,KAAoB;IACzD,IAAM,MAAM,GAAa,EAAE,CAAA;IAE3B,2BAAS,CAAC,eAAe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AY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,OAAO,+DAA6D,YAAc,CAAA;AACpF,CAAC,CAAA;AARY,QAAA,YAAY,gBAQxB;AAEM,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,yCAAwB,CAAC,gCAA8B,KAAK,YAAO,GAAK,CAAC,CAAA;SACpF;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAPY,QAAA,aAAa,iBAOzB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Decoder } from '@mojotech/json-type-validation';
|
|
2
|
+
import { VComponentUIDL, VRootComponentUIDL } from '@teleporthq/teleport-types';
|
|
3
|
+
export declare const componentUIDLDecoder: Decoder<VComponentUIDL>;
|
|
4
|
+
export declare const rootComponentUIDLDecoder: Decoder<VRootComponentUIDL>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { object, string, dict, withDefault, optional, } from '@mojotech/json-type-validation';
|
|
2
|
+
import { styleSetDefinitionDecoder, propDefinitionsDecoder, stateDefinitionsDecoder, outputOptionsDecoder, elementNodeDecoder, componentSeoDecoder, externaldependencyDecoder, peerDependencyDecoder, designTokensDecoder, } from './utils';
|
|
3
|
+
export var componentUIDLDecoder = object({
|
|
4
|
+
name: withDefault('MyComponent', string()),
|
|
5
|
+
node: elementNodeDecoder,
|
|
6
|
+
stateDefinitions: optional(dict(stateDefinitionsDecoder)),
|
|
7
|
+
propDefinitions: optional(dict(propDefinitionsDecoder)),
|
|
8
|
+
styleSetDefinitions: optional(dict(styleSetDefinitionDecoder)),
|
|
9
|
+
importDefinitions: optional(dict(externaldependencyDecoder)),
|
|
10
|
+
outputOptions: optional(outputOptionsDecoder),
|
|
11
|
+
seo: optional(componentSeoDecoder),
|
|
12
|
+
});
|
|
13
|
+
export var rootComponentUIDLDecoder = object({
|
|
14
|
+
name: withDefault('App', string()),
|
|
15
|
+
node: elementNodeDecoder,
|
|
16
|
+
stateDefinitions: dict(stateDefinitionsDecoder),
|
|
17
|
+
propDefinitions: optional(dict(propDefinitionsDecoder)),
|
|
18
|
+
importDefinitions: optional(dict(externaldependencyDecoder)),
|
|
19
|
+
peerDefinitions: optional(dict(peerDependencyDecoder)),
|
|
20
|
+
styleSetDefinitions: optional(dict(styleSetDefinitionDecoder)),
|
|
21
|
+
outputOptions: optional(outputOptionsDecoder),
|
|
22
|
+
seo: optional(componentSeoDecoder),
|
|
23
|
+
designLanguage: optional(object({
|
|
24
|
+
tokens: optional(designTokensDecoder),
|
|
25
|
+
})),
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=component-decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-decoder.js","sourceRoot":"","sources":["../../../src/decoders/component-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,WAAW,EAEX,QAAQ,GACT,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,SAAS,CAAA;AAEhB,MAAM,CAAC,IAAM,oBAAoB,GAA4B,MAAM,CAAC;IAClE,IAAI,EAAE,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;IAC1C,IAAI,EAAE,kBAAkB;IACxB,gBAAgB,EAAE,QAAQ,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACzD,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACvD,mBAAmB,EAAE,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC9D,iBAAiB,EAAE,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC5D,aAAa,EAAE,QAAQ,CAAC,oBAAoB,CAAC;IAC7C,GAAG,EAAE,QAAQ,CAAC,mBAAmB,CAAC;CACnC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAM,wBAAwB,GAAgC,MAAM,CAAC;IAC1E,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAClC,IAAI,EAAE,kBAAkB;IACxB,gBAAgB,EAAE,IAAI,CAAC,uBAAuB,CAAC;IAC/C,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACvD,iBAAiB,EAAE,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC5D,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACtD,mBAAmB,EAAE,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC9D,aAAa,EAAE,QAAQ,CAAC,oBAAoB,CAAC;IAC7C,GAAG,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAClC,cAAc,EAAE,QAAQ,CACtB,MAAM,CAAC;QACL,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC;KACtC,CAAC,CACH;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class CustomCombinators<A> {
|
|
2
|
+
private decode;
|
|
3
|
+
private constructor();
|
|
4
|
+
static isValidComponentName(): CustomCombinators<string>;
|
|
5
|
+
static isValidNavLink(): CustomCombinators<string>;
|
|
6
|
+
static isValidFileName(): CustomCombinators<string>;
|
|
7
|
+
static isValidElementName(): CustomCombinators<string>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* tslint:disable member-ordering */
|
|
2
|
+
import { Result } from '@mojotech/json-type-validation';
|
|
3
|
+
var CustomCombinators = /** @class */ (function () {
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
function CustomCombinators(decode) {
|
|
6
|
+
this.decode = decode;
|
|
7
|
+
}
|
|
8
|
+
CustomCombinators.isValidComponentName = function () {
|
|
9
|
+
return new CustomCombinators(function (json) {
|
|
10
|
+
var componentNameRegex = new RegExp('^[A-Z]+[a-zA-Z0-9]*$');
|
|
11
|
+
if (json && typeof json === 'string' && componentNameRegex.test(json)) {
|
|
12
|
+
return Result.ok(json);
|
|
13
|
+
}
|
|
14
|
+
else if (json.length === 0) {
|
|
15
|
+
throw new Error("Component Name cannot be empty");
|
|
16
|
+
}
|
|
17
|
+
throw new Error("Invalid Component name, got " + json);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
CustomCombinators.isValidNavLink = function () {
|
|
21
|
+
return new CustomCombinators(function (json) {
|
|
22
|
+
var navLinkRegex = new RegExp('/[a-zA-Z0-9-_]*$');
|
|
23
|
+
if (json && typeof json === 'string' && navLinkRegex.test(json)) {
|
|
24
|
+
return Result.ok(json);
|
|
25
|
+
}
|
|
26
|
+
throw new Error("Invalid link attribute, received " + json);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
CustomCombinators.isValidFileName = function () {
|
|
30
|
+
return new CustomCombinators(function (json) {
|
|
31
|
+
var fileNameRegex = new RegExp('^[a-zA-Z0-9-_.]*$');
|
|
32
|
+
if (json && typeof json === 'string' && fileNameRegex.test(json)) {
|
|
33
|
+
return Result.ok(json);
|
|
34
|
+
}
|
|
35
|
+
else if (json.length === 0) {
|
|
36
|
+
throw new Error("File Name cannot be empty");
|
|
37
|
+
}
|
|
38
|
+
throw new Error("Invalid File name, received " + json);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
CustomCombinators.isValidElementName = function () {
|
|
42
|
+
return new CustomCombinators(function (json) {
|
|
43
|
+
var fileNameRegex = new RegExp('^[a-zA-Z]+[a-zA-Z0-9-_]*$');
|
|
44
|
+
if (json && typeof json === 'string' && fileNameRegex.test(json)) {
|
|
45
|
+
return Result.ok(json);
|
|
46
|
+
}
|
|
47
|
+
else if (json.length === 0) {
|
|
48
|
+
throw new Error("Name attribute cannot be empty");
|
|
49
|
+
}
|
|
50
|
+
throw new Error("Invalid name attribute, received " + json);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
return CustomCombinators;
|
|
54
|
+
}());
|
|
55
|
+
export { CustomCombinators };
|
|
56
|
+
//# sourceMappingURL=custom-combinators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-combinators.js","sourceRoot":"","sources":["../../../src/decoders/custom-combinators.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,MAAM,EAAgB,MAAM,gCAAgC,CAAA;AAQrE;IACE,aAAa;IACb,2BAA4B,MAAyC;QAAzC,WAAM,GAAN,MAAM,CAAmC;IAAG,CAAC;IAElE,sCAAoB,GAA3B;QACE,OAAO,IAAI,iBAAiB,CAAS,UAAC,IAAY;YAChD,IAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAA;YAC7D,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACrE,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;aACvB;iBAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC5B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;aAClD;YACD,MAAM,IAAI,KAAK,CAAC,iCAA+B,IAAM,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;IACJ,CAAC;IAEM,gCAAc,GAArB;QACE,OAAO,IAAI,iBAAiB,CAAS,UAAC,IAAY;YAChD,IAAM,YAAY,GAAG,IAAI,MAAM,CAAC,kBAAk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J,CAAC;IACH,wBAAC;AAAD,CAAC,AAjDD,IAiDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decoders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Decoder } from '@mojotech/json-type-validation';
|
|
2
|
+
import { UIDLGlobalProjectValues, WebManifest, VProjectUIDL } from '@teleporthq/teleport-types';
|
|
3
|
+
export declare const webManifestDecoder: Decoder<WebManifest>;
|
|
4
|
+
export declare const globalProjectValuesDecoder: Decoder<UIDLGlobalProjectValues>;
|
|
5
|
+
export declare const projectUIDLDecoder: Decoder<VProjectUIDL>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { object, optional, string, dict, array } from '@mojotech/json-type-validation';
|
|
2
|
+
import { globalAssetsDecoder } from './utils';
|
|
3
|
+
import { componentUIDLDecoder, rootComponentUIDLDecoder } from './component-decoder';
|
|
4
|
+
export var webManifestDecoder = object({
|
|
5
|
+
short_name: optional(string()),
|
|
6
|
+
name: optional(string()),
|
|
7
|
+
icons: optional(array(object({ src: string(), type: string(), sizes: string() }))),
|
|
8
|
+
start_url: optional(string()),
|
|
9
|
+
background_color: optional(string()),
|
|
10
|
+
display: optional(string()),
|
|
11
|
+
orientation: optional(string()),
|
|
12
|
+
scope: optional(string()),
|
|
13
|
+
theme_color: optional(string()),
|
|
14
|
+
});
|
|
15
|
+
export var globalProjectValuesDecoder = object({
|
|
16
|
+
settings: object({
|
|
17
|
+
title: string(),
|
|
18
|
+
language: string(),
|
|
19
|
+
}),
|
|
20
|
+
customCode: optional(object({
|
|
21
|
+
head: optional(string()),
|
|
22
|
+
body: optional(string()),
|
|
23
|
+
})),
|
|
24
|
+
meta: array(dict(string())),
|
|
25
|
+
assets: array(globalAssetsDecoder),
|
|
26
|
+
manifest: optional(webManifestDecoder),
|
|
27
|
+
variables: optional(dict(string())),
|
|
28
|
+
});
|
|
29
|
+
export var projectUIDLDecoder = object({
|
|
30
|
+
name: string(),
|
|
31
|
+
globals: globalProjectValuesDecoder,
|
|
32
|
+
root: rootComponentUIDLDecoder,
|
|
33
|
+
components: optional(dict(componentUIDLDecoder)),
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=project-decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-decoder.js","sourceRoot":"","sources":["../../../src/decoders/project-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AAE/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAEpF,MAAM,CAAC,IAAM,kBAAkB,GAAyB,MAAM,CAAC;IAC7D,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC9B,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAClF,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC7B,gBAAgB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACpC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC3B,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/B,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAM,0BAA0B,GAAqC,MAAM,CAAC;IACjF,QAAQ,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,EAAE;QACf,QAAQ,EAAE,MAAM,EAAE;KACnB,CAAC;IACF,UAAU,EAAE,QAAQ,CAClB,MAAM,CAAC;QACL,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxB,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;KACzB,CAAC,CACH;IACD,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3B,MAAM,EAAE,KAAK,CAAC,mBAAmB,CAAC;IAClC,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IACtC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAA0B,MAAM,CAAC;IAC9D,IAAI,EAAE,MAAM,EAAE;IACd,OAAO,EAAE,0BAA0B;IACnC,IAAI,EAAE,wBAAwB;IAC9B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;CACjD,CAAC,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Decoder } from '@mojotech/json-type-validation';
|
|
2
|
+
import { UIDLStaticValue, ReferenceType, UIDLDynamicReference, UIDLPropDefinition, UIDLStateDefinition, UIDLStateValueDetails, UIDLPageOptions, UIDLComponentOutputOptions, UIDLDependency, UIDLStyleDefinitions, UIDLStyleValue, UIDLAttributeValue, UIDLEventHandlerStatement, UIDLNavLinkNode, UIDLMailLinkNode, UIDLPhoneLinkNode, UIDLRawValue, UIDLElementStyleStates, UIDLStyleStateCondition, UIDLStyleMediaQueryScreenSizeCondition, UIDLStyleConditions, UIDLElementNodeProjectReferencedStyle, UIDLComponentSEO, UIDLGlobalAsset, UIDLExternalDependency, UIDLLocalDependency, UIDLPeerDependency, UIDLImportReference, UIDLStyleSetTokenReference, VUIDLStyleSetDefnition, VUIDLElement, VUIDLSlotNode, VUIDLConditionalNode, VUIDLRepeatNode, VUIDLElementNode, VUIDLNode, VUIDLElementNodeInlineReferencedStyle, VUIDLSectionLinkNode, VUIDLLinkNode, VUIDLURLLinkNode, VUIDLStyleSetConditions, VUIDLStyleSetMediaCondition, VUIDLStyleSetStateCondition, VUIDLDesignTokens, UIDLPropCallEvent, UIDLStateModifierEvent, UIDLScriptExternalAsset, UIDLScriptInlineAsset, UIDLStyleInlineAsset, UIDLStyleExternalAsset, UIDLFontAsset, UIDLCanonicalAsset, UIDLIconAsset, UIDLAssetBase, VUIDLElementNodeClassReferencedStyle, UIDLCompDynamicReference } from '@teleporthq/teleport-types';
|
|
3
|
+
export declare const referenceTypeDecoder: Decoder<ReferenceType>;
|
|
4
|
+
export declare const dynamicValueDecoder: Decoder<UIDLDynamicReference>;
|
|
5
|
+
export declare const staticValueDecoder: Decoder<UIDLStaticValue>;
|
|
6
|
+
export declare const styleSetMediaConditionDecoder: Decoder<VUIDLStyleSetMediaCondition>;
|
|
7
|
+
export declare const styleSetStateConditionDecoder: Decoder<VUIDLStyleSetStateCondition>;
|
|
8
|
+
export declare const projectStyleConditionsDecoder: Decoder<VUIDLStyleSetConditions>;
|
|
9
|
+
export declare const tokenReferenceDecoder: Decoder<UIDLStyleSetTokenReference>;
|
|
10
|
+
export declare const styleSetDefinitionDecoder: Decoder<VUIDLStyleSetDefnition>;
|
|
11
|
+
export declare const stateOrPropDefinitionDecoder: Decoder<string | number | boolean | Record<string, unknown> | (string | number | Record<string, unknown>)[]>;
|
|
12
|
+
export declare const pageOptionsDecoder: Decoder<UIDLPageOptions>;
|
|
13
|
+
export declare const globalAssetsDecoder: Decoder<UIDLGlobalAsset>;
|
|
14
|
+
export declare const baseAssetDecoder: Decoder<UIDLAssetBase>;
|
|
15
|
+
export declare const inlineScriptAssetDecoder: Decoder<UIDLScriptInlineAsset>;
|
|
16
|
+
export declare const externalScriptAssetDecoder: Decoder<UIDLScriptExternalAsset>;
|
|
17
|
+
export declare const inlineStyletAssetDecoder: Decoder<UIDLStyleInlineAsset>;
|
|
18
|
+
export declare const externalStyleAssetDecoder: Decoder<UIDLStyleExternalAsset>;
|
|
19
|
+
export declare const fontAssetDecoder: Decoder<UIDLFontAsset>;
|
|
20
|
+
export declare const canonicalAssetDecoder: Decoder<UIDLCanonicalAsset>;
|
|
21
|
+
export declare const iconAssetDecoder: Decoder<UIDLIconAsset>;
|
|
22
|
+
export declare const componentSeoDecoder: Decoder<UIDLComponentSEO>;
|
|
23
|
+
export declare const stateValueDetailsDecoder: Decoder<UIDLStateValueDetails>;
|
|
24
|
+
export declare const propDefinitionsDecoder: Decoder<UIDLPropDefinition>;
|
|
25
|
+
export declare const stateDefinitionsDecoder: Decoder<UIDLStateDefinition>;
|
|
26
|
+
export declare const outputOptionsDecoder: Decoder<UIDLComponentOutputOptions>;
|
|
27
|
+
export declare const peerDependencyDecoder: Decoder<UIDLPeerDependency>;
|
|
28
|
+
export declare const externaldependencyDecoder: Decoder<UIDLExternalDependency>;
|
|
29
|
+
export declare const localDependencyDecoder: Decoder<UIDLLocalDependency>;
|
|
30
|
+
export declare const dependencyDecoder: Decoder<UIDLDependency>;
|
|
31
|
+
export declare const importReferenceDecoder: Decoder<UIDLImportReference>;
|
|
32
|
+
export declare const attributeValueDecoder: Decoder<UIDLAttributeValue>;
|
|
33
|
+
export declare const styleValueDecoder: Decoder<UIDLStyleValue>;
|
|
34
|
+
export declare const styleDefinitionsDecoder: Decoder<UIDLStyleDefinitions>;
|
|
35
|
+
export declare const eventHandlerStatementDecoder: Decoder<UIDLEventHandlerStatement>;
|
|
36
|
+
export declare const propCallEventDecoder: Decoder<UIDLPropCallEvent>;
|
|
37
|
+
export declare const stateChangeEventDecoder: Decoder<UIDLStateModifierEvent>;
|
|
38
|
+
export declare const urlLinkNodeDecoder: Decoder<VUIDLURLLinkNode>;
|
|
39
|
+
export declare const sectionLinkNodeDecoder: Decoder<VUIDLSectionLinkNode>;
|
|
40
|
+
export declare const navLinkNodeDecoder: Decoder<UIDLNavLinkNode>;
|
|
41
|
+
export declare const uidlMailLinkNodeDecoder: Decoder<UIDLMailLinkNode>;
|
|
42
|
+
export declare const phoneLinkNodeDecoder: Decoder<UIDLPhoneLinkNode>;
|
|
43
|
+
export declare const uidlLinkNodeDecoder: Decoder<VUIDLLinkNode>;
|
|
44
|
+
export declare const rawValueDecoder: Decoder<UIDLRawValue>;
|
|
45
|
+
export declare const elementStateDecoder: Decoder<UIDLElementStyleStates>;
|
|
46
|
+
export declare const elementStyleWithStateConditionDecoder: Decoder<UIDLStyleStateCondition>;
|
|
47
|
+
export declare const elementStyleWithMediaConditionDecoder: Decoder<UIDLStyleMediaQueryScreenSizeCondition>;
|
|
48
|
+
export declare const styleConditionsDecoder: Decoder<UIDLStyleConditions>;
|
|
49
|
+
export declare const elementProjectReferencedStyle: Decoder<UIDLElementNodeProjectReferencedStyle>;
|
|
50
|
+
export declare const elementInlineReferencedStyle: Decoder<VUIDLElementNodeInlineReferencedStyle>;
|
|
51
|
+
export declare const classDynamicReferenceDecoder: Decoder<UIDLCompDynamicReference>;
|
|
52
|
+
export declare const elementComponentReferencedStyle: Decoder<VUIDLElementNodeClassReferencedStyle>;
|
|
53
|
+
export declare const designTokensDecoder: Decoder<VUIDLDesignTokens>;
|
|
54
|
+
export declare const elementDecoder: Decoder<VUIDLElement>;
|
|
55
|
+
export declare const slotNodeDecoder: Decoder<VUIDLSlotNode>;
|
|
56
|
+
export declare const repeatNodeDecoder: Decoder<VUIDLRepeatNode>;
|
|
57
|
+
export declare const conditionalNodeDecoder: Decoder<VUIDLConditionalNode>;
|
|
58
|
+
export declare const elementNodeDecoder: Decoder<VUIDLElementNode>;
|
|
59
|
+
export declare const uidlNodeDecoder: Decoder<VUIDLNode>;
|