n8n-nodes-confirm8 0.15.0 → 0.17.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.
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
export declare class Confirm8AgentTool implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
|
-
/**
|
|
5
|
-
* Tool description for AI Agent
|
|
6
|
-
* This helps the AI understand when and how to use this tool
|
|
7
|
-
*/
|
|
8
|
-
getToolDescription(): IDataObject;
|
|
9
4
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
10
5
|
}
|
|
@@ -10,11 +10,10 @@ class Confirm8AgentTool {
|
|
|
10
10
|
icon: 'file:tool.svg',
|
|
11
11
|
group: ['transform'],
|
|
12
12
|
version: 1,
|
|
13
|
-
description: 'AI Agent tool for Confirm8 API
|
|
13
|
+
description: 'Autonomous AI Agent tool for Confirm8 API',
|
|
14
14
|
defaults: {
|
|
15
15
|
name: 'Confirm8 AI Tool',
|
|
16
16
|
},
|
|
17
|
-
// IMPORTANT: Makes this node usable as an AI Agent Tool
|
|
18
17
|
usableAsTool: true,
|
|
19
18
|
inputs: ['main'],
|
|
20
19
|
outputs: ['main'],
|
|
@@ -36,7 +35,6 @@ class Confirm8AgentTool {
|
|
|
36
35
|
typeOptions: { password: true },
|
|
37
36
|
default: '',
|
|
38
37
|
required: true,
|
|
39
|
-
description: 'Authentication token',
|
|
40
38
|
},
|
|
41
39
|
{
|
|
42
40
|
displayName: 'X-API-DOMAIN',
|
|
@@ -53,153 +51,34 @@ class Confirm8AgentTool {
|
|
|
53
51
|
default: '',
|
|
54
52
|
required: true,
|
|
55
53
|
},
|
|
56
|
-
//
|
|
54
|
+
// Tool parameters (provided by AI)
|
|
57
55
|
{
|
|
58
56
|
displayName: 'Resource',
|
|
59
57
|
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
58
|
type: 'string',
|
|
120
59
|
default: '',
|
|
121
|
-
|
|
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
|
-
},
|
|
140
|
-
],
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Tool description for AI Agent
|
|
145
|
-
* This helps the AI understand when and how to use this tool
|
|
146
|
-
*/
|
|
147
|
-
getToolDescription() {
|
|
148
|
-
return {
|
|
149
|
-
name: 'confirm8_api',
|
|
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.',
|
|
156
|
-
properties: [
|
|
157
|
-
{
|
|
158
|
-
displayName: 'Resource',
|
|
159
|
-
name: 'resource',
|
|
160
|
-
type: 'options',
|
|
161
|
-
required: true,
|
|
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',
|
|
60
|
+
description: 'Resource type',
|
|
174
61
|
},
|
|
175
62
|
{
|
|
176
63
|
displayName: 'Operation',
|
|
177
64
|
name: 'operation',
|
|
178
|
-
type: '
|
|
179
|
-
|
|
180
|
-
|
|
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',
|
|
65
|
+
type: 'string',
|
|
66
|
+
default: '',
|
|
67
|
+
description: 'Operation to perform',
|
|
189
68
|
},
|
|
190
69
|
{
|
|
191
70
|
displayName: 'Record ID',
|
|
192
71
|
name: 'recordId',
|
|
193
72
|
type: 'string',
|
|
194
|
-
|
|
195
|
-
description: 'ID
|
|
73
|
+
default: '',
|
|
74
|
+
description: 'Record ID',
|
|
196
75
|
},
|
|
197
76
|
{
|
|
198
77
|
displayName: 'Data',
|
|
199
|
-
name: '
|
|
200
|
-
type: '
|
|
201
|
-
|
|
202
|
-
description: 'JSON data
|
|
78
|
+
name: 'data',
|
|
79
|
+
type: 'string',
|
|
80
|
+
default: '',
|
|
81
|
+
description: 'JSON data',
|
|
203
82
|
},
|
|
204
83
|
],
|
|
205
84
|
};
|
|
@@ -209,88 +88,138 @@ class Confirm8AgentTool {
|
|
|
209
88
|
const returnData = [];
|
|
210
89
|
for (let i = 0; i < items.length; i++) {
|
|
211
90
|
try {
|
|
212
|
-
// Get API
|
|
91
|
+
// Get API credentials
|
|
213
92
|
const baseUrl = this.getNodeParameter('baseUrl', i);
|
|
214
93
|
const bearerToken = this.getNodeParameter('bearerToken', i);
|
|
215
94
|
const apiDomain = this.getNodeParameter('apiDomain', i);
|
|
216
95
|
const apiKeyToken = this.getNodeParameter('apiKeyToken', i);
|
|
217
|
-
// Get operation parameters
|
|
218
|
-
const resource = this.getNodeParameter('resource', i);
|
|
219
|
-
const operation = this.getNodeParameter('operation', i);
|
|
96
|
+
// Get operation parameters (from AI or manual)
|
|
97
|
+
const resource = this.getNodeParameter('resource', i, '');
|
|
98
|
+
const operation = this.getNodeParameter('operation', i, '');
|
|
220
99
|
const recordId = this.getNodeParameter('recordId', i, '');
|
|
221
|
-
// Parse data
|
|
222
|
-
let
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
100
|
+
// Parse data
|
|
101
|
+
let data = {};
|
|
102
|
+
const dataParam = this.getNodeParameter('data', i, '');
|
|
103
|
+
if (dataParam) {
|
|
104
|
+
try {
|
|
105
|
+
data = JSON.parse(dataParam);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
// If not JSON, treat as empty
|
|
227
109
|
}
|
|
228
110
|
}
|
|
229
|
-
|
|
230
|
-
|
|
111
|
+
if (!resource || !operation) {
|
|
112
|
+
throw new Error('Resource and operation are required');
|
|
231
113
|
}
|
|
232
|
-
// Map
|
|
114
|
+
// Map resources to endpoints
|
|
233
115
|
const resourceMap = {
|
|
234
116
|
user: 'users',
|
|
235
117
|
client: 'clients',
|
|
236
118
|
item: 'items',
|
|
119
|
+
itemType: 'itemTypes',
|
|
237
120
|
task: 'tasks',
|
|
238
121
|
service: 'services',
|
|
239
122
|
product: 'products',
|
|
240
123
|
order: 'wos',
|
|
124
|
+
modality: 'modalities',
|
|
241
125
|
ticket: 'tickets',
|
|
242
126
|
property: 'properties',
|
|
243
127
|
};
|
|
244
|
-
const
|
|
245
|
-
let
|
|
128
|
+
const baseEndpoint = resourceMap[resource] || resource;
|
|
129
|
+
let endpoint = '';
|
|
246
130
|
let method = 'GET';
|
|
247
131
|
let body = {};
|
|
248
|
-
// Build request
|
|
132
|
+
// Build request
|
|
249
133
|
switch (operation) {
|
|
250
134
|
case 'getAll':
|
|
251
|
-
|
|
252
|
-
method = 'GET';
|
|
135
|
+
endpoint = `/${baseEndpoint}`;
|
|
253
136
|
break;
|
|
254
137
|
case 'get':
|
|
255
|
-
if (!recordId)
|
|
256
|
-
throw new Error('
|
|
257
|
-
}
|
|
258
|
-
url = `${baseUrl}/${endpoint}/${recordId}`;
|
|
259
|
-
method = 'GET';
|
|
138
|
+
if (!recordId)
|
|
139
|
+
throw new Error('recordId required for get');
|
|
140
|
+
endpoint = `/${baseEndpoint}/${recordId}`;
|
|
260
141
|
break;
|
|
261
142
|
case 'create':
|
|
262
|
-
|
|
143
|
+
endpoint = `/${baseEndpoint}`;
|
|
263
144
|
method = 'POST';
|
|
264
|
-
body =
|
|
145
|
+
body = data;
|
|
265
146
|
break;
|
|
266
147
|
case 'update':
|
|
267
|
-
if (!recordId)
|
|
268
|
-
throw new Error('
|
|
269
|
-
}
|
|
270
|
-
url = `${baseUrl}/${endpoint}/${recordId}`;
|
|
148
|
+
if (!recordId)
|
|
149
|
+
throw new Error('recordId required for update');
|
|
150
|
+
endpoint = `/${baseEndpoint}/${recordId}`;
|
|
271
151
|
method = 'PUT';
|
|
272
|
-
body =
|
|
152
|
+
body = data;
|
|
273
153
|
break;
|
|
274
154
|
case 'activate':
|
|
275
|
-
if (!recordId)
|
|
276
|
-
throw new Error('
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
resource === 'service' || resource === 'product' || resource === 'order' ? 'PUT' : 'PATCH';
|
|
155
|
+
if (!recordId)
|
|
156
|
+
throw new Error('recordId required for activate');
|
|
157
|
+
endpoint = `/${baseEndpoint}/${recordId}/active`;
|
|
158
|
+
method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
|
|
159
|
+
? 'PUT' : 'PATCH';
|
|
281
160
|
break;
|
|
282
161
|
case 'deactivate':
|
|
283
|
-
if (!recordId)
|
|
284
|
-
throw new Error('
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
162
|
+
if (!recordId)
|
|
163
|
+
throw new Error('recordId required for deactivate');
|
|
164
|
+
endpoint = `/${baseEndpoint}/${recordId}/inactive`;
|
|
165
|
+
method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
|
|
166
|
+
? 'PUT' : 'PATCH';
|
|
167
|
+
break;
|
|
168
|
+
// Special user operations
|
|
169
|
+
case 'getByUsername':
|
|
170
|
+
if (!data.username)
|
|
171
|
+
throw new Error('username required in data');
|
|
172
|
+
endpoint = `/users/${data.username}/user`;
|
|
173
|
+
break;
|
|
174
|
+
case 'getTickets':
|
|
175
|
+
if (!recordId)
|
|
176
|
+
throw new Error('recordId required');
|
|
177
|
+
endpoint = `/users/${recordId}/tickets`;
|
|
178
|
+
break;
|
|
179
|
+
case 'getTasks':
|
|
180
|
+
if (!recordId)
|
|
181
|
+
throw new Error('recordId required');
|
|
182
|
+
endpoint = `/users/${recordId}/tasks`;
|
|
183
|
+
break;
|
|
184
|
+
case 'getPermissions':
|
|
185
|
+
if (!recordId)
|
|
186
|
+
throw new Error('recordId required');
|
|
187
|
+
endpoint = `/users/${recordId}/permissions`;
|
|
188
|
+
break;
|
|
189
|
+
case 'linkTasks':
|
|
190
|
+
endpoint = '/users/tasks';
|
|
191
|
+
method = 'POST';
|
|
192
|
+
body = data;
|
|
193
|
+
break;
|
|
194
|
+
case 'deleteLinkedTasks':
|
|
195
|
+
endpoint = '/users/tasks';
|
|
196
|
+
method = 'DELETE';
|
|
197
|
+
break;
|
|
198
|
+
case 'deleteLinkedTasksByUser':
|
|
199
|
+
if (!data.employeeId)
|
|
200
|
+
throw new Error('employeeId required in data');
|
|
201
|
+
endpoint = `/users/tasks/${data.employeeId}`;
|
|
202
|
+
method = 'DELETE';
|
|
203
|
+
break;
|
|
204
|
+
case 'uploadPhoto':
|
|
205
|
+
if (!recordId)
|
|
206
|
+
throw new Error('recordId required');
|
|
207
|
+
endpoint = `/users/${recordId}/photos`;
|
|
208
|
+
method = 'PATCH';
|
|
209
|
+
body = data;
|
|
210
|
+
break;
|
|
211
|
+
case 'uploadSignature':
|
|
212
|
+
if (!recordId)
|
|
213
|
+
throw new Error('recordId required');
|
|
214
|
+
endpoint = `/users/${recordId}/signatures`;
|
|
215
|
+
method = 'PATCH';
|
|
216
|
+
body = data;
|
|
289
217
|
break;
|
|
290
218
|
default:
|
|
291
219
|
throw new Error(`Unknown operation: ${operation}`);
|
|
292
220
|
}
|
|
293
|
-
// Make
|
|
221
|
+
// Make request
|
|
222
|
+
const url = `${baseUrl}${endpoint}`;
|
|
294
223
|
const options = {
|
|
295
224
|
method,
|
|
296
225
|
uri: url,
|
|
@@ -311,6 +240,7 @@ class Confirm8AgentTool {
|
|
|
311
240
|
success: true,
|
|
312
241
|
operation,
|
|
313
242
|
resource,
|
|
243
|
+
endpoint,
|
|
314
244
|
data: responseData,
|
|
315
245
|
},
|
|
316
246
|
pairedItem: { item: i },
|
|
@@ -321,7 +251,9 @@ class Confirm8AgentTool {
|
|
|
321
251
|
returnData.push({
|
|
322
252
|
json: {
|
|
323
253
|
success: false,
|
|
324
|
-
error: error || 'Unknown error',
|
|
254
|
+
error: error.message || 'Unknown error',
|
|
255
|
+
resource: this.getNodeParameter('resource', i, ''),
|
|
256
|
+
operation: this.getNodeParameter('operation', i, ''),
|
|
325
257
|
},
|
|
326
258
|
pairedItem: { item: i },
|
|
327
259
|
});
|