wasm-cel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +324 -0
- package/dist/functions.d.ts +96 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +97 -0
- package/dist/functions.js.map +1 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +420 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/main.wasm +0 -0
- package/package.json +47 -0
- package/wasm_exec.cjs +575 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { execSync } from "node:child_process";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
// Get __dirname equivalent in ESM
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
// Load wasm_exec.cjs if it exists, otherwise use a fallback
|
|
10
|
+
// wasm_exec.cjs is a CommonJS file, so we use createRequire to load it
|
|
11
|
+
let wasmExecPath = path.join(__dirname, "..", "wasm_exec.cjs");
|
|
12
|
+
if (!fs.existsSync(wasmExecPath)) {
|
|
13
|
+
// Try to find it in Go installation (as .js, we'll load it as .cjs)
|
|
14
|
+
const goRoot = process.env.GOROOT ||
|
|
15
|
+
execSync("go env GOROOT", { encoding: "utf-8" }).trim();
|
|
16
|
+
const goWasmExecPath = path.join(goRoot, "misc", "wasm", "wasm_exec.js");
|
|
17
|
+
if (fs.existsSync(goWasmExecPath)) {
|
|
18
|
+
wasmExecPath = goWasmExecPath;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (fs.existsSync(wasmExecPath)) {
|
|
22
|
+
// Convert to absolute path for createRequire
|
|
23
|
+
const absoluteWasmExecPath = path.resolve(wasmExecPath);
|
|
24
|
+
const require = createRequire(import.meta.url);
|
|
25
|
+
require(absoluteWasmExecPath);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(`wasm_exec.cjs not found. Please ensure Go is installed and run 'pnpm run build:copy-wasm-exec' to copy wasm_exec.js`);
|
|
29
|
+
}
|
|
30
|
+
let isInitialized = false;
|
|
31
|
+
let initPromise = null;
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the WASM module
|
|
34
|
+
* @returns {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
export async function init() {
|
|
37
|
+
if (isInitialized) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (initPromise) {
|
|
41
|
+
return initPromise;
|
|
42
|
+
}
|
|
43
|
+
initPromise = new Promise((resolve, reject) => {
|
|
44
|
+
const wasmPath = path.join(__dirname, "..", "main.wasm");
|
|
45
|
+
if (!fs.existsSync(wasmPath)) {
|
|
46
|
+
reject(new Error(`WASM file not found at ${wasmPath}. Please build it first using 'pnpm run build' or 'go build -o main.wasm -target wasm ./cmd/wasm'`));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const go = new Go();
|
|
50
|
+
const wasmBuffer = fs.readFileSync(wasmPath);
|
|
51
|
+
WebAssembly.instantiate(wasmBuffer, go.importObject)
|
|
52
|
+
.then((result) => {
|
|
53
|
+
go.run(result.instance);
|
|
54
|
+
isInitialized = true;
|
|
55
|
+
resolve();
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
59
|
+
reject(new Error(`Failed to instantiate WASM module: ${error.message}`));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return initPromise;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Serialize a CEL type definition to a format that can be sent to Go
|
|
66
|
+
*/
|
|
67
|
+
function serializeTypeDef(type) {
|
|
68
|
+
if (typeof type === "string") {
|
|
69
|
+
return type;
|
|
70
|
+
}
|
|
71
|
+
if (typeof type === "object" && type !== null) {
|
|
72
|
+
if ("kind" in type) {
|
|
73
|
+
if (type.kind === "list") {
|
|
74
|
+
return {
|
|
75
|
+
kind: "list",
|
|
76
|
+
elementType: serializeTypeDef(type.elementType),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (type.kind === "map") {
|
|
80
|
+
return {
|
|
81
|
+
kind: "map",
|
|
82
|
+
keyType: serializeTypeDef(type.keyType),
|
|
83
|
+
valueType: serializeTypeDef(type.valueType),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return "dyn"; // Fallback to dynamic type
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Serialize function definitions for transmission to Go
|
|
92
|
+
*/
|
|
93
|
+
// Counter for generating unique implementation IDs
|
|
94
|
+
let implIDCounter = 0;
|
|
95
|
+
function serializeFunctionDefs(functions) {
|
|
96
|
+
return functions.map((fn, index) => {
|
|
97
|
+
// Generate a unique implementation ID
|
|
98
|
+
const implID = `${fn.name}_${index}_${++implIDCounter}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
99
|
+
// Register the JavaScript function implementation
|
|
100
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
101
|
+
if (typeof globalObj.registerCELFunction === "function") {
|
|
102
|
+
const registerResult = globalObj.registerCELFunction(implID, fn.impl);
|
|
103
|
+
if (registerResult.error) {
|
|
104
|
+
throw new Error(`Failed to register function ${fn.name}: ${registerResult.error}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
throw new Error("registerCELFunction not available. Make sure WASM is initialized.");
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
name: fn.name,
|
|
112
|
+
params: fn.params.map((param) => ({
|
|
113
|
+
name: param.name,
|
|
114
|
+
type: serializeTypeDef(param.type),
|
|
115
|
+
optional: param.optional,
|
|
116
|
+
})),
|
|
117
|
+
returnType: serializeTypeDef(fn.returnType),
|
|
118
|
+
implID,
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// FinalizationRegistry for automatic cleanup
|
|
123
|
+
// This provides best-effort cleanup when objects are garbage collected
|
|
124
|
+
const programRegistry = typeof FinalizationRegistry !== "undefined"
|
|
125
|
+
? new FinalizationRegistry((programID) => {
|
|
126
|
+
// Best-effort cleanup when program is garbage collected
|
|
127
|
+
try {
|
|
128
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
129
|
+
if (typeof globalObj.destroyProgram === "function") {
|
|
130
|
+
globalObj.destroyProgram(programID);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
// Ignore errors during finalization - this is best-effort only
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
: null;
|
|
138
|
+
const envRegistry = typeof FinalizationRegistry !== "undefined"
|
|
139
|
+
? new FinalizationRegistry((envID) => {
|
|
140
|
+
// Best-effort cleanup when environment is garbage collected
|
|
141
|
+
try {
|
|
142
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
143
|
+
if (typeof globalObj.destroyEnv === "function") {
|
|
144
|
+
globalObj.destroyEnv(envID);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
// Ignore errors during finalization - this is best-effort only
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
: null;
|
|
152
|
+
/**
|
|
153
|
+
* A compiled CEL program that can be evaluated with variables
|
|
154
|
+
*/
|
|
155
|
+
export class Program {
|
|
156
|
+
constructor(programID) {
|
|
157
|
+
this.destroyed = false;
|
|
158
|
+
this.programID = programID;
|
|
159
|
+
// Register for automatic cleanup via FinalizationRegistry
|
|
160
|
+
if (programRegistry) {
|
|
161
|
+
programRegistry.register(this, programID);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Evaluate the compiled program with the given variables
|
|
166
|
+
* @param vars - Variables to use in the evaluation
|
|
167
|
+
* @returns Promise resolving to the evaluation result
|
|
168
|
+
* @throws Error if evaluation fails or program has been destroyed
|
|
169
|
+
*/
|
|
170
|
+
async eval(vars = null) {
|
|
171
|
+
if (this.destroyed) {
|
|
172
|
+
throw new Error("Program has been destroyed");
|
|
173
|
+
}
|
|
174
|
+
await init();
|
|
175
|
+
return new Promise((resolve, reject) => {
|
|
176
|
+
try {
|
|
177
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
178
|
+
const result = globalObj.evalProgram(this.programID, vars || {});
|
|
179
|
+
if (result.error) {
|
|
180
|
+
reject(new Error(result.error));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
resolve(result.result);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
188
|
+
reject(new Error(`WASM call failed: ${error.message}`));
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Destroy this program and free associated WASM resources.
|
|
194
|
+
* After calling destroy(), this program instance should not be used.
|
|
195
|
+
* If FinalizationRegistry is available, resources will be automatically
|
|
196
|
+
* cleaned up when the object is garbage collected, but explicit cleanup
|
|
197
|
+
* is recommended.
|
|
198
|
+
*/
|
|
199
|
+
destroy() {
|
|
200
|
+
if (this.destroyed) {
|
|
201
|
+
return; // Already destroyed, no-op
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
205
|
+
if (typeof globalObj.destroyProgram === "function") {
|
|
206
|
+
const result = globalObj.destroyProgram(this.programID);
|
|
207
|
+
if (result.error) {
|
|
208
|
+
// Log but don't throw - cleanup should be best-effort
|
|
209
|
+
console.warn(`Failed to destroy program: ${result.error}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
// Log but don't throw - cleanup should be best-effort
|
|
215
|
+
console.warn(`Error destroying program: ${err}`);
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
this.destroyed = true;
|
|
219
|
+
// Unregister from FinalizationRegistry since we've explicitly cleaned up
|
|
220
|
+
if (programRegistry) {
|
|
221
|
+
programRegistry.unregister(this);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* A CEL environment that holds variable declarations and function definitions
|
|
228
|
+
*/
|
|
229
|
+
export class Env {
|
|
230
|
+
constructor(envID) {
|
|
231
|
+
this.destroyed = false;
|
|
232
|
+
this.envID = envID;
|
|
233
|
+
// Register for automatic cleanup via FinalizationRegistry
|
|
234
|
+
if (envRegistry) {
|
|
235
|
+
envRegistry.register(this, envID);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create a new CEL environment
|
|
240
|
+
* @param options - Options including variable declarations and function definitions
|
|
241
|
+
* @returns Promise resolving to a new Env instance
|
|
242
|
+
* @throws Error if environment creation fails
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const env = await Env.new({
|
|
247
|
+
* variables: [
|
|
248
|
+
* { name: "x", type: "int" },
|
|
249
|
+
* { name: "y", type: "int" }
|
|
250
|
+
* ],
|
|
251
|
+
* functions: [
|
|
252
|
+
* CELFunction.new("add")
|
|
253
|
+
* .param("a", "int")
|
|
254
|
+
* .param("b", "int")
|
|
255
|
+
* .returns("int")
|
|
256
|
+
* .implement((a, b) => a + b)
|
|
257
|
+
* ]
|
|
258
|
+
* });
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
static async new(options) {
|
|
262
|
+
await init();
|
|
263
|
+
// Serialize variable declarations
|
|
264
|
+
const varDecls = (options?.variables || []).map((v) => ({
|
|
265
|
+
name: v.name,
|
|
266
|
+
type: serializeTypeDef(v.type),
|
|
267
|
+
}));
|
|
268
|
+
// Serialize function definitions if provided
|
|
269
|
+
let serializedFuncDefs = null;
|
|
270
|
+
if (options?.functions && options.functions.length > 0) {
|
|
271
|
+
serializedFuncDefs = serializeFunctionDefs(options.functions);
|
|
272
|
+
}
|
|
273
|
+
return new Promise((resolve, reject) => {
|
|
274
|
+
try {
|
|
275
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
276
|
+
const result = globalObj.createEnv(varDecls, serializedFuncDefs);
|
|
277
|
+
if (result.error) {
|
|
278
|
+
reject(new Error(result.error));
|
|
279
|
+
}
|
|
280
|
+
else if (!result.envID) {
|
|
281
|
+
reject(new Error("Environment creation failed: no envID returned"));
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
resolve(new Env(result.envID));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (err) {
|
|
288
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
289
|
+
reject(new Error(`WASM call failed: ${error.message}`));
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Compile a CEL expression in this environment
|
|
295
|
+
* @param expr - The CEL expression to compile
|
|
296
|
+
* @returns Promise resolving to a compiled Program
|
|
297
|
+
* @throws Error if compilation fails or environment has been destroyed
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* const env = await Env.new({
|
|
302
|
+
* variables: [{ name: "x", type: "int" }]
|
|
303
|
+
* });
|
|
304
|
+
* const program = await env.compile("x + 10");
|
|
305
|
+
* const result = await program.eval({ x: 5 });
|
|
306
|
+
* console.log(result); // 15
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
async compile(expr) {
|
|
310
|
+
if (this.destroyed) {
|
|
311
|
+
throw new Error("Environment has been destroyed");
|
|
312
|
+
}
|
|
313
|
+
await init();
|
|
314
|
+
if (typeof expr !== "string") {
|
|
315
|
+
throw new Error("Expression must be a string");
|
|
316
|
+
}
|
|
317
|
+
return new Promise((resolve, reject) => {
|
|
318
|
+
try {
|
|
319
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
320
|
+
const result = globalObj.compileExpr(this.envID, expr);
|
|
321
|
+
if (result.error) {
|
|
322
|
+
reject(new Error(result.error));
|
|
323
|
+
}
|
|
324
|
+
else if (!result.programID) {
|
|
325
|
+
reject(new Error("Compilation failed: no programID returned"));
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
resolve(new Program(result.programID));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
333
|
+
reject(new Error(`WASM call failed: ${error.message}`));
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Typecheck a CEL expression in this environment without compiling it
|
|
339
|
+
* @param expr - The CEL expression to typecheck
|
|
340
|
+
* @returns Promise resolving to the type information
|
|
341
|
+
* @throws Error if typechecking fails or environment has been destroyed
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* const env = await Env.new({
|
|
346
|
+
* variables: [{ name: "x", type: "int" }, { name: "y", type: "int" }]
|
|
347
|
+
* });
|
|
348
|
+
* const typeInfo = await env.typecheck("x + y");
|
|
349
|
+
* console.log(typeInfo.type); // "int"
|
|
350
|
+
*
|
|
351
|
+
* const listType = await env.typecheck("[1, 2, 3]");
|
|
352
|
+
* console.log(listType.type); // { kind: "list", elementType: "int" }
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
async typecheck(expr) {
|
|
356
|
+
if (this.destroyed) {
|
|
357
|
+
throw new Error("Environment has been destroyed");
|
|
358
|
+
}
|
|
359
|
+
await init();
|
|
360
|
+
if (typeof expr !== "string") {
|
|
361
|
+
throw new Error("Expression must be a string");
|
|
362
|
+
}
|
|
363
|
+
return new Promise((resolve, reject) => {
|
|
364
|
+
try {
|
|
365
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
366
|
+
const result = globalObj.typecheckExpr(this.envID, expr);
|
|
367
|
+
if (result.error) {
|
|
368
|
+
reject(new Error(result.error));
|
|
369
|
+
}
|
|
370
|
+
else if (result.type === undefined) {
|
|
371
|
+
reject(new Error("Typecheck failed: no type returned"));
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
resolve({ type: result.type });
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
catch (err) {
|
|
378
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
379
|
+
reject(new Error(`WASM call failed: ${error.message}`));
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Destroy this environment and free associated WASM resources.
|
|
385
|
+
* This will also clean up any registered JavaScript functions associated
|
|
386
|
+
* with this environment.
|
|
387
|
+
* After calling destroy(), this environment instance should not be used.
|
|
388
|
+
* If FinalizationRegistry is available, resources will be automatically
|
|
389
|
+
* cleaned up when the object is garbage collected, but explicit cleanup
|
|
390
|
+
* is recommended.
|
|
391
|
+
*/
|
|
392
|
+
destroy() {
|
|
393
|
+
if (this.destroyed) {
|
|
394
|
+
return; // Already destroyed, no-op
|
|
395
|
+
}
|
|
396
|
+
try {
|
|
397
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : global;
|
|
398
|
+
if (typeof globalObj.destroyEnv === "function") {
|
|
399
|
+
const result = globalObj.destroyEnv(this.envID);
|
|
400
|
+
if (result.error) {
|
|
401
|
+
// Log but don't throw - cleanup should be best-effort
|
|
402
|
+
console.warn(`Failed to destroy environment: ${result.error}`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
catch (err) {
|
|
407
|
+
// Log but don't throw - cleanup should be best-effort
|
|
408
|
+
console.warn(`Error destroying environment: ${err}`);
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
this.destroyed = true;
|
|
412
|
+
// Unregister from FinalizationRegistry since we've explicitly cleaned up
|
|
413
|
+
if (envRegistry) {
|
|
414
|
+
envRegistry.unregister(this);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
export { listType, mapType, CELFunction } from "./functions.js";
|
|
420
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.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;AAQ5C,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,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;AAC/D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;IACjC,oEAAoE;IACpE,MAAM,MAAM,GACV,OAAO,CAAC,GAAG,CAAC,MAAM;QAClB,QAAQ,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CA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MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAClE,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;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;AAeD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CEL type system definitions
|
|
3
|
+
* These types correspond to CEL's type system and will be used for type checking
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base CEL types
|
|
7
|
+
*/
|
|
8
|
+
export type CELType = "bool" | "int" | "uint" | "double" | "string" | "bytes" | "list" | "map" | "dyn" | "null" | "timestamp" | "duration";
|
|
9
|
+
/**
|
|
10
|
+
* CEL list type with element type
|
|
11
|
+
*/
|
|
12
|
+
export interface CELListType {
|
|
13
|
+
kind: "list";
|
|
14
|
+
elementType: CELType | CELListType | CELMapType;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* CEL map type with key and value types
|
|
18
|
+
*/
|
|
19
|
+
export interface CELMapType {
|
|
20
|
+
kind: "map";
|
|
21
|
+
keyType: CELType;
|
|
22
|
+
valueType: CELType | CELListType | CELMapType;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Union of all possible CEL type representations
|
|
26
|
+
*/
|
|
27
|
+
export type CELTypeDef = CELType | CELListType | CELMapType;
|
|
28
|
+
/**
|
|
29
|
+
* Parameter definition for a CEL function
|
|
30
|
+
*/
|
|
31
|
+
export interface CELFunctionParam {
|
|
32
|
+
/** Parameter name */
|
|
33
|
+
name: string;
|
|
34
|
+
/** Parameter type */
|
|
35
|
+
type: CELTypeDef;
|
|
36
|
+
/** Whether the parameter is optional */
|
|
37
|
+
optional?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Definition of a custom CEL function
|
|
41
|
+
*/
|
|
42
|
+
export interface CELFunctionDefinition {
|
|
43
|
+
/** Function name (must be a valid CEL identifier) */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Function parameters */
|
|
46
|
+
params: CELFunctionParam[];
|
|
47
|
+
/** Return type */
|
|
48
|
+
returnType: CELTypeDef;
|
|
49
|
+
/** Implementation function that will be called when the CEL function is invoked */
|
|
50
|
+
impl: (...args: any[]) => any;
|
|
51
|
+
/** Whether the function accepts variable arguments (overloads) */
|
|
52
|
+
overloads?: CELFunctionDefinition[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Variable declaration for an environment
|
|
56
|
+
*/
|
|
57
|
+
export interface VariableDeclaration {
|
|
58
|
+
/** Variable name */
|
|
59
|
+
name: string;
|
|
60
|
+
/** Variable type */
|
|
61
|
+
type: CELTypeDef;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Options for creating a CEL environment
|
|
65
|
+
*/
|
|
66
|
+
export interface EnvOptions {
|
|
67
|
+
/** Variable declarations (name and type) */
|
|
68
|
+
variables?: VariableDeclaration[];
|
|
69
|
+
/** Custom functions to register */
|
|
70
|
+
functions?: CELFunctionDefinition[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Result of typechecking a CEL expression
|
|
74
|
+
*/
|
|
75
|
+
export interface TypeCheckResult {
|
|
76
|
+
/** The inferred type of the expression */
|
|
77
|
+
type: CELTypeDef;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,OAAO,GACf,MAAM,GACN,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,KAAK,GACL,KAAK,GACL,MAAM,GACN,WAAW,GACX,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,kBAAkB;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,mFAAmF;IACnF,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IAC9B,kEAAkE;IAClE,SAAS,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAClC,mCAAmC;IACnC,SAAS,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,IAAI,EAAE,UAAU,CAAC;CAClB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/main.wasm
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wasm-cel",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "WebAssembly module for evaluating CEL (Common Expression Language) expressions in Node.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"cel",
|
|
16
|
+
"common-expression-language",
|
|
17
|
+
"wasm",
|
|
18
|
+
"webassembly",
|
|
19
|
+
"expression-evaluation"
|
|
20
|
+
],
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18.0.0"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/**/*",
|
|
28
|
+
"main.wasm",
|
|
29
|
+
"wasm_exec.cjs",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.0.0",
|
|
34
|
+
"jest": "^30.2.0",
|
|
35
|
+
"typescript": "^5.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "GOOS=js GOARCH=wasm go build -o main.wasm ./cmd/wasm",
|
|
39
|
+
"build:copy-wasm-exec": "node scripts/copy-wasm-exec.js",
|
|
40
|
+
"build:ts": "tsc",
|
|
41
|
+
"build:all": "pnpm run build && pnpm run build:copy-wasm-exec && pnpm run build:ts",
|
|
42
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
43
|
+
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
|
|
44
|
+
"test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
|
|
45
|
+
"example": "node examples/example.js"
|
|
46
|
+
}
|
|
47
|
+
}
|