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.
This commit is contained in:
commit
b4150c8250
1364 changed files with 6814366 additions and 0 deletions
68
vendor/zapier-platform/packages/schema/lib/functional-constraints/deepNestedFields.js
vendored
Normal file
68
vendor/zapier-platform/packages/schema/lib/functional-constraints/deepNestedFields.js
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
const jsonschema = require('jsonschema');
|
||||
|
||||
const collectErrors = (inputFields, path) => {
|
||||
const errors = [];
|
||||
|
||||
_.each(inputFields, (inputField, index) => {
|
||||
if (inputField.children) {
|
||||
if (inputField.children.length === 0) {
|
||||
errors.push(
|
||||
new jsonschema.ValidationError(
|
||||
'must not be empty.',
|
||||
inputField,
|
||||
'/PlainFieldSchema',
|
||||
`instance.${path}.inputFields[${index}].children`,
|
||||
'empty',
|
||||
'inputFields',
|
||||
),
|
||||
);
|
||||
} else {
|
||||
const hasDeeplyNestedChildren = _.some(
|
||||
inputField.children,
|
||||
(child) => child.children,
|
||||
);
|
||||
|
||||
if (hasDeeplyNestedChildren) {
|
||||
errors.push(
|
||||
new jsonschema.ValidationError(
|
||||
'must not contain deeply nested child fields. One level max.',
|
||||
inputField,
|
||||
'/PlainFieldSchema',
|
||||
`instance.${path}.inputFields[${index}]`,
|
||||
'deepNesting',
|
||||
'inputFields',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
const validateFieldNesting = (definition) => {
|
||||
let errors = [];
|
||||
|
||||
_.each(['triggers', 'searches', 'creates'], (typeOf) => {
|
||||
if (definition[typeOf]) {
|
||||
_.each(definition[typeOf], (actionDef) => {
|
||||
if (actionDef.operation && actionDef.operation.inputFields) {
|
||||
errors = errors.concat(
|
||||
collectErrors(
|
||||
actionDef.operation.inputFields,
|
||||
`${typeOf}.${actionDef.key}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
module.exports = validateFieldNesting;
|
||||
Loading…
Add table
Add a link
Reference in a new issue