@bodhiapp/app-bindings 0.0.5 → 0.0.7

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/package.json +3 -7
  2. package/index.d.ts +0 -95
  3. package/index.js +0 -398
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@bodhiapp/app-bindings",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
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
8
  "binaryName": "app-bindings",
10
9
  "targets": [
@@ -37,7 +36,7 @@
37
36
  },
38
37
  "devDependencies": {
39
38
  "@biomejs/biome": "^1.9.4",
40
- "@napi-rs/cli": "=3.0.0-alpha.68",
39
+ "@napi-rs/cli": "3.0.0-alpha.88",
41
40
  "@playwright/test": "^1.48.2",
42
41
  "dotenv": "^16.5.0",
43
42
  "vitest": "^2.1.8"
@@ -69,8 +68,5 @@
69
68
  "files": [
70
69
  "index.d.ts",
71
70
  "index.js"
72
- ],
73
- "optionalDependencies": {
74
- "@bodhiapp/app-bindings-darwin-arm64": "0.0.1"
75
- }
71
+ ]
76
72
  }
package/index.d.ts DELETED
@@ -1,95 +0,0 @@
1
- /* auto-generated by NAPI-RS */
2
- /* eslint-disable */
3
- /** The main Bodhi server wrapper for NAPI */
4
- export declare class BodhiServer {
5
- /** Create a new Bodhi server instance with the given configuration */
6
- constructor(config: NapiAppOptions)
7
- /** Get the server configuration */
8
- get config(): NapiAppOptions
9
- /** Get the server URL */
10
- serverUrl(): string
11
- /** Get the server host */
12
- host(): string
13
- /** Get the server port */
14
- port(): number
15
- /** Start the Bodhi server */
16
- start(): Promise<void>
17
- /** Stop the Bodhi server */
18
- stop(): Promise<void>
19
- /** Check if the server is running */
20
- isRunning(): Promise<boolean>
21
- /** Get server ping status */
22
- ping(): Promise<boolean>
23
- }
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 DELETED
@@ -1,398 +0,0 @@
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
- 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)) {
47
- return true
48
- }
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
59
- }
60
- }
61
-
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()) {
207
- 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 {
219
- 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()) {
233
- 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 {
245
- 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()) {
259
- 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
-
270
- } 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)
280
- }
281
-
282
- }
283
- } else if (process.arch === 'riscv64') {
284
- if (isMusl()) {
285
- 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 {
297
- 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}`))
335
- }
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)
349
- }
350
- }
351
- if (!nativeBinding) {
352
- try {
353
- nativeBinding = require('@bodhiapp/app-bindings-wasm32-wasi')
354
- } catch (err) {
355
- if (process.env.NAPI_RS_FORCE_WASI) {
356
- loadErrors.push(err)
357
- }
358
- }
359
- }
360
- }
361
-
362
- 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 })
369
- }
370
- throw new Error(`Failed to load native binding`)
371
- }
372
-
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