@superpanel-sdk/runtime 0.0.1-internal.1
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 +35 -0
- package/bin/superpanel-sdk-runtime.mjs +22 -0
- package/dist/builder/codegen/emit.d.ts +17 -0
- package/dist/builder/codegen/emit.js +143 -0
- package/dist/builder/codegen/generate.d.ts +21 -0
- package/dist/builder/codegen/generate.js +90 -0
- package/dist/builder/compile/compile-agenda.d.ts +15 -0
- package/dist/builder/compile/compile-agenda.js +59 -0
- package/dist/builder/compile/compile-sequence.d.ts +24 -0
- package/dist/builder/compile/compile-sequence.js +121 -0
- package/dist/builder/compile/function-code.d.ts +6 -0
- package/dist/builder/compile/function-code.js +30 -0
- package/dist/builder/compile/registry.d.ts +13 -0
- package/dist/builder/compile/registry.js +42 -0
- package/dist/builder/load.d.ts +22 -0
- package/dist/builder/load.js +169 -0
- package/dist/builder/merge.d.ts +4 -0
- package/dist/builder/merge.js +19 -0
- package/dist/builder/paths.d.ts +10 -0
- package/dist/builder/paths.js +22 -0
- package/dist/builder/types.d.ts +31 -0
- package/dist/builder/types.js +2 -0
- package/dist/cli/compile/index.d.ts +4 -0
- package/dist/cli/compile/index.js +11 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +64 -0
- package/dist/cli/serve/index.d.ts +9 -0
- package/dist/cli/serve/index.js +340 -0
- package/dist/cli/type-gen/index.d.ts +5 -0
- package/dist/cli/type-gen/index.js +90 -0
- package/dist/compute-host/compute-host.d.ts +38 -0
- package/dist/compute-host/compute-host.js +45 -0
- package/dist/compute-host/index.d.ts +5 -0
- package/dist/compute-host/index.js +3 -0
- package/dist/compute-host/source-compute-host.d.ts +29 -0
- package/dist/compute-host/source-compute-host.js +72 -0
- package/dist/core/context/account-fields.d.ts +12 -0
- package/dist/core/context/account-fields.js +2 -0
- package/dist/core/context/contact.d.ts +60 -0
- package/dist/core/context/contact.js +34 -0
- package/dist/core/context/db.d.ts +69 -0
- package/dist/core/context/db.js +44 -0
- package/dist/core/context/docusign.d.ts +134 -0
- package/dist/core/context/docusign.js +108 -0
- package/dist/core/context/env.d.ts +9 -0
- package/dist/core/context/env.js +19 -0
- package/dist/core/context/filevine.d.ts +323 -0
- package/dist/core/context/filevine.js +254 -0
- package/dist/core/context/http.d.ts +9 -0
- package/dist/core/context/http.js +4 -0
- package/dist/core/context/hubspot.d.ts +250 -0
- package/dist/core/context/hubspot.js +191 -0
- package/dist/core/context/platform-registry.d.ts +67 -0
- package/dist/core/context/platform-registry.js +11 -0
- package/dist/core/context/platform.d.ts +33 -0
- package/dist/core/context/platform.js +2 -0
- package/dist/core/context/twilio.d.ts +50 -0
- package/dist/core/context/twilio.js +42 -0
- package/dist/core/context/types.d.ts +87 -0
- package/dist/core/context/types.js +9 -0
- package/dist/core/functions/define/case-context.d.ts +14 -0
- package/dist/core/functions/define/case-context.js +15 -0
- package/dist/core/functions/define/compute.d.ts +7 -0
- package/dist/core/functions/define/compute.js +17 -0
- package/dist/core/functions/define/custom.d.ts +4 -0
- package/dist/core/functions/define/custom.js +8 -0
- package/dist/core/functions/define/system.d.ts +7 -0
- package/dist/core/functions/define/system.js +12 -0
- package/dist/core/functions/func-ref.d.ts +16 -0
- package/dist/core/functions/func-ref.js +20 -0
- package/dist/core/functions/types.d.ts +78 -0
- package/dist/core/functions/types.js +5 -0
- package/dist/core/slot/compile-schema.d.ts +24 -0
- package/dist/core/slot/compile-schema.js +336 -0
- package/dist/core/slot/deps.d.ts +15 -0
- package/dist/core/slot/deps.js +88 -0
- package/dist/core/slot/derived.d.ts +32 -0
- package/dist/core/slot/derived.js +115 -0
- package/dist/core/slot/field.d.ts +36 -0
- package/dist/core/slot/field.js +97 -0
- package/dist/core/slot/id-ref.d.ts +4 -0
- package/dist/core/slot/id-ref.js +15 -0
- package/dist/core/slot/index.d.ts +15 -0
- package/dist/core/slot/index.js +14 -0
- package/dist/core/slot/path.d.ts +18 -0
- package/dist/core/slot/path.js +22 -0
- package/dist/core/slot/row.d.ts +22 -0
- package/dist/core/slot/row.js +54 -0
- package/dist/core/slot/schema.d.ts +102 -0
- package/dist/core/slot/schema.js +17 -0
- package/dist/core/slot/sf-schema.d.ts +23 -0
- package/dist/core/slot/sf-schema.js +125 -0
- package/dist/core/slot/sf-validate.d.ts +14 -0
- package/dist/core/slot/sf-validate.js +132 -0
- package/dist/core/slot/snapshot.d.ts +18 -0
- package/dist/core/slot/snapshot.js +138 -0
- package/dist/core/slot/types.d.ts +144 -0
- package/dist/core/slot/types.js +2 -0
- package/dist/core/slot/value.d.ts +9 -0
- package/dist/core/slot/value.js +97 -0
- package/dist/core/slot/write.d.ts +41 -0
- package/dist/core/slot/write.js +319 -0
- package/dist/core/stage/builders.d.ts +36 -0
- package/dist/core/stage/builders.js +28 -0
- package/dist/core/stage/condition.d.ts +17 -0
- package/dist/core/stage/condition.js +198 -0
- package/dist/core/stage/drive.d.ts +43 -0
- package/dist/core/stage/drive.js +77 -0
- package/dist/core/stage/finish-when.d.ts +20 -0
- package/dist/core/stage/finish-when.js +82 -0
- package/dist/core/stage/flatten.d.ts +27 -0
- package/dist/core/stage/flatten.js +464 -0
- package/dist/core/stage/index.d.ts +11 -0
- package/dist/core/stage/index.js +10 -0
- package/dist/core/stage/simulate.d.ts +24 -0
- package/dist/core/stage/simulate.js +33 -0
- package/dist/core/stage/transfer-fields.d.ts +14 -0
- package/dist/core/stage/transfer-fields.js +88 -0
- package/dist/core/stage/types.d.ts +177 -0
- package/dist/core/stage/types.js +2 -0
- package/dist/core/stage/validate.d.ts +11 -0
- package/dist/core/stage/validate.js +226 -0
- package/dist/core/stage/walk.d.ts +34 -0
- package/dist/core/stage/walk.js +96 -0
- package/dist/dev-overlay/protocol.d.ts +53 -0
- package/dist/dev-overlay/protocol.js +21 -0
- package/dist/fn-context/build-context.d.ts +11 -0
- package/dist/fn-context/build-context.js +21 -0
- package/dist/fn-context/fake/empty-api.d.ts +9 -0
- package/dist/fn-context/fake/empty-api.js +50 -0
- package/dist/fn-context/fake/index.d.ts +12 -0
- package/dist/fn-context/fake/index.js +22 -0
- package/dist/fn-context/index.d.ts +9 -0
- package/dist/fn-context/index.js +8 -0
- package/dist/fn-context/log.d.ts +8 -0
- package/dist/fn-context/log.js +29 -0
- package/dist/fn-context/make-ctx.d.ts +9 -0
- package/dist/fn-context/make-ctx.js +51 -0
- package/dist/fn-context/rpc/errors.d.ts +25 -0
- package/dist/fn-context/rpc/errors.js +23 -0
- package/dist/fn-context/rpc/index.d.ts +10 -0
- package/dist/fn-context/rpc/index.js +9 -0
- package/dist/fn-context/rpc/integration/index.d.ts +51 -0
- package/dist/fn-context/rpc/integration/index.js +19 -0
- package/dist/fn-context/rpc/integration/list-bindings.d.ts +21 -0
- package/dist/fn-context/rpc/integration/list-bindings.js +18 -0
- package/dist/fn-context/rpc/log.d.ts +36 -0
- package/dist/fn-context/rpc/log.js +16 -0
- package/dist/fn-context/rpc/platform.d.ts +28 -0
- package/dist/fn-context/rpc/platform.js +15 -0
- package/dist/fn-context/rpc/request-id.d.ts +5 -0
- package/dist/fn-context/rpc/request-id.js +13 -0
- package/dist/fn-context/rpc/trpc-client.d.ts +7 -0
- package/dist/fn-context/rpc/trpc-client.js +109 -0
- package/dist/fn-context/rpc/trpc-init.d.ts +17 -0
- package/dist/fn-context/rpc/trpc-init.js +17 -0
- package/dist/fn-context/rpc/trpc-router-factory.d.ts +84 -0
- package/dist/fn-context/rpc/trpc-router-factory.js +9 -0
- package/dist/fn-context/types.d.ts +17 -0
- package/dist/fn-context/types.js +2 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +34 -0
- package/dist/voice-service/actions.d.ts +20 -0
- package/dist/voice-service/actions.js +2 -0
- package/dist/voice-service/index.d.ts +3 -0
- package/dist/voice-service/index.js +3 -0
- package/dist/voice-service/types.d.ts +1010 -0
- package/dist/voice-service/types.js +16 -0
- package/package.json +55 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FieldPath } from './path.js';
|
|
2
|
+
import type { RuntimeTableDef, ValidationIssue } from './types.js';
|
|
3
|
+
export type DependencyGraphResult = {
|
|
4
|
+
derivedOrder: FieldPath[];
|
|
5
|
+
reverseDeps: Record<FieldPath, FieldPath[]>;
|
|
6
|
+
issues: ValidationIssue[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Build topological order of derived fields and reverse dependency index.
|
|
10
|
+
* Reports cycles instead of throwing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildDependencyGraph(tables: Record<string, RuntimeTableDef>): DependencyGraphResult;
|
|
13
|
+
/** Collect derived fields affected by changed columns, in topo order. */
|
|
14
|
+
export declare function affectedDerivedFields(changed: Iterable<FieldPath>, reverseDeps: Record<FieldPath, FieldPath[]>, derivedOrder: FieldPath[]): FieldPath[];
|
|
15
|
+
//# sourceMappingURL=deps.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { formatFieldPath, parseFieldPath } from './path.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build topological order of derived fields and reverse dependency index.
|
|
4
|
+
* Reports cycles instead of throwing.
|
|
5
|
+
*/
|
|
6
|
+
export function buildDependencyGraph(tables) {
|
|
7
|
+
const issues = [];
|
|
8
|
+
const derivedPaths = [];
|
|
9
|
+
const edges = new Map();
|
|
10
|
+
const reverseDeps = {};
|
|
11
|
+
for (const [tableName, table] of Object.entries(tables)) {
|
|
12
|
+
for (const [fieldName, field] of Object.entries(table.fields)) {
|
|
13
|
+
if (!field.derived)
|
|
14
|
+
continue;
|
|
15
|
+
const path = formatFieldPath(tableName, fieldName);
|
|
16
|
+
derivedPaths.push(path);
|
|
17
|
+
const deps = [];
|
|
18
|
+
for (const dep of field.dependsOn) {
|
|
19
|
+
const parsed = parseFieldPath(dep);
|
|
20
|
+
if (!parsed) {
|
|
21
|
+
issues.push({
|
|
22
|
+
code: 'invalid-depends-on',
|
|
23
|
+
message: `Invalid dependsOn path: ${dep}`,
|
|
24
|
+
path,
|
|
25
|
+
});
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
deps.push(parsed.path);
|
|
29
|
+
if (!reverseDeps[parsed.path])
|
|
30
|
+
reverseDeps[parsed.path] = [];
|
|
31
|
+
reverseDeps[parsed.path].push(path);
|
|
32
|
+
}
|
|
33
|
+
edges.set(path, deps);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Kahn topological sort over derived nodes only; edges point to dependencies.
|
|
37
|
+
const indegree = new Map();
|
|
38
|
+
const dependents = new Map();
|
|
39
|
+
for (const path of derivedPaths) {
|
|
40
|
+
indegree.set(path, 0);
|
|
41
|
+
dependents.set(path, []);
|
|
42
|
+
}
|
|
43
|
+
for (const [path, deps] of edges) {
|
|
44
|
+
for (const dep of deps) {
|
|
45
|
+
if (!indegree.has(dep))
|
|
46
|
+
continue; // dependency is a normal field
|
|
47
|
+
indegree.set(path, (indegree.get(path) ?? 0) + 1);
|
|
48
|
+
dependents.get(dep).push(path);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const queue = derivedPaths.filter((p) => (indegree.get(p) ?? 0) === 0);
|
|
52
|
+
const derivedOrder = [];
|
|
53
|
+
while (queue.length > 0) {
|
|
54
|
+
const path = queue.shift();
|
|
55
|
+
derivedOrder.push(path);
|
|
56
|
+
for (const next of dependents.get(path) ?? []) {
|
|
57
|
+
const nextDeg = (indegree.get(next) ?? 0) - 1;
|
|
58
|
+
indegree.set(next, nextDeg);
|
|
59
|
+
if (nextDeg === 0)
|
|
60
|
+
queue.push(next);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (derivedOrder.length !== derivedPaths.length) {
|
|
64
|
+
const remaining = derivedPaths.filter((p) => !derivedOrder.includes(p));
|
|
65
|
+
issues.push({
|
|
66
|
+
code: 'cyclic-dependency',
|
|
67
|
+
message: `Cyclic derived dependency involving: ${remaining.join(' → ')}`,
|
|
68
|
+
path: remaining[0],
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return { derivedOrder, reverseDeps, issues };
|
|
72
|
+
}
|
|
73
|
+
/** Collect derived fields affected by changed columns, in topo order. */
|
|
74
|
+
export function affectedDerivedFields(changed, reverseDeps, derivedOrder) {
|
|
75
|
+
const hit = new Set();
|
|
76
|
+
const stack = [...changed];
|
|
77
|
+
while (stack.length > 0) {
|
|
78
|
+
const path = stack.pop();
|
|
79
|
+
for (const derived of reverseDeps[path] ?? []) {
|
|
80
|
+
if (hit.has(derived))
|
|
81
|
+
continue;
|
|
82
|
+
hit.add(derived);
|
|
83
|
+
stack.push(derived);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return derivedOrder.filter((path) => hit.has(path));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=deps.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Writes } from '../context/types.js';
|
|
2
|
+
import type { FieldPath } from './path.js';
|
|
3
|
+
import type { ApplyWritesOptions, CompiledSlotSchema, RecomputeResult, RuntimeSlotsSnapshot, SlotFillingOutput } from './types.js';
|
|
4
|
+
import { createLocalComputeHost, resolveComputeHost, type ComputeFnMap, type ComputeHost, type ComputeHostOrFns, type LocalComputeHostOptions } from '../../compute-host/compute-host.js';
|
|
5
|
+
import { createSourceComputeHost } from '../../compute-host/source-compute-host.js';
|
|
6
|
+
import { type ApplySlotFillingOptions, type FieldPatchInput } from './write.js';
|
|
7
|
+
export type { ComputeFnMap, ComputeHost, ComputeHostOrFns, LocalComputeHostOptions };
|
|
8
|
+
export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost };
|
|
9
|
+
export type RecomputeOptions = {
|
|
10
|
+
now?: number;
|
|
11
|
+
/**
|
|
12
|
+
* When true, recompute every derived field in topo order (session start heal).
|
|
13
|
+
* When false (default), only fields affected by `changed`.
|
|
14
|
+
*/
|
|
15
|
+
all?: boolean;
|
|
16
|
+
changed?: Iterable<FieldPath>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* C6: recompute derived fields in topological order via {@link ComputeHost}.
|
|
20
|
+
* `null` return means no conclusion yet (stored as filled+null).
|
|
21
|
+
*/
|
|
22
|
+
export declare function recomputeDerived(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, hostOrFns: ComputeHostOrFns, options?: RecomputeOptions): Promise<RecomputeResult>;
|
|
23
|
+
/** C4→C6: apply normal writes then recompute affected derived fields. */
|
|
24
|
+
export declare function applyWritesAndRecompute(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, writes: Writes | null | undefined, hostOrFns: ComputeHostOrFns, writeOptions: ApplyWritesOptions): Promise<RecomputeResult>;
|
|
25
|
+
/** Apply an explicit-state field edit, then recompute every affected derived field. */
|
|
26
|
+
export declare function applyFieldPatchAndRecompute(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, patch: FieldPatchInput, hostOrFns: ComputeHostOrFns, options: {
|
|
27
|
+
source: ApplyWritesOptions['source'];
|
|
28
|
+
now?: number;
|
|
29
|
+
}): Promise<RecomputeResult>;
|
|
30
|
+
/** C4→C6 for accepted Slot Filling output. */
|
|
31
|
+
export declare function applySlotFillingAndRecompute(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, output: SlotFillingOutput, hostOrFns: ComputeHostOrFns, options?: ApplySlotFillingOptions): Promise<RecomputeResult>;
|
|
32
|
+
//# sourceMappingURL=derived.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { getCompiledTable, isSnapshotSingleRow } from './compile-schema.js';
|
|
2
|
+
import { createLocalComputeHost, resolveComputeHost, } from '../../compute-host/compute-host.js';
|
|
3
|
+
import { createSourceComputeHost } from '../../compute-host/source-compute-host.js';
|
|
4
|
+
import { affectedDerivedFields } from './deps.js';
|
|
5
|
+
import { commitFieldWrite, makeFieldValue } from './field.js';
|
|
6
|
+
import { requireFieldPath } from './path.js';
|
|
7
|
+
import { getRowField } from './row.js';
|
|
8
|
+
import { cloneSnapshot, getSnapshotTable } from './snapshot.js';
|
|
9
|
+
import { validateBareValue } from './value.js';
|
|
10
|
+
import { applyFieldPatch, applySlotFilling, applyWrites, } from './write.js';
|
|
11
|
+
export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost };
|
|
12
|
+
/**
|
|
13
|
+
* C6: recompute derived fields in topological order via {@link ComputeHost}.
|
|
14
|
+
* `null` return means no conclusion yet (stored as filled+null).
|
|
15
|
+
*/
|
|
16
|
+
export async function recomputeDerived(schema, snapshot, hostOrFns, options = {}) {
|
|
17
|
+
const host = resolveComputeHost(hostOrFns);
|
|
18
|
+
const now = options.now ?? Date.now();
|
|
19
|
+
const next = cloneSnapshot(snapshot);
|
|
20
|
+
const changedOut = [];
|
|
21
|
+
const history = [];
|
|
22
|
+
const targets = options.all
|
|
23
|
+
? schema.derivedOrder
|
|
24
|
+
: affectedDerivedFields(options.changed ?? [], schema.reverseDeps, schema.derivedOrder);
|
|
25
|
+
for (const path of targets) {
|
|
26
|
+
const parsed = requireFieldPath(path);
|
|
27
|
+
const table = getCompiledTable(schema, parsed.table);
|
|
28
|
+
const field = table?.fields[parsed.field];
|
|
29
|
+
if (!table || !field || !field.derived)
|
|
30
|
+
continue;
|
|
31
|
+
if (!isSnapshotSingleRow(table))
|
|
32
|
+
continue;
|
|
33
|
+
const raw = await host.execute(field.computeFn, [next]);
|
|
34
|
+
const issues = validateBareValue(field, raw, path, { allowNull: true });
|
|
35
|
+
if (issues.length > 0) {
|
|
36
|
+
throw new Error(`Derived ${path} returned invalid value: ${issues.map((i) => i.message).join('; ')}`);
|
|
37
|
+
}
|
|
38
|
+
const tableData = getSnapshotTable(next, parsed.table);
|
|
39
|
+
const prev = getRowField(tableData, parsed.field);
|
|
40
|
+
if (!prev)
|
|
41
|
+
continue;
|
|
42
|
+
const committed = commitFieldWrite(prev, makeFieldValue({
|
|
43
|
+
value: (raw ?? null),
|
|
44
|
+
state: 'filled',
|
|
45
|
+
reason: null,
|
|
46
|
+
updatedBy: 'derived',
|
|
47
|
+
updatedAt: now,
|
|
48
|
+
}));
|
|
49
|
+
tableData[parsed.field] = committed.field;
|
|
50
|
+
if (committed.changed) {
|
|
51
|
+
changedOut.push(path);
|
|
52
|
+
if (committed.historyEntry) {
|
|
53
|
+
history.push({ path, entry: committed.historyEntry });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { snapshot: next, changed: changedOut, history };
|
|
58
|
+
}
|
|
59
|
+
/** C4→C6: apply normal writes then recompute affected derived fields. */
|
|
60
|
+
export async function applyWritesAndRecompute(schema, snapshot, writes, hostOrFns, writeOptions) {
|
|
61
|
+
const applied = applyWrites(schema, snapshot, writes, writeOptions);
|
|
62
|
+
if (applied.changed.length === 0) {
|
|
63
|
+
return {
|
|
64
|
+
snapshot: applied.snapshot,
|
|
65
|
+
changed: [],
|
|
66
|
+
history: applied.history,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const recomputed = await recomputeDerived(schema, applied.snapshot, hostOrFns, {
|
|
70
|
+
now: writeOptions.now,
|
|
71
|
+
changed: applied.changed,
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
snapshot: recomputed.snapshot,
|
|
75
|
+
changed: [...applied.changed, ...recomputed.changed],
|
|
76
|
+
history: [...applied.history, ...recomputed.history],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Apply an explicit-state field edit, then recompute every affected derived field. */
|
|
80
|
+
export async function applyFieldPatchAndRecompute(schema, snapshot, patch, hostOrFns, options) {
|
|
81
|
+
const applied = applyFieldPatch(schema, snapshot, patch, options);
|
|
82
|
+
if (applied.changed.length === 0) {
|
|
83
|
+
return { snapshot: applied.snapshot, changed: [], history: applied.history };
|
|
84
|
+
}
|
|
85
|
+
const recomputed = await recomputeDerived(schema, applied.snapshot, hostOrFns, {
|
|
86
|
+
now: options.now,
|
|
87
|
+
changed: applied.changed,
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
snapshot: recomputed.snapshot,
|
|
91
|
+
changed: [...applied.changed, ...recomputed.changed],
|
|
92
|
+
history: [...applied.history, ...recomputed.history],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** C4→C6 for accepted Slot Filling output. */
|
|
96
|
+
export async function applySlotFillingAndRecompute(schema, snapshot, output, hostOrFns, options = {}) {
|
|
97
|
+
const applied = applySlotFilling(schema, snapshot, output, options);
|
|
98
|
+
if (applied.changed.length === 0) {
|
|
99
|
+
return {
|
|
100
|
+
snapshot: applied.snapshot,
|
|
101
|
+
changed: [],
|
|
102
|
+
history: applied.history,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const recomputed = await recomputeDerived(schema, applied.snapshot, hostOrFns, {
|
|
106
|
+
now: options.now,
|
|
107
|
+
changed: applied.changed,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
snapshot: recomputed.snapshot,
|
|
111
|
+
changed: [...applied.changed, ...recomputed.changed],
|
|
112
|
+
history: [...applied.history, ...recomputed.history],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=derived.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FieldState } from '../context/types.js';
|
|
2
|
+
import type { FieldHistoryEntry, FieldValue, UpdatedBy } from './types.js';
|
|
3
|
+
/** Stage done checks use resolved, not "has a value". */
|
|
4
|
+
export declare function isResolved(field: FieldValue | null | undefined): boolean;
|
|
5
|
+
export declare function emptyFieldValue(now?: number): FieldValue;
|
|
6
|
+
export declare function makeFieldValue(partial: {
|
|
7
|
+
value: string | number | boolean | null;
|
|
8
|
+
state: FieldState;
|
|
9
|
+
reason?: string | null;
|
|
10
|
+
updatedBy?: UpdatedBy;
|
|
11
|
+
updatedAt?: number;
|
|
12
|
+
history?: FieldHistoryEntry[];
|
|
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
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const RESOLVED = new Set(['filled', 'asked_unknown', 'declined']);
|
|
2
|
+
/** Stage done checks use resolved, not "has a value". */
|
|
3
|
+
export function isResolved(field) {
|
|
4
|
+
if (!field)
|
|
5
|
+
return false;
|
|
6
|
+
return RESOLVED.has(field.state);
|
|
7
|
+
}
|
|
8
|
+
export function emptyFieldValue(now = 0) {
|
|
9
|
+
return {
|
|
10
|
+
reason: null,
|
|
11
|
+
value: null,
|
|
12
|
+
state: 'empty',
|
|
13
|
+
updatedAt: now,
|
|
14
|
+
updatedBy: 'platform',
|
|
15
|
+
history: [],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function makeFieldValue(partial) {
|
|
19
|
+
return {
|
|
20
|
+
reason: partial.reason ?? null,
|
|
21
|
+
value: partial.value,
|
|
22
|
+
state: partial.state,
|
|
23
|
+
updatedAt: partial.updatedAt ?? 0,
|
|
24
|
+
updatedBy: partial.updatedBy ?? 'platform',
|
|
25
|
+
history: partial.history ?? [],
|
|
26
|
+
};
|
|
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
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CompanyNormalFieldDef } from './schema.js';
|
|
2
|
+
/** System string field that stores `{table}.id`. */
|
|
3
|
+
export declare function idRef(table: string, extras?: Pick<Partial<CompanyNormalFieldDef>, 'label' | 'nullable' | 'extraction'>): CompanyNormalFieldDef;
|
|
4
|
+
//# sourceMappingURL=id-ref.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** System string field that stores `{table}.id`. */
|
|
2
|
+
export function idRef(table, extras) {
|
|
3
|
+
return {
|
|
4
|
+
derived: false,
|
|
5
|
+
label: extras?.label ?? table,
|
|
6
|
+
dataType: 'string',
|
|
7
|
+
source: 'system',
|
|
8
|
+
extraction: extras?.extraction ?? `Reference to ${table}.id`,
|
|
9
|
+
enum: null,
|
|
10
|
+
nullable: extras?.nullable ?? false,
|
|
11
|
+
identifier: null,
|
|
12
|
+
ref: { table },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=id-ref.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { ROW_ID_FIELD, idField, idFieldCore } from './schema.js';
|
|
2
|
+
export { idRef } from './id-ref.js';
|
|
3
|
+
export { emptyMultiRow, emptySlotRow, getRowField, isFieldValue, isReservedTableName, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, rowValueEntries, slotFieldEntries, slotFieldNames, type SlotRow, } from './row.js';
|
|
4
|
+
export { parseFieldPath, requireFieldPath, formatFieldPath, type FieldPath, type ParsedFieldPath } from './path.js';
|
|
5
|
+
export { isResolved, emptyFieldValue, makeFieldValue, fieldChanged, commitFieldWrite, getLastThreeValues, toHistoryEntry, getFieldValue, getFieldState, type CommitFieldWriteResult, } from './field.js';
|
|
6
|
+
export { buildDependencyGraph, affectedDerivedFields, type DependencyGraphResult } from './deps.js';
|
|
7
|
+
export { compileSlotSchema, compiledTableEntries, getCompiledTable, validateFieldRefs, toEffectiveSchema, listConversationFields, isSnapshotSingleRow, } from './compile-schema.js';
|
|
8
|
+
export { isValidDataTypeValue, validateExtractedField, validateBareValue } from './value.js';
|
|
9
|
+
export { buildSlotFillingJsonSchema, buildFieldCatalog, type SfSchemaOptions } from './sf-schema.js';
|
|
10
|
+
export { validateSlotFillingOutput, type ValidateSlotFillingOptions } from './sf-validate.js';
|
|
11
|
+
export { snapshotFrom, cloneSnapshot, getSingleField, getSnapshotTable, type SnapshotSeed } from './snapshot.js';
|
|
12
|
+
export { applyFieldPatch, applyWrites, applySlotFilling, markAskedUnknown, type ApplySlotFillingOptions, type FieldPatchInput, } from './write.js';
|
|
13
|
+
export type { ComputeFnMap, ComputeHost, ComputeHostOrFns, LocalComputeHostOptions, RecomputeOptions, } from './derived.js';
|
|
14
|
+
export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost, recomputeDerived, applyFieldPatchAndRecompute, applyWritesAndRecompute, applySlotFillingAndRecompute, } from './derived.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { ROW_ID_FIELD, idField, idFieldCore } from './schema.js';
|
|
2
|
+
export { idRef } from './id-ref.js';
|
|
3
|
+
export { emptyMultiRow, emptySlotRow, getRowField, isFieldValue, isReservedTableName, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, rowValueEntries, slotFieldEntries, slotFieldNames, } from './row.js';
|
|
4
|
+
export { parseFieldPath, requireFieldPath, formatFieldPath } from './path.js';
|
|
5
|
+
export { isResolved, emptyFieldValue, makeFieldValue, fieldChanged, commitFieldWrite, getLastThreeValues, toHistoryEntry, getFieldValue, getFieldState, } from './field.js';
|
|
6
|
+
export { buildDependencyGraph, affectedDerivedFields } from './deps.js';
|
|
7
|
+
export { compileSlotSchema, compiledTableEntries, getCompiledTable, validateFieldRefs, toEffectiveSchema, listConversationFields, isSnapshotSingleRow, } from './compile-schema.js';
|
|
8
|
+
export { isValidDataTypeValue, validateExtractedField, validateBareValue } from './value.js';
|
|
9
|
+
export { buildSlotFillingJsonSchema, buildFieldCatalog } from './sf-schema.js';
|
|
10
|
+
export { validateSlotFillingOutput } from './sf-validate.js';
|
|
11
|
+
export { snapshotFrom, cloneSnapshot, getSingleField, getSnapshotTable } from './snapshot.js';
|
|
12
|
+
export { applyFieldPatch, applyWrites, applySlotFilling, markAskedUnknown, } from './write.js';
|
|
13
|
+
export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost, recomputeDerived, applyFieldPatchAndRecompute, applyWritesAndRecompute, applySlotFillingAndRecompute, } from './derived.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field path: `table.field`
|
|
3
|
+
*
|
|
4
|
+
* Defined here, next to its parse/format helpers, so the lowest layers
|
|
5
|
+
* (`functions`, `context`) can name a field without reaching into `schema.js`.
|
|
6
|
+
*/
|
|
7
|
+
export type FieldPath = `${string}.${string}`;
|
|
8
|
+
export type ParsedFieldPath = {
|
|
9
|
+
table: string;
|
|
10
|
+
field: string;
|
|
11
|
+
path: FieldPath;
|
|
12
|
+
};
|
|
13
|
+
/** Parse a `table.field` reference. Returns null when the shape is invalid. */
|
|
14
|
+
export declare function parseFieldPath(ref: string): ParsedFieldPath | null;
|
|
15
|
+
/** Require a valid `table.field` path or throw. */
|
|
16
|
+
export declare function requireFieldPath(ref: string): ParsedFieldPath;
|
|
17
|
+
export declare function formatFieldPath(table: string, field: string): FieldPath;
|
|
18
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const FIELD_PATH_RE = /^([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)$/;
|
|
2
|
+
/** Parse a `table.field` reference. Returns null when the shape is invalid. */
|
|
3
|
+
export function parseFieldPath(ref) {
|
|
4
|
+
const match = FIELD_PATH_RE.exec(ref);
|
|
5
|
+
if (!match)
|
|
6
|
+
return null;
|
|
7
|
+
const table = match[1];
|
|
8
|
+
const field = match[2];
|
|
9
|
+
return { table, field, path: `${table}.${field}` };
|
|
10
|
+
}
|
|
11
|
+
/** Require a valid `table.field` path or throw. */
|
|
12
|
+
export function requireFieldPath(ref) {
|
|
13
|
+
const parsed = parseFieldPath(ref);
|
|
14
|
+
if (!parsed) {
|
|
15
|
+
throw new Error(`Invalid field path: ${ref}`);
|
|
16
|
+
}
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
export function formatFieldPath(table, field) {
|
|
20
|
+
return `${table}.${field}`;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ROW_ID_FIELD } from './schema.js';
|
|
2
|
+
import type { FieldValue, MultiRowRecord, SingleRowTableData } from './types.js';
|
|
3
|
+
export type SlotRow = SingleRowTableData | MultiRowRecord;
|
|
4
|
+
/** Reserved snapshot key; cannot be a company / sequence table name. */
|
|
5
|
+
export declare const SNAPSHOT_CURRENT_KEY = "current";
|
|
6
|
+
export declare function isReservedTableName(tableName: string): boolean;
|
|
7
|
+
/** App-minted row id for jsonb-hosted tables. */
|
|
8
|
+
export declare function mintRowId(): string;
|
|
9
|
+
export declare function isRowIdField(name: string): name is typeof ROW_ID_FIELD;
|
|
10
|
+
export declare function isFieldValue(value: unknown): value is FieldValue;
|
|
11
|
+
export declare function getRowField(row: SlotRow, fieldName: string): FieldValue | undefined;
|
|
12
|
+
/** Schema fields that store envelopes — excludes row `id`. */
|
|
13
|
+
export declare function slotFieldEntries<T>(fields: Record<string, T>): Array<[string, T]>;
|
|
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
|
+
//# sourceMappingURL=row.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { emptyFieldValue } from './field.js';
|
|
2
|
+
import { ROW_ID_FIELD } from './schema.js';
|
|
3
|
+
/** Reserved snapshot key; cannot be a company / sequence table name. */
|
|
4
|
+
export const SNAPSHOT_CURRENT_KEY = 'current';
|
|
5
|
+
const RESERVED_TABLE_NAMES = new Set([SNAPSHOT_CURRENT_KEY, 'derivedOrder', 'reverseDeps']);
|
|
6
|
+
export function isReservedTableName(tableName) {
|
|
7
|
+
return RESERVED_TABLE_NAMES.has(tableName);
|
|
8
|
+
}
|
|
9
|
+
/** App-minted row id for jsonb-hosted tables. */
|
|
10
|
+
export function mintRowId() {
|
|
11
|
+
return crypto.randomUUID();
|
|
12
|
+
}
|
|
13
|
+
export function isRowIdField(name) {
|
|
14
|
+
return name === ROW_ID_FIELD;
|
|
15
|
+
}
|
|
16
|
+
export function isFieldValue(value) {
|
|
17
|
+
return typeof value === 'object' && value !== null && 'state' in value && 'value' in value;
|
|
18
|
+
}
|
|
19
|
+
export function getRowField(row, fieldName) {
|
|
20
|
+
if (isRowIdField(fieldName))
|
|
21
|
+
return undefined;
|
|
22
|
+
const value = row[fieldName];
|
|
23
|
+
return isFieldValue(value) ? value : undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Schema fields that store envelopes — excludes row `id`. */
|
|
26
|
+
export function slotFieldEntries(fields) {
|
|
27
|
+
return Object.entries(fields).filter(([name]) => !isRowIdField(name));
|
|
28
|
+
}
|
|
29
|
+
export function slotFieldNames(fields) {
|
|
30
|
+
return slotFieldEntries(fields).map(([name]) => name);
|
|
31
|
+
}
|
|
32
|
+
/** Envelope cells on a runtime row — excludes `id`. */
|
|
33
|
+
export function rowValueEntries(row) {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const [name, value] of Object.entries(row)) {
|
|
36
|
+
if (isRowIdField(name) || !isFieldValue(value))
|
|
37
|
+
continue;
|
|
38
|
+
out.push([name, value]);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
export function emptySlotRow(fields, options = {}) {
|
|
43
|
+
return fillRowFields({ id: options.id ?? '' }, fields, options.now ?? 0);
|
|
44
|
+
}
|
|
45
|
+
export function emptyMultiRow(fields, id, now = 0) {
|
|
46
|
+
return fillRowFields({ id }, fields, now);
|
|
47
|
+
}
|
|
48
|
+
function fillRowFields(row, fields, now) {
|
|
49
|
+
for (const name of slotFieldNames(fields)) {
|
|
50
|
+
row[name] = emptyFieldValue(now);
|
|
51
|
+
}
|
|
52
|
+
return row;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=row.js.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { FuncRef } from '../functions/func-ref.js';
|
|
2
|
+
import type { FieldPath } from './path.js';
|
|
3
|
+
export type DataType = 'string' | 'number' | 'boolean' | 'date' | 'datetime';
|
|
4
|
+
/** Shared core for normal (non-derived) fields — company + session. */
|
|
5
|
+
export type NormalFieldCore = {
|
|
6
|
+
derived: false;
|
|
7
|
+
label: string;
|
|
8
|
+
dataType: DataType;
|
|
9
|
+
source: 'conversation' | 'system';
|
|
10
|
+
extraction: string;
|
|
11
|
+
enum: Array<string | number> | null;
|
|
12
|
+
nullable: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Reserved row-identity field name. Authors should not invent another. */
|
|
15
|
+
export declare const ROW_ID_FIELD = "id";
|
|
16
|
+
export declare const idFieldCore: {
|
|
17
|
+
readonly derived: false;
|
|
18
|
+
readonly label: 'Id';
|
|
19
|
+
readonly dataType: 'string';
|
|
20
|
+
readonly source: 'system';
|
|
21
|
+
readonly extraction: 'Row identity';
|
|
22
|
+
readonly enum: null;
|
|
23
|
+
readonly nullable: false;
|
|
24
|
+
};
|
|
25
|
+
/** Unified row id. Write `id: idField` on every table. */
|
|
26
|
+
export declare const idField: {
|
|
27
|
+
readonly derived: false;
|
|
28
|
+
readonly label: 'Id';
|
|
29
|
+
readonly dataType: 'string';
|
|
30
|
+
readonly source: 'system';
|
|
31
|
+
readonly extraction: 'Row identity';
|
|
32
|
+
readonly enum: null;
|
|
33
|
+
readonly nullable: false;
|
|
34
|
+
readonly identifier: null;
|
|
35
|
+
};
|
|
36
|
+
export type CompanyNormalFieldDef = NormalFieldCore & {
|
|
37
|
+
/**
|
|
38
|
+
* Whether this field can reverse-look up a party.
|
|
39
|
+
* Sequence configs must not override this.
|
|
40
|
+
*/
|
|
41
|
+
identifier: null | {
|
|
42
|
+
kind: 'phone' | 'email';
|
|
43
|
+
};
|
|
44
|
+
/** Present only on reference fields. Always points at `{table}.id`. */
|
|
45
|
+
ref?: {
|
|
46
|
+
table: string;
|
|
47
|
+
};
|
|
48
|
+
deprecated?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export type CompanyDerivedFieldDef = {
|
|
51
|
+
derived: true;
|
|
52
|
+
label: string;
|
|
53
|
+
dataType: DataType;
|
|
54
|
+
dependsOn: FieldPath[];
|
|
55
|
+
/** String name or `functions.<key>` registration object. */
|
|
56
|
+
computeFn: FuncRef;
|
|
57
|
+
deprecated?: boolean;
|
|
58
|
+
};
|
|
59
|
+
export type CompanyFieldDef = CompanyNormalFieldDef | CompanyDerivedFieldDef;
|
|
60
|
+
export type CompanyTableDef = {
|
|
61
|
+
label: string;
|
|
62
|
+
rows: 'single' | 'multi';
|
|
63
|
+
description: string;
|
|
64
|
+
fields: Record<string, CompanyFieldDef>;
|
|
65
|
+
};
|
|
66
|
+
export type CompanySchema = Record<string, CompanyTableDef>;
|
|
67
|
+
/** Usage-only overrides; structural keys are forbidden. */
|
|
68
|
+
export type FieldOverride = {
|
|
69
|
+
label?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
extraction?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Overlay on an inherited company table. Keys here override usage; other company fields stay as-is. */
|
|
74
|
+
export type SequenceCompanyTableView = {
|
|
75
|
+
fields: Record<string, FieldOverride>;
|
|
76
|
+
};
|
|
77
|
+
/** Session is sequence-owned; always single-row; no derived / identifier. */
|
|
78
|
+
export type SessionTableDef = {
|
|
79
|
+
label: string;
|
|
80
|
+
rows: 'single';
|
|
81
|
+
description: string;
|
|
82
|
+
fields: Record<string, NormalFieldCore>;
|
|
83
|
+
};
|
|
84
|
+
export type SequenceSlots = {
|
|
85
|
+
[table: string]: SequenceCompanyTableView | SessionTableDef;
|
|
86
|
+
session: SessionTableDef;
|
|
87
|
+
};
|
|
88
|
+
/** Effective field shape used for Slots codegen. */
|
|
89
|
+
export type EffectiveFieldDef = {
|
|
90
|
+
dataType: DataType;
|
|
91
|
+
enum: Array<string | number> | null;
|
|
92
|
+
nullable: boolean;
|
|
93
|
+
ref: null | {
|
|
94
|
+
table: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export type EffectiveTableDef = {
|
|
98
|
+
rows: 'single' | 'multi';
|
|
99
|
+
fields: Record<string, EffectiveFieldDef>;
|
|
100
|
+
};
|
|
101
|
+
export type EffectiveSchema = Record<string, EffectiveTableDef>;
|
|
102
|
+
//# sourceMappingURL=schema.d.ts.map
|