@superpanel-sdk/runtime 0.2.3 → 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/README.md +28 -8
- package/dist/builder/codegen/emit.d.ts +29 -11
- package/dist/builder/codegen/emit.js +328 -61
- package/dist/builder/codegen/generate.d.ts +21 -0
- package/dist/builder/codegen/generate.js +152 -20
- 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 +24 -0
- package/dist/builder/company-imports.js +114 -0
- package/dist/builder/compile/compile-sequence.d.ts +59 -8
- package/dist/builder/compile/compile-sequence.js +279 -77
- package/dist/builder/compile/function-code.d.ts +12 -2
- package/dist/builder/compile/function-code.js +87 -39
- package/dist/builder/compile/registry.d.ts +7 -3
- package/dist/builder/compile/registry.js +24 -23
- package/dist/builder/load.d.ts +70 -10
- package/dist/builder/load.js +250 -61
- package/dist/builder/paths.d.ts +3 -0
- package/dist/builder/paths.js +16 -0
- package/dist/builder/schedules.d.ts +23 -0
- package/dist/builder/schedules.js +102 -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 +105 -0
- package/dist/builder/types.d.ts +91 -19
- package/dist/builder/types.js +2 -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/compile/index.js +3 -0
- package/dist/cli/config.d.ts +10 -0
- package/dist/cli/config.js +52 -0
- package/dist/cli/index.js +28 -8
- package/dist/cli/serve/index.d.ts +73 -3
- package/dist/cli/serve/index.js +365 -116
- package/dist/cli/type-gen/index.js +9 -8
- package/dist/compiler.d.ts +7 -0
- package/dist/compiler.js +7 -0
- package/dist/compute-host/compute-host.d.ts +15 -23
- package/dist/compute-host/compute-host.js +25 -28
- 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 +11 -9
- package/dist/compute-host/source-compute-host.js +46 -32
- package/dist/core/case-orchestrator/contact-hours.d.ts +50 -0
- package/dist/core/case-orchestrator/contact-hours.js +108 -0
- package/dist/core/case-orchestrator/follow-ups.d.ts +31 -0
- package/dist/core/case-orchestrator/follow-ups.js +103 -0
- package/dist/core/case-orchestrator/index.d.ts +6 -0
- package/dist/core/case-orchestrator/index.js +6 -0
- package/dist/core/case-orchestrator/render.d.ts +75 -0
- package/dist/core/case-orchestrator/render.js +239 -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/tools.d.ts +29 -0
- package/dist/core/case-orchestrator/tools.js +31 -0
- package/dist/core/case-orchestrator/types.d.ts +753 -0
- package/dist/core/case-orchestrator/types.js +46 -0
- package/dist/core/case-orchestrator/validate.d.ts +11 -0
- package/dist/core/case-orchestrator/validate.js +63 -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 +159 -0
- package/dist/core/context/email-message.js +59 -0
- package/dist/core/context/email.d.ts +97 -0
- package/dist/core/context/email.js +91 -0
- package/dist/core/context/exchanges.d.ts +142 -0
- package/dist/core/context/exchanges.js +63 -0
- package/dist/core/context/instances.d.ts +278 -0
- package/dist/core/context/instances.js +123 -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 +509 -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 +147 -0
- package/dist/core/context/sms.js +57 -0
- package/dist/core/context/types.d.ts +51 -48
- package/dist/core/context/types.js +1 -7
- package/dist/core/conversation/index.d.ts +31 -0
- package/dist/core/conversation/index.js +14 -0
- package/dist/core/functions/define/bind.d.ts +25 -0
- package/dist/core/functions/define/bind.js +14 -0
- package/dist/core/functions/define/case.d.ts +9 -0
- package/dist/core/functions/define/case.js +13 -0
- package/dist/core/functions/define/events.d.ts +20 -0
- package/dist/core/functions/define/events.js +21 -0
- package/dist/core/functions/define/no-case.d.ts +4 -0
- package/dist/core/functions/define/no-case.js +9 -0
- package/dist/core/functions/events.d.ts +247 -0
- package/dist/core/functions/events.js +32 -0
- package/dist/core/functions/func-ref.d.ts +11 -2
- package/dist/core/functions/schedules.d.ts +51 -0
- package/dist/core/functions/schedules.js +20 -0
- package/dist/core/functions/types.d.ts +62 -51
- package/dist/core/functions/types.js +6 -1
- 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 +834 -0
- package/dist/core/page/define.js +477 -0
- package/dist/core/page/ops.d.ts +58 -0
- package/dist/core/page/ops.js +220 -0
- package/dist/core/page/render.d.ts +253 -0
- package/dist/core/page/render.js +840 -0
- package/dist/core/page/time-format.d.ts +19 -0
- package/dist/core/page/time-format.js +41 -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 +642 -0
- package/dist/core/page/typed.js +2 -0
- package/dist/core/page/workspace.d.ts +33 -0
- package/dist/core/page/workspace.js +231 -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 +137 -0
- package/dist/core/party/schema.js +80 -0
- package/dist/core/party/types.d.ts +40 -0
- package/dist/core/party/types.js +15 -0
- package/dist/core/sequence/define.d.ts +57 -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 +113 -0
- package/dist/core/slot/company-metadata.js +563 -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 -24
- package/dist/core/slot/field.js +0 -69
- 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 +16 -0
- package/dist/core/slot/schema-compat.js +112 -0
- package/dist/core/slot/schema.d.ts +409 -76
- package/dist/core/slot/schema.js +178 -10
- package/dist/core/slot/types.d.ts +27 -94
- package/dist/core/slot/value.d.ts +26 -3
- package/dist/core/slot/value.js +89 -57
- package/dist/dev-overlay/protocol.d.ts +41 -8
- package/dist/fn-context/build-context.d.ts +3 -1
- package/dist/fn-context/build-context.js +20 -10
- package/dist/fn-context/fake/empty-api.js +9 -28
- package/dist/fn-context/fake/index.d.ts +11 -4
- package/dist/fn-context/fake/index.js +27 -2
- package/dist/fn-context/fn-params.d.ts +6 -0
- package/dist/fn-context/fn-params.js +13 -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 +18 -8
- package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +24 -0
- package/dist/fn-context/rpc/case-orchestrator-tools.js +13 -0
- package/dist/fn-context/rpc/index.d.ts +3 -1
- package/dist/fn-context/rpc/index.js +3 -1
- package/dist/fn-context/rpc/integration/index.d.ts +4 -4
- 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/platform.d.ts +2 -2
- package/dist/fn-context/rpc/platform.js +1 -1
- package/dist/fn-context/rpc/records.d.ts +78 -0
- package/dist/fn-context/rpc/records.js +26 -0
- package/dist/fn-context/rpc/trpc-client.d.ts +2 -2
- package/dist/fn-context/rpc/trpc-client.js +88 -7
- package/dist/fn-context/rpc/trpc-init.d.ts +2 -2
- package/dist/fn-context/rpc/trpc-router-factory.d.ts +49 -3
- 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 +36 -3
- package/dist/index.d.ts +37 -46
- package/dist/index.js +33 -33
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +41 -0
- package/dist/platform.d.ts +76 -0
- package/dist/platform.js +56 -0
- package/dist/voice-service/actions.d.ts +71 -4
- package/dist/voice-service/types.d.ts +42 -5
- package/dist/worker.d.ts +10 -0
- package/dist/worker.js +10 -0
- package/package.json +38 -19
- 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/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
|
@@ -1,36 +1,14 @@
|
|
|
1
1
|
import type { FieldState } from '../context/types.js';
|
|
2
|
-
import type { FieldHistoryEntry, FieldValue, UpdatedBy } from './types.js';
|
|
2
|
+
import type { FieldHistoryEntry, FieldValue, SlotValue, UpdatedBy } from './types.js';
|
|
3
3
|
/** Stage done checks use resolved, not "has a value". */
|
|
4
4
|
export declare function isResolved(field: FieldValue | null | undefined): boolean;
|
|
5
5
|
export declare function emptyFieldValue(now?: number): FieldValue;
|
|
6
6
|
export declare function makeFieldValue(partial: {
|
|
7
|
-
value:
|
|
7
|
+
value: SlotValue;
|
|
8
8
|
state: FieldState;
|
|
9
9
|
reason?: string | null;
|
|
10
10
|
updatedBy?: UpdatedBy;
|
|
11
11
|
updatedAt?: number;
|
|
12
12
|
history?: FieldHistoryEntry[];
|
|
13
13
|
}): FieldValue;
|
|
14
|
-
/**
|
|
15
|
-
* C5 change detection: value or state changed.
|
|
16
|
-
* reason-only updates do not count (01-slot-design §2 iron rule).
|
|
17
|
-
*/
|
|
18
|
-
export declare function fieldChanged(prev: FieldValue | undefined, next: FieldValue): boolean;
|
|
19
|
-
export declare function toHistoryEntry(field: FieldValue): FieldHistoryEntry;
|
|
20
|
-
export type CommitFieldWriteResult = {
|
|
21
|
-
field: FieldValue;
|
|
22
|
-
changed: boolean;
|
|
23
|
-
/** Previous generation archived into `field.history` (absent when unchanged or prev was empty). */
|
|
24
|
-
historyEntry?: FieldHistoryEntry;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Apply a write onto a field envelope.
|
|
28
|
-
* - C5 change: archive previous non-empty generation into `history`, then replace current
|
|
29
|
-
* - reason-only: update reason, keep value/state/history/updated*
|
|
30
|
-
*/
|
|
31
|
-
export declare function commitFieldWrite(prev: FieldValue | undefined, next: FieldValue): CommitFieldWriteResult;
|
|
32
|
-
/** Last N generation values: prior history entries + current value (01-slot-db §4.2). */
|
|
33
|
-
export declare function getLastThreeValues(field: FieldValue, n?: number): Array<string | number | boolean | null>;
|
|
34
|
-
export declare function getFieldValue(field: FieldValue | null | undefined): string | number | boolean | null;
|
|
35
|
-
export declare function getFieldState(field: FieldValue | null | undefined): FieldState;
|
|
36
14
|
//# sourceMappingURL=field.d.ts.map
|
package/dist/core/slot/field.js
CHANGED
|
@@ -25,73 +25,4 @@ export function makeFieldValue(partial) {
|
|
|
25
25
|
history: partial.history ?? [],
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* C5 change detection: value or state changed.
|
|
30
|
-
* reason-only updates do not count (01-slot-design §2 iron rule).
|
|
31
|
-
*/
|
|
32
|
-
export function fieldChanged(prev, next) {
|
|
33
|
-
if (!prev) {
|
|
34
|
-
return next.state !== 'empty' || next.value !== null;
|
|
35
|
-
}
|
|
36
|
-
return prev.value !== next.value || prev.state !== next.state;
|
|
37
|
-
}
|
|
38
|
-
export function toHistoryEntry(field) {
|
|
39
|
-
return {
|
|
40
|
-
value: field.value,
|
|
41
|
-
state: field.state,
|
|
42
|
-
at: field.updatedAt,
|
|
43
|
-
by: field.updatedBy,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Apply a write onto a field envelope.
|
|
48
|
-
* - C5 change: archive previous non-empty generation into `history`, then replace current
|
|
49
|
-
* - reason-only: update reason, keep value/state/history/updated*
|
|
50
|
-
*/
|
|
51
|
-
export function commitFieldWrite(prev, next) {
|
|
52
|
-
if (!fieldChanged(prev, next)) {
|
|
53
|
-
if (!prev) {
|
|
54
|
-
return {
|
|
55
|
-
field: makeFieldValue({ ...next, history: [] }),
|
|
56
|
-
changed: false,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
field: {
|
|
61
|
-
...prev,
|
|
62
|
-
reason: next.reason,
|
|
63
|
-
},
|
|
64
|
-
changed: false,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const history = [...(prev?.history ?? [])];
|
|
68
|
-
let historyEntry;
|
|
69
|
-
if (prev && prev.state !== 'empty') {
|
|
70
|
-
historyEntry = toHistoryEntry(prev);
|
|
71
|
-
history.push(historyEntry);
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
field: makeFieldValue({
|
|
75
|
-
value: next.value,
|
|
76
|
-
state: next.state,
|
|
77
|
-
reason: next.reason,
|
|
78
|
-
updatedBy: next.updatedBy,
|
|
79
|
-
updatedAt: next.updatedAt,
|
|
80
|
-
history,
|
|
81
|
-
}),
|
|
82
|
-
changed: true,
|
|
83
|
-
...(historyEntry ? { historyEntry } : {}),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/** Last N generation values: prior history entries + current value (01-slot-db §4.2). */
|
|
87
|
-
export function getLastThreeValues(field, n = 3) {
|
|
88
|
-
const generations = [...field.history.map((h) => h.value), field.value];
|
|
89
|
-
return generations.slice(-n);
|
|
90
|
-
}
|
|
91
|
-
export function getFieldValue(field) {
|
|
92
|
-
return field?.value ?? null;
|
|
93
|
-
}
|
|
94
|
-
export function getFieldState(field) {
|
|
95
|
-
return field?.state ?? 'empty';
|
|
96
|
-
}
|
|
97
28
|
//# sourceMappingURL=field.js.map
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { CompanyNormalFieldDef } from './schema.js';
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* What a ref may say of itself beyond its target: `relatedName`, the name of the way back from the
|
|
4
|
+
* target row to the rows that point at it (13-data-model-v1 §23.4 item 3), e.g.
|
|
5
|
+
* `case_file: parentRef('case_file', { relatedName: 'injuries' })` gives `case_file.injuries`.
|
|
6
|
+
*/
|
|
7
|
+
type RefOptions = {
|
|
8
|
+
relatedName?: string;
|
|
9
|
+
};
|
|
10
|
+
/** String field that stores `{table}.id`: a lookup (13-data-model-v1 §11.2). */
|
|
11
|
+
export declare function lookupRef(table: string, extras?: Pick<Partial<CompanyNormalFieldDef>, 'label' | 'extraction'> & RefOptions): CompanyNormalFieldDef;
|
|
12
|
+
/**
|
|
13
|
+
* The row's owner (13-data-model-v1 §11.2, §22.4, 14-sequence-instance §16.1), e.g.
|
|
14
|
+
* `matter: parentRef('matter')`. Required; filled by the platform when it points at the sequence's
|
|
15
|
+
* business root, otherwise given once on insert. A parent row has any number of rows under it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parentRef(table: string, options?: Pick<Partial<CompanyNormalFieldDef>, 'label' | 'extraction'> & RefOptions): CompanyNormalFieldDef;
|
|
18
|
+
export {};
|
|
4
19
|
//# sourceMappingURL=id-ref.d.ts.map
|
package/dist/core/slot/id-ref.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export function
|
|
1
|
+
/** String field that stores `{table}.id`: a lookup (13-data-model-v1 §11.2). */
|
|
2
|
+
export function lookupRef(table, extras) {
|
|
3
3
|
return {
|
|
4
|
-
derived: false,
|
|
5
4
|
label: extras?.label ?? table,
|
|
6
5
|
dataType: 'string',
|
|
7
|
-
source: 'system',
|
|
8
6
|
extraction: extras?.extraction ?? `Reference to ${table}.id`,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
ref: { table, kind: 'lookup', ...(extras?.relatedName !== undefined ? { relatedName: extras.relatedName } : {}) },
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The row's owner (13-data-model-v1 §11.2, §22.4, 14-sequence-instance §16.1), e.g.
|
|
12
|
+
* `matter: parentRef('matter')`. Required; filled by the platform when it points at the sequence's
|
|
13
|
+
* business root, otherwise given once on insert. A parent row has any number of rows under it.
|
|
14
|
+
*/
|
|
15
|
+
export function parentRef(table, options) {
|
|
16
|
+
return {
|
|
17
|
+
label: options?.label ?? table,
|
|
18
|
+
dataType: 'string',
|
|
19
|
+
extraction: options?.extraction ?? `The ${table} this row belongs to`,
|
|
20
|
+
ref: { table, kind: 'parent', ...(options?.relatedName !== undefined ? { relatedName: options.relatedName } : {}) },
|
|
13
21
|
};
|
|
14
22
|
}
|
|
15
23
|
//# sourceMappingURL=id-ref.js.map
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
export { ROW_ID_FIELD,
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { ROW_ID_FIELD, ROW_SYSTEM_KEYS, ROW_TIME_KEYS, isRowTimeKey, type RowSystemKey, type RowTimeKey, idFieldCore, normalFieldCoreSchema, companyNormalFieldDefSchema, compiledCompanyMetadataSchema, companyFieldDefSchema, companyTableDefSchema, companySchemaSchema, contactScheduleValueSchema, localTimeRangeSchema, isCompanySchema, } from './schema.js';
|
|
2
|
+
export { CONTACT_OPT_OUT_FIELDS, CONTACT_TABLE, LIMITS, PLATFORM_CONTACT_FIELDS, POLICY_IDS, SESSION_TABLE, compileCompanyMetadata, isCustomTable, isParentField, isRecordTable, parentOf, subjectTableIssues, compileCompanySchema, type CompileCompanyMetadataResult, type ResponsePolicyId, type SlotFillingPolicyId, type VoiceProfileId, } from './company-metadata.js';
|
|
3
|
+
export { lookupRef, parentRef } from './id-ref.js';
|
|
4
|
+
export { isFieldValue, isReservedTableName, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, slotFieldEntries, slotFieldNames, type SlotRow, } from './row.js';
|
|
4
5
|
export { parseFieldPath, requireFieldPath, formatFieldPath, type FieldPath, type ParsedFieldPath } from './path.js';
|
|
5
|
-
export { isResolved, emptyFieldValue, makeFieldValue,
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export type { ComputeFnMap, ComputeHost, ComputeHostOrFns, LocalComputeHostOptions, RecomputeOptions, } from './derived.js';
|
|
14
|
-
export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost, recomputeDerived, applyFieldPatchAndRecompute, applyWritesAndRecompute, applySlotFillingAndRecompute, } from './derived.js';
|
|
6
|
+
export { isResolved, emptyFieldValue, makeFieldValue, } from './field.js';
|
|
7
|
+
export { compileSlotSchema, compiledTableEntries, getCompiledTable, getTableField, relationsOf, type TableRelation, validateFieldRefs, companyFieldToRuntime, } from './compile-schema.js';
|
|
8
|
+
export { companyMetadataCompatibilityIssues } from './schema-compat.js';
|
|
9
|
+
export { DATE_VALUE_FORMAT, DATE_VALUE_PATTERN, DATETIME_VALUE_FORMAT, DATETIME_VALUE_PATTERN, isValidDataTypeValue, validateBareValue, } from './value.js';
|
|
10
|
+
export { refKind, refValueIssues, type RefKind } from './ref.js';
|
|
11
|
+
export type { ComputeFnMap, ComputeHost, ComputeHostOrFns } from '../../compute-host/compute-host.js';
|
|
12
|
+
export { createLocalComputeHost, resolveComputeHost } from '../../compute-host/compute-host.js';
|
|
13
|
+
export { createSourceComputeHost } from '../../compute-host/source-compute-host.js';
|
|
15
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/slot/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
export { ROW_ID_FIELD,
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { ROW_ID_FIELD, ROW_SYSTEM_KEYS, ROW_TIME_KEYS, isRowTimeKey, idFieldCore, normalFieldCoreSchema, companyNormalFieldDefSchema, compiledCompanyMetadataSchema, companyFieldDefSchema, companyTableDefSchema, companySchemaSchema, contactScheduleValueSchema, localTimeRangeSchema, isCompanySchema, } from './schema.js';
|
|
2
|
+
export { CONTACT_OPT_OUT_FIELDS, CONTACT_TABLE, LIMITS, PLATFORM_CONTACT_FIELDS, POLICY_IDS, SESSION_TABLE, compileCompanyMetadata, isCustomTable, isParentField, isRecordTable, parentOf, subjectTableIssues, compileCompanySchema, } from './company-metadata.js';
|
|
3
|
+
export { lookupRef, parentRef } from './id-ref.js';
|
|
4
|
+
export { isFieldValue, isReservedTableName, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, slotFieldEntries, slotFieldNames, } from './row.js';
|
|
4
5
|
export { parseFieldPath, requireFieldPath, formatFieldPath } from './path.js';
|
|
5
|
-
export { isResolved, emptyFieldValue, makeFieldValue,
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export { applyFieldPatch, applyWrites, applySlotFilling, markAskedUnknown, isRowWrite, isStructuredWrites, normalizeWrites, } from './write.js';
|
|
13
|
-
export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost, recomputeDerived, applyFieldPatchAndRecompute, applyWritesAndRecompute, applySlotFillingAndRecompute, } from './derived.js';
|
|
6
|
+
export { isResolved, emptyFieldValue, makeFieldValue, } from './field.js';
|
|
7
|
+
export { compileSlotSchema, compiledTableEntries, getCompiledTable, getTableField, relationsOf, validateFieldRefs, companyFieldToRuntime, } from './compile-schema.js';
|
|
8
|
+
export { companyMetadataCompatibilityIssues } from './schema-compat.js';
|
|
9
|
+
export { DATE_VALUE_FORMAT, DATE_VALUE_PATTERN, DATETIME_VALUE_FORMAT, DATETIME_VALUE_PATTERN, isValidDataTypeValue, validateBareValue, } from './value.js';
|
|
10
|
+
export { refKind, refValueIssues } from './ref.js';
|
|
11
|
+
export { createLocalComputeHost, resolveComputeHost } from '../../compute-host/compute-host.js';
|
|
12
|
+
export { createSourceComputeHost } from '../../compute-host/source-compute-host.js';
|
|
14
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming rules for the company schema (13-data-model-v1 §23.4 item 6): table names, field names
|
|
3
|
+
* (session fields included) and relation names. A name ends up as a path segment (`table.field`,
|
|
4
|
+
* `injury#1.severity`), an object key at runtime and a property in generated TypeScript, so it is
|
|
5
|
+
* kept to what is safe in all three.
|
|
6
|
+
*/
|
|
7
|
+
/** Postgres's identifier limit: a field can become a real column without a rename. */
|
|
8
|
+
export declare const NAME_MAX_LENGTH = 63;
|
|
9
|
+
export type NameProblem = {
|
|
10
|
+
code: 'invalid-name' | 'reserved-name';
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
/** Why `name` cannot name a table, field or relation; null when it can. */
|
|
14
|
+
export declare function nameProblem(name: string): NameProblem | null;
|
|
15
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming rules for the company schema (13-data-model-v1 §23.4 item 6): table names, field names
|
|
3
|
+
* (session fields included) and relation names. A name ends up as a path segment (`table.field`,
|
|
4
|
+
* `injury#1.severity`), an object key at runtime and a property in generated TypeScript, so it is
|
|
5
|
+
* kept to what is safe in all three.
|
|
6
|
+
*/
|
|
7
|
+
/** Lowercase letters, digits and `_`, starting with a letter: never `.`, `-`, `#`, `*`, `$` or a space. */
|
|
8
|
+
const NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
9
|
+
/** Postgres's identifier limit: a field can become a real column without a rename. */
|
|
10
|
+
export const NAME_MAX_LENGTH = 63;
|
|
11
|
+
/**
|
|
12
|
+
* JavaScript's reserved words. A row's `case` still works as `row.case`, but `const { case } = row`
|
|
13
|
+
* does not parse; a schema is written by an AI, so another name costs nothing.
|
|
14
|
+
*/
|
|
15
|
+
const JS_RESERVED_WORDS = new Set([
|
|
16
|
+
'await',
|
|
17
|
+
'break',
|
|
18
|
+
'case',
|
|
19
|
+
'catch',
|
|
20
|
+
'class',
|
|
21
|
+
'const',
|
|
22
|
+
'continue',
|
|
23
|
+
'debugger',
|
|
24
|
+
'default',
|
|
25
|
+
'delete',
|
|
26
|
+
'do',
|
|
27
|
+
'else',
|
|
28
|
+
'enum',
|
|
29
|
+
'export',
|
|
30
|
+
'extends',
|
|
31
|
+
'false',
|
|
32
|
+
'finally',
|
|
33
|
+
'for',
|
|
34
|
+
'function',
|
|
35
|
+
'if',
|
|
36
|
+
'implements',
|
|
37
|
+
'import',
|
|
38
|
+
'in',
|
|
39
|
+
'instanceof',
|
|
40
|
+
'interface',
|
|
41
|
+
'let',
|
|
42
|
+
'new',
|
|
43
|
+
'null',
|
|
44
|
+
'package',
|
|
45
|
+
'private',
|
|
46
|
+
'protected',
|
|
47
|
+
'public',
|
|
48
|
+
'return',
|
|
49
|
+
'static',
|
|
50
|
+
'super',
|
|
51
|
+
'switch',
|
|
52
|
+
'this',
|
|
53
|
+
'throw',
|
|
54
|
+
'true',
|
|
55
|
+
'try',
|
|
56
|
+
'typeof',
|
|
57
|
+
'var',
|
|
58
|
+
'void',
|
|
59
|
+
'while',
|
|
60
|
+
'with',
|
|
61
|
+
'yield',
|
|
62
|
+
]);
|
|
63
|
+
/**
|
|
64
|
+
* Properties every object has. A table or field by one of these names is found on the prototype by a
|
|
65
|
+
* plain lookup (`tables[name]`) when it is not there, or replaces it when it is.
|
|
66
|
+
*/
|
|
67
|
+
const OBJECT_PROPERTY_NAMES = new Set([
|
|
68
|
+
'constructor',
|
|
69
|
+
'hasOwnProperty',
|
|
70
|
+
'isPrototypeOf',
|
|
71
|
+
'propertyIsEnumerable',
|
|
72
|
+
'prototype',
|
|
73
|
+
'toLocaleString',
|
|
74
|
+
'toString',
|
|
75
|
+
'valueOf',
|
|
76
|
+
'__proto__',
|
|
77
|
+
'__defineGetter__',
|
|
78
|
+
'__defineSetter__',
|
|
79
|
+
'__lookupGetter__',
|
|
80
|
+
'__lookupSetter__',
|
|
81
|
+
]);
|
|
82
|
+
/** Why `name` cannot name a table, field or relation; null when it can. */
|
|
83
|
+
export function nameProblem(name) {
|
|
84
|
+
if (!NAME_PATTERN.test(name)) {
|
|
85
|
+
return { code: 'invalid-name', reason: 'use lowercase letters, digits and _, starting with a letter' };
|
|
86
|
+
}
|
|
87
|
+
if (name.length > NAME_MAX_LENGTH) {
|
|
88
|
+
return { code: 'invalid-name', reason: `at most ${NAME_MAX_LENGTH} characters` };
|
|
89
|
+
}
|
|
90
|
+
if (JS_RESERVED_WORDS.has(name))
|
|
91
|
+
return { code: 'reserved-name', reason: 'a JavaScript reserved word' };
|
|
92
|
+
if (OBJECT_PROPERTY_NAMES.has(name))
|
|
93
|
+
return { code: 'reserved-name', reason: 'a property every object has' };
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contact table's platform fields. The company schema spreads them into `contact` and the runtime
|
|
3
|
+
* checks them against these definitions, so a field added here reaches every company without editing
|
|
4
|
+
* its schema. Every sequence carries them and none may override them. Before adding one, check no
|
|
5
|
+
* company's live schema has a field of that name (14 §5.3).
|
|
6
|
+
*/
|
|
7
|
+
export declare const PLATFORM_CONTACT_FIELDS: {
|
|
8
|
+
readonly kind: {
|
|
9
|
+
readonly label: 'Kind';
|
|
10
|
+
readonly dataType: 'select';
|
|
11
|
+
readonly extraction: 'Whether the contact is a person or an organization';
|
|
12
|
+
readonly options: ["person", "organization"];
|
|
13
|
+
};
|
|
14
|
+
readonly phone: {
|
|
15
|
+
readonly label: 'Phone';
|
|
16
|
+
readonly dataType: 'phone';
|
|
17
|
+
readonly extraction: "The contact's main phone number, the one to call back; only when they give one.";
|
|
18
|
+
};
|
|
19
|
+
readonly email: {
|
|
20
|
+
readonly label: 'Email';
|
|
21
|
+
readonly dataType: 'email';
|
|
22
|
+
readonly extraction: "The contact's main email address; only when they give one.";
|
|
23
|
+
};
|
|
24
|
+
readonly first_name: {
|
|
25
|
+
readonly label: 'First name';
|
|
26
|
+
readonly dataType: 'string';
|
|
27
|
+
readonly extraction: "The contact's first (given) name. They may spell it; keep their spelling.";
|
|
28
|
+
};
|
|
29
|
+
readonly last_name: {
|
|
30
|
+
readonly label: 'Last name';
|
|
31
|
+
readonly dataType: 'string';
|
|
32
|
+
readonly extraction: "The contact's last (family) name. They may spell it; keep their spelling.";
|
|
33
|
+
};
|
|
34
|
+
readonly street: {
|
|
35
|
+
readonly label: 'Street address';
|
|
36
|
+
readonly dataType: 'string';
|
|
37
|
+
readonly extraction: 'The street line of the contact\'s home or mailing address: number and street, with the unit or apartment (e.g. "1450 NE 2nd Ave, Apt 7"). Not the city, state or postal code.';
|
|
38
|
+
};
|
|
39
|
+
readonly city: {
|
|
40
|
+
readonly label: 'City';
|
|
41
|
+
readonly dataType: 'string';
|
|
42
|
+
readonly extraction: "The city of the contact's home or mailing address.";
|
|
43
|
+
};
|
|
44
|
+
readonly state: {
|
|
45
|
+
readonly label: 'State or province';
|
|
46
|
+
readonly dataType: 'select';
|
|
47
|
+
readonly extraction: "The two-letter code (FL, TX, ON) of the state or province they live in; from a city only when it is unambiguous.";
|
|
48
|
+
readonly options: ("AB" | "AK" | "AL" | "AR" | "AS" | "AZ" | "BC" | "CA" | "CO" | "CT" | "DC" | "DE" | "FL" | "GA" | "GU" | "HI" | "IA" | "ID" | "IL" | "IN" | "KS" | "KY" | "LA" | "MA" | "MB" | "MD" | "ME" | "MI" | "MN" | "MO" | "MP" | "MS" | "MT" | "NB" | "NC" | "ND" | "NE" | "NH" | "NJ" | "NL" | "NM" | "NS" | "NT" | "NU" | "NV" | "NY" | "OH" | "OK" | "ON" | "OR" | "PA" | "PE" | "PR" | "QC" | "RI" | "SC" | "SD" | "SK" | "TN" | "TX" | "UT" | "VA" | "VI" | "VT" | "WA" | "WI" | "WV" | "WY" | "YT")[];
|
|
49
|
+
};
|
|
50
|
+
readonly postal_code: {
|
|
51
|
+
readonly label: 'Postal code';
|
|
52
|
+
readonly dataType: 'string';
|
|
53
|
+
readonly extraction: "The ZIP code (5 digits, or ZIP+4) or Canadian postal code of the contact's home or mailing address.";
|
|
54
|
+
};
|
|
55
|
+
readonly country: {
|
|
56
|
+
readonly label: 'Country';
|
|
57
|
+
readonly dataType: 'string';
|
|
58
|
+
readonly extraction: 'ISO two-letter code (US, CA); only when they say they live outside the US.';
|
|
59
|
+
};
|
|
60
|
+
readonly timezone: {
|
|
61
|
+
readonly label: 'Timezone';
|
|
62
|
+
readonly dataType: 'string';
|
|
63
|
+
readonly extraction: 'An IANA timezone, only when they state one or a place that fixes one; never from a phone number.';
|
|
64
|
+
};
|
|
65
|
+
readonly language: {
|
|
66
|
+
readonly label: 'Language';
|
|
67
|
+
readonly dataType: 'select';
|
|
68
|
+
readonly extraction: 'The language they speak with us, when they speak or ask for one of these; the platform then speaks it.';
|
|
69
|
+
readonly options: ["english", "spanish"];
|
|
70
|
+
};
|
|
71
|
+
readonly opted_out: {
|
|
72
|
+
readonly label: 'Opted out';
|
|
73
|
+
readonly dataType: 'boolean';
|
|
74
|
+
readonly extraction: 'true when they clearly ask us to stop contacting them at all; false only when they agree to be contacted again. Not for one channel.';
|
|
75
|
+
};
|
|
76
|
+
readonly call_opted_out: {
|
|
77
|
+
readonly label: 'Call opted out';
|
|
78
|
+
readonly dataType: 'boolean';
|
|
79
|
+
readonly extraction: 'true when they clearly ask not to be called; false only when they agree to calls again.';
|
|
80
|
+
};
|
|
81
|
+
readonly sms_opted_out: {
|
|
82
|
+
readonly label: 'SMS opted out';
|
|
83
|
+
readonly dataType: 'boolean';
|
|
84
|
+
readonly extraction: 'true when they clearly ask not to be texted; false only when they agree to texts again.';
|
|
85
|
+
};
|
|
86
|
+
readonly email_opted_out: {
|
|
87
|
+
readonly label: 'Email opted out';
|
|
88
|
+
readonly dataType: 'boolean';
|
|
89
|
+
readonly extraction: 'true when they clearly ask not to be emailed; false only when they agree to emails again.';
|
|
90
|
+
};
|
|
91
|
+
readonly contact_schedule: {
|
|
92
|
+
readonly label: 'Contact schedule';
|
|
93
|
+
readonly dataType: 'contact_schedule';
|
|
94
|
+
readonly extraction: 'When they may be contacted, only when they say: the whole schedule with their change applied. Relative dates from today in their timezone; split overnight windows; do not guess an unclear time.';
|
|
95
|
+
};
|
|
96
|
+
readonly assigned_phone_number: {
|
|
97
|
+
readonly label: 'Assigned phone number';
|
|
98
|
+
readonly dataType: 'phone';
|
|
99
|
+
readonly extraction: 'Our phone number (E.164) this contact is reached from; set by the platform';
|
|
100
|
+
};
|
|
101
|
+
readonly assigned_mailbox: {
|
|
102
|
+
readonly label: 'Assigned mailbox';
|
|
103
|
+
readonly dataType: 'email';
|
|
104
|
+
readonly extraction: 'Our mailbox address this contact is emailed from; set by the platform';
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* The session's platform fields (24 §5.2): `schema/session.ts` spreads them into its fields, checked
|
|
109
|
+
* like the contact's. `stuck`: the AI marked the call stuck (its `stuck` action); the page reads it,
|
|
110
|
+
* decides what to do, and clears it.
|
|
111
|
+
*/
|
|
112
|
+
export declare const PLATFORM_SESSION_FIELDS: {
|
|
113
|
+
readonly stuck: {
|
|
114
|
+
readonly label: 'Stuck';
|
|
115
|
+
readonly dataType: 'boolean';
|
|
116
|
+
readonly extraction: 'Set by the platform when the AI marks the conversation stuck; the page clears it once handled.';
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=platform-fields.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { SPOKEN_LANGUAGES } from '../conversation/index.js';
|
|
2
|
+
import { STATE_CODES } from './contact-timezone.js';
|
|
3
|
+
/**
|
|
4
|
+
* The contact table's platform fields. The company schema spreads them into `contact` and the runtime
|
|
5
|
+
* checks them against these definitions, so a field added here reaches every company without editing
|
|
6
|
+
* its schema. Every sequence carries them and none may override them. Before adding one, check no
|
|
7
|
+
* company's live schema has a field of that name (14 §5.3).
|
|
8
|
+
*/
|
|
9
|
+
export const PLATFORM_CONTACT_FIELDS = {
|
|
10
|
+
kind: {
|
|
11
|
+
label: 'Kind',
|
|
12
|
+
dataType: 'select',
|
|
13
|
+
extraction: 'Whether the contact is a person or an organization',
|
|
14
|
+
options: ['person', 'organization'],
|
|
15
|
+
},
|
|
16
|
+
phone: {
|
|
17
|
+
label: 'Phone',
|
|
18
|
+
dataType: 'phone',
|
|
19
|
+
extraction: "The contact's main phone number, the one to call back; only when they give one.",
|
|
20
|
+
},
|
|
21
|
+
email: {
|
|
22
|
+
label: 'Email',
|
|
23
|
+
dataType: 'email',
|
|
24
|
+
extraction: "The contact's main email address; only when they give one.",
|
|
25
|
+
},
|
|
26
|
+
first_name: {
|
|
27
|
+
label: 'First name',
|
|
28
|
+
dataType: 'string',
|
|
29
|
+
extraction: "The contact's first (given) name. They may spell it; keep their spelling.",
|
|
30
|
+
},
|
|
31
|
+
last_name: {
|
|
32
|
+
label: 'Last name',
|
|
33
|
+
dataType: 'string',
|
|
34
|
+
extraction: "The contact's last (family) name. They may spell it; keep their spelling.",
|
|
35
|
+
},
|
|
36
|
+
street: {
|
|
37
|
+
label: 'Street address',
|
|
38
|
+
dataType: 'string',
|
|
39
|
+
extraction: 'The street line of the contact\'s home or mailing address: number and street, with the unit or apartment (e.g. "1450 NE 2nd Ave, Apt 7"). Not the city, state or postal code.',
|
|
40
|
+
},
|
|
41
|
+
city: {
|
|
42
|
+
label: 'City',
|
|
43
|
+
dataType: 'string',
|
|
44
|
+
extraction: "The city of the contact's home or mailing address.",
|
|
45
|
+
},
|
|
46
|
+
state: {
|
|
47
|
+
label: 'State or province',
|
|
48
|
+
dataType: 'select',
|
|
49
|
+
extraction: "The two-letter code (FL, TX, ON) of the state or province they live in; from a city only when it is unambiguous.",
|
|
50
|
+
options: [...STATE_CODES],
|
|
51
|
+
},
|
|
52
|
+
postal_code: {
|
|
53
|
+
label: 'Postal code',
|
|
54
|
+
dataType: 'string',
|
|
55
|
+
extraction: "The ZIP code (5 digits, or ZIP+4) or Canadian postal code of the contact's home or mailing address.",
|
|
56
|
+
},
|
|
57
|
+
country: {
|
|
58
|
+
label: 'Country',
|
|
59
|
+
dataType: 'string',
|
|
60
|
+
extraction: 'ISO two-letter code (US, CA); only when they say they live outside the US.',
|
|
61
|
+
},
|
|
62
|
+
timezone: {
|
|
63
|
+
label: 'Timezone',
|
|
64
|
+
dataType: 'string',
|
|
65
|
+
extraction: 'An IANA timezone, only when they state one or a place that fixes one; never from a phone number.',
|
|
66
|
+
},
|
|
67
|
+
language: {
|
|
68
|
+
label: 'Language',
|
|
69
|
+
dataType: 'select',
|
|
70
|
+
extraction: 'The language they speak with us, when they speak or ask for one of these; the platform then speaks it.',
|
|
71
|
+
options: [...SPOKEN_LANGUAGES],
|
|
72
|
+
},
|
|
73
|
+
opted_out: {
|
|
74
|
+
label: 'Opted out',
|
|
75
|
+
dataType: 'boolean',
|
|
76
|
+
extraction: 'true when they clearly ask us to stop contacting them at all; false only when they agree to be contacted again. Not for one channel.',
|
|
77
|
+
},
|
|
78
|
+
call_opted_out: {
|
|
79
|
+
label: 'Call opted out',
|
|
80
|
+
dataType: 'boolean',
|
|
81
|
+
extraction: 'true when they clearly ask not to be called; false only when they agree to calls again.',
|
|
82
|
+
},
|
|
83
|
+
sms_opted_out: {
|
|
84
|
+
label: 'SMS opted out',
|
|
85
|
+
dataType: 'boolean',
|
|
86
|
+
extraction: 'true when they clearly ask not to be texted; false only when they agree to texts again.',
|
|
87
|
+
},
|
|
88
|
+
email_opted_out: {
|
|
89
|
+
label: 'Email opted out',
|
|
90
|
+
dataType: 'boolean',
|
|
91
|
+
extraction: 'true when they clearly ask not to be emailed; false only when they agree to emails again.',
|
|
92
|
+
},
|
|
93
|
+
contact_schedule: {
|
|
94
|
+
label: 'Contact schedule',
|
|
95
|
+
dataType: 'contact_schedule',
|
|
96
|
+
extraction: 'When they may be contacted, only when they say: the whole schedule with their change applied. Relative dates from today in their timezone; split overnight windows; do not guess an unclear time.',
|
|
97
|
+
},
|
|
98
|
+
assigned_phone_number: {
|
|
99
|
+
label: 'Assigned phone number',
|
|
100
|
+
dataType: 'phone',
|
|
101
|
+
extraction: 'Our phone number (E.164) this contact is reached from; set by the platform',
|
|
102
|
+
},
|
|
103
|
+
assigned_mailbox: {
|
|
104
|
+
label: 'Assigned mailbox',
|
|
105
|
+
dataType: 'email',
|
|
106
|
+
extraction: 'Our mailbox address this contact is emailed from; set by the platform',
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The session's platform fields (24 §5.2): `schema/session.ts` spreads them into its fields, checked
|
|
111
|
+
* like the contact's. `stuck`: the AI marked the call stuck (its `stuck` action); the page reads it,
|
|
112
|
+
* decides what to do, and clears it.
|
|
113
|
+
*/
|
|
114
|
+
export const PLATFORM_SESSION_FIELDS = {
|
|
115
|
+
stuck: {
|
|
116
|
+
label: 'Stuck',
|
|
117
|
+
dataType: 'boolean',
|
|
118
|
+
extraction: 'Set by the platform when the AI marks the conversation stuck; the page clears it once handled.',
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=platform-fields.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ref fields (`ref: { table }`): a field whose value is another row's id (13-data-model-v1 §10.6).
|
|
3
|
+
* Writes check the value is a uuid here; whether the target row exists is checked where the ref is
|
|
4
|
+
* stored (services `syncLookupRefs`), which sees every write path and the database.
|
|
5
|
+
*/
|
|
6
|
+
import type { TableRef } from './schema.js';
|
|
7
|
+
import type { RuntimeFieldDef, ValidationIssue } from './types.js';
|
|
8
|
+
/** `parent`: the row's owner (`case_file`); `lookup`: any other ref (13-data-model-v1 §11.2). */
|
|
9
|
+
export type RefKind = 'parent' | 'lookup';
|
|
10
|
+
/** The kind a ref field declares (`ref.kind`); a field without a ref is not a ref. */
|
|
11
|
+
export declare function refKind(field: {
|
|
12
|
+
ref?: TableRef | null;
|
|
13
|
+
}): RefKind | null;
|
|
14
|
+
/** A ref value must be a row id; anything else can never resolve. */
|
|
15
|
+
export declare function refValueIssues(field: RuntimeFieldDef, value: unknown, path: string): ValidationIssue[];
|
|
16
|
+
//# sourceMappingURL=ref.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
2
|
+
/** The kind a ref field declares (`ref.kind`); a field without a ref is not a ref. */
|
|
3
|
+
export function refKind(field) {
|
|
4
|
+
return field.ref?.kind ?? null;
|
|
5
|
+
}
|
|
6
|
+
/** A ref value must be a row id; anything else can never resolve. */
|
|
7
|
+
export function refValueIssues(field, value, path) {
|
|
8
|
+
if (!field.ref || value === null || value === undefined)
|
|
9
|
+
return [];
|
|
10
|
+
if (typeof value === 'string' && UUID.test(value))
|
|
11
|
+
return [];
|
|
12
|
+
return [{ code: 'ref-not-uuid', message: `${path} must be a ${field.ref.table} row id`, path }];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ref.js.map
|
package/dist/core/slot/row.d.ts
CHANGED
|
@@ -4,19 +4,12 @@ export type SlotRow = SingleRowTableData | MultiRowRecord;
|
|
|
4
4
|
/** Reserved snapshot key; cannot be a company / sequence table name. */
|
|
5
5
|
export declare const SNAPSHOT_CURRENT_KEY = "current";
|
|
6
6
|
export declare function isReservedTableName(tableName: string): boolean;
|
|
7
|
-
|
|
7
|
+
export declare function hasBoundRow(tableName: string): boolean;
|
|
8
|
+
/** App-minted row id for multi-row tables (the Record's id). */
|
|
8
9
|
export declare function mintRowId(): string;
|
|
9
10
|
export declare function isRowIdField(name: string): name is typeof ROW_ID_FIELD;
|
|
10
11
|
export declare function isFieldValue(value: unknown): value is FieldValue;
|
|
11
|
-
export declare function getRowField(row: SlotRow, fieldName: string): FieldValue | undefined;
|
|
12
12
|
/** Schema fields that store envelopes — excludes row `id`. */
|
|
13
13
|
export declare function slotFieldEntries<T>(fields: Record<string, T>): Array<[string, T]>;
|
|
14
14
|
export declare function slotFieldNames(fields: Record<string, unknown>): string[];
|
|
15
|
-
/** Envelope cells on a runtime row — excludes `id`. */
|
|
16
|
-
export declare function rowValueEntries(row: SlotRow): Array<[string, FieldValue]>;
|
|
17
|
-
export declare function emptySlotRow(fields: Record<string, unknown>, options?: {
|
|
18
|
-
id?: string;
|
|
19
|
-
now?: number;
|
|
20
|
-
}): SingleRowTableData;
|
|
21
|
-
export declare function emptyMultiRow(fields: Record<string, unknown>, id: string, now?: number): MultiRowRecord;
|
|
22
15
|
//# sourceMappingURL=row.d.ts.map
|