@json-eval-rs/vanilla 0.0.54 → 0.0.56

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/dist/index.d.ts CHANGED
@@ -17,6 +17,16 @@ export declare class JSONEval extends JSONEvalCore {
17
17
  * @returns Promise resolving to WASM module
18
18
  */
19
19
  static initWasm(input?: string | Request | Response | BufferSource | WebAssembly.Module): Promise<any>;
20
+ /**
21
+ * Evaluate logic expression without creating an instance.
22
+ * NOTE: You MUST call `JSONEval.initWasm()` or `init()` before using this method.
23
+ *
24
+ * @param logicStr - JSON Logic expression (string or object)
25
+ * @param data - Optional data (string or object)
26
+ * @param context - Optional context (string or object)
27
+ * @returns Evaluation result
28
+ */
29
+ static evaluateLogic(logicStr: string | object, data?: any, context?: any): any;
20
30
  }
21
31
  /**
22
32
  * Get library version
package/dist/index.js CHANGED
@@ -22,6 +22,18 @@ export class JSONEval extends JSONEvalCore {
22
22
  static async initWasm(input) {
23
23
  return init(input);
24
24
  }
25
+ /**
26
+ * Evaluate logic expression without creating an instance.
27
+ * NOTE: You MUST call `JSONEval.initWasm()` or `init()` before using this method.
28
+ *
29
+ * @param logicStr - JSON Logic expression (string or object)
30
+ * @param data - Optional data (string or object)
31
+ * @param context - Optional context (string or object)
32
+ * @returns Evaluation result
33
+ */
34
+ static evaluateLogic(logicStr, data, context) {
35
+ return JSONEvalCore.evaluateLogic(wasm, logicStr, data, context);
36
+ }
25
37
  }
26
38
  /**
27
39
  * Get library version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-eval-rs/vanilla",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "description": "JSON Eval RS for direct browser usage (vanilla JS) or manual WASM loading (Next.js Turbopack compat)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,17 +1,17 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Initialize the library (sets up panic hook)
4
+ * Get the library version
5
5
  */
6
- export function init(): void;
6
+ export function getVersion(): string;
7
7
  /**
8
8
  * Get library version (alias)
9
9
  */
10
10
  export function version(): string;
11
11
  /**
12
- * Get the library version
12
+ * Initialize the library (sets up panic hook)
13
13
  */
14
- export function getVersion(): string;
14
+ export function init(): void;
15
15
  /**
16
16
  * WebAssembly wrapper for JSONEval
17
17
  */
@@ -49,6 +49,14 @@ export class JSONEvalWasm {
49
49
  * @returns Result as JavaScript object
50
50
  */
51
51
  compileAndRunLogic(logic_str: string, data?: string | null, context?: string | null): any;
52
+ /**
53
+ * Static helper to evaluate logic without creating an instance
54
+ * @param logic_str - JSON logic expression string
55
+ * @param data - Optional JSON data string
56
+ * @param context - Optional JSON context string
57
+ * @returns Result as JavaScript object
58
+ */
59
+ static evaluateLogic(logic_str: string, data?: string | null, context?: string | null): any;
52
60
  /**
53
61
  * Evaluate dependents and return as JavaScript object
54
62
  *
@@ -242,6 +250,13 @@ export class JSONEvalWasm {
242
250
  * @returns Data in specified format as JavaScript object
243
251
  */
244
252
  getSchemaByPathsJS(paths_json: string, format: number): any;
253
+ /**
254
+ * Get all schema values as array of path-value pairs
255
+ * Returns [{path: "", value: ""}, ...]
256
+ *
257
+ * @returns Array of {path, value} objects as JavaScript array
258
+ */
259
+ getSchemaValueArray(): any;
245
260
  /**
246
261
  * Get the evaluated schema as JavaScript object
247
262
  *
@@ -249,6 +264,13 @@ export class JSONEvalWasm {
249
264
  * @returns Evaluated schema as JavaScript object
250
265
  */
251
266
  getEvaluatedSchemaJS(skip_layout: boolean): any;
267
+ /**
268
+ * Get all schema values as object with dotted path keys
269
+ * Returns {path: value, ...}
270
+ *
271
+ * @returns Flat object with dotted paths as keys
272
+ */
273
+ getSchemaValueObject(): any;
252
274
  /**
253
275
  * Reload schema from ParsedSchemaCache using a cache key
254
276
  *
@@ -360,10 +382,11 @@ export class JSONEvalWasm {
360
382
  */
361
383
  resolveLayoutSubform(subform_path: string, evaluate: boolean): void;
362
384
  /**
363
- * Get schema value from subform (all .value fields)
385
+ * Get schema value from subform in nested object format (all .value fields).
386
+ * Returns a hierarchical object structure mimicking the schema.
364
387
  *
365
388
  * @param subformPath - Path to the subform
366
- * @returns Modified data as JavaScript object
389
+ * @returns Modified data as JavaScript object (Nested)
367
390
  */
368
391
  getSchemaValueSubform(subform_path: string): any;
369
392
  /**
@@ -424,6 +447,14 @@ export class JSONEvalWasm {
424
447
  * @returns Data in specified format as JavaScript object
425
448
  */
426
449
  getSchemaByPathsSubformJS(subform_path: string, paths_json: string, format: number): any;
450
+ /**
451
+ * Get schema values from subform as a flat array of path-value pairs.
452
+ * Returns an array like `[{path: "field.sub", value: 123}, ...]`.
453
+ *
454
+ * @param subformPath - Path to the subform
455
+ * @returns Array of {path, value} objects
456
+ */
457
+ getSchemaValueArraySubform(subform_path: string): any;
427
458
  /**
428
459
  * Get evaluated schema from subform as JavaScript object
429
460
  *
@@ -432,6 +463,14 @@ export class JSONEvalWasm {
432
463
  * @returns Evaluated schema as JavaScript object
433
464
  */
434
465
  getEvaluatedSchemaSubformJS(subform_path: string, resolve_layout: boolean): any;
466
+ /**
467
+ * Get schema values from subform as a flat object with dotted path keys.
468
+ * Returns an object like `{"field.sub": 123, ...}`.
469
+ *
470
+ * @param subformPath - Path to the subform
471
+ * @returns Flat object with dotted paths as keys
472
+ */
473
+ getSchemaValueObjectSubform(subform_path: string): any;
435
474
  /**
436
475
  * Get evaluated schema by specific path from subform
437
476
  *
@@ -534,6 +573,7 @@ export interface InitOutput {
534
573
  readonly jsonevalwasm_evaluateDependentsSubform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
535
574
  readonly jsonevalwasm_evaluateDependentsSubformJS: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
536
575
  readonly jsonevalwasm_evaluateJS: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
576
+ readonly jsonevalwasm_evaluateLogic: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
537
577
  readonly jsonevalwasm_evaluateSubform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
538
578
  readonly jsonevalwasm_getEvaluatedSchema: (a: number, b: number, c: number) => void;
539
579
  readonly jsonevalwasm_getEvaluatedSchemaByPath: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -561,6 +601,10 @@ export interface InitOutput {
561
601
  readonly jsonevalwasm_getSchemaByPathsSubform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
562
602
  readonly jsonevalwasm_getSchemaByPathsSubformJS: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
563
603
  readonly jsonevalwasm_getSchemaValue: (a: number, b: number) => void;
604
+ readonly jsonevalwasm_getSchemaValueArray: (a: number, b: number) => void;
605
+ readonly jsonevalwasm_getSchemaValueArraySubform: (a: number, b: number, c: number, d: number) => void;
606
+ readonly jsonevalwasm_getSchemaValueObject: (a: number, b: number) => void;
607
+ readonly jsonevalwasm_getSchemaValueObjectSubform: (a: number, b: number, c: number, d: number) => void;
564
608
  readonly jsonevalwasm_getSchemaValueSubform: (a: number, b: number, c: number, d: number) => void;
565
609
  readonly jsonevalwasm_getSubformPaths: (a: number, b: number) => void;
566
610
  readonly jsonevalwasm_hasSubform: (a: number, b: number, c: number) => number;
@@ -149,17 +149,10 @@ function passArrayJsValueToWasm0(array, malloc) {
149
149
  return ptr;
150
150
  }
151
151
  /**
152
- * Initialize the library (sets up panic hook)
153
- */
154
- export function init() {
155
- wasm.init();
156
- }
157
-
158
- /**
159
- * Get library version (alias)
152
+ * Get the library version
160
153
  * @returns {string}
161
154
  */
162
- export function version() {
155
+ export function getVersion() {
163
156
  let deferred1_0;
164
157
  let deferred1_1;
165
158
  try {
@@ -177,10 +170,10 @@ export function version() {
177
170
  }
178
171
 
179
172
  /**
180
- * Get the library version
173
+ * Get library version (alias)
181
174
  * @returns {string}
182
175
  */
183
- export function getVersion() {
176
+ export function version() {
184
177
  let deferred1_0;
185
178
  let deferred1_1;
186
179
  try {
@@ -197,6 +190,13 @@ export function getVersion() {
197
190
  }
198
191
  }
199
192
 
193
+ /**
194
+ * Initialize the library (sets up panic hook)
195
+ */
196
+ export function init() {
197
+ wasm.init();
198
+ }
199
+
200
200
  function passArray8ToWasm0(arg, malloc) {
201
201
  const ptr = malloc(arg.length * 1, 1) >>> 0;
202
202
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -372,6 +372,38 @@ export class JSONEvalWasm {
372
372
  wasm.__wbindgen_add_to_stack_pointer(16);
373
373
  }
374
374
  }
375
+ /**
376
+ * Static helper to evaluate logic without creating an instance
377
+ * @param logic_str - JSON logic expression string
378
+ * @param data - Optional JSON data string
379
+ * @param context - Optional JSON context string
380
+ * @returns Result as JavaScript object
381
+ * @param {string} logic_str
382
+ * @param {string | null} [data]
383
+ * @param {string | null} [context]
384
+ * @returns {any}
385
+ */
386
+ static evaluateLogic(logic_str, data, context) {
387
+ try {
388
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
389
+ const ptr0 = passStringToWasm0(logic_str, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
390
+ const len0 = WASM_VECTOR_LEN;
391
+ var ptr1 = isLikeNone(data) ? 0 : passStringToWasm0(data, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
392
+ var len1 = WASM_VECTOR_LEN;
393
+ var ptr2 = isLikeNone(context) ? 0 : passStringToWasm0(context, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
394
+ var len2 = WASM_VECTOR_LEN;
395
+ wasm.jsonevalwasm_evaluateLogic(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
396
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
397
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
398
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
399
+ if (r2) {
400
+ throw takeObject(r1);
401
+ }
402
+ return takeObject(r0);
403
+ } finally {
404
+ wasm.__wbindgen_add_to_stack_pointer(16);
405
+ }
406
+ }
375
407
  /**
376
408
  * Evaluate dependents and return as JavaScript object
377
409
  *
@@ -1001,6 +1033,28 @@ export class JSONEvalWasm {
1001
1033
  wasm.__wbindgen_add_to_stack_pointer(16);
1002
1034
  }
1003
1035
  }
1036
+ /**
1037
+ * Get all schema values as array of path-value pairs
1038
+ * Returns [{path: "", value: ""}, ...]
1039
+ *
1040
+ * @returns Array of {path, value} objects as JavaScript array
1041
+ * @returns {any}
1042
+ */
1043
+ getSchemaValueArray() {
1044
+ try {
1045
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1046
+ wasm.jsonevalwasm_getSchemaValueArray(retptr, this.__wbg_ptr);
1047
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1048
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1049
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1050
+ if (r2) {
1051
+ throw takeObject(r1);
1052
+ }
1053
+ return takeObject(r0);
1054
+ } finally {
1055
+ wasm.__wbindgen_add_to_stack_pointer(16);
1056
+ }
1057
+ }
1004
1058
  /**
1005
1059
  * Get the evaluated schema as JavaScript object
1006
1060
  *
@@ -1024,6 +1078,28 @@ export class JSONEvalWasm {
1024
1078
  wasm.__wbindgen_add_to_stack_pointer(16);
1025
1079
  }
1026
1080
  }
1081
+ /**
1082
+ * Get all schema values as object with dotted path keys
1083
+ * Returns {path: value, ...}
1084
+ *
1085
+ * @returns Flat object with dotted paths as keys
1086
+ * @returns {any}
1087
+ */
1088
+ getSchemaValueObject() {
1089
+ try {
1090
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1091
+ wasm.jsonevalwasm_getSchemaValueObject(retptr, this.__wbg_ptr);
1092
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1093
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1094
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1095
+ if (r2) {
1096
+ throw takeObject(r1);
1097
+ }
1098
+ return takeObject(r0);
1099
+ } finally {
1100
+ wasm.__wbindgen_add_to_stack_pointer(16);
1101
+ }
1102
+ }
1027
1103
  /**
1028
1104
  * Reload schema from ParsedSchemaCache using a cache key
1029
1105
  *
@@ -1380,10 +1456,11 @@ export class JSONEvalWasm {
1380
1456
  }
1381
1457
  }
1382
1458
  /**
1383
- * Get schema value from subform (all .value fields)
1459
+ * Get schema value from subform in nested object format (all .value fields).
1460
+ * Returns a hierarchical object structure mimicking the schema.
1384
1461
  *
1385
1462
  * @param subformPath - Path to the subform
1386
- * @returns Modified data as JavaScript object
1463
+ * @returns Modified data as JavaScript object (Nested)
1387
1464
  * @param {string} subform_path
1388
1465
  * @returns {any}
1389
1466
  */
@@ -1643,6 +1720,32 @@ export class JSONEvalWasm {
1643
1720
  wasm.__wbindgen_add_to_stack_pointer(16);
1644
1721
  }
1645
1722
  }
1723
+ /**
1724
+ * Get schema values from subform as a flat array of path-value pairs.
1725
+ * Returns an array like `[{path: "field.sub", value: 123}, ...]`.
1726
+ *
1727
+ * @param subformPath - Path to the subform
1728
+ * @returns Array of {path, value} objects
1729
+ * @param {string} subform_path
1730
+ * @returns {any}
1731
+ */
1732
+ getSchemaValueArraySubform(subform_path) {
1733
+ try {
1734
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1735
+ const ptr0 = passStringToWasm0(subform_path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1736
+ const len0 = WASM_VECTOR_LEN;
1737
+ wasm.jsonevalwasm_getSchemaValueArraySubform(retptr, this.__wbg_ptr, ptr0, len0);
1738
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1739
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1740
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1741
+ if (r2) {
1742
+ throw takeObject(r1);
1743
+ }
1744
+ return takeObject(r0);
1745
+ } finally {
1746
+ wasm.__wbindgen_add_to_stack_pointer(16);
1747
+ }
1748
+ }
1646
1749
  /**
1647
1750
  * Get evaluated schema from subform as JavaScript object
1648
1751
  *
@@ -1670,6 +1773,32 @@ export class JSONEvalWasm {
1670
1773
  wasm.__wbindgen_add_to_stack_pointer(16);
1671
1774
  }
1672
1775
  }
1776
+ /**
1777
+ * Get schema values from subform as a flat object with dotted path keys.
1778
+ * Returns an object like `{"field.sub": 123, ...}`.
1779
+ *
1780
+ * @param subformPath - Path to the subform
1781
+ * @returns Flat object with dotted paths as keys
1782
+ * @param {string} subform_path
1783
+ * @returns {any}
1784
+ */
1785
+ getSchemaValueObjectSubform(subform_path) {
1786
+ try {
1787
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1788
+ const ptr0 = passStringToWasm0(subform_path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1789
+ const len0 = WASM_VECTOR_LEN;
1790
+ wasm.jsonevalwasm_getSchemaValueObjectSubform(retptr, this.__wbg_ptr, ptr0, len0);
1791
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1792
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1793
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1794
+ if (r2) {
1795
+ throw takeObject(r1);
1796
+ }
1797
+ return takeObject(r0);
1798
+ } finally {
1799
+ wasm.__wbindgen_add_to_stack_pointer(16);
1800
+ }
1801
+ }
1673
1802
  /**
1674
1803
  * Get evaluated schema by specific path from subform
1675
1804
  *
@@ -2153,7 +2282,7 @@ function __wbg_get_imports() {
2153
2282
  const ret = getObject(arg0).getTime();
2154
2283
  return ret;
2155
2284
  };
2156
- imports.wbg.__wbg_log_14f17096e508a1ab = function(arg0, arg1) {
2285
+ imports.wbg.__wbg_log_2f61091b102ce39d = function(arg0, arg1) {
2157
2286
  console.log(getStringFromWasm0(arg0, arg1));
2158
2287
  };
2159
2288
  imports.wbg.__wbg_new0_b0a0a38c201e6df5 = function() {
Binary file
@@ -19,6 +19,7 @@ export const jsonevalwasm_evaluateDependentsJS: (a: number, b: number, c: number
19
19
  export const jsonevalwasm_evaluateDependentsSubform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
20
20
  export const jsonevalwasm_evaluateDependentsSubformJS: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
21
21
  export const jsonevalwasm_evaluateJS: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
22
+ export const jsonevalwasm_evaluateLogic: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
22
23
  export const jsonevalwasm_evaluateSubform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
23
24
  export const jsonevalwasm_getEvaluatedSchema: (a: number, b: number, c: number) => void;
24
25
  export const jsonevalwasm_getEvaluatedSchemaByPath: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -46,6 +47,10 @@ export const jsonevalwasm_getSchemaByPathsJS: (a: number, b: number, c: number,
46
47
  export const jsonevalwasm_getSchemaByPathsSubform: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
47
48
  export const jsonevalwasm_getSchemaByPathsSubformJS: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
48
49
  export const jsonevalwasm_getSchemaValue: (a: number, b: number) => void;
50
+ export const jsonevalwasm_getSchemaValueArray: (a: number, b: number) => void;
51
+ export const jsonevalwasm_getSchemaValueArraySubform: (a: number, b: number, c: number, d: number) => void;
52
+ export const jsonevalwasm_getSchemaValueObject: (a: number, b: number) => void;
53
+ export const jsonevalwasm_getSchemaValueObjectSubform: (a: number, b: number, c: number, d: number) => void;
49
54
  export const jsonevalwasm_getSchemaValueSubform: (a: number, b: number, c: number, d: number) => void;
50
55
  export const jsonevalwasm_getSubformPaths: (a: number, b: number) => void;
51
56
  export const jsonevalwasm_hasSubform: (a: number, b: number, c: number) => number;