@bodhiapp/app-bindings 0.0.6 → 0.0.8

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 (3) hide show
  1. package/index.d.ts +50 -73
  2. package/index.js +308 -366
  3. package/package.json +23 -15
package/index.d.ts CHANGED
@@ -1,5 +1,54 @@
1
- /* auto-generated by NAPI-RS */
1
+ /* tslint:disable */
2
2
  /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ /** Flexible configuration options for the Bodhi server that can be passed across NAPI boundary */
7
+ export interface NapiAppOptions {
8
+ /** Environment variables to set */
9
+ envVars: Record<string, string>
10
+ /** App settings (configurable via settings.yaml) */
11
+ appSettings: Record<string, string>
12
+ /** System settings (immutable) */
13
+ systemSettings: Record<string, string>
14
+ /** OAuth client ID (optional) */
15
+ clientId?: string
16
+ /** OAuth client secret (optional) */
17
+ clientSecret?: string
18
+ /** App status as string (optional) */
19
+ appStatus?: string
20
+ }
21
+ /** Create a new NapiAppOptions with empty configuration */
22
+ export declare function createNapiAppOptions(): NapiAppOptions
23
+ /** Set an environment variable */
24
+ export declare function setEnvVar(config: NapiAppOptions, key: string, value: string): NapiAppOptions
25
+ /** Set an app setting (configurable via settings.yaml) */
26
+ export declare function setAppSetting(config: NapiAppOptions, key: string, value: string): NapiAppOptions
27
+ /** Set a system setting (immutable) */
28
+ export declare function setSystemSetting(config: NapiAppOptions, key: string, value: string): NapiAppOptions
29
+ /** Set OAuth client credentials */
30
+ export declare function setClientCredentials(config: NapiAppOptions, clientId: string, clientSecret: string): NapiAppOptions
31
+ /** Set app status */
32
+ export declare function setAppStatus(config: NapiAppOptions, status: string): NapiAppOptions
33
+ export const BODHI_HOME: string
34
+ export const BODHI_HOST: string
35
+ export const BODHI_PORT: string
36
+ export const BODHI_SCHEME: string
37
+ export const BODHI_LOG_LEVEL: string
38
+ export const BODHI_LOG_STDOUT: string
39
+ export const BODHI_LOGS: string
40
+ export const BODHI_ENV_TYPE: string
41
+ export const BODHI_APP_TYPE: string
42
+ export const BODHI_VERSION: string
43
+ export const BODHI_AUTH_URL: string
44
+ export const BODHI_AUTH_REALM: string
45
+ export const BODHI_ENCRYPTION_KEY: string
46
+ export const BODHI_EXEC_LOOKUP_PATH: string
47
+ export const BODHI_EXEC_VARIANT: string
48
+ export const BODHI_KEEP_ALIVE_SECS: string
49
+ export const HF_HOME: string
50
+ export const DEFAULT_HOST: string
51
+ export const DEFAULT_PORT: number
3
52
  /** The main Bodhi server wrapper for NAPI */
4
53
  export declare class BodhiServer {
5
54
  /** Create a new Bodhi server instance with the given configuration */
@@ -21,75 +70,3 @@ export declare class BodhiServer {
21
70
  /** Get server ping status */
22
71
  ping(): Promise<boolean>
23
72
  }
24
-
25
- export const BODHI_APP_TYPE: string
26
-
27
- export const BODHI_AUTH_REALM: string
28
-
29
- export const BODHI_AUTH_URL: string
30
-
31
- export const BODHI_ENCRYPTION_KEY: string
32
-
33
- export const BODHI_ENV_TYPE: string
34
-
35
- export const BODHI_EXEC_LOOKUP_PATH: string
36
-
37
- export const BODHI_EXEC_VARIANT: string
38
-
39
- export const BODHI_HOME: string
40
-
41
- export const BODHI_HOST: string
42
-
43
- export const BODHI_KEEP_ALIVE_SECS: string
44
-
45
- export const BODHI_LOG_LEVEL: string
46
-
47
- export const BODHI_LOG_STDOUT: string
48
-
49
- export const BODHI_LOGS: string
50
-
51
- export const BODHI_PORT: string
52
-
53
- export const BODHI_SCHEME: string
54
-
55
- export const BODHI_VERSION: string
56
-
57
- /** Create a new NapiAppOptions with empty configuration */
58
- export declare export declare function createNapiAppOptions(): NapiAppOptions
59
-
60
- export const DEFAULT_HOST: string
61
-
62
- export const DEFAULT_PORT: number
63
-
64
- export const HF_HOME: string
65
-
66
- /** Flexible configuration options for the Bodhi server that can be passed across NAPI boundary */
67
- export interface NapiAppOptions {
68
- /** Environment variables to set */
69
- envVars: Record<string, string>
70
- /** App settings (configurable via settings.yaml) */
71
- appSettings: Record<string, string>
72
- /** System settings (immutable) */
73
- systemSettings: Record<string, string>
74
- /** OAuth client ID (optional) */
75
- clientId?: string
76
- /** OAuth client secret (optional) */
77
- clientSecret?: string
78
- /** App status as string (optional) */
79
- appStatus?: string
80
- }
81
-
82
- /** Set an app setting (configurable via settings.yaml) */
83
- export declare export declare function setAppSetting(config: NapiAppOptions, key: string, value: string): NapiAppOptions
84
-
85
- /** Set app status */
86
- export declare export declare function setAppStatus(config: NapiAppOptions, status: string): NapiAppOptions
87
-
88
- /** Set OAuth client credentials */
89
- export declare export declare function setClientCredentials(config: NapiAppOptions, clientId: string, clientSecret: string): NapiAppOptions
90
-
91
- /** Set an environment variable */
92
- export declare export declare function setEnvVar(config: NapiAppOptions, key: string, value: string): NapiAppOptions
93
-
94
- /** Set a system setting (immutable) */
95
- export declare export declare function setSystemSetting(config: NapiAppOptions, key: string, value: string): NapiAppOptions
package/index.js CHANGED
@@ -1,398 +1,340 @@
1
- // prettier-ignore
1
+ /* tslint:disable */
2
2
  /* eslint-disable */
3
- // @ts-nocheck
4
- /* auto-generated by NAPI-RS */
5
-
6
- const { createRequire } = require('node:module')
7
- require = createRequire(__filename)
3
+ /* prettier-ignore */
8
4
 
9
- const { readFileSync } = require('node:fs')
10
- let nativeBinding = null
11
- const loadErrors = []
5
+ /* auto-generated by NAPI-RS */
12
6
 
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
- }
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join } = require('path')
26
9
 
27
- const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
10
+ const { platform, arch } = process
28
11
 
29
- const isMuslFromFilesystem = () => {
30
- try {
31
- return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
32
- } catch {
33
- return null
34
- }
35
- }
12
+ let nativeBinding = null
13
+ let localFileExisted = false
14
+ let loadError = null
36
15
 
37
- const isMuslFromReport = () => {
38
- const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
39
- if (!report) {
40
- return null
41
- }
42
- if (report.header && report.header.glibcVersionRuntime) {
43
- return false
44
- }
45
- if (Array.isArray(report.sharedObjects)) {
46
- if (report.sharedObjects.some(isFileMusl)) {
16
+ function isMusl() {
17
+ // For Node 10
18
+ if (!process.report || typeof process.report.getReport !== 'function') {
19
+ try {
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
+ return readFileSync(lddPath, 'utf8').includes('musl')
22
+ } catch (e) {
47
23
  return true
48
24
  }
49
- }
50
- return false
51
- }
52
-
53
- const isMuslFromChildProcess = () => {
54
- try {
55
- return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
56
- } catch (e) {
57
- // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
58
- return false
25
+ } else {
26
+ const { glibcVersionRuntime } = process.report.getReport().header
27
+ return !glibcVersionRuntime
59
28
  }
60
29
  }
61
30
 
62
- function requireNative() {
63
- if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
64
- try {
65
- nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
66
- } catch (err) {
67
- loadErrors.push(err);
68
- }
69
- } else if (process.platform === 'android') {
70
- if (process.arch === 'arm64') {
71
- try {
72
- return require('./app-bindings.android-arm64.node')
73
- } catch (e) {
74
- loadErrors.push(e)
75
- }
76
- try {
77
- return require('@bodhiapp/app-bindings-android-arm64')
78
- } catch (e) {
79
- loadErrors.push(e)
80
- }
81
-
82
- } else if (process.arch === 'arm') {
83
- try {
84
- return require('./app-bindings.android-arm-eabi.node')
85
- } catch (e) {
86
- loadErrors.push(e)
87
- }
88
- try {
89
- return require('@bodhiapp/app-bindings-android-arm-eabi')
90
- } catch (e) {
91
- loadErrors.push(e)
92
- }
93
-
94
- } else {
95
- loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
96
- }
97
- } else if (process.platform === 'win32') {
98
- if (process.arch === 'x64') {
99
- try {
100
- return require('./app-bindings.win32-x64-msvc.node')
101
- } catch (e) {
102
- loadErrors.push(e)
103
- }
104
- try {
105
- return require('@bodhiapp/app-bindings-win32-x64-msvc')
106
- } catch (e) {
107
- loadErrors.push(e)
108
- }
109
-
110
- } else if (process.arch === 'ia32') {
111
- try {
112
- return require('./app-bindings.win32-ia32-msvc.node')
113
- } catch (e) {
114
- loadErrors.push(e)
115
- }
116
- try {
117
- return require('@bodhiapp/app-bindings-win32-ia32-msvc')
118
- } catch (e) {
119
- loadErrors.push(e)
120
- }
121
-
122
- } else if (process.arch === 'arm64') {
123
- try {
124
- return require('./app-bindings.win32-arm64-msvc.node')
125
- } catch (e) {
126
- loadErrors.push(e)
127
- }
128
- try {
129
- return require('@bodhiapp/app-bindings-win32-arm64-msvc')
130
- } catch (e) {
131
- loadErrors.push(e)
132
- }
133
-
134
- } else {
135
- loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
136
- }
137
- } else if (process.platform === 'darwin') {
138
- try {
139
- return require('./app-bindings.darwin-universal.node')
140
- } catch (e) {
141
- loadErrors.push(e)
142
- }
143
- try {
144
- return require('@bodhiapp/app-bindings-darwin-universal')
145
- } catch (e) {
146
- loadErrors.push(e)
147
- }
148
-
149
- if (process.arch === 'x64') {
150
- try {
151
- return require('./app-bindings.darwin-x64.node')
152
- } catch (e) {
153
- loadErrors.push(e)
154
- }
155
- try {
156
- return require('@bodhiapp/app-bindings-darwin-x64')
157
- } catch (e) {
158
- loadErrors.push(e)
159
- }
160
-
161
- } else if (process.arch === 'arm64') {
162
- try {
163
- return require('./app-bindings.darwin-arm64.node')
164
- } catch (e) {
165
- loadErrors.push(e)
166
- }
167
- try {
168
- return require('@bodhiapp/app-bindings-darwin-arm64')
169
- } catch (e) {
170
- loadErrors.push(e)
171
- }
172
-
173
- } else {
174
- loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
175
- }
176
- } else if (process.platform === 'freebsd') {
177
- if (process.arch === 'x64') {
178
- try {
179
- return require('./app-bindings.freebsd-x64.node')
180
- } catch (e) {
181
- loadErrors.push(e)
182
- }
183
- try {
184
- return require('@bodhiapp/app-bindings-freebsd-x64')
185
- } catch (e) {
186
- loadErrors.push(e)
187
- }
188
-
189
- } else if (process.arch === 'arm64') {
190
- try {
191
- return require('./app-bindings.freebsd-arm64.node')
192
- } catch (e) {
193
- loadErrors.push(e)
194
- }
195
- try {
196
- return require('@bodhiapp/app-bindings-freebsd-arm64')
197
- } catch (e) {
198
- loadErrors.push(e)
199
- }
200
-
201
- } else {
202
- loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
203
- }
204
- } else if (process.platform === 'linux') {
205
- if (process.arch === 'x64') {
206
- if (isMusl()) {
31
+ switch (platform) {
32
+ case 'android':
33
+ switch (arch) {
34
+ case 'arm64':
35
+ localFileExisted = existsSync(join(__dirname, 'app-bindings.android-arm64.node'))
207
36
  try {
208
- return require('./app-bindings.linux-x64-musl.node')
209
- } catch (e) {
210
- loadErrors.push(e)
211
- }
212
- try {
213
- return require('@bodhiapp/app-bindings-linux-x64-musl')
214
- } catch (e) {
215
- loadErrors.push(e)
216
- }
217
-
218
- } else {
37
+ if (localFileExisted) {
38
+ nativeBinding = require('./app-bindings.android-arm64.node')
39
+ } else {
40
+ nativeBinding = require('@bodhiapp/app-bindings-android-arm64')
41
+ }
42
+ } catch (e) {
43
+ loadError = e
44
+ }
45
+ break
46
+ case 'arm':
47
+ localFileExisted = existsSync(join(__dirname, 'app-bindings.android-arm-eabi.node'))
219
48
  try {
220
- return require('./app-bindings.linux-x64-gnu.node')
221
- } catch (e) {
222
- loadErrors.push(e)
223
- }
224
- try {
225
- return require('@bodhiapp/app-bindings-linux-x64-gnu')
226
- } catch (e) {
227
- loadErrors.push(e)
228
- }
229
-
230
- }
231
- } else if (process.arch === 'arm64') {
232
- if (isMusl()) {
49
+ if (localFileExisted) {
50
+ nativeBinding = require('./app-bindings.android-arm-eabi.node')
51
+ } else {
52
+ nativeBinding = require('@bodhiapp/app-bindings-android-arm-eabi')
53
+ }
54
+ } catch (e) {
55
+ loadError = e
56
+ }
57
+ break
58
+ default:
59
+ throw new Error(`Unsupported architecture on Android ${arch}`)
60
+ }
61
+ break
62
+ case 'win32':
63
+ switch (arch) {
64
+ case 'x64':
65
+ localFileExisted = existsSync(
66
+ join(__dirname, 'app-bindings.win32-x64-msvc.node')
67
+ )
233
68
  try {
234
- return require('./app-bindings.linux-arm64-musl.node')
235
- } catch (e) {
236
- loadErrors.push(e)
237
- }
238
- try {
239
- return require('@bodhiapp/app-bindings-linux-arm64-musl')
240
- } catch (e) {
241
- loadErrors.push(e)
242
- }
243
-
244
- } else {
69
+ if (localFileExisted) {
70
+ nativeBinding = require('./app-bindings.win32-x64-msvc.node')
71
+ } else {
72
+ nativeBinding = require('@bodhiapp/app-bindings-win32-x64-msvc')
73
+ }
74
+ } catch (e) {
75
+ loadError = e
76
+ }
77
+ break
78
+ case 'ia32':
79
+ localFileExisted = existsSync(
80
+ join(__dirname, 'app-bindings.win32-ia32-msvc.node')
81
+ )
245
82
  try {
246
- return require('./app-bindings.linux-arm64-gnu.node')
247
- } catch (e) {
248
- loadErrors.push(e)
249
- }
250
- try {
251
- return require('@bodhiapp/app-bindings-linux-arm64-gnu')
252
- } catch (e) {
253
- loadErrors.push(e)
254
- }
255
-
256
- }
257
- } else if (process.arch === 'arm') {
258
- if (isMusl()) {
83
+ if (localFileExisted) {
84
+ nativeBinding = require('./app-bindings.win32-ia32-msvc.node')
85
+ } else {
86
+ nativeBinding = require('@bodhiapp/app-bindings-win32-ia32-msvc')
87
+ }
88
+ } catch (e) {
89
+ loadError = e
90
+ }
91
+ break
92
+ case 'arm64':
93
+ localFileExisted = existsSync(
94
+ join(__dirname, 'app-bindings.win32-arm64-msvc.node')
95
+ )
259
96
  try {
260
- return require('./app-bindings.linux-arm-musleabihf.node')
261
- } catch (e) {
262
- loadErrors.push(e)
263
- }
264
- try {
265
- return require('@bodhiapp/app-bindings-linux-arm-musleabihf')
266
- } catch (e) {
267
- loadErrors.push(e)
268
- }
269
-
97
+ if (localFileExisted) {
98
+ nativeBinding = require('./app-bindings.win32-arm64-msvc.node')
99
+ } else {
100
+ nativeBinding = require('@bodhiapp/app-bindings-win32-arm64-msvc')
101
+ }
102
+ } catch (e) {
103
+ loadError = e
104
+ }
105
+ break
106
+ default:
107
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
+ }
109
+ break
110
+ case 'darwin':
111
+ localFileExisted = existsSync(join(__dirname, 'app-bindings.darwin-universal.node'))
112
+ try {
113
+ if (localFileExisted) {
114
+ nativeBinding = require('./app-bindings.darwin-universal.node')
270
115
  } else {
271
- try {
272
- return require('./app-bindings.linux-arm-gnueabihf.node')
273
- } catch (e) {
274
- loadErrors.push(e)
275
- }
276
- try {
277
- return require('@bodhiapp/app-bindings-linux-arm-gnueabihf')
278
- } catch (e) {
279
- loadErrors.push(e)
116
+ nativeBinding = require('@bodhiapp/app-bindings-darwin-universal')
280
117
  }
281
-
282
- }
283
- } else if (process.arch === 'riscv64') {
284
- if (isMusl()) {
118
+ break
119
+ } catch {}
120
+ switch (arch) {
121
+ case 'x64':
122
+ localFileExisted = existsSync(join(__dirname, 'app-bindings.darwin-x64.node'))
285
123
  try {
286
- return require('./app-bindings.linux-riscv64-musl.node')
287
- } catch (e) {
288
- loadErrors.push(e)
289
- }
290
- try {
291
- return require('@bodhiapp/app-bindings-linux-riscv64-musl')
292
- } catch (e) {
293
- loadErrors.push(e)
294
- }
295
-
296
- } else {
124
+ if (localFileExisted) {
125
+ nativeBinding = require('./app-bindings.darwin-x64.node')
126
+ } else {
127
+ nativeBinding = require('@bodhiapp/app-bindings-darwin-x64')
128
+ }
129
+ } catch (e) {
130
+ loadError = e
131
+ }
132
+ break
133
+ case 'arm64':
134
+ localFileExisted = existsSync(
135
+ join(__dirname, 'app-bindings.darwin-arm64.node')
136
+ )
297
137
  try {
298
- return require('./app-bindings.linux-riscv64-gnu.node')
299
- } catch (e) {
300
- loadErrors.push(e)
301
- }
302
- try {
303
- return require('@bodhiapp/app-bindings-linux-riscv64-gnu')
304
- } catch (e) {
305
- loadErrors.push(e)
306
- }
307
-
308
- }
309
- } else if (process.arch === 'ppc64') {
310
- try {
311
- return require('./app-bindings.linux-ppc64-gnu.node')
312
- } catch (e) {
313
- loadErrors.push(e)
314
- }
315
- try {
316
- return require('@bodhiapp/app-bindings-linux-ppc64-gnu')
317
- } catch (e) {
318
- loadErrors.push(e)
319
- }
320
-
321
- } else if (process.arch === 's390x') {
322
- try {
323
- return require('./app-bindings.linux-s390x-gnu.node')
324
- } catch (e) {
325
- loadErrors.push(e)
326
- }
327
- try {
328
- return require('@bodhiapp/app-bindings-linux-s390x-gnu')
329
- } catch (e) {
330
- loadErrors.push(e)
331
- }
332
-
333
- } else {
334
- loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
138
+ if (localFileExisted) {
139
+ nativeBinding = require('./app-bindings.darwin-arm64.node')
140
+ } else {
141
+ nativeBinding = require('@bodhiapp/app-bindings-darwin-arm64')
142
+ }
143
+ } catch (e) {
144
+ loadError = e
145
+ }
146
+ break
147
+ default:
148
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
335
149
  }
336
- } else {
337
- loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
338
- }
339
- }
340
-
341
- nativeBinding = requireNative()
342
-
343
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
344
- try {
345
- nativeBinding = require('./app-bindings.wasi.cjs')
346
- } catch (err) {
347
- if (process.env.NAPI_RS_FORCE_WASI) {
348
- loadErrors.push(err)
150
+ break
151
+ case 'freebsd':
152
+ if (arch !== 'x64') {
153
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
349
154
  }
350
- }
351
- if (!nativeBinding) {
155
+ localFileExisted = existsSync(join(__dirname, 'app-bindings.freebsd-x64.node'))
352
156
  try {
353
- nativeBinding = require('@bodhiapp/app-bindings-wasm32-wasi')
354
- } catch (err) {
355
- if (process.env.NAPI_RS_FORCE_WASI) {
356
- loadErrors.push(err)
157
+ if (localFileExisted) {
158
+ nativeBinding = require('./app-bindings.freebsd-x64.node')
159
+ } else {
160
+ nativeBinding = require('@bodhiapp/app-bindings-freebsd-x64')
357
161
  }
162
+ } catch (e) {
163
+ loadError = e
358
164
  }
359
- }
165
+ break
166
+ case 'linux':
167
+ switch (arch) {
168
+ case 'x64':
169
+ if (isMusl()) {
170
+ localFileExisted = existsSync(
171
+ join(__dirname, 'app-bindings.linux-x64-musl.node')
172
+ )
173
+ try {
174
+ if (localFileExisted) {
175
+ nativeBinding = require('./app-bindings.linux-x64-musl.node')
176
+ } else {
177
+ nativeBinding = require('@bodhiapp/app-bindings-linux-x64-musl')
178
+ }
179
+ } catch (e) {
180
+ loadError = e
181
+ }
182
+ } else {
183
+ localFileExisted = existsSync(
184
+ join(__dirname, 'app-bindings.linux-x64-gnu.node')
185
+ )
186
+ try {
187
+ if (localFileExisted) {
188
+ nativeBinding = require('./app-bindings.linux-x64-gnu.node')
189
+ } else {
190
+ nativeBinding = require('@bodhiapp/app-bindings-linux-x64-gnu')
191
+ }
192
+ } catch (e) {
193
+ loadError = e
194
+ }
195
+ }
196
+ break
197
+ case 'arm64':
198
+ if (isMusl()) {
199
+ localFileExisted = existsSync(
200
+ join(__dirname, 'app-bindings.linux-arm64-musl.node')
201
+ )
202
+ try {
203
+ if (localFileExisted) {
204
+ nativeBinding = require('./app-bindings.linux-arm64-musl.node')
205
+ } else {
206
+ nativeBinding = require('@bodhiapp/app-bindings-linux-arm64-musl')
207
+ }
208
+ } catch (e) {
209
+ loadError = e
210
+ }
211
+ } else {
212
+ localFileExisted = existsSync(
213
+ join(__dirname, 'app-bindings.linux-arm64-gnu.node')
214
+ )
215
+ try {
216
+ if (localFileExisted) {
217
+ nativeBinding = require('./app-bindings.linux-arm64-gnu.node')
218
+ } else {
219
+ nativeBinding = require('@bodhiapp/app-bindings-linux-arm64-gnu')
220
+ }
221
+ } catch (e) {
222
+ loadError = e
223
+ }
224
+ }
225
+ break
226
+ case 'arm':
227
+ if (isMusl()) {
228
+ localFileExisted = existsSync(
229
+ join(__dirname, 'app-bindings.linux-arm-musleabihf.node')
230
+ )
231
+ try {
232
+ if (localFileExisted) {
233
+ nativeBinding = require('./app-bindings.linux-arm-musleabihf.node')
234
+ } else {
235
+ nativeBinding = require('@bodhiapp/app-bindings-linux-arm-musleabihf')
236
+ }
237
+ } catch (e) {
238
+ loadError = e
239
+ }
240
+ } else {
241
+ localFileExisted = existsSync(
242
+ join(__dirname, 'app-bindings.linux-arm-gnueabihf.node')
243
+ )
244
+ try {
245
+ if (localFileExisted) {
246
+ nativeBinding = require('./app-bindings.linux-arm-gnueabihf.node')
247
+ } else {
248
+ nativeBinding = require('@bodhiapp/app-bindings-linux-arm-gnueabihf')
249
+ }
250
+ } catch (e) {
251
+ loadError = e
252
+ }
253
+ }
254
+ break
255
+ case 'riscv64':
256
+ if (isMusl()) {
257
+ localFileExisted = existsSync(
258
+ join(__dirname, 'app-bindings.linux-riscv64-musl.node')
259
+ )
260
+ try {
261
+ if (localFileExisted) {
262
+ nativeBinding = require('./app-bindings.linux-riscv64-musl.node')
263
+ } else {
264
+ nativeBinding = require('@bodhiapp/app-bindings-linux-riscv64-musl')
265
+ }
266
+ } catch (e) {
267
+ loadError = e
268
+ }
269
+ } else {
270
+ localFileExisted = existsSync(
271
+ join(__dirname, 'app-bindings.linux-riscv64-gnu.node')
272
+ )
273
+ try {
274
+ if (localFileExisted) {
275
+ nativeBinding = require('./app-bindings.linux-riscv64-gnu.node')
276
+ } else {
277
+ nativeBinding = require('@bodhiapp/app-bindings-linux-riscv64-gnu')
278
+ }
279
+ } catch (e) {
280
+ loadError = e
281
+ }
282
+ }
283
+ break
284
+ case 's390x':
285
+ localFileExisted = existsSync(
286
+ join(__dirname, 'app-bindings.linux-s390x-gnu.node')
287
+ )
288
+ try {
289
+ if (localFileExisted) {
290
+ nativeBinding = require('./app-bindings.linux-s390x-gnu.node')
291
+ } else {
292
+ nativeBinding = require('@bodhiapp/app-bindings-linux-s390x-gnu')
293
+ }
294
+ } catch (e) {
295
+ loadError = e
296
+ }
297
+ break
298
+ default:
299
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
300
+ }
301
+ break
302
+ default:
303
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
360
304
  }
361
305
 
362
306
  if (!nativeBinding) {
363
- if (loadErrors.length > 0) {
364
- // TODO Link to documentation with potential fixes
365
- // - The package owner could build/publish bindings for this arch
366
- // - The user may need to bundle the correct files
367
- // - The user may need to re-install node_modules to get new packages
368
- throw new Error('Failed to load native binding', { cause: loadErrors })
307
+ if (loadError) {
308
+ throw loadError
369
309
  }
370
310
  throw new Error(`Failed to load native binding`)
371
311
  }
372
312
 
373
- module.exports.BodhiServer = nativeBinding.BodhiServer
374
- module.exports.BODHI_APP_TYPE = nativeBinding.BODHI_APP_TYPE
375
- module.exports.BODHI_AUTH_REALM = nativeBinding.BODHI_AUTH_REALM
376
- module.exports.BODHI_AUTH_URL = nativeBinding.BODHI_AUTH_URL
377
- module.exports.BODHI_ENCRYPTION_KEY = nativeBinding.BODHI_ENCRYPTION_KEY
378
- module.exports.BODHI_ENV_TYPE = nativeBinding.BODHI_ENV_TYPE
379
- module.exports.BODHI_EXEC_LOOKUP_PATH = nativeBinding.BODHI_EXEC_LOOKUP_PATH
380
- module.exports.BODHI_EXEC_VARIANT = nativeBinding.BODHI_EXEC_VARIANT
381
- module.exports.BODHI_HOME = nativeBinding.BODHI_HOME
382
- module.exports.BODHI_HOST = nativeBinding.BODHI_HOST
383
- module.exports.BODHI_KEEP_ALIVE_SECS = nativeBinding.BODHI_KEEP_ALIVE_SECS
384
- module.exports.BODHI_LOG_LEVEL = nativeBinding.BODHI_LOG_LEVEL
385
- module.exports.BODHI_LOG_STDOUT = nativeBinding.BODHI_LOG_STDOUT
386
- module.exports.BODHI_LOGS = nativeBinding.BODHI_LOGS
387
- module.exports.BODHI_PORT = nativeBinding.BODHI_PORT
388
- module.exports.BODHI_SCHEME = nativeBinding.BODHI_SCHEME
389
- module.exports.BODHI_VERSION = nativeBinding.BODHI_VERSION
390
- module.exports.createNapiAppOptions = nativeBinding.createNapiAppOptions
391
- module.exports.DEFAULT_HOST = nativeBinding.DEFAULT_HOST
392
- module.exports.DEFAULT_PORT = nativeBinding.DEFAULT_PORT
393
- module.exports.HF_HOME = nativeBinding.HF_HOME
394
- module.exports.setAppSetting = nativeBinding.setAppSetting
395
- module.exports.setAppStatus = nativeBinding.setAppStatus
396
- module.exports.setClientCredentials = nativeBinding.setClientCredentials
397
- module.exports.setEnvVar = nativeBinding.setEnvVar
398
- module.exports.setSystemSetting = nativeBinding.setSystemSetting
313
+ const { createNapiAppOptions, setEnvVar, setAppSetting, setSystemSetting, setClientCredentials, setAppStatus, BODHI_HOME, BODHI_HOST, BODHI_PORT, BODHI_SCHEME, BODHI_LOG_LEVEL, BODHI_LOG_STDOUT, BODHI_LOGS, BODHI_ENV_TYPE, BODHI_APP_TYPE, BODHI_VERSION, BODHI_AUTH_URL, BODHI_AUTH_REALM, BODHI_ENCRYPTION_KEY, BODHI_EXEC_LOOKUP_PATH, BODHI_EXEC_VARIANT, BODHI_KEEP_ALIVE_SECS, HF_HOME, DEFAULT_HOST, DEFAULT_PORT, BodhiServer } = nativeBinding
314
+
315
+ module.exports.createNapiAppOptions = createNapiAppOptions
316
+ module.exports.setEnvVar = setEnvVar
317
+ module.exports.setAppSetting = setAppSetting
318
+ module.exports.setSystemSetting = setSystemSetting
319
+ module.exports.setClientCredentials = setClientCredentials
320
+ module.exports.setAppStatus = setAppStatus
321
+ module.exports.BODHI_HOME = BODHI_HOME
322
+ module.exports.BODHI_HOST = BODHI_HOST
323
+ module.exports.BODHI_PORT = BODHI_PORT
324
+ module.exports.BODHI_SCHEME = BODHI_SCHEME
325
+ module.exports.BODHI_LOG_LEVEL = BODHI_LOG_LEVEL
326
+ module.exports.BODHI_LOG_STDOUT = BODHI_LOG_STDOUT
327
+ module.exports.BODHI_LOGS = BODHI_LOGS
328
+ module.exports.BODHI_ENV_TYPE = BODHI_ENV_TYPE
329
+ module.exports.BODHI_APP_TYPE = BODHI_APP_TYPE
330
+ module.exports.BODHI_VERSION = BODHI_VERSION
331
+ module.exports.BODHI_AUTH_URL = BODHI_AUTH_URL
332
+ module.exports.BODHI_AUTH_REALM = BODHI_AUTH_REALM
333
+ module.exports.BODHI_ENCRYPTION_KEY = BODHI_ENCRYPTION_KEY
334
+ module.exports.BODHI_EXEC_LOOKUP_PATH = BODHI_EXEC_LOOKUP_PATH
335
+ module.exports.BODHI_EXEC_VARIANT = BODHI_EXEC_VARIANT
336
+ module.exports.BODHI_KEEP_ALIVE_SECS = BODHI_KEEP_ALIVE_SECS
337
+ module.exports.HF_HOME = HF_HOME
338
+ module.exports.DEFAULT_HOST = DEFAULT_HOST
339
+ module.exports.DEFAULT_PORT = DEFAULT_PORT
340
+ module.exports.BodhiServer = BodhiServer
package/package.json CHANGED
@@ -1,32 +1,37 @@
1
1
  {
2
2
  "name": "@bodhiapp/app-bindings",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "NAPI-RS bindings for BodhiApp server with integrated tests",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
- "type": "module",
8
7
  "napi": {
9
- "binaryName": "app-bindings",
10
- "targets": [
11
- "aarch64-apple-darwin"
12
- ]
8
+ "name": "app-bindings",
9
+ "triples": {
10
+ "defaults": false,
11
+ "additional": [
12
+ "aarch64-apple-darwin",
13
+ "x86_64-pc-windows-msvc",
14
+ "x86_64-unknown-linux-gnu"
15
+ ]
16
+ }
13
17
  },
14
18
  "scripts": {
15
19
  "artifacts": "napi artifacts",
16
- "create-npm-dirs": "napi create-npm-dirs",
20
+ "create-npm-dirs": "napi create-npm-dir --target .",
17
21
  "build": "napi build --platform --release",
18
22
  "build:debug": "napi build --platform",
19
23
  "build:release": "napi build --platform --release",
20
24
  "build:release:win": "napi build --platform --release --target x86_64-pc-windows-msvc",
21
- "test": "vitest run",
25
+ "update-optional-dependencies": "node scripts/update-optional-dependencies.js",
26
+ "test": "npm run test:run && npm run test:playwright",
22
27
  "test:run": "vitest run",
23
28
  "test:config": "vitest run --testNamePattern='Configuration'",
24
29
  "test:integration": "vitest run --testNamePattern='Integration'",
25
30
  "test:live": "vitest run --testNamePattern='Live Server'",
26
- "test:playwright": "playwright test --reporter=list",
27
- "test:playwright:ci": "playwright test",
28
- "test:playwright:ui": "playwright test --ui",
29
- "test:playwright:headed": "playwright test --headed",
31
+ "test:playwright": "playwright test --config=playwright.config.mjs --reporter=list",
32
+ "test:playwright:ci": "playwright test --config=playwright.config.mjs",
33
+ "test:playwright:ui": "playwright test --config=playwright.config.mjs --ui",
34
+ "test:playwright:headed": "playwright test --config=playwright.config.mjs --headed",
30
35
  "test:all": "npm run test:run && npm run test:playwright",
31
36
  "format": "biome format --write .",
32
37
  "format:check": "biome format .",
@@ -37,7 +42,7 @@
37
42
  },
38
43
  "devDependencies": {
39
44
  "@biomejs/biome": "^1.9.4",
40
- "@napi-rs/cli": "=3.0.0-alpha.72",
45
+ "@napi-rs/cli": "^2.18.4",
41
46
  "@playwright/test": "^1.48.2",
42
47
  "dotenv": "^16.5.0",
43
48
  "vitest": "^2.1.8"
@@ -69,5 +74,8 @@
69
74
  "files": [
70
75
  "index.d.ts",
71
76
  "index.js"
72
- ]
73
- }
77
+ ],
78
+ "optionalDependencies": {
79
+ "@bodhiapp/app-bindings-darwin-arm64": "0.0.8"
80
+ }
81
+ }