@appsemble/utils 0.19.4 → 0.19.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.
- package/dist/api/components/schemas/App.js +27 -3
- package/dist/api/components/schemas/App.js.map +1 -1
- package/dist/api/components/schemas/FlowPageDefinition.js +1 -1
- package/dist/api/components/schemas/ResourceDefinition.js +2 -1
- package/dist/api/components/schemas/ResourceDefinition.js.map +1 -1
- package/dist/api/paths/apps.js +6 -19
- package/dist/api/paths/apps.js.map +1 -1
- package/dist/api/paths/templates.js +2 -2
- package/dist/api/paths/templates.js.map +1 -1
- package/dist/blockUtils.d.ts +4 -4
- package/dist/blockUtils.js +16 -13
- package/dist/blockUtils.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/iterApp.js +12 -1
- package/dist/iterApp.js.map +1 -1
- package/dist/validation.d.ts +16 -0
- package/dist/validation.js +404 -0
- package/dist/validation.js.map +1 -0
- package/package.json +4 -4
- package/dist/getAppBlocks.d.ts +0 -10
- package/dist/getAppBlocks.js +0 -22
- package/dist/getAppBlocks.js.map +0 -1
- package/dist/validateAppDefinition.d.ts +0 -32
- package/dist/validateAppDefinition.js +0 -252
- package/dist/validateAppDefinition.js.map +0 -1
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateAppDefinition = void 0;
|
|
7
|
+
const cron_parser_1 = require("cron-parser");
|
|
8
|
+
const jsonschema_1 = require("jsonschema");
|
|
9
|
+
const language_tags_1 = __importDefault(require("language-tags"));
|
|
10
|
+
const _1 = require(".");
|
|
11
|
+
const blockUtils_1 = require("./blockUtils");
|
|
12
|
+
const has_1 = require("./has");
|
|
13
|
+
const iterApp_1 = require("./iterApp");
|
|
14
|
+
function validateBlocks(definition, blockVersions, report) {
|
|
15
|
+
const blockVersionMap = new Map();
|
|
16
|
+
for (const version of blockVersions) {
|
|
17
|
+
if (!blockVersionMap.has(version.name)) {
|
|
18
|
+
blockVersionMap.set(version.name, new Map());
|
|
19
|
+
}
|
|
20
|
+
blockVersionMap.get(version.name).set(version.version, version);
|
|
21
|
+
}
|
|
22
|
+
iterApp_1.iterApp(definition, {
|
|
23
|
+
onBlock(block, path) {
|
|
24
|
+
var _a, _b, _c, _d, _e, _f;
|
|
25
|
+
const type = blockUtils_1.normalizeBlockName(block.type);
|
|
26
|
+
const versions = blockVersionMap.get(type);
|
|
27
|
+
if (!versions) {
|
|
28
|
+
report(block.type, 'is not a known block type', [...path, 'type']);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const actionParameters = new Set();
|
|
32
|
+
const version = versions.get(block.version);
|
|
33
|
+
if (!version) {
|
|
34
|
+
report(block.version, 'is not a known version for this block type', [...path, 'version']);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (version.parameters) {
|
|
38
|
+
const validator = new jsonschema_1.Validator();
|
|
39
|
+
validator.customFormats.fontawesome = () => true;
|
|
40
|
+
validator.customFormats.remapper = () => true;
|
|
41
|
+
validator.customFormats.action = (property) => {
|
|
42
|
+
actionParameters.add(property);
|
|
43
|
+
return has_1.has(block.actions, property);
|
|
44
|
+
};
|
|
45
|
+
validator.customFormats['event-listener'] = (property) => { var _a; return has_1.has((_a = block.events) === null || _a === void 0 ? void 0 : _a.listen, property); };
|
|
46
|
+
validator.customFormats['event-emitter'] = (property) => { var _a; return has_1.has((_a = block.events) === null || _a === void 0 ? void 0 : _a.emit, property); };
|
|
47
|
+
const result = validator.validate(block.parameters || {}, version.parameters);
|
|
48
|
+
for (const error of result.errors) {
|
|
49
|
+
report(error.instance, error.message, [...path, 'parameters', ...error.path]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (block.parameters) {
|
|
53
|
+
report(block.parameters, 'is now allowed on this block type', [...path, 'parameters']);
|
|
54
|
+
}
|
|
55
|
+
if (block.actions) {
|
|
56
|
+
if (version.actions) {
|
|
57
|
+
for (const [key, action] of Object.entries(block.actions)) {
|
|
58
|
+
if (version.actions.$any) {
|
|
59
|
+
if (actionParameters.has(key)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (!has_1.has(version.actions, key) && !version.wildcardActions) {
|
|
63
|
+
report(action, 'is unused', [...path, 'actions', key]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (!has_1.has(version.actions, key)) {
|
|
67
|
+
report(action, 'is an unknown action for this block', [...path, 'actions', key]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
report(block.actions, 'is now allowed on this block', [...path, 'actions']);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!block.events) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (block.events.emit) {
|
|
79
|
+
for (const [key, value] of Object.entries(block.events.emit)) {
|
|
80
|
+
if (!((_b = (_a = version.events) === null || _a === void 0 ? void 0 : _a.emit) === null || _b === void 0 ? void 0 : _b.$any) && !has_1.has((_c = version.events) === null || _c === void 0 ? void 0 : _c.emit, key)) {
|
|
81
|
+
report(value, 'is an unknown event emitter', [...path, 'events', 'emit', key]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (block.events.listen) {
|
|
86
|
+
for (const [key, value] of Object.entries(block.events.listen)) {
|
|
87
|
+
if (!((_e = (_d = version.events) === null || _d === void 0 ? void 0 : _d.listen) === null || _e === void 0 ? void 0 : _e.$any) && !has_1.has((_f = version.events) === null || _f === void 0 ? void 0 : _f.listen, key)) {
|
|
88
|
+
report(value, 'is an unknown event listener', [...path, 'events', 'listen', key]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function checkCyclicRoleInheritance(roles, name, report) {
|
|
96
|
+
let lastchecked;
|
|
97
|
+
const stack = [];
|
|
98
|
+
const checkRoleRecursively = (role) => {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
lastchecked = role;
|
|
101
|
+
if (stack.includes(role)) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
stack.push(role);
|
|
105
|
+
return (_b = (_a = roles[role]) === null || _a === void 0 ? void 0 : _a.inherits) === null || _b === void 0 ? void 0 : _b.some(checkRoleRecursively);
|
|
106
|
+
};
|
|
107
|
+
const duplicate = checkRoleRecursively(name);
|
|
108
|
+
if (duplicate && lastchecked === name) {
|
|
109
|
+
report(roles[name], 'cyclicly inherits itself', ['security', 'roles', name]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Validate security related definitions within the app definition.
|
|
114
|
+
*
|
|
115
|
+
* @param definition - The definition of the app
|
|
116
|
+
* @param report - A function used to report a value.
|
|
117
|
+
*/
|
|
118
|
+
function validateSecurity(definition, report) {
|
|
119
|
+
const { security } = definition;
|
|
120
|
+
const defaultAllow = ['$none', '$public', '$team:member', '$team:manager'];
|
|
121
|
+
if (!security) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const checkRoleExists = (name, path, allow = defaultAllow) => {
|
|
125
|
+
if (!has_1.has(security.roles, name) && !allow.includes(name)) {
|
|
126
|
+
report(name, 'does not exist in this app’s roles', path);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
const checkRoles = (object, path, allow = defaultAllow) => {
|
|
132
|
+
if (!(object === null || object === void 0 ? void 0 : object.roles)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
for (const [index, role] of object.roles.entries()) {
|
|
136
|
+
checkRoleExists(role, [...path, 'roles', index], allow);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
checkRoleExists(security.default.role, ['security', 'default', 'role']);
|
|
140
|
+
checkRoles(definition, []);
|
|
141
|
+
if (definition.resources) {
|
|
142
|
+
for (const [resourceName, resource] of Object.entries(definition.resources)) {
|
|
143
|
+
checkRoles(resource, ['resources', resourceName], [...defaultAllow, '$author']);
|
|
144
|
+
checkRoles(resource.count, ['resources', resourceName, 'count'], [...defaultAllow, '$author']);
|
|
145
|
+
checkRoles(resource.create, ['resources', resourceName, 'create']);
|
|
146
|
+
checkRoles(resource.delete, ['resources', resourceName, 'delete'], [...defaultAllow, '$author']);
|
|
147
|
+
checkRoles(resource.get, ['resources', resourceName, 'get'], [...defaultAllow, '$author']);
|
|
148
|
+
checkRoles(resource.query, ['resources', resourceName, 'query'], [...defaultAllow, '$author']);
|
|
149
|
+
checkRoles(resource.update, ['resources', resourceName, 'update'], [...defaultAllow, '$author']);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
iterApp_1.iterApp(definition, { onBlock: checkRoles, onPage: checkRoles });
|
|
153
|
+
for (const [name, role] of Object.entries(security.roles)) {
|
|
154
|
+
if (!(role === null || role === void 0 ? void 0 : role.inherits)) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
let found = false;
|
|
158
|
+
for (const [index, inheritee] of role.inherits.entries()) {
|
|
159
|
+
found || (found = checkRoleExists(inheritee, ['security', 'roles', name, 'inherits', index]));
|
|
160
|
+
}
|
|
161
|
+
if (found) {
|
|
162
|
+
checkCyclicRoleInheritance(security.roles, name, report);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Validates the hooks in resource definition to ensure its properties are valid.
|
|
168
|
+
*
|
|
169
|
+
* @param definition - The definition of the app
|
|
170
|
+
* @param report - A function used to report a value.
|
|
171
|
+
*/
|
|
172
|
+
function validateHooks(definition, report) {
|
|
173
|
+
var _a, _b, _c;
|
|
174
|
+
if (!definition.resources) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const actionTypes = ['create', 'update', 'delete'];
|
|
178
|
+
for (const [resourceKey, resource] of Object.entries(definition.resources)) {
|
|
179
|
+
for (const actionType of actionTypes) {
|
|
180
|
+
if (!has_1.has(resource, actionType)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const tos = (_b = (_a = resource[actionType].hooks) === null || _a === void 0 ? void 0 : _a.notification) === null || _b === void 0 ? void 0 : _b.to;
|
|
184
|
+
if (tos) {
|
|
185
|
+
for (const [index, to] of tos.entries()) {
|
|
186
|
+
if (to !== '$author' && !has_1.has((_c = definition.security) === null || _c === void 0 ? void 0 : _c.roles, to)) {
|
|
187
|
+
report(to, 'is an unknown role', [
|
|
188
|
+
'resources',
|
|
189
|
+
resourceKey,
|
|
190
|
+
actionType,
|
|
191
|
+
'hooks',
|
|
192
|
+
'notifications',
|
|
193
|
+
'to',
|
|
194
|
+
index,
|
|
195
|
+
]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function validateResourceReferences(definition, report) {
|
|
203
|
+
if (!definition.resources) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
for (const [resourceType, resource] of Object.entries(definition.resources)) {
|
|
207
|
+
if (!resource.references) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
for (const [field, reference] of Object.entries(resource.references)) {
|
|
211
|
+
if (!has_1.has(definition.resources, reference.resource)) {
|
|
212
|
+
report(reference.resource, 'is not an existing resource', [
|
|
213
|
+
'resources',
|
|
214
|
+
resourceType,
|
|
215
|
+
'references',
|
|
216
|
+
field,
|
|
217
|
+
'resource',
|
|
218
|
+
]);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (!has_1.has(resource.schema.properties, field)) {
|
|
222
|
+
report(field, 'does not exist on this resource', [
|
|
223
|
+
'resources',
|
|
224
|
+
resourceType,
|
|
225
|
+
'references',
|
|
226
|
+
field,
|
|
227
|
+
]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function validateLanguage({ defaultLanguage }, report) {
|
|
233
|
+
if (defaultLanguage != null && !language_tags_1.default.check(defaultLanguage)) {
|
|
234
|
+
report(defaultLanguage, 'is not a valid language code', ['defaultLanguage']);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function validateDefaultPage({ defaultPage, pages }, report) {
|
|
238
|
+
const page = pages === null || pages === void 0 ? void 0 : pages.find((p) => p.name === defaultPage);
|
|
239
|
+
if (!page) {
|
|
240
|
+
report(defaultPage, 'does not refer to an existing page', ['defaultPage']);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (page.parameters) {
|
|
244
|
+
report(defaultPage, 'may not specifiy parameters', ['defaultPage']);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function validateCronJobs({ cron }, report) {
|
|
248
|
+
if (!cron) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
for (const [id, job] of Object.entries(cron)) {
|
|
252
|
+
if (typeof (job === null || job === void 0 ? void 0 : job.schedule) !== 'string') {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
cron_parser_1.parseExpression(job.schedule);
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
report(job.schedule, 'contains an invalid expression', ['cron', id, 'schedule']);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function validateActions(definition, report) {
|
|
264
|
+
const urlRegex = new RegExp(`^${_1.partialNormalized.source}:`);
|
|
265
|
+
iterApp_1.iterApp(definition, {
|
|
266
|
+
onAction(action, path) {
|
|
267
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
268
|
+
if (action.type.startsWith('user.') && !definition.security) {
|
|
269
|
+
report(action.type, 'refers to a user action but the app doesn’t have a security definition', [...path, 'type']);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (action.type.startsWith('resource.')) {
|
|
273
|
+
// All of the actions starting with `resource.` contain a property called `resource`.
|
|
274
|
+
const { resource: resourceName } = action;
|
|
275
|
+
const resource = (_a = definition.resources) === null || _a === void 0 ? void 0 : _a[resourceName];
|
|
276
|
+
if (!resource) {
|
|
277
|
+
report(action.type, 'refers to a resource that doesn’t exist', [...path, 'resource']);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (!action.type.startsWith('resource.subscription.')) {
|
|
281
|
+
const type = action.type.split('.')[1];
|
|
282
|
+
const roles = (_c = (_b = resource === null || resource === void 0 ? void 0 : resource[type]) === null || _b === void 0 ? void 0 : _b.roles) !== null && _c !== void 0 ? _c : resource === null || resource === void 0 ? void 0 : resource.roles;
|
|
283
|
+
if (!roles) {
|
|
284
|
+
report(action.type, 'refers to a resource action that is currently set to private', [
|
|
285
|
+
...path,
|
|
286
|
+
'resource',
|
|
287
|
+
]);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (roles && !roles.length && !definition.security) {
|
|
291
|
+
report(action.type, 'refers to a resource action that is accessible when logged in, but the app has no security definitions', [...path, 'resource']);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (action.type.startsWith('flow.')) {
|
|
297
|
+
const page = (_d = definition.pages) === null || _d === void 0 ? void 0 : _d[Number(path[1])];
|
|
298
|
+
if ((page === null || page === void 0 ? void 0 : page.type) !== 'flow') {
|
|
299
|
+
report(action.type, 'flow actions can only be used on pages with the type ‘flow’', [
|
|
300
|
+
...path,
|
|
301
|
+
'type',
|
|
302
|
+
]);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (action.type === 'flow.cancel' && !((_e = page.actions) === null || _e === void 0 ? void 0 : _e.onFlowCancel)) {
|
|
306
|
+
report(action.type, 'was defined but ‘onFlowCancel’ page action wasn’t defined', [
|
|
307
|
+
...path,
|
|
308
|
+
'type',
|
|
309
|
+
]);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (action.type === 'flow.finish' && !((_f = page.actions) === null || _f === void 0 ? void 0 : _f.onFlowFinish)) {
|
|
313
|
+
report(action.type, 'was defined but ‘onFlowFinish’ page action wasn’t defined', [
|
|
314
|
+
...path,
|
|
315
|
+
'type',
|
|
316
|
+
]);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (action.type === 'flow.back' && path[3] === 0) {
|
|
320
|
+
report(action.type, 'is not allowed on the first step in the flow', [...path, 'type']);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (action.type === 'flow.next' &&
|
|
324
|
+
Number(path[3]) === page.steps.length - 1 &&
|
|
325
|
+
!((_g = page.actions) === null || _g === void 0 ? void 0 : _g.onFlowFinish)) {
|
|
326
|
+
report(action.type, 'was defined on the last step but ‘onFlowFinish’ page action wasn’t defined', [...path, 'type']);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (action.type === 'flow.to' && !page.steps.some((step) => step.name === action.step)) {
|
|
330
|
+
report(action.type, 'refers to a step that doesn’t exist', [...path, 'step']);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (action.type === 'link') {
|
|
335
|
+
const { to } = action;
|
|
336
|
+
if (typeof to === 'string' && urlRegex.test(to)) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const [toBase, toSub] = [].concat(to);
|
|
340
|
+
const toPage = definition.pages.find(({ name }) => name === toBase);
|
|
341
|
+
if (!toPage) {
|
|
342
|
+
report(to, 'refers to a page that doesn’t exist', [...path, 'to']);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (toPage.type !== 'tabs' && toSub) {
|
|
346
|
+
report(toSub, 'refers to a sub page on a page that isn’t of type ‘tabs’ or ‘flow’', [
|
|
347
|
+
...path,
|
|
348
|
+
'to',
|
|
349
|
+
1,
|
|
350
|
+
]);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (toPage.type === 'tabs' && toSub) {
|
|
354
|
+
const subPage = toPage.tabs.find(({ name }) => name === toSub);
|
|
355
|
+
if (!subPage) {
|
|
356
|
+
report(toSub, 'refers to a tab that doesn’t exist', [...path, 'to', 1]);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Validate an app definition.
|
|
365
|
+
*
|
|
366
|
+
* This check various conditions which can’t be validated using basic JSON schema validation.
|
|
367
|
+
*
|
|
368
|
+
* @param definition - The app validation to check.
|
|
369
|
+
* @param getBlockVersions - A function for getting block manifests from block versions.
|
|
370
|
+
* @param validatorResult - If specified, error messages will be applied to this existing validator
|
|
371
|
+
* result.
|
|
372
|
+
* @returns A validator result which contains all app validation violations.
|
|
373
|
+
*/
|
|
374
|
+
async function validateAppDefinition(definition, getBlockVersions, validatorResult) {
|
|
375
|
+
let result = validatorResult;
|
|
376
|
+
if (!result) {
|
|
377
|
+
const validator = new jsonschema_1.Validator();
|
|
378
|
+
result = validator.validate(definition, {});
|
|
379
|
+
}
|
|
380
|
+
if (!definition) {
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
const blocks = blockUtils_1.getAppBlocks(definition);
|
|
384
|
+
const blockVersions = await getBlockVersions(blocks);
|
|
385
|
+
const report = (instance, message, path) => {
|
|
386
|
+
result.errors.push(new jsonschema_1.ValidationError(message, instance, undefined, path));
|
|
387
|
+
};
|
|
388
|
+
try {
|
|
389
|
+
validateCronJobs(definition, report);
|
|
390
|
+
validateDefaultPage(definition, report);
|
|
391
|
+
validateHooks(definition, report);
|
|
392
|
+
validateLanguage(definition, report);
|
|
393
|
+
validateResourceReferences(definition, report);
|
|
394
|
+
validateSecurity(definition, report);
|
|
395
|
+
validateBlocks(definition, blockVersions, report);
|
|
396
|
+
validateActions(definition, report);
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
report(null, `Unexpected error: ${error.message}`, []);
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
403
|
+
exports.validateAppDefinition = validateAppDefinition;
|
|
404
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;;;;;AAMA,6CAA8C;AAC9C,2CAAyE;AACzE,kEAAyC;AAGzC,wBAAsC;AACtC,6CAAmF;AACnF,+BAA4B;AAC5B,uCAA4C;AAI5C,SAAS,cAAc,CACrB,UAAyB,EACzB,aAA8B,EAC9B,MAAc;IAEd,MAAM,eAAe,GAAG,IAAI,GAAG,EAAsC,CAAC;IACtE,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;QACnC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACtC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;SAC9C;QACD,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACjE;IACD,iBAAO,CAAC,UAAU,EAAE;QAClB,OAAO,CAAC,KAAK,EAAE,IAAI;;YACjB,MAAM,IAAI,GAAG,+BAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,2BAA2B,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;gBACnE,OA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EAAE;QACf,OAAO,MAAM,CAAC;KACf;IAED,MAAM,MAAM,GAAG,yBAAY,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,MAAM,GAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,4BAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC;IAEF,IAAI;QACF,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACrC,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACxC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAClC,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACrC,0BAA0B,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC/C,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACrC,cAAc,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAClD,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;KACrC;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,IAAI,EAAE,qBAAqB,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;KACxD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAnCD,sDAmCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/utils",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.8",
|
|
4
4
|
"description": "Utility functions used in Appsemble internally",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test": "jest"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@appsemble/types": "0.19.
|
|
32
|
+
"@appsemble/types": "0.19.8",
|
|
33
33
|
"axios": "^0.23.0",
|
|
34
34
|
"cron-parser": "^4.0.0",
|
|
35
35
|
"date-fns": "^2.0.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@types/language-tags": "^1.0.0",
|
|
51
51
|
"@types/lcm": "^0.0.0",
|
|
52
52
|
"bulma": "0.9.3",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
53
|
+
"koas-core": "^0.5.0",
|
|
54
|
+
"yaml": "^2.0.0-8"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=12.0.0"
|
package/dist/getAppBlocks.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AppDefinition, BlockDefinition } from '@appsemble/types';
|
|
2
|
-
export declare type BlockMap = Record<string, BlockDefinition>;
|
|
3
|
-
/**
|
|
4
|
-
* Extract all blocks from an app definition.
|
|
5
|
-
*
|
|
6
|
-
* @param definition - The app from which to extract the blocks.
|
|
7
|
-
* @returns A mapping of paths in the app definition to blocks. The returned blocks are the same
|
|
8
|
-
* instance as that in the app definition.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getAppBlocks(definition: AppDefinition): BlockMap;
|
package/dist/getAppBlocks.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAppBlocks = void 0;
|
|
4
|
-
const iterApp_1 = require("./iterApp");
|
|
5
|
-
/**
|
|
6
|
-
* Extract all blocks from an app definition.
|
|
7
|
-
*
|
|
8
|
-
* @param definition - The app from which to extract the blocks.
|
|
9
|
-
* @returns A mapping of paths in the app definition to blocks. The returned blocks are the same
|
|
10
|
-
* instance as that in the app definition.
|
|
11
|
-
*/
|
|
12
|
-
function getAppBlocks(definition) {
|
|
13
|
-
const blocks = {};
|
|
14
|
-
iterApp_1.iterApp(definition, {
|
|
15
|
-
onBlock(block, prefix) {
|
|
16
|
-
blocks[prefix.join('.')] = block;
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
return blocks;
|
|
20
|
-
}
|
|
21
|
-
exports.getAppBlocks = getAppBlocks;
|
|
22
|
-
//# sourceMappingURL=getAppBlocks.js.map
|
package/dist/getAppBlocks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAppBlocks.js","sourceRoot":"","sources":["../src/getAppBlocks.ts"],"names":[],"mappings":";;;AAEA,uCAAoC;AAIpC;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,UAAyB;IACpD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,iBAAO,CAAC,UAAU,EAAE;QAClB,OAAO,CAAC,KAAK,EAAE,MAAM;YACnB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACnC,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,oCAUC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AppDefinition, BlockManifest } from '@appsemble/types';
|
|
2
|
-
import { Promisable } from 'type-fest';
|
|
3
|
-
import { BlockMap } from './getAppBlocks';
|
|
4
|
-
/**
|
|
5
|
-
* Used for throwing known Appsemble validation errors.
|
|
6
|
-
*/
|
|
7
|
-
export declare class AppsembleValidationError extends Error {
|
|
8
|
-
data?: unknown;
|
|
9
|
-
/**
|
|
10
|
-
* @param message - The error message to show to the user.
|
|
11
|
-
* @param data - Additional data that can be passed to convey additional info about the error.
|
|
12
|
-
*/
|
|
13
|
-
constructor(message: string, data?: unknown);
|
|
14
|
-
}
|
|
15
|
-
export declare function checkBlocks(blocks: BlockMap, blockVersions: BlockManifest[]): void;
|
|
16
|
-
/**
|
|
17
|
-
* Validates security-related definitions within the app definition.
|
|
18
|
-
*
|
|
19
|
-
* @param definition - The definition of the app
|
|
20
|
-
*/
|
|
21
|
-
export declare function validateSecurity(definition: AppDefinition): void;
|
|
22
|
-
/**
|
|
23
|
-
* Validates the hooks in resource definition to ensure its properties are valid.
|
|
24
|
-
*
|
|
25
|
-
* @param {} definition - The definition of the app
|
|
26
|
-
*/
|
|
27
|
-
export declare function validateHooks(definition: AppDefinition): void;
|
|
28
|
-
export declare function validateReferences(definition: AppDefinition): void;
|
|
29
|
-
export declare function validateLanguage(language: string): void;
|
|
30
|
-
export declare function validateDefaultPage({ defaultPage, pages }: AppDefinition): void;
|
|
31
|
-
export declare function validateCronJobs({ cron }: AppDefinition): void;
|
|
32
|
-
export declare function validateAppDefinition(definition: AppDefinition, getBlockVersions: (blockMap: BlockMap) => Promisable<BlockManifest[]>): Promise<void>;
|