@beam-network/sdk 0.5.17-dev.0 → 0.5.17-dev.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 +2 -0
- package/dist/provider-signing.d.ts +5 -3
- package/dist/provider-signing.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,3 +178,5 @@ Only short-lived range/upload routes go to workers. Multipart creation, verifica
|
|
|
178
178
|
`listMultipartParts`, `completeMultipartUpload`, and `inspectDestinationObject` reuse the same provider client and return metadata only. ListParts walks every page; completion submits the selected provider-verified parts. Adapters must durably retain the upload and verified manifest before completion so restart recovery cannot infer delivery from size alone.
|
|
179
179
|
|
|
180
180
|
Manual releases from `dev` require a committed `-dev.N` version and publish only to npm tag `dev`; the stable tag is unchanged.
|
|
181
|
+
|
|
182
|
+
Multipart control helpers (`createMultipartUpload`, `listMultipartParts`, `completeMultipartUpload`, `inspectDestinationObject`, and `abortMultipartUpload`) accept an optional `AbortSignal` and cancel through the existing provider HTTP transport. Pass it as `signal` in object arguments or as the last positional argument. Cancellation stops waiting and network activity; it cannot undo a provider operation already accepted. After an interrupted completion, inspect the durable upload/object identity before retrying or reporting cleanup complete.
|
|
@@ -18,6 +18,7 @@ export declare function createMultipartUpload(input: {
|
|
|
18
18
|
destination: ProviderDestinationConfig;
|
|
19
19
|
objectKey: string;
|
|
20
20
|
metadata: Record<string, string>;
|
|
21
|
+
signal?: AbortSignal;
|
|
21
22
|
}): Promise<string>;
|
|
22
23
|
export declare function signFinalObjectHead(destination: ProviderDestinationConfig, objectKey: string, expiresIn: number): Promise<string>;
|
|
23
24
|
export declare function signCompleteMultipartUpload(destination: ProviderDestinationConfig, objectKey: string, uploadId: string, expiresIn: number): Promise<string>;
|
|
@@ -26,9 +27,9 @@ export declare function signListMultipartUpload(destination: ProviderDestination
|
|
|
26
27
|
maxParts?: number;
|
|
27
28
|
partNumberMarker?: number;
|
|
28
29
|
}): Promise<string>;
|
|
29
|
-
export declare function abortMultipartUpload(destination: ProviderDestinationConfig, objectKey: string, uploadId: string): Promise<void>;
|
|
30
|
+
export declare function abortMultipartUpload(destination: ProviderDestinationConfig, objectKey: string, uploadId: string, signal?: AbortSignal): Promise<void>;
|
|
30
31
|
/** Provider metadata only. These operations never read or proxy object bytes. */
|
|
31
|
-
export declare function listMultipartParts(destination: ProviderDestinationConfig, objectKey: string, uploadId: string): Promise<{
|
|
32
|
+
export declare function listMultipartParts(destination: ProviderDestinationConfig, objectKey: string, uploadId: string, signal?: AbortSignal): Promise<{
|
|
32
33
|
partNumber: number;
|
|
33
34
|
etag: string;
|
|
34
35
|
size: number;
|
|
@@ -41,11 +42,12 @@ export declare function completeMultipartUpload(input: {
|
|
|
41
42
|
partNumber: number;
|
|
42
43
|
etag: string;
|
|
43
44
|
}[];
|
|
45
|
+
signal?: AbortSignal;
|
|
44
46
|
}): Promise<{
|
|
45
47
|
etag: string | undefined;
|
|
46
48
|
versionId: string | undefined;
|
|
47
49
|
}>;
|
|
48
|
-
export declare function inspectDestinationObject(destination: ProviderDestinationConfig, objectKey: string): Promise<{
|
|
50
|
+
export declare function inspectDestinationObject(destination: ProviderDestinationConfig, objectKey: string, signal?: AbortSignal): Promise<{
|
|
49
51
|
size: number | undefined;
|
|
50
52
|
etag: string | undefined;
|
|
51
53
|
versionId: string | undefined;
|
package/dist/provider-signing.js
CHANGED
|
@@ -152,7 +152,7 @@ export async function createMultipartUpload(input) {
|
|
|
152
152
|
Bucket: input.destination.bucket,
|
|
153
153
|
Key: input.objectKey,
|
|
154
154
|
Metadata: input.metadata
|
|
155
|
-
}));
|
|
155
|
+
}), { abortSignal: input.signal });
|
|
156
156
|
if (!response.UploadId) {
|
|
157
157
|
throw new Error(`provider did not return UploadId for ${input.objectKey}`);
|
|
158
158
|
}
|
|
@@ -194,15 +194,15 @@ export async function signListMultipartUpload(destination, objectKey, uploadId,
|
|
|
194
194
|
}
|
|
195
195
|
throw new Error(`multipart list-parts is not supported for ${destination.provider}`);
|
|
196
196
|
}
|
|
197
|
-
export async function abortMultipartUpload(destination, objectKey, uploadId) {
|
|
197
|
+
export async function abortMultipartUpload(destination, objectKey, uploadId, signal) {
|
|
198
198
|
if (isS3CompatibleProvider(destination)) {
|
|
199
|
-
await createS3CompatibleClient(destination).send(new AbortMultipartUploadCommand({ Bucket: destination.bucket, Key: objectKey, UploadId: uploadId }));
|
|
199
|
+
await createS3CompatibleClient(destination).send(new AbortMultipartUploadCommand({ Bucket: destination.bucket, Key: objectKey, UploadId: uploadId }), { abortSignal: signal });
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
throw new Error(`multipart abort is not supported for ${destination.provider}`);
|
|
203
203
|
}
|
|
204
204
|
/** Provider metadata only. These operations never read or proxy object bytes. */
|
|
205
|
-
export async function listMultipartParts(destination, objectKey, uploadId) {
|
|
205
|
+
export async function listMultipartParts(destination, objectKey, uploadId, signal) {
|
|
206
206
|
if (!isS3CompatibleProvider(destination))
|
|
207
207
|
return unsupportedProviderConfig(destination);
|
|
208
208
|
const parts = [];
|
|
@@ -210,7 +210,7 @@ export async function listMultipartParts(destination, objectKey, uploadId) {
|
|
|
210
210
|
do {
|
|
211
211
|
const page = await createS3CompatibleClient(destination).send(new ListPartsCommand({
|
|
212
212
|
Bucket: destination.bucket, Key: objectKey, UploadId: uploadId, MaxParts: 1000, PartNumberMarker: marker
|
|
213
|
-
}));
|
|
213
|
+
}), { abortSignal: signal });
|
|
214
214
|
for (const part of page.Parts ?? []) {
|
|
215
215
|
if (!part.PartNumber || !part.ETag || !Number.isSafeInteger(part.Size))
|
|
216
216
|
throw new Error("invalid multipart part metadata");
|
|
@@ -230,13 +230,13 @@ export async function completeMultipartUpload(input) {
|
|
|
230
230
|
Bucket: input.destination.bucket, Key: input.objectKey, UploadId: input.uploadId,
|
|
231
231
|
MultipartUpload: { Parts: [...input.parts].sort((a, b) => a.partNumber - b.partNumber)
|
|
232
232
|
.map((part) => ({ PartNumber: part.partNumber, ETag: part.etag })) }
|
|
233
|
-
}));
|
|
233
|
+
}), { abortSignal: input.signal });
|
|
234
234
|
return { etag: result.ETag, versionId: result.VersionId };
|
|
235
235
|
}
|
|
236
|
-
export async function inspectDestinationObject(destination, objectKey) {
|
|
236
|
+
export async function inspectDestinationObject(destination, objectKey, signal) {
|
|
237
237
|
if (!isS3CompatibleProvider(destination))
|
|
238
238
|
return unsupportedProviderConfig(destination);
|
|
239
|
-
const result = await createS3CompatibleClient(destination).send(new HeadObjectCommand({ Bucket: destination.bucket, Key: objectKey }));
|
|
239
|
+
const result = await createS3CompatibleClient(destination).send(new HeadObjectCommand({ Bucket: destination.bucket, Key: objectKey }), { abortSignal: signal });
|
|
240
240
|
return { size: result.ContentLength, etag: result.ETag, versionId: result.VersionId, metadata: result.Metadata ?? {} };
|
|
241
241
|
}
|
|
242
242
|
export async function signDestinationRoute(input) {
|