@json-eval-rs/node 0.0.29

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 ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @json-eval-rs/node - TypeScript definitions
3
+ */
4
+
5
+ /**
6
+ * Get the library version
7
+ * @returns Version string
8
+ */
9
+ export function version(): string;
10
+
11
+ export interface ValidationError {
12
+ path: string;
13
+ rule_type: string;
14
+ message: string;
15
+ }
16
+
17
+ export interface ValidationResult {
18
+ has_error: boolean;
19
+ errors: ValidationError[];
20
+ }
21
+
22
+ export interface JSONEvalOptions {
23
+ schema: any;
24
+ context?: any;
25
+ data?: any;
26
+ }
27
+
28
+ export interface ValidateOptions {
29
+ data: any;
30
+ context?: any;
31
+ }
32
+
33
+ export interface EvaluateOptions {
34
+ data: any;
35
+ context?: any;
36
+ }
37
+
38
+ export interface EvaluateDependentsOptions {
39
+ changedPath: string;
40
+ data?: any;
41
+ context?: any;
42
+ }
43
+
44
+ export interface GetEvaluatedSchemaOptions {
45
+ skipLayout?: boolean;
46
+ }
47
+
48
+ export interface GetValueByPathOptions {
49
+ path: string;
50
+ skipLayout?: boolean;
51
+ }
52
+
53
+ export interface ReloadSchemaOptions {
54
+ schema: any;
55
+ context?: any;
56
+ data?: any;
57
+ }
58
+
59
+ export interface CacheStats {
60
+ hits: number;
61
+ misses: number;
62
+ entries: number;
63
+ }
64
+
65
+ export interface EvaluateSubformOptions {
66
+ subformPath: string;
67
+ data: any;
68
+ context?: any;
69
+ }
70
+
71
+ export interface ValidateSubformOptions {
72
+ subformPath: string;
73
+ data: any;
74
+ context?: any;
75
+ }
76
+
77
+ export interface EvaluateDependentsSubformOptions {
78
+ subformPath: string;
79
+ changedPath: string;
80
+ data?: any;
81
+ context?: any;
82
+ }
83
+
84
+ export interface ResolveLayoutSubformOptions {
85
+ subformPath: string;
86
+ evaluate?: boolean;
87
+ }
88
+
89
+ export interface GetEvaluatedSchemaSubformOptions {
90
+ subformPath: string;
91
+ resolveLayout?: boolean;
92
+ }
93
+
94
+ export interface GetSchemaValueSubformOptions {
95
+ subformPath: string;
96
+ }
97
+
98
+ export interface GetEvaluatedSchemaByPathSubformOptions {
99
+ subformPath: string;
100
+ schemaPath: string;
101
+ skipLayout?: boolean;
102
+ }
103
+
104
+ export class JSONEval {
105
+ constructor(options: JSONEvalOptions);
106
+ init(): Promise<void>;
107
+ validate(options: ValidateOptions): Promise<ValidationResult>;
108
+ evaluate(options: EvaluateOptions): Promise<any>;
109
+ evaluateDependents(options: EvaluateDependentsOptions): Promise<any>;
110
+ getEvaluatedSchema(options?: GetEvaluatedSchemaOptions): Promise<any>;
111
+ getSchemaValue(): Promise<any>;
112
+ getEvaluatedSchemaWithoutParams(options?: GetEvaluatedSchemaOptions): Promise<any>;
113
+ getValueByPath(options: GetValueByPathOptions): Promise<any | null>;
114
+ reloadSchema(options: ReloadSchemaOptions): Promise<void>;
115
+ cacheStats(): Promise<CacheStats>;
116
+ clearCache(): Promise<void>;
117
+ cacheLen(): Promise<number>;
118
+
119
+ // Subform methods
120
+ evaluateSubform(options: EvaluateSubformOptions): Promise<void>;
121
+ validateSubform(options: ValidateSubformOptions): Promise<ValidationResult>;
122
+ evaluateDependentsSubform(options: EvaluateDependentsSubformOptions): Promise<any>;
123
+ resolveLayoutSubform(options: ResolveLayoutSubformOptions): Promise<void>;
124
+ getEvaluatedSchemaSubform(options: GetEvaluatedSchemaSubformOptions): Promise<any>;
125
+ getSchemaValueSubform(options: GetSchemaValueSubformOptions): Promise<any>;
126
+ getEvaluatedSchemaWithoutParamsSubform(options: GetEvaluatedSchemaSubformOptions): Promise<any>;
127
+ getEvaluatedSchemaByPathSubform(options: GetEvaluatedSchemaByPathSubformOptions): Promise<any | null>;
128
+ getSubformPaths(): Promise<string[]>;
129
+ hasSubform(subformPath: string): Promise<boolean>;
130
+
131
+ free(): void;
132
+ }
133
+
134
+ export function version(): string;
135
+
136
+ export default JSONEval;
package/index.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @json-eval-rs/node
3
+ * JSON Eval RS for Node.js and Server-Side Rendering (SSR)
4
+ */
5
+
6
+ import { JSONEvalCore, getVersion } from '@json-eval-rs/webcore';
7
+ import * as wasm from './pkg/json_eval_rs.js';
8
+
9
+ /**
10
+ * JSONEval class with Node.js WASM pre-configured
11
+ */
12
+ export class JSONEval extends JSONEvalCore {
13
+ constructor(options) {
14
+ super(wasm, options);
15
+ }
16
+
17
+ /**
18
+ * Create a new JSONEval instance from a cached ParsedSchema
19
+ * @param {string} cacheKey - Cache key to lookup in ParsedSchemaCache
20
+ * @param {object} [context] - Optional context data
21
+ * @param {object} [data] - Optional initial data
22
+ * @returns {JSONEval} New instance
23
+ */
24
+ static fromCache(cacheKey, context, data) {
25
+ return new JSONEval({
26
+ schema: cacheKey,
27
+ context,
28
+ data,
29
+ fromCache: true
30
+ });
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Get library version
36
+ * @returns {string}
37
+ */
38
+ export function version() {
39
+ return getVersion(wasm);
40
+ }
41
+
42
+ // Re-export types for convenience
43
+ export * from '@json-eval-rs/webcore';
44
+
45
+ export default JSONEval;
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@json-eval-rs/node",
3
+ "version": "0.0.29",
4
+ "description": "JSON Eval RS for Node.js and Server-Side Rendering with ergonomic API",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "module",
8
+ "files": [
9
+ "index.js",
10
+ "index.d.ts",
11
+ "pkg/*.js",
12
+ "pkg/*.wasm",
13
+ "pkg/*.d.ts"
14
+ ],
15
+ "keywords": [
16
+ "json",
17
+ "json-logic",
18
+ "schema",
19
+ "validation",
20
+ "wasm",
21
+ "nodejs",
22
+ "ssr"
23
+ ],
24
+ "author": "Muhamad Rizki",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/byrizki/json-eval-rs.git",
29
+ "directory": "bindings/web/packages/node"
30
+ },
31
+ "dependencies": {
32
+ "@json-eval-rs/webcore": "*"
33
+ },
34
+ "sideEffects": false
35
+ }