From bae0116d78784dabd9c4c3143c15b241c03b1944 Mon Sep 17 00:00:00 2001 From: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com> Date: Wed, 14 Aug 2024 12:01:14 +0100 Subject: [PATCH] fix: Remove node AI Transform node (no-changelog) (#10400) --- .../ManualChatTrigger.node.ts | 4 +- .../dynamicNodeParameters.controller.ts | 26 +- packages/cli/src/requests.ts | 6 - .../services/dynamicNodeParameters.service.ts | 27 +- packages/editor-ui/src/Interface.ts | 5 - packages/editor-ui/src/api/nodeTypes.ts | 13 - .../ButtonParameter/ButtonParameter.vue | 281 ------------------ .../src/components/ButtonParameter/utils.ts | 46 --- .../CodeNodeEditor/CodeNodeEditor.vue | 12 +- .../src/components/JsEditor/JsEditor.vue | 32 +- .../src/components/Node/NodeCreator/utils.ts | 8 - .../components/Node/NodeCreator/viewsData.ts | 11 +- .../src/components/ParameterInput.vue | 9 +- .../src/components/ParameterInputList.vue | 26 +- .../__tests__/ButtonParameter.test.ts | 136 --------- packages/editor-ui/src/constants.ts | 7 +- .../editor-ui/src/stores/nodeTypes.store.ts | 7 - .../editor-ui/src/stores/posthog.store.ts | 15 +- .../nodes/AiTransform/AiTransform.node.json | 18 -- .../nodes/AiTransform/AiTransform.node.ts | 148 --------- .../nodes/AiTransform/aitransform.svg | 10 - packages/nodes-base/package.json | 1 - packages/workflow/src/Interfaces.ts | 21 +- 23 files changed, 38 insertions(+), 831 deletions(-) delete mode 100644 packages/editor-ui/src/components/ButtonParameter/ButtonParameter.vue delete mode 100644 packages/editor-ui/src/components/ButtonParameter/utils.ts delete mode 100644 packages/editor-ui/src/components/__tests__/ButtonParameter.test.ts delete mode 100644 packages/nodes-base/nodes/AiTransform/AiTransform.node.json delete mode 100644 packages/nodes-base/nodes/AiTransform/AiTransform.node.ts delete mode 100644 packages/nodes-base/nodes/AiTransform/aitransform.svg diff --git a/packages/@n8n/nodes-langchain/nodes/trigger/ManualChatTrigger/ManualChatTrigger.node.ts b/packages/@n8n/nodes-langchain/nodes/trigger/ManualChatTrigger/ManualChatTrigger.node.ts index 816b56b59a..272213d539 100644 --- a/packages/@n8n/nodes-langchain/nodes/trigger/ManualChatTrigger/ManualChatTrigger.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/trigger/ManualChatTrigger/ManualChatTrigger.node.ts @@ -50,9 +50,7 @@ export class ManualChatTrigger implements INodeType { name: 'openChat', type: 'button', typeOptions: { - buttonConfig: { - action: 'openChat', - }, + action: 'openChat', }, default: '', }, diff --git a/packages/cli/src/controllers/dynamicNodeParameters.controller.ts b/packages/cli/src/controllers/dynamicNodeParameters.controller.ts index bfd1cf651b..c6a46aa3d4 100644 --- a/packages/cli/src/controllers/dynamicNodeParameters.controller.ts +++ b/packages/cli/src/controllers/dynamicNodeParameters.controller.ts @@ -1,4 +1,4 @@ -import type { INodePropertyOptions, NodeParameterValueType } from 'n8n-workflow'; +import type { INodePropertyOptions } from 'n8n-workflow'; import { Post, RestController } from '@/decorators'; import { getBase } from '@/WorkflowExecuteAdditionalData'; @@ -92,28 +92,4 @@ export class DynamicNodeParametersController { credentials, ); } - - @Post('/action-result') - async getActionResult( - req: DynamicNodeParametersRequest.ActionResult, - ): Promise { - const { currentNodeParameters, nodeTypeAndVersion, path, credentials, handler, payload } = - req.body; - - const additionalData = await getBase(req.user.id, currentNodeParameters); - - if (handler) { - return await this.service.getActionResult( - handler, - path, - additionalData, - nodeTypeAndVersion, - currentNodeParameters, - payload, - credentials, - ); - } - - return; - } } diff --git a/packages/cli/src/requests.ts b/packages/cli/src/requests.ts index 565020447c..45ee15b763 100644 --- a/packages/cli/src/requests.ts +++ b/packages/cli/src/requests.ts @@ -419,12 +419,6 @@ export declare namespace DynamicNodeParametersRequest { type ResourceMapperFields = BaseRequest<{ methodName: string; }>; - - /** POST /dynamic-node-parameters/action-result */ - type ActionResult = BaseRequest<{ - handler: string; - payload: IDataObject | string | undefined; - }>; } // ---------------------------------- diff --git a/packages/cli/src/services/dynamicNodeParameters.service.ts b/packages/cli/src/services/dynamicNodeParameters.service.ts index f3b0f7e192..1788bac6e1 100644 --- a/packages/cli/src/services/dynamicNodeParameters.service.ts +++ b/packages/cli/src/services/dynamicNodeParameters.service.ts @@ -15,8 +15,6 @@ import type { INodeCredentials, INodeParameters, INodeTypeNameVersion, - NodeParameterValueType, - IDataObject, } from 'n8n-workflow'; import { Workflow, RoutingNode, ApplicationError } from 'n8n-workflow'; import { NodeExecuteFunctions } from 'n8n-core'; @@ -158,24 +156,6 @@ export class DynamicNodeParametersService { return method.call(thisArgs); } - /** Returns the result of the action handler */ - async getActionResult( - handler: string, - path: string, - additionalData: IWorkflowExecuteAdditionalData, - nodeTypeAndVersion: INodeTypeNameVersion, - currentNodeParameters: INodeParameters, - payload: IDataObject | string | undefined, - credentials?: INodeCredentials, - ): Promise { - const nodeType = this.getNodeType(nodeTypeAndVersion); - const method = this.getMethod('actionHandler', handler, nodeType); - const workflow = this.getWorkflow(nodeTypeAndVersion, currentNodeParameters, credentials); - const thisArgs = this.getThisArg(path, additionalData, workflow); - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return method.call(thisArgs, payload); - } - private getMethod( type: 'resourceMapping', methodName: string, @@ -195,14 +175,9 @@ export class DynamicNodeParametersService { methodName: string, nodeType: INodeType, ): (this: ILoadOptionsFunctions) => Promise; - private getMethod( - type: 'actionHandler', - methodName: string, - nodeType: INodeType, - ): (this: ILoadOptionsFunctions, payload?: string) => Promise; private getMethod( - type: 'resourceMapping' | 'listSearch' | 'loadOptions' | 'actionHandler', + type: 'resourceMapping' | 'listSearch' | 'loadOptions', methodName: string, nodeType: INodeType, ) { diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 05c40402f1..04365662b2 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -1553,11 +1553,6 @@ export declare namespace DynamicNodeParameters { interface ResourceMapperFieldsRequest extends BaseRequest { methodName: string; } - - interface ActionResultRequest extends BaseRequest { - handler: string; - payload: IDataObject | string | undefined; - } } export interface EnvironmentVariable { diff --git a/packages/editor-ui/src/api/nodeTypes.ts b/packages/editor-ui/src/api/nodeTypes.ts index f4d516aaef..300b25390d 100644 --- a/packages/editor-ui/src/api/nodeTypes.ts +++ b/packages/editor-ui/src/api/nodeTypes.ts @@ -5,7 +5,6 @@ import type { INodePropertyOptions, INodeTypeDescription, INodeTypeNameVersion, - NodeParameterValueType, ResourceMapperFields, } from 'n8n-workflow'; import axios from 'axios'; @@ -58,15 +57,3 @@ export async function getResourceMapperFields( sendData, ); } - -export async function getNodeParameterActionResult( - context: IRestApiContext, - sendData: DynamicNodeParameters.ActionResultRequest, -): Promise { - return await makeRestApiRequest( - context, - 'POST', - '/dynamic-node-parameters/action-result', - sendData, - ); -} diff --git a/packages/editor-ui/src/components/ButtonParameter/ButtonParameter.vue b/packages/editor-ui/src/components/ButtonParameter/ButtonParameter.vue deleted file mode 100644 index d7e05b0f5b..0000000000 --- a/packages/editor-ui/src/components/ButtonParameter/ButtonParameter.vue +++ /dev/null @@ -1,281 +0,0 @@ - - - - - diff --git a/packages/editor-ui/src/components/ButtonParameter/utils.ts b/packages/editor-ui/src/components/ButtonParameter/utils.ts deleted file mode 100644 index 14d3ca4d78..0000000000 --- a/packages/editor-ui/src/components/ButtonParameter/utils.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { Schema } from '@/Interface'; -import type { INodeExecutionData } from 'n8n-workflow'; -import { useWorkflowsStore } from '@/stores/workflows.store'; -import { useNDVStore } from '@/stores/ndv.store'; -import { useDataSchema } from '@/composables/useDataSchema'; -import { executionDataToJson } from '@/utils/nodeTypesUtils'; - -export function getParentNodes() { - const activeNode = useNDVStore().activeNode; - const { getCurrentWorkflow, getNodeByName } = useWorkflowsStore(); - const workflow = getCurrentWorkflow(); - - if (!activeNode || !workflow) return []; - - return workflow - .getParentNodesByDepth(activeNode?.name) - .filter(({ name }, i, nodes) => { - return name !== activeNode.name && nodes.findIndex((node) => node.name === name) === i; - }) - .map((n) => getNodeByName(n.name)) - .filter((n) => n !== null); -} - -export function getSchemas() { - const parentNodes = getParentNodes(); - const parentNodesNames = parentNodes.map((node) => node?.name); - const { getSchemaForExecutionData, getInputDataWithPinned } = useDataSchema(); - const parentNodesSchemas: Array<{ nodeName: string; schema: Schema }> = parentNodes - .map((node) => { - const inputData: INodeExecutionData[] = getInputDataWithPinned(node); - - return { - nodeName: node?.name || '', - schema: getSchemaForExecutionData(executionDataToJson(inputData), true), - }; - }) - .filter((node) => node.schema?.value.length > 0); - - const inputSchema = parentNodesSchemas.shift(); - - return { - parentNodesNames, - inputSchema, - parentNodesSchemas, - }; -} diff --git a/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue b/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue index f4ba1febf2..d59a13e98e 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue +++ b/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue @@ -60,12 +60,13 @@ import jsParser from 'prettier/plugins/babel'; import * as estree from 'prettier/plugins/estree'; import { type Ref, computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'; -import { CODE_NODE_TYPE } from '@/constants'; +import { ASK_AI_EXPERIMENT, CODE_NODE_TYPE } from '@/constants'; import { codeNodeEditorEventBus } from '@/event-bus'; import { useRootStore } from '@/stores/root.store'; import { usePostHog } from '@/stores/posthog.store'; import { useMessage } from '@/composables/useMessage'; +import { useSettingsStore } from '@/stores/settings.store'; import AskAI from './AskAI/AskAI.vue'; import { readOnlyEditorExtensions, writableEditorExtensions } from './baseExtensions'; import { useCompleter } from './completer'; @@ -113,6 +114,7 @@ const { autocompletionExtension } = useCompleter(() => props.mode, editor); const { createLinter } = useLinter(() => props.mode, editor); const rootStore = useRootStore(); +const settingsStore = useSettingsStore(); const posthog = usePostHog(); const i18n = useI18n(); const telemetry = useTelemetry(); @@ -189,7 +191,13 @@ onBeforeUnmount(() => { }); const aiEnabled = computed(() => { - return posthog.isAiEnabled() && props.language === 'javaScript'; + const isAiExperimentEnabled = [ASK_AI_EXPERIMENT.gpt3, ASK_AI_EXPERIMENT.gpt4].includes( + (posthog.getVariant(ASK_AI_EXPERIMENT.name) ?? '') as string, + ); + + return ( + isAiExperimentEnabled && settingsStore.settings.ai.enabled && props.language === 'javaScript' + ); }); const placeholder = computed(() => { diff --git a/packages/editor-ui/src/components/JsEditor/JsEditor.vue b/packages/editor-ui/src/components/JsEditor/JsEditor.vue index 5a5f2cb411..40692ab323 100644 --- a/packages/editor-ui/src/components/JsEditor/JsEditor.vue +++ b/packages/editor-ui/src/components/JsEditor/JsEditor.vue @@ -1,5 +1,5 @@