n8n-nodes-confirm8 0.19.0 → 0.20.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: '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)',
13
+ description: 'AI Agent tool for Confirm8 API with relations and filters support',
14
14
  defaults: {
15
15
  name: 'Confirm8 AI Tool',
16
16
  },
@@ -50,7 +50,7 @@ class Confirm8AgentTool {
50
50
  default: '',
51
51
  required: true,
52
52
  },
53
- // Tool parameters - MUST use exact enum values
53
+ // Tool parameters
54
54
  {
55
55
  displayName: 'Resource',
56
56
  name: 'resource',
@@ -69,7 +69,7 @@ class Confirm8AgentTool {
69
69
  { name: 'Property', value: 'property', description: 'Properties' },
70
70
  ],
71
71
  default: 'user',
72
- description: 'IMPORTANT: Use EXACT value from list',
72
+ description: 'Resource type',
73
73
  },
74
74
  {
75
75
  displayName: 'Operation',
@@ -84,14 +84,14 @@ class Confirm8AgentTool {
84
84
  { name: 'Deactivate', value: 'deactivate', description: 'Deactivate record' },
85
85
  ],
86
86
  default: 'getAll',
87
- description: 'IMPORTANT: Use EXACT value from list',
87
+ description: 'Operation to perform',
88
88
  },
89
89
  {
90
90
  displayName: 'Record ID',
91
91
  name: 'recordId',
92
92
  type: 'string',
93
93
  default: '',
94
- description: 'ID of record (for get/update/activate/deactivate)',
94
+ description: 'ID of record',
95
95
  },
96
96
  {
97
97
  displayName: 'Data',
@@ -100,6 +100,13 @@ class Confirm8AgentTool {
100
100
  default: '',
101
101
  description: 'JSON data for create/update',
102
102
  },
103
+ {
104
+ displayName: 'Filters',
105
+ name: 'filters',
106
+ type: 'string',
107
+ default: '',
108
+ description: 'Filters as JSON object. Example: {"start_date":{"gte":"2025-11-23"},"status":{"eq":"complete"}}',
109
+ },
103
110
  ],
104
111
  };
105
112
  }
@@ -123,104 +130,167 @@ class Confirm8AgentTool {
123
130
  data = JSON.parse(dataParam);
124
131
  }
125
132
  catch (e) {
126
- // Ignore parse errors
133
+ // Ignore
127
134
  }
128
135
  }
129
- // Normalize common variations
136
+ // Parse filters
137
+ let filters = {};
138
+ const filtersParam = this.getNodeParameter('filters', i, '');
139
+ if (filtersParam) {
140
+ try {
141
+ filters = JSON.parse(filtersParam);
142
+ }
143
+ catch (e) {
144
+ // Ignore
145
+ }
146
+ }
147
+ // Normalize variations
130
148
  const resourceMap = {
131
- 'users': 'user', 'usuarios': 'user', 'usuários': 'user', 'employees': 'user', 'funcionários': 'user',
149
+ 'users': 'user', 'usuarios': 'user', 'usuários': 'user', 'employees': 'user',
132
150
  'clients': 'client', 'clientes': 'client', 'customers': 'client',
133
151
  'items': 'item', 'itens': 'item',
134
152
  'itemtypes': 'itemType', 'tipos': 'itemType',
135
153
  'tasks': 'task', 'tarefas': 'task',
136
154
  'services': 'service', 'serviços': 'service', 'servicos': 'service',
137
155
  'products': 'product', 'produtos': 'product',
138
- 'orders': 'order', 'ordens': 'order', 'pedidos': 'order', 'wos': 'order',
156
+ 'orders': 'order', 'ordens': 'order', 'wos': 'order',
139
157
  'modalities': 'modality', 'modalidades': 'modality',
140
158
  'tickets': 'ticket', 'chamados': 'ticket',
141
159
  'properties': 'property', 'propriedades': 'property',
142
160
  };
143
161
  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',
162
+ 'list': 'getAll', 'listar': 'getAll', 'mostrar': 'getAll',
163
+ 'buscar todos': 'getAll', 'busque': 'getAll',
164
+ 'criar': 'create', 'adicionar': 'create',
165
+ 'atualizar': 'update', 'modificar': 'update',
166
+ 'ativar': 'activate', 'desativar': 'deactivate',
152
167
  };
153
- // Normalize
154
168
  resource = resourceMap[resource.toLowerCase().trim()] || resource;
155
169
  operation = operationMap[operation.toLowerCase().trim()] || operation;
156
170
  if (!resource || !operation) {
157
171
  throw new Error('Resource and operation are required');
158
172
  }
159
- // Map to endpoints
160
- const endpointMap = {
161
- user: 'users',
162
- client: 'clients',
163
- item: 'items',
164
- itemType: 'itemTypes',
165
- task: 'tasks',
166
- service: 'services',
167
- product: 'products',
168
- order: 'wos',
169
- modality: 'modalities',
170
- ticket: 'tickets',
171
- property: 'properties',
173
+ // Map to endpoints with relations
174
+ const resourceConfig = {
175
+ user: {
176
+ endpoint: 'users',
177
+ relations: ['clients', 'attachments', 'permissions', 'device', 'employee']
178
+ },
179
+ client: {
180
+ endpoint: 'clients',
181
+ relations: ['wos', 'items', 'employees', 'headquarter', 'files', 'userGroup', 'properties']
182
+ },
183
+ item: {
184
+ endpoint: 'items',
185
+ relations: ['client', 'item_type', 'properties', 'parent', 'children', 'collects', 'wos']
186
+ },
187
+ itemType: {
188
+ endpoint: 'itemTypes',
189
+ relations: ['properties']
190
+ },
191
+ task: {
192
+ endpoint: 'tasks',
193
+ relations: ['itemType', 'activities', 'wos', 'modalities']
194
+ },
195
+ service: {
196
+ endpoint: 'services',
197
+ relations: ['task']
198
+ },
199
+ product: {
200
+ endpoint: 'products',
201
+ relations: []
202
+ },
203
+ order: {
204
+ endpoint: 'wos',
205
+ relations: ['client', 'modalities', 'tasks', 'pivot_tasks', 'products', 'users', 'items', 'tickets', 'services', 'collects', 'attachments']
206
+ },
207
+ modality: {
208
+ endpoint: 'modalities',
209
+ relations: ['tasks']
210
+ },
211
+ ticket: {
212
+ endpoint: 'tickets',
213
+ relations: ['client', 'subject_category', 'category', 'status', 'attachments', 'item', 'owner', 'priority', 'users', 'orders', 'properties']
214
+ },
215
+ property: {
216
+ endpoint: 'properties',
217
+ relations: []
218
+ },
172
219
  };
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`);
220
+ const config = resourceConfig[resource];
221
+ if (!config) {
222
+ throw new Error(`Unknown resource: ${resource}`);
176
223
  }
224
+ const baseEndpoint = config.endpoint;
177
225
  let endpoint = '';
178
226
  let method = 'GET';
179
227
  let body = {};
180
- // Build request
228
+ // Build endpoint based on operation
181
229
  switch (operation) {
182
230
  case 'getAll':
183
- endpoint = `/${baseEndpoint}`;
231
+ endpoint = `/v3/${baseEndpoint}`;
184
232
  break;
185
233
  case 'get':
186
234
  if (!recordId)
187
- throw new Error('recordId required for get operation');
188
- endpoint = `/${baseEndpoint}/${recordId}`;
235
+ throw new Error('recordId required');
236
+ endpoint = `/v3/${baseEndpoint}/${recordId}`;
189
237
  break;
190
238
  case 'create':
191
- endpoint = `/${baseEndpoint}`;
239
+ endpoint = `/v3/${baseEndpoint}`;
192
240
  method = 'POST';
193
241
  body = data;
194
242
  break;
195
243
  case 'update':
196
244
  if (!recordId)
197
- throw new Error('recordId required for update operation');
198
- endpoint = `/${baseEndpoint}/${recordId}`;
245
+ throw new Error('recordId required');
246
+ endpoint = `/v3/${baseEndpoint}/${recordId}`;
199
247
  method = 'PUT';
200
248
  body = data;
201
249
  break;
202
250
  case 'activate':
203
251
  if (!recordId)
204
- throw new Error('recordId required for activate operation');
205
- endpoint = `/${baseEndpoint}/${recordId}/active`;
252
+ throw new Error('recordId required');
253
+ endpoint = `/v3/${baseEndpoint}/${recordId}/active`;
206
254
  method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
207
255
  ? 'PUT' : 'PATCH';
208
256
  break;
209
257
  case 'deactivate':
210
258
  if (!recordId)
211
- throw new Error('recordId required for deactivate operation');
212
- endpoint = `/${baseEndpoint}/${recordId}/inactive`;
259
+ throw new Error('recordId required');
260
+ endpoint = `/v3/${baseEndpoint}/${recordId}/inactive`;
213
261
  method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
214
262
  ? 'PUT' : 'PATCH';
215
263
  break;
216
264
  default:
217
- throw new Error(`Unknown operation: ${operation}. Must be one of: getAll, get, create, update, activate, deactivate`);
265
+ throw new Error(`Unknown operation: ${operation}`);
266
+ }
267
+ // Build query string
268
+ const queryParams = [];
269
+ // Add relations (only for GET operations)
270
+ if (method === 'GET' && config.relations.length > 0) {
271
+ config.relations.forEach(relation => {
272
+ queryParams.push(`relations=${relation}`);
273
+ });
274
+ }
275
+ // Add filters
276
+ if (Object.keys(filters).length > 0) {
277
+ Object.keys(filters).forEach(field => {
278
+ const operators = filters[field];
279
+ Object.keys(operators).forEach(operator => {
280
+ const value = operators[operator];
281
+ queryParams.push(`filters[${field}][${operator}]=${encodeURIComponent(String(value))}`);
282
+ });
283
+ });
284
+ }
285
+ // Construct full URL
286
+ let fullUrl = `${baseUrl}${endpoint}`;
287
+ if (queryParams.length > 0) {
288
+ fullUrl += '?' + queryParams.join('&');
218
289
  }
219
290
  // Make request
220
- const url = `${baseUrl}${endpoint}`;
221
291
  const options = {
222
292
  method,
223
- uri: url,
293
+ uri: fullUrl,
224
294
  headers: {
225
295
  'Authorization': `Bearer ${bearerToken}`,
226
296
  'X-API-DOMAIN': apiDomain,
@@ -238,13 +308,10 @@ class Confirm8AgentTool {
238
308
  success: true,
239
309
  operation,
240
310
  resource,
241
- normalized: {
242
- originalResource: this.getNodeParameter('resource', i, ''),
243
- originalOperation: this.getNodeParameter('operation', i, ''),
244
- normalizedResource: resource,
245
- normalizedOperation: operation,
246
- },
247
311
  endpoint,
312
+ fullUrl,
313
+ relations: config.relations,
314
+ filters: filters,
248
315
  method,
249
316
  data: responseData,
250
317
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-confirm8",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Simple n8n node for Confirm8 API - no credentials needed",
5
5
  "license": "MIT",
6
6
  "author": "Bill Hebert",