@json-eval-rs/node 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
@@ -16,6 +16,14 @@ export declare class JSONEval extends JSONEvalCore {
16
16
  * @returns New instance
17
17
  */
18
18
  static fromCache(cacheKey: string, context?: any, data?: any): JSONEval;
19
+ /**
20
+ * Evaluate logic expression without creating an instance
21
+ * @param logicStr - JSON Logic expression (string or object)
22
+ * @param data - Optional data (string or object)
23
+ * @param context - Optional context (string or object)
24
+ * @returns Evaluation result
25
+ */
26
+ static evaluateLogic(logicStr: string | object, data?: any, context?: any): any;
19
27
  }
20
28
  /**
21
29
  * Get library version
package/dist/index.js CHANGED
@@ -27,6 +27,16 @@ export class JSONEval extends JSONEvalCore {
27
27
  fromCache: true
28
28
  });
29
29
  }
30
+ /**
31
+ * Evaluate logic expression without creating an instance
32
+ * @param logicStr - JSON Logic expression (string or object)
33
+ * @param data - Optional data (string or object)
34
+ * @param context - Optional context (string or object)
35
+ * @returns Evaluation result
36
+ */
37
+ static evaluateLogic(logicStr, data, context) {
38
+ return JSONEvalCore.evaluateLogic(wasm, logicStr, data, context);
39
+ }
30
40
  }
31
41
  /**
32
42
  * Get library version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-eval-rs/node",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "description": "JSON Eval RS for Node.js and Server-Side Rendering with ergonomic API",
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
  *
@@ -143,17 +143,10 @@ function passArrayJsValueToWasm0(array, malloc) {
143
143
  return ptr;
144
144
  }
145
145
  /**
146
- * Initialize the library (sets up panic hook)
147
- */
148
- exports.init = function() {
149
- wasm.init();
150
- };
151
-
152
- /**
153
- * Get library version (alias)
146
+ * Get the library version
154
147
  * @returns {string}
155
148
  */
156
- exports.version = function() {
149
+ exports.getVersion = function() {
157
150
  let deferred1_0;
158
151
  let deferred1_1;
159
152
  try {
@@ -171,10 +164,10 @@ exports.version = function() {
171
164
  };
172
165
 
173
166
  /**
174
- * Get the library version
167
+ * Get library version (alias)
175
168
  * @returns {string}
176
169
  */
177
- exports.getVersion = function() {
170
+ exports.version = function() {
178
171
  let deferred1_0;
179
172
  let deferred1_1;
180
173
  try {
@@ -191,6 +184,13 @@ exports.getVersion = function() {
191
184
  }
192
185
  };
193
186
 
187
+ /**
188
+ * Initialize the library (sets up panic hook)
189
+ */
190
+ exports.init = function() {
191
+ wasm.init();
192
+ };
193
+
194
194
  function passArray8ToWasm0(arg, malloc) {
195
195
  const ptr = malloc(arg.length * 1, 1) >>> 0;
196
196
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -366,6 +366,38 @@ class JSONEvalWasm {
366
366
  wasm.__wbindgen_add_to_stack_pointer(16);
367
367
  }
368
368
  }
369
+ /**
370
+ * Static helper to evaluate logic without creating an instance
371
+ * @param logic_str - JSON logic expression string
372
+ * @param data - Optional JSON data string
373
+ * @param context - Optional JSON context string
374
+ * @returns Result as JavaScript object
375
+ * @param {string} logic_str
376
+ * @param {string | null} [data]
377
+ * @param {string | null} [context]
378
+ * @returns {any}
379
+ */
380
+ static evaluateLogic(logic_str, data, context) {
381
+ try {
382
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
383
+ const ptr0 = passStringToWasm0(logic_str, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
384
+ const len0 = WASM_VECTOR_LEN;
385
+ var ptr1 = isLikeNone(data) ? 0 : passStringToWasm0(data, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
386
+ var len1 = WASM_VECTOR_LEN;
387
+ var ptr2 = isLikeNone(context) ? 0 : passStringToWasm0(context, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
388
+ var len2 = WASM_VECTOR_LEN;
389
+ wasm.jsonevalwasm_evaluateLogic(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
390
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
391
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
392
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
393
+ if (r2) {
394
+ throw takeObject(r1);
395
+ }
396
+ return takeObject(r0);
397
+ } finally {
398
+ wasm.__wbindgen_add_to_stack_pointer(16);
399
+ }
400
+ }
369
401
  /**
370
402
  * Evaluate dependents and return as JavaScript object
371
403
  *
@@ -995,6 +1027,28 @@ class JSONEvalWasm {
995
1027
  wasm.__wbindgen_add_to_stack_pointer(16);
996
1028
  }
997
1029
  }
1030
+ /**
1031
+ * Get all schema values as array of path-value pairs
1032
+ * Returns [{path: "", value: ""}, ...]
1033
+ *
1034
+ * @returns Array of {path, value} objects as JavaScript array
1035
+ * @returns {any}
1036
+ */
1037
+ getSchemaValueArray() {
1038
+ try {
1039
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1040
+ wasm.jsonevalwasm_getSchemaValueArray(retptr, this.__wbg_ptr);
1041
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1042
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1043
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1044
+ if (r2) {
1045
+ throw takeObject(r1);
1046
+ }
1047
+ return takeObject(r0);
1048
+ } finally {
1049
+ wasm.__wbindgen_add_to_stack_pointer(16);
1050
+ }
1051
+ }
998
1052
  /**
999
1053
  * Get the evaluated schema as JavaScript object
1000
1054
  *
@@ -1018,6 +1072,28 @@ class JSONEvalWasm {
1018
1072
  wasm.__wbindgen_add_to_stack_pointer(16);
1019
1073
  }
1020
1074
  }
1075
+ /**
1076
+ * Get all schema values as object with dotted path keys
1077
+ * Returns {path: value, ...}
1078
+ *
1079
+ * @returns Flat object with dotted paths as keys
1080
+ * @returns {any}
1081
+ */
1082
+ getSchemaValueObject() {
1083
+ try {
1084
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1085
+ wasm.jsonevalwasm_getSchemaValueObject(retptr, this.__wbg_ptr);
1086
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1087
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1088
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1089
+ if (r2) {
1090
+ throw takeObject(r1);
1091
+ }
1092
+ return takeObject(r0);
1093
+ } finally {
1094
+ wasm.__wbindgen_add_to_stack_pointer(16);
1095
+ }
1096
+ }
1021
1097
  /**
1022
1098
  * Reload schema from ParsedSchemaCache using a cache key
1023
1099
  *
@@ -1374,10 +1450,11 @@ class JSONEvalWasm {
1374
1450
  }
1375
1451
  }
1376
1452
  /**
1377
- * Get schema value from subform (all .value fields)
1453
+ * Get schema value from subform in nested object format (all .value fields).
1454
+ * Returns a hierarchical object structure mimicking the schema.
1378
1455
  *
1379
1456
  * @param subformPath - Path to the subform
1380
- * @returns Modified data as JavaScript object
1457
+ * @returns Modified data as JavaScript object (Nested)
1381
1458
  * @param {string} subform_path
1382
1459
  * @returns {any}
1383
1460
  */
@@ -1637,6 +1714,32 @@ class JSONEvalWasm {
1637
1714
  wasm.__wbindgen_add_to_stack_pointer(16);
1638
1715
  }
1639
1716
  }
1717
+ /**
1718
+ * Get schema values from subform as a flat array of path-value pairs.
1719
+ * Returns an array like `[{path: "field.sub", value: 123}, ...]`.
1720
+ *
1721
+ * @param subformPath - Path to the subform
1722
+ * @returns Array of {path, value} objects
1723
+ * @param {string} subform_path
1724
+ * @returns {any}
1725
+ */
1726
+ getSchemaValueArraySubform(subform_path) {
1727
+ try {
1728
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1729
+ const ptr0 = passStringToWasm0(subform_path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1730
+ const len0 = WASM_VECTOR_LEN;
1731
+ wasm.jsonevalwasm_getSchemaValueArraySubform(retptr, this.__wbg_ptr, ptr0, len0);
1732
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1733
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1734
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1735
+ if (r2) {
1736
+ throw takeObject(r1);
1737
+ }
1738
+ return takeObject(r0);
1739
+ } finally {
1740
+ wasm.__wbindgen_add_to_stack_pointer(16);
1741
+ }
1742
+ }
1640
1743
  /**
1641
1744
  * Get evaluated schema from subform as JavaScript object
1642
1745
  *
@@ -1664,6 +1767,32 @@ class JSONEvalWasm {
1664
1767
  wasm.__wbindgen_add_to_stack_pointer(16);
1665
1768
  }
1666
1769
  }
1770
+ /**
1771
+ * Get schema values from subform as a flat object with dotted path keys.
1772
+ * Returns an object like `{"field.sub": 123, ...}`.
1773
+ *
1774
+ * @param subformPath - Path to the subform
1775
+ * @returns Flat object with dotted paths as keys
1776
+ * @param {string} subform_path
1777
+ * @returns {any}
1778
+ */
1779
+ getSchemaValueObjectSubform(subform_path) {
1780
+ try {
1781
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1782
+ const ptr0 = passStringToWasm0(subform_path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1783
+ const len0 = WASM_VECTOR_LEN;
1784
+ wasm.jsonevalwasm_getSchemaValueObjectSubform(retptr, this.__wbg_ptr, ptr0, len0);
1785
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1786
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1787
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1788
+ if (r2) {
1789
+ throw takeObject(r1);
1790
+ }
1791
+ return takeObject(r0);
1792
+ } finally {
1793
+ wasm.__wbindgen_add_to_stack_pointer(16);
1794
+ }
1795
+ }
1667
1796
  /**
1668
1797
  * Get evaluated schema by specific path from subform
1669
1798
  *
@@ -2120,7 +2249,7 @@ exports.__wbg_getTime_6bb3f64e0f18f817 = function(arg0) {
2120
2249
  return ret;
2121
2250
  };
2122
2251
 
2123
- exports.__wbg_log_14f17096e508a1ab = function(arg0, arg1) {
2252
+ exports.__wbg_log_2f61091b102ce39d = function(arg0, arg1) {
2124
2253
  console.log(getStringFromWasm0(arg0, arg1));
2125
2254
  };
2126
2255
 
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;