@hostr/upload 0.3.0 → 0.4.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/api/client.d.ts +7 -1
- package/dist/browser.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/node.js +2 -1
- 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;
|
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;
|
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;
|