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.
Files changed (60) hide show
  1. package/README.md +208 -296
  2. package/dist/Client.d.ts +85 -148
  3. package/dist/Client.js +73 -798
  4. package/dist/api/resources/account.d.ts +38 -0
  5. package/dist/api/resources/account.js +96 -0
  6. package/dist/api/resources/editing.d.ts +54 -0
  7. package/dist/api/resources/editing.js +168 -0
  8. package/dist/api/resources/generations.d.ts +52 -0
  9. package/dist/api/resources/generations.js +145 -0
  10. package/dist/api/resources/index.d.ts +5 -7
  11. package/dist/api/resources/index.js +18 -15
  12. package/dist/api/resources/models.d.ts +9 -0
  13. package/dist/api/resources/models.js +23 -0
  14. package/dist/api/resources/projects.d.ts +51 -0
  15. package/dist/api/resources/projects.js +128 -0
  16. package/dist/api/types.d.ts +423 -222
  17. package/dist/api/types.js +2 -0
  18. package/dist/core/edgeUpload.d.ts +39 -39
  19. package/dist/core/edgeUpload.js +170 -125
  20. package/dist/core/files.d.ts +15 -0
  21. package/dist/core/files.js +121 -0
  22. package/dist/core/node.d.ts +7 -0
  23. package/dist/core/node.js +17 -0
  24. package/dist/core/pagination.d.ts +33 -0
  25. package/dist/core/pagination.js +64 -0
  26. package/dist/core/poll.d.ts +23 -0
  27. package/dist/core/poll.js +30 -0
  28. package/dist/core/retry.d.ts +8 -7
  29. package/dist/core/retry.js +39 -25
  30. package/dist/core/transport.d.ts +75 -0
  31. package/dist/core/transport.js +220 -0
  32. package/dist/core/url.d.ts +10 -0
  33. package/dist/core/url.js +38 -0
  34. package/dist/core/webhookSignature.d.ts +20 -0
  35. package/dist/core/webhookSignature.js +147 -0
  36. package/dist/errors/index.d.ts +60 -18
  37. package/dist/errors/index.js +61 -13
  38. package/dist/index.d.ts +8 -1
  39. package/dist/index.js +9 -1
  40. package/dist/version.d.ts +1 -1
  41. package/dist/version.js +1 -1
  42. package/package.json +2 -7
  43. package/dist/BaseClient.d.ts +0 -26
  44. package/dist/BaseClient.js +0 -17
  45. package/dist/api/resources/account/client/Client.d.ts +0 -15
  46. package/dist/api/resources/account/client/Client.js +0 -15
  47. package/dist/api/resources/apiKeys/client/Client.d.ts +0 -27
  48. package/dist/api/resources/apiKeys/client/Client.js +0 -21
  49. package/dist/api/resources/audioIsolation/client/Client.d.ts +0 -43
  50. package/dist/api/resources/audioIsolation/client/Client.js +0 -33
  51. package/dist/api/resources/generations/client/Client.d.ts +0 -48
  52. package/dist/api/resources/generations/client/Client.js +0 -36
  53. package/dist/api/resources/projects/client/Client.d.ts +0 -21
  54. package/dist/api/resources/projects/client/Client.js +0 -19
  55. package/dist/api/resources/usage/client/Client.d.ts +0 -11
  56. package/dist/api/resources/usage/client/Client.js +0 -12
  57. package/dist/api/resources/webhooks/client/Client.d.ts +0 -29
  58. package/dist/api/resources/webhooks/client/Client.js +0 -76
  59. package/dist/api/serialization.d.ts +0 -21
  60. package/dist/api/serialization.js +0 -274
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ // Verifies Diffio webhook deliveries. Diffio delivers webhooks through Svix, so a delivery carries
3
+ // `svix-id`, `svix-timestamp` and `svix-signature` headers, and the endpoint's signing secret starts
4
+ // `whsec_`. The signature is base64(HMAC-SHA256(key = base64-decoded secret, "{id}.{timestamp}.{raw body}")),
5
+ // listed as space-separated `v1,<signature>` entries. Node uses node:crypto (sync); any runtime with
6
+ // WebCrypto (browsers, Deno, Cloudflare Workers, Bun, Node 18+) can use the async variant.
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.verifyWebhookSignature = verifyWebhookSignature;
9
+ exports.verifyWebhookSignatureAsync = verifyWebhookSignatureAsync;
10
+ exports.signWebhookPayload = signWebhookPayload;
11
+ const errors_1 = require("../errors");
12
+ const node_1 = require("./node");
13
+ const SIGNATURE_PREFIX = "v1,";
14
+ function headerValue(headers, name) {
15
+ if (typeof Headers !== "undefined" && headers instanceof Headers)
16
+ return headers.get(name);
17
+ const record = headers;
18
+ for (const [key, value] of Object.entries(record)) {
19
+ if (key.toLowerCase() !== name || value == null)
20
+ continue;
21
+ return Array.isArray(value) ? value.join(" ") : String(value);
22
+ }
23
+ return null;
24
+ }
25
+ function payloadText(payload) {
26
+ if (typeof payload === "string")
27
+ return payload;
28
+ const bytes = payload instanceof Uint8Array ? payload : new Uint8Array(payload);
29
+ return new TextDecoder().decode(bytes);
30
+ }
31
+ function decodeBase64(text) {
32
+ if (typeof Buffer !== "undefined")
33
+ return new Uint8Array(Buffer.from(text, "base64"));
34
+ const binary = atob(text);
35
+ const bytes = new Uint8Array(binary.length);
36
+ for (let index = 0; index < binary.length; index += 1)
37
+ bytes[index] = binary.charCodeAt(index);
38
+ return bytes;
39
+ }
40
+ function encodeBase64(bytes) {
41
+ if (typeof Buffer !== "undefined")
42
+ return Buffer.from(bytes).toString("base64");
43
+ let binary = "";
44
+ for (const byte of bytes)
45
+ binary += String.fromCharCode(byte);
46
+ return btoa(binary);
47
+ }
48
+ function secretKey(secret) {
49
+ if (typeof secret !== "string" || !secret.trim()) {
50
+ throw new errors_1.DiffioWebhookVerificationError("The webhook signing secret is required (it starts whsec_).");
51
+ }
52
+ const trimmed = secret.trim();
53
+ return decodeBase64(trimmed.startsWith("whsec_") ? trimmed.slice("whsec_".length) : trimmed);
54
+ }
55
+ function prepare(payload, headers, options) {
56
+ if (!headers)
57
+ throw new errors_1.DiffioWebhookVerificationError("Webhook headers are required.");
58
+ const id = headerValue(headers, "svix-id") ?? headerValue(headers, "webhook-id");
59
+ const timestamp = headerValue(headers, "svix-timestamp") ?? headerValue(headers, "webhook-timestamp");
60
+ const signature = headerValue(headers, "svix-signature") ?? headerValue(headers, "webhook-signature");
61
+ const missing = [
62
+ id ? null : "svix-id",
63
+ timestamp ? null : "svix-timestamp",
64
+ signature ? null : "svix-signature"
65
+ ].filter(Boolean);
66
+ if (missing.length > 0)
67
+ throw new errors_1.DiffioWebhookVerificationError(`Missing webhook headers: ${missing.join(", ")}`);
68
+ const seconds = Number(timestamp);
69
+ if (!Number.isFinite(seconds))
70
+ throw new errors_1.DiffioWebhookVerificationError("Invalid svix-timestamp header.");
71
+ const now = options?.now ?? Math.floor(Date.now() / 1000);
72
+ const tolerance = options?.toleranceSeconds ?? 300;
73
+ if (now - seconds > tolerance)
74
+ throw new errors_1.DiffioWebhookVerificationError("Webhook timestamp is too old.");
75
+ if (seconds - now > tolerance)
76
+ throw new errors_1.DiffioWebhookVerificationError("Webhook timestamp is in the future.");
77
+ const signatures = String(signature)
78
+ .split(" ")
79
+ .map((entry) => entry.trim())
80
+ .filter((entry) => entry.startsWith(SIGNATURE_PREFIX))
81
+ .map((entry) => entry.slice(SIGNATURE_PREFIX.length));
82
+ if (signatures.length === 0)
83
+ throw new errors_1.DiffioWebhookVerificationError("No v1 signature in svix-signature.");
84
+ const body = payloadText(payload);
85
+ return { signedContent: `${id}.${timestamp}.${body}`, signatures, body };
86
+ }
87
+ function constantTimeEqual(left, right) {
88
+ if (left.length !== right.length)
89
+ return false;
90
+ let difference = 0;
91
+ for (let index = 0; index < left.length; index += 1)
92
+ difference |= left.charCodeAt(index) ^ right.charCodeAt(index);
93
+ return difference === 0;
94
+ }
95
+ function finish(prepared, expected) {
96
+ if (!prepared.signatures.some((signature) => constantTimeEqual(signature, expected))) {
97
+ throw new errors_1.DiffioWebhookVerificationError("Webhook signature does not match.");
98
+ }
99
+ let event;
100
+ try {
101
+ event = JSON.parse(prepared.body);
102
+ }
103
+ catch {
104
+ throw new errors_1.DiffioWebhookVerificationError("Webhook payload is not JSON.");
105
+ }
106
+ if (!event || typeof event !== "object" || Array.isArray(event)) {
107
+ throw new errors_1.DiffioWebhookVerificationError("Webhook payload must be a JSON object.");
108
+ }
109
+ return event;
110
+ }
111
+ /**
112
+ * Checks a delivery's signature and timestamp with node:crypto and returns the parsed event.
113
+ * Pass the raw request body exactly as received (not re-serialized JSON). Throws
114
+ * DiffioWebhookVerificationError when anything does not check out. Node only; elsewhere use
115
+ * `verifySignatureAsync`.
116
+ */
117
+ function verifyWebhookSignature(payload, headers, secret, options) {
118
+ const key = secretKey(secret);
119
+ const prepared = prepare(payload, headers, options);
120
+ const crypto = (0, node_1.nodeRequire)("node:crypto");
121
+ if (!crypto) {
122
+ throw new errors_1.DiffioWebhookVerificationError("verifySignature needs Node's crypto; use verifySignatureAsync here.");
123
+ }
124
+ const expected = crypto.createHmac("sha256", key).update(prepared.signedContent, "utf8").digest("base64");
125
+ return finish(prepared, expected);
126
+ }
127
+ /** Same check with WebCrypto, for browsers, edge runtimes, Deno and Bun (works in Node 18+ too). */
128
+ async function verifyWebhookSignatureAsync(payload, headers, secret, options) {
129
+ const key = secretKey(secret);
130
+ const prepared = prepare(payload, headers, options);
131
+ let subtle = globalThis.crypto?.subtle;
132
+ if (!subtle)
133
+ subtle = (0, node_1.nodeRequire)("node:crypto")?.webcrypto.subtle;
134
+ if (!subtle)
135
+ throw new errors_1.DiffioWebhookVerificationError("WebCrypto is not available in this runtime.");
136
+ const cryptoKey = await subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
137
+ const signature = await subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(prepared.signedContent));
138
+ return finish(prepared, encodeBase64(new Uint8Array(signature)));
139
+ }
140
+ /** Signs a payload the way Svix does; for tests of your own webhook handler. */
141
+ function signWebhookPayload(payload, secret, id, timestamp) {
142
+ const crypto = (0, node_1.nodeRequire)("node:crypto");
143
+ if (!crypto)
144
+ throw new errors_1.DiffioWebhookVerificationError("signWebhookPayload needs Node's crypto.");
145
+ const digest = crypto.createHmac("sha256", secretKey(secret)).update(`${id}.${timestamp}.${payload}`, "utf8").digest("base64");
146
+ return `${SIGNATURE_PREFIX}${digest}`;
147
+ }
@@ -1,31 +1,73 @@
1
+ /** Base class of every error the SDK throws. */
1
2
  export declare class DiffioError extends Error {
2
3
  constructor(message: string);
3
4
  }
5
+ /**
6
+ * A refusal from the Diffio API: the v2 error body `{"error": {"code", "message", "request_id", "details"}}`
7
+ * with the HTTP status. `request_id` matches the response's `X-Request-Id`; quote it when you contact support.
8
+ */
4
9
  export declare class DiffioApiError extends DiffioError {
5
- statusCode?: number;
6
- responseBody?: unknown;
7
- constructor(message: string, options?: {
8
- statusCode?: number;
9
- responseBody?: unknown;
10
+ /** HTTP status, such as 400, 404 or 409. */
11
+ readonly status: number;
12
+ /** Stable snake_case error code, such as `unknown_model` or `project_not_found`. */
13
+ readonly code: string;
14
+ readonly request_id: string | null;
15
+ /** Extra fields for this code, such as `{"field": "model"}`; `{}` when the API sent none. */
16
+ readonly details: Record<string, unknown>;
17
+ /** Response headers, when there was a response. */
18
+ readonly headers: Headers | null;
19
+ /** The parsed response body (or its text when it was not JSON). */
20
+ readonly body: unknown;
21
+ constructor(options: {
22
+ status: number;
23
+ code: string;
24
+ message: string;
25
+ request_id?: string | null;
26
+ details?: Record<string, unknown> | null;
27
+ headers?: Headers | null;
28
+ body?: unknown;
10
29
  });
11
30
  }
12
- /** Stable failure codes for uploads through the edge Worker, modeled on the Diffio web uploader's codes. */
13
- export type EdgeUploadErrorCode = "upload/too-large" | "upload/unauthorized" | "upload/rejected" | "upload/network" | "upload/server" | "upload/invalid-response" | "upload/canceled";
14
- /** A failed project media upload; `apiProjectId` names the project whose upload did not finish. */
31
+ /**
32
+ * A failed transfer of media bytes to Diffio's media host (the `upload.requests` steps).
33
+ * `code` is the media host's error code (such as `invalid_token` or `payload_too_large`), or one of the
34
+ * SDK's own codes: `network`, `invalid_response`, `too_large`, `canceled`.
35
+ */
15
36
  export declare class DiffioUploadError extends DiffioApiError {
16
- uploadErrorCode: EdgeUploadErrorCode;
17
- /** The edge's machine-readable `error.code`, such as `token_expired`, when it sent one. */
18
- edgeErrorCode?: string;
19
- retryable: boolean;
20
- apiProjectId?: string;
21
- constructor(uploadErrorCode: EdgeUploadErrorCode, message: string, options?: {
22
- statusCode?: number;
23
- responseBody?: unknown;
24
- edgeErrorCode?: string;
37
+ /** True when sending the same upload again may succeed (network trouble, 5xx, 429). */
38
+ readonly retryable: boolean;
39
+ /** The project whose upload did not finish, when known. */
40
+ project_id: string | null;
41
+ constructor(options: {
42
+ code: string;
43
+ message: string;
44
+ status?: number;
25
45
  retryable?: boolean;
26
- apiProjectId?: string;
46
+ project_id?: string | null;
47
+ body?: unknown;
27
48
  });
28
49
  }
50
+ /** The request never got an HTTP answer (DNS, TLS, reset connection) after every retry. */
51
+ export declare class DiffioConnectionError extends DiffioError {
52
+ readonly cause: unknown;
53
+ constructor(message: string, cause?: unknown);
54
+ }
55
+ /** A request took longer than its timeout, or a `wait` helper ran out of time. */
29
56
  export declare class DiffioTimeoutError extends DiffioError {
57
+ /** For `wait` helpers: the last state read before giving up. */
58
+ readonly resource: unknown;
59
+ constructor(message: string, resource?: unknown);
60
+ }
61
+ /**
62
+ * Thrown by `wait` helpers when a generation, export or assistant turn ends `failed`.
63
+ * `code` and `message` are the resource's `error`; `resource` is the failed object itself.
64
+ */
65
+ export declare class DiffioResourceFailedError extends DiffioError {
66
+ readonly code: string;
67
+ readonly resource: unknown;
68
+ constructor(code: string, message: string, resource: unknown);
69
+ }
70
+ /** A webhook delivery whose signature, timestamp or headers do not check out. */
71
+ export declare class DiffioWebhookVerificationError extends DiffioError {
30
72
  constructor(message: string);
31
73
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DiffioTimeoutError = exports.DiffioUploadError = exports.DiffioApiError = exports.DiffioError = void 0;
3
+ exports.DiffioWebhookVerificationError = exports.DiffioResourceFailedError = exports.DiffioTimeoutError = exports.DiffioConnectionError = exports.DiffioUploadError = exports.DiffioApiError = exports.DiffioError = void 0;
4
+ /** Base class of every error the SDK throws. */
4
5
  class DiffioError extends Error {
5
6
  constructor(message) {
6
7
  super(message);
@@ -8,31 +9,78 @@ class DiffioError extends Error {
8
9
  }
9
10
  }
10
11
  exports.DiffioError = DiffioError;
12
+ /**
13
+ * A refusal from the Diffio API: the v2 error body `{"error": {"code", "message", "request_id", "details"}}`
14
+ * with the HTTP status. `request_id` matches the response's `X-Request-Id`; quote it when you contact support.
15
+ */
11
16
  class DiffioApiError extends DiffioError {
12
- constructor(message, options) {
13
- super(message);
17
+ constructor(options) {
18
+ super(options.message);
14
19
  this.name = "DiffioApiError";
15
- this.statusCode = options?.statusCode;
16
- this.responseBody = options?.responseBody;
20
+ this.status = options.status;
21
+ this.code = options.code;
22
+ this.request_id = options.request_id ?? null;
23
+ this.details = options.details ?? {};
24
+ this.headers = options.headers ?? null;
25
+ this.body = options.body;
17
26
  }
18
27
  }
19
28
  exports.DiffioApiError = DiffioApiError;
20
- /** A failed project media upload; `apiProjectId` names the project whose upload did not finish. */
29
+ /**
30
+ * A failed transfer of media bytes to Diffio's media host (the `upload.requests` steps).
31
+ * `code` is the media host's error code (such as `invalid_token` or `payload_too_large`), or one of the
32
+ * SDK's own codes: `network`, `invalid_response`, `too_large`, `canceled`.
33
+ */
21
34
  class DiffioUploadError extends DiffioApiError {
22
- constructor(uploadErrorCode, message, options) {
23
- super(message, { statusCode: options?.statusCode, responseBody: options?.responseBody });
35
+ constructor(options) {
36
+ super({
37
+ status: options.status ?? 0,
38
+ code: options.code,
39
+ message: options.message,
40
+ body: options.body
41
+ });
24
42
  this.name = "DiffioUploadError";
25
- this.uploadErrorCode = uploadErrorCode;
26
- this.edgeErrorCode = options?.edgeErrorCode;
27
- this.retryable = options?.retryable ?? false;
28
- this.apiProjectId = options?.apiProjectId;
43
+ this.retryable = options.retryable ?? false;
44
+ this.project_id = options.project_id ?? null;
29
45
  }
30
46
  }
31
47
  exports.DiffioUploadError = DiffioUploadError;
48
+ /** The request never got an HTTP answer (DNS, TLS, reset connection) after every retry. */
49
+ class DiffioConnectionError extends DiffioError {
50
+ constructor(message, cause) {
51
+ super(message);
52
+ this.name = "DiffioConnectionError";
53
+ this.cause = cause;
54
+ }
55
+ }
56
+ exports.DiffioConnectionError = DiffioConnectionError;
57
+ /** A request took longer than its timeout, or a `wait` helper ran out of time. */
32
58
  class DiffioTimeoutError extends DiffioError {
33
- constructor(message) {
59
+ constructor(message, resource) {
34
60
  super(message);
35
61
  this.name = "DiffioTimeoutError";
62
+ this.resource = resource ?? null;
36
63
  }
37
64
  }
38
65
  exports.DiffioTimeoutError = DiffioTimeoutError;
66
+ /**
67
+ * Thrown by `wait` helpers when a generation, export or assistant turn ends `failed`.
68
+ * `code` and `message` are the resource's `error`; `resource` is the failed object itself.
69
+ */
70
+ class DiffioResourceFailedError extends DiffioError {
71
+ constructor(code, message, resource) {
72
+ super(message);
73
+ this.name = "DiffioResourceFailedError";
74
+ this.code = code;
75
+ this.resource = resource;
76
+ }
77
+ }
78
+ exports.DiffioResourceFailedError = DiffioResourceFailedError;
79
+ /** A webhook delivery whose signature, timestamp or headers do not check out. */
80
+ class DiffioWebhookVerificationError extends DiffioError {
81
+ constructor(message) {
82
+ super(message);
83
+ this.name = "DiffioWebhookVerificationError";
84
+ }
85
+ }
86
+ exports.DiffioWebhookVerificationError = DiffioWebhookVerificationError;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- export { DiffioClient } from "./Client";
1
+ export { DiffioClient, type RestoreAudioParams, type RestoreAudioResult } from "./Client";
2
2
  export * as Diffio from "./api";
3
+ export * from "./api/types";
3
4
  export * from "./errors";
5
+ export type { RequestOptions } from "./core/transport";
6
+ export { Page, PagePromise } from "./core/pagination";
7
+ export type { WaitOptions } from "./core/poll";
8
+ export type { FileInput } from "./core/files";
9
+ export { verifyWebhookSignature, verifyWebhookSignatureAsync, signWebhookPayload, type WebhookHeaders, type WebhookPayload, type VerifySignatureOptions } from "./core/webhookSignature";
10
+ export type { GenerationDownload, GenerationDownloadOptions, ProjectUploadOptions } from "./api/resources";
4
11
  export { DIFFIO_SDK_VERSION } from "./version";
package/dist/index.js CHANGED
@@ -36,10 +36,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.DIFFIO_SDK_VERSION = exports.Diffio = exports.DiffioClient = void 0;
39
+ exports.DIFFIO_SDK_VERSION = exports.signWebhookPayload = exports.verifyWebhookSignatureAsync = exports.verifyWebhookSignature = exports.PagePromise = exports.Page = exports.Diffio = exports.DiffioClient = void 0;
40
40
  var Client_1 = require("./Client");
41
41
  Object.defineProperty(exports, "DiffioClient", { enumerable: true, get: function () { return Client_1.DiffioClient; } });
42
42
  exports.Diffio = __importStar(require("./api"));
43
+ __exportStar(require("./api/types"), exports);
43
44
  __exportStar(require("./errors"), exports);
45
+ var pagination_1 = require("./core/pagination");
46
+ Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return pagination_1.Page; } });
47
+ Object.defineProperty(exports, "PagePromise", { enumerable: true, get: function () { return pagination_1.PagePromise; } });
48
+ var webhookSignature_1 = require("./core/webhookSignature");
49
+ Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return webhookSignature_1.verifyWebhookSignature; } });
50
+ Object.defineProperty(exports, "verifyWebhookSignatureAsync", { enumerable: true, get: function () { return webhookSignature_1.verifyWebhookSignatureAsync; } });
51
+ Object.defineProperty(exports, "signWebhookPayload", { enumerable: true, get: function () { return webhookSignature_1.signWebhookPayload; } });
44
52
  var version_1 = require("./version");
45
53
  Object.defineProperty(exports, "DIFFIO_SDK_VERSION", { enumerable: true, get: function () { return version_1.DIFFIO_SDK_VERSION; } });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const DIFFIO_SDK_VERSION = "0.4.63";
1
+ export declare const DIFFIO_SDK_VERSION = "1.0.0";
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.4.63";
4
+ exports.DIFFIO_SDK_VERSION = "1.0.0";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "diffio",
3
- "version": "0.4.63",
4
- "description": "Diffio API client for Node.js",
3
+ "version": "1.0.0",
4
+ "description": "Diffio API v2 client for Node.js and browsers",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/Diffio-AI/diffio-js"
@@ -23,13 +23,8 @@
23
23
  "test:unit": "jest --selectProjects unit",
24
24
  "test:wire": "jest --selectProjects wire"
25
25
  },
26
- "dependencies": {
27
- "mime-types": "^2.1.35",
28
- "svix": "^1.84.1"
29
- },
30
26
  "devDependencies": {
31
27
  "@types/jest": "^29.5.14",
32
- "@types/mime-types": "^2.1.4",
33
28
  "@types/node": "^18.19.70",
34
29
  "jest": "^29.7.0",
35
30
  "msw": "^2.11.2",
@@ -1,26 +0,0 @@
1
- import type { Supplier } from "./core/supplier";
2
- export interface BaseClientOptions {
3
- baseUrl?: Supplier<string>;
4
- apiKey?: Supplier<string | undefined>;
5
- headers?: Record<string, string | Supplier<string | null | undefined> | null | undefined>;
6
- timeoutInSeconds?: number;
7
- timeout?: number;
8
- maxRetries?: number;
9
- retryBackoff?: number;
10
- retryStatusCodes?: number[];
11
- fetch?: typeof fetch;
12
- }
13
- export interface BaseRequestOptions {
14
- timeoutInSeconds?: number;
15
- timeout?: number;
16
- maxRetries?: number;
17
- retryBackoff?: number;
18
- retryStatusCodes?: number[];
19
- abortSignal?: AbortSignal;
20
- apiKey?: string | undefined;
21
- headers?: Record<string, string | Supplier<string | null | undefined> | null | undefined>;
22
- }
23
- export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
24
- headers: Record<string, string | Supplier<string | null | undefined> | null | undefined>;
25
- };
26
- export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeClientOptions = normalizeClientOptions;
4
- const version_1 = require("./version");
5
- const headers_1 = require("./core/headers");
6
- function normalizeClientOptions(options) {
7
- const headers = (0, headers_1.mergeHeaders)({
8
- "X-Diffio-SDK-Language": "JavaScript",
9
- "X-Diffio-SDK-Name": "diffio",
10
- "X-Diffio-SDK-Version": version_1.DIFFIO_SDK_VERSION,
11
- "User-Agent": `diffio/${version_1.DIFFIO_SDK_VERSION}`
12
- }, options?.headers);
13
- return {
14
- ...options,
15
- headers
16
- };
17
- }
@@ -1,15 +0,0 @@
1
- import type { DiffioClient } from "../../../../Client";
2
- import type { AccountSettingsResponse } from "../../../types";
3
- export interface AccountGetSettingsOptions {
4
- requestOptions?: DiffioClient.RequestOptions;
5
- }
6
- export interface AccountUpdateSettingsOptions {
7
- billingPolicy: Record<string, unknown>;
8
- requestOptions?: DiffioClient.RequestOptions;
9
- }
10
- export declare class AccountClient {
11
- private _parent;
12
- constructor(parent: DiffioClient);
13
- getSettings(options?: AccountGetSettingsOptions): Promise<AccountSettingsResponse>;
14
- updateSettings(options: AccountUpdateSettingsOptions): Promise<AccountSettingsResponse>;
15
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccountClient = void 0;
4
- class AccountClient {
5
- constructor(parent) {
6
- this._parent = parent;
7
- }
8
- async getSettings(options = {}) {
9
- return this._parent.getAccountSettings(options);
10
- }
11
- async updateSettings(options) {
12
- return this._parent.updateAccountSettings(options);
13
- }
14
- }
15
- exports.AccountClient = AccountClient;
@@ -1,27 +0,0 @@
1
- import type { DiffioClient } from "../../../../Client";
2
- import type { ApiKeyResponse, ApiKeysListResponse } from "../../../types";
3
- export interface ApiKeysCreateOptions {
4
- label: string;
5
- scopes: string[];
6
- resourceBounds?: Record<string, unknown>;
7
- requestOptions?: DiffioClient.RequestOptions;
8
- }
9
- export interface ApiKeysListOptions {
10
- requestOptions?: DiffioClient.RequestOptions;
11
- }
12
- export interface ApiKeysRotateOptions {
13
- keyId: string;
14
- requestOptions?: DiffioClient.RequestOptions;
15
- }
16
- export interface ApiKeysRevokeOptions {
17
- keyId: string;
18
- requestOptions?: DiffioClient.RequestOptions;
19
- }
20
- export declare class ApiKeysClient {
21
- private _parent;
22
- constructor(parent: DiffioClient);
23
- create(options: ApiKeysCreateOptions): Promise<ApiKeyResponse>;
24
- list(options?: ApiKeysListOptions): Promise<ApiKeysListResponse>;
25
- rotate(options: ApiKeysRotateOptions): Promise<ApiKeyResponse>;
26
- revoke(options: ApiKeysRevokeOptions): Promise<ApiKeyResponse>;
27
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiKeysClient = void 0;
4
- class ApiKeysClient {
5
- constructor(parent) {
6
- this._parent = parent;
7
- }
8
- async create(options) {
9
- return this._parent.createApiKey(options);
10
- }
11
- async list(options = {}) {
12
- return this._parent.listApiKeys(options);
13
- }
14
- async rotate(options) {
15
- return this._parent.rotateApiKey(options);
16
- }
17
- async revoke(options) {
18
- return this._parent.revokeApiKey(options);
19
- }
20
- }
21
- exports.ApiKeysClient = ApiKeysClient;
@@ -1,43 +0,0 @@
1
- import type { DiffioClient } from "../../../../Client";
2
- import type { AcceptedModelKey, AudioIsolationResult, GenerationProgressResponse, RestoreMetadata } from "../../../types";
3
- export interface AudioIsolationRestoreOptions {
4
- filePath: string;
5
- contentType?: string;
6
- contentLength?: number;
7
- fileFormat?: string;
8
- model?: AcceptedModelKey;
9
- sampling?: Record<string, unknown>;
10
- projectParams?: Record<string, unknown>;
11
- generationParams?: Record<string, unknown>;
12
- idempotencyKey?: string;
13
- downloadType?: string;
14
- pollInterval?: number;
15
- timeout?: number;
16
- timeoutInSeconds?: number;
17
- onProgress?: (progress: GenerationProgressResponse) => void | Promise<void>;
18
- showProgress?: boolean;
19
- requestOptions?: DiffioClient.RequestOptions;
20
- progressRequestOptions?: DiffioClient.RequestOptions;
21
- downloadRequestOptions?: DiffioClient.RequestOptions;
22
- raiseOnError?: boolean;
23
- }
24
- export interface AudioIsolationIsolateOptions {
25
- filePath: string;
26
- contentType?: string;
27
- contentLength?: number;
28
- fileFormat?: string;
29
- model?: AcceptedModelKey;
30
- sampling?: Record<string, unknown>;
31
- projectParams?: Record<string, unknown>;
32
- generationParams?: Record<string, unknown>;
33
- idempotencyKey?: string;
34
- requestOptions?: DiffioClient.RequestOptions;
35
- }
36
- export declare class AudioIsolationClient {
37
- private _parent;
38
- constructor(parent: DiffioClient);
39
- convert(options: AudioIsolationIsolateOptions): Promise<AudioIsolationResult>;
40
- isolate(options: AudioIsolationIsolateOptions): Promise<AudioIsolationResult>;
41
- restoreAudio(options: AudioIsolationRestoreOptions): Promise<[Uint8Array | null, RestoreMetadata]>;
42
- restore(options: AudioIsolationRestoreOptions): Promise<[Uint8Array | null, RestoreMetadata]>;
43
- }
@@ -1,33 +0,0 @@
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, idempotencyKey, requestOptions } = options;
13
- return this._parent.audioIsolationIsolate({
14
- filePath,
15
- contentType,
16
- contentLength,
17
- fileFormat,
18
- model,
19
- sampling,
20
- projectParams,
21
- generationParams,
22
- idempotencyKey,
23
- requestOptions
24
- });
25
- }
26
- async restoreAudio(options) {
27
- return this._parent.restoreAudio(options);
28
- }
29
- async restore(options) {
30
- return this.restoreAudio(options);
31
- }
32
- }
33
- exports.AudioIsolationClient = AudioIsolationClient;