Skip to content

Commit 88a5445

Browse files
committed
Use routing.send for query
1 parent b3c822d commit 88a5445

File tree

2 files changed

+145
-28
lines changed

2 files changed

+145
-28
lines changed

src/N8NPropertiesBuilder.spec.ts

Lines changed: 140 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ test('query param - schema', () => {
135135
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
136136
description: 'Boolean flag description',
137137
routing: {
138-
request: {
139-
qs: {
140-
all: '={{ $value }}',
141-
},
142-
},
138+
"send": {
139+
"property": "all",
140+
"propertyInDotNotation": false,
141+
"type": "query",
142+
"value": "={{ $value }}"
143+
}
143144
},
144145
},
145146
]);
@@ -290,17 +291,129 @@ test('query param - content', () => {
290291
},
291292
"name": "filter",
292293
"routing": {
293-
"request": {
294-
"qs": {
295-
"filter": "={{ $value }}"
296-
}
294+
"send": {
295+
"property": "filter",
296+
"propertyInDotNotation": false,
297+
"type": "query",
298+
"value": "={{ $value }}"
297299
}
298300
},
299301
"type": "json"
300302
}
301303
]);
302304
});
303305

306+
test('query param - dot in field name', () => {
307+
const paths = {
308+
'/api/entities': {
309+
get: {
310+
operationId: 'EntityController_list',
311+
summary: 'List all entities',
312+
parameters: [
313+
{
314+
name: 'filter.all',
315+
required: false,
316+
in: 'query',
317+
example: false,
318+
description: 'Boolean flag description',
319+
schema: {
320+
type: 'boolean',
321+
},
322+
},
323+
],
324+
tags: ['🖥️ Entity'],
325+
},
326+
},
327+
};
328+
329+
const parser = new N8NPropertiesBuilder({paths}, {
330+
operation: new CustomOperationParser(),
331+
resource: new CustomResourceParser(),
332+
});
333+
const result = parser.build()
334+
335+
expect(result).toEqual([
336+
{
337+
"default": "",
338+
"displayName": "Resource",
339+
"name": "resource",
340+
"noDataExpression": true,
341+
"options": [
342+
{
343+
"description": "",
344+
"name": "🖥️ Entity",
345+
"value": "Entity"
346+
}
347+
],
348+
"type": "options"
349+
},
350+
{
351+
displayName: 'Operation',
352+
name: 'operation',
353+
type: 'options',
354+
noDataExpression: true,
355+
displayOptions: {
356+
show: {
357+
resource: ['Entity'],
358+
},
359+
},
360+
options: [
361+
{
362+
name: 'List',
363+
value: 'List',
364+
action: 'List all entities',
365+
description: 'List all entities',
366+
routing: {
367+
request: {
368+
method: 'GET',
369+
url: '=/api/entities',
370+
},
371+
},
372+
},
373+
],
374+
// eslint-disable-next-line
375+
default: '',
376+
},
377+
{
378+
displayName: 'GET /api/entities',
379+
default: '',
380+
displayOptions: {
381+
show: {
382+
operation: ['List'],
383+
resource: ['Entity'],
384+
},
385+
},
386+
name: 'operation',
387+
type: 'notice',
388+
typeOptions: {
389+
theme: 'info',
390+
},
391+
},
392+
{
393+
displayName: 'Filter All',
394+
name: 'filter.all',
395+
type: 'boolean',
396+
displayOptions: {
397+
show: {
398+
resource: ['Entity'],
399+
operation: ['List'],
400+
},
401+
},
402+
default: false,
403+
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
404+
description: 'Boolean flag description',
405+
routing: {
406+
"send": {
407+
"property": "filter.all",
408+
"propertyInDotNotation": false,
409+
"type": "query",
410+
"value": "={{ $value }}"
411+
}
412+
},
413+
},
414+
]);
415+
});
416+
304417
test('path param', () => {
305418
const paths = {
306419
'/api/entities/{entity}': {
@@ -1097,11 +1210,12 @@ test('multiple tags', () => {
10971210
},
10981211
"name": "all",
10991212
"routing": {
1100-
"request": {
1101-
"qs": {
1102-
"all": "={{ $value }}"
1103-
}
1104-
}
1213+
"send": {
1214+
"property": "all",
1215+
"propertyInDotNotation": false,
1216+
"type": "query",
1217+
"value": "={{ $value }}"
1218+
},
11051219
},
11061220
"type": "boolean"
11071221
},
@@ -1140,11 +1254,12 @@ test('multiple tags', () => {
11401254
},
11411255
"name": "all",
11421256
"routing": {
1143-
"request": {
1144-
"qs": {
1145-
"all": "={{ $value }}"
1146-
}
1147-
}
1257+
"send": {
1258+
"property": "all",
1259+
"propertyInDotNotation": false,
1260+
"type": "query",
1261+
"value": "={{ $value }}"
1262+
},
11481263
},
11491264
"type": "boolean"
11501265
}
@@ -1260,11 +1375,12 @@ test('no tags - default tag', () => {
12601375
},
12611376
"name": "all",
12621377
"routing": {
1263-
"request": {
1264-
"qs": {
1265-
"all": "={{ $value }}"
1266-
}
1267-
}
1378+
"send": {
1379+
"property": "all",
1380+
"propertyInDotNotation": false,
1381+
"type": "query",
1382+
"value": "={{ $value }}"
1383+
},
12681384
},
12691385
"type": "boolean"
12701386
}

src/n8n/SchemaToINodeProperties.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ export class N8NINodeProperties {
112112
switch (parameter.in) {
113113
case "query":
114114
field.routing = {
115-
request: {
116-
qs: {
117-
[parameter.name]: '={{ $value }}',
118-
},
115+
send: {
116+
type: 'query',
117+
property: parameter.name,
118+
value: '={{ $value }}',
119+
propertyInDotNotation: false,
119120
},
120121
};
121122
break;

0 commit comments

Comments
 (0)