@goplasmatic/datalogic 4.0.6
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/LICENSE +201 -0
- package/README.md +233 -0
- package/bundler/datalogic_wasm.d.ts +69 -0
- package/bundler/datalogic_wasm.js +5 -0
- package/bundler/datalogic_wasm_bg.js +310 -0
- package/bundler/datalogic_wasm_bg.wasm +0 -0
- package/bundler/datalogic_wasm_bg.wasm.d.ts +15 -0
- package/nodejs/datalogic_wasm.d.ts +69 -0
- package/nodejs/datalogic_wasm.js +312 -0
- package/nodejs/datalogic_wasm_bg.wasm +0 -0
- package/nodejs/datalogic_wasm_bg.wasm.d.ts +15 -0
- package/package.json +71 -0
- package/web/datalogic_wasm.d.ts +109 -0
- package/web/datalogic_wasm.js +400 -0
- package/web/datalogic_wasm_bg.wasm +0 -0
- package/web/datalogic_wasm_bg.wasm.d.ts +15 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
let cachedDataViewMemory0 = null;
|
|
7
|
+
function getDataViewMemory0() {
|
|
8
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
9
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
10
|
+
}
|
|
11
|
+
return cachedDataViewMemory0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getStringFromWasm0(ptr, len) {
|
|
15
|
+
ptr = ptr >>> 0;
|
|
16
|
+
return decodeText(ptr, len);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let cachedUint8ArrayMemory0 = null;
|
|
20
|
+
function getUint8ArrayMemory0() {
|
|
21
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
22
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
23
|
+
}
|
|
24
|
+
return cachedUint8ArrayMemory0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
28
|
+
if (realloc === undefined) {
|
|
29
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
30
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
31
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
32
|
+
WASM_VECTOR_LEN = buf.length;
|
|
33
|
+
return ptr;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let len = arg.length;
|
|
37
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
38
|
+
|
|
39
|
+
const mem = getUint8ArrayMemory0();
|
|
40
|
+
|
|
41
|
+
let offset = 0;
|
|
42
|
+
|
|
43
|
+
for (; offset < len; offset++) {
|
|
44
|
+
const code = arg.charCodeAt(offset);
|
|
45
|
+
if (code > 0x7F) break;
|
|
46
|
+
mem[ptr + offset] = code;
|
|
47
|
+
}
|
|
48
|
+
if (offset !== len) {
|
|
49
|
+
if (offset !== 0) {
|
|
50
|
+
arg = arg.slice(offset);
|
|
51
|
+
}
|
|
52
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
53
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
54
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
55
|
+
|
|
56
|
+
offset += ret.written;
|
|
57
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
WASM_VECTOR_LEN = offset;
|
|
61
|
+
return ptr;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function takeFromExternrefTable0(idx) {
|
|
65
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
66
|
+
wasm.__externref_table_dealloc(idx);
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
71
|
+
cachedTextDecoder.decode();
|
|
72
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
73
|
+
let numBytesDecoded = 0;
|
|
74
|
+
function decodeText(ptr, len) {
|
|
75
|
+
numBytesDecoded += len;
|
|
76
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
77
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
78
|
+
cachedTextDecoder.decode();
|
|
79
|
+
numBytesDecoded = len;
|
|
80
|
+
}
|
|
81
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const cachedTextEncoder = new TextEncoder();
|
|
85
|
+
|
|
86
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
87
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
88
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
89
|
+
view.set(buf);
|
|
90
|
+
return {
|
|
91
|
+
read: arg.length,
|
|
92
|
+
written: buf.length
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let WASM_VECTOR_LEN = 0;
|
|
98
|
+
|
|
99
|
+
const CompiledRuleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
100
|
+
? { register: () => {}, unregister: () => {} }
|
|
101
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compiledrule_free(ptr >>> 0, 1));
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* A compiled JSONLogic rule that can be evaluated multiple times.
|
|
105
|
+
*
|
|
106
|
+
* Use this when you need to evaluate the same logic against different data,
|
|
107
|
+
* as it avoids re-parsing the logic on each evaluation.
|
|
108
|
+
*/
|
|
109
|
+
export class CompiledRule {
|
|
110
|
+
__destroy_into_raw() {
|
|
111
|
+
const ptr = this.__wbg_ptr;
|
|
112
|
+
this.__wbg_ptr = 0;
|
|
113
|
+
CompiledRuleFinalization.unregister(this);
|
|
114
|
+
return ptr;
|
|
115
|
+
}
|
|
116
|
+
free() {
|
|
117
|
+
const ptr = this.__destroy_into_raw();
|
|
118
|
+
wasm.__wbg_compiledrule_free(ptr, 0);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create a new CompiledRule from a JSONLogic expression.
|
|
122
|
+
*
|
|
123
|
+
* # Arguments
|
|
124
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
125
|
+
* @param {string} logic
|
|
126
|
+
*/
|
|
127
|
+
constructor(logic) {
|
|
128
|
+
const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
|
+
const len0 = WASM_VECTOR_LEN;
|
|
130
|
+
const ret = wasm.compiledrule_new(ptr0, len0);
|
|
131
|
+
if (ret[2]) {
|
|
132
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
133
|
+
}
|
|
134
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
135
|
+
CompiledRuleFinalization.register(this, this.__wbg_ptr, this);
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Evaluate the compiled rule against data.
|
|
140
|
+
*
|
|
141
|
+
* # Arguments
|
|
142
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
143
|
+
*
|
|
144
|
+
* # Returns
|
|
145
|
+
* JSON string result or error message
|
|
146
|
+
* @param {string} data
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
evaluate(data) {
|
|
150
|
+
let deferred3_0;
|
|
151
|
+
let deferred3_1;
|
|
152
|
+
try {
|
|
153
|
+
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ret = wasm.compiledrule_evaluate(this.__wbg_ptr, ptr0, len0);
|
|
156
|
+
var ptr2 = ret[0];
|
|
157
|
+
var len2 = ret[1];
|
|
158
|
+
if (ret[3]) {
|
|
159
|
+
ptr2 = 0; len2 = 0;
|
|
160
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
161
|
+
}
|
|
162
|
+
deferred3_0 = ptr2;
|
|
163
|
+
deferred3_1 = len2;
|
|
164
|
+
return getStringFromWasm0(ptr2, len2);
|
|
165
|
+
} finally {
|
|
166
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (Symbol.dispose) CompiledRule.prototype[Symbol.dispose] = CompiledRule.prototype.free;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Evaluate a JSONLogic expression against data.
|
|
174
|
+
*
|
|
175
|
+
* # Arguments
|
|
176
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
177
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
178
|
+
*
|
|
179
|
+
* # Returns
|
|
180
|
+
* JSON string result or error message
|
|
181
|
+
* @param {string} logic
|
|
182
|
+
* @param {string} data
|
|
183
|
+
* @returns {string}
|
|
184
|
+
*/
|
|
185
|
+
export function evaluate(logic, data) {
|
|
186
|
+
let deferred4_0;
|
|
187
|
+
let deferred4_1;
|
|
188
|
+
try {
|
|
189
|
+
const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
190
|
+
const len0 = WASM_VECTOR_LEN;
|
|
191
|
+
const ptr1 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
+
const len1 = WASM_VECTOR_LEN;
|
|
193
|
+
const ret = wasm.evaluate(ptr0, len0, ptr1, len1);
|
|
194
|
+
var ptr3 = ret[0];
|
|
195
|
+
var len3 = ret[1];
|
|
196
|
+
if (ret[3]) {
|
|
197
|
+
ptr3 = 0; len3 = 0;
|
|
198
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
199
|
+
}
|
|
200
|
+
deferred4_0 = ptr3;
|
|
201
|
+
deferred4_1 = len3;
|
|
202
|
+
return getStringFromWasm0(ptr3, len3);
|
|
203
|
+
} finally {
|
|
204
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Evaluate a JSONLogic expression with execution trace for debugging.
|
|
210
|
+
*
|
|
211
|
+
* Returns a JSON string containing the result, expression tree, and execution steps.
|
|
212
|
+
* This enables step-by-step debugging and visualization of the evaluation process.
|
|
213
|
+
*
|
|
214
|
+
* # Arguments
|
|
215
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
216
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
217
|
+
*
|
|
218
|
+
* # Returns
|
|
219
|
+
* JSON string containing TracedResult (result, expression_tree, steps) or error message
|
|
220
|
+
*
|
|
221
|
+
* # Example Output
|
|
222
|
+
* ```json
|
|
223
|
+
* {
|
|
224
|
+
* "result": true,
|
|
225
|
+
* "expression_tree": {
|
|
226
|
+
* "id": 0,
|
|
227
|
+
* "expression": "{\"and\": [...]}",
|
|
228
|
+
* "children": [...]
|
|
229
|
+
* },
|
|
230
|
+
* "steps": [
|
|
231
|
+
* {"id": 0, "node_id": 2, "context": {...}, "result": 25, "error": null},
|
|
232
|
+
* ...
|
|
233
|
+
* ]
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
* @param {string} logic
|
|
237
|
+
* @param {string} data
|
|
238
|
+
* @returns {string}
|
|
239
|
+
*/
|
|
240
|
+
export function evaluate_with_trace(logic, data) {
|
|
241
|
+
let deferred4_0;
|
|
242
|
+
let deferred4_1;
|
|
243
|
+
try {
|
|
244
|
+
const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
245
|
+
const len0 = WASM_VECTOR_LEN;
|
|
246
|
+
const ptr1 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
247
|
+
const len1 = WASM_VECTOR_LEN;
|
|
248
|
+
const ret = wasm.evaluate_with_trace(ptr0, len0, ptr1, len1);
|
|
249
|
+
var ptr3 = ret[0];
|
|
250
|
+
var len3 = ret[1];
|
|
251
|
+
if (ret[3]) {
|
|
252
|
+
ptr3 = 0; len3 = 0;
|
|
253
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
254
|
+
}
|
|
255
|
+
deferred4_0 = ptr3;
|
|
256
|
+
deferred4_1 = len3;
|
|
257
|
+
return getStringFromWasm0(ptr3, len3);
|
|
258
|
+
} finally {
|
|
259
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function init() {
|
|
264
|
+
wasm.init();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
|
|
268
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
|
|
272
|
+
let deferred0_0;
|
|
273
|
+
let deferred0_1;
|
|
274
|
+
try {
|
|
275
|
+
deferred0_0 = arg0;
|
|
276
|
+
deferred0_1 = arg1;
|
|
277
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
278
|
+
} finally {
|
|
279
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export function __wbg_new_8a6f238a6ece86ea() {
|
|
284
|
+
const ret = new Error();
|
|
285
|
+
return ret;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
|
|
289
|
+
const ret = arg1.stack;
|
|
290
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
+
const len1 = WASM_VECTOR_LEN;
|
|
292
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
293
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
297
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
298
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
299
|
+
return ret;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
export function __wbindgen_init_externref_table() {
|
|
303
|
+
const table = wasm.__wbindgen_externrefs;
|
|
304
|
+
const offset = table.grow(4);
|
|
305
|
+
table.set(0, undefined);
|
|
306
|
+
table.set(offset + 0, undefined);
|
|
307
|
+
table.set(offset + 1, null);
|
|
308
|
+
table.set(offset + 2, true);
|
|
309
|
+
table.set(offset + 3, false);
|
|
310
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_compiledrule_free: (a: number, b: number) => void;
|
|
5
|
+
export const compiledrule_evaluate: (a: number, b: number, c: number) => [number, number, number, number];
|
|
6
|
+
export const compiledrule_new: (a: number, b: number) => [number, number, number];
|
|
7
|
+
export const evaluate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
8
|
+
export const evaluate_with_trace: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
|
+
export const init: () => void;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
11
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
12
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
13
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
14
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
15
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class CompiledRule {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
/**
|
|
8
|
+
* Create a new CompiledRule from a JSONLogic expression.
|
|
9
|
+
*
|
|
10
|
+
* # Arguments
|
|
11
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
12
|
+
*/
|
|
13
|
+
constructor(logic: string);
|
|
14
|
+
/**
|
|
15
|
+
* Evaluate the compiled rule against data.
|
|
16
|
+
*
|
|
17
|
+
* # Arguments
|
|
18
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
19
|
+
*
|
|
20
|
+
* # Returns
|
|
21
|
+
* JSON string result or error message
|
|
22
|
+
*/
|
|
23
|
+
evaluate(data: string): string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Evaluate a JSONLogic expression against data.
|
|
28
|
+
*
|
|
29
|
+
* # Arguments
|
|
30
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
31
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
32
|
+
*
|
|
33
|
+
* # Returns
|
|
34
|
+
* JSON string result or error message
|
|
35
|
+
*/
|
|
36
|
+
export function evaluate(logic: string, data: string): string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Evaluate a JSONLogic expression with execution trace for debugging.
|
|
40
|
+
*
|
|
41
|
+
* Returns a JSON string containing the result, expression tree, and execution steps.
|
|
42
|
+
* This enables step-by-step debugging and visualization of the evaluation process.
|
|
43
|
+
*
|
|
44
|
+
* # Arguments
|
|
45
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
46
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
47
|
+
*
|
|
48
|
+
* # Returns
|
|
49
|
+
* JSON string containing TracedResult (result, expression_tree, steps) or error message
|
|
50
|
+
*
|
|
51
|
+
* # Example Output
|
|
52
|
+
* ```json
|
|
53
|
+
* {
|
|
54
|
+
* "result": true,
|
|
55
|
+
* "expression_tree": {
|
|
56
|
+
* "id": 0,
|
|
57
|
+
* "expression": "{\"and\": [...]}",
|
|
58
|
+
* "children": [...]
|
|
59
|
+
* },
|
|
60
|
+
* "steps": [
|
|
61
|
+
* {"id": 0, "node_id": 2, "context": {...}, "result": 25, "error": null},
|
|
62
|
+
* ...
|
|
63
|
+
* ]
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function evaluate_with_trace(logic: string, data: string): string;
|
|
68
|
+
|
|
69
|
+
export function init(): void;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
|
|
5
|
+
let cachedDataViewMemory0 = null;
|
|
6
|
+
function getDataViewMemory0() {
|
|
7
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
8
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
9
|
+
}
|
|
10
|
+
return cachedDataViewMemory0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getStringFromWasm0(ptr, len) {
|
|
14
|
+
ptr = ptr >>> 0;
|
|
15
|
+
return decodeText(ptr, len);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let cachedUint8ArrayMemory0 = null;
|
|
19
|
+
function getUint8ArrayMemory0() {
|
|
20
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
21
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
22
|
+
}
|
|
23
|
+
return cachedUint8ArrayMemory0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
27
|
+
if (realloc === undefined) {
|
|
28
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
29
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
30
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
31
|
+
WASM_VECTOR_LEN = buf.length;
|
|
32
|
+
return ptr;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let len = arg.length;
|
|
36
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
37
|
+
|
|
38
|
+
const mem = getUint8ArrayMemory0();
|
|
39
|
+
|
|
40
|
+
let offset = 0;
|
|
41
|
+
|
|
42
|
+
for (; offset < len; offset++) {
|
|
43
|
+
const code = arg.charCodeAt(offset);
|
|
44
|
+
if (code > 0x7F) break;
|
|
45
|
+
mem[ptr + offset] = code;
|
|
46
|
+
}
|
|
47
|
+
if (offset !== len) {
|
|
48
|
+
if (offset !== 0) {
|
|
49
|
+
arg = arg.slice(offset);
|
|
50
|
+
}
|
|
51
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
52
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
53
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
54
|
+
|
|
55
|
+
offset += ret.written;
|
|
56
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
WASM_VECTOR_LEN = offset;
|
|
60
|
+
return ptr;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function takeFromExternrefTable0(idx) {
|
|
64
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
65
|
+
wasm.__externref_table_dealloc(idx);
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
70
|
+
cachedTextDecoder.decode();
|
|
71
|
+
function decodeText(ptr, len) {
|
|
72
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const cachedTextEncoder = new TextEncoder();
|
|
76
|
+
|
|
77
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
78
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
79
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
80
|
+
view.set(buf);
|
|
81
|
+
return {
|
|
82
|
+
read: arg.length,
|
|
83
|
+
written: buf.length
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let WASM_VECTOR_LEN = 0;
|
|
89
|
+
|
|
90
|
+
const CompiledRuleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
91
|
+
? { register: () => {}, unregister: () => {} }
|
|
92
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compiledrule_free(ptr >>> 0, 1));
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A compiled JSONLogic rule that can be evaluated multiple times.
|
|
96
|
+
*
|
|
97
|
+
* Use this when you need to evaluate the same logic against different data,
|
|
98
|
+
* as it avoids re-parsing the logic on each evaluation.
|
|
99
|
+
*/
|
|
100
|
+
class CompiledRule {
|
|
101
|
+
__destroy_into_raw() {
|
|
102
|
+
const ptr = this.__wbg_ptr;
|
|
103
|
+
this.__wbg_ptr = 0;
|
|
104
|
+
CompiledRuleFinalization.unregister(this);
|
|
105
|
+
return ptr;
|
|
106
|
+
}
|
|
107
|
+
free() {
|
|
108
|
+
const ptr = this.__destroy_into_raw();
|
|
109
|
+
wasm.__wbg_compiledrule_free(ptr, 0);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a new CompiledRule from a JSONLogic expression.
|
|
113
|
+
*
|
|
114
|
+
* # Arguments
|
|
115
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
116
|
+
* @param {string} logic
|
|
117
|
+
*/
|
|
118
|
+
constructor(logic) {
|
|
119
|
+
const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
120
|
+
const len0 = WASM_VECTOR_LEN;
|
|
121
|
+
const ret = wasm.compiledrule_new(ptr0, len0);
|
|
122
|
+
if (ret[2]) {
|
|
123
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
124
|
+
}
|
|
125
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
126
|
+
CompiledRuleFinalization.register(this, this.__wbg_ptr, this);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Evaluate the compiled rule against data.
|
|
131
|
+
*
|
|
132
|
+
* # Arguments
|
|
133
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
134
|
+
*
|
|
135
|
+
* # Returns
|
|
136
|
+
* JSON string result or error message
|
|
137
|
+
* @param {string} data
|
|
138
|
+
* @returns {string}
|
|
139
|
+
*/
|
|
140
|
+
evaluate(data) {
|
|
141
|
+
let deferred3_0;
|
|
142
|
+
let deferred3_1;
|
|
143
|
+
try {
|
|
144
|
+
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
145
|
+
const len0 = WASM_VECTOR_LEN;
|
|
146
|
+
const ret = wasm.compiledrule_evaluate(this.__wbg_ptr, ptr0, len0);
|
|
147
|
+
var ptr2 = ret[0];
|
|
148
|
+
var len2 = ret[1];
|
|
149
|
+
if (ret[3]) {
|
|
150
|
+
ptr2 = 0; len2 = 0;
|
|
151
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
152
|
+
}
|
|
153
|
+
deferred3_0 = ptr2;
|
|
154
|
+
deferred3_1 = len2;
|
|
155
|
+
return getStringFromWasm0(ptr2, len2);
|
|
156
|
+
} finally {
|
|
157
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (Symbol.dispose) CompiledRule.prototype[Symbol.dispose] = CompiledRule.prototype.free;
|
|
162
|
+
exports.CompiledRule = CompiledRule;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Evaluate a JSONLogic expression against data.
|
|
166
|
+
*
|
|
167
|
+
* # Arguments
|
|
168
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
169
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
170
|
+
*
|
|
171
|
+
* # Returns
|
|
172
|
+
* JSON string result or error message
|
|
173
|
+
* @param {string} logic
|
|
174
|
+
* @param {string} data
|
|
175
|
+
* @returns {string}
|
|
176
|
+
*/
|
|
177
|
+
function evaluate(logic, data) {
|
|
178
|
+
let deferred4_0;
|
|
179
|
+
let deferred4_1;
|
|
180
|
+
try {
|
|
181
|
+
const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
182
|
+
const len0 = WASM_VECTOR_LEN;
|
|
183
|
+
const ptr1 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
184
|
+
const len1 = WASM_VECTOR_LEN;
|
|
185
|
+
const ret = wasm.evaluate(ptr0, len0, ptr1, len1);
|
|
186
|
+
var ptr3 = ret[0];
|
|
187
|
+
var len3 = ret[1];
|
|
188
|
+
if (ret[3]) {
|
|
189
|
+
ptr3 = 0; len3 = 0;
|
|
190
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
191
|
+
}
|
|
192
|
+
deferred4_0 = ptr3;
|
|
193
|
+
deferred4_1 = len3;
|
|
194
|
+
return getStringFromWasm0(ptr3, len3);
|
|
195
|
+
} finally {
|
|
196
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.evaluate = evaluate;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Evaluate a JSONLogic expression with execution trace for debugging.
|
|
203
|
+
*
|
|
204
|
+
* Returns a JSON string containing the result, expression tree, and execution steps.
|
|
205
|
+
* This enables step-by-step debugging and visualization of the evaluation process.
|
|
206
|
+
*
|
|
207
|
+
* # Arguments
|
|
208
|
+
* * `logic` - JSON string containing the JSONLogic expression
|
|
209
|
+
* * `data` - JSON string containing the data to evaluate against
|
|
210
|
+
*
|
|
211
|
+
* # Returns
|
|
212
|
+
* JSON string containing TracedResult (result, expression_tree, steps) or error message
|
|
213
|
+
*
|
|
214
|
+
* # Example Output
|
|
215
|
+
* ```json
|
|
216
|
+
* {
|
|
217
|
+
* "result": true,
|
|
218
|
+
* "expression_tree": {
|
|
219
|
+
* "id": 0,
|
|
220
|
+
* "expression": "{\"and\": [...]}",
|
|
221
|
+
* "children": [...]
|
|
222
|
+
* },
|
|
223
|
+
* "steps": [
|
|
224
|
+
* {"id": 0, "node_id": 2, "context": {...}, "result": 25, "error": null},
|
|
225
|
+
* ...
|
|
226
|
+
* ]
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
* @param {string} logic
|
|
230
|
+
* @param {string} data
|
|
231
|
+
* @returns {string}
|
|
232
|
+
*/
|
|
233
|
+
function evaluate_with_trace(logic, data) {
|
|
234
|
+
let deferred4_0;
|
|
235
|
+
let deferred4_1;
|
|
236
|
+
try {
|
|
237
|
+
const ptr0 = passStringToWasm0(logic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
238
|
+
const len0 = WASM_VECTOR_LEN;
|
|
239
|
+
const ptr1 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
240
|
+
const len1 = WASM_VECTOR_LEN;
|
|
241
|
+
const ret = wasm.evaluate_with_trace(ptr0, len0, ptr1, len1);
|
|
242
|
+
var ptr3 = ret[0];
|
|
243
|
+
var len3 = ret[1];
|
|
244
|
+
if (ret[3]) {
|
|
245
|
+
ptr3 = 0; len3 = 0;
|
|
246
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
247
|
+
}
|
|
248
|
+
deferred4_0 = ptr3;
|
|
249
|
+
deferred4_1 = len3;
|
|
250
|
+
return getStringFromWasm0(ptr3, len3);
|
|
251
|
+
} finally {
|
|
252
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
exports.evaluate_with_trace = evaluate_with_trace;
|
|
256
|
+
|
|
257
|
+
function init() {
|
|
258
|
+
wasm.init();
|
|
259
|
+
}
|
|
260
|
+
exports.init = init;
|
|
261
|
+
|
|
262
|
+
exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
263
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
exports.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
267
|
+
let deferred0_0;
|
|
268
|
+
let deferred0_1;
|
|
269
|
+
try {
|
|
270
|
+
deferred0_0 = arg0;
|
|
271
|
+
deferred0_1 = arg1;
|
|
272
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
273
|
+
} finally {
|
|
274
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
exports.__wbg_new_8a6f238a6ece86ea = function() {
|
|
279
|
+
const ret = new Error();
|
|
280
|
+
return ret;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
exports.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
284
|
+
const ret = arg1.stack;
|
|
285
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
286
|
+
const len1 = WASM_VECTOR_LEN;
|
|
287
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
288
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
292
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
293
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
294
|
+
return ret;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
exports.__wbindgen_init_externref_table = function() {
|
|
298
|
+
const table = wasm.__wbindgen_externrefs;
|
|
299
|
+
const offset = table.grow(4);
|
|
300
|
+
table.set(0, undefined);
|
|
301
|
+
table.set(offset + 0, undefined);
|
|
302
|
+
table.set(offset + 1, null);
|
|
303
|
+
table.set(offset + 2, true);
|
|
304
|
+
table.set(offset + 3, false);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const wasmPath = `${__dirname}/datalogic_wasm_bg.wasm`;
|
|
308
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
309
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
310
|
+
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
311
|
+
|
|
312
|
+
wasm.__wbindgen_start();
|
|
Binary file
|