n8n-nodes-confirm8 0.16.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, IDataObject } from 'n8n-workflow';
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
2
  export declare class Confirm8AgentTool implements INodeType {
3
3
  description: INodeTypeDescription;
4
- /**
5
- * Complete tool description for AI Agent
6
- * The AI will use this to understand ALL available operations
7
- */
8
- getToolDescription(): IDataObject;
9
4
  execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
10
5
  }
@@ -10,16 +10,15 @@ class Confirm8AgentTool {
10
10
  icon: 'file:tool.svg',
11
11
  group: ['transform'],
12
12
  version: 1,
13
- description: 'Autonomous AI Agent tool for Confirm8 API - AI decides everything',
13
+ description: 'Autonomous AI Agent tool for Confirm8 API',
14
14
  defaults: {
15
15
  name: 'Confirm8 AI Tool',
16
16
  },
17
- // CRITICAL: Makes this node usable as an AI Agent Tool
18
17
  usableAsTool: true,
19
18
  inputs: ['main'],
20
19
  outputs: ['main'],
21
20
  properties: [
22
- // ONLY API Configuration - AI decides the rest
21
+ // API Configuration
23
22
  {
24
23
  displayName: 'Base URL',
25
24
  name: 'baseUrl',
@@ -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,82 +51,34 @@ class Confirm8AgentTool {
53
51
  default: '',
54
52
  required: true,
55
53
  },
56
- ],
57
- };
58
- }
59
- /**
60
- * Complete tool description for AI Agent
61
- * The AI will use this to understand ALL available operations
62
- */
63
- getToolDescription() {
64
- return {
65
- name: 'confirm8_api',
66
- description: 'Complete Confirm8 API access tool. Use this to interact with the Confirm8 system. ' +
67
- 'You can fetch, create, update, activate, or deactivate any resource. ' +
68
- '\n\n**Available Resources:**\n' +
69
- '- user (users/employees)\n' +
70
- '- client (clients/customers)\n' +
71
- '- item (items/products inventory)\n' +
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"',
104
- properties: [
54
+ // Tool parameters (provided by AI)
105
55
  {
106
56
  displayName: 'Resource',
107
57
  name: 'resource',
108
58
  type: 'string',
109
- required: true,
110
- description: 'Resource type: user, client, item, itemType, task, service, product, order, modality, ticket, or property',
59
+ default: '',
60
+ description: 'Resource type',
111
61
  },
112
62
  {
113
63
  displayName: 'Operation',
114
64
  name: 'operation',
115
65
  type: 'string',
116
- required: true,
117
- description: 'Operation: getAll, get, create, update, activate, deactivate, or special operations (getByUsername, getTickets, getTasks, etc.)',
66
+ default: '',
67
+ description: 'Operation to perform',
118
68
  },
119
69
  {
120
70
  displayName: 'Record ID',
121
71
  name: 'recordId',
122
72
  type: 'string',
123
- required: false,
124
- description: 'ID of the record (required for get, update, activate, deactivate, and some special operations)',
73
+ default: '',
74
+ description: 'Record ID',
125
75
  },
126
76
  {
127
77
  displayName: 'Data',
128
78
  name: 'data',
129
- type: 'json',
130
- required: false,
131
- description: 'JSON data for create/update operations or additional parameters. Example: {"name":"John","email":"john@example.com"}',
79
+ type: 'string',
80
+ default: '',
81
+ description: 'JSON data',
132
82
  },
133
83
  ],
134
84
  };
@@ -138,32 +88,30 @@ class Confirm8AgentTool {
138
88
  const returnData = [];
139
89
  for (let i = 0; i < items.length; i++) {
140
90
  try {
141
- // Get API configuration (only thing configured in the UI)
91
+ // Get API credentials
142
92
  const baseUrl = this.getNodeParameter('baseUrl', i);
143
93
  const bearerToken = this.getNodeParameter('bearerToken', i);
144
94
  const apiDomain = this.getNodeParameter('apiDomain', i);
145
95
  const apiKeyToken = this.getNodeParameter('apiKeyToken', i);
146
- // Get operation parameters from the TOOL CALL (provided by AI)
147
- const resource = this.getNodeParameter('resource', i);
148
- 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, '');
149
99
  const recordId = this.getNodeParameter('recordId', i, '');
150
- // Parse data if provided
100
+ // Parse data
151
101
  let data = {};
152
- try {
153
- const dataParam = this.getNodeParameter('data', i, '');
154
- if (dataParam) {
155
- if (typeof dataParam === 'string') {
156
- data = JSON.parse(dataParam);
157
- }
158
- else if (typeof dataParam === 'object') {
159
- data = dataParam;
160
- }
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
161
109
  }
162
110
  }
163
- catch (e) {
164
- // Data is optional
111
+ if (!resource || !operation) {
112
+ throw new Error('Resource and operation are required');
165
113
  }
166
- // Map resource to API endpoint
114
+ // Map resources to endpoints
167
115
  const resourceMap = {
168
116
  user: 'users',
169
117
  client: 'clients',
@@ -181,18 +129,15 @@ class Confirm8AgentTool {
181
129
  let endpoint = '';
182
130
  let method = 'GET';
183
131
  let body = {};
184
- // Build request based on operation
132
+ // Build request
185
133
  switch (operation) {
186
134
  case 'getAll':
187
135
  endpoint = `/${baseEndpoint}`;
188
- method = 'GET';
189
136
  break;
190
137
  case 'get':
191
- if (!recordId) {
192
- throw new Error('recordId is required for get operation');
193
- }
138
+ if (!recordId)
139
+ throw new Error('recordId required for get');
194
140
  endpoint = `/${baseEndpoint}/${recordId}`;
195
- method = 'GET';
196
141
  break;
197
142
  case 'create':
198
143
  endpoint = `/${baseEndpoint}`;
@@ -200,67 +145,46 @@ class Confirm8AgentTool {
200
145
  body = data;
201
146
  break;
202
147
  case 'update':
203
- if (!recordId) {
204
- throw new Error('recordId is required for update operation');
205
- }
148
+ if (!recordId)
149
+ throw new Error('recordId required for update');
206
150
  endpoint = `/${baseEndpoint}/${recordId}`;
207
151
  method = 'PUT';
208
152
  body = data;
209
153
  break;
210
154
  case 'activate':
211
- if (!recordId) {
212
- throw new Error('recordId is required for activate operation');
213
- }
155
+ if (!recordId)
156
+ throw new Error('recordId required for activate');
214
157
  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';
221
- }
158
+ method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
159
+ ? 'PUT' : 'PATCH';
222
160
  break;
223
161
  case 'deactivate':
224
- if (!recordId) {
225
- throw new Error('recordId is required for deactivate operation');
226
- }
162
+ if (!recordId)
163
+ throw new Error('recordId required for deactivate');
227
164
  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
- }
165
+ method = ['client', 'item', 'itemType', 'task', 'service', 'product', 'order', 'modality'].includes(resource)
166
+ ? 'PUT' : 'PATCH';
235
167
  break;
236
- // Special User Operations
168
+ // Special user operations
237
169
  case 'getByUsername':
238
- if (!data.username) {
239
- throw new Error('username is required in data for getByUsername operation');
240
- }
170
+ if (!data.username)
171
+ throw new Error('username required in data');
241
172
  endpoint = `/users/${data.username}/user`;
242
- method = 'GET';
243
173
  break;
244
174
  case 'getTickets':
245
- if (!recordId) {
246
- throw new Error('recordId is required for getTickets operation');
247
- }
175
+ if (!recordId)
176
+ throw new Error('recordId required');
248
177
  endpoint = `/users/${recordId}/tickets`;
249
- method = 'GET';
250
178
  break;
251
179
  case 'getTasks':
252
- if (!recordId) {
253
- throw new Error('recordId is required for getTasks operation');
254
- }
180
+ if (!recordId)
181
+ throw new Error('recordId required');
255
182
  endpoint = `/users/${recordId}/tasks`;
256
- method = 'GET';
257
183
  break;
258
184
  case 'getPermissions':
259
- if (!recordId) {
260
- throw new Error('recordId is required for getPermissions operation');
261
- }
185
+ if (!recordId)
186
+ throw new Error('recordId required');
262
187
  endpoint = `/users/${recordId}/permissions`;
263
- method = 'GET';
264
188
  break;
265
189
  case 'linkTasks':
266
190
  endpoint = '/users/tasks';
@@ -272,24 +196,21 @@ class Confirm8AgentTool {
272
196
  method = 'DELETE';
273
197
  break;
274
198
  case 'deleteLinkedTasksByUser':
275
- if (!data.employeeId) {
276
- throw new Error('employeeId is required in data for deleteLinkedTasksByUser operation');
277
- }
199
+ if (!data.employeeId)
200
+ throw new Error('employeeId required in data');
278
201
  endpoint = `/users/tasks/${data.employeeId}`;
279
202
  method = 'DELETE';
280
203
  break;
281
204
  case 'uploadPhoto':
282
- if (!recordId) {
283
- throw new Error('recordId is required for uploadPhoto operation');
284
- }
205
+ if (!recordId)
206
+ throw new Error('recordId required');
285
207
  endpoint = `/users/${recordId}/photos`;
286
208
  method = 'PATCH';
287
209
  body = data;
288
210
  break;
289
211
  case 'uploadSignature':
290
- if (!recordId) {
291
- throw new Error('recordId is required for uploadSignature operation');
292
- }
212
+ if (!recordId)
213
+ throw new Error('recordId required');
293
214
  endpoint = `/users/${recordId}/signatures`;
294
215
  method = 'PATCH';
295
216
  body = data;
@@ -297,7 +218,7 @@ class Confirm8AgentTool {
297
218
  default:
298
219
  throw new Error(`Unknown operation: ${operation}`);
299
220
  }
300
- // Make HTTP request
221
+ // Make request
301
222
  const url = `${baseUrl}${endpoint}`;
302
223
  const options = {
303
224
  method,
@@ -330,7 +251,7 @@ class Confirm8AgentTool {
330
251
  returnData.push({
331
252
  json: {
332
253
  success: false,
333
- error: error || 'Unknown error',
254
+ error: error.message || 'Unknown error',
334
255
  resource: this.getNodeParameter('resource', i, ''),
335
256
  operation: this.getNodeParameter('operation', i, ''),
336
257
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-confirm8",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Simple n8n node for Confirm8 API - no credentials needed",
5
5
  "license": "MIT",
6
6
  "author": "Bill Hebert",