@superpanel-sdk/runtime 0.2.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +410 -113
- 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 -2
- package/dist/compute-host/index.js +1 -1
- package/dist/compute-host/source-compute-host.d.ts +11 -9
- package/dist/compute-host/source-compute-host.js +50 -31
- 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 -30
- 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 -92
- 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 +89 -5
- 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 -2
- 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 -59
- package/dist/builder/merge.d.ts +0 -4
- package/dist/builder/merge.js +0 -19
- 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 -41
- package/dist/core/slot/write.js +0 -319
- package/dist/core/stage/builders.d.ts +0 -36
- package/dist/core/stage/builders.js +0 -28
- 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 -77
- 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 -464
- package/dist/core/stage/index.d.ts +0 -11
- package/dist/core/stage/index.js +0 -10
- 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 -14
- package/dist/core/stage/transfer-fields.js +0 -88
- package/dist/core/stage/types.d.ts +0 -177
- package/dist/core/stage/types.js +0 -2
- package/dist/core/stage/validate.d.ts +0 -11
- package/dist/core/stage/validate.js +0 -226
- package/dist/core/stage/walk.d.ts +0 -34
- package/dist/core/stage/walk.js +0 -96
- 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,48 +0,0 @@
|
|
|
1
|
-
import { idField } from './schema.js';
|
|
2
|
-
export const PLATFORM_SESSION_FIELDS = {
|
|
3
|
-
is_inbound_call: {
|
|
4
|
-
derived: false,
|
|
5
|
-
label: 'Inbound call',
|
|
6
|
-
dataType: 'boolean',
|
|
7
|
-
source: 'system',
|
|
8
|
-
extraction: 'Set by the conversation entry pipeline',
|
|
9
|
-
enum: null,
|
|
10
|
-
nullable: false,
|
|
11
|
-
identifier: null,
|
|
12
|
-
ref: null,
|
|
13
|
-
},
|
|
14
|
-
is_first_call: {
|
|
15
|
-
derived: false,
|
|
16
|
-
label: 'First call',
|
|
17
|
-
dataType: 'boolean',
|
|
18
|
-
source: 'system',
|
|
19
|
-
extraction: 'No prior session for this case contact',
|
|
20
|
-
enum: null,
|
|
21
|
-
nullable: false,
|
|
22
|
-
identifier: null,
|
|
23
|
-
ref: null,
|
|
24
|
-
},
|
|
25
|
-
is_new_user: {
|
|
26
|
-
derived: false,
|
|
27
|
-
label: 'New user',
|
|
28
|
-
dataType: 'boolean',
|
|
29
|
-
source: 'system',
|
|
30
|
-
extraction: 'No existing contact for this party',
|
|
31
|
-
enum: null,
|
|
32
|
-
nullable: false,
|
|
33
|
-
identifier: null,
|
|
34
|
-
ref: null,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
export function createPlatformSessionTable() {
|
|
38
|
-
return {
|
|
39
|
-
label: 'Session',
|
|
40
|
-
rows: 'single',
|
|
41
|
-
description: 'Per-conversation session fields',
|
|
42
|
-
fields: {
|
|
43
|
-
id: { ...idField, ref: null },
|
|
44
|
-
...PLATFORM_SESSION_FIELDS,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=platform-session-fields.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { FieldPath } from './path.js';
|
|
2
|
-
import type { CompiledSlotSchema } from './types.js';
|
|
3
|
-
type JsonSchema = Record<string, unknown>;
|
|
4
|
-
export type SfSchemaOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* Field paths included with full definitions.
|
|
7
|
-
* When omitted, all conversation fields are included (full-schema / hangup pass).
|
|
8
|
-
*/
|
|
9
|
-
focusFields?: Iterable<FieldPath>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Build JSON Schema for Slot Filling structured output.
|
|
13
|
-
* Derived and `source: system` fields are never included.
|
|
14
|
-
*/
|
|
15
|
-
export declare function buildSlotFillingJsonSchema(schema: CompiledSlotSchema, options?: SfSchemaOptions): JsonSchema;
|
|
16
|
-
/** Compact catalog for out-of-focus conversation fields (C1). */
|
|
17
|
-
export declare function buildFieldCatalog(schema: CompiledSlotSchema, exclude?: Iterable<FieldPath>): Array<{
|
|
18
|
-
path: FieldPath;
|
|
19
|
-
label: string;
|
|
20
|
-
extraction: string;
|
|
21
|
-
}>;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=sf-schema.d.ts.map
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { compiledTableEntries, isSnapshotSingleRow } from './compile-schema.js';
|
|
2
|
-
import { formatFieldPath, parseFieldPath } from './path.js';
|
|
3
|
-
function dataTypeToJsonSchema(dataType, enumValues, nullable) {
|
|
4
|
-
let base;
|
|
5
|
-
if (enumValues && enumValues.length > 0) {
|
|
6
|
-
base = { enum: [...enumValues] };
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
switch (dataType) {
|
|
10
|
-
case 'string':
|
|
11
|
-
case 'date':
|
|
12
|
-
case 'datetime':
|
|
13
|
-
base = { type: 'string' };
|
|
14
|
-
break;
|
|
15
|
-
case 'number':
|
|
16
|
-
base = { type: 'number' };
|
|
17
|
-
break;
|
|
18
|
-
case 'boolean':
|
|
19
|
-
base = { type: 'boolean' };
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (nullable) {
|
|
24
|
-
if (base.enum) {
|
|
25
|
-
return { enum: [...base.enum, null] };
|
|
26
|
-
}
|
|
27
|
-
return { type: [base.type, 'null'] };
|
|
28
|
-
}
|
|
29
|
-
return base;
|
|
30
|
-
}
|
|
31
|
-
function extractedFieldSchema(field) {
|
|
32
|
-
return {
|
|
33
|
-
type: 'object',
|
|
34
|
-
additionalProperties: false,
|
|
35
|
-
required: ['reason', 'value', 'state'],
|
|
36
|
-
properties: {
|
|
37
|
-
reason: { type: 'string', minLength: 1 },
|
|
38
|
-
value: dataTypeToJsonSchema(field.dataType, field.enum, true),
|
|
39
|
-
state: { type: 'string', enum: ['filled', 'asked_unknown', 'declined'] },
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Build JSON Schema for Slot Filling structured output.
|
|
45
|
-
* Derived and `source: system` fields are never included.
|
|
46
|
-
*/
|
|
47
|
-
export function buildSlotFillingJsonSchema(schema, options = {}) {
|
|
48
|
-
const focus = options.focusFields
|
|
49
|
-
? new Set([...options.focusFields].map((p) => {
|
|
50
|
-
const parsed = parseFieldPath(p);
|
|
51
|
-
if (!parsed)
|
|
52
|
-
throw new Error(`Invalid focus field: ${p}`);
|
|
53
|
-
return parsed.path;
|
|
54
|
-
}))
|
|
55
|
-
: null;
|
|
56
|
-
const tableSchemas = {};
|
|
57
|
-
for (const [tableName, table] of compiledTableEntries(schema)) {
|
|
58
|
-
const fieldProps = {};
|
|
59
|
-
for (const [fieldName, field] of Object.entries(table.fields)) {
|
|
60
|
-
if (field.derived)
|
|
61
|
-
continue;
|
|
62
|
-
if (field.source !== 'conversation')
|
|
63
|
-
continue;
|
|
64
|
-
const path = formatFieldPath(tableName, fieldName);
|
|
65
|
-
if (focus && !focus.has(path))
|
|
66
|
-
continue;
|
|
67
|
-
fieldProps[fieldName] = extractedFieldSchema(field);
|
|
68
|
-
}
|
|
69
|
-
if (Object.keys(fieldProps).length === 0)
|
|
70
|
-
continue;
|
|
71
|
-
if (isSnapshotSingleRow(table)) {
|
|
72
|
-
tableSchemas[tableName] = {
|
|
73
|
-
type: 'object',
|
|
74
|
-
additionalProperties: false,
|
|
75
|
-
properties: fieldProps,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
tableSchemas[tableName] = {
|
|
80
|
-
type: 'array',
|
|
81
|
-
items: {
|
|
82
|
-
type: 'object',
|
|
83
|
-
additionalProperties: false,
|
|
84
|
-
required: ['rowKey', 'fields'],
|
|
85
|
-
properties: {
|
|
86
|
-
rowKey: { type: 'string', minLength: 1 },
|
|
87
|
-
fields: {
|
|
88
|
-
type: 'object',
|
|
89
|
-
additionalProperties: false,
|
|
90
|
-
properties: fieldProps,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
type: 'object',
|
|
99
|
-
additionalProperties: false,
|
|
100
|
-
properties: tableSchemas,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
/** Compact catalog for out-of-focus conversation fields (C1). */
|
|
104
|
-
export function buildFieldCatalog(schema, exclude = []) {
|
|
105
|
-
const excluded = new Set([...exclude].map((p) => parseFieldPath(p)?.path).filter(Boolean));
|
|
106
|
-
const catalog = [];
|
|
107
|
-
for (const [tableName, table] of compiledTableEntries(schema)) {
|
|
108
|
-
for (const [fieldName, field] of Object.entries(table.fields)) {
|
|
109
|
-
if (field.derived)
|
|
110
|
-
continue;
|
|
111
|
-
if (field.source !== 'conversation')
|
|
112
|
-
continue;
|
|
113
|
-
const path = formatFieldPath(tableName, fieldName);
|
|
114
|
-
if (excluded.has(path))
|
|
115
|
-
continue;
|
|
116
|
-
catalog.push({
|
|
117
|
-
path,
|
|
118
|
-
label: field.label,
|
|
119
|
-
extraction: field.extraction,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return catalog;
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=sf-schema.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CompiledSlotSchema, SlotFillingValidateResult } from './types.js';
|
|
2
|
-
export type ValidateSlotFillingOptions = {
|
|
3
|
-
/** Conversation version carried by the SF task. */
|
|
4
|
-
taskVersion: number;
|
|
5
|
-
/** Current conversation version; mismatch → whole pack discarded. */
|
|
6
|
-
currentVersion: number;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* C3 gates for Slot Filling output: version gate, type/enum, write protection.
|
|
10
|
-
* Derived / system fields in the payload are dropped (write protection).
|
|
11
|
-
* Type/enum failures are rejected per-field; valid fields stay accepted.
|
|
12
|
-
*/
|
|
13
|
-
export declare function validateSlotFillingOutput(schema: CompiledSlotSchema, raw: unknown, options: ValidateSlotFillingOptions): SlotFillingValidateResult;
|
|
14
|
-
//# sourceMappingURL=sf-validate.d.ts.map
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { getCompiledTable, isSnapshotSingleRow } from './compile-schema.js';
|
|
2
|
-
import { formatFieldPath } from './path.js';
|
|
3
|
-
import { isReservedTableName } from './row.js';
|
|
4
|
-
import { validateExtractedField } from './value.js';
|
|
5
|
-
function isExtractedField(value) {
|
|
6
|
-
if (!value || typeof value !== 'object')
|
|
7
|
-
return false;
|
|
8
|
-
const v = value;
|
|
9
|
-
return (typeof v.reason === 'string' &&
|
|
10
|
-
'value' in v &&
|
|
11
|
-
(v.state === 'filled' || v.state === 'asked_unknown' || v.state === 'declined'));
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* C3 gates for Slot Filling output: version gate, type/enum, write protection.
|
|
15
|
-
* Derived / system fields in the payload are dropped (write protection).
|
|
16
|
-
* Type/enum failures are rejected per-field; valid fields stay accepted.
|
|
17
|
-
*/
|
|
18
|
-
export function validateSlotFillingOutput(schema, raw, options) {
|
|
19
|
-
if (options.taskVersion !== options.currentVersion) {
|
|
20
|
-
return {
|
|
21
|
-
ok: false,
|
|
22
|
-
reason: 'stale-version',
|
|
23
|
-
issues: [
|
|
24
|
-
{
|
|
25
|
-
code: 'stale-version',
|
|
26
|
-
message: `SF version ${options.taskVersion} != current ${options.currentVersion}`,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
32
|
-
return {
|
|
33
|
-
ok: false,
|
|
34
|
-
reason: 'invalid-shape',
|
|
35
|
-
issues: [
|
|
36
|
-
{
|
|
37
|
-
code: 'invalid-shape',
|
|
38
|
-
message: 'SlotFillingOutput must be an object of table projections',
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const accepted = {};
|
|
44
|
-
const rejected = [];
|
|
45
|
-
const shapeIssues = [];
|
|
46
|
-
for (const [tableName, projection] of Object.entries(raw)) {
|
|
47
|
-
if (isReservedTableName(tableName))
|
|
48
|
-
continue;
|
|
49
|
-
const table = getCompiledTable(schema, tableName);
|
|
50
|
-
if (!table) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (isSnapshotSingleRow(table)) {
|
|
54
|
-
if (!projection || typeof projection !== 'object' || Array.isArray(projection)) {
|
|
55
|
-
shapeIssues.push({
|
|
56
|
-
code: 'invalid-projection',
|
|
57
|
-
message: `single-row table ${tableName} expects an object projection`,
|
|
58
|
-
path: tableName,
|
|
59
|
-
});
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const outFields = {};
|
|
63
|
-
for (const [fieldName, extracted] of Object.entries(projection)) {
|
|
64
|
-
const path = formatFieldPath(tableName, fieldName);
|
|
65
|
-
const field = table.fields[fieldName];
|
|
66
|
-
if (!field || field.derived || field.source !== 'conversation') {
|
|
67
|
-
continue; // write protection: drop
|
|
68
|
-
}
|
|
69
|
-
if (!isExtractedField(extracted)) {
|
|
70
|
-
rejected.push(path);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const issues = validateExtractedField(field, extracted, path);
|
|
74
|
-
if (issues.length > 0) {
|
|
75
|
-
rejected.push(path);
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
outFields[fieldName] = extracted;
|
|
79
|
-
}
|
|
80
|
-
if (Object.keys(outFields).length > 0) {
|
|
81
|
-
accepted[tableName] = outFields;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
if (!Array.isArray(projection)) {
|
|
86
|
-
shapeIssues.push({
|
|
87
|
-
code: 'invalid-projection',
|
|
88
|
-
message: `multi-row table ${tableName} expects an array projection`,
|
|
89
|
-
path: tableName,
|
|
90
|
-
});
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const outRows = [];
|
|
94
|
-
for (const row of projection) {
|
|
95
|
-
if (!row || typeof row !== 'object' || typeof row.rowKey !== 'string') {
|
|
96
|
-
shapeIssues.push({
|
|
97
|
-
code: 'invalid-row',
|
|
98
|
-
message: `multi-row table ${tableName} row missing rowKey`,
|
|
99
|
-
path: tableName,
|
|
100
|
-
});
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const fieldsIn = row.fields ?? {};
|
|
104
|
-
const outFields = {};
|
|
105
|
-
for (const [fieldName, extracted] of Object.entries(fieldsIn)) {
|
|
106
|
-
const path = formatFieldPath(tableName, fieldName);
|
|
107
|
-
const field = table.fields[fieldName];
|
|
108
|
-
if (!field || field.derived || field.source !== 'conversation') {
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (!isExtractedField(extracted)) {
|
|
112
|
-
rejected.push(path);
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const issues = validateExtractedField(field, extracted, path);
|
|
116
|
-
if (issues.length > 0) {
|
|
117
|
-
rejected.push(path);
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
outFields[fieldName] = extracted;
|
|
121
|
-
}
|
|
122
|
-
outRows.push({ rowKey: row.rowKey, fields: outFields });
|
|
123
|
-
}
|
|
124
|
-
accepted[tableName] = outRows;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (shapeIssues.length > 0) {
|
|
128
|
-
return { ok: false, reason: 'invalid-shape', issues: shapeIssues };
|
|
129
|
-
}
|
|
130
|
-
return { ok: true, accepted, rejected };
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=sf-validate.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { FieldPath } from './path.js';
|
|
2
|
-
import type { CompiledSlotSchema, FieldValue, RuntimeSlotsSnapshot, TableData } from './types.js';
|
|
3
|
-
export type SnapshotSeed = Record<string, unknown>;
|
|
4
|
-
/**
|
|
5
|
-
* Build a runtime snapshot for local tests.
|
|
6
|
-
*
|
|
7
|
-
* - `table.field` keys seed single-row (or current-party) fields
|
|
8
|
-
* - bare multi-table name keys seed row arrays:
|
|
9
|
-
* `children: [{ id?: string, name: 'Lily', age: 8 }]`
|
|
10
|
-
*/
|
|
11
|
-
export declare function snapshotFrom(schema: CompiledSlotSchema, seed?: SnapshotSeed, options?: {
|
|
12
|
-
now?: number;
|
|
13
|
-
}): RuntimeSlotsSnapshot;
|
|
14
|
-
/** Deep-clone a snapshot (structuredClone when available). */
|
|
15
|
-
export declare function cloneSnapshot(snapshot: RuntimeSlotsSnapshot): RuntimeSlotsSnapshot;
|
|
16
|
-
export declare function getSnapshotTable(snapshot: RuntimeSlotsSnapshot, tableName: string): TableData | undefined;
|
|
17
|
-
export declare function getSingleField(snapshot: RuntimeSlotsSnapshot, path: FieldPath): FieldValue | undefined;
|
|
18
|
-
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { compiledTableEntries, getCompiledTable, isSnapshotSingleRow } from './compile-schema.js';
|
|
2
|
-
import { emptyFieldValue, makeFieldValue } from './field.js';
|
|
3
|
-
import { parseFieldPath } from './path.js';
|
|
4
|
-
import { emptySlotRow, getRowField, isReservedTableName, isRowIdField, slotFieldNames } from './row.js';
|
|
5
|
-
import { validateBareValue } from './value.js';
|
|
6
|
-
function seedToFieldValue(seed, now) {
|
|
7
|
-
if (seed && typeof seed === 'object' && !Array.isArray(seed) && 'state' in seed) {
|
|
8
|
-
const s = seed;
|
|
9
|
-
return makeFieldValue({
|
|
10
|
-
value: (s.value ?? null),
|
|
11
|
-
state: s.state,
|
|
12
|
-
reason: s.reason ?? null,
|
|
13
|
-
updatedBy: s.updatedBy ?? 'import',
|
|
14
|
-
updatedAt: s.updatedAt ?? now,
|
|
15
|
-
history: s.history ?? [],
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
if (seed === undefined) {
|
|
19
|
-
return emptyFieldValue(now);
|
|
20
|
-
}
|
|
21
|
-
return makeFieldValue({
|
|
22
|
-
value: seed,
|
|
23
|
-
state: 'filled',
|
|
24
|
-
reason: null,
|
|
25
|
-
updatedBy: 'import',
|
|
26
|
-
updatedAt: now,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Build a runtime snapshot for local tests.
|
|
31
|
-
*
|
|
32
|
-
* - `table.field` keys seed single-row (or current-party) fields
|
|
33
|
-
* - bare multi-table name keys seed row arrays:
|
|
34
|
-
* `children: [{ id?: string, name: 'Lily', age: 8 }]`
|
|
35
|
-
*/
|
|
36
|
-
export function snapshotFrom(schema, seed = {}, options = {}) {
|
|
37
|
-
const now = options.now ?? 0;
|
|
38
|
-
const snapshot = {};
|
|
39
|
-
for (const [tableName, table] of compiledTableEntries(schema)) {
|
|
40
|
-
if (isSnapshotSingleRow(table)) {
|
|
41
|
-
snapshot[tableName] = emptySlotRow(table.fields, { now });
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
snapshot[tableName] = [];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
for (const [key, value] of Object.entries(seed)) {
|
|
48
|
-
const parsed = parseFieldPath(key);
|
|
49
|
-
if (parsed) {
|
|
50
|
-
const table = getCompiledTable(schema, parsed.table);
|
|
51
|
-
if (!table) {
|
|
52
|
-
throw new Error(`Unknown table in seed: ${parsed.table}`);
|
|
53
|
-
}
|
|
54
|
-
if (!isSnapshotSingleRow(table)) {
|
|
55
|
-
throw new Error(`Field path seed ${key} is only for single-row tables; seed multi rows by table name`);
|
|
56
|
-
}
|
|
57
|
-
if (isRowIdField(parsed.field)) {
|
|
58
|
-
snapshot[parsed.table].id = value == null ? '' : String(value);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const field = table.fields[parsed.field];
|
|
62
|
-
if (!field) {
|
|
63
|
-
throw new Error(`Unknown field in seed: ${key}`);
|
|
64
|
-
}
|
|
65
|
-
const fv = seedToFieldValue(value, now);
|
|
66
|
-
if (fv.state === 'filled' || fv.state === 'asked_unknown') {
|
|
67
|
-
const issues = validateBareValue(field, fv.value, key, {
|
|
68
|
-
allowNull: field.derived || (field.derived === false && field.nullable),
|
|
69
|
-
});
|
|
70
|
-
if (issues.length > 0) {
|
|
71
|
-
throw new Error(issues.map((i) => i.message).join('; '));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
snapshot[parsed.table][parsed.field] = fv;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const table = getCompiledTable(schema, key);
|
|
78
|
-
if (!table) {
|
|
79
|
-
throw new Error(`Unknown seed key: ${key}`);
|
|
80
|
-
}
|
|
81
|
-
if (isSnapshotSingleRow(table)) {
|
|
82
|
-
throw new Error(`Seed key ${key} is not a multi-row table`);
|
|
83
|
-
}
|
|
84
|
-
if (!Array.isArray(value)) {
|
|
85
|
-
throw new Error(`Multi-row seed ${key} must be an array`);
|
|
86
|
-
}
|
|
87
|
-
const rows = [];
|
|
88
|
-
let i = 0;
|
|
89
|
-
for (const rowSeed of value) {
|
|
90
|
-
if (!rowSeed || typeof rowSeed !== 'object') {
|
|
91
|
-
throw new Error(`Invalid row seed in ${key}`);
|
|
92
|
-
}
|
|
93
|
-
const rowObj = rowSeed;
|
|
94
|
-
const seededId = rowObj.id ?? rowObj.rowId;
|
|
95
|
-
const id = typeof seededId === 'string' && seededId.length > 0 ? seededId : `r${++i}`;
|
|
96
|
-
const row = { id };
|
|
97
|
-
for (const fieldName of slotFieldNames(table.fields)) {
|
|
98
|
-
if (fieldName in rowObj) {
|
|
99
|
-
row[fieldName] = seedToFieldValue(rowObj[fieldName], now);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
row[fieldName] = emptyFieldValue(now);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
rows.push(row);
|
|
106
|
-
}
|
|
107
|
-
snapshot[key] = rows;
|
|
108
|
-
}
|
|
109
|
-
return snapshot;
|
|
110
|
-
}
|
|
111
|
-
/** Deep-clone a snapshot (structuredClone when available). */
|
|
112
|
-
export function cloneSnapshot(snapshot) {
|
|
113
|
-
return typeof structuredClone === 'function'
|
|
114
|
-
? structuredClone(snapshot)
|
|
115
|
-
: JSON.parse(JSON.stringify(snapshot));
|
|
116
|
-
}
|
|
117
|
-
export function getSnapshotTable(snapshot, tableName) {
|
|
118
|
-
if (isReservedTableName(tableName))
|
|
119
|
-
return undefined;
|
|
120
|
-
const value = snapshot[tableName];
|
|
121
|
-
if (value == null)
|
|
122
|
-
return undefined;
|
|
123
|
-
if (Array.isArray(value))
|
|
124
|
-
return value;
|
|
125
|
-
if (typeof value === 'object' && 'id' in value)
|
|
126
|
-
return value;
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
export function getSingleField(snapshot, path) {
|
|
130
|
-
const parsed = parseFieldPath(path);
|
|
131
|
-
if (!parsed)
|
|
132
|
-
return undefined;
|
|
133
|
-
const table = getSnapshotTable(snapshot, parsed.table);
|
|
134
|
-
if (!table || Array.isArray(table))
|
|
135
|
-
return undefined;
|
|
136
|
-
return getRowField(table, parsed.field);
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { FieldState, Writes } from '../context/types.js';
|
|
2
|
-
import type { FieldPath } from './path.js';
|
|
3
|
-
import type { ApplyWritesOptions, ApplyWritesResult, CompiledSlotSchema, RuntimeSlotsSnapshot, SlotFillingOutput, UpdatedBy } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Apply bare Writes (function / human / import / platform) onto a snapshot.
|
|
6
|
-
* Validates type/enum and write permissions. Detects C5 changes and appends history.
|
|
7
|
-
*/
|
|
8
|
-
export declare function applyWrites(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, writes: Writes | null | undefined, options: ApplyWritesOptions): ApplyWritesResult;
|
|
9
|
-
export type FieldPatchInput = {
|
|
10
|
-
path: FieldPath;
|
|
11
|
-
rowId?: string;
|
|
12
|
-
value: string | number | boolean | null;
|
|
13
|
-
state: FieldState;
|
|
14
|
-
reason?: string | null;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Apply one human/admin field edit, including explicit slot state.
|
|
18
|
-
* Unlike bare writes, this supports a selected row in a multi-row entity table.
|
|
19
|
-
*/
|
|
20
|
-
export declare function applyFieldPatch(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, patch: FieldPatchInput, options: {
|
|
21
|
-
source: UpdatedBy;
|
|
22
|
-
now?: number;
|
|
23
|
-
}): ApplyWritesResult;
|
|
24
|
-
export type ApplySlotFillingOptions = {
|
|
25
|
-
now?: number;
|
|
26
|
-
/** Map SF placeholder row keys (`new-1`) → allocated row ids (mutated in place). */
|
|
27
|
-
rowKeyMap?: Map<string, string>;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* C4: apply accepted Slot Filling projection (full replace for present fields/rows).
|
|
31
|
-
* Multi-row: projection is the full set of rows; omitted existing rows are deleted.
|
|
32
|
-
*/
|
|
33
|
-
export declare function applySlotFilling(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, output: SlotFillingOutput, options?: ApplySlotFillingOptions): ApplyWritesResult;
|
|
34
|
-
/**
|
|
35
|
-
* Mark remaining conversation fields as asked_unknown (Topic move-on).
|
|
36
|
-
*/
|
|
37
|
-
export declare function markAskedUnknown(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, fields: Iterable<FieldPath>, options?: {
|
|
38
|
-
now?: number;
|
|
39
|
-
reason?: string;
|
|
40
|
-
}): ApplyWritesResult;
|
|
41
|
-
//# sourceMappingURL=write.d.ts.map
|