evo360-types 1.3.141 → 1.3.144

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,94 +1,228 @@
1
1
  export * from "./fb_collections";
2
2
  import type { FirestoreDocumentReference, IFireDoc, ITag } from "../shared";
3
- export type TaskAction = "CREATE_TASK" | "DELETE_TASK" | "UPDATE_TASK";
4
- export declare enum ITaskAction {
5
- Create_task = "CREATE_TASK",
6
- Delete_task = "DELETE_TASK",
7
- Update_task = "UPDATE_TASK"
8
- }
9
- export type TaskStatus = "not_started" | "in_progress" | "completed" | "cancelled" | "on_hold";
10
- export declare enum ITaskStatus {
11
- NotStarted = "not_started",
12
- InProgress = "in_progress",
13
- Completed = "completed",
14
- Cancelled = "cancelled",
15
- OnHold = "on_hold"
16
- }
17
- export type TaskPriority = "low" | "medium" | "high";
18
- export declare enum ITaskPriority {
19
- Low = "low",
20
- Medium = "medium",
21
- High = "high"
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 type IATaskType = "data_analysis" | "content_generation" | "classification" | "extraction" | "summarization" | "translation" | "sentiment_analysis" | "question_answering" | "send_reminder" | "request_contact_info" | "request_operator_info" | "confirm_appointment" | "send_documents" | "create_appointment" | "reschedule_appointment" | "cancel_appointment" | "financial_charge" | "custom";
24
- export declare enum IIATaskType {
25
- DataAnalysis = "data_analysis",
26
- ContentGeneration = "content_generation",
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 type TaskExternalObjectType = "crm_lead" | "med_patient" | "med_professional" | "med_appointment" | "chat_contact";
45
- export declare enum ITaskExternalObjectType {
46
- CrmLead = "crm_lead",
47
- MedPatient = "med_patient",
48
- MedProfessional = "med_professional",
49
- MedAppointment = "med_appointment",
50
- ChatContact = "chat_contact"
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 ITask extends IFireDoc {
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
- assigneeName?: string;
67
- assigneeRef?: FirestoreDocumentReference;
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
- authorName: string;
90
- authorRef?: FirestoreDocumentReference;
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
+ }
@@ -14,54 +14,96 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ITaskExternalObjectType = exports.IIATaskType = exports.ITaskPriority = exports.ITaskStatus = exports.ITaskAction = void 0;
17
+ exports.TaskExecutionStatusEnum = exports.TaskExternalObjectTypeEnum = exports.TaskDedupWindowEnum = exports.TaskDedupScopeEnum = exports.TaskRetryStrategyEnum = exports.TaskAutoHandlerEnum = exports.TaskModeEnum = exports.TaskSourceEnum = exports.TaskPriorityEnum = exports.TaskStatusEnum = exports.TaskActionEnum = exports.EvoTaskCollections = void 0;
18
18
  __exportStar(require("./fb_collections"), exports);
19
- var ITaskAction;
20
- (function (ITaskAction) {
21
- ITaskAction["Create_task"] = "CREATE_TASK";
22
- ITaskAction["Delete_task"] = "DELETE_TASK";
23
- ITaskAction["Update_task"] = "UPDATE_TASK";
24
- })(ITaskAction || (exports.ITaskAction = ITaskAction = {}));
25
- var ITaskStatus;
26
- (function (ITaskStatus) {
27
- ITaskStatus["NotStarted"] = "not_started";
28
- ITaskStatus["InProgress"] = "in_progress";
29
- ITaskStatus["Completed"] = "completed";
30
- ITaskStatus["Cancelled"] = "cancelled";
31
- ITaskStatus["OnHold"] = "on_hold";
32
- })(ITaskStatus || (exports.ITaskStatus = ITaskStatus = {}));
33
- var ITaskPriority;
34
- (function (ITaskPriority) {
35
- ITaskPriority["Low"] = "low";
36
- ITaskPriority["Medium"] = "medium";
37
- ITaskPriority["High"] = "high";
38
- })(ITaskPriority || (exports.ITaskPriority = ITaskPriority = {}));
39
- var IIATaskType;
40
- (function (IIATaskType) {
41
- IIATaskType["DataAnalysis"] = "data_analysis";
42
- IIATaskType["ContentGeneration"] = "content_generation";
43
- IIATaskType["Classification"] = "classification";
44
- IIATaskType["Extraction"] = "extraction";
45
- IIATaskType["Summarization"] = "summarization";
46
- IIATaskType["Translation"] = "translation";
47
- IIATaskType["SentimentAnalysis"] = "sentiment_analysis";
48
- IIATaskType["QuestionAnswering"] = "question_answering";
49
- IIATaskType["SendReminder"] = "send_reminder";
50
- IIATaskType["RequestContactInfo"] = "request_contact_info";
51
- IIATaskType["RequestOperatorInfo"] = "request_operator_info";
52
- IIATaskType["ConfirmAppointment"] = "confirm_appointment";
53
- IIATaskType["SendDocuments"] = "send_documents";
54
- IIATaskType["CreateAppointment"] = "create_appointment";
55
- IIATaskType["RescheduleAppointment"] = "reschedule_appointment";
56
- IIATaskType["CancelAppointment"] = "cancel_appointment";
57
- IIATaskType["FinancialCharge"] = "financial_charge";
58
- IIATaskType["Custom"] = "custom";
59
- })(IIATaskType || (exports.IIATaskType = IIATaskType = {}));
60
- var ITaskExternalObjectType;
61
- (function (ITaskExternalObjectType) {
62
- ITaskExternalObjectType["CrmLead"] = "crm_lead";
63
- ITaskExternalObjectType["MedPatient"] = "med_patient";
64
- ITaskExternalObjectType["MedProfessional"] = "med_professional";
65
- ITaskExternalObjectType["MedAppointment"] = "med_appointment";
66
- ITaskExternalObjectType["ChatContact"] = "chat_contact";
67
- })(ITaskExternalObjectType || (exports.ITaskExternalObjectType = ITaskExternalObjectType = {}));
19
+ // ======================================================
20
+ // evo-task (Tasks)
21
+ //
22
+ // Design goals:
23
+ // - Single, generic Task model used by humans and automation
24
+ // - AUTO tasks are executed by Task Runner (in evo-task-runner)
25
+ // - Payloads for specific handlers (notifications, AI, invoices, etc.)
26
+ // live in their own modules; here we keep the contract generic
27
+ // - Sub-collections (executions/comments/logs) keep lists fast
28
+ // ======================================================
29
+ // ----- Firestore collection conventions (per tenant)
30
+ // Root: /tenants/{tenant}/apps/evo-task/tasks/{taskId}
31
+ exports.EvoTaskCollections = {
32
+ Tasks: "tasks",
33
+ Executions: "executions",
34
+ Comments: "comments",
35
+ Logs: "logs",
36
+ };
37
+ // ----- Activities tracking
38
+ exports.TaskActionEnum = {
39
+ CreateTask: "CREATE_TASK",
40
+ DeleteTask: "DELETE_TASK",
41
+ UpdateTask: "UPDATE_TASK",
42
+ };
43
+ // ----- Task lifecycle status
44
+ // Keep the human-friendly lifecycle states (legacy-friendly): not_started / in_progress.
45
+ exports.TaskStatusEnum = {
46
+ NotStarted: "not_started",
47
+ InProgress: "in_progress",
48
+ Completed: "completed",
49
+ Failed: "failed", // final failure (after retries)
50
+ Cancelled: "cancelled",
51
+ OnHold: "on_hold",
52
+ Suppressed: "suppressed", // intentionally skipped (e.g., dedup)
53
+ };
54
+ // ----- Task priority (human-friendly)
55
+ exports.TaskPriorityEnum = {
56
+ Low: "low",
57
+ Medium: "medium",
58
+ High: "high",
59
+ };
60
+ // ----- Task source (who created it)
61
+ exports.TaskSourceEnum = {
62
+ User: "user",
63
+ AutomationHub: "automation_hub",
64
+ System: "system",
65
+ };
66
+ // ----- Task execution mode
67
+ exports.TaskModeEnum = {
68
+ Human: "human",
69
+ Auto: "auto",
70
+ };
71
+ // ----- AUTO task handler (which executor processes the task)
72
+ // Keep it open for future modules; these are logical handler identifiers.
73
+ exports.TaskAutoHandlerEnum = {
74
+ Notifications: "notifications",
75
+ AIAgent: "ai_agent",
76
+ Invoices: "invoices",
77
+ Webhook: "webhook",
78
+ Custom: "custom",
79
+ };
80
+ // ----- Retry policy
81
+ exports.TaskRetryStrategyEnum = {
82
+ Fixed: "fixed",
83
+ Exponential: "exponential",
84
+ };
85
+ // ----- Dedup / suppression (optional)
86
+ exports.TaskDedupScopeEnum = {
87
+ PerRecipient: "per_recipient",
88
+ PerRecipientAndObject: "per_recipient_and_object",
89
+ Custom: "custom",
90
+ };
91
+ exports.TaskDedupWindowEnum = {
92
+ SameDay: "same_day",
93
+ NHours: "n_hours",
94
+ Custom: "custom",
95
+ };
96
+ // ----- External object links (for unified UI views)
97
+ exports.TaskExternalObjectTypeEnum = {
98
+ CrmLead: "crm_lead",
99
+ MedPatient: "med_patient",
100
+ MedProfessional: "med_professional",
101
+ MedAppointment: "med_appointment",
102
+ ChatContact: "chat_contact",
103
+ };
104
+ // ----- Task execution attempts (sub-collection: tasks/{taskId}/executions)
105
+ exports.TaskExecutionStatusEnum = {
106
+ Success: "success",
107
+ Error: "error",
108
+ Retry: "retry",
109
+ };