diffio 0.1.79 → 0.1.80

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
@@ -77,7 +77,11 @@ retrying after an uncertain response.
77
77
 
78
78
  `waitForGeneration` and `generations.waitForComplete` wait for the overall `status` to become
79
79
  `complete`. Individual stages reaching 100% or `complete` do not end polling while video publication
80
- or usage settlement is still pending.
80
+ or usage settlement is still pending. For Diffio 2.0, `complete` means restored media is ready;
81
+ transcription can still be `pending`, become `available` later, or finish as `unavailable`.
82
+ Read `progress.transcription?.status` independently. Older responses omit `transcription`;
83
+ absence does not establish availability. Unavailable transcription does not fail completed
84
+ Diffio 2.0 media. Diffio 3.5 requires its transcript before restoration can complete.
81
85
 
82
86
  ## Audio isolation helper
83
87
 
@@ -136,6 +140,7 @@ const progress = await client.generations.getProgress({
136
140
  });
137
141
 
138
142
  console.log(progress.status);
143
+ console.log(progress.transcription?.status ?? "not reported");
139
144
  ```
140
145
 
141
146
  ## Generation download
@@ -153,16 +158,43 @@ const download = await client.generations.getDownload({
153
158
  console.log(download.downloadUrl);
154
159
  ```
155
160
 
156
- Set `downloadType` to `"transcript"` to fetch the transcript JSON artifact when the generation has one.
161
+ Set `downloadType` to `"transcript"` to fetch the transcript JSON artifact when available.
162
+ Pending transcripts raise `DiffioApiError` with `statusCode === 409` and error code
163
+ `TRANSCRIPT_PENDING`. Unavailable transcripts return `404` with `TRANSCRIPT_UNAVAILABLE`.
164
+ The `responseBody` also includes `transcription.status`. Check the error code to distinguish
165
+ these from other 409 or 404 errors.
157
166
 
158
167
  ```ts
159
- const transcript = await client.generations.getDownload({
160
- generationId: "gen_123",
161
- apiProjectId: "proj_123",
162
- downloadType: "transcript"
163
- });
168
+ import { DiffioApiError } from "diffio";
169
+
170
+ try {
171
+ const transcript = await client.generations.getDownload({
172
+ generationId: "gen_123",
173
+ apiProjectId: "proj_123",
174
+ downloadType: "transcript"
175
+ });
176
+ console.log(transcript.downloadUrl);
177
+ } catch (error) {
178
+ if (!(error instanceof DiffioApiError)) throw error;
179
+ const body = error.responseBody;
180
+ const code = body && typeof body === "object" && "code" in body ? body.code : undefined;
181
+ if (error.statusCode === 409 && code === "TRANSCRIPT_PENDING") {
182
+ console.log("Transcript pending; check progress and retry later.");
183
+ } else if (error.statusCode === 404 && code === "TRANSCRIPT_UNAVAILABLE") {
184
+ console.log("Transcript unavailable; restored media remains available.");
185
+ } else {
186
+ throw error;
187
+ }
188
+ }
164
189
  ```
165
190
 
191
+ `restoreAudio` with `downloadType: "transcript"` also attempts a transcript download after
192
+ media completion. It does not wait for pending transcription. With the default `raiseOnError: false`,
193
+ it returns `[null, info]` and preserves `info.statusCode` and `info.responseBody`; `info.status`
194
+ can still be `complete` because media restoration succeeded. With `raiseOnError: true`, it throws
195
+ `DiffioApiError` and attaches metadata as `error.restoreInfo`. Poll progress and retry the download
196
+ explicitly for the same generation. Audio and video downloads proceed independently of transcription.
197
+
166
198
  ## Account, keys, usage, and webhook configuration
167
199
 
168
200
  Agent keys can manage account settings, scoped keys, usage, and webhook endpoints.
@@ -227,6 +259,11 @@ console.log(event.svixMessageId);
227
259
 
228
260
  Use the raw request body (not parsed JSON) plus the `svix-*` headers and your webhook signing secret.
229
261
 
262
+ Verified events expose the same optional `event.transcription` object as generation progress.
263
+ A Diffio 2.0 `generation.completed` event can report `pending` or `unavailable` transcription.
264
+ Later transcript publication does not emit another completion event; poll progress when you need
265
+ to follow a pending transcript. Older events can omit `transcription`.
266
+
230
267
  ```ts
231
268
  import express from "express";
232
269
  import { DiffioClient } from "diffio";
package/dist/Client.d.ts CHANGED
@@ -47,7 +47,7 @@ export declare class DiffioClient {
47
47
  apiProjectId?: string;
48
48
  requestOptions?: DiffioClient.RequestOptions;
49
49
  }): Promise<GenerationProgressResponse>;
50
- /** Waits for the authoritative overall status, including artifact publication and settlement. */
50
+ /** Waits for media completion and settlement. Diffio 2.0 transcription may still be pending or unavailable. */
51
51
  waitForGeneration(options: {
52
52
  generationId: string;
53
53
  apiProjectId?: string;
package/dist/Client.js CHANGED
@@ -182,7 +182,7 @@ class DiffioClient {
182
182
  const response = await this._requestJson("POST", "get_generation_progress", payload, requestOptions);
183
183
  return (0, serialization_1.parseGenerationProgressResponse)(response);
184
184
  }
185
- /** Waits for the authoritative overall status, including artifact publication and settlement. */
185
+ /** Waits for media completion and settlement. Diffio 2.0 transcription may still be pending or unavailable. */
186
186
  async waitForGeneration(options) {
187
187
  const { generationId, apiProjectId, pollInterval = 2, timeout, timeoutInSeconds, onProgress, showProgress, requestOptions } = options;
188
188
  const timeoutSeconds = timeoutInSeconds ?? timeout ?? DEFAULT_TIMEOUT_SECONDS;
@@ -739,6 +739,10 @@ function setRestoreError(metadata, error) {
739
739
  metadata.error = message;
740
740
  metadata.exceptionType = error instanceof Error ? error.name : typeof error;
741
741
  metadata.exceptionMessage = message;
742
+ if (error instanceof errors_1.DiffioApiError) {
743
+ metadata.statusCode = error.statusCode;
744
+ metadata.responseBody = error.responseBody;
745
+ }
742
746
  }
743
747
  function attachRestoreMetadata(error, metadata) {
744
748
  if (error && typeof error === "object") {
@@ -1,5 +1,5 @@
1
1
  import type { DiffioClient } from "../../../../Client";
2
- import type { AudioIsolationResult, ModelKey, RestoreMetadata } from "../../../types";
2
+ import type { AudioIsolationResult, GenerationProgressResponse, ModelKey, RestoreMetadata } from "../../../types";
3
3
  export interface AudioIsolationRestoreOptions {
4
4
  filePath: string;
5
5
  contentType?: string;
@@ -14,7 +14,7 @@ export interface AudioIsolationRestoreOptions {
14
14
  pollInterval?: number;
15
15
  timeout?: number;
16
16
  timeoutInSeconds?: number;
17
- onProgress?: (progress: unknown) => void | Promise<void>;
17
+ onProgress?: (progress: GenerationProgressResponse) => void | Promise<void>;
18
18
  showProgress?: boolean;
19
19
  requestOptions?: DiffioClient.RequestOptions;
20
20
  progressRequestOptions?: DiffioClient.RequestOptions;
@@ -85,6 +85,7 @@ function parseGenerationProgressStage(data) {
85
85
  }
86
86
  function parseGenerationProgressResponse(data) {
87
87
  const restoredVideo = data?.restoredVideo;
88
+ const transcription = parseGenerationTranscription(data?.transcription);
88
89
  return {
89
90
  generationId: data.generationId,
90
91
  apiProjectId: data.apiProjectId,
@@ -93,6 +94,7 @@ function parseGenerationProgressResponse(data) {
93
94
  preProcessing: parseGenerationProgressStage(data.preProcessing),
94
95
  inference: parseGenerationProgressStage(data.inference),
95
96
  restoredVideo: restoredVideo ? parseGenerationProgressStage(restoredVideo) : null,
97
+ ...(transcription ? { transcription } : {}),
96
98
  error: data.error ?? null,
97
99
  errorDetails: data.errorDetails ?? null
98
100
  };
@@ -157,6 +159,7 @@ function parseWebhookConfigureResponse(data) {
157
159
  };
158
160
  }
159
161
  function parseGenerationWebhookEvent(data) {
162
+ const transcription = parseGenerationTranscription(data?.transcription);
160
163
  return {
161
164
  eventType: data.eventType,
162
165
  eventId: data.eventId,
@@ -167,10 +170,21 @@ function parseGenerationWebhookEvent(data) {
167
170
  status: data.status,
168
171
  hasVideo: data.hasVideo ?? null,
169
172
  modelKey: data.modelKey ?? null,
173
+ ...(transcription ? { transcription } : {}),
170
174
  error: data.error ?? null,
171
175
  errorDetails: data.errorDetails ?? null
172
176
  };
173
177
  }
178
+ function parseGenerationTranscription(data) {
179
+ if (data == null || typeof data !== "object" || !("status" in data)) {
180
+ return undefined;
181
+ }
182
+ const { status } = data;
183
+ if (status === "pending" || status === "available" || status === "unavailable") {
184
+ return { status };
185
+ }
186
+ return undefined;
187
+ }
174
188
  function createAudioIsolationResult(project, generation) {
175
189
  return { project, generation };
176
190
  }
@@ -3,6 +3,10 @@ export type DownloadType = "audio" | "video" | "transcript";
3
3
  export type WebhookMode = "test" | "live";
4
4
  export type WebhookEventType = "generation.queued" | "generation.processing" | "generation.failed" | "generation.completed";
5
5
  export type GenerationWebhookStatus = "queued" | "processing" | "error" | "complete";
6
+ export type TranscriptionStatus = "pending" | "available" | "unavailable";
7
+ export interface GenerationTranscription {
8
+ status: TranscriptionStatus;
9
+ }
6
10
  export interface CreateProjectResponse {
7
11
  apiProjectId: string;
8
12
  uploadUrl: string;
@@ -60,6 +64,8 @@ export interface GenerationProgressResponse {
60
64
  preProcessing: GenerationProgressStage;
61
65
  inference: GenerationProgressStage;
62
66
  restoredVideo?: GenerationProgressStage | null;
67
+ /** Independent of media completion; omitted by older API versions. */
68
+ transcription?: GenerationTranscription;
63
69
  error?: string | null;
64
70
  errorDetails?: string | null;
65
71
  }
@@ -123,6 +129,8 @@ export interface GenerationWebhookEvent {
123
129
  status: GenerationWebhookStatus | string;
124
130
  hasVideo?: boolean | null;
125
131
  modelKey?: ModelKey | string | null;
132
+ /** A completed Diffio 2.0 generation may still have a pending or unavailable transcript. */
133
+ transcription?: GenerationTranscription;
126
134
  error?: string | null;
127
135
  errorDetails?: string | null;
128
136
  }
@@ -144,4 +152,7 @@ export interface RestoreMetadata {
144
152
  errorDetails: string | null;
145
153
  exceptionType: string | null;
146
154
  exceptionMessage: string | null;
155
+ /** HTTP error details retained when a restore helper returns instead of throwing. */
156
+ statusCode?: number;
157
+ responseBody?: unknown;
147
158
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const DIFFIO_SDK_VERSION = "0.1.79";
1
+ export declare const DIFFIO_SDK_VERSION = "0.1.80";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DIFFIO_SDK_VERSION = void 0;
4
- exports.DIFFIO_SDK_VERSION = "0.1.79";
4
+ exports.DIFFIO_SDK_VERSION = "0.1.80";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffio",
3
- "version": "0.1.79",
3
+ "version": "0.1.80",
4
4
  "description": "Diffio API client for Node.js",
5
5
  "repository": {
6
6
  "type": "git",