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,76 @@
|
|
|
1
|
+
import type { IFireDoc } from "../shared";
|
|
2
|
+
import type { TaskAutoHandler, TaskExecutionStatus, TaskRetryStrategy } from "../evo-task";
|
|
3
|
+
export declare const TaskRunnerTopics: {
|
|
4
|
+
readonly Tick: "task_runner.tick";
|
|
5
|
+
readonly ExecuteRequests: "task_runner.execute_requests";
|
|
6
|
+
readonly ExecutionReports: "task_runner.execution_reports";
|
|
7
|
+
};
|
|
8
|
+
export type TaskRunnerTopic = (typeof TaskRunnerTopics)[keyof typeof TaskRunnerTopics];
|
|
9
|
+
export declare const TaskRunnerTickReasonEnum: {
|
|
10
|
+
readonly Schedule: "schedule";
|
|
11
|
+
readonly Manual: "manual";
|
|
12
|
+
readonly Recovery: "recovery";
|
|
13
|
+
};
|
|
14
|
+
export type TaskRunnerTickReason = (typeof TaskRunnerTickReasonEnum)[keyof typeof TaskRunnerTickReasonEnum];
|
|
15
|
+
export interface ITaskRunnerTick {
|
|
16
|
+
tenant: string;
|
|
17
|
+
reason: TaskRunnerTickReason;
|
|
18
|
+
requested_at: Date;
|
|
19
|
+
max_to_claim?: number;
|
|
20
|
+
look_ahead_seconds?: number;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface ITaskExecuteRequest {
|
|
24
|
+
tenant: string;
|
|
25
|
+
task_id: string;
|
|
26
|
+
task_path?: string;
|
|
27
|
+
handler: TaskAutoHandler;
|
|
28
|
+
kind: string;
|
|
29
|
+
version?: number | string;
|
|
30
|
+
attempt: number;
|
|
31
|
+
idempotency_key?: string;
|
|
32
|
+
payload: Record<string, unknown>;
|
|
33
|
+
correlation_id?: string;
|
|
34
|
+
requested_at: Date;
|
|
35
|
+
timeout_ms?: number;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface ITaskExecutionReport {
|
|
39
|
+
tenant: string;
|
|
40
|
+
task_id: string;
|
|
41
|
+
handler: TaskAutoHandler;
|
|
42
|
+
kind: string;
|
|
43
|
+
attempt: number;
|
|
44
|
+
correlation_id?: string;
|
|
45
|
+
status: TaskExecutionStatus;
|
|
46
|
+
started_at: Date;
|
|
47
|
+
completed_at: Date;
|
|
48
|
+
suggested_retry?: {
|
|
49
|
+
retryable: boolean;
|
|
50
|
+
code?: string | number;
|
|
51
|
+
message?: string;
|
|
52
|
+
next_attempt_at?: Date;
|
|
53
|
+
strategy?: TaskRetryStrategy;
|
|
54
|
+
backoff_seconds?: number;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
result?: Record<string, unknown>;
|
|
58
|
+
error?: {
|
|
59
|
+
message: string;
|
|
60
|
+
code?: string | number;
|
|
61
|
+
details?: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
provider?: {
|
|
64
|
+
name?: string;
|
|
65
|
+
message_id?: string;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
};
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
export interface ITaskRunnerEvent extends IFireDoc {
|
|
71
|
+
tenant: string;
|
|
72
|
+
type: "tick" | "dispatch" | "report";
|
|
73
|
+
at: Date;
|
|
74
|
+
data?: Record<string, unknown>;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskRunnerTickReasonEnum = exports.TaskRunnerTopics = void 0;
|
|
4
|
+
// ======================================================
|
|
5
|
+
// evo-task-runner (Task Runner)
|
|
6
|
+
//
|
|
7
|
+
// This module defines the contracts used by the Task Runner to:
|
|
8
|
+
// - pick due AUTO tasks
|
|
9
|
+
// - dispatch execution requests to handler executors (notifications, ai_agent, ...)
|
|
10
|
+
// - receive async execution reports
|
|
11
|
+
//
|
|
12
|
+
// NOTE:
|
|
13
|
+
// - Task payload schemas live in their respective modules.
|
|
14
|
+
// - This contract is handler-agnostic and safe to share between backend/frontend.
|
|
15
|
+
// ======================================================
|
|
16
|
+
// ----- Pub/Sub topic suggestions (logical names)
|
|
17
|
+
exports.TaskRunnerTopics = {
|
|
18
|
+
Tick: "task_runner.tick",
|
|
19
|
+
ExecuteRequests: "task_runner.execute_requests",
|
|
20
|
+
ExecutionReports: "task_runner.execution_reports",
|
|
21
|
+
};
|
|
22
|
+
// ----- Runner tick messages (optional)
|
|
23
|
+
exports.TaskRunnerTickReasonEnum = {
|
|
24
|
+
Schedule: "schedule",
|
|
25
|
+
Manual: "manual",
|
|
26
|
+
Recovery: "recovery",
|
|
27
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { IFireDoc } from "../shared";
|
|
2
|
+
import type {
|
|
3
|
+
TaskAutoHandler,
|
|
4
|
+
TaskExecutionStatus,
|
|
5
|
+
TaskRetryStrategy,
|
|
6
|
+
} from "../evo-task";
|
|
7
|
+
|
|
8
|
+
// ======================================================
|
|
9
|
+
// evo-task-runner (Task Runner)
|
|
10
|
+
//
|
|
11
|
+
// This module defines the contracts used by the Task Runner to:
|
|
12
|
+
// - pick due AUTO tasks
|
|
13
|
+
// - dispatch execution requests to handler executors (notifications, ai_agent, ...)
|
|
14
|
+
// - receive async execution reports
|
|
15
|
+
//
|
|
16
|
+
// NOTE:
|
|
17
|
+
// - Task payload schemas live in their respective modules.
|
|
18
|
+
// - This contract is handler-agnostic and safe to share between backend/frontend.
|
|
19
|
+
// ======================================================
|
|
20
|
+
|
|
21
|
+
// ----- Pub/Sub topic suggestions (logical names)
|
|
22
|
+
export const TaskRunnerTopics = {
|
|
23
|
+
Tick: "task_runner.tick",
|
|
24
|
+
ExecuteRequests: "task_runner.execute_requests",
|
|
25
|
+
ExecutionReports: "task_runner.execution_reports",
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
export type TaskRunnerTopic =
|
|
29
|
+
(typeof TaskRunnerTopics)[keyof typeof TaskRunnerTopics];
|
|
30
|
+
|
|
31
|
+
// ----- Runner tick messages (optional)
|
|
32
|
+
export const TaskRunnerTickReasonEnum = {
|
|
33
|
+
Schedule: "schedule",
|
|
34
|
+
Manual: "manual",
|
|
35
|
+
Recovery: "recovery",
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
export type TaskRunnerTickReason =
|
|
39
|
+
(typeof TaskRunnerTickReasonEnum)[keyof typeof TaskRunnerTickReasonEnum];
|
|
40
|
+
|
|
41
|
+
export interface ITaskRunnerTick {
|
|
42
|
+
tenant: string;
|
|
43
|
+
reason: TaskRunnerTickReason;
|
|
44
|
+
requested_at: Date;
|
|
45
|
+
// Useful for batch processing controls
|
|
46
|
+
max_to_claim?: number;
|
|
47
|
+
look_ahead_seconds?: number; // if you want to include "execute_at <= now + lookahead"
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ----- Execution request (Runner -> Handler Executor)
|
|
52
|
+
// This message must be idempotent and safe to deliver at-least-once.
|
|
53
|
+
export interface ITaskExecuteRequest {
|
|
54
|
+
tenant: string;
|
|
55
|
+
|
|
56
|
+
// Task identity
|
|
57
|
+
task_id: string;
|
|
58
|
+
task_path?: string; // optional Firestore path for convenience
|
|
59
|
+
|
|
60
|
+
// What to execute
|
|
61
|
+
handler: TaskAutoHandler;
|
|
62
|
+
kind: string; // mirrors task.auto.kind
|
|
63
|
+
version?: number | string; // mirrors task.auto.version
|
|
64
|
+
|
|
65
|
+
// Attempting/Idempotency
|
|
66
|
+
attempt: number; // 0-based attempt
|
|
67
|
+
idempotency_key?: string; // should be stable for "same attempt" dispatch
|
|
68
|
+
|
|
69
|
+
// Payload (handler-specific)
|
|
70
|
+
payload: Record<string, unknown>;
|
|
71
|
+
|
|
72
|
+
// Correlation / tracing
|
|
73
|
+
correlation_id?: string;
|
|
74
|
+
requested_at: Date;
|
|
75
|
+
|
|
76
|
+
// Optional execution constraints
|
|
77
|
+
timeout_ms?: number;
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ----- Execution report (Handler Executor -> Runner)
|
|
82
|
+
// Handler executors should emit a report for every request (success/failure).
|
|
83
|
+
export interface ITaskExecutionReport {
|
|
84
|
+
tenant: string;
|
|
85
|
+
|
|
86
|
+
// Task identity
|
|
87
|
+
task_id: string;
|
|
88
|
+
|
|
89
|
+
// Execution identity
|
|
90
|
+
handler: TaskAutoHandler;
|
|
91
|
+
kind: string;
|
|
92
|
+
attempt: number;
|
|
93
|
+
correlation_id?: string;
|
|
94
|
+
|
|
95
|
+
// Status/result
|
|
96
|
+
status: TaskExecutionStatus; // success | error | retry
|
|
97
|
+
|
|
98
|
+
started_at: Date;
|
|
99
|
+
completed_at: Date;
|
|
100
|
+
|
|
101
|
+
// Retry hints (Runner remains the source of truth)
|
|
102
|
+
suggested_retry?: {
|
|
103
|
+
// If handler believes the error is retryable, it can suggest.
|
|
104
|
+
// Runner may override based on task.retry policy.
|
|
105
|
+
retryable: boolean;
|
|
106
|
+
code?: string | number;
|
|
107
|
+
message?: string;
|
|
108
|
+
next_attempt_at?: Date;
|
|
109
|
+
strategy?: TaskRetryStrategy;
|
|
110
|
+
backoff_seconds?: number;
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Handler-specific result data
|
|
115
|
+
result?: Record<string, unknown>;
|
|
116
|
+
|
|
117
|
+
// Error data (when status is error/retry)
|
|
118
|
+
error?: {
|
|
119
|
+
message: string;
|
|
120
|
+
code?: string | number;
|
|
121
|
+
details?: Record<string, unknown>;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Optional provider metadata (e.g. WhatsApp provider message id)
|
|
125
|
+
provider?: {
|
|
126
|
+
name?: string;
|
|
127
|
+
message_id?: string;
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
[key: string]: unknown;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ----- Optional: runner audit doc (if you want a central collection for runner events)
|
|
135
|
+
export interface ITaskRunnerEvent extends IFireDoc {
|
|
136
|
+
tenant: string;
|
|
137
|
+
type: "tick" | "dispatch" | "report";
|
|
138
|
+
at: Date;
|
|
139
|
+
data?: Record<string, unknown>;
|
|
140
|
+
[key: string]: unknown;
|
|
141
|
+
}
|