@json-eval-rs/webcore 0.0.48 → 0.0.50

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
@@ -70,13 +70,28 @@ export interface DependentChange {
70
70
  * Options for creating a JSONEval instance
71
71
  */
72
72
  export interface JSONEvalOptions {
73
- /** JSON schema object */
73
+ /**
74
+ * JSON schema object or MessagePack binary or cache key string.
75
+ * - If object: Standard JSON Schema
76
+ * - If Uint8Array: MessagePack encoded schema
77
+ * - If string (and fromCache=true): Cache key for pre-parsed schema
78
+ */
74
79
  schema: any;
75
- /** Optional context data */
80
+ /**
81
+ * Optional context data accessible via $context in logic.
82
+ * Useful for user sessions, environment variables, etc.
83
+ */
76
84
  context?: any;
77
- /** Optional initial data */
85
+ /**
86
+ * Optional initial data object to evaluate against.
87
+ * Can be updated later with reloadSchema.
88
+ */
78
89
  data?: any;
79
- /** If true, schema is treated as a cache key */
90
+ /**
91
+ * If true, the `schema` parameter is treated as a string cache key
92
+ * to lookup a pre-parsed schema from the global cache.
93
+ * Default: false
94
+ */
80
95
  fromCache?: boolean;
81
96
  }
82
97
  /**
@@ -317,17 +332,28 @@ export interface CompileAndRunLogicOptions {
317
332
  * ```
318
333
  */
319
334
  export declare class JSONEvalCore {
335
+ /** Internal storage for the schema (JSON, MsgPack, or Cache Key) */
320
336
  private _schema;
337
+ /** Reference to the loaded WASM module */
321
338
  private _wasmModule;
339
+ /** Current context data */
322
340
  private _context;
341
+ /** Current evaluation data */
323
342
  private _data;
343
+ /** The underlying WASM JSONEval instance */
324
344
  private _instance;
345
+ /** Initialization state flag */
325
346
  private _ready;
347
+ /** Flag indicating if schema provided is binary MessagePack */
326
348
  private _isMsgpackSchema;
349
+ /** Flag indicating if schema is a cache key reference */
327
350
  private _isFromCache;
328
351
  /**
329
- * @param wasmModule - WASM module (injected by wrapper package)
330
- * @param options
352
+ * Create a new JSONEval Core instance.
353
+ * Does not initialize WASM immediately; wait for `init()` or call async methods.
354
+ *
355
+ * @param wasmModule - The loaded WASM module (provided by wrapper packages like @json-eval-rs/node or /vanilla)
356
+ * @param options - Configuration options containing schema, data, and context
331
357
  */
332
358
  constructor(wasmModule: any, { schema, context, data, fromCache }: JSONEvalOptions);
333
359
  /**
package/dist/index.js CHANGED
@@ -49,11 +49,16 @@ export var ReturnFormat;
49
49
  */
50
50
  export class JSONEvalCore {
51
51
  /**
52
- * @param wasmModule - WASM module (injected by wrapper package)
53
- * @param options
52
+ * Create a new JSONEval Core instance.
53
+ * Does not initialize WASM immediately; wait for `init()` or call async methods.
54
+ *
55
+ * @param wasmModule - The loaded WASM module (provided by wrapper packages like @json-eval-rs/node or /vanilla)
56
+ * @param options - Configuration options containing schema, data, and context
54
57
  */
55
58
  constructor(wasmModule, { schema, context, data, fromCache = false }) {
59
+ /** The underlying WASM JSONEval instance */
56
60
  this._instance = null;
61
+ /** Initialization state flag */
57
62
  this._ready = false;
58
63
  this._schema = schema;
59
64
  this._wasmModule = wasmModule;
@@ -343,8 +348,7 @@ export class JSONEvalCore {
343
348
  await this.init();
344
349
  const logic = typeof logicStr === 'string' ? logicStr : JSON.stringify(logicStr);
345
350
  const result = await this._instance.compileAndRunLogic(logic, data ? JSON.stringify(data) : null, context ? JSON.stringify(context) : null);
346
- // Parse result if it's a string
347
- return typeof result === 'string' ? JSON.parse(result) : result;
351
+ return result;
348
352
  }
349
353
  /**
350
354
  * Compile JSON logic and return a global ID
@@ -360,8 +364,7 @@ export class JSONEvalCore {
360
364
  async runLogic(logicId, data, context) {
361
365
  await this.init();
362
366
  const result = await this._instance.runLogic(logicId, data ? JSON.stringify(data) : null, context ? JSON.stringify(context) : null);
363
- // Parse result if it's a string
364
- return typeof result === 'string' ? JSON.parse(result) : result;
367
+ return result;
365
368
  }
366
369
  /**
367
370
  * Validate data against schema rules with optional path filtering
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-eval-rs/webcore",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "description": "JSON Eval RS core JavaScript wrapper (internal package - not published)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",