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
102
vendor/zapier-platform/packages/schema/lib/functional-constraints/bufferedCreateConstraints.js
vendored
Normal file
102
vendor/zapier-platform/packages/schema/lib/functional-constraints/bufferedCreateConstraints.js
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
const jsonschema = require('jsonschema');
|
||||
|
||||
const bufferedCreateConstraints = (definition) => {
|
||||
const errors = [];
|
||||
const actionType = 'creates';
|
||||
|
||||
if (definition[actionType]) {
|
||||
_.each(definition[actionType], (actionDef) => {
|
||||
if (actionDef.operation && actionDef.operation.buffer) {
|
||||
if (!actionDef.operation.performBuffer) {
|
||||
errors.push(
|
||||
new jsonschema.ValidationError(
|
||||
'must contain property "performBuffer" because property "buffer" is present.',
|
||||
actionDef.operation,
|
||||
'/BasicCreateOperationSchema',
|
||||
`instance.${actionType}.${actionDef.key}.operation`,
|
||||
'missing',
|
||||
'performBuffer',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (actionDef.operation.perform) {
|
||||
errors.push(
|
||||
new jsonschema.ValidationError(
|
||||
'must not contain property "perform" because it is mutually exclusive with property "buffer".',
|
||||
actionDef.operation,
|
||||
'/BasicCreateOperationSchema',
|
||||
`instance.${actionType}.${actionDef.key}.operation`,
|
||||
'invalid',
|
||||
'perform',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (actionDef.operation.buffer.groupedBy) {
|
||||
const requiredInputFields = [];
|
||||
const inputFields = _.get(
|
||||
actionDef,
|
||||
['operation', 'inputFields'],
|
||||
[],
|
||||
);
|
||||
inputFields.forEach((inputField) => {
|
||||
if (inputField.required) {
|
||||
requiredInputFields.push(inputField.key);
|
||||
}
|
||||
});
|
||||
|
||||
actionDef.operation.buffer.groupedBy.forEach((field, index) => {
|
||||
if (!requiredInputFields.includes(field)) {
|
||||
errors.push(
|
||||
new jsonschema.ValidationError(
|
||||
`cannot use optional or non-existent inputField "${field}".`,
|
||||
actionDef.operation.buffer,
|
||||
'/BufferConfigSchema',
|
||||
`instance.${actionType}.${actionDef.key}.operation.buffer.groupedBy[${index}]`,
|
||||
'invalid',
|
||||
'groupedBy',
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (actionDef.operation && actionDef.operation.performBuffer) {
|
||||
if (!actionDef.operation.buffer) {
|
||||
errors.push(
|
||||
new jsonschema.ValidationError(
|
||||
'must contain property "buffer" because property "performBuffer" is present.',
|
||||
actionDef.operation,
|
||||
'/BasicCreateOperationSchema',
|
||||
`instance.${actionType}.${actionDef.key}.operation`,
|
||||
'missing',
|
||||
'buffer',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (actionDef.operation.perform) {
|
||||
errors.push(
|
||||
new jsonschema.ValidationError(
|
||||
'must not contain property "perform" because it is mutually exclusive with property "performBuffer".',
|
||||
actionDef.operation,
|
||||
'/BasicCreateOperationSchema',
|
||||
`instance.${actionType}.${actionDef.key}.operation`,
|
||||
'invalid',
|
||||
'perform',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
module.exports = bufferedCreateConstraints;
|
||||
Loading…
Add table
Add a link
Reference in a new issue