mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(AI Transform Node): New node (#9990)
Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
This commit is contained in:
46
packages/editor-ui/src/components/ButtonParameter/utils.ts
Normal file
46
packages/editor-ui/src/components/ButtonParameter/utils.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user