@siafoundation/sia-storage 0.0.12 → 0.0.14
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.node.d.ts +39 -4
- package/package.json +10 -9
- package/wasm/sia_storage_wasm.d.ts +67 -32
- package/wasm/sia_storage_wasm.js +203 -252
- package/wasm/sia_storage_wasm_bg.wasm +0 -0
- package/wasm/sia_storage_wasm_bg.wasm.d.ts +7 -7
package/dist/index.node.d.ts
CHANGED
|
@@ -73,7 +73,9 @@ export declare class PackedUpload {
|
|
|
73
73
|
*
|
|
74
74
|
* If the reader errors part-way, it's safe to continue calling
|
|
75
75
|
* [add](Self::add); no object is registered for the failed call. Or call
|
|
76
|
-
* [finalize](Self::finalize) to collect the objects added so far.
|
|
76
|
+
* [finalize](Self::finalize) to collect the objects added so far. Bytes
|
|
77
|
+
* read before the error remain in the current slab as padding and stay
|
|
78
|
+
* counted in [length](Self::length) and [remaining](Self::remaining).
|
|
77
79
|
*
|
|
78
80
|
* ```js
|
|
79
81
|
* const packed = sdk.uploadPacked();
|
|
@@ -83,6 +85,20 @@ export declare class PackedUpload {
|
|
|
83
85
|
* ```
|
|
84
86
|
*/
|
|
85
87
|
add(stream: ReadableStream): Promise<bigint>
|
|
88
|
+
/**
|
|
89
|
+
* Adds a new object to the upload by opening the file at `path`. Behaves
|
|
90
|
+
* like [add](Self::add) otherwise.
|
|
91
|
+
*
|
|
92
|
+
* Prefer this to [add](Self::add) for files on disk: the read stays in
|
|
93
|
+
* Rust instead of streaming each chunk through JS.
|
|
94
|
+
*
|
|
95
|
+
* ```js
|
|
96
|
+
* const packed = sdk.uploadPacked();
|
|
97
|
+
* await packed.addPath("/tmp/photo.jpg");
|
|
98
|
+
* const objects = await packed.finalize();
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
addPath(path: string): Promise<bigint>
|
|
86
102
|
/** Cancels the upload. */
|
|
87
103
|
cancel(): void
|
|
88
104
|
/**
|
|
@@ -125,7 +141,7 @@ export declare class Sdk {
|
|
|
125
141
|
* Creates a new packed upload for efficiently uploading multiple small
|
|
126
142
|
* objects together. Returns a `PackedUpload` handle.
|
|
127
143
|
*/
|
|
128
|
-
uploadPacked(options?:
|
|
144
|
+
uploadPacked(options?: PackedUploadOptions): PackedUpload
|
|
129
145
|
/**
|
|
130
146
|
* Uploads data to the Sia network.
|
|
131
147
|
*
|
|
@@ -135,6 +151,14 @@ export declare class Sdk {
|
|
|
135
151
|
* the previous ID must be updated.
|
|
136
152
|
*/
|
|
137
153
|
upload(object: PinnedObject, stream: ReadableStream, options?: UploadOptions): Promise<PinnedObject>
|
|
154
|
+
/**
|
|
155
|
+
* Uploads the file at `path`. Behaves like [upload](Self::upload)
|
|
156
|
+
* otherwise.
|
|
157
|
+
*
|
|
158
|
+
* Prefer this to [upload](Self::upload) for files on disk: the read stays
|
|
159
|
+
* in Rust instead of streaming each chunk through JS.
|
|
160
|
+
*/
|
|
161
|
+
uploadPath(object: PinnedObject, path: string, options?: UploadOptions): Promise<PinnedObject>
|
|
138
162
|
/**
|
|
139
163
|
* Downloads an object from the Sia network, returning a `ReadableStream`
|
|
140
164
|
* of the object's data.
|
|
@@ -203,7 +227,7 @@ export interface AppMetadata {
|
|
|
203
227
|
|
|
204
228
|
/** Download options. */
|
|
205
229
|
export interface DownloadOptions {
|
|
206
|
-
|
|
230
|
+
maxBufferedChunks?: number
|
|
207
231
|
offset?: bigint
|
|
208
232
|
length?: bigint
|
|
209
233
|
onShardDownloaded?: (progress: ShardProgress) => void
|
|
@@ -237,6 +261,14 @@ export interface ObjectsCursor {
|
|
|
237
261
|
after: Date
|
|
238
262
|
}
|
|
239
263
|
|
|
264
|
+
/** Packed upload options. */
|
|
265
|
+
export interface PackedUploadOptions {
|
|
266
|
+
maxBufferedSlabs?: number
|
|
267
|
+
dataShards?: number
|
|
268
|
+
parityShards?: number
|
|
269
|
+
onShardUploaded?: (progress: ShardProgress) => void
|
|
270
|
+
}
|
|
271
|
+
|
|
240
272
|
/** A sector stored on a specific host. */
|
|
241
273
|
export interface PinnedSector {
|
|
242
274
|
root: string
|
|
@@ -245,6 +277,7 @@ export interface PinnedSector {
|
|
|
245
277
|
|
|
246
278
|
/** A pinned slab from the indexer. */
|
|
247
279
|
export interface PinnedSlab {
|
|
280
|
+
version: number
|
|
248
281
|
id: string
|
|
249
282
|
encryptionKey: Buffer
|
|
250
283
|
minShards: number
|
|
@@ -283,6 +316,7 @@ export interface ShardProgress {
|
|
|
283
316
|
|
|
284
317
|
/** A slab representing a contiguous erasure-coded segment of a file. */
|
|
285
318
|
export interface Slab {
|
|
319
|
+
version: number
|
|
286
320
|
encryptionKey: Buffer
|
|
287
321
|
minShards: number
|
|
288
322
|
sectors: Array<PinnedSector>
|
|
@@ -292,9 +326,10 @@ export interface Slab {
|
|
|
292
326
|
|
|
293
327
|
/** Upload options. */
|
|
294
328
|
export interface UploadOptions {
|
|
295
|
-
|
|
329
|
+
maxBufferedSlabs?: number
|
|
296
330
|
dataShards?: number
|
|
297
331
|
parityShards?: number
|
|
332
|
+
startOffset?: bigint
|
|
298
333
|
onShardUploaded?: (progress: ShardProgress) => void
|
|
299
334
|
}
|
|
300
335
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siafoundation/sia-storage",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"build-wasm": "bun run scripts/build-wasm.ts",
|
|
41
41
|
"setup": "bun run scripts/setup-rust.ts",
|
|
42
42
|
"setup-napi-test": "bun run scripts/setup-napi-test.ts",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
43
44
|
"test": "bun test src/tests/install-integration.test.ts",
|
|
44
45
|
"test:browser": "bun test src/tests/vite-integration.test.ts src/tests/esbuild-integration.test.ts src/tests/webpack-integration.test.ts src/tests/rollup-integration.test.ts src/tests/nextjs-integration.test.ts",
|
|
45
46
|
"test:all": "bun test",
|
|
@@ -47,17 +48,17 @@
|
|
|
47
48
|
"publish-npm": "bun run scripts/publish.ts"
|
|
48
49
|
},
|
|
49
50
|
"optionalDependencies": {
|
|
50
|
-
"@siafoundation/sia-storage-darwin-arm64": "0.0.
|
|
51
|
-
"@siafoundation/sia-storage-darwin-x64": "0.0.
|
|
52
|
-
"@siafoundation/sia-storage-linux-x64-gnu": "0.0.
|
|
53
|
-
"@siafoundation/sia-storage-linux-arm64-gnu": "0.0.
|
|
54
|
-
"@siafoundation/sia-storage-win32-x64-msvc": "0.0.
|
|
51
|
+
"@siafoundation/sia-storage-darwin-arm64": "0.0.14",
|
|
52
|
+
"@siafoundation/sia-storage-darwin-x64": "0.0.14",
|
|
53
|
+
"@siafoundation/sia-storage-linux-x64-gnu": "0.0.14",
|
|
54
|
+
"@siafoundation/sia-storage-linux-arm64-gnu": "0.0.14",
|
|
55
|
+
"@siafoundation/sia-storage-win32-x64-msvc": "0.0.14"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@types/bun": "^1.3.12",
|
|
58
|
-
"@types/node": "^
|
|
59
|
-
"playwright": "^1.
|
|
59
|
+
"@types/node": "^24.13.2",
|
|
60
|
+
"playwright": "^1.60.0",
|
|
60
61
|
"tsup": "^8.4.0",
|
|
61
|
-
"typescript": "
|
|
62
|
+
"typescript": "5.9.3"
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* *This API requires the following crate features to be activated: `ReadableStreamType`*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
type ReadableStreamType = "bytes";
|
|
9
|
+
export type ReadableStreamType = "bytes";
|
|
10
10
|
|
|
11
11
|
export interface DownloadOptions {
|
|
12
|
-
|
|
12
|
+
maxBufferedChunks?: number;
|
|
13
13
|
offset?: number;
|
|
14
14
|
length?: number;
|
|
15
15
|
onShardDownloaded?: (progress: ShardProgress) => void;
|
|
@@ -36,6 +36,7 @@ export interface Sector {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface Slab {
|
|
39
|
+
version: number;
|
|
39
40
|
encryptionKey: string;
|
|
40
41
|
minShards: number;
|
|
41
42
|
offset: number;
|
|
@@ -44,6 +45,7 @@ export interface Slab {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export interface PinnedSlab {
|
|
48
|
+
version: number;
|
|
47
49
|
id: string;
|
|
48
50
|
encryptionKey: string;
|
|
49
51
|
minShards: number;
|
|
@@ -64,7 +66,15 @@ export interface Host {
|
|
|
64
66
|
export interface UploadOptions {
|
|
65
67
|
dataShards?: number;
|
|
66
68
|
parityShards?: number;
|
|
67
|
-
|
|
69
|
+
maxBufferedSlabs?: number;
|
|
70
|
+
startOffset?: bigint;
|
|
71
|
+
onShardUploaded?: (progress: ShardProgress) => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface PackedUploadOptions {
|
|
75
|
+
dataShards?: number;
|
|
76
|
+
parityShards?: number;
|
|
77
|
+
maxBufferedSlabs?: number;
|
|
68
78
|
onShardUploaded?: (progress: ShardProgress) => void;
|
|
69
79
|
}
|
|
70
80
|
|
|
@@ -73,10 +83,24 @@ export interface UploadOptions {
|
|
|
73
83
|
interface Sdk {
|
|
74
84
|
download(object: PinnedObject, options?: DownloadOptions): ReadableStream;
|
|
75
85
|
upload(object: PinnedObject, source: ReadableStream, options?: UploadOptions): Promise<PinnedObject>;
|
|
76
|
-
uploadPacked(options?:
|
|
86
|
+
uploadPacked(options?: PackedUploadOptions): PackedUpload;
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Application info registered with the indexer.
|
|
92
|
+
*/
|
|
93
|
+
export interface App {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
logoUrl: string | undefined;
|
|
98
|
+
serviceUrl: string | undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Information about the user\'s account on the indexer.
|
|
103
|
+
*/
|
|
80
104
|
export interface Account {
|
|
81
105
|
accountKey: string;
|
|
82
106
|
maxPinnedData: number;
|
|
@@ -88,14 +112,33 @@ export interface Account {
|
|
|
88
112
|
lastUsed: Date;
|
|
89
113
|
}
|
|
90
114
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Progress information about a successfully uploaded or downloaded shard.
|
|
117
|
+
*/
|
|
118
|
+
export interface ShardProgress {
|
|
119
|
+
hostKey: string;
|
|
120
|
+
shardSize: number;
|
|
121
|
+
shardIndex: number;
|
|
122
|
+
slabIndex: number;
|
|
123
|
+
/**
|
|
124
|
+
* Elapsed time in milliseconds since the start of the shard upload or download.
|
|
125
|
+
*/
|
|
126
|
+
elapsedMs: number;
|
|
97
127
|
}
|
|
98
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Query parameters for filtering hosts.
|
|
131
|
+
*/
|
|
132
|
+
export interface HostQuery {
|
|
133
|
+
country: string | undefined;
|
|
134
|
+
limit: number | undefined;
|
|
135
|
+
offset: number | undefined;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* TS interface for `Builder::new`\'s `app` parameter. Field names must
|
|
140
|
+
* match the Reflect reads in `helpers::make_app_metadata`.
|
|
141
|
+
*/
|
|
99
142
|
export interface AppMetadata {
|
|
100
143
|
appId: string;
|
|
101
144
|
name: string;
|
|
@@ -105,25 +148,15 @@ export interface AppMetadata {
|
|
|
105
148
|
callbackUrl: string | undefined;
|
|
106
149
|
}
|
|
107
150
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
151
|
+
/**
|
|
152
|
+
* TS interface for `Sdk::objectEvents`\'s `cursor` parameter. Field
|
|
153
|
+
* names must match the Reflect reads in `sdk.rs`.
|
|
154
|
+
*/
|
|
114
155
|
export interface ObjectsCursor {
|
|
115
156
|
id: string;
|
|
116
157
|
after: Date;
|
|
117
158
|
}
|
|
118
159
|
|
|
119
|
-
export interface ShardProgress {
|
|
120
|
-
hostKey: string;
|
|
121
|
-
shardSize: number;
|
|
122
|
-
shardIndex: number;
|
|
123
|
-
slabIndex: number;
|
|
124
|
-
elapsedMs: number;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
160
|
export type SealedObject = SealedObject;
|
|
128
161
|
|
|
129
162
|
|
|
@@ -262,7 +295,9 @@ export class PackedUpload {
|
|
|
262
295
|
*
|
|
263
296
|
* If the reader errors part-way, it's safe to continue calling
|
|
264
297
|
* [add](Self::add); no object is registered for the failed call. Or call
|
|
265
|
-
* [finalize](Self::finalize) to collect the objects added so far.
|
|
298
|
+
* [finalize](Self::finalize) to collect the objects added so far. Bytes
|
|
299
|
+
* read before the error remain in the current slab as padding and stay
|
|
300
|
+
* counted in [length](Self::length) and [remaining](Self::remaining).
|
|
266
301
|
*
|
|
267
302
|
* ```js
|
|
268
303
|
* const packed = sdk.uploadPacked();
|
|
@@ -559,13 +594,13 @@ export interface InitOutput {
|
|
|
559
594
|
readonly intounderlyingsink_write: (a: number, b: any) => any;
|
|
560
595
|
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
561
596
|
readonly intounderlyingsource_pull: (a: number, b: any) => any;
|
|
562
|
-
readonly
|
|
563
|
-
readonly
|
|
564
|
-
readonly
|
|
565
|
-
readonly
|
|
566
|
-
readonly
|
|
567
|
-
readonly
|
|
568
|
-
readonly
|
|
597
|
+
readonly wasm_bindgen_94d9ab53edc6bea3___convert__closures_____invoke___wasm_bindgen_94d9ab53edc6bea3___sys__Undefined__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_94d9ab53edc6bea3___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
598
|
+
readonly wasm_bindgen_94d9ab53edc6bea3___convert__closures_____invoke___wasm_bindgen_94d9ab53edc6bea3___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_94d9ab53edc6bea3___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
599
|
+
readonly wasm_bindgen_94d9ab53edc6bea3___convert__closures_____invoke___wasm_bindgen_94d9ab53edc6bea3___sys__Undefined__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_94d9ab53edc6bea3___JsError___true__3: (a: number, b: number, c: any) => [number, number];
|
|
600
|
+
readonly wasm_bindgen_94d9ab53edc6bea3___convert__closures_____invoke___wasm_bindgen_94d9ab53edc6bea3___sys__Undefined__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_94d9ab53edc6bea3___JsError___true__4: (a: number, b: number, c: any) => [number, number];
|
|
601
|
+
readonly wasm_bindgen_94d9ab53edc6bea3___convert__closures_____invoke___js_sys_2b0a4a9337300fde___Function_fn_wasm_bindgen_94d9ab53edc6bea3___JsValue_____wasm_bindgen_94d9ab53edc6bea3___sys__Undefined___js_sys_2b0a4a9337300fde___Function_fn_wasm_bindgen_94d9ab53edc6bea3___JsValue_____wasm_bindgen_94d9ab53edc6bea3___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
602
|
+
readonly wasm_bindgen_94d9ab53edc6bea3___convert__closures_____invoke___wasm_bindgen_94d9ab53edc6bea3___JsValue______true_: (a: number, b: number, c: any) => void;
|
|
603
|
+
readonly wasm_bindgen_94d9ab53edc6bea3___convert__closures_____invoke_______true_: (a: number, b: number) => void;
|
|
569
604
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
570
605
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
571
606
|
readonly __wbindgen_exn_store: (a: number) => void;
|