n8n-nodes-confirm8 0.30.0 → 0.31.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.
|
@@ -2,8 +2,8 @@ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription,
|
|
|
2
2
|
export declare class Confirm8AgentTool implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Tool description for AI Agent
|
|
6
|
+
* This helps the AI understand when and how to use this tool
|
|
7
7
|
*/
|
|
8
8
|
getToolDescription(): IDataObject;
|
|
9
9
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
@@ -10,16 +10,16 @@ class Confirm8AgentTool {
|
|
|
10
10
|
icon: 'file:tool.svg',
|
|
11
11
|
group: ['transform'],
|
|
12
12
|
version: 1,
|
|
13
|
-
description: '
|
|
13
|
+
description: 'AI Agent tool for Confirm8 API - Use to fetch, create, update data from Confirm8',
|
|
14
14
|
defaults: {
|
|
15
15
|
name: 'Confirm8 AI Tool',
|
|
16
16
|
},
|
|
17
|
-
//
|
|
17
|
+
// IMPORTANT: Makes this node usable as an AI Agent Tool
|
|
18
18
|
usableAsTool: true,
|
|
19
19
|
inputs: ['main'],
|
|
20
20
|
outputs: ['main'],
|
|
21
21
|
properties: [
|
|
22
|
-
//
|
|
22
|
+
// API Configuration
|
|
23
23
|
{
|
|
24
24
|
displayName: 'Base URL',
|
|
25
25
|
name: 'baseUrl',
|
|
@@ -53,82 +53,153 @@ class Confirm8AgentTool {
|
|
|
53
53
|
default: '',
|
|
54
54
|
required: true,
|
|
55
55
|
},
|
|
56
|
+
// Operation Configuration
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Resource',
|
|
59
|
+
name: 'resource',
|
|
60
|
+
type: 'options',
|
|
61
|
+
noDataExpression: true,
|
|
62
|
+
options: [
|
|
63
|
+
{ name: 'User', value: 'user', description: 'Operations with users/employees' },
|
|
64
|
+
{ name: 'Client', value: 'client', description: 'Operations with clients/customers' },
|
|
65
|
+
{ name: 'Item', value: 'item', description: 'Operations with items' },
|
|
66
|
+
{ name: 'Task', value: 'task', description: 'Operations with tasks/checklists' },
|
|
67
|
+
{ name: 'Service', value: 'service', description: 'Operations with services' },
|
|
68
|
+
{ name: 'Product', value: 'product', description: 'Operations with products' },
|
|
69
|
+
{ name: 'Order', value: 'order', description: 'Operations with work orders' },
|
|
70
|
+
{ name: 'Ticket', value: 'ticket', description: 'Operations with tickets' },
|
|
71
|
+
{ name: 'Property', value: 'property', description: 'Operations with properties' },
|
|
72
|
+
],
|
|
73
|
+
default: 'user',
|
|
74
|
+
description: 'Type of resource to interact with',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
displayName: 'Operation',
|
|
78
|
+
name: 'operation',
|
|
79
|
+
type: 'options',
|
|
80
|
+
noDataExpression: true,
|
|
81
|
+
options: [
|
|
82
|
+
{
|
|
83
|
+
name: 'Get',
|
|
84
|
+
value: 'get',
|
|
85
|
+
description: 'Fetch a single record by ID'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'Get All',
|
|
89
|
+
value: 'getAll',
|
|
90
|
+
description: 'Fetch all records or list records'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Create',
|
|
94
|
+
value: 'create',
|
|
95
|
+
description: 'Create a new record'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'Update',
|
|
99
|
+
value: 'update',
|
|
100
|
+
description: 'Update an existing record'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'Activate',
|
|
104
|
+
value: 'activate',
|
|
105
|
+
description: 'Activate/enable a record'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'Deactivate',
|
|
109
|
+
value: 'deactivate',
|
|
110
|
+
description: 'Deactivate/disable a record'
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
default: 'getAll',
|
|
114
|
+
description: 'Operation to perform',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Record ID',
|
|
118
|
+
name: 'recordId',
|
|
119
|
+
type: 'string',
|
|
120
|
+
default: '',
|
|
121
|
+
displayOptions: {
|
|
122
|
+
show: {
|
|
123
|
+
operation: ['get', 'update', 'activate', 'deactivate'],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
description: 'ID of the record to fetch or modify',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
displayName: 'Data (JSON)',
|
|
130
|
+
name: 'dataJson',
|
|
131
|
+
type: 'json',
|
|
132
|
+
default: '{}',
|
|
133
|
+
displayOptions: {
|
|
134
|
+
show: {
|
|
135
|
+
operation: ['create', 'update'],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
description: 'Data to send in the request body as JSON',
|
|
139
|
+
},
|
|
56
140
|
],
|
|
57
141
|
};
|
|
58
142
|
}
|
|
59
143
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
144
|
+
* Tool description for AI Agent
|
|
145
|
+
* This helps the AI understand when and how to use this tool
|
|
62
146
|
*/
|
|
63
147
|
getToolDescription() {
|
|
64
148
|
return {
|
|
65
149
|
name: 'confirm8_api',
|
|
66
|
-
description: '
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'- itemType (item type categories)\n' +
|
|
73
|
-
'- task (tasks/checklists)\n' +
|
|
74
|
-
'- service (services)\n' +
|
|
75
|
-
'- product (products/insumos)\n' +
|
|
76
|
-
'- order (work orders/WOS)\n' +
|
|
77
|
-
'- modality (order modalities)\n' +
|
|
78
|
-
'- ticket (tickets/occurrences)\n' +
|
|
79
|
-
'- property (properties)\n' +
|
|
80
|
-
'\n**Available Operations:**\n' +
|
|
81
|
-
'- getAll: List all records (no ID needed)\n' +
|
|
82
|
-
'- get: Get single record (requires recordId)\n' +
|
|
83
|
-
'- create: Create new record (requires data)\n' +
|
|
84
|
-
'- update: Update existing record (requires recordId and data)\n' +
|
|
85
|
-
'- activate: Activate/enable record (requires recordId)\n' +
|
|
86
|
-
'- deactivate: Deactivate/disable record (requires recordId)\n' +
|
|
87
|
-
'\n**Special User Operations:**\n' +
|
|
88
|
-
'- getByUsername: Get user by username (requires username in data)\n' +
|
|
89
|
-
'- getTickets: Get user tickets (requires recordId)\n' +
|
|
90
|
-
'- getTasks: Get user tasks (requires recordId)\n' +
|
|
91
|
-
'- getPermissions: Get user permissions (requires recordId)\n' +
|
|
92
|
-
'- linkTasks: Link tasks to user (requires data with userId and taskIds)\n' +
|
|
93
|
-
'- deleteLinkedTasks: Delete all linked tasks\n' +
|
|
94
|
-
'- deleteLinkedTasksByUser: Delete tasks by user (requires employeeId in data)\n' +
|
|
95
|
-
'- uploadPhoto: Upload user photo (requires recordId and photo data)\n' +
|
|
96
|
-
'- uploadSignature: Upload user signature (requires recordId and signature data)\n' +
|
|
97
|
-
'\n**Examples:**\n' +
|
|
98
|
-
'- List all users: resource="user", operation="getAll"\n' +
|
|
99
|
-
'- Get client 123: resource="client", operation="get", recordId="123"\n' +
|
|
100
|
-
'- Create product: resource="product", operation="create", data={"name":"Product X","price":99.99}\n' +
|
|
101
|
-
'- Update task: resource="task", operation="update", recordId="456", data={"status":"completed"}\n' +
|
|
102
|
-
'- Activate user: resource="user", operation="activate", recordId="789"\n' +
|
|
103
|
-
'- Get user tickets: resource="user", operation="getTickets", recordId="123"',
|
|
150
|
+
description: 'Use this tool to interact with the Confirm8 API. ' +
|
|
151
|
+
'It can fetch, create, update, activate, or deactivate records in the Confirm8 system. ' +
|
|
152
|
+
'Available resources: users, clients, items, tasks, services, products, orders, tickets, properties. ' +
|
|
153
|
+
'Use "Get All" to list records, "Get" to fetch a specific record by ID, ' +
|
|
154
|
+
'"Create" to add new records, "Update" to modify existing records, ' +
|
|
155
|
+
'"Activate/Deactivate" to enable or disable records.',
|
|
104
156
|
properties: [
|
|
105
157
|
{
|
|
106
158
|
displayName: 'Resource',
|
|
107
159
|
name: 'resource',
|
|
108
|
-
type: '
|
|
160
|
+
type: 'options',
|
|
109
161
|
required: true,
|
|
110
|
-
|
|
162
|
+
options: [
|
|
163
|
+
{ name: 'User', value: 'user' },
|
|
164
|
+
{ name: 'Client', value: 'client' },
|
|
165
|
+
{ name: 'Item', value: 'item' },
|
|
166
|
+
{ name: 'Task', value: 'task' },
|
|
167
|
+
{ name: 'Service', value: 'service' },
|
|
168
|
+
{ name: 'Product', value: 'product' },
|
|
169
|
+
{ name: 'Order', value: 'order' },
|
|
170
|
+
{ name: 'Ticket', value: 'ticket' },
|
|
171
|
+
{ name: 'Property', value: 'property' },
|
|
172
|
+
],
|
|
173
|
+
description: 'Type of resource: user, client, item, task, service, product, order, ticket, or property',
|
|
111
174
|
},
|
|
112
175
|
{
|
|
113
176
|
displayName: 'Operation',
|
|
114
177
|
name: 'operation',
|
|
115
|
-
type: '
|
|
178
|
+
type: 'options',
|
|
116
179
|
required: true,
|
|
117
|
-
|
|
180
|
+
options: [
|
|
181
|
+
{ name: 'Get', value: 'get' },
|
|
182
|
+
{ name: 'Get All', value: 'getAll' },
|
|
183
|
+
{ name: 'Create', value: 'create' },
|
|
184
|
+
{ name: 'Update', value: 'update' },
|
|
185
|
+
{ name: 'Activate', value: 'activate' },
|
|
186
|
+
{ name: 'Deactivate', value: 'deactivate' },
|
|
187
|
+
],
|
|
188
|
+
description: 'Operation: get (single), getAll (list), create, update, activate, deactivate',
|
|
118
189
|
},
|
|
119
190
|
{
|
|
120
191
|
displayName: 'Record ID',
|
|
121
192
|
name: 'recordId',
|
|
122
193
|
type: 'string',
|
|
123
194
|
required: false,
|
|
124
|
-
description: 'ID of the record (required for get, update, activate, deactivate
|
|
195
|
+
description: 'ID of the record (required for get, update, activate, deactivate)',
|
|
125
196
|
},
|
|
126
197
|
{
|
|
127
198
|
displayName: 'Data',
|
|
128
|
-
name: '
|
|
199
|
+
name: 'dataJson',
|
|
129
200
|
type: 'json',
|
|
130
201
|
required: false,
|
|
131
|
-
description: 'JSON data for create/update operations
|
|
202
|
+
description: 'JSON data for create/update operations. Example: {"name":"John","email":"john@example.com"}',
|
|
132
203
|
},
|
|
133
204
|
],
|
|
134
205
|
};
|
|
@@ -138,167 +209,88 @@ class Confirm8AgentTool {
|
|
|
138
209
|
const returnData = [];
|
|
139
210
|
for (let i = 0; i < items.length; i++) {
|
|
140
211
|
try {
|
|
141
|
-
// Get API configuration
|
|
212
|
+
// Get API configuration
|
|
142
213
|
const baseUrl = this.getNodeParameter('baseUrl', i);
|
|
143
214
|
const bearerToken = this.getNodeParameter('bearerToken', i);
|
|
144
215
|
const apiDomain = this.getNodeParameter('apiDomain', i);
|
|
145
216
|
const apiKeyToken = this.getNodeParameter('apiKeyToken', i);
|
|
146
|
-
// Get operation parameters
|
|
217
|
+
// Get operation parameters
|
|
147
218
|
const resource = this.getNodeParameter('resource', i);
|
|
148
219
|
const operation = this.getNodeParameter('operation', i);
|
|
149
220
|
const recordId = this.getNodeParameter('recordId', i, '');
|
|
150
|
-
// Parse data
|
|
151
|
-
let
|
|
221
|
+
// Parse data JSON
|
|
222
|
+
let dataJson = {};
|
|
152
223
|
try {
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
data = JSON.parse(dataParam);
|
|
157
|
-
}
|
|
158
|
-
else if (typeof dataParam === 'object') {
|
|
159
|
-
data = dataParam;
|
|
160
|
-
}
|
|
224
|
+
const dataJsonStr = this.getNodeParameter('dataJson', i, '{}');
|
|
225
|
+
if (dataJsonStr && dataJsonStr.trim() !== '{}') {
|
|
226
|
+
dataJson = JSON.parse(dataJsonStr);
|
|
161
227
|
}
|
|
162
228
|
}
|
|
163
229
|
catch (e) {
|
|
164
230
|
// Data is optional
|
|
165
231
|
}
|
|
166
|
-
// Map resource to
|
|
232
|
+
// Map resource to endpoint
|
|
167
233
|
const resourceMap = {
|
|
168
234
|
user: 'users',
|
|
169
235
|
client: 'clients',
|
|
170
236
|
item: 'items',
|
|
171
|
-
itemType: 'itemTypes',
|
|
172
237
|
task: 'tasks',
|
|
173
238
|
service: 'services',
|
|
174
239
|
product: 'products',
|
|
175
240
|
order: 'wos',
|
|
176
|
-
modality: 'modalities',
|
|
177
241
|
ticket: 'tickets',
|
|
178
242
|
property: 'properties',
|
|
179
243
|
};
|
|
180
|
-
const
|
|
181
|
-
let
|
|
244
|
+
const endpoint = resourceMap[resource] || resource;
|
|
245
|
+
let url = '';
|
|
182
246
|
let method = 'GET';
|
|
183
247
|
let body = {};
|
|
184
248
|
// Build request based on operation
|
|
185
249
|
switch (operation) {
|
|
186
250
|
case 'getAll':
|
|
187
|
-
|
|
251
|
+
url = `${baseUrl}/${endpoint}`;
|
|
188
252
|
method = 'GET';
|
|
189
253
|
break;
|
|
190
254
|
case 'get':
|
|
191
255
|
if (!recordId) {
|
|
192
|
-
throw new Error('
|
|
256
|
+
throw new Error('Record ID is required for Get operation');
|
|
193
257
|
}
|
|
194
|
-
|
|
258
|
+
url = `${baseUrl}/${endpoint}/${recordId}`;
|
|
195
259
|
method = 'GET';
|
|
196
260
|
break;
|
|
197
261
|
case 'create':
|
|
198
|
-
|
|
262
|
+
url = `${baseUrl}/${endpoint}`;
|
|
199
263
|
method = 'POST';
|
|
200
|
-
body =
|
|
264
|
+
body = dataJson;
|
|
201
265
|
break;
|
|
202
266
|
case 'update':
|
|
203
267
|
if (!recordId) {
|
|
204
|
-
throw new Error('
|
|
268
|
+
throw new Error('Record ID is required for Update operation');
|
|
205
269
|
}
|
|
206
|
-
|
|
270
|
+
url = `${baseUrl}/${endpoint}/${recordId}`;
|
|
207
271
|
method = 'PUT';
|
|
208
|
-
body =
|
|
272
|
+
body = dataJson;
|
|
209
273
|
break;
|
|
210
274
|
case 'activate':
|
|
211
275
|
if (!recordId) {
|
|
212
|
-
throw new Error('
|
|
213
|
-
}
|
|
214
|
-
endpoint = `/${baseEndpoint}/${recordId}/active`;
|
|
215
|
-
// Different resources use different methods
|
|
216
|
-
if (['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)) {
|
|
217
|
-
method = 'PUT';
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
method = 'PATCH';
|
|
276
|
+
throw new Error('Record ID is required for Activate operation');
|
|
221
277
|
}
|
|
278
|
+
url = `${baseUrl}/${endpoint}/${recordId}/active`;
|
|
279
|
+
method = resource === 'client' || resource === 'item' || resource === 'task' ||
|
|
280
|
+
resource === 'service' || resource === 'product' || resource === 'order' ? 'PUT' : 'PATCH';
|
|
222
281
|
break;
|
|
223
282
|
case 'deactivate':
|
|
224
283
|
if (!recordId) {
|
|
225
|
-
throw new Error('
|
|
226
|
-
}
|
|
227
|
-
endpoint = `/${baseEndpoint}/${recordId}/inactive`;
|
|
228
|
-
// Different resources use different methods
|
|
229
|
-
if (['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)) {
|
|
230
|
-
method = 'PUT';
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
method = 'PATCH';
|
|
234
|
-
}
|
|
235
|
-
break;
|
|
236
|
-
// Special User Operations
|
|
237
|
-
case 'getByUsername':
|
|
238
|
-
if (!data.username) {
|
|
239
|
-
throw new Error('username is required in data for getByUsername operation');
|
|
240
|
-
}
|
|
241
|
-
endpoint = `/users/${data.username}/user`;
|
|
242
|
-
method = 'GET';
|
|
243
|
-
break;
|
|
244
|
-
case 'getTickets':
|
|
245
|
-
if (!recordId) {
|
|
246
|
-
throw new Error('recordId is required for getTickets operation');
|
|
247
|
-
}
|
|
248
|
-
endpoint = `/users/${recordId}/tickets`;
|
|
249
|
-
method = 'GET';
|
|
250
|
-
break;
|
|
251
|
-
case 'getTasks':
|
|
252
|
-
if (!recordId) {
|
|
253
|
-
throw new Error('recordId is required for getTasks operation');
|
|
254
|
-
}
|
|
255
|
-
endpoint = `/users/${recordId}/tasks`;
|
|
256
|
-
method = 'GET';
|
|
257
|
-
break;
|
|
258
|
-
case 'getPermissions':
|
|
259
|
-
if (!recordId) {
|
|
260
|
-
throw new Error('recordId is required for getPermissions operation');
|
|
261
|
-
}
|
|
262
|
-
endpoint = `/users/${recordId}/permissions`;
|
|
263
|
-
method = 'GET';
|
|
264
|
-
break;
|
|
265
|
-
case 'linkTasks':
|
|
266
|
-
endpoint = '/users/tasks';
|
|
267
|
-
method = 'POST';
|
|
268
|
-
body = data;
|
|
269
|
-
break;
|
|
270
|
-
case 'deleteLinkedTasks':
|
|
271
|
-
endpoint = '/users/tasks';
|
|
272
|
-
method = 'DELETE';
|
|
273
|
-
break;
|
|
274
|
-
case 'deleteLinkedTasksByUser':
|
|
275
|
-
if (!data.employeeId) {
|
|
276
|
-
throw new Error('employeeId is required in data for deleteLinkedTasksByUser operation');
|
|
277
|
-
}
|
|
278
|
-
endpoint = `/users/tasks/${data.employeeId}`;
|
|
279
|
-
method = 'DELETE';
|
|
280
|
-
break;
|
|
281
|
-
case 'uploadPhoto':
|
|
282
|
-
if (!recordId) {
|
|
283
|
-
throw new Error('recordId is required for uploadPhoto operation');
|
|
284
|
-
}
|
|
285
|
-
endpoint = `/users/${recordId}/photos`;
|
|
286
|
-
method = 'PATCH';
|
|
287
|
-
body = data;
|
|
288
|
-
break;
|
|
289
|
-
case 'uploadSignature':
|
|
290
|
-
if (!recordId) {
|
|
291
|
-
throw new Error('recordId is required for uploadSignature operation');
|
|
284
|
+
throw new Error('Record ID is required for Deactivate operation');
|
|
292
285
|
}
|
|
293
|
-
|
|
294
|
-
method = '
|
|
295
|
-
|
|
286
|
+
url = `${baseUrl}/${endpoint}/${recordId}/inactive`;
|
|
287
|
+
method = resource === 'client' || resource === 'item' || resource === 'task' ||
|
|
288
|
+
resource === 'service' || resource === 'product' || resource === 'order' ? 'PUT' : 'PATCH';
|
|
296
289
|
break;
|
|
297
290
|
default:
|
|
298
291
|
throw new Error(`Unknown operation: ${operation}`);
|
|
299
292
|
}
|
|
300
293
|
// Make HTTP request
|
|
301
|
-
const url = `${baseUrl}${endpoint}`;
|
|
302
294
|
const options = {
|
|
303
295
|
method,
|
|
304
296
|
uri: url,
|
|
@@ -319,7 +311,6 @@ class Confirm8AgentTool {
|
|
|
319
311
|
success: true,
|
|
320
312
|
operation,
|
|
321
313
|
resource,
|
|
322
|
-
endpoint,
|
|
323
314
|
data: responseData,
|
|
324
315
|
},
|
|
325
316
|
pairedItem: { item: i },
|
|
@@ -331,8 +322,6 @@ class Confirm8AgentTool {
|
|
|
331
322
|
json: {
|
|
332
323
|
success: false,
|
|
333
324
|
error: error || 'Unknown error',
|
|
334
|
-
resource: this.getNodeParameter('resource', i, ''),
|
|
335
|
-
operation: this.getNodeParameter('operation', i, ''),
|
|
336
325
|
},
|
|
337
326
|
pairedItem: { item: i },
|
|
338
327
|
});
|