@hasna/microservices 0.0.15 → 0.0.17
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/README.md +120 -138
- package/bin/index.js +703 -12728
- package/bin/mcp.js +250 -9726
- package/dist/index.js +170 -9407
- package/package.json +25 -25
- package/microservices/microservice-ads/package.json +0 -27
- package/microservices/microservice-ads/src/cli/index.ts +0 -605
- package/microservices/microservice-ads/src/db/campaigns.ts +0 -797
- package/microservices/microservice-ads/src/db/database.ts +0 -93
- package/microservices/microservice-ads/src/db/migrations.ts +0 -60
- package/microservices/microservice-ads/src/index.ts +0 -39
- package/microservices/microservice-ads/src/mcp/index.ts +0 -480
- package/microservices/microservice-analytics/package.json +0 -27
- package/microservices/microservice-analytics/src/cli/index.ts +0 -373
- package/microservices/microservice-analytics/src/db/analytics.ts +0 -564
- package/microservices/microservice-analytics/src/db/database.ts +0 -93
- package/microservices/microservice-analytics/src/db/migrations.ts +0 -50
- package/microservices/microservice-analytics/src/index.ts +0 -37
- package/microservices/microservice-analytics/src/mcp/index.ts +0 -334
- package/microservices/microservice-assets/package.json +0 -27
- package/microservices/microservice-assets/src/cli/index.ts +0 -375
- package/microservices/microservice-assets/src/db/assets.ts +0 -370
- package/microservices/microservice-assets/src/db/database.ts +0 -93
- package/microservices/microservice-assets/src/db/migrations.ts +0 -51
- package/microservices/microservice-assets/src/index.ts +0 -32
- package/microservices/microservice-assets/src/mcp/index.ts +0 -346
- package/microservices/microservice-bookkeeping/package.json +0 -27
- package/microservices/microservice-bookkeeping/src/cli/index.ts +0 -386
- package/microservices/microservice-bookkeeping/src/db/bookkeeping.ts +0 -591
- package/microservices/microservice-bookkeeping/src/db/database.ts +0 -93
- package/microservices/microservice-bookkeeping/src/db/migrations.ts +0 -52
- package/microservices/microservice-bookkeeping/src/index.ts +0 -32
- package/microservices/microservice-bookkeeping/src/mcp/index.ts +0 -284
- package/microservices/microservice-calendar/package.json +0 -27
- package/microservices/microservice-calendar/src/cli/index.ts +0 -287
- package/microservices/microservice-calendar/src/db/calendar.ts +0 -328
- package/microservices/microservice-calendar/src/db/database.ts +0 -82
- package/microservices/microservice-calendar/src/db/migrations.ts +0 -47
- package/microservices/microservice-calendar/src/index.ts +0 -24
- package/microservices/microservice-calendar/src/mcp/index.ts +0 -226
- package/microservices/microservice-company/package.json +0 -27
- package/microservices/microservice-company/src/cli/index.ts +0 -1126
- package/microservices/microservice-company/src/db/company.ts +0 -854
- package/microservices/microservice-company/src/db/database.ts +0 -93
- package/microservices/microservice-company/src/db/migrations.ts +0 -214
- package/microservices/microservice-company/src/db/workflow-migrations.ts +0 -44
- package/microservices/microservice-company/src/index.ts +0 -60
- package/microservices/microservice-company/src/lib/audit.ts +0 -168
- package/microservices/microservice-company/src/lib/finance.ts +0 -299
- package/microservices/microservice-company/src/lib/settings.ts +0 -85
- package/microservices/microservice-company/src/lib/workflows.ts +0 -698
- package/microservices/microservice-company/src/mcp/index.ts +0 -991
- package/microservices/microservice-compliance/package.json +0 -27
- package/microservices/microservice-compliance/src/cli/index.ts +0 -467
- package/microservices/microservice-compliance/src/db/compliance.ts +0 -633
- package/microservices/microservice-compliance/src/db/database.ts +0 -93
- package/microservices/microservice-compliance/src/db/migrations.ts +0 -63
- package/microservices/microservice-compliance/src/index.ts +0 -46
- package/microservices/microservice-compliance/src/mcp/index.ts +0 -438
- package/microservices/microservice-contacts/package.json +0 -27
- package/microservices/microservice-contacts/src/cli/index.ts +0 -393
- package/microservices/microservice-contacts/src/db/companies.ts +0 -167
- package/microservices/microservice-contacts/src/db/contacts.ts +0 -249
- package/microservices/microservice-contacts/src/db/database.ts +0 -93
- package/microservices/microservice-contacts/src/db/migrations.ts +0 -71
- package/microservices/microservice-contacts/src/db/relationships.ts +0 -53
- package/microservices/microservice-contacts/src/index.ts +0 -42
- package/microservices/microservice-contacts/src/mcp/index.ts +0 -303
- package/microservices/microservice-contracts/package.json +0 -27
- package/microservices/microservice-contracts/src/cli/index.ts +0 -770
- package/microservices/microservice-contracts/src/db/contracts.ts +0 -925
- package/microservices/microservice-contracts/src/db/database.ts +0 -93
- package/microservices/microservice-contracts/src/db/migrations.ts +0 -141
- package/microservices/microservice-contracts/src/index.ts +0 -43
- package/microservices/microservice-contracts/src/mcp/index.ts +0 -617
- package/microservices/microservice-crm/package.json +0 -27
- package/microservices/microservice-crm/src/cli/index.ts +0 -396
- package/microservices/microservice-crm/src/db/database.ts +0 -82
- package/microservices/microservice-crm/src/db/migrations.ts +0 -66
- package/microservices/microservice-crm/src/db/pipeline.ts +0 -397
- package/microservices/microservice-crm/src/index.ts +0 -34
- package/microservices/microservice-crm/src/mcp/index.ts +0 -294
- package/microservices/microservice-documents/package.json +0 -27
- package/microservices/microservice-documents/src/cli/index.ts +0 -246
- package/microservices/microservice-documents/src/db/database.ts +0 -82
- package/microservices/microservice-documents/src/db/documents.ts +0 -316
- package/microservices/microservice-documents/src/db/migrations.ts +0 -49
- package/microservices/microservice-documents/src/index.ts +0 -24
- package/microservices/microservice-documents/src/mcp/index.ts +0 -202
- package/microservices/microservice-domains/package.json +0 -27
- package/microservices/microservice-domains/src/cli/index.ts +0 -1111
- package/microservices/microservice-domains/src/db/database.ts +0 -93
- package/microservices/microservice-domains/src/db/domains.ts +0 -1164
- package/microservices/microservice-domains/src/db/migrations.ts +0 -60
- package/microservices/microservice-domains/src/index.ts +0 -65
- package/microservices/microservice-domains/src/lib/brandsight.ts +0 -350
- package/microservices/microservice-domains/src/lib/godaddy.ts +0 -338
- package/microservices/microservice-domains/src/lib/namecheap.ts +0 -262
- package/microservices/microservice-domains/src/lib/registrar.ts +0 -355
- package/microservices/microservice-domains/src/mcp/index.ts +0 -781
- package/microservices/microservice-expenses/package.json +0 -27
- package/microservices/microservice-expenses/src/cli/index.ts +0 -267
- package/microservices/microservice-expenses/src/db/database.ts +0 -82
- package/microservices/microservice-expenses/src/db/expenses.ts +0 -345
- package/microservices/microservice-expenses/src/db/migrations.ts +0 -45
- package/microservices/microservice-expenses/src/index.ts +0 -25
- package/microservices/microservice-expenses/src/mcp/index.ts +0 -196
- package/microservices/microservice-habits/package.json +0 -27
- package/microservices/microservice-habits/src/cli/index.ts +0 -315
- package/microservices/microservice-habits/src/db/database.ts +0 -93
- package/microservices/microservice-habits/src/db/habits.ts +0 -451
- package/microservices/microservice-habits/src/db/migrations.ts +0 -46
- package/microservices/microservice-habits/src/index.ts +0 -31
- package/microservices/microservice-habits/src/mcp/index.ts +0 -313
- package/microservices/microservice-health/package.json +0 -27
- package/microservices/microservice-health/src/cli/index.ts +0 -484
- package/microservices/microservice-health/src/db/database.ts +0 -93
- package/microservices/microservice-health/src/db/health.ts +0 -708
- package/microservices/microservice-health/src/db/migrations.ts +0 -70
- package/microservices/microservice-health/src/index.ts +0 -63
- package/microservices/microservice-health/src/mcp/index.ts +0 -437
- package/microservices/microservice-hiring/package.json +0 -27
- package/microservices/microservice-hiring/src/cli/index.ts +0 -741
- package/microservices/microservice-hiring/src/db/database.ts +0 -93
- package/microservices/microservice-hiring/src/db/hiring.ts +0 -1085
- package/microservices/microservice-hiring/src/db/migrations.ts +0 -89
- package/microservices/microservice-hiring/src/index.ts +0 -80
- package/microservices/microservice-hiring/src/lib/scoring.ts +0 -206
- package/microservices/microservice-hiring/src/mcp/index.ts +0 -709
- package/microservices/microservice-inventory/package.json +0 -27
- package/microservices/microservice-inventory/src/cli/index.ts +0 -365
- package/microservices/microservice-inventory/src/db/database.ts +0 -82
- package/microservices/microservice-inventory/src/db/inventory.ts +0 -393
- package/microservices/microservice-inventory/src/db/migrations.ts +0 -54
- package/microservices/microservice-inventory/src/index.ts +0 -28
- package/microservices/microservice-inventory/src/mcp/index.ts +0 -250
- package/microservices/microservice-invoices/dashboard/dist/assets/index-Bngq7FNM.css +0 -1
- package/microservices/microservice-invoices/dashboard/dist/assets/index-aHW4ARZR.js +0 -124
- package/microservices/microservice-invoices/dashboard/dist/index.html +0 -13
- package/microservices/microservice-invoices/dashboard/index.html +0 -12
- package/microservices/microservice-invoices/dashboard/package.json +0 -29
- package/microservices/microservice-invoices/dashboard/tsconfig.json +0 -14
- package/microservices/microservice-invoices/dashboard/vite.config.ts +0 -15
- package/microservices/microservice-invoices/package.json +0 -30
- package/microservices/microservice-invoices/src/cli/index.ts +0 -308
- package/microservices/microservice-invoices/src/db/business.ts +0 -241
- package/microservices/microservice-invoices/src/db/clients.ts +0 -127
- package/microservices/microservice-invoices/src/db/database.ts +0 -82
- package/microservices/microservice-invoices/src/db/invoices.ts +0 -345
- package/microservices/microservice-invoices/src/db/migrations.ts +0 -184
- package/microservices/microservice-invoices/src/index.ts +0 -56
- package/microservices/microservice-invoices/src/mcp/index.ts +0 -242
- package/microservices/microservice-invoices/src/server/index.ts +0 -162
- package/microservices/microservice-leads/package.json +0 -27
- package/microservices/microservice-leads/src/cli/index.ts +0 -596
- package/microservices/microservice-leads/src/db/database.ts +0 -93
- package/microservices/microservice-leads/src/db/leads.ts +0 -520
- package/microservices/microservice-leads/src/db/lists.ts +0 -151
- package/microservices/microservice-leads/src/db/migrations.ts +0 -93
- package/microservices/microservice-leads/src/index.ts +0 -65
- package/microservices/microservice-leads/src/lib/enrichment.ts +0 -202
- package/microservices/microservice-leads/src/lib/scoring.ts +0 -134
- package/microservices/microservice-leads/src/mcp/index.ts +0 -533
- package/microservices/microservice-notes/package.json +0 -27
- package/microservices/microservice-notes/src/cli/index.ts +0 -63
- package/microservices/microservice-notes/src/db/database.ts +0 -93
- package/microservices/microservice-notes/src/db/migrations.ts +0 -40
- package/microservices/microservice-notes/src/db/notes.ts +0 -114
- package/microservices/microservice-notes/src/index.ts +0 -2
- package/microservices/microservice-notes/src/mcp/index.ts +0 -37
- package/microservices/microservice-notifications/package.json +0 -27
- package/microservices/microservice-notifications/src/cli/index.ts +0 -349
- package/microservices/microservice-notifications/src/db/database.ts +0 -93
- package/microservices/microservice-notifications/src/db/migrations.ts +0 -62
- package/microservices/microservice-notifications/src/db/notifications.ts +0 -509
- package/microservices/microservice-notifications/src/index.ts +0 -41
- package/microservices/microservice-notifications/src/mcp/index.ts +0 -422
- package/microservices/microservice-payments/package.json +0 -27
- package/microservices/microservice-payments/src/cli/index.ts +0 -609
- package/microservices/microservice-payments/src/db/database.ts +0 -93
- package/microservices/microservice-payments/src/db/migrations.ts +0 -81
- package/microservices/microservice-payments/src/db/payments.ts +0 -1204
- package/microservices/microservice-payments/src/index.ts +0 -51
- package/microservices/microservice-payments/src/mcp/index.ts +0 -683
- package/microservices/microservice-payroll/package.json +0 -27
- package/microservices/microservice-payroll/src/cli/index.ts +0 -643
- package/microservices/microservice-payroll/src/db/database.ts +0 -93
- package/microservices/microservice-payroll/src/db/migrations.ts +0 -95
- package/microservices/microservice-payroll/src/db/payroll.ts +0 -1377
- package/microservices/microservice-payroll/src/index.ts +0 -48
- package/microservices/microservice-payroll/src/mcp/index.ts +0 -666
- package/microservices/microservice-products/package.json +0 -27
- package/microservices/microservice-products/src/cli/index.ts +0 -416
- package/microservices/microservice-products/src/db/categories.ts +0 -154
- package/microservices/microservice-products/src/db/database.ts +0 -93
- package/microservices/microservice-products/src/db/migrations.ts +0 -58
- package/microservices/microservice-products/src/db/pricing-tiers.ts +0 -66
- package/microservices/microservice-products/src/db/products.ts +0 -452
- package/microservices/microservice-products/src/index.ts +0 -53
- package/microservices/microservice-products/src/mcp/index.ts +0 -453
- package/microservices/microservice-projects/package.json +0 -27
- package/microservices/microservice-projects/src/cli/index.ts +0 -480
- package/microservices/microservice-projects/src/db/database.ts +0 -93
- package/microservices/microservice-projects/src/db/migrations.ts +0 -65
- package/microservices/microservice-projects/src/db/projects.ts +0 -715
- package/microservices/microservice-projects/src/index.ts +0 -57
- package/microservices/microservice-projects/src/mcp/index.ts +0 -501
- package/microservices/microservice-proposals/package.json +0 -27
- package/microservices/microservice-proposals/src/cli/index.ts +0 -400
- package/microservices/microservice-proposals/src/db/database.ts +0 -93
- package/microservices/microservice-proposals/src/db/migrations.ts +0 -52
- package/microservices/microservice-proposals/src/db/proposals.ts +0 -532
- package/microservices/microservice-proposals/src/index.ts +0 -37
- package/microservices/microservice-proposals/src/mcp/index.ts +0 -375
- package/microservices/microservice-reading/package.json +0 -27
- package/microservices/microservice-reading/src/cli/index.ts +0 -464
- package/microservices/microservice-reading/src/db/database.ts +0 -93
- package/microservices/microservice-reading/src/db/migrations.ts +0 -59
- package/microservices/microservice-reading/src/db/reading.ts +0 -524
- package/microservices/microservice-reading/src/index.ts +0 -51
- package/microservices/microservice-reading/src/mcp/index.ts +0 -368
- package/microservices/microservice-shipping/package.json +0 -27
- package/microservices/microservice-shipping/src/cli/index.ts +0 -606
- package/microservices/microservice-shipping/src/db/database.ts +0 -93
- package/microservices/microservice-shipping/src/db/migrations.ts +0 -69
- package/microservices/microservice-shipping/src/db/shipping.ts +0 -1093
- package/microservices/microservice-shipping/src/index.ts +0 -53
- package/microservices/microservice-shipping/src/mcp/index.ts +0 -533
- package/microservices/microservice-social/package.json +0 -28
- package/microservices/microservice-social/src/cli/index.ts +0 -1583
- package/microservices/microservice-social/src/db/database.ts +0 -93
- package/microservices/microservice-social/src/db/migrations.ts +0 -160
- package/microservices/microservice-social/src/db/social.ts +0 -1076
- package/microservices/microservice-social/src/index.ts +0 -46
- package/microservices/microservice-social/src/lib/audience.ts +0 -353
- package/microservices/microservice-social/src/lib/content-ai.ts +0 -278
- package/microservices/microservice-social/src/lib/media.ts +0 -311
- package/microservices/microservice-social/src/lib/mentions.ts +0 -434
- package/microservices/microservice-social/src/lib/metrics-sync.ts +0 -264
- package/microservices/microservice-social/src/lib/publisher.ts +0 -377
- package/microservices/microservice-social/src/lib/scheduler.ts +0 -229
- package/microservices/microservice-social/src/lib/sentiment.ts +0 -256
- package/microservices/microservice-social/src/lib/threads.ts +0 -291
- package/microservices/microservice-social/src/mcp/index.ts +0 -1425
- package/microservices/microservice-social/src/server/index.ts +0 -441
- package/microservices/microservice-subscriptions/package.json +0 -27
- package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
- package/microservices/microservice-subscriptions/src/db/database.ts +0 -93
- package/microservices/microservice-subscriptions/src/db/migrations.ts +0 -125
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +0 -1256
- package/microservices/microservice-subscriptions/src/index.ts +0 -41
- package/microservices/microservice-subscriptions/src/mcp/index.ts +0 -631
- package/microservices/microservice-timesheets/package.json +0 -27
- package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
- package/microservices/microservice-timesheets/src/db/database.ts +0 -82
- package/microservices/microservice-timesheets/src/db/locale.ts +0 -217
- package/microservices/microservice-timesheets/src/db/migrations.ts +0 -74
- package/microservices/microservice-timesheets/src/db/timesheets.ts +0 -447
- package/microservices/microservice-timesheets/src/index.ts +0 -44
- package/microservices/microservice-timesheets/src/mcp/index.ts +0 -269
- package/microservices/microservice-transcriber/package.json +0 -28
- package/microservices/microservice-transcriber/src/cli/index.ts +0 -1593
- package/microservices/microservice-transcriber/src/db/annotations.ts +0 -37
- package/microservices/microservice-transcriber/src/db/comments.ts +0 -166
- package/microservices/microservice-transcriber/src/db/database.ts +0 -82
- package/microservices/microservice-transcriber/src/db/migrations.ts +0 -118
- package/microservices/microservice-transcriber/src/db/proofread.ts +0 -119
- package/microservices/microservice-transcriber/src/db/transcripts.ts +0 -395
- package/microservices/microservice-transcriber/src/index.ts +0 -43
- package/microservices/microservice-transcriber/src/lib/config.ts +0 -77
- package/microservices/microservice-transcriber/src/lib/diff.ts +0 -91
- package/microservices/microservice-transcriber/src/lib/downloader.ts +0 -638
- package/microservices/microservice-transcriber/src/lib/feeds.ts +0 -62
- package/microservices/microservice-transcriber/src/lib/live.ts +0 -94
- package/microservices/microservice-transcriber/src/lib/notion.ts +0 -129
- package/microservices/microservice-transcriber/src/lib/proofread.ts +0 -296
- package/microservices/microservice-transcriber/src/lib/providers.ts +0 -713
- package/microservices/microservice-transcriber/src/lib/summarizer.ts +0 -147
- package/microservices/microservice-transcriber/src/lib/translator.ts +0 -75
- package/microservices/microservice-transcriber/src/lib/webhook.ts +0 -37
- package/microservices/microservice-transcriber/src/mcp/index.ts +0 -1330
- package/microservices/microservice-transcriber/src/server/index.ts +0 -199
- package/microservices/microservice-travel/package.json +0 -27
- package/microservices/microservice-travel/src/cli/index.ts +0 -505
- package/microservices/microservice-travel/src/db/database.ts +0 -93
- package/microservices/microservice-travel/src/db/migrations.ts +0 -77
- package/microservices/microservice-travel/src/db/travel.ts +0 -802
- package/microservices/microservice-travel/src/index.ts +0 -60
- package/microservices/microservice-travel/src/mcp/index.ts +0 -495
- package/microservices/microservice-wiki/package.json +0 -27
- package/microservices/microservice-wiki/src/cli/index.ts +0 -345
- package/microservices/microservice-wiki/src/db/database.ts +0 -93
- package/microservices/microservice-wiki/src/db/migrations.ts +0 -55
- package/microservices/microservice-wiki/src/db/wiki.ts +0 -395
- package/microservices/microservice-wiki/src/index.ts +0 -32
- package/microservices/microservice-wiki/src/mcp/index.ts +0 -344
|
@@ -1,698 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow engine — orchestrates multi-service automation for microservice-company
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { existsSync } from "node:fs";
|
|
6
|
-
import { join, dirname, resolve } from "node:path";
|
|
7
|
-
import { execFile } from "node:child_process";
|
|
8
|
-
|
|
9
|
-
// ── Types ──────────────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
export interface WorkflowStep {
|
|
12
|
-
service: string;
|
|
13
|
-
action: string;
|
|
14
|
-
args?: Record<string, string>;
|
|
15
|
-
on_failure?: "stop" | "continue" | `retry:${number}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface Workflow {
|
|
19
|
-
id: string;
|
|
20
|
-
org_id: string | null;
|
|
21
|
-
name: string;
|
|
22
|
-
trigger_event: string;
|
|
23
|
-
steps: WorkflowStep[];
|
|
24
|
-
enabled: boolean;
|
|
25
|
-
last_run_at: string | null;
|
|
26
|
-
run_count: number;
|
|
27
|
-
metadata: Record<string, unknown>;
|
|
28
|
-
created_at: string;
|
|
29
|
-
updated_at: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface WorkflowRow {
|
|
33
|
-
id: string;
|
|
34
|
-
org_id: string | null;
|
|
35
|
-
name: string;
|
|
36
|
-
trigger_event: string;
|
|
37
|
-
steps: string;
|
|
38
|
-
enabled: number;
|
|
39
|
-
last_run_at: string | null;
|
|
40
|
-
run_count: number;
|
|
41
|
-
metadata: string;
|
|
42
|
-
created_at: string;
|
|
43
|
-
updated_at: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface StepResult {
|
|
47
|
-
step_index: number;
|
|
48
|
-
service: string;
|
|
49
|
-
action: string;
|
|
50
|
-
status: "success" | "failed" | "skipped";
|
|
51
|
-
output: string;
|
|
52
|
-
duration_ms: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface WorkflowRun {
|
|
56
|
-
id: string;
|
|
57
|
-
workflow_id: string;
|
|
58
|
-
trigger_data: Record<string, unknown> | null;
|
|
59
|
-
status: "running" | "completed" | "failed" | "partial";
|
|
60
|
-
steps_completed: number;
|
|
61
|
-
steps_total: number;
|
|
62
|
-
results: StepResult[];
|
|
63
|
-
started_at: string;
|
|
64
|
-
completed_at: string | null;
|
|
65
|
-
error: string | null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface WorkflowRunRow {
|
|
69
|
-
id: string;
|
|
70
|
-
workflow_id: string;
|
|
71
|
-
trigger_data: string | null;
|
|
72
|
-
status: string;
|
|
73
|
-
steps_completed: number;
|
|
74
|
-
steps_total: number;
|
|
75
|
-
results: string;
|
|
76
|
-
started_at: string;
|
|
77
|
-
completed_at: string | null;
|
|
78
|
-
error: string | null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface CreateWorkflowInput {
|
|
82
|
-
name: string;
|
|
83
|
-
trigger_event: string;
|
|
84
|
-
steps: WorkflowStep[];
|
|
85
|
-
org_id?: string;
|
|
86
|
-
metadata?: Record<string, unknown>;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface UpdateWorkflowInput {
|
|
90
|
-
name?: string;
|
|
91
|
-
trigger_event?: string;
|
|
92
|
-
steps?: WorkflowStep[];
|
|
93
|
-
org_id?: string;
|
|
94
|
-
metadata?: Record<string, unknown>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface ListWorkflowsOptions {
|
|
98
|
-
org_id?: string;
|
|
99
|
-
trigger_event?: string;
|
|
100
|
-
enabled?: boolean;
|
|
101
|
-
limit?: number;
|
|
102
|
-
offset?: number;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ── Database access ────────────────────────────────────────────────────
|
|
106
|
-
|
|
107
|
-
// The database getter is injected to avoid circular dependency with the
|
|
108
|
-
// other agent's database.ts. Tests provide their own DB via setDatabase().
|
|
109
|
-
type DatabaseGetter = () => import("bun:sqlite").Database;
|
|
110
|
-
|
|
111
|
-
let _getDb: DatabaseGetter | null = null;
|
|
112
|
-
|
|
113
|
-
export function setDatabase(getter: DatabaseGetter): void {
|
|
114
|
-
_getDb = getter;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function db() {
|
|
118
|
-
if (!_getDb) {
|
|
119
|
-
// Lazy import — the other agent's database.ts will exist at runtime
|
|
120
|
-
try {
|
|
121
|
-
const mod = require("../db/database.js");
|
|
122
|
-
_getDb = mod.getDatabase;
|
|
123
|
-
} catch {
|
|
124
|
-
throw new Error(
|
|
125
|
-
"No database configured. Call setDatabase() or ensure ../db/database.ts exists."
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return _getDb();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ── Row converters ─────────────────────────────────────────────────────
|
|
133
|
-
|
|
134
|
-
function rowToWorkflow(row: WorkflowRow): Workflow {
|
|
135
|
-
return {
|
|
136
|
-
...row,
|
|
137
|
-
steps: JSON.parse(row.steps || "[]"),
|
|
138
|
-
enabled: row.enabled === 1,
|
|
139
|
-
metadata: JSON.parse(row.metadata || "{}"),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function rowToWorkflowRun(row: WorkflowRunRow): WorkflowRun {
|
|
144
|
-
return {
|
|
145
|
-
...row,
|
|
146
|
-
trigger_data: row.trigger_data ? JSON.parse(row.trigger_data) : null,
|
|
147
|
-
status: row.status as WorkflowRun["status"],
|
|
148
|
-
results: JSON.parse(row.results || "[]"),
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// ── CRUD ───────────────────────────────────────────────────────────────
|
|
153
|
-
|
|
154
|
-
export function createWorkflow(input: CreateWorkflowInput): Workflow {
|
|
155
|
-
const id = crypto.randomUUID();
|
|
156
|
-
const steps = JSON.stringify(input.steps);
|
|
157
|
-
const metadata = JSON.stringify(input.metadata || {});
|
|
158
|
-
|
|
159
|
-
db()
|
|
160
|
-
.prepare(
|
|
161
|
-
`INSERT INTO workflows (id, org_id, name, trigger_event, steps, metadata)
|
|
162
|
-
VALUES (?, ?, ?, ?, ?, ?)`
|
|
163
|
-
)
|
|
164
|
-
.run(id, input.org_id || null, input.name, input.trigger_event, steps, metadata);
|
|
165
|
-
|
|
166
|
-
return getWorkflow(id)!;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function getWorkflow(id: string): Workflow | null {
|
|
170
|
-
const row = db()
|
|
171
|
-
.prepare("SELECT * FROM workflows WHERE id = ?")
|
|
172
|
-
.get(id) as WorkflowRow | null;
|
|
173
|
-
return row ? rowToWorkflow(row) : null;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function listWorkflows(options: ListWorkflowsOptions = {}): Workflow[] {
|
|
177
|
-
const conditions: string[] = [];
|
|
178
|
-
const params: unknown[] = [];
|
|
179
|
-
|
|
180
|
-
if (options.org_id !== undefined) {
|
|
181
|
-
conditions.push("org_id = ?");
|
|
182
|
-
params.push(options.org_id);
|
|
183
|
-
}
|
|
184
|
-
if (options.trigger_event !== undefined) {
|
|
185
|
-
conditions.push("trigger_event = ?");
|
|
186
|
-
params.push(options.trigger_event);
|
|
187
|
-
}
|
|
188
|
-
if (options.enabled !== undefined) {
|
|
189
|
-
conditions.push("enabled = ?");
|
|
190
|
-
params.push(options.enabled ? 1 : 0);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
let sql = "SELECT * FROM workflows";
|
|
194
|
-
if (conditions.length > 0) {
|
|
195
|
-
sql += " WHERE " + conditions.join(" AND ");
|
|
196
|
-
}
|
|
197
|
-
sql += " ORDER BY created_at DESC";
|
|
198
|
-
|
|
199
|
-
if (options.limit) {
|
|
200
|
-
sql += " LIMIT ?";
|
|
201
|
-
params.push(options.limit);
|
|
202
|
-
}
|
|
203
|
-
if (options.offset) {
|
|
204
|
-
sql += " OFFSET ?";
|
|
205
|
-
params.push(options.offset);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const rows = db().prepare(sql).all(...params) as WorkflowRow[];
|
|
209
|
-
return rows.map(rowToWorkflow);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export function updateWorkflow(id: string, input: UpdateWorkflowInput): Workflow | null {
|
|
213
|
-
const existing = getWorkflow(id);
|
|
214
|
-
if (!existing) return null;
|
|
215
|
-
|
|
216
|
-
const sets: string[] = [];
|
|
217
|
-
const params: unknown[] = [];
|
|
218
|
-
|
|
219
|
-
if (input.name !== undefined) {
|
|
220
|
-
sets.push("name = ?");
|
|
221
|
-
params.push(input.name);
|
|
222
|
-
}
|
|
223
|
-
if (input.trigger_event !== undefined) {
|
|
224
|
-
sets.push("trigger_event = ?");
|
|
225
|
-
params.push(input.trigger_event);
|
|
226
|
-
}
|
|
227
|
-
if (input.steps !== undefined) {
|
|
228
|
-
sets.push("steps = ?");
|
|
229
|
-
params.push(JSON.stringify(input.steps));
|
|
230
|
-
}
|
|
231
|
-
if (input.org_id !== undefined) {
|
|
232
|
-
sets.push("org_id = ?");
|
|
233
|
-
params.push(input.org_id);
|
|
234
|
-
}
|
|
235
|
-
if (input.metadata !== undefined) {
|
|
236
|
-
sets.push("metadata = ?");
|
|
237
|
-
params.push(JSON.stringify(input.metadata));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (sets.length === 0) return existing;
|
|
241
|
-
|
|
242
|
-
sets.push("updated_at = datetime('now')");
|
|
243
|
-
params.push(id);
|
|
244
|
-
|
|
245
|
-
db()
|
|
246
|
-
.prepare(`UPDATE workflows SET ${sets.join(", ")} WHERE id = ?`)
|
|
247
|
-
.run(...params);
|
|
248
|
-
|
|
249
|
-
return getWorkflow(id);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export function deleteWorkflow(id: string): boolean {
|
|
253
|
-
const result = db().prepare("DELETE FROM workflows WHERE id = ?").run(id);
|
|
254
|
-
return result.changes > 0;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export function enableWorkflow(id: string): Workflow | null {
|
|
258
|
-
const existing = getWorkflow(id);
|
|
259
|
-
if (!existing) return null;
|
|
260
|
-
db()
|
|
261
|
-
.prepare("UPDATE workflows SET enabled = 1, updated_at = datetime('now') WHERE id = ?")
|
|
262
|
-
.run(id);
|
|
263
|
-
return getWorkflow(id);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export function disableWorkflow(id: string): Workflow | null {
|
|
267
|
-
const existing = getWorkflow(id);
|
|
268
|
-
if (!existing) return null;
|
|
269
|
-
db()
|
|
270
|
-
.prepare("UPDATE workflows SET enabled = 0, updated_at = datetime('now') WHERE id = ?")
|
|
271
|
-
.run(id);
|
|
272
|
-
return getWorkflow(id);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// ── Template resolution ────────────────────────────────────────────────
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Resolve template variables in a string.
|
|
279
|
-
* Supports:
|
|
280
|
-
* {{data.field}} — from trigger data
|
|
281
|
-
* {{data.nested.field}} — dot-path into trigger data
|
|
282
|
-
* {{steps[0].output}} — output from a previous step
|
|
283
|
-
*/
|
|
284
|
-
export function resolveTemplate(
|
|
285
|
-
template: string,
|
|
286
|
-
context: { data?: Record<string, unknown>; steps?: StepResult[] }
|
|
287
|
-
): string {
|
|
288
|
-
return template.replace(/\{\{([^}]+)\}\}/g, (_match, expr: string) => {
|
|
289
|
-
const trimmed = expr.trim();
|
|
290
|
-
|
|
291
|
-
// {{steps[N].output}}
|
|
292
|
-
const stepMatch = trimmed.match(/^steps\[(\d+)\]\.output$/);
|
|
293
|
-
if (stepMatch) {
|
|
294
|
-
const idx = parseInt(stepMatch[1], 10);
|
|
295
|
-
if (context.steps && context.steps[idx]) {
|
|
296
|
-
return context.steps[idx].output;
|
|
297
|
-
}
|
|
298
|
-
return "";
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// {{data.X}} or {{data.X.Y}}
|
|
302
|
-
if (trimmed.startsWith("data.")) {
|
|
303
|
-
const path = trimmed.slice(5).split(".");
|
|
304
|
-
let current: unknown = context.data || {};
|
|
305
|
-
for (const key of path) {
|
|
306
|
-
if (current === null || current === undefined || typeof current !== "object") {
|
|
307
|
-
return "";
|
|
308
|
-
}
|
|
309
|
-
current = (current as Record<string, unknown>)[key];
|
|
310
|
-
}
|
|
311
|
-
return current !== null && current !== undefined ? String(current) : "";
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return "";
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// ── Microservice CLI path resolution ───────────────────────────────────
|
|
319
|
-
|
|
320
|
-
function getMicroservicesDir(): string {
|
|
321
|
-
if (process.env["MICROSERVICES_DIR"]) {
|
|
322
|
-
return process.env["MICROSERVICES_DIR"];
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
let dir = resolve(process.cwd());
|
|
326
|
-
while (true) {
|
|
327
|
-
const candidate = join(dir, ".microservices");
|
|
328
|
-
if (existsSync(candidate)) return candidate;
|
|
329
|
-
const parent = dirname(dir);
|
|
330
|
-
if (parent === dir) break;
|
|
331
|
-
dir = parent;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
335
|
-
return join(home, ".microservices");
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function getMicroserviceCliPath(name: string): string | null {
|
|
339
|
-
const dir = getMicroservicesDir();
|
|
340
|
-
const msName = name.startsWith("microservice-") ? name : `microservice-${name}`;
|
|
341
|
-
|
|
342
|
-
const candidates = [
|
|
343
|
-
join(dir, msName, "src", "cli", "index.ts"),
|
|
344
|
-
join(dir, msName, "cli.ts"),
|
|
345
|
-
join(dir, msName, "src", "index.ts"),
|
|
346
|
-
];
|
|
347
|
-
|
|
348
|
-
for (const candidate of candidates) {
|
|
349
|
-
if (existsSync(candidate)) return candidate;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return null;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// ── Step execution ─────────────────────────────────────────────────────
|
|
356
|
-
|
|
357
|
-
async function executeStep(
|
|
358
|
-
step: WorkflowStep,
|
|
359
|
-
context: { data: Record<string, unknown>; steps: StepResult[] }
|
|
360
|
-
): Promise<StepResult> {
|
|
361
|
-
const start = Date.now();
|
|
362
|
-
|
|
363
|
-
// Build CLI args from the step definition
|
|
364
|
-
const cliArgs: string[] = [step.action];
|
|
365
|
-
if (step.args) {
|
|
366
|
-
for (const [key, rawValue] of Object.entries(step.args)) {
|
|
367
|
-
const value = resolveTemplate(rawValue, context);
|
|
368
|
-
cliArgs.push(`--${key}`, value);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const cliPath = getMicroserviceCliPath(step.service);
|
|
373
|
-
if (!cliPath) {
|
|
374
|
-
return {
|
|
375
|
-
step_index: context.steps.length,
|
|
376
|
-
service: step.service,
|
|
377
|
-
action: step.action,
|
|
378
|
-
status: "failed",
|
|
379
|
-
output: `CLI not found for service '${step.service}'`,
|
|
380
|
-
duration_ms: Date.now() - start,
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
try {
|
|
385
|
-
const output = await new Promise<string>((resolve, reject) => {
|
|
386
|
-
execFile(
|
|
387
|
-
"bun",
|
|
388
|
-
["run", cliPath, ...cliArgs],
|
|
389
|
-
{
|
|
390
|
-
timeout: 30000,
|
|
391
|
-
env: { ...process.env, MICROSERVICES_DIR: getMicroservicesDir() },
|
|
392
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
393
|
-
},
|
|
394
|
-
(error, stdout, stderr) => {
|
|
395
|
-
if (error) {
|
|
396
|
-
reject(new Error(stderr || stdout || error.message));
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
resolve((stdout || "").trim());
|
|
400
|
-
}
|
|
401
|
-
);
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
return {
|
|
405
|
-
step_index: context.steps.length,
|
|
406
|
-
service: step.service,
|
|
407
|
-
action: step.action,
|
|
408
|
-
status: "success",
|
|
409
|
-
output,
|
|
410
|
-
duration_ms: Date.now() - start,
|
|
411
|
-
};
|
|
412
|
-
} catch (err) {
|
|
413
|
-
return {
|
|
414
|
-
step_index: context.steps.length,
|
|
415
|
-
service: step.service,
|
|
416
|
-
action: step.action,
|
|
417
|
-
status: "failed",
|
|
418
|
-
output: err instanceof Error ? err.message : String(err),
|
|
419
|
-
duration_ms: Date.now() - start,
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// ── Workflow runner ────────────────────────────────────────────────────
|
|
425
|
-
|
|
426
|
-
export async function runWorkflow(
|
|
427
|
-
id: string,
|
|
428
|
-
triggerData: Record<string, unknown> = {}
|
|
429
|
-
): Promise<WorkflowRun> {
|
|
430
|
-
const workflow = getWorkflow(id);
|
|
431
|
-
if (!workflow) throw new Error(`Workflow '${id}' not found`);
|
|
432
|
-
if (!workflow.enabled) throw new Error(`Workflow '${workflow.name}' is disabled`);
|
|
433
|
-
|
|
434
|
-
// Create workflow_run record
|
|
435
|
-
const runId = crypto.randomUUID();
|
|
436
|
-
db()
|
|
437
|
-
.prepare(
|
|
438
|
-
`INSERT INTO workflow_runs (id, workflow_id, trigger_data, status, steps_total)
|
|
439
|
-
VALUES (?, ?, ?, 'running', ?)`
|
|
440
|
-
)
|
|
441
|
-
.run(runId, id, JSON.stringify(triggerData), workflow.steps.length);
|
|
442
|
-
|
|
443
|
-
const context: { data: Record<string, unknown>; steps: StepResult[] } = {
|
|
444
|
-
data: triggerData,
|
|
445
|
-
steps: [],
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
let finalStatus: WorkflowRun["status"] = "completed";
|
|
449
|
-
let errorMsg: string | null = null;
|
|
450
|
-
|
|
451
|
-
for (let i = 0; i < workflow.steps.length; i++) {
|
|
452
|
-
const step = workflow.steps[i];
|
|
453
|
-
const onFailure = step.on_failure || "stop";
|
|
454
|
-
|
|
455
|
-
let result: StepResult | null = null;
|
|
456
|
-
|
|
457
|
-
if (onFailure.startsWith("retry:")) {
|
|
458
|
-
const maxRetries = parseInt(onFailure.split(":")[1], 10) || 1;
|
|
459
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
460
|
-
result = await executeStep(step, context);
|
|
461
|
-
if (result.status === "success") break;
|
|
462
|
-
}
|
|
463
|
-
} else {
|
|
464
|
-
result = await executeStep(step, context);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
context.steps.push(result!);
|
|
468
|
-
|
|
469
|
-
// Update progress in DB
|
|
470
|
-
db()
|
|
471
|
-
.prepare(
|
|
472
|
-
`UPDATE workflow_runs SET steps_completed = ?, results = ? WHERE id = ?`
|
|
473
|
-
)
|
|
474
|
-
.run(i + 1, JSON.stringify(context.steps), runId);
|
|
475
|
-
|
|
476
|
-
if (result!.status === "failed") {
|
|
477
|
-
if (onFailure === "stop") {
|
|
478
|
-
finalStatus = "failed";
|
|
479
|
-
errorMsg = `Step ${i} (${step.service}.${step.action}) failed: ${result!.output}`;
|
|
480
|
-
// Mark remaining steps as skipped
|
|
481
|
-
for (let j = i + 1; j < workflow.steps.length; j++) {
|
|
482
|
-
context.steps.push({
|
|
483
|
-
step_index: j,
|
|
484
|
-
service: workflow.steps[j].service,
|
|
485
|
-
action: workflow.steps[j].action,
|
|
486
|
-
status: "skipped",
|
|
487
|
-
output: "",
|
|
488
|
-
duration_ms: 0,
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
break;
|
|
492
|
-
} else if (onFailure === "continue") {
|
|
493
|
-
finalStatus = "partial";
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// Finalize the run
|
|
499
|
-
db()
|
|
500
|
-
.prepare(
|
|
501
|
-
`UPDATE workflow_runs
|
|
502
|
-
SET status = ?, results = ?, completed_at = datetime('now'), error = ?
|
|
503
|
-
WHERE id = ?`
|
|
504
|
-
)
|
|
505
|
-
.run(finalStatus, JSON.stringify(context.steps), errorMsg, runId);
|
|
506
|
-
|
|
507
|
-
// Update workflow stats
|
|
508
|
-
db()
|
|
509
|
-
.prepare(
|
|
510
|
-
`UPDATE workflows
|
|
511
|
-
SET last_run_at = datetime('now'), run_count = run_count + 1, updated_at = datetime('now')
|
|
512
|
-
WHERE id = ?`
|
|
513
|
-
)
|
|
514
|
-
.run(id);
|
|
515
|
-
|
|
516
|
-
return getWorkflowRun(runId)!;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// ── Run queries ────────────────────────────────────────────────────────
|
|
520
|
-
|
|
521
|
-
export function getWorkflowRun(runId: string): WorkflowRun | null {
|
|
522
|
-
const row = db()
|
|
523
|
-
.prepare("SELECT * FROM workflow_runs WHERE id = ?")
|
|
524
|
-
.get(runId) as WorkflowRunRow | null;
|
|
525
|
-
return row ? rowToWorkflowRun(row) : null;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
export function getWorkflowRuns(workflowId: string, limit: number = 20): WorkflowRun[] {
|
|
529
|
-
const rows = db()
|
|
530
|
-
.prepare(
|
|
531
|
-
"SELECT * FROM workflow_runs WHERE workflow_id = ? ORDER BY started_at DESC LIMIT ?"
|
|
532
|
-
)
|
|
533
|
-
.all(workflowId, limit) as WorkflowRunRow[];
|
|
534
|
-
return rows.map(rowToWorkflowRun);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// ── Preset workflows ───────────────────────────────────────────────────
|
|
538
|
-
|
|
539
|
-
export interface PresetWorkflow {
|
|
540
|
-
name: string;
|
|
541
|
-
trigger_event: string;
|
|
542
|
-
steps: WorkflowStep[];
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
export function getPresetWorkflows(): PresetWorkflow[] {
|
|
546
|
-
return [
|
|
547
|
-
{
|
|
548
|
-
name: "Deal Won",
|
|
549
|
-
trigger_event: "deal.won",
|
|
550
|
-
steps: [
|
|
551
|
-
{
|
|
552
|
-
service: "invoices",
|
|
553
|
-
action: "create",
|
|
554
|
-
args: {
|
|
555
|
-
client: "{{data.customer_name}}",
|
|
556
|
-
amount: "{{data.deal_amount}}",
|
|
557
|
-
description: "Invoice for deal {{data.deal_name}}",
|
|
558
|
-
},
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
service: "contracts",
|
|
562
|
-
action: "create",
|
|
563
|
-
args: {
|
|
564
|
-
title: "Contract for {{data.customer_name}}",
|
|
565
|
-
type: "service-agreement",
|
|
566
|
-
value: "{{data.deal_amount}}",
|
|
567
|
-
},
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
service: "notes",
|
|
571
|
-
action: "create",
|
|
572
|
-
args: {
|
|
573
|
-
title: "Deal won: {{data.deal_name}}",
|
|
574
|
-
content: "Deal closed with {{data.customer_name}} for {{data.deal_amount}}",
|
|
575
|
-
},
|
|
576
|
-
},
|
|
577
|
-
],
|
|
578
|
-
},
|
|
579
|
-
{
|
|
580
|
-
name: "Invoice Overdue",
|
|
581
|
-
trigger_event: "invoice.overdue",
|
|
582
|
-
steps: [
|
|
583
|
-
{
|
|
584
|
-
service: "notes",
|
|
585
|
-
action: "create",
|
|
586
|
-
args: {
|
|
587
|
-
title: "Overdue reminder: {{data.invoice_id}}",
|
|
588
|
-
content: "Invoice {{data.invoice_id}} for {{data.customer_name}} is overdue by {{data.days_overdue}} days",
|
|
589
|
-
},
|
|
590
|
-
on_failure: "continue",
|
|
591
|
-
},
|
|
592
|
-
{
|
|
593
|
-
service: "calendar",
|
|
594
|
-
action: "create",
|
|
595
|
-
args: {
|
|
596
|
-
title: "Follow up on overdue invoice {{data.invoice_id}}",
|
|
597
|
-
description: "Contact {{data.customer_name}} about overdue payment",
|
|
598
|
-
},
|
|
599
|
-
on_failure: "continue",
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
service: "notes",
|
|
603
|
-
action: "create",
|
|
604
|
-
args: {
|
|
605
|
-
title: "Audit: overdue invoice {{data.invoice_id}}",
|
|
606
|
-
content: "Logged overdue event for {{data.customer_name}}, amount: {{data.amount}}",
|
|
607
|
-
},
|
|
608
|
-
},
|
|
609
|
-
],
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
name: "Payroll Close",
|
|
613
|
-
trigger_event: "payroll.close",
|
|
614
|
-
steps: [
|
|
615
|
-
{
|
|
616
|
-
service: "payroll",
|
|
617
|
-
action: "process",
|
|
618
|
-
args: {
|
|
619
|
-
period: "{{data.period}}",
|
|
620
|
-
org_id: "{{data.org_id}}",
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
service: "bookkeeping",
|
|
625
|
-
action: "create",
|
|
626
|
-
args: {
|
|
627
|
-
type: "expense",
|
|
628
|
-
category: "payroll",
|
|
629
|
-
amount: "{{data.total_amount}}",
|
|
630
|
-
description: "Payroll for period {{data.period}}",
|
|
631
|
-
},
|
|
632
|
-
},
|
|
633
|
-
{
|
|
634
|
-
service: "notes",
|
|
635
|
-
action: "create",
|
|
636
|
-
args: {
|
|
637
|
-
title: "Payroll report: {{data.period}}",
|
|
638
|
-
content: "Processed payroll for {{data.employee_count}} employees, total: {{data.total_amount}}",
|
|
639
|
-
},
|
|
640
|
-
},
|
|
641
|
-
],
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
name: "New Hire",
|
|
645
|
-
trigger_event: "new.hire",
|
|
646
|
-
steps: [
|
|
647
|
-
{
|
|
648
|
-
service: "contracts",
|
|
649
|
-
action: "create",
|
|
650
|
-
args: {
|
|
651
|
-
title: "Employment contract: {{data.employee_name}}",
|
|
652
|
-
type: "employment",
|
|
653
|
-
value: "{{data.salary}}",
|
|
654
|
-
},
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
service: "payroll",
|
|
658
|
-
action: "add-employee",
|
|
659
|
-
args: {
|
|
660
|
-
name: "{{data.employee_name}}",
|
|
661
|
-
salary: "{{data.salary}}",
|
|
662
|
-
start_date: "{{data.start_date}}",
|
|
663
|
-
},
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
service: "calendar",
|
|
667
|
-
action: "create",
|
|
668
|
-
args: {
|
|
669
|
-
title: "Onboarding: {{data.employee_name}}",
|
|
670
|
-
description: "Complete onboarding tasks for {{data.employee_name}} starting {{data.start_date}}",
|
|
671
|
-
},
|
|
672
|
-
},
|
|
673
|
-
],
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
name: "Contract Expiring",
|
|
677
|
-
trigger_event: "contract.expiring",
|
|
678
|
-
steps: [
|
|
679
|
-
{
|
|
680
|
-
service: "notes",
|
|
681
|
-
action: "create",
|
|
682
|
-
args: {
|
|
683
|
-
title: "Contract expiring: {{data.contract_title}}",
|
|
684
|
-
content: "Contract {{data.contract_id}} with {{data.party_name}} expires on {{data.expiry_date}}",
|
|
685
|
-
},
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
service: "calendar",
|
|
689
|
-
action: "create",
|
|
690
|
-
args: {
|
|
691
|
-
title: "Renew contract: {{data.contract_title}}",
|
|
692
|
-
description: "Review and renew contract with {{data.party_name}} before {{data.expiry_date}}",
|
|
693
|
-
},
|
|
694
|
-
},
|
|
695
|
-
],
|
|
696
|
-
},
|
|
697
|
-
];
|
|
698
|
-
}
|