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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationRecipientKindEnum = exports.NotificationAttemptStatusEnum = exports.NotificationMessageStatusEnum = exports.NotificationChannelTypeEnum = exports.NotificationsTopics = exports.NotificationTaskKindEnum = exports.EvoNotificationsCollections = void 0;
|
|
4
|
+
// ======================================================
|
|
5
|
+
// evo-notifications
|
|
6
|
+
//
|
|
7
|
+
// Responsibilities (types only):
|
|
8
|
+
// - Define the notification execution payload schema (used by Task Runner)
|
|
9
|
+
// - Define persistence models for notification messages and attempts
|
|
10
|
+
// - Keep channel/provider details generic and extensible
|
|
11
|
+
//
|
|
12
|
+
// Firestore (per tenant):
|
|
13
|
+
// - Root app path: /tenants/{tenant}/apps/evo-notifications
|
|
14
|
+
// - Messages: /tenants/{tenant}/apps/evo-notifications/messages/{messageId}
|
|
15
|
+
// - Attempts: /tenants/{tenant}/apps/evo-notifications/messages/{messageId}/attempts/{attemptId}
|
|
16
|
+
// - Logs: /tenants/{tenant}/apps/evo-notifications/messages/{messageId}/logs/{logId}
|
|
17
|
+
// ======================================================
|
|
18
|
+
// ----- Firestore collections
|
|
19
|
+
exports.EvoNotificationsCollections = {
|
|
20
|
+
Messages: "messages",
|
|
21
|
+
Attempts: "attempts",
|
|
22
|
+
Logs: "logs",
|
|
23
|
+
};
|
|
24
|
+
// ----- Task Runner integration
|
|
25
|
+
exports.NotificationTaskKindEnum = {
|
|
26
|
+
Send: "notification.send",
|
|
27
|
+
};
|
|
28
|
+
// Logical Pub/Sub topic names (optional, but useful as shared constants)
|
|
29
|
+
exports.NotificationsTopics = {
|
|
30
|
+
ExecuteRequests: "notifications.execute_requests",
|
|
31
|
+
ExecutionReports: "notifications.execution_reports",
|
|
32
|
+
ProviderWebhooks: "notifications.provider_webhooks",
|
|
33
|
+
};
|
|
34
|
+
// ----- Channel types
|
|
35
|
+
exports.NotificationChannelTypeEnum = {
|
|
36
|
+
WhatsApp: "whatsapp",
|
|
37
|
+
Email: "email",
|
|
38
|
+
SMS: "sms",
|
|
39
|
+
Push: "push",
|
|
40
|
+
};
|
|
41
|
+
// ----- High-level message status (channel-agnostic)
|
|
42
|
+
exports.NotificationMessageStatusEnum = {
|
|
43
|
+
Queued: "queued", // created and waiting execution
|
|
44
|
+
Processing: "processing", // being handled by notifications service
|
|
45
|
+
Sent: "sent", // accepted by provider
|
|
46
|
+
Delivered: "delivered", // delivery confirmed (when supported)
|
|
47
|
+
Failed: "failed", // permanent failure
|
|
48
|
+
Cancelled: "cancelled",
|
|
49
|
+
Suppressed: "suppressed", // dedup/skip decision
|
|
50
|
+
};
|
|
51
|
+
// ----- Attempt status
|
|
52
|
+
exports.NotificationAttemptStatusEnum = {
|
|
53
|
+
Success: "success",
|
|
54
|
+
Retry: "retry",
|
|
55
|
+
Error: "error",
|
|
56
|
+
};
|
|
57
|
+
// ----- Recipient
|
|
58
|
+
exports.NotificationRecipientKindEnum = {
|
|
59
|
+
Patient: "patient",
|
|
60
|
+
Professional: "professional",
|
|
61
|
+
Preconfigured: "preconfigured",
|
|
62
|
+
Raw: "raw",
|
|
63
|
+
};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import type { FirestoreDocumentReference, IFireDoc } from "../shared";
|
|
2
|
+
|
|
3
|
+
// ======================================================
|
|
4
|
+
// evo-notifications
|
|
5
|
+
//
|
|
6
|
+
// Responsibilities (types only):
|
|
7
|
+
// - Define the notification execution payload schema (used by Task Runner)
|
|
8
|
+
// - Define persistence models for notification messages and attempts
|
|
9
|
+
// - Keep channel/provider details generic and extensible
|
|
10
|
+
//
|
|
11
|
+
// Firestore (per tenant):
|
|
12
|
+
// - Root app path: /tenants/{tenant}/apps/evo-notifications
|
|
13
|
+
// - Messages: /tenants/{tenant}/apps/evo-notifications/messages/{messageId}
|
|
14
|
+
// - Attempts: /tenants/{tenant}/apps/evo-notifications/messages/{messageId}/attempts/{attemptId}
|
|
15
|
+
// - Logs: /tenants/{tenant}/apps/evo-notifications/messages/{messageId}/logs/{logId}
|
|
16
|
+
// ======================================================
|
|
17
|
+
|
|
18
|
+
// ----- Firestore collections
|
|
19
|
+
export const EvoNotificationsCollections = {
|
|
20
|
+
Messages: "messages",
|
|
21
|
+
Attempts: "attempts",
|
|
22
|
+
Logs: "logs",
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
export type EvoNotificationsCollectionName =
|
|
26
|
+
(typeof EvoNotificationsCollections)[keyof typeof EvoNotificationsCollections];
|
|
27
|
+
|
|
28
|
+
// ----- Task Runner integration
|
|
29
|
+
export const NotificationTaskKindEnum = {
|
|
30
|
+
Send: "notification.send",
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
export type NotificationTaskKind =
|
|
34
|
+
(typeof NotificationTaskKindEnum)[keyof typeof NotificationTaskKindEnum];
|
|
35
|
+
|
|
36
|
+
// Logical Pub/Sub topic names (optional, but useful as shared constants)
|
|
37
|
+
export const NotificationsTopics = {
|
|
38
|
+
ExecuteRequests: "notifications.execute_requests",
|
|
39
|
+
ExecutionReports: "notifications.execution_reports",
|
|
40
|
+
ProviderWebhooks: "notifications.provider_webhooks",
|
|
41
|
+
} as const;
|
|
42
|
+
|
|
43
|
+
export type NotificationsTopic =
|
|
44
|
+
(typeof NotificationsTopics)[keyof typeof NotificationsTopics];
|
|
45
|
+
|
|
46
|
+
// ----- Channel types
|
|
47
|
+
export const NotificationChannelTypeEnum = {
|
|
48
|
+
WhatsApp: "whatsapp",
|
|
49
|
+
Email: "email",
|
|
50
|
+
SMS: "sms",
|
|
51
|
+
Push: "push",
|
|
52
|
+
} as const;
|
|
53
|
+
|
|
54
|
+
export type NotificationChannelType =
|
|
55
|
+
(typeof NotificationChannelTypeEnum)[keyof typeof NotificationChannelTypeEnum];
|
|
56
|
+
|
|
57
|
+
// ----- High-level message status (channel-agnostic)
|
|
58
|
+
export const NotificationMessageStatusEnum = {
|
|
59
|
+
Queued: "queued", // created and waiting execution
|
|
60
|
+
Processing: "processing", // being handled by notifications service
|
|
61
|
+
Sent: "sent", // accepted by provider
|
|
62
|
+
Delivered: "delivered", // delivery confirmed (when supported)
|
|
63
|
+
Failed: "failed", // permanent failure
|
|
64
|
+
Cancelled: "cancelled",
|
|
65
|
+
Suppressed: "suppressed", // dedup/skip decision
|
|
66
|
+
} as const;
|
|
67
|
+
|
|
68
|
+
export type NotificationMessageStatus =
|
|
69
|
+
(typeof NotificationMessageStatusEnum)[keyof typeof NotificationMessageStatusEnum];
|
|
70
|
+
|
|
71
|
+
// ----- Attempt status
|
|
72
|
+
export const NotificationAttemptStatusEnum = {
|
|
73
|
+
Success: "success",
|
|
74
|
+
Retry: "retry",
|
|
75
|
+
Error: "error",
|
|
76
|
+
} as const;
|
|
77
|
+
|
|
78
|
+
export type NotificationAttemptStatus =
|
|
79
|
+
(typeof NotificationAttemptStatusEnum)[keyof typeof NotificationAttemptStatusEnum];
|
|
80
|
+
|
|
81
|
+
// ----- Recipient
|
|
82
|
+
export const NotificationRecipientKindEnum = {
|
|
83
|
+
Patient: "patient",
|
|
84
|
+
Professional: "professional",
|
|
85
|
+
Preconfigured: "preconfigured",
|
|
86
|
+
Raw: "raw",
|
|
87
|
+
} as const;
|
|
88
|
+
|
|
89
|
+
export type NotificationRecipientKind =
|
|
90
|
+
(typeof NotificationRecipientKindEnum)[keyof typeof NotificationRecipientKindEnum];
|
|
91
|
+
|
|
92
|
+
export interface INotificationRecipient {
|
|
93
|
+
kind: NotificationRecipientKind;
|
|
94
|
+
|
|
95
|
+
// Internal references (optional)
|
|
96
|
+
id?: string; // patientId/professionalId/etc.
|
|
97
|
+
ref?: FirestoreDocumentReference;
|
|
98
|
+
|
|
99
|
+
// Destination address (required for kind=raw, may also be filled for others)
|
|
100
|
+
// - whatsapp/sms: E.164 phone
|
|
101
|
+
// - email: email address
|
|
102
|
+
// - push: device token or topic
|
|
103
|
+
address?: string;
|
|
104
|
+
|
|
105
|
+
// Display helpers
|
|
106
|
+
display_name?: string;
|
|
107
|
+
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ----- Channel reference (points to CHAT module configuration)
|
|
112
|
+
export interface INotificationChannelRef {
|
|
113
|
+
type: NotificationChannelType;
|
|
114
|
+
channel_id: string; // reference to channel config in CHAT module
|
|
115
|
+
sender_id?: string; // optional (e.g., whatsapp business number, email sender id)
|
|
116
|
+
[key: string]: unknown;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ----- Template reference
|
|
120
|
+
export interface INotificationTemplateRef {
|
|
121
|
+
template_id: string; // HSM template id, email template id, push template id...
|
|
122
|
+
locale?: string;
|
|
123
|
+
version?: number | string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ----- Provider metadata (generic)
|
|
128
|
+
export interface INotificationProviderMeta {
|
|
129
|
+
name?: string; // e.g., meta, twilio, sendgrid, firebase
|
|
130
|
+
message_id?: string; // provider-specific id
|
|
131
|
+
status?: string; // provider status string
|
|
132
|
+
raw?: Record<string, unknown>; // sanitized provider response
|
|
133
|
+
[key: string]: unknown;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ----- Error model
|
|
137
|
+
export interface INotificationError {
|
|
138
|
+
message: string;
|
|
139
|
+
code?: string | number;
|
|
140
|
+
details?: Record<string, unknown>;
|
|
141
|
+
[key: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ======================================================
|
|
145
|
+
// Payload schema for Task Runner (task.auto.kind = "notification.send")
|
|
146
|
+
// ======================================================
|
|
147
|
+
|
|
148
|
+
export interface INotificationSendPayload {
|
|
149
|
+
kind: "notification.send";
|
|
150
|
+
|
|
151
|
+
// Classification/category is useful for UI filters and dedup grouping
|
|
152
|
+
classification?: string; // e.g. REMINDER, CSAT, BILLING, SYSTEM
|
|
153
|
+
importance?: number; // 0-100 tie-breaker
|
|
154
|
+
|
|
155
|
+
// Destination + channel
|
|
156
|
+
recipient: INotificationRecipient;
|
|
157
|
+
channel: INotificationChannelRef;
|
|
158
|
+
|
|
159
|
+
// Template and variables
|
|
160
|
+
template?: INotificationTemplateRef;
|
|
161
|
+
variables?: Record<string, unknown>; // resolved upstream (Automation Hub / Task Runner)
|
|
162
|
+
|
|
163
|
+
// Optional business context
|
|
164
|
+
routine?: {
|
|
165
|
+
id: string;
|
|
166
|
+
version?: number | string;
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// Idempotency for provider send (for the same attempt)
|
|
171
|
+
idempotency_key?: string;
|
|
172
|
+
|
|
173
|
+
// Optional dedup keys (mirrors Task dedup; helpful when writing message docs)
|
|
174
|
+
dedup_key?: string;
|
|
175
|
+
dedup_group_key?: string;
|
|
176
|
+
|
|
177
|
+
[key: string]: unknown;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ======================================================
|
|
181
|
+
// Persistence models
|
|
182
|
+
// ======================================================
|
|
183
|
+
|
|
184
|
+
// A persisted notification message represents the execution of a task in this module.
|
|
185
|
+
// It should be easily listable/filterable in the UI.
|
|
186
|
+
export interface INotificationMessage extends IFireDoc {
|
|
187
|
+
tenant: string;
|
|
188
|
+
|
|
189
|
+
// Link back to the originating task
|
|
190
|
+
task_id?: string;
|
|
191
|
+
|
|
192
|
+
// Optional routine context
|
|
193
|
+
routine_id?: string;
|
|
194
|
+
routine_version?: number | string;
|
|
195
|
+
|
|
196
|
+
// Classification and importance for filtering
|
|
197
|
+
classification?: string;
|
|
198
|
+
importance?: number;
|
|
199
|
+
|
|
200
|
+
// Channel/template snapshot
|
|
201
|
+
channel: INotificationChannelRef;
|
|
202
|
+
template?: INotificationTemplateRef;
|
|
203
|
+
|
|
204
|
+
// Recipient snapshot
|
|
205
|
+
recipient: INotificationRecipient;
|
|
206
|
+
|
|
207
|
+
// Variables snapshot (avoid storing sensitive info when possible)
|
|
208
|
+
variables?: Record<string, unknown>;
|
|
209
|
+
|
|
210
|
+
// Status tracking
|
|
211
|
+
status: NotificationMessageStatus;
|
|
212
|
+
queued_at: Date;
|
|
213
|
+
processing_started_at?: Date;
|
|
214
|
+
sent_at?: Date;
|
|
215
|
+
delivered_at?: Date;
|
|
216
|
+
completed_at?: Date;
|
|
217
|
+
|
|
218
|
+
// Final outcome
|
|
219
|
+
provider?: INotificationProviderMeta;
|
|
220
|
+
error?: INotificationError;
|
|
221
|
+
|
|
222
|
+
// Dedup helpers
|
|
223
|
+
dedup_key?: string;
|
|
224
|
+
dedup_group_key?: string;
|
|
225
|
+
|
|
226
|
+
// Indexing helpers (optional)
|
|
227
|
+
date_bucket?: string; // e.g., YYYY-MM-DD (tenant timezone)
|
|
228
|
+
|
|
229
|
+
[key: string]: unknown;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Each send attempt is stored in a sub-collection to keep the message list lightweight.
|
|
233
|
+
export interface INotificationAttempt extends IFireDoc {
|
|
234
|
+
message_id: string;
|
|
235
|
+
task_id?: string;
|
|
236
|
+
|
|
237
|
+
attempt: number; // 0-based
|
|
238
|
+
status: NotificationAttemptStatus;
|
|
239
|
+
|
|
240
|
+
requested_at: Date;
|
|
241
|
+
started_at?: Date;
|
|
242
|
+
finished_at?: Date;
|
|
243
|
+
|
|
244
|
+
provider?: INotificationProviderMeta;
|
|
245
|
+
error?: INotificationError;
|
|
246
|
+
|
|
247
|
+
// Sanitized request/response summaries (never store secrets)
|
|
248
|
+
request_summary?: Record<string, unknown>;
|
|
249
|
+
response_summary?: Record<string, unknown>;
|
|
250
|
+
|
|
251
|
+
[key: string]: unknown;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface INotificationLog extends IFireDoc {
|
|
255
|
+
message_id: string;
|
|
256
|
+
level: "debug" | "info" | "warn" | "error";
|
|
257
|
+
message: string;
|
|
258
|
+
data?: Record<string, unknown>;
|
|
259
|
+
at: Date;
|
|
260
|
+
[key: string]: unknown;
|
|
261
|
+
}
|
|
@@ -1,94 +1,228 @@
|
|
|
1
1
|
export * from "./fb_collections";
|
|
2
2
|
import type { FirestoreDocumentReference, IFireDoc, ITag } from "../shared";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export type
|
|
10
|
-
export declare
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
export declare const EvoTaskCollections: {
|
|
4
|
+
readonly Tasks: "tasks";
|
|
5
|
+
readonly Executions: "executions";
|
|
6
|
+
readonly Comments: "comments";
|
|
7
|
+
readonly Logs: "logs";
|
|
8
|
+
};
|
|
9
|
+
export type EvoTaskCollectionName = (typeof EvoTaskCollections)[keyof typeof EvoTaskCollections];
|
|
10
|
+
export declare const TaskActionEnum: {
|
|
11
|
+
readonly CreateTask: "CREATE_TASK";
|
|
12
|
+
readonly DeleteTask: "DELETE_TASK";
|
|
13
|
+
readonly UpdateTask: "UPDATE_TASK";
|
|
14
|
+
};
|
|
15
|
+
export type TaskAction = (typeof TaskActionEnum)[keyof typeof TaskActionEnum];
|
|
16
|
+
export declare const TaskStatusEnum: {
|
|
17
|
+
readonly NotStarted: "not_started";
|
|
18
|
+
readonly InProgress: "in_progress";
|
|
19
|
+
readonly Completed: "completed";
|
|
20
|
+
readonly Failed: "failed";
|
|
21
|
+
readonly Cancelled: "cancelled";
|
|
22
|
+
readonly OnHold: "on_hold";
|
|
23
|
+
readonly Suppressed: "suppressed";
|
|
24
|
+
};
|
|
25
|
+
export type TaskStatus = (typeof TaskStatusEnum)[keyof typeof TaskStatusEnum];
|
|
26
|
+
export declare const TaskPriorityEnum: {
|
|
27
|
+
readonly Low: "low";
|
|
28
|
+
readonly Medium: "medium";
|
|
29
|
+
readonly High: "high";
|
|
30
|
+
};
|
|
31
|
+
export type TaskPriority = (typeof TaskPriorityEnum)[keyof typeof TaskPriorityEnum];
|
|
32
|
+
export declare const TaskSourceEnum: {
|
|
33
|
+
readonly User: "user";
|
|
34
|
+
readonly AutomationHub: "automation_hub";
|
|
35
|
+
readonly System: "system";
|
|
36
|
+
};
|
|
37
|
+
export type TaskSource = (typeof TaskSourceEnum)[keyof typeof TaskSourceEnum];
|
|
38
|
+
export declare const TaskModeEnum: {
|
|
39
|
+
readonly Human: "human";
|
|
40
|
+
readonly Auto: "auto";
|
|
41
|
+
};
|
|
42
|
+
export type TaskMode = (typeof TaskModeEnum)[keyof typeof TaskModeEnum];
|
|
43
|
+
export declare const TaskAutoHandlerEnum: {
|
|
44
|
+
readonly Notifications: "notifications";
|
|
45
|
+
readonly AIAgent: "ai_agent";
|
|
46
|
+
readonly Invoices: "invoices";
|
|
47
|
+
readonly Webhook: "webhook";
|
|
48
|
+
readonly Custom: "custom";
|
|
49
|
+
};
|
|
50
|
+
export type TaskAutoHandler = (typeof TaskAutoHandlerEnum)[keyof typeof TaskAutoHandlerEnum];
|
|
51
|
+
export declare const TaskRetryStrategyEnum: {
|
|
52
|
+
readonly Fixed: "fixed";
|
|
53
|
+
readonly Exponential: "exponential";
|
|
54
|
+
};
|
|
55
|
+
export type TaskRetryStrategy = (typeof TaskRetryStrategyEnum)[keyof typeof TaskRetryStrategyEnum];
|
|
56
|
+
export interface ITaskRetryPolicy {
|
|
57
|
+
max_attempts: number;
|
|
58
|
+
attempt: number;
|
|
59
|
+
strategy: TaskRetryStrategy;
|
|
60
|
+
backoff_seconds: number;
|
|
61
|
+
next_attempt_at?: Date;
|
|
62
|
+
last_error?: {
|
|
63
|
+
message: string;
|
|
64
|
+
code?: string | number;
|
|
65
|
+
at: Date;
|
|
66
|
+
details?: Record<string, unknown>;
|
|
67
|
+
};
|
|
68
|
+
[key: string]: unknown;
|
|
22
69
|
}
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Classification = "classification",
|
|
28
|
-
Extraction = "extraction",
|
|
29
|
-
Summarization = "summarization",
|
|
30
|
-
Translation = "translation",
|
|
31
|
-
SentimentAnalysis = "sentiment_analysis",
|
|
32
|
-
QuestionAnswering = "question_answering",
|
|
33
|
-
SendReminder = "send_reminder",
|
|
34
|
-
RequestContactInfo = "request_contact_info",
|
|
35
|
-
RequestOperatorInfo = "request_operator_info",
|
|
36
|
-
ConfirmAppointment = "confirm_appointment",
|
|
37
|
-
SendDocuments = "send_documents",
|
|
38
|
-
CreateAppointment = "create_appointment",
|
|
39
|
-
RescheduleAppointment = "reschedule_appointment",
|
|
40
|
-
CancelAppointment = "cancel_appointment",
|
|
41
|
-
FinancialCharge = "financial_charge",
|
|
42
|
-
Custom = "custom"
|
|
70
|
+
export interface ITaskLock {
|
|
71
|
+
locked_by: string;
|
|
72
|
+
lock_until: Date;
|
|
73
|
+
[key: string]: unknown;
|
|
43
74
|
}
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
75
|
+
export declare const TaskDedupScopeEnum: {
|
|
76
|
+
readonly PerRecipient: "per_recipient";
|
|
77
|
+
readonly PerRecipientAndObject: "per_recipient_and_object";
|
|
78
|
+
readonly Custom: "custom";
|
|
79
|
+
};
|
|
80
|
+
export type TaskDedupScope = (typeof TaskDedupScopeEnum)[keyof typeof TaskDedupScopeEnum];
|
|
81
|
+
export declare const TaskDedupWindowEnum: {
|
|
82
|
+
readonly SameDay: "same_day";
|
|
83
|
+
readonly NHours: "n_hours";
|
|
84
|
+
readonly Custom: "custom";
|
|
85
|
+
};
|
|
86
|
+
export type TaskDedupWindow = (typeof TaskDedupWindowEnum)[keyof typeof TaskDedupWindowEnum];
|
|
87
|
+
export interface ITaskDedup {
|
|
88
|
+
enabled: boolean;
|
|
89
|
+
key: string;
|
|
90
|
+
group_key?: string;
|
|
91
|
+
scope?: TaskDedupScope;
|
|
92
|
+
window?: TaskDedupWindow;
|
|
93
|
+
window_hours?: number;
|
|
94
|
+
importance?: number;
|
|
95
|
+
[key: string]: unknown;
|
|
51
96
|
}
|
|
97
|
+
export declare const TaskExternalObjectTypeEnum: {
|
|
98
|
+
readonly CrmLead: "crm_lead";
|
|
99
|
+
readonly MedPatient: "med_patient";
|
|
100
|
+
readonly MedProfessional: "med_professional";
|
|
101
|
+
readonly MedAppointment: "med_appointment";
|
|
102
|
+
readonly ChatContact: "chat_contact";
|
|
103
|
+
};
|
|
104
|
+
export type TaskExternalObjectType = (typeof TaskExternalObjectTypeEnum)[keyof typeof TaskExternalObjectTypeEnum];
|
|
52
105
|
export interface ITaskExternalLink {
|
|
53
106
|
type: TaskExternalObjectType;
|
|
54
107
|
id: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
[key: string]: unknown;
|
|
110
|
+
}
|
|
111
|
+
export interface ITaskUserAssignee {
|
|
112
|
+
kind: "user";
|
|
113
|
+
name?: string;
|
|
114
|
+
ref?: FirestoreDocumentReference;
|
|
115
|
+
[key: string]: unknown;
|
|
116
|
+
}
|
|
117
|
+
export interface ITaskSchedule {
|
|
118
|
+
execute_at?: Date;
|
|
119
|
+
due_at?: Date;
|
|
120
|
+
timezone?: string;
|
|
121
|
+
[key: string]: unknown;
|
|
122
|
+
}
|
|
123
|
+
export interface ITaskAutoSpec {
|
|
124
|
+
handler: TaskAutoHandler;
|
|
125
|
+
kind: string;
|
|
126
|
+
version?: number | string;
|
|
127
|
+
payload: Record<string, unknown>;
|
|
128
|
+
idempotency_key?: string;
|
|
55
129
|
[key: string]: unknown;
|
|
56
130
|
}
|
|
57
|
-
export interface
|
|
131
|
+
export interface ITaskOnFailure {
|
|
132
|
+
handoff_to_user?: {
|
|
133
|
+
name?: string;
|
|
134
|
+
ref?: FirestoreDocumentReference;
|
|
135
|
+
};
|
|
136
|
+
create_handoff_task?: {
|
|
137
|
+
title?: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
priority?: TaskPriority;
|
|
140
|
+
tags?: ITag[] | null;
|
|
141
|
+
};
|
|
142
|
+
auto_fallbacks?: Array<{
|
|
143
|
+
handler: TaskAutoHandler;
|
|
144
|
+
kind: string;
|
|
145
|
+
payload: Record<string, unknown>;
|
|
146
|
+
}>;
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
}
|
|
149
|
+
export interface ITaskBase extends IFireDoc {
|
|
58
150
|
title: string;
|
|
59
151
|
description?: string;
|
|
60
|
-
creatorName: string;
|
|
61
|
-
creatorRef?: FirestoreDocumentReference;
|
|
62
|
-
startDate: Date;
|
|
63
|
-
dueDate?: Date;
|
|
64
152
|
status: TaskStatus;
|
|
65
153
|
priority?: TaskPriority;
|
|
66
|
-
|
|
67
|
-
|
|
154
|
+
importance?: number;
|
|
155
|
+
source: TaskSource;
|
|
156
|
+
creator: {
|
|
157
|
+
name: string;
|
|
158
|
+
ref?: FirestoreDocumentReference;
|
|
159
|
+
};
|
|
160
|
+
schedule?: ITaskSchedule;
|
|
68
161
|
tags?: ITag[] | null;
|
|
69
|
-
ia_assigned?: boolean;
|
|
70
|
-
ia_agent?: string;
|
|
71
|
-
ia_duescheduled?: Date;
|
|
72
|
-
ia_task_type?: IATaskType;
|
|
73
|
-
ia_result?: string;
|
|
74
|
-
ia_result_code?: number;
|
|
75
|
-
ia_started_at?: Date;
|
|
76
|
-
ia_completed_at?: Date;
|
|
77
|
-
ia_error?: string;
|
|
78
|
-
ia_retry_count?: number;
|
|
79
|
-
ia_metadata?: Record<string, unknown>;
|
|
80
|
-
ia_prompt?: string;
|
|
81
|
-
ia_model?: string;
|
|
82
|
-
ia_progress?: number;
|
|
83
162
|
externalLinks?: ITaskExternalLink[];
|
|
163
|
+
idempotency_key?: string;
|
|
164
|
+
dedup?: ITaskDedup;
|
|
165
|
+
metadata?: Record<string, unknown>;
|
|
166
|
+
[key: string]: unknown;
|
|
167
|
+
}
|
|
168
|
+
export interface IHumanTask extends ITaskBase {
|
|
169
|
+
mode: "human";
|
|
170
|
+
assignee?: ITaskUserAssignee;
|
|
171
|
+
}
|
|
172
|
+
export interface IAutoTask extends ITaskBase {
|
|
173
|
+
mode: "auto";
|
|
174
|
+
schedule: ITaskSchedule & {
|
|
175
|
+
execute_at: Date;
|
|
176
|
+
};
|
|
177
|
+
lock?: ITaskLock;
|
|
178
|
+
retry?: ITaskRetryPolicy;
|
|
179
|
+
on_failure?: ITaskOnFailure;
|
|
180
|
+
auto: ITaskAutoSpec;
|
|
181
|
+
}
|
|
182
|
+
export type ITask = IHumanTask | IAutoTask;
|
|
183
|
+
export declare const TaskExecutionStatusEnum: {
|
|
184
|
+
readonly Success: "success";
|
|
185
|
+
readonly Error: "error";
|
|
186
|
+
readonly Retry: "retry";
|
|
187
|
+
};
|
|
188
|
+
export type TaskExecutionStatus = (typeof TaskExecutionStatusEnum)[keyof typeof TaskExecutionStatusEnum];
|
|
189
|
+
export interface ITaskExecution extends IFireDoc {
|
|
190
|
+
taskId: string;
|
|
191
|
+
handler: TaskAutoHandler;
|
|
192
|
+
kind: string;
|
|
193
|
+
status: TaskExecutionStatus;
|
|
194
|
+
attempt: number;
|
|
195
|
+
started_at: Date;
|
|
196
|
+
completed_at?: Date;
|
|
197
|
+
result?: Record<string, unknown>;
|
|
198
|
+
error?: {
|
|
199
|
+
message: string;
|
|
200
|
+
code?: string | number;
|
|
201
|
+
details?: Record<string, unknown>;
|
|
202
|
+
};
|
|
203
|
+
provider?: {
|
|
204
|
+
name?: string;
|
|
205
|
+
message_id?: string;
|
|
206
|
+
[key: string]: unknown;
|
|
207
|
+
};
|
|
84
208
|
[key: string]: unknown;
|
|
85
209
|
}
|
|
86
210
|
export interface ITaskComment extends IFireDoc {
|
|
87
211
|
taskId: string;
|
|
88
212
|
text: string;
|
|
89
|
-
|
|
90
|
-
|
|
213
|
+
author: {
|
|
214
|
+
name: string;
|
|
215
|
+
ref?: FirestoreDocumentReference;
|
|
216
|
+
};
|
|
91
217
|
edited?: boolean;
|
|
92
218
|
edited_at?: Date;
|
|
93
219
|
[key: string]: unknown;
|
|
94
220
|
}
|
|
221
|
+
export interface ITaskLog extends IFireDoc {
|
|
222
|
+
taskId: string;
|
|
223
|
+
level: "debug" | "info" | "warn" | "error";
|
|
224
|
+
message: string;
|
|
225
|
+
data?: Record<string, unknown>;
|
|
226
|
+
at: Date;
|
|
227
|
+
[key: string]: unknown;
|
|
228
|
+
}
|