@mountra/mountra-sdk 0.1.0 → 0.2.0
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/CHANGELOG.md +19 -0
- package/README.md +62 -2
- package/dist/index.cjs +965 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +211 -1
- package/dist/index.d.ts +211 -1
- package/dist/index.js +960 -12
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,202 @@
|
|
|
1
|
+
interface FileSystemWritableFileStreamLike {
|
|
2
|
+
write(data: Uint8Array | Blob): Promise<void>;
|
|
3
|
+
seek(position: number): Promise<void>;
|
|
4
|
+
truncate(size: number): Promise<void>;
|
|
5
|
+
close(): Promise<void>;
|
|
6
|
+
abort?(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
interface FileSystemFileHandleLike {
|
|
9
|
+
readonly kind?: "file";
|
|
10
|
+
readonly name?: string;
|
|
11
|
+
createWritable(options?: {
|
|
12
|
+
keepExistingData?: boolean;
|
|
13
|
+
}): Promise<FileSystemWritableFileStreamLike>;
|
|
14
|
+
isSameEntry?(other: FileSystemFileHandleLike): Promise<boolean>;
|
|
15
|
+
queryPermission?(descriptor?: {
|
|
16
|
+
mode?: "read" | "readwrite";
|
|
17
|
+
}): Promise<PermissionState>;
|
|
18
|
+
requestPermission?(descriptor?: {
|
|
19
|
+
mode?: "read" | "readwrite";
|
|
20
|
+
}): Promise<PermissionState>;
|
|
21
|
+
}
|
|
22
|
+
interface ExportFileOptions extends WorkspaceSelector {
|
|
23
|
+
path?: string;
|
|
24
|
+
ino?: number | string;
|
|
25
|
+
timeout?: number;
|
|
26
|
+
contentDisposition?: string;
|
|
27
|
+
downloadFilename?: string;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
interface ExportFileChunk {
|
|
31
|
+
index: number;
|
|
32
|
+
offset: number;
|
|
33
|
+
size: number;
|
|
34
|
+
storageKey: string;
|
|
35
|
+
url: string;
|
|
36
|
+
}
|
|
37
|
+
interface ExportFileResponse {
|
|
38
|
+
path: string;
|
|
39
|
+
storageKey: string;
|
|
40
|
+
url: string;
|
|
41
|
+
timeout: number;
|
|
42
|
+
size: number;
|
|
43
|
+
contentType?: string;
|
|
44
|
+
chunkMethod?: string;
|
|
45
|
+
isFastPath?: boolean;
|
|
46
|
+
chunks?: ExportFileChunk[];
|
|
47
|
+
}
|
|
48
|
+
interface DownloadProgress {
|
|
49
|
+
phase: "downloading" | "retrying" | "completed";
|
|
50
|
+
downloadedBytes: number;
|
|
51
|
+
totalBytes: number;
|
|
52
|
+
downloadedChunks: number;
|
|
53
|
+
totalChunks: number;
|
|
54
|
+
currentChunkIndex?: number;
|
|
55
|
+
speedBytesPerSecond: number;
|
|
56
|
+
estimatedRemainingSeconds?: number;
|
|
57
|
+
elapsedMs: number;
|
|
58
|
+
retryCount: number;
|
|
59
|
+
}
|
|
60
|
+
interface DownloadFileOptions extends ExportFileOptions {
|
|
61
|
+
/** Prefer File System Access API when available. Defaults to true. */
|
|
62
|
+
preferFileSystemAccess?: boolean;
|
|
63
|
+
/** Continue a matching IndexedDB checkpoint when the selected file is the same entry. */
|
|
64
|
+
resume?: boolean;
|
|
65
|
+
maxRetries?: number;
|
|
66
|
+
retryDelayMs?: number;
|
|
67
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
68
|
+
/** Use a previously selected file handle, primarily for resumeDownload. */
|
|
69
|
+
fileHandle?: FileSystemFileHandleLike;
|
|
70
|
+
}
|
|
71
|
+
interface DownloadResumeOptions {
|
|
72
|
+
signal?: AbortSignal;
|
|
73
|
+
maxRetries?: number;
|
|
74
|
+
retryDelayMs?: number;
|
|
75
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
76
|
+
}
|
|
77
|
+
interface DownloadResult {
|
|
78
|
+
export: ExportFileResponse;
|
|
79
|
+
downloadKey: string;
|
|
80
|
+
downloadedBytes: number;
|
|
81
|
+
resumed: boolean;
|
|
82
|
+
fileHandle?: FileSystemFileHandleLike;
|
|
83
|
+
blob?: Blob;
|
|
84
|
+
}
|
|
85
|
+
interface DownloadCheckpointChunk {
|
|
86
|
+
index: number;
|
|
87
|
+
offset: number;
|
|
88
|
+
size: number;
|
|
89
|
+
storageKey: string;
|
|
90
|
+
downloadedBytes: number;
|
|
91
|
+
completed: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface DownloadCheckpointRequest {
|
|
94
|
+
workspaceCuid?: string;
|
|
95
|
+
workspaceId?: number | string;
|
|
96
|
+
path?: string;
|
|
97
|
+
ino?: number | string;
|
|
98
|
+
timeout?: number;
|
|
99
|
+
contentDisposition?: string;
|
|
100
|
+
downloadFilename?: string;
|
|
101
|
+
}
|
|
102
|
+
interface DownloadCheckpoint {
|
|
103
|
+
version: 1;
|
|
104
|
+
key: string;
|
|
105
|
+
requestKey: string;
|
|
106
|
+
request: DownloadCheckpointRequest;
|
|
107
|
+
path: string;
|
|
108
|
+
size: number;
|
|
109
|
+
chunks: DownloadCheckpointChunk[];
|
|
110
|
+
fileHandle?: FileSystemFileHandleLike;
|
|
111
|
+
updatedAt: number;
|
|
112
|
+
}
|
|
113
|
+
interface DownloadCheckpointStore {
|
|
114
|
+
load(key: string): Promise<DownloadCheckpoint | null>;
|
|
115
|
+
save(key: string, checkpoint: DownloadCheckpoint): Promise<void>;
|
|
116
|
+
remove(key: string): Promise<void>;
|
|
117
|
+
list(): Promise<DownloadCheckpoint[]>;
|
|
118
|
+
}
|
|
119
|
+
declare class InMemoryDownloadCheckpointStore implements DownloadCheckpointStore {
|
|
120
|
+
private readonly records;
|
|
121
|
+
load(key: string): Promise<DownloadCheckpoint | null>;
|
|
122
|
+
save(key: string, checkpoint: DownloadCheckpoint): Promise<void>;
|
|
123
|
+
remove(key: string): Promise<void>;
|
|
124
|
+
list(): Promise<DownloadCheckpoint[]>;
|
|
125
|
+
}
|
|
126
|
+
declare class IndexedDBDownloadCheckpointStore implements DownloadCheckpointStore {
|
|
127
|
+
private readonly fallback;
|
|
128
|
+
private databasePromise?;
|
|
129
|
+
load(key: string): Promise<DownloadCheckpoint | null>;
|
|
130
|
+
save(key: string, checkpoint: DownloadCheckpoint): Promise<void>;
|
|
131
|
+
remove(key: string): Promise<void>;
|
|
132
|
+
list(): Promise<DownloadCheckpoint[]>;
|
|
133
|
+
private openDatabase;
|
|
134
|
+
private request;
|
|
135
|
+
}
|
|
136
|
+
declare class DownloadHttpError extends Error {
|
|
137
|
+
readonly status: number;
|
|
138
|
+
constructor(status: number, message: string);
|
|
139
|
+
}
|
|
140
|
+
interface DownloadTransport {
|
|
141
|
+
readonly baseUrl: string;
|
|
142
|
+
readonly clientSelector: WorkspaceSelector;
|
|
143
|
+
readonly fetchImpl: typeof globalThis.fetch;
|
|
144
|
+
readonly checkpointStore: DownloadCheckpointStore;
|
|
145
|
+
requestJson(path: string, body: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
146
|
+
}
|
|
147
|
+
declare class MountraDownloader {
|
|
148
|
+
private readonly transport;
|
|
149
|
+
constructor(transport: DownloadTransport);
|
|
150
|
+
exportFile(options: ExportFileOptions): Promise<ExportFileResponse>;
|
|
151
|
+
downloadFile(options: DownloadFileOptions): Promise<DownloadResult>;
|
|
152
|
+
downloadExport(exported: ExportFileResponse, options?: DownloadFileOptions): Promise<DownloadResult>;
|
|
153
|
+
resumeDownload(downloadKey: string, options?: DownloadResumeOptions): Promise<DownloadResult>;
|
|
154
|
+
listResumableDownloads(): Promise<DownloadCheckpoint[]>;
|
|
155
|
+
clearDownloadCheckpoint(downloadKey: string): Promise<void>;
|
|
156
|
+
private pickSaveFile;
|
|
157
|
+
private ensureWritePermission;
|
|
158
|
+
private downloadResolved;
|
|
159
|
+
private consumeResponse;
|
|
160
|
+
private consumeBytes;
|
|
161
|
+
private isSameFileHandle;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type MountraFileTarget = {
|
|
165
|
+
path: string;
|
|
166
|
+
ino?: never;
|
|
167
|
+
} | {
|
|
168
|
+
path?: never;
|
|
169
|
+
ino: number | string;
|
|
170
|
+
};
|
|
171
|
+
/** A file identity accepted by `MountraClient.file()`. */
|
|
172
|
+
type MountraFileLocator = WorkspaceSelector & Partial<{
|
|
173
|
+
wsid: WorkspaceId;
|
|
174
|
+
}> & MountraFileTarget;
|
|
175
|
+
type NormalizedMountraFileLocator = WorkspaceSelector & MountraFileTarget;
|
|
176
|
+
/** Options for exporting an already identified Mountra file. */
|
|
177
|
+
type MountraFileExportOptions = Omit<ExportFileOptions, "workspaceCuid" | "workspaceId" | "path" | "ino">;
|
|
178
|
+
/** Options for downloading an already identified Mountra file. */
|
|
179
|
+
type MountraFileDownloadOptions = Omit<DownloadFileOptions, "workspaceCuid" | "workspaceId" | "path" | "ino">;
|
|
180
|
+
interface MountraFileResumeOptions extends DownloadResumeOptions {
|
|
181
|
+
/** Select a particular checkpoint; otherwise the newest matching one is used. */
|
|
182
|
+
downloadKey?: string;
|
|
183
|
+
}
|
|
184
|
+
/** A stable resource object for one file in one Mountra workspace. */
|
|
185
|
+
declare class MountraFile {
|
|
186
|
+
private readonly client;
|
|
187
|
+
readonly locator: Readonly<NormalizedMountraFileLocator>;
|
|
188
|
+
constructor(client: MountraClient, locator: NormalizedMountraFileLocator);
|
|
189
|
+
get workspaceCuid(): string | undefined;
|
|
190
|
+
get workspaceId(): WorkspaceId | undefined;
|
|
191
|
+
/** `wsid` is the short alias used by the file-object API. */
|
|
192
|
+
get wsid(): WorkspaceId | undefined;
|
|
193
|
+
get path(): string | undefined;
|
|
194
|
+
get ino(): number | string | undefined;
|
|
195
|
+
export(options?: MountraFileExportOptions): Promise<ExportFileResponse>;
|
|
196
|
+
download(options?: MountraFileDownloadOptions): Promise<DownloadResult>;
|
|
197
|
+
resume(options?: MountraFileResumeOptions): Promise<DownloadResult>;
|
|
198
|
+
}
|
|
199
|
+
|
|
1
200
|
type ChunkMethod = "none" | "fix";
|
|
2
201
|
type WorkspaceId = number | string;
|
|
3
202
|
declare const JUMBO_CHUNK_THRESHOLD_BYTES: number;
|
|
@@ -24,6 +223,8 @@ interface MountraClientOptions extends WorkspaceSelector {
|
|
|
24
223
|
jumboChunkCheckpointStore?: JumboChunkCheckpointStore;
|
|
25
224
|
/** S3 Multipart part size. Defaults to 16 MiB. */
|
|
26
225
|
jumboPartSize?: number;
|
|
226
|
+
/** IndexedDB-backed download checkpoint store. */
|
|
227
|
+
downloadCheckpointStore?: DownloadCheckpointStore;
|
|
27
228
|
}
|
|
28
229
|
interface UploadFileOptions extends WorkspaceSelector {
|
|
29
230
|
path: string;
|
|
@@ -283,7 +484,16 @@ declare class MountraClient {
|
|
|
283
484
|
private readonly jumboChunkUploader?;
|
|
284
485
|
private readonly jumboChunkCheckpointStore;
|
|
285
486
|
private readonly jumboPartSize;
|
|
487
|
+
private readonly downloader;
|
|
286
488
|
constructor(options: MountraClientOptions);
|
|
489
|
+
exportFile(options: ExportFileOptions): Promise<ExportFileResponse>;
|
|
490
|
+
downloadFile(options: DownloadFileOptions): Promise<DownloadResult>;
|
|
491
|
+
downloadExport(exported: ExportFileResponse, options?: DownloadFileOptions): Promise<DownloadResult>;
|
|
492
|
+
resumeDownload(downloadKey: string, options?: DownloadResumeOptions): Promise<DownloadResult>;
|
|
493
|
+
listResumableDownloads(): Promise<DownloadCheckpoint[]>;
|
|
494
|
+
clearDownloadCheckpoint(downloadKey: string): Promise<void>;
|
|
495
|
+
/** Create a stable resource object for one file in this or another workspace. */
|
|
496
|
+
file(locator: MountraFileLocator): MountraFile;
|
|
287
497
|
prepareUpload(file: Blob, options: UploadFileOptions): Promise<PreparedUpload>;
|
|
288
498
|
uploadFile(file: Blob, options: UploadFileOptions): Promise<UploadResult>;
|
|
289
499
|
/** Generic upload entry point. It selects PUT or S3 Multipart per chunk. */
|
|
@@ -306,4 +516,4 @@ declare class MountraClient {
|
|
|
306
516
|
}
|
|
307
517
|
declare function createMountraClient(options: MountraClientOptions): MountraClient;
|
|
308
518
|
|
|
309
|
-
export { type AccessToken, type ChunkMethod, DEFAULT_S3_MULTIPART_PART_SIZE_BYTES, type FileChunk, type FinishUploadResponse, InMemoryJumboChunkCheckpointStore, JUMBO_CHUNK_THRESHOLD_BYTES, type JumboChunkCheckpoint, type JumboChunkCheckpointStore, type JumboChunkCompleteInput, type JumboChunkCreateInput, type JumboChunkUploadPartInput, type JumboChunkUploader, LocalStorageJumboChunkCheckpointStore, MAX_S3_MULTIPART_PARTS, MIN_S3_MULTIPART_PART_SIZE_BYTES, MountraApiError, MountraClient, type MountraClientOptions, type MountraProgress, MountraClient as MountraSDK, type PrepareUploadResponse, type PreparedUpload, type S3MultipartClient, type S3MultipartPart, S3MultipartUploader, type UploadFileOptions, type UploadResult, type UploadResumeOptions, type UploadSessionChunkContext, type UploadSessionContext, type UploadStatusChunk, type UploadStatusResponse, type UploadTarget, type WorkspaceId, type WorkspaceSelector, createMountraClient, isJumboChunk, sha256Hex, splitFileIntoChunks };
|
|
519
|
+
export { type AccessToken, type ChunkMethod, DEFAULT_S3_MULTIPART_PART_SIZE_BYTES, type DownloadCheckpoint, type DownloadCheckpointChunk, type DownloadCheckpointRequest, type DownloadCheckpointStore, type DownloadFileOptions, DownloadHttpError, type DownloadProgress, type DownloadResult, type DownloadResumeOptions, type ExportFileChunk, type ExportFileOptions, type ExportFileResponse, type FileChunk, type FileSystemFileHandleLike, type FileSystemWritableFileStreamLike, type FinishUploadResponse, InMemoryDownloadCheckpointStore, InMemoryJumboChunkCheckpointStore, IndexedDBDownloadCheckpointStore, JUMBO_CHUNK_THRESHOLD_BYTES, type JumboChunkCheckpoint, type JumboChunkCheckpointStore, type JumboChunkCompleteInput, type JumboChunkCreateInput, type JumboChunkUploadPartInput, type JumboChunkUploader, LocalStorageJumboChunkCheckpointStore, MAX_S3_MULTIPART_PARTS, MIN_S3_MULTIPART_PART_SIZE_BYTES, MountraApiError, MountraClient, type MountraClientOptions, MountraDownloader, MountraFile, type MountraFileDownloadOptions, type MountraFileExportOptions, type MountraFileLocator, type MountraFileResumeOptions, type MountraProgress, MountraClient as MountraSDK, type NormalizedMountraFileLocator, type PrepareUploadResponse, type PreparedUpload, type S3MultipartClient, type S3MultipartPart, S3MultipartUploader, type UploadFileOptions, type UploadResult, type UploadResumeOptions, type UploadSessionChunkContext, type UploadSessionContext, type UploadStatusChunk, type UploadStatusResponse, type UploadTarget, type WorkspaceId, type WorkspaceSelector, createMountraClient, isJumboChunk, sha256Hex, splitFileIntoChunks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,202 @@
|
|
|
1
|
+
interface FileSystemWritableFileStreamLike {
|
|
2
|
+
write(data: Uint8Array | Blob): Promise<void>;
|
|
3
|
+
seek(position: number): Promise<void>;
|
|
4
|
+
truncate(size: number): Promise<void>;
|
|
5
|
+
close(): Promise<void>;
|
|
6
|
+
abort?(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
interface FileSystemFileHandleLike {
|
|
9
|
+
readonly kind?: "file";
|
|
10
|
+
readonly name?: string;
|
|
11
|
+
createWritable(options?: {
|
|
12
|
+
keepExistingData?: boolean;
|
|
13
|
+
}): Promise<FileSystemWritableFileStreamLike>;
|
|
14
|
+
isSameEntry?(other: FileSystemFileHandleLike): Promise<boolean>;
|
|
15
|
+
queryPermission?(descriptor?: {
|
|
16
|
+
mode?: "read" | "readwrite";
|
|
17
|
+
}): Promise<PermissionState>;
|
|
18
|
+
requestPermission?(descriptor?: {
|
|
19
|
+
mode?: "read" | "readwrite";
|
|
20
|
+
}): Promise<PermissionState>;
|
|
21
|
+
}
|
|
22
|
+
interface ExportFileOptions extends WorkspaceSelector {
|
|
23
|
+
path?: string;
|
|
24
|
+
ino?: number | string;
|
|
25
|
+
timeout?: number;
|
|
26
|
+
contentDisposition?: string;
|
|
27
|
+
downloadFilename?: string;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
interface ExportFileChunk {
|
|
31
|
+
index: number;
|
|
32
|
+
offset: number;
|
|
33
|
+
size: number;
|
|
34
|
+
storageKey: string;
|
|
35
|
+
url: string;
|
|
36
|
+
}
|
|
37
|
+
interface ExportFileResponse {
|
|
38
|
+
path: string;
|
|
39
|
+
storageKey: string;
|
|
40
|
+
url: string;
|
|
41
|
+
timeout: number;
|
|
42
|
+
size: number;
|
|
43
|
+
contentType?: string;
|
|
44
|
+
chunkMethod?: string;
|
|
45
|
+
isFastPath?: boolean;
|
|
46
|
+
chunks?: ExportFileChunk[];
|
|
47
|
+
}
|
|
48
|
+
interface DownloadProgress {
|
|
49
|
+
phase: "downloading" | "retrying" | "completed";
|
|
50
|
+
downloadedBytes: number;
|
|
51
|
+
totalBytes: number;
|
|
52
|
+
downloadedChunks: number;
|
|
53
|
+
totalChunks: number;
|
|
54
|
+
currentChunkIndex?: number;
|
|
55
|
+
speedBytesPerSecond: number;
|
|
56
|
+
estimatedRemainingSeconds?: number;
|
|
57
|
+
elapsedMs: number;
|
|
58
|
+
retryCount: number;
|
|
59
|
+
}
|
|
60
|
+
interface DownloadFileOptions extends ExportFileOptions {
|
|
61
|
+
/** Prefer File System Access API when available. Defaults to true. */
|
|
62
|
+
preferFileSystemAccess?: boolean;
|
|
63
|
+
/** Continue a matching IndexedDB checkpoint when the selected file is the same entry. */
|
|
64
|
+
resume?: boolean;
|
|
65
|
+
maxRetries?: number;
|
|
66
|
+
retryDelayMs?: number;
|
|
67
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
68
|
+
/** Use a previously selected file handle, primarily for resumeDownload. */
|
|
69
|
+
fileHandle?: FileSystemFileHandleLike;
|
|
70
|
+
}
|
|
71
|
+
interface DownloadResumeOptions {
|
|
72
|
+
signal?: AbortSignal;
|
|
73
|
+
maxRetries?: number;
|
|
74
|
+
retryDelayMs?: number;
|
|
75
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
76
|
+
}
|
|
77
|
+
interface DownloadResult {
|
|
78
|
+
export: ExportFileResponse;
|
|
79
|
+
downloadKey: string;
|
|
80
|
+
downloadedBytes: number;
|
|
81
|
+
resumed: boolean;
|
|
82
|
+
fileHandle?: FileSystemFileHandleLike;
|
|
83
|
+
blob?: Blob;
|
|
84
|
+
}
|
|
85
|
+
interface DownloadCheckpointChunk {
|
|
86
|
+
index: number;
|
|
87
|
+
offset: number;
|
|
88
|
+
size: number;
|
|
89
|
+
storageKey: string;
|
|
90
|
+
downloadedBytes: number;
|
|
91
|
+
completed: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface DownloadCheckpointRequest {
|
|
94
|
+
workspaceCuid?: string;
|
|
95
|
+
workspaceId?: number | string;
|
|
96
|
+
path?: string;
|
|
97
|
+
ino?: number | string;
|
|
98
|
+
timeout?: number;
|
|
99
|
+
contentDisposition?: string;
|
|
100
|
+
downloadFilename?: string;
|
|
101
|
+
}
|
|
102
|
+
interface DownloadCheckpoint {
|
|
103
|
+
version: 1;
|
|
104
|
+
key: string;
|
|
105
|
+
requestKey: string;
|
|
106
|
+
request: DownloadCheckpointRequest;
|
|
107
|
+
path: string;
|
|
108
|
+
size: number;
|
|
109
|
+
chunks: DownloadCheckpointChunk[];
|
|
110
|
+
fileHandle?: FileSystemFileHandleLike;
|
|
111
|
+
updatedAt: number;
|
|
112
|
+
}
|
|
113
|
+
interface DownloadCheckpointStore {
|
|
114
|
+
load(key: string): Promise<DownloadCheckpoint | null>;
|
|
115
|
+
save(key: string, checkpoint: DownloadCheckpoint): Promise<void>;
|
|
116
|
+
remove(key: string): Promise<void>;
|
|
117
|
+
list(): Promise<DownloadCheckpoint[]>;
|
|
118
|
+
}
|
|
119
|
+
declare class InMemoryDownloadCheckpointStore implements DownloadCheckpointStore {
|
|
120
|
+
private readonly records;
|
|
121
|
+
load(key: string): Promise<DownloadCheckpoint | null>;
|
|
122
|
+
save(key: string, checkpoint: DownloadCheckpoint): Promise<void>;
|
|
123
|
+
remove(key: string): Promise<void>;
|
|
124
|
+
list(): Promise<DownloadCheckpoint[]>;
|
|
125
|
+
}
|
|
126
|
+
declare class IndexedDBDownloadCheckpointStore implements DownloadCheckpointStore {
|
|
127
|
+
private readonly fallback;
|
|
128
|
+
private databasePromise?;
|
|
129
|
+
load(key: string): Promise<DownloadCheckpoint | null>;
|
|
130
|
+
save(key: string, checkpoint: DownloadCheckpoint): Promise<void>;
|
|
131
|
+
remove(key: string): Promise<void>;
|
|
132
|
+
list(): Promise<DownloadCheckpoint[]>;
|
|
133
|
+
private openDatabase;
|
|
134
|
+
private request;
|
|
135
|
+
}
|
|
136
|
+
declare class DownloadHttpError extends Error {
|
|
137
|
+
readonly status: number;
|
|
138
|
+
constructor(status: number, message: string);
|
|
139
|
+
}
|
|
140
|
+
interface DownloadTransport {
|
|
141
|
+
readonly baseUrl: string;
|
|
142
|
+
readonly clientSelector: WorkspaceSelector;
|
|
143
|
+
readonly fetchImpl: typeof globalThis.fetch;
|
|
144
|
+
readonly checkpointStore: DownloadCheckpointStore;
|
|
145
|
+
requestJson(path: string, body: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
146
|
+
}
|
|
147
|
+
declare class MountraDownloader {
|
|
148
|
+
private readonly transport;
|
|
149
|
+
constructor(transport: DownloadTransport);
|
|
150
|
+
exportFile(options: ExportFileOptions): Promise<ExportFileResponse>;
|
|
151
|
+
downloadFile(options: DownloadFileOptions): Promise<DownloadResult>;
|
|
152
|
+
downloadExport(exported: ExportFileResponse, options?: DownloadFileOptions): Promise<DownloadResult>;
|
|
153
|
+
resumeDownload(downloadKey: string, options?: DownloadResumeOptions): Promise<DownloadResult>;
|
|
154
|
+
listResumableDownloads(): Promise<DownloadCheckpoint[]>;
|
|
155
|
+
clearDownloadCheckpoint(downloadKey: string): Promise<void>;
|
|
156
|
+
private pickSaveFile;
|
|
157
|
+
private ensureWritePermission;
|
|
158
|
+
private downloadResolved;
|
|
159
|
+
private consumeResponse;
|
|
160
|
+
private consumeBytes;
|
|
161
|
+
private isSameFileHandle;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type MountraFileTarget = {
|
|
165
|
+
path: string;
|
|
166
|
+
ino?: never;
|
|
167
|
+
} | {
|
|
168
|
+
path?: never;
|
|
169
|
+
ino: number | string;
|
|
170
|
+
};
|
|
171
|
+
/** A file identity accepted by `MountraClient.file()`. */
|
|
172
|
+
type MountraFileLocator = WorkspaceSelector & Partial<{
|
|
173
|
+
wsid: WorkspaceId;
|
|
174
|
+
}> & MountraFileTarget;
|
|
175
|
+
type NormalizedMountraFileLocator = WorkspaceSelector & MountraFileTarget;
|
|
176
|
+
/** Options for exporting an already identified Mountra file. */
|
|
177
|
+
type MountraFileExportOptions = Omit<ExportFileOptions, "workspaceCuid" | "workspaceId" | "path" | "ino">;
|
|
178
|
+
/** Options for downloading an already identified Mountra file. */
|
|
179
|
+
type MountraFileDownloadOptions = Omit<DownloadFileOptions, "workspaceCuid" | "workspaceId" | "path" | "ino">;
|
|
180
|
+
interface MountraFileResumeOptions extends DownloadResumeOptions {
|
|
181
|
+
/** Select a particular checkpoint; otherwise the newest matching one is used. */
|
|
182
|
+
downloadKey?: string;
|
|
183
|
+
}
|
|
184
|
+
/** A stable resource object for one file in one Mountra workspace. */
|
|
185
|
+
declare class MountraFile {
|
|
186
|
+
private readonly client;
|
|
187
|
+
readonly locator: Readonly<NormalizedMountraFileLocator>;
|
|
188
|
+
constructor(client: MountraClient, locator: NormalizedMountraFileLocator);
|
|
189
|
+
get workspaceCuid(): string | undefined;
|
|
190
|
+
get workspaceId(): WorkspaceId | undefined;
|
|
191
|
+
/** `wsid` is the short alias used by the file-object API. */
|
|
192
|
+
get wsid(): WorkspaceId | undefined;
|
|
193
|
+
get path(): string | undefined;
|
|
194
|
+
get ino(): number | string | undefined;
|
|
195
|
+
export(options?: MountraFileExportOptions): Promise<ExportFileResponse>;
|
|
196
|
+
download(options?: MountraFileDownloadOptions): Promise<DownloadResult>;
|
|
197
|
+
resume(options?: MountraFileResumeOptions): Promise<DownloadResult>;
|
|
198
|
+
}
|
|
199
|
+
|
|
1
200
|
type ChunkMethod = "none" | "fix";
|
|
2
201
|
type WorkspaceId = number | string;
|
|
3
202
|
declare const JUMBO_CHUNK_THRESHOLD_BYTES: number;
|
|
@@ -24,6 +223,8 @@ interface MountraClientOptions extends WorkspaceSelector {
|
|
|
24
223
|
jumboChunkCheckpointStore?: JumboChunkCheckpointStore;
|
|
25
224
|
/** S3 Multipart part size. Defaults to 16 MiB. */
|
|
26
225
|
jumboPartSize?: number;
|
|
226
|
+
/** IndexedDB-backed download checkpoint store. */
|
|
227
|
+
downloadCheckpointStore?: DownloadCheckpointStore;
|
|
27
228
|
}
|
|
28
229
|
interface UploadFileOptions extends WorkspaceSelector {
|
|
29
230
|
path: string;
|
|
@@ -283,7 +484,16 @@ declare class MountraClient {
|
|
|
283
484
|
private readonly jumboChunkUploader?;
|
|
284
485
|
private readonly jumboChunkCheckpointStore;
|
|
285
486
|
private readonly jumboPartSize;
|
|
487
|
+
private readonly downloader;
|
|
286
488
|
constructor(options: MountraClientOptions);
|
|
489
|
+
exportFile(options: ExportFileOptions): Promise<ExportFileResponse>;
|
|
490
|
+
downloadFile(options: DownloadFileOptions): Promise<DownloadResult>;
|
|
491
|
+
downloadExport(exported: ExportFileResponse, options?: DownloadFileOptions): Promise<DownloadResult>;
|
|
492
|
+
resumeDownload(downloadKey: string, options?: DownloadResumeOptions): Promise<DownloadResult>;
|
|
493
|
+
listResumableDownloads(): Promise<DownloadCheckpoint[]>;
|
|
494
|
+
clearDownloadCheckpoint(downloadKey: string): Promise<void>;
|
|
495
|
+
/** Create a stable resource object for one file in this or another workspace. */
|
|
496
|
+
file(locator: MountraFileLocator): MountraFile;
|
|
287
497
|
prepareUpload(file: Blob, options: UploadFileOptions): Promise<PreparedUpload>;
|
|
288
498
|
uploadFile(file: Blob, options: UploadFileOptions): Promise<UploadResult>;
|
|
289
499
|
/** Generic upload entry point. It selects PUT or S3 Multipart per chunk. */
|
|
@@ -306,4 +516,4 @@ declare class MountraClient {
|
|
|
306
516
|
}
|
|
307
517
|
declare function createMountraClient(options: MountraClientOptions): MountraClient;
|
|
308
518
|
|
|
309
|
-
export { type AccessToken, type ChunkMethod, DEFAULT_S3_MULTIPART_PART_SIZE_BYTES, type FileChunk, type FinishUploadResponse, InMemoryJumboChunkCheckpointStore, JUMBO_CHUNK_THRESHOLD_BYTES, type JumboChunkCheckpoint, type JumboChunkCheckpointStore, type JumboChunkCompleteInput, type JumboChunkCreateInput, type JumboChunkUploadPartInput, type JumboChunkUploader, LocalStorageJumboChunkCheckpointStore, MAX_S3_MULTIPART_PARTS, MIN_S3_MULTIPART_PART_SIZE_BYTES, MountraApiError, MountraClient, type MountraClientOptions, type MountraProgress, MountraClient as MountraSDK, type PrepareUploadResponse, type PreparedUpload, type S3MultipartClient, type S3MultipartPart, S3MultipartUploader, type UploadFileOptions, type UploadResult, type UploadResumeOptions, type UploadSessionChunkContext, type UploadSessionContext, type UploadStatusChunk, type UploadStatusResponse, type UploadTarget, type WorkspaceId, type WorkspaceSelector, createMountraClient, isJumboChunk, sha256Hex, splitFileIntoChunks };
|
|
519
|
+
export { type AccessToken, type ChunkMethod, DEFAULT_S3_MULTIPART_PART_SIZE_BYTES, type DownloadCheckpoint, type DownloadCheckpointChunk, type DownloadCheckpointRequest, type DownloadCheckpointStore, type DownloadFileOptions, DownloadHttpError, type DownloadProgress, type DownloadResult, type DownloadResumeOptions, type ExportFileChunk, type ExportFileOptions, type ExportFileResponse, type FileChunk, type FileSystemFileHandleLike, type FileSystemWritableFileStreamLike, type FinishUploadResponse, InMemoryDownloadCheckpointStore, InMemoryJumboChunkCheckpointStore, IndexedDBDownloadCheckpointStore, JUMBO_CHUNK_THRESHOLD_BYTES, type JumboChunkCheckpoint, type JumboChunkCheckpointStore, type JumboChunkCompleteInput, type JumboChunkCreateInput, type JumboChunkUploadPartInput, type JumboChunkUploader, LocalStorageJumboChunkCheckpointStore, MAX_S3_MULTIPART_PARTS, MIN_S3_MULTIPART_PART_SIZE_BYTES, MountraApiError, MountraClient, type MountraClientOptions, MountraDownloader, MountraFile, type MountraFileDownloadOptions, type MountraFileExportOptions, type MountraFileLocator, type MountraFileResumeOptions, type MountraProgress, MountraClient as MountraSDK, type NormalizedMountraFileLocator, type PrepareUploadResponse, type PreparedUpload, type S3MultipartClient, type S3MultipartPart, S3MultipartUploader, type UploadFileOptions, type UploadResult, type UploadResumeOptions, type UploadSessionChunkContext, type UploadSessionContext, type UploadStatusChunk, type UploadStatusResponse, type UploadTarget, type WorkspaceId, type WorkspaceSelector, createMountraClient, isJumboChunk, sha256Hex, splitFileIntoChunks };
|