@graphql-hive/router-query-planner 0.0.2 → 0.0.3

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.cjs ADDED
@@ -0,0 +1,329 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ const { createRequire } = require('node:module')
7
+ require = createRequire(__filename);
8
+
9
+ const { readFileSync } = require("node:fs");
10
+ let nativeBinding = null;
11
+ const loadErrors = [];
12
+
13
+ const isMusl = () => {
14
+ let musl = false;
15
+ if (process.platform === "linux") {
16
+ musl = isMuslFromFilesystem();
17
+ if (musl === null) {
18
+ musl = isMuslFromReport();
19
+ }
20
+ if (musl === null) {
21
+ musl = isMuslFromChildProcess();
22
+ }
23
+ }
24
+ return musl;
25
+ };
26
+
27
+ const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
28
+
29
+ const isMuslFromFilesystem = () => {
30
+ try {
31
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
32
+ } catch {
33
+ return null;
34
+ }
35
+ };
36
+
37
+ const isMuslFromReport = () => {
38
+ let report = null;
39
+ if (typeof process.report?.getReport === "function") {
40
+ process.report.excludeNetwork = true;
41
+ report = process.report.getReport();
42
+ }
43
+ if (!report) {
44
+ return null;
45
+ }
46
+ if (report.header && report.header.glibcVersionRuntime) {
47
+ return false;
48
+ }
49
+ if (Array.isArray(report.sharedObjects)) {
50
+ if (report.sharedObjects.some(isFileMusl)) {
51
+ return true;
52
+ }
53
+ }
54
+ return false;
55
+ };
56
+
57
+ const isMuslFromChildProcess = () => {
58
+ try {
59
+ return require("child_process")
60
+ .execSync("ldd --version", { encoding: "utf8" })
61
+ .includes("musl");
62
+ } catch (e) {
63
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
64
+ return false;
65
+ }
66
+ };
67
+
68
+ function requireNative() {
69
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
70
+ try {
71
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
72
+ } catch (err) {
73
+ loadErrors.push(err);
74
+ }
75
+ } else if (process.platform === "android") {
76
+ if (process.arch === "arm64") {
77
+ try {
78
+ return require("./hive_router_query_planner.android-arm64.node");
79
+ } catch (e) {
80
+ loadErrors.push(e);
81
+ }
82
+ } else if (process.arch === "arm") {
83
+ try {
84
+ return require("./hive_router_query_planner.android-arm-eabi.node");
85
+ } catch (e) {
86
+ loadErrors.push(e);
87
+ }
88
+ } else {
89
+ loadErrors.push(
90
+ new Error(`Unsupported architecture on Android ${process.arch}`)
91
+ );
92
+ }
93
+ } else if (process.platform === "win32") {
94
+ if (process.arch === "x64") {
95
+ if (
96
+ process.report?.getReport?.()?.header?.osName?.startsWith?.("MINGW")
97
+ ) {
98
+ try {
99
+ return require("./hive_router_query_planner.win32-x64-gnu.node");
100
+ } catch (e) {
101
+ loadErrors.push(e);
102
+ }
103
+ } else {
104
+ try {
105
+ return require("./hive_router_query_planner.win32-x64-msvc.node");
106
+ } catch (e) {
107
+ loadErrors.push(e);
108
+ }
109
+ }
110
+ } else if (process.arch === "ia32") {
111
+ try {
112
+ return require("./hive_router_query_planner.win32-ia32-msvc.node");
113
+ } catch (e) {
114
+ loadErrors.push(e);
115
+ }
116
+ } else if (process.arch === "arm64") {
117
+ try {
118
+ return require("./hive_router_query_planner.win32-arm64-msvc.node");
119
+ } catch (e) {
120
+ loadErrors.push(e);
121
+ }
122
+ } else {
123
+ loadErrors.push(
124
+ new Error(`Unsupported architecture on Windows: ${process.arch}`)
125
+ );
126
+ }
127
+ } else if (process.platform === "darwin") {
128
+ try {
129
+ return require("./hive_router_query_planner.darwin-universal.node");
130
+ } catch (e) {
131
+ loadErrors.push(e);
132
+ }
133
+ if (process.arch === "x64") {
134
+ try {
135
+ return require("./hive_router_query_planner.darwin-x64.node");
136
+ } catch (e) {
137
+ loadErrors.push(e);
138
+ }
139
+ } else if (process.arch === "arm64") {
140
+ try {
141
+ return require("./hive_router_query_planner.darwin-arm64.node");
142
+ } catch (e) {
143
+ loadErrors.push(e);
144
+ }
145
+ } else {
146
+ loadErrors.push(
147
+ new Error(`Unsupported architecture on macOS: ${process.arch}`)
148
+ );
149
+ }
150
+ } else if (process.platform === "freebsd") {
151
+ if (process.arch === "x64") {
152
+ try {
153
+ return require("./hive_router_query_planner.freebsd-x64.node");
154
+ } catch (e) {
155
+ loadErrors.push(e);
156
+ }
157
+ } else if (process.arch === "arm64") {
158
+ try {
159
+ return require("./hive_router_query_planner.freebsd-arm64.node");
160
+ } catch (e) {
161
+ loadErrors.push(e);
162
+ }
163
+ } else {
164
+ loadErrors.push(
165
+ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)
166
+ );
167
+ }
168
+ } else if (process.platform === "linux") {
169
+ if (process.arch === "x64") {
170
+ if (isMusl()) {
171
+ try {
172
+ return require("./hive_router_query_planner.linux-x64-musl.node");
173
+ } catch (e) {
174
+ loadErrors.push(e);
175
+ }
176
+ } else {
177
+ try {
178
+ return require("./hive_router_query_planner.linux-x64-gnu.node");
179
+ } catch (e) {
180
+ loadErrors.push(e);
181
+ }
182
+ }
183
+ } else if (process.arch === "arm64") {
184
+ if (isMusl()) {
185
+ try {
186
+ return require("./hive_router_query_planner.linux-arm64-musl.node");
187
+ } catch (e) {
188
+ loadErrors.push(e);
189
+ }
190
+ } else {
191
+ try {
192
+ return require("./hive_router_query_planner.linux-arm64-gnu.node");
193
+ } catch (e) {
194
+ loadErrors.push(e);
195
+ }
196
+ }
197
+ } else if (process.arch === "arm") {
198
+ if (isMusl()) {
199
+ try {
200
+ return require("./hive_router_query_planner.linux-arm-musleabihf.node");
201
+ } catch (e) {
202
+ loadErrors.push(e);
203
+ }
204
+ } else {
205
+ try {
206
+ return require("./hive_router_query_planner.linux-arm-gnueabihf.node");
207
+ } catch (e) {
208
+ loadErrors.push(e);
209
+ }
210
+ }
211
+ } else if (process.arch === "loong64") {
212
+ if (isMusl()) {
213
+ try {
214
+ return require("./hive_router_query_planner.linux-loong64-musl.node");
215
+ } catch (e) {
216
+ loadErrors.push(e);
217
+ }
218
+ } else {
219
+ try {
220
+ return require("./hive_router_query_planner.linux-loong64-gnu.node");
221
+ } catch (e) {
222
+ loadErrors.push(e);
223
+ }
224
+ }
225
+ } else if (process.arch === "riscv64") {
226
+ if (isMusl()) {
227
+ try {
228
+ return require("./hive_router_query_planner.linux-riscv64-musl.node");
229
+ } catch (e) {
230
+ loadErrors.push(e);
231
+ }
232
+ } else {
233
+ try {
234
+ return require("./hive_router_query_planner.linux-riscv64-gnu.node");
235
+ } catch (e) {
236
+ loadErrors.push(e);
237
+ }
238
+ }
239
+ } else if (process.arch === "ppc64") {
240
+ try {
241
+ return require("./hive_router_query_planner.linux-ppc64-gnu.node");
242
+ } catch (e) {
243
+ loadErrors.push(e);
244
+ }
245
+ } else if (process.arch === "s390x") {
246
+ try {
247
+ return require("./hive_router_query_planner.linux-s390x-gnu.node");
248
+ } catch (e) {
249
+ loadErrors.push(e);
250
+ }
251
+ } else {
252
+ loadErrors.push(
253
+ new Error(`Unsupported architecture on Linux: ${process.arch}`)
254
+ );
255
+ }
256
+ } else if (process.platform === "openharmony") {
257
+ if (process.arch === "arm64") {
258
+ try {
259
+ return require("./hive_router_query_planner.openharmony-arm64.node");
260
+ } catch (e) {
261
+ loadErrors.push(e);
262
+ }
263
+ } else if (process.arch === "x64") {
264
+ try {
265
+ return require("./hive_router_query_planner.openharmony-x64.node");
266
+ } catch (e) {
267
+ loadErrors.push(e);
268
+ }
269
+ } else if (process.arch === "arm") {
270
+ try {
271
+ return require("./hive_router_query_planner.openharmony-arm.node");
272
+ } catch (e) {
273
+ loadErrors.push(e);
274
+ }
275
+ } else {
276
+ loadErrors.push(
277
+ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)
278
+ );
279
+ }
280
+ } else {
281
+ loadErrors.push(
282
+ new Error(
283
+ `Unsupported OS: ${process.platform}, architecture: ${process.arch}`
284
+ )
285
+ );
286
+ }
287
+ }
288
+
289
+ nativeBinding = requireNative();
290
+
291
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
292
+ let wasiBinding = null;
293
+ let wasiBindingError = null;
294
+ try {
295
+ wasiBinding = require("./hive_router_query_planner.wasi.cjs");
296
+ nativeBinding = wasiBinding;
297
+ } catch (err) {
298
+ if (process.env.NAPI_RS_FORCE_WASI) {
299
+ wasiBindingError = err;
300
+ }
301
+ }
302
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
303
+ const error = new Error(
304
+ "WASI binding not found and NAPI_RS_FORCE_WASI is set to error"
305
+ );
306
+ error.cause = wasiBindingError;
307
+ throw error;
308
+ }
309
+ }
310
+
311
+ if (!nativeBinding) {
312
+ if (loadErrors.length > 0) {
313
+ throw new Error(
314
+ `Cannot find native binding. ` +
315
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
316
+ "Please try `npm i` again after removing both package-lock.json and node_modules directory.",
317
+ {
318
+ cause: loadErrors.reduce((err, cur) => {
319
+ cur.cause = err;
320
+ return cur;
321
+ }),
322
+ }
323
+ );
324
+ }
325
+ throw new Error(`Failed to load native binding`);
326
+ }
327
+
328
+ module.exports = nativeBinding;
329
+ module.exports.QueryPlanner = nativeBinding.QueryPlanner;
package/index.js CHANGED
@@ -4,286 +4,308 @@
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
6
  import { createRequire } from 'node:module'
7
- const require = createRequire(import.meta.url)
8
- const __dirname = new URL('.', import.meta.url).pathname
7
+ const require = createRequire(import.meta.url);
8
+ const __dirname = new URL(".", import.meta.url).pathname;
9
9
 
10
- const { readFileSync } = require('node:fs')
11
- let nativeBinding = null
12
- const loadErrors = []
10
+ const { readFileSync } = require("node:fs");
11
+ let nativeBinding = null;
12
+ const loadErrors = [];
13
13
 
14
14
  const isMusl = () => {
15
- let musl = false
16
- if (process.platform === 'linux') {
17
- musl = isMuslFromFilesystem()
15
+ let musl = false;
16
+ if (process.platform === "linux") {
17
+ musl = isMuslFromFilesystem();
18
18
  if (musl === null) {
19
- musl = isMuslFromReport()
19
+ musl = isMuslFromReport();
20
20
  }
21
21
  if (musl === null) {
22
- musl = isMuslFromChildProcess()
22
+ musl = isMuslFromChildProcess();
23
23
  }
24
24
  }
25
- return musl
26
- }
25
+ return musl;
26
+ };
27
27
 
28
- const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
28
+ const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
29
29
 
30
30
  const isMuslFromFilesystem = () => {
31
31
  try {
32
- return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
32
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
33
33
  } catch {
34
- return null
34
+ return null;
35
35
  }
36
- }
36
+ };
37
37
 
38
38
  const isMuslFromReport = () => {
39
- let report = null
40
- if (typeof process.report?.getReport === 'function') {
41
- process.report.excludeNetwork = true
42
- report = process.report.getReport()
39
+ let report = null;
40
+ if (typeof process.report?.getReport === "function") {
41
+ process.report.excludeNetwork = true;
42
+ report = process.report.getReport();
43
43
  }
44
44
  if (!report) {
45
- return null
45
+ return null;
46
46
  }
47
47
  if (report.header && report.header.glibcVersionRuntime) {
48
- return false
48
+ return false;
49
49
  }
50
50
  if (Array.isArray(report.sharedObjects)) {
51
51
  if (report.sharedObjects.some(isFileMusl)) {
52
- return true
52
+ return true;
53
53
  }
54
54
  }
55
- return false
56
- }
55
+ return false;
56
+ };
57
57
 
58
58
  const isMuslFromChildProcess = () => {
59
59
  try {
60
- return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
60
+ return require("child_process")
61
+ .execSync("ldd --version", { encoding: "utf8" })
62
+ .includes("musl");
61
63
  } catch (e) {
62
64
  // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
63
- return false
65
+ return false;
64
66
  }
65
- }
67
+ };
66
68
 
67
69
  function requireNative() {
68
70
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
69
71
  try {
70
72
  return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
71
73
  } catch (err) {
72
- loadErrors.push(err)
74
+ loadErrors.push(err);
73
75
  }
74
- } else if (process.platform === 'android') {
75
- if (process.arch === 'arm64') {
76
+ } else if (process.platform === "android") {
77
+ if (process.arch === "arm64") {
76
78
  try {
77
- return require('./hive_router_query_planner.android-arm64.node')
79
+ return require("./hive_router_query_planner.android-arm64.node");
78
80
  } catch (e) {
79
- loadErrors.push(e)
81
+ loadErrors.push(e);
80
82
  }
81
- } else if (process.arch === 'arm') {
83
+ } else if (process.arch === "arm") {
82
84
  try {
83
- return require('./hive_router_query_planner.android-arm-eabi.node')
85
+ return require("./hive_router_query_planner.android-arm-eabi.node");
84
86
  } catch (e) {
85
- loadErrors.push(e)
87
+ loadErrors.push(e);
86
88
  }
87
89
  } else {
88
- loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
90
+ loadErrors.push(
91
+ new Error(`Unsupported architecture on Android ${process.arch}`)
92
+ );
89
93
  }
90
- } else if (process.platform === 'win32') {
91
- if (process.arch === 'x64') {
92
- if (process.report?.getReport?.()?.header?.osName?.startsWith?.('MINGW')) {
94
+ } else if (process.platform === "win32") {
95
+ if (process.arch === "x64") {
96
+ if (
97
+ process.report?.getReport?.()?.header?.osName?.startsWith?.("MINGW")
98
+ ) {
93
99
  try {
94
- return require('./hive_router_query_planner.win32-x64-gnu.node')
95
- } catch (e) {
96
- loadErrors.push(e)
97
- }
100
+ return require("./hive_router_query_planner.win32-x64-gnu.node");
101
+ } catch (e) {
102
+ loadErrors.push(e);
103
+ }
98
104
  } else {
99
105
  try {
100
- return require('./hive_router_query_planner.win32-x64-msvc.node')
101
- } catch (e) {
102
- loadErrors.push(e)
103
- }
106
+ return require("./hive_router_query_planner.win32-x64-msvc.node");
107
+ } catch (e) {
108
+ loadErrors.push(e);
109
+ }
104
110
  }
105
- } else if (process.arch === 'ia32') {
111
+ } else if (process.arch === "ia32") {
106
112
  try {
107
- return require('./hive_router_query_planner.win32-ia32-msvc.node')
113
+ return require("./hive_router_query_planner.win32-ia32-msvc.node");
108
114
  } catch (e) {
109
- loadErrors.push(e)
115
+ loadErrors.push(e);
110
116
  }
111
- } else if (process.arch === 'arm64') {
117
+ } else if (process.arch === "arm64") {
112
118
  try {
113
- return require('./hive_router_query_planner.win32-arm64-msvc.node')
119
+ return require("./hive_router_query_planner.win32-arm64-msvc.node");
114
120
  } catch (e) {
115
- loadErrors.push(e)
121
+ loadErrors.push(e);
116
122
  }
117
123
  } else {
118
- loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
124
+ loadErrors.push(
125
+ new Error(`Unsupported architecture on Windows: ${process.arch}`)
126
+ );
119
127
  }
120
- } else if (process.platform === 'darwin') {
128
+ } else if (process.platform === "darwin") {
121
129
  try {
122
- return require('./hive_router_query_planner.darwin-universal.node')
130
+ return require("./hive_router_query_planner.darwin-universal.node");
123
131
  } catch (e) {
124
- loadErrors.push(e)
132
+ loadErrors.push(e);
125
133
  }
126
- if (process.arch === 'x64') {
134
+ if (process.arch === "x64") {
127
135
  try {
128
- return require('./hive_router_query_planner.darwin-x64.node')
136
+ return require("./hive_router_query_planner.darwin-x64.node");
129
137
  } catch (e) {
130
- loadErrors.push(e)
138
+ loadErrors.push(e);
131
139
  }
132
- } else if (process.arch === 'arm64') {
140
+ } else if (process.arch === "arm64") {
133
141
  try {
134
- return require('./hive_router_query_planner.darwin-arm64.node')
142
+ return require("./hive_router_query_planner.darwin-arm64.node");
135
143
  } catch (e) {
136
- loadErrors.push(e)
144
+ loadErrors.push(e);
137
145
  }
138
146
  } else {
139
- loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
147
+ loadErrors.push(
148
+ new Error(`Unsupported architecture on macOS: ${process.arch}`)
149
+ );
140
150
  }
141
- } else if (process.platform === 'freebsd') {
142
- if (process.arch === 'x64') {
151
+ } else if (process.platform === "freebsd") {
152
+ if (process.arch === "x64") {
143
153
  try {
144
- return require('./hive_router_query_planner.freebsd-x64.node')
154
+ return require("./hive_router_query_planner.freebsd-x64.node");
145
155
  } catch (e) {
146
- loadErrors.push(e)
156
+ loadErrors.push(e);
147
157
  }
148
- } else if (process.arch === 'arm64') {
158
+ } else if (process.arch === "arm64") {
149
159
  try {
150
- return require('./hive_router_query_planner.freebsd-arm64.node')
160
+ return require("./hive_router_query_planner.freebsd-arm64.node");
151
161
  } catch (e) {
152
- loadErrors.push(e)
162
+ loadErrors.push(e);
153
163
  }
154
164
  } else {
155
- loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
165
+ loadErrors.push(
166
+ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)
167
+ );
156
168
  }
157
- } else if (process.platform === 'linux') {
158
- if (process.arch === 'x64') {
169
+ } else if (process.platform === "linux") {
170
+ if (process.arch === "x64") {
159
171
  if (isMusl()) {
160
172
  try {
161
- return require('./hive_router_query_planner.linux-x64-musl.node')
173
+ return require("./hive_router_query_planner.linux-x64-musl.node");
162
174
  } catch (e) {
163
- loadErrors.push(e)
175
+ loadErrors.push(e);
164
176
  }
165
177
  } else {
166
178
  try {
167
- return require('./hive_router_query_planner.linux-x64-gnu.node')
179
+ return require("./hive_router_query_planner.linux-x64-gnu.node");
168
180
  } catch (e) {
169
- loadErrors.push(e)
181
+ loadErrors.push(e);
170
182
  }
171
183
  }
172
- } else if (process.arch === 'arm64') {
184
+ } else if (process.arch === "arm64") {
173
185
  if (isMusl()) {
174
186
  try {
175
- return require('./hive_router_query_planner.linux-arm64-musl.node')
187
+ return require("./hive_router_query_planner.linux-arm64-musl.node");
176
188
  } catch (e) {
177
- loadErrors.push(e)
189
+ loadErrors.push(e);
178
190
  }
179
191
  } else {
180
192
  try {
181
- return require('./hive_router_query_planner.linux-arm64-gnu.node')
193
+ return require("./hive_router_query_planner.linux-arm64-gnu.node");
182
194
  } catch (e) {
183
- loadErrors.push(e)
195
+ loadErrors.push(e);
184
196
  }
185
197
  }
186
- } else if (process.arch === 'arm') {
198
+ } else if (process.arch === "arm") {
187
199
  if (isMusl()) {
188
200
  try {
189
- return require('./hive_router_query_planner.linux-arm-musleabihf.node')
201
+ return require("./hive_router_query_planner.linux-arm-musleabihf.node");
190
202
  } catch (e) {
191
- loadErrors.push(e)
203
+ loadErrors.push(e);
192
204
  }
193
205
  } else {
194
206
  try {
195
- return require('./hive_router_query_planner.linux-arm-gnueabihf.node')
207
+ return require("./hive_router_query_planner.linux-arm-gnueabihf.node");
196
208
  } catch (e) {
197
- loadErrors.push(e)
209
+ loadErrors.push(e);
198
210
  }
199
211
  }
200
- } else if (process.arch === 'loong64') {
212
+ } else if (process.arch === "loong64") {
201
213
  if (isMusl()) {
202
214
  try {
203
- return require('./hive_router_query_planner.linux-loong64-musl.node')
215
+ return require("./hive_router_query_planner.linux-loong64-musl.node");
204
216
  } catch (e) {
205
- loadErrors.push(e)
217
+ loadErrors.push(e);
206
218
  }
207
219
  } else {
208
220
  try {
209
- return require('./hive_router_query_planner.linux-loong64-gnu.node')
221
+ return require("./hive_router_query_planner.linux-loong64-gnu.node");
210
222
  } catch (e) {
211
- loadErrors.push(e)
223
+ loadErrors.push(e);
212
224
  }
213
225
  }
214
- } else if (process.arch === 'riscv64') {
226
+ } else if (process.arch === "riscv64") {
215
227
  if (isMusl()) {
216
228
  try {
217
- return require('./hive_router_query_planner.linux-riscv64-musl.node')
229
+ return require("./hive_router_query_planner.linux-riscv64-musl.node");
218
230
  } catch (e) {
219
- loadErrors.push(e)
231
+ loadErrors.push(e);
220
232
  }
221
233
  } else {
222
234
  try {
223
- return require('./hive_router_query_planner.linux-riscv64-gnu.node')
235
+ return require("./hive_router_query_planner.linux-riscv64-gnu.node");
224
236
  } catch (e) {
225
- loadErrors.push(e)
237
+ loadErrors.push(e);
226
238
  }
227
239
  }
228
- } else if (process.arch === 'ppc64') {
240
+ } else if (process.arch === "ppc64") {
229
241
  try {
230
- return require('./hive_router_query_planner.linux-ppc64-gnu.node')
242
+ return require("./hive_router_query_planner.linux-ppc64-gnu.node");
231
243
  } catch (e) {
232
- loadErrors.push(e)
244
+ loadErrors.push(e);
233
245
  }
234
- } else if (process.arch === 's390x') {
246
+ } else if (process.arch === "s390x") {
235
247
  try {
236
- return require('./hive_router_query_planner.linux-s390x-gnu.node')
248
+ return require("./hive_router_query_planner.linux-s390x-gnu.node");
237
249
  } catch (e) {
238
- loadErrors.push(e)
250
+ loadErrors.push(e);
239
251
  }
240
252
  } else {
241
- loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
253
+ loadErrors.push(
254
+ new Error(`Unsupported architecture on Linux: ${process.arch}`)
255
+ );
242
256
  }
243
- } else if (process.platform === 'openharmony') {
244
- if (process.arch === 'arm64') {
257
+ } else if (process.platform === "openharmony") {
258
+ if (process.arch === "arm64") {
245
259
  try {
246
- return require('./hive_router_query_planner.openharmony-arm64.node')
260
+ return require("./hive_router_query_planner.openharmony-arm64.node");
247
261
  } catch (e) {
248
- loadErrors.push(e)
262
+ loadErrors.push(e);
249
263
  }
250
- } else if (process.arch === 'x64') {
264
+ } else if (process.arch === "x64") {
251
265
  try {
252
- return require('./hive_router_query_planner.openharmony-x64.node')
266
+ return require("./hive_router_query_planner.openharmony-x64.node");
253
267
  } catch (e) {
254
- loadErrors.push(e)
268
+ loadErrors.push(e);
255
269
  }
256
- } else if (process.arch === 'arm') {
270
+ } else if (process.arch === "arm") {
257
271
  try {
258
- return require('./hive_router_query_planner.openharmony-arm.node')
272
+ return require("./hive_router_query_planner.openharmony-arm.node");
259
273
  } catch (e) {
260
- loadErrors.push(e)
274
+ loadErrors.push(e);
261
275
  }
262
276
  } else {
263
- loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
277
+ loadErrors.push(
278
+ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)
279
+ );
264
280
  }
265
281
  } else {
266
- loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
282
+ loadErrors.push(
283
+ new Error(
284
+ `Unsupported OS: ${process.platform}, architecture: ${process.arch}`
285
+ )
286
+ );
267
287
  }
268
288
  }
269
289
 
270
- nativeBinding = requireNative()
290
+ nativeBinding = requireNative();
271
291
 
272
292
  if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
273
- let wasiBinding = null
274
- let wasiBindingError = null
293
+ let wasiBinding = null;
294
+ let wasiBindingError = null;
275
295
  try {
276
- wasiBinding = require('./hive_router_query_planner.wasi.cjs')
277
- nativeBinding = wasiBinding
296
+ wasiBinding = require("./hive_router_query_planner.wasi.cjs");
297
+ nativeBinding = wasiBinding;
278
298
  } catch (err) {
279
299
  if (process.env.NAPI_RS_FORCE_WASI) {
280
- wasiBindingError = err
300
+ wasiBindingError = err;
281
301
  }
282
302
  }
283
- if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
284
- const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
285
- error.cause = wasiBindingError
286
- throw error
303
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
304
+ const error = new Error(
305
+ "WASI binding not found and NAPI_RS_FORCE_WASI is set to error"
306
+ );
307
+ error.cause = wasiBindingError;
308
+ throw error;
287
309
  }
288
310
  }
289
311
 
@@ -292,17 +314,17 @@ if (!nativeBinding) {
292
314
  throw new Error(
293
315
  `Cannot find native binding. ` +
294
316
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
295
- 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
317
+ "Please try `npm i` again after removing both package-lock.json and node_modules directory.",
296
318
  {
297
319
  cause: loadErrors.reduce((err, cur) => {
298
- cur.cause = err
299
- return cur
320
+ cur.cause = err;
321
+ return cur;
300
322
  }),
301
- },
302
- )
323
+ }
324
+ );
303
325
  }
304
- throw new Error(`Failed to load native binding`)
326
+ throw new Error(`Failed to load native binding`);
305
327
  }
306
328
 
307
- const { QueryPlanner } = nativeBinding
308
- export { QueryPlanner }
329
+ const { QueryPlanner } = nativeBinding;
330
+ export { QueryPlanner };
package/package.json CHANGED
@@ -1,15 +1,24 @@
1
1
  {
2
2
  "name": "@graphql-hive/router-query-planner",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "files": [
8
8
  "README.md",
9
9
  "index.js",
10
+ "index.cjs",
10
11
  "index.d.ts",
11
12
  "*.node"
12
13
  ],
14
+ "exports": {
15
+ ".": {
16
+ "import": "./index.js",
17
+ "require": "./index.cjs",
18
+ "types": "./index.d.ts"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
13
22
  "repository": {
14
23
  "type": "git",
15
24
  "url": "git+https://github.com/graphql-hive/router.git",