n8n-nodes-base
Version:
Base nodes of n8n
24 lines (22 loc) • 1 kB
JavaScript
/**
* Cockpit Node - Version 1 - Zod Schema Factory
* Exports a factory that unions all discriminator schemas.
*
* Schema helpers (z, expressionSchema, etc.) are passed as parameters
* by the schema-validator, not imported from external files.
*
* @generated - CommonJS JavaScript for runtime loading
*/
const getCollectionSchema = require('./resource_collection/index.schema');
const getFormSchema = require('./resource_form/index.schema');
const getSingletonSchema = require('./resource_singleton/index.schema');
module.exports = function getSchema(helpers) {
const { parameters, z } = helpers;
// Apply discriminator default if not set
const effectiveParams = parameters.resource === undefined ? { ...parameters, resource: 'collection' } : parameters;
return z.union([
getCollectionSchema({ ...helpers, parameters: effectiveParams }),
getFormSchema({ ...helpers, parameters: effectiveParams }),
getSingletonSchema({ ...helpers, parameters: effectiveParams }),
]);
};