n8n-nodes-confirm8 0.17.0 → 0.19.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.
|
@@ -10,7 +10,7 @@ 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 EXACT enum values: resource (user/client/item/task/service/product/order/ticket/property) and operation (getAll/get/create/update/activate/deactivate)',
|
|
14
14
|
defaults: {
|
|
15
15
|
name: 'Confirm8 AI Tool',
|
|
16
16
|
},
|
|
@@ -26,7 +26,6 @@ class Confirm8AgentTool {
|
|
|
26
26
|
default: '',
|
|
27
27
|
placeholder: 'https://api.confirm8.com',
|
|
28
28
|
required: true,
|
|
29
|
-
description: 'Base URL of Confirm8 API',
|
|
30
29
|
},
|
|
31
30
|
{
|
|
32
31
|
displayName: 'Bearer Token',
|
|
@@ -51,34 +50,55 @@ class Confirm8AgentTool {
|
|
|
51
50
|
default: '',
|
|
52
51
|
required: true,
|
|
53
52
|
},
|
|
54
|
-
// Tool parameters
|
|
53
|
+
// Tool parameters - MUST use exact enum values
|
|
55
54
|
{
|
|
56
55
|
displayName: 'Resource',
|
|
57
56
|
name: 'resource',
|
|
58
|
-
type: '
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
type: 'options',
|
|
58
|
+
options: [
|
|
59
|
+
{ name: 'User', value: 'user', description: 'Users/employees' },
|
|
60
|
+
{ name: 'Client', value: 'client', description: 'Clients/customers' },
|
|
61
|
+
{ name: 'Item', value: 'item', description: 'Items/inventory' },
|
|
62
|
+
{ name: 'Item Type', value: 'itemType', description: 'Item categories' },
|
|
63
|
+
{ name: 'Task', value: 'task', description: 'Tasks/checklists' },
|
|
64
|
+
{ name: 'Service', value: 'service', description: 'Services' },
|
|
65
|
+
{ name: 'Product', value: 'product', description: 'Products' },
|
|
66
|
+
{ name: 'Order', value: 'order', description: 'Work orders' },
|
|
67
|
+
{ name: 'Modality', value: 'modality', description: 'Order modalities' },
|
|
68
|
+
{ name: 'Ticket', value: 'ticket', description: 'Tickets' },
|
|
69
|
+
{ name: 'Property', value: 'property', description: 'Properties' },
|
|
70
|
+
],
|
|
71
|
+
default: 'user',
|
|
72
|
+
description: 'IMPORTANT: Use EXACT value from list',
|
|
61
73
|
},
|
|
62
74
|
{
|
|
63
75
|
displayName: 'Operation',
|
|
64
76
|
name: 'operation',
|
|
65
|
-
type: '
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
type: 'options',
|
|
78
|
+
options: [
|
|
79
|
+
{ name: 'Get All', value: 'getAll', description: 'List all records' },
|
|
80
|
+
{ name: 'Get', value: 'get', description: 'Get single record' },
|
|
81
|
+
{ name: 'Create', value: 'create', description: 'Create new record' },
|
|
82
|
+
{ name: 'Update', value: 'update', description: 'Update record' },
|
|
83
|
+
{ name: 'Activate', value: 'activate', description: 'Activate record' },
|
|
84
|
+
{ name: 'Deactivate', value: 'deactivate', description: 'Deactivate record' },
|
|
85
|
+
],
|
|
86
|
+
default: 'getAll',
|
|
87
|
+
description: 'IMPORTANT: Use EXACT value from list',
|
|
68
88
|
},
|
|
69
89
|
{
|
|
70
90
|
displayName: 'Record ID',
|
|
71
91
|
name: 'recordId',
|
|
72
92
|
type: 'string',
|
|
73
93
|
default: '',
|
|
74
|
-
description: '
|
|
94
|
+
description: 'ID of record (for get/update/activate/deactivate)',
|
|
75
95
|
},
|
|
76
96
|
{
|
|
77
97
|
displayName: 'Data',
|
|
78
98
|
name: 'data',
|
|
79
99
|
type: 'string',
|
|
80
100
|
default: '',
|
|
81
|
-
description: 'JSON data',
|
|
101
|
+
description: 'JSON data for create/update',
|
|
82
102
|
},
|
|
83
103
|
],
|
|
84
104
|
};
|
|
@@ -88,14 +108,12 @@ class Confirm8AgentTool {
|
|
|
88
108
|
const returnData = [];
|
|
89
109
|
for (let i = 0; i < items.length; i++) {
|
|
90
110
|
try {
|
|
91
|
-
// Get API credentials
|
|
92
111
|
const baseUrl = this.getNodeParameter('baseUrl', i);
|
|
93
112
|
const bearerToken = this.getNodeParameter('bearerToken', i);
|
|
94
113
|
const apiDomain = this.getNodeParameter('apiDomain', i);
|
|
95
114
|
const apiKeyToken = this.getNodeParameter('apiKeyToken', i);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const operation = this.getNodeParameter('operation', i, '');
|
|
115
|
+
let resource = this.getNodeParameter('resource', i, '');
|
|
116
|
+
let operation = this.getNodeParameter('operation', i, '');
|
|
99
117
|
const recordId = this.getNodeParameter('recordId', i, '');
|
|
100
118
|
// Parse data
|
|
101
119
|
let data = {};
|
|
@@ -105,14 +123,41 @@ class Confirm8AgentTool {
|
|
|
105
123
|
data = JSON.parse(dataParam);
|
|
106
124
|
}
|
|
107
125
|
catch (e) {
|
|
108
|
-
//
|
|
126
|
+
// Ignore parse errors
|
|
109
127
|
}
|
|
110
128
|
}
|
|
129
|
+
// Normalize common variations
|
|
130
|
+
const resourceMap = {
|
|
131
|
+
'users': 'user', 'usuarios': 'user', 'usuários': 'user', 'employees': 'user', 'funcionários': 'user',
|
|
132
|
+
'clients': 'client', 'clientes': 'client', 'customers': 'client',
|
|
133
|
+
'items': 'item', 'itens': 'item',
|
|
134
|
+
'itemtypes': 'itemType', 'tipos': 'itemType',
|
|
135
|
+
'tasks': 'task', 'tarefas': 'task',
|
|
136
|
+
'services': 'service', 'serviços': 'service', 'servicos': 'service',
|
|
137
|
+
'products': 'product', 'produtos': 'product',
|
|
138
|
+
'orders': 'order', 'ordens': 'order', 'pedidos': 'order', 'wos': 'order',
|
|
139
|
+
'modalities': 'modality', 'modalidades': 'modality',
|
|
140
|
+
'tickets': 'ticket', 'chamados': 'ticket',
|
|
141
|
+
'properties': 'property', 'propriedades': 'property',
|
|
142
|
+
};
|
|
143
|
+
const operationMap = {
|
|
144
|
+
'list': 'getAll', 'listar': 'getAll', 'mostrar': 'getAll', 'show': 'getAll',
|
|
145
|
+
'buscar': 'getAll', 'busque': 'getAll', 'buscar todos': 'getAll', 'get all': 'getAll',
|
|
146
|
+
'show all': 'getAll', 'list all': 'getAll', 'todos': 'getAll',
|
|
147
|
+
'obter': 'get', 'pegar': 'get',
|
|
148
|
+
'criar': 'create', 'adicionar': 'create', 'add': 'create', 'novo': 'create', 'new': 'create',
|
|
149
|
+
'atualizar': 'update', 'modificar': 'update', 'modify': 'update', 'editar': 'update',
|
|
150
|
+
'ativar': 'activate', 'enable': 'activate', 'habilitar': 'activate',
|
|
151
|
+
'desativar': 'deactivate', 'disable': 'deactivate', 'desabilitar': 'deactivate',
|
|
152
|
+
};
|
|
153
|
+
// Normalize
|
|
154
|
+
resource = resourceMap[resource.toLowerCase().trim()] || resource;
|
|
155
|
+
operation = operationMap[operation.toLowerCase().trim()] || operation;
|
|
111
156
|
if (!resource || !operation) {
|
|
112
157
|
throw new Error('Resource and operation are required');
|
|
113
158
|
}
|
|
114
|
-
// Map
|
|
115
|
-
const
|
|
159
|
+
// Map to endpoints
|
|
160
|
+
const endpointMap = {
|
|
116
161
|
user: 'users',
|
|
117
162
|
client: 'clients',
|
|
118
163
|
item: 'items',
|
|
@@ -125,7 +170,10 @@ class Confirm8AgentTool {
|
|
|
125
170
|
ticket: 'tickets',
|
|
126
171
|
property: 'properties',
|
|
127
172
|
};
|
|
128
|
-
const baseEndpoint =
|
|
173
|
+
const baseEndpoint = endpointMap[resource];
|
|
174
|
+
if (!baseEndpoint) {
|
|
175
|
+
throw new Error(`Unknown resource: ${resource}. Must be one of: user, client, item, itemType, task, service, product, order, modality, ticket, property`);
|
|
176
|
+
}
|
|
129
177
|
let endpoint = '';
|
|
130
178
|
let method = 'GET';
|
|
131
179
|
let body = {};
|
|
@@ -136,7 +184,7 @@ class Confirm8AgentTool {
|
|
|
136
184
|
break;
|
|
137
185
|
case 'get':
|
|
138
186
|
if (!recordId)
|
|
139
|
-
throw new Error('recordId required for get');
|
|
187
|
+
throw new Error('recordId required for get operation');
|
|
140
188
|
endpoint = `/${baseEndpoint}/${recordId}`;
|
|
141
189
|
break;
|
|
142
190
|
case 'create':
|
|
@@ -146,77 +194,27 @@ class Confirm8AgentTool {
|
|
|
146
194
|
break;
|
|
147
195
|
case 'update':
|
|
148
196
|
if (!recordId)
|
|
149
|
-
throw new Error('recordId required for update');
|
|
197
|
+
throw new Error('recordId required for update operation');
|
|
150
198
|
endpoint = `/${baseEndpoint}/${recordId}`;
|
|
151
199
|
method = 'PUT';
|
|
152
200
|
body = data;
|
|
153
201
|
break;
|
|
154
202
|
case 'activate':
|
|
155
203
|
if (!recordId)
|
|
156
|
-
throw new Error('recordId required for activate');
|
|
204
|
+
throw new Error('recordId required for activate operation');
|
|
157
205
|
endpoint = `/${baseEndpoint}/${recordId}/active`;
|
|
158
206
|
method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
|
|
159
207
|
? 'PUT' : 'PATCH';
|
|
160
208
|
break;
|
|
161
209
|
case 'deactivate':
|
|
162
210
|
if (!recordId)
|
|
163
|
-
throw new Error('recordId required for deactivate');
|
|
211
|
+
throw new Error('recordId required for deactivate operation');
|
|
164
212
|
endpoint = `/${baseEndpoint}/${recordId}/inactive`;
|
|
165
213
|
method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
|
|
166
214
|
? 'PUT' : 'PATCH';
|
|
167
215
|
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;
|
|
217
|
-
break;
|
|
218
216
|
default:
|
|
219
|
-
throw new Error(`Unknown operation: ${operation}`);
|
|
217
|
+
throw new Error(`Unknown operation: ${operation}. Must be one of: getAll, get, create, update, activate, deactivate`);
|
|
220
218
|
}
|
|
221
219
|
// Make request
|
|
222
220
|
const url = `${baseUrl}${endpoint}`;
|
|
@@ -240,7 +238,14 @@ class Confirm8AgentTool {
|
|
|
240
238
|
success: true,
|
|
241
239
|
operation,
|
|
242
240
|
resource,
|
|
241
|
+
normalized: {
|
|
242
|
+
originalResource: this.getNodeParameter('resource', i, ''),
|
|
243
|
+
originalOperation: this.getNodeParameter('operation', i, ''),
|
|
244
|
+
normalizedResource: resource,
|
|
245
|
+
normalizedOperation: operation,
|
|
246
|
+
},
|
|
243
247
|
endpoint,
|
|
248
|
+
method,
|
|
244
249
|
data: responseData,
|
|
245
250
|
},
|
|
246
251
|
pairedItem: { item: i },
|
|
@@ -252,8 +257,6 @@ class Confirm8AgentTool {
|
|
|
252
257
|
json: {
|
|
253
258
|
success: false,
|
|
254
259
|
error: error.message || 'Unknown error',
|
|
255
|
-
resource: this.getNodeParameter('resource', i, ''),
|
|
256
|
-
operation: this.getNodeParameter('operation', i, ''),
|
|
257
260
|
},
|
|
258
261
|
pairedItem: { item: i },
|
|
259
262
|
});
|