@hostr/upload 0.2.0 → 0.3.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/README.md CHANGED
@@ -75,6 +75,11 @@ upload.start();
75
75
  const { etag, sha256 } = await upload.done;
76
76
  ```
77
77
 
78
+ `createUploadSession` also takes `audio` (`'asmr'` or the knobs) and, from
79
+ 0.3.0, `captions` — `{ language?: 'auto' | bcp47, translate?: string[], context?: string }`
80
+ — which has hostr transcribe and translate the video once its audio exists
81
+ (the account must have captions enabled; see the captions guide).
82
+
78
83
  `infra/scripts/test-upload.mjs` is the canonical example — it drives the SDK
79
84
  through a kill/resume cycle and a corrupted-part self-heal against a real API
80
85
  and real R2.
@@ -63,6 +63,21 @@ export type UploadAudioOptions = 'asmr' | {
63
63
  truePeakDbtp?: number;
64
64
  kbps?: number;
65
65
  };
66
+ /**
67
+ * Per-asset captions for `POST /v1/uploads`: hostr transcribes the audio as
68
+ * soon as it exists, attaches it as a `<Language> (auto)` subtitle track, and
69
+ * translates it into each `translate` language as `(auto-translated)` tracks.
70
+ * Needs captions enabled on the account (the request is refused with
71
+ * `403 captions_not_enabled` otherwise). Watch for `captions.ready` per track.
72
+ */
73
+ export type UploadCaptionsOptions = {
74
+ /** `'auto'` (the default) to detect, or the BCP 47 tag the speech is in. */
75
+ language?: string;
76
+ /** Target BCP 47 tags, at most 10. A target in the spoken language is dropped. */
77
+ translate?: string[];
78
+ /** Up to 1000 characters of context for the transcriber: creator, title, terms. */
79
+ context?: string;
80
+ };
66
81
  export declare function createUploadSession(opts: {
67
82
  endpoint: string;
68
83
  apiKey: string;
@@ -71,7 +86,10 @@ export declare function createUploadSession(opts: {
71
86
  size: number;
72
87
  partSize?: number;
73
88
  tokenTtlSec?: number;
89
+ /** Allow Hostr to finalize validated parts without a client callback. */
90
+ autoComplete?: boolean;
74
91
  audio?: UploadAudioOptions;
92
+ captions?: UploadCaptionsOptions;
75
93
  }, fetchFn?: typeof fetch): Promise<CreateResult>;
76
94
  export declare function mintUploadToken(opts: {
77
95
  endpoint: string;
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 } from './api/client.js';
3
+ export type { RemotePart, RemoteUpload, CreateResult, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostr/upload",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,