n8n-nodes-confirm8 0.29.0 → 0.31.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,51 +1,10 @@
1
- import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, IDataObject, NodeOperationError } from "n8n-workflow";
2
- /**
3
- * =========================
4
- * Confirm8 Utils (merged)
5
- * =========================
6
- */
7
- export declare const VALID_RESOURCES: readonly ["user", "client", "item", "itemType", "task", "service", "product", "order", "modality", "ticket", "property"];
8
- export declare const VALID_OPERATIONS: readonly ["getAll", "get", "create", "update", "activate", "deactivate"];
9
- export type Confirm8Resource = (typeof VALID_RESOURCES)[number];
10
- export type Confirm8Operation = (typeof VALID_OPERATIONS)[number];
11
- export declare const RESOURCE_ENDPOINTS: Record<Confirm8Resource, {
12
- endpoint: string;
13
- relations: string[];
14
- }>;
15
- export declare function assertIsoDate(dateStr: string, label: string): void;
16
- export declare function formatIsoDate(d: Date): string;
17
- /**
18
- * Week starts on Monday (pt-BR business default).
19
- * Returns inclusive start/end in YYYY-MM-DD.
20
- */
21
- export declare function getThisWeekRange(now?: Date): {
22
- start: string;
23
- end: string;
24
- };
25
- /** Build query params for relations + filters in Confirm8 format. */
26
- export declare function buildQueryParams(relations: string[], filters?: IDataObject): string;
27
- export declare function confirm8Request(this: IExecuteFunctions, i: number, args: {
28
- baseUrl: string;
29
- bearerToken: string;
30
- apiDomain: string;
31
- apiKeyToken: string;
32
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
33
- endpoint: string;
34
- query?: string;
35
- body?: IDataObject;
36
- }): Promise<any>;
37
- export declare function toNodeError(node: any, err: unknown, i: number): NodeOperationError;
38
- /**
39
- * =========================
40
- * Confirm8 OS Tool (merged)
41
- * =========================
42
- *
43
- * CHUMBED:
44
- * - resource is ALWAYS "order"
45
- * - operation is ALWAYS "getAll" OR "get" (derived only from presence of recordId)
46
- * - dates are ALWAYS ISO YYYY-MM-DD (validated / computed here)
47
- */
48
- export declare class Confirm8OSTool implements INodeType {
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, IDataObject } from 'n8n-workflow';
2
+ export declare class Confirm8AgentTool implements INodeType {
49
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;
50
9
  execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
51
10
  }
@@ -1,288 +1,205 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Confirm8OSTool = exports.RESOURCE_ENDPOINTS = exports.VALID_OPERATIONS = exports.VALID_RESOURCES = void 0;
4
- exports.assertIsoDate = assertIsoDate;
5
- exports.formatIsoDate = formatIsoDate;
6
- exports.getThisWeekRange = getThisWeekRange;
7
- exports.buildQueryParams = buildQueryParams;
8
- exports.confirm8Request = confirm8Request;
9
- exports.toNodeError = toNodeError;
3
+ exports.Confirm8AgentTool = void 0;
10
4
  const n8n_workflow_1 = require("n8n-workflow");
11
- /**
12
- * =========================
13
- * Confirm8 Utils (merged)
14
- * =========================
15
- */
16
- exports.VALID_RESOURCES = [
17
- "user",
18
- "client",
19
- "item",
20
- "itemType",
21
- "task",
22
- "service",
23
- "product",
24
- "order",
25
- "modality",
26
- "ticket",
27
- "property",
28
- ];
29
- exports.VALID_OPERATIONS = [
30
- "getAll",
31
- "get",
32
- "create",
33
- "update",
34
- "activate",
35
- "deactivate",
36
- ];
37
- exports.RESOURCE_ENDPOINTS = {
38
- user: {
39
- endpoint: "users",
40
- relations: ["clients", "attachments", "permissions", "device", "employee"],
41
- },
42
- client: {
43
- endpoint: "clients",
44
- relations: [
45
- "address",
46
- "contacts",
47
- "items",
48
- "tickets",
49
- "orders",
50
- "properties",
51
- "attachments",
52
- ],
53
- },
54
- item: {
55
- endpoint: "items",
56
- relations: ["client", "itemType", "properties", "attachments"],
57
- },
58
- itemType: { endpoint: "item-types", relations: ["properties"] },
59
- task: {
60
- endpoint: "tasks",
61
- relations: ["itemType", "modality", "services", "products"],
62
- },
63
- service: { endpoint: "services", relations: ["task"] },
64
- product: { endpoint: "products", relations: [] },
65
- // IMPORTANT: Confirm8 Work Orders endpoint is 'wos'
66
- order: {
67
- endpoint: "wos",
68
- relations: [
69
- "client",
70
- "modalities",
71
- "tasks",
72
- "pivot_tasks",
73
- "products",
74
- "users",
75
- "items",
76
- "tickets",
77
- "services",
78
- "collects",
79
- "attachments",
80
- ],
81
- },
82
- modality: { endpoint: "modalities", relations: ["tasks"] },
83
- ticket: {
84
- endpoint: "tickets",
85
- relations: ["client", "subject_category", "category", "user", "attachments"],
86
- },
87
- property: { endpoint: "properties", relations: ["client", "item", "itemType"] },
88
- };
89
- const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
90
- function assertIsoDate(dateStr, label) {
91
- if (!ISO_DATE.test(dateStr)) {
92
- throw new Error(`${label} must be in YYYY-MM-DD format. Received: "${dateStr}"`);
93
- }
94
- }
95
- function formatIsoDate(d) {
96
- const y = d.getFullYear();
97
- const m = String(d.getMonth() + 1).padStart(2, "0");
98
- const day = String(d.getDate()).padStart(2, "0");
99
- return `${y}-${m}-${day}`;
100
- }
101
- /**
102
- * Week starts on Monday (pt-BR business default).
103
- * Returns inclusive start/end in YYYY-MM-DD.
104
- */
105
- function getThisWeekRange(now = new Date()) {
106
- const d = new Date(now);
107
- d.setHours(0, 0, 0, 0);
108
- // JS: Sunday=0 ... Saturday=6
109
- const day = d.getDay();
110
- const diffToMonday = day === 0 ? -6 : 1 - day; // if Sunday -> go back 6 days
111
- const startDate = new Date(d);
112
- startDate.setDate(d.getDate() + diffToMonday);
113
- const endDate = new Date(startDate);
114
- endDate.setDate(startDate.getDate() + 6);
115
- return { start: formatIsoDate(startDate), end: formatIsoDate(endDate) };
116
- }
117
- /** Build query params for relations + filters in Confirm8 format. */
118
- function buildQueryParams(relations, filters) {
119
- const queryParams = [];
120
- if (relations?.length) {
121
- for (const rel of relations)
122
- queryParams.push(`relations=${encodeURIComponent(rel)}`);
123
- }
124
- if (filters && Object.keys(filters).length) {
125
- for (const field of Object.keys(filters)) {
126
- const operators = filters[field];
127
- for (const op of Object.keys(operators)) {
128
- const value = operators[op];
129
- queryParams.push(`filters[${encodeURIComponent(field)}][${encodeURIComponent(op)}]=${encodeURIComponent(String(value))}`);
130
- }
131
- }
132
- }
133
- return queryParams.length ? `?${queryParams.join("&")}` : "";
134
- }
135
- function confirm8Request(i, args) {
136
- const { baseUrl, bearerToken, apiDomain, apiKeyToken, method, endpoint, query, body, } = args;
137
- const uri = `${baseUrl}${endpoint}${query ?? ""}`;
138
- const options = {
139
- method,
140
- uri,
141
- headers: {
142
- Authorization: `Bearer ${bearerToken}`,
143
- "X-API-DOMAIN": apiDomain,
144
- "X-APIKEY-TOKEN": apiKeyToken,
145
- "Content-Type": "application/json",
146
- },
147
- json: true,
148
- };
149
- if (body && method !== "GET" && method !== "DELETE") {
150
- options.body = body;
151
- }
152
- return this.helpers.request(options);
153
- }
154
- function toNodeError(node, err, i) {
155
- if (err instanceof n8n_workflow_1.NodeOperationError)
156
- return err;
157
- const message = err instanceof Error ? err.message : String(err);
158
- return new n8n_workflow_1.NodeOperationError(node, message, { itemIndex: i });
159
- }
160
- /**
161
- * =========================
162
- * Confirm8 OS Tool (merged)
163
- * =========================
164
- *
165
- * CHUMBED:
166
- * - resource is ALWAYS "order"
167
- * - operation is ALWAYS "getAll" OR "get" (derived only from presence of recordId)
168
- * - dates are ALWAYS ISO YYYY-MM-DD (validated / computed here)
169
- */
170
- class Confirm8OSTool {
5
+ class Confirm8AgentTool {
171
6
  constructor() {
172
7
  this.description = {
173
- displayName: "Confirm8 OS (Chumbed AI Tool)",
174
- name: "confirm8OsTool",
175
- group: ["transform"],
8
+ displayName: 'Confirm8 AI Tool',
9
+ name: 'confirm8AgentTool',
10
+ icon: 'file:tool.svg',
11
+ group: ['transform'],
176
12
  version: 1,
177
- description: "Work Orders (OS) tool for Confirm8. CHUMBED: resource/order is fixed; operation is derived internally (getAll vs get). Dates are always ISO YYYY-MM-DD.",
178
- defaults: { name: "Confirm8 OS" },
179
- inputs: ["main"],
180
- outputs: ["main"],
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'],
181
21
  properties: [
22
+ // API Configuration
182
23
  {
183
- displayName: "Base URL",
184
- name: "baseUrl",
185
- type: "string",
186
- default: "",
187
- placeholder: "https://api.confirm8.com",
24
+ displayName: 'Base URL',
25
+ name: 'baseUrl',
26
+ type: 'string',
27
+ default: '',
28
+ placeholder: 'https://api.confirm8.com',
188
29
  required: true,
30
+ description: 'Base URL of Confirm8 API',
189
31
  },
190
32
  {
191
- displayName: "Bearer Token",
192
- name: "bearerToken",
193
- type: "string",
33
+ displayName: 'Bearer Token',
34
+ name: 'bearerToken',
35
+ type: 'string',
194
36
  typeOptions: { password: true },
195
- default: "",
37
+ default: '',
196
38
  required: true,
39
+ description: 'Authentication token',
197
40
  },
198
41
  {
199
- displayName: "API Domain",
200
- name: "apiDomain",
201
- type: "string",
202
- default: "",
42
+ displayName: 'X-API-DOMAIN',
43
+ name: 'apiDomain',
44
+ type: 'string',
45
+ default: '',
203
46
  required: true,
204
47
  },
205
48
  {
206
- displayName: "API Key Token",
207
- name: "apiKeyToken",
208
- type: "string",
49
+ displayName: 'X-APIKEY-TOKEN',
50
+ name: 'apiKeyToken',
51
+ type: 'string',
209
52
  typeOptions: { password: true },
210
- default: "",
53
+ default: '',
211
54
  required: true,
212
55
  },
56
+ // Operation Configuration
213
57
  {
214
- displayName: "Session ID",
215
- name: "sessionId",
216
- type: "string",
217
- default: "",
218
- },
219
- {
220
- displayName: "User Query (Optional)",
221
- name: "chatinput",
222
- type: "string",
223
- default: "",
224
- },
225
- // If filled, tool performs GET by ID; otherwise, GET ALL (list)
226
- {
227
- displayName: "OS ID (recordId)",
228
- name: "recordId",
229
- type: "string",
230
- default: "",
231
- description: "If provided, fetches a single OS (get). If empty, lists OS (getAll).",
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',
232
75
  },
233
- // Listing options (only relevant when recordId is empty)
234
76
  {
235
- displayName: "Date Range",
236
- name: "dateRange",
237
- type: "options",
238
- default: "thisWeek",
239
- displayOptions: { show: { recordId: [""] } },
77
+ displayName: 'Operation',
78
+ name: 'operation',
79
+ type: 'options',
80
+ noDataExpression: true,
240
81
  options: [
241
- { name: "This week (Mon..Sun)", value: "thisWeek" },
242
- { name: "Custom", value: "custom" },
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
+ },
243
112
  ],
113
+ default: 'getAll',
114
+ description: 'Operation to perform',
244
115
  },
245
116
  {
246
- displayName: "Start Date (YYYY-MM-DD)",
247
- name: "startDate",
248
- type: "string",
249
- default: "",
250
- displayOptions: { show: { dateRange: ["custom"], recordId: [""] } },
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',
251
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: [
252
157
  {
253
- displayName: "End Date (YYYY-MM-DD)",
254
- name: "endDate",
255
- type: "string",
256
- default: "",
257
- displayOptions: { show: { dateRange: ["custom"], recordId: [""] } },
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',
258
174
  },
259
175
  {
260
- displayName: "Date Field",
261
- name: "dateField",
262
- type: "options",
263
- default: "created_at",
264
- displayOptions: { show: { recordId: [""] } },
176
+ displayName: 'Operation',
177
+ name: 'operation',
178
+ type: 'options',
179
+ required: true,
265
180
  options: [
266
- { name: "created_at (recommended)", value: "created_at" },
267
- { name: "date", value: "date" },
268
- { name: "data", value: "data" },
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' },
269
187
  ],
188
+ description: 'Operation: get (single), getAll (list), create, update, activate, deactivate',
270
189
  },
271
190
  {
272
- displayName: "Per Page",
273
- name: "perPage",
274
- type: "number",
275
- default: 50,
276
- displayOptions: { show: { recordId: [""] } },
277
- typeOptions: { minValue: 1, maxValue: 200 },
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)',
278
196
  },
279
197
  {
280
- displayName: "Page",
281
- name: "page",
282
- type: "number",
283
- default: 1,
284
- displayOptions: { show: { recordId: [""] } },
285
- typeOptions: { minValue: 1 },
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"}',
286
203
  },
287
204
  ],
288
205
  };
@@ -292,106 +209,128 @@ class Confirm8OSTool {
292
209
  const returnData = [];
293
210
  for (let i = 0; i < items.length; i++) {
294
211
  try {
295
- const baseUrl = this.getNodeParameter("baseUrl", i);
296
- const bearerToken = this.getNodeParameter("bearerToken", i);
297
- const apiDomain = this.getNodeParameter("apiDomain", i);
298
- const apiKeyToken = this.getNodeParameter("apiKeyToken", i);
299
- const sessionId = this.getNodeParameter("sessionId", i, "");
300
- const chatinput = this.getNodeParameter("chatinput", i, "");
301
- const recordId = this.getNodeParameter("recordId", i, "").trim();
302
- // CHUMBED RESOURCE
303
- const resource = "order";
304
- const config = exports.RESOURCE_ENDPOINTS[resource];
305
- // Decide operation internally
306
- const operation = recordId ? "get" : "getAll";
307
- if (operation === "get") {
308
- const endpoint = `/v3/${config.endpoint}/${encodeURIComponent(recordId)}`;
309
- const query = config.relations?.length
310
- ? `?${config.relations
311
- .map((r) => `relations=${encodeURIComponent(r)}`)
312
- .join("&")}`
313
- : "";
314
- const data = await confirm8Request.call(this, i, {
315
- baseUrl,
316
- bearerToken,
317
- apiDomain,
318
- apiKeyToken,
319
- method: "GET",
320
- endpoint,
321
- query,
322
- });
323
- returnData.push({
324
- json: {
325
- success: true,
326
- fixed: { resource, operation },
327
- request: { sessionId, chatinput, recordId, endpoint },
328
- data,
329
- },
330
- pairedItem: { item: i },
331
- });
332
- continue;
333
- }
334
- // operation === getAll
335
- const dateRange = this.getNodeParameter("dateRange", i);
336
- const dateField = this.getNodeParameter("dateField", i);
337
- let start;
338
- let end;
339
- if (dateRange === "custom") {
340
- start = this.getNodeParameter("startDate", i) || "";
341
- end = this.getNodeParameter("endDate", i) || "";
342
- if (!start || !end) {
343
- throw new Error("When Date Range is Custom, startDate and endDate are required.");
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);
344
227
  }
345
- assertIsoDate(start, "startDate");
346
- assertIsoDate(end, "endDate");
347
228
  }
348
- else {
349
- const r = getThisWeekRange(new Date());
350
- start = r.start;
351
- end = r.end;
229
+ catch (e) {
230
+ // Data is optional
352
231
  }
353
- const endpoint = `/v3/${config.endpoint}`;
354
- const filters = { [dateField]: { gte: start, lte: end } };
355
- const page = this.getNodeParameter("page", i);
356
- const perPage = this.getNodeParameter("perPage", i);
357
- const query = buildQueryParams(config.relations, filters);
358
- const pagination = `&page=${encodeURIComponent(String(page))}&per_page=${encodeURIComponent(String(perPage))}`;
359
- const finalQuery = query
360
- ? `${query}${pagination}`
361
- : `?page=${page}&per_page=${perPage}`;
362
- const data = await confirm8Request.call(this, i, {
363
- baseUrl,
364
- bearerToken,
365
- apiDomain,
366
- apiKeyToken,
367
- method: "GET",
368
- endpoint,
369
- query: finalQuery,
370
- });
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);
371
309
  returnData.push({
372
310
  json: {
373
311
  success: true,
374
- fixed: { resource, operation },
375
- request: {
376
- sessionId,
377
- chatinput,
378
- endpoint,
379
- dateField,
380
- startDate: start,
381
- endDate: end,
382
- page,
383
- perPage,
384
- },
385
- data,
312
+ operation,
313
+ resource,
314
+ data: responseData,
386
315
  },
387
316
  pairedItem: { item: i },
388
317
  });
389
318
  }
390
- catch (err) {
391
- throw toNodeError(this.getNode(), err, i);
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 });
392
331
  }
393
332
  }
394
333
  return [returnData];
395
334
  }
396
335
  }
397
- exports.Confirm8OSTool = Confirm8OSTool;
336
+ exports.Confirm8AgentTool = Confirm8AgentTool;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-confirm8",
3
- "version": "0.29.0",
3
+ "version": "0.31.0",
4
4
  "description": "Simple n8n node for Confirm8 API - no credentials needed",
5
5
  "license": "MIT",
6
6
  "author": "Bill Hebert",