n8n-nodes-qwease 0.3.9
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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/credentials/QweaseApi.credentials.d.ts +10 -0
- package/dist/credentials/QweaseApi.credentials.js +37 -0
- package/dist/credentials/qwease.png +0 -0
- package/dist/credentials/qwease.svg +4 -0
- package/dist/nodes/Qwease/FormFieldsHelper.d.ts +21 -0
- package/dist/nodes/Qwease/FormFieldsHelper.js +187 -0
- package/dist/nodes/Qwease/GenericFunctions.d.ts +4 -0
- package/dist/nodes/Qwease/GenericFunctions.js +30 -0
- package/dist/nodes/Qwease/KnowledgeTaskDescription.d.ts +5 -0
- package/dist/nodes/Qwease/KnowledgeTaskDescription.js +306 -0
- package/dist/nodes/Qwease/OtherResourcesDescription.d.ts +12 -0
- package/dist/nodes/Qwease/OtherResourcesDescription.js +444 -0
- package/dist/nodes/Qwease/Qwease.node.d.ts +32 -0
- package/dist/nodes/Qwease/Qwease.node.js +187 -0
- package/dist/nodes/Qwease/QweaseDescription.d.ts +3 -0
- package/dist/nodes/Qwease/QweaseDescription.js +390 -0
- package/dist/nodes/Qwease/QweaseMethods.d.ts +22 -0
- package/dist/nodes/Qwease/QweaseMethods.js +335 -0
- package/dist/nodes/Qwease/QweaseTrigger.node.d.ts +12 -0
- package/dist/nodes/Qwease/QweaseTrigger.node.js +152 -0
- package/dist/nodes/Qwease/TicketBody.d.ts +3 -0
- package/dist/nodes/Qwease/TicketBody.js +104 -0
- package/dist/nodes/Qwease/executeHelpers.d.ts +14 -0
- package/dist/nodes/Qwease/executeHelpers.js +66 -0
- package/dist/nodes/Qwease/executeKnowledgeTask.d.ts +3 -0
- package/dist/nodes/Qwease/executeKnowledgeTask.js +127 -0
- package/dist/nodes/Qwease/executeOtherResources.d.ts +7 -0
- package/dist/nodes/Qwease/executeOtherResources.js +256 -0
- package/dist/nodes/Qwease/qwease.png +0 -0
- package/dist/nodes/Qwease/qwease.svg +4 -0
- package/dist/nodes/Qwease/shared.d.ts +13 -0
- package/dist/nodes/Qwease/shared.js +155 -0
- package/package.json +54 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
export declare function executeKnowledge(this: IExecuteFunctions, itemIndex: number, operation: string): Promise<INodeExecutionData[]>;
|
|
3
|
+
export declare function executeTask(this: IExecuteFunctions, itemIndex: number, operation: string): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeKnowledge = executeKnowledge;
|
|
4
|
+
exports.executeTask = executeTask;
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
const executeHelpers_1 = require("./executeHelpers");
|
|
7
|
+
function applyPageFields(body, fields) {
|
|
8
|
+
if (fields.title)
|
|
9
|
+
body.title = fields.title;
|
|
10
|
+
if (fields.pageType)
|
|
11
|
+
body.type = fields.pageType;
|
|
12
|
+
if (fields.pageStatus)
|
|
13
|
+
body.status = fields.pageStatus;
|
|
14
|
+
const parent = (0, executeHelpers_1.parseOptionalInt)(fields.parent);
|
|
15
|
+
if (parent !== undefined)
|
|
16
|
+
body.parent = parent;
|
|
17
|
+
if (fields.order !== undefined && fields.order !== null) {
|
|
18
|
+
body.order = fields.order;
|
|
19
|
+
}
|
|
20
|
+
if (fields.icon)
|
|
21
|
+
body.icon = fields.icon;
|
|
22
|
+
if (fields.coverUrl)
|
|
23
|
+
body.cover_url = fields.coverUrl;
|
|
24
|
+
if (fields.color)
|
|
25
|
+
body.color = fields.color;
|
|
26
|
+
}
|
|
27
|
+
function applyTaskFields(body, fields) {
|
|
28
|
+
if (fields.taskTitle)
|
|
29
|
+
body.task_title = fields.taskTitle;
|
|
30
|
+
if (fields.taskDescription)
|
|
31
|
+
body.task_description = fields.taskDescription;
|
|
32
|
+
if (fields.taskPosition !== undefined && fields.taskPosition !== null) {
|
|
33
|
+
body.task_position = fields.taskPosition;
|
|
34
|
+
}
|
|
35
|
+
if (fields.taskType)
|
|
36
|
+
body.task_type = fields.taskType;
|
|
37
|
+
if (fields.taskStatus)
|
|
38
|
+
body.task_status = fields.taskStatus;
|
|
39
|
+
if (fields.taskStatusCommentary) {
|
|
40
|
+
body.task_status_commentary = fields.taskStatusCommentary;
|
|
41
|
+
}
|
|
42
|
+
const validator = (0, executeHelpers_1.parseOptionalInt)(fields.taskValidator);
|
|
43
|
+
if (validator !== undefined)
|
|
44
|
+
body.task_validator = validator;
|
|
45
|
+
}
|
|
46
|
+
async function executeKnowledge(itemIndex, operation) {
|
|
47
|
+
if (operation === 'get') {
|
|
48
|
+
return [await (0, executeHelpers_1.executeGetById)(this, itemIndex, '/pages/', 'pageId', 'Page')];
|
|
49
|
+
}
|
|
50
|
+
if (operation === 'getAll') {
|
|
51
|
+
return (0, executeHelpers_1.executeGetAll)(this, itemIndex, '/pages/');
|
|
52
|
+
}
|
|
53
|
+
if (operation === 'search') {
|
|
54
|
+
const q = this.getNodeParameter('knowledgeQuery', itemIndex);
|
|
55
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'GET', '/pages/search/', {}, { q });
|
|
56
|
+
const list = (0, GenericFunctions_1.qweaseListFromResponse)(response);
|
|
57
|
+
if (list.length === 0 && response && typeof response === 'object') {
|
|
58
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
59
|
+
}
|
|
60
|
+
return list.map((entry) => ({ json: entry, pairedItem: { item: itemIndex } }));
|
|
61
|
+
}
|
|
62
|
+
if (operation === 'create') {
|
|
63
|
+
const body = {
|
|
64
|
+
title: this.getNodeParameter('title', itemIndex),
|
|
65
|
+
type: this.getNodeParameter('pageType', itemIndex),
|
|
66
|
+
status: this.getNodeParameter('pageStatus', itemIndex),
|
|
67
|
+
};
|
|
68
|
+
const additional = this.getNodeParameter('additionalFields', itemIndex, {});
|
|
69
|
+
applyPageFields(body, additional);
|
|
70
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'POST', '/pages/', body);
|
|
71
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
72
|
+
}
|
|
73
|
+
if (operation === 'update') {
|
|
74
|
+
const pageId = (0, executeHelpers_1.requireResourceId)(this, 'pageId', itemIndex, 'Page');
|
|
75
|
+
const fields = this.getNodeParameter('updateFields', itemIndex, {});
|
|
76
|
+
const body = {};
|
|
77
|
+
applyPageFields(body, fields);
|
|
78
|
+
if (Object.keys(body).length === 0) {
|
|
79
|
+
throw new Error('Set at least one field to update.');
|
|
80
|
+
}
|
|
81
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'PATCH', `/pages/${pageId}/`, body);
|
|
82
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
83
|
+
}
|
|
84
|
+
if (operation === 'updateContent') {
|
|
85
|
+
const pageId = (0, executeHelpers_1.requireResourceId)(this, 'pageId', itemIndex, 'Page');
|
|
86
|
+
const contentRaw = this.getNodeParameter('content', itemIndex);
|
|
87
|
+
const body = typeof contentRaw === 'string' ? JSON.parse(contentRaw) : contentRaw;
|
|
88
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'PATCH', `/pages/${pageId}/content/`, body);
|
|
89
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`Unknown knowledge operation: ${operation}`);
|
|
92
|
+
}
|
|
93
|
+
async function executeTask(itemIndex, operation) {
|
|
94
|
+
if (operation === 'get') {
|
|
95
|
+
return [await (0, executeHelpers_1.executeGetById)(this, itemIndex, '/tasks/', 'taskId', 'Task')];
|
|
96
|
+
}
|
|
97
|
+
if (operation === 'getAll') {
|
|
98
|
+
return (0, executeHelpers_1.executeGetAll)(this, itemIndex, '/tasks/');
|
|
99
|
+
}
|
|
100
|
+
if (operation === 'create') {
|
|
101
|
+
const ticket = (0, executeHelpers_1.parseOptionalInt)(this.getNodeParameter('ticket', itemIndex, undefined, { extractValue: true }));
|
|
102
|
+
if (!ticket) {
|
|
103
|
+
throw new Error('Select a Ticket (list or ID).');
|
|
104
|
+
}
|
|
105
|
+
const body = {
|
|
106
|
+
ticket,
|
|
107
|
+
task_title: this.getNodeParameter('taskTitle', itemIndex),
|
|
108
|
+
task_position: this.getNodeParameter('taskPosition', itemIndex),
|
|
109
|
+
};
|
|
110
|
+
const additional = this.getNodeParameter('additionalFields', itemIndex, {});
|
|
111
|
+
applyTaskFields(body, additional);
|
|
112
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'POST', '/tasks/', body);
|
|
113
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
114
|
+
}
|
|
115
|
+
if (operation === 'update') {
|
|
116
|
+
const taskId = (0, executeHelpers_1.requireResourceId)(this, 'taskId', itemIndex, 'Task');
|
|
117
|
+
const fields = this.getNodeParameter('updateFields', itemIndex, {});
|
|
118
|
+
const body = {};
|
|
119
|
+
applyTaskFields(body, fields);
|
|
120
|
+
if (Object.keys(body).length === 0) {
|
|
121
|
+
throw new Error('Set at least one field to update.');
|
|
122
|
+
}
|
|
123
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'PATCH', `/tasks/${taskId}/`, body);
|
|
124
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Unknown task operation: ${operation}`);
|
|
127
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
export declare function executeMe(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
3
|
+
export declare function executeUser(this: IExecuteFunctions, itemIndex: number, operation: string): Promise<INodeExecutionData[]>;
|
|
4
|
+
export declare function executeOrganization(this: IExecuteFunctions, itemIndex: number, operation: string): Promise<INodeExecutionData[]>;
|
|
5
|
+
export declare function executeDevice(this: IExecuteFunctions, itemIndex: number, operation: string): Promise<INodeExecutionData[]>;
|
|
6
|
+
export declare function executeTeam(this: IExecuteFunctions, itemIndex: number, operation: string): Promise<INodeExecutionData[]>;
|
|
7
|
+
export declare function executeSearch(this: IExecuteFunctions, itemIndex: number, operation: string): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeMe = executeMe;
|
|
4
|
+
exports.executeUser = executeUser;
|
|
5
|
+
exports.executeOrganization = executeOrganization;
|
|
6
|
+
exports.executeDevice = executeDevice;
|
|
7
|
+
exports.executeTeam = executeTeam;
|
|
8
|
+
exports.executeSearch = executeSearch;
|
|
9
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
10
|
+
const executeHelpers_1 = require("./executeHelpers");
|
|
11
|
+
function applyCommonOptional(body, fields) {
|
|
12
|
+
if (fields.isActive !== undefined) {
|
|
13
|
+
body.is_active = fields.isActive;
|
|
14
|
+
}
|
|
15
|
+
const customFields = (0, executeHelpers_1.buildCustomFieldsFromUi)(fields.customFieldsUi);
|
|
16
|
+
if (customFields) {
|
|
17
|
+
body.custom_fields = customFields;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function executeMe(itemIndex) {
|
|
21
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'GET', '/me/');
|
|
22
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
23
|
+
}
|
|
24
|
+
async function executeUser(itemIndex, operation) {
|
|
25
|
+
if (operation === 'get') {
|
|
26
|
+
return [await (0, executeHelpers_1.executeGetById)(this, itemIndex, '/users/', 'userId', 'User')];
|
|
27
|
+
}
|
|
28
|
+
if (operation === 'getAll') {
|
|
29
|
+
return (0, executeHelpers_1.executeGetAll)(this, itemIndex, '/users/');
|
|
30
|
+
}
|
|
31
|
+
if (operation === 'create') {
|
|
32
|
+
const client = (0, executeHelpers_1.parseOptionalInt)(this.getNodeParameter('client', itemIndex, undefined, { extractValue: true }));
|
|
33
|
+
if (!client) {
|
|
34
|
+
throw new Error('Select an Organization (list or ID).');
|
|
35
|
+
}
|
|
36
|
+
const body = {
|
|
37
|
+
email: this.getNodeParameter('email', itemIndex),
|
|
38
|
+
first_name: this.getNodeParameter('firstName', itemIndex),
|
|
39
|
+
last_name: this.getNodeParameter('lastName', itemIndex),
|
|
40
|
+
client,
|
|
41
|
+
};
|
|
42
|
+
const additional = this.getNodeParameter('additionalFields', itemIndex, {});
|
|
43
|
+
applyCommonOptional(body, additional);
|
|
44
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'POST', '/users/', body);
|
|
45
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
46
|
+
}
|
|
47
|
+
if (operation === 'update') {
|
|
48
|
+
const userId = (0, executeHelpers_1.requireResourceId)(this, 'userId', itemIndex, 'User');
|
|
49
|
+
const fields = this.getNodeParameter('updateFields', itemIndex, {});
|
|
50
|
+
const body = {};
|
|
51
|
+
if (fields.email)
|
|
52
|
+
body.email = fields.email;
|
|
53
|
+
if (fields.firstName)
|
|
54
|
+
body.first_name = fields.firstName;
|
|
55
|
+
if (fields.lastName)
|
|
56
|
+
body.last_name = fields.lastName;
|
|
57
|
+
const client = (0, executeHelpers_1.parseOptionalInt)(fields.client);
|
|
58
|
+
if (client !== undefined)
|
|
59
|
+
body.client = client;
|
|
60
|
+
applyCommonOptional(body, fields);
|
|
61
|
+
if (Object.keys(body).length === 0) {
|
|
62
|
+
throw new Error('Set at least one field to update.');
|
|
63
|
+
}
|
|
64
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'PATCH', `/users/${userId}/`, body);
|
|
65
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`Unknown user operation: ${operation}`);
|
|
68
|
+
}
|
|
69
|
+
async function executeOrganization(itemIndex, operation) {
|
|
70
|
+
if (operation === 'get') {
|
|
71
|
+
return [
|
|
72
|
+
await (0, executeHelpers_1.executeGetById)(this, itemIndex, '/client/', 'organizationId', 'Organization'),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
if (operation === 'getAll') {
|
|
76
|
+
return (0, executeHelpers_1.executeGetAll)(this, itemIndex, '/client/');
|
|
77
|
+
}
|
|
78
|
+
if (operation === 'create') {
|
|
79
|
+
const body = {
|
|
80
|
+
name: this.getNodeParameter('name', itemIndex),
|
|
81
|
+
};
|
|
82
|
+
const additional = this.getNodeParameter('additionalFields', itemIndex, {});
|
|
83
|
+
applyCommonOptional(body, additional);
|
|
84
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'POST', '/client/', body);
|
|
85
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
86
|
+
}
|
|
87
|
+
if (operation === 'update') {
|
|
88
|
+
const organizationId = (0, executeHelpers_1.requireResourceId)(this, 'organizationId', itemIndex, 'Organization');
|
|
89
|
+
const fields = this.getNodeParameter('updateFields', itemIndex, {});
|
|
90
|
+
const body = {};
|
|
91
|
+
if (fields.name)
|
|
92
|
+
body.name = fields.name;
|
|
93
|
+
applyCommonOptional(body, fields);
|
|
94
|
+
if (Object.keys(body).length === 0) {
|
|
95
|
+
throw new Error('Set at least one field to update.');
|
|
96
|
+
}
|
|
97
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'PATCH', `/client/${organizationId}/`, body);
|
|
98
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
99
|
+
}
|
|
100
|
+
throw new Error(`Unknown organization operation: ${operation}`);
|
|
101
|
+
}
|
|
102
|
+
async function executeDevice(itemIndex, operation) {
|
|
103
|
+
if (operation === 'get') {
|
|
104
|
+
return [await (0, executeHelpers_1.executeGetById)(this, itemIndex, '/device/', 'deviceId', 'Device')];
|
|
105
|
+
}
|
|
106
|
+
if (operation === 'getAll') {
|
|
107
|
+
return (0, executeHelpers_1.executeGetAll)(this, itemIndex, '/device/');
|
|
108
|
+
}
|
|
109
|
+
if (operation === 'create') {
|
|
110
|
+
const client = (0, executeHelpers_1.parseOptionalInt)(this.getNodeParameter('client', itemIndex, undefined, { extractValue: true }));
|
|
111
|
+
if (!client) {
|
|
112
|
+
throw new Error('Select an Organization (list or ID).');
|
|
113
|
+
}
|
|
114
|
+
const body = {
|
|
115
|
+
name: this.getNodeParameter('name', itemIndex),
|
|
116
|
+
client,
|
|
117
|
+
};
|
|
118
|
+
const additional = this.getNodeParameter('additionalFields', itemIndex, {});
|
|
119
|
+
if (additional.serialNumber)
|
|
120
|
+
body.serial_number = additional.serialNumber;
|
|
121
|
+
const owner = (0, executeHelpers_1.parseOptionalInt)(additional.owner);
|
|
122
|
+
if (owner !== undefined)
|
|
123
|
+
body.owner = owner;
|
|
124
|
+
applyCommonOptional(body, additional);
|
|
125
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'POST', '/device/', body);
|
|
126
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
127
|
+
}
|
|
128
|
+
if (operation === 'update') {
|
|
129
|
+
const deviceId = (0, executeHelpers_1.requireResourceId)(this, 'deviceId', itemIndex, 'Device');
|
|
130
|
+
const fields = this.getNodeParameter('updateFields', itemIndex, {});
|
|
131
|
+
const body = {};
|
|
132
|
+
if (fields.name)
|
|
133
|
+
body.name = fields.name;
|
|
134
|
+
if (fields.serialNumber)
|
|
135
|
+
body.serial_number = fields.serialNumber;
|
|
136
|
+
const client = (0, executeHelpers_1.parseOptionalInt)(fields.client);
|
|
137
|
+
if (client !== undefined)
|
|
138
|
+
body.client = client;
|
|
139
|
+
const owner = (0, executeHelpers_1.parseOptionalInt)(fields.owner);
|
|
140
|
+
if (owner !== undefined)
|
|
141
|
+
body.owner = owner;
|
|
142
|
+
applyCommonOptional(body, fields);
|
|
143
|
+
if (Object.keys(body).length === 0) {
|
|
144
|
+
throw new Error('Set at least one field to update.');
|
|
145
|
+
}
|
|
146
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'PATCH', `/device/${deviceId}/`, body);
|
|
147
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
148
|
+
}
|
|
149
|
+
throw new Error(`Unknown device operation: ${operation}`);
|
|
150
|
+
}
|
|
151
|
+
async function executeTeam(itemIndex, operation) {
|
|
152
|
+
if (operation === 'get') {
|
|
153
|
+
return [await (0, executeHelpers_1.executeGetById)(this, itemIndex, '/teams/', 'teamId', 'Team')];
|
|
154
|
+
}
|
|
155
|
+
if (operation === 'getAll') {
|
|
156
|
+
return (0, executeHelpers_1.executeGetAll)(this, itemIndex, '/teams/');
|
|
157
|
+
}
|
|
158
|
+
if (operation === 'create') {
|
|
159
|
+
const body = {
|
|
160
|
+
name: this.getNodeParameter('name', itemIndex),
|
|
161
|
+
};
|
|
162
|
+
const additional = this.getNodeParameter('additionalFields', itemIndex, {});
|
|
163
|
+
const clients = parseMultiIds(additional.clients);
|
|
164
|
+
const members = parseMultiIds(additional.members);
|
|
165
|
+
const admins = parseMultiIds(additional.administrators);
|
|
166
|
+
if (clients)
|
|
167
|
+
body.client = clients;
|
|
168
|
+
if (members)
|
|
169
|
+
body.members = members;
|
|
170
|
+
if (admins)
|
|
171
|
+
body.administrators = admins;
|
|
172
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'POST', '/teams/', body);
|
|
173
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
174
|
+
}
|
|
175
|
+
if (operation === 'update') {
|
|
176
|
+
const teamId = (0, executeHelpers_1.requireResourceId)(this, 'teamId', itemIndex, 'Team');
|
|
177
|
+
const fields = this.getNodeParameter('updateFields', itemIndex, {});
|
|
178
|
+
const body = {};
|
|
179
|
+
if (fields.name)
|
|
180
|
+
body.name = fields.name;
|
|
181
|
+
const clients = parseMultiIds(fields.clients);
|
|
182
|
+
const members = parseMultiIds(fields.members);
|
|
183
|
+
const admins = parseMultiIds(fields.administrators);
|
|
184
|
+
if (clients)
|
|
185
|
+
body.client = clients;
|
|
186
|
+
if (members)
|
|
187
|
+
body.members = members;
|
|
188
|
+
if (admins)
|
|
189
|
+
body.administrators = admins;
|
|
190
|
+
if (Object.keys(body).length === 0) {
|
|
191
|
+
throw new Error('Set at least one field to update.');
|
|
192
|
+
}
|
|
193
|
+
const response = await GenericFunctions_1.qweaseApiRequest.call(this, 'PATCH', `/teams/${teamId}/`, body);
|
|
194
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
195
|
+
}
|
|
196
|
+
throw new Error(`Unknown team operation: ${operation}`);
|
|
197
|
+
}
|
|
198
|
+
function parseMultiIds(value) {
|
|
199
|
+
if (value === undefined || value === null || value === '') {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
const raw = Array.isArray(value) ? value : String(value).split(',');
|
|
203
|
+
const ids = raw
|
|
204
|
+
.map((part) => parseInt(String(part).trim(), 10))
|
|
205
|
+
.filter((n) => !Number.isNaN(n));
|
|
206
|
+
return ids.length ? ids : undefined;
|
|
207
|
+
}
|
|
208
|
+
async function executeSearch(itemIndex, operation) {
|
|
209
|
+
if (operation === 'quick') {
|
|
210
|
+
const q = this.getNodeParameter('query', itemIndex);
|
|
211
|
+
const type = this.getNodeParameter('searchType', itemIndex);
|
|
212
|
+
const limit = this.getNodeParameter('quickLimit', itemIndex);
|
|
213
|
+
const response = (await GenericFunctions_1.qweaseApiRequest.call(this, 'GET', '/search/', {}, { q, type, limit }));
|
|
214
|
+
const results = response.results || {};
|
|
215
|
+
const key = type === 'user' ? 'users' : 'tickets';
|
|
216
|
+
const list = Array.isArray(results[key]) ? results[key] : [];
|
|
217
|
+
if (list.length === 0) {
|
|
218
|
+
return [{ json: response, pairedItem: { item: itemIndex } }];
|
|
219
|
+
}
|
|
220
|
+
return list.map((entry) => ({ json: entry, pairedItem: { item: itemIndex } }));
|
|
221
|
+
}
|
|
222
|
+
if (operation === 'advanced') {
|
|
223
|
+
const conditionsRaw = this.getNodeParameter('conditionsJson', itemIndex);
|
|
224
|
+
const conditions = typeof conditionsRaw === 'string' ? JSON.parse(conditionsRaw) : conditionsRaw;
|
|
225
|
+
const searchText = this.getNodeParameter('searchText', itemIndex, '');
|
|
226
|
+
const pageSize = this.getNodeParameter('pageSize', itemIndex);
|
|
227
|
+
const ordering = this.getNodeParameter('ordering', itemIndex, '');
|
|
228
|
+
const customFieldsDisplay = this.getNodeParameter('customFieldsDisplay', itemIndex, false);
|
|
229
|
+
const returnAll = this.getNodeParameter('returnAll', itemIndex, false);
|
|
230
|
+
const qs = {};
|
|
231
|
+
if (customFieldsDisplay) {
|
|
232
|
+
qs.custom_fields_display = 1;
|
|
233
|
+
}
|
|
234
|
+
const collected = [];
|
|
235
|
+
let page = returnAll ? 1 : this.getNodeParameter('page', itemIndex);
|
|
236
|
+
let totalPages = 1;
|
|
237
|
+
do {
|
|
238
|
+
const body = {
|
|
239
|
+
conditions,
|
|
240
|
+
page,
|
|
241
|
+
page_size: pageSize,
|
|
242
|
+
search: searchText || '',
|
|
243
|
+
};
|
|
244
|
+
if (ordering) {
|
|
245
|
+
body.ordering = ordering;
|
|
246
|
+
}
|
|
247
|
+
const response = (await GenericFunctions_1.qweaseApiRequest.call(this, 'POST', '/advanced-search/', body, qs));
|
|
248
|
+
const pageResults = (0, GenericFunctions_1.qweaseListFromResponse)(response);
|
|
249
|
+
collected.push(...pageResults);
|
|
250
|
+
totalPages = Number(response.total_pages || 1);
|
|
251
|
+
page += 1;
|
|
252
|
+
} while (returnAll && page <= totalPages);
|
|
253
|
+
return collected.map((entry) => ({ json: entry, pairedItem: { item: itemIndex } }));
|
|
254
|
+
}
|
|
255
|
+
throw new Error(`Unknown search operation: ${operation}`);
|
|
256
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" width="60" height="60">
|
|
2
|
+
<circle cx="30" cy="30" r="30" fill="#0B3D91"/>
|
|
3
|
+
<text x="30" y="38" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="32" font-weight="700" fill="#FFFFFF">Q</text>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare const idModeValidation: {
|
|
3
|
+
type: "regex";
|
|
4
|
+
properties: {
|
|
5
|
+
regex: string;
|
|
6
|
+
errorMessage: string;
|
|
7
|
+
};
|
|
8
|
+
}[];
|
|
9
|
+
export declare function resourceLocatorModes(searchListMethod: string, listPlaceholder: string, idPlaceholder?: string): NonNullable<INodeProperties['modes']>;
|
|
10
|
+
export declare const returnAllLimitFields: (resource: string) => INodeProperties[];
|
|
11
|
+
export declare function multiOptionsFromLoad(displayName: string, name: string, loadOptionsMethod: string, description?: string): INodeProperties;
|
|
12
|
+
/** Custom fields with From list / By Name (listSearch method varies by scope) */
|
|
13
|
+
export declare function customFieldsFixedCollectionWithList(searchListMethod: string, description?: string): INodeProperties;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.returnAllLimitFields = exports.idModeValidation = void 0;
|
|
4
|
+
exports.resourceLocatorModes = resourceLocatorModes;
|
|
5
|
+
exports.multiOptionsFromLoad = multiOptionsFromLoad;
|
|
6
|
+
exports.customFieldsFixedCollectionWithList = customFieldsFixedCollectionWithList;
|
|
7
|
+
exports.idModeValidation = [
|
|
8
|
+
{
|
|
9
|
+
type: 'regex',
|
|
10
|
+
properties: {
|
|
11
|
+
regex: '^[0-9]+$',
|
|
12
|
+
errorMessage: 'ID must be a positive integer',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
function resourceLocatorModes(searchListMethod, listPlaceholder, idPlaceholder = '1') {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
displayName: 'From List',
|
|
20
|
+
name: 'list',
|
|
21
|
+
type: 'list',
|
|
22
|
+
placeholder: listPlaceholder,
|
|
23
|
+
typeOptions: {
|
|
24
|
+
searchListMethod,
|
|
25
|
+
searchable: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'By ID',
|
|
30
|
+
name: 'id',
|
|
31
|
+
type: 'string',
|
|
32
|
+
placeholder: idPlaceholder,
|
|
33
|
+
validation: exports.idModeValidation,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
const returnAllLimitFields = (resource) => [
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Return All',
|
|
40
|
+
name: 'returnAll',
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
43
|
+
displayOptions: {
|
|
44
|
+
show: {
|
|
45
|
+
resource: [resource],
|
|
46
|
+
operation: ['getAll'],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
default: false,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
displayName: 'Limit',
|
|
53
|
+
name: 'limit',
|
|
54
|
+
type: 'number',
|
|
55
|
+
description: 'Max number of results to return',
|
|
56
|
+
typeOptions: { minValue: 1 },
|
|
57
|
+
displayOptions: {
|
|
58
|
+
show: {
|
|
59
|
+
resource: [resource],
|
|
60
|
+
operation: ['getAll'],
|
|
61
|
+
returnAll: [false],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
default: 50,
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
exports.returnAllLimitFields = returnAllLimitFields;
|
|
68
|
+
function multiOptionsFromLoad(displayName, name, loadOptionsMethod, description) {
|
|
69
|
+
return {
|
|
70
|
+
displayName,
|
|
71
|
+
name,
|
|
72
|
+
type: 'multiOptions',
|
|
73
|
+
typeOptions: {
|
|
74
|
+
loadOptionsMethod,
|
|
75
|
+
},
|
|
76
|
+
default: [],
|
|
77
|
+
description,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Custom fields with From list / By Name (listSearch method varies by scope) */
|
|
81
|
+
function customFieldsFixedCollectionWithList(searchListMethod, description = 'Pick a field from your Qwease tenant (or enter technical_name)') {
|
|
82
|
+
return {
|
|
83
|
+
displayName: 'Custom Fields',
|
|
84
|
+
name: 'customFieldsUi',
|
|
85
|
+
type: 'fixedCollection',
|
|
86
|
+
typeOptions: {
|
|
87
|
+
multipleValues: true,
|
|
88
|
+
},
|
|
89
|
+
default: {},
|
|
90
|
+
placeholder: 'Add Custom Field',
|
|
91
|
+
description,
|
|
92
|
+
options: [
|
|
93
|
+
{
|
|
94
|
+
displayName: 'Field',
|
|
95
|
+
name: 'field',
|
|
96
|
+
values: [
|
|
97
|
+
{
|
|
98
|
+
displayName: 'Field',
|
|
99
|
+
name: 'key',
|
|
100
|
+
type: 'resourceLocator',
|
|
101
|
+
default: { mode: 'list', value: '' },
|
|
102
|
+
modes: [
|
|
103
|
+
{
|
|
104
|
+
displayName: 'From List',
|
|
105
|
+
name: 'list',
|
|
106
|
+
type: 'list',
|
|
107
|
+
placeholder: 'Select a field...',
|
|
108
|
+
typeOptions: {
|
|
109
|
+
searchListMethod,
|
|
110
|
+
searchable: true,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
displayName: 'By Name',
|
|
115
|
+
name: 'name',
|
|
116
|
+
type: 'string',
|
|
117
|
+
placeholder: 'Customfield1',
|
|
118
|
+
hint: 'technical_name from Qwease',
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
displayName: 'Field Value',
|
|
124
|
+
name: 'value',
|
|
125
|
+
type: 'resourceLocator',
|
|
126
|
+
default: { mode: 'list', value: '' },
|
|
127
|
+
description: 'For list fields: pick an option. Otherwise switch to By Value and enter text / ID.',
|
|
128
|
+
typeOptions: {
|
|
129
|
+
loadOptionsDependsOn: ['&key', '&key.value'],
|
|
130
|
+
},
|
|
131
|
+
modes: [
|
|
132
|
+
{
|
|
133
|
+
displayName: 'From List',
|
|
134
|
+
name: 'list',
|
|
135
|
+
type: 'list',
|
|
136
|
+
placeholder: 'Select an option...',
|
|
137
|
+
typeOptions: {
|
|
138
|
+
searchListMethod: 'getCustomFieldOptions',
|
|
139
|
+
searchable: true,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
displayName: 'By Value',
|
|
144
|
+
name: 'id',
|
|
145
|
+
type: 'string',
|
|
146
|
+
placeholder: 'Text value or option ID',
|
|
147
|
+
hint: 'Use for non-list fields, or paste an option ID',
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-qwease",
|
|
3
|
+
"version": "0.3.9",
|
|
4
|
+
"description": "n8n community node for the Qwease ITSM API (tickets, users, KB, tasks, webhooks)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://qwease.fr",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Qwease",
|
|
9
|
+
"email": "contact@qwease.fr"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/symna/n8n-nodes-qwease.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"n8n-community-node-package",
|
|
17
|
+
"n8n",
|
|
18
|
+
"qwease",
|
|
19
|
+
"itsm",
|
|
20
|
+
"helpdesk",
|
|
21
|
+
"msp"
|
|
22
|
+
],
|
|
23
|
+
"main": "index.js",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "n8n-node build",
|
|
26
|
+
"dev": "n8n-node dev",
|
|
27
|
+
"lint": "n8n-node lint",
|
|
28
|
+
"release": "n8n-node release"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"n8n": {
|
|
34
|
+
"n8nNodesApiVersion": 1,
|
|
35
|
+
"credentials": [
|
|
36
|
+
"dist/credentials/QweaseApi.credentials.js"
|
|
37
|
+
],
|
|
38
|
+
"nodes": [
|
|
39
|
+
"dist/nodes/Qwease/Qwease.node.js",
|
|
40
|
+
"dist/nodes/Qwease/QweaseTrigger.node.js"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@n8n/node-cli": "^0.23.0",
|
|
45
|
+
"eslint": "^9.39.4",
|
|
46
|
+
"typescript": "^5.8.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"n8n-workflow": "*"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
}
|
|
54
|
+
}
|