@beam-network/sdk 0.5.0 → 0.5.1

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/README.md CHANGED
@@ -96,10 +96,14 @@ For low-level raw transfer configs, use `createRawTransfer`; lifecycle transport
96
96
 
97
97
  ## Route Streaming And Payload Size
98
98
 
99
- Provider transfers default to `signed_url_v1` and `transfer-client-control/v3`. S3, R2, and S3-compatible destinations create one final multipart upload per source/destination object, then each route signs direct `UploadPart` to that upload. Core receives per-route completion, abort, ListParts, and final HEAD controls and completes the destination after all winning ETags are known. `signed_url_v2` remains explicitly selectable for the legacy staged-copy manifest path.
99
+ Provider transfers use `transfer-client-control/v5`. Every reply carries Runtime and transport epochs; prepare and every route-stream message carry a UUID route generation. S3, R2, and S3-compatible destinations retain direct multipart UploadPart/ListParts/HEAD handling.
100
100
 
101
101
  The client signs up to 64 routes concurrently by default and emits 2,048-route logical batches, split only when encoded MessagePack requests exceed `maxPayloadBytes` (24 MiB by default). The stream ID derives from the transfer, selected flow, and immutable plan identity, and each ordered batch ID includes its route-coordinate checksum. Manual multi-destination attachment requires `delivery_index` on every route. Lifecycle mutations retry transient failures up to three times with the same request identity. `waitForTransfer` subscribes to the API-key-owned, at-most-once terminal signal before its first status read and reconciles every signal through authoritative status; subscription failure degrades to the same jittered 15-to-30-second status fallback. Call `close()` when the client is no longer needed; it also closes outstanding terminal waiters.
102
102
 
103
103
  Hippius uses genuine non-multipart v2 routes, so its manifest is empty and group-level final HEAD verification is not available from that provider flow.
104
104
 
105
105
  NATS requires this guard because the broker rejects messages above its configured `max_payload`. This limit applies only to lifecycle/control metadata; transfer file bytes do not flow through NATS.
106
+
107
+ ## Restart Recovery
108
+
109
+ The client keeps one in-memory recovery lease per active transfer and one `runtime.hello` monitor per active shard. The lease is installed before route-stream begin, and a per-transfer lock coalesces initial streaming with replay. Multipart recovery retains the existing upload IDs and compact group state, then re-signs only the expiring route and commit controls. A Runtime epoch change invalidates cached auth, coalesces one `transfer.resume`, and regenerates routes under a fresh generation; a transport-only epoch change replays only when Runtime reports routes missing or expired. Provider credentials and signing inputs are retained only in memory and released on terminal status or `close()`. Low-level `attachSignedUrls` requires `routeGenerationId`, the plan fingerprint/checksum, and a `recoveryFactory`; signed URLs are never journaled to disk. Foreground cancellation, deadline expiry, and Runtime state-loss responses keep the background lease and retained multipart upload alive.
package/dist/client.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { AttachSignedUrlsResponse, BeamClientOptions, DistributeResponse, MultipartGroupManifest, PlanningHttpSource, PreparedDestination, PreparedHttpSource, ProviderTransferCreateInput, RawTransferCreateInput, SignedChunkRoute, SignedUrlFlow, TransferCancelResponse, TransferCreateResponse, TransferPlanResponse, TransferPrepareResponse, TransferStatusInfo, TransferTerminalSignalWaiter } from "./models.js";
2
2
  import { BEAM_DEFAULT_NATS_URL } from "./nats-control.js";
3
3
  export { BEAM_DEFAULT_NATS_URL };
4
+ export declare class BeamApiError extends Error {
5
+ readonly status: number;
6
+ readonly body: string;
7
+ constructor(message: string, status: number, body: string);
8
+ }
4
9
  export declare class BeamClient {
5
10
  readonly apiKey: string;
6
11
  readonly natsUrl: string;
@@ -8,8 +13,6 @@ export declare class BeamClient {
8
13
  private readonly control;
9
14
  private readonly routeSigningConcurrency;
10
15
  private readonly routeSigningConcurrencyOverridden;
11
- /** Last credit state Beam reported. Null until the first request or connect. */
12
- get creditStatus(): import("./models.js").CreditStatus | null;
13
16
  constructor(options?: BeamClientOptions);
14
17
  close(): Promise<void>;
15
18
  openTransferTerminalWaiter(transferId: string): Promise<TransferTerminalSignalWaiter>;
@@ -34,11 +37,20 @@ export declare class BeamClient {
34
37
  urlsExpiresAt?: string;
35
38
  signedUrlFlow?: SignedUrlFlow;
36
39
  idempotencyKey?: string;
40
+ routeGenerationId?: string;
37
41
  }): Promise<TransferPrepareResponse>;
38
42
  attachSignedUrls(transferId: string, input: {
39
43
  chunkRoutes: SignedChunkRoute[];
40
44
  multipartGroupManifest: MultipartGroupManifest[];
41
45
  transferKey?: string;
46
+ routeGenerationId: string;
47
+ planFingerprint: string;
48
+ coordinateChecksum: string;
49
+ recoveryFactory: (routeGenerationId: string) => Promise<{
50
+ chunkRoutes: SignedChunkRoute[];
51
+ multipartGroupManifest: MultipartGroupManifest[];
52
+ urlsExpiresAt?: string;
53
+ }>;
42
54
  urlsExpiresAt?: string;
43
55
  autoDistribute?: boolean;
44
56
  }): Promise<AttachSignedUrlsResponse>;