@reboot-dev/reboot 0.32.0 → 0.33.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
@@ -41,6 +41,9 @@ export declare class ExternalContext {
41
41
  get __external(): any;
42
42
  generateIdempotentStateId(stateType: string, serviceName: string, method: string, idempotency: IdempotencyOptions): Promise<string>;
43
43
  }
44
+ export declare class InitializeContext extends ExternalContext {
45
+ static fromNativeExternal(external: any): InitializeContext;
46
+ }
44
47
  export declare function getContext(): Context;
45
48
  export declare function isWithinUntil(): boolean;
46
49
  export declare function isWithinLoop(): boolean;
@@ -199,7 +202,7 @@ export declare class Application {
199
202
  #private;
200
203
  constructor({ servicers, initialize, initializeBearerToken, tokenVerifier, }: {
201
204
  servicers: ServicerFactory[];
202
- initialize?: (context: ExternalContext) => Promise<void>;
205
+ initialize?: (context: InitializeContext) => Promise<void>;
203
206
  initializeBearerToken?: string;
204
207
  tokenVerifier?: TokenVerifier;
205
208
  });
package/index.js CHANGED
@@ -126,6 +126,11 @@ export class ExternalContext {
126
126
  }
127
127
  }
128
128
  _ExternalContext_external = new WeakMap();
129
+ export class InitializeContext extends ExternalContext {
130
+ static fromNativeExternal(external) {
131
+ return new InitializeContext({ external });
132
+ }
133
+ }
129
134
  const contextStorage = new AsyncLocalStorage();
130
135
  export function getContext() {
131
136
  const store = contextStorage.getStore();
@@ -535,7 +540,13 @@ export class Application {
535
540
  return await __classPrivateFieldGet(this, _Application_createExternalContext, "f").call(this, args);
536
541
  }), "f");
537
542
  __classPrivateFieldSet(this, _Application_servers, new Map(), "f");
538
- __classPrivateFieldSet(this, _Application_external, reboot_native.Application_constructor(ExternalContext.fromNativeExternal, servicers, {
543
+ __classPrivateFieldSet(this, _Application_external, reboot_native.Application_constructor((external, kind) => {
544
+ if (kind === "external") {
545
+ return ExternalContext.fromNativeExternal(external);
546
+ }
547
+ assert(kind === "initialize");
548
+ return InitializeContext.fromNativeExternal(external);
549
+ }, servicers, {
539
550
  start: async (consensusId, port, createExternalContext) => {
540
551
  // Store `createExternalContext` function before listening
541
552
  // so we don't attempt to serve any traffic and try and use
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.32.0",
6
+ "@reboot-dev/reboot-api": "0.33.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.32.0",
21
+ "version": "0.33.0",
22
22
  "description": "npm package for Reboot",
23
23
  "scripts": {
24
24
  "preinstall": "node preinstall.cjs",
@@ -41,7 +41,7 @@
41
41
  "protoc-gen-es": "./protoc-gen-es.js"
42
42
  },
43
43
  "engines": {
44
- "node": ">=18.0.0"
44
+ "node": ">=20.10.0"
45
45
  },
46
46
  "engineStrict": true,
47
47
  "gypfile": true,
package/reboot_native.cc CHANGED
@@ -2173,7 +2173,9 @@ Napi::Value Application_constructor(const Napi::CallbackInfo& info) {
2173
2173
  .Value(env)
2174
2174
  .Call(
2175
2175
  env.Global(),
2176
- {js_external_context});
2176
+ {js_external_context,
2177
+ // (check_line_length skip)
2178
+ Napi::String::New(env, "external")});
2177
2179
  });
2178
2180
  });
2179
2181
 
@@ -2236,7 +2238,8 @@ Napi::Value Application_constructor(const Napi::CallbackInfo& info) {
2236
2238
  .Value(env)
2237
2239
  .Call(
2238
2240
  env.Global(),
2239
- {js_external_context})
2241
+ {js_external_context,
2242
+ Napi::String::New(env, "initialize")})
2240
2243
  .As<Napi::Object>();
2241
2244
 
2242
2245
  return js_initialize
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const REBOOT_VERSION = "0.32.0";
1
+ export declare const REBOOT_VERSION = "0.33.0";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const REBOOT_VERSION = "0.32.0";
1
+ export const REBOOT_VERSION = "0.33.0";