@qcobro/common 1.12.4 → 1.14.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/billing/evaluate.d.ts +36 -0
- package/dist/billing/evaluate.d.ts.map +1 -0
- package/dist/billing/evaluate.js +136 -0
- package/dist/billing/evaluate.js.map +1 -0
- package/dist/billing/index.d.ts +7 -0
- package/dist/billing/index.d.ts.map +1 -0
- package/dist/billing/index.js +7 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/ledger.d.ts +70 -0
- package/dist/billing/ledger.d.ts.map +1 -0
- package/dist/billing/ledger.js +59 -0
- package/dist/billing/ledger.js.map +1 -0
- package/dist/billing/money.d.ts +26 -0
- package/dist/billing/money.d.ts.map +1 -0
- package/dist/billing/money.js +58 -0
- package/dist/billing/money.js.map +1 -0
- package/dist/billing/pricing.d.ts +58 -0
- package/dist/billing/pricing.d.ts.map +1 -0
- package/dist/billing/pricing.js +68 -0
- package/dist/billing/pricing.js.map +1 -0
- package/dist/billing/proration.d.ts +8 -0
- package/dist/billing/proration.d.ts.map +1 -0
- package/dist/billing/proration.js +17 -0
- package/dist/billing/proration.js.map +1 -0
- package/dist/billing/rates.d.ts +108 -0
- package/dist/billing/rates.d.ts.map +1 -0
- package/dist/billing/rates.js +56 -0
- package/dist/billing/rates.js.map +1 -0
- package/dist/bin/engineEval.d.ts +67 -0
- package/dist/bin/engineEval.d.ts.map +1 -0
- package/dist/bin/engineEval.js +290 -0
- package/dist/bin/engineEval.js.map +1 -0
- package/dist/config.d.ts +141 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +70 -2
- package/dist/config.js.map +1 -1
- package/dist/evaluation/evaluate.d.ts +4 -0
- package/dist/evaluation/evaluate.d.ts.map +1 -0
- package/dist/evaluation/evaluate.js +504 -0
- package/dist/evaluation/evaluate.js.map +1 -0
- package/dist/evaluation/index.d.ts +3 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +3 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/evaluation/scorecard.d.ts +84 -0
- package/dist/evaluation/scorecard.d.ts.map +1 -0
- package/dist/evaluation/scorecard.js +29 -0
- package/dist/evaluation/scorecard.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas/billing.d.ts +74 -0
- package/dist/schemas/billing.d.ts.map +1 -0
- package/dist/schemas/billing.js +68 -0
- package/dist/schemas/billing.js.map +1 -0
- package/dist/schemas/engineEvents.d.ts +407 -0
- package/dist/schemas/engineEvents.d.ts.map +1 -0
- package/dist/schemas/engineEvents.js +179 -0
- package/dist/schemas/engineEvents.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/types/billing.d.ts +134 -0
- package/dist/types/billing.d.ts.map +1 -0
- package/dist/types/billing.js +8 -0
- package/dist/types/billing.js.map +1 -0
- package/dist/types/engine.d.ts +13 -2
- package/dist/types/engine.d.ts.map +1 -1
- package/dist/types/engine.js +12 -1
- package/dist/types/engine.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/pacing.d.ts +17 -0
- package/dist/utils/pacing.d.ts.map +1 -0
- package/dist/utils/pacing.js +18 -0
- package/dist/utils/pacing.js.map +1 -0
- package/dist/utils/time.d.ts +16 -0
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/time.js +17 -0
- package/dist/utils/time.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Contracts for the engine judge: the parameter set `evaluate` runs against and
|
|
4
|
+
* the scorecard it produces. Thresholds default here; rate caps and the tick
|
|
5
|
+
* interval mirror the deployment's engine config and are supplied by the caller
|
|
6
|
+
* (the events endpoint returns them alongside the stream).
|
|
7
|
+
*/
|
|
8
|
+
export const evaluationParametersSchema = z.object({
|
|
9
|
+
/** Seconds between engine ticks (`engine.tickSeconds`). */
|
|
10
|
+
tickSeconds: z.number().int().positive(),
|
|
11
|
+
/** Deployment-wide pacing caps, mirroring the engine config. `0` = channel paused. */
|
|
12
|
+
ratesPerMinute: z.object({
|
|
13
|
+
voice: z.number().nonnegative(),
|
|
14
|
+
sms: z.number().nonnegative(),
|
|
15
|
+
email: z.number().nonnegative(),
|
|
16
|
+
whatsApp: z.number().nonnegative()
|
|
17
|
+
}),
|
|
18
|
+
thresholds: z
|
|
19
|
+
.object({
|
|
20
|
+
/** PERF-2: p95 of provider dispatch latency (the API call, not call duration). */
|
|
21
|
+
dispatchLatencyP95Ms: z.number().positive().default(2000),
|
|
22
|
+
/** PERF-3: max fraction of dispatches that may fail, per channel. */
|
|
23
|
+
maxErrorRate: z.number().min(0).max(1).default(0.02),
|
|
24
|
+
/** LIVE-1: max consecutive budget-starved in-window ticks before an account counts as starved. */
|
|
25
|
+
livenessTicks: z.number().int().positive().default(10)
|
|
26
|
+
})
|
|
27
|
+
.prefault({})
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=scorecard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorecard.js","sourceRoot":"","sources":["../../src/evaluation/scorecard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,2DAA2D;IAC3D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxC,sFAAsF;IACtF,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;QAC/B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;QAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;QAC/B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC;IACF,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,kFAAkF;QAClF,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;QACzD,qEAAqE;QACrE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QACpD,kGAAkG;QAClG,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KACvD,CAAC;SACD,QAAQ,CAAC,EAAE,CAAC;CAChB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export * from "./errors/index.js";
|
|
|
3
3
|
export * from "./utils/index.js";
|
|
4
4
|
export * from "./schemas/index.js";
|
|
5
5
|
export * from "./types/index.js";
|
|
6
|
+
export * from "./evaluation/index.js";
|
|
7
|
+
export * from "./billing/index.js";
|
|
6
8
|
export * from "./config.js";
|
|
7
9
|
/**
|
|
8
10
|
* Placeholder contract proving the shared-schema pattern.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAE5B;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;iBAEpB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAE5B;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;iBAEpB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export * from "./errors/index.js";
|
|
|
3
3
|
export * from "./utils/index.js";
|
|
4
4
|
export * from "./schemas/index.js";
|
|
5
5
|
export * from "./types/index.js";
|
|
6
|
+
export * from "./evaluation/index.js";
|
|
7
|
+
export * from "./billing/index.js";
|
|
6
8
|
export * from "./config.js";
|
|
7
9
|
/**
|
|
8
10
|
* Placeholder contract proving the shared-schema pattern.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACpC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Input schemas for the billing service functions (usage-ledger capability).
|
|
4
|
+
* The client interfaces they pair with live in `../types/billing.ts`.
|
|
5
|
+
*/
|
|
6
|
+
/** Meters one billable dispatch (priced at write time from the workspace's plan). */
|
|
7
|
+
export declare const meterDispatchSchema: z.ZodObject<{
|
|
8
|
+
workspaceRef: z.ZodString;
|
|
9
|
+
meter: z.ZodEnum<{
|
|
10
|
+
sms: "sms";
|
|
11
|
+
email: "email";
|
|
12
|
+
whatsappMessage: "whatsappMessage";
|
|
13
|
+
voicePrerecorded: "voicePrerecorded";
|
|
14
|
+
voiceAi: "voiceAi";
|
|
15
|
+
whatsappVoicePrerecorded: "whatsappVoicePrerecorded";
|
|
16
|
+
whatsappVoiceAi: "whatsappVoiceAi";
|
|
17
|
+
}>;
|
|
18
|
+
at: z.ZodString;
|
|
19
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
20
|
+
portfolioAccountId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
providerRef: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type MeterDispatchInput = z.infer<typeof meterDispatchSchema>;
|
|
24
|
+
/** Settles a voice usage record to its actual answered duration (idempotent per ref). */
|
|
25
|
+
export declare const settleVoiceUsageSchema: z.ZodObject<{
|
|
26
|
+
providerRef: z.ZodString;
|
|
27
|
+
answeredSeconds: z.ZodNumber;
|
|
28
|
+
at: z.ZodString;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type SettleVoiceUsageInput = z.infer<typeof settleVoiceUsageSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Turns a workspace's billing cycle over (close previous, open next): voids the
|
|
33
|
+
* unused remainder and grants the new allowance. Idempotent per
|
|
34
|
+
* `(workspaceRef, stripeInvoiceId)` — a replayed webhook no-ops.
|
|
35
|
+
*/
|
|
36
|
+
export declare const cycleTurnoverSchema: z.ZodObject<{
|
|
37
|
+
workspaceRef: z.ZodString;
|
|
38
|
+
stripeInvoiceId: z.ZodString;
|
|
39
|
+
grantMicro: z.ZodNumber;
|
|
40
|
+
cycleStart: z.ZodString;
|
|
41
|
+
cycleEnd: z.ZodString;
|
|
42
|
+
at: z.ZodString;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type CycleTurnoverInput = z.infer<typeof cycleTurnoverSchema>;
|
|
45
|
+
/** Reads a workspace's billing status (balance, plan, cycle). */
|
|
46
|
+
export declare const getWorkspaceBillingStatusSchema: z.ZodObject<{
|
|
47
|
+
workspaceRef: z.ZodString;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type GetWorkspaceBillingStatusInput = z.infer<typeof getWorkspaceBillingStatusSchema>;
|
|
50
|
+
/**
|
|
51
|
+
* Puts a workspace on a paid plan. First paid workspace for a payer → a
|
|
52
|
+
* Stripe-hosted Checkout session (collects the card, creates customer +
|
|
53
|
+
* subscription); subsequent workspaces → a prorated subscription item on the
|
|
54
|
+
* existing subscription, no card entry.
|
|
55
|
+
*/
|
|
56
|
+
export declare const subscribeWorkspaceSchema: z.ZodObject<{
|
|
57
|
+
workspaceRef: z.ZodString;
|
|
58
|
+
planKey: z.ZodString;
|
|
59
|
+
ownerUserRef: z.ZodString;
|
|
60
|
+
successUrl: z.ZodString;
|
|
61
|
+
cancelUrl: z.ZodString;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export type SubscribeWorkspaceInput = z.infer<typeof subscribeWorkspaceSchema>;
|
|
64
|
+
/**
|
|
65
|
+
* Changes a workspace's plan. Upgrades apply immediately (prorated charge +
|
|
66
|
+
* prorated allowance replacing the remainder); downgrades take effect at
|
|
67
|
+
* period end via a subscription schedule.
|
|
68
|
+
*/
|
|
69
|
+
export declare const changePlanSchema: z.ZodObject<{
|
|
70
|
+
workspaceRef: z.ZodString;
|
|
71
|
+
targetPlanKey: z.ZodString;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type ChangePlanInput = z.infer<typeof changePlanSchema>;
|
|
74
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/schemas/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AAEH,qFAAqF;AACrF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;iBAS9B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,yFAAyF;AACzF,eAAO,MAAM,sBAAsB;;;;iBAMjC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;iBAU9B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,iEAAiE;AACjE,eAAO,MAAM,+BAA+B;;iBAE1C,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE7F;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;iBAMnC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { billingMeterSchema } from "../billing/rates.js";
|
|
3
|
+
/**
|
|
4
|
+
* Input schemas for the billing service functions (usage-ledger capability).
|
|
5
|
+
* The client interfaces they pair with live in `../types/billing.ts`.
|
|
6
|
+
*/
|
|
7
|
+
/** Meters one billable dispatch (priced at write time from the workspace's plan). */
|
|
8
|
+
export const meterDispatchSchema = z.object({
|
|
9
|
+
workspaceRef: z.string().min(1),
|
|
10
|
+
meter: billingMeterSchema,
|
|
11
|
+
/** Dispatch instant, ISO. */
|
|
12
|
+
at: z.string().min(1),
|
|
13
|
+
campaignId: z.string().min(1).optional(),
|
|
14
|
+
portfolioAccountId: z.string().min(1).optional(),
|
|
15
|
+
/** Provider ref of the dispatch — the settlement correlation key for voice. */
|
|
16
|
+
providerRef: z.string().min(1).optional()
|
|
17
|
+
});
|
|
18
|
+
/** Settles a voice usage record to its actual answered duration (idempotent per ref). */
|
|
19
|
+
export const settleVoiceUsageSchema = z.object({
|
|
20
|
+
providerRef: z.string().min(1),
|
|
21
|
+
/** Answered seconds (answer → hang-up; 0 = never answered, ring time excluded). */
|
|
22
|
+
answeredSeconds: z.number().int().nonnegative(),
|
|
23
|
+
/** Settlement instant, ISO. */
|
|
24
|
+
at: z.string().min(1)
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Turns a workspace's billing cycle over (close previous, open next): voids the
|
|
28
|
+
* unused remainder and grants the new allowance. Idempotent per
|
|
29
|
+
* `(workspaceRef, stripeInvoiceId)` — a replayed webhook no-ops.
|
|
30
|
+
*/
|
|
31
|
+
export const cycleTurnoverSchema = z.object({
|
|
32
|
+
workspaceRef: z.string().min(1),
|
|
33
|
+
stripeInvoiceId: z.string().min(1),
|
|
34
|
+
/** The (possibly prorated) allowance to grant, integer micro-units. */
|
|
35
|
+
grantMicro: z.number().int().nonnegative(),
|
|
36
|
+
/** New cycle bounds, ISO. */
|
|
37
|
+
cycleStart: z.string().min(1),
|
|
38
|
+
cycleEnd: z.string().min(1),
|
|
39
|
+
/** Turnover instant, ISO. */
|
|
40
|
+
at: z.string().min(1)
|
|
41
|
+
});
|
|
42
|
+
/** Reads a workspace's billing status (balance, plan, cycle). */
|
|
43
|
+
export const getWorkspaceBillingStatusSchema = z.object({
|
|
44
|
+
workspaceRef: z.string().min(1)
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Puts a workspace on a paid plan. First paid workspace for a payer → a
|
|
48
|
+
* Stripe-hosted Checkout session (collects the card, creates customer +
|
|
49
|
+
* subscription); subsequent workspaces → a prorated subscription item on the
|
|
50
|
+
* existing subscription, no card entry.
|
|
51
|
+
*/
|
|
52
|
+
export const subscribeWorkspaceSchema = z.object({
|
|
53
|
+
workspaceRef: z.string().min(1),
|
|
54
|
+
planKey: z.string().min(1),
|
|
55
|
+
ownerUserRef: z.string().min(1),
|
|
56
|
+
successUrl: z.string().url(),
|
|
57
|
+
cancelUrl: z.string().url()
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Changes a workspace's plan. Upgrades apply immediately (prorated charge +
|
|
61
|
+
* prorated allowance replacing the remainder); downgrades take effect at
|
|
62
|
+
* period end via a subscription schedule.
|
|
63
|
+
*/
|
|
64
|
+
export const changePlanSchema = z.object({
|
|
65
|
+
workspaceRef: z.string().min(1),
|
|
66
|
+
targetPlanKey: z.string().min(1)
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/schemas/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;GAGG;AAEH,qFAAqF;AACrF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,KAAK,EAAE,kBAAkB;IACzB,6BAA6B;IAC7B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChD,+EAA+E;IAC/E,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAGH,yFAAyF;AACzF,MAAM,CAAC,MAAM,sBAAsB,G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C,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC5B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;CAC5B,CAAC,CAAC;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Engine flight-recorder events. The engine (and the inbound provider webhooks)
|
|
4
|
+
* emit these as an append-only stream; the pure evaluator in `../evaluation/`
|
|
5
|
+
* replays a stream to prove a run stayed within parameters. Events are
|
|
6
|
+
* self-contained: `campaign.evaluated` snapshots the config in force that tick,
|
|
7
|
+
* so evaluating never requires reading live campaign rows.
|
|
8
|
+
*
|
|
9
|
+
* Correlation spine: `tickId` + `seq` order events within a tick;
|
|
10
|
+
* `workspaceRef`/`campaignId`/`portfolioAccountId`/`providerRef` tie them to the
|
|
11
|
+
* domain. Only tick lifecycle events are deployment-level (one engine loop ticks
|
|
12
|
+
* across all workspaces) — everything else carries `workspaceRef`.
|
|
13
|
+
*
|
|
14
|
+
* Privacy: recipient identifiers are masked (see `maskRecipient`); rendered
|
|
15
|
+
* bodies, scripts, and transcripts never enter the stream (they live on the
|
|
16
|
+
* gestión).
|
|
17
|
+
*/
|
|
18
|
+
export declare const engineEventKindSchema: z.ZodEnum<{
|
|
19
|
+
"tick.started": "tick.started";
|
|
20
|
+
"tick.completed": "tick.completed";
|
|
21
|
+
"campaign.evaluated": "campaign.evaluated";
|
|
22
|
+
"account.decided": "account.decided";
|
|
23
|
+
"attempt.reserved": "attempt.reserved";
|
|
24
|
+
"dispatch.requested": "dispatch.requested";
|
|
25
|
+
"dispatch.succeeded": "dispatch.succeeded";
|
|
26
|
+
"dispatch.failed": "dispatch.failed";
|
|
27
|
+
"provider.event": "provider.event";
|
|
28
|
+
}>;
|
|
29
|
+
export type EngineEventKind = z.infer<typeof engineEventKindSchema>;
|
|
30
|
+
/** Snapshot of the campaign parameters in force during a tick (self-contained stream). */
|
|
31
|
+
export declare const campaignSnapshotSchema: z.ZodObject<{
|
|
32
|
+
status: z.ZodString;
|
|
33
|
+
startDate: z.ZodString;
|
|
34
|
+
endDate: z.ZodNullable<z.ZodString>;
|
|
35
|
+
daysOfWeek: z.ZodArray<z.ZodNumber>;
|
|
36
|
+
startTime: z.ZodString;
|
|
37
|
+
endTime: z.ZodString;
|
|
38
|
+
maxAttemptsPerAccount: z.ZodNumber;
|
|
39
|
+
maxAttemptsPerDay: z.ZodNumber;
|
|
40
|
+
timezone: z.ZodString;
|
|
41
|
+
channel: z.ZodNullable<z.ZodEnum<{
|
|
42
|
+
VOICE_AI: "VOICE_AI";
|
|
43
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
44
|
+
SMS: "SMS";
|
|
45
|
+
EMAIL: "EMAIL";
|
|
46
|
+
WHATSAPP: "WHATSAPP";
|
|
47
|
+
}>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type CampaignSnapshot = z.infer<typeof campaignSnapshotSchema>;
|
|
50
|
+
declare const tickStartedSchema: z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
at: z.ZodString;
|
|
53
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
54
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
kind: z.ZodLiteral<"tick.started">;
|
|
56
|
+
budgets: z.ZodRecord<z.ZodEnum<{
|
|
57
|
+
VOICE_AI: "VOICE_AI";
|
|
58
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
59
|
+
SMS: "SMS";
|
|
60
|
+
EMAIL: "EMAIL";
|
|
61
|
+
WHATSAPP: "WHATSAPP";
|
|
62
|
+
}> & z.core.$partial, z.ZodNumber>;
|
|
63
|
+
perTickMax: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
declare const tickCompletedSchema: z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
at: z.ZodString;
|
|
68
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
69
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
kind: z.ZodLiteral<"tick.completed">;
|
|
71
|
+
durationMs: z.ZodNumber;
|
|
72
|
+
dispatched: z.ZodNumber;
|
|
73
|
+
perTickMaxReached: z.ZodBoolean;
|
|
74
|
+
channelUsage: z.ZodRecord<z.ZodEnum<{
|
|
75
|
+
VOICE_AI: "VOICE_AI";
|
|
76
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
77
|
+
SMS: "SMS";
|
|
78
|
+
EMAIL: "EMAIL";
|
|
79
|
+
WHATSAPP: "WHATSAPP";
|
|
80
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
81
|
+
dispatched: z.ZodNumber;
|
|
82
|
+
budget: z.ZodNumber;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
declare const campaignEvaluatedSchema: z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
at: z.ZodString;
|
|
88
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
89
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
workspaceRef: z.ZodString;
|
|
91
|
+
kind: z.ZodLiteral<"campaign.evaluated">;
|
|
92
|
+
campaignId: z.ZodString;
|
|
93
|
+
campaignName: z.ZodOptional<z.ZodString>;
|
|
94
|
+
inWindow: z.ZodBoolean;
|
|
95
|
+
skipReason: z.ZodOptional<z.ZodString>;
|
|
96
|
+
completed: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
candidateCount: z.ZodNumber;
|
|
98
|
+
snapshot: z.ZodObject<{
|
|
99
|
+
status: z.ZodString;
|
|
100
|
+
startDate: z.ZodString;
|
|
101
|
+
endDate: z.ZodNullable<z.ZodString>;
|
|
102
|
+
daysOfWeek: z.ZodArray<z.ZodNumber>;
|
|
103
|
+
startTime: z.ZodString;
|
|
104
|
+
endTime: z.ZodString;
|
|
105
|
+
maxAttemptsPerAccount: z.ZodNumber;
|
|
106
|
+
maxAttemptsPerDay: z.ZodNumber;
|
|
107
|
+
timezone: z.ZodString;
|
|
108
|
+
channel: z.ZodNullable<z.ZodEnum<{
|
|
109
|
+
VOICE_AI: "VOICE_AI";
|
|
110
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
111
|
+
SMS: "SMS";
|
|
112
|
+
EMAIL: "EMAIL";
|
|
113
|
+
WHATSAPP: "WHATSAPP";
|
|
114
|
+
}>>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
declare const accountDecidedSchema: z.ZodObject<{
|
|
118
|
+
id: z.ZodString;
|
|
119
|
+
at: z.ZodString;
|
|
120
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
121
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
workspaceRef: z.ZodString;
|
|
123
|
+
kind: z.ZodLiteral<"account.decided">;
|
|
124
|
+
campaignId: z.ZodString;
|
|
125
|
+
portfolioAccountId: z.ZodString;
|
|
126
|
+
decision: z.ZodString;
|
|
127
|
+
providerRef: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
declare const attemptReservedSchema: z.ZodObject<{
|
|
130
|
+
id: z.ZodString;
|
|
131
|
+
at: z.ZodString;
|
|
132
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
133
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
workspaceRef: z.ZodString;
|
|
135
|
+
kind: z.ZodLiteral<"attempt.reserved">;
|
|
136
|
+
campaignId: z.ZodString;
|
|
137
|
+
portfolioAccountId: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
declare const dispatchRequestedSchema: z.ZodObject<{
|
|
140
|
+
id: z.ZodString;
|
|
141
|
+
at: z.ZodString;
|
|
142
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
143
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
workspaceRef: z.ZodString;
|
|
145
|
+
kind: z.ZodLiteral<"dispatch.requested">;
|
|
146
|
+
campaignId: z.ZodString;
|
|
147
|
+
portfolioAccountId: z.ZodString;
|
|
148
|
+
channel: z.ZodEnum<{
|
|
149
|
+
VOICE_AI: "VOICE_AI";
|
|
150
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
151
|
+
SMS: "SMS";
|
|
152
|
+
EMAIL: "EMAIL";
|
|
153
|
+
WHATSAPP: "WHATSAPP";
|
|
154
|
+
}>;
|
|
155
|
+
toMasked: z.ZodString;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
declare const dispatchSucceededSchema: z.ZodObject<{
|
|
158
|
+
id: z.ZodString;
|
|
159
|
+
at: z.ZodString;
|
|
160
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
161
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
workspaceRef: z.ZodString;
|
|
163
|
+
kind: z.ZodLiteral<"dispatch.succeeded">;
|
|
164
|
+
campaignId: z.ZodString;
|
|
165
|
+
portfolioAccountId: z.ZodString;
|
|
166
|
+
channel: z.ZodEnum<{
|
|
167
|
+
VOICE_AI: "VOICE_AI";
|
|
168
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
169
|
+
SMS: "SMS";
|
|
170
|
+
EMAIL: "EMAIL";
|
|
171
|
+
WHATSAPP: "WHATSAPP";
|
|
172
|
+
}>;
|
|
173
|
+
providerRef: z.ZodString;
|
|
174
|
+
latencyMs: z.ZodNumber;
|
|
175
|
+
toMasked: z.ZodString;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
declare const dispatchFailedSchema: z.ZodObject<{
|
|
178
|
+
id: z.ZodString;
|
|
179
|
+
at: z.ZodString;
|
|
180
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
181
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
182
|
+
workspaceRef: z.ZodString;
|
|
183
|
+
kind: z.ZodLiteral<"dispatch.failed">;
|
|
184
|
+
campaignId: z.ZodString;
|
|
185
|
+
portfolioAccountId: z.ZodString;
|
|
186
|
+
channel: z.ZodEnum<{
|
|
187
|
+
VOICE_AI: "VOICE_AI";
|
|
188
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
189
|
+
SMS: "SMS";
|
|
190
|
+
EMAIL: "EMAIL";
|
|
191
|
+
WHATSAPP: "WHATSAPP";
|
|
192
|
+
}>;
|
|
193
|
+
latencyMs: z.ZodNumber;
|
|
194
|
+
errorClass: z.ZodString;
|
|
195
|
+
errorMessage: z.ZodString;
|
|
196
|
+
toMasked: z.ZodString;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
declare const providerEventSchema: z.ZodObject<{
|
|
199
|
+
id: z.ZodString;
|
|
200
|
+
at: z.ZodString;
|
|
201
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
202
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
kind: z.ZodLiteral<"provider.event">;
|
|
204
|
+
workspaceRef: z.ZodOptional<z.ZodString>;
|
|
205
|
+
source: z.ZodEnum<{
|
|
206
|
+
"voice-events": "voice-events";
|
|
207
|
+
"contact-logs": "contact-logs";
|
|
208
|
+
"meta-whatsapp": "meta-whatsapp";
|
|
209
|
+
"email-inbound": "email-inbound";
|
|
210
|
+
}>;
|
|
211
|
+
providerRef: z.ZodOptional<z.ZodString>;
|
|
212
|
+
providerAt: z.ZodOptional<z.ZodString>;
|
|
213
|
+
matched: z.ZodBoolean;
|
|
214
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
215
|
+
portfolioAccountId: z.ZodOptional<z.ZodString>;
|
|
216
|
+
summary: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
export declare const engineEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
219
|
+
id: z.ZodString;
|
|
220
|
+
at: z.ZodString;
|
|
221
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
222
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
kind: z.ZodLiteral<"tick.started">;
|
|
224
|
+
budgets: z.ZodRecord<z.ZodEnum<{
|
|
225
|
+
VOICE_AI: "VOICE_AI";
|
|
226
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
227
|
+
SMS: "SMS";
|
|
228
|
+
EMAIL: "EMAIL";
|
|
229
|
+
WHATSAPP: "WHATSAPP";
|
|
230
|
+
}> & z.core.$partial, z.ZodNumber>;
|
|
231
|
+
perTickMax: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
233
|
+
id: z.ZodString;
|
|
234
|
+
at: z.ZodString;
|
|
235
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
236
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
237
|
+
kind: z.ZodLiteral<"tick.completed">;
|
|
238
|
+
durationMs: z.ZodNumber;
|
|
239
|
+
dispatched: z.ZodNumber;
|
|
240
|
+
perTickMaxReached: z.ZodBoolean;
|
|
241
|
+
channelUsage: z.ZodRecord<z.ZodEnum<{
|
|
242
|
+
VOICE_AI: "VOICE_AI";
|
|
243
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
244
|
+
SMS: "SMS";
|
|
245
|
+
EMAIL: "EMAIL";
|
|
246
|
+
WHATSAPP: "WHATSAPP";
|
|
247
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
248
|
+
dispatched: z.ZodNumber;
|
|
249
|
+
budget: z.ZodNumber;
|
|
250
|
+
}, z.core.$strip>>;
|
|
251
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
252
|
+
id: z.ZodString;
|
|
253
|
+
at: z.ZodString;
|
|
254
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
255
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
workspaceRef: z.ZodString;
|
|
257
|
+
kind: z.ZodLiteral<"campaign.evaluated">;
|
|
258
|
+
campaignId: z.ZodString;
|
|
259
|
+
campaignName: z.ZodOptional<z.ZodString>;
|
|
260
|
+
inWindow: z.ZodBoolean;
|
|
261
|
+
skipReason: z.ZodOptional<z.ZodString>;
|
|
262
|
+
completed: z.ZodOptional<z.ZodBoolean>;
|
|
263
|
+
candidateCount: z.ZodNumber;
|
|
264
|
+
snapshot: z.ZodObject<{
|
|
265
|
+
status: z.ZodString;
|
|
266
|
+
startDate: z.ZodString;
|
|
267
|
+
endDate: z.ZodNullable<z.ZodString>;
|
|
268
|
+
daysOfWeek: z.ZodArray<z.ZodNumber>;
|
|
269
|
+
startTime: z.ZodString;
|
|
270
|
+
endTime: z.ZodString;
|
|
271
|
+
maxAttemptsPerAccount: z.ZodNumber;
|
|
272
|
+
maxAttemptsPerDay: z.ZodNumber;
|
|
273
|
+
timezone: z.ZodString;
|
|
274
|
+
channel: z.ZodNullable<z.ZodEnum<{
|
|
275
|
+
VOICE_AI: "VOICE_AI";
|
|
276
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
277
|
+
SMS: "SMS";
|
|
278
|
+
EMAIL: "EMAIL";
|
|
279
|
+
WHATSAPP: "WHATSAPP";
|
|
280
|
+
}>>;
|
|
281
|
+
}, z.core.$strip>;
|
|
282
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
283
|
+
id: z.ZodString;
|
|
284
|
+
at: z.ZodString;
|
|
285
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
286
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
287
|
+
workspaceRef: z.ZodString;
|
|
288
|
+
kind: z.ZodLiteral<"account.decided">;
|
|
289
|
+
campaignId: z.ZodString;
|
|
290
|
+
portfolioAccountId: z.ZodString;
|
|
291
|
+
decision: z.ZodString;
|
|
292
|
+
providerRef: z.ZodOptional<z.ZodString>;
|
|
293
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
294
|
+
id: z.ZodString;
|
|
295
|
+
at: z.ZodString;
|
|
296
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
297
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
298
|
+
workspaceRef: z.ZodString;
|
|
299
|
+
kind: z.ZodLiteral<"attempt.reserved">;
|
|
300
|
+
campaignId: z.ZodString;
|
|
301
|
+
portfolioAccountId: z.ZodString;
|
|
302
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
303
|
+
id: z.ZodString;
|
|
304
|
+
at: z.ZodString;
|
|
305
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
306
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
307
|
+
workspaceRef: z.ZodString;
|
|
308
|
+
kind: z.ZodLiteral<"dispatch.requested">;
|
|
309
|
+
campaignId: z.ZodString;
|
|
310
|
+
portfolioAccountId: z.ZodString;
|
|
311
|
+
channel: z.ZodEnum<{
|
|
312
|
+
VOICE_AI: "VOICE_AI";
|
|
313
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
314
|
+
SMS: "SMS";
|
|
315
|
+
EMAIL: "EMAIL";
|
|
316
|
+
WHATSAPP: "WHATSAPP";
|
|
317
|
+
}>;
|
|
318
|
+
toMasked: z.ZodString;
|
|
319
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
320
|
+
id: z.ZodString;
|
|
321
|
+
at: z.ZodString;
|
|
322
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
323
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
324
|
+
workspaceRef: z.ZodString;
|
|
325
|
+
kind: z.ZodLiteral<"dispatch.succeeded">;
|
|
326
|
+
campaignId: z.ZodString;
|
|
327
|
+
portfolioAccountId: z.ZodString;
|
|
328
|
+
channel: z.ZodEnum<{
|
|
329
|
+
VOICE_AI: "VOICE_AI";
|
|
330
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
331
|
+
SMS: "SMS";
|
|
332
|
+
EMAIL: "EMAIL";
|
|
333
|
+
WHATSAPP: "WHATSAPP";
|
|
334
|
+
}>;
|
|
335
|
+
providerRef: z.ZodString;
|
|
336
|
+
latencyMs: z.ZodNumber;
|
|
337
|
+
toMasked: z.ZodString;
|
|
338
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
339
|
+
id: z.ZodString;
|
|
340
|
+
at: z.ZodString;
|
|
341
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
342
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
343
|
+
workspaceRef: z.ZodString;
|
|
344
|
+
kind: z.ZodLiteral<"dispatch.failed">;
|
|
345
|
+
campaignId: z.ZodString;
|
|
346
|
+
portfolioAccountId: z.ZodString;
|
|
347
|
+
channel: z.ZodEnum<{
|
|
348
|
+
VOICE_AI: "VOICE_AI";
|
|
349
|
+
VOICE_PRERECORDED: "VOICE_PRERECORDED";
|
|
350
|
+
SMS: "SMS";
|
|
351
|
+
EMAIL: "EMAIL";
|
|
352
|
+
WHATSAPP: "WHATSAPP";
|
|
353
|
+
}>;
|
|
354
|
+
latencyMs: z.ZodNumber;
|
|
355
|
+
errorClass: z.ZodString;
|
|
356
|
+
errorMessage: z.ZodString;
|
|
357
|
+
toMasked: z.ZodString;
|
|
358
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
359
|
+
id: z.ZodString;
|
|
360
|
+
at: z.ZodString;
|
|
361
|
+
tickId: z.ZodOptional<z.ZodString>;
|
|
362
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
363
|
+
kind: z.ZodLiteral<"provider.event">;
|
|
364
|
+
workspaceRef: z.ZodOptional<z.ZodString>;
|
|
365
|
+
source: z.ZodEnum<{
|
|
366
|
+
"voice-events": "voice-events";
|
|
367
|
+
"contact-logs": "contact-logs";
|
|
368
|
+
"meta-whatsapp": "meta-whatsapp";
|
|
369
|
+
"email-inbound": "email-inbound";
|
|
370
|
+
}>;
|
|
371
|
+
providerRef: z.ZodOptional<z.ZodString>;
|
|
372
|
+
providerAt: z.ZodOptional<z.ZodString>;
|
|
373
|
+
matched: z.ZodBoolean;
|
|
374
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
375
|
+
portfolioAccountId: z.ZodOptional<z.ZodString>;
|
|
376
|
+
summary: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
377
|
+
}, z.core.$strip>], "kind">;
|
|
378
|
+
export type EngineEvent = z.infer<typeof engineEventSchema>;
|
|
379
|
+
/** `Omit` distributed over the union (a plain Omit collapses the discriminant). */
|
|
380
|
+
type DistOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
381
|
+
/** An event as emission sites provide it — the recorder fills the id/at/tickId/seq spine. */
|
|
382
|
+
export type EngineEventInput = DistOmit<EngineEvent, "id" | "at" | "tickId" | "seq">;
|
|
383
|
+
export type TickStartedEvent = z.infer<typeof tickStartedSchema>;
|
|
384
|
+
export type TickCompletedEvent = z.infer<typeof tickCompletedSchema>;
|
|
385
|
+
export type CampaignEvaluatedEvent = z.infer<typeof campaignEvaluatedSchema>;
|
|
386
|
+
export type AccountDecidedEvent = z.infer<typeof accountDecidedSchema>;
|
|
387
|
+
export type AttemptReservedEvent = z.infer<typeof attemptReservedSchema>;
|
|
388
|
+
export type DispatchRequestedEvent = z.infer<typeof dispatchRequestedSchema>;
|
|
389
|
+
export type DispatchSucceededEvent = z.infer<typeof dispatchSucceededSchema>;
|
|
390
|
+
export type DispatchFailedEvent = z.infer<typeof dispatchFailedSchema>;
|
|
391
|
+
export type ProviderEventEvent = z.infer<typeof providerEventSchema>;
|
|
392
|
+
/**
|
|
393
|
+
* Where engine events land. Prisma-backed in production, in-memory in tests,
|
|
394
|
+
* no-op when recording is disabled. Implementations MUST be best-effort: a
|
|
395
|
+
* failing sink is caught and logged by the caller and never fails a tick or a
|
|
396
|
+
* dispatch.
|
|
397
|
+
*/
|
|
398
|
+
export interface EngineEventSink {
|
|
399
|
+
record(events: EngineEvent[]): Promise<void>;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Mask a recipient identifier for the event stream. Phones keep the last 4
|
|
403
|
+
* characters; emails keep the first character of the local part and the domain.
|
|
404
|
+
*/
|
|
405
|
+
export declare function maskRecipient(to: string): string;
|
|
406
|
+
export {};
|
|
407
|
+
//# sourceMappingURL=engineEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineEvents.d.ts","sourceRoot":"","sources":["../../src/schemas/engineEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;EAUhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAsBpE,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;iBAejC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;iBAMrB,CAA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