@json-eval-rs/webcore 0.0.30 → 0.0.33
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/index.d.ts +9 -0
- package/index.js +18 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -101,6 +101,8 @@ export interface EvaluateOptions {
|
|
|
101
101
|
data: any;
|
|
102
102
|
/** Optional context data */
|
|
103
103
|
context?: any;
|
|
104
|
+
/** Optional array of paths for selective evaluation */
|
|
105
|
+
paths?: string[];
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
/**
|
|
@@ -360,6 +362,13 @@ export class JSONEval {
|
|
|
360
362
|
getSubformPaths(): Promise<string[]>;
|
|
361
363
|
hasSubform(subformPath: string): Promise<boolean>;
|
|
362
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Set timezone offset for datetime operations (TODAY, NOW)
|
|
367
|
+
* @param offsetMinutes - Timezone offset in minutes from UTC (e.g., 420 for UTC+7, -300 for UTC-5)
|
|
368
|
+
* Pass null or undefined to reset to UTC
|
|
369
|
+
*/
|
|
370
|
+
setTimezoneOffset(offsetMinutes: number | null | undefined): void;
|
|
371
|
+
|
|
363
372
|
free(): void;
|
|
364
373
|
}
|
|
365
374
|
|
package/index.js
CHANGED
|
@@ -147,14 +147,16 @@ export class JSONEvalCore {
|
|
|
147
147
|
* @param {object} options
|
|
148
148
|
* @param {object} options.data - Data to evaluate
|
|
149
149
|
* @param {object} [options.context] - Optional context
|
|
150
|
+
* @param {string[]} [options.paths] - Optional array of paths for selective evaluation
|
|
150
151
|
* @returns {Promise<any>}
|
|
151
152
|
*/
|
|
152
|
-
async evaluate({ data, context }) {
|
|
153
|
+
async evaluate({ data, context, paths }) {
|
|
153
154
|
await this.init();
|
|
154
155
|
try {
|
|
155
156
|
return this._instance.evaluateJS(
|
|
156
157
|
JSON.stringify(data),
|
|
157
|
-
context ? JSON.stringify(context) : null
|
|
158
|
+
context ? JSON.stringify(context) : null,
|
|
159
|
+
paths ? JSON.stringify(paths) : null
|
|
158
160
|
);
|
|
159
161
|
} catch (error) {
|
|
160
162
|
throw new Error(`Evaluation failed: ${error.message || error}`);
|
|
@@ -438,6 +440,20 @@ export class JSONEvalCore {
|
|
|
438
440
|
return this._instance.resolveLayout(evaluate);
|
|
439
441
|
}
|
|
440
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Set timezone offset for datetime operations (TODAY, NOW)
|
|
445
|
+
* @param {number|null|undefined} offsetMinutes - Timezone offset in minutes from UTC
|
|
446
|
+
* (e.g., 420 for UTC+7, -300 for UTC-5)
|
|
447
|
+
* Pass null or undefined to reset to UTC
|
|
448
|
+
* @returns {void}
|
|
449
|
+
*/
|
|
450
|
+
setTimezoneOffset(offsetMinutes) {
|
|
451
|
+
if (!this._instance) {
|
|
452
|
+
throw new Error('Instance not initialized. Call init() first.');
|
|
453
|
+
}
|
|
454
|
+
this._instance.set_timezone_offset(offsetMinutes);
|
|
455
|
+
}
|
|
456
|
+
|
|
441
457
|
/**
|
|
442
458
|
* Compile and run JSON logic from a JSON logic string
|
|
443
459
|
* @param {object} options - Options for compile and run logic
|