@cobol-ts/cel-types 0.0.14 → 0.0.17

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 CHANGED
@@ -1,7 +1,23 @@
1
1
  # @cobol-ts/cel-types
2
2
 
3
- Type-only contracts for scalar CEL values, compiled evaluation functions, pluggable ordinary functions, and the throw/continue evaluation policy. The module does not depend on a specific reader, source format, or CEL parsing implementation.
3
+ Define the CEL value, expression-runner, collection and error-policy contracts shared by compilers and executors.
4
4
 
5
- The initial runtime kinds are `int`, `uint`, `double`, `string`, `bool`, `null`. This is the scalar execution representation, not an alternative source-projection authority. Physical source/projection type metadata determines how a field is decoded and represented.
5
+ These are types, not a parser, source reader, or accumulator storage format.
6
6
 
7
- Collection compilation adds `CompiledCelCollectionExpression` and recursive `CelCollectionValue` for materialised lists, including nested lists and selected shallow source objects. These are separate from `CelValue`: the current graph accumulator is deliberately still scalar.
7
+ ## Main types
8
+
9
+ - `CelScalarKind`, `CelValue` and `CelScalarValueType` describe scalar CEL values and representations.
10
+ - `CelValueType` also describes array, object and map expression types.
11
+ - `CompiledCelExpression` exposes a compiled `run(record, indices)` hot path and optional session-local `createRunner()`.
12
+ - `CompiledCelCollectionExpression` covers materialised collection results; it does not change scalar accumulator semantics.
13
+ - `EvaluationPolicy` and `EvaluationOutcome` separate throw/continue failure handling from the compiled evaluator.
14
+
15
+ The canonical domain type authority lives in [`@cobol-ts/value-types`](../../types/value-types/README.md).
16
+
17
+ ## Source and tests
18
+
19
+ **Public entry points:** [cel.types.ts](./src/cel.types.ts).
20
+
21
+ **Tests:** No package-local test suite; exercised through dependent module tests.
22
+
23
+ **Related:** [@cobol-ts/value-types](../../types/value-types/README.md) · [@cobol-ts/cel-implementation](../implementation/README.md).
@@ -1,10 +1,43 @@
1
+ import type { ScalarValueType } from '@cobol-ts/value-types';
2
+ /** CEL extends domain scalars only for expression-local null and unresolved external values.
3
+ * Canonical graph and projection types remain exclusively domain ValueType. */
4
+ export type CelScalarValueType = Exclude<ScalarValueType, {
5
+ semanticType: 'fixed2' | 'fixed3';
6
+ }> | Readonly<{
7
+ kind: 'scalar';
8
+ semanticType: 'null';
9
+ javascriptType: 'null';
10
+ }> | Readonly<{
11
+ kind: 'scalar';
12
+ semanticType: 'integer' | 'unsignedInteger';
13
+ javascriptType: 'dynamic';
14
+ }>;
15
+ export type CelValueType = CelScalarValueType | Readonly<{
16
+ kind: 'array';
17
+ element: CelValueType;
18
+ }> | Readonly<{
19
+ kind: 'object';
20
+ fields: Readonly<Record<string, CelValueType>>;
21
+ }> | Readonly<{
22
+ kind: 'map';
23
+ key: ScalarValueType;
24
+ value: CelValueType;
25
+ }>;
1
26
  /** CEL scalar kinds used by the first compiled-expression implementation. */
2
27
  export type CelScalarKind = 'int' | 'uint' | 'double' | 'string' | 'bool' | 'null';
3
- export type CelValue<K extends CelScalarKind = CelScalarKind> = K extends 'int' | 'uint' ? bigint : K extends 'double' ? number : K extends 'string' ? string : K extends 'bool' ? boolean : null;
28
+ export type CelValue<K extends CelScalarKind = CelScalarKind> = K extends 'int' | 'uint' ? number | bigint : K extends 'double' ? number : K extends 'string' ? string : K extends 'bool' ? boolean : null;
4
29
  export interface CompiledCelExpression<R, I extends readonly number[]> {
5
30
  readonly type: CelScalarKind;
31
+ /** Compile-time type of the expression, including its working representation. */
32
+ readonly valueType: CelScalarValueType;
33
+ /** Concrete physical output type selected by the compiling interpreter. */
34
+ readonly representation?: 'number' | 'bigint' | 'string' | 'boolean' | 'null' | 'dynamic';
35
+ /** Whether int results may use number in this compiled expression. */
36
+ readonly acceptNumberIntegers?: boolean;
6
37
  /** A function compiled once. This is the unwrapped hot path. */
7
38
  run(record: R, indices: I): CelValue;
39
+ /** Build a stateful runner whose collection scratch belongs to one sequential session. */
40
+ createRunner?(): (record: R, indices: I) => CelValue;
8
41
  }
9
42
  /** Errors are recorded by the execution boundary, never for successful reads. */
10
43
  export type EvaluationPolicy = Readonly<{
@@ -30,6 +63,9 @@ export interface CelCollectionObject {
30
63
  export type CelCollectionValue = CelValue | readonly CelCollectionValue[] | CelCollectionObject;
31
64
  export interface CompiledCelCollectionExpression<R, I extends readonly number[]> {
32
65
  readonly type: 'list';
66
+ readonly valueType: CelValueType;
33
67
  readonly elementType: CelScalarKind | 'object' | 'list';
34
68
  run(record: R, indices: I): readonly CelCollectionValue[];
69
+ /** Separate reusable traversal scratch; returned collections remain independent. */
70
+ createRunner?(): (record: R, indices: I) => readonly CelCollectionValue[];
35
71
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/cel-types",
3
3
  "description": "Value and evaluation contracts for compiled CEL",
4
- "version": "0.0.14",
4
+ "version": "0.0.17",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {
@@ -16,7 +16,9 @@
16
16
  "not op_mini all"
17
17
  ]
18
18
  },
19
- "dependencies": {},
19
+ "dependencies": {
20
+ "@cobol-ts/value-types": "0.0.17"
21
+ },
20
22
  "devDependencies": {
21
23
  "typescript": "^5.2.2",
22
24
  "@testing-library/jest-dom": "^6.1.4",