n8n-nodes-get-variables 0.1.1 → 0.1.4
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/credentials/N8nApi.credentials.ts +1 -1
- package/dist/credentials/N8nApi.credentials.js +1 -1
- package/dist/credentials/N8nApi.credentials.js.map +1 -1
- package/dist/nodes/GetVariables/GetVariables.node.js +13 -6
- package/dist/nodes/GetVariables/GetVariables.node.js.map +1 -1
- package/nodes/GetVariables/GetVariables.node.ts +15 -6
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export class N8nApi implements ICredentialType {
|
|
|
6
6
|
test: ICredentialTestRequest = {
|
|
7
7
|
request: {
|
|
8
8
|
baseURL: '={{$credentials.baseUrl.replace(/\\/$/, "")}}',
|
|
9
|
-
url: '/api/v1/
|
|
9
|
+
url: '/api/v1/data-tables',
|
|
10
10
|
headers: {
|
|
11
11
|
'X-N8N-API-KEY': '={{$credentials.apiKey}}',
|
|
12
12
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"N8nApi.credentials.js","sourceRoot":"","sources":["../../credentials/N8nApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;IAAnB;QACE,SAAI,GAAG,QAAQ,CAAC;QAChB,gBAAW,GAAG,SAAS,CAAC;QACxB,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,+CAA+C;gBACxD,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"N8nApi.credentials.js","sourceRoot":"","sources":["../../credentials/N8nApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;IAAnB;QACE,SAAI,GAAG,QAAQ,CAAC;QAChB,gBAAW,GAAG,SAAS,CAAC;QACxB,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,+CAA+C;gBACxD,GAAG,EAAE,qBAAqB;gBAC1B,OAAO,EAAE;oBACP,eAAe,EAAE,0BAA0B;iBAC5C;aACF;SACF,CAAC;QACF,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uBAAuB;gBAChC,WAAW,EAAE,+BAA+B;gBAC5C,WAAW,EAAE,uDAAuD;aACrE;YACD;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,oDAAoD;aAClE;SACF,CAAC;IACJ,CAAC;CAAA;AA9BD,wBA8BC"}
|
|
@@ -11,7 +11,7 @@ class GetVariables {
|
|
|
11
11
|
version: 1,
|
|
12
12
|
description: 'Fetch variables from an n8n DataTable and return them as a key-value object',
|
|
13
13
|
defaults: { name: 'Get Variables' },
|
|
14
|
-
inputs: [],
|
|
14
|
+
inputs: ['main'],
|
|
15
15
|
outputs: ['main'],
|
|
16
16
|
credentials: [
|
|
17
17
|
{
|
|
@@ -53,7 +53,7 @@ class GetVariables {
|
|
|
53
53
|
const apiKey = credentials.apiKey;
|
|
54
54
|
const response = await this.helpers.httpRequest({
|
|
55
55
|
method: 'GET',
|
|
56
|
-
url: `${baseUrl}/api/v1/
|
|
56
|
+
url: `${baseUrl}/api/v1/data-tables`,
|
|
57
57
|
headers: { 'X-N8N-API-KEY': apiKey },
|
|
58
58
|
});
|
|
59
59
|
const tables = (_a = response.data) !== null && _a !== void 0 ? _a : response;
|
|
@@ -72,7 +72,7 @@ class GetVariables {
|
|
|
72
72
|
return [];
|
|
73
73
|
const response = await this.helpers.httpRequest({
|
|
74
74
|
method: 'GET',
|
|
75
|
-
url: `${baseUrl}/api/v1/
|
|
75
|
+
url: `${baseUrl}/api/v1/data-tables/${tableId}/rows`,
|
|
76
76
|
headers: { 'X-N8N-API-KEY': apiKey },
|
|
77
77
|
});
|
|
78
78
|
const rows = (_a = response.data) !== null && _a !== void 0 ? _a : response;
|
|
@@ -95,11 +95,11 @@ class GetVariables {
|
|
|
95
95
|
const selectedKeys = this.getNodeParameter('variableKeys', 0);
|
|
96
96
|
const response = await this.helpers.httpRequest({
|
|
97
97
|
method: 'GET',
|
|
98
|
-
url: `${baseUrl}/api/v1/
|
|
98
|
+
url: `${baseUrl}/api/v1/data-tables/${tableId}/rows`,
|
|
99
99
|
headers: { 'X-N8N-API-KEY': apiKey },
|
|
100
100
|
});
|
|
101
101
|
const rows = (_a = response.data) !== null && _a !== void 0 ? _a : response;
|
|
102
|
-
const
|
|
102
|
+
const variables = rows.reduce((acc, row) => {
|
|
103
103
|
const key = row.variable_key;
|
|
104
104
|
if (!key)
|
|
105
105
|
return acc;
|
|
@@ -108,7 +108,14 @@ class GetVariables {
|
|
|
108
108
|
}
|
|
109
109
|
return acc;
|
|
110
110
|
}, {});
|
|
111
|
-
|
|
111
|
+
const inputItems = this.getInputData();
|
|
112
|
+
if (inputItems.length > 0) {
|
|
113
|
+
// merge variables into each incoming item so trigger data is preserved
|
|
114
|
+
return [inputItems.map((item) => ({
|
|
115
|
+
json: { ...item.json, ...variables },
|
|
116
|
+
}))];
|
|
117
|
+
}
|
|
118
|
+
return [[{ json: variables }]];
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
exports.GetVariables = GetVariables;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetVariables.node.js","sourceRoot":"","sources":["../../../nodes/GetVariables/GetVariables.node.ts"],"names":[],"mappings":";;;AAUA,MAAa,YAAY;IAAzB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,eAAe;YAC5B,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;YACnC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"GetVariables.node.js","sourceRoot":"","sources":["../../../nodes/GetVariables/GetVariables.node.ts"],"names":[],"mappings":";;;AAUA,MAAa,YAAY;IAAzB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,eAAe;YAC5B,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;YACnC,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,UAAU,EAAE;gBACV;oBACE,WAAW,EAAE,WAAW;oBACxB,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE;wBACX,iBAAiB,EAAE,eAAe;qBACnC;oBACD,OAAO,EAAE,EAAE;oBACX,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,uCAAuC;iBACrD;gBACD;oBACE,WAAW,EAAE,eAAe;oBAC5B,IAAI,EAAE,cAAc;oBACpB,IAAI,EAAE,cAAc;oBACpB,WAAW,EAAE;wBACX,iBAAiB,EAAE,iBAAiB;wBACpC,oBAAoB,EAAE,CAAC,aAAa,CAAC;qBACtC;oBACD,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,kEAAkE;iBAChF;aACF;SACF,CAAC;QAEF,YAAO,GAAG;YACR,WAAW,EAAE;gBACX,KAAK,CAAC,aAAa;;oBACjB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;oBACxD,MAAM,OAAO,GAAI,WAAW,CAAC,OAAkB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC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AAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5D,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,cAAwB,CAAC;YAC1C,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAiB,CAAC,CAAC;QAEtB,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAEvC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,uEAAuE;YACvE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBAChC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,SAAS,EAAE;iBACrC,CAAC,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACjC,CAAC;CACF;AA9HD,oCA8HC"}
|
|
@@ -17,7 +17,7 @@ export class GetVariables implements INodeType {
|
|
|
17
17
|
version: 1,
|
|
18
18
|
description: 'Fetch variables from an n8n DataTable and return them as a key-value object',
|
|
19
19
|
defaults: { name: 'Get Variables' },
|
|
20
|
-
inputs: [],
|
|
20
|
+
inputs: ['main'],
|
|
21
21
|
outputs: ['main'],
|
|
22
22
|
credentials: [
|
|
23
23
|
{
|
|
@@ -60,7 +60,7 @@ export class GetVariables implements INodeType {
|
|
|
60
60
|
|
|
61
61
|
const response = await this.helpers.httpRequest({
|
|
62
62
|
method: 'GET',
|
|
63
|
-
url: `${baseUrl}/api/v1/
|
|
63
|
+
url: `${baseUrl}/api/v1/data-tables`,
|
|
64
64
|
headers: { 'X-N8N-API-KEY': apiKey },
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -81,7 +81,7 @@ export class GetVariables implements INodeType {
|
|
|
81
81
|
|
|
82
82
|
const response = await this.helpers.httpRequest({
|
|
83
83
|
method: 'GET',
|
|
84
|
-
url: `${baseUrl}/api/v1/
|
|
84
|
+
url: `${baseUrl}/api/v1/data-tables/${tableId}/rows`,
|
|
85
85
|
headers: { 'X-N8N-API-KEY': apiKey },
|
|
86
86
|
});
|
|
87
87
|
|
|
@@ -108,13 +108,13 @@ export class GetVariables implements INodeType {
|
|
|
108
108
|
|
|
109
109
|
const response = await this.helpers.httpRequest({
|
|
110
110
|
method: 'GET',
|
|
111
|
-
url: `${baseUrl}/api/v1/
|
|
111
|
+
url: `${baseUrl}/api/v1/data-tables/${tableId}/rows`,
|
|
112
112
|
headers: { 'X-N8N-API-KEY': apiKey },
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
const rows: IDataObject[] = response.data ?? response;
|
|
116
116
|
|
|
117
|
-
const
|
|
117
|
+
const variables = rows.reduce((acc, row) => {
|
|
118
118
|
const key = row.variable_key as string;
|
|
119
119
|
if (!key) return acc;
|
|
120
120
|
if (selectedKeys.length === 0 || selectedKeys.includes(key)) {
|
|
@@ -123,6 +123,15 @@ export class GetVariables implements INodeType {
|
|
|
123
123
|
return acc;
|
|
124
124
|
}, {} as IDataObject);
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
const inputItems = this.getInputData();
|
|
127
|
+
|
|
128
|
+
if (inputItems.length > 0) {
|
|
129
|
+
// merge variables into each incoming item so trigger data is preserved
|
|
130
|
+
return [inputItems.map((item) => ({
|
|
131
|
+
json: { ...item.json, ...variables },
|
|
132
|
+
}))];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return [[{ json: variables }]];
|
|
127
136
|
}
|
|
128
137
|
}
|