@reboot-dev/reboot 0.20.0 → 0.22.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} +3 -1
- package/{reboot.js → index.js} +7 -4
- package/package.json +5 -5
- package/reboot_native.cc +38 -18
- package/reboot_native.cjs +1 -0
- package/reboot_native.d.ts +2 -3
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -12,14 +12,16 @@ export declare class Reboot {
|
|
|
12
12
|
createExternalContext(name: string, options?: {
|
|
13
13
|
idempotencySeed?: string;
|
|
14
14
|
bearerToken?: string;
|
|
15
|
-
|
|
15
|
+
appInternal?: boolean;
|
|
16
16
|
}): ExternalContext;
|
|
17
17
|
start(): Promise<void>;
|
|
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;
|
package/{reboot.js → index.js}
RENAMED
|
@@ -59,10 +59,10 @@ export class Reboot {
|
|
|
59
59
|
__classPrivateFieldSet(this, _Reboot_external, reboot_native.Reboot_constructor(), "f");
|
|
60
60
|
}
|
|
61
61
|
createExternalContext(name, options) {
|
|
62
|
-
if (options?.bearerToken && options?.
|
|
63
|
-
throw new Error("At most one of `bearerToken` and `
|
|
62
|
+
if (options?.bearerToken && options?.appInternal) {
|
|
63
|
+
throw new Error("At most one of `bearerToken` and `appInternal` may be set.");
|
|
64
64
|
}
|
|
65
|
-
return reboot_native.Reboot_createExternalContext(__classPrivateFieldGet(this, _Reboot_external, "f"), ExternalContext.fromNativeExternal, name, options?.idempotencySeed, options?.bearerToken, options?.
|
|
65
|
+
return reboot_native.Reboot_createExternalContext(__classPrivateFieldGet(this, _Reboot_external, "f"), ExternalContext.fromNativeExternal, name, options?.idempotencySeed, options?.bearerToken, options?.appInternal);
|
|
66
66
|
}
|
|
67
67
|
async start() {
|
|
68
68
|
await reboot_native.Reboot_start(__classPrivateFieldGet(this, _Reboot_external, "f"));
|
|
@@ -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 {
|
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.22.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.22.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
|
@@ -437,9 +437,9 @@ Napi::Value Reboot_createExternalContext(const Napi::CallbackInfo& info) {
|
|
|
437
437
|
bearer_token = info[4].As<Napi::String>().Utf8Value();
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
-
|
|
440
|
+
bool app_internal = false;
|
|
441
441
|
if (!info[5].IsUndefined()) {
|
|
442
|
-
|
|
442
|
+
app_internal = info[5].As<Napi::Boolean>();
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
std::promise<py::object*> promise;
|
|
@@ -449,7 +449,7 @@ Napi::Value Reboot_createExternalContext(const Napi::CallbackInfo& info) {
|
|
|
449
449
|
&name,
|
|
450
450
|
&idempotency_seed,
|
|
451
451
|
&bearer_token,
|
|
452
|
-
|
|
452
|
+
app_internal,
|
|
453
453
|
&promise]() {
|
|
454
454
|
py::object py_idempotency_seed = py::none();
|
|
455
455
|
if (idempotency_seed.has_value()) {
|
|
@@ -461,18 +461,13 @@ Napi::Value Reboot_createExternalContext(const Napi::CallbackInfo& info) {
|
|
|
461
461
|
if (bearer_token.has_value()) {
|
|
462
462
|
py_bearer_token = py::str(*bearer_token);
|
|
463
463
|
}
|
|
464
|
-
py::object py_use_internal_api_key_from = py::none();
|
|
465
|
-
if (use_internal_api_key_from.has_value()) {
|
|
466
|
-
py_use_internal_api_key_from = py::str(*use_internal_api_key_from);
|
|
467
|
-
}
|
|
468
464
|
promise.set_value(
|
|
469
465
|
new py::object(
|
|
470
466
|
py_reboot->attr("create_external_context")(
|
|
471
467
|
"name"_a = name,
|
|
472
468
|
"idempotency_seed"_a = py_idempotency_seed,
|
|
473
469
|
"bearer_token"_a = py_bearer_token,
|
|
474
|
-
"
|
|
475
|
-
py_use_internal_api_key_from)));
|
|
470
|
+
"app_internal"_a = app_internal)));
|
|
476
471
|
});
|
|
477
472
|
|
|
478
473
|
py::object* py_context = promise.get_future().get();
|
|
@@ -1264,6 +1259,11 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1264
1259
|
js_token_verifier = NapiSafeReference(info[2].As<Napi::Object>());
|
|
1265
1260
|
}
|
|
1266
1261
|
|
|
1262
|
+
bool local_envoy = false;
|
|
1263
|
+
if (!info[3].IsUndefined()) {
|
|
1264
|
+
local_envoy = info[3].As<Napi::Boolean>();
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
1267
|
auto env = info.Env();
|
|
1268
1268
|
auto servicer_details = make_servicer_details(env, js_servicers);
|
|
1269
1269
|
|
|
@@ -1275,6 +1275,7 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1275
1275
|
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1276
1276
|
py_reboot,
|
|
1277
1277
|
js_token_verifier,
|
|
1278
|
+
local_envoy,
|
|
1278
1279
|
servicer_details = std::move(servicer_details),
|
|
1279
1280
|
deferred = std::move(deferred)]() {
|
|
1280
1281
|
py::list py_servicers = make_py_servicers(servicer_details);
|
|
@@ -1294,7 +1295,7 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1294
1295
|
// clone a process like we do with multiprocessing
|
|
1295
1296
|
// in Python.
|
|
1296
1297
|
"in_process"_a = true,
|
|
1297
|
-
"local_envoy"_a =
|
|
1298
|
+
"local_envoy"_a = local_envoy),
|
|
1298
1299
|
"name"_a = "Reboot.up(...) in nodejs");
|
|
1299
1300
|
|
|
1300
1301
|
py_task.attr("add_done_callback")(py::cpp_function(
|
|
@@ -1475,6 +1476,29 @@ Napi::Value Reboot_stop(const Napi::CallbackInfo& info) {
|
|
|
1475
1476
|
return promise;
|
|
1476
1477
|
}
|
|
1477
1478
|
|
|
1479
|
+
// NOTE: We block on a promise here, so this method should not be called outside
|
|
1480
|
+
// of tests.
|
|
1481
|
+
Napi::Value Reboot_url(const Napi::CallbackInfo& info) {
|
|
1482
|
+
// NOTE: we immediately get a safe reference to the `Napi::External`
|
|
1483
|
+
// so that Node will not garbage collect it and the `py::object*` we
|
|
1484
|
+
// get out of it will remain valid.
|
|
1485
|
+
auto js_external_reboot = NapiSafeReference(
|
|
1486
|
+
info[0].As<Napi::External<py::object>>());
|
|
1487
|
+
|
|
1488
|
+
// CHECK(...CheckTypeTag(...));
|
|
1489
|
+
|
|
1490
|
+
py::object* py_reboot = js_external_reboot.Value(info.Env()).Data();
|
|
1491
|
+
|
|
1492
|
+
std::promise<std::string> promise;
|
|
1493
|
+
|
|
1494
|
+
adaptor->ScheduleCallbackOnPythonEventLoop(
|
|
1495
|
+
[py_reboot, &promise]() {
|
|
1496
|
+
py::str url = py_reboot->attr("url")();
|
|
1497
|
+
promise.set_value(std::string(url));
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
return Napi::String::New(info.Env(), promise.get_future().get());
|
|
1501
|
+
}
|
|
1478
1502
|
|
|
1479
1503
|
Napi::Value Service_constructor(const Napi::CallbackInfo& info) {
|
|
1480
1504
|
Napi::Object js_args = info[0].As<Napi::Object>();
|
|
@@ -1786,14 +1810,6 @@ Napi::Value ExternalContext_constructor(const Napi::CallbackInfo& info) {
|
|
|
1786
1810
|
return py::none();
|
|
1787
1811
|
}
|
|
1788
1812
|
};
|
|
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
1813
|
|
|
1798
1814
|
promise.set_value(
|
|
1799
1815
|
new py::object(py_external.attr("ExternalContext")(
|
|
@@ -2806,6 +2822,10 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
|
2806
2822
|
Napi::String::New(env, "Reboot_down"),
|
|
2807
2823
|
Napi::Function::New<Reboot_down>(env));
|
|
2808
2824
|
|
|
2825
|
+
exports.Set(
|
|
2826
|
+
Napi::String::New(env, "Reboot_url"),
|
|
2827
|
+
Napi::Function::New<Reboot_url>(env));
|
|
2828
|
+
|
|
2809
2829
|
exports.Set(
|
|
2810
2830
|
Napi::String::New(env, "Service_constructor"),
|
|
2811
2831
|
Napi::Function::New<Service_constructor>(env));
|
package/reboot_native.cjs
CHANGED
|
@@ -64,6 +64,7 @@ exports.Reboot_start = reboot_native.exports.Reboot_start;
|
|
|
64
64
|
exports.Reboot_stop = reboot_native.exports.Reboot_stop;
|
|
65
65
|
exports.Reboot_up = reboot_native.exports.Reboot_up;
|
|
66
66
|
exports.Reboot_down = reboot_native.exports.Reboot_down;
|
|
67
|
+
exports.Reboot_url = reboot_native.exports.Reboot_url;
|
|
67
68
|
exports.Context_auth = reboot_native.exports.Context_auth;
|
|
68
69
|
exports.Context_stateId = reboot_native.exports.Context_stateId;
|
|
69
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.22.0";
|
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const REBOOT_VERSION = "0.
|
|
1
|
+
export const REBOOT_VERSION = "0.22.0";
|