@sparkvault/sdk-js 11.1.13 → 11.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/dist/index.cjs +250 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +92 -8
- package/dist/index.mjs +250 -30
- package/dist/index.mjs.map +1 -1
- package/dist/ingots/index.d.ts +46 -3
- package/dist/ingots/types.d.ts +20 -0
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/index.d.ts +7 -4
- package/dist/vaults/types.d.ts +41 -8
- package/dist/vaults/upload/api.d.ts +39 -2
- package/package.json +1 -1
package/dist/ingots/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { type ResolvedConfig } from '../config';
|
|
13
13
|
import { HttpClient } from '../http';
|
|
14
|
-
import type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
|
|
14
|
+
import type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
|
|
15
15
|
export declare class IngotsModule {
|
|
16
16
|
private readonly config;
|
|
17
17
|
private readonly http;
|
|
@@ -51,11 +51,15 @@ export declare class IngotsModule {
|
|
|
51
51
|
* `details.coreCode`: a new upload is no remedy. A publication the server
|
|
52
52
|
* still defers at the transfer's idle limit rejects with code
|
|
53
53
|
* `upload_received_publishing`: every byte is received, and the server
|
|
54
|
-
* finishes the publication on its own, so never upload the file again
|
|
54
|
+
* finishes the publication on its own, so never upload the file again; a
|
|
55
|
+
* caller that kept the session (`onSessionCreated`) learns what became of
|
|
56
|
+
* it with {@link resumeUpload}.
|
|
55
57
|
*
|
|
56
58
|
* @param options.signal - Cancels this transfer (it rejects with code
|
|
57
59
|
* `cancelled`); other transfers carry on.
|
|
58
60
|
* @param options.onProgress - Bytes sent so far and the file size; never runs backwards.
|
|
61
|
+
* @param options.onSessionCreated - Hands over the upload's session once
|
|
62
|
+
* Forge opens it, before the first byte is sent.
|
|
59
63
|
*
|
|
60
64
|
* @example
|
|
61
65
|
* const session = await sv.ingots.createUpload({ vault: unsealed, name: file.name,
|
|
@@ -63,6 +67,45 @@ export declare class IngotsModule {
|
|
|
63
67
|
* await sv.ingots.sendUpload(session.uploadUrl, file, { signal: controller.signal });
|
|
64
68
|
*/
|
|
65
69
|
sendUpload(uploadUrl: string, file: File | Blob, options?: SendUploadOptions): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Continue an upload in the session a {@link sendUpload} opened for the same
|
|
72
|
+
* file (the `session` its `onSessionCreated` handed over): Forge is asked
|
|
73
|
+
* where the session stands, only the bytes it lacks are sent, and the
|
|
74
|
+
* promise resolves once the server confirms the ingot is published. A
|
|
75
|
+
* session that already holds every byte sends none and only asks: this is
|
|
76
|
+
* how a caller follows an upload that ended `upload_received_publishing`
|
|
77
|
+
* until the server publishes it or ends it.
|
|
78
|
+
*
|
|
79
|
+
* It rejects as {@link sendUpload} does: `session_gone` once the server no
|
|
80
|
+
* longer holds the session (it expired, was cancelled, or ended when the
|
|
81
|
+
* server refused to publish it), `upload_refused` for an upload refused for
|
|
82
|
+
* good, `upload_received_publishing` again for a publication the server
|
|
83
|
+
* still defers at the transfer's idle limit, which leaves the session to
|
|
84
|
+
* resume again later. A session URL that is not an upload session on an
|
|
85
|
+
* allowed transfer host is refused (`invalid_forge_url`), and one whose
|
|
86
|
+
* upload is not this file's length (`session_mismatch`), before a byte is
|
|
87
|
+
* sent.
|
|
88
|
+
*
|
|
89
|
+
* @param options.signal - Cancels this transfer (it rejects with code
|
|
90
|
+
* `cancelled`); the session stays as it stands.
|
|
91
|
+
* @param options.onProgress - Bytes the session holds so far and the file size; never runs backwards.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* let session;
|
|
95
|
+
* try {
|
|
96
|
+
* await sv.ingots.sendUpload(upload.uploadUrl, file, { onSessionCreated: (s) => { session = s; } });
|
|
97
|
+
* } catch (error) {
|
|
98
|
+
* if (error.code !== 'upload_received_publishing') throw error;
|
|
99
|
+
* await sv.ingots.resumeUpload(session, file);
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
resumeUpload(session: UploadSession, file: File | Blob, options?: ResumeUploadOptions): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Run one transfer on a transfer client of its own: its abort is scoped to
|
|
105
|
+
* its own session, so cancelling one upload never touches another in
|
|
106
|
+
* flight, and the caller's signal cancels it (code `cancelled`).
|
|
107
|
+
*/
|
|
108
|
+
private runTransfer;
|
|
66
109
|
/**
|
|
67
110
|
* Upload a file as a new ingot (high-level flow).
|
|
68
111
|
*
|
|
@@ -239,4 +282,4 @@ export declare class IngotsModule {
|
|
|
239
282
|
export { NAME_CONFLICT_POLICIES } from './types';
|
|
240
283
|
export { fetchDownload } from './fetch-download';
|
|
241
284
|
export type { FetchDownloadOptions, FetchedDownload } from './fetch-download';
|
|
242
|
-
export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse, } from './types';
|
|
285
|
+
export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse, } from './types';
|
package/dist/ingots/types.d.ts
CHANGED
|
@@ -140,13 +140,33 @@ export interface UploadIngotOptions {
|
|
|
140
140
|
/** Progress callback for the Forge/TUS transfer */
|
|
141
141
|
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* The upload session a file's bytes go to, which `sendUpload` hands over once
|
|
145
|
+
* Forge opens it (`onSessionCreated`): what `resumeUpload` continues the
|
|
146
|
+
* upload in. Its URL addresses the upload itself (a request to it can end the
|
|
147
|
+
* upload), so keep it in memory, never in a log or a URL a person shares.
|
|
148
|
+
*/
|
|
149
|
+
export interface UploadSession {
|
|
150
|
+
/** The session's URL on Forge. */
|
|
151
|
+
readonly sessionUrl: string;
|
|
152
|
+
}
|
|
143
153
|
/** Options for sendUpload. */
|
|
144
154
|
export interface SendUploadOptions {
|
|
145
155
|
/** Cancels the transfer. */
|
|
146
156
|
signal?: AbortSignal;
|
|
147
157
|
/** Bytes sent so far and the file size; never runs backwards. */
|
|
148
158
|
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Hands over the upload's session once Forge opens it, before the first
|
|
161
|
+
* byte is sent, so the caller can `resumeUpload` the upload in it later:
|
|
162
|
+
* after `upload_received_publishing`, to learn whether the server published
|
|
163
|
+
* it, or after a failure, to send only the bytes the server lacks. A throw
|
|
164
|
+
* here ends the transfer with that error.
|
|
165
|
+
*/
|
|
166
|
+
onSessionCreated?: (session: UploadSession) => void;
|
|
149
167
|
}
|
|
168
|
+
/** Options for resumeUpload. */
|
|
169
|
+
export type ResumeUploadOptions = Omit<SendUploadOptions, 'onSessionCreated'>;
|
|
150
170
|
/** Options for replacing an existing ingot's content. */
|
|
151
171
|
export interface ReplaceIngotOptions {
|
|
152
172
|
/** File or Blob to upload as the new content */
|