@beam-network/sdk 0.5.1 → 0.5.2

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
@@ -98,7 +98,7 @@ For low-level raw transfer configs, use `createRawTransfer`; lifecycle transport
98
98
 
99
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
- 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.
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` (8 MiB by default; explicit positive overrides remain supported). A single route larger than the configured limit fails before publication with both sizes in the error. 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
 
package/dist/client.d.ts CHANGED
@@ -1,5 +1,10 @@
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
+ export declare class BeamRouteRecoveryPendingError extends Error {
4
+ readonly transferId: string;
5
+ readonly cause: unknown;
6
+ constructor(transferId: string, cause: unknown);
7
+ }
3
8
  export { BEAM_DEFAULT_NATS_URL };
4
9
  export declare class BeamApiError extends Error {
5
10
  readonly status: number;
package/dist/client.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import { abortMultipartUpload, createMultipartUpload, expiresAtIso, prepareProviderDestination, prepareProviderSource, signAbortMultipartUpload, signCompleteMultipartUpload, signDeleteObject, signDestinationRoute, signFinalObjectHead, signListMultipartUpload, signListObjects, signUploadPartCopy } from "./provider-signing.js";
2
2
  import { BeamTransferControl, BEAM_DEFAULT_NATS_URL, compactSignedRoutes, isRecoverableRouteStreamError } from "./nats-control.js";
3
+ export class BeamRouteRecoveryPendingError extends Error {
4
+ transferId;
5
+ cause;
6
+ constructor(transferId, cause) {
7
+ super(`Transfer ${transferId} is prepared and route recovery is continuing in the background.`);
8
+ this.name = "BeamRouteRecoveryPendingError";
9
+ this.transferId = transferId;
10
+ this.cause = cause;
11
+ }
12
+ }
3
13
  import { multipartPartNumber } from "./multipart-limits.js";
4
14
  export { BEAM_DEFAULT_NATS_URL };
5
15
  export class BeamApiError extends Error {
@@ -192,10 +202,11 @@ export class BeamClient {
192
202
  return attached;
193
203
  }
194
204
  catch (error) {
195
- if (isRecoverableRouteStreamError(error))
205
+ if (isRecoverableRouteStreamError(error)) {
196
206
  this.control.continueRecoveryLease(transferId);
197
- else
198
- this.control.releaseRecoveryLease(transferId);
207
+ throw new BeamRouteRecoveryPendingError(transferId, error);
208
+ }
209
+ this.control.releaseRecoveryLease(transferId);
199
210
  throw error;
200
211
  }
201
212
  finally {
@@ -381,8 +392,12 @@ export class BeamClient {
381
392
  if (multipartManifestTask)
382
393
  await Promise.allSettled([multipartManifestTask]);
383
394
  if (!recoveryReplay) {
384
- if (foregroundCancelled || isRecoverableRouteStreamError(error)) {
395
+ if (foregroundCancelled) {
396
+ this.control.continueRecoveryLease(prepared.transfer_id);
397
+ }
398
+ else if (isRecoverableRouteStreamError(error)) {
385
399
  this.control.continueRecoveryLease(prepared.transfer_id);
400
+ throw new BeamRouteRecoveryPendingError(prepared.transfer_id, error);
386
401
  }
387
402
  else {
388
403
  this.control.releaseRecoveryLease(prepared.transfer_id);
@@ -5,7 +5,7 @@ export const BEAM_DEFAULT_NATS_URL = "tls://nats.b1m.ai:4222";
5
5
  export const BEAM_DEFAULT_NATS_WS_URL = "wss://nats.b1m.ai:443";
6
6
  // NATS enforces max_payload per message. This guard splits signed-route control
7
7
  // messages before the broker rejects them; transfer bytes never flow through NATS.
8
- export const BEAM_DEFAULT_MAX_PAYLOAD_BYTES = 24 * 1024 * 1024;
8
+ export const BEAM_DEFAULT_MAX_PAYLOAD_BYTES = 8 * 1024 * 1024;
9
9
  export function buildConnectionOptions(options) {
10
10
  const connectionOptions = {
11
11
  servers: options.natsUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beam-network/sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "TypeScript SDK for BEAM transfer creation and management.",
5
5
  "type": "module",
6
6
  "license": "MIT",