@tool-bridge/server 0.26.2 → 0.28.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/dist/index.d.ts CHANGED
@@ -1764,6 +1764,9 @@ declare class BootstrapStateStore {
1764
1764
  write(name: string, value: unknown): Promise<void>;
1765
1765
  state(): Promise<BootstrapState | undefined>;
1766
1766
  initialize(): Promise<BootstrapState>;
1767
+ /** Keep bootstrap reads, including the first initialization, locked through admission. */
1768
+ withStartupState(initializedInstanceId: string | undefined, admit: (state: BootstrapState) => Promise<void>): Promise<void>;
1769
+ private readOrInitialize;
1767
1770
  private pair;
1768
1771
  createLocalPairing(mode: Pairing['mode']): Promise<string>;
1769
1772
  private hash;
@@ -2327,6 +2330,7 @@ interface ManagedServerOptions {
2327
2330
  declare function createManagedServer(options: ManagedServerOptions): Promise<{
2328
2331
  app: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
2329
2332
  store: BootstrapStateStore;
2333
+ ownershipLost: AbortSignal;
2330
2334
  start(): Promise<{
2331
2335
  port: number;
2332
2336
  }>;
@@ -2632,6 +2636,6 @@ interface TbServer {
2632
2636
  state: StateStore;
2633
2637
  storage: StorageManager;
2634
2638
  }
2635
- declare function createTbServer(config: ServerConfig): TbServer;
2639
+ declare function createTbServer(config: ServerConfig, onOwnershipLost?: () => void): TbServer;
2636
2640
 
2637
2641
  export { BootstrapStateStore, DEVICE_FORWARD_TIMEOUT_MS, DEVICE_ROUTE_TTL_SEC, DEVICE_WS_PATH, DeviceHub, type DeviceLocalCall, DeviceRouter, type DeviceRouterBackend, type KeyManagementHooks, KeyManager, type MaintenanceHooks, MaintenanceManager, type ManagedServerOptions, PgEventRepository, PgKeyRotation, PgMailboxRepository, PgSearchIndex, PgStateStore, PgStoreRepository, RedisDeviceRouterBackend, type S3ObjectStore, type S3ObjectStoreOptions, type S3ProbeResult, type ServerConfig, StorageManager, type TbServer, createManagedServer, createS3ObjectStore, createTbServer, probeS3ObjectStore, runtimeAppSettings };
package/dist/index.js CHANGED
@@ -19,11 +19,11 @@ import {
19
19
  createTbServer,
20
20
  probeS3ObjectStore,
21
21
  runtimeAppSettings
22
- } from "./chunk-VKZYPURU.js";
22
+ } from "./chunk-WR4IHUDC.js";
23
23
  import "./chunk-U7PTOA3U.js";
24
24
  import {
25
25
  BootstrapStateStore
26
- } from "./chunk-KTWFYFDL.js";
26
+ } from "./chunk-A5VV3P2S.js";
27
27
  import "./chunk-NXLE6ZEK.js";
28
28
  import "./chunk-6W5WJCKR.js";
29
29
  import "./chunk-4WDQGEOC.js";
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createManagedServer
4
- } from "./chunk-VKZYPURU.js";
4
+ } from "./chunk-WR4IHUDC.js";
5
5
  import "./chunk-U7PTOA3U.js";
6
6
  import {
7
7
  package_default
8
- } from "./chunk-KTWFYFDL.js";
8
+ } from "./chunk-A5VV3P2S.js";
9
9
  import "./chunk-NXLE6ZEK.js";
10
10
  import "./chunk-6W5WJCKR.js";
11
11
  import "./chunk-4WDQGEOC.js";
@@ -51,12 +51,14 @@ var program = new Command("tool-bridge-server").version(package_default.version)
51
51
  stopping = true;
52
52
  console.log(JSON.stringify({ event: "tool_bridge_draining" }));
53
53
  void server.shutdown().then(
54
- () => process.exit(0),
54
+ () => process.exit(server.ownershipLost.aborted ? 1 : 0),
55
55
  () => process.exit(1)
56
56
  );
57
57
  };
58
58
  process.on("SIGINT", shutdown);
59
59
  process.on("SIGTERM", shutdown);
60
+ server.ownershipLost.addEventListener("abort", shutdown, { once: true });
61
+ if (server.ownershipLost.aborted) shutdown();
60
62
  });
61
63
  try {
62
64
  await program.parseAsync();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tool-bridge/server",
3
- "version": "0.26.2",
3
+ "version": "0.28.0",
4
4
  "description": "Self-hosted Tool Bridge Node server with PostgreSQL, S3 object storage and WebSocket device channels",
5
5
  "type": "module",
6
6
  "license": "MIT",