@superpanel-sdk/runtime 0.0.1-internal.2 → 0.2.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.
@@ -11,7 +11,6 @@ import { toCaseContextViewRegistry, toFunctionRegistry } from './registry.js';
11
11
  const FATAL_CODES = new Set([
12
12
  'unknown-table',
13
13
  'unknown-field',
14
- 'missing-session',
15
14
  'missing-compute-fn',
16
15
  'cyclic-dependency',
17
16
  'multi-derived-forbidden',
@@ -38,7 +38,7 @@ function isCompanySchema(value) {
38
38
  return entries.length > 0 && entries.every(looksLikeTable);
39
39
  }
40
40
  function isSequenceSlots(value) {
41
- return isPlainObject(value) && looksLikeTable(value.session);
41
+ return isPlainObject(value) && Object.values(value).every(looksLikeTable);
42
42
  }
43
43
  /**
44
44
  * Resolve the config object from a dynamically imported module.
@@ -1,4 +1,5 @@
1
1
  import { ROW_ID_FIELD } from './schema.js';
2
+ import { createPlatformSessionTable, PLATFORM_SESSION_FIELDS } from './platform-session-fields.js';
2
3
  import { isReservedTableName, isRowIdField } from './row.js';
3
4
  import { resolveFuncName } from '../functions/func-ref.js';
4
5
  import { buildDependencyGraph } from './deps.js';
@@ -91,14 +92,9 @@ function validateCompanyRefs(company, issues) {
91
92
  */
92
93
  export function compileSlotSchema(company, sequenceSlots, options = {}) {
93
94
  const issues = [];
94
- const tables = {};
95
- if (!sequenceSlots.session) {
96
- issues.push({
97
- code: 'missing-session',
98
- message: 'Sequence slots must define a session table',
99
- path: 'session',
100
- });
101
- }
95
+ const tables = {
96
+ session: createPlatformSessionTable(),
97
+ };
102
98
  for (const [tableName, companyTable] of Object.entries(company)) {
103
99
  if (tableName === 'session' || isReservedTableName(tableName)) {
104
100
  if (isReservedTableName(tableName)) {
@@ -123,6 +119,8 @@ export function compileSlotSchema(company, sequenceSlots, options = {}) {
123
119
  };
124
120
  }
125
121
  for (const [tableName, tableView] of Object.entries(sequenceSlots)) {
122
+ if (!tableView)
123
+ continue;
126
124
  if (isReservedTableName(tableName)) {
127
125
  issues.push({
128
126
  code: 'reserved-table-name',
@@ -144,6 +142,7 @@ export function compileSlotSchema(company, sequenceSlots, options = {}) {
144
142
  }
145
143
  fields[fieldName] = toRuntimeField(fieldDef, options.functions);
146
144
  }
145
+ Object.assign(fields, PLATFORM_SESSION_FIELDS);
147
146
  requireRowIdField(fields, formatFieldPath('session', ROW_ID_FIELD), issues);
148
147
  tables.session = {
149
148
  label: tableView.label,
@@ -0,0 +1,38 @@
1
+ import type { RuntimeTableDef } from './types.js';
2
+ export declare const PLATFORM_SESSION_FIELDS: {
3
+ readonly is_inbound_call: {
4
+ readonly derived: false;
5
+ readonly label: 'Inbound call';
6
+ readonly dataType: 'boolean';
7
+ readonly source: 'system';
8
+ readonly extraction: 'Set by the conversation entry pipeline';
9
+ readonly enum: null;
10
+ readonly nullable: false;
11
+ readonly identifier: null;
12
+ readonly ref: null;
13
+ };
14
+ readonly is_first_call: {
15
+ readonly derived: false;
16
+ readonly label: 'First call';
17
+ readonly dataType: 'boolean';
18
+ readonly source: 'system';
19
+ readonly extraction: 'No prior session for this case contact';
20
+ readonly enum: null;
21
+ readonly nullable: false;
22
+ readonly identifier: null;
23
+ readonly ref: null;
24
+ };
25
+ readonly is_new_user: {
26
+ readonly derived: false;
27
+ readonly label: 'New user';
28
+ readonly dataType: 'boolean';
29
+ readonly source: 'system';
30
+ readonly extraction: 'No existing contact for this party';
31
+ readonly enum: null;
32
+ readonly nullable: false;
33
+ readonly identifier: null;
34
+ readonly ref: null;
35
+ };
36
+ };
37
+ export declare function createPlatformSessionTable(): RuntimeTableDef;
38
+ //# sourceMappingURL=platform-session-fields.d.ts.map
@@ -0,0 +1,48 @@
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
@@ -82,8 +82,8 @@ export type SessionTableDef = {
82
82
  fields: Record<string, NormalFieldCore>;
83
83
  };
84
84
  export type SequenceSlots = {
85
- [table: string]: SequenceCompanyTableView | SessionTableDef;
86
- session: SessionTableDef;
85
+ [table: string]: SequenceCompanyTableView | SessionTableDef | undefined;
86
+ session?: SessionTableDef;
87
87
  };
88
88
  /** Effective field shape used for Slots codegen. */
89
89
  export type EffectiveFieldDef = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superpanel-sdk/runtime",
3
- "version": "0.0.1-internal.2",
3
+ "version": "0.2.0",
4
4
  "description": "Slot + Stage runtime: schema, writes, derived recompute, agenda compile/walk/simulate",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",