@reboot-dev/reboot 0.31.0 → 0.32.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/index.d.ts CHANGED
@@ -54,6 +54,8 @@ export declare class Context {
54
54
  get __external(): any;
55
55
  get auth(): Auth | null;
56
56
  get stateId(): string;
57
+ get stateTypeName(): string;
58
+ get method(): string;
57
59
  get callerBearerToken(): string | null;
58
60
  get cookie(): string;
59
61
  get appInternal(): boolean;
package/index.js CHANGED
@@ -9,8 +9,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Reboot_external, _ExternalContext_external, _a, _Context_external, _Context_isInternalConstructing, _Context_stateId, _ReaderContext_kind, _WriterContext_kind, _TransactionContext_kind, _WorkflowContext_kind, _Application_servicers, _Application_tokenVerifier, _Application_express, _Application_http, _Application_servers, _Application_createExternalContext, _Application_external;
13
- import { auth_pb, errors_pb, protobuf_es, tasks_pb, } from "@reboot-dev/reboot-api";
12
+ var _Reboot_external, _ExternalContext_external, _a, _Context_external, _Context_isInternalConstructing, _Context_stateId, _Context_method, _Context_stateTypeName, _ReaderContext_kind, _WriterContext_kind, _TransactionContext_kind, _WorkflowContext_kind, _Application_servicers, _Application_tokenVerifier, _Application_express, _Application_http, _Application_servers, _Application_createExternalContext, _Application_external;
13
+ import { auth_pb, errors_pb, protobuf_es, toCamelCase, tasks_pb, } from "@reboot-dev/reboot-api";
14
14
  import { strict as assert } from "assert";
15
15
  import { AsyncLocalStorage } from "node:async_hooks";
16
16
  import { fork } from "node:child_process";
@@ -166,6 +166,8 @@ export class Context {
166
166
  constructor(external, cancelled) {
167
167
  _Context_external.set(this, void 0);
168
168
  _Context_stateId.set(this, void 0);
169
+ _Context_method.set(this, void 0);
170
+ _Context_stateTypeName.set(this, void 0);
169
171
  if (!__classPrivateFieldGet(_a, _a, "f", _Context_isInternalConstructing)) {
170
172
  throw new TypeError("Context is not publicly constructable");
171
173
  }
@@ -205,6 +207,18 @@ export class Context {
205
207
  }
206
208
  return __classPrivateFieldGet(this, _Context_stateId, "f");
207
209
  }
210
+ get stateTypeName() {
211
+ if (__classPrivateFieldGet(this, _Context_stateTypeName, "f") === undefined) {
212
+ __classPrivateFieldSet(this, _Context_stateTypeName, reboot_native.Context_stateTypeName(__classPrivateFieldGet(this, _Context_external, "f")), "f");
213
+ }
214
+ return __classPrivateFieldGet(this, _Context_stateTypeName, "f");
215
+ }
216
+ get method() {
217
+ if (__classPrivateFieldGet(this, _Context_method, "f") === undefined) {
218
+ __classPrivateFieldSet(this, _Context_method, toCamelCase(reboot_native.Context_method(__classPrivateFieldGet(this, _Context_external, "f"))), "f");
219
+ }
220
+ return __classPrivateFieldGet(this, _Context_method, "f");
221
+ }
208
222
  get callerBearerToken() {
209
223
  return reboot_native.Context_callerBearerToken(__classPrivateFieldGet(this, _Context_external, "f"));
210
224
  }
@@ -218,7 +232,7 @@ export class Context {
218
232
  return reboot_native.Context_generateIdempotentStateId(__classPrivateFieldGet(this, _Context_external, "f"), stateType, serviceName, method, idempotency);
219
233
  }
220
234
  }
221
- _a = Context, _Context_external = new WeakMap(), _Context_stateId = new WeakMap();
235
+ _a = Context, _Context_external = new WeakMap(), _Context_stateId = new WeakMap(), _Context_method = new WeakMap(), _Context_stateTypeName = new WeakMap();
222
236
  _Context_isInternalConstructing = { value: false };
223
237
  export class ReaderContext extends Context {
224
238
  constructor(external, cancelled) {
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.31.0",
6
+ "@reboot-dev/reboot-api": "0.32.0",
7
7
  "chalk": "^4.1.2",
8
8
  "node-addon-api": "^7.0.0",
9
9
  "node-gyp": ">=10.2.0",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "type": "module",
20
20
  "name": "@reboot-dev/reboot",
21
- "version": "0.31.0",
21
+ "version": "0.32.0",
22
22
  "description": "npm package for Reboot",
23
23
  "scripts": {
24
24
  "preinstall": "node preinstall.cjs",
package/reboot_native.cc CHANGED
@@ -2374,6 +2374,43 @@ Napi::Value Context_stateId(const Napi::CallbackInfo& info) {
2374
2374
  return Napi::String::New(info.Env(), state_id);
2375
2375
  }
2376
2376
 
2377
+
2378
+ Napi::Value Context_stateTypeName(const Napi::CallbackInfo& info) {
2379
+ Napi::External<py::object> js_external_context =
2380
+ info[0].As<Napi::External<py::object>>();
2381
+
2382
+ // CHECK(...CheckTypeTag(...));
2383
+
2384
+ py::object* py_context = js_external_context.Data();
2385
+
2386
+ std::string state_type_name = RunCallbackOnPythonEventLoop(
2387
+ [py_context]() {
2388
+ py::str state_type_name = py_context->attr("state_type_name");
2389
+ return std::string(state_type_name);
2390
+ });
2391
+
2392
+ return Napi::String::New(info.Env(), state_type_name);
2393
+ }
2394
+
2395
+
2396
+ Napi::Value Context_method(const Napi::CallbackInfo& info) {
2397
+ Napi::External<py::object> js_external_context =
2398
+ info[0].As<Napi::External<py::object>>();
2399
+
2400
+ // CHECK(...CheckTypeTag(...));
2401
+
2402
+ py::object* py_context = js_external_context.Data();
2403
+
2404
+ std::string method = RunCallbackOnPythonEventLoop(
2405
+ [py_context]() {
2406
+ py::str method = py_context->attr("method");
2407
+ return std::string(method);
2408
+ });
2409
+
2410
+ return Napi::String::New(info.Env(), method);
2411
+ }
2412
+
2413
+
2377
2414
  Napi::Value Context_callerBearerToken(
2378
2415
  const Napi::CallbackInfo& info) {
2379
2416
  Napi::External<py::object> js_external_context =
@@ -2879,6 +2916,14 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
2879
2916
  Napi::String::New(env, "Context_stateId"),
2880
2917
  Napi::Function::New<Context_stateId>(env));
2881
2918
 
2919
+ exports.Set(
2920
+ Napi::String::New(env, "Context_stateTypeName"),
2921
+ Napi::Function::New<Context_stateTypeName>(env));
2922
+
2923
+ exports.Set(
2924
+ Napi::String::New(env, "Context_method"),
2925
+ Napi::Function::New<Context_method>(env));
2926
+
2882
2927
  exports.Set(
2883
2928
  Napi::String::New(env, "Context_callerBearerToken"),
2884
2929
  Napi::Function::New<Context_callerBearerToken>(env));
package/reboot_native.cjs CHANGED
@@ -76,6 +76,8 @@ exports.Reboot_down = reboot_native.exports.Reboot_down;
76
76
  exports.Reboot_url = reboot_native.exports.Reboot_url;
77
77
  exports.Context_auth = reboot_native.exports.Context_auth;
78
78
  exports.Context_stateId = reboot_native.exports.Context_stateId;
79
+ exports.Context_stateTypeName = reboot_native.exports.Context_stateTypeName;
80
+ exports.Context_method = reboot_native.exports.Context_method;
79
81
  exports.Context_callerBearerToken =
80
82
  reboot_native.exports.Context_callerBearerToken;
81
83
  exports.Context_cookie = reboot_native.exports.Context_cookie;
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const REBOOT_VERSION = "0.31.0";
1
+ export declare const REBOOT_VERSION = "0.32.0";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const REBOOT_VERSION = "0.31.0";
1
+ export const REBOOT_VERSION = "0.32.0";