UNPKG

n8n

Version:

n8n Workflow Automation Tool

68 lines 3.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.packageRequirementsSchema = exports.packageVariableRequirementSchema = exports.packageNodeTypeRequirementSchema = exports.packageWorkflowRequirementSchema = exports.packageDataTableRequirementSchema = exports.packageCredentialRequirementSchema = void 0; const zod_1 = require("zod"); exports.packageCredentialRequirementSchema = zod_1.z.object({ id: zod_1.z.string().min(1), name: zod_1.z.string().min(1), type: zod_1.z.string().min(1), usedByWorkflows: zod_1.z.array(zod_1.z.string().min(1)).min(1), }); exports.packageDataTableRequirementSchema = zod_1.z.object({ id: zod_1.z.string().min(1), name: zod_1.z.string().min(1), usedByWorkflows: zod_1.z.array(zod_1.z.string().min(1)).min(1), }); exports.packageWorkflowRequirementSchema = zod_1.z.object({ id: zod_1.z.string().min(1), name: zod_1.z.string().min(1), usedByWorkflows: zod_1.z.array(zod_1.z.string().min(1)).min(1), }); exports.packageNodeTypeRequirementSchema = zod_1.z.object({ type: zod_1.z.string().min(1), typeVersion: zod_1.z.number().finite(), usedByWorkflows: zod_1.z.array(zod_1.z.string().min(1)).min(1), }); exports.packageVariableRequirementSchema = zod_1.z.object({ name: zod_1.z.string().min(1), value: zod_1.z.string().optional(), usedByWorkflows: zod_1.z.array(zod_1.z.string().min(1)).min(1), }); function assertNoDuplicateKey(entries, keyOf, label, ctx) { if (!entries) return; const seen = new Set(); for (const entry of entries) { const key = keyOf(entry); if (seen.has(key)) { ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message: `Duplicate ${label}: ${key}`, }); } seen.add(key); } } exports.packageRequirementsSchema = zod_1.z.object({ credentials: zod_1.z .array(exports.packageCredentialRequirementSchema) .optional() .superRefine((credentials, ctx) => assertNoDuplicateKey(credentials, ({ id }) => id, 'credential id', ctx)), dataTables: zod_1.z .array(exports.packageDataTableRequirementSchema) .optional() .superRefine((dataTables, ctx) => assertNoDuplicateKey(dataTables, ({ id }) => id, 'data table id', ctx)), workflows: zod_1.z .array(exports.packageWorkflowRequirementSchema) .optional() .superRefine((workflows, ctx) => assertNoDuplicateKey(workflows, ({ id }) => id, 'workflow id', ctx)), variables: zod_1.z .array(exports.packageVariableRequirementSchema) .optional() .superRefine((variables, ctx) => assertNoDuplicateKey(variables, ({ name }) => name, 'variable name', ctx)), nodeTypes: zod_1.z .array(exports.packageNodeTypeRequirementSchema) .optional() .superRefine((nodeTypes, ctx) => assertNoDuplicateKey(nodeTypes, ({ type, typeVersion }) => `${type}@${typeVersion}`, 'node type', ctx)), }); //# sourceMappingURL=requirements.schema.js.map