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
56
vendor/zapier-platform/packages/schema/lib/functional-constraints/requiredSamples.js
vendored
Normal file
56
vendor/zapier-platform/packages/schema/lib/functional-constraints/requiredSamples.js
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
const jsonschema = require('jsonschema');
|
||||
|
||||
// todo: deal with circular dep.
|
||||
const RESOURCE_ID = '/ResourceSchema';
|
||||
const RESOURCE_METHODS = ['get', 'hook', 'list', 'search', 'create'];
|
||||
|
||||
const check = (definition) => {
|
||||
if (!definition.operation || _.get(definition, 'display.hidden')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const samples = _.get(definition, 'operation.sample', {});
|
||||
return !_.isEmpty(samples)
|
||||
? null
|
||||
: new jsonschema.ValidationError(
|
||||
'requires "sample", because it\'s not hidden',
|
||||
definition,
|
||||
definition.id,
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = (definition, mainSchema) => {
|
||||
let definitions = [];
|
||||
|
||||
if (mainSchema.id === RESOURCE_ID) {
|
||||
definitions = RESOURCE_METHODS.map((method) => definition[method]).filter(
|
||||
Boolean,
|
||||
);
|
||||
|
||||
// allow method definitions to inherit the sample
|
||||
if (definition.sample) {
|
||||
definitions.forEach((methodDefinition) => {
|
||||
if (methodDefinition.operation && !methodDefinition.operation.sample) {
|
||||
methodDefinition.operation.sample = definition.sample;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!definitions.length) {
|
||||
return [
|
||||
new jsonschema.ValidationError(
|
||||
'expected at least one resource operation',
|
||||
definition,
|
||||
definition.id,
|
||||
),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
definitions = [definition];
|
||||
}
|
||||
|
||||
return definitions.map(check).filter(Boolean);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue