@n8n/stores 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/useAgentRequestStore.cjs +21 -116
- package/dist/useAgentRequestStore.cjs.map +1 -1
- package/dist/useAgentRequestStore.d.cts +23 -22
- package/dist/useAgentRequestStore.d.ts +23 -22
- package/dist/useAgentRequestStore.js +21 -116
- package/dist/useAgentRequestStore.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,60 +1,37 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/useAgentRequestStore.ts
|
|
2
|
+
var _core = require('@vueuse/core');
|
|
2
3
|
var _pinia = require('pinia');
|
|
3
|
-
var
|
|
4
|
-
var STORAGE_KEY = "n8n-agent-requests";
|
|
4
|
+
var LOCAL_STORAGE_AGENT_REQUESTS = "N8N_AGENT_REQUESTS";
|
|
5
5
|
var useAgentRequestStore = _pinia.defineStore.call(void 0, "agentRequest", () => {
|
|
6
|
-
const agentRequests =
|
|
7
|
-
function loadFromLocalStorage() {
|
|
8
|
-
try {
|
|
9
|
-
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
10
|
-
return storedData ? JSON.parse(storedData) : {};
|
|
11
|
-
} catch (error) {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
_vue.watch.call(void 0,
|
|
16
|
-
agentRequests,
|
|
17
|
-
(newValue) => {
|
|
18
|
-
try {
|
|
19
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(newValue));
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error("Failed to save agent requests to localStorage:", error);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
{ deep: true }
|
|
25
|
-
);
|
|
6
|
+
const agentRequests = _core.useLocalStorage.call(void 0, LOCAL_STORAGE_AGENT_REQUESTS, {});
|
|
26
7
|
const ensureWorkflowAndNodeExist = (workflowId, nodeId) => {
|
|
27
8
|
if (!agentRequests.value[workflowId]) {
|
|
28
9
|
agentRequests.value[workflowId] = {};
|
|
29
10
|
}
|
|
30
11
|
if (!agentRequests.value[workflowId][nodeId]) {
|
|
31
|
-
agentRequests.value[workflowId][nodeId] = {};
|
|
12
|
+
agentRequests.value[workflowId][nodeId] = { query: {} };
|
|
32
13
|
}
|
|
33
14
|
};
|
|
34
15
|
const getAgentRequests = (workflowId, nodeId) => {
|
|
35
|
-
return _optionalChain([agentRequests, 'access', _ => _.value, 'access', _2 => _2[workflowId], 'optionalAccess', _3 => _3[nodeId]]) || {};
|
|
36
|
-
};
|
|
37
|
-
const getAgentRequest = (workflowId, nodeId, paramName) => {
|
|
38
|
-
return _optionalChain([agentRequests, 'access', _4 => _4.value, 'access', _5 => _5[workflowId], 'optionalAccess', _6 => _6[nodeId], 'optionalAccess', _7 => _7[paramName]]);
|
|
16
|
+
return _optionalChain([agentRequests, 'access', _ => _.value, 'access', _2 => _2[workflowId], 'optionalAccess', _3 => _3[nodeId], 'optionalAccess', _4 => _4.query]) || {};
|
|
39
17
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return agentRequests.value[workflowId][nodeId];
|
|
18
|
+
const getQueryValue = (workflowId, nodeId, paramName) => {
|
|
19
|
+
const query = _optionalChain([agentRequests, 'access', _5 => _5.value, 'access', _6 => _6[workflowId], 'optionalAccess', _7 => _7[nodeId], 'optionalAccess', _8 => _8.query]);
|
|
20
|
+
if (typeof query === "string") {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
return _optionalChain([query, 'optionalAccess', _9 => _9[paramName]]);
|
|
47
24
|
};
|
|
48
|
-
const
|
|
25
|
+
const setAgentRequestForNode = (workflowId, nodeId, request) => {
|
|
49
26
|
ensureWorkflowAndNodeExist(workflowId, nodeId);
|
|
50
27
|
agentRequests.value[workflowId][nodeId] = {
|
|
51
|
-
...
|
|
52
|
-
...
|
|
28
|
+
...request,
|
|
29
|
+
query: typeof request.query === "string" ? request.query : { ...request.query }
|
|
53
30
|
};
|
|
54
31
|
};
|
|
55
32
|
const clearAgentRequests = (workflowId, nodeId) => {
|
|
56
33
|
if (agentRequests.value[workflowId]) {
|
|
57
|
-
agentRequests.value[workflowId][nodeId] = {};
|
|
34
|
+
agentRequests.value[workflowId][nodeId] = { query: {} };
|
|
58
35
|
}
|
|
59
36
|
};
|
|
60
37
|
const clearAllAgentRequests = (workflowId) => {
|
|
@@ -64,90 +41,18 @@ var useAgentRequestStore = _pinia.defineStore.call(void 0, "agentRequest", () =>
|
|
|
64
41
|
agentRequests.value = {};
|
|
65
42
|
}
|
|
66
43
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const [arrayName, index] = part.split("[");
|
|
71
|
-
if (arrayName) acc.push(arrayName);
|
|
72
|
-
if (index) acc.push(index.replace("]", ""));
|
|
73
|
-
} else {
|
|
74
|
-
acc.push(part);
|
|
75
|
-
}
|
|
76
|
-
return acc;
|
|
77
|
-
}, []);
|
|
78
|
-
}
|
|
79
|
-
function buildRequestObject(path, value) {
|
|
80
|
-
const result = {};
|
|
81
|
-
let current = result;
|
|
82
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
83
|
-
const part = path[i];
|
|
84
|
-
const nextPart = path[i + 1];
|
|
85
|
-
const isArrayIndex = nextPart && !isNaN(Number(nextPart));
|
|
86
|
-
if (isArrayIndex) {
|
|
87
|
-
if (!current[part]) {
|
|
88
|
-
current[part] = [];
|
|
89
|
-
}
|
|
90
|
-
while (current[part].length <= Number(nextPart)) {
|
|
91
|
-
current[part].push({});
|
|
92
|
-
}
|
|
93
|
-
} else if (!current[part]) {
|
|
94
|
-
current[part] = {};
|
|
95
|
-
}
|
|
96
|
-
current = current[part];
|
|
97
|
-
}
|
|
98
|
-
current[path[path.length - 1]] = value;
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
function deepMerge(target, source) {
|
|
102
|
-
const result = { ...target };
|
|
103
|
-
for (const key in source) {
|
|
104
|
-
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
105
|
-
result[key] = deepMerge(
|
|
106
|
-
result[key] || {},
|
|
107
|
-
source[key]
|
|
108
|
-
);
|
|
109
|
-
} else if (Array.isArray(source[key])) {
|
|
110
|
-
if (Array.isArray(result[key])) {
|
|
111
|
-
const targetArray = result[key];
|
|
112
|
-
const sourceArray = source[key];
|
|
113
|
-
while (targetArray.length < sourceArray.length) {
|
|
114
|
-
targetArray.push({});
|
|
115
|
-
}
|
|
116
|
-
sourceArray.forEach((item, index) => {
|
|
117
|
-
if (item && typeof item === "object") {
|
|
118
|
-
targetArray[index] = deepMerge(
|
|
119
|
-
targetArray[index] || {},
|
|
120
|
-
item
|
|
121
|
-
);
|
|
122
|
-
} else {
|
|
123
|
-
targetArray[index] = item;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
result[key] = source[key];
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
result[key] = source[key];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
const generateAgentRequest = (workflowId, nodeId) => {
|
|
136
|
-
const nodeRequests = _optionalChain([agentRequests, 'access', _8 => _8.value, 'access', _9 => _9[workflowId], 'optionalAccess', _10 => _10[nodeId]]) || {};
|
|
137
|
-
return Object.entries(nodeRequests).reduce(
|
|
138
|
-
(acc, [path, value]) => deepMerge(acc, buildRequestObject(parsePath(path), value)),
|
|
139
|
-
{}
|
|
140
|
-
);
|
|
44
|
+
const getAgentRequest = (workflowId, nodeId) => {
|
|
45
|
+
if (agentRequests.value[workflowId]) return _optionalChain([agentRequests, 'access', _10 => _10.value, 'access', _11 => _11[workflowId], 'optionalAccess', _12 => _12[nodeId]]);
|
|
46
|
+
return void 0;
|
|
141
47
|
};
|
|
142
48
|
return {
|
|
143
49
|
agentRequests,
|
|
144
50
|
getAgentRequests,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
addAgentRequests,
|
|
51
|
+
getQueryValue,
|
|
52
|
+
setAgentRequestForNode,
|
|
148
53
|
clearAgentRequests,
|
|
149
54
|
clearAllAgentRequests,
|
|
150
|
-
|
|
55
|
+
getAgentRequest
|
|
151
56
|
};
|
|
152
57
|
});
|
|
153
58
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/n8n/n8n/packages/frontend/@n8n/stores/dist/useAgentRequestStore.cjs","../src/useAgentRequestStore.ts"],"names":[],"mappings":"AAAA;ACCA,8BAA4B;AAC5B,0BAA2B;AAQ3B,IAAM,YAAA,EAAc,oBAAA;AAEb,IAAM,qBAAA,EAAuB,gCAAA,cAAY,EAAgB,CAAA,EAAA,GAAM;AAErE,EAAA,MAAM,cAAA,EAAgB,sBAAA,oBAA6B,CAAqB,CAAC,CAAA;AAGzE,EAAA,SAAS,oBAAA,CAAA,EAAgD;AACxD,IAAA,IAAI;AACH,MAAA,MAAM,WAAA,EAAa,YAAA,CAAa,OAAA,CAAQ,WAAW,CAAA;AACnD,MAAA,OAAO,WAAA,EAAa,IAAA,CAAK,KAAA,CAAM,UAAU,EAAA,EAAI,CAAC,CAAA;AAAA,IAC/C,EAAA,MAAA,CAAS,KAAA,EAAO;AACf,MAAA,OAAO,CAAC,CAAA;AAAA,IACT;AAAA,EACD;AAGA,EAAA,wBAAA;AAAA,IACC,aAAA;AAAA,IACA,CAAC,QAAA,EAAA,GAAa;AACb,MA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AAAA,MACjF,CAAC;AAAA,IACF,CAAA;AAAA,EACD,CAAA;AAEA,EAAA,OAAO;AAAA,IACN,aAAA;AAAA,IACA,gBAAA;AAAA,IACA,eAAA;AAAA,IACA,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,kBAAA;AAAA,IACA,qBAAA;AAAA,IACA;AAAA,EACD,CAAA;AACD,CAAC,CAAA;ADzDD;AACE;AACF,oDAAC","file":"/home/runner/work/n8n/n8n/packages/frontend/@n8n/stores/dist/useAgentRequestStore.cjs","sourcesContent":[null,"import type { INodeParameters, NodeParameterValueType } from 'n8n-workflow';\nimport { defineStore } from 'pinia';\nimport { ref, watch } from 'vue';\n\ninterface IAgentRequestStoreState {\n\t[workflowId: string]: {\n\t\t[nodeName: string]: INodeParameters;\n\t};\n}\n\nconst STORAGE_KEY = 'n8n-agent-requests';\n\nexport const useAgentRequestStore = defineStore('agentRequest', () => {\n\t// State\n\tconst agentRequests = ref<IAgentRequestStoreState>(loadFromLocalStorage());\n\n\t// Load initial state from localStorage\n\tfunction loadFromLocalStorage(): IAgentRequestStoreState {\n\t\ttry {\n\t\t\tconst storedData = localStorage.getItem(STORAGE_KEY);\n\t\t\treturn storedData ? JSON.parse(storedData) : {};\n\t\t} catch (error) {\n\t\t\treturn {};\n\t\t}\n\t}\n\n\t// Save state to localStorage whenever it changes\n\twatch(\n\t\tagentRequests,\n\t\t(newValue) => {\n\t\t\ttry {\n\t\t\t\tlocalStorage.setItem(STORAGE_KEY, JSON.stringify(newValue));\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Failed to save agent requests to localStorage:', error);\n\t\t\t}\n\t\t},\n\t\t{ deep: true },\n\t);\n\n\t// Helper function to ensure workflow and node entries exist\n\tconst ensureWorkflowAndNodeExist = (workflowId: string, nodeId: string): void => {\n\t\tif (!agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t}\n\n\t\tif (!agentRequests.value[workflowId][nodeId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = {};\n\t\t}\n\t};\n\n\t// Getters\n\tconst getAgentRequests = (workflowId: string, nodeId: string): INodeParameters => {\n\t\treturn agentRequests.value[workflowId]?.[nodeId] || {};\n\t};\n\n\tconst getAgentRequest = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\tparamName: string,\n\t): NodeParameterValueType | undefined => {\n\t\treturn agentRequests.value[workflowId]?.[nodeId]?.[paramName];\n\t};\n\n\t// Actions\n\tconst addAgentRequest = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\tparamName: string,\n\t\tparamValues: NodeParameterValueType,\n\t): INodeParameters => {\n\t\tensureWorkflowAndNodeExist(workflowId, nodeId);\n\n\t\tagentRequests.value[workflowId][nodeId] = {\n\t\t\t...agentRequests.value[workflowId][nodeId],\n\t\t\t[paramName]: paramValues,\n\t\t};\n\n\t\treturn agentRequests.value[workflowId][nodeId];\n\t};\n\n\tconst addAgentRequests = (workflowId: string, nodeId: string, params: INodeParameters): void => {\n\t\tensureWorkflowAndNodeExist(workflowId, nodeId);\n\n\t\tagentRequests.value[workflowId][nodeId] = {\n\t\t\t...agentRequests.value[workflowId][nodeId],\n\t\t\t...params,\n\t\t};\n\t};\n\n\tconst clearAgentRequests = (workflowId: string, nodeId: string): void => {\n\t\tif (agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = {};\n\t\t}\n\t};\n\n\tconst clearAllAgentRequests = (workflowId?: string): void => {\n\t\tif (workflowId) {\n\t\t\t// Clear requests for a specific workflow\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t} else {\n\t\t\t// Clear all requests\n\t\t\tagentRequests.value = {};\n\t\t}\n\t};\n\n\tfunction parsePath(path: string): string[] {\n\t\treturn path.split('.').reduce((acc: string[], part) => {\n\t\t\tif (part.includes('[')) {\n\t\t\t\tconst [arrayName, index] = part.split('[');\n\t\t\t\tif (arrayName) acc.push(arrayName);\n\t\t\t\tif (index) acc.push(index.replace(']', ''));\n\t\t\t} else {\n\t\t\t\tacc.push(part);\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, []);\n\t}\n\n\tfunction buildRequestObject(path: string[], value: NodeParameterValueType): INodeParameters {\n\t\tconst result: INodeParameters = {};\n\t\tlet current = result;\n\n\t\tfor (let i = 0; i < path.length - 1; i++) {\n\t\t\tconst part = path[i];\n\t\t\tconst nextPart = path[i + 1];\n\t\t\tconst isArrayIndex = nextPart && !isNaN(Number(nextPart));\n\n\t\t\tif (isArrayIndex) {\n\t\t\t\tif (!current[part]) {\n\t\t\t\t\tcurrent[part] = [];\n\t\t\t\t}\n\t\t\t\twhile ((current[part] as NodeParameterValueType[]).length <= Number(nextPart)) {\n\t\t\t\t\t(current[part] as NodeParameterValueType[]).push({});\n\t\t\t\t}\n\t\t\t} else if (!current[part]) {\n\t\t\t\tcurrent[part] = {};\n\t\t\t}\n\n\t\t\tcurrent = current[part] as INodeParameters;\n\t\t}\n\n\t\tcurrent[path[path.length - 1]] = value;\n\t\treturn result;\n\t}\n\n\t// Helper function to deep merge objects\n\tfunction deepMerge(target: INodeParameters, source: INodeParameters): INodeParameters {\n\t\tconst result = { ...target };\n\n\t\tfor (const key in source) {\n\t\t\tif (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n\t\t\t\t// Recursively merge nested objects\n\t\t\t\tresult[key] = deepMerge(\n\t\t\t\t\t(result[key] as INodeParameters) || {},\n\t\t\t\t\tsource[key] as INodeParameters,\n\t\t\t\t);\n\t\t\t} else if (Array.isArray(source[key])) {\n\t\t\t\t// For arrays, merge by index\n\t\t\t\tif (Array.isArray(result[key])) {\n\t\t\t\t\tconst targetArray = result[key] as NodeParameterValueType[];\n\t\t\t\t\tconst sourceArray = source[key] as NodeParameterValueType[];\n\n\t\t\t\t\t// Ensure target array has enough elements\n\t\t\t\t\twhile (targetArray.length < sourceArray.length) {\n\t\t\t\t\t\ttargetArray.push({});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Merge each array item\n\t\t\t\t\tsourceArray.forEach((item, index) => {\n\t\t\t\t\t\tif (item && typeof item === 'object') {\n\t\t\t\t\t\t\ttargetArray[index] = deepMerge(\n\t\t\t\t\t\t\t\t(targetArray[index] as INodeParameters) || {},\n\t\t\t\t\t\t\t\titem as INodeParameters,\n\t\t\t\t\t\t\t) as NodeParameterValueType;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttargetArray[index] = item;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult[key] = source[key];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// For primitive values, use source value\n\t\t\t\tresult[key] = source[key];\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tconst generateAgentRequest = (workflowId: string, nodeId: string): INodeParameters => {\n\t\tconst nodeRequests = agentRequests.value[workflowId]?.[nodeId] || {};\n\n\t\treturn Object.entries(nodeRequests).reduce(\n\t\t\t(acc, [path, value]) => deepMerge(acc, buildRequestObject(parsePath(path), value)),\n\t\t\t{} as INodeParameters,\n\t\t);\n\t};\n\n\treturn {\n\t\tagentRequests,\n\t\tgetAgentRequests,\n\t\tgetAgentRequest,\n\t\taddAgentRequest,\n\t\taddAgentRequests,\n\t\tclearAgentRequests,\n\t\tclearAllAgentRequests,\n\t\tgenerateAgentRequest,\n\t};\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/n8n/n8n/packages/frontend/@n8n/stores/dist/useAgentRequestStore.cjs","../src/useAgentRequestStore.ts"],"names":[],"mappings":"AAAA;ACAA,oCAAgC;AAEhC,8BAA4B;AAE5B,IAAM,6BAAA,EAA+B,oBAAA;AAa9B,IAAM,qBAAA,EAAuB,gCAAA,cAAY,EAAgB,CAAA,EAAA,GAAM;AAErE,EAAA,MAAM,cAAA,EAAgB,mCAAA,4BAAyC,EAA8B,CAAC,CAAC,CAAA;AAG/F,EAAA,MAAM,2BAAA,EAA6B,CAAC,UAAA,EAAoB,MAAA,EAAA,GAAyB;AACh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AQ,MAAA,EAAQ,EAAE,GAAG,OAAA,CAAQ,MAAM;AAAA,IAC/E,CAAA;AAAA,EACD,CAAA;AAEA,EAAA,MAAM,mBAAA,EAAqB,CAAC,UAAA,EAAoB,MAAA,EAAA,GAAyB;AACxE,IAAA,GAAA,CAAI,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA,EAAG;AACpC,MAAA,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA,CAAE,MAAM,EAAA,EAAI,EAAE,KAAA,EAAO,CAAC,EAAE,CAAA;AAAA,IACvD;AAAA,EACD,CAAA;AAEA,EAAA,MAAM,sBAAA,EAAwB,CAAC,UAAA,EAAA,GAA8B;AAC5D,IAAA,GAAA,CAAI,UAAA,EAAY;AACf,MAAA,aAAA,CAAc,KAAA,CAAM,UAAU,EAAA,EAAI,CAAC,CAAA;AAAA,IACpC,EAAA,KAAO;AACN,MAAA,aAAA,CAAc,MAAA,EAAQ,CAAC,CAAA;AAAA,IACxB;AAAA,EACD,CAAA;AAEA,EAAA,MAAM,gBAAA,EAAkB,CAAC,UAAA,EAAoB,MAAA,EAAA,GAA8C;AAC1F,IAAA,GAAA,CAAI,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA,EAAG,uBAAO,aAAA,uBAAc,KAAA,uBAAM,UAAU,CAAA,8BAAA,CAAI,MAAM,GAAA;AACpF,IAAA,OAAO,KAAA,CAAA;AAAA,EACR,CAAA;AAEA,EAAA,OAAO;AAAA,IACN,aAAA;AAAA,IACA,gBAAA;AAAA,IACA,aAAA;AAAA,IACA,sBAAA;AAAA,IACA,kBAAA;AAAA,IACA,qBAAA;AAAA,IACA;AAAA,EACD,CAAA;AACD,CAAC,CAAA;ADjCD;AACE;AACF,oDAAC","file":"/home/runner/work/n8n/n8n/packages/frontend/@n8n/stores/dist/useAgentRequestStore.cjs","sourcesContent":[null,"import { useLocalStorage } from '@vueuse/core';\nimport type { INodeParameters, NodeParameterValueType } from 'n8n-workflow';\nimport { defineStore } from 'pinia';\n\nconst LOCAL_STORAGE_AGENT_REQUESTS = 'N8N_AGENT_REQUESTS';\n\nexport interface IAgentRequest {\n\tquery: INodeParameters | string;\n\ttoolName?: string;\n}\n\nexport interface IAgentRequestStoreState {\n\t[workflowId: string]: {\n\t\t[nodeName: string]: IAgentRequest;\n\t};\n}\n\nexport const useAgentRequestStore = defineStore('agentRequest', () => {\n\t// State\n\tconst agentRequests = useLocalStorage<IAgentRequestStoreState>(LOCAL_STORAGE_AGENT_REQUESTS, {});\n\n\t// Helper function to ensure workflow and node entries exist\n\tconst ensureWorkflowAndNodeExist = (workflowId: string, nodeId: string): void => {\n\t\tif (!agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t}\n\n\t\tif (!agentRequests.value[workflowId][nodeId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = { query: {} };\n\t\t}\n\t};\n\n\t// Getters\n\tconst getAgentRequests = (workflowId: string, nodeId: string): INodeParameters | string => {\n\t\treturn agentRequests.value[workflowId]?.[nodeId]?.query || {};\n\t};\n\n\tconst getQueryValue = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\tparamName: string,\n\t): NodeParameterValueType | undefined => {\n\t\tconst query = agentRequests.value[workflowId]?.[nodeId]?.query;\n\t\tif (typeof query === 'string') {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn query?.[paramName] as NodeParameterValueType;\n\t};\n\n\tconst setAgentRequestForNode = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\trequest: IAgentRequest,\n\t): void => {\n\t\tensureWorkflowAndNodeExist(workflowId, nodeId);\n\n\t\tagentRequests.value[workflowId][nodeId] = {\n\t\t\t...request,\n\t\t\tquery: typeof request.query === 'string' ? request.query : { ...request.query },\n\t\t};\n\t};\n\n\tconst clearAgentRequests = (workflowId: string, nodeId: string): void => {\n\t\tif (agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = { query: {} };\n\t\t}\n\t};\n\n\tconst clearAllAgentRequests = (workflowId?: string): void => {\n\t\tif (workflowId) {\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t} else {\n\t\t\tagentRequests.value = {};\n\t\t}\n\t};\n\n\tconst getAgentRequest = (workflowId: string, nodeId: string): IAgentRequest | undefined => {\n\t\tif (agentRequests.value[workflowId]) return agentRequests.value[workflowId]?.[nodeId];\n\t\treturn undefined;\n\t};\n\n\treturn {\n\t\tagentRequests,\n\t\tgetAgentRequests,\n\t\tgetQueryValue,\n\t\tsetAgentRequestForNode,\n\t\tclearAgentRequests,\n\t\tclearAllAgentRequests,\n\t\tgetAgentRequest,\n\t};\n});\n"]}
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import * as pinia from 'pinia';
|
|
2
|
-
import * as
|
|
2
|
+
import * as _vueuse_core from '@vueuse/core';
|
|
3
3
|
import { INodeParameters, NodeParameterValueType } from 'n8n-workflow';
|
|
4
4
|
|
|
5
|
+
interface IAgentRequest {
|
|
6
|
+
query: INodeParameters | string;
|
|
7
|
+
toolName?: string;
|
|
8
|
+
}
|
|
5
9
|
interface IAgentRequestStoreState {
|
|
6
10
|
[workflowId: string]: {
|
|
7
|
-
[nodeName: string]:
|
|
11
|
+
[nodeName: string]: IAgentRequest;
|
|
8
12
|
};
|
|
9
13
|
}
|
|
10
14
|
declare const useAgentRequestStore: pinia.StoreDefinition<"agentRequest", Pick<{
|
|
11
|
-
agentRequests:
|
|
12
|
-
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
addAgentRequests: (workflowId: string, nodeId: string, params: INodeParameters) => void;
|
|
15
|
+
agentRequests: _vueuse_core.RemovableRef<IAgentRequestStoreState>;
|
|
16
|
+
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters | string;
|
|
17
|
+
getQueryValue: (workflowId: string, nodeId: string, paramName: string) => NodeParameterValueType | undefined;
|
|
18
|
+
setAgentRequestForNode: (workflowId: string, nodeId: string, request: IAgentRequest) => void;
|
|
16
19
|
clearAgentRequests: (workflowId: string, nodeId: string) => void;
|
|
17
20
|
clearAllAgentRequests: (workflowId?: string) => void;
|
|
18
|
-
|
|
21
|
+
getAgentRequest: (workflowId: string, nodeId: string) => IAgentRequest | undefined;
|
|
19
22
|
}, "agentRequests">, Pick<{
|
|
20
|
-
agentRequests:
|
|
21
|
-
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
addAgentRequests: (workflowId: string, nodeId: string, params: INodeParameters) => void;
|
|
23
|
+
agentRequests: _vueuse_core.RemovableRef<IAgentRequestStoreState>;
|
|
24
|
+
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters | string;
|
|
25
|
+
getQueryValue: (workflowId: string, nodeId: string, paramName: string) => NodeParameterValueType | undefined;
|
|
26
|
+
setAgentRequestForNode: (workflowId: string, nodeId: string, request: IAgentRequest) => void;
|
|
25
27
|
clearAgentRequests: (workflowId: string, nodeId: string) => void;
|
|
26
28
|
clearAllAgentRequests: (workflowId?: string) => void;
|
|
27
|
-
|
|
29
|
+
getAgentRequest: (workflowId: string, nodeId: string) => IAgentRequest | undefined;
|
|
28
30
|
}, never>, Pick<{
|
|
29
|
-
agentRequests:
|
|
30
|
-
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
addAgentRequests: (workflowId: string, nodeId: string, params: INodeParameters) => void;
|
|
31
|
+
agentRequests: _vueuse_core.RemovableRef<IAgentRequestStoreState>;
|
|
32
|
+
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters | string;
|
|
33
|
+
getQueryValue: (workflowId: string, nodeId: string, paramName: string) => NodeParameterValueType | undefined;
|
|
34
|
+
setAgentRequestForNode: (workflowId: string, nodeId: string, request: IAgentRequest) => void;
|
|
34
35
|
clearAgentRequests: (workflowId: string, nodeId: string) => void;
|
|
35
36
|
clearAllAgentRequests: (workflowId?: string) => void;
|
|
36
|
-
|
|
37
|
-
}, "getAgentRequests" | "
|
|
37
|
+
getAgentRequest: (workflowId: string, nodeId: string) => IAgentRequest | undefined;
|
|
38
|
+
}, "getAgentRequests" | "getQueryValue" | "setAgentRequestForNode" | "clearAgentRequests" | "clearAllAgentRequests" | "getAgentRequest">>;
|
|
38
39
|
|
|
39
|
-
export { useAgentRequestStore };
|
|
40
|
+
export { type IAgentRequest, type IAgentRequestStoreState, useAgentRequestStore };
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import * as pinia from 'pinia';
|
|
2
|
-
import * as
|
|
2
|
+
import * as _vueuse_core from '@vueuse/core';
|
|
3
3
|
import { INodeParameters, NodeParameterValueType } from 'n8n-workflow';
|
|
4
4
|
|
|
5
|
+
interface IAgentRequest {
|
|
6
|
+
query: INodeParameters | string;
|
|
7
|
+
toolName?: string;
|
|
8
|
+
}
|
|
5
9
|
interface IAgentRequestStoreState {
|
|
6
10
|
[workflowId: string]: {
|
|
7
|
-
[nodeName: string]:
|
|
11
|
+
[nodeName: string]: IAgentRequest;
|
|
8
12
|
};
|
|
9
13
|
}
|
|
10
14
|
declare const useAgentRequestStore: pinia.StoreDefinition<"agentRequest", Pick<{
|
|
11
|
-
agentRequests:
|
|
12
|
-
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
addAgentRequests: (workflowId: string, nodeId: string, params: INodeParameters) => void;
|
|
15
|
+
agentRequests: _vueuse_core.RemovableRef<IAgentRequestStoreState>;
|
|
16
|
+
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters | string;
|
|
17
|
+
getQueryValue: (workflowId: string, nodeId: string, paramName: string) => NodeParameterValueType | undefined;
|
|
18
|
+
setAgentRequestForNode: (workflowId: string, nodeId: string, request: IAgentRequest) => void;
|
|
16
19
|
clearAgentRequests: (workflowId: string, nodeId: string) => void;
|
|
17
20
|
clearAllAgentRequests: (workflowId?: string) => void;
|
|
18
|
-
|
|
21
|
+
getAgentRequest: (workflowId: string, nodeId: string) => IAgentRequest | undefined;
|
|
19
22
|
}, "agentRequests">, Pick<{
|
|
20
|
-
agentRequests:
|
|
21
|
-
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
addAgentRequests: (workflowId: string, nodeId: string, params: INodeParameters) => void;
|
|
23
|
+
agentRequests: _vueuse_core.RemovableRef<IAgentRequestStoreState>;
|
|
24
|
+
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters | string;
|
|
25
|
+
getQueryValue: (workflowId: string, nodeId: string, paramName: string) => NodeParameterValueType | undefined;
|
|
26
|
+
setAgentRequestForNode: (workflowId: string, nodeId: string, request: IAgentRequest) => void;
|
|
25
27
|
clearAgentRequests: (workflowId: string, nodeId: string) => void;
|
|
26
28
|
clearAllAgentRequests: (workflowId?: string) => void;
|
|
27
|
-
|
|
29
|
+
getAgentRequest: (workflowId: string, nodeId: string) => IAgentRequest | undefined;
|
|
28
30
|
}, never>, Pick<{
|
|
29
|
-
agentRequests:
|
|
30
|
-
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
addAgentRequests: (workflowId: string, nodeId: string, params: INodeParameters) => void;
|
|
31
|
+
agentRequests: _vueuse_core.RemovableRef<IAgentRequestStoreState>;
|
|
32
|
+
getAgentRequests: (workflowId: string, nodeId: string) => INodeParameters | string;
|
|
33
|
+
getQueryValue: (workflowId: string, nodeId: string, paramName: string) => NodeParameterValueType | undefined;
|
|
34
|
+
setAgentRequestForNode: (workflowId: string, nodeId: string, request: IAgentRequest) => void;
|
|
34
35
|
clearAgentRequests: (workflowId: string, nodeId: string) => void;
|
|
35
36
|
clearAllAgentRequests: (workflowId?: string) => void;
|
|
36
|
-
|
|
37
|
-
}, "getAgentRequests" | "
|
|
37
|
+
getAgentRequest: (workflowId: string, nodeId: string) => IAgentRequest | undefined;
|
|
38
|
+
}, "getAgentRequests" | "getQueryValue" | "setAgentRequestForNode" | "clearAgentRequests" | "clearAllAgentRequests" | "getAgentRequest">>;
|
|
38
39
|
|
|
39
|
-
export { useAgentRequestStore };
|
|
40
|
+
export { type IAgentRequest, type IAgentRequestStoreState, useAgentRequestStore };
|
|
@@ -1,60 +1,37 @@
|
|
|
1
1
|
// src/useAgentRequestStore.ts
|
|
2
|
+
import { useLocalStorage } from "@vueuse/core";
|
|
2
3
|
import { defineStore } from "pinia";
|
|
3
|
-
|
|
4
|
-
var STORAGE_KEY = "n8n-agent-requests";
|
|
4
|
+
var LOCAL_STORAGE_AGENT_REQUESTS = "N8N_AGENT_REQUESTS";
|
|
5
5
|
var useAgentRequestStore = defineStore("agentRequest", () => {
|
|
6
|
-
const agentRequests =
|
|
7
|
-
function loadFromLocalStorage() {
|
|
8
|
-
try {
|
|
9
|
-
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
10
|
-
return storedData ? JSON.parse(storedData) : {};
|
|
11
|
-
} catch (error) {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
watch(
|
|
16
|
-
agentRequests,
|
|
17
|
-
(newValue) => {
|
|
18
|
-
try {
|
|
19
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(newValue));
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error("Failed to save agent requests to localStorage:", error);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
{ deep: true }
|
|
25
|
-
);
|
|
6
|
+
const agentRequests = useLocalStorage(LOCAL_STORAGE_AGENT_REQUESTS, {});
|
|
26
7
|
const ensureWorkflowAndNodeExist = (workflowId, nodeId) => {
|
|
27
8
|
if (!agentRequests.value[workflowId]) {
|
|
28
9
|
agentRequests.value[workflowId] = {};
|
|
29
10
|
}
|
|
30
11
|
if (!agentRequests.value[workflowId][nodeId]) {
|
|
31
|
-
agentRequests.value[workflowId][nodeId] = {};
|
|
12
|
+
agentRequests.value[workflowId][nodeId] = { query: {} };
|
|
32
13
|
}
|
|
33
14
|
};
|
|
34
15
|
const getAgentRequests = (workflowId, nodeId) => {
|
|
35
|
-
return agentRequests.value[workflowId]?.[nodeId] || {};
|
|
36
|
-
};
|
|
37
|
-
const getAgentRequest = (workflowId, nodeId, paramName) => {
|
|
38
|
-
return agentRequests.value[workflowId]?.[nodeId]?.[paramName];
|
|
16
|
+
return agentRequests.value[workflowId]?.[nodeId]?.query || {};
|
|
39
17
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return agentRequests.value[workflowId][nodeId];
|
|
18
|
+
const getQueryValue = (workflowId, nodeId, paramName) => {
|
|
19
|
+
const query = agentRequests.value[workflowId]?.[nodeId]?.query;
|
|
20
|
+
if (typeof query === "string") {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
return query?.[paramName];
|
|
47
24
|
};
|
|
48
|
-
const
|
|
25
|
+
const setAgentRequestForNode = (workflowId, nodeId, request) => {
|
|
49
26
|
ensureWorkflowAndNodeExist(workflowId, nodeId);
|
|
50
27
|
agentRequests.value[workflowId][nodeId] = {
|
|
51
|
-
...
|
|
52
|
-
...
|
|
28
|
+
...request,
|
|
29
|
+
query: typeof request.query === "string" ? request.query : { ...request.query }
|
|
53
30
|
};
|
|
54
31
|
};
|
|
55
32
|
const clearAgentRequests = (workflowId, nodeId) => {
|
|
56
33
|
if (agentRequests.value[workflowId]) {
|
|
57
|
-
agentRequests.value[workflowId][nodeId] = {};
|
|
34
|
+
agentRequests.value[workflowId][nodeId] = { query: {} };
|
|
58
35
|
}
|
|
59
36
|
};
|
|
60
37
|
const clearAllAgentRequests = (workflowId) => {
|
|
@@ -64,90 +41,18 @@ var useAgentRequestStore = defineStore("agentRequest", () => {
|
|
|
64
41
|
agentRequests.value = {};
|
|
65
42
|
}
|
|
66
43
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const [arrayName, index] = part.split("[");
|
|
71
|
-
if (arrayName) acc.push(arrayName);
|
|
72
|
-
if (index) acc.push(index.replace("]", ""));
|
|
73
|
-
} else {
|
|
74
|
-
acc.push(part);
|
|
75
|
-
}
|
|
76
|
-
return acc;
|
|
77
|
-
}, []);
|
|
78
|
-
}
|
|
79
|
-
function buildRequestObject(path, value) {
|
|
80
|
-
const result = {};
|
|
81
|
-
let current = result;
|
|
82
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
83
|
-
const part = path[i];
|
|
84
|
-
const nextPart = path[i + 1];
|
|
85
|
-
const isArrayIndex = nextPart && !isNaN(Number(nextPart));
|
|
86
|
-
if (isArrayIndex) {
|
|
87
|
-
if (!current[part]) {
|
|
88
|
-
current[part] = [];
|
|
89
|
-
}
|
|
90
|
-
while (current[part].length <= Number(nextPart)) {
|
|
91
|
-
current[part].push({});
|
|
92
|
-
}
|
|
93
|
-
} else if (!current[part]) {
|
|
94
|
-
current[part] = {};
|
|
95
|
-
}
|
|
96
|
-
current = current[part];
|
|
97
|
-
}
|
|
98
|
-
current[path[path.length - 1]] = value;
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
function deepMerge(target, source) {
|
|
102
|
-
const result = { ...target };
|
|
103
|
-
for (const key in source) {
|
|
104
|
-
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
105
|
-
result[key] = deepMerge(
|
|
106
|
-
result[key] || {},
|
|
107
|
-
source[key]
|
|
108
|
-
);
|
|
109
|
-
} else if (Array.isArray(source[key])) {
|
|
110
|
-
if (Array.isArray(result[key])) {
|
|
111
|
-
const targetArray = result[key];
|
|
112
|
-
const sourceArray = source[key];
|
|
113
|
-
while (targetArray.length < sourceArray.length) {
|
|
114
|
-
targetArray.push({});
|
|
115
|
-
}
|
|
116
|
-
sourceArray.forEach((item, index) => {
|
|
117
|
-
if (item && typeof item === "object") {
|
|
118
|
-
targetArray[index] = deepMerge(
|
|
119
|
-
targetArray[index] || {},
|
|
120
|
-
item
|
|
121
|
-
);
|
|
122
|
-
} else {
|
|
123
|
-
targetArray[index] = item;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
result[key] = source[key];
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
result[key] = source[key];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
const generateAgentRequest = (workflowId, nodeId) => {
|
|
136
|
-
const nodeRequests = agentRequests.value[workflowId]?.[nodeId] || {};
|
|
137
|
-
return Object.entries(nodeRequests).reduce(
|
|
138
|
-
(acc, [path, value]) => deepMerge(acc, buildRequestObject(parsePath(path), value)),
|
|
139
|
-
{}
|
|
140
|
-
);
|
|
44
|
+
const getAgentRequest = (workflowId, nodeId) => {
|
|
45
|
+
if (agentRequests.value[workflowId]) return agentRequests.value[workflowId]?.[nodeId];
|
|
46
|
+
return void 0;
|
|
141
47
|
};
|
|
142
48
|
return {
|
|
143
49
|
agentRequests,
|
|
144
50
|
getAgentRequests,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
addAgentRequests,
|
|
51
|
+
getQueryValue,
|
|
52
|
+
setAgentRequestForNode,
|
|
148
53
|
clearAgentRequests,
|
|
149
54
|
clearAllAgentRequests,
|
|
150
|
-
|
|
55
|
+
getAgentRequest
|
|
151
56
|
};
|
|
152
57
|
});
|
|
153
58
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useAgentRequestStore.ts"],"sourcesContent":["import type { INodeParameters, NodeParameterValueType } from 'n8n-workflow';\nimport { defineStore } from 'pinia';\nimport { ref, watch } from 'vue';\n\ninterface IAgentRequestStoreState {\n\t[workflowId: string]: {\n\t\t[nodeName: string]: INodeParameters;\n\t};\n}\n\nconst STORAGE_KEY = 'n8n-agent-requests';\n\nexport const useAgentRequestStore = defineStore('agentRequest', () => {\n\t// State\n\tconst agentRequests = ref<IAgentRequestStoreState>(loadFromLocalStorage());\n\n\t// Load initial state from localStorage\n\tfunction loadFromLocalStorage(): IAgentRequestStoreState {\n\t\ttry {\n\t\t\tconst storedData = localStorage.getItem(STORAGE_KEY);\n\t\t\treturn storedData ? JSON.parse(storedData) : {};\n\t\t} catch (error) {\n\t\t\treturn {};\n\t\t}\n\t}\n\n\t// Save state to localStorage whenever it changes\n\twatch(\n\t\tagentRequests,\n\t\t(newValue) => {\n\t\t\ttry {\n\t\t\t\tlocalStorage.setItem(STORAGE_KEY, JSON.stringify(newValue));\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Failed to save agent requests to localStorage:', error);\n\t\t\t}\n\t\t},\n\t\t{ deep: true },\n\t);\n\n\t// Helper function to ensure workflow and node entries exist\n\tconst ensureWorkflowAndNodeExist = (workflowId: string, nodeId: string): void => {\n\t\tif (!agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t}\n\n\t\tif (!agentRequests.value[workflowId][nodeId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = {};\n\t\t}\n\t};\n\n\t// Getters\n\tconst getAgentRequests = (workflowId: string, nodeId: string): INodeParameters => {\n\t\treturn agentRequests.value[workflowId]?.[nodeId] || {};\n\t};\n\n\tconst getAgentRequest = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\tparamName: string,\n\t): NodeParameterValueType | undefined => {\n\t\treturn agentRequests.value[workflowId]?.[nodeId]?.[paramName];\n\t};\n\n\t// Actions\n\tconst addAgentRequest = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\tparamName: string,\n\t\tparamValues: NodeParameterValueType,\n\t): INodeParameters => {\n\t\tensureWorkflowAndNodeExist(workflowId, nodeId);\n\n\t\tagentRequests.value[workflowId][nodeId] = {\n\t\t\t...agentRequests.value[workflowId][nodeId],\n\t\t\t[paramName]: paramValues,\n\t\t};\n\n\t\treturn agentRequests.value[workflowId][nodeId];\n\t};\n\n\tconst addAgentRequests = (workflowId: string, nodeId: string, params: INodeParameters): void => {\n\t\tensureWorkflowAndNodeExist(workflowId, nodeId);\n\n\t\tagentRequests.value[workflowId][nodeId] = {\n\t\t\t...agentRequests.value[workflowId][nodeId],\n\t\t\t...params,\n\t\t};\n\t};\n\n\tconst clearAgentRequests = (workflowId: string, nodeId: string): void => {\n\t\tif (agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = {};\n\t\t}\n\t};\n\n\tconst clearAllAgentRequests = (workflowId?: string): void => {\n\t\tif (workflowId) {\n\t\t\t// Clear requests for a specific workflow\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t} else {\n\t\t\t// Clear all requests\n\t\t\tagentRequests.value = {};\n\t\t}\n\t};\n\n\tfunction parsePath(path: string): string[] {\n\t\treturn path.split('.').reduce((acc: string[], part) => {\n\t\t\tif (part.includes('[')) {\n\t\t\t\tconst [arrayName, index] = part.split('[');\n\t\t\t\tif (arrayName) acc.push(arrayName);\n\t\t\t\tif (index) acc.push(index.replace(']', ''));\n\t\t\t} else {\n\t\t\t\tacc.push(part);\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, []);\n\t}\n\n\tfunction buildRequestObject(path: string[], value: NodeParameterValueType): INodeParameters {\n\t\tconst result: INodeParameters = {};\n\t\tlet current = result;\n\n\t\tfor (let i = 0; i < path.length - 1; i++) {\n\t\t\tconst part = path[i];\n\t\t\tconst nextPart = path[i + 1];\n\t\t\tconst isArrayIndex = nextPart && !isNaN(Number(nextPart));\n\n\t\t\tif (isArrayIndex) {\n\t\t\t\tif (!current[part]) {\n\t\t\t\t\tcurrent[part] = [];\n\t\t\t\t}\n\t\t\t\twhile ((current[part] as NodeParameterValueType[]).length <= Number(nextPart)) {\n\t\t\t\t\t(current[part] as NodeParameterValueType[]).push({});\n\t\t\t\t}\n\t\t\t} else if (!current[part]) {\n\t\t\t\tcurrent[part] = {};\n\t\t\t}\n\n\t\t\tcurrent = current[part] as INodeParameters;\n\t\t}\n\n\t\tcurrent[path[path.length - 1]] = value;\n\t\treturn result;\n\t}\n\n\t// Helper function to deep merge objects\n\tfunction deepMerge(target: INodeParameters, source: INodeParameters): INodeParameters {\n\t\tconst result = { ...target };\n\n\t\tfor (const key in source) {\n\t\t\tif (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n\t\t\t\t// Recursively merge nested objects\n\t\t\t\tresult[key] = deepMerge(\n\t\t\t\t\t(result[key] as INodeParameters) || {},\n\t\t\t\t\tsource[key] as INodeParameters,\n\t\t\t\t);\n\t\t\t} else if (Array.isArray(source[key])) {\n\t\t\t\t// For arrays, merge by index\n\t\t\t\tif (Array.isArray(result[key])) {\n\t\t\t\t\tconst targetArray = result[key] as NodeParameterValueType[];\n\t\t\t\t\tconst sourceArray = source[key] as NodeParameterValueType[];\n\n\t\t\t\t\t// Ensure target array has enough elements\n\t\t\t\t\twhile (targetArray.length < sourceArray.length) {\n\t\t\t\t\t\ttargetArray.push({});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Merge each array item\n\t\t\t\t\tsourceArray.forEach((item, index) => {\n\t\t\t\t\t\tif (item && typeof item === 'object') {\n\t\t\t\t\t\t\ttargetArray[index] = deepMerge(\n\t\t\t\t\t\t\t\t(targetArray[index] as INodeParameters) || {},\n\t\t\t\t\t\t\t\titem as INodeParameters,\n\t\t\t\t\t\t\t) as NodeParameterValueType;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttargetArray[index] = item;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult[key] = source[key];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// For primitive values, use source value\n\t\t\t\tresult[key] = source[key];\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tconst generateAgentRequest = (workflowId: string, nodeId: string): INodeParameters => {\n\t\tconst nodeRequests = agentRequests.value[workflowId]?.[nodeId] || {};\n\n\t\treturn Object.entries(nodeRequests).reduce(\n\t\t\t(acc, [path, value]) => deepMerge(acc, buildRequestObject(parsePath(path), value)),\n\t\t\t{} as INodeParameters,\n\t\t);\n\t};\n\n\treturn {\n\t\tagentRequests,\n\t\tgetAgentRequests,\n\t\tgetAgentRequest,\n\t\taddAgentRequest,\n\t\taddAgentRequests,\n\t\tclearAgentRequests,\n\t\tclearAllAgentRequests,\n\t\tgenerateAgentRequest,\n\t};\n});\n"],"mappings":";AACA,SAAS,mBAAmB;AAC5B,SAAS,KAAK,aAAa;AAQ3B,IAAM,cAAc;AAEb,IAAM,uBAAuB,YAAY,gBAAgB,MAAM;AAErE,QAAM,gBAAgB,IAA6B,qBAAqB,CAAC;AAGzE,WAAS,uBAAgD;AACxD,QAAI;AACH,YAAM,aAAa,aAAa,QAAQ,WAAW;AACnD,aAAO,aAAa,KAAK,MAAM,UAAU,IAAI,CAAC;AAAA,IAC/C,SAAS,OAAO;AACf,aAAO,CAAC;AAAA,IACT;AAAA,EACD;AAGA;AAAA,IACC;AAAA,IACA,CAAC,aAAa;AACb,UAAI;AACH,qBAAa,QAAQ,aAAa,KAAK,UAAU,QAAQ,CAAC;AAAA,MAC3D,SAAS,OAAO;AACf,gBAAQ,MAAM,kDAAkD,KAAK;AAAA,MACtE;AAAA,IACD;AAAA,IACA,EAAE,MAAM,KAAK;AAAA,EACd;AAGA,QAAM,6BAA6B,CAAC,YAAoB,WAAyB;AAChF,QAAI,CAAC,cAAc,MAAM,UAAU,GAAG;AACrC,oBAAc,MAAM,UAAU,IAAI,CAAC;AAAA,IACpC;AAEA,QAAI,CAAC,cAAc,MAAM,UAAU,EAAE,MAAM,GAAG;AAC7C,oBAAc,MAAM,UAAU,EAAE,MAAM,IAAI,CAAC;AAAA,IAC5C;AAAA,EACD;AAGA,QAAM,mBAAmB,CAAC,YAAoB,WAAoC;AACjF,WAAO,cAAc,MAAM,UAAU,IAAI,MAAM,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,kBAAkB,CACvB,YACA,QACA,cACwC;AACxC,WAAO,cAAc,MAAM,UAAU,IAAI,MAAM,IAAI,SAAS;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AS,UAAU;AACrC,0BAAY,KAAK,IAAI;AAAA,gBACnB,YAAY,KAAK,KAAyB,CAAC;AAAA,gBAC5C;AAAA,cACD;AAAA,YACD,OAAO;AACN,0BAAY,KAAK,IAAI;AAAA,YACtB;AAAA,UACD,CAAC;AAAA,QACF,OAAO;AACN,iBAAO,GAAG,IAAI,OAAO,GAAG;AAAA,QACzB;AAAA,MACD,OAAO;AAEN,eAAO,GAAG,IAAI,OAAO,GAAG;AAAA,MACzB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAEA,QAAM,uBAAuB,CAAC,YAAoB,WAAoC;AACrF,UAAM,eAAe,cAAc,MAAM,UAAU,IAAI,MAAM,KAAK,CAAC;AAEnE,WAAO,OAAO,QAAQ,YAAY,EAAE;AAAA,MACnC,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,UAAU,KAAK,mBAAmB,UAAU,IAAI,GAAG,KAAK,CAAC;AAAA,MACjF,CAAC;AAAA,IACF;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/useAgentRequestStore.ts"],"sourcesContent":["import { useLocalStorage } from '@vueuse/core';\nimport type { INodeParameters, NodeParameterValueType } from 'n8n-workflow';\nimport { defineStore } from 'pinia';\n\nconst LOCAL_STORAGE_AGENT_REQUESTS = 'N8N_AGENT_REQUESTS';\n\nexport interface IAgentRequest {\n\tquery: INodeParameters | string;\n\ttoolName?: string;\n}\n\nexport interface IAgentRequestStoreState {\n\t[workflowId: string]: {\n\t\t[nodeName: string]: IAgentRequest;\n\t};\n}\n\nexport const useAgentRequestStore = defineStore('agentRequest', () => {\n\t// State\n\tconst agentRequests = useLocalStorage<IAgentRequestStoreState>(LOCAL_STORAGE_AGENT_REQUESTS, {});\n\n\t// Helper function to ensure workflow and node entries exist\n\tconst ensureWorkflowAndNodeExist = (workflowId: string, nodeId: string): void => {\n\t\tif (!agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t}\n\n\t\tif (!agentRequests.value[workflowId][nodeId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = { query: {} };\n\t\t}\n\t};\n\n\t// Getters\n\tconst getAgentRequests = (workflowId: string, nodeId: string): INodeParameters | string => {\n\t\treturn agentRequests.value[workflowId]?.[nodeId]?.query || {};\n\t};\n\n\tconst getQueryValue = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\tparamName: string,\n\t): NodeParameterValueType | undefined => {\n\t\tconst query = agentRequests.value[workflowId]?.[nodeId]?.query;\n\t\tif (typeof query === 'string') {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn query?.[paramName] as NodeParameterValueType;\n\t};\n\n\tconst setAgentRequestForNode = (\n\t\tworkflowId: string,\n\t\tnodeId: string,\n\t\trequest: IAgentRequest,\n\t): void => {\n\t\tensureWorkflowAndNodeExist(workflowId, nodeId);\n\n\t\tagentRequests.value[workflowId][nodeId] = {\n\t\t\t...request,\n\t\t\tquery: typeof request.query === 'string' ? request.query : { ...request.query },\n\t\t};\n\t};\n\n\tconst clearAgentRequests = (workflowId: string, nodeId: string): void => {\n\t\tif (agentRequests.value[workflowId]) {\n\t\t\tagentRequests.value[workflowId][nodeId] = { query: {} };\n\t\t}\n\t};\n\n\tconst clearAllAgentRequests = (workflowId?: string): void => {\n\t\tif (workflowId) {\n\t\t\tagentRequests.value[workflowId] = {};\n\t\t} else {\n\t\t\tagentRequests.value = {};\n\t\t}\n\t};\n\n\tconst getAgentRequest = (workflowId: string, nodeId: string): IAgentRequest | undefined => {\n\t\tif (agentRequests.value[workflowId]) return agentRequests.value[workflowId]?.[nodeId];\n\t\treturn undefined;\n\t};\n\n\treturn {\n\t\tagentRequests,\n\t\tgetAgentRequests,\n\t\tgetQueryValue,\n\t\tsetAgentRequestForNode,\n\t\tclearAgentRequests,\n\t\tcl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,QAAI,YAAY;AACf,oBAAc,MAAM,UAAU,IAAI,CAAC;AAAA,IACpC,OAAO;AACN,oBAAc,QAAQ,CAAC;AAAA,IACxB;AAAA,EACD;AAEA,QAAM,kBAAkB,CAAC,YAAoB,WAA8C;AAC1F,QAAI,cAAc,MAAM,UAAU,EAAG,QAAO,cAAc,MAAM,UAAU,IAAI,MAAM;AACpF,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/stores",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"LICENSE.md",
|
|
8
|
+
"LICENSE_EE.md"
|
|
9
9
|
],
|
|
10
10
|
"main": "dist/index.cjs",
|
|
11
11
|
"module": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"n8n-workflow": "1.
|
|
26
|
+
"n8n-workflow": "1.94.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"vitest": "^3.1.3",
|
|
41
41
|
"vue-tsc": "^2.2.8",
|
|
42
42
|
"@n8n/eslint-config": "0.0.1",
|
|
43
|
-
"@n8n/
|
|
44
|
-
"@n8n/
|
|
43
|
+
"@n8n/vitest-config": "1.2.0",
|
|
44
|
+
"@n8n/typescript-config": "1.2.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@vueuse/core": "^10.11.0",
|