diffio 0.1.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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +204 -0
  3. package/dist/BaseClient.d.ts +26 -0
  4. package/dist/BaseClient.js +17 -0
  5. package/dist/Client.d.ts +109 -0
  6. package/dist/Client.js +689 -0
  7. package/dist/api/index.d.ts +2 -0
  8. package/dist/api/index.js +18 -0
  9. package/dist/api/resources/audioIsolation/client/Client.d.ts +41 -0
  10. package/dist/api/resources/audioIsolation/client/Client.js +32 -0
  11. package/dist/api/resources/generations/client/Client.d.ts +47 -0
  12. package/dist/api/resources/generations/client/Client.js +36 -0
  13. package/dist/api/resources/index.d.ts +4 -0
  14. package/dist/api/resources/index.js +11 -0
  15. package/dist/api/resources/projects/client/Client.d.ts +15 -0
  16. package/dist/api/resources/projects/client/Client.js +15 -0
  17. package/dist/api/resources/webhooks/client/Client.d.ts +20 -0
  18. package/dist/api/resources/webhooks/client/Client.js +15 -0
  19. package/dist/api/serialization.d.ts +14 -0
  20. package/dist/api/serialization.js +138 -0
  21. package/dist/api/types.d.ts +122 -0
  22. package/dist/api/types.js +2 -0
  23. package/dist/core/headers.d.ts +6 -0
  24. package/dist/core/headers.js +44 -0
  25. package/dist/core/retry.d.ts +7 -0
  26. package/dist/core/retry.js +31 -0
  27. package/dist/core/supplier.d.ts +4 -0
  28. package/dist/core/supplier.js +14 -0
  29. package/dist/core/url.d.ts +1 -0
  30. package/dist/core/url.js +14 -0
  31. package/dist/errors/index.d.ts +14 -0
  32. package/dist/errors/index.js +26 -0
  33. package/dist/index.d.ts +4 -0
  34. package/dist/index.js +45 -0
  35. package/dist/version.d.ts +1 -0
  36. package/dist/version.js +4 -0
  37. package/package.json +36 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./resources"), exports);
@@ -0,0 +1,41 @@
1
+ import type { DiffioClient } from "../../../../Client";
2
+ import type { AudioIsolationResult, RestoreMetadata } from "../../../types";
3
+ export interface AudioIsolationRestoreOptions {
4
+ filePath: string;
5
+ contentType?: string;
6
+ contentLength?: number;
7
+ fileFormat?: string;
8
+ model?: string;
9
+ sampling?: Record<string, unknown>;
10
+ projectParams?: Record<string, unknown>;
11
+ generationParams?: Record<string, unknown>;
12
+ downloadType?: string;
13
+ pollInterval?: number;
14
+ timeout?: number;
15
+ timeoutInSeconds?: number;
16
+ onProgress?: (progress: unknown) => void | Promise<void>;
17
+ showProgress?: boolean;
18
+ requestOptions?: DiffioClient.RequestOptions;
19
+ progressRequestOptions?: DiffioClient.RequestOptions;
20
+ downloadRequestOptions?: DiffioClient.RequestOptions;
21
+ raiseOnError?: boolean;
22
+ }
23
+ export interface AudioIsolationIsolateOptions {
24
+ filePath: string;
25
+ contentType?: string;
26
+ contentLength?: number;
27
+ fileFormat?: string;
28
+ model?: string;
29
+ sampling?: Record<string, unknown>;
30
+ projectParams?: Record<string, unknown>;
31
+ generationParams?: Record<string, unknown>;
32
+ requestOptions?: DiffioClient.RequestOptions;
33
+ }
34
+ export declare class AudioIsolationClient {
35
+ private _parent;
36
+ constructor(parent: DiffioClient);
37
+ convert(options: AudioIsolationIsolateOptions): Promise<AudioIsolationResult>;
38
+ isolate(options: AudioIsolationIsolateOptions): Promise<AudioIsolationResult>;
39
+ restoreAudio(options: AudioIsolationRestoreOptions): Promise<[Uint8Array | null, RestoreMetadata]>;
40
+ restore(options: AudioIsolationRestoreOptions): Promise<[Uint8Array | null, RestoreMetadata]>;
41
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudioIsolationClient = void 0;
4
+ class AudioIsolationClient {
5
+ constructor(parent) {
6
+ this._parent = parent;
7
+ }
8
+ async convert(options) {
9
+ return this.isolate(options);
10
+ }
11
+ async isolate(options) {
12
+ const { filePath, contentType, contentLength, fileFormat, model, sampling, projectParams, generationParams, requestOptions } = options;
13
+ return this._parent.audioIsolationIsolate({
14
+ filePath,
15
+ contentType,
16
+ contentLength,
17
+ fileFormat,
18
+ model,
19
+ sampling,
20
+ projectParams,
21
+ generationParams,
22
+ requestOptions
23
+ });
24
+ }
25
+ async restoreAudio(options) {
26
+ return this._parent.restoreAudio(options);
27
+ }
28
+ async restore(options) {
29
+ return this.restoreAudio(options);
30
+ }
31
+ }
32
+ exports.AudioIsolationClient = AudioIsolationClient;
@@ -0,0 +1,47 @@
1
+ import type { DiffioClient } from "../../../../Client";
2
+ import type { CreateGenerationResponse, GenerationDownloadResponse, GenerationProgressResponse } from "../../../types";
3
+ export interface GenerationCreateOptions {
4
+ apiProjectId: string;
5
+ model?: string;
6
+ sampling?: Record<string, unknown>;
7
+ params?: Record<string, unknown>;
8
+ requestOptions?: DiffioClient.RequestOptions;
9
+ }
10
+ export interface GenerationProgressOptions {
11
+ generationId: string;
12
+ apiProjectId?: string;
13
+ requestOptions?: DiffioClient.RequestOptions;
14
+ }
15
+ export interface GenerationDownloadOptions {
16
+ generationId: string;
17
+ apiProjectId: string;
18
+ downloadType?: string;
19
+ requestOptions?: DiffioClient.RequestOptions;
20
+ }
21
+ export interface GenerationWaitOptions {
22
+ generationId: string;
23
+ apiProjectId?: string;
24
+ pollInterval?: number;
25
+ timeout?: number;
26
+ timeoutInSeconds?: number;
27
+ onProgress?: (progress: GenerationProgressResponse) => void | Promise<void>;
28
+ showProgress?: boolean;
29
+ requestOptions?: DiffioClient.RequestOptions;
30
+ }
31
+ export interface GenerationCreateAndWaitOptions extends GenerationCreateOptions {
32
+ pollInterval?: number;
33
+ timeout?: number;
34
+ timeoutInSeconds?: number;
35
+ onProgress?: (progress: GenerationProgressResponse) => void | Promise<void>;
36
+ showProgress?: boolean;
37
+ progressRequestOptions?: DiffioClient.RequestOptions;
38
+ }
39
+ export declare class GenerationsClient {
40
+ private _parent;
41
+ constructor(parent: DiffioClient);
42
+ create(options: GenerationCreateOptions): Promise<CreateGenerationResponse>;
43
+ getProgress(options: GenerationProgressOptions): Promise<GenerationProgressResponse>;
44
+ getDownload(options: GenerationDownloadOptions): Promise<GenerationDownloadResponse>;
45
+ waitForComplete(options: GenerationWaitOptions): Promise<GenerationProgressResponse>;
46
+ createAndWait(options: GenerationCreateAndWaitOptions): Promise<[CreateGenerationResponse, GenerationProgressResponse]>;
47
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerationsClient = void 0;
4
+ class GenerationsClient {
5
+ constructor(parent) {
6
+ this._parent = parent;
7
+ }
8
+ async create(options) {
9
+ return this._parent.createGeneration(options);
10
+ }
11
+ async getProgress(options) {
12
+ return this._parent.getGenerationProgress(options);
13
+ }
14
+ async getDownload(options) {
15
+ return this._parent.getGenerationDownload(options);
16
+ }
17
+ async waitForComplete(options) {
18
+ return this._parent.waitForGeneration(options);
19
+ }
20
+ async createAndWait(options) {
21
+ const { progressRequestOptions, ...createOptions } = options;
22
+ const generation = await this.create(createOptions);
23
+ const progress = await this.waitForComplete({
24
+ generationId: generation.generationId,
25
+ apiProjectId: generation.apiProjectId,
26
+ pollInterval: options.pollInterval,
27
+ timeout: options.timeout,
28
+ timeoutInSeconds: options.timeoutInSeconds,
29
+ onProgress: options.onProgress,
30
+ showProgress: options.showProgress,
31
+ requestOptions: progressRequestOptions ?? options.requestOptions
32
+ });
33
+ return [generation, progress];
34
+ }
35
+ }
36
+ exports.GenerationsClient = GenerationsClient;
@@ -0,0 +1,4 @@
1
+ export { AudioIsolationClient } from "./audioIsolation/client/Client";
2
+ export { GenerationsClient } from "./generations/client/Client";
3
+ export { ProjectsClient } from "./projects/client/Client";
4
+ export { WebhooksClient } from "./webhooks/client/Client";
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebhooksClient = exports.ProjectsClient = exports.GenerationsClient = exports.AudioIsolationClient = void 0;
4
+ var Client_1 = require("./audioIsolation/client/Client");
5
+ Object.defineProperty(exports, "AudioIsolationClient", { enumerable: true, get: function () { return Client_1.AudioIsolationClient; } });
6
+ var Client_2 = require("./generations/client/Client");
7
+ Object.defineProperty(exports, "GenerationsClient", { enumerable: true, get: function () { return Client_2.GenerationsClient; } });
8
+ var Client_3 = require("./projects/client/Client");
9
+ Object.defineProperty(exports, "ProjectsClient", { enumerable: true, get: function () { return Client_3.ProjectsClient; } });
10
+ var Client_4 = require("./webhooks/client/Client");
11
+ Object.defineProperty(exports, "WebhooksClient", { enumerable: true, get: function () { return Client_4.WebhooksClient; } });
@@ -0,0 +1,15 @@
1
+ import type { DiffioClient } from "../../../../Client";
2
+ import type { ListProjectGenerationsResponse, ListProjectsResponse } from "../../../types";
3
+ export interface ProjectsListOptions {
4
+ requestOptions?: DiffioClient.RequestOptions;
5
+ }
6
+ export interface ProjectsListGenerationsOptions {
7
+ apiProjectId: string;
8
+ requestOptions?: DiffioClient.RequestOptions;
9
+ }
10
+ export declare class ProjectsClient {
11
+ private _parent;
12
+ constructor(parent: DiffioClient);
13
+ list(options?: ProjectsListOptions): Promise<ListProjectsResponse>;
14
+ listGenerations(options: ProjectsListGenerationsOptions): Promise<ListProjectGenerationsResponse>;
15
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectsClient = void 0;
4
+ class ProjectsClient {
5
+ constructor(parent) {
6
+ this._parent = parent;
7
+ }
8
+ async list(options = {}) {
9
+ return this._parent.listProjects(options);
10
+ }
11
+ async listGenerations(options) {
12
+ return this._parent.listProjectGenerations(options);
13
+ }
14
+ }
15
+ exports.ProjectsClient = ProjectsClient;
@@ -0,0 +1,20 @@
1
+ import type { DiffioClient } from "../../../../Client";
2
+ import type { WebhookPortalResponse, WebhookTestEventResponse } from "../../../types";
3
+ export interface WebhookPortalAccessOptions {
4
+ mode: string;
5
+ apiKeyId?: string;
6
+ requestOptions?: DiffioClient.RequestOptions;
7
+ }
8
+ export interface WebhookTestEventOptions {
9
+ eventType: string;
10
+ mode: string;
11
+ apiKeyId?: string;
12
+ samplePayload?: Record<string, unknown>;
13
+ requestOptions?: DiffioClient.RequestOptions;
14
+ }
15
+ export declare class WebhooksClient {
16
+ private _parent;
17
+ constructor(parent: DiffioClient);
18
+ getPortalAccess(options: WebhookPortalAccessOptions): Promise<WebhookPortalResponse>;
19
+ sendTestEvent(options: WebhookTestEventOptions): Promise<WebhookTestEventResponse>;
20
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebhooksClient = void 0;
4
+ class WebhooksClient {
5
+ constructor(parent) {
6
+ this._parent = parent;
7
+ }
8
+ async getPortalAccess(options) {
9
+ return this._parent.getWebhooksPortalAccess(options);
10
+ }
11
+ async sendTestEvent(options) {
12
+ return this._parent.sendWebhookTestEvent(options);
13
+ }
14
+ }
15
+ exports.WebhooksClient = WebhooksClient;
@@ -0,0 +1,14 @@
1
+ import type { AudioIsolationResult, CreateGenerationResponse, CreateProjectResponse, GenerationWebhookEvent, GenerationDownloadResponse, GenerationProgressResponse, GenerationProgressStage, ListProjectGenerationsResponse, ListProjectsResponse, ProjectGenerationSummary, ProjectSummary, WebhookPortalResponse, WebhookTestEventResponse } from "./types";
2
+ export declare function parseCreateProjectResponse(data: any): CreateProjectResponse;
3
+ export declare function parseProjectSummary(data: any): ProjectSummary;
4
+ export declare function parseListProjectsResponse(data: any): ListProjectsResponse;
5
+ export declare function parseCreateGenerationResponse(data: any): CreateGenerationResponse;
6
+ export declare function parseProjectGenerationSummary(data: any): ProjectGenerationSummary;
7
+ export declare function parseListProjectGenerationsResponse(data: any): ListProjectGenerationsResponse;
8
+ export declare function parseGenerationProgressStage(data: any): GenerationProgressStage;
9
+ export declare function parseGenerationProgressResponse(data: any): GenerationProgressResponse;
10
+ export declare function parseGenerationDownloadResponse(data: any): GenerationDownloadResponse;
11
+ export declare function parseWebhookPortalResponse(data: any): WebhookPortalResponse;
12
+ export declare function parseWebhookTestEventResponse(data: any): WebhookTestEventResponse;
13
+ export declare function parseGenerationWebhookEvent(data: any): GenerationWebhookEvent;
14
+ export declare function createAudioIsolationResult(project: CreateProjectResponse, generation: CreateGenerationResponse): AudioIsolationResult;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCreateProjectResponse = parseCreateProjectResponse;
4
+ exports.parseProjectSummary = parseProjectSummary;
5
+ exports.parseListProjectsResponse = parseListProjectsResponse;
6
+ exports.parseCreateGenerationResponse = parseCreateGenerationResponse;
7
+ exports.parseProjectGenerationSummary = parseProjectGenerationSummary;
8
+ exports.parseListProjectGenerationsResponse = parseListProjectGenerationsResponse;
9
+ exports.parseGenerationProgressStage = parseGenerationProgressStage;
10
+ exports.parseGenerationProgressResponse = parseGenerationProgressResponse;
11
+ exports.parseGenerationDownloadResponse = parseGenerationDownloadResponse;
12
+ exports.parseWebhookPortalResponse = parseWebhookPortalResponse;
13
+ exports.parseWebhookTestEventResponse = parseWebhookTestEventResponse;
14
+ exports.parseGenerationWebhookEvent = parseGenerationWebhookEvent;
15
+ exports.createAudioIsolationResult = createAudioIsolationResult;
16
+ function parseCreateProjectResponse(data) {
17
+ return {
18
+ apiProjectId: data.apiProjectId,
19
+ uploadUrl: data.uploadUrl,
20
+ uploadMethod: data.uploadMethod || "PUT",
21
+ objectPath: data.objectPath,
22
+ bucket: data.bucket,
23
+ expiresAt: data.expiresAt
24
+ };
25
+ }
26
+ function parseProjectSummary(data) {
27
+ return {
28
+ apiProjectId: data.apiProjectId,
29
+ status: data.status || "uploading",
30
+ originalFileName: data.originalFileName ?? null,
31
+ contentType: data.contentType ?? null,
32
+ hasVideo: Boolean(data.hasVideo),
33
+ generationCount: Number(data.generationCount || 0),
34
+ createdAt: data.createdAt ?? null,
35
+ updatedAt: data.updatedAt ?? null
36
+ };
37
+ }
38
+ function parseListProjectsResponse(data) {
39
+ const items = Array.isArray(data?.projects) ? data.projects : [];
40
+ return { projects: items.filter(Boolean).map(parseProjectSummary) };
41
+ }
42
+ function parseCreateGenerationResponse(data) {
43
+ return {
44
+ generationId: data.generationId,
45
+ apiProjectId: data.apiProjectId,
46
+ modelKey: data.modelKey,
47
+ status: data.status
48
+ };
49
+ }
50
+ function parseProjectGenerationSummary(data) {
51
+ const progress = data.progress;
52
+ return {
53
+ generationId: data.generationId,
54
+ status: data.status || "queued",
55
+ modelKey: data.modelKey ?? null,
56
+ progress: progress != null ? Number(progress) : null,
57
+ createdAt: data.createdAt ?? null,
58
+ updatedAt: data.updatedAt ?? null
59
+ };
60
+ }
61
+ function parseListProjectGenerationsResponse(data) {
62
+ const items = Array.isArray(data?.generations) ? data.generations : [];
63
+ return {
64
+ apiProjectId: data.apiProjectId,
65
+ generations: items.filter(Boolean).map(parseProjectGenerationSummary)
66
+ };
67
+ }
68
+ function parseGenerationProgressStage(data) {
69
+ return {
70
+ jobId: data?.jobId ?? null,
71
+ jobState: data?.jobState ?? null,
72
+ status: data?.status || "pending",
73
+ progress: Number(data?.progress || 0),
74
+ statusMessage: data?.statusMessage ?? null,
75
+ error: data?.error ?? null,
76
+ errorDetails: data?.errorDetails ?? null
77
+ };
78
+ }
79
+ function parseGenerationProgressResponse(data) {
80
+ const restoredVideo = data?.restoredVideo;
81
+ return {
82
+ generationId: data.generationId,
83
+ apiProjectId: data.apiProjectId,
84
+ status: data.status,
85
+ hasVideo: Boolean(data.hasVideo),
86
+ preProcessing: parseGenerationProgressStage(data.preProcessing),
87
+ inference: parseGenerationProgressStage(data.inference),
88
+ restoredVideo: restoredVideo ? parseGenerationProgressStage(restoredVideo) : null,
89
+ error: data.error ?? null,
90
+ errorDetails: data.errorDetails ?? null
91
+ };
92
+ }
93
+ function parseGenerationDownloadResponse(data) {
94
+ return {
95
+ generationId: data.generationId,
96
+ apiProjectId: data.apiProjectId,
97
+ downloadType: data.downloadType,
98
+ downloadUrl: data.downloadUrl,
99
+ fileName: data.fileName,
100
+ storagePath: data.storagePath,
101
+ bucket: data.bucket,
102
+ mimeType: data.mimeType
103
+ };
104
+ }
105
+ function parseWebhookPortalResponse(data) {
106
+ return {
107
+ portalUrl: data.portalUrl,
108
+ mode: data.mode ?? null,
109
+ apiKeyId: data.apiKeyId ?? null
110
+ };
111
+ }
112
+ function parseWebhookTestEventResponse(data) {
113
+ return {
114
+ svixMessageId: data.svixMessageId,
115
+ eventId: data.eventId,
116
+ eventType: data.eventType,
117
+ mode: data.mode ?? null,
118
+ apiKeyId: data.apiKeyId ?? null
119
+ };
120
+ }
121
+ function parseGenerationWebhookEvent(data) {
122
+ return {
123
+ eventType: data.eventType,
124
+ eventId: data.eventId,
125
+ createdAt: data.createdAt,
126
+ apiKeyId: data.apiKeyId,
127
+ apiProjectId: data.apiProjectId ?? null,
128
+ generationId: data.generationId,
129
+ status: data.status,
130
+ hasVideo: data.hasVideo ?? null,
131
+ modelKey: data.modelKey ?? null,
132
+ error: data.error ?? null,
133
+ errorDetails: data.errorDetails ?? null
134
+ };
135
+ }
136
+ function createAudioIsolationResult(project, generation) {
137
+ return { project, generation };
138
+ }
@@ -0,0 +1,122 @@
1
+ export type ModelKey = "diffio-2" | "diffio-2-flash" | "diffio-3";
2
+ export type DownloadType = "audio" | "video";
3
+ export type WebhookMode = "test" | "live";
4
+ export type WebhookEventType = "generation.queued" | "generation.processing" | "generation.failed" | "generation.completed";
5
+ export type GenerationWebhookStatus = "queued" | "processing" | "error" | "complete";
6
+ export interface CreateProjectResponse {
7
+ apiProjectId: string;
8
+ uploadUrl: string;
9
+ uploadMethod: string;
10
+ objectPath: string;
11
+ bucket: string;
12
+ expiresAt: string;
13
+ }
14
+ export interface ProjectSummary {
15
+ apiProjectId: string;
16
+ status: string;
17
+ originalFileName?: string | null;
18
+ contentType?: string | null;
19
+ hasVideo: boolean;
20
+ generationCount: number;
21
+ createdAt?: string | null;
22
+ updatedAt?: string | null;
23
+ }
24
+ export interface ListProjectsResponse {
25
+ projects: ProjectSummary[];
26
+ }
27
+ export interface CreateGenerationResponse {
28
+ generationId: string;
29
+ apiProjectId: string;
30
+ modelKey: ModelKey | string;
31
+ status: string;
32
+ }
33
+ export interface ProjectGenerationSummary {
34
+ generationId: string;
35
+ status: string;
36
+ modelKey?: ModelKey | string | null;
37
+ progress?: number | null;
38
+ createdAt?: string | null;
39
+ updatedAt?: string | null;
40
+ }
41
+ export interface ListProjectGenerationsResponse {
42
+ apiProjectId: string;
43
+ generations: ProjectGenerationSummary[];
44
+ }
45
+ export interface GenerationProgressStage {
46
+ jobId?: string | null;
47
+ jobState?: string | null;
48
+ status: string;
49
+ progress: number;
50
+ statusMessage?: string | null;
51
+ error?: string | null;
52
+ errorDetails?: string | null;
53
+ }
54
+ export interface GenerationProgressResponse {
55
+ generationId: string;
56
+ apiProjectId: string;
57
+ status: string;
58
+ hasVideo: boolean;
59
+ preProcessing: GenerationProgressStage;
60
+ inference: GenerationProgressStage;
61
+ restoredVideo?: GenerationProgressStage | null;
62
+ error?: string | null;
63
+ errorDetails?: string | null;
64
+ }
65
+ export interface GenerationDownloadResponse {
66
+ generationId: string;
67
+ apiProjectId: string;
68
+ downloadType: DownloadType | string;
69
+ downloadUrl: string;
70
+ fileName: string;
71
+ storagePath: string;
72
+ bucket: string;
73
+ mimeType: string;
74
+ }
75
+ export interface AudioIsolationResult {
76
+ project: CreateProjectResponse;
77
+ generation: CreateGenerationResponse;
78
+ }
79
+ export interface WebhookPortalResponse {
80
+ portalUrl: string;
81
+ mode?: WebhookMode | string | null;
82
+ apiKeyId?: string | null;
83
+ }
84
+ export interface WebhookTestEventResponse {
85
+ svixMessageId: string;
86
+ eventId: string;
87
+ eventType: WebhookEventType | string;
88
+ mode?: WebhookMode | string | null;
89
+ apiKeyId?: string | null;
90
+ }
91
+ export interface GenerationWebhookEvent {
92
+ eventType: WebhookEventType | string;
93
+ eventId: string;
94
+ createdAt: string;
95
+ apiKeyId: string;
96
+ apiProjectId?: string | null;
97
+ generationId: string;
98
+ status: GenerationWebhookStatus | string;
99
+ hasVideo?: boolean | null;
100
+ modelKey?: ModelKey | string | null;
101
+ error?: string | null;
102
+ errorDetails?: string | null;
103
+ }
104
+ export interface RestoreMetadata {
105
+ ok: boolean;
106
+ stage: string;
107
+ apiProjectId: string | null;
108
+ generationId: string | null;
109
+ project: CreateProjectResponse | null;
110
+ generation: CreateGenerationResponse | null;
111
+ progress: GenerationProgressResponse | null;
112
+ download: GenerationDownloadResponse | null;
113
+ downloadType: DownloadType | string | null;
114
+ downloadUrl: string | null;
115
+ fileName: string | null;
116
+ mimeType: string | null;
117
+ status: string | null;
118
+ error: string | null;
119
+ errorDetails: string | null;
120
+ exceptionType: string | null;
121
+ exceptionMessage: string | null;
122
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { type Supplier as SupplierType } from "./supplier";
2
+ export type HeaderValue = string | SupplierType<string | null | undefined> | null | undefined;
3
+ export type HeaderRecord = Record<string, HeaderValue>;
4
+ export declare function mergeHeaders(...sets: Array<HeaderRecord | null | undefined>): HeaderRecord;
5
+ export declare function mergeOnlyDefinedHeaders(headers: HeaderRecord): HeaderRecord;
6
+ export declare function resolveHeaders(headers: HeaderRecord | null | undefined): Promise<Record<string, string>>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeHeaders = mergeHeaders;
4
+ exports.mergeOnlyDefinedHeaders = mergeOnlyDefinedHeaders;
5
+ exports.resolveHeaders = resolveHeaders;
6
+ const supplier_1 = require("./supplier");
7
+ function mergeHeaders(...sets) {
8
+ const result = {};
9
+ for (const set of sets) {
10
+ if (!set) {
11
+ continue;
12
+ }
13
+ for (const [key, value] of Object.entries(set)) {
14
+ result[key] = value;
15
+ }
16
+ }
17
+ return result;
18
+ }
19
+ function mergeOnlyDefinedHeaders(headers) {
20
+ const result = {};
21
+ for (const [key, value] of Object.entries(headers)) {
22
+ if (value !== undefined) {
23
+ result[key] = value;
24
+ }
25
+ }
26
+ return result;
27
+ }
28
+ async function resolveHeaders(headers) {
29
+ const resolved = {};
30
+ if (!headers) {
31
+ return resolved;
32
+ }
33
+ for (const [key, value] of Object.entries(headers)) {
34
+ if (value == null) {
35
+ continue;
36
+ }
37
+ const resolvedValue = await supplier_1.Supplier.get(value);
38
+ if (resolvedValue == null) {
39
+ continue;
40
+ }
41
+ resolved[key] = resolvedValue;
42
+ }
43
+ return resolved;
44
+ }
@@ -0,0 +1,7 @@
1
+ export declare function sleep(ms: number): Promise<void>;
2
+ export interface RetryOptions {
3
+ maxRetries: number;
4
+ retryBackoff: number;
5
+ retryStatusCodes: number[];
6
+ }
7
+ export declare function requestWithRetries(requestFn: () => Promise<Response>, { maxRetries, retryBackoff, retryStatusCodes }: RetryOptions): Promise<Response>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = sleep;
4
+ exports.requestWithRetries = requestWithRetries;
5
+ function sleep(ms) {
6
+ return new Promise((resolve) => setTimeout(resolve, ms));
7
+ }
8
+ async function requestWithRetries(requestFn, { maxRetries, retryBackoff, retryStatusCodes }) {
9
+ let attempt = 0;
10
+ while (true) {
11
+ try {
12
+ const response = await requestFn();
13
+ if (retryStatusCodes.length > 0 &&
14
+ retryStatusCodes.includes(response.status) &&
15
+ attempt < maxRetries) {
16
+ response.body?.cancel?.();
17
+ await sleep(retryBackoff * 1000 * 2 ** attempt);
18
+ attempt += 1;
19
+ continue;
20
+ }
21
+ return response;
22
+ }
23
+ catch (error) {
24
+ if (attempt >= maxRetries) {
25
+ throw error;
26
+ }
27
+ await sleep(retryBackoff * 1000 * 2 ** attempt);
28
+ attempt += 1;
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,4 @@
1
+ export type Supplier<T> = T | (() => T | Promise<T>);
2
+ export declare const Supplier: {
3
+ get<T>(value: Supplier<T> | null | undefined): Promise<T | undefined>;
4
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Supplier = void 0;
4
+ exports.Supplier = {
5
+ async get(value) {
6
+ if (value == null) {
7
+ return undefined;
8
+ }
9
+ if (typeof value === "function") {
10
+ return value();
11
+ }
12
+ return value;
13
+ }
14
+ };
@@ -0,0 +1 @@
1
+ export declare function join(base: string, ...paths: string[]): string;