mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix(Code Tool Node): Fix Input Schema Parameter not hiding correctly (#13245)
This commit is contained in:
@@ -15,7 +15,11 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
import { jsonParse, NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { inputSchemaField, jsonSchemaExampleField, schemaTypeField } from '@utils/descriptions';
|
||||
import {
|
||||
buildInputSchemaField,
|
||||
buildJsonSchemaExampleField,
|
||||
schemaTypeField,
|
||||
} from '@utils/descriptions';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
@@ -168,8 +172,8 @@ export class ToolCode implements INodeType {
|
||||
default: false,
|
||||
},
|
||||
{ ...schemaTypeField, displayOptions: { show: { specifyInputSchema: [true] } } },
|
||||
jsonSchemaExampleField,
|
||||
inputSchemaField,
|
||||
buildJsonSchemaExampleField({ showExtraProps: { specifyInputSchema: [true] } }),
|
||||
buildInputSchemaField({ showExtraProps: { specifyInputSchema: [true] } }),
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import type { DisplayCondition, INodeProperties, NodeParameterValue } from 'n8n-workflow';
|
||||
|
||||
export const schemaTypeField: INodeProperties = {
|
||||
displayName: 'Schema Type',
|
||||
@@ -21,7 +21,9 @@ export const schemaTypeField: INodeProperties = {
|
||||
description: 'How to specify the schema for the function',
|
||||
};
|
||||
|
||||
export const jsonSchemaExampleField: INodeProperties = {
|
||||
export const buildJsonSchemaExampleField = (props?: {
|
||||
showExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;
|
||||
}): INodeProperties => ({
|
||||
displayName: 'JSON Example',
|
||||
name: 'jsonSchemaExample',
|
||||
type: 'json',
|
||||
@@ -34,13 +36,18 @@ export const jsonSchemaExampleField: INodeProperties = {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
...props?.showExtraProps,
|
||||
schemaType: ['fromJson'],
|
||||
},
|
||||
},
|
||||
description: 'Example JSON object to use to generate the schema',
|
||||
};
|
||||
});
|
||||
|
||||
export const inputSchemaField: INodeProperties = {
|
||||
export const jsonSchemaExampleField = buildJsonSchemaExampleField();
|
||||
|
||||
export const buildInputSchemaField = (props?: {
|
||||
showExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;
|
||||
}): INodeProperties => ({
|
||||
displayName: 'Input Schema',
|
||||
name: 'inputSchema',
|
||||
type: 'json',
|
||||
@@ -59,11 +66,14 @@ export const inputSchemaField: INodeProperties = {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
...props?.showExtraProps,
|
||||
schemaType: ['manual'],
|
||||
},
|
||||
},
|
||||
description: 'Schema to use for the function',
|
||||
};
|
||||
});
|
||||
|
||||
export const inputSchemaField = buildInputSchemaField();
|
||||
|
||||
export const promptTypeOptions: INodeProperties = {
|
||||
displayName: 'Source for Prompt (User Message)',
|
||||
|
||||
Reference in New Issue
Block a user