@appsemble/lang-sdk 0.40.7-node-brotli.0 → 0.40.7
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 +14 -1
- package/package.json +1 -1
- package/validation.js +7 -12
package/iterApp.js
CHANGED
|
@@ -25,6 +25,9 @@ export function iterAction(action, callbacks, prefix = []) {
|
|
|
25
25
|
if (action.type === 'each') {
|
|
26
26
|
return iterAction(action.do, callbacks, [...prefix, 'do']);
|
|
27
27
|
}
|
|
28
|
+
if (action.type === 'match') {
|
|
29
|
+
return action.match.some((matchCase, index) => iterAction(matchCase.action, callbacks, [...prefix, 'match', index, 'action']));
|
|
30
|
+
}
|
|
28
31
|
if ('blocks' in action) {
|
|
29
32
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
30
33
|
return iterBlockList(action.blocks, callbacks, [...prefix, 'blocks']);
|
|
@@ -137,7 +140,10 @@ export function iterPage(page, callbacks, prefix = []) {
|
|
|
137
140
|
}
|
|
138
141
|
return result;
|
|
139
142
|
}
|
|
140
|
-
const { blocks = [] } = page;
|
|
143
|
+
const { actions, blocks = [] } = page;
|
|
144
|
+
if (Object.entries(actions ?? {}).some(([key, action]) => iterAction(action, callbacks, [...prefix, 'actions', key]))) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
141
147
|
return iterBlockList(blocks, callbacks, [...prefix, 'blocks']);
|
|
142
148
|
}
|
|
143
149
|
/**
|
|
@@ -162,6 +168,13 @@ export function iterApp(app, callbacks) {
|
|
|
162
168
|
}
|
|
163
169
|
}
|
|
164
170
|
}
|
|
171
|
+
if (app.webhooks) {
|
|
172
|
+
for (const [name, webhook] of Object.entries(app.webhooks)) {
|
|
173
|
+
if (webhook?.action && iterAction(webhook.action, callbacks, ['webhooks', name, 'action'])) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
165
178
|
return false;
|
|
166
179
|
}
|
|
167
180
|
//# sourceMappingURL=iterApp.js.map
|
package/package.json
CHANGED
package/validation.js
CHANGED
|
@@ -9,7 +9,7 @@ import { findPageByName } from './findPageByName.js';
|
|
|
9
9
|
import { isAppLink } from './pageUtils.js';
|
|
10
10
|
import { bottomNavigationGridArea, breadcrumbsGridArea, builtinPagesGridAreaOrder, getBuiltinPagesDefaultGridLayout, getCascadedGridTemplateAreas, getGridTemplateAreas, gridDeviceOrder, resendBannerGridArea, } from './gridUtils.js';
|
|
11
11
|
import { isValidIconName, parseIconReference } from './icons.js';
|
|
12
|
-
import {
|
|
12
|
+
import { iterApp } from './iterApp.js';
|
|
13
13
|
import { has } from './miscellaneous.js';
|
|
14
14
|
import { normalize } from './normalize.js';
|
|
15
15
|
import { serverActions } from './serverActions.js';
|
|
@@ -1467,6 +1467,10 @@ function validateActions(definition, report) {
|
|
|
1467
1467
|
report(action.type, 'action type is not supported for cron jobs', [...path, 'type']);
|
|
1468
1468
|
return;
|
|
1469
1469
|
}
|
|
1470
|
+
if (path[0] === 'webhooks' && !serverActions.has(action.type)) {
|
|
1471
|
+
report(action.type, 'action type is not supported for webhooks', [...path, 'type']);
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1470
1474
|
if (validateUnsupportedServerOptimisticResourceWrite(action, path)) {
|
|
1471
1475
|
return;
|
|
1472
1476
|
}
|
|
@@ -1502,7 +1506,8 @@ function validateActions(definition, report) {
|
|
|
1502
1506
|
report(action.type, 'refers to a resource that doesn’t exist', [...path, 'resource']);
|
|
1503
1507
|
return;
|
|
1504
1508
|
}
|
|
1505
|
-
|
|
1509
|
+
// Webhook actions run on the server without checking resource permissions.
|
|
1510
|
+
if (!action.type.startsWith('resource.subscription.') && path[0] !== 'webhooks') {
|
|
1506
1511
|
if (!definition.security) {
|
|
1507
1512
|
report(action.type, 'missing security definition', [...path, 'resource']);
|
|
1508
1513
|
return;
|
|
@@ -1637,16 +1642,6 @@ function validateActions(definition, report) {
|
|
|
1637
1642
|
}
|
|
1638
1643
|
},
|
|
1639
1644
|
});
|
|
1640
|
-
for (const [name, webhook] of Object.entries(definition.webhooks ?? {})) {
|
|
1641
|
-
if (webhook.action &&
|
|
1642
|
-
iterAction(webhook.action, {
|
|
1643
|
-
onAction(action, path) {
|
|
1644
|
-
return validateUnsupportedServerOptimisticResourceWrite(action, path);
|
|
1645
|
-
},
|
|
1646
|
-
}, ['webhooks', name, 'action'])) {
|
|
1647
|
-
return;
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
1645
|
}
|
|
1651
1646
|
function validateEvents(definition, blockVersions, report) {
|
|
1652
1647
|
const indexMap = new Map();
|