Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AI Transform Node): New node #9990

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c58986f
setup
michael-radency Jul 9, 2024
2112b53
button action setup
michael-radency Jul 9, 2024
bf312c8
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 9, 2024
9180f33
action-result endpoint setup
michael-radency Jul 10, 2024
5f4df58
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 10, 2024
ce80f40
cleanup
michael-radency Jul 10, 2024
621b72f
renamed actionHandlers
michael-radency Jul 10, 2024
71c97e5
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 10, 2024
2888fe3
ButtonParameter, wip
michael-radency Jul 11, 2024
161a66c
replaced n8n button with ButtonParameter
michael-radency Jul 11, 2024
43faff2
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 11, 2024
964f300
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 16, 2024
8455e28
input data for action handler method
michael-radency Jul 16, 2024
6b017b4
min length fix, cleanup
michael-radency Jul 17, 2024
f2e44c3
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 17, 2024
6b08f31
remove dependancy on session storage, extracted utils for geting schema
michael-radency Jul 17, 2024
8a924eb
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 17, 2024
1180ea8
update editor on value change
michael-radency Jul 17, 2024
018ad29
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 18, 2024
c20d041
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Jul 23, 2024
70bf0c9
use AskAi service on cloud, icon update
michael-radency Jul 23, 2024
501702b
Copy tweaks and new icon.
gandreini Jul 31, 2024
0a53844
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 1, 2024
91bd962
review update
michael-radency Aug 1, 2024
38f891f
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 1, 2024
ffd7286
review update
michael-radency Aug 2, 2024
0e54e16
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 2, 2024
173d0d7
remove default from test url
michael-radency Aug 2, 2024
f99f1c7
removed prompt wrapper
michael-radency Aug 2, 2024
bafac61
updated prompt wrapper
michael-radency Aug 2, 2024
6f4d739
Minor copy tweak.
gandreini Aug 2, 2024
1e2a1d3
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 5, 2024
479a68c
errors update in case code or instructions missing
michael-radency Aug 5, 2024
5f02d37
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 5, 2024
3cf8fd6
Update packages/editor-ui/src/components/ButtonParameter.vue
michael-radency Aug 6, 2024
963f3fd
Update packages/editor-ui/src/components/ButtonParameter.vue
michael-radency Aug 6, 2024
d089a47
Update packages/editor-ui/src/components/ButtonParameter.vue
michael-radency Aug 6, 2024
894c966
Update packages/editor-ui/src/components/CodeNodeEditor/utils.ts
michael-radency Aug 6, 2024
f2c717d
Update packages/nodes-base/nodes/AiTransform/AiTransform.node.json
michael-radency Aug 6, 2024
42f1aa8
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 6, 2024
39314b6
Merge branch 'node-1461-transform-ai-node-click-handler-component' of…
michael-radency Aug 6, 2024
b0ea3e2
utils cleanup, filter to show aitransform only on cloud
michael-radency Aug 6, 2024
abb8a6d
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 6, 2024
02ee271
action handler interface update
michael-radency Aug 6, 2024
2251ee9
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 6, 2024
3089202
manual chat trigger update
michael-radency Aug 6, 2024
ebb77de
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 7, 2024
f3f4c9c
removed code used for local testing
michael-radency Aug 7, 2024
2508c35
tests
michael-radency Aug 7, 2024
867eaa6
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1461…
michael-radency Aug 7, 2024
66baa77
removed duplicated code
michael-radency Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export class ManualChatTrigger implements INodeType {
name: 'openChat',
type: 'button',
typeOptions: {
action: 'openChat',
buttonConfig: {
action: 'openChat',
},
},
default: '',
},
Expand Down
26 changes: 25 additions & 1 deletion packages/cli/src/controllers/dynamicNodeParameters.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { INodePropertyOptions } from 'n8n-workflow';
import type { INodePropertyOptions, NodeParameterValueType } from 'n8n-workflow';

import { Post, RestController } from '@/decorators';
import { getBase } from '@/WorkflowExecuteAdditionalData';
Expand Down Expand Up @@ -92,4 +92,28 @@ export class DynamicNodeParametersController {
credentials,
);
}

@Post('/action-result')
async getActionResult(
req: DynamicNodeParametersRequest.ActionResult,
): Promise<NodeParameterValueType> {
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;
}
}
6 changes: 6 additions & 0 deletions packages/cli/src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ export declare namespace DynamicNodeParametersRequest {
type ResourceMapperFields = BaseRequest<{
methodName: string;
}>;

/** POST /dynamic-node-parameters/action-result */
type ActionResult = BaseRequest<{
handler: string;
payload: IDataObject | string | undefined;
}>;
}

// ----------------------------------
Expand Down
27 changes: 26 additions & 1 deletion packages/cli/src/services/dynamicNodeParameters.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import type {
INodeCredentials,
INodeParameters,
INodeTypeNameVersion,
NodeParameterValueType,
IDataObject,
} from 'n8n-workflow';
import { Workflow, RoutingNode, ApplicationError } from 'n8n-workflow';
import { NodeExecuteFunctions } from 'n8n-core';
Expand Down Expand Up @@ -156,6 +158,24 @@ 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<NodeParameterValueType> {
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,
Expand All @@ -175,9 +195,14 @@ export class DynamicNodeParametersService {
methodName: string,
nodeType: INodeType,
): (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
private getMethod(
type: 'actionHandler',
methodName: string,
nodeType: INodeType,
): (this: ILoadOptionsFunctions, payload?: string) => Promise<NodeParameterValueType>;

private getMethod(
type: 'resourceMapping' | 'listSearch' | 'loadOptions',
type: 'resourceMapping' | 'listSearch' | 'loadOptions' | 'actionHandler',
methodName: string,
nodeType: INodeType,
) {
Expand Down
5 changes: 5 additions & 0 deletions packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,11 @@ export declare namespace DynamicNodeParameters {
interface ResourceMapperFieldsRequest extends BaseRequest {
methodName: string;
}

interface ActionResultRequest extends BaseRequest {
handler: string;
payload: IDataObject | string | undefined;
}
}

export interface EnvironmentVariable {
Expand Down
13 changes: 13 additions & 0 deletions packages/editor-ui/src/api/nodeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
INodePropertyOptions,
INodeTypeDescription,
INodeTypeNameVersion,
NodeParameterValueType,
ResourceMapperFields,
} from 'n8n-workflow';
import axios from 'axios';
Expand Down Expand Up @@ -57,3 +58,15 @@ export async function getResourceMapperFields(
sendData,
);
}

export async function getNodeParameterActionResult(
context: IRestApiContext,
sendData: DynamicNodeParameters.ActionResultRequest,
): Promise<NodeParameterValueType> {
return await makeRestApiRequest(
context,
'POST',
'/dynamic-node-parameters/action-result',
sendData,
);
}
Loading
Loading