@appsemble/lang-sdk 0.37.0 → 0.37.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/iterApp.js +24 -15
- package/package.json +1 -1
- package/validation.js +9 -1
package/iterApp.js
CHANGED
|
@@ -97,34 +97,43 @@ export function iterPage(page, callbacks, prefix = []) {
|
|
|
97
97
|
if ('actions' in page) {
|
|
98
98
|
result = Object.entries(page.actions ?? {}).some(([key, action]) => iterAction(action, callbacks, [...prefix, 'actions', key]));
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
if (result) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (page.type === 'flow') {
|
|
104
|
+
const { steps = [] } = page;
|
|
105
|
+
return steps.some((step, index) => iterBlockList(step.blocks ?? [], callbacks, [...prefix, 'steps', index, 'blocks']));
|
|
106
|
+
}
|
|
107
|
+
return page.tabs
|
|
108
|
+
? page.tabs.some((tab, index) => iterBlockList(tab.blocks, callbacks, [...prefix, 'tabs', index, 'blocks']))
|
|
109
|
+
: iterBlockList(page.definition?.foreach.blocks ?? [], callbacks, [
|
|
110
|
+
...prefix,
|
|
111
|
+
'tabs',
|
|
112
|
+
0,
|
|
113
|
+
'blocks',
|
|
114
|
+
]);
|
|
111
115
|
}
|
|
112
116
|
if (page.type === 'loop') {
|
|
113
117
|
let result = false;
|
|
114
118
|
if ('actions' in page) {
|
|
115
119
|
result = Object.entries(page.actions ?? {}).some(([key, action]) => iterAction(action, callbacks, [...prefix, 'actions', key]));
|
|
116
120
|
}
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
if (result) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
const { foreach } = page;
|
|
125
|
+
return ['steps.first', 'steps', 'steps.last'].some((suffix) => iterBlockList(foreach?.blocks ?? [], callbacks, [...prefix, suffix, 'blocks']));
|
|
119
126
|
}
|
|
120
127
|
if (page.type === 'container') {
|
|
121
128
|
let result = false;
|
|
122
|
-
|
|
129
|
+
const { pages = [] } = page;
|
|
130
|
+
for (const containerPage of pages) {
|
|
123
131
|
result = iterPage(containerPage, callbacks, prefix);
|
|
124
132
|
}
|
|
125
133
|
return result;
|
|
126
134
|
}
|
|
127
|
-
|
|
135
|
+
const { blocks = [] } = page;
|
|
136
|
+
return iterBlockList(blocks, callbacks, [...prefix, 'blocks']);
|
|
128
137
|
}
|
|
129
138
|
/**
|
|
130
139
|
* Iterate over an app definition and call each callback if relevant.
|
package/package.json
CHANGED
package/validation.js
CHANGED
|
@@ -55,7 +55,10 @@ function validateJSONSchema(schema, prefix, report) {
|
|
|
55
55
|
if (schema.type !== 'object') {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
// An object that only defines `additionalProperties` (an open map, e.g. a
|
|
59
|
+
// dictionary of confidence scores) is a valid schema and does not need
|
|
60
|
+
// `properties`. Only require `properties` when there is no `additionalProperties`.
|
|
61
|
+
if (!('properties' in schema) && !schema.additionalProperties) {
|
|
59
62
|
report(schema, 'is missing properties', prefix);
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
@@ -69,6 +72,11 @@ function validateJSONSchema(schema, prefix, report) {
|
|
|
69
72
|
for (const [key, propertySchema] of Object.entries(schema.properties ?? {})) {
|
|
70
73
|
validateJSONSchema(propertySchema, [...prefix, 'properties', key], report);
|
|
71
74
|
}
|
|
75
|
+
// Recurse into the `additionalProperties` sub schema so open maps are validated
|
|
76
|
+
// as thoroughly as `properties`. A boolean `additionalProperties` has no sub schema.
|
|
77
|
+
if (typeof schema.additionalProperties === 'object') {
|
|
78
|
+
validateJSONSchema(schema.additionalProperties, [...prefix, 'additionalProperties'], report);
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
81
|
/**
|
|
74
82
|
* Validates the pages in the app definition to ensure there are no duplicate page names.
|