@reboot-dev/reboot 0.25.1 → 0.25.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/binding.gyp +147 -112
- package/index.d.ts +7 -6
- package/index.js +18 -8
- package/package.json +6 -4
- package/rbt.js +2 -5
- package/reboot_native.cc +51 -5
- package/reboot_native.cjs +13 -2
- package/reboot_native.d.ts +1 -0
- package/utils/errors.d.ts +1 -1
- package/utils/errors.js +4 -6
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/binding.gyp
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
{
|
|
4
4
|
"python3":
|
|
5
5
|
"<!(echo $RBT_PYTHON3_USE)",
|
|
6
|
+
# Using `node` to get the OS and arch since it is platform independent.
|
|
6
7
|
"os_and_arch":
|
|
7
|
-
"<(OS) <!(
|
|
8
|
+
"<(OS) <!(node -p process.arch)",
|
|
8
9
|
# See https://gregoryszorc.com/docs/python-build-standalone/main/running.html.
|
|
9
10
|
# We use `gnu` (rather than `musl`) because we need a libc that we can install
|
|
10
11
|
# our native python extension on.
|
|
@@ -18,121 +19,155 @@
|
|
|
18
19
|
"conditions":
|
|
19
20
|
[
|
|
20
21
|
[
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
22
|
+
"OS != 'win'",
|
|
23
|
+
{
|
|
24
|
+
"conditions":
|
|
25
|
+
[
|
|
26
|
+
[
|
|
27
|
+
"os_and_arch=='mac arm64' and python3==''", {
|
|
28
|
+
"variables":
|
|
29
|
+
{
|
|
30
|
+
"python3":
|
|
31
|
+
"<!(curl -s -L <(pbs_base_url)-aarch64-apple-darwin-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"os_and_arch=='mac x64' and python3==''", {
|
|
37
|
+
"variables":
|
|
38
|
+
{
|
|
39
|
+
"python3":
|
|
40
|
+
"<!(curl -s -L <(pbs_base_url)-x86_64-apple-darwin-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"os_and_arch=='linux arm64' and python3==''", {
|
|
46
|
+
"variables":
|
|
47
|
+
{
|
|
48
|
+
"python3":
|
|
49
|
+
"<!(curl -s -L <(pbs_base_url)-aarch64-unknown-linux-gnu-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
"os_and_arch=='linux x64' and python3==''", {
|
|
55
|
+
"variables":
|
|
56
|
+
{
|
|
57
|
+
"python3":
|
|
58
|
+
"<!(curl -s -L <(pbs_base_url)-x86_64-unknown-linux-gnu-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"OS=='mac' and python3==''",
|
|
64
|
+
{
|
|
65
|
+
"variables":
|
|
66
|
+
{
|
|
67
|
+
# NOTE: On macOS, the `rpath` is not respected, and the dependency name of the
|
|
68
|
+
# downloaded Python is based on what it self-reports. We adjust what it will
|
|
69
|
+
# self-report in order to ensure that it is located at runtime.
|
|
70
|
+
#
|
|
71
|
+
# In theory, `gyp` supports Actions and dependencies between Targets. But
|
|
72
|
+
# in practice, `node-gyp` makes (undocumented) adjustments to both Actions and
|
|
73
|
+
# Targets that make it very challenging to use it for either fetching or
|
|
74
|
+
# updating the interpreter. We use private/dummy variables here to trigger
|
|
75
|
+
# side-effects instead.
|
|
76
|
+
"_absolute_lib_path":
|
|
77
|
+
"<!(echo $(pwd)/python/lib/libpython3.10.dylib)",
|
|
78
|
+
"_dummy":
|
|
79
|
+
"<!(install_name_tool -id <(_absolute_lib_path) <(_absolute_lib_path))"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
],
|
|
84
|
+
"targets":
|
|
85
|
+
[
|
|
86
|
+
{
|
|
87
|
+
"target_name":
|
|
88
|
+
"reboot_native",
|
|
89
|
+
"sources": ["reboot_native.cc"],
|
|
90
|
+
"variables":
|
|
91
|
+
{
|
|
92
|
+
# We additionally determine the `lib`/`bin` dir using sysconfig, in order to
|
|
93
|
+
# resolve through any shims that might be masking the true location of the
|
|
94
|
+
# underlying binaries (`python3.10-config`, in particular).
|
|
95
|
+
"python_lib_dir":
|
|
96
|
+
"<!(dirname $(<(python3) -c \"import sysconfig; print(sysconfig.get_path('stdlib', scheme='posix_prefix'))\"))",
|
|
97
|
+
"python_bin_dir":
|
|
98
|
+
"<!(<(python3) -c \"import sysconfig; print(sysconfig.get_path('scripts', scheme='posix_prefix'))\")",
|
|
99
|
+
"python3_config":
|
|
100
|
+
"<(python_bin_dir)/python3.10-config"
|
|
101
|
+
},
|
|
102
|
+
"include_dirs":
|
|
103
|
+
[
|
|
104
|
+
"<!@(node -p \"require('node-addon-api').include\")",
|
|
105
|
+
"<!@(<(python3) -c \"import sysconfig; print(sysconfig.get_path('include'))\")",
|
|
106
|
+
"include"
|
|
107
|
+
],
|
|
108
|
+
"dependencies":
|
|
109
|
+
[
|
|
110
|
+
"<!@(node -p \"require('node-addon-api').gyp\")"
|
|
111
|
+
],
|
|
112
|
+
"libraries":
|
|
113
|
+
[
|
|
114
|
+
"-L<(python_lib_dir)",
|
|
115
|
+
"<!@(<(python3_config) --libs --embed)",
|
|
116
|
+
# Adding extra lib path for `npm install`, while using local Python.
|
|
117
|
+
"<!@(<(python3_config) --ldflags --embed)",
|
|
118
|
+
# Set the `python_lib_dir` as an rpath for our library, so that it will be
|
|
119
|
+
# used as the runtime source of `libpython3.10`.
|
|
120
|
+
# NOTE: Although this is applied on macOS it is not actually obeyed for some
|
|
121
|
+
# reason: see the NOTE in the `conditions` above.
|
|
122
|
+
"-Wl,-rpath,<(python_lib_dir)"
|
|
123
|
+
],
|
|
124
|
+
"cflags!": ["-fno-exceptions", "-fno-rtti"],
|
|
125
|
+
"cflags_cc!": ["-fno-exceptions", "-fno-rtti"],
|
|
126
|
+
"cflags_cc":
|
|
127
|
+
[
|
|
128
|
+
"<!@(<(python3_config) --cflags --embed)",
|
|
129
|
+
"-std=c++17"
|
|
130
|
+
],
|
|
131
|
+
# For no reason 'node gyp' doesn't respect 'cflags' and 'cflags_cc'.
|
|
132
|
+
# For more information: https://github.com/nodejs/node-gyp/issues/152
|
|
133
|
+
"xcode_settings":
|
|
134
|
+
{
|
|
135
|
+
"OTHER_CFLAGS":
|
|
136
|
+
[
|
|
137
|
+
"<!@(<(python3_config) --cflags --embed)",
|
|
138
|
+
"-std=c++17",
|
|
139
|
+
"-fexceptions",
|
|
140
|
+
"-frtti",
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
"ldflags":
|
|
144
|
+
[
|
|
145
|
+
"<!@(<(python3_config) --ldflags --embed)"
|
|
146
|
+
],
|
|
147
|
+
"defines":
|
|
148
|
+
[
|
|
149
|
+
"NAPI_CPP_EXCEPTIONS",
|
|
150
|
+
"RBT_PYTHON3_USE=\"<(python3)\""
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
]
|
|
54
154
|
}
|
|
55
155
|
],
|
|
56
156
|
[
|
|
57
|
-
|
|
157
|
+
# 'node-gyp' requires at least one target to be defined.
|
|
158
|
+
# This is a workaround to avoid building the 'reboot_native'
|
|
159
|
+
# target on Windows.
|
|
160
|
+
"OS == 'win'",
|
|
58
161
|
{
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
# Targets that make it very challenging to use it for either fetching or
|
|
68
|
-
# updating the interpreter. We use private/dummy variables here to trigger
|
|
69
|
-
# side-effects instead.
|
|
70
|
-
"_absolute_lib_path":
|
|
71
|
-
"<!(echo $(pwd)/python/lib/libpython3.10.dylib)",
|
|
72
|
-
"_dummy":
|
|
73
|
-
"<!(install_name_tool -id <(_absolute_lib_path) <(_absolute_lib_path))",
|
|
74
|
-
},
|
|
162
|
+
"targets":
|
|
163
|
+
[
|
|
164
|
+
{
|
|
165
|
+
"target_name": "empty",
|
|
166
|
+
"type": "none",
|
|
167
|
+
"sources": []
|
|
168
|
+
}
|
|
169
|
+
]
|
|
75
170
|
}
|
|
76
171
|
],
|
|
77
|
-
]
|
|
78
|
-
"targets":
|
|
79
|
-
[
|
|
80
|
-
{
|
|
81
|
-
"target_name":
|
|
82
|
-
"reboot_native",
|
|
83
|
-
"sources": ["reboot_native.cc"],
|
|
84
|
-
"variables":
|
|
85
|
-
{
|
|
86
|
-
# We additionally determine the `lib`/`bin` dir using sysconfig, in order to
|
|
87
|
-
# resolve through any shims that might be masking the true location of the
|
|
88
|
-
# underlying binaries (`python3.10-config`, in particular).
|
|
89
|
-
"python_lib_dir":
|
|
90
|
-
"<!(dirname $(<(python3) -c \"import sysconfig; print(sysconfig.get_path('stdlib', scheme='posix_prefix'))\"))",
|
|
91
|
-
"python_bin_dir":
|
|
92
|
-
"<!(<(python3) -c \"import sysconfig; print(sysconfig.get_path('scripts', scheme='posix_prefix'))\")",
|
|
93
|
-
"python3_config":
|
|
94
|
-
"<(python_bin_dir)/python3.10-config",
|
|
95
|
-
},
|
|
96
|
-
"include_dirs":
|
|
97
|
-
[
|
|
98
|
-
"<!@(node -p \"require('node-addon-api').include\")",
|
|
99
|
-
"<!@(<(python3) -c \"import sysconfig; print(sysconfig.get_path('include'))\")",
|
|
100
|
-
"include",
|
|
101
|
-
],
|
|
102
|
-
"dependencies":
|
|
103
|
-
["<!@(node -p \"require('node-addon-api').gyp\")"],
|
|
104
|
-
"libraries":
|
|
105
|
-
[
|
|
106
|
-
"-L<(python_lib_dir)",
|
|
107
|
-
"<!@(<(python3_config) --libs --embed)",
|
|
108
|
-
# Adding extra lib path for `npm install`, while using local Python.
|
|
109
|
-
"<!@(<(python3_config) --ldflags --embed)",
|
|
110
|
-
# Set the `python_lib_dir` as an rpath for our library, so that it will be
|
|
111
|
-
# used as the runtime source of `libpython3.10`.
|
|
112
|
-
# NOTE: Although this is applied on macOS it is not actually obeyed for some
|
|
113
|
-
# reason: see the NOTE in the `conditions` above.
|
|
114
|
-
"-Wl,-rpath,<(python_lib_dir)",
|
|
115
|
-
],
|
|
116
|
-
"cflags!": ["-fno-exceptions", "-fno-rtti"],
|
|
117
|
-
"cflags_cc!": ["-fno-exceptions", "-fno-rtti"],
|
|
118
|
-
"cflags_cc":
|
|
119
|
-
["<!@(<(python3_config) --cflags --embed)", "-std=c++17"],
|
|
120
|
-
# For no reason 'node gyp' doesn't respect 'cflags' and 'cflags_cc'.
|
|
121
|
-
# For more information: https://github.com/nodejs/node-gyp/issues/152
|
|
122
|
-
'xcode_settings':
|
|
123
|
-
{
|
|
124
|
-
'OTHER_CFLAGS':
|
|
125
|
-
[
|
|
126
|
-
"<!@(<(python3_config) --cflags --embed)",
|
|
127
|
-
"-std=c++17", "-fexceptions", "-frtti"
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
"ldflags": ["<!@(<(python3_config) --ldflags --embed)"],
|
|
131
|
-
"defines":
|
|
132
|
-
[
|
|
133
|
-
"NAPI_CPP_EXCEPTIONS",
|
|
134
|
-
'RBT_PYTHON3_USE="<(python3)"',
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
|
-
],
|
|
172
|
+
]
|
|
138
173
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errors_pb, IdempotencyOptions, protobuf_es, ScheduleOptions } from "@reboot-dev/reboot-api";
|
|
2
|
-
import express from "express";
|
|
3
2
|
import * as reboot_native from "./reboot_native.cjs";
|
|
3
|
+
import { Application as ExpressApplication, NextFunction as ExpressNextFunction, Request as ExpressRequest, Response as ExpressResponse } from "express";
|
|
4
4
|
export { reboot_native };
|
|
5
5
|
export * from "./utils/index.js";
|
|
6
6
|
type ApplicationRevision = {
|
|
@@ -49,6 +49,7 @@ export declare class Context {
|
|
|
49
49
|
get __external(): any;
|
|
50
50
|
get auth(): Auth | null;
|
|
51
51
|
get stateId(): string;
|
|
52
|
+
get callerBearerToken(): string | null;
|
|
52
53
|
get iteration(): number;
|
|
53
54
|
get cookie(): string;
|
|
54
55
|
get appInternal(): boolean;
|
|
@@ -177,7 +178,7 @@ export declare function isAppInternal({ context, }: {
|
|
|
177
178
|
context: ReaderContext;
|
|
178
179
|
state?: protobuf_es.Message;
|
|
179
180
|
request?: protobuf_es.Message;
|
|
180
|
-
}): errors_pb.
|
|
181
|
+
}): errors_pb.PermissionDenied | errors_pb.Ok;
|
|
181
182
|
export declare class Application {
|
|
182
183
|
#private;
|
|
183
184
|
constructor({ servicers, initialize, initializeBearerToken, tokenVerifier, }: {
|
|
@@ -195,14 +196,14 @@ export declare class Application {
|
|
|
195
196
|
export declare namespace Application {
|
|
196
197
|
namespace Http {
|
|
197
198
|
type Path = string | RegExp | (string | RegExp)[];
|
|
198
|
-
type ReqResHandler = (context: ExternalContext, req:
|
|
199
|
-
type ReqResNextHandler = (context: ExternalContext, req:
|
|
200
|
-
type ErrReqResNextHandler = (context: ExternalContext, err: any, req:
|
|
199
|
+
type ReqResHandler = (context: ExternalContext, req: ExpressRequest, res: ExpressResponse) => any;
|
|
200
|
+
type ReqResNextHandler = (context: ExternalContext, req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => any;
|
|
201
|
+
type ErrReqResNextHandler = (context: ExternalContext, err: any, req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => any;
|
|
201
202
|
type Handler = ReqResHandler | ReqResNextHandler | ErrReqResNextHandler;
|
|
202
203
|
}
|
|
203
204
|
class Http {
|
|
204
205
|
#private;
|
|
205
|
-
constructor(express:
|
|
206
|
+
constructor(express: ExpressApplication, createExternalContext: (args: {
|
|
206
207
|
name: string;
|
|
207
208
|
bearerToken?: string;
|
|
208
209
|
}) => Promise<ExternalContext>);
|
package/index.js
CHANGED
|
@@ -12,12 +12,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _Reboot_external, _ExternalContext_external, _a, _Context_external, _Context_isInternalConstructing, _ReaderContext_kind, _WriterContext_kind, _TransactionContext_kind, _WorkflowContext_kind, _Application_servicers, _Application_tokenVerifier, _Application_express, _Application_http, _Application_servers, _Application_createExternalContext, _Application_external;
|
|
13
13
|
import { auth_pb, errors_pb, protobuf_es, } from "@reboot-dev/reboot-api";
|
|
14
14
|
import { strict as assert } from "assert";
|
|
15
|
-
import express from "express";
|
|
16
15
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
16
|
import { fork } from "node:child_process";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
18
18
|
import { test } from "node:test";
|
|
19
19
|
import * as reboot_native from "./reboot_native.cjs";
|
|
20
|
+
import { ensureError } from "./utils/errors.js";
|
|
20
21
|
import { ensurePythonVenv } from "./venv.js";
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
const express = require("express");
|
|
21
24
|
export { reboot_native };
|
|
22
25
|
export * from "./utils/index.js";
|
|
23
26
|
const startedInstances = [];
|
|
@@ -173,6 +176,9 @@ export class Context {
|
|
|
173
176
|
get stateId() {
|
|
174
177
|
return reboot_native.Context_stateId(__classPrivateFieldGet(this, _Context_external, "f"));
|
|
175
178
|
}
|
|
179
|
+
get callerBearerToken() {
|
|
180
|
+
return reboot_native.Context_callerBearerToken(__classPrivateFieldGet(this, _Context_external, "f"));
|
|
181
|
+
}
|
|
176
182
|
get iteration() {
|
|
177
183
|
return reboot_native.Context_iteration(__classPrivateFieldGet(this, _Context_external, "f"));
|
|
178
184
|
}
|
|
@@ -431,7 +437,7 @@ export function isAppInternal({ context, }) {
|
|
|
431
437
|
if (context.appInternal) {
|
|
432
438
|
return new errors_pb.Ok();
|
|
433
439
|
}
|
|
434
|
-
return new errors_pb.
|
|
440
|
+
return new errors_pb.PermissionDenied();
|
|
435
441
|
}
|
|
436
442
|
export class Application {
|
|
437
443
|
constructor({ servicers, initialize, initializeBearerToken, tokenVerifier, }) {
|
|
@@ -500,12 +506,16 @@ export class Application {
|
|
|
500
506
|
await initialize(context);
|
|
501
507
|
}
|
|
502
508
|
catch (e) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
+
// Ensure we have an `Error` and then `console.error()` it
|
|
510
|
+
// so that developers see a stack trace of what is going
|
|
511
|
+
// on.
|
|
512
|
+
const error = ensureError(e);
|
|
513
|
+
// Write an empy message which includes a newline to make
|
|
514
|
+
// it easier to identify the stack trace.
|
|
515
|
+
console.error("");
|
|
516
|
+
console.error(error);
|
|
517
|
+
console.error("");
|
|
518
|
+
throw error;
|
|
509
519
|
}
|
|
510
520
|
}
|
|
511
521
|
}, initializeBearerToken, tokenVerifier), "f");
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"@bufbuild/protobuf": "1.3.2",
|
|
4
4
|
"@bufbuild/protoplugin": "1.3.2",
|
|
5
5
|
"@bufbuild/protoc-gen-es": "1.3.2",
|
|
6
|
-
"@reboot-dev/reboot-api": "0.25.
|
|
6
|
+
"@reboot-dev/reboot-api": "0.25.3",
|
|
7
7
|
"chalk": "^4.1.2",
|
|
8
8
|
"node-addon-api": "^7.0.0",
|
|
9
9
|
"node-gyp": ">=10.2.0",
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
"which-pm-runs": "^1.1.0",
|
|
12
12
|
"extensionless": "^1.9.9",
|
|
13
13
|
"esbuild": "^0.24.0",
|
|
14
|
-
"express": "^5.1.0"
|
|
14
|
+
"express": "^5.1.0",
|
|
15
|
+
"@scarf/scarf": "1.4.0"
|
|
15
16
|
},
|
|
16
17
|
"type": "module",
|
|
17
18
|
"name": "@reboot-dev/reboot",
|
|
18
|
-
"version": "0.25.
|
|
19
|
+
"version": "0.25.3",
|
|
19
20
|
"description": "npm package for Reboot",
|
|
20
21
|
"scripts": {
|
|
21
22
|
"postinstall": "rbt || exit 0",
|
|
@@ -24,9 +25,10 @@
|
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"typescript": ">=4.9.5",
|
|
28
|
+
"@types/express": "^5.0.1",
|
|
27
29
|
"@types/node": "20.11.5",
|
|
28
30
|
"@types/uuid": "^9.0.4",
|
|
29
|
-
"@types/express": "^5.0.
|
|
31
|
+
"@types/express-serve-static-core": "^5.0.6"
|
|
30
32
|
},
|
|
31
33
|
"bin": {
|
|
32
34
|
"rbt": "./rbt.js",
|
package/rbt.js
CHANGED
|
@@ -27,16 +27,13 @@ function addExtensionlessToNodeOptions() {
|
|
|
27
27
|
// If we have one of those two versions then we can pre import
|
|
28
28
|
// `extensionless/register` to use the `module.register()` function,
|
|
29
29
|
// otherwise we need to fall back to `--experimental-loader`.
|
|
30
|
-
if (major >= 21 ||
|
|
31
|
-
(major == 20 && minor >= 6) ||
|
|
32
|
-
(major == 18 && minor >= 19)) {
|
|
30
|
+
if (major >= 21 || (major == 20 && minor >= 6)) {
|
|
33
31
|
process.env.NODE_OPTIONS += "--import=extensionless/register";
|
|
34
32
|
}
|
|
35
33
|
else {
|
|
36
34
|
throw new Error(`The current version of Node.js is not supported.
|
|
37
35
|
Supported versions are:
|
|
38
|
-
* greater than or equal to 20.6
|
|
39
|
-
* greater than or equal to 18.19 but less than 19`);
|
|
36
|
+
* greater than or equal to 20.6`);
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
async function main() {
|
package/reboot_native.cc
CHANGED
|
@@ -1504,7 +1504,7 @@ py::object make_py_token_verifier(NapiSafeObjectReference js_token_verifier) {
|
|
|
1504
1504
|
if (token.has_value()) {
|
|
1505
1505
|
js_args.push_back(Napi::String::New(env, *token));
|
|
1506
1506
|
} else {
|
|
1507
|
-
js_args.push_back(env.
|
|
1507
|
+
js_args.push_back(env.Null());
|
|
1508
1508
|
}
|
|
1509
1509
|
|
|
1510
1510
|
Napi::Object js_token_verifier =
|
|
@@ -1605,8 +1605,22 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1605
1605
|
});
|
|
1606
1606
|
}
|
|
1607
1607
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1608
|
+
Napi::Value Reboot_down(const Napi::CallbackInfo& info) {
|
|
1609
|
+
auto js_external_reboot = NapiSafeReference(
|
|
1610
|
+
info[0].As<Napi::External<py::object>>());
|
|
1611
|
+
|
|
1612
|
+
// CHECK(js_external_reboot.CheckTypeTag(&reboot_aio_tests_Reboot));
|
|
1613
|
+
|
|
1614
|
+
py::object* py_reboot = js_external_reboot.Value(info.Env()).Data();
|
|
1615
|
+
|
|
1616
|
+
return NodePromiseFromPythonTask(
|
|
1617
|
+
info.Env(),
|
|
1618
|
+
"Reboot.down() in nodejs",
|
|
1619
|
+
{"asyncio", "create_task"},
|
|
1620
|
+
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1621
|
+
py_reboot]() {
|
|
1622
|
+
return py_reboot->attr("down")();
|
|
1623
|
+
});
|
|
1610
1624
|
}
|
|
1611
1625
|
|
|
1612
1626
|
Napi::Value Reboot_start(const Napi::CallbackInfo& info) {
|
|
@@ -1633,7 +1647,8 @@ Napi::Value Reboot_start(const Napi::CallbackInfo& info) {
|
|
|
1633
1647
|
info.Env(),
|
|
1634
1648
|
"Reboot.start() in nodejs",
|
|
1635
1649
|
{"asyncio", "create_task"},
|
|
1636
|
-
[py_reboot
|
|
1650
|
+
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1651
|
+
py_reboot]() {
|
|
1637
1652
|
return py_reboot->attr("start")();
|
|
1638
1653
|
});
|
|
1639
1654
|
}
|
|
@@ -1653,7 +1668,8 @@ Napi::Value Reboot_stop(const Napi::CallbackInfo& info) {
|
|
|
1653
1668
|
info.Env(),
|
|
1654
1669
|
"Reboot.stop() in nodejs",
|
|
1655
1670
|
{"asyncio", "create_task"},
|
|
1656
|
-
[py_reboot
|
|
1671
|
+
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1672
|
+
py_reboot]() {
|
|
1657
1673
|
return py_reboot->attr("stop")();
|
|
1658
1674
|
});
|
|
1659
1675
|
|
|
@@ -2275,6 +2291,32 @@ Napi::Value Context_stateId(const Napi::CallbackInfo& info) {
|
|
|
2275
2291
|
return Napi::String::New(info.Env(), state_id);
|
|
2276
2292
|
}
|
|
2277
2293
|
|
|
2294
|
+
Napi::Value Context_callerBearerToken(
|
|
2295
|
+
const Napi::CallbackInfo& info) {
|
|
2296
|
+
Napi::External<py::object> js_external_context =
|
|
2297
|
+
info[0].As<Napi::External<py::object>>();
|
|
2298
|
+
|
|
2299
|
+
// CHECK(...CheckTypeTag(...));
|
|
2300
|
+
|
|
2301
|
+
py::object* py_context = js_external_context.Data();
|
|
2302
|
+
|
|
2303
|
+
std::optional<std::string> caller_bearer_token = RunCallbackOnPythonEventLoop(
|
|
2304
|
+
[py_context]() -> std::optional<std::string> {
|
|
2305
|
+
py::object caller_bearer_token = py_context->attr(
|
|
2306
|
+
"caller_bearer_token");
|
|
2307
|
+
if (caller_bearer_token.is_none()) {
|
|
2308
|
+
return std::nullopt;
|
|
2309
|
+
} else {
|
|
2310
|
+
return std::string(py::str(caller_bearer_token));
|
|
2311
|
+
}
|
|
2312
|
+
});
|
|
2313
|
+
if (caller_bearer_token.has_value()) {
|
|
2314
|
+
return Napi::String::New(info.Env(), *caller_bearer_token);
|
|
2315
|
+
} else {
|
|
2316
|
+
return info.Env().Null();
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2278
2320
|
|
|
2279
2321
|
Napi::Value Context_iteration(const Napi::CallbackInfo& info) {
|
|
2280
2322
|
Napi::External<py::object> js_external_context =
|
|
@@ -2686,6 +2728,10 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
|
2686
2728
|
Napi::String::New(env, "Context_stateId"),
|
|
2687
2729
|
Napi::Function::New<Context_stateId>(env));
|
|
2688
2730
|
|
|
2731
|
+
exports.Set(
|
|
2732
|
+
Napi::String::New(env, "Context_callerBearerToken"),
|
|
2733
|
+
Napi::Function::New<Context_callerBearerToken>(env));
|
|
2734
|
+
|
|
2689
2735
|
exports.Set(
|
|
2690
2736
|
Napi::String::New(env, "Context_iteration"),
|
|
2691
2737
|
Napi::Function::New<Context_iteration>(env));
|
package/reboot_native.cjs
CHANGED
|
@@ -3,12 +3,21 @@ const process = require("node:process");
|
|
|
3
3
|
const os = require("node:os");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
|
|
6
|
+
if (os.platform() === "win32") {
|
|
7
|
+
console.error(
|
|
8
|
+
chalk.stderr.bold.red(
|
|
9
|
+
`Reboot is not yet supported on Windows. Please use Linux or macOS.`
|
|
10
|
+
)
|
|
11
|
+
);
|
|
12
|
+
process.exit(-1);
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
const [major, minor, patch] = process.versions.node.split(".").map(Number);
|
|
7
16
|
|
|
8
|
-
if (major <
|
|
17
|
+
if (major < 20) {
|
|
9
18
|
console.error(
|
|
10
19
|
chalk.stderr.bold.red(
|
|
11
|
-
`Reboot requires nodejs version >=
|
|
20
|
+
`Reboot requires nodejs version >=20 (found ${major}.${minor}.${patch})`
|
|
12
21
|
)
|
|
13
22
|
);
|
|
14
23
|
process.exit(-1);
|
|
@@ -67,6 +76,8 @@ exports.Reboot_down = reboot_native.exports.Reboot_down;
|
|
|
67
76
|
exports.Reboot_url = reboot_native.exports.Reboot_url;
|
|
68
77
|
exports.Context_auth = reboot_native.exports.Context_auth;
|
|
69
78
|
exports.Context_stateId = reboot_native.exports.Context_stateId;
|
|
79
|
+
exports.Context_callerBearerToken =
|
|
80
|
+
reboot_native.exports.Context_callerBearerToken;
|
|
70
81
|
exports.Context_cookie = reboot_native.exports.Context_cookie;
|
|
71
82
|
exports.Context_appInternal = reboot_native.exports.Context_appInternal;
|
|
72
83
|
exports.Context_iteration = reboot_native.exports.Context_iteration;
|
package/reboot_native.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ export namespace rbt_native {
|
|
|
74
74
|
// This will take an ApplicationConfig proto.
|
|
75
75
|
function Reboot_down(external: NapiExternal): void;
|
|
76
76
|
function Context_stateId(external: NapiExternal): string;
|
|
77
|
+
function Context_callerBearerToken(external: NapiExternal): string;
|
|
77
78
|
function Context_iteration(external: NapiExternal): number;
|
|
78
79
|
function Context_cookie(external: NapiExternal): string;
|
|
79
80
|
function Context_appInternal(external: NapiExternal): boolean;
|
package/utils/errors.d.ts
CHANGED
package/utils/errors.js
CHANGED
|
@@ -4,13 +4,11 @@ export class UnknownError extends Error {
|
|
|
4
4
|
this.name = "UnknownError";
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
error = errorObject;
|
|
7
|
+
export const ensureError = (error) => {
|
|
8
|
+
if (error instanceof Error) {
|
|
9
|
+
return error;
|
|
11
10
|
}
|
|
12
11
|
else {
|
|
13
|
-
|
|
12
|
+
return new UnknownError(error);
|
|
14
13
|
}
|
|
15
|
-
return error;
|
|
16
14
|
};
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const REBOOT_VERSION = "0.25.
|
|
1
|
+
export declare const REBOOT_VERSION = "0.25.3";
|
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const REBOOT_VERSION = "0.25.
|
|
1
|
+
export const REBOOT_VERSION = "0.25.3";
|