Compose-ready workspace: packages/zappier (rate card, portal, Stripe), packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier (CLI app), vendor/zapier-platform, and research/zapier vendor corpus. Gate 0 structure checks pass. Product code and research are not yet wired.
35 lines
867 B
JavaScript
35 lines
867 B
JavaScript
'use strict';
|
|
|
|
const _ = require('lodash');
|
|
const jsonschema = require('jsonschema');
|
|
|
|
const actionTypes = ['triggers', 'searches', 'creates'];
|
|
|
|
const matchingKeys = (definition) => {
|
|
const errors = [];
|
|
|
|
// verifies that x.key === x
|
|
// otherwise, we double results in the compiled app via core's compileApp
|
|
|
|
for (const actionType of actionTypes) {
|
|
const group = definition[actionType] || {};
|
|
_.each(group, (action, key) => {
|
|
if (action.key !== key) {
|
|
errors.push(
|
|
new jsonschema.ValidationError(
|
|
`must have a matching top-level key (found "${key}" and "${action.key}")`,
|
|
action,
|
|
`/${_.capitalize(actionType)}Schema`,
|
|
`instance.${key}.key`,
|
|
'invalid',
|
|
'key',
|
|
),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
return errors;
|
|
};
|
|
|
|
module.exports = matchingKeys;
|