@superpanel-sdk/runtime 0.2.3 → 0.7.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/README.md +30 -10
- package/dist/builder/codegen/emit.d.ts +25 -12
- package/dist/builder/codegen/emit.js +339 -78
- package/dist/builder/codegen/generate.d.ts +21 -2
- package/dist/builder/codegen/generate.js +147 -34
- package/dist/builder/company-import-graph.d.ts +2 -0
- package/dist/builder/company-import-graph.js +40 -8
- package/dist/builder/company-imports.d.ts +29 -0
- package/dist/builder/company-imports.js +122 -0
- package/dist/builder/compile/compile-sequence.d.ts +61 -8
- package/dist/builder/compile/compile-sequence.js +334 -80
- package/dist/builder/compile/function-code.d.ts +19 -3
- package/dist/builder/compile/function-code.js +123 -45
- package/dist/builder/compile/registry.d.ts +7 -3
- package/dist/builder/compile/registry.js +30 -27
- package/dist/builder/errors.d.ts +9 -0
- package/dist/builder/errors.js +17 -0
- package/dist/builder/function-params.d.ts +10 -0
- package/dist/builder/function-params.js +203 -0
- package/dist/builder/load.d.ts +70 -10
- package/dist/builder/load.js +258 -67
- package/dist/builder/paths.d.ts +9 -1
- package/dist/builder/paths.js +32 -2
- package/dist/builder/schedules.d.ts +25 -0
- package/dist/builder/schedules.js +101 -0
- package/dist/builder/slot-schema-validation.d.ts +4 -0
- package/dist/builder/slot-schema-validation.js +10 -0
- package/dist/builder/typecheck.d.ts +8 -0
- package/dist/builder/typecheck.js +102 -0
- package/dist/builder/types.d.ts +127 -19
- package/dist/builder/types.js +21 -1
- package/dist/cli/auth/auth.d.ts +37 -0
- package/dist/cli/auth/auth.js +211 -0
- package/dist/cli/auth/backend-url.d.ts +5 -0
- package/dist/cli/auth/backend-url.js +25 -0
- package/dist/cli/auth/clipboard.d.ts +9 -0
- package/dist/cli/auth/clipboard.js +38 -0
- package/dist/cli/auth/http.d.ts +20 -0
- package/dist/cli/auth/http.js +27 -0
- package/dist/cli/auth/index.d.ts +10 -0
- package/dist/cli/auth/index.js +27 -0
- package/dist/cli/auth/progress.d.ts +12 -0
- package/dist/cli/auth/progress.js +15 -0
- package/dist/cli/auth/serve-login.d.ts +8 -0
- package/dist/cli/auth/serve-login.js +24 -0
- package/dist/cli/calls/index.d.ts +177 -0
- package/dist/cli/calls/index.js +96 -0
- package/dist/cli/compile/index.js +3 -0
- package/dist/cli/config.d.ts +10 -0
- package/dist/cli/config.js +52 -0
- package/dist/cli/debug/index.d.ts +31 -0
- package/dist/cli/debug/index.js +119 -0
- package/dist/cli/exec/index.d.ts +39 -0
- package/dist/cli/exec/index.js +138 -0
- package/dist/cli/exec/session.d.ts +48 -0
- package/dist/cli/exec/session.js +82 -0
- package/dist/cli/exec/trace.d.ts +18 -0
- package/dist/cli/exec/trace.js +52 -0
- package/dist/cli/index.js +112 -9
- package/dist/cli/logs/index.d.ts +47 -0
- package/dist/cli/logs/index.js +113 -0
- package/dist/cli/mobile/index.d.ts +12 -0
- package/dist/cli/mobile/index.js +405 -0
- package/dist/cli/serve/index.d.ts +109 -3
- package/dist/cli/serve/index.js +506 -118
- package/dist/cli/turns/index.d.ts +105 -0
- package/dist/cli/turns/index.js +128 -0
- package/dist/cli/turns/run.d.ts +13 -0
- package/dist/cli/turns/run.js +57 -0
- package/dist/cli/turns/shadow.d.ts +112 -0
- package/dist/cli/turns/shadow.js +54 -0
- package/dist/cli/type-gen/index.js +9 -9
- package/dist/compiler.d.ts +7 -0
- package/dist/compiler.js +7 -0
- package/dist/compute-host/compute-host.d.ts +14 -23
- package/dist/compute-host/compute-host.js +18 -30
- package/dist/compute-host/index.d.ts +2 -4
- package/dist/compute-host/index.js +1 -2
- package/dist/compute-host/source-compute-host.d.ts +10 -10
- package/dist/compute-host/source-compute-host.js +33 -40
- package/dist/core/case-orchestrator/contact-hours.d.ts +70 -0
- package/dist/core/case-orchestrator/contact-hours.js +127 -0
- package/dist/core/case-orchestrator/index.d.ts +3 -0
- package/dist/core/case-orchestrator/index.js +3 -0
- package/dist/core/case-orchestrator/render.d.ts +75 -0
- package/dist/core/case-orchestrator/render.js +244 -0
- package/dist/core/case-orchestrator/time.d.ts +11 -0
- package/dist/core/case-orchestrator/time.js +29 -0
- package/dist/core/case-orchestrator/types.d.ts +708 -0
- package/dist/core/case-orchestrator/types.js +42 -0
- package/dist/core/context/call.d.ts +291 -0
- package/dist/core/context/call.js +94 -0
- package/dist/core/context/channels.d.ts +60 -0
- package/dist/core/context/channels.js +35 -0
- package/dist/core/context/contact.d.ts +96 -6
- package/dist/core/context/contact.js +48 -2
- package/dist/core/context/email-message.d.ts +198 -0
- package/dist/core/context/email-message.js +86 -0
- package/dist/core/context/email.d.ts +109 -0
- package/dist/core/context/email.js +90 -0
- package/dist/core/context/exchanges.d.ts +167 -0
- package/dist/core/context/exchanges.js +81 -0
- package/dist/core/context/instances.d.ts +307 -0
- package/dist/core/context/instances.js +137 -0
- package/dist/core/context/kv.d.ts +113 -0
- package/dist/core/context/kv.js +60 -0
- package/dist/core/context/platform-registry.d.ts +544 -4
- package/dist/core/context/platform-registry.js +14 -2
- package/dist/core/context/platform.d.ts +2 -1
- package/dist/core/context/sms.d.ts +177 -0
- package/dist/core/context/sms.js +77 -0
- package/dist/core/context/types.d.ts +79 -48
- package/dist/core/context/types.js +1 -7
- package/dist/core/conversation/index.d.ts +85 -0
- package/dist/core/conversation/index.js +133 -0
- package/dist/core/functions/errors.d.ts +74 -0
- package/dist/core/functions/errors.js +26 -0
- package/dist/core/functions/events.d.ts +192 -0
- package/dist/core/functions/events.js +23 -0
- package/dist/core/functions/schedules.d.ts +50 -0
- package/dist/core/functions/schedules.js +20 -0
- package/dist/core/functions/types.d.ts +29 -73
- package/dist/core/functions/types.js +1 -4
- package/dist/core/office-hours/index.d.ts +39 -0
- package/dist/core/office-hours/index.js +187 -0
- package/dist/core/page/define.d.ts +904 -0
- package/dist/core/page/define.js +518 -0
- package/dist/core/page/envelope.d.ts +55 -0
- package/dist/core/page/envelope.js +4 -0
- package/dist/core/page/fns.d.ts +448 -0
- package/dist/core/page/fns.js +539 -0
- package/dist/core/page/memory-reader.d.ts +27 -0
- package/dist/core/page/memory-reader.js +299 -0
- package/dist/core/page/ops.d.ts +58 -0
- package/dist/core/page/ops.js +220 -0
- package/dist/core/page/page-host.d.ts +20 -0
- package/dist/core/page/page-host.js +57 -0
- package/dist/core/page/records-query.d.ts +234 -0
- package/dist/core/page/records-query.js +780 -0
- package/dist/core/page/render.d.ts +295 -0
- package/dist/core/page/render.js +1060 -0
- package/dist/core/page/sandbox.d.ts +85 -0
- package/dist/core/page/sandbox.js +357 -0
- package/dist/core/page/time-format.d.ts +46 -0
- package/dist/core/page/time-format.js +125 -0
- package/dist/core/page/timeline.d.ts +40 -0
- package/dist/core/page/timeline.js +2 -0
- package/dist/core/page/typed.d.ts +648 -0
- package/dist/core/page/typed.js +2 -0
- package/dist/core/page/workspace.d.ts +57 -0
- package/dist/core/page/workspace.js +266 -0
- package/dist/core/party/index.d.ts +3 -0
- package/dist/core/party/index.js +3 -0
- package/dist/core/party/schema.d.ts +208 -0
- package/dist/core/party/schema.js +113 -0
- package/dist/core/party/types.d.ts +35 -0
- package/dist/core/party/types.js +15 -0
- package/dist/core/sequence/define.d.ts +56 -0
- package/dist/core/sequence/define.js +10 -0
- package/dist/core/sequence/index.d.ts +63 -0
- package/dist/core/sequence/index.js +231 -0
- package/dist/core/slot/binding.d.ts +40 -0
- package/dist/core/slot/binding.js +2 -0
- package/dist/core/slot/company-metadata.d.ts +102 -0
- package/dist/core/slot/company-metadata.js +536 -0
- package/dist/core/slot/compile-schema.d.ts +19 -13
- package/dist/core/slot/compile-schema.js +51 -248
- package/dist/core/slot/contact-timezone.d.ts +110 -0
- package/dist/core/slot/contact-timezone.js +186 -0
- package/dist/core/slot/field.d.ts +2 -25
- package/dist/core/slot/field.js +0 -71
- package/dist/core/slot/id-ref.d.ts +17 -2
- package/dist/core/slot/id-ref.js +16 -8
- package/dist/core/slot/index.d.ts +12 -13
- package/dist/core/slot/index.js +11 -12
- package/dist/core/slot/naming.d.ts +15 -0
- package/dist/core/slot/naming.js +96 -0
- package/dist/core/slot/platform-fields.d.ts +119 -0
- package/dist/core/slot/platform-fields.js +121 -0
- package/dist/core/slot/ref.d.ts +16 -0
- package/dist/core/slot/ref.js +14 -0
- package/dist/core/slot/row.d.ts +2 -9
- package/dist/core/slot/row.js +13 -23
- package/dist/core/slot/schema-compat.d.ts +17 -0
- package/dist/core/slot/schema-compat.js +103 -0
- package/dist/core/slot/schema.d.ts +353 -76
- package/dist/core/slot/schema.js +163 -10
- package/dist/core/slot/types.d.ts +30 -103
- package/dist/core/slot/value.d.ts +28 -3
- package/dist/core/slot/value.js +93 -57
- package/dist/dev-overlay/protocol.d.ts +74 -8
- package/dist/fn-context/build-context.d.ts +3 -1
- package/dist/fn-context/build-context.js +26 -10
- package/dist/fn-context/fake/empty-api.js +9 -28
- package/dist/fn-context/fake/index.d.ts +13 -4
- package/dist/fn-context/fake/index.js +29 -2
- package/dist/fn-context/fn-params.d.ts +3 -0
- package/dist/fn-context/fn-params.js +10 -0
- package/dist/fn-context/index.d.ts +5 -5
- package/dist/fn-context/index.js +4 -4
- package/dist/fn-context/log.js +2 -2
- package/dist/fn-context/make-ctx.d.ts +11 -0
- package/dist/fn-context/make-ctx.js +20 -9
- package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +32 -0
- package/dist/fn-context/rpc/case-orchestrator-tools.js +12 -0
- package/dist/fn-context/rpc/errors.d.ts +13 -0
- package/dist/fn-context/rpc/errors.js +22 -0
- package/dist/fn-context/rpc/index.d.ts +4 -2
- package/dist/fn-context/rpc/index.js +4 -2
- package/dist/fn-context/rpc/integration/index.d.ts +15 -5
- package/dist/fn-context/rpc/integration/index.js +1 -1
- package/dist/fn-context/rpc/integration/list-surfaces.d.ts +21 -0
- package/dist/fn-context/rpc/integration/{list-bindings.js → list-surfaces.js} +4 -4
- package/dist/fn-context/rpc/log.d.ts +11 -1
- package/dist/fn-context/rpc/platform.d.ts +13 -3
- package/dist/fn-context/rpc/platform.js +1 -1
- package/dist/fn-context/rpc/records.d.ts +85 -0
- package/dist/fn-context/rpc/records.js +24 -0
- package/dist/fn-context/rpc/trpc-client.d.ts +44 -2
- package/dist/fn-context/rpc/trpc-client.js +222 -12
- package/dist/fn-context/rpc/trpc-init.d.ts +21 -3
- package/dist/fn-context/rpc/trpc-init.js +10 -4
- package/dist/fn-context/rpc/trpc-router-factory.d.ts +111 -7
- package/dist/fn-context/rpc/trpc-router-factory.js +2 -0
- package/dist/fn-context/run-scope.d.ts +4 -0
- package/dist/fn-context/run-scope.js +9 -0
- package/dist/fn-context/types.d.ts +52 -5
- package/dist/index.d.ts +36 -46
- package/dist/index.js +30 -33
- package/dist/logger.d.ts +11 -0
- package/dist/logger.js +49 -0
- package/dist/platform.d.ts +75 -0
- package/dist/platform.js +57 -0
- package/dist/testing-compile-child.d.ts +2 -0
- package/dist/testing-compile-child.js +20 -0
- package/dist/testing.d.ts +368 -0
- package/dist/testing.js +439 -0
- package/dist/voice-service/actions.d.ts +50 -6
- package/dist/voice-service/index.d.ts +2 -0
- package/dist/voice-service/index.js +2 -0
- package/dist/voice-service/protocol.d.ts +604 -0
- package/dist/voice-service/protocol.js +67 -0
- package/dist/voice-service/types.d.ts +55 -8
- package/dist/worker.d.ts +11 -0
- package/dist/worker.js +11 -0
- package/package.json +38 -15
- package/dist/builder/compile/compile-agenda.d.ts +0 -15
- package/dist/builder/compile/compile-agenda.js +0 -64
- package/dist/builder/merge.d.ts +0 -4
- package/dist/builder/merge.js +0 -19
- package/dist/compute-host/read-only-cache.d.ts +0 -20
- package/dist/compute-host/read-only-cache.js +0 -61
- package/dist/core/context/db.d.ts +0 -69
- package/dist/core/context/db.js +0 -44
- package/dist/core/context/docusign.d.ts +0 -134
- package/dist/core/context/docusign.js +0 -108
- package/dist/core/context/filevine.d.ts +0 -323
- package/dist/core/context/filevine.js +0 -254
- package/dist/core/context/http.d.ts +0 -9
- package/dist/core/context/http.js +0 -4
- package/dist/core/context/hubspot.d.ts +0 -250
- package/dist/core/context/hubspot.js +0 -191
- package/dist/core/context/twilio.d.ts +0 -50
- package/dist/core/context/twilio.js +0 -42
- package/dist/core/functions/define/case-context.d.ts +0 -14
- package/dist/core/functions/define/case-context.js +0 -15
- package/dist/core/functions/define/compute.d.ts +0 -7
- package/dist/core/functions/define/compute.js +0 -17
- package/dist/core/functions/define/custom.d.ts +0 -4
- package/dist/core/functions/define/custom.js +0 -8
- package/dist/core/functions/define/system.d.ts +0 -7
- package/dist/core/functions/define/system.js +0 -12
- package/dist/core/functions/func-ref.d.ts +0 -16
- package/dist/core/functions/func-ref.js +0 -20
- package/dist/core/slot/deps.d.ts +0 -15
- package/dist/core/slot/deps.js +0 -88
- package/dist/core/slot/derived.d.ts +0 -32
- package/dist/core/slot/derived.js +0 -115
- package/dist/core/slot/platform-session-fields.d.ts +0 -38
- package/dist/core/slot/platform-session-fields.js +0 -48
- package/dist/core/slot/sf-schema.d.ts +0 -23
- package/dist/core/slot/sf-schema.js +0 -125
- package/dist/core/slot/sf-validate.d.ts +0 -14
- package/dist/core/slot/sf-validate.js +0 -132
- package/dist/core/slot/snapshot.d.ts +0 -18
- package/dist/core/slot/snapshot.js +0 -138
- package/dist/core/slot/write.d.ts +0 -48
- package/dist/core/slot/write.js +0 -426
- package/dist/core/stage/builders.d.ts +0 -54
- package/dist/core/stage/builders.js +0 -31
- package/dist/core/stage/condition.d.ts +0 -17
- package/dist/core/stage/condition.js +0 -198
- package/dist/core/stage/drive.d.ts +0 -43
- package/dist/core/stage/drive.js +0 -78
- package/dist/core/stage/finish-when.d.ts +0 -20
- package/dist/core/stage/finish-when.js +0 -82
- package/dist/core/stage/flatten.d.ts +0 -27
- package/dist/core/stage/flatten.js +0 -466
- package/dist/core/stage/index.d.ts +0 -15
- package/dist/core/stage/index.js +0 -13
- package/dist/core/stage/interrupts.d.ts +0 -28
- package/dist/core/stage/interrupts.js +0 -120
- package/dist/core/stage/ivr-fields.d.ts +0 -9
- package/dist/core/stage/ivr-fields.js +0 -75
- package/dist/core/stage/simulate.d.ts +0 -24
- package/dist/core/stage/simulate.js +0 -33
- package/dist/core/stage/transfer-fields.d.ts +0 -19
- package/dist/core/stage/transfer-fields.js +0 -129
- package/dist/core/stage/transfer-spec.d.ts +0 -48
- package/dist/core/stage/transfer-spec.js +0 -113
- package/dist/core/stage/types.d.ts +0 -208
- package/dist/core/stage/types.js +0 -2
- package/dist/core/stage/validate.d.ts +0 -11
- package/dist/core/stage/validate.js +0 -330
- package/dist/core/stage/walk.d.ts +0 -39
- package/dist/core/stage/walk.js +0 -119
- package/dist/fn-context/rpc/integration/list-bindings.d.ts +0 -21
- package/dist/fn-context/system-args.d.ts +0 -6
- package/dist/fn-context/system-args.js +0 -14
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SMS_PAGE_LIMIT_MAX = 100;
|
|
3
|
+
export declare const smsDirection: z.ZodEnum<{
|
|
4
|
+
inbound: "inbound";
|
|
5
|
+
outbound: "outbound";
|
|
6
|
+
}>;
|
|
7
|
+
export type SmsDirection = z.infer<typeof smsDirection>;
|
|
8
|
+
/**
|
|
9
|
+
* Script-facing SMS projection (21 §5.10). A text line is our number and theirs: `from` / `to` are the
|
|
10
|
+
* message's own. Provider metadata stays private.
|
|
11
|
+
*/
|
|
12
|
+
export declare const smsRecord: z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
instanceId: z.ZodNullable<z.ZodString>;
|
|
15
|
+
contactId: z.ZodNullable<z.ZodString>;
|
|
16
|
+
runId: z.ZodNullable<z.ZodString>;
|
|
17
|
+
direction: z.ZodEnum<{
|
|
18
|
+
inbound: "inbound";
|
|
19
|
+
outbound: "outbound";
|
|
20
|
+
}>;
|
|
21
|
+
from: z.ZodString;
|
|
22
|
+
to: z.ZodString;
|
|
23
|
+
body: z.ZodNullable<z.ZodString>;
|
|
24
|
+
processing: z.ZodNullable<z.ZodString>;
|
|
25
|
+
delivery: z.ZodNullable<z.ZodString>;
|
|
26
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
27
|
+
occurredAt: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type SmsRecord = z.infer<typeof smsRecord>;
|
|
30
|
+
export declare const smsListInput: z.ZodObject<{
|
|
31
|
+
offset: z.ZodNumber;
|
|
32
|
+
limit: z.ZodNumber;
|
|
33
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
34
|
+
contactId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
counterpart: z.ZodOptional<z.ZodString>;
|
|
36
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
37
|
+
inbound: "inbound";
|
|
38
|
+
outbound: "outbound";
|
|
39
|
+
}>>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export type SmsListParams = z.infer<typeof smsListInput>;
|
|
42
|
+
export declare const smsListOutput: z.ZodObject<{
|
|
43
|
+
sms: z.ZodArray<z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
instanceId: z.ZodNullable<z.ZodString>;
|
|
46
|
+
contactId: z.ZodNullable<z.ZodString>;
|
|
47
|
+
runId: z.ZodNullable<z.ZodString>;
|
|
48
|
+
direction: z.ZodEnum<{
|
|
49
|
+
inbound: "inbound";
|
|
50
|
+
outbound: "outbound";
|
|
51
|
+
}>;
|
|
52
|
+
from: z.ZodString;
|
|
53
|
+
to: z.ZodString;
|
|
54
|
+
body: z.ZodNullable<z.ZodString>;
|
|
55
|
+
processing: z.ZodNullable<z.ZodString>;
|
|
56
|
+
delivery: z.ZodNullable<z.ZodString>;
|
|
57
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
58
|
+
occurredAt: z.ZodString;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
offset: z.ZodNumber;
|
|
61
|
+
limit: z.ZodNumber;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export type SmsListResult = z.infer<typeof smsListOutput>;
|
|
64
|
+
export declare const smsGetInput: z.ZodString;
|
|
65
|
+
export declare const smsGetOutput: z.ZodNullable<z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
instanceId: z.ZodNullable<z.ZodString>;
|
|
68
|
+
contactId: z.ZodNullable<z.ZodString>;
|
|
69
|
+
runId: z.ZodNullable<z.ZodString>;
|
|
70
|
+
direction: z.ZodEnum<{
|
|
71
|
+
inbound: "inbound";
|
|
72
|
+
outbound: "outbound";
|
|
73
|
+
}>;
|
|
74
|
+
from: z.ZodString;
|
|
75
|
+
to: z.ZodString;
|
|
76
|
+
body: z.ZodNullable<z.ZodString>;
|
|
77
|
+
processing: z.ZodNullable<z.ZodString>;
|
|
78
|
+
delivery: z.ZodNullable<z.ZodString>;
|
|
79
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
80
|
+
occurredAt: z.ZodString;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
/**
|
|
83
|
+
* A text sent now (32), from any entry (64 §15): to a contact (its row id, not a number: the platform checks
|
|
84
|
+
* their opt-outs and finds their number), from the number of the call the run is on, else the one they are
|
|
85
|
+
* texted from. Stored with the run, then sent. The case it is about: `instanceId` when given (one of this
|
|
86
|
+
* environment's, else refused: `unknown_instance`), else the case the run is on; the case's Orchestrator
|
|
87
|
+
* hears `sms.sent`. With neither it is on no case: in the contact's history only (49), nobody told. Pause
|
|
88
|
+
* and contact hours are not checked: sending is company code's call.
|
|
89
|
+
*/
|
|
90
|
+
export declare const smsSendInput: z.ZodObject<{
|
|
91
|
+
to: z.ZodString;
|
|
92
|
+
body: z.ZodString;
|
|
93
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
export type SmsSendParams = z.infer<typeof smsSendInput>;
|
|
96
|
+
/** The exchange the text was recorded as (`sms.sent` on the case's timeline). */
|
|
97
|
+
export declare const smsSendOutput: z.ZodObject<{
|
|
98
|
+
exchangeId: z.ZodString;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
export type SmsSendResult = z.infer<typeof smsSendOutput>;
|
|
101
|
+
/** Platform SMS capability, reached from scripts as `ctx.api.sms`. */
|
|
102
|
+
export type SmsApi = {
|
|
103
|
+
list(input: SmsListParams): Promise<SmsListResult>;
|
|
104
|
+
get(id: string): Promise<SmsRecord | null>;
|
|
105
|
+
send(input: SmsSendParams): Promise<SmsSendResult>;
|
|
106
|
+
};
|
|
107
|
+
export declare const smsMockService: SmsApi;
|
|
108
|
+
export declare const smsSurface: {
|
|
109
|
+
methods: {
|
|
110
|
+
list: {
|
|
111
|
+
input: z.ZodObject<{
|
|
112
|
+
offset: z.ZodNumber;
|
|
113
|
+
limit: z.ZodNumber;
|
|
114
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
115
|
+
contactId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
counterpart: z.ZodOptional<z.ZodString>;
|
|
117
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
118
|
+
inbound: "inbound";
|
|
119
|
+
outbound: "outbound";
|
|
120
|
+
}>>;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
output: z.ZodObject<{
|
|
123
|
+
sms: z.ZodArray<z.ZodObject<{
|
|
124
|
+
id: z.ZodString;
|
|
125
|
+
instanceId: z.ZodNullable<z.ZodString>;
|
|
126
|
+
contactId: z.ZodNullable<z.ZodString>;
|
|
127
|
+
runId: z.ZodNullable<z.ZodString>;
|
|
128
|
+
direction: z.ZodEnum<{
|
|
129
|
+
inbound: "inbound";
|
|
130
|
+
outbound: "outbound";
|
|
131
|
+
}>;
|
|
132
|
+
from: z.ZodString;
|
|
133
|
+
to: z.ZodString;
|
|
134
|
+
body: z.ZodNullable<z.ZodString>;
|
|
135
|
+
processing: z.ZodNullable<z.ZodString>;
|
|
136
|
+
delivery: z.ZodNullable<z.ZodString>;
|
|
137
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
138
|
+
occurredAt: z.ZodString;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
offset: z.ZodNumber;
|
|
141
|
+
limit: z.ZodNumber;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
};
|
|
144
|
+
get: {
|
|
145
|
+
input: z.ZodString;
|
|
146
|
+
output: z.ZodNullable<z.ZodObject<{
|
|
147
|
+
id: z.ZodString;
|
|
148
|
+
instanceId: z.ZodNullable<z.ZodString>;
|
|
149
|
+
contactId: z.ZodNullable<z.ZodString>;
|
|
150
|
+
runId: z.ZodNullable<z.ZodString>;
|
|
151
|
+
direction: z.ZodEnum<{
|
|
152
|
+
inbound: "inbound";
|
|
153
|
+
outbound: "outbound";
|
|
154
|
+
}>;
|
|
155
|
+
from: z.ZodString;
|
|
156
|
+
to: z.ZodString;
|
|
157
|
+
body: z.ZodNullable<z.ZodString>;
|
|
158
|
+
processing: z.ZodNullable<z.ZodString>;
|
|
159
|
+
delivery: z.ZodNullable<z.ZodString>;
|
|
160
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
161
|
+
occurredAt: z.ZodString;
|
|
162
|
+
}, z.core.$strip>>;
|
|
163
|
+
};
|
|
164
|
+
send: {
|
|
165
|
+
input: z.ZodObject<{
|
|
166
|
+
to: z.ZodString;
|
|
167
|
+
body: z.ZodString;
|
|
168
|
+
instanceId: z.ZodOptional<z.ZodString>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
output: z.ZodObject<{
|
|
171
|
+
exchangeId: z.ZodString;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
mock: SmsApi;
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=sms.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const SMS_PAGE_LIMIT_MAX = 100;
|
|
3
|
+
export const smsDirection = z.enum(['inbound', 'outbound']);
|
|
4
|
+
/**
|
|
5
|
+
* Script-facing SMS projection (21 §5.10). A text line is our number and theirs: `from` / `to` are the
|
|
6
|
+
* message's own. Provider metadata stays private.
|
|
7
|
+
*/
|
|
8
|
+
export const smsRecord = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
instanceId: z.string().nullable(),
|
|
11
|
+
contactId: z.string().nullable(),
|
|
12
|
+
/** Inbound: the run that handled it; outbound: the run that sent it (null: the platform did). */
|
|
13
|
+
runId: z.string().nullable(),
|
|
14
|
+
direction: smsDirection,
|
|
15
|
+
from: z.string(),
|
|
16
|
+
to: z.string(),
|
|
17
|
+
body: z.string().nullable(),
|
|
18
|
+
/** Inbound: pending | claimed | processed | skipped | declined | failed. */
|
|
19
|
+
processing: z.string().nullable(),
|
|
20
|
+
/** Outbound: pending | submitting | the provider's status (queued, sent, delivered, undelivered, failed …). */
|
|
21
|
+
delivery: z.string().nullable(),
|
|
22
|
+
/** The provider's error code, as given. */
|
|
23
|
+
errorCode: z.string().nullable(),
|
|
24
|
+
occurredAt: z.string(),
|
|
25
|
+
});
|
|
26
|
+
export const smsListInput = z.object({
|
|
27
|
+
offset: z.number().int().min(0),
|
|
28
|
+
limit: z.number().int().min(1).max(SMS_PAGE_LIMIT_MAX),
|
|
29
|
+
instanceId: z.string().optional(),
|
|
30
|
+
contactId: z.string().optional(),
|
|
31
|
+
/** Their number: one text line with them (on any of our numbers). */
|
|
32
|
+
counterpart: z.string().optional(),
|
|
33
|
+
direction: smsDirection.optional(),
|
|
34
|
+
});
|
|
35
|
+
export const smsListOutput = z.object({
|
|
36
|
+
sms: z.array(smsRecord),
|
|
37
|
+
offset: z.number().int(),
|
|
38
|
+
limit: z.number().int(),
|
|
39
|
+
});
|
|
40
|
+
export const smsGetInput = z.string().min(1);
|
|
41
|
+
export const smsGetOutput = smsRecord.nullable();
|
|
42
|
+
/**
|
|
43
|
+
* A text sent now (32), from any entry (64 §15): to a contact (its row id, not a number: the platform checks
|
|
44
|
+
* their opt-outs and finds their number), from the number of the call the run is on, else the one they are
|
|
45
|
+
* texted from. Stored with the run, then sent. The case it is about: `instanceId` when given (one of this
|
|
46
|
+
* environment's, else refused: `unknown_instance`), else the case the run is on; the case's Orchestrator
|
|
47
|
+
* hears `sms.sent`. With neither it is on no case: in the contact's history only (49), nobody told. Pause
|
|
48
|
+
* and contact hours are not checked: sending is company code's call.
|
|
49
|
+
*/
|
|
50
|
+
export const smsSendInput = z.object({
|
|
51
|
+
to: z.string().min(1),
|
|
52
|
+
body: z.string().min(1),
|
|
53
|
+
/** The case the text is about, any of this environment's; absent: the run's own case, if any. */
|
|
54
|
+
instanceId: z.string().min(1).optional(),
|
|
55
|
+
});
|
|
56
|
+
/** The exchange the text was recorded as (`sms.sent` on the case's timeline). */
|
|
57
|
+
export const smsSendOutput = z.object({ exchangeId: z.string() });
|
|
58
|
+
export const smsMockService = {
|
|
59
|
+
async list(input) {
|
|
60
|
+
return { sms: [], offset: input.offset, limit: input.limit };
|
|
61
|
+
},
|
|
62
|
+
async get() {
|
|
63
|
+
return null;
|
|
64
|
+
},
|
|
65
|
+
async send() {
|
|
66
|
+
return { exchangeId: 'mock-sms' };
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export const smsSurface = {
|
|
70
|
+
methods: {
|
|
71
|
+
list: { input: smsListInput, output: smsListOutput },
|
|
72
|
+
get: { input: smsGetInput, output: smsGetOutput },
|
|
73
|
+
send: { input: smsSendInput, output: smsSendOutput },
|
|
74
|
+
},
|
|
75
|
+
mock: smsMockService,
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=sms.js.map
|
|
@@ -1,100 +1,131 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CaseOrchestratorTools } from '../case-orchestrator/types.js';
|
|
2
2
|
import type { PlatformApis } from './platform-registry.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Db } from '../page/define.js';
|
|
4
|
+
import type { EmailApi } from './email.js';
|
|
4
5
|
import type { EnvApi } from './env.js';
|
|
5
|
-
import type { FilevineApi } from './filevine.js';
|
|
6
|
-
import type { HubspotApi } from './hubspot.js';
|
|
7
|
-
import type { TwilioApi } from './twilio.js';
|
|
8
|
-
import type { HttpApi } from './http.js';
|
|
9
6
|
import type { IntegrationAccountFields } from './account-fields.js';
|
|
7
|
+
import type { TimeParts } from '../page/time-format.js';
|
|
10
8
|
export type { IntegrationAccountFields, IntegrationTarget } from './account-fields.js';
|
|
11
|
-
export type FieldState = 'empty' | 'filled' | 'asked_unknown' | 'declined';
|
|
12
|
-
/**
|
|
13
|
-
* Fallback Slots. Sequence `__gen/slots.type.ts` provides the narrowed shape;
|
|
14
|
-
* `view.ts` selectors import that type.
|
|
15
|
-
*/
|
|
16
|
-
export type Slots = Record<string, unknown>;
|
|
17
|
-
/**
|
|
18
|
-
* Fallback CaseContext (no view / before narrowing).
|
|
19
|
-
* With `view.ts`, use `CaseContextOf<typeof caseContextView>` from that module.
|
|
20
|
-
*/
|
|
21
|
-
export type CaseContext = Record<string, unknown>;
|
|
22
|
-
/** Flat writes for single-row tables, or the current-bound row of an entity table. */
|
|
23
|
-
export type FieldWrites = Record<FieldPath, unknown>;
|
|
24
|
-
/** Address one row of a multi-row table (`children`, `contact`, custom arrays). */
|
|
25
|
-
export type RowWrite = {
|
|
26
|
-
table: string;
|
|
27
|
-
rowId: string;
|
|
28
|
-
values: Record<string, unknown>;
|
|
29
|
-
};
|
|
30
|
-
/** Mix flat field writes with explicit row writes in one return. */
|
|
31
|
-
export type StructuredWrites = {
|
|
32
|
-
fields?: FieldWrites;
|
|
33
|
-
rows?: RowWrite[];
|
|
34
|
-
};
|
|
35
9
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* `
|
|
10
|
+
* Lifecycle state of a slot field (`01-slot-design §2`):
|
|
11
|
+
* - `'empty'`: Not yet asked or set (`value` is `null`). Not `resolved`.
|
|
12
|
+
* - `'filled'`: Has an answer (`value` is non-null). Counts as `resolved`.
|
|
13
|
+
* - `'asked_unknown'`: Asked, and the contact does not know / cannot remember (`value` is `null` or a coarse value). Counts as `resolved`.
|
|
14
|
+
* - `'declined'`: Asked, and the contact refused to answer (`value` is `null`). Counts as `resolved`.
|
|
39
15
|
*/
|
|
40
|
-
export type
|
|
16
|
+
export type FieldState = 'empty' | 'filled' | 'asked_unknown' | 'declined';
|
|
17
|
+
/** Field states a write can set without a value; the platform stores `value: null`. */
|
|
18
|
+
export type SlotWriteClearState = 'empty' | 'asked_unknown' | 'declined';
|
|
41
19
|
export type Logger = {
|
|
42
20
|
info: (message: string, extra?: Record<string, unknown>) => void;
|
|
43
21
|
warn: (message: string, extra?: Record<string, unknown>) => void;
|
|
44
22
|
error: (message: string, extra?: Record<string, unknown>) => void;
|
|
45
23
|
};
|
|
46
|
-
export type {
|
|
24
|
+
export type { EmailApi, EmailAttachment, EmailGetAttachmentInput, EmailGetAttachmentOutput, EmailGetMessageInput, EmailGetMessageOutput, EmailListMessagesInput, EmailListMessagesOutput, EmailProvider, EmailProviderService, EmailSendEmailInput, EmailSendEmailOutput, EmailService, } from './email.js';
|
|
47
25
|
export type { EnvApi, EnvService } from './env.js';
|
|
48
|
-
export type { FilevineApi, FilevineService } from './filevine.js';
|
|
49
|
-
export type { HubspotApi, HubspotService } from './hubspot.js';
|
|
50
|
-
export type { TwilioApi, TwilioCreateCallInput, TwilioCreateCallOutput, TwilioIncomingNumber, TwilioListIncomingNumbersOutput, TwilioSendSmsInput, TwilioSendSmsOutput, TwilioService, } from './twilio.js';
|
|
51
26
|
export type { ContactApi, ContactListParams, ContactListResult, ContactSummary } from './contact.js';
|
|
52
|
-
export type { HttpApi } from './http.js';
|
|
53
27
|
/**
|
|
54
28
|
* Integration API: surfaceKey → array of bound stubs.
|
|
55
29
|
* Add a key here when the platform adds a script surface; the provider table must implement it.
|
|
56
30
|
*/
|
|
57
31
|
export type IntegrationApi = {
|
|
58
|
-
hubspots?: HubspotApi[];
|
|
59
|
-
twilios?: TwilioApi[];
|
|
60
|
-
filevines?: FilevineApi[];
|
|
61
|
-
docusigns?: DocusignApi[];
|
|
62
32
|
envs?: EnvApi[];
|
|
33
|
+
emails?: EmailApi[];
|
|
63
34
|
};
|
|
64
35
|
export type IntegrationSurfaceKey = keyof IntegrationApi;
|
|
65
36
|
type SurfaceItem<K extends IntegrationSurfaceKey> = NonNullable<IntegrationApi[K]>[number];
|
|
66
37
|
export type IntegrationStub = SurfaceItem<IntegrationSurfaceKey>;
|
|
67
|
-
export declare const integrationSurfaceKeys: readonly ["
|
|
68
|
-
export type
|
|
38
|
+
export declare const integrationSurfaceKeys: readonly ["envs", "emails"];
|
|
39
|
+
export type IntegrationSurfaceMeta = IntegrationAccountFields & {
|
|
69
40
|
surfaceKey: IntegrationSurfaceKey;
|
|
70
41
|
methods: string[];
|
|
71
42
|
};
|
|
43
|
+
/** What does not hold while an environment is tested (68 §6.2). */
|
|
44
|
+
export type ContactHoursIgnore = Readonly<{
|
|
45
|
+
contactHours: boolean;
|
|
46
|
+
contactSchedule: boolean;
|
|
47
|
+
}>;
|
|
72
48
|
/** Context injected into custom and system functions. */
|
|
73
49
|
export type SystemContext = {
|
|
74
50
|
time: Readonly<{
|
|
51
|
+
/** Current wall-clock timestamp in epoch milliseconds (use instead of `Date.now()`). */
|
|
75
52
|
now: number;
|
|
53
|
+
/** IANA timezone of `today`; currently always `'UTC'` (not the contact's or office's timezone). */
|
|
76
54
|
timezone: string;
|
|
55
|
+
/** Current calendar date (`YYYY-MM-DD`) in `time.timezone`, i.e. the UTC date. */
|
|
77
56
|
today: string;
|
|
57
|
+
/**
|
|
58
|
+
* What does not hold in this environment while it is tested (68 §6.2, set on the environment, never in
|
|
59
|
+
* prod): `contactHours`, the company's contact hours; `contactSchedule`, contacts' own schedules.
|
|
60
|
+
* `nextContactTime(hours, ctx.time, zone)` and `withinContactHours(…, ctx.time.ignore)` follow it.
|
|
61
|
+
*/
|
|
62
|
+
ignore: ContactHoursIgnore;
|
|
63
|
+
/**
|
|
64
|
+
* `at` as people read it, in `timeZone` (25 §11): "Tue, Nov 3, 3:00 PM EST" (`style` `'date'` or
|
|
65
|
+
* `'time'` for one part). A contact's zone is `contactTimezone(…)`.
|
|
66
|
+
*/
|
|
67
|
+
format(at: string | number, options: {
|
|
68
|
+
timeZone: string;
|
|
69
|
+
style?: 'datetime' | 'date' | 'time';
|
|
70
|
+
}): string;
|
|
71
|
+
/** The calendar day (`YYYY-MM-DD`) at `at` in `timeZone` (25 §11), to compare days or key a rule by date. */
|
|
72
|
+
day(at: string | number, timeZone: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* The exact moment (ISO 8601, UTC) a clock in `timeZone` shows `date` (`YYYY-MM-DD`) at `time` (`HH:mm`)
|
|
75
|
+
* (74 §4.7): "the day before delivery at 17:00 her time" is `at(dayBefore, '17:00', zone)`. A time the
|
|
76
|
+
* clocks skip is the moment just after the gap; one they show twice, the first.
|
|
77
|
+
*/
|
|
78
|
+
at(date: string, time: string, timeZone: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* `at` on a clock in `timeZone` (74 §4.7): its date, `HH:mm`, hour, minute, ISO weekday (1 Monday … 7
|
|
81
|
+
* Sunday) and offset, to decide "is the office open now" without parsing `format`'s text.
|
|
82
|
+
*/
|
|
83
|
+
parts(at: string | number, timeZone: string): TimeParts;
|
|
78
84
|
}>;
|
|
79
85
|
meta: Readonly<{
|
|
80
86
|
companyId: string;
|
|
81
87
|
environmentId: string;
|
|
82
88
|
sequenceId: string;
|
|
89
|
+
/**
|
|
90
|
+
* What the function runs under: `'voice'` / `'sms'` / `'email'` in a conversation,
|
|
91
|
+
* `'orchestrator'` in an Orchestrator Run, `'resolve'` when resolving a conversation.
|
|
92
|
+
*/
|
|
83
93
|
entry: string;
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
/**
|
|
95
|
+
* The instance the function runs on; null when none (`resolve`, a webhook, a handler without one).
|
|
96
|
+
* Who the conversation is with, and its session, are not here (28 §4): a page passes them as the
|
|
97
|
+
* function's params (`runFunction(name, { prefill: { contactId: ctx.caller.id, sessionId: ctx.session.id } })`).
|
|
98
|
+
*/
|
|
99
|
+
instanceId: string | null;
|
|
100
|
+
/**
|
|
101
|
+
* A function pressed as a button (25 §11): this press's key, the same when the AI presses it again with
|
|
102
|
+
* the same arguments in the same run. Send it to another system as its idempotency key, so a second
|
|
103
|
+
* press does not do the work twice. Absent outside a button.
|
|
104
|
+
*/
|
|
105
|
+
idempotencyKey?: string;
|
|
86
106
|
}>;
|
|
87
107
|
config: Readonly<{
|
|
108
|
+
/** Base URL of the frontend app. */
|
|
88
109
|
frontendUrl: string;
|
|
110
|
+
/** Base URL of the backend RPC endpoint. */
|
|
89
111
|
backendUrl: string;
|
|
90
112
|
}>;
|
|
91
113
|
api: PlatformApis & {
|
|
92
114
|
integration: IntegrationApi;
|
|
93
115
|
log: Logger;
|
|
94
|
-
|
|
116
|
+
/**
|
|
117
|
+
* The company's records, Prisma-shaped (`db.<table>.findMany(…)`, `db.<table>.update(…)`): reads
|
|
118
|
+
* like a page script's (every `where` anchored), writes like a page action's, through the explicit
|
|
119
|
+
* write entry, each call its own transaction. Any row of the company and environment.
|
|
120
|
+
*/
|
|
121
|
+
db: Db;
|
|
122
|
+
/** The platform's tools (38 §2.7): schedule, reschedule, cancel, hand over, read exchanges, on an instance named in each call. */
|
|
123
|
+
tools: CaseOrchestratorTools;
|
|
95
124
|
};
|
|
96
125
|
};
|
|
97
126
|
export type MakeCtxOverrides = {
|
|
127
|
+
/** `ctx.time.ignore`: what does not hold while the environment is tested (68 §6.2); nothing when left out. */
|
|
128
|
+
ignore?: ContactHoursIgnore;
|
|
98
129
|
today?: string;
|
|
99
130
|
timezone?: string;
|
|
100
131
|
now?: number;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the platform knows of a conversation's channel, shared by the page, the engine and the pipeline.
|
|
3
|
+
*/
|
|
4
|
+
export type Direction = 'inbound' | 'outbound';
|
|
5
|
+
/** The channels a conversation runs on. A conversation engine runs on calls and SMS (17b §9.0); email routes and stores only. */
|
|
6
|
+
export declare const CHANNELS: readonly ['call', 'sms', 'email'];
|
|
7
|
+
export type Channel = (typeof CHANNELS)[number];
|
|
8
|
+
/**
|
|
9
|
+
* The languages a contact can have (`contact.language`, 48 §3) and texts and emails tag their replies with
|
|
10
|
+
* (48 §5.2): BCP-47 base tags. Texts and emails need no voice, so they are not limited to what calls can
|
|
11
|
+
* speak (75 §3); a contact who writes in Chinese keeps `zh`, and a call with them opens in English.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CONTACT_LANGUAGES: readonly ['en', 'fr', 'de', 'es', 'pt', 'zh', 'ja', 'hi', 'it', 'ko', 'nl', 'pl', 'ru', 'sv', 'tr', 'tl', 'bg', 'ro', 'ar', 'cs', 'el', 'fi', 'hr', 'ms', 'sk', 'da', 'ta', 'uk', 'hu', 'no', 'vi', 'bn', 'th', 'he', 'ka', 'id', 'te', 'gu', 'kn', 'ml', 'mr', 'pa'];
|
|
14
|
+
/**
|
|
15
|
+
* The languages calls can speak (48 §4, narrowed by 75 §3): the platform language table's tags, the ones
|
|
16
|
+
* Deepgram Flux (`flux-general-multi`) turns on, all spoken by Cartesia. Each has a native default voice,
|
|
17
|
+
* the platform's fixed lines and STOP words (services' language table). A caller speaking another language
|
|
18
|
+
* is answered in the call's language, told once it cannot be spoken (48 §1 item 6).
|
|
19
|
+
*/
|
|
20
|
+
export declare const SPOKEN_LANGUAGES: readonly ['en', 'es', 'fr', 'de', 'hi', 'ru', 'pt', 'ja', 'it', 'nl'];
|
|
21
|
+
/** A language as the platform stores it: a canonical BCP-47 tag (`en`, `es`, `pt-BR`). */
|
|
22
|
+
export type SpokenLanguage = string;
|
|
23
|
+
/** A language `contact.language` holds, texts and emails are written in: a canonical tag, one of `CONTACT_LANGUAGES`. */
|
|
24
|
+
export type ContactLanguage = string;
|
|
25
|
+
/** One of the table's tags, as a type: a key of `Spoken`. */
|
|
26
|
+
export type SpokenTag = (typeof SPOKEN_LANGUAGES)[number];
|
|
27
|
+
/**
|
|
28
|
+
* A fixed line the platform says word for word to the customer, in each language the page wrote (66 §2):
|
|
29
|
+
* `{ en: 'One moment.', es: 'Un momento.' }`. At least one language; `en` is not required.
|
|
30
|
+
*/
|
|
31
|
+
export type Spoken = {
|
|
32
|
+
[K in SpokenTag]: {
|
|
33
|
+
[L in K]: string;
|
|
34
|
+
} & Partial<Record<SpokenTag, string>>;
|
|
35
|
+
}[SpokenTag];
|
|
36
|
+
/**
|
|
37
|
+
* `value` checked as a `Spoken` (66 §2): an object, at least one language, every key a table tag, every
|
|
38
|
+
* text not empty. Copied, in the order written. No `Intl` (the page sandbox has none).
|
|
39
|
+
*/
|
|
40
|
+
export declare function checkSpoken(value: unknown, at: string): Spoken;
|
|
41
|
+
/** The text a `Spoken` falls back to (66 §3): `en` when written, else the first language written. */
|
|
42
|
+
export declare function fallbackSpoken(spoken: Spoken): {
|
|
43
|
+
text: string;
|
|
44
|
+
language: SpokenTag;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The line to say on a call in `language` (66 §3): the same tag, else the same base language
|
|
48
|
+
* (`pt-BR` → `pt`), else `en`, else the first written. `missing`: the language it fell back from, to tell
|
|
49
|
+
* the company.
|
|
50
|
+
*/
|
|
51
|
+
export declare function pickSpoken(spoken: Spoken, language: string | null | undefined): {
|
|
52
|
+
text: string;
|
|
53
|
+
missing: string | null;
|
|
54
|
+
};
|
|
55
|
+
/** `value` as a canonical BCP-47 tag (`pt-br` → `pt-BR`), or null when it is not one. */
|
|
56
|
+
export declare function canonicalLanguage(value: unknown): string | null;
|
|
57
|
+
/** Whether `value` is one of the table's tags as stored (a language calls can speak). */
|
|
58
|
+
export declare function isSpokenLanguage(value: unknown): value is SpokenLanguage;
|
|
59
|
+
/** Whether `value` is a language `contact.language` can hold, as stored (texts and emails: any of them). */
|
|
60
|
+
export declare function isContactLanguage(value: unknown): value is ContactLanguage;
|
|
61
|
+
/**
|
|
62
|
+
* The table's language a tag resolves to (48 §2): the same tag, else the first with its base language
|
|
63
|
+
* (`es-MX` → `es`), unless that entry is not the fallback for it (`zh-HK`). Null: calls cannot speak it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function matchSpokenLanguage(value: unknown): SpokenLanguage | null;
|
|
66
|
+
/** The contact language a tag resolves to, as {@link matchSpokenLanguage} (`zh-CN` → `zh`). Null: none. */
|
|
67
|
+
export declare function matchContactLanguage(value: unknown): ContactLanguage | null;
|
|
68
|
+
/** A language's name in English, for prompts (`zh` → `Chinese`); the tag itself when it has none. */
|
|
69
|
+
export declare function languageName(tag: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* The scheduled action that started an outbound conversation (a scheduled call or message), fixed for
|
|
72
|
+
* the session. An agreed follow-up has `agreedInExchangeId`; `note` says why it happens
|
|
73
|
+
* (docs/design/09-agreed-follow-up.md).
|
|
74
|
+
*/
|
|
75
|
+
export type ScheduledContactContext = {
|
|
76
|
+
scheduledActionId: string;
|
|
77
|
+
/** Set for an agreed follow-up: the exchange the party asked for or agreed to it in. */
|
|
78
|
+
agreedInExchangeId: string | null;
|
|
79
|
+
/** An agreed follow-up: the party's own words agreeing to it; null otherwise. */
|
|
80
|
+
customerQuote: string | null;
|
|
81
|
+
note: string | null;
|
|
82
|
+
/** When it was due, ISO 8601. */
|
|
83
|
+
scheduledFor: string;
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the platform knows of a conversation's channel, shared by the page, the engine and the pipeline.
|
|
3
|
+
*/
|
|
4
|
+
/** The channels a conversation runs on. A conversation engine runs on calls and SMS (17b §9.0); email routes and stores only. */
|
|
5
|
+
export const CHANNELS = ['call', 'sms', 'email'];
|
|
6
|
+
/**
|
|
7
|
+
* The languages a contact can have (`contact.language`, 48 §3) and texts and emails tag their replies with
|
|
8
|
+
* (48 §5.2): BCP-47 base tags. Texts and emails need no voice, so they are not limited to what calls can
|
|
9
|
+
* speak (75 §3); a contact who writes in Chinese keeps `zh`, and a call with them opens in English.
|
|
10
|
+
*/
|
|
11
|
+
export const CONTACT_LANGUAGES = [
|
|
12
|
+
'en', 'fr', 'de', 'es', 'pt', 'zh', 'ja', 'hi', 'it', 'ko', 'nl', 'pl', 'ru', 'sv', 'tr', 'tl', 'bg', 'ro', 'ar', 'cs',
|
|
13
|
+
'el', 'fi', 'hr', 'ms', 'sk', 'da', 'ta', 'uk', 'hu', 'no', 'vi', 'bn', 'th', 'he', 'ka', 'id', 'te', 'gu', 'kn', 'ml',
|
|
14
|
+
'mr', 'pa',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* The languages calls can speak (48 §4, narrowed by 75 §3): the platform language table's tags, the ones
|
|
18
|
+
* Deepgram Flux (`flux-general-multi`) turns on, all spoken by Cartesia. Each has a native default voice,
|
|
19
|
+
* the platform's fixed lines and STOP words (services' language table). A caller speaking another language
|
|
20
|
+
* is answered in the call's language, told once it cannot be spoken (48 §1 item 6).
|
|
21
|
+
*/
|
|
22
|
+
export const SPOKEN_LANGUAGES = ['en', 'es', 'fr', 'de', 'hi', 'ru', 'pt', 'ja', 'it', 'nl'];
|
|
23
|
+
/**
|
|
24
|
+
* `value` checked as a `Spoken` (66 §2): an object, at least one language, every key a table tag, every
|
|
25
|
+
* text not empty. Copied, in the order written. No `Intl` (the page sandbox has none).
|
|
26
|
+
*/
|
|
27
|
+
export function checkSpoken(value, at) {
|
|
28
|
+
if (typeof value === 'string')
|
|
29
|
+
throw new Error(`${at}: write it per language, { en: '…', es: '…' } (66 §2), not one string`);
|
|
30
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
31
|
+
throw new Error(`${at}: write it per language, { en: '…', es: '…' } (66 §2)`);
|
|
32
|
+
const out = {};
|
|
33
|
+
for (const [key, text] of Object.entries(value)) {
|
|
34
|
+
if (!SPOKEN_LANGUAGES.includes(key))
|
|
35
|
+
throw new Error(`${at}: '${key}' is not a language of the platform's table (${SPOKEN_LANGUAGES.join(', ')})`);
|
|
36
|
+
if (typeof text !== 'string' || !text.trim())
|
|
37
|
+
throw new Error(`${at}: the ${key} text is empty`);
|
|
38
|
+
out[key] = text;
|
|
39
|
+
}
|
|
40
|
+
if (!Object.keys(out).length)
|
|
41
|
+
throw new Error(`${at}: write it in at least one language`);
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
/** The text a `Spoken` falls back to (66 §3): `en` when written, else the first language written. */
|
|
45
|
+
export function fallbackSpoken(spoken) {
|
|
46
|
+
const texts = spoken;
|
|
47
|
+
if (texts.en)
|
|
48
|
+
return { text: texts.en, language: 'en' };
|
|
49
|
+
const [language, text] = Object.entries(texts).find(([, t]) => !!t);
|
|
50
|
+
return { text, language };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The line to say on a call in `language` (66 §3): the same tag, else the same base language
|
|
54
|
+
* (`pt-BR` → `pt`), else `en`, else the first written. `missing`: the language it fell back from, to tell
|
|
55
|
+
* the company.
|
|
56
|
+
*/
|
|
57
|
+
export function pickSpoken(spoken, language) {
|
|
58
|
+
const texts = spoken;
|
|
59
|
+
if (language) {
|
|
60
|
+
const exact = texts[language];
|
|
61
|
+
if (exact)
|
|
62
|
+
return { text: exact, missing: null };
|
|
63
|
+
const base = matchSpokenLanguage(language);
|
|
64
|
+
const near = base ? texts[base] : undefined;
|
|
65
|
+
if (near)
|
|
66
|
+
return { text: near, missing: null };
|
|
67
|
+
}
|
|
68
|
+
const fallback = fallbackSpoken(spoken);
|
|
69
|
+
return { text: fallback.text, missing: language && language !== fallback.language ? language : null };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Tags a table entry is not the fallback for (48 §2): the same base language, not understood by its
|
|
73
|
+
* speakers. Matched by language and region (`zh-HK` covers `zh-Hant-HK`); Cantonese (`yue`) is apart already.
|
|
74
|
+
*/
|
|
75
|
+
const NOT_FALLBACK_FOR = { zh: ['zh-HK', 'zh-MO'] };
|
|
76
|
+
/** `value` as a canonical BCP-47 tag (`pt-br` → `pt-BR`), or null when it is not one. */
|
|
77
|
+
export function canonicalLanguage(value) {
|
|
78
|
+
if (typeof value !== 'string' || !value.trim())
|
|
79
|
+
return null;
|
|
80
|
+
try {
|
|
81
|
+
return Intl.getCanonicalLocales(value.trim())[0] ?? null;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Whether `value` is one of the table's tags as stored (a language calls can speak). */
|
|
88
|
+
export function isSpokenLanguage(value) {
|
|
89
|
+
return typeof value === 'string' && SPOKEN_LANGUAGES.includes(value);
|
|
90
|
+
}
|
|
91
|
+
/** Whether `value` is a language `contact.language` can hold, as stored (texts and emails: any of them). */
|
|
92
|
+
export function isContactLanguage(value) {
|
|
93
|
+
return typeof value === 'string' && CONTACT_LANGUAGES.includes(value);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The table's language a tag resolves to (48 §2): the same tag, else the first with its base language
|
|
97
|
+
* (`es-MX` → `es`), unless that entry is not the fallback for it (`zh-HK`). Null: calls cannot speak it.
|
|
98
|
+
*/
|
|
99
|
+
export function matchSpokenLanguage(value) {
|
|
100
|
+
return matchIn(SPOKEN_LANGUAGES, value);
|
|
101
|
+
}
|
|
102
|
+
/** The contact language a tag resolves to, as {@link matchSpokenLanguage} (`zh-CN` → `zh`). Null: none. */
|
|
103
|
+
export function matchContactLanguage(value) {
|
|
104
|
+
return matchIn(CONTACT_LANGUAGES, value);
|
|
105
|
+
}
|
|
106
|
+
function matchIn(tags, value) {
|
|
107
|
+
const tag = canonicalLanguage(value);
|
|
108
|
+
if (!tag)
|
|
109
|
+
return null;
|
|
110
|
+
if (tags.includes(tag))
|
|
111
|
+
return tag;
|
|
112
|
+
const locale = new Intl.Locale(tag);
|
|
113
|
+
const hit = tags.find((l) => new Intl.Locale(l).language === locale.language);
|
|
114
|
+
if (!hit)
|
|
115
|
+
return null;
|
|
116
|
+
const excluded = (NOT_FALLBACK_FOR[hit] ?? []).some((x) => {
|
|
117
|
+
const ex = new Intl.Locale(x);
|
|
118
|
+
return ex.language === locale.language && (!ex.region || ex.region === locale.region);
|
|
119
|
+
});
|
|
120
|
+
return excluded ? null : hit;
|
|
121
|
+
}
|
|
122
|
+
let displayNames = null;
|
|
123
|
+
/** A language's name in English, for prompts (`zh` → `Chinese`); the tag itself when it has none. */
|
|
124
|
+
export function languageName(tag) {
|
|
125
|
+
try {
|
|
126
|
+
displayNames ??= new Intl.DisplayNames(['en'], { type: 'language' });
|
|
127
|
+
return displayNames.of(tag) ?? tag;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return tag;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=index.js.map
|