@reboot-dev/reboot 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{reboot.d.ts → index.d.ts} +4 -2
- package/{reboot.js → index.js} +6 -3
- package/package.json +5 -5
- package/reboot_native.cc +34 -9
- package/reboot_native.cjs +14 -4
- package/reboot_native.d.ts +2 -3
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -18,8 +18,10 @@ export declare class Reboot {
|
|
|
18
18
|
stop(): Promise<void>;
|
|
19
19
|
up(servicers: any, options?: {
|
|
20
20
|
tokenVerifier?: TokenVerifier;
|
|
21
|
+
localEnvoy?: boolean;
|
|
21
22
|
}): Promise<ApplicationConfig>;
|
|
22
23
|
down(): Promise<void>;
|
|
24
|
+
url(): string;
|
|
23
25
|
}
|
|
24
26
|
export declare class ExternalContext {
|
|
25
27
|
#private;
|
|
@@ -88,10 +90,10 @@ export type ServicerFactory = {
|
|
|
88
90
|
*/
|
|
89
91
|
export declare class Auth {
|
|
90
92
|
userId?: string;
|
|
91
|
-
properties:
|
|
93
|
+
properties: protobuf_es.JsonValue;
|
|
92
94
|
constructor(options?: {
|
|
93
95
|
userId?: string;
|
|
94
|
-
properties?:
|
|
96
|
+
properties?: protobuf_es.JsonValue;
|
|
95
97
|
});
|
|
96
98
|
toProtoBytes(): Uint8Array;
|
|
97
99
|
static fromProtoBytes(bytes: Uint8Array): Auth;
|
package/{reboot.js → index.js}
RENAMED
|
@@ -81,11 +81,14 @@ export class Reboot {
|
|
|
81
81
|
async up(servicers, options) {
|
|
82
82
|
// TODO(benh): determine module and file name so that we can
|
|
83
83
|
// namespace if we have more than one implementation of servicers.
|
|
84
|
-
return await reboot_native.Reboot_up(__classPrivateFieldGet(this, _Reboot_external, "f"), servicers, options?.tokenVerifier);
|
|
84
|
+
return await reboot_native.Reboot_up(__classPrivateFieldGet(this, _Reboot_external, "f"), servicers, options?.tokenVerifier, options?.localEnvoy);
|
|
85
85
|
}
|
|
86
86
|
async down() {
|
|
87
87
|
await reboot_native.Reboot_down(__classPrivateFieldGet(this, _Reboot_external, "f"));
|
|
88
88
|
}
|
|
89
|
+
url() {
|
|
90
|
+
return reboot_native.Reboot_url(__classPrivateFieldGet(this, _Reboot_external, "f"));
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
93
|
_Reboot_external = new WeakMap();
|
|
91
94
|
export class ExternalContext {
|
|
@@ -95,7 +98,7 @@ export class ExternalContext {
|
|
|
95
98
|
__classPrivateFieldSet(this, _ExternalContext_external, args.external, "f");
|
|
96
99
|
}
|
|
97
100
|
else {
|
|
98
|
-
if (!args.url.startsWith("http")) {
|
|
101
|
+
if (!args.url || !args.url.startsWith("http")) {
|
|
99
102
|
throw new Error("`ExternalContext` must be constructed with a `url` " +
|
|
100
103
|
"including an explicit 'http' or 'https' protocol");
|
|
101
104
|
}
|
|
@@ -277,7 +280,7 @@ export class Auth {
|
|
|
277
280
|
toProtoBytes() {
|
|
278
281
|
const auth = new auth_pb.Auth({
|
|
279
282
|
userId: this.userId,
|
|
280
|
-
properties: this.properties,
|
|
283
|
+
properties: protobuf_es.Struct.fromJson(this.properties),
|
|
281
284
|
});
|
|
282
285
|
return auth.toBinary();
|
|
283
286
|
}
|
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.
|
|
6
|
+
"@reboot-dev/reboot-api": "0.21.0",
|
|
7
7
|
"chalk": "^4.1.2",
|
|
8
8
|
"node-addon-api": "^7.0.0",
|
|
9
9
|
"node-gyp": ">=10.2.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
16
|
"name": "@reboot-dev/reboot",
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.21.0",
|
|
18
18
|
"description": "npm package for Reboot",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"postinstall": "rbt || exit 0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"rbt-esbuild.d.ts",
|
|
50
50
|
"rbt-esbuild.js",
|
|
51
51
|
"rbt.js",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
52
|
+
"index.d.ts",
|
|
53
|
+
"index.js",
|
|
54
54
|
"reboot_native.cc",
|
|
55
55
|
"reboot_native.cjs",
|
|
56
56
|
"reboot_native.d.ts",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
],
|
|
64
64
|
"exports": {
|
|
65
65
|
"./package.json": "./package.json",
|
|
66
|
-
".": "./
|
|
66
|
+
".": "./index.js",
|
|
67
67
|
"./utils": "./utils/index.js"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/reboot_native.cc
CHANGED
|
@@ -1264,6 +1264,11 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1264
1264
|
js_token_verifier = NapiSafeReference(info[2].As<Napi::Object>());
|
|
1265
1265
|
}
|
|
1266
1266
|
|
|
1267
|
+
bool local_envoy = false;
|
|
1268
|
+
if (!info[3].IsUndefined()) {
|
|
1269
|
+
local_envoy = info[3].As<Napi::Boolean>();
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1267
1272
|
auto env = info.Env();
|
|
1268
1273
|
auto servicer_details = make_servicer_details(env, js_servicers);
|
|
1269
1274
|
|
|
@@ -1275,6 +1280,7 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1275
1280
|
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1276
1281
|
py_reboot,
|
|
1277
1282
|
js_token_verifier,
|
|
1283
|
+
local_envoy,
|
|
1278
1284
|
servicer_details = std::move(servicer_details),
|
|
1279
1285
|
deferred = std::move(deferred)]() {
|
|
1280
1286
|
py::list py_servicers = make_py_servicers(servicer_details);
|
|
@@ -1294,7 +1300,7 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1294
1300
|
// clone a process like we do with multiprocessing
|
|
1295
1301
|
// in Python.
|
|
1296
1302
|
"in_process"_a = true,
|
|
1297
|
-
"local_envoy"_a =
|
|
1303
|
+
"local_envoy"_a = local_envoy),
|
|
1298
1304
|
"name"_a = "Reboot.up(...) in nodejs");
|
|
1299
1305
|
|
|
1300
1306
|
py_task.attr("add_done_callback")(py::cpp_function(
|
|
@@ -1475,6 +1481,29 @@ Napi::Value Reboot_stop(const Napi::CallbackInfo& info) {
|
|
|
1475
1481
|
return promise;
|
|
1476
1482
|
}
|
|
1477
1483
|
|
|
1484
|
+
// NOTE: We block on a promise here, so this method should not be called outside
|
|
1485
|
+
// of tests.
|
|
1486
|
+
Napi::Value Reboot_url(const Napi::CallbackInfo& info) {
|
|
1487
|
+
// NOTE: we immediately get a safe reference to the `Napi::External`
|
|
1488
|
+
// so that Node will not garbage collect it and the `py::object*` we
|
|
1489
|
+
// get out of it will remain valid.
|
|
1490
|
+
auto js_external_reboot = NapiSafeReference(
|
|
1491
|
+
info[0].As<Napi::External<py::object>>());
|
|
1492
|
+
|
|
1493
|
+
// CHECK(...CheckTypeTag(...));
|
|
1494
|
+
|
|
1495
|
+
py::object* py_reboot = js_external_reboot.Value(info.Env()).Data();
|
|
1496
|
+
|
|
1497
|
+
std::promise<std::string> promise;
|
|
1498
|
+
|
|
1499
|
+
adaptor->ScheduleCallbackOnPythonEventLoop(
|
|
1500
|
+
[py_reboot, &promise]() {
|
|
1501
|
+
py::str url = py_reboot->attr("url")();
|
|
1502
|
+
promise.set_value(std::string(url));
|
|
1503
|
+
});
|
|
1504
|
+
|
|
1505
|
+
return Napi::String::New(info.Env(), promise.get_future().get());
|
|
1506
|
+
}
|
|
1478
1507
|
|
|
1479
1508
|
Napi::Value Service_constructor(const Napi::CallbackInfo& info) {
|
|
1480
1509
|
Napi::Object js_args = info[0].As<Napi::Object>();
|
|
@@ -1786,14 +1815,6 @@ Napi::Value ExternalContext_constructor(const Napi::CallbackInfo& info) {
|
|
|
1786
1815
|
return py::none();
|
|
1787
1816
|
}
|
|
1788
1817
|
};
|
|
1789
|
-
auto convert_bool =
|
|
1790
|
-
[](const std::optional<bool>& optional) -> py::object {
|
|
1791
|
-
if (optional.has_value()) {
|
|
1792
|
-
return py::bool_(*optional);
|
|
1793
|
-
} else {
|
|
1794
|
-
return py::none();
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
1818
|
|
|
1798
1819
|
promise.set_value(
|
|
1799
1820
|
new py::object(py_external.attr("ExternalContext")(
|
|
@@ -2806,6 +2827,10 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
|
2806
2827
|
Napi::String::New(env, "Reboot_down"),
|
|
2807
2828
|
Napi::Function::New<Reboot_down>(env));
|
|
2808
2829
|
|
|
2830
|
+
exports.Set(
|
|
2831
|
+
Napi::String::New(env, "Reboot_url"),
|
|
2832
|
+
Napi::Function::New<Reboot_url>(env));
|
|
2833
|
+
|
|
2809
2834
|
exports.Set(
|
|
2810
2835
|
Napi::String::New(env, "Service_constructor"),
|
|
2811
2836
|
Napi::Function::New<Service_constructor>(env));
|
package/reboot_native.cjs
CHANGED
|
@@ -19,12 +19,21 @@ const reboot_native = { exports: {} };
|
|
|
19
19
|
// If we are in a Next.js context, check that serverExternalPackages is
|
|
20
20
|
// correctly set. If not correctly set, Reboot backend TS code will not work
|
|
21
21
|
// with React Server Components inside Next.
|
|
22
|
-
|
|
23
22
|
if (__dirname.includes(".next")) {
|
|
24
23
|
throw new Error(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
`For Next.js to work correctly with Reboot native code, an external
|
|
25
|
+
package must be added to 'next.config.ts':
|
|
26
|
+
|
|
27
|
+
In Next.js 14:
|
|
28
|
+
experimental: {
|
|
29
|
+
serverComponentsExternalPackages: ["@reboot-dev/reboot"],
|
|
30
|
+
},
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
In Next.js 15
|
|
34
|
+
'serverExternalPackages: ['@reboot-dev/reboot']',
|
|
35
|
+
...
|
|
36
|
+
`
|
|
28
37
|
);
|
|
29
38
|
}
|
|
30
39
|
|
|
@@ -55,6 +64,7 @@ exports.Reboot_start = reboot_native.exports.Reboot_start;
|
|
|
55
64
|
exports.Reboot_stop = reboot_native.exports.Reboot_stop;
|
|
56
65
|
exports.Reboot_up = reboot_native.exports.Reboot_up;
|
|
57
66
|
exports.Reboot_down = reboot_native.exports.Reboot_down;
|
|
67
|
+
exports.Reboot_url = reboot_native.exports.Reboot_url;
|
|
58
68
|
exports.Context_auth = reboot_native.exports.Context_auth;
|
|
59
69
|
exports.Context_stateId = reboot_native.exports.Context_stateId;
|
|
60
70
|
exports.Context_iteration = reboot_native.exports.Context_iteration;
|
package/reboot_native.d.ts
CHANGED
|
@@ -4,11 +4,10 @@ import {
|
|
|
4
4
|
Context,
|
|
5
5
|
ExternalContext,
|
|
6
6
|
Servicer,
|
|
7
|
+
TokenVerifier,
|
|
7
8
|
TransactionContext,
|
|
8
9
|
WorkflowContext,
|
|
9
|
-
|
|
10
|
-
TokenVerifier,
|
|
11
|
-
} from "./reboot.js";
|
|
10
|
+
} from "./index.js";
|
|
12
11
|
|
|
13
12
|
// The Nodejs addon API does not expose TypeScript types so we alias
|
|
14
13
|
// our C++ `Napi::External` type to `NapiExternal` to make it more
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const REBOOT_VERSION = "0.
|
|
1
|
+
export declare const REBOOT_VERSION = "0.21.0";
|
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const REBOOT_VERSION = "0.
|
|
1
|
+
export const REBOOT_VERSION = "0.21.0";
|