@lead-routing/cli 0.4.2 → 0.5.0
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/prisma/migrations/20260312200000_add_cooldown_stamp_status/migration.sql +3 -0
- package/dist/prisma/migrations/20260314000000_add_decision_trace/migration.sql +5 -0
- package/dist/prisma/migrations/20260314000000_add_license_fields/migration.sql +5 -0
- package/dist/prisma/migrations/20260314000000_add_route_type/migration.sql +19 -0
- package/dist/prisma/migrations/20260314100000_add_distribution_type/migration.sql +2 -0
- package/dist/prisma/schema.prisma +29 -2
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- AlterEnum: Add SEARCH to TriggerEvent
|
|
2
|
+
ALTER TYPE "TriggerEvent" ADD VALUE 'SEARCH';
|
|
3
|
+
|
|
4
|
+
-- CreateEnum: RouteType
|
|
5
|
+
CREATE TYPE "RouteType" AS ENUM ('REALTIME', 'SCHEDULED');
|
|
6
|
+
|
|
7
|
+
-- AlterTable: Add route type and scheduled fields to routing_rules
|
|
8
|
+
ALTER TABLE "routing_rules" ADD COLUMN "routeType" "RouteType" NOT NULL DEFAULT 'REALTIME';
|
|
9
|
+
ALTER TABLE "routing_rules" ADD COLUMN "scheduleFrequency" TEXT;
|
|
10
|
+
ALTER TABLE "routing_rules" ADD COLUMN "scheduleTime" TEXT;
|
|
11
|
+
ALTER TABLE "routing_rules" ADD COLUMN "scheduleTimezone" TEXT;
|
|
12
|
+
ALTER TABLE "routing_rules" ADD COLUMN "scheduleCron" TEXT;
|
|
13
|
+
ALTER TABLE "routing_rules" ADD COLUMN "searchCriteria" JSONB;
|
|
14
|
+
ALTER TABLE "routing_rules" ADD COLUMN "lastRunAt" TIMESTAMP(3);
|
|
15
|
+
ALTER TABLE "routing_rules" ADD COLUMN "lastRunStatus" TEXT;
|
|
16
|
+
ALTER TABLE "routing_rules" ADD COLUMN "lastRunRecords" INTEGER;
|
|
17
|
+
ALTER TABLE "routing_rules" ADD COLUMN "lastRunDurationMs" INTEGER;
|
|
18
|
+
ALTER TABLE "routing_rules" ADD COLUMN "totalRuns" INTEGER NOT NULL DEFAULT 0;
|
|
19
|
+
ALTER TABLE "routing_rules" ADD COLUMN "totalRecordsRouted" INTEGER NOT NULL DEFAULT 0;
|
|
@@ -20,6 +20,12 @@ enum TriggerEvent {
|
|
|
20
20
|
INSERT
|
|
21
21
|
UPDATE
|
|
22
22
|
BOTH
|
|
23
|
+
SEARCH
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
enum RouteType {
|
|
27
|
+
REALTIME
|
|
28
|
+
SCHEDULED
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
enum RuleStatus {
|
|
@@ -44,6 +50,8 @@ enum RoutingStatus {
|
|
|
44
50
|
UNMATCHED
|
|
45
51
|
RETRY
|
|
46
52
|
MERGED
|
|
53
|
+
COOLDOWN_SKIPPED
|
|
54
|
+
STAMP_SKIPPED
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
enum LeadMatchAction {
|
|
@@ -160,6 +168,7 @@ model User {
|
|
|
160
168
|
profile String?
|
|
161
169
|
department String?
|
|
162
170
|
isLicensed Boolean @default(false)
|
|
171
|
+
licensedVia String? // "individual" | "role" | "profile" | "custom_field" — how user was licensed
|
|
163
172
|
isActive Boolean @default(true) // false if no longer in SFDC
|
|
164
173
|
lastRoutedAt DateTime?
|
|
165
174
|
syncedAt DateTime @default(now())
|
|
@@ -179,8 +188,9 @@ model RoundRobinTeam {
|
|
|
179
188
|
id String @id @default(cuid())
|
|
180
189
|
orgId String
|
|
181
190
|
name String
|
|
182
|
-
description
|
|
183
|
-
|
|
191
|
+
description String?
|
|
192
|
+
distributionType String @default("round-robin") // "round-robin" | "weighted"
|
|
193
|
+
pointerIndex Int @default(0) // kept in sync with Redis; Redis is authoritative
|
|
184
194
|
createdAt DateTime @default(now())
|
|
185
195
|
updatedAt DateTime @updatedAt
|
|
186
196
|
|
|
@@ -226,6 +236,20 @@ model RoutingRule {
|
|
|
226
236
|
isDryRun Boolean @default(false)
|
|
227
237
|
triggerName String @default("")
|
|
228
238
|
criteriaSyncedAt DateTime?
|
|
239
|
+
// Route type (real-time Apex trigger vs scheduled search)
|
|
240
|
+
routeType RouteType @default(REALTIME)
|
|
241
|
+
// Scheduled route fields
|
|
242
|
+
scheduleFrequency String? // "DAILY" | "WEEKLY" | "MONTHLY" | null (one-time)
|
|
243
|
+
scheduleTime String? // "06:00" (24h format)
|
|
244
|
+
scheduleTimezone String? // "UTC", "US/Eastern", etc.
|
|
245
|
+
scheduleCron String? // computed cron expression for BullMQ
|
|
246
|
+
searchCriteria Json? // ConditionGroup[] — search trigger criteria
|
|
247
|
+
lastRunAt DateTime?
|
|
248
|
+
lastRunStatus String? // "SUCCESS" | "FAILED" | "PARTIAL"
|
|
249
|
+
lastRunRecords Int? // records routed in last run
|
|
250
|
+
lastRunDurationMs Int?
|
|
251
|
+
totalRuns Int @default(0)
|
|
252
|
+
totalRecordsRouted Int @default(0)
|
|
229
253
|
// Default owner: absolute catch-all for new Route Builder routes
|
|
230
254
|
defaultOwnerType AssignmentType?
|
|
231
255
|
defaultOwnerUserId String?
|
|
@@ -374,6 +398,7 @@ model RoutingLog {
|
|
|
374
398
|
retryCount Int @default(0)
|
|
375
399
|
dismissed Boolean @default(false)
|
|
376
400
|
recordSnapshot Json? // full field payload from SFDC at time of routing
|
|
401
|
+
decisionTrace Json? // structured routing decision trace for Record Journey
|
|
377
402
|
teamId String?
|
|
378
403
|
teamName String?
|
|
379
404
|
routingDurationMs Int? // ms from webhook receipt → SFDC assignment
|
|
@@ -388,6 +413,7 @@ model RoutingLog {
|
|
|
388
413
|
@@index([orgId, status])
|
|
389
414
|
@@index([orgId, teamId])
|
|
390
415
|
@@index([orgId, ruleId])
|
|
416
|
+
@@index([orgId, sfdcRecordId, createdAt])
|
|
391
417
|
@@map("routing_logs")
|
|
392
418
|
}
|
|
393
419
|
|
|
@@ -414,6 +440,7 @@ model SfdcQueue {
|
|
|
414
440
|
orgId String
|
|
415
441
|
sfdcQueueId String // SFDC Queue ID (00G...)
|
|
416
442
|
name String
|
|
443
|
+
isLicensed Boolean @default(false) // whether queue can receive routed records
|
|
417
444
|
syncedAt DateTime @default(now())
|
|
418
445
|
|
|
419
446
|
org Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)
|