master-zapier-plan-draft/vendor/zapier-platform/packages/schema/lib/functional-constraints/matchingKeys.js
George Lambert b4150c8250 Milestone 0: import zappier billing, Verae middleware, and Zapier research
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.
2026-09-09 02:37:36 -04:00

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;