@n8n/n8n-nodes-langchain
Version:

31 lines (28 loc) • 2.13 kB
JavaScript
/**
* Code Tool Node - Version 1.2 - Zod Validation Schemas
*
* These schemas validate node configuration at runtime.
* Use .parse() for strict validation or .safeParse() for error handling.
*
* Schema helpers (z, expressionSchema, etc.) are passed as parameters
* by the schema-validator, not imported from external files.
*
* @generated - CommonJS JavaScript for runtime loading
*/
module.exports = function getSchema({ parameters, z, expressionSchema, stringOrExpression, numberOrExpression, booleanOrExpression, resourceLocatorValueSchema, resourceMapperValueSchema, filterValueSchema, assignmentCollectionValueSchema, iDataObjectSchema, resolveSchema }) {
// Parameters schema
const parametersSchema = z.object({
description: stringOrExpression.optional(),
language: z.union([z.literal('javaScript'), z.literal('python')]).optional(),
jsCode: resolveSchema({ parameters, schema: z.string(), required: false, displayOptions: {"show":{"language":["javaScript"]}}, defaults: {"language":"javaScript"} }),
pythonCode: resolveSchema({ parameters, schema: z.string(), required: false, displayOptions: {"show":{"language":["python"]}}, defaults: {"language":"javaScript"} }),
specifyInputSchema: z.boolean().optional(),
schemaType: resolveSchema({ parameters, schema: z.union([z.literal('fromJson'), z.literal('manual')]), required: false, displayOptions: {"show":{"specifyInputSchema":[true]}}, defaults: {"specifyInputSchema":false} }),
jsonSchemaExample: resolveSchema({ parameters, schema: z.union([iDataObjectSchema, z.string()]), required: false, displayOptions: {"show":{"specifyInputSchema":[true],"schemaType":["fromJson"]}}, defaults: {"specifyInputSchema":false,"schemaType":"fromJson"} }),
inputSchema: resolveSchema({ parameters, schema: z.union([iDataObjectSchema, z.string()]), required: false, displayOptions: {"show":{"specifyInputSchema":[true],"schemaType":["manual"]}}, defaults: {"specifyInputSchema":false,"schemaType":"fromJson"} }),
});
// Return combined config schema
return z.object({
parameters: parametersSchema.nullable().optional(),
});
};