n8n-nodes-confirm8 0.12.0 → 0.15.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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, IDataObject } from 'n8n-workflow';
|
|
2
|
+
export declare class Confirm8AgentTool implements INodeType {
|
|
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
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Confirm8AgentTool = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
class Confirm8AgentTool {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Confirm8 AI Tool',
|
|
9
|
+
name: 'confirm8AgentTool',
|
|
10
|
+
icon: 'file:tool.svg',
|
|
11
|
+
group: ['transform'],
|
|
12
|
+
version: 1,
|
|
13
|
+
description: 'AI Agent tool for Confirm8 API - Use to fetch, create, update data from Confirm8',
|
|
14
|
+
defaults: {
|
|
15
|
+
name: 'Confirm8 AI Tool',
|
|
16
|
+
},
|
|
17
|
+
// IMPORTANT: Makes this node usable as an AI Agent Tool
|
|
18
|
+
usableAsTool: true,
|
|
19
|
+
inputs: ['main'],
|
|
20
|
+
outputs: ['main'],
|
|
21
|
+
properties: [
|
|
22
|
+
// API Configuration
|
|
23
|
+
{
|
|
24
|
+
displayName: 'Base URL',
|
|
25
|
+
name: 'baseUrl',
|
|
26
|
+
type: 'string',
|
|
27
|
+
default: '',
|
|
28
|
+
placeholder: 'https://api.confirm8.com',
|
|
29
|
+
required: true,
|
|
30
|
+
description: 'Base URL of Confirm8 API',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Bearer Token',
|
|
34
|
+
name: 'bearerToken',
|
|
35
|
+
type: 'string',
|
|
36
|
+
typeOptions: { password: true },
|
|
37
|
+
default: '',
|
|
38
|
+
required: true,
|
|
39
|
+
description: 'Authentication token',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'X-API-DOMAIN',
|
|
43
|
+
name: 'apiDomain',
|
|
44
|
+
type: 'string',
|
|
45
|
+
default: '',
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
displayName: 'X-APIKEY-TOKEN',
|
|
50
|
+
name: 'apiKeyToken',
|
|
51
|
+
type: 'string',
|
|
52
|
+
typeOptions: { password: true },
|
|
53
|
+
default: '',
|
|
54
|
+
required: true,
|
|
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
|
+
},
|
|
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',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
displayName: 'Operation',
|
|
177
|
+
name: 'operation',
|
|
178
|
+
type: 'options',
|
|
179
|
+
required: true,
|
|
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',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
displayName: 'Record ID',
|
|
192
|
+
name: 'recordId',
|
|
193
|
+
type: 'string',
|
|
194
|
+
required: false,
|
|
195
|
+
description: 'ID of the record (required for get, update, activate, deactivate)',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
displayName: 'Data',
|
|
199
|
+
name: 'dataJson',
|
|
200
|
+
type: 'json',
|
|
201
|
+
required: false,
|
|
202
|
+
description: 'JSON data for create/update operations. Example: {"name":"John","email":"john@example.com"}',
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
async execute() {
|
|
208
|
+
const items = this.getInputData();
|
|
209
|
+
const returnData = [];
|
|
210
|
+
for (let i = 0; i < items.length; i++) {
|
|
211
|
+
try {
|
|
212
|
+
// Get API configuration
|
|
213
|
+
const baseUrl = this.getNodeParameter('baseUrl', i);
|
|
214
|
+
const bearerToken = this.getNodeParameter('bearerToken', i);
|
|
215
|
+
const apiDomain = this.getNodeParameter('apiDomain', i);
|
|
216
|
+
const apiKeyToken = this.getNodeParameter('apiKeyToken', i);
|
|
217
|
+
// Get operation parameters
|
|
218
|
+
const resource = this.getNodeParameter('resource', i);
|
|
219
|
+
const operation = this.getNodeParameter('operation', i);
|
|
220
|
+
const recordId = this.getNodeParameter('recordId', i, '');
|
|
221
|
+
// Parse data JSON
|
|
222
|
+
let dataJson = {};
|
|
223
|
+
try {
|
|
224
|
+
const dataJsonStr = this.getNodeParameter('dataJson', i, '{}');
|
|
225
|
+
if (dataJsonStr && dataJsonStr.trim() !== '{}') {
|
|
226
|
+
dataJson = JSON.parse(dataJsonStr);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
// Data is optional
|
|
231
|
+
}
|
|
232
|
+
// Map resource to endpoint
|
|
233
|
+
const resourceMap = {
|
|
234
|
+
user: 'users',
|
|
235
|
+
client: 'clients',
|
|
236
|
+
item: 'items',
|
|
237
|
+
task: 'tasks',
|
|
238
|
+
service: 'services',
|
|
239
|
+
product: 'products',
|
|
240
|
+
order: 'wos',
|
|
241
|
+
ticket: 'tickets',
|
|
242
|
+
property: 'properties',
|
|
243
|
+
};
|
|
244
|
+
const endpoint = resourceMap[resource] || resource;
|
|
245
|
+
let url = '';
|
|
246
|
+
let method = 'GET';
|
|
247
|
+
let body = {};
|
|
248
|
+
// Build request based on operation
|
|
249
|
+
switch (operation) {
|
|
250
|
+
case 'getAll':
|
|
251
|
+
url = `${baseUrl}/${endpoint}`;
|
|
252
|
+
method = 'GET';
|
|
253
|
+
break;
|
|
254
|
+
case 'get':
|
|
255
|
+
if (!recordId) {
|
|
256
|
+
throw new Error('Record ID is required for Get operation');
|
|
257
|
+
}
|
|
258
|
+
url = `${baseUrl}/${endpoint}/${recordId}`;
|
|
259
|
+
method = 'GET';
|
|
260
|
+
break;
|
|
261
|
+
case 'create':
|
|
262
|
+
url = `${baseUrl}/${endpoint}`;
|
|
263
|
+
method = 'POST';
|
|
264
|
+
body = dataJson;
|
|
265
|
+
break;
|
|
266
|
+
case 'update':
|
|
267
|
+
if (!recordId) {
|
|
268
|
+
throw new Error('Record ID is required for Update operation');
|
|
269
|
+
}
|
|
270
|
+
url = `${baseUrl}/${endpoint}/${recordId}`;
|
|
271
|
+
method = 'PUT';
|
|
272
|
+
body = dataJson;
|
|
273
|
+
break;
|
|
274
|
+
case 'activate':
|
|
275
|
+
if (!recordId) {
|
|
276
|
+
throw new Error('Record ID is required for Activate operation');
|
|
277
|
+
}
|
|
278
|
+
url = `${baseUrl}/${endpoint}/${recordId}/active`;
|
|
279
|
+
method = resource === 'client' || resource === 'item' || resource === 'task' ||
|
|
280
|
+
resource === 'service' || resource === 'product' || resource === 'order' ? 'PUT' : 'PATCH';
|
|
281
|
+
break;
|
|
282
|
+
case 'deactivate':
|
|
283
|
+
if (!recordId) {
|
|
284
|
+
throw new Error('Record ID is required for Deactivate operation');
|
|
285
|
+
}
|
|
286
|
+
url = `${baseUrl}/${endpoint}/${recordId}/inactive`;
|
|
287
|
+
method = resource === 'client' || resource === 'item' || resource === 'task' ||
|
|
288
|
+
resource === 'service' || resource === 'product' || resource === 'order' ? 'PUT' : 'PATCH';
|
|
289
|
+
break;
|
|
290
|
+
default:
|
|
291
|
+
throw new Error(`Unknown operation: ${operation}`);
|
|
292
|
+
}
|
|
293
|
+
// Make HTTP request
|
|
294
|
+
const options = {
|
|
295
|
+
method,
|
|
296
|
+
uri: url,
|
|
297
|
+
headers: {
|
|
298
|
+
'Authorization': `Bearer ${bearerToken}`,
|
|
299
|
+
'X-API-DOMAIN': apiDomain,
|
|
300
|
+
'X-APIKEY-TOKEN': apiKeyToken,
|
|
301
|
+
'Content-Type': 'application/json',
|
|
302
|
+
},
|
|
303
|
+
json: true,
|
|
304
|
+
};
|
|
305
|
+
if (method !== 'GET' && method !== 'DELETE' && Object.keys(body).length > 0) {
|
|
306
|
+
options.body = body;
|
|
307
|
+
}
|
|
308
|
+
const responseData = await this.helpers.request(options);
|
|
309
|
+
returnData.push({
|
|
310
|
+
json: {
|
|
311
|
+
success: true,
|
|
312
|
+
operation,
|
|
313
|
+
resource,
|
|
314
|
+
data: responseData,
|
|
315
|
+
},
|
|
316
|
+
pairedItem: { item: i },
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
if (this.continueOnFail()) {
|
|
321
|
+
returnData.push({
|
|
322
|
+
json: {
|
|
323
|
+
success: false,
|
|
324
|
+
error: error || 'Unknown error',
|
|
325
|
+
},
|
|
326
|
+
pairedItem: { item: i },
|
|
327
|
+
});
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return [returnData];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
exports.Confirm8AgentTool = Confirm8AgentTool;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-confirm8",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Simple n8n node for Confirm8 API - no credentials needed",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bill Hebert",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"n8n": {
|
|
23
23
|
"nodes": [
|
|
24
|
-
"dist/nodes/Confirm8/ApiConfirm8.node.js"
|
|
24
|
+
"dist/nodes/Confirm8/ApiConfirm8.node.js",
|
|
25
|
+
"dist/nodes/Confirm8Tool/Confirm8AgentTool.node.js"
|
|
25
26
|
]
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|