wasm-cel 0.5.0 → 0.5.2
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 +3 -1
- package/dist/browser.d.ts +3 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/functions.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +3 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +1 -1
- package/dist/node.js.map +1 -1
- package/dist/options/astValidators.js.map +1 -1
- package/dist/options/base.js.map +1 -1
- package/dist/options/crossTypeNumericComparisons.js.map +1 -1
- package/dist/options/encoders.js.map +1 -1
- package/dist/options/index.js.map +1 -1
- package/dist/options/math.js.map +1 -1
- package/dist/options/optionalTypes.js.map +1 -1
- package/dist/options/options.js.map +1 -1
- package/dist/options/strings.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/main.wasm +0 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -763,8 +763,10 @@ import {
|
|
|
763
763
|
|
|
764
764
|
To build the package from source, you'll need:
|
|
765
765
|
|
|
766
|
-
- Go 1.
|
|
766
|
+
- Go 1.25 or later
|
|
767
767
|
- Node.js 18 or later
|
|
768
|
+
- Rust (stable)
|
|
769
|
+
- `wasm-opt` installed via `cargo install wasm-opt --version 0.116.1 --locked`
|
|
768
770
|
- pnpm (or npm/yarn)
|
|
769
771
|
|
|
770
772
|
```bash
|
package/dist/browser.d.ts
CHANGED
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
*/
|
|
35
35
|
declare function init(wasmBytes: Uint8Array | string | URL | Promise<Uint8Array> | Response, wasmExecUrl?: string | URL): Promise<void>;
|
|
36
36
|
export { Program, Env } from "./core.js";
|
|
37
|
-
export type { CELType, CELTypeDef, CELListType, CELMapType, CELFunctionDefinition, CELFunctionParam, EnvOptions, VariableDeclaration, TypeCheckResult, CompilationIssue, CompilationResult, } from "./types.js";
|
|
38
|
-
export { listType, mapType, CELFunction } from "./functions.js";
|
|
37
|
+
export type { CELType, CELTypeDef, CELListType, CELMapType, EnvExtensions, InferExtensions, TypeExtensionHKT, CELFunctionDefinition, CELFunctionParam, EnvOptions, VariableDeclaration, TypeCheckResult, CompilationIssue, CompilationResult, } from "./types.js";
|
|
38
|
+
export { listType, mapType, optionalType, CELFunction } from "./functions.js";
|
|
39
39
|
export type { CELTypeToTS, ExtractParamTypes } from "./functions.js";
|
|
40
40
|
export { Options } from "./options/index.js";
|
|
41
|
-
export type { EnvOptionConfig, OptionalTypesConfig, ValidationIssue, ValidationContext, ValidatorResult, ASTValidatorFunction, ASTValidatorsConfig, } from "./options/index.js";
|
|
41
|
+
export type { EnvOptionConfig, CELOptionalType, OptionalTypesExt, OptionalTypesConfig, ValidationIssue, ValidationContext, ValidatorResult, ASTValidatorFunction, ASTValidatorsConfig, } from "./options/index.js";
|
|
42
42
|
export { init };
|
|
43
43
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../lib/browser.ts"],"names":[],"mappings":"AA0EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,iBAAe,IAAI,CACjB,SAAS,EAAE,UAAU,GAAG,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,QAAQ,EACrE,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,GACzB,OAAO,CAAC,IAAI,CAAC,CAwEf;AAMD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGzC,YAAY,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../lib/browser.ts"],"names":[],"mappings":"AA0EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,iBAAe,IAAI,CACjB,SAAS,EAAE,UAAU,GAAG,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,QAAQ,EACrE,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,GACzB,OAAO,CAAC,IAAI,CAAC,CAwEf;AAMD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGzC,YAAY,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/browser.js
CHANGED
|
@@ -148,7 +148,7 @@ async function init(wasmBytes, wasmExecUrl) {
|
|
|
148
148
|
setInitFunction(internalInit);
|
|
149
149
|
// Re-export everything from core
|
|
150
150
|
export { Program, Env } from "./core.js";
|
|
151
|
-
export { listType, mapType, CELFunction } from "./functions.js";
|
|
151
|
+
export { listType, mapType, optionalType, CELFunction } from "./functions.js";
|
|
152
152
|
export { Options } from "./options/index.js";
|
|
153
153
|
// Export init function for browser (requires wasmBytes parameter)
|
|
154
154
|
export { init };
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../lib/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAE1D,IAAI,aAAa,GAAG,KAAK,CAAC;AAC1B,IAAI,WAAW,GAAyB,IAAI,CAAC;AAE7C;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAAC,WAA0B;IACpD,mCAAmC;IACnC,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1E,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK,WAAW,EAAE,CAAC;QACxC,OAAO,CAAC,iBAAiB;IAC3B,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,gGAAgG;YAC9F,mBAAmB;YACnB,2EAA2E;YAC3E,0DAA0D,CAC7D,CAAC;IACJ,CAAC;IAED,gCAAgC;IAChC,MAAM,GAAG,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;IAE7E,uEAAuE;IACvE,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,uHAAuH,CACxH,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,MAAM,CAAC,IAAI,GAAG,iBAAiB,CA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,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAa7C,kEAAkE;AAClE,OAAO,EAAE,IAAI,EAAE,CAAC","sourcesContent":["import { setInitFunction, Program, Env } from \"./core.js\";\n\nlet isInitialized = false;\nlet initPromise: Promise<void> | null = null;\n\n/**\n * Load wasm_exec.js from a URL (if not already loaded)\n * @param wasmExecUrl - URL to wasm_exec.js (optional, assumes already loaded if not provided)\n * @returns Promise that resolves when wasm_exec.js is loaded\n */\nasync function loadWasmExec(wasmExecUrl?: string | URL): Promise<void> {\n // Check if Go is already available\n const globalObj = typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.Go !== \"undefined\") {\n return; // Already loaded\n }\n\n if (!wasmExecUrl) {\n throw new Error(\n \"Go WASM runtime (wasm_exec.js) not found. Please load it before initializing the WASM module. \" +\n \"You can either:\\n\" +\n \"1. Load it via script tag: <script src='path/to/wasm_exec.js'></script>\\n\" +\n \"2. Or pass wasmExecUrl to init() to load it dynamically.\",\n );\n }\n\n // Load wasm_exec.js dynamically\n const url = typeof wasmExecUrl === \"string\" ? wasmExecUrl : wasmExecUrl.href;\n\n // Check if we're in an environment with document (browser main thread)\n if (typeof document === \"undefined\") {\n throw new Error(\n \"document is not available. In environments like Web Workers, please load wasm_exec.js manually before calling init().\",\n );\n }\n\n const script = document.createElement(\"script\");\n script.src = url;\n script.type = \"text/javascript\";\n\n return new Promise<void>((resolve, reject) => {\n script.onload = () => {\n if (typeof globalObj.Go === \"undefined\") {\n reject(\n new Error(\n \"wasm_exec.js loaded but Go class not found. Make sure you're using the correct wasm_exec.js file.\",\n ),\n );\n } else {\n resolve();\n }\n };\n script.onerror = () => {\n reject(\n new Error(\n `Failed to load wasm_exec.js from ${url}. Make sure the URL is correct and accessible.`,\n ),\n );\n };\n document.head.appendChild(script);\n });\n}\n\n/**\n * Internal init function that core will call\n */\nasync function internalInit(): Promise<void> {\n if (!isInitialized) {\n throw new Error(\n \"WASM module not initialized. In browsers, you must call init(wasmBytes) with the WASM module bytes or URL before using the library.\",\n );\n }\n}\n\n/**\n * Initialize the WASM module (Browser version - requires WASM bytes)\n * @param wasmBytes - The WASM module bytes. Can be:\n * - Uint8Array: Direct bytes\n * - string: URL to fetch the WASM file from (supports Vite-processed URLs)\n * - URL: URL object pointing to the WASM file\n * - Promise<Uint8Array>: Async import of WASM bytes (for Vite `?init` pattern)\n * - Response: Fetch Response object containing WASM bytes\n * @param wasmExecUrl - Optional URL to wasm_exec.js if it needs to be loaded dynamically\n * @returns {Promise<void>}\n *\n * @example\n * ```typescript\n * // With Vite - recommended pattern using ?url query parameter\n * // Vite will process and optimize the WASM file, returning a URL string\n * import wasmUrl from 'wasm-cel/main.wasm?url';\n * await init(wasmUrl);\n *\n * // With Vite - alternative: fetch the processed URL\n * import wasmUrl from 'wasm-cel/main.wasm?url';\n * const response = await fetch(wasmUrl);\n * await init(response);\n *\n * // Traditional URL (works in any environment)\n * await init('/path/to/main.wasm');\n *\n * // Direct bytes\n * const bytes = await fetch('/main.wasm').then(r => r.arrayBuffer());\n * await init(new Uint8Array(bytes));\n *\n * // URL object\n * await init(new URL('/main.wasm', window.location.origin));\n * ```\n */\nasync function init(\n wasmBytes: Uint8Array | string | URL | Promise<Uint8Array> | Response,\n wasmExecUrl?: string | URL,\n): Promise<void> {\n if (isInitialized) {\n return;\n }\n\n if (initPromise) {\n return initPromise;\n }\n\n initPromise = (async () => {\n // Load wasm_exec.js if needed\n await loadWasmExec(wasmExecUrl);\n\n // Get the Go class\n const globalObj = typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.Go === \"undefined\") {\n throw new Error(\n \"Go WASM runtime not available. Please ensure wasm_exec.js is loaded.\",\n );\n }\n\n // Load WASM bytes\n let wasmBuffer: Uint8Array;\n\n if (wasmBytes instanceof Uint8Array) {\n // Direct bytes\n wasmBuffer = wasmBytes;\n } else if (wasmBytes instanceof Response) {\n // Response object\n const arrayBuffer = await wasmBytes.arrayBuffer();\n wasmBuffer = new Uint8Array(arrayBuffer);\n } else if (wasmBytes instanceof Promise) {\n // Promise resolving to Uint8Array (for Vite ?init pattern or async imports)\n wasmBuffer = await wasmBytes;\n } else if (wasmBytes instanceof URL) {\n // URL object\n const response = await fetch(wasmBytes.href);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch WASM file from ${wasmBytes.href}: ${response.statusText}`,\n );\n }\n const arrayBuffer = await response.arrayBuffer();\n wasmBuffer = new Uint8Array(arrayBuffer);\n } else if (typeof wasmBytes === \"string\") {\n // String URL (supports Vite-processed URLs)\n const response = await fetch(wasmBytes);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch WASM file from ${wasmBytes}: ${response.statusText}`,\n );\n }\n const arrayBuffer = await response.arrayBuffer();\n wasmBuffer = new Uint8Array(arrayBuffer);\n } else {\n throw new Error(\n `Invalid wasmBytes type. Expected Uint8Array, string, URL, Response, or Promise<Uint8Array>, got ${typeof wasmBytes}`,\n );\n }\n\n // Instantiate WASM\n const go = new globalObj.Go();\n // TypeScript needs help with overload resolution - cast through unknown\n const result = (await WebAssembly.instantiate(\n wasmBuffer,\n go.importObject,\n )) as unknown as WebAssembly.WebAssemblyInstantiatedSource;\n go.run(result.instance);\n isInitialized = true;\n })();\n\n return initPromise;\n}\n\n// Set the init function in core (this is what core will call to check initialization)\nsetInitFunction(internalInit);\n\n// Re-export everything from core\nexport { Program, Env } from \"./core.js\";\n\n// Re-export types and functions\nexport type {\n CELType,\n CELTypeDef,\n CELListType,\n CELMapType,\n EnvExtensions,\n InferExtensions,\n TypeExtensionHKT,\n CELFunctionDefinition,\n CELFunctionParam,\n EnvOptions,\n VariableDeclaration,\n TypeCheckResult,\n CompilationIssue,\n CompilationResult,\n} from \"./types.js\";\n\nexport { listType, mapType, optionalType, CELFunction } from \"./functions.js\";\nexport type { CELTypeToTS, ExtractParamTypes } from \"./functions.js\";\nexport { Options } from \"./options/index.js\";\nexport type {\n EnvOptionConfig,\n CELOptionalType,\n OptionalTypesExt,\n OptionalTypesConfig,\n ValidationIssue,\n ValidationContext,\n ValidatorResult,\n ASTValidatorFunction,\n ASTValidatorsConfig,\n} from \"./options/index.js\";\n\n// Export init function for browser (requires wasmBytes parameter)\nexport { init };\n"]}
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../lib/core.ts"],"names":[],"mappings":"AAWA,yEAAyE;AACzE,IAAI,MAAM,GAAiC,IAAI,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,EAAuB;IACrD,MAAM,GAAG,EAAE,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,uKAAuK,CACxK,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,EAAE,CAAC;AACjB,CAAC;AAED,qDAAqD;AACrD,MAAM,YAAY,GAChB,OAAO,MAAM,KAAK,WAAW;IAC3B,CAAC,CAAC,CAAC,KAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC9D,CAAC,CAAC,CAAC,KAAiB,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;AAEjE,MAAM,YAAY,GAChB,OAAO,MAAM,KAAK,WAAW;IAC3B,CAAC,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC,GAAW,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,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;;;OAQG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,2BAA2B;QACrC,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;YAC1E,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBAC/C,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAChD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;oBACjB,sDAAsD;oBACtD,OAAO,CAAC,IAAI,CAAC,kCAAkC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,sDAAsD;YACtD,OAAO,CAAC,IAAI,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;QACvD,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,yEAAyE;YACzE,IAAI,WAAW,EAAE,CAAC;gBAChB,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { _envExtensions } from \"./types.js\";\nimport type {\n CELFunctionDefinition,\n CELTypeDef,\n EnvOptions,\n EnvWithExtensions,\n InferExtensions,\n TypeCheckResult,\n TypeExtensionHKT,\n} from \"./types.js\";\n\n// Init function that will be set by the environment-specific entry point\nlet initFn: (() => Promise<void>) | null = null;\n\n/**\n * Set the initialization function (called by node.ts or browser.ts)\n * @internal\n */\nexport function setInitFunction(fn: () => Promise<void>): void {\n initFn = fn;\n}\n\n/**\n * Call the initialization function\n * @internal\n */\nasync function init(): Promise<void> {\n if (!initFn) {\n throw new Error(\n \"WASM module not initialized. Please call init() first. In Node.js, this happens automatically. In browsers, you must call init(wasmBytes) with the WASM module bytes.\",\n );\n }\n await initFn();\n}\n\n// Base64 encoding/decoding helpers for bytes support\nconst base64Encode =\n typeof Buffer !== \"undefined\"\n ? (bytes: Uint8Array) => Buffer.from(bytes).toString(\"base64\")\n : (bytes: Uint8Array) => btoa(String.fromCharCode(...bytes));\n\nconst base64Decode =\n typeof Buffer !== \"undefined\"\n ? (str: string) => new Uint8Array(Buffer.from(str, \"base64\"))\n : (str: string) => {\n const binary = atob(str);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n };\n\n/**\n * Recursively prepare variables for serialization to WASM.\n * Converts Uint8Array/Buffer values to tagged bytes objects.\n * @internal\n */\nfunction prepareVarsForWasm(vars: Record<string, any>): Record<string, any> {\n const result: Record<string, any> = {};\n for (const [key, value] of Object.entries(vars)) {\n result[key] = encodeBytes(value);\n }\n return result;\n}\n\nfunction encodeBytes(value: any): any {\n if (value instanceof Uint8Array) {\n return { $bytes: base64Encode(value) };\n }\n if (typeof Buffer !== \"undefined\" && Buffer.isBuffer(value)) {\n return { $bytes: (value as Buffer).toString(\"base64\") };\n }\n if (Array.isArray(value)) {\n return value.map(encodeBytes);\n }\n if (value !== null && typeof value === \"object\") {\n const result: Record<string, any> = {};\n for (const [k, v] of Object.entries(value)) {\n result[k] = encodeBytes(v);\n }\n return result;\n }\n return value;\n}\n\n/**\n * Recursively decode tagged bytes objects in WASM results to Uint8Array.\n * @internal\n */\nfunction decodeBytes(value: any): any {\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value === \"object\" && !Array.isArray(value)) {\n // Detect tagged bytes: { $bytes: \"<base64>\" }\n const keys = Object.keys(value);\n if (keys.length === 1 && keys[0] === \"$bytes\" && typeof value.$bytes === \"string\") {\n return base64Decode(value.$bytes);\n }\n // Recursively decode map values\n const result: Record<string, any> = {};\n for (const [k, v] of Object.entries(value)) {\n result[k] = decodeBytes(v);\n }\n return result;\n }\n if (Array.isArray(value)) {\n return value.map(decodeBytes);\n }\n return value;\n}\n\n/**\n * Serialize a CEL type definition to a format that can be sent to Go\n */\nfunction serializeTypeDef(type: CELTypeDef<any>): any {\n if (typeof type === \"string\") {\n return type;\n }\n if (typeof type === \"object\" && type !== null) {\n if (\"kind\" in type) {\n if (type.kind === \"list\") {\n return {\n kind: \"list\",\n elementType: serializeTypeDef(type.elementType),\n };\n }\n if (type.kind === \"map\") {\n return {\n kind: \"map\",\n keyType: serializeTypeDef(type.keyType),\n valueType: serializeTypeDef(type.valueType),\n };\n }\n if ((type as any).kind === \"optional\") {\n return {\n kind: \"optional\",\n innerType: serializeTypeDef((type as any).innerType),\n };\n }\n }\n }\n return \"dyn\"; // Fallback to dynamic type\n}\n\n/**\n * Serialize function definitions for transmission to Go\n */\n// Counter for generating unique implementation IDs\nlet implIDCounter = 0;\n\nfunction expandFunctionDefinitions(\n functions: CELFunctionDefinition[],\n): CELFunctionDefinition[] {\n const expanded: CELFunctionDefinition[] = [];\n\n const visit = (fn: CELFunctionDefinition): void => {\n expanded.push(fn);\n if (fn.overloads && fn.overloads.length > 0) {\n for (const overload of fn.overloads) {\n visit(overload);\n }\n }\n };\n\n for (const fn of functions) {\n visit(fn);\n }\n\n return expanded;\n}\n\nfunction serializeFunctionDefs(functions: CELFunctionDefinition[]): Array<{\n name: string;\n params: Array<{ name: string; type: any; optional?: boolean }>;\n returnType: any;\n implID: string;\n}> {\n const flattened = expandFunctionDefinitions(functions);\n\n return flattened.map((fn, index) => {\n // Generate a unique implementation ID\n const implID = `${fn.name}_${index}_${++implIDCounter}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n\n // Register the JavaScript function implementation\n const globalObj = typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.registerCELFunction === \"function\") {\n const registerResult = globalObj.registerCELFunction(implID, fn.impl);\n if (registerResult.error) {\n throw new Error(\n `Failed to register function ${fn.name}: ${registerResult.error}`,\n );\n }\n } else {\n throw new Error(\n \"registerCELFunction not available. Make sure WASM is initialized.\",\n );\n }\n\n return {\n name: fn.name,\n params: fn.params.map((param) => ({\n name: param.name,\n type: serializeTypeDef(param.type),\n optional: param.optional,\n })),\n returnType: serializeTypeDef(fn.returnType),\n implID,\n };\n });\n}\n\n// FinalizationRegistry for automatic cleanup\n// This provides best-effort cleanup when objects are garbage collected\nconst programRegistry =\n typeof FinalizationRegistry !== \"undefined\"\n ? new FinalizationRegistry<string>((programID: string) => {\n // Best-effort cleanup when program is garbage collected\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.destroyProgram === \"function\") {\n globalObj.destroyProgram(programID);\n }\n } catch (err) {\n // Ignore errors during finalization - this is best-effort only\n }\n })\n : null;\n\nconst envRegistry =\n typeof FinalizationRegistry !== \"undefined\"\n ? new FinalizationRegistry<string>((envID: string) => {\n // Best-effort cleanup when environment is garbage collected\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.destroyEnv === \"function\") {\n globalObj.destroyEnv(envID);\n }\n } catch (err) {\n // Ignore errors during finalization - this is best-effort only\n }\n })\n : null;\n\n/**\n * A compiled CEL program that can be evaluated with variables\n */\nexport class Program {\n private programID: string;\n private destroyed: boolean = false;\n\n constructor(programID: string) {\n this.programID = programID;\n // Register for automatic cleanup via FinalizationRegistry\n if (programRegistry) {\n programRegistry.register(this, programID);\n }\n }\n\n /**\n * Evaluate the compiled program with the given variables\n * @param vars - Variables to use in the evaluation\n * @returns Promise resolving to the evaluation result\n * @throws Error if evaluation fails or program has been destroyed\n */\n async eval(vars: Record<string, any> | null = null): Promise<any> {\n if (this.destroyed) {\n throw new Error(\"Program has been destroyed\");\n }\n\n await init();\n\n return new Promise<any>((resolve, reject) => {\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n const preparedVars = vars ? prepareVarsForWasm(vars) : {};\n const result = globalObj.evalProgram(this.programID, preparedVars);\n\n if (result.error) {\n reject(new Error(result.error));\n } else {\n resolve(decodeBytes(result.result));\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reject(new Error(`WASM call failed: ${error.message}`));\n }\n });\n }\n\n /**\n * Destroy this program and free associated WASM resources.\n * After calling destroy(), this program instance should not be used.\n * If FinalizationRegistry is available, resources will be automatically\n * cleaned up when the object is garbage collected, but explicit cleanup\n * is recommended.\n */\n destroy(): void {\n if (this.destroyed) {\n return; // Already destroyed, no-op\n }\n\n try {\n const globalObj = typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.destroyProgram === \"function\") {\n const result = globalObj.destroyProgram(this.programID);\n if (result.error) {\n // Log but don't throw - cleanup should be best-effort\n console.warn(`Failed to destroy program: ${result.error}`);\n }\n }\n } catch (err) {\n // Log but don't throw - cleanup should be best-effort\n console.warn(`Error destroying program: ${err}`);\n } finally {\n this.destroyed = true;\n // Unregister from FinalizationRegistry since we've explicitly cleaned up\n if (programRegistry) {\n programRegistry.unregister(this);\n }\n }\n }\n}\n\n/**\n * A CEL environment that holds variable declarations and function definitions\n */\nexport class Env<Exts extends TypeExtensionHKT[] = []>\n implements EnvWithExtensions<Exts>\n{\n private envID: string;\n private destroyed: boolean = false;\n declare readonly [_envExtensions]?: Exts;\n\n private constructor(envID: string) {\n this.envID = envID;\n // Register for automatic cleanup via FinalizationRegistry\n if (envRegistry) {\n envRegistry.register(this, envID);\n }\n }\n\n /**\n * Get the environment ID (useful for debugging or advanced use cases)\n */\n getID(): string {\n return this.envID;\n }\n\n /**\n * Create a new CEL environment\n * @param options - Options including variable declarations, function definitions, and environment options\n * @returns Promise resolving to a new Env instance\n * @throws Error if environment creation fails\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [\n * { name: \"x\", type: \"int\" },\n * { name: \"y\", type: \"int\" }\n * ],\n * functions: [\n * CELFunction.new(\"add\")\n * .param(\"a\", \"int\")\n * .param(\"b\", \"int\")\n * .returns(\"int\")\n * .implement((a, b) => a + b)\n * ],\n * options: [\n * Options.optionalTypes()\n * ]\n * });\n * ```\n */\n static async new<Opts extends readonly import(\"./options/index.js\").EnvOptionInput<any>[] = []>(\n options?: Omit<EnvOptions<InferExtensions<Opts>>, \"options\"> & {\n options?: Opts;\n },\n ): Promise<Env<InferExtensions<Opts>>> {\n await init();\n\n // Serialize variable declarations\n const varDecls = (options?.variables || []).map((v) => ({\n name: v.name,\n type: serializeTypeDef(v.type),\n }));\n\n // Serialize function definitions if provided\n let serializedFuncDefs: any = null;\n if (options?.functions && options.functions.length > 0) {\n serializedFuncDefs = serializeFunctionDefs(options.functions);\n }\n\n // INTERNAL: Create environment first without options, then extend if needed\n // This allows complex options to perform JavaScript-side setup before being applied\n const env = await new Promise<Env<InferExtensions<Opts>>>((resolve, reject) => {\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n const result = globalObj.createEnv(varDecls, serializedFuncDefs);\n\n if (result.error) {\n reject(new Error(result.error));\n } else if (!result.envID) {\n reject(new Error(\"Environment creation failed: no envID returned\"));\n } else {\n resolve(new Env<InferExtensions<Opts>>(result.envID));\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reject(new Error(`WASM call failed: ${error.message}`));\n }\n });\n\n // INTERNAL: If options were provided, extend the environment\n // This allows options to perform JavaScript-side setup (like registering functions)\n if (options?.options && options.options.length > 0) {\n await env._extendWithOptions([...options.options]);\n }\n\n return env;\n }\n\n /**\n * Compile a CEL expression in this environment\n * @param expr - The CEL expression to compile\n * @returns Promise resolving to a compiled Program\n * @throws Error if compilation fails or environment has been destroyed\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [{ name: \"x\", type: \"int\" }]\n * });\n * const program = await env.compile(\"x + 10\");\n * const result = await program.eval({ x: 5 });\n * console.log(result); // 15\n * ```\n */\n async compile(expr: string): Promise<Program> {\n if (this.destroyed) {\n throw new Error(\"Environment has been destroyed\");\n }\n\n await init();\n\n if (typeof expr !== \"string\") {\n throw new Error(\"Expression must be a string\");\n }\n\n return new Promise<Program>((resolve, reject) => {\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n const result = globalObj.compileExpr(this.envID, expr);\n\n if (result.error) {\n reject(new Error(result.error));\n } else if (!result.programID) {\n reject(new Error(\"Compilation failed: no programID returned\"));\n } else {\n resolve(new Program(result.programID));\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reject(new Error(`WASM call failed: ${error.message}`));\n }\n });\n }\n\n /**\n * Compile a CEL expression with detailed results including warnings and issues\n * @param expr - The CEL expression to compile\n * @returns Promise resolving to detailed compilation results\n * @throws Error if environment has been destroyed\n *\n * @example\n * ```typescript\n * const result = await env.compileDetailed(\"x + y\");\n * if (result.success) {\n * console.log(\"Compiled successfully\");\n * if (result.issues.length > 0) {\n * console.log(\"Warnings:\", result.issues);\n * }\n * const evalResult = await result.program.eval({ x: 10, y: 20 });\n * } else {\n * console.log(\"Compilation failed:\", result.error);\n * console.log(\"All issues:\", result.issues);\n * }\n * ```\n */\n async compileDetailed(\n expr: string,\n ): Promise<import(\"./types.js\").CompilationResult> {\n if (this.destroyed) {\n throw new Error(\"Environment has been destroyed\");\n }\n\n await init();\n\n if (typeof expr !== \"string\") {\n throw new Error(\"Expression must be a string\");\n }\n\n return new Promise<import(\"./types.js\").CompilationResult>((resolve) => {\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n const result = (globalObj as any).compileExprDetailed(this.envID, expr);\n\n if (result.error && !result.programID) {\n // Compilation failed completely\n resolve({\n success: false,\n error: result.error,\n issues: result.issues || [],\n program: undefined,\n });\n } else if (result.programID) {\n // Compilation succeeded (possibly with warnings)\n resolve({\n success: true,\n error: undefined,\n issues: result.issues || [],\n program: new Program(result.programID),\n });\n } else {\n // Unexpected state\n resolve({\n success: false,\n error: \"Compilation failed: no programID returned\",\n issues: result.issues || [],\n program: undefined,\n });\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n resolve({\n success: false,\n error: `WASM call failed: ${error.message}`,\n issues: [],\n program: undefined,\n });\n }\n });\n }\n\n /**\n * Typecheck a CEL expression in this environment without compiling it\n * @param expr - The CEL expression to typecheck\n * @returns Promise resolving to the type information\n * @throws Error if typechecking fails or environment has been destroyed\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [{ name: \"x\", type: \"int\" }, { name: \"y\", type: \"int\" }]\n * });\n * const typeInfo = await env.typecheck(\"x + y\");\n * console.log(typeInfo.type); // \"int\"\n *\n * const listType = await env.typecheck(\"[1, 2, 3]\");\n * console.log(listType.type); // { kind: \"list\", elementType: \"int\" }\n * ```\n */\n async typecheck(expr: string): Promise<TypeCheckResult> {\n if (this.destroyed) {\n throw new Error(\"Environment has been destroyed\");\n }\n\n await init();\n\n if (typeof expr !== \"string\") {\n throw new Error(\"Expression must be a string\");\n }\n\n return new Promise<TypeCheckResult>((resolve, reject) => {\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n const result = globalObj.typecheckExpr(this.envID, expr);\n\n if (result.error) {\n reject(new Error(result.error));\n } else if (result.type === undefined) {\n reject(new Error(\"Typecheck failed: no type returned\"));\n } else {\n resolve({ type: result.type });\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reject(new Error(`WASM call failed: ${error.message}`));\n }\n });\n }\n\n /**\n * Extend this environment with additional CEL environment options\n * @param options - Array of CEL environment option configurations or complex options with setup\n * @returns Promise that resolves when the environment has been extended\n * @throws Error if extension fails or environment has been destroyed\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [{ name: \"x\", type: \"int\" }]\n * });\n *\n * // Add options after creation\n * await env.extend([Options.optionalTypes()]);\n * ```\n */\n async extend(\n options: import(\"./options/index.js\").EnvOptionInput[],\n ): Promise<void> {\n return this._extendWithOptions(options);\n }\n\n /**\n * Internal method to extend environment with options\n * This method delegates to options that implement OptionWithSetup for complex operations\n * @private\n */\n private async _extendWithOptions(\n options: import(\"./options/index.js\").EnvOptionInput[],\n ): Promise<void> {\n if (this.destroyed) {\n throw new Error(\"Environment has been destroyed\");\n }\n\n await init();\n\n if (!options || options.length === 0) {\n return; // Nothing to extend\n }\n\n // Process options: delegate to options that can handle their own setup\n const processedOptions: import(\"./options/index.js\").EnvOptionConfig[] = [];\n\n for (const option of options) {\n // Check if this option implements OptionWithSetup\n if (\n \"setupAndProcess\" in option &&\n typeof option.setupAndProcess === \"function\"\n ) {\n // Let the option handle its own complex setup operations\n const setupEnv: import(\"./options/index.js\").OptionSetupEnvironment = {\n getID: () => this.getID(),\n registerFunction: async (\n name: string,\n impl: (...args: any[]) => any,\n ): Promise<string> => {\n if (this.destroyed) {\n throw new Error(\"Environment has been destroyed\");\n }\n\n // Generate a unique implementation ID for this function\n const implID = `${name}_${this.envID}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n\n // Register the JavaScript function implementation\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.registerCELFunction === \"function\") {\n const registerResult = globalObj.registerCELFunction(\n implID,\n impl,\n );\n if (registerResult.error) {\n throw new Error(\n `Failed to register function ${name}: ${registerResult.error}`,\n );\n }\n } else {\n throw new Error(\n \"registerCELFunction not available. Make sure WASM is initialized.\",\n );\n }\n\n // Return the actual implementation ID that was registered\n return implID;\n },\n };\n const processedOption = await option.setupAndProcess(setupEnv);\n processedOptions.push(processedOption);\n } else {\n // Simple option configuration, pass through directly\n processedOptions.push(\n option as import(\"./options/index.js\").EnvOptionConfig,\n );\n }\n }\n\n const serializedOptions = JSON.stringify(processedOptions);\n\n return new Promise<void>((resolve, reject) => {\n try {\n const globalObj =\n typeof globalThis !== \"undefined\" ? globalThis : global;\n const result = globalObj.extendEnv(this.envID, serializedOptions);\n\n if (result.error) {\n reject(new Error(result.error));\n } else {\n resolve();\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reject(new Error(`WASM call failed: ${error.message}`));\n }\n });\n }\n\n /**\n * Destroy this environment and free associated WASM resources.\n * This will also clean up any registered JavaScript functions associated\n * with this environment.\n * After calling destroy(), this environment instance should not be used.\n * If FinalizationRegistry is available, resources will be automatically\n * cleaned up when the object is garbage collected, but explicit cleanup\n * is recommended.\n */\n destroy(): void {\n if (this.destroyed) {\n return; // Already destroyed, no-op\n }\n\n try {\n const globalObj = typeof globalThis !== \"undefined\" ? globalThis : global;\n if (typeof globalObj.destroyEnv === \"function\") {\n const result = globalObj.destroyEnv(this.envID);\n if (result.error) {\n // Log but don't throw - cleanup should be best-effort\n console.warn(`Failed to destroy environment: ${result.error}`);\n }\n }\n } catch (err) {\n // Log but don't throw - cleanup should be best-effort\n console.warn(`Error destroying environment: ${err}`);\n } finally {\n this.destroyed = true;\n // Unregister from FinalizationRegistry since we've explicitly cleaned up\n if (envRegistry) {\n envRegistry.unregister(this);\n }\n }\n }\n}\n"]}
|
package/dist/functions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../lib/functions.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6GH,MAAM,OAAO,WAAW;IAYtB,YACE,IAAY,EACZ,SAAiE,EAAE,EACnE,aAA6D,KAAK,EAClE,YAAqC,EAAE;QANjC,cAAS,GAA4B,EAAE,CAAC;QAQ9C,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CACb,0BAA0B,IAAI,mCAAmC,CAClE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,GAAG,CACR,IAAY;QAEZ,OAAO,I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AAM,UAAU,OAAO,CACrB,OAAmB,EACnB,SAAqB;IAErB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,SAAY;IAEZ,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AACzC,CAAC","sourcesContent":["/**\n * Type-safe builder for CEL function definitions\n */\n\nimport type {\n CELFunctionDefinition,\n CELFunctionParam,\n CELTypeDef,\n EnvWithExtensions,\n TypeExtensionHKT,\n} from \"./types.js\";\nimport type { CELOptionalType } from \"./options/optionalTypes.js\";\n\ntype CELFunctionContext = TypeExtensionHKT[] | EnvWithExtensions<any>;\n\ntype ResolveFunctionExtensions<Context> = Context extends TypeExtensionHKT[]\n ? Context\n : Context extends EnvWithExtensions<infer Exts>\n ? Exts\n : [];\n\n/**\n * Maps a CEL type definition to its corresponding TypeScript type.\n *\n * Useful for deriving the TS type that a CEL value will have at runtime,\n * e.g. when building wrappers or utilities on top of {@link CELFunction}.\n *\n * @example\n * ```typescript\n * import type { CELTypeToTS } from \"wasm-cel\";\n *\n * type N = CELTypeToTS<\"int\">; // number\n * type S = CELTypeToTS<\"string\">; // string\n * type L = CELTypeToTS<{ kind: \"list\"; elementType: \"bool\" }>; // boolean[]\n * ```\n */\nexport type CELTypeToTS<\n T extends CELTypeDef<any>,\n Depth extends readonly unknown[] = [],\n> = Depth[\"length\"] extends 5\n ? any // Limit recursion depth to 5 levels\n : T extends \"bool\"\n ? boolean\n : T extends \"int\" | \"uint\" | \"double\"\n ? number\n : T extends \"string\"\n ? string\n : T extends \"bytes\"\n ? string\n : T extends { kind: \"list\"; elementType: infer E }\n ? E extends CELTypeDef\n ? Array<CELTypeToTS<E, [...Depth, unknown]>>\n : never\n : T extends { kind: \"map\"; keyType: infer K; valueType: infer V }\n ? V extends CELTypeDef\n ? Record<string, CELTypeToTS<V, [...Depth, unknown]>>\n : never\n : T extends CELOptionalType<infer Inner>\n ? CELTypeToTS<Inner, [...Depth, unknown]> | null\n : T extends \"dyn\"\n ? any\n : T extends \"null\"\n ? null\n : T extends \"timestamp\"\n ? Date\n : T extends \"duration\"\n ? string\n : never;\n\n/**\n * Extracts a TypeScript parameter-type tuple from CEL function parameter definitions.\n *\n * Given a tuple of {@link CELFunctionParam} entries (as accumulated by the builder),\n * produces the matching tuple of TypeScript types — the same tuple used for the\n * `impl` callback signature in {@link CELFunction.implement}.\n *\n * @example\n * ```typescript\n * import type { ExtractParamTypes, CELFunctionParam } from \"wasm-cel\";\n *\n * type Params = readonly [\n * { name: \"a\"; type: \"int\"; optional: false },\n * { name: \"b\"; type: \"string\"; optional: false },\n * { name: \"c\"; type: \"bool\"; optional: true },\n * ];\n *\n * type Args = ExtractParamTypes<Params>; // [number, string, boolean | undefined]\n * ```\n */\nexport type ExtractParamTypes<P extends readonly CELFunctionParam<any>[]> = {\n [K in keyof P]: P[K] extends CELFunctionParam\n ? P[K][\"optional\"] extends true\n ? CELTypeToTS<P[K][\"type\"]> | undefined\n : CELTypeToTS<P[K][\"type\"]>\n : never;\n};\n\n/**\n * Builder class for creating type-safe CEL function definitions\n *\n * @example\n * ```typescript\n * const add = CELFunction.new(\"add\")\n * .param(\"a\", \"int\")\n * .param(\"b\", \"int\")\n * .returns(\"int\")\n * .implement((a, b) => a + b);\n * ```\n */\ntype BuilderStage = \"params\" | \"returns\";\n\nexport class CELFunction<\n Context extends CELFunctionContext | [] = [],\n Stage extends BuilderStage = \"params\",\n Params extends readonly CELFunctionParam<ResolveFunctionExtensions<Context>>[] = readonly [],\n ReturnType extends CELTypeDef<ResolveFunctionExtensions<Context>> = \"dyn\",\n> {\n private readonly stageMarker!: Stage;\n private name: string;\n private readonly params: CELFunctionParam<ResolveFunctionExtensions<Context>>[];\n private returnType: CELTypeDef<ResolveFunctionExtensions<Context>>;\n private overloads: CELFunctionDefinition[] = [];\n\n private constructor(\n name: string,\n params: CELFunctionParam<ResolveFunctionExtensions<Context>>[] = [],\n returnType: CELTypeDef<ResolveFunctionExtensions<Context>> = \"dyn\",\n overloads: CELFunctionDefinition[] = [],\n ) {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n throw new Error(\n `Invalid function name: ${name}. Must be a valid CEL identifier.`,\n );\n }\n this.name = name;\n this.params = params;\n this.returnType = returnType;\n this.overloads = [...overloads];\n }\n\n /**\n * Create a new CEL function builder\n * @param name - The name of the function\n * @returns A builder instance for chaining\n *\n * @example\n * ```typescript\n * const add = CELFunction.new(\"add\")\n * .param(\"a\", \"int\")\n * .param(\"b\", \"int\")\n * .returns(\"int\")\n * .implement((a, b) => a + b);\n * ```\n */\n static new<Context extends CELFunctionContext | [] = []>(\n name: string,\n ): CELFunction<Context, \"params\", readonly [], \"dyn\"> {\n return new CELFunction<Context, \"params\", readonly [], \"dyn\">(name);\n }\n\n /**\n * Add a parameter to the function\n */\n param<\n T extends CELTypeDef<ResolveFunctionExtensions<Context>>,\n Optional extends boolean = false,\n >(\n this: CELFunction<Context, \"params\", Params, ReturnType>,\n name: string,\n type: T,\n optional?: Optional,\n ): CELFunction<\n Context,\n \"params\",\n readonly [...Params, { name: string; type: T; optional: Optional }],\n ReturnType\n > {\n const newParams = [\n ...this.params,\n { name, type, optional: (optional ?? false) as Optional },\n ] as CELFunctionParam<ResolveFunctionExtensions<Context>>[];\n return new CELFunction<\n Context,\n \"params\",\n readonly [...Params, { name: string; type: T; optional: Optional }],\n ReturnType\n >(this.name, newParams, this.returnType, this.overloads);\n }\n\n /**\n * Set the return type of the function\n */\n returns<T extends CELTypeDef<ResolveFunctionExtensions<Context>>>(\n this: CELFunction<Context, \"params\", Params, ReturnType>,\n type: T,\n ): CELFunction<Context, \"returns\", Params, T> {\n return new CELFunction<Context, \"returns\", Params, T>(\n this.name,\n this.params,\n type,\n this.overloads,\n );\n }\n\n /**\n * Set the implementation function and return the final definition\n */\n implement(\n this: CELFunction<Context, \"returns\", Params, ReturnType>,\n impl: (...args: ExtractParamTypes<Params>) => CELTypeToTS<ReturnType>,\n ): CELFunctionDefinition {\n const definition = {\n name: this.name,\n params: [...this.params],\n returnType: this.returnType,\n impl: impl as (...args: any[]) => any,\n } as CELFunctionDefinition;\n\n if (this.overloads.length > 0) {\n definition.overloads = this.overloads;\n }\n\n return definition;\n }\n\n /**\n * Add an overload variant of this function\n */\n overload(\n this: CELFunction<Context, \"returns\", Params, ReturnType>,\n overload: CELFunctionDefinition,\n ): CELFunction<Context, \"returns\", Params, ReturnType> {\n if (overload.name !== this.name) {\n throw new Error(\n `Overload name mismatch: expected ${this.name}, got ${overload.name}`,\n );\n }\n this.overloads.push(overload);\n return this;\n }\n}\n\n/**\n * Helper function to create a list type\n */\nexport function listType<Exts extends TypeExtensionHKT[] = []>(\n elementType: CELTypeDef<Exts>,\n): {\n kind: \"list\";\n elementType: CELTypeDef<Exts>;\n} {\n return { kind: \"list\", elementType };\n}\n\n/**\n * Helper function to create a map type\n */\nexport function mapType(\n keyType: CELTypeDef,\n valueType: CELTypeDef,\n): { kind: \"map\"; keyType: CELTypeDef; valueType: CELTypeDef } {\n return { kind: \"map\", keyType, valueType };\n}\n\nexport function optionalType<const T extends CELTypeDef<any>>(\n innerType: T,\n): CELOptionalType<T> {\n return { kind: \"optional\", innerType };\n}\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,kBAAkB;AAClB,yFAAyF;AACzF,mEAAmE;AACnE,EAAE;AACF,qEAAqE;AACrE,6EAA6E;AAE7E,yCAAyC;AACzC,MAAM,SAAS,GACb,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,CAAC;AAEnE,gCAAgC;AAChC,6DAA6D;AAC7D,MAAM,MAAM,GAAG,SAAS;IACtB,CAAC,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC;IAC9B,CAAC,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;AAE9B,uBAAuB;AACvB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,kBAAkB;AAClB,yFAAyF;AACzF,mEAAmE;AACnE,EAAE;AACF,qEAAqE;AACrE,6EAA6E;AAE7E,yCAAyC;AACzC,MAAM,SAAS,GACb,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,CAAC;AAEnE,gCAAgC;AAChC,6DAA6D;AAC7D,MAAM,MAAM,GAAG,SAAS;IACtB,CAAC,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC;IAC9B,CAAC,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;AAE9B,uBAAuB;AACvB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["// Main entry point with runtime environment detection\n//\n// This works for:\n// 1. Bundlers: They use package.json conditional exports (preferred, tree-shakes better)\n// 2. Native ES modules: Runtime detection selects the right module\n//\n// For best results with bundlers, they will use conditional exports.\n// For native ES modules without bundlers, this file detects the environment.\n\n// Detect environment at module load time\nconst isBrowser =\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\n\n// Import the appropriate module\n// Note: This is a top-level await, which works in ES modules\nconst module = isBrowser\n ? await import(\"./browser.js\")\n : await import(\"./node.js\");\n\n// Re-export everything\nexport const { Program, Env, init } = module;\nexport { listType, mapType, optionalType, CELFunction } from \"./functions.js\";\nexport type { CELTypeToTS, ExtractParamTypes } from \"./functions.js\";\nexport { Options } from \"./options/index.js\";\n\n// Re-export types\nexport type {\n CELType,\n CELTypeDef,\n CELListType,\n CELMapType,\n EnvExtensions,\n InferExtensions,\n TypeExtensionHKT,\n CELFunctionDefinition,\n CELFunctionParam,\n EnvOptions,\n VariableDeclaration,\n TypeCheckResult,\n CompilationIssue,\n CompilationResult,\n} from \"./types.js\";\n\nexport type {\n EnvOptionConfig,\n CELOptionalType,\n OptionalTypesExt,\n OptionalTypesConfig,\n ValidationIssue,\n ValidationContext,\n ValidatorResult,\n ASTValidatorFunction,\n ASTValidatorsConfig,\n} from \"./options/index.js\";\n"]}
|
package/dist/node.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
declare function init(): Promise<void>;
|
|
6
6
|
export { Program, Env } from "./core.js";
|
|
7
|
-
export type { CELType, CELTypeDef, CELListType, CELMapType, CELFunctionDefinition, CELFunctionParam, EnvOptions, VariableDeclaration, TypeCheckResult, CompilationIssue, CompilationResult, } from "./types.js";
|
|
8
|
-
export { listType, mapType, CELFunction } from "./functions.js";
|
|
7
|
+
export type { CELType, CELTypeDef, CELListType, CELMapType, EnvExtensions, InferExtensions, TypeExtensionHKT, CELFunctionDefinition, CELFunctionParam, EnvOptions, VariableDeclaration, TypeCheckResult, CompilationIssue, CompilationResult, } from "./types.js";
|
|
8
|
+
export { listType, mapType, optionalType, CELFunction } from "./functions.js";
|
|
9
9
|
export type { CELTypeToTS, ExtractParamTypes } from "./functions.js";
|
|
10
10
|
export { Options } from "./options/index.js";
|
|
11
|
-
export type { EnvOptionConfig, OptionalTypesConfig, ValidationIssue, ValidationContext, ValidatorResult, ASTValidatorFunction, ASTValidatorsConfig, } from "./options/index.js";
|
|
11
|
+
export type { EnvOptionConfig, CELOptionalType, OptionalTypesExt, OptionalTypesConfig, ValidationIssue, ValidationContext, ValidatorResult, ASTValidatorFunction, ASTValidatorsConfig, } from "./options/index.js";
|
|
12
12
|
export { init };
|
|
13
13
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../lib/node.ts"],"names":[],"mappings":"AAuCA;;;GAGG;AACH,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuCnC;AAMD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGzC,YAAY,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../lib/node.ts"],"names":[],"mappings":"AAuCA;;;GAGG;AACH,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuCnC;AAMD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGzC,YAAY,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/node.js
CHANGED
|
@@ -66,7 +66,7 @@ async function init() {
|
|
|
66
66
|
setInitFunction(init);
|
|
67
67
|
// Re-export everything from core
|
|
68
68
|
export { Program, Env } from "./core.js";
|
|
69
|
-
export { listType, mapType, CELFunction } from "./functions.js";
|
|
69
|
+
export { listType, mapType, optionalType, CELFunction } from "./functions.js";
|
|
70
70
|
export { Options } from "./options/index.js";
|
|
71
71
|
// Export init function for Node.js (no parameters needed - auto-loads)
|
|
72
72
|
export { init };
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../lib/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAE1D,kCAAkC;AAClC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,4DAA4D;AAC5D,uEAAuE;AACvE,IAAI,YAAY,GAAG,IAAI,CAAC,I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C;AAED,gCAAgC;AAChC,eAAe,CAAC,IAAI,CAAC,CAAC;AAEtB,iCAAiC;AACjC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAoBzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAa7C,uEAAuE;AACvE,OAAO,EAAE,IAAI,EAAE,CAAC","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { execSync } from \"node:child_process\";\nimport { createRequire } from \"node:module\";\nimport { setInitFunction, Program, Env } from \"./core.js\";\n\n// Get __dirname equivalent in ESM\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Load wasm_exec.cjs if it exists, otherwise use a fallback\n// wasm_exec.cjs is a CommonJS file, so we use createRequire to load it\nlet wasmExecPath = path.join(__dirname, \"..\", \"wasm_exec.cjs\");\nif (!fs.existsSync(wasmExecPath)) {\n // Try to find it in Go installation (as .js, we'll load it as .cjs)\n const goRoot =\n process.env.GOROOT ||\n execSync(\"go env GOROOT\", { encoding: \"utf-8\" }).trim();\n const goWasmExecPath = path.join(goRoot, \"misc\", \"wasm\", \"wasm_exec.js\");\n if (fs.existsSync(goWasmExecPath)) {\n wasmExecPath = goWasmExecPath;\n }\n}\n\nif (fs.existsSync(wasmExecPath)) {\n // Convert to absolute path for createRequire\n const absoluteWasmExecPath = path.resolve(wasmExecPath);\n const require = createRequire(import.meta.url);\n require(absoluteWasmExecPath);\n} else {\n throw new Error(\n `wasm_exec.cjs not found. Please ensure Go is installed and run 'pnpm run build:copy-wasm-exec' to copy wasm_exec.js`,\n );\n}\n\nlet isInitialized = false;\nlet initPromise: Promise<void> | null = null;\n\n/**\n * Initialize the WASM module (Node.js version - auto-loads from file system)\n * @returns {Promise<void>}\n */\nasync function init(): Promise<void> {\n if (isInitialized) {\n return;\n }\n\n if (initPromise) {\n return initPromise;\n }\n\n initPromise = new Promise<void>((resolve, reject) => {\n const wasmPath = path.join(__dirname, \"..\", \"main.wasm\");\n\n if (!fs.existsSync(wasmPath)) {\n reject(\n new Error(\n `WASM file not found at ${wasmPath}. Please build it first using 'pnpm run build' or 'go build -o main.wasm -target wasm ./cmd/wasm'`,\n ),\n );\n return;\n }\n\n const go = new Go();\n const wasmBuffer = fs.readFileSync(wasmPath);\n\n WebAssembly.instantiate(wasmBuffer, go.importObject)\n .then((result: WebAssembly.WebAssemblyInstantiatedSource) => {\n go.run(result.instance);\n isInitialized = true;\n resolve();\n })\n .catch((err: unknown) => {\n const error = err instanceof Error ? err : new Error(String(err));\n reject(\n new Error(`Failed to instantiate WASM module: ${error.message}`),\n );\n });\n });\n\n return initPromise;\n}\n\n// Set the init function in core\nsetInitFunction(init);\n\n// Re-export everything from core\nexport { Program, Env } from \"./core.js\";\n\n// Re-export types and functions\nexport type {\n CELType,\n CELTypeDef,\n CELListType,\n CELMapType,\n EnvExtensions,\n InferExtensions,\n TypeExtensionHKT,\n CELFunctionDefinition,\n CELFunctionParam,\n EnvOptions,\n VariableDeclaration,\n TypeCheckResult,\n CompilationIssue,\n CompilationResult,\n} from \"./types.js\";\n\nexport { listType, mapType, optionalType, CELFunction } from \"./functions.js\";\nexport type { CELTypeToTS, ExtractParamTypes } from \"./functions.js\";\nexport { Options } from \"./options/index.js\";\nexport type {\n EnvOptionConfig,\n CELOptionalType,\n OptionalTypesExt,\n OptionalTypesConfig,\n ValidationIssue,\n ValidationContext,\n ValidatorResult,\n ASTValidatorFunction,\n ASTValidatorsConfig,\n} from \"./options/index.js\";\n\n// Export init function for Node.js (no parameters needed - auto-loads)\nexport { init };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astValidators.js","sourceRoot":"","sources":["../../lib/options/astValidators.ts"],"names":[],"mappings":"AAAA;;GAEG;AA+FH;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,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAClD,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACvC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,CAAC;gBAExC,uEAAuE;gBACvE,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBACrE,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC1C,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,eAAe;gBACrB,MAAM,EAAE;oBACN,oBAAoB;oBACpB,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,IAAI,IAAI;oBACpD,eAAe,EAAE,MAAM,CAAC,OAAO,EAAE,eAAe,IAAI,IAAI;iBACnB;aACxC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * ASTValidators CEL environment option\n */\n\nimport type {\n OptionSetupEnvironment,\n OptionWithSetup,\n EnvOptionConfig,\n} from \"./base.js\";\n\n/**\n * Represents an issue found during AST validation\n */\nexport interface ValidationIssue {\n /** The severity of the issue */\n severity: \"error\" | \"warning\" | \"info\";\n /** Human-readable description of the issue */\n message: string;\n /** Optional location information */\n location?: {\n /** Line number (1-based) */\n line?: number;\n /** Column number (1-based) */\n column?: number;\n /** Character offset in the source */\n offset?: number;\n };\n}\n\n/**\n * Context provided to validator functions during AST validation\n */\nexport interface ValidationContext {\n /** The source expression being validated */\n readonly source: string;\n /** Additional context data */\n readonly contextData: Record<string, any>;\n}\n\n/**\n * Result returned by AST validator functions\n */\nexport interface ValidatorResult {\n /** Issues found during validation */\n issues?: ValidationIssue[];\n}\n\n/**\n * A user-defined AST validator function\n *\n * This function will be called during AST validation with information about\n * the current expression node being visited. The function should examine\n * the node and return any validation issues found.\n *\n * @param nodeType - The type of AST node being visited (e.g., \"select\", \"call\", \"literal\")\n * @param nodeData - Data about the current node, including location information when available\n * @param context - Validation context with source and additional data\n * @returns Validation result with any issues found, or undefined if no issues\n */\nexport type ASTValidatorFunction = (\n nodeType: string,\n nodeData: Record<string, any>,\n context: ValidationContext,\n) => ValidatorResult | undefined;\n\n/**\n * Configuration for ASTValidators CEL environment option\n *\n * ASTValidators allow you to define custom validation rules that are applied\n * during CEL expression compilation. Each validator is implemented as an\n * ExprVisitor that examines AST nodes and reports validation issues.\n */\nexport interface ASTValidatorsConfig {\n /** Array of validator functions to register */\n validators: ASTValidatorFunction[];\n /** Optional configuration for the validators */\n options?: {\n /** Whether to fail compilation on validation warnings (default: true). Errors always cause compilation failure. */\n failOnWarning?: boolean;\n /** Whether to include warnings in the validation results (default: true) */\n includeWarnings?: boolean;\n };\n}\n\n/**\n * Internal configuration structure for AST validators after function registration.\n * This is what gets sent to the WASM layer.\n * @internal\n */\nexport interface ASTValidatorsInternalConfig {\n /** Internal validator function IDs registered with the environment */\n validatorFunctionIds: string[];\n /** Configuration options */\n failOnWarning?: boolean;\n includeWarnings?: boolean;\n}\n\n/**\n * Create an ASTValidators option configuration\n *\n * This option allows you to define custom validation rules that are applied\n * during CEL expression compilation. Each validator function will be called\n * for each AST node during compilation, allowing you to implement custom\n * validation logic.\n *\n * @param config - Configuration for the AST validators\n * @returns An option configuration that implements OptionWithSetup\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [{ name: \"user\", type: { kind: \"map\", keyType: \"string\", valueType: \"string\" } }],\n * options: [\n * Options.astValidators({\n * validators: [\n * // Validator that warns about accessing potentially unsafe fields\n * (nodeType, nodeData, context) => {\n * if (nodeType === \"select\" && nodeData.field === \"password\") {\n * return {\n * issues: [{\n * severity: \"warning\",\n * message: \"Accessing password field may not be secure\",\n * location: nodeData.location // Use actual location from AST\n * }]\n * };\n * }\n * },\n * // Validator that prevents certain function calls\n * (nodeType, nodeData, context) => {\n * if (nodeType === \"call\" && nodeData.function === \"dangerousFunction\") {\n * return {\n * issues: [{\n * severity: \"error\",\n * message: \"Use of dangerousFunction is not allowed\",\n * location: nodeData.location\n * }]\n * };\n * }\n * }\n * ],\n * options: {\n * failOnWarning: true,\n * includeWarnings: true\n * }\n * })\n * ]\n * });\n * ```\n */\nexport function astValidators(config: ASTValidatorsConfig): OptionWithSetup {\n return {\n async setupAndProcess(\n env: OptionSetupEnvironment,\n ): Promise<EnvOptionConfig> {\n // Register each validator function with the environment\n const validatorFunctionIds: string[] = [];\n\n for (let i = 0; i < config.validators.length; i++) {\n const validator = config.validators[i];\n const baseName = `__ast_validator_${i}`;\n\n // Register the validator function and get the actual implementation ID\n const actualImplId = await env.registerFunction(baseName, validator);\n validatorFunctionIds.push(actualImplId);\n }\n\n return {\n type: \"ASTValidators\",\n params: {\n validatorFunctionIds,\n failOnWarning: config.options?.failOnWarning ?? true,\n includeWarnings: config.options?.includeWarnings ?? true,\n } satisfies ASTValidatorsInternalConfig,\n };\n },\n };\n}\n"]}
|
package/dist/options/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../lib/options/base.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../lib/options/base.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Base types and interfaces for CEL environment options\n */\n\nimport type { TypedEnvOption, TypeExtensionHKT } from \"../types.js\";\n\n/**\n * Interface representing the environment capabilities available to options during setup\n */\nexport interface OptionSetupEnvironment {\n /**\n * Get the environment ID\n */\n getID(): string;\n\n /**\n * Register a custom JavaScript function to this environment\n * @param name - The name of the function as it will appear in CEL expressions\n * @param impl - The JavaScript implementation of the function\n * @returns Promise resolving to the actual implementation ID that was registered\n */\n registerFunction(\n name: string,\n impl: (...args: any[]) => any,\n ): Promise<string>;\n}\n\n/**\n * Interface for options that need to perform setup operations before being applied\n * This allows options to handle their own complex JavaScript-side operations\n */\nexport interface OptionWithSetup {\n /**\n * Perform any necessary setup operations (like registering JavaScript functions)\n * and return the processed option configuration ready for WASM\n *\n * @param env - The environment instance to perform setup on\n * @returns Promise resolving to the processed option configuration\n */\n setupAndProcess(env: OptionSetupEnvironment): Promise<EnvOptionConfig>;\n}\n\n/**\n * Base option configuration that gets sent to WASM\n */\nexport type EnvOptionConfig =\n | {\n type: \"OptionalTypes\";\n params?: import(\"./optionalTypes.js\").OptionalTypesConfig;\n }\n | {\n type: \"ASTValidators\";\n params?: import(\"./astValidators.js\").ASTValidatorsInternalConfig;\n }\n | {\n type: \"CrossTypeNumericComparisons\";\n params?: import(\"./crossTypeNumericComparisons.js\").CrossTypeNumericComparisonsConfig;\n }\n | {\n type: \"StringsExt\";\n params?: import(\"./strings.js\").StringsExtConfig;\n }\n | {\n type: \"MathExt\";\n params?: import(\"./math.js\").MathExtConfig;\n }\n | {\n type: \"EncodersExt\";\n params?: import(\"./encoders.js\").EncodersExtConfig;\n };\n\n/**\n * Union type of all available option inputs (simple configs or complex options with setup)\n */\nexport type EnvOptionInput<Exts extends TypeExtensionHKT[] = any> =\n | (EnvOptionConfig & TypedEnvOption<Exts>)\n | OptionWithSetup;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crossTypeNumericComparisons.js","sourceRoot":"","sources":["../../lib/options/crossTypeNumericComparisons.ts"],"names":[],"mappings":"AAAA;;GAEG;AA0BH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAA4C,EAAE;IAE9C,OAAO;QACL,IAAI,EAAE,6BAA6B;QACnC,MAAM,EAAE;YACN,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;SAChC;KACF,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"crossTypeNumericComparisons.js","sourceRoot":"","sources":["../../lib/options/crossTypeNumericComparisons.ts"],"names":[],"mappings":"AAAA;;GAEG;AA0BH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAA4C,EAAE;IAE9C,OAAO;QACL,IAAI,EAAE,6BAA6B;QACnC,MAAM,EAAE;YACN,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;SAChC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * CrossTypeNumericComparisons CEL environment option\n */\n\nimport type { EnvOptionConfig } from \"./base.js\";\n\n/**\n * Configuration for CrossTypeNumericComparisons CEL environment option\n *\n * CrossTypeNumericComparisons makes it possible to compare across numeric types\n * using ordering operators, e.g. double < int. This enables cross-type numeric\n * comparisons for ordering operations in CEL expressions.\n *\n * Note: This only enables ordering operators (<, <=, >, >=), not equality operators (==, !=).\n *\n * When enabled, you can write expressions like:\n * - `3.14 > 3` (double > int)\n * - `42 >= 42.0` (int >= double)\n * - `1.5 <= 2` (double <= int)\n */\nexport interface CrossTypeNumericComparisonsConfig {\n /**\n * Whether to enable cross-type numeric comparisons.\n * @default true\n */\n enabled?: boolean;\n}\n\n/**\n * Create a CrossTypeNumericComparisons option configuration\n *\n * @param config - Configuration for cross-type numeric comparisons\n * @returns An option configuration for enabling cross-type numeric comparisons\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [\n * { name: \"doubleValue\", type: \"double\" },\n * { name: \"intValue\", type: \"int\" }\n * ],\n * options: [Options.crossTypeNumericComparisons()]\n * });\n *\n * // Now you can use cross-type comparisons:\n * const program = env.compile(\"doubleValue > intValue\");\n * ```\n *\n * @example\n * ```typescript\n * // Explicitly disable cross-type comparisons\n * const env = await Env.new({\n * variables: [{ name: \"x\", type: \"int\" }],\n * options: [Options.crossTypeNumericComparisons({ enabled: false })]\n * });\n * ```\n */\nexport function crossTypeNumericComparisons(\n config: CrossTypeNumericComparisonsConfig = {},\n): EnvOptionConfig {\n return {\n type: \"CrossTypeNumericComparisons\",\n params: {\n enabled: config.enabled ?? true,\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoders.js","sourceRoot":"","sources":["../../lib/options/encoders.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,QAAQ,CAAC,SAA4B,EAAE;IACrD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"encoders.js","sourceRoot":"","sources":["../../lib/options/encoders.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,QAAQ,CAAC,SAA4B,EAAE;IACrD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["/**\n * EncodersExt CEL environment option\n */\n\nimport type { EnvOptionConfig } from \"./base.js\";\n\n/**\n * Configuration for the CEL encoders extension library.\n *\n * Enables encoding/decoding functions including:\n * - `base64.encode` - encodes bytes to a base64-encoded string\n * - `base64.decode` - decodes a base64-encoded string to bytes\n */\nexport interface EncodersExtConfig {\n /**\n * The version of the encoders extension library to enable.\n * Only functions introduced at or below the given version are included.\n * If not set, all functions are available.\n */\n version?: number;\n}\n\n/**\n * Create an EncodersExt option configuration to enable the CEL encoders extension library.\n *\n * @param config - Optional configuration for the encoders extension\n * @returns An option configuration for enabling CEL encoder extensions\n *\n * @example\n * ```typescript\n * // Enable all encoder extension functions\n * const env = await Env.new({\n * options: [Options.encoders()]\n * });\n *\n * const program = await env.compile(\"base64.encode(b'hello')\");\n * const result = await program.eval(); // \"aGVsbG8=\"\n * ```\n */\nexport function encoders(config: EncodersExtConfig = {}): EnvOptionConfig {\n const params: Record<string, unknown> = {};\n\n if (config.version !== undefined) {\n params.version = config.version;\n }\n\n return {\n type: \"EncodersExt\",\n params,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/options/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4BH,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/options/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4BH,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * CEL Environment Options\n *\n * This module contains TypeScript definitions for configurable CEL environment options.\n */\n\n// Re-export base types and interfaces\nexport type {\n OptionSetupEnvironment,\n OptionWithSetup,\n EnvOptionConfig,\n EnvOptionInput,\n} from \"./base.js\";\n\n// Re-export specific option types\nexport type {\n CELOptionalType,\n OptionalTypesConfig,\n OptionalTypesExt,\n} from \"./optionalTypes.js\";\nexport type {\n ValidationIssue,\n ValidationContext,\n ValidatorResult,\n ASTValidatorFunction,\n ASTValidatorsConfig,\n} from \"./astValidators.js\";\nexport type { CrossTypeNumericComparisonsConfig } from \"./crossTypeNumericComparisons.js\";\nexport type { StringsExtConfig } from \"./strings.js\";\nexport type { MathExtConfig } from \"./math.js\";\nexport type { EncodersExtConfig } from \"./encoders.js\";\n\n// Re-export the Options helper object\nexport { Options } from \"./options.js\";\n"]}
|
package/dist/options/math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../lib/options/math.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6BH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,IAAI,CAAC,SAAwB,EAAE;IAC7C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../lib/options/math.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6BH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,IAAI,CAAC,SAAwB,EAAE;IAC7C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["/**\n * MathExt CEL environment option\n */\n\nimport type { EnvOptionConfig } from \"./base.js\";\n\n/**\n * Configuration for the CEL math extension library.\n *\n * Enables namespaced math helper macros and functions including:\n * - `math.greatest`, `math.least` - min/max across arguments or lists\n * - `math.ceil`, `math.floor`, `math.round`, `math.trunc` (v1+) - rounding\n * - `math.abs`, `math.sign` (v1+) - absolute value and sign\n * - `math.isNaN`, `math.isInf`, `math.isFinite` (v1+) - floating point checks\n * - `math.bitAnd`, `math.bitOr`, `math.bitXor`, `math.bitNot` (v1+) - bitwise ops\n * - `math.bitShiftLeft`, `math.bitShiftRight` (v1+) - bit shifting\n * - `math.sqrt` (v2+) - square root\n */\nexport interface MathExtConfig {\n /**\n * The version of the math extension library to enable.\n * Only functions introduced at or below the given version are included.\n * If not set, all functions are available.\n *\n * - Version 0: math.greatest, math.least\n * - Version 1: adds ceil, floor, round, trunc, abs, sign, isNaN, isInf, isFinite, bitwise ops\n * - Version 2: adds sqrt\n */\n version?: number;\n}\n\n/**\n * Create a MathExt option configuration to enable the CEL math extension library.\n *\n * @param config - Optional configuration for the math extension\n * @returns An option configuration for enabling CEL math extensions\n *\n * @example\n * ```typescript\n * // Enable all math extension functions\n * const env = await Env.new({\n * options: [Options.math()]\n * });\n *\n * const program = await env.compile(\"math.greatest(1, 2, 3)\");\n * const result = await program.eval(); // 3\n * ```\n *\n * @example\n * ```typescript\n * // Enable with specific version\n * const env = await Env.new({\n * options: [Options.math({ version: 1 })]\n * });\n *\n * // Now ceil/floor/round etc. are available\n * const program = await env.compile(\"math.ceil(1.2)\");\n * const result = await program.eval(); // 2.0\n * ```\n */\nexport function math(config: MathExtConfig = {}): EnvOptionConfig {\n const params: Record<string, unknown> = {};\n\n if (config.version !== undefined) {\n params.version = config.version;\n }\n\n return {\n type: \"MathExt\",\n params,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionalTypes.js","sourceRoot":"","sources":["../../lib/options/optionalTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkCH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"optionalTypes.js","sourceRoot":"","sources":["../../lib/options/optionalTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkCH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC","sourcesContent":["/**\n * OptionalTypes CEL environment option\n */\n\nimport type {\n _types,\n CELTypeDef,\n TypeExtensionHKT,\n TypedEnvOption,\n} from \"../types.js\";\nimport type { EnvOptionConfig } from \"./base.js\";\n\ntype Cast<T, U> = T extends U ? T : U;\n\nexport interface CELOptionalType<T = CELTypeDef<any>> {\n kind: \"optional\";\n innerType: T;\n}\n\nexport interface OptionalTypesExt extends TypeExtensionHKT {\n fn: (types: Cast<this[typeof _types], CELTypeDef<any>>) => CELOptionalType<typeof types>;\n}\n\n/**\n * Configuration for OptionalTypes CEL environment option\n *\n * OptionalTypes enable support for optional syntax and types in CEL.\n * This includes optional field access (obj.?field), optional indexing (list[?0]),\n * and optional value creation (optional.of(value)).\n *\n * This option takes no configuration parameters - it's simply enabled or disabled.\n */\nexport interface OptionalTypesConfig {\n // No configuration needed - OptionalTypes is simply enabled when used\n}\n\n/**\n * Create an OptionalTypes option configuration\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [{ name: \"x\", type: \"int\" }],\n * options: [Options.optionalTypes()]\n * });\n * ```\n */\nexport function optionalTypes(): EnvOptionConfig & TypedEnvOption<[OptionalTypesExt]> {\n return {\n type: \"OptionalTypes\",\n params: {},\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../lib/options/options.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;;;;;;;;OAUG;IACH,aAAa;IAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,aAAa;IAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,2BAA2B;IAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,OAAO;IAEP;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI;IAEJ;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ;CACA,CAAC"}
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../lib/options/options.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;;;;;;;;OAUG;IACH,aAAa;IAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,aAAa;IAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,2BAA2B;IAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,OAAO;IAEP;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI;IAEJ;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ;CACA,CAAC","sourcesContent":["/**\n * Helper functions for creating option configurations\n */\n\nimport { optionalTypes } from \"./optionalTypes.js\";\nimport { astValidators } from \"./astValidators.js\";\nimport { crossTypeNumericComparisons } from \"./crossTypeNumericComparisons.js\";\nimport { strings } from \"./strings.js\";\nimport { math } from \"./math.js\";\nimport { encoders } from \"./encoders.js\";\n\n/**\n * Helper object containing functions for creating CEL environment option configurations\n */\nexport const Options = {\n /**\n * Create an OptionalTypes option configuration\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [{ name: \"x\", type: \"int\" }],\n * options: [Options.optionalTypes()]\n * });\n * ```\n */\n optionalTypes,\n\n /**\n * Create an ASTValidators option configuration\n *\n * This option allows you to define custom validation rules that are applied\n * during CEL expression compilation. Each validator function will be called\n * for each AST node during compilation, allowing you to implement custom\n * validation logic.\n *\n * @param config - Configuration for the AST validators\n * @returns An option configuration that implements OptionWithSetup\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [{ name: \"user\", type: { kind: \"map\", keyType: \"string\", valueType: \"string\" } }],\n * options: [\n * Options.astValidators({\n * validators: [\n * // Validator that warns about accessing potentially unsafe fields\n * (nodeType, nodeData, context) => {\n * if (nodeType === \"select\" && nodeData.field === \"password\") {\n * context.addIssue({\n * severity: \"warning\",\n * message: \"Accessing password field may not be secure\"\n * });\n * }\n * },\n * // Validator that prevents certain function calls\n * (nodeType, nodeData, context) => {\n * if (nodeType === \"call\" && nodeData.function === \"dangerousFunction\") {\n * context.addIssue({\n * severity: \"error\",\n * message: \"Use of dangerousFunction is not allowed\"\n * });\n * }\n * }\n * ],\n * options: {\n * failOnError: true,\n * includeWarnings: true\n * }\n * })\n * ]\n * });\n * ```\n */\n astValidators,\n\n /**\n * Create a CrossTypeNumericComparisons option configuration\n *\n * This option enables cross-type numeric comparisons for ordering operators\n * in CEL expressions, allowing you to compare values of different numeric types\n * using <, <=, >, >= operators (but not == or !=).\n *\n * @param config - Configuration for cross-type numeric comparisons\n * @returns An option configuration for enabling cross-type numeric comparisons\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * variables: [\n * { name: \"doubleValue\", type: \"double\" },\n * { name: \"intValue\", type: \"int\" }\n * ],\n * options: [Options.crossTypeNumericComparisons()]\n * });\n *\n * // Now you can use cross-type ordering comparisons:\n * const program = env.compile(\"doubleValue > intValue\");\n * ```\n *\n * @example\n * ```typescript\n * // Explicitly disable cross-type comparisons\n * const env = await Env.new({\n * variables: [{ name: \"x\", type: \"int\" }],\n * options: [Options.crossTypeNumericComparisons({ enabled: false })]\n * });\n * ```\n */\n crossTypeNumericComparisons,\n\n /**\n * Create a StringsExt option configuration to enable the CEL string extension library.\n *\n * This option provides additional string manipulation functions including\n * charAt, indexOf, join, lowerAscii, upperAscii, replace, split, substring,\n * trim, format, quote, reverse, and more.\n *\n * @param config - Optional configuration for the string extension\n * @returns An option configuration for enabling CEL string extensions\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * options: [Options.strings()]\n * });\n *\n * const program = await env.compile(\"'hello world'.upperAscii()\");\n * const result = await program.eval(); // \"HELLO WORLD\"\n * ```\n *\n * @example\n * ```typescript\n * // Enable with specific version for format support\n * const env = await Env.new({\n * options: [Options.strings({ version: 1 })]\n * });\n * ```\n */\n strings,\n\n /**\n * Create a MathExt option configuration to enable the CEL math extension library.\n *\n * This option provides namespaced math helper macros and functions including\n * math.greatest, math.least, math.ceil, math.floor, math.round, math.trunc,\n * math.abs, math.sign, math.isNaN, math.isInf, math.isFinite, bitwise operations,\n * and math.sqrt.\n *\n * @param config - Optional configuration for the math extension\n * @returns An option configuration for enabling CEL math extensions\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * options: [Options.math()]\n * });\n *\n * const program = await env.compile(\"math.greatest(1, 2, 3)\");\n * const result = await program.eval(); // 3\n * ```\n */\n math,\n\n /**\n * Create an EncodersExt option configuration to enable the CEL encoders extension library.\n *\n * This option provides encoding/decoding functions including\n * base64.encode and base64.decode.\n *\n * @param config - Optional configuration for the encoders extension\n * @returns An option configuration for enabling CEL encoder extensions\n *\n * @example\n * ```typescript\n * const env = await Env.new({\n * options: [Options.encoders()]\n * });\n *\n * const program = await env.compile(\"base64.encode(b'hello')\");\n * const result = await program.eval(); // \"aGVsbG8=\"\n * ```\n */\n encoders,\n} as const;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../lib/options/strings.ts"],"names":[],"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AAC","sourcesContent":["/**\n * StringsExt CEL environment option\n */\n\nimport type { EnvOptionConfig } from \"./base.js\";\n\n/**\n * Configuration for the CEL string extension library.\n *\n * Enables additional string manipulation functions including:\n * - `charAt`, `indexOf`, `lastIndexOf` - character/substring searching\n * - `join` - list-to-string joining\n * - `lowerAscii`, `upperAscii` - ASCII case conversion\n * - `replace` - substring replacement\n * - `split` - string splitting\n * - `substring` - substring extraction\n * - `trim` - whitespace trimming\n * - `format` (v1+) - printf-style string formatting\n * - `quote` (v1+) - safe string quoting\n * - `reverse` (v3+) - string reversal\n */\nexport interface StringsExtConfig {\n /**\n * The version of the string extension library to enable.\n * Only functions introduced at or below the given version are included.\n * If not set, all functions are available.\n *\n * - Version 0: charAt, indexOf, join, lastIndexOf, lowerAscii, replace, split, substring, trim, upperAscii\n * - Version 1: adds format, quote\n * - Version 3: adds reverse\n */\n version?: number;\n\n /**\n * The locale to use for locale-sensitive string operations.\n */\n locale?: string;\n\n /**\n * Whether to validate format calls at compile time.\n * When enabled, format string arguments are checked for correctness during compilation.\n */\n validateFormatCalls?: boolean;\n}\n\n/**\n * Create a StringsExt option configuration to enable the CEL string extension library.\n *\n * @param config - Optional configuration for the string extension\n * @returns An option configuration for enabling CEL string extensions\n *\n * @example\n * ```typescript\n * // Enable all string extension functions\n * const env = await Env.new({\n * options: [Options.strings()]\n * });\n *\n * const program = await env.compile(\"'hello world'.upperAscii()\");\n * const result = await program.eval(); // \"HELLO WORLD\"\n * ```\n *\n * @example\n * ```typescript\n * // Enable with specific version\n * const env = await Env.new({\n * options: [Options.strings({ version: 1 })]\n * });\n *\n * // Now format is available (v1+)\n * const program = await env.compile(\"'Hello %s, you are %d'.format(['World', 42])\");\n * ```\n */\nexport function strings(config: StringsExtConfig = {}): EnvOptionConfig {\n const params: Record<string, unknown> = {};\n\n if (config.version !== undefined) {\n params.version = config.version;\n }\n if (config.locale !== undefined) {\n params.locale = config.locale;\n }\n if (config.validateFormatCalls !== undefined) {\n params.validateFormatCalls = config.validateFormatCalls;\n }\n\n return {\n type: \"StringsExt\",\n params,\n };\n}\n"]}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAgB,gBAAgB;CAGrC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAgB,gBAAgB;CAGrC","sourcesContent":["/**\n * CEL type system definitions\n * These types correspond to CEL's type system and will be used for type checking\n */\n\n// ============================================================\n// HKT infrastructure for extensible CEL types\n// ============================================================\n\nexport declare const _types: unique symbol;\ntype TypeExtensionFn = (...args: never[]) => unknown;\n\n/**\n * Base higher-kinded type for CEL type extensions.\n *\n * Extensions implement this to declare what CEL types they contribute\n * to the type universe. The {@link _types} slot receives the full resolved\n * type universe at the point of use (filled via intersection), enabling\n * recursive types like `optional(optional(T))`.\n *\n * @example\n * ```typescript\n * interface MyExtension extends TypeExtensionHKT {\n * // `this[typeof _types]` is the full type universe including all extensions\n * provided: { kind: \"myType\"; inner: this[typeof _types] };\n * }\n * ```\n */\nexport abstract class TypeExtensionHKT {\n declare [_types]: unknown;\n abstract fn: TypeExtensionFn;\n}\n\ntype ResolveExtensionType<\n Ext extends TypeExtensionHKT,\n Universe,\n> = (Ext & { [_types]: Universe }) extends infer T extends TypeExtensionHKT\n ? ReturnType<T[\"fn\"]>\n : never;\n\ntype AnyCELTypeDef =\n | CELType\n | { kind: \"list\"; elementType: AnyCELTypeDef }\n | { kind: \"map\"; keyType: CELType; valueType: AnyCELTypeDef }\n | Record<string, unknown>;\n\n// ============================================================\n// Core CEL types\n// ============================================================\n\n/**\n * Base CEL types\n */\nexport type CELType =\n | \"bool\"\n | \"int\"\n | \"uint\"\n | \"double\"\n | \"string\"\n | \"bytes\"\n | \"list\"\n | \"map\"\n | \"dyn\"\n | \"null\"\n | \"timestamp\"\n | \"duration\";\n\n/**\n * CEL list type with element type\n */\nexport interface CELListType<Exts extends TypeExtensionHKT[] = []> {\n kind: \"list\";\n elementType: CELTypeDef<Exts>;\n}\n\n/**\n * CEL map type with key and value types\n */\nexport interface CELMapType<Exts extends TypeExtensionHKT[] = []> {\n kind: \"map\";\n keyType: CELType;\n valueType: CELTypeDef<Exts>;\n}\n\n/**\n * Full CEL type definition, parameterized by active extensions.\n *\n * With no extensions (`CELTypeDef<[]>`), this is equivalent to the base\n * type union. When extensions are provided, their contributed types are\n * included in the union.\n *\n * @example\n * ```typescript\n * // Base types only:\n * type Basic = CELTypeDef; // \"bool\" | \"int\" | ... | CELListType | CELMapType\n *\n * // With optional types:\n * type WithOpt = CELTypeDef<[OptionalTypesExt]>;\n * // also includes { kind: \"optional\"; innerType: WithOpt }\n * ```\n */\ntype BaseCELTypeDef<Exts extends TypeExtensionHKT[] = []> =\n | CELType\n | CELListType<Exts>\n | CELMapType<Exts>;\n\ntype ProvidedCELTypes<\n Exts extends TypeExtensionHKT[] = [],\n Universe = AnyCELTypeDef,\n> = {\n [K in keyof Exts]: Exts[K] extends TypeExtensionHKT\n ? ResolveExtensionType<Exts[K], Universe>\n : never;\n}[number];\n\nexport type CELTypeDef<Exts extends TypeExtensionHKT[] = []> =\n | BaseCELTypeDef<Exts>\n | ProvidedCELTypes<Exts>;\n\n// ============================================================\n// Function and variable declarations\n// ============================================================\n\n/**\n * Parameter definition for a CEL function\n */\nexport interface CELFunctionParam<Exts extends TypeExtensionHKT[] = []> {\n /** Parameter name */\n name: string;\n /** Parameter type */\n type: CELTypeDef<Exts>;\n /** Whether the parameter is optional */\n optional?: boolean;\n}\n\ndeclare const CELFunctionDefinitionBrand: unique symbol;\nexport type CELFunctionDefinitionBrand = typeof CELFunctionDefinitionBrand;\n\nexport interface CELFunctionDefinition {\n /** Function name (must be a valid CEL identifier) */\n name: string;\n /** Function parameters */\n params: CELFunctionParam<any>[];\n /** Return type */\n returnType: CELTypeDef<any>;\n /** Implementation function that will be called when the CEL function is invoked */\n impl: (...args: any[]) => any;\n /** Whether the function accepts variable arguments (overloads) */\n overloads?: CELFunctionDefinition[];\n /** Brand to ensure only verified builders can create definitions */\n readonly [CELFunctionDefinitionBrand]: true;\n}\n\n/**\n * Variable declaration for an environment\n */\nexport interface VariableDeclaration<Exts extends TypeExtensionHKT[] = []> {\n /** Variable name */\n name: string;\n /** Variable type */\n type: CELTypeDef<Exts>;\n}\n\n/**\n * Options for creating a CEL environment\n */\nexport interface EnvOptions<Exts extends TypeExtensionHKT[] = []> {\n /** Variable declarations (name and type) */\n variables?: VariableDeclaration<Exts>[];\n /** Custom functions to register */\n functions?: CELFunctionDefinition[];\n /** Environment options (like OptionalTypes) */\n options?: import(\"./options/index.js\").EnvOptionInput[];\n}\n\n/**\n * Result of typechecking a CEL expression\n */\nexport interface TypeCheckResult {\n /** The inferred type of the expression */\n type: CELTypeDef<any>;\n}\n\n/**\n * Represents a compilation issue (error, warning, or info)\n */\nexport interface CompilationIssue {\n /** Severity level of the issue */\n severity: \"error\" | \"warning\" | \"info\";\n /** Human-readable description of the issue */\n message: string;\n /** Source location information */\n location?: {\n /** Line number (1-based) */\n line?: number;\n /** Column number (1-based) */\n column?: number;\n /** Character offset in the source */\n offset?: number;\n };\n}\n\n/**\n * Detailed result of compiling a CEL expression\n */\nexport interface CompilationResult {\n /** Whether compilation succeeded */\n success: boolean;\n /** Error message if compilation failed completely */\n error?: string;\n /** All issues found during compilation (errors, warnings, info) */\n issues: CompilationIssue[];\n /** The compiled program if compilation succeeded */\n program?: import(\"./core.js\").Program;\n}\n\n// ============================================================\n// Extension helpers\n// ============================================================\n\n/** Phantom brand for carrying extension type info on option values */\ndeclare const _ext: unique symbol;\nexport type _ext = typeof _ext;\nexport declare const _envExtensions: unique symbol;\nexport type _envExtensions = typeof _envExtensions;\n\n/**\n * Marker interface for env options that carry extension type info.\n * The phantom {@link _ext} field encodes which extensions an option provides.\n */\nexport interface TypedEnvOption<Exts extends TypeExtensionHKT[] = []> {\n readonly [_ext]?: Exts;\n}\n\nexport interface EnvWithExtensions<Exts extends TypeExtensionHKT[] = []> {\n readonly [_envExtensions]?: Exts;\n}\n\n/** Flatten a tuple of extension tuples into a single extension tuple */\ntype Flatten<T extends readonly any[]> = T extends readonly [\n infer Head extends readonly any[],\n ...infer Rest extends readonly any[],\n]\n ? [...Head, ...Flatten<Rest>]\n : [];\n\n/**\n * Infer the combined extension tuple from an array of env options.\n *\n * @example\n * ```typescript\n * type Exts = InferExtensions<[\n * TypedEnvOption<[OptionalTypesExt]>,\n * TypedEnvOption<[]>,\n * ]>;\n * // Exts = [OptionalTypesExt]\n * ```\n */\nexport type InferExtensions<Opts extends readonly any[]> = Flatten<{\n [K in keyof Opts]: Opts[K] extends TypedEnvOption<infer E> ? E : [];\n}>;\n\n/**\n * Extract the extension tuple from an Env instance type.\n *\n * @example\n * ```typescript\n * const env = await Env.new({ options: [Options.optionalTypes()] });\n * type Exts = EnvExtensions<typeof env>; // [OptionalTypesExt]\n *\n * const fn = CELFunction.new<Exts>(\"wrap\")\n * .param(\"x\", { kind: \"optional\", innerType: \"string\" })\n * .returns(\"string\")\n * .implement((x) => x ?? \"\");\n * ```\n */\nexport type EnvExtensions<E> = E extends EnvWithExtensions<\n infer Exts extends TypeExtensionHKT[]\n>\n ? Exts\n : [];\n"]}
|
package/main.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wasm-cel",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "WebAssembly module for evaluating CEL (Common Expression Language) expressions in Node.js and browsers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
],
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "24.12.0",
|
|
56
|
-
"@vitest/browser": "4.0
|
|
57
|
-
"@vitest/browser-playwright": "4.0
|
|
58
|
-
"@vitest/coverage-v8": "4.0
|
|
59
|
-
"@vitest/ui": "4.0
|
|
56
|
+
"@vitest/browser": "4.1.0",
|
|
57
|
+
"@vitest/browser-playwright": "4.1.0",
|
|
58
|
+
"@vitest/coverage-v8": "4.1.0",
|
|
59
|
+
"@vitest/ui": "4.1.0",
|
|
60
60
|
"playwright": "1.58.2",
|
|
61
61
|
"typescript": "5.9.3",
|
|
62
|
-
"vitest": "4.0
|
|
62
|
+
"vitest": "4.1.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
|
-
"build": "GOOS=js GOARCH=wasm go build -ldflags '-s -w' -o main.wasm ./cmd/wasm",
|
|
65
|
+
"build": "GOOS=js GOARCH=wasm go build -ldflags '-s -w' -o main.wasm ./cmd/wasm && node scripts/optimize-wasm.js",
|
|
66
66
|
"build:copy-wasm-exec": "node scripts/copy-wasm-exec.js",
|
|
67
67
|
"build:ts": "tsc",
|
|
68
68
|
"build:all": "pnpm run build && pnpm run build:copy-wasm-exec && pnpm run build:ts",
|