n8n-nodes-confirm8 0.22.0 → 0.23.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.
|
@@ -5,5 +5,13 @@ export declare class Confirm8AgentTool implements INodeType {
|
|
|
5
5
|
* Parse natural date queries into filter JSON
|
|
6
6
|
*/
|
|
7
7
|
private parseDateQuery;
|
|
8
|
+
/**
|
|
9
|
+
* Validate ISO date string yyyy-mm-dd
|
|
10
|
+
*/
|
|
11
|
+
private isIsoDate;
|
|
12
|
+
/**
|
|
13
|
+
* Enforce date filters format when present
|
|
14
|
+
*/
|
|
15
|
+
private validateDateFilters;
|
|
8
16
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
9
17
|
}
|
|
@@ -2,41 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Confirm8AgentTool = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
6
|
-
// STRICT ALLOWED VALUES (used both for UI + for agent/tool schema guidance)
|
|
7
|
-
// IMPORTANT: Any agent calling this tool MUST use ONLY these exact tokens.
|
|
8
|
-
// -----------------------------------------------------------------------------
|
|
9
|
-
const VALID_RESOURCES = [
|
|
10
|
-
"user",
|
|
11
|
-
"client",
|
|
12
|
-
"item",
|
|
13
|
-
"itemType",
|
|
14
|
-
"task",
|
|
15
|
-
"service",
|
|
16
|
-
"product",
|
|
17
|
-
"order",
|
|
18
|
-
"modality",
|
|
19
|
-
"ticket",
|
|
20
|
-
"property",
|
|
21
|
-
];
|
|
22
|
-
const VALID_OPERATIONS = [
|
|
23
|
-
"getAll",
|
|
24
|
-
"get",
|
|
25
|
-
"create",
|
|
26
|
-
"update",
|
|
27
|
-
"activate",
|
|
28
|
-
"deactivate",
|
|
29
|
-
];
|
|
30
|
-
const AGENT_USAGE_NOTE = `
|
|
31
|
-
CRITICAL (Agents):
|
|
32
|
-
- You MUST return ONLY the option *value* token (not the label).
|
|
33
|
-
- Allowed resource values: ${VALID_RESOURCES.join(", ")}
|
|
34
|
-
- Allowed operation values: ${VALID_OPERATIONS.join(", ")}
|
|
35
|
-
Examples:
|
|
36
|
-
- "Ordem de Serviço" / "OS" / "Work Order" => resource="order"
|
|
37
|
-
- To list/search => operation="getAll"
|
|
38
|
-
Anything outside these lists will throw a fatal error.
|
|
39
|
-
`.trim();
|
|
40
5
|
class Confirm8AgentTool {
|
|
41
6
|
constructor() {
|
|
42
7
|
this.description = {
|
|
@@ -45,7 +10,15 @@ class Confirm8AgentTool {
|
|
|
45
10
|
icon: "file:tool.svg",
|
|
46
11
|
group: ["transform"],
|
|
47
12
|
version: 1,
|
|
48
|
-
description:
|
|
13
|
+
description: `AI tool for Confirm8 (STRICT).
|
|
14
|
+
|
|
15
|
+
CRITICAL FOR AGENTS:
|
|
16
|
+
- "resource" MUST be exactly one of: user, client, item, itemType, task, service, product, order, modality, ticket, property
|
|
17
|
+
- "operation" MUST be exactly one of: getAll, get, create, update, activate, deactivate
|
|
18
|
+
- Use ONLY these tokens. Do NOT use labels like "OS", "Ordem de Serviço", "buscar".
|
|
19
|
+
- For OS/ordem de serviço => resource="order"
|
|
20
|
+
- To list/search => operation="getAll"
|
|
21
|
+
- Date filters MUST be ISO yyyy-mm-dd.`,
|
|
49
22
|
defaults: {
|
|
50
23
|
name: "Confirm8 AI Tool",
|
|
51
24
|
},
|
|
@@ -92,55 +65,56 @@ class Confirm8AgentTool {
|
|
|
92
65
|
type: "options",
|
|
93
66
|
options: [
|
|
94
67
|
{
|
|
95
|
-
name: "
|
|
68
|
+
name: "user",
|
|
96
69
|
value: "user",
|
|
97
70
|
description: "Users/Employees/Funcionários",
|
|
98
71
|
},
|
|
99
72
|
{
|
|
100
|
-
name: "
|
|
73
|
+
name: "client",
|
|
101
74
|
value: "client",
|
|
102
75
|
description: "Clients/Customers/Clientes",
|
|
103
76
|
},
|
|
104
|
-
{ name: "
|
|
77
|
+
{ name: "item", value: "item", description: "Items/Itens" },
|
|
105
78
|
{
|
|
106
|
-
name: "
|
|
79
|
+
name: "itemType",
|
|
107
80
|
value: "itemType",
|
|
108
81
|
description: "Item Types/Tipos",
|
|
109
82
|
},
|
|
110
83
|
{
|
|
111
|
-
name: "
|
|
84
|
+
name: "task",
|
|
112
85
|
value: "task",
|
|
113
86
|
description: "Tasks/Tarefas/Checklists",
|
|
114
87
|
},
|
|
115
88
|
{
|
|
116
|
-
name: "
|
|
89
|
+
name: "service",
|
|
117
90
|
value: "service",
|
|
118
91
|
description: "Services/Serviços",
|
|
119
92
|
},
|
|
120
93
|
{
|
|
121
|
-
name: "
|
|
94
|
+
name: "product",
|
|
122
95
|
value: "product",
|
|
123
96
|
description: "Products/Produtos",
|
|
124
97
|
},
|
|
125
98
|
{
|
|
126
|
-
name: "
|
|
99
|
+
name: "order",
|
|
127
100
|
value: "order",
|
|
128
101
|
description: "Work Orders/OS/Ordens de Serviço/WOS",
|
|
129
102
|
},
|
|
130
103
|
{
|
|
131
|
-
name: "
|
|
104
|
+
name: "modality",
|
|
132
105
|
value: "modality",
|
|
133
106
|
description: "Modalities/Modalidades",
|
|
134
107
|
},
|
|
135
|
-
{ name: "
|
|
108
|
+
{ name: "ticket", value: "ticket", description: "Tickets/Chamados" },
|
|
136
109
|
{
|
|
137
|
-
name: "
|
|
110
|
+
name: "property",
|
|
138
111
|
value: "property",
|
|
139
112
|
description: "Properties/Propriedades",
|
|
140
113
|
},
|
|
141
114
|
],
|
|
142
115
|
default: "user",
|
|
143
|
-
description:
|
|
116
|
+
description: `CRITICAL (Agents): Resource MUST be EXACTLY one of: user, client, item, itemType, task, service, product, order, modality, ticket, property.
|
|
117
|
+
Use ONLY the value token (example: order), never labels like OS.`,
|
|
144
118
|
},
|
|
145
119
|
{
|
|
146
120
|
displayName: "Operation",
|
|
@@ -148,38 +122,39 @@ class Confirm8AgentTool {
|
|
|
148
122
|
type: "options",
|
|
149
123
|
options: [
|
|
150
124
|
{
|
|
151
|
-
name: "
|
|
125
|
+
name: "getAll",
|
|
152
126
|
value: "getAll",
|
|
153
|
-
description:
|
|
127
|
+
description: "List/Listar/Buscar todos/Mostrar todos",
|
|
154
128
|
},
|
|
155
129
|
{
|
|
156
|
-
name: "
|
|
130
|
+
name: "get",
|
|
157
131
|
value: "get",
|
|
158
|
-
description:
|
|
132
|
+
description: "Get one/Buscar um/Obter",
|
|
159
133
|
},
|
|
160
134
|
{
|
|
161
|
-
name: "
|
|
135
|
+
name: "create",
|
|
162
136
|
value: "create",
|
|
163
|
-
description:
|
|
137
|
+
description: "Create/Criar/Adicionar",
|
|
164
138
|
},
|
|
165
139
|
{
|
|
166
|
-
name: "
|
|
140
|
+
name: "update",
|
|
167
141
|
value: "update",
|
|
168
|
-
description:
|
|
142
|
+
description: "Update/Atualizar/Modificar",
|
|
169
143
|
},
|
|
170
144
|
{
|
|
171
|
-
name: "
|
|
145
|
+
name: "activate",
|
|
172
146
|
value: "activate",
|
|
173
|
-
description:
|
|
147
|
+
description: "Activate/Ativar",
|
|
174
148
|
},
|
|
175
149
|
{
|
|
176
|
-
name: "
|
|
150
|
+
name: "deactivate",
|
|
177
151
|
value: "deactivate",
|
|
178
|
-
description:
|
|
152
|
+
description: "Deactivate/Desativar",
|
|
179
153
|
},
|
|
180
154
|
],
|
|
181
155
|
default: "getAll",
|
|
182
|
-
description:
|
|
156
|
+
description: `CRITICAL (Agents): Operation MUST be EXACTLY one of: getAll, get, create, update, activate, deactivate.
|
|
157
|
+
Use ONLY the value token (example: getAll), never labels like buscar.`,
|
|
183
158
|
},
|
|
184
159
|
{
|
|
185
160
|
displayName: "Record ID",
|
|
@@ -200,7 +175,10 @@ class Confirm8AgentTool {
|
|
|
200
175
|
name: "filters",
|
|
201
176
|
type: "string",
|
|
202
177
|
default: "",
|
|
203
|
-
description:
|
|
178
|
+
description: `Filters as JSON ONLY.
|
|
179
|
+
Dates MUST be ISO yyyy-mm-dd.
|
|
180
|
+
Example (this week): {"start_date":{"gte":"2025-06-16"},"end_date":{"lte":"2025-06-22"}}
|
|
181
|
+
Do NOT send expressions like "data >= start_of_week".`,
|
|
204
182
|
},
|
|
205
183
|
],
|
|
206
184
|
};
|
|
@@ -273,6 +251,36 @@ class Confirm8AgentTool {
|
|
|
273
251
|
}
|
|
274
252
|
return null;
|
|
275
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Validate ISO date string yyyy-mm-dd
|
|
256
|
+
*/
|
|
257
|
+
isIsoDate(value) {
|
|
258
|
+
if (typeof value !== "string")
|
|
259
|
+
return false;
|
|
260
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Enforce date filters format when present
|
|
264
|
+
*/
|
|
265
|
+
validateDateFilters(filters) {
|
|
266
|
+
const dateFields = ["start_date", "end_date", "date", "data"];
|
|
267
|
+
for (const field of dateFields) {
|
|
268
|
+
if (!filters[field])
|
|
269
|
+
continue;
|
|
270
|
+
const ops = filters[field];
|
|
271
|
+
if (!ops || typeof ops !== "object")
|
|
272
|
+
continue;
|
|
273
|
+
for (const op of Object.keys(ops)) {
|
|
274
|
+
const v = ops[op];
|
|
275
|
+
if (v == null)
|
|
276
|
+
continue;
|
|
277
|
+
if (!this.isIsoDate(v)) {
|
|
278
|
+
throw new Error(`Invalid date format in filters["${field}"]["${op}"]="${String(v)}". ` +
|
|
279
|
+
`Dates MUST be yyyy-mm-dd (ISO), e.g. "2025-06-16".`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
276
284
|
async execute() {
|
|
277
285
|
const items = this.getInputData();
|
|
278
286
|
const returnData = [];
|
|
@@ -311,6 +319,8 @@ class Confirm8AgentTool {
|
|
|
311
319
|
filters = parsedDate;
|
|
312
320
|
}
|
|
313
321
|
}
|
|
322
|
+
// Enforce ISO date filters when present
|
|
323
|
+
this.validateDateFilters(filters);
|
|
314
324
|
}
|
|
315
325
|
// Aggressive normalization - EXPAND THIS
|
|
316
326
|
const resourceMap = {
|
|
@@ -404,7 +414,7 @@ class Confirm8AgentTool {
|
|
|
404
414
|
disable: "deactivate",
|
|
405
415
|
desabilitar: "deactivate",
|
|
406
416
|
};
|
|
407
|
-
// Normalize - clean and map
|
|
417
|
+
// Normalize - clean and map (remove accents/punctuation)
|
|
408
418
|
const normalizeKey = (value) => value
|
|
409
419
|
.toLowerCase()
|
|
410
420
|
.normalize("NFD")
|
|
@@ -417,8 +427,27 @@ class Confirm8AgentTool {
|
|
|
417
427
|
resource = resourceMap[cleanResource] || resource;
|
|
418
428
|
operation = operationMap[cleanOperation] || operation;
|
|
419
429
|
// If still not valid, throw clear error
|
|
420
|
-
const validResources =
|
|
421
|
-
|
|
430
|
+
const validResources = [
|
|
431
|
+
"user",
|
|
432
|
+
"client",
|
|
433
|
+
"item",
|
|
434
|
+
"itemType",
|
|
435
|
+
"task",
|
|
436
|
+
"service",
|
|
437
|
+
"product",
|
|
438
|
+
"order",
|
|
439
|
+
"modality",
|
|
440
|
+
"ticket",
|
|
441
|
+
"property",
|
|
442
|
+
];
|
|
443
|
+
const validOperations = [
|
|
444
|
+
"getAll",
|
|
445
|
+
"get",
|
|
446
|
+
"create",
|
|
447
|
+
"update",
|
|
448
|
+
"activate",
|
|
449
|
+
"deactivate",
|
|
450
|
+
];
|
|
422
451
|
if (!validResources.includes(resource)) {
|
|
423
452
|
throw new Error(`Invalid resource: "${resource}". Must be one of: ${validResources.join(", ")}. ` + `For OS/Ordem de Serviço use "order".`);
|
|
424
453
|
}
|