evo360-types 1.3.143 → 1.3.145
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.
- package/dist/apps/evo-task/zod-schemas.d.ts +1273 -71
- package/dist/apps/evo-task/zod-schemas.js +157 -48
- package/dist/apps/evo-task/zod-schemas.ts +177 -47
- package/dist/types/evo-notifications/index.d.ts +144 -0
- package/dist/types/evo-notifications/index.js +63 -0
- package/dist/types/evo-notifications/index.ts +261 -0
- package/dist/types/evo-task/index.d.ts +203 -69
- package/dist/types/evo-task/index.js +92 -50
- package/dist/types/evo-task/index.ts +324 -126
- package/dist/types/evo-task-runner/index.d.ts +76 -0
- package/dist/types/evo-task-runner/index.js +27 -0
- package/dist/types/evo-task-runner/index.ts +141 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zTaskCommentSchema = exports.zTaskSchema = exports.zTaskExternalLinkSchema = exports.
|
|
3
|
+
exports.zTaskLogSchema = exports.zTaskExecutionSchema = exports.zTaskExecutionProviderSchema = exports.zTaskExecutionErrorSchema = exports.zTaskCommentSchema = exports.zTaskCommentAuthorSchema = exports.zTaskSchema = exports.zTaskCreatorSchema = exports.zTaskOnFailureSchema = exports.zTaskAutoSpecSchema = exports.zTaskDedupSchema = exports.zTaskRetryPolicySchema = exports.zTaskLockSchema = exports.zTaskUserAssigneeSchema = exports.zTaskScheduleSchema = exports.zTaskExternalLinkSchema = exports.zTaskExecutionStatusSchema = exports.zTaskExternalObjectTypeSchema = exports.zTaskDedupWindowSchema = exports.zTaskDedupScopeSchema = exports.zTaskRetryStrategySchema = exports.zTaskAutoHandlerSchema = exports.zTaskModeSchema = exports.zTaskSourceSchema = exports.zTaskPrioritySchema = exports.zTaskStatusSchema = exports.zTaskActionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const zod_schemas_1 = require("../shared/zod-schemas");
|
|
6
6
|
exports.zTaskActionSchema = zod_1.z.enum([
|
|
@@ -12,10 +12,28 @@ exports.zTaskStatusSchema = zod_1.z.enum([
|
|
|
12
12
|
"not_started",
|
|
13
13
|
"in_progress",
|
|
14
14
|
"completed",
|
|
15
|
+
"failed",
|
|
15
16
|
"cancelled",
|
|
16
17
|
"on_hold",
|
|
18
|
+
"suppressed",
|
|
17
19
|
]);
|
|
18
20
|
exports.zTaskPrioritySchema = zod_1.z.enum(["low", "medium", "high"]);
|
|
21
|
+
exports.zTaskSourceSchema = zod_1.z.enum(["user", "automation_hub", "system"]);
|
|
22
|
+
exports.zTaskModeSchema = zod_1.z.enum(["human", "auto"]);
|
|
23
|
+
exports.zTaskAutoHandlerSchema = zod_1.z.enum([
|
|
24
|
+
"notifications",
|
|
25
|
+
"ai_agent",
|
|
26
|
+
"invoices",
|
|
27
|
+
"webhook",
|
|
28
|
+
"custom",
|
|
29
|
+
]);
|
|
30
|
+
exports.zTaskRetryStrategySchema = zod_1.z.enum(["fixed", "exponential"]);
|
|
31
|
+
exports.zTaskDedupScopeSchema = zod_1.z.enum([
|
|
32
|
+
"per_recipient",
|
|
33
|
+
"per_recipient_and_object",
|
|
34
|
+
"custom",
|
|
35
|
+
]);
|
|
36
|
+
exports.zTaskDedupWindowSchema = zod_1.z.enum(["same_day", "n_hours", "custom"]);
|
|
19
37
|
exports.zTaskExternalObjectTypeSchema = zod_1.z.enum([
|
|
20
38
|
"crm_lead",
|
|
21
39
|
"med_patient",
|
|
@@ -23,72 +41,163 @@ exports.zTaskExternalObjectTypeSchema = zod_1.z.enum([
|
|
|
23
41
|
"med_appointment",
|
|
24
42
|
"chat_contact",
|
|
25
43
|
]);
|
|
26
|
-
exports.
|
|
27
|
-
|
|
28
|
-
"content_generation",
|
|
29
|
-
"classification",
|
|
30
|
-
"extraction",
|
|
31
|
-
"summarization",
|
|
32
|
-
"translation",
|
|
33
|
-
"sentiment_analysis",
|
|
34
|
-
"question_answering",
|
|
35
|
-
"send_reminder",
|
|
36
|
-
"request_contact_info",
|
|
37
|
-
"request_operator_info",
|
|
38
|
-
"confirm_appointment",
|
|
39
|
-
"send_documents",
|
|
40
|
-
"create_appointment",
|
|
41
|
-
"reschedule_appointment",
|
|
42
|
-
"cancel_appointment",
|
|
43
|
-
"financial_charge",
|
|
44
|
-
"custom",
|
|
45
|
-
]);
|
|
46
|
-
// Schema para a interface ITaskExternalLink
|
|
44
|
+
exports.zTaskExecutionStatusSchema = zod_1.z.enum(["success", "error", "retry"]);
|
|
45
|
+
// Schema para ITaskExternalLink
|
|
47
46
|
exports.zTaskExternalLinkSchema = zod_1.z.object({
|
|
48
47
|
type: exports.zTaskExternalObjectTypeSchema,
|
|
49
48
|
id: zod_1.z.string(),
|
|
49
|
+
label: zod_1.z.string().optional(),
|
|
50
|
+
});
|
|
51
|
+
// Schema para ITaskSchedule
|
|
52
|
+
exports.zTaskScheduleSchema = zod_1.z.object({
|
|
53
|
+
execute_at: zod_1.z.coerce.date().optional(),
|
|
54
|
+
due_at: zod_1.z.coerce.date().optional(),
|
|
55
|
+
timezone: zod_1.z.string().optional(),
|
|
56
|
+
});
|
|
57
|
+
// Schema para ITaskUserAssignee
|
|
58
|
+
exports.zTaskUserAssigneeSchema = zod_1.z.object({
|
|
59
|
+
kind: zod_1.z.literal("user"),
|
|
60
|
+
name: zod_1.z.string().optional(),
|
|
61
|
+
ref: zod_1.z.any().optional(), // FirestoreDocumentReference
|
|
62
|
+
});
|
|
63
|
+
// Schema para ITaskLock
|
|
64
|
+
exports.zTaskLockSchema = zod_1.z.object({
|
|
65
|
+
locked_by: zod_1.z.string(),
|
|
66
|
+
lock_until: zod_1.z.coerce.date(),
|
|
67
|
+
});
|
|
68
|
+
// Schema para ITaskRetryPolicy
|
|
69
|
+
exports.zTaskRetryPolicySchema = zod_1.z.object({
|
|
70
|
+
max_attempts: zod_1.z.number(),
|
|
71
|
+
attempt: zod_1.z.number(),
|
|
72
|
+
strategy: exports.zTaskRetryStrategySchema,
|
|
73
|
+
backoff_seconds: zod_1.z.number(),
|
|
74
|
+
next_attempt_at: zod_1.z.coerce.date().optional(),
|
|
75
|
+
last_error: zod_1.z
|
|
76
|
+
.object({
|
|
77
|
+
message: zod_1.z.string(),
|
|
78
|
+
code: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional(),
|
|
79
|
+
at: zod_1.z.coerce.date(),
|
|
80
|
+
details: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
81
|
+
})
|
|
82
|
+
.optional(),
|
|
83
|
+
});
|
|
84
|
+
// Schema para ITaskDedup
|
|
85
|
+
exports.zTaskDedupSchema = zod_1.z.object({
|
|
86
|
+
enabled: zod_1.z.boolean(),
|
|
87
|
+
key: zod_1.z.string(),
|
|
88
|
+
group_key: zod_1.z.string().optional(),
|
|
89
|
+
scope: exports.zTaskDedupScopeSchema.optional(),
|
|
90
|
+
window: exports.zTaskDedupWindowSchema.optional(),
|
|
91
|
+
window_hours: zod_1.z.number().optional(),
|
|
92
|
+
importance: zod_1.z.number().optional(),
|
|
93
|
+
});
|
|
94
|
+
// Schema para ITaskAutoSpec
|
|
95
|
+
exports.zTaskAutoSpecSchema = zod_1.z.object({
|
|
96
|
+
handler: exports.zTaskAutoHandlerSchema,
|
|
97
|
+
kind: zod_1.z.string(),
|
|
98
|
+
version: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).optional(),
|
|
99
|
+
payload: zod_1.z.record(zod_1.z.unknown()),
|
|
100
|
+
idempotency_key: zod_1.z.string().optional(),
|
|
101
|
+
});
|
|
102
|
+
// Schema para ITaskOnFailure
|
|
103
|
+
exports.zTaskOnFailureSchema = zod_1.z.object({
|
|
104
|
+
handoff_to_user: zod_1.z
|
|
105
|
+
.object({
|
|
106
|
+
name: zod_1.z.string().optional(),
|
|
107
|
+
ref: zod_1.z.any().optional(), // FirestoreDocumentReference
|
|
108
|
+
})
|
|
109
|
+
.optional(),
|
|
110
|
+
create_handoff_task: zod_1.z
|
|
111
|
+
.object({
|
|
112
|
+
title: zod_1.z.string().optional(),
|
|
113
|
+
description: zod_1.z.string().optional(),
|
|
114
|
+
priority: exports.zTaskPrioritySchema.optional(),
|
|
115
|
+
tags: zod_1.z.array(zod_schemas_1.zTagSchema).nullable().optional(),
|
|
116
|
+
})
|
|
117
|
+
.optional(),
|
|
118
|
+
auto_fallbacks: zod_1.z
|
|
119
|
+
.array(zod_1.z.object({
|
|
120
|
+
handler: exports.zTaskAutoHandlerSchema,
|
|
121
|
+
kind: zod_1.z.string(),
|
|
122
|
+
payload: zod_1.z.record(zod_1.z.unknown()),
|
|
123
|
+
}))
|
|
124
|
+
.optional(),
|
|
50
125
|
});
|
|
51
|
-
// Schema para
|
|
126
|
+
// Schema para creator object
|
|
127
|
+
exports.zTaskCreatorSchema = zod_1.z.object({
|
|
128
|
+
name: zod_1.z.string(),
|
|
129
|
+
ref: zod_1.z.any().optional(), // FirestoreDocumentReference
|
|
130
|
+
});
|
|
131
|
+
// Schema para ITaskBase / ITask
|
|
52
132
|
exports.zTaskSchema = zod_schemas_1.zFireDocSchema
|
|
53
133
|
.extend({
|
|
54
134
|
title: zod_1.z.string(),
|
|
55
135
|
description: zod_1.z.string().optional(),
|
|
56
|
-
creatorName: zod_1.z.string(),
|
|
57
|
-
creatorRef: zod_1.z.any().optional(),
|
|
58
|
-
startDate: zod_1.z.coerce.date(),
|
|
59
|
-
dueDate: zod_1.z.coerce.date().optional(),
|
|
60
136
|
status: exports.zTaskStatusSchema,
|
|
61
137
|
priority: exports.zTaskPrioritySchema.optional(),
|
|
62
|
-
|
|
63
|
-
|
|
138
|
+
importance: zod_1.z.number().min(0).max(100).optional(),
|
|
139
|
+
source: exports.zTaskSourceSchema,
|
|
140
|
+
creator: exports.zTaskCreatorSchema,
|
|
141
|
+
schedule: exports.zTaskScheduleSchema.optional(),
|
|
64
142
|
tags: zod_1.z.array(zod_schemas_1.zTagSchema).nullable().optional(),
|
|
65
|
-
// IA (Inteligência Artificial) related fields
|
|
66
|
-
ia_assigned: zod_1.z.boolean().optional(),
|
|
67
|
-
ia_agent: zod_1.z.string().optional(),
|
|
68
|
-
ia_duescheduled: zod_1.z.coerce.date().optional(),
|
|
69
|
-
ia_task_type: exports.zIATaskTypeSchema.optional(),
|
|
70
|
-
ia_result: zod_1.z.string().optional(),
|
|
71
|
-
ia_result_code: zod_1.z.number().optional(),
|
|
72
|
-
ia_started_at: zod_1.z.coerce.date().optional(),
|
|
73
|
-
ia_completed_at: zod_1.z.coerce.date().optional(),
|
|
74
|
-
ia_error: zod_1.z.string().optional(),
|
|
75
|
-
ia_retry_count: zod_1.z.number().optional(),
|
|
76
|
-
ia_metadata: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
77
|
-
ia_prompt: zod_1.z.string().optional(),
|
|
78
|
-
ia_model: zod_1.z.string().optional(),
|
|
79
|
-
ia_progress: zod_1.z.number().min(0).max(100).optional(),
|
|
80
|
-
// External object links
|
|
81
143
|
externalLinks: zod_1.z.array(exports.zTaskExternalLinkSchema).optional(),
|
|
144
|
+
idempotency_key: zod_1.z.string().optional(),
|
|
145
|
+
dedup: exports.zTaskDedupSchema.optional(),
|
|
146
|
+
metadata: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
147
|
+
// Mode-specific fields
|
|
148
|
+
mode: exports.zTaskModeSchema,
|
|
149
|
+
assignee: exports.zTaskUserAssigneeSchema.optional(), // for human tasks
|
|
150
|
+
lock: exports.zTaskLockSchema.optional(), // for auto tasks
|
|
151
|
+
retry: exports.zTaskRetryPolicySchema.optional(), // for auto tasks
|
|
152
|
+
on_failure: exports.zTaskOnFailureSchema.optional(), // for auto tasks
|
|
153
|
+
auto: exports.zTaskAutoSpecSchema.optional(), // for auto tasks (required when mode=auto)
|
|
82
154
|
})
|
|
83
155
|
.passthrough();
|
|
84
|
-
// Schema para
|
|
156
|
+
// Schema para ITaskComment
|
|
157
|
+
exports.zTaskCommentAuthorSchema = zod_1.z.object({
|
|
158
|
+
name: zod_1.z.string(),
|
|
159
|
+
ref: zod_1.z.any().optional(), // FirestoreDocumentReference
|
|
160
|
+
});
|
|
85
161
|
exports.zTaskCommentSchema = zod_schemas_1.zFireDocSchema
|
|
86
162
|
.extend({
|
|
87
163
|
taskId: zod_1.z.string(),
|
|
88
164
|
text: zod_1.z.string(),
|
|
89
|
-
|
|
90
|
-
authorRef: zod_1.z.any().optional(),
|
|
165
|
+
author: exports.zTaskCommentAuthorSchema,
|
|
91
166
|
edited: zod_1.z.boolean().optional(),
|
|
92
167
|
edited_at: zod_1.z.coerce.date().optional(),
|
|
93
168
|
})
|
|
94
169
|
.passthrough();
|
|
170
|
+
// Schema para ITaskExecution
|
|
171
|
+
exports.zTaskExecutionErrorSchema = zod_1.z.object({
|
|
172
|
+
message: zod_1.z.string(),
|
|
173
|
+
code: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional(),
|
|
174
|
+
details: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
175
|
+
});
|
|
176
|
+
exports.zTaskExecutionProviderSchema = zod_1.z.object({
|
|
177
|
+
name: zod_1.z.string().optional(),
|
|
178
|
+
message_id: zod_1.z.string().optional(),
|
|
179
|
+
});
|
|
180
|
+
exports.zTaskExecutionSchema = zod_schemas_1.zFireDocSchema
|
|
181
|
+
.extend({
|
|
182
|
+
taskId: zod_1.z.string(),
|
|
183
|
+
handler: exports.zTaskAutoHandlerSchema,
|
|
184
|
+
kind: zod_1.z.string(),
|
|
185
|
+
status: exports.zTaskExecutionStatusSchema,
|
|
186
|
+
attempt: zod_1.z.number(),
|
|
187
|
+
started_at: zod_1.z.coerce.date(),
|
|
188
|
+
completed_at: zod_1.z.coerce.date().optional(),
|
|
189
|
+
result: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
190
|
+
error: exports.zTaskExecutionErrorSchema.optional(),
|
|
191
|
+
provider: exports.zTaskExecutionProviderSchema.optional(),
|
|
192
|
+
})
|
|
193
|
+
.passthrough();
|
|
194
|
+
// Schema para ITaskLog
|
|
195
|
+
exports.zTaskLogSchema = zod_schemas_1.zFireDocSchema
|
|
196
|
+
.extend({
|
|
197
|
+
taskId: zod_1.z.string(),
|
|
198
|
+
level: zod_1.z.enum(["debug", "info", "warn", "error"]),
|
|
199
|
+
message: zod_1.z.string(),
|
|
200
|
+
data: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
201
|
+
at: zod_1.z.coerce.date(),
|
|
202
|
+
})
|
|
203
|
+
.passthrough();
|
|
@@ -11,12 +11,36 @@ export const zTaskStatusSchema = z.enum([
|
|
|
11
11
|
"not_started",
|
|
12
12
|
"in_progress",
|
|
13
13
|
"completed",
|
|
14
|
+
"failed",
|
|
14
15
|
"cancelled",
|
|
15
16
|
"on_hold",
|
|
17
|
+
"suppressed",
|
|
16
18
|
]);
|
|
17
19
|
|
|
18
20
|
export const zTaskPrioritySchema = z.enum(["low", "medium", "high"]);
|
|
19
21
|
|
|
22
|
+
export const zTaskSourceSchema = z.enum(["user", "automation_hub", "system"]);
|
|
23
|
+
|
|
24
|
+
export const zTaskModeSchema = z.enum(["human", "auto"]);
|
|
25
|
+
|
|
26
|
+
export const zTaskAutoHandlerSchema = z.enum([
|
|
27
|
+
"notifications",
|
|
28
|
+
"ai_agent",
|
|
29
|
+
"invoices",
|
|
30
|
+
"webhook",
|
|
31
|
+
"custom",
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
export const zTaskRetryStrategySchema = z.enum(["fixed", "exponential"]);
|
|
35
|
+
|
|
36
|
+
export const zTaskDedupScopeSchema = z.enum([
|
|
37
|
+
"per_recipient",
|
|
38
|
+
"per_recipient_and_object",
|
|
39
|
+
"custom",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export const zTaskDedupWindowSchema = z.enum(["same_day", "n_hours", "custom"]);
|
|
43
|
+
|
|
20
44
|
export const zTaskExternalObjectTypeSchema = z.enum([
|
|
21
45
|
"crm_lead",
|
|
22
46
|
"med_patient",
|
|
@@ -25,75 +49,181 @@ export const zTaskExternalObjectTypeSchema = z.enum([
|
|
|
25
49
|
"chat_contact",
|
|
26
50
|
]);
|
|
27
51
|
|
|
28
|
-
export const
|
|
29
|
-
"data_analysis",
|
|
30
|
-
"content_generation",
|
|
31
|
-
"classification",
|
|
32
|
-
"extraction",
|
|
33
|
-
"summarization",
|
|
34
|
-
"translation",
|
|
35
|
-
"sentiment_analysis",
|
|
36
|
-
"question_answering",
|
|
37
|
-
"send_reminder",
|
|
38
|
-
"request_contact_info",
|
|
39
|
-
"request_operator_info",
|
|
40
|
-
"confirm_appointment",
|
|
41
|
-
"send_documents",
|
|
42
|
-
"create_appointment",
|
|
43
|
-
"reschedule_appointment",
|
|
44
|
-
"cancel_appointment",
|
|
45
|
-
"financial_charge",
|
|
46
|
-
"custom",
|
|
47
|
-
]);
|
|
52
|
+
export const zTaskExecutionStatusSchema = z.enum(["success", "error", "retry"]);
|
|
48
53
|
|
|
49
|
-
// Schema para
|
|
54
|
+
// Schema para ITaskExternalLink
|
|
50
55
|
export const zTaskExternalLinkSchema = z.object({
|
|
51
56
|
type: zTaskExternalObjectTypeSchema,
|
|
52
57
|
id: z.string(),
|
|
58
|
+
label: z.string().optional(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Schema para ITaskSchedule
|
|
62
|
+
export const zTaskScheduleSchema = z.object({
|
|
63
|
+
execute_at: z.coerce.date().optional(),
|
|
64
|
+
due_at: z.coerce.date().optional(),
|
|
65
|
+
timezone: z.string().optional(),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Schema para ITaskUserAssignee
|
|
69
|
+
export const zTaskUserAssigneeSchema = z.object({
|
|
70
|
+
kind: z.literal("user"),
|
|
71
|
+
name: z.string().optional(),
|
|
72
|
+
ref: z.any().optional(), // FirestoreDocumentReference
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Schema para ITaskLock
|
|
76
|
+
export const zTaskLockSchema = z.object({
|
|
77
|
+
locked_by: z.string(),
|
|
78
|
+
lock_until: z.coerce.date(),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Schema para ITaskRetryPolicy
|
|
82
|
+
export const zTaskRetryPolicySchema = z.object({
|
|
83
|
+
max_attempts: z.number(),
|
|
84
|
+
attempt: z.number(),
|
|
85
|
+
strategy: zTaskRetryStrategySchema,
|
|
86
|
+
backoff_seconds: z.number(),
|
|
87
|
+
next_attempt_at: z.coerce.date().optional(),
|
|
88
|
+
last_error: z
|
|
89
|
+
.object({
|
|
90
|
+
message: z.string(),
|
|
91
|
+
code: z.union([z.string(), z.number()]).optional(),
|
|
92
|
+
at: z.coerce.date(),
|
|
93
|
+
details: z.record(z.unknown()).optional(),
|
|
94
|
+
})
|
|
95
|
+
.optional(),
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Schema para ITaskDedup
|
|
99
|
+
export const zTaskDedupSchema = z.object({
|
|
100
|
+
enabled: z.boolean(),
|
|
101
|
+
key: z.string(),
|
|
102
|
+
group_key: z.string().optional(),
|
|
103
|
+
scope: zTaskDedupScopeSchema.optional(),
|
|
104
|
+
window: zTaskDedupWindowSchema.optional(),
|
|
105
|
+
window_hours: z.number().optional(),
|
|
106
|
+
importance: z.number().optional(),
|
|
53
107
|
});
|
|
54
108
|
|
|
55
|
-
// Schema para
|
|
109
|
+
// Schema para ITaskAutoSpec
|
|
110
|
+
export const zTaskAutoSpecSchema = z.object({
|
|
111
|
+
handler: zTaskAutoHandlerSchema,
|
|
112
|
+
kind: z.string(),
|
|
113
|
+
version: z.union([z.number(), z.string()]).optional(),
|
|
114
|
+
payload: z.record(z.unknown()),
|
|
115
|
+
idempotency_key: z.string().optional(),
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Schema para ITaskOnFailure
|
|
119
|
+
export const zTaskOnFailureSchema = z.object({
|
|
120
|
+
handoff_to_user: z
|
|
121
|
+
.object({
|
|
122
|
+
name: z.string().optional(),
|
|
123
|
+
ref: z.any().optional(), // FirestoreDocumentReference
|
|
124
|
+
})
|
|
125
|
+
.optional(),
|
|
126
|
+
create_handoff_task: z
|
|
127
|
+
.object({
|
|
128
|
+
title: z.string().optional(),
|
|
129
|
+
description: z.string().optional(),
|
|
130
|
+
priority: zTaskPrioritySchema.optional(),
|
|
131
|
+
tags: z.array(zTagSchema).nullable().optional(),
|
|
132
|
+
})
|
|
133
|
+
.optional(),
|
|
134
|
+
auto_fallbacks: z
|
|
135
|
+
.array(
|
|
136
|
+
z.object({
|
|
137
|
+
handler: zTaskAutoHandlerSchema,
|
|
138
|
+
kind: z.string(),
|
|
139
|
+
payload: z.record(z.unknown()),
|
|
140
|
+
})
|
|
141
|
+
)
|
|
142
|
+
.optional(),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Schema para creator object
|
|
146
|
+
export const zTaskCreatorSchema = z.object({
|
|
147
|
+
name: z.string(),
|
|
148
|
+
ref: z.any().optional(), // FirestoreDocumentReference
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Schema para ITaskBase / ITask
|
|
56
152
|
export const zTaskSchema = zFireDocSchema
|
|
57
153
|
.extend({
|
|
58
154
|
title: z.string(),
|
|
59
155
|
description: z.string().optional(),
|
|
60
|
-
creatorName: z.string(),
|
|
61
|
-
creatorRef: z.any().optional(),
|
|
62
|
-
startDate: z.coerce.date(),
|
|
63
|
-
dueDate: z.coerce.date().optional(),
|
|
64
156
|
status: zTaskStatusSchema,
|
|
65
157
|
priority: zTaskPrioritySchema.optional(),
|
|
66
|
-
|
|
67
|
-
|
|
158
|
+
importance: z.number().min(0).max(100).optional(),
|
|
159
|
+
source: zTaskSourceSchema,
|
|
160
|
+
creator: zTaskCreatorSchema,
|
|
161
|
+
schedule: zTaskScheduleSchema.optional(),
|
|
68
162
|
tags: z.array(zTagSchema).nullable().optional(),
|
|
69
|
-
// IA (Inteligência Artificial) related fields
|
|
70
|
-
ia_assigned: z.boolean().optional(),
|
|
71
|
-
ia_agent: z.string().optional(),
|
|
72
|
-
ia_duescheduled: z.coerce.date().optional(),
|
|
73
|
-
ia_task_type: zIATaskTypeSchema.optional(),
|
|
74
|
-
ia_result: z.string().optional(),
|
|
75
|
-
ia_result_code: z.number().optional(),
|
|
76
|
-
ia_started_at: z.coerce.date().optional(),
|
|
77
|
-
ia_completed_at: z.coerce.date().optional(),
|
|
78
|
-
ia_error: z.string().optional(),
|
|
79
|
-
ia_retry_count: z.number().optional(),
|
|
80
|
-
ia_metadata: z.record(z.unknown()).optional(),
|
|
81
|
-
ia_prompt: z.string().optional(),
|
|
82
|
-
ia_model: z.string().optional(),
|
|
83
|
-
ia_progress: z.number().min(0).max(100).optional(),
|
|
84
|
-
// External object links
|
|
85
163
|
externalLinks: z.array(zTaskExternalLinkSchema).optional(),
|
|
164
|
+
idempotency_key: z.string().optional(),
|
|
165
|
+
dedup: zTaskDedupSchema.optional(),
|
|
166
|
+
metadata: z.record(z.unknown()).optional(),
|
|
167
|
+
// Mode-specific fields
|
|
168
|
+
mode: zTaskModeSchema,
|
|
169
|
+
assignee: zTaskUserAssigneeSchema.optional(), // for human tasks
|
|
170
|
+
lock: zTaskLockSchema.optional(), // for auto tasks
|
|
171
|
+
retry: zTaskRetryPolicySchema.optional(), // for auto tasks
|
|
172
|
+
on_failure: zTaskOnFailureSchema.optional(), // for auto tasks
|
|
173
|
+
auto: zTaskAutoSpecSchema.optional(), // for auto tasks (required when mode=auto)
|
|
86
174
|
})
|
|
87
175
|
.passthrough();
|
|
88
176
|
|
|
89
|
-
// Schema para
|
|
177
|
+
// Schema para ITaskComment
|
|
178
|
+
export const zTaskCommentAuthorSchema = z.object({
|
|
179
|
+
name: z.string(),
|
|
180
|
+
ref: z.any().optional(), // FirestoreDocumentReference
|
|
181
|
+
});
|
|
182
|
+
|
|
90
183
|
export const zTaskCommentSchema = zFireDocSchema
|
|
91
184
|
.extend({
|
|
92
185
|
taskId: z.string(),
|
|
93
186
|
text: z.string(),
|
|
94
|
-
|
|
95
|
-
authorRef: z.any().optional(),
|
|
187
|
+
author: zTaskCommentAuthorSchema,
|
|
96
188
|
edited: z.boolean().optional(),
|
|
97
189
|
edited_at: z.coerce.date().optional(),
|
|
98
190
|
})
|
|
99
191
|
.passthrough();
|
|
192
|
+
|
|
193
|
+
// Schema para ITaskExecution
|
|
194
|
+
export const zTaskExecutionErrorSchema = z.object({
|
|
195
|
+
message: z.string(),
|
|
196
|
+
code: z.union([z.string(), z.number()]).optional(),
|
|
197
|
+
details: z.record(z.unknown()).optional(),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
export const zTaskExecutionProviderSchema = z.object({
|
|
201
|
+
name: z.string().optional(),
|
|
202
|
+
message_id: z.string().optional(),
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
export const zTaskExecutionSchema = zFireDocSchema
|
|
206
|
+
.extend({
|
|
207
|
+
taskId: z.string(),
|
|
208
|
+
handler: zTaskAutoHandlerSchema,
|
|
209
|
+
kind: z.string(),
|
|
210
|
+
status: zTaskExecutionStatusSchema,
|
|
211
|
+
attempt: z.number(),
|
|
212
|
+
started_at: z.coerce.date(),
|
|
213
|
+
completed_at: z.coerce.date().optional(),
|
|
214
|
+
result: z.record(z.unknown()).optional(),
|
|
215
|
+
error: zTaskExecutionErrorSchema.optional(),
|
|
216
|
+
provider: zTaskExecutionProviderSchema.optional(),
|
|
217
|
+
})
|
|
218
|
+
.passthrough();
|
|
219
|
+
|
|
220
|
+
// Schema para ITaskLog
|
|
221
|
+
export const zTaskLogSchema = zFireDocSchema
|
|
222
|
+
.extend({
|
|
223
|
+
taskId: z.string(),
|
|
224
|
+
level: z.enum(["debug", "info", "warn", "error"]),
|
|
225
|
+
message: z.string(),
|
|
226
|
+
data: z.record(z.unknown()).optional(),
|
|
227
|
+
at: z.coerce.date(),
|
|
228
|
+
})
|
|
229
|
+
.passthrough();
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { FirestoreDocumentReference, IFireDoc } from "../shared";
|
|
2
|
+
export declare const EvoNotificationsCollections: {
|
|
3
|
+
readonly Messages: "messages";
|
|
4
|
+
readonly Attempts: "attempts";
|
|
5
|
+
readonly Logs: "logs";
|
|
6
|
+
};
|
|
7
|
+
export type EvoNotificationsCollectionName = (typeof EvoNotificationsCollections)[keyof typeof EvoNotificationsCollections];
|
|
8
|
+
export declare const NotificationTaskKindEnum: {
|
|
9
|
+
readonly Send: "notification.send";
|
|
10
|
+
};
|
|
11
|
+
export type NotificationTaskKind = (typeof NotificationTaskKindEnum)[keyof typeof NotificationTaskKindEnum];
|
|
12
|
+
export declare const NotificationsTopics: {
|
|
13
|
+
readonly ExecuteRequests: "notifications.execute_requests";
|
|
14
|
+
readonly ExecutionReports: "notifications.execution_reports";
|
|
15
|
+
readonly ProviderWebhooks: "notifications.provider_webhooks";
|
|
16
|
+
};
|
|
17
|
+
export type NotificationsTopic = (typeof NotificationsTopics)[keyof typeof NotificationsTopics];
|
|
18
|
+
export declare const NotificationChannelTypeEnum: {
|
|
19
|
+
readonly WhatsApp: "whatsapp";
|
|
20
|
+
readonly Email: "email";
|
|
21
|
+
readonly SMS: "sms";
|
|
22
|
+
readonly Push: "push";
|
|
23
|
+
};
|
|
24
|
+
export type NotificationChannelType = (typeof NotificationChannelTypeEnum)[keyof typeof NotificationChannelTypeEnum];
|
|
25
|
+
export declare const NotificationMessageStatusEnum: {
|
|
26
|
+
readonly Queued: "queued";
|
|
27
|
+
readonly Processing: "processing";
|
|
28
|
+
readonly Sent: "sent";
|
|
29
|
+
readonly Delivered: "delivered";
|
|
30
|
+
readonly Failed: "failed";
|
|
31
|
+
readonly Cancelled: "cancelled";
|
|
32
|
+
readonly Suppressed: "suppressed";
|
|
33
|
+
};
|
|
34
|
+
export type NotificationMessageStatus = (typeof NotificationMessageStatusEnum)[keyof typeof NotificationMessageStatusEnum];
|
|
35
|
+
export declare const NotificationAttemptStatusEnum: {
|
|
36
|
+
readonly Success: "success";
|
|
37
|
+
readonly Retry: "retry";
|
|
38
|
+
readonly Error: "error";
|
|
39
|
+
};
|
|
40
|
+
export type NotificationAttemptStatus = (typeof NotificationAttemptStatusEnum)[keyof typeof NotificationAttemptStatusEnum];
|
|
41
|
+
export declare const NotificationRecipientKindEnum: {
|
|
42
|
+
readonly Patient: "patient";
|
|
43
|
+
readonly Professional: "professional";
|
|
44
|
+
readonly Preconfigured: "preconfigured";
|
|
45
|
+
readonly Raw: "raw";
|
|
46
|
+
};
|
|
47
|
+
export type NotificationRecipientKind = (typeof NotificationRecipientKindEnum)[keyof typeof NotificationRecipientKindEnum];
|
|
48
|
+
export interface INotificationRecipient {
|
|
49
|
+
kind: NotificationRecipientKind;
|
|
50
|
+
id?: string;
|
|
51
|
+
ref?: FirestoreDocumentReference;
|
|
52
|
+
address?: string;
|
|
53
|
+
display_name?: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface INotificationChannelRef {
|
|
57
|
+
type: NotificationChannelType;
|
|
58
|
+
channel_id: string;
|
|
59
|
+
sender_id?: string;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
export interface INotificationTemplateRef {
|
|
63
|
+
template_id: string;
|
|
64
|
+
locale?: string;
|
|
65
|
+
version?: number | string;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
export interface INotificationProviderMeta {
|
|
69
|
+
name?: string;
|
|
70
|
+
message_id?: string;
|
|
71
|
+
status?: string;
|
|
72
|
+
raw?: Record<string, unknown>;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
export interface INotificationError {
|
|
76
|
+
message: string;
|
|
77
|
+
code?: string | number;
|
|
78
|
+
details?: Record<string, unknown>;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
81
|
+
export interface INotificationSendPayload {
|
|
82
|
+
kind: "notification.send";
|
|
83
|
+
classification?: string;
|
|
84
|
+
importance?: number;
|
|
85
|
+
recipient: INotificationRecipient;
|
|
86
|
+
channel: INotificationChannelRef;
|
|
87
|
+
template?: INotificationTemplateRef;
|
|
88
|
+
variables?: Record<string, unknown>;
|
|
89
|
+
routine?: {
|
|
90
|
+
id: string;
|
|
91
|
+
version?: number | string;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
};
|
|
94
|
+
idempotency_key?: string;
|
|
95
|
+
dedup_key?: string;
|
|
96
|
+
dedup_group_key?: string;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
export interface INotificationMessage extends IFireDoc {
|
|
100
|
+
tenant: string;
|
|
101
|
+
task_id?: string;
|
|
102
|
+
routine_id?: string;
|
|
103
|
+
routine_version?: number | string;
|
|
104
|
+
classification?: string;
|
|
105
|
+
importance?: number;
|
|
106
|
+
channel: INotificationChannelRef;
|
|
107
|
+
template?: INotificationTemplateRef;
|
|
108
|
+
recipient: INotificationRecipient;
|
|
109
|
+
variables?: Record<string, unknown>;
|
|
110
|
+
status: NotificationMessageStatus;
|
|
111
|
+
queued_at: Date;
|
|
112
|
+
processing_started_at?: Date;
|
|
113
|
+
sent_at?: Date;
|
|
114
|
+
delivered_at?: Date;
|
|
115
|
+
completed_at?: Date;
|
|
116
|
+
provider?: INotificationProviderMeta;
|
|
117
|
+
error?: INotificationError;
|
|
118
|
+
dedup_key?: string;
|
|
119
|
+
dedup_group_key?: string;
|
|
120
|
+
date_bucket?: string;
|
|
121
|
+
[key: string]: unknown;
|
|
122
|
+
}
|
|
123
|
+
export interface INotificationAttempt extends IFireDoc {
|
|
124
|
+
message_id: string;
|
|
125
|
+
task_id?: string;
|
|
126
|
+
attempt: number;
|
|
127
|
+
status: NotificationAttemptStatus;
|
|
128
|
+
requested_at: Date;
|
|
129
|
+
started_at?: Date;
|
|
130
|
+
finished_at?: Date;
|
|
131
|
+
provider?: INotificationProviderMeta;
|
|
132
|
+
error?: INotificationError;
|
|
133
|
+
request_summary?: Record<string, unknown>;
|
|
134
|
+
response_summary?: Record<string, unknown>;
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
}
|
|
137
|
+
export interface INotificationLog extends IFireDoc {
|
|
138
|
+
message_id: string;
|
|
139
|
+
level: "debug" | "info" | "warn" | "error";
|
|
140
|
+
message: string;
|
|
141
|
+
data?: Record<string, unknown>;
|
|
142
|
+
at: Date;
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
}
|