evo360-types 1.3.324 → 1.3.328
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-integrations/zod-schemas.d.ts +755 -0
- package/dist/apps/evo-integrations/zod-schemas.js +117 -0
- package/dist/apps/evo-integrations/zod-schemas.ts +130 -0
- package/dist/apps/evo-med/calendar/zod-schemas.d.ts +792 -0
- package/dist/apps/evo-med/calendar/zod-schemas.js +2 -0
- package/dist/apps/evo-med/calendar/zod-schemas.ts +2 -0
- package/dist/apps/evo-task/zod-schemas.d.ts +68 -4
- package/dist/apps/evo-task/zod-schemas.js +12 -1
- package/dist/apps/evo-task/zod-schemas.ts +12 -0
- package/dist/apps/evo-task-runner/index.d.ts +1 -0
- package/dist/apps/evo-task-runner/index.js +17 -0
- package/dist/apps/evo-task-runner/index.ts +1 -0
- package/dist/apps/evo-task-runner/zod-schemas.d.ts +30 -0
- package/dist/apps/evo-task-runner/zod-schemas.js +15 -0
- package/dist/apps/evo-task-runner/zod-schemas.ts +15 -0
- package/dist/apps/evo-tenant/zod-schemas.d.ts +3 -3
- package/dist/apps/evo-tenant/zod-schemas.js +1 -1
- package/dist/apps/evo-tenant/zod-schemas.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.ts +3 -0
- package/dist/types/evo-integrations/fb_collections.d.ts +5 -0
- package/dist/types/evo-integrations/fb_collections.js +14 -0
- package/dist/types/evo-integrations/fb_collections.ts +13 -0
- package/dist/types/evo-integrations/index.d.ts +133 -0
- package/dist/types/evo-integrations/index.js +71 -0
- package/dist/types/evo-integrations/index.ts +232 -0
- package/dist/types/evo-med/calendar/index.d.ts +2 -0
- package/dist/types/evo-med/calendar/index.ts +3 -0
- package/dist/types/evo-task/index.d.ts +9 -0
- package/dist/types/evo-task/index.js +1 -0
- package/dist/types/evo-task/index.ts +13 -0
- package/dist/types/evo-task-runner/fb_collections.d.ts +1 -0
- package/dist/types/evo-task-runner/fb_collections.js +8 -0
- package/dist/types/evo-task-runner/fb_collections.ts +5 -0
- package/dist/types/evo-task-runner/index.d.ts +4 -0
- package/dist/types/evo-task-runner/index.js +23 -1
- package/dist/types/evo-task-runner/index.ts +11 -0
- package/dist/types/evo-tenant/index.d.ts +1 -1
- package/dist/types/evo-tenant/index.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.OBLIGATORY_CAPABILITIES = exports.SYNC_RUN_HANDLER = exports.SYNC_RUN_PUBSUB_TOPIC = exports.EvoIntegrationsPermissions = void 0;
|
|
18
|
+
exports.isInternalCapability = isInternalCapability;
|
|
19
|
+
exports.splitCapabilityName = splitCapabilityName;
|
|
20
|
+
__exportStar(require("./fb_collections"), exports);
|
|
21
|
+
// ======================================================
|
|
22
|
+
// evo-integrations
|
|
23
|
+
//
|
|
24
|
+
// Padroniza integração com sistemas externos de agenda/prontuário
|
|
25
|
+
// (iClinic, Feegow, MedX, ...). Feat-004.
|
|
26
|
+
//
|
|
27
|
+
// Arquitetura em 4 pilares:
|
|
28
|
+
// 1. Adapter registry global (Nexus-managed, /platform/evo-integrations/adapters)
|
|
29
|
+
// 2. Credential vault (Google Secret Manager; n8n lê via SA direto)
|
|
30
|
+
// 3. Sync engine (handler do evo-task-runner; janelas hot/warm/recent_reconcile/cold)
|
|
31
|
+
// 4. Action envelope (dispatcher transparente — uma URL fixa pra consumers)
|
|
32
|
+
// ======================================================
|
|
33
|
+
// ----- Permissions
|
|
34
|
+
exports.EvoIntegrationsPermissions = {
|
|
35
|
+
List: "evo_integrations_read",
|
|
36
|
+
Get: "evo_integrations_read",
|
|
37
|
+
Create: "evo_integrations_write",
|
|
38
|
+
Update: "evo_integrations_write",
|
|
39
|
+
Delete: "evo_integrations_write",
|
|
40
|
+
InvokeAction: "evo_integrations_action_invoke",
|
|
41
|
+
};
|
|
42
|
+
// ----- PubSub topics
|
|
43
|
+
// 1 evento por sync run, sink em BigQuery (hr-evo360.evo_log.evo_integrations_sync_runs).
|
|
44
|
+
exports.SYNC_RUN_PUBSUB_TOPIC = "evo-integrations.sync_runs";
|
|
45
|
+
// Handler do evo-task-runner — resolve pro tópico ${handler}.execute_requests.
|
|
46
|
+
exports.SYNC_RUN_HANDLER = "evo-integrations.sync-run";
|
|
47
|
+
/**
|
|
48
|
+
* Capabilities obrigatórias em qualquer adapter. Sem elas, o adapter
|
|
49
|
+
* não pode ser ativado. `appointment.get` é fundamental pra auto-deleção
|
|
50
|
+
* confiável via get-after-diff.
|
|
51
|
+
*/
|
|
52
|
+
exports.OBLIGATORY_CAPABILITIES = [
|
|
53
|
+
"appointment.get",
|
|
54
|
+
"appointment.create",
|
|
55
|
+
"appointment.update",
|
|
56
|
+
"appointment.cancel",
|
|
57
|
+
"appointment.confirm",
|
|
58
|
+
"patient.get",
|
|
59
|
+
"sync.appointments",
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Capabilities internas (não expostas via action dispatcher — apenas
|
|
63
|
+
* via sync engine / task-runner).
|
|
64
|
+
*/
|
|
65
|
+
function isInternalCapability(name) {
|
|
66
|
+
return name === "sync.appointments";
|
|
67
|
+
}
|
|
68
|
+
function splitCapabilityName(name) {
|
|
69
|
+
const [entity, ...rest] = name.split(".");
|
|
70
|
+
return { entity: entity, action: rest.join(".") };
|
|
71
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
export * from "./fb_collections";
|
|
2
|
+
import type { IFireDoc } from "../shared";
|
|
3
|
+
|
|
4
|
+
// ======================================================
|
|
5
|
+
// evo-integrations
|
|
6
|
+
//
|
|
7
|
+
// Padroniza integração com sistemas externos de agenda/prontuário
|
|
8
|
+
// (iClinic, Feegow, MedX, ...). Feat-004.
|
|
9
|
+
//
|
|
10
|
+
// Arquitetura em 4 pilares:
|
|
11
|
+
// 1. Adapter registry global (Nexus-managed, /platform/evo-integrations/adapters)
|
|
12
|
+
// 2. Credential vault (Google Secret Manager; n8n lê via SA direto)
|
|
13
|
+
// 3. Sync engine (handler do evo-task-runner; janelas hot/warm/recent_reconcile/cold)
|
|
14
|
+
// 4. Action envelope (dispatcher transparente — uma URL fixa pra consumers)
|
|
15
|
+
// ======================================================
|
|
16
|
+
|
|
17
|
+
// ----- Permissions
|
|
18
|
+
export const EvoIntegrationsPermissions = {
|
|
19
|
+
List: "evo_integrations_read",
|
|
20
|
+
Get: "evo_integrations_read",
|
|
21
|
+
Create: "evo_integrations_write",
|
|
22
|
+
Update: "evo_integrations_write",
|
|
23
|
+
Delete: "evo_integrations_write",
|
|
24
|
+
InvokeAction: "evo_integrations_action_invoke",
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
export type EvoIntegrationsPermissions =
|
|
28
|
+
(typeof EvoIntegrationsPermissions)[keyof typeof EvoIntegrationsPermissions];
|
|
29
|
+
|
|
30
|
+
// ----- PubSub topics
|
|
31
|
+
// 1 evento por sync run, sink em BigQuery (hr-evo360.evo_log.evo_integrations_sync_runs).
|
|
32
|
+
export const SYNC_RUN_PUBSUB_TOPIC = "evo-integrations.sync_runs";
|
|
33
|
+
|
|
34
|
+
// Handler do evo-task-runner — resolve pro tópico ${handler}.execute_requests.
|
|
35
|
+
export const SYNC_RUN_HANDLER = "evo-integrations.sync-run";
|
|
36
|
+
|
|
37
|
+
// ======================================================
|
|
38
|
+
// Capabilities — nomenclatura {entity}.{action}
|
|
39
|
+
// ======================================================
|
|
40
|
+
|
|
41
|
+
export type CapabilityEntity = "appointment" | "patient" | "payment" | "sync";
|
|
42
|
+
|
|
43
|
+
export type CapabilityName =
|
|
44
|
+
| "appointment.get"
|
|
45
|
+
| "appointment.list"
|
|
46
|
+
| "appointment.create"
|
|
47
|
+
| "appointment.update"
|
|
48
|
+
| "appointment.cancel"
|
|
49
|
+
| "appointment.confirm"
|
|
50
|
+
| "appointment.reschedule"
|
|
51
|
+
| "patient.get"
|
|
52
|
+
| "patient.list"
|
|
53
|
+
| "patient.create"
|
|
54
|
+
| "patient.update"
|
|
55
|
+
| "patient.document.upload"
|
|
56
|
+
| "payment.update"
|
|
57
|
+
| "sync.appointments";
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Capabilities obrigatórias em qualquer adapter. Sem elas, o adapter
|
|
61
|
+
* não pode ser ativado. `appointment.get` é fundamental pra auto-deleção
|
|
62
|
+
* confiável via get-after-diff.
|
|
63
|
+
*/
|
|
64
|
+
export const OBLIGATORY_CAPABILITIES: readonly CapabilityName[] = [
|
|
65
|
+
"appointment.get",
|
|
66
|
+
"appointment.create",
|
|
67
|
+
"appointment.update",
|
|
68
|
+
"appointment.cancel",
|
|
69
|
+
"appointment.confirm",
|
|
70
|
+
"patient.get",
|
|
71
|
+
"sync.appointments",
|
|
72
|
+
] as const;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Capabilities internas (não expostas via action dispatcher — apenas
|
|
76
|
+
* via sync engine / task-runner).
|
|
77
|
+
*/
|
|
78
|
+
export function isInternalCapability(name: CapabilityName): boolean {
|
|
79
|
+
return name === "sync.appointments";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function splitCapabilityName(name: CapabilityName): {
|
|
83
|
+
entity: CapabilityEntity;
|
|
84
|
+
action: string;
|
|
85
|
+
} {
|
|
86
|
+
const [entity, ...rest] = name.split(".");
|
|
87
|
+
return { entity: entity as CapabilityEntity, action: rest.join(".") };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ======================================================
|
|
91
|
+
// Adapter — contrato declarativo
|
|
92
|
+
// Código do adapter vive em @evo/model/evo-integrations/adapters/{id}.
|
|
93
|
+
// Doc correspondente em Firestore (/platform/evo-integrations/adapters/{id})
|
|
94
|
+
// pode overrider URLs default sem deploy.
|
|
95
|
+
// ======================================================
|
|
96
|
+
|
|
97
|
+
export type AdapterCategory = "clinic-agenda" | "prontuario" | "misc";
|
|
98
|
+
export type AdapterStatus = "active" | "disabled" | "beta";
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Doc Firestore global do adapter, gerenciado pela Nexus UI.
|
|
102
|
+
* Path: /platform/evo-integrations/adapters/{adapter_id}
|
|
103
|
+
*/
|
|
104
|
+
export interface IIntegrationsAdapterDoc extends IFireDoc {
|
|
105
|
+
name: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
category: AdapterCategory;
|
|
108
|
+
status: AdapterStatus;
|
|
109
|
+
/** Semver string do código do adapter (distinto do `version` numérico do IFireDoc). */
|
|
110
|
+
adapter_version: string;
|
|
111
|
+
/**
|
|
112
|
+
* URLs default dos workflows n8n por capability.
|
|
113
|
+
* Precedência: calendar.integration.workflow_overrides → este doc → adapter code default.
|
|
114
|
+
*/
|
|
115
|
+
default_workflow_urls: Partial<Record<CapabilityName, string>>;
|
|
116
|
+
supported_capabilities: readonly CapabilityName[];
|
|
117
|
+
auth_schema_version?: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ======================================================
|
|
121
|
+
// Credential — metadados. Raw creds vivem no Google Secret Manager.
|
|
122
|
+
// Path: /tenants/{t}/apps/evo-med/integration-credentials/{cred_id}
|
|
123
|
+
// ======================================================
|
|
124
|
+
|
|
125
|
+
export type IntegrationCredentialStatus = "active" | "paused" | "revoked";
|
|
126
|
+
|
|
127
|
+
export interface IIntegrationsCredential extends IFireDoc {
|
|
128
|
+
adapter_id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
/**
|
|
131
|
+
* Referência ao secret no Google Secret Manager.
|
|
132
|
+
* Formato: projects/hr-evo360/secrets/evo-integrations-{tenant}-{cred_id}
|
|
133
|
+
*/
|
|
134
|
+
secret_ref: string;
|
|
135
|
+
/** Config não-secreta (api_base, external_org_id, etc.). */
|
|
136
|
+
config?: Record<string, unknown>;
|
|
137
|
+
status: IntegrationCredentialStatus;
|
|
138
|
+
last_used_at?: Date | null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ======================================================
|
|
142
|
+
// Sync state — 1 doc por calendar, mutável.
|
|
143
|
+
// Path: /tenants/{t}/apps/evo-med/sync-states/{calendar_id}
|
|
144
|
+
// ======================================================
|
|
145
|
+
|
|
146
|
+
export type SyncWindowType = "hot" | "warm" | "recent_reconcile" | "cold";
|
|
147
|
+
|
|
148
|
+
export interface ICoveredWindow {
|
|
149
|
+
start: Date;
|
|
150
|
+
end: Date;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface ISyncedHashes {
|
|
154
|
+
patients: Record<string, string>;
|
|
155
|
+
appointments: Record<string, string>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface ISyncState extends IFireDoc {
|
|
159
|
+
calendar_id: string;
|
|
160
|
+
last_sync_at?: Date | null;
|
|
161
|
+
last_window_type?: SyncWindowType;
|
|
162
|
+
last_synced_hashes: ISyncedHashes;
|
|
163
|
+
last_coveredWindow?: ICoveredWindow | null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ======================================================
|
|
167
|
+
// Sync run event — publicado no SYNC_RUN_PUBSUB_TOPIC ao final de cada run.
|
|
168
|
+
// Schema espelha a tabela BigQuery (hr-evo360.evo_log.evo_integrations_sync_runs).
|
|
169
|
+
// ======================================================
|
|
170
|
+
|
|
171
|
+
export type SyncRunStatus = "success" | "partial" | "error";
|
|
172
|
+
|
|
173
|
+
export interface ISyncRunEventError {
|
|
174
|
+
code?: string;
|
|
175
|
+
message: string;
|
|
176
|
+
details?: Record<string, unknown>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface ISyncRunEvent {
|
|
180
|
+
run_id: string;
|
|
181
|
+
tenant: string;
|
|
182
|
+
calendar_id: string;
|
|
183
|
+
adapter_id: string;
|
|
184
|
+
window_type: SyncWindowType;
|
|
185
|
+
started_at: Date;
|
|
186
|
+
finished_at: Date;
|
|
187
|
+
status: SyncRunStatus;
|
|
188
|
+
patients_upserted: number;
|
|
189
|
+
appointments_upserted: number;
|
|
190
|
+
appointments_skipped: number;
|
|
191
|
+
deletions_detected: number;
|
|
192
|
+
coveredWindow_start?: Date;
|
|
193
|
+
coveredWindow_end?: Date;
|
|
194
|
+
duration_ms: number;
|
|
195
|
+
firestore_reads: number;
|
|
196
|
+
firestore_writes: number;
|
|
197
|
+
n8n_calls: number;
|
|
198
|
+
errors?: ISyncRunEventError[];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ======================================================
|
|
202
|
+
// Calendar integration config — vive inline no calendar doc.
|
|
203
|
+
// Ver IMedCalendar em evo-types/src/types/evo-med/calendar.
|
|
204
|
+
// ======================================================
|
|
205
|
+
|
|
206
|
+
export interface ISyncWindowConfig {
|
|
207
|
+
enabled: boolean;
|
|
208
|
+
/** Cadência em minutos. Ex.: hot=60, warm=360, cold=10080 (semanal). */
|
|
209
|
+
cadence_minutes: number;
|
|
210
|
+
/** Janela absoluta em dias a partir de "hoje". */
|
|
211
|
+
window_days: {
|
|
212
|
+
past: number;
|
|
213
|
+
future: number;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface ISyncConfig {
|
|
218
|
+
hot?: ISyncWindowConfig;
|
|
219
|
+
warm?: ISyncWindowConfig;
|
|
220
|
+
recent_reconcile?: ISyncWindowConfig;
|
|
221
|
+
cold?: ISyncWindowConfig;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface IMedCalendarIntegration {
|
|
225
|
+
adapter_id: string;
|
|
226
|
+
credentials_id: string;
|
|
227
|
+
/** Prefixo opcional pra namespacing de patient_id entre adapters/calendars. Default vazio. */
|
|
228
|
+
patient_prefix?: string;
|
|
229
|
+
sync_config: ISyncConfig;
|
|
230
|
+
/** Override por capability — precedência mais alta no resolver de URL. */
|
|
231
|
+
workflow_overrides?: Partial<Record<CapabilityName, string>>;
|
|
232
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "../../evo-people/fb_collections";
|
|
2
2
|
import type { FirestoreDocumentReference, IFireDoc, ITag } from "../../shared";
|
|
3
3
|
import type { IAppointmentCounters } from "../people";
|
|
4
|
+
import type { IMedCalendarIntegration } from "../../evo-integrations";
|
|
4
5
|
export declare const EvoMedCalendarPermissions: {
|
|
5
6
|
readonly List: "evo_med_calendar_read";
|
|
6
7
|
readonly Get: "evo_med_calendar_read";
|
|
@@ -35,5 +36,6 @@ export interface IMedCalendar extends IFireDoc {
|
|
|
35
36
|
appointmentCounters?: IAppointmentCounters | null;
|
|
36
37
|
available_weekdays?: number[];
|
|
37
38
|
available_for_hubia?: boolean;
|
|
39
|
+
integration?: IMedCalendarIntegration;
|
|
38
40
|
[key: string]: unknown;
|
|
39
41
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "../../evo-people/fb_collections";
|
|
2
2
|
import type { FirestoreDocumentReference, IFireDoc, ITag } from "../../shared";
|
|
3
3
|
import type { IAppointmentCounters } from "../people";
|
|
4
|
+
import type { IMedCalendarIntegration } from "../../evo-integrations";
|
|
4
5
|
|
|
5
6
|
// Permissões para o calendário
|
|
6
7
|
export const EvoMedCalendarPermissions = {
|
|
@@ -44,5 +45,7 @@ export interface IMedCalendar extends IFireDoc {
|
|
|
44
45
|
available_weekdays?: number[];
|
|
45
46
|
// Se true, a agenda é elegível para oferecer horários via HubIA
|
|
46
47
|
available_for_hubia?: boolean;
|
|
48
|
+
// Config de integração (feat-004 evo-integrations). Opcional — calendars legados mantêm n8n_wf/url/ext_urls.
|
|
49
|
+
integration?: IMedCalendarIntegration;
|
|
47
50
|
[key: string]: unknown; // index signature
|
|
48
51
|
}
|
|
@@ -22,6 +22,7 @@ export declare const TaskStatusEnum: {
|
|
|
22
22
|
readonly Cancelled: "cancelled";
|
|
23
23
|
readonly OnHold: "on_hold";
|
|
24
24
|
readonly Suppressed: "suppressed";
|
|
25
|
+
readonly DeadLetter: "dead_letter";
|
|
25
26
|
};
|
|
26
27
|
export type TaskStatus = (typeof TaskStatusEnum)[keyof typeof TaskStatusEnum];
|
|
27
28
|
export declare const TaskPriorityEnum: {
|
|
@@ -73,6 +74,13 @@ export interface ITaskLock {
|
|
|
73
74
|
lock_until: Date;
|
|
74
75
|
[key: string]: unknown;
|
|
75
76
|
}
|
|
77
|
+
export interface ITaskRunnerState {
|
|
78
|
+
reclaim_count?: number;
|
|
79
|
+
fallback_index?: number;
|
|
80
|
+
last_dispatch_at?: Date;
|
|
81
|
+
dispatched_attempts?: number;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}
|
|
76
84
|
export declare const TaskDedupScopeEnum: {
|
|
77
85
|
readonly PerRecipient: "per_recipient";
|
|
78
86
|
readonly PerRecipientAndObject: "per_recipient_and_object";
|
|
@@ -167,6 +175,7 @@ export interface IAutoTask extends ITaskBase {
|
|
|
167
175
|
lock?: ITaskLock;
|
|
168
176
|
retry?: ITaskRetryPolicy;
|
|
169
177
|
on_failure?: ITaskOnFailure;
|
|
178
|
+
runner_state?: ITaskRunnerState;
|
|
170
179
|
auto: ITaskAutoSpec;
|
|
171
180
|
}
|
|
172
181
|
export type ITask = IHumanTask | IAutoTask;
|
|
@@ -50,6 +50,7 @@ exports.TaskStatusEnum = {
|
|
|
50
50
|
Cancelled: "cancelled",
|
|
51
51
|
OnHold: "on_hold",
|
|
52
52
|
Suppressed: "suppressed", // intentionally skipped (e.g., dedup)
|
|
53
|
+
DeadLetter: "dead_letter", // unrecoverable after reclaim attempts
|
|
53
54
|
};
|
|
54
55
|
// ----- Task priority (human-friendly)
|
|
55
56
|
exports.TaskPriorityEnum = {
|
|
@@ -48,6 +48,7 @@ export const TaskStatusEnum = {
|
|
|
48
48
|
Cancelled: "cancelled",
|
|
49
49
|
OnHold: "on_hold",
|
|
50
50
|
Suppressed: "suppressed", // intentionally skipped (e.g., dedup)
|
|
51
|
+
DeadLetter: "dead_letter", // unrecoverable after reclaim attempts
|
|
51
52
|
} as const;
|
|
52
53
|
|
|
53
54
|
export type TaskStatus = (typeof TaskStatusEnum)[keyof typeof TaskStatusEnum];
|
|
@@ -123,6 +124,15 @@ export interface ITaskLock {
|
|
|
123
124
|
[key: string]: unknown;
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
// ----- Runtime state maintained by the Task Runner
|
|
128
|
+
export interface ITaskRunnerState {
|
|
129
|
+
reclaim_count?: number;
|
|
130
|
+
fallback_index?: number; // -1 = primary, 0..N = auto_fallbacks[i]
|
|
131
|
+
last_dispatch_at?: Date;
|
|
132
|
+
dispatched_attempts?: number;
|
|
133
|
+
[key: string]: unknown;
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
// ----- Dedup / suppression (optional)
|
|
127
137
|
export const TaskDedupScopeEnum = {
|
|
128
138
|
PerRecipient: "per_recipient",
|
|
@@ -276,6 +286,9 @@ export interface IAutoTask extends ITaskBase {
|
|
|
276
286
|
retry?: ITaskRetryPolicy;
|
|
277
287
|
on_failure?: ITaskOnFailure;
|
|
278
288
|
|
|
289
|
+
// Runtime state populated by the Task Runner
|
|
290
|
+
runner_state?: ITaskRunnerState;
|
|
291
|
+
|
|
279
292
|
// What to execute
|
|
280
293
|
auto: ITaskAutoSpec;
|
|
281
294
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TASK_RUNNER_CONFIG_DOC = "config";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TASK_RUNNER_CONFIG_DOC = void 0;
|
|
4
|
+
// Per-tenant task runner configuration.
|
|
5
|
+
// Path: tenants/{tenant}/apps/evo-task-runner/config/config
|
|
6
|
+
// - `config` subcollection reuses the shared CONFIG_COLLECTION ("config")
|
|
7
|
+
// - TASK_RUNNER_CONFIG_DOC is the fixed doc id inside that subcollection
|
|
8
|
+
exports.TASK_RUNNER_CONFIG_DOC = "config";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Per-tenant task runner configuration.
|
|
2
|
+
// Path: tenants/{tenant}/apps/evo-task-runner/config/config
|
|
3
|
+
// - `config` subcollection reuses the shared CONFIG_COLLECTION ("config")
|
|
4
|
+
// - TASK_RUNNER_CONFIG_DOC is the fixed doc id inside that subcollection
|
|
5
|
+
export const TASK_RUNNER_CONFIG_DOC = "config";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./fb_collections";
|
|
1
2
|
import type { IFireDoc } from "../shared";
|
|
2
3
|
import type { TaskAutoHandler, TaskExecutionStatus, TaskRetryStrategy } from "../evo-task";
|
|
3
4
|
export declare const EvoTaskRunnerPermissions: {
|
|
@@ -8,12 +9,15 @@ export declare const EvoTaskRunnerPermissions: {
|
|
|
8
9
|
readonly Delete: "evo_task_runner_write";
|
|
9
10
|
};
|
|
10
11
|
export type EvoTaskRunnerPermissions = (typeof EvoTaskRunnerPermissions)[keyof typeof EvoTaskRunnerPermissions];
|
|
12
|
+
export declare const EVO_TASK_RUNNER_APP = "evo-task-runner";
|
|
13
|
+
export declare const TaskRunnerWorkerIdPrefix = "task-runner";
|
|
11
14
|
export declare const TaskRunnerTopics: {
|
|
12
15
|
readonly Tick: "task_runner.tick";
|
|
13
16
|
readonly ExecuteRequests: "task_runner.execute_requests";
|
|
14
17
|
readonly ExecutionReports: "task_runner.execution_reports";
|
|
15
18
|
};
|
|
16
19
|
export type TaskRunnerTopic = (typeof TaskRunnerTopics)[keyof typeof TaskRunnerTopics];
|
|
20
|
+
export declare const taskRunnerHandlerTopic: (handler: string) => string;
|
|
17
21
|
export declare const TaskRunnerTickReasonEnum: {
|
|
18
22
|
readonly Schedule: "schedule";
|
|
19
23
|
readonly Manual: "manual";
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskRunnerTickReasonEnum = exports.TaskRunnerTopics = exports.EvoTaskRunnerPermissions = void 0;
|
|
17
|
+
exports.TaskRunnerTickReasonEnum = exports.taskRunnerHandlerTopic = exports.TaskRunnerTopics = exports.TaskRunnerWorkerIdPrefix = exports.EVO_TASK_RUNNER_APP = exports.EvoTaskRunnerPermissions = void 0;
|
|
18
|
+
__exportStar(require("./fb_collections"), exports);
|
|
4
19
|
// Permissões para o task runner
|
|
5
20
|
exports.EvoTaskRunnerPermissions = {
|
|
6
21
|
List: "evo_task_runner_read",
|
|
@@ -21,12 +36,19 @@ exports.EvoTaskRunnerPermissions = {
|
|
|
21
36
|
// - Task payload schemas live in their respective modules.
|
|
22
37
|
// - This contract is handler-agnostic and safe to share between backend/frontend.
|
|
23
38
|
// ======================================================
|
|
39
|
+
// ----- App identifier (Firestore path: tenants/{t}/apps/evo-task-runner/...)
|
|
40
|
+
exports.EVO_TASK_RUNNER_APP = "evo-task-runner";
|
|
41
|
+
// ----- Prefix used to compose worker ids (e.g. `${prefix}-${K_SERVICE}-${uuid}`)
|
|
42
|
+
exports.TaskRunnerWorkerIdPrefix = "task-runner";
|
|
24
43
|
// ----- Pub/Sub topic suggestions (logical names)
|
|
25
44
|
exports.TaskRunnerTopics = {
|
|
26
45
|
Tick: "task_runner.tick",
|
|
27
46
|
ExecuteRequests: "task_runner.execute_requests",
|
|
28
47
|
ExecutionReports: "task_runner.execution_reports",
|
|
29
48
|
};
|
|
49
|
+
// ----- Per-handler execute requests topic (one topic per handler id)
|
|
50
|
+
const taskRunnerHandlerTopic = (handler) => `${handler}.execute_requests`;
|
|
51
|
+
exports.taskRunnerHandlerTopic = taskRunnerHandlerTopic;
|
|
30
52
|
// ----- Runner tick messages (optional)
|
|
31
53
|
exports.TaskRunnerTickReasonEnum = {
|
|
32
54
|
Schedule: "schedule",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./fb_collections";
|
|
1
2
|
import type { IFireDoc } from "../shared";
|
|
2
3
|
import type {
|
|
3
4
|
TaskAutoHandler,
|
|
@@ -29,6 +30,12 @@ export type EvoTaskRunnerPermissions =
|
|
|
29
30
|
// - This contract is handler-agnostic and safe to share between backend/frontend.
|
|
30
31
|
// ======================================================
|
|
31
32
|
|
|
33
|
+
// ----- App identifier (Firestore path: tenants/{t}/apps/evo-task-runner/...)
|
|
34
|
+
export const EVO_TASK_RUNNER_APP = "evo-task-runner";
|
|
35
|
+
|
|
36
|
+
// ----- Prefix used to compose worker ids (e.g. `${prefix}-${K_SERVICE}-${uuid}`)
|
|
37
|
+
export const TaskRunnerWorkerIdPrefix = "task-runner";
|
|
38
|
+
|
|
32
39
|
// ----- Pub/Sub topic suggestions (logical names)
|
|
33
40
|
export const TaskRunnerTopics = {
|
|
34
41
|
Tick: "task_runner.tick",
|
|
@@ -39,6 +46,10 @@ export const TaskRunnerTopics = {
|
|
|
39
46
|
export type TaskRunnerTopic =
|
|
40
47
|
(typeof TaskRunnerTopics)[keyof typeof TaskRunnerTopics];
|
|
41
48
|
|
|
49
|
+
// ----- Per-handler execute requests topic (one topic per handler id)
|
|
50
|
+
export const taskRunnerHandlerTopic = (handler: string) =>
|
|
51
|
+
`${handler}.execute_requests`;
|
|
52
|
+
|
|
42
53
|
// ----- Runner tick messages (optional)
|
|
43
54
|
export const TaskRunnerTickReasonEnum = {
|
|
44
55
|
Schedule: "schedule",
|