@hostr/upload 0.3.0 → 0.4.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/dist/api/client.d.ts +7 -1
- package/dist/browser.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/node.js +3 -2
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ export type CreateResult = {
|
|
|
29
29
|
expectedParts: number;
|
|
30
30
|
key: string;
|
|
31
31
|
};
|
|
32
|
+
/** `createUploadSession`'s result: the API's response plus the `endpoint` it
|
|
33
|
+
* was minted against, because the token is only valid there and the client
|
|
34
|
+
* must take the endpoint from this response, not from its own config. */
|
|
35
|
+
export type UploadSession = CreateResult & {
|
|
36
|
+
endpoint: string;
|
|
37
|
+
};
|
|
32
38
|
export type CompleteResult = {
|
|
33
39
|
status: string;
|
|
34
40
|
etag?: string;
|
|
@@ -90,7 +96,7 @@ export declare function createUploadSession(opts: {
|
|
|
90
96
|
autoComplete?: boolean;
|
|
91
97
|
audio?: UploadAudioOptions;
|
|
92
98
|
captions?: UploadCaptionsOptions;
|
|
93
|
-
}, fetchFn?: typeof fetch): Promise<
|
|
99
|
+
}, fetchFn?: typeof fetch): Promise<UploadSession>;
|
|
94
100
|
export declare function mintUploadToken(opts: {
|
|
95
101
|
endpoint: string;
|
|
96
102
|
apiKey: string;
|
package/dist/browser.js
CHANGED
|
@@ -97,7 +97,8 @@ var HostrApi = class {
|
|
|
97
97
|
};
|
|
98
98
|
async function createUploadSession(opts, fetchFn = fetch) {
|
|
99
99
|
const { endpoint, apiKey, ...body } = opts;
|
|
100
|
-
|
|
100
|
+
const created = await req(fetchFn, endpoint, apiKey, "/v1/uploads", { method: "POST", body });
|
|
101
|
+
return { ...created, endpoint };
|
|
101
102
|
}
|
|
102
103
|
function mintUploadToken(opts, fetchFn = fetch) {
|
|
103
104
|
const { endpoint, apiKey, assetId, tokenTtlSec } = opts;
|
|
@@ -887,7 +888,7 @@ var UploadEngine = class {
|
|
|
887
888
|
code: "systemic-transport-failure",
|
|
888
889
|
consecutiveNetworkFailures: this.consecutiveNetworkFailures,
|
|
889
890
|
bytesEverConfirmed: this.bytesConfirmed(),
|
|
890
|
-
hint:
|
|
891
|
+
hint: "every part PUT is failing at the network layer and no bytes have ever been confirmed for this session \u2014 check the connection; in a browser, check that the page CSP connect-src allows the storage host, and (self-hosted buckets only) bucket CORS"
|
|
891
892
|
});
|
|
892
893
|
}
|
|
893
894
|
bytesConfirmed() {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type * from './core/types.js';
|
|
2
2
|
export { ApiError, NetworkError, HostrApi, createUploadSession, mintUploadToken, } from './api/client.js';
|
|
3
|
-
export type { RemotePart, RemoteUpload, CreateResult, CompleteResult, UploadAudioOptions, UploadCaptionsOptions } from './api/client.js';
|
|
3
|
+
export type { RemotePart, RemoteUpload, CreateResult, UploadSession, CompleteResult, UploadAudioOptions, UploadCaptionsOptions } from './api/client.js';
|
|
4
4
|
export { storageKey, loadSession, saveSession, clearSession, partSizeOf, memoryStore, } from './core/session.js';
|
|
5
5
|
export type { SessionStatus, SessionRecord } from './core/session.js';
|
|
6
6
|
export { classifyPut, classifyApi, backoffMs, RETRY_BUDGET } from './core/retry.js';
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,8 @@ var HostrApi = class {
|
|
|
71
71
|
};
|
|
72
72
|
async function createUploadSession(opts, fetchFn = fetch) {
|
|
73
73
|
const { endpoint, apiKey, ...body } = opts;
|
|
74
|
-
|
|
74
|
+
const created = await req(fetchFn, endpoint, apiKey, "/v1/uploads", { method: "POST", body });
|
|
75
|
+
return { ...created, endpoint };
|
|
75
76
|
}
|
|
76
77
|
function mintUploadToken(opts, fetchFn = fetch) {
|
|
77
78
|
const { endpoint, apiKey, assetId, tokenTtlSec } = opts;
|
|
@@ -901,7 +902,7 @@ var UploadEngine = class {
|
|
|
901
902
|
code: "systemic-transport-failure",
|
|
902
903
|
consecutiveNetworkFailures: this.consecutiveNetworkFailures,
|
|
903
904
|
bytesEverConfirmed: this.bytesConfirmed(),
|
|
904
|
-
hint:
|
|
905
|
+
hint: "every part PUT is failing at the network layer and no bytes have ever been confirmed for this session \u2014 check the connection; in a browser, check that the page CSP connect-src allows the storage host, and (self-hosted buckets only) bucket CORS"
|
|
905
906
|
});
|
|
906
907
|
}
|
|
907
908
|
bytesConfirmed() {
|
package/dist/node.js
CHANGED
|
@@ -102,7 +102,8 @@ var HostrApi = class {
|
|
|
102
102
|
};
|
|
103
103
|
async function createUploadSession(opts, fetchFn = fetch) {
|
|
104
104
|
const { endpoint, apiKey, ...body } = opts;
|
|
105
|
-
|
|
105
|
+
const created = await req(fetchFn, endpoint, apiKey, "/v1/uploads", { method: "POST", body });
|
|
106
|
+
return { ...created, endpoint };
|
|
106
107
|
}
|
|
107
108
|
function mintUploadToken(opts, fetchFn = fetch) {
|
|
108
109
|
const { endpoint, apiKey, assetId, tokenTtlSec } = opts;
|
|
@@ -892,7 +893,7 @@ var UploadEngine = class {
|
|
|
892
893
|
code: "systemic-transport-failure",
|
|
893
894
|
consecutiveNetworkFailures: this.consecutiveNetworkFailures,
|
|
894
895
|
bytesEverConfirmed: this.bytesConfirmed(),
|
|
895
|
-
hint:
|
|
896
|
+
hint: "every part PUT is failing at the network layer and no bytes have ever been confirmed for this session \u2014 check the connection; in a browser, check that the page CSP connect-src allows the storage host, and (self-hosted buckets only) bucket CORS"
|
|
896
897
|
});
|
|
897
898
|
}
|
|
898
899
|
bytesConfirmed() {
|