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';
|
} from 'n8n-workflow';
|
||||||
import { jsonParse, NodeConnectionType, NodeOperationError } 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 { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';
|
||||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||||
|
|
||||||
@@ -168,8 +172,8 @@ export class ToolCode implements INodeType {
|
|||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{ ...schemaTypeField, displayOptions: { show: { specifyInputSchema: [true] } } },
|
{ ...schemaTypeField, displayOptions: { show: { specifyInputSchema: [true] } } },
|
||||||
jsonSchemaExampleField,
|
buildJsonSchemaExampleField({ showExtraProps: { specifyInputSchema: [true] } }),
|
||||||
inputSchemaField,
|
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 = {
|
export const schemaTypeField: INodeProperties = {
|
||||||
displayName: 'Schema Type',
|
displayName: 'Schema Type',
|
||||||
@@ -21,7 +21,9 @@ export const schemaTypeField: INodeProperties = {
|
|||||||
description: 'How to specify the schema for the function',
|
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',
|
displayName: 'JSON Example',
|
||||||
name: 'jsonSchemaExample',
|
name: 'jsonSchemaExample',
|
||||||
type: 'json',
|
type: 'json',
|
||||||
@@ -34,13 +36,18 @@ export const jsonSchemaExampleField: INodeProperties = {
|
|||||||
},
|
},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
...props?.showExtraProps,
|
||||||
schemaType: ['fromJson'],
|
schemaType: ['fromJson'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'Example JSON object to use to generate the schema',
|
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',
|
displayName: 'Input Schema',
|
||||||
name: 'inputSchema',
|
name: 'inputSchema',
|
||||||
type: 'json',
|
type: 'json',
|
||||||
@@ -59,11 +66,14 @@ export const inputSchemaField: INodeProperties = {
|
|||||||
},
|
},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
...props?.showExtraProps,
|
||||||
schemaType: ['manual'],
|
schemaType: ['manual'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'Schema to use for the function',
|
description: 'Schema to use for the function',
|
||||||
};
|
});
|
||||||
|
|
||||||
|
export const inputSchemaField = buildInputSchemaField();
|
||||||
|
|
||||||
export const promptTypeOptions: INodeProperties = {
|
export const promptTypeOptions: INodeProperties = {
|
||||||
displayName: 'Source for Prompt (User Message)',
|
displayName: 'Source for Prompt (User Message)',
|
||||||
|
|||||||
Reference in New Issue
Block a user