@beam-network/sdk 0.2.8 → 0.2.9
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/client.js +5 -0
- package/dist/models.d.ts +5 -13
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -88,6 +88,8 @@ export class BeamClient {
|
|
|
88
88
|
if (!prepared.success) {
|
|
89
89
|
return prepared;
|
|
90
90
|
}
|
|
91
|
+
await input.onPrepared?.(prepared);
|
|
92
|
+
await input.throwIfCancelled?.(prepared.transfer_id);
|
|
91
93
|
const destinationsById = new Map();
|
|
92
94
|
preparedDestinations.forEach((preparedDestination, index) => {
|
|
93
95
|
destinationsById.set(preparedDestination.destination_id, input.destinations[index]);
|
|
@@ -100,6 +102,7 @@ export class BeamClient {
|
|
|
100
102
|
const multipartUploads = new Map();
|
|
101
103
|
try {
|
|
102
104
|
for (const chunk of prepared.chunk_plan) {
|
|
105
|
+
await input.throwIfCancelled?.(prepared.transfer_id);
|
|
103
106
|
for (const target of chunk.destinations) {
|
|
104
107
|
const destination = destinationsById.get(target.destination_id);
|
|
105
108
|
if (!destination) {
|
|
@@ -168,6 +171,7 @@ export class BeamClient {
|
|
|
168
171
|
throw error;
|
|
169
172
|
}
|
|
170
173
|
try {
|
|
174
|
+
await input.throwIfCancelled?.(prepared.transfer_id);
|
|
171
175
|
const attached = await this.attachSignedUrls(prepared.transfer_id, {
|
|
172
176
|
chunkRoutes: routes,
|
|
173
177
|
transferKey: prepared.transfer_key
|
|
@@ -181,6 +185,7 @@ export class BeamClient {
|
|
|
181
185
|
throw error;
|
|
182
186
|
}
|
|
183
187
|
if (input.distribute !== false) {
|
|
188
|
+
await input.throwIfCancelled?.(prepared.transfer_id);
|
|
184
189
|
await this.distributeTransfer(prepared.transfer_id);
|
|
185
190
|
}
|
|
186
191
|
return prepared;
|
package/dist/models.d.ts
CHANGED
|
@@ -104,20 +104,10 @@ export interface DestinationStatusInfo {
|
|
|
104
104
|
}
|
|
105
105
|
export interface TransferStatusInfo {
|
|
106
106
|
transfer_id: string;
|
|
107
|
-
name?: string;
|
|
108
107
|
status: string;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
total_destinations?: number;
|
|
113
|
-
chunks_completed?: number;
|
|
114
|
-
destinations_completed?: number;
|
|
115
|
-
sources?: SourceStatusInfo[];
|
|
116
|
-
destinations?: DestinationStatusInfo[];
|
|
117
|
-
created_at?: string;
|
|
118
|
-
started_at?: string;
|
|
119
|
-
completed_at?: string;
|
|
120
|
-
error_message?: string;
|
|
108
|
+
error_message: string | null;
|
|
109
|
+
started_at: string | null;
|
|
110
|
+
completed_at: string | null;
|
|
121
111
|
}
|
|
122
112
|
export interface S3ProviderConfig {
|
|
123
113
|
provider: "s3";
|
|
@@ -194,6 +184,8 @@ export interface ProviderTransferCreateInput {
|
|
|
194
184
|
* Defaults to true. Set to false to only prepare and attach signed URLs.
|
|
195
185
|
*/
|
|
196
186
|
distribute?: boolean;
|
|
187
|
+
onPrepared?: (prepared: TransferPrepareResponse) => void | Promise<void>;
|
|
188
|
+
throwIfCancelled?: (transferId: string) => void | Promise<void>;
|
|
197
189
|
}
|
|
198
190
|
export interface PreparedHttpSource {
|
|
199
191
|
source_id: string;
|