node-json-schema-transformer 0.1.0

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.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +103 -0
  3. package/index.d.ts +148 -0
  4. package/index.js +716 -0
  5. package/package.json +95 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 N-API for Rust
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # `node-json-schema-transformer`
2
+
3
+ Node bindings for [json-schema-transformer](https://github.com/ChildishForces/json-schema-transformer) — transform JSON Schema into native types and validation schemas for multiple languages, powered by Rust via [napi-rs](https://napi.rs).
4
+
5
+ Supported targets: **Zod** (TypeScript), **TypeScript** declarations, **Pydantic** (Python), **Swift** (Codable), **Kotlin** (kotlinx.serialization), and **Rust** (serde).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ yarn add node-json-schema-transformer
11
+ ```
12
+
13
+ Prebuilt binaries are published for macOS (x64/arm64), Linux (x64/arm64 gnu), and Windows (x64).
14
+
15
+ ## Usage
16
+
17
+ ### Convenience functions
18
+
19
+ One call per target language; the module string is returned:
20
+
21
+ ```ts
22
+ import { jsonSchemaToZodModule } from 'node-json-schema-transformer'
23
+
24
+ const schema = {
25
+ type: 'object',
26
+ properties: {
27
+ id: { type: 'string', format: 'uuid' },
28
+ name: { type: 'string' },
29
+ },
30
+ required: ['id'],
31
+ }
32
+
33
+ const module = jsonSchemaToZodModule(schema, 'person')
34
+ // import { z } from "zod";
35
+ // export const PersonSchema = z.object({ id: z.string().uuid(), name: z.string().optional() });
36
+ // export type Person = z.infer<typeof PersonSchema>;
37
+ ```
38
+
39
+ Also available: `jsonSchemaToTypescript`, `jsonSchemaToPydantic`, `jsonSchemaToSwift`, `jsonSchemaToKotlin`, `jsonSchemaToRust`.
40
+
41
+ The name argument is optional — when omitted, the schema's root `title` is used; if neither is present an error is thrown.
42
+
43
+ ### `transform` with options
44
+
45
+ ```ts
46
+ import { Language, transform } from 'node-json-schema-transformer'
47
+
48
+ const swift = transform(schema, Language.Swift, {
49
+ name: 'person',
50
+ // Swift `var` / Kotlin `var` / Pydantic assignment re-validation
51
+ mutable: true,
52
+ // treat `format` as annotation-only (draft 2020-12 behavior)
53
+ enforceFormats: false,
54
+ // resolve non-fragment $refs against remote documents
55
+ remotes: { 'https://example.com/address.json': addressSchema },
56
+ })
57
+ ```
58
+
59
+ ### Collections
60
+
61
+ When generating many modules, use a `CollectionSession` so runtime helpers are shared via one companion file (tailored to exactly what the emitted modules need) instead of being inlined into every module:
62
+
63
+ ```ts
64
+ import { CollectionSession, Language } from 'node-json-schema-transformer'
65
+
66
+ const session = new CollectionSession(Language.Zod)
67
+ const moduleA = session.emit(schemaA, 'EventA')
68
+ const moduleB = session.emit(schemaB, 'EventB', '../') // nested one directory down
69
+
70
+ const helpers = session.helpers()
71
+ if (helpers) {
72
+ // write helpers.content to helpers.fileName at the collection root
73
+ }
74
+ ```
75
+
76
+ ### Language metadata
77
+
78
+ ```ts
79
+ import { defaultHelpersFile, extensionFor, helpersContent, Language } from 'node-json-schema-transformer'
80
+
81
+ extensionFor(Language.Zod) // "zod.ts"
82
+ defaultHelpersFile(Language.Pydantic) // "jst_helpers.py"
83
+ helpersContent(Language.Kotlin) // full helpers file superset
84
+ ```
85
+
86
+ ## Develop
87
+
88
+ - Install the latest Rust toolchain, Node.js, [bun](https://bun.sh), and yarn 4 (via corepack)
89
+ - `yarn install`
90
+ - `yarn build:debug` — build the native addon and regenerate `index.js` / `index.d.ts`
91
+ - `yarn test` — run the test suite with `bun test`
92
+ - `yarn bench` — run benchmarks
93
+
94
+ ## Release
95
+
96
+ Set **NPM_TOKEN** in the repository's GitHub secrets, then:
97
+
98
+ ```bash
99
+ npm version [major | minor | patch | ...]
100
+ git push
101
+ ```
102
+
103
+ GitHub Actions builds the per-platform binaries and publishes to npm. Don't run `npm publish` manually.
package/index.d.ts ADDED
@@ -0,0 +1,148 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Emits a collection of schemas that share one tailored helpers file.
6
+ *
7
+ * Each `emit` call produces one module in collection mode (helpers
8
+ * referenced, never inlined) and accumulates the helper components that
9
+ * module needs. After all members are emitted, `helpers()` yields the shared
10
+ * helpers file containing exactly the union of accumulated needs — or null
11
+ * when no member needed any helpers.
12
+ */
13
+ export declare class CollectionSession {
14
+ constructor(language: Language, options?: CollectionSessionOptions | undefined | null)
15
+ /**
16
+ * Emit one member module. `dirPrefix` is the relative path from the
17
+ * module's output directory back to the collection root: "" (default) for
18
+ * root-level files, one "../" per nesting level.
19
+ */
20
+ emit(schema: any, name?: string | undefined | null, dirPrefix?: string | undefined | null, options?: ConvertOptions | undefined | null): string
21
+ /**
22
+ * The shared helpers file name this session will use, or null for
23
+ * languages that emit no runtime helpers.
24
+ */
25
+ helpersFileName(): string | null
26
+ /** Helper component keys needed by all members emitted so far. */
27
+ helperNeeds(): Array<string>
28
+ /**
29
+ * The tailored shared helpers file, or null when no member needed helpers
30
+ * (no file should be written).
31
+ */
32
+ helpers(): HelpersFile | null
33
+ }
34
+
35
+ export interface CollectionSessionOptions {
36
+ /** Custom helpers file name; defaults to the language's conventional name. */
37
+ helpersFile?: string
38
+ /** Emit mutable stored properties (see `TransformOptions#mutable`). */
39
+ mutable?: boolean
40
+ }
41
+
42
+ export interface ConvertOptions {
43
+ /**
44
+ * Remote schema documents (URI → document) that non-fragment `$ref`s may
45
+ * resolve against.
46
+ */
47
+ remotes?: Record<string, any>
48
+ /** Enforce `format` during validation (default true). */
49
+ enforceFormats?: boolean
50
+ }
51
+
52
+ /**
53
+ * Conventional shared helpers file name for the language, or null for
54
+ * languages that emit no runtime helpers.
55
+ */
56
+ export declare function defaultHelpersFile(language: Language): string | null
57
+
58
+ /** File extension for the language's generated output (e.g. "zod.ts", "d.ts", "py"). */
59
+ export declare function extensionFor(language: Language): string
60
+
61
+ /**
62
+ * Full content of the language's shared helpers file (a superset of every
63
+ * possible need), or null when the language emits no runtime helpers. Prefer
64
+ * `CollectionSession#helpers` which tailors the file to actual needs.
65
+ */
66
+ export declare function helpersContent(language: Language): string | null
67
+
68
+ /** The shared helpers companion file for an emitted collection. */
69
+ export interface HelpersFile {
70
+ fileName: string
71
+ content: string
72
+ }
73
+
74
+ /** Convert a JSON Schema to a Kotlin data class. */
75
+ export declare function jsonSchemaToKotlin(schema: any, name?: string | undefined | null): string
76
+
77
+ /** Convert a JSON Schema to a Python Pydantic model. */
78
+ export declare function jsonSchemaToPydantic(schema: any, name?: string | undefined | null): string
79
+
80
+ /** Convert a JSON Schema to Rust serde types with validating deserialization. */
81
+ export declare function jsonSchemaToRust(schema: any, name?: string | undefined | null): string
82
+
83
+ /** Convert a JSON Schema to a Swift Codable struct. */
84
+ export declare function jsonSchemaToSwift(schema: any, name?: string | undefined | null): string
85
+
86
+ /** Convert a JSON Schema to TypeScript type definitions (.d.ts). */
87
+ export declare function jsonSchemaToTypescript(schema: any, name?: string | undefined | null): string
88
+
89
+ /** Convert a JSON Schema to a complete Zod TypeScript module string. */
90
+ export declare function jsonSchemaToZodModule(schema: any, name?: string | undefined | null): string
91
+
92
+ /** Target language/framework for generated output. */
93
+ export declare const enum Language {
94
+ Zod = 'zod',
95
+ TypeScript = 'typescript',
96
+ Pydantic = 'pydantic',
97
+ Swift = 'swift',
98
+ Kotlin = 'kotlin',
99
+ Rust = 'rust',
100
+ }
101
+
102
+ /**
103
+ * Location of the shared helpers file relative to a generated module
104
+ * (collection mode). Without this, helpers are inlined and the module is
105
+ * self-contained.
106
+ */
107
+ export interface SharedHelpersOptions {
108
+ /** Helper file name at the collection root, e.g. "jst-helpers.ts". */
109
+ fileName: string
110
+ /**
111
+ * Relative path prefix from the generated file's directory back to the
112
+ * collection root: "" (default) for root-level files, one "../" per
113
+ * nesting level.
114
+ */
115
+ dirPrefix?: string
116
+ }
117
+
118
+ /** Convert a JSON Schema to generated code for the given target language. */
119
+ export declare function transform(schema: any, language: Language, options?: TransformOptions | undefined | null): string
120
+
121
+ export interface TransformOptions {
122
+ /**
123
+ * Generated root type name (PascalCased). Falls back to the schema's root
124
+ * `title`; errors when neither is available.
125
+ */
126
+ name?: string
127
+ /**
128
+ * Emit mutable stored properties (Swift `var`, Kotlin `var`; Pydantic
129
+ * enables assignment re-validation). No-op for Rust and TypeScript/Zod.
130
+ */
131
+ mutable?: boolean
132
+ /**
133
+ * Collection mode: reference helpers from a shared companion file instead
134
+ * of inlining them. Prefer `CollectionSession` which also tailors the
135
+ * helpers file to what the emitted modules actually need.
136
+ */
137
+ helpers?: SharedHelpersOptions
138
+ /**
139
+ * Remote schema documents (URI → document) that non-fragment `$ref`s may
140
+ * resolve against.
141
+ */
142
+ remotes?: Record<string, any>
143
+ /**
144
+ * Enforce `format` during validation (default true). Draft 2020-12 treats
145
+ * `format` as annotation-only; set false for that behavior.
146
+ */
147
+ enforceFormats?: boolean
148
+ }
package/index.js ADDED
@@ -0,0 +1,716 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /* auto-generated by NAPI-RS */
4
+
5
+ import { createRequire } from 'module'
6
+ const require = createRequire(import.meta.url)
7
+
8
+ const { readFileSync } = require('fs')
9
+ let nativeBinding = null
10
+ const loadErrors = []
11
+
12
+ const isMusl = () => {
13
+ let musl = false
14
+ if (process.platform === 'linux') {
15
+ musl = isMuslFromFilesystem()
16
+ if (musl === null) {
17
+ musl = isMuslFromReport()
18
+ }
19
+ if (musl === null) {
20
+ musl = isMuslFromChildProcess()
21
+ }
22
+ }
23
+ return musl
24
+ }
25
+
26
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
27
+
28
+ const isMuslFromFilesystem = () => {
29
+ try {
30
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
31
+ } catch {
32
+ return null
33
+ }
34
+ }
35
+
36
+ const isMuslFromReport = () => {
37
+ let report = null
38
+ if (process.report && typeof process.report.getReport === 'function') {
39
+ process.report.excludeNetwork = true
40
+ report = process.report.getReport()
41
+ }
42
+ if (!report) {
43
+ return null
44
+ }
45
+ if (report.header && report.header.glibcVersionRuntime) {
46
+ return false
47
+ }
48
+ if (Array.isArray(report.sharedObjects)) {
49
+ if (report.sharedObjects.some(isFileMusl)) {
50
+ return true
51
+ }
52
+ }
53
+ return false
54
+ }
55
+
56
+ const isMuslFromChildProcess = () => {
57
+ try {
58
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
59
+ } catch (e) {
60
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
61
+ return false
62
+ }
63
+ }
64
+
65
+ function requireNative() {
66
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
67
+ try {
68
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
69
+ } catch (err) {
70
+ loadErrors.push(err)
71
+ }
72
+ } else if (process.platform === 'android') {
73
+ if (process.arch === 'arm64') {
74
+ try {
75
+ return require('./node-json-schema-transformer.android-arm64.node')
76
+ } catch (e) {
77
+ loadErrors.push(e)
78
+ }
79
+ try {
80
+ const binding = require('node-json-schema-transformer-android-arm64')
81
+ const bindingPackageVersion = require('node-json-schema-transformer-android-arm64/package.json').version
82
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
83
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ }
85
+ return binding
86
+ } catch (e) {
87
+ loadErrors.push(e)
88
+ }
89
+ } else if (process.arch === 'arm') {
90
+ try {
91
+ return require('./node-json-schema-transformer.android-arm-eabi.node')
92
+ } catch (e) {
93
+ loadErrors.push(e)
94
+ }
95
+ try {
96
+ const binding = require('node-json-schema-transformer-android-arm-eabi')
97
+ const bindingPackageVersion = require('node-json-schema-transformer-android-arm-eabi/package.json').version
98
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
99
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ }
101
+ return binding
102
+ } catch (e) {
103
+ loadErrors.push(e)
104
+ }
105
+ } else {
106
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
107
+ }
108
+ } else if (process.platform === 'win32') {
109
+ if (process.arch === 'x64') {
110
+ if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
111
+ try {
112
+ return require('./node-json-schema-transformer.win32-x64-gnu.node')
113
+ } catch (e) {
114
+ loadErrors.push(e)
115
+ }
116
+ try {
117
+ const binding = require('node-json-schema-transformer-win32-x64-gnu')
118
+ const bindingPackageVersion = require('node-json-schema-transformer-win32-x64-gnu/package.json').version
119
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
120
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
+ }
122
+ return binding
123
+ } catch (e) {
124
+ loadErrors.push(e)
125
+ }
126
+ } else {
127
+ try {
128
+ return require('./node-json-schema-transformer.win32-x64-msvc.node')
129
+ } catch (e) {
130
+ loadErrors.push(e)
131
+ }
132
+ try {
133
+ const binding = require('node-json-schema-transformer-win32-x64-msvc')
134
+ const bindingPackageVersion = require('node-json-schema-transformer-win32-x64-msvc/package.json').version
135
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
136
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ }
138
+ return binding
139
+ } catch (e) {
140
+ loadErrors.push(e)
141
+ }
142
+ }
143
+ } else if (process.arch === 'ia32') {
144
+ try {
145
+ return require('./node-json-schema-transformer.win32-ia32-msvc.node')
146
+ } catch (e) {
147
+ loadErrors.push(e)
148
+ }
149
+ try {
150
+ const binding = require('node-json-schema-transformer-win32-ia32-msvc')
151
+ const bindingPackageVersion = require('node-json-schema-transformer-win32-ia32-msvc/package.json').version
152
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
153
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ }
155
+ return binding
156
+ } catch (e) {
157
+ loadErrors.push(e)
158
+ }
159
+ } else if (process.arch === 'arm64') {
160
+ try {
161
+ return require('./node-json-schema-transformer.win32-arm64-msvc.node')
162
+ } catch (e) {
163
+ loadErrors.push(e)
164
+ }
165
+ try {
166
+ const binding = require('node-json-schema-transformer-win32-arm64-msvc')
167
+ const bindingPackageVersion = require('node-json-schema-transformer-win32-arm64-msvc/package.json').version
168
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
169
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ }
171
+ return binding
172
+ } catch (e) {
173
+ loadErrors.push(e)
174
+ }
175
+ } else {
176
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
177
+ }
178
+ } else if (process.platform === 'darwin') {
179
+ try {
180
+ return require('./node-json-schema-transformer.darwin-universal.node')
181
+ } catch (e) {
182
+ loadErrors.push(e)
183
+ }
184
+ try {
185
+ const binding = require('node-json-schema-transformer-darwin-universal')
186
+ const bindingPackageVersion = require('node-json-schema-transformer-darwin-universal/package.json').version
187
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
188
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ }
190
+ return binding
191
+ } catch (e) {
192
+ loadErrors.push(e)
193
+ }
194
+ if (process.arch === 'x64') {
195
+ try {
196
+ return require('./node-json-schema-transformer.darwin-x64.node')
197
+ } catch (e) {
198
+ loadErrors.push(e)
199
+ }
200
+ try {
201
+ const binding = require('node-json-schema-transformer-darwin-x64')
202
+ const bindingPackageVersion = require('node-json-schema-transformer-darwin-x64/package.json').version
203
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
204
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ }
206
+ return binding
207
+ } catch (e) {
208
+ loadErrors.push(e)
209
+ }
210
+ } else if (process.arch === 'arm64') {
211
+ try {
212
+ return require('./node-json-schema-transformer.darwin-arm64.node')
213
+ } catch (e) {
214
+ loadErrors.push(e)
215
+ }
216
+ try {
217
+ const binding = require('node-json-schema-transformer-darwin-arm64')
218
+ const bindingPackageVersion = require('node-json-schema-transformer-darwin-arm64/package.json').version
219
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
220
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ }
222
+ return binding
223
+ } catch (e) {
224
+ loadErrors.push(e)
225
+ }
226
+ } else {
227
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
228
+ }
229
+ } else if (process.platform === 'freebsd') {
230
+ if (process.arch === 'x64') {
231
+ try {
232
+ return require('./node-json-schema-transformer.freebsd-x64.node')
233
+ } catch (e) {
234
+ loadErrors.push(e)
235
+ }
236
+ try {
237
+ const binding = require('node-json-schema-transformer-freebsd-x64')
238
+ const bindingPackageVersion = require('node-json-schema-transformer-freebsd-x64/package.json').version
239
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
240
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ }
242
+ return binding
243
+ } catch (e) {
244
+ loadErrors.push(e)
245
+ }
246
+ } else if (process.arch === 'arm64') {
247
+ try {
248
+ return require('./node-json-schema-transformer.freebsd-arm64.node')
249
+ } catch (e) {
250
+ loadErrors.push(e)
251
+ }
252
+ try {
253
+ const binding = require('node-json-schema-transformer-freebsd-arm64')
254
+ const bindingPackageVersion = require('node-json-schema-transformer-freebsd-arm64/package.json').version
255
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
256
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ }
258
+ return binding
259
+ } catch (e) {
260
+ loadErrors.push(e)
261
+ }
262
+ } else {
263
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
264
+ }
265
+ } else if (process.platform === 'linux') {
266
+ if (process.arch === 'x64') {
267
+ if (isMusl()) {
268
+ try {
269
+ return require('./node-json-schema-transformer.linux-x64-musl.node')
270
+ } catch (e) {
271
+ loadErrors.push(e)
272
+ }
273
+ try {
274
+ const binding = require('node-json-schema-transformer-linux-x64-musl')
275
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-x64-musl/package.json').version
276
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
277
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ }
279
+ return binding
280
+ } catch (e) {
281
+ loadErrors.push(e)
282
+ }
283
+ } else {
284
+ try {
285
+ return require('./node-json-schema-transformer.linux-x64-gnu.node')
286
+ } catch (e) {
287
+ loadErrors.push(e)
288
+ }
289
+ try {
290
+ const binding = require('node-json-schema-transformer-linux-x64-gnu')
291
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-x64-gnu/package.json').version
292
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
293
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ }
295
+ return binding
296
+ } catch (e) {
297
+ loadErrors.push(e)
298
+ }
299
+ }
300
+ } else if (process.arch === 'arm64') {
301
+ if (isMusl()) {
302
+ try {
303
+ return require('./node-json-schema-transformer.linux-arm64-musl.node')
304
+ } catch (e) {
305
+ loadErrors.push(e)
306
+ }
307
+ try {
308
+ const binding = require('node-json-schema-transformer-linux-arm64-musl')
309
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-arm64-musl/package.json').version
310
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ }
313
+ return binding
314
+ } catch (e) {
315
+ loadErrors.push(e)
316
+ }
317
+ } else {
318
+ try {
319
+ return require('./node-json-schema-transformer.linux-arm64-gnu.node')
320
+ } catch (e) {
321
+ loadErrors.push(e)
322
+ }
323
+ try {
324
+ const binding = require('node-json-schema-transformer-linux-arm64-gnu')
325
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-arm64-gnu/package.json').version
326
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
327
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ }
329
+ return binding
330
+ } catch (e) {
331
+ loadErrors.push(e)
332
+ }
333
+ }
334
+ } else if (process.arch === 'arm') {
335
+ if (isMusl()) {
336
+ try {
337
+ return require('./node-json-schema-transformer.linux-arm-musleabihf.node')
338
+ } catch (e) {
339
+ loadErrors.push(e)
340
+ }
341
+ try {
342
+ const binding = require('node-json-schema-transformer-linux-arm-musleabihf')
343
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-arm-musleabihf/package.json').version
344
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ }
347
+ return binding
348
+ } catch (e) {
349
+ loadErrors.push(e)
350
+ }
351
+ } else {
352
+ try {
353
+ return require('./node-json-schema-transformer.linux-arm-gnueabihf.node')
354
+ } catch (e) {
355
+ loadErrors.push(e)
356
+ }
357
+ try {
358
+ const binding = require('node-json-schema-transformer-linux-arm-gnueabihf')
359
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-arm-gnueabihf/package.json').version
360
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
361
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
+ }
363
+ return binding
364
+ } catch (e) {
365
+ loadErrors.push(e)
366
+ }
367
+ }
368
+ } else if (process.arch === 'loong64') {
369
+ if (isMusl()) {
370
+ try {
371
+ return require('./node-json-schema-transformer.linux-loong64-musl.node')
372
+ } catch (e) {
373
+ loadErrors.push(e)
374
+ }
375
+ try {
376
+ const binding = require('node-json-schema-transformer-linux-loong64-musl')
377
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-loong64-musl/package.json').version
378
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ }
381
+ return binding
382
+ } catch (e) {
383
+ loadErrors.push(e)
384
+ }
385
+ } else {
386
+ try {
387
+ return require('./node-json-schema-transformer.linux-loong64-gnu.node')
388
+ } catch (e) {
389
+ loadErrors.push(e)
390
+ }
391
+ try {
392
+ const binding = require('node-json-schema-transformer-linux-loong64-gnu')
393
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-loong64-gnu/package.json').version
394
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
395
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ }
397
+ return binding
398
+ } catch (e) {
399
+ loadErrors.push(e)
400
+ }
401
+ }
402
+ } else if (process.arch === 'riscv64') {
403
+ if (isMusl()) {
404
+ try {
405
+ return require('./node-json-schema-transformer.linux-riscv64-musl.node')
406
+ } catch (e) {
407
+ loadErrors.push(e)
408
+ }
409
+ try {
410
+ const binding = require('node-json-schema-transformer-linux-riscv64-musl')
411
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-riscv64-musl/package.json').version
412
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
413
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
+ }
415
+ return binding
416
+ } catch (e) {
417
+ loadErrors.push(e)
418
+ }
419
+ } else {
420
+ try {
421
+ return require('./node-json-schema-transformer.linux-riscv64-gnu.node')
422
+ } catch (e) {
423
+ loadErrors.push(e)
424
+ }
425
+ try {
426
+ const binding = require('node-json-schema-transformer-linux-riscv64-gnu')
427
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-riscv64-gnu/package.json').version
428
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
429
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ }
431
+ return binding
432
+ } catch (e) {
433
+ loadErrors.push(e)
434
+ }
435
+ }
436
+ } else if (process.arch === 'ppc64') {
437
+ try {
438
+ return require('./node-json-schema-transformer.linux-ppc64-gnu.node')
439
+ } catch (e) {
440
+ loadErrors.push(e)
441
+ }
442
+ try {
443
+ const binding = require('node-json-schema-transformer-linux-ppc64-gnu')
444
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-ppc64-gnu/package.json').version
445
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
446
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
+ }
448
+ return binding
449
+ } catch (e) {
450
+ loadErrors.push(e)
451
+ }
452
+ } else if (process.arch === 's390x') {
453
+ try {
454
+ return require('./node-json-schema-transformer.linux-s390x-gnu.node')
455
+ } catch (e) {
456
+ loadErrors.push(e)
457
+ }
458
+ try {
459
+ const binding = require('node-json-schema-transformer-linux-s390x-gnu')
460
+ const bindingPackageVersion = require('node-json-schema-transformer-linux-s390x-gnu/package.json').version
461
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
462
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
463
+ }
464
+ return binding
465
+ } catch (e) {
466
+ loadErrors.push(e)
467
+ }
468
+ } else {
469
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
470
+ }
471
+ } else if (process.platform === 'openharmony') {
472
+ if (process.arch === 'arm64') {
473
+ try {
474
+ return require('./node-json-schema-transformer.openharmony-arm64.node')
475
+ } catch (e) {
476
+ loadErrors.push(e)
477
+ }
478
+ try {
479
+ const binding = require('node-json-schema-transformer-openharmony-arm64')
480
+ const bindingPackageVersion = require('node-json-schema-transformer-openharmony-arm64/package.json').version
481
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
482
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
+ }
484
+ return binding
485
+ } catch (e) {
486
+ loadErrors.push(e)
487
+ }
488
+ } else if (process.arch === 'x64') {
489
+ try {
490
+ return require('./node-json-schema-transformer.openharmony-x64.node')
491
+ } catch (e) {
492
+ loadErrors.push(e)
493
+ }
494
+ try {
495
+ const binding = require('node-json-schema-transformer-openharmony-x64')
496
+ const bindingPackageVersion = require('node-json-schema-transformer-openharmony-x64/package.json').version
497
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
498
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
+ }
500
+ return binding
501
+ } catch (e) {
502
+ loadErrors.push(e)
503
+ }
504
+ } else if (process.arch === 'arm') {
505
+ try {
506
+ return require('./node-json-schema-transformer.openharmony-arm.node')
507
+ } catch (e) {
508
+ loadErrors.push(e)
509
+ }
510
+ try {
511
+ const binding = require('node-json-schema-transformer-openharmony-arm')
512
+ const bindingPackageVersion = require('node-json-schema-transformer-openharmony-arm/package.json').version
513
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
514
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ }
516
+ return binding
517
+ } catch (e) {
518
+ loadErrors.push(e)
519
+ }
520
+ } else {
521
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
522
+ }
523
+ } else {
524
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
525
+ }
526
+ }
527
+
528
+ function createLoadErrorChain(errors) {
529
+ return errors.reduce((previous, current) => {
530
+ let message
531
+ try {
532
+ message =
533
+ current && typeof current.message === 'string'
534
+ ? current.message
535
+ : String(current)
536
+ } catch {
537
+ message = 'Unknown error'
538
+ }
539
+ const error = new Error(message)
540
+ error.cause = previous
541
+ return error
542
+ }, null)
543
+ }
544
+
545
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
546
+ // unset / any other value → native binding preferred, WASI is only a fallback
547
+ // 'true' → prefer WASI, but retain native as a lazy fallback
548
+ // 'error' → require WASI without initializing a native fallback
549
+ // Treating any non-empty string as truthy (the historical behavior) meant
550
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
551
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
552
+ //
553
+ // NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
554
+ // WASI loading. It never crosses into another flavor or falls back to native.
555
+ const __napiWasiFlavors = ['wasm32-wasi']
556
+ const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
557
+ const __napiWasiFlavorRequested =
558
+ typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
559
+ if (
560
+ __napiWasiFlavorRequested &&
561
+ __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
562
+ ) {
563
+ throw new Error(
564
+ 'Unsupported WASI flavor "' +
565
+ __napiWasiFlavor +
566
+ '". Available flavors: ' +
567
+ __napiWasiFlavors.join(', '),
568
+ )
569
+ }
570
+ const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
571
+ const forceWasi =
572
+ process.env.NAPI_RS_FORCE_WASI === 'true' ||
573
+ forceWasiError ||
574
+ __napiWasiFlavorRequested
575
+
576
+ if (!forceWasi) {
577
+ nativeBinding = requireNative()
578
+ }
579
+
580
+ if (!nativeBinding || forceWasi) {
581
+ let wasiBinding = null
582
+ let wasiBindingLoaded = false
583
+ const wasiBindingErrors = []
584
+ const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
585
+ try {
586
+ require.resolve(specifier)
587
+ } catch (resolveError) {
588
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
589
+ throw resolveError
590
+ }
591
+ if (isPackage) {
592
+ try {
593
+ require.resolve(specifier + '/package.json')
594
+ } catch (packageError) {
595
+ if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
596
+ return resolveError
597
+ }
598
+ // An exports restriction proves the package exists even when its
599
+ // package.json is not public. Preserve the root resolution failure.
600
+ throw resolveError
601
+ }
602
+ // The package exists but its main/export target is broken.
603
+ throw resolveError
604
+ }
605
+ return resolveError
606
+ }
607
+ if (localArtifacts) {
608
+ let artifactError = null
609
+ for (let i = 0; i < localArtifacts.length; i++) {
610
+ try {
611
+ require.resolve(localArtifacts[i])
612
+ return null
613
+ } catch (resolveError) {
614
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
615
+ throw resolveError
616
+ }
617
+ artifactError = resolveError
618
+ }
619
+ }
620
+ return artifactError
621
+ }
622
+ return null
623
+ }
624
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
625
+ let candidateError = null
626
+ let candidateFailed = false
627
+ try {
628
+ candidateError = __napiWasiResolveCandidate('./node-json-schema-transformer.wasi.cjs', false, ['./node-json-schema-transformer.wasm32-wasi.debug.wasm', './node-json-schema-transformer.wasm32-wasi.wasm'])
629
+ candidateFailed = candidateError !== null
630
+ if (!candidateFailed) {
631
+ wasiBinding = require('./node-json-schema-transformer.wasi.cjs')
632
+ nativeBinding = wasiBinding
633
+ wasiBindingLoaded = true
634
+ }
635
+ } catch (err) {
636
+ candidateError = err
637
+ candidateFailed = true
638
+ }
639
+ if (candidateFailed) {
640
+ wasiBindingErrors.push(candidateError)
641
+ loadErrors.push(candidateError)
642
+ }
643
+ }
644
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
645
+ let candidateError = null
646
+ let candidateFailed = false
647
+ try {
648
+ candidateError = __napiWasiResolveCandidate('node-json-schema-transformer-wasm32-wasi', true, undefined)
649
+ candidateFailed = candidateError !== null
650
+ if (!candidateFailed) {
651
+ if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
652
+ const bindingPackageVersion = require('node-json-schema-transformer-wasm32-wasi/package.json').version
653
+ if (bindingPackageVersion !== '0.1.0') {
654
+ throw new Error(`WASI binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
655
+ }
656
+ }
657
+ wasiBinding = require('node-json-schema-transformer-wasm32-wasi')
658
+ nativeBinding = wasiBinding
659
+ wasiBindingLoaded = true
660
+ }
661
+ } catch (err) {
662
+ candidateError = err
663
+ candidateFailed = true
664
+ }
665
+ if (candidateFailed) {
666
+ wasiBindingErrors.push(candidateError)
667
+ loadErrors.push(candidateError)
668
+ }
669
+ }
670
+ if (
671
+ !wasiBindingLoaded &&
672
+ forceWasi &&
673
+ !forceWasiError &&
674
+ !__napiWasiFlavorRequested
675
+ ) {
676
+ nativeBinding = requireNative()
677
+ }
678
+ if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
679
+ const error = new Error(
680
+ __napiWasiFlavorRequested
681
+ ? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
682
+ : 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
683
+ )
684
+ error.cause = createLoadErrorChain(wasiBindingErrors)
685
+ throw error
686
+ }
687
+ }
688
+
689
+ if (!nativeBinding) {
690
+ if (loadErrors.length > 0) {
691
+ const error = new Error(
692
+ `Cannot find native binding. ` +
693
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
694
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
695
+ )
696
+ // assign instead of the `new Error(message, { cause })` options form,
697
+ // which Node < 16.9 silently ignores
698
+ error.cause = createLoadErrorChain(loadErrors)
699
+ throw error
700
+ }
701
+ throw new Error(`Failed to load native binding`)
702
+ }
703
+
704
+ const { CollectionSession, defaultHelpersFile, extensionFor, helpersContent, jsonSchemaToKotlin, jsonSchemaToPydantic, jsonSchemaToRust, jsonSchemaToSwift, jsonSchemaToTypescript, jsonSchemaToZodModule, Language, transform } = nativeBinding
705
+ export { CollectionSession }
706
+ export { defaultHelpersFile }
707
+ export { extensionFor }
708
+ export { helpersContent }
709
+ export { jsonSchemaToKotlin }
710
+ export { jsonSchemaToPydantic }
711
+ export { jsonSchemaToRust }
712
+ export { jsonSchemaToSwift }
713
+ export { jsonSchemaToTypescript }
714
+ export { jsonSchemaToZodModule }
715
+ export { Language }
716
+ export { transform }
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "node-json-schema-transformer",
3
+ "version": "0.1.0",
4
+ "description": "Transform JSON Schema into native types and validation schemas for multiple languages",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ChildishForces/node-json-schema-transformer.git"
10
+ },
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "json-schema",
14
+ "zod",
15
+ "typescript",
16
+ "pydantic",
17
+ "swift",
18
+ "kotlin",
19
+ "codegen",
20
+ "napi-rs",
21
+ "Rust",
22
+ "node-addon"
23
+ ],
24
+ "files": [
25
+ "index.d.ts",
26
+ "index.js"
27
+ ],
28
+ "napi": {
29
+ "binaryName": "node-json-schema-transformer",
30
+ "targets": [
31
+ "aarch64-apple-darwin",
32
+ "aarch64-unknown-linux-gnu",
33
+ "x86_64-apple-darwin",
34
+ "x86_64-pc-windows-msvc",
35
+ "x86_64-unknown-linux-gnu"
36
+ ]
37
+ },
38
+ "engines": {
39
+ "node": ">= 10"
40
+ },
41
+ "publishConfig": {
42
+ "registry": "https://registry.npmjs.org/",
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "artifacts": "napi artifacts",
47
+ "bench": "node --import @oxc-node/core/register benchmark/bench.ts",
48
+ "build": "napi build --platform --release --esm",
49
+ "build:debug": "napi build --platform --esm",
50
+ "format": "run-p format:oxfmt format:rs",
51
+ "format:oxfmt": "oxfmt",
52
+ "format:rs": "cargo fmt",
53
+ "lint": "oxlint .",
54
+ "prepublishOnly": "napi prepublish -t npm",
55
+ "test": "bun test __test__",
56
+ "preversion": "napi build --platform --esm && git add .",
57
+ "version": "napi version",
58
+ "prepare": "husky"
59
+ },
60
+ "devDependencies": {
61
+ "@emnapi/core": "^2.0.0-alpha.5",
62
+ "@emnapi/runtime": "^2.0.0-alpha.5",
63
+ "@napi-rs/cli": "^3.9.1",
64
+ "@napi-rs/wasm-runtime": "^1.2.4",
65
+ "@oxc-node/core": "^0.1.2",
66
+ "@tybys/wasm-util": "^0.10.4",
67
+ "@types/bun": "^1.2.0",
68
+ "chalk": "^6.0.0",
69
+ "emnapi": "^2.0.0-alpha.5",
70
+ "husky": "^9.1.7",
71
+ "lint-staged": "^17.5.1",
72
+ "npm-run-all2": "^9.0.3",
73
+ "oxfmt": "^0.68.0",
74
+ "oxlint": "^1.83.0",
75
+ "prettier": "^3.9.6",
76
+ "tinybench": "^6.2.0",
77
+ "typescript": "^7.0.2"
78
+ },
79
+ "lint-staged": {
80
+ "*.@(js|ts|tsx)": [
81
+ "oxlint --fix"
82
+ ],
83
+ "*.@(js|ts|tsx|yml|yaml|md|json|toml)": [
84
+ "oxfmt --write"
85
+ ]
86
+ },
87
+ "packageManager": "yarn@4.18.0",
88
+ "optionalDependencies": {
89
+ "node-json-schema-transformer-darwin-arm64": "0.1.0",
90
+ "node-json-schema-transformer-linux-arm64-gnu": "0.1.0",
91
+ "node-json-schema-transformer-darwin-x64": "0.1.0",
92
+ "node-json-schema-transformer-win32-x64-msvc": "0.1.0",
93
+ "node-json-schema-transformer-linux-x64-gnu": "0.1.0"
94
+ }
95
+ }