diffio 0.4.63 → 1.0.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 +208 -296
- package/dist/Client.d.ts +85 -148
- package/dist/Client.js +73 -798
- package/dist/api/resources/account.d.ts +38 -0
- package/dist/api/resources/account.js +96 -0
- package/dist/api/resources/editing.d.ts +54 -0
- package/dist/api/resources/editing.js +168 -0
- package/dist/api/resources/generations.d.ts +52 -0
- package/dist/api/resources/generations.js +145 -0
- package/dist/api/resources/index.d.ts +5 -7
- package/dist/api/resources/index.js +18 -15
- package/dist/api/resources/models.d.ts +9 -0
- package/dist/api/resources/models.js +23 -0
- package/dist/api/resources/projects.d.ts +51 -0
- package/dist/api/resources/projects.js +128 -0
- package/dist/api/types.d.ts +423 -222
- package/dist/api/types.js +2 -0
- package/dist/core/edgeUpload.d.ts +39 -39
- package/dist/core/edgeUpload.js +170 -125
- package/dist/core/files.d.ts +15 -0
- package/dist/core/files.js +121 -0
- package/dist/core/node.d.ts +7 -0
- package/dist/core/node.js +17 -0
- package/dist/core/pagination.d.ts +33 -0
- package/dist/core/pagination.js +64 -0
- package/dist/core/poll.d.ts +23 -0
- package/dist/core/poll.js +30 -0
- package/dist/core/retry.d.ts +8 -7
- package/dist/core/retry.js +39 -25
- package/dist/core/transport.d.ts +75 -0
- package/dist/core/transport.js +220 -0
- package/dist/core/url.d.ts +10 -0
- package/dist/core/url.js +38 -0
- package/dist/core/webhookSignature.d.ts +20 -0
- package/dist/core/webhookSignature.js +147 -0
- package/dist/errors/index.d.ts +60 -18
- package/dist/errors/index.js +61 -13
- package/dist/index.d.ts +8 -1
- package/dist/index.js +9 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -7
- package/dist/BaseClient.d.ts +0 -26
- package/dist/BaseClient.js +0 -17
- package/dist/api/resources/account/client/Client.d.ts +0 -15
- package/dist/api/resources/account/client/Client.js +0 -15
- package/dist/api/resources/apiKeys/client/Client.d.ts +0 -27
- package/dist/api/resources/apiKeys/client/Client.js +0 -21
- package/dist/api/resources/audioIsolation/client/Client.d.ts +0 -43
- package/dist/api/resources/audioIsolation/client/Client.js +0 -33
- package/dist/api/resources/generations/client/Client.d.ts +0 -48
- package/dist/api/resources/generations/client/Client.js +0 -36
- package/dist/api/resources/projects/client/Client.d.ts +0 -21
- package/dist/api/resources/projects/client/Client.js +0 -19
- package/dist/api/resources/usage/client/Client.d.ts +0 -11
- package/dist/api/resources/usage/client/Client.js +0 -12
- package/dist/api/resources/webhooks/client/Client.d.ts +0 -29
- package/dist/api/resources/webhooks/client/Client.js +0 -76
- package/dist/api/serialization.d.ts +0 -21
- package/dist/api/serialization.js +0 -274
package/dist/Client.d.ts
CHANGED
|
@@ -1,156 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import { Transport, type RequestOptions } from "./core/transport";
|
|
2
|
+
import type { HeaderRecord } from "./core/headers";
|
|
3
|
+
import type { Supplier } from "./core/supplier";
|
|
4
|
+
import { type FileInput } from "./core/files";
|
|
5
|
+
import type { WaitOptions } from "./core/poll";
|
|
6
|
+
import { AssistantResource, EditsResource, ExportsResource, GenerationsResource, MixResource, ModelsResource, ProjectsResource, SharesResource, TranscriptsResource, UsageResource, WebhooksResource } from "./api/resources";
|
|
7
|
+
import type { Generation, GenerationFileName, ModelName, Project } from "./api/types";
|
|
4
8
|
export declare namespace DiffioClient {
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
interface Options {
|
|
10
|
+
/** API key (`diffio_live_...`). Default: the `DIFFIO_API_KEY` environment variable. */
|
|
11
|
+
apiKey?: Supplier<string | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* API host, such as `https://api.diffio.ai` (the default); `/v2` is added when missing.
|
|
14
|
+
* Default: the `DIFFIO_API_BASE_URL` environment variable, then `https://api.diffio.ai`.
|
|
15
|
+
*/
|
|
16
|
+
baseUrl?: Supplier<string | undefined>;
|
|
17
|
+
/** Sent as `Diffio-End-User` on every call (a call's own `endUser` wins). */
|
|
18
|
+
endUser?: string;
|
|
19
|
+
/** Seconds before one HTTP attempt gives up (default 60). */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
/** Retries of idempotent calls after network errors, 408, 429 and 5xx (default 2). */
|
|
22
|
+
maxRetries?: number;
|
|
23
|
+
/** First retry delay in seconds; doubles each retry (default 0.5). */
|
|
24
|
+
retryBackoff?: number;
|
|
25
|
+
retryStatusCodes?: number[];
|
|
26
|
+
/** Extra headers on every API call. */
|
|
27
|
+
headers?: HeaderRecord;
|
|
28
|
+
/** A fetch implementation (default `globalThis.fetch`). */
|
|
29
|
+
fetch?: typeof fetch;
|
|
7
30
|
}
|
|
31
|
+
type RequestOptions = import("./core/transport").RequestOptions;
|
|
32
|
+
}
|
|
33
|
+
export interface RestoreAudioParams extends RequestOptions {
|
|
34
|
+
/** A file path (Node), a Blob or File, or bytes. */
|
|
35
|
+
file: FileInput;
|
|
36
|
+
/** Default `diffio-flash`. */
|
|
37
|
+
model?: ModelName;
|
|
38
|
+
/** Node: write the restored file here. Without it the bytes come back in `data`. */
|
|
39
|
+
outputPath?: string;
|
|
40
|
+
/** Needed for bytes; default the path's or File's name. */
|
|
41
|
+
file_name?: string;
|
|
42
|
+
content_type?: string;
|
|
43
|
+
metadata?: Record<string, string>;
|
|
44
|
+
label?: string;
|
|
45
|
+
sampling?: Record<string, unknown>;
|
|
46
|
+
/** Which result file to fetch (default `audio`). */
|
|
47
|
+
downloadFile?: GenerationFileName;
|
|
48
|
+
/** Seconds to wait for the restore (default 3600). */
|
|
49
|
+
timeout?: number;
|
|
50
|
+
/** Seconds between polls (default 2). */
|
|
51
|
+
pollInterval?: number;
|
|
52
|
+
/** Called with the generation on every poll. */
|
|
53
|
+
onProgress?: WaitOptions<Generation>["onProgress"];
|
|
54
|
+
onUploadProgress?: (progress: {
|
|
55
|
+
bytes_sent: number;
|
|
56
|
+
bytes_total: number;
|
|
57
|
+
parts_done: number;
|
|
58
|
+
parts_total: number;
|
|
59
|
+
}) => void;
|
|
60
|
+
}
|
|
61
|
+
export interface RestoreAudioResult {
|
|
62
|
+
project: Project;
|
|
63
|
+
generation: Generation;
|
|
64
|
+
/** Where the file was written, when `outputPath` was given. */
|
|
65
|
+
output_path: string | null;
|
|
66
|
+
/** The restored file's bytes, when no `outputPath` was given. */
|
|
67
|
+
data: Uint8Array | null;
|
|
68
|
+
size_bytes: number;
|
|
69
|
+
content_type: string | null;
|
|
8
70
|
}
|
|
71
|
+
/** Client for Diffio API v2 (`https://api.diffio.ai/v2`). */
|
|
9
72
|
export declare class DiffioClient {
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
readonly generations:
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
73
|
+
readonly models: ModelsResource;
|
|
74
|
+
readonly projects: ProjectsResource;
|
|
75
|
+
readonly generations: GenerationsResource;
|
|
76
|
+
readonly edits: EditsResource;
|
|
77
|
+
readonly mix: MixResource;
|
|
78
|
+
readonly exports: ExportsResource;
|
|
79
|
+
readonly transcripts: TranscriptsResource;
|
|
80
|
+
readonly assistant: AssistantResource;
|
|
81
|
+
readonly shares: SharesResource;
|
|
82
|
+
readonly usage: UsageResource;
|
|
83
|
+
readonly webhooks: WebhooksResource;
|
|
84
|
+
protected readonly transport: Transport;
|
|
18
85
|
constructor(options?: DiffioClient.Options);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
filePath: string;
|
|
22
|
-
contentType?: string;
|
|
23
|
-
contentLength?: number;
|
|
24
|
-
params?: Record<string, unknown>;
|
|
25
|
-
fileFormat?: string;
|
|
26
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
27
|
-
}): Promise<CreateProjectResponse>;
|
|
86
|
+
/** The v2 base URL calls go to, such as `https://api.diffio.ai/v2`. */
|
|
87
|
+
baseUrl(): Promise<string>;
|
|
28
88
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
89
|
+
* One call: creates a project with a generation, uploads the file, waits for the restore and downloads the
|
|
90
|
+
* result. Throws DiffioResourceFailedError when the restore fails and DiffioTimeoutError on timeout.
|
|
31
91
|
*/
|
|
32
|
-
|
|
33
|
-
apiProjectId: string;
|
|
34
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
35
|
-
}): Promise<CompleteProjectUploadResponse>;
|
|
36
|
-
/** Sends one edge upload call with the session's upload token; never the API key or SDK default headers. */
|
|
37
|
-
private _sendEdgeUploadRequest;
|
|
38
|
-
/** Retries generation admission only when the caller supplies a nonblank idempotency key. */
|
|
39
|
-
createGeneration(options: {
|
|
40
|
-
apiProjectId: string;
|
|
41
|
-
model?: AcceptedModelKey;
|
|
42
|
-
sampling?: Record<string, unknown>;
|
|
43
|
-
params?: Record<string, unknown>;
|
|
44
|
-
idempotencyKey?: string;
|
|
45
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
46
|
-
}): Promise<CreateGenerationResponse>;
|
|
47
|
-
listProjects(options?: {
|
|
48
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
49
|
-
}): Promise<ListProjectsResponse>;
|
|
50
|
-
listProjectGenerations(options: {
|
|
51
|
-
apiProjectId: string;
|
|
52
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
53
|
-
}): Promise<ListProjectGenerationsResponse>;
|
|
54
|
-
getGenerationProgress(options: {
|
|
55
|
-
generationId: string;
|
|
56
|
-
apiProjectId?: string;
|
|
57
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
58
|
-
}): Promise<GenerationProgressResponse>;
|
|
59
|
-
/** Waits for media completion and settlement; transcription may still be pending or unavailable. */
|
|
60
|
-
waitForGeneration(options: {
|
|
61
|
-
generationId: string;
|
|
62
|
-
apiProjectId?: string;
|
|
63
|
-
pollInterval?: number;
|
|
64
|
-
timeout?: number;
|
|
65
|
-
timeoutInSeconds?: number;
|
|
66
|
-
onProgress?: (progress: GenerationProgressResponse) => void | Promise<void>;
|
|
67
|
-
showProgress?: boolean;
|
|
68
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
69
|
-
}): Promise<GenerationProgressResponse>;
|
|
70
|
-
getGenerationDownload(options: {
|
|
71
|
-
generationId: string;
|
|
72
|
-
apiProjectId: string;
|
|
73
|
-
downloadType?: string;
|
|
74
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
75
|
-
}): Promise<GenerationDownloadResponse>;
|
|
76
|
-
getAccountSettings(options?: {
|
|
77
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
78
|
-
}): Promise<AccountSettingsResponse>;
|
|
79
|
-
updateAccountSettings(options: {
|
|
80
|
-
billingPolicy: Record<string, unknown>;
|
|
81
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
82
|
-
}): Promise<AccountSettingsResponse>;
|
|
83
|
-
createApiKey(options: {
|
|
84
|
-
label: string;
|
|
85
|
-
scopes: string[];
|
|
86
|
-
resourceBounds?: Record<string, unknown>;
|
|
87
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
88
|
-
}): Promise<ApiKeyResponse>;
|
|
89
|
-
listApiKeys(options?: {
|
|
90
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
91
|
-
}): Promise<ApiKeysListResponse>;
|
|
92
|
-
rotateApiKey(options: {
|
|
93
|
-
keyId: string;
|
|
94
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
95
|
-
}): Promise<ApiKeyResponse>;
|
|
96
|
-
revokeApiKey(options: {
|
|
97
|
-
keyId: string;
|
|
98
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
99
|
-
}): Promise<ApiKeyResponse>;
|
|
100
|
-
getUsageSummary(options?: {
|
|
101
|
-
apiKeyId?: string;
|
|
102
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
103
|
-
}): Promise<UsageSummaryResponse>;
|
|
104
|
-
configureWebhook(options: {
|
|
105
|
-
mode: string;
|
|
106
|
-
url: string;
|
|
107
|
-
eventTypes: string[];
|
|
108
|
-
apiKeyId?: string;
|
|
109
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
110
|
-
}): Promise<WebhookConfigureResponse>;
|
|
111
|
-
sendWebhookTestEvent(options: {
|
|
112
|
-
eventType: string;
|
|
113
|
-
mode: string;
|
|
114
|
-
apiKeyId?: string;
|
|
115
|
-
samplePayload?: Record<string, unknown>;
|
|
116
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
117
|
-
}): Promise<WebhookTestEventResponse>;
|
|
118
|
-
restoreAudio(options: {
|
|
119
|
-
filePath: string;
|
|
120
|
-
contentType?: string;
|
|
121
|
-
contentLength?: number;
|
|
122
|
-
fileFormat?: string;
|
|
123
|
-
model?: AcceptedModelKey;
|
|
124
|
-
sampling?: Record<string, unknown>;
|
|
125
|
-
projectParams?: Record<string, unknown>;
|
|
126
|
-
generationParams?: Record<string, unknown>;
|
|
127
|
-
idempotencyKey?: string;
|
|
128
|
-
downloadType?: string;
|
|
129
|
-
pollInterval?: number;
|
|
130
|
-
timeout?: number;
|
|
131
|
-
timeoutInSeconds?: number;
|
|
132
|
-
onProgress?: (progress: GenerationProgressResponse) => void | Promise<void>;
|
|
133
|
-
showProgress?: boolean;
|
|
134
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
135
|
-
progressRequestOptions?: DiffioClient.RequestOptions;
|
|
136
|
-
downloadRequestOptions?: DiffioClient.RequestOptions;
|
|
137
|
-
raiseOnError?: boolean;
|
|
138
|
-
}): Promise<[Uint8Array | null, RestoreMetadata]>;
|
|
139
|
-
restore(options: Parameters<DiffioClient["restoreAudio"]>[0]): Promise<[Uint8Array | null, RestoreMetadata]>;
|
|
140
|
-
audioIsolationIsolate(options: {
|
|
141
|
-
filePath: string;
|
|
142
|
-
contentType?: string;
|
|
143
|
-
contentLength?: number;
|
|
144
|
-
fileFormat?: string;
|
|
145
|
-
model?: AcceptedModelKey;
|
|
146
|
-
sampling?: Record<string, unknown>;
|
|
147
|
-
projectParams?: Record<string, unknown>;
|
|
148
|
-
generationParams?: Record<string, unknown>;
|
|
149
|
-
idempotencyKey?: string;
|
|
150
|
-
requestOptions?: DiffioClient.RequestOptions;
|
|
151
|
-
}): Promise<AudioIsolationResult>;
|
|
152
|
-
private _downloadBinary;
|
|
153
|
-
private _requestJson;
|
|
154
|
-
private _requestBinary;
|
|
155
|
-
private _buildRequest;
|
|
92
|
+
restoreAudio(params: RestoreAudioParams): Promise<RestoreAudioResult>;
|
|
156
93
|
}
|