@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
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import { getCompiledTable } from '../slot/compile-schema.js';
|
|
2
|
-
import { parseFieldPath } from '../slot/path.js';
|
|
3
|
-
import { extractTemplateFields } from './condition.js';
|
|
4
|
-
import { whenFields } from './finish-when.js';
|
|
5
|
-
import { headerHasTransferInterrupt, validateInterrupts } from './interrupts.js';
|
|
6
|
-
import { LAST_TRANSFER_RESULT_FIELD } from './transfer-fields.js';
|
|
7
|
-
import { validateTransferDestinations } from './transfer-spec.js';
|
|
8
|
-
function fieldExists(schema, path) {
|
|
9
|
-
const parsed = parseFieldPath(path);
|
|
10
|
-
if (!parsed)
|
|
11
|
-
return false;
|
|
12
|
-
return getCompiledTable(schema, parsed.table)?.fields[parsed.field] != null;
|
|
13
|
-
}
|
|
14
|
-
function requireFields(schema, fields, issues, path, code = 'unknown-field') {
|
|
15
|
-
for (const field of fields) {
|
|
16
|
-
if (!parseFieldPath(field)) {
|
|
17
|
-
issues.push({ code: 'invalid-field-path', message: `Invalid field path: ${field}`, path: `${path}:${field}` });
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (!fieldExists(schema, field)) {
|
|
21
|
-
issues.push({ code, message: `Unknown field: ${field}`, path: `${path}:${field}` });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function earlierCollected(items, index) {
|
|
26
|
-
const collected = new Set();
|
|
27
|
-
for (let i = 0; i < index; i++) {
|
|
28
|
-
const item = items[i];
|
|
29
|
-
if (item.kind === 'topic') {
|
|
30
|
-
for (const field of item.fields)
|
|
31
|
-
collected.add(field);
|
|
32
|
-
}
|
|
33
|
-
if (item.kind === 'ivr') {
|
|
34
|
-
for (const field of whenFields(item.finishWhen))
|
|
35
|
-
collected.add(field);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return collected;
|
|
39
|
-
}
|
|
40
|
-
function transferIndexByResultField(items) {
|
|
41
|
-
const map = new Map();
|
|
42
|
-
items.forEach((item, index) => {
|
|
43
|
-
if (item.kind === 'transfer') {
|
|
44
|
-
map.set(item.resultField, index);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return map;
|
|
48
|
-
}
|
|
49
|
-
function listedCustomFunctions(functions) {
|
|
50
|
-
const names = Object.entries(functions)
|
|
51
|
-
.filter(([, def]) => def.kind === 'custom')
|
|
52
|
-
.map(([name]) => name)
|
|
53
|
-
.sort((a, b) => a.localeCompare(b));
|
|
54
|
-
return names.length > 0 ? names.join(', ') : 'none';
|
|
55
|
-
}
|
|
56
|
-
function requireBoolWhen(when, functions, issues, path, label) {
|
|
57
|
-
if (when.kind === 'fn') {
|
|
58
|
-
const def = functions?.[when.fn];
|
|
59
|
-
if (functions && !def) {
|
|
60
|
-
issues.push({ code: 'unknown-function', message: `${label} fn not found: ${when.fn}`, path });
|
|
61
|
-
}
|
|
62
|
-
else if (def && def.kind !== 'boolCompute') {
|
|
63
|
-
issues.push({
|
|
64
|
-
code: label === 'applyWhen' ? 'apply-when-not-bool' : 'finish-when-not-bool',
|
|
65
|
-
message: `${label} fn '${when.fn}' must be defineBoolComputeFunc`,
|
|
66
|
-
path,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function firstTransferIndex(items) {
|
|
73
|
-
return items.findIndex((item) => item.kind === 'transfer');
|
|
74
|
-
}
|
|
75
|
-
export function validateCompiledAgenda(compiled, options) {
|
|
76
|
-
const issues = [];
|
|
77
|
-
const { schema, functions } = options;
|
|
78
|
-
const prefix = options.agendaId ?? 'agenda';
|
|
79
|
-
const items = compiled.flat;
|
|
80
|
-
const seenPlacement = new Set();
|
|
81
|
-
const transferByResult = transferIndexByResultField(items);
|
|
82
|
-
const firstTransfer = firstTransferIndex(items);
|
|
83
|
-
const transferInterrupt = headerHasTransferInterrupt(compiled.header);
|
|
84
|
-
if (compiled.header) {
|
|
85
|
-
issues.push(...validateInterrupts(compiled.header.interrupts, {
|
|
86
|
-
schema,
|
|
87
|
-
agendaId: prefix,
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
if (compiled.header?.channel && compiled.header.channel !== 'call') {
|
|
91
|
-
for (const item of items) {
|
|
92
|
-
if (item.kind === 'transfer') {
|
|
93
|
-
issues.push({
|
|
94
|
-
code: 'transfer-channel',
|
|
95
|
-
message: `Transfer ${item.id} is only valid on call agendas`,
|
|
96
|
-
path: `${prefix}/${item.placementId}`,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
if (item.kind === 'ivr') {
|
|
100
|
-
issues.push({
|
|
101
|
-
code: 'ivr-channel',
|
|
102
|
-
message: `IVR ${item.id} is only valid on call agendas`,
|
|
103
|
-
path: `${prefix}/${item.placementId}`,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (compiled.header?.firstMessage?.kind === 'template') {
|
|
109
|
-
requireFields(schema, extractTemplateFields(compiled.header.firstMessage.text), issues, `${prefix}/header/firstMessage`);
|
|
110
|
-
}
|
|
111
|
-
if (compiled.header?.firstMessage?.kind === 'fn') {
|
|
112
|
-
const name = compiled.header.firstMessage.fn;
|
|
113
|
-
const def = functions?.[name];
|
|
114
|
-
if (functions && !def) {
|
|
115
|
-
issues.push({
|
|
116
|
-
code: 'unknown-function',
|
|
117
|
-
message: `firstMessage fn not found: ${name}`,
|
|
118
|
-
path: `${prefix}/header/firstMessage`,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
else if (def && def.kind !== 'system') {
|
|
122
|
-
issues.push({
|
|
123
|
-
code: 'invalid-function-kind',
|
|
124
|
-
message: `firstMessage fn must be a system function: ${name}`,
|
|
125
|
-
path: `${prefix}/header/firstMessage`,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
for (let index = 0; index < items.length; index++) {
|
|
130
|
-
const item = items[index];
|
|
131
|
-
const path = `${prefix}/${item.placementId}`;
|
|
132
|
-
if (seenPlacement.has(item.placementId)) {
|
|
133
|
-
issues.push({ code: 'duplicate-placement', message: `Duplicate placementId: ${item.placementId}`, path });
|
|
134
|
-
}
|
|
135
|
-
seenPlacement.add(item.placementId);
|
|
136
|
-
requireFields(schema, whenFields(item.applyWhen), issues, `${path}/applyWhen`);
|
|
137
|
-
const collected = earlierCollected(items, index);
|
|
138
|
-
for (const field of whenFields(item.applyWhen)) {
|
|
139
|
-
if (field.startsWith('session.transfer_') && field.endsWith('_result')) {
|
|
140
|
-
const writer = transferByResult.get(field);
|
|
141
|
-
if (writer == null || writer >= index) {
|
|
142
|
-
issues.push({
|
|
143
|
-
code: 'transfer-result-before-node',
|
|
144
|
-
message: `applyWhen reads ${field} before the transfer node`,
|
|
145
|
-
path: `${path}/applyWhen`,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (field === LAST_TRANSFER_RESULT_FIELD) {
|
|
151
|
-
if (!transferInterrupt && (firstTransfer < 0 || firstTransfer >= index)) {
|
|
152
|
-
issues.push({
|
|
153
|
-
code: 'transfer-result-before-node',
|
|
154
|
-
message: `applyWhen reads ${LAST_TRANSFER_RESULT_FIELD} before any transfer`,
|
|
155
|
-
path: `${path}/applyWhen`,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
const parsed = parseFieldPath(field);
|
|
161
|
-
const def = parsed ? getCompiledTable(schema, parsed.table)?.fields[parsed.field] : undefined;
|
|
162
|
-
if (def?.derived)
|
|
163
|
-
continue;
|
|
164
|
-
if (def && !def.derived && def.source === 'system')
|
|
165
|
-
continue;
|
|
166
|
-
if (!collected.has(field)) {
|
|
167
|
-
issues.push({
|
|
168
|
-
code: 'fork-field-not-collected',
|
|
169
|
-
message: `applyWhen field ${field} is not collected by an earlier topic`,
|
|
170
|
-
path: `${path}/applyWhen`,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
requireBoolWhen(item.applyWhen, functions, issues, `${path}/applyWhen`, 'applyWhen');
|
|
175
|
-
if (item.kind === 'ivr') {
|
|
176
|
-
requireBoolWhen(item.finishWhen, functions, issues, `${path}/finishWhen`, 'finishWhen');
|
|
177
|
-
if (item.finishWhen.kind === 'rules') {
|
|
178
|
-
requireFields(schema, whenFields(item.finishWhen), issues, `${path}/finishWhen`);
|
|
179
|
-
}
|
|
180
|
-
const run = functions?.[item.onDtmfResult];
|
|
181
|
-
if (functions && !run) {
|
|
182
|
-
issues.push({
|
|
183
|
-
code: 'unknown-function',
|
|
184
|
-
message: `IVR '${item.id}' onDtmfResult unknown function '${item.onDtmfResult}'. Custom functions: ${listedCustomFunctions(functions)}`,
|
|
185
|
-
path: `${path}/onDtmfResult`,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
else if (run && run.kind !== 'custom') {
|
|
189
|
-
issues.push({
|
|
190
|
-
code: 'ivr-run-not-custom',
|
|
191
|
-
message: `IVR '${item.id}' onDtmfResult '${item.onDtmfResult}' must be defineCustomFunc`,
|
|
192
|
-
path: `${path}/onDtmfResult`,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
if (!item.loopSay.trim()) {
|
|
196
|
-
issues.push({
|
|
197
|
-
code: 'ivr-say-empty',
|
|
198
|
-
message: 'ivr loopSay must not be empty',
|
|
199
|
-
path: `${path}/loopSay`,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
if (!(item.confirmTimeoutMs > 0) || !(item.pauseAfterSayMs >= 0)) {
|
|
203
|
-
issues.push({
|
|
204
|
-
code: 'ivr-timing',
|
|
205
|
-
message: 'ivr confirmTimeoutMs must be > 0 and pauseAfterSayMs must be >= 0',
|
|
206
|
-
path: `${path}/timing`,
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
if (item.fallbackAction !== 'end-call' && item.fallbackAction !== 'restore-normal-call-state') {
|
|
210
|
-
issues.push({
|
|
211
|
-
code: 'ivr-fallback',
|
|
212
|
-
message: 'ivr fallbackAction must be end-call or restore-normal-call-state',
|
|
213
|
-
path: `${path}/fallbackAction`,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
const digits = (item.validateDigits ?? []).map((digit) => digit.trim()).filter(Boolean);
|
|
217
|
-
if (!item.finishOnKey && digits.length === 0) {
|
|
218
|
-
issues.push({
|
|
219
|
-
code: 'ivr-digits-empty',
|
|
220
|
-
message: 'ivr needs validateDigits when finishOnKey is not set',
|
|
221
|
-
path: `${path}/validateDigits`,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
if (item.kind === 'topic') {
|
|
226
|
-
requireFields(schema, item.fields, issues, `${path}/fields`);
|
|
227
|
-
const referenced = whenFields(item.finishWhen);
|
|
228
|
-
requireFields(schema, referenced, issues, `${path}/finishWhen`);
|
|
229
|
-
requireBoolWhen(item.finishWhen, functions, issues, `${path}/finishWhen`, 'finishWhen');
|
|
230
|
-
if (item.finishWhen.kind !== 'fn') {
|
|
231
|
-
for (const field of referenced) {
|
|
232
|
-
if (!item.fields.includes(field)) {
|
|
233
|
-
issues.push({
|
|
234
|
-
code: 'finish-when-not-in-fields',
|
|
235
|
-
message: `finishWhen field ${field} is not in topic fields`,
|
|
236
|
-
path: `${path}/finishWhen`,
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (item.kind === 'action') {
|
|
243
|
-
requireBoolWhen(item.finishWhen, functions, issues, `${path}/finishWhen`, 'finishWhen');
|
|
244
|
-
if (item.finishWhen.kind === 'rules') {
|
|
245
|
-
requireFields(schema, whenFields(item.finishWhen), issues, `${path}/finishWhen`);
|
|
246
|
-
}
|
|
247
|
-
const run = functions?.[item.run];
|
|
248
|
-
if (functions && !run) {
|
|
249
|
-
issues.push({
|
|
250
|
-
code: 'unknown-function',
|
|
251
|
-
message: `Action '${item.id}' runs unknown function '${item.run}'. Custom functions: ${listedCustomFunctions(functions)}`,
|
|
252
|
-
path: `${path}/run`,
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
else if (run && run.kind !== 'custom') {
|
|
256
|
-
issues.push({
|
|
257
|
-
code: 'action-run-not-custom',
|
|
258
|
-
message: `Action '${item.id}' runs '${item.run}', which is ${run.kind}. Actions must use defineCustomFunc.`,
|
|
259
|
-
path: `${path}/run`,
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (item.kind === 'transfer') {
|
|
264
|
-
for (const number of item.numbers) {
|
|
265
|
-
requireFields(schema, extractTemplateFields(number), issues, `${path}/numbers`);
|
|
266
|
-
}
|
|
267
|
-
if (item.arguments) {
|
|
268
|
-
for (const key of ['sendDigits', 'sipUrl', 'sipUsername', 'sipPassword']) {
|
|
269
|
-
const text = item.arguments[key];
|
|
270
|
-
if (text) {
|
|
271
|
-
requireFields(schema, extractTemplateFields(text), issues, `${path}/arguments/${key}`);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (typeof item.say === 'string') {
|
|
276
|
-
requireFields(schema, extractTemplateFields(item.say), issues, `${path}/say`);
|
|
277
|
-
}
|
|
278
|
-
else if (item.say) {
|
|
279
|
-
for (const text of Object.values(item.say)) {
|
|
280
|
-
requireFields(schema, extractTemplateFields(text), issues, `${path}/say`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
issues.push(...validateTransferDestinations(item.numbers, {
|
|
284
|
-
path: `${path}/numbers`,
|
|
285
|
-
code: 'transfer-target',
|
|
286
|
-
}));
|
|
287
|
-
requireFields(schema, [item.resultField, LAST_TRANSFER_RESULT_FIELD], issues, `${path}/result`);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return issues.length === 0 ? { ok: true } : { ok: false, issues };
|
|
291
|
-
}
|
|
292
|
-
const FATAL_AGENDA_CODES = new Set([
|
|
293
|
-
'unknown-block',
|
|
294
|
-
'unknown-field',
|
|
295
|
-
'invalid-field-path',
|
|
296
|
-
'invalid-finish-when',
|
|
297
|
-
'unknown-function',
|
|
298
|
-
'finish-when-not-bool',
|
|
299
|
-
'apply-when-not-bool',
|
|
300
|
-
'invalid-apply-when',
|
|
301
|
-
'finish-when-not-in-fields',
|
|
302
|
-
'fork-field-not-collected',
|
|
303
|
-
'otherwise-not-unique',
|
|
304
|
-
'otherwise-not-last',
|
|
305
|
-
'branch-no-explicit',
|
|
306
|
-
'otherwise-unexpanded',
|
|
307
|
-
'transfer-channel',
|
|
308
|
-
'ivr-channel',
|
|
309
|
-
'ivr-run-not-custom',
|
|
310
|
-
'ivr-fallback',
|
|
311
|
-
'ivr-timing',
|
|
312
|
-
'ivr-say-empty',
|
|
313
|
-
'ivr-digits-empty',
|
|
314
|
-
'transfer-result-before-node',
|
|
315
|
-
'action-run-not-custom',
|
|
316
|
-
'duplicate-placement',
|
|
317
|
-
'block-kind-mismatch',
|
|
318
|
-
'interrupt-tool-reserved',
|
|
319
|
-
'interrupt-tool-duplicate',
|
|
320
|
-
'interrupt-priority-tie',
|
|
321
|
-
'interrupt-languages-empty',
|
|
322
|
-
'interrupt-language-field',
|
|
323
|
-
'interrupt-transfer-number',
|
|
324
|
-
'interrupt-escalation-criteria',
|
|
325
|
-
'transfer-target',
|
|
326
|
-
]);
|
|
327
|
-
export function fatalAgendaIssues(issues) {
|
|
328
|
-
return issues.filter((issue) => FATAL_AGENDA_CODES.has(issue.code));
|
|
329
|
-
}
|
|
330
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ComputeHost } from '../../compute-host/compute-host.js';
|
|
2
|
-
import type { FieldPath } from '../slot/path.js';
|
|
3
|
-
import type { RuntimeSlotsSnapshot } from '../slot/types.js';
|
|
4
|
-
import type { FlatAgendaItem } from './types.js';
|
|
5
|
-
export type WalkSkipReason = 'folded' | 'done' | 'skipped';
|
|
6
|
-
export type WalkSkip = {
|
|
7
|
-
placementId: string;
|
|
8
|
-
blockId: string;
|
|
9
|
-
reason: WalkSkipReason;
|
|
10
|
-
};
|
|
11
|
-
export type WalkHitReason = 'sticky' | 'scan';
|
|
12
|
-
export type WalkStats = {
|
|
13
|
-
durationMs: number;
|
|
14
|
-
evals: number;
|
|
15
|
-
};
|
|
16
|
-
export type WalkResult = {
|
|
17
|
-
hit: FlatAgendaItem | null;
|
|
18
|
-
reason: WalkHitReason | 'complete';
|
|
19
|
-
skipped: WalkSkip[];
|
|
20
|
-
decisions: WalkDecision[];
|
|
21
|
-
stats: WalkStats;
|
|
22
|
-
};
|
|
23
|
-
export type WalkDecision = {
|
|
24
|
-
placementId: string;
|
|
25
|
-
blockId: string;
|
|
26
|
-
status: 'folded' | 'done' | 'hit' | 'skipped';
|
|
27
|
-
via: WalkHitReason;
|
|
28
|
-
applyWhen: boolean | null;
|
|
29
|
-
finishWhen: boolean | null;
|
|
30
|
-
};
|
|
31
|
-
export type WalkOptions = {
|
|
32
|
-
currentPlacementId?: string | null;
|
|
33
|
-
/** This-tick skips (action returned null). */
|
|
34
|
-
skipPlacementIds?: ReadonlySet<string>;
|
|
35
|
-
compute?: ComputeHost;
|
|
36
|
-
};
|
|
37
|
-
export declare function walkAgenda(items: FlatAgendaItem[], snapshot: RuntimeSlotsSnapshot, options?: WalkOptions): Promise<WalkResult>;
|
|
38
|
-
export declare function unresolvedFinishWhenFields(item: FlatAgendaItem, snapshot: RuntimeSlotsSnapshot, compute?: ComputeHost): Promise<FieldPath[]>;
|
|
39
|
-
//# sourceMappingURL=walk.d.ts.map
|
package/dist/core/stage/walk.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { evaluateWhen } from './finish-when.js';
|
|
2
|
-
import { ivrAttempted } from './ivr-fields.js';
|
|
3
|
-
function startsWithGroup(groupPath, prefix) {
|
|
4
|
-
if (prefix.length === 0)
|
|
5
|
-
return true;
|
|
6
|
-
if (groupPath.length < prefix.length)
|
|
7
|
-
return false;
|
|
8
|
-
return prefix.every((id, i) => groupPath[i] === id);
|
|
9
|
-
}
|
|
10
|
-
async function consider(item, snapshot, compute, skip, via, skipped, decisions, stats) {
|
|
11
|
-
if (skip.has(item.placementId)) {
|
|
12
|
-
skipped.push({ placementId: item.placementId, blockId: item.id, reason: 'skipped' });
|
|
13
|
-
decisions.push({
|
|
14
|
-
placementId: item.placementId,
|
|
15
|
-
blockId: item.id,
|
|
16
|
-
status: 'skipped',
|
|
17
|
-
via,
|
|
18
|
-
applyWhen: null,
|
|
19
|
-
finishWhen: null,
|
|
20
|
-
});
|
|
21
|
-
return 'skip';
|
|
22
|
-
}
|
|
23
|
-
stats.evals += 1;
|
|
24
|
-
const applies = await evaluateWhen(item.applyWhen, snapshot, compute);
|
|
25
|
-
if (!applies.pass) {
|
|
26
|
-
skipped.push({ placementId: item.placementId, blockId: item.id, reason: 'folded' });
|
|
27
|
-
decisions.push({
|
|
28
|
-
placementId: item.placementId,
|
|
29
|
-
blockId: item.id,
|
|
30
|
-
status: 'folded',
|
|
31
|
-
via,
|
|
32
|
-
applyWhen: false,
|
|
33
|
-
finishWhen: null,
|
|
34
|
-
});
|
|
35
|
-
return 'fold';
|
|
36
|
-
}
|
|
37
|
-
if (item.kind === 'ivr' && ivrAttempted(item, snapshot)) {
|
|
38
|
-
skipped.push({ placementId: item.placementId, blockId: item.id, reason: 'done' });
|
|
39
|
-
decisions.push({
|
|
40
|
-
placementId: item.placementId,
|
|
41
|
-
blockId: item.id,
|
|
42
|
-
status: 'done',
|
|
43
|
-
via,
|
|
44
|
-
applyWhen: true,
|
|
45
|
-
finishWhen: true,
|
|
46
|
-
});
|
|
47
|
-
return 'done';
|
|
48
|
-
}
|
|
49
|
-
stats.evals += 1;
|
|
50
|
-
const finished = await evaluateWhen(item.finishWhen, snapshot, compute);
|
|
51
|
-
if (finished.done) {
|
|
52
|
-
skipped.push({ placementId: item.placementId, blockId: item.id, reason: 'done' });
|
|
53
|
-
decisions.push({
|
|
54
|
-
placementId: item.placementId,
|
|
55
|
-
blockId: item.id,
|
|
56
|
-
status: 'done',
|
|
57
|
-
via,
|
|
58
|
-
applyWhen: true,
|
|
59
|
-
finishWhen: true,
|
|
60
|
-
});
|
|
61
|
-
return 'done';
|
|
62
|
-
}
|
|
63
|
-
decisions.push({
|
|
64
|
-
placementId: item.placementId,
|
|
65
|
-
blockId: item.id,
|
|
66
|
-
status: 'hit',
|
|
67
|
-
via,
|
|
68
|
-
applyWhen: true,
|
|
69
|
-
finishWhen: false,
|
|
70
|
-
});
|
|
71
|
-
return 'hit';
|
|
72
|
-
}
|
|
73
|
-
async function firstHit(items, snapshot, compute, skip, via, skipped, decisions, considered, stats) {
|
|
74
|
-
for (const item of items) {
|
|
75
|
-
if (considered.has(item.placementId))
|
|
76
|
-
continue;
|
|
77
|
-
considered.add(item.placementId);
|
|
78
|
-
if ((await consider(item, snapshot, compute, skip, via, skipped, decisions, stats)) === 'hit') {
|
|
79
|
-
return item;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
export async function walkAgenda(items, snapshot, options = {}) {
|
|
85
|
-
const started = Date.now();
|
|
86
|
-
const skip = options.skipPlacementIds ?? new Set();
|
|
87
|
-
const skipped = [];
|
|
88
|
-
const decisions = [];
|
|
89
|
-
const considered = new Set();
|
|
90
|
-
const stats = { evals: 0 };
|
|
91
|
-
const currentId = options.currentPlacementId ?? null;
|
|
92
|
-
const finish = (hit, reason) => ({
|
|
93
|
-
hit,
|
|
94
|
-
reason,
|
|
95
|
-
skipped,
|
|
96
|
-
decisions,
|
|
97
|
-
stats: { durationMs: Date.now() - started, evals: stats.evals },
|
|
98
|
-
});
|
|
99
|
-
if (currentId) {
|
|
100
|
-
const current = items.find((item) => item.placementId === currentId);
|
|
101
|
-
if (current && current.groupPath.length > 0) {
|
|
102
|
-
for (let depth = current.groupPath.length; depth >= 1; depth--) {
|
|
103
|
-
const prefix = current.groupPath.slice(0, depth);
|
|
104
|
-
const groupItems = items.filter((item) => startsWithGroup(item.groupPath, prefix));
|
|
105
|
-
const hit = await firstHit(groupItems, snapshot, options.compute, skip, 'sticky', skipped, decisions, considered, stats);
|
|
106
|
-
if (hit)
|
|
107
|
-
return finish(hit, 'sticky');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const hit = await firstHit(items, snapshot, options.compute, skip, 'scan', skipped, decisions, considered, stats);
|
|
112
|
-
if (hit)
|
|
113
|
-
return finish(hit, 'scan');
|
|
114
|
-
return finish(null, 'complete');
|
|
115
|
-
}
|
|
116
|
-
export async function unresolvedFinishWhenFields(item, snapshot, compute) {
|
|
117
|
-
return (await evaluateWhen(item.finishWhen, snapshot, compute)).failedFields;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=walk.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type BoundIntegrationMeta } from '../../../core/context/types.js';
|
|
2
|
-
import { type RpcContext } from '../trpc-init.js';
|
|
3
|
-
export type ListBindingsHandler = (opts: {
|
|
4
|
-
ctx: RpcContext;
|
|
5
|
-
}) => Promise<BoundIntegrationMeta[]>;
|
|
6
|
-
export declare function createListBindingsProcedure(handler: ListBindingsHandler): import("@trpc/server").TRPCQueryProcedure<{
|
|
7
|
-
input: void;
|
|
8
|
-
output: {
|
|
9
|
-
surfaceKey: "docusigns" | "envs" | "filevines" | "hubspots" | "twilios";
|
|
10
|
-
target: {
|
|
11
|
-
kind: "account" | "resource";
|
|
12
|
-
id: string;
|
|
13
|
-
};
|
|
14
|
-
name: string;
|
|
15
|
-
methods: string[];
|
|
16
|
-
credentials: Record<string, unknown>;
|
|
17
|
-
config: Record<string, unknown>;
|
|
18
|
-
}[];
|
|
19
|
-
meta: object;
|
|
20
|
-
}>;
|
|
21
|
-
//# sourceMappingURL=list-bindings.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `kind: 'system'` — `args[0]` is the params object (empty when omitted).
|
|
3
|
-
* Snapshot projection belongs to compute / custom / caseContextView, not here.
|
|
4
|
-
*/
|
|
5
|
-
export declare function resolveSystemFnParams(args: unknown[]): object;
|
|
6
|
-
//# sourceMappingURL=system-args.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `kind: 'system'` — `args[0]` is the params object (empty when omitted).
|
|
3
|
-
* Snapshot projection belongs to compute / custom / caseContextView, not here.
|
|
4
|
-
*/
|
|
5
|
-
export function resolveSystemFnParams(args) {
|
|
6
|
-
const raw = args[0];
|
|
7
|
-
if (raw == null)
|
|
8
|
-
return {};
|
|
9
|
-
if (typeof raw !== 'object' || Array.isArray(raw)) {
|
|
10
|
-
throw new Error('system function args[0] must be a params object');
|
|
11
|
-
}
|
|
12
|
-
return raw;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=system-args.js.map
|