@sync.so/sdk 0.1.8 → 0.2.1

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 (129) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +7 -2
  3. package/README.md +2 -2
  4. package/api/resources/batch/client/Client.d.ts +89 -0
  5. package/api/resources/batch/client/Client.js +297 -0
  6. package/api/resources/batch/client/index.d.ts +1 -0
  7. package/api/resources/batch/client/index.js +17 -0
  8. package/api/resources/batch/client/requests/CreateBatchRequest.d.ts +21 -0
  9. package/api/resources/batch/client/requests/CreateBatchRequest.js +5 -0
  10. package/api/resources/batch/client/requests/ListBatchesRequest.d.ts +22 -0
  11. package/api/resources/batch/client/requests/ListBatchesRequest.js +5 -0
  12. package/api/resources/batch/client/requests/index.d.ts +2 -0
  13. package/api/resources/batch/client/requests/index.js +2 -0
  14. package/api/resources/batch/index.d.ts +1 -0
  15. package/api/resources/batch/index.js +17 -0
  16. package/api/resources/common/errors/PaymentRequiredError.d.ts +9 -0
  17. package/api/resources/common/errors/PaymentRequiredError.js +52 -0
  18. package/api/resources/common/errors/TooManyRequestsError.d.ts +9 -0
  19. package/api/resources/common/errors/TooManyRequestsError.js +52 -0
  20. package/api/resources/common/errors/index.d.ts +2 -0
  21. package/api/resources/common/errors/index.js +2 -0
  22. package/api/resources/common/types/ActiveSpeaker.d.ts +10 -0
  23. package/api/resources/common/types/ActiveSpeaker.js +5 -0
  24. package/api/resources/common/types/BatchId.d.ts +7 -0
  25. package/api/resources/common/types/BatchId.js +5 -0
  26. package/api/resources/common/types/BatchMetrics.d.ts +13 -0
  27. package/api/resources/common/types/BatchMetrics.js +5 -0
  28. package/api/resources/common/types/BatchResponse.d.ts +17 -0
  29. package/api/resources/common/types/BatchResponse.js +5 -0
  30. package/api/resources/common/types/BatchStatus.d.ts +14 -0
  31. package/api/resources/common/types/BatchStatus.js +13 -0
  32. package/api/resources/common/types/CreateBatchResponse.d.ts +5 -0
  33. package/api/resources/common/types/CreateBatchResponse.js +5 -0
  34. package/api/resources/common/types/CreateGenerationDto.d.ts +2 -0
  35. package/api/resources/common/types/Generation.d.ts +2 -0
  36. package/api/resources/common/types/GenerationOptions.d.ts +6 -14
  37. package/api/resources/common/types/Model.d.ts +1 -4
  38. package/api/resources/common/types/Model.js +0 -3
  39. package/api/resources/common/types/SyncMode.d.ts +20 -2
  40. package/api/resources/common/types/SyncMode.js +1 -1
  41. package/api/resources/common/types/ValidationResponse.d.ts +7 -0
  42. package/api/resources/common/types/ValidationResponse.js +5 -0
  43. package/api/resources/common/types/index.d.ts +7 -0
  44. package/api/resources/common/types/index.js +7 -0
  45. package/api/resources/generations/client/Client.d.ts +23 -4
  46. package/api/resources/generations/client/Client.js +97 -8
  47. package/api/resources/generations/client/requests/CreateGenerationRequest.d.ts +17 -0
  48. package/api/resources/generations/client/requests/CreateGenerationRequest.js +5 -0
  49. package/api/resources/generations/client/requests/index.d.ts +1 -0
  50. package/api/resources/index.d.ts +2 -0
  51. package/api/resources/index.js +3 -1
  52. package/api/resources/webhooks/types/GenerationNotification.d.ts +2 -0
  53. package/core/form-data-utils/FormDataWrapper.d.ts +63 -0
  54. package/core/form-data-utils/FormDataWrapper.js +227 -0
  55. package/core/form-data-utils/encodeAsFormParameter.d.ts +4 -0
  56. package/core/form-data-utils/encodeAsFormParameter.js +18 -0
  57. package/core/form-data-utils/index.d.ts +2 -0
  58. package/core/form-data-utils/index.js +20 -0
  59. package/core/index.d.ts +1 -0
  60. package/core/index.js +1 -0
  61. package/dist/Client.d.ts +3 -0
  62. package/dist/Client.js +7 -2
  63. package/dist/api/resources/batch/client/Client.d.ts +89 -0
  64. package/dist/api/resources/batch/client/Client.js +297 -0
  65. package/dist/api/resources/batch/client/index.d.ts +1 -0
  66. package/dist/api/resources/batch/client/index.js +17 -0
  67. package/dist/api/resources/batch/client/requests/CreateBatchRequest.d.ts +21 -0
  68. package/dist/api/resources/batch/client/requests/CreateBatchRequest.js +5 -0
  69. package/dist/api/resources/batch/client/requests/ListBatchesRequest.d.ts +22 -0
  70. package/dist/api/resources/batch/client/requests/ListBatchesRequest.js +5 -0
  71. package/dist/api/resources/batch/client/requests/index.d.ts +2 -0
  72. package/dist/api/resources/batch/client/requests/index.js +2 -0
  73. package/dist/api/resources/batch/index.d.ts +1 -0
  74. package/dist/api/resources/batch/index.js +17 -0
  75. package/dist/api/resources/common/errors/PaymentRequiredError.d.ts +9 -0
  76. package/dist/api/resources/common/errors/PaymentRequiredError.js +52 -0
  77. package/dist/api/resources/common/errors/TooManyRequestsError.d.ts +9 -0
  78. package/dist/api/resources/common/errors/TooManyRequestsError.js +52 -0
  79. package/dist/api/resources/common/errors/index.d.ts +2 -0
  80. package/dist/api/resources/common/errors/index.js +2 -0
  81. package/dist/api/resources/common/types/ActiveSpeaker.d.ts +10 -0
  82. package/dist/api/resources/common/types/ActiveSpeaker.js +5 -0
  83. package/dist/api/resources/common/types/BatchId.d.ts +7 -0
  84. package/dist/api/resources/common/types/BatchId.js +5 -0
  85. package/dist/api/resources/common/types/BatchMetrics.d.ts +13 -0
  86. package/dist/api/resources/common/types/BatchMetrics.js +5 -0
  87. package/dist/api/resources/common/types/BatchResponse.d.ts +17 -0
  88. package/dist/api/resources/common/types/BatchResponse.js +5 -0
  89. package/dist/api/resources/common/types/BatchStatus.d.ts +14 -0
  90. package/dist/api/resources/common/types/BatchStatus.js +13 -0
  91. package/dist/api/resources/common/types/CreateBatchResponse.d.ts +5 -0
  92. package/dist/api/resources/common/types/CreateBatchResponse.js +5 -0
  93. package/dist/api/resources/common/types/CreateGenerationDto.d.ts +2 -0
  94. package/dist/api/resources/common/types/Generation.d.ts +2 -0
  95. package/dist/api/resources/common/types/GenerationOptions.d.ts +6 -14
  96. package/dist/api/resources/common/types/Model.d.ts +1 -4
  97. package/dist/api/resources/common/types/Model.js +0 -3
  98. package/dist/api/resources/common/types/SyncMode.d.ts +20 -2
  99. package/dist/api/resources/common/types/SyncMode.js +1 -1
  100. package/dist/api/resources/common/types/ValidationResponse.d.ts +7 -0
  101. package/dist/api/resources/common/types/ValidationResponse.js +5 -0
  102. package/dist/api/resources/common/types/index.d.ts +7 -0
  103. package/dist/api/resources/common/types/index.js +7 -0
  104. package/dist/api/resources/generations/client/Client.d.ts +23 -4
  105. package/dist/api/resources/generations/client/Client.js +97 -8
  106. package/dist/api/resources/generations/client/requests/CreateGenerationRequest.d.ts +17 -0
  107. package/dist/api/resources/generations/client/requests/CreateGenerationRequest.js +5 -0
  108. package/dist/api/resources/generations/client/requests/index.d.ts +1 -0
  109. package/dist/api/resources/index.d.ts +2 -0
  110. package/dist/api/resources/index.js +3 -1
  111. package/dist/api/resources/webhooks/types/GenerationNotification.d.ts +2 -0
  112. package/dist/core/form-data-utils/FormDataWrapper.d.ts +63 -0
  113. package/dist/core/form-data-utils/FormDataWrapper.js +227 -0
  114. package/dist/core/form-data-utils/encodeAsFormParameter.d.ts +4 -0
  115. package/dist/core/form-data-utils/encodeAsFormParameter.js +18 -0
  116. package/dist/core/form-data-utils/index.d.ts +2 -0
  117. package/dist/core/form-data-utils/index.js +20 -0
  118. package/dist/core/index.d.ts +1 -0
  119. package/dist/core/index.js +1 -0
  120. package/dist/environments.d.ts +2 -1
  121. package/dist/environments.js +1 -0
  122. package/dist/version.d.ts +1 -1
  123. package/dist/version.js +1 -1
  124. package/environments.d.ts +2 -1
  125. package/environments.js +1 -0
  126. package/package.json +3 -2
  127. package/reference.md +276 -4
  128. package/version.d.ts +1 -1
  129. package/version.js +1 -1
package/Client.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as environments from "./environments";
5
5
  import * as core from "./core";
6
+ import { Batch } from "./api/resources/batch/client/Client";
6
7
  import { Generations } from "./api/resources/generations/client/Client";
7
8
  export declare namespace SyncClient {
8
9
  interface Options {
@@ -25,7 +26,9 @@ export declare namespace SyncClient {
25
26
  }
26
27
  export declare class SyncClient {
27
28
  protected readonly _options: SyncClient.Options;
29
+ protected _batch: Batch | undefined;
28
30
  protected _generations: Generations | undefined;
29
31
  constructor(_options: SyncClient.Options);
32
+ get batch(): Batch;
30
33
  get generations(): Generations;
31
34
  }
package/Client.js CHANGED
@@ -4,14 +4,19 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SyncClient = void 0;
7
- const Client_1 = require("./api/resources/generations/client/Client");
7
+ const Client_1 = require("./api/resources/batch/client/Client");
8
+ const Client_2 = require("./api/resources/generations/client/Client");
8
9
  class SyncClient {
9
10
  constructor(_options) {
10
11
  this._options = _options;
11
12
  }
13
+ get batch() {
14
+ var _a;
15
+ return ((_a = this._batch) !== null && _a !== void 0 ? _a : (this._batch = new Client_1.Batch(this._options)));
16
+ }
12
17
  get generations() {
13
18
  var _a;
14
- return ((_a = this._generations) !== null && _a !== void 0 ? _a : (this._generations = new Client_1.Generations(this._options)));
19
+ return ((_a = this._generations) !== null && _a !== void 0 ? _a : (this._generations = new Client_2.Generations(this._options)));
15
20
  }
16
21
  }
17
22
  exports.SyncClient = SyncClient;
package/README.md CHANGED
@@ -31,11 +31,11 @@ await client.generations.create({
31
31
  input: [
32
32
  {
33
33
  type: "video",
34
- url: "https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
34
+ url: "https://assets.sync.so/docs/example-video.mp4",
35
35
  },
36
36
  {
37
37
  type: "audio",
38
- url: "https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
38
+ url: "https://assets.sync.so/docs/example-audio.wav",
39
39
  },
40
40
  ],
41
41
  model: "lipsync-2",
@@ -0,0 +1,89 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../environments";
5
+ import * as core from "../../../../core";
6
+ import * as Sync from "../../../index";
7
+ import * as fs from "fs";
8
+ import { Blob } from "buffer";
9
+ export declare namespace Batch {
10
+ interface Options {
11
+ environment?: core.Supplier<environments.SyncEnvironment | string>;
12
+ /** Specify a custom URL to connect the client to. */
13
+ baseUrl?: core.Supplier<string>;
14
+ apiKey: core.Supplier<string>;
15
+ fetcher?: core.FetchFunction;
16
+ }
17
+ interface RequestOptions {
18
+ /** The maximum time to wait for a response in seconds. */
19
+ timeoutInSeconds?: number;
20
+ /** The number of times to retry the request. Defaults to 2. */
21
+ maxRetries?: number;
22
+ /** A hook to abort the request. */
23
+ abortSignal?: AbortSignal;
24
+ /** Additional headers to include in the request. */
25
+ headers?: Record<string, string>;
26
+ }
27
+ }
28
+ export declare class Batch {
29
+ protected readonly _options: Batch.Options;
30
+ constructor(_options: Batch.Options);
31
+ /**
32
+ * API for [Batch Processing](/api-reference/guides/batch-processing). Available only for `Scale` and `Enterprise` plans.
33
+ *
34
+ * @param {File | fs.ReadStream | Blob} input
35
+ * @param {Sync.CreateBatchRequest} request
36
+ * @param {Batch.RequestOptions} requestOptions - Request-specific configuration.
37
+ *
38
+ * @throws {@link Sync.BadRequestError}
39
+ * @throws {@link Sync.UnauthorizedError}
40
+ * @throws {@link Sync.PaymentRequiredError}
41
+ * @throws {@link Sync.TooManyRequestsError}
42
+ * @throws {@link Sync.InternalServerError}
43
+ *
44
+ * @example
45
+ * await client.batch.create(fs.createReadStream("/path/to/your/file"), {
46
+ * webhook_url: "https://your-webhook-url.com/batch-webhook",
47
+ * dry_run: false
48
+ * })
49
+ *
50
+ * @example
51
+ * await client.batch.create(fs.createReadStream("/path/to/your/file"), {
52
+ * dry_run: true
53
+ * })
54
+ */
55
+ create(input: File | fs.ReadStream | Blob, request: Sync.CreateBatchRequest, requestOptions?: Batch.RequestOptions): core.HttpResponsePromise<Sync.CreateBatchResponse>;
56
+ private __create;
57
+ /**
58
+ * Retrieve details about a specific batch, including its current status, processing metrics, and output file URL when available.
59
+ *
60
+ * @param {Sync.BatchId} id - The unique identifier of the batch
61
+ * @param {Batch.RequestOptions} requestOptions - Request-specific configuration.
62
+ *
63
+ * @throws {@link Sync.UnauthorizedError}
64
+ * @throws {@link Sync.NotFoundError}
65
+ * @throws {@link Sync.InternalServerError}
66
+ *
67
+ * @example
68
+ * await client.batch.get("batch_abc123")
69
+ */
70
+ get(id: Sync.BatchId, requestOptions?: Batch.RequestOptions): core.HttpResponsePromise<Sync.BatchResponse>;
71
+ private __get;
72
+ /**
73
+ * List all batches for your organization with optional filtering by status and creation date. Results are ordered by creation date (newest first).
74
+ *
75
+ * @param {Sync.ListBatchesRequest} request
76
+ * @param {Batch.RequestOptions} requestOptions - Request-specific configuration.
77
+ *
78
+ * @throws {@link Sync.UnauthorizedError}
79
+ * @throws {@link Sync.InternalServerError}
80
+ *
81
+ * @example
82
+ * await client.batch.list()
83
+ */
84
+ list(request?: Sync.ListBatchesRequest, requestOptions?: Batch.RequestOptions): core.HttpResponsePromise<Sync.BatchResponse[]>;
85
+ private __list;
86
+ protected _getCustomAuthorizationHeaders(): Promise<{
87
+ "x-api-key": string;
88
+ }>;
89
+ }
@@ -0,0 +1,297 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.Batch = void 0;
52
+ const environments = __importStar(require("../../../../environments"));
53
+ const core = __importStar(require("../../../../core"));
54
+ const Sync = __importStar(require("../../../index"));
55
+ const url_join_1 = __importDefault(require("url-join"));
56
+ const errors = __importStar(require("../../../../errors/index"));
57
+ class Batch {
58
+ constructor(_options) {
59
+ this._options = _options;
60
+ }
61
+ /**
62
+ * API for [Batch Processing](/api-reference/guides/batch-processing). Available only for `Scale` and `Enterprise` plans.
63
+ *
64
+ * @param {File | fs.ReadStream | Blob} input
65
+ * @param {Sync.CreateBatchRequest} request
66
+ * @param {Batch.RequestOptions} requestOptions - Request-specific configuration.
67
+ *
68
+ * @throws {@link Sync.BadRequestError}
69
+ * @throws {@link Sync.UnauthorizedError}
70
+ * @throws {@link Sync.PaymentRequiredError}
71
+ * @throws {@link Sync.TooManyRequestsError}
72
+ * @throws {@link Sync.InternalServerError}
73
+ *
74
+ * @example
75
+ * await client.batch.create(fs.createReadStream("/path/to/your/file"), {
76
+ * webhook_url: "https://your-webhook-url.com/batch-webhook",
77
+ * dry_run: false
78
+ * })
79
+ *
80
+ * @example
81
+ * await client.batch.create(fs.createReadStream("/path/to/your/file"), {
82
+ * dry_run: true
83
+ * })
84
+ */
85
+ create(input, request, requestOptions) {
86
+ return core.HttpResponsePromise.fromPromise(this.__create(input, request, requestOptions));
87
+ }
88
+ __create(input, request, requestOptions) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ var _a, _b, _c;
91
+ const _request = yield core.newFormData();
92
+ yield _request.appendFile("input", input);
93
+ if (request.webhook_url != null) {
94
+ _request.append("webhook_url", request.webhook_url);
95
+ }
96
+ if (request.dry_run != null) {
97
+ _request.append("dry_run", request.dry_run.toString());
98
+ }
99
+ const _maybeEncodedRequest = yield _request.getRequest();
100
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
101
+ url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SyncEnvironment.Default, "/v2/batch"),
102
+ method: "POST",
103
+ headers: Object.assign(Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@sync.so/sdk", "X-Fern-SDK-Version": "0.2.1", "User-Agent": "@sync.so/sdk/0.2.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
104
+ requestType: "file",
105
+ duplex: _maybeEncodedRequest.duplex,
106
+ body: _maybeEncodedRequest.body,
107
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
108
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
109
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
110
+ });
111
+ if (_response.ok) {
112
+ return { data: _response.body, rawResponse: _response.rawResponse };
113
+ }
114
+ if (_response.error.reason === "status-code") {
115
+ switch (_response.error.statusCode) {
116
+ case 400:
117
+ throw new Sync.BadRequestError(_response.error.body, _response.rawResponse);
118
+ case 401:
119
+ throw new Sync.UnauthorizedError(_response.error.body, _response.rawResponse);
120
+ case 402:
121
+ throw new Sync.PaymentRequiredError(_response.error.body, _response.rawResponse);
122
+ case 429:
123
+ throw new Sync.TooManyRequestsError(_response.error.body, _response.rawResponse);
124
+ case 500:
125
+ throw new Sync.InternalServerError(_response.error.body, _response.rawResponse);
126
+ default:
127
+ throw new errors.SyncError({
128
+ statusCode: _response.error.statusCode,
129
+ body: _response.error.body,
130
+ rawResponse: _response.rawResponse,
131
+ });
132
+ }
133
+ }
134
+ switch (_response.error.reason) {
135
+ case "non-json":
136
+ throw new errors.SyncError({
137
+ statusCode: _response.error.statusCode,
138
+ body: _response.error.rawBody,
139
+ rawResponse: _response.rawResponse,
140
+ });
141
+ case "timeout":
142
+ throw new errors.SyncTimeoutError("Timeout exceeded when calling POST /v2/batch.");
143
+ case "unknown":
144
+ throw new errors.SyncError({
145
+ message: _response.error.errorMessage,
146
+ rawResponse: _response.rawResponse,
147
+ });
148
+ }
149
+ });
150
+ }
151
+ /**
152
+ * Retrieve details about a specific batch, including its current status, processing metrics, and output file URL when available.
153
+ *
154
+ * @param {Sync.BatchId} id - The unique identifier of the batch
155
+ * @param {Batch.RequestOptions} requestOptions - Request-specific configuration.
156
+ *
157
+ * @throws {@link Sync.UnauthorizedError}
158
+ * @throws {@link Sync.NotFoundError}
159
+ * @throws {@link Sync.InternalServerError}
160
+ *
161
+ * @example
162
+ * await client.batch.get("batch_abc123")
163
+ */
164
+ get(id, requestOptions) {
165
+ return core.HttpResponsePromise.fromPromise(this.__get(id, requestOptions));
166
+ }
167
+ __get(id, requestOptions) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ var _a, _b, _c;
170
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
171
+ url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SyncEnvironment.Default, `/v2/batch/${encodeURIComponent(id)}`),
172
+ method: "GET",
173
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@sync.so/sdk", "X-Fern-SDK-Version": "0.2.1", "User-Agent": "@sync.so/sdk/0.2.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
174
+ contentType: "application/json",
175
+ requestType: "json",
176
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
177
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
178
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
179
+ });
180
+ if (_response.ok) {
181
+ return { data: _response.body, rawResponse: _response.rawResponse };
182
+ }
183
+ if (_response.error.reason === "status-code") {
184
+ switch (_response.error.statusCode) {
185
+ case 401:
186
+ throw new Sync.UnauthorizedError(_response.error.body, _response.rawResponse);
187
+ case 404:
188
+ throw new Sync.NotFoundError(_response.error.body, _response.rawResponse);
189
+ case 500:
190
+ throw new Sync.InternalServerError(_response.error.body, _response.rawResponse);
191
+ default:
192
+ throw new errors.SyncError({
193
+ statusCode: _response.error.statusCode,
194
+ body: _response.error.body,
195
+ rawResponse: _response.rawResponse,
196
+ });
197
+ }
198
+ }
199
+ switch (_response.error.reason) {
200
+ case "non-json":
201
+ throw new errors.SyncError({
202
+ statusCode: _response.error.statusCode,
203
+ body: _response.error.rawBody,
204
+ rawResponse: _response.rawResponse,
205
+ });
206
+ case "timeout":
207
+ throw new errors.SyncTimeoutError("Timeout exceeded when calling GET /v2/batch/{id}.");
208
+ case "unknown":
209
+ throw new errors.SyncError({
210
+ message: _response.error.errorMessage,
211
+ rawResponse: _response.rawResponse,
212
+ });
213
+ }
214
+ });
215
+ }
216
+ /**
217
+ * List all batches for your organization with optional filtering by status and creation date. Results are ordered by creation date (newest first).
218
+ *
219
+ * @param {Sync.ListBatchesRequest} request
220
+ * @param {Batch.RequestOptions} requestOptions - Request-specific configuration.
221
+ *
222
+ * @throws {@link Sync.UnauthorizedError}
223
+ * @throws {@link Sync.InternalServerError}
224
+ *
225
+ * @example
226
+ * await client.batch.list()
227
+ */
228
+ list(request = {}, requestOptions) {
229
+ return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
230
+ }
231
+ __list() {
232
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
233
+ var _a, _b, _c;
234
+ const { status, created_after: createdAfter, created_before: createdBefore } = request;
235
+ const _queryParams = {};
236
+ if (status != null) {
237
+ _queryParams["status"] = status;
238
+ }
239
+ if (createdAfter != null) {
240
+ _queryParams["created_after"] = createdAfter;
241
+ }
242
+ if (createdBefore != null) {
243
+ _queryParams["created_before"] = createdBefore;
244
+ }
245
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
246
+ url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SyncEnvironment.Default, "/v2/batch"),
247
+ method: "GET",
248
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@sync.so/sdk", "X-Fern-SDK-Version": "0.2.1", "User-Agent": "@sync.so/sdk/0.2.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
249
+ contentType: "application/json",
250
+ queryParameters: _queryParams,
251
+ requestType: "json",
252
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
253
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
254
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
255
+ });
256
+ if (_response.ok) {
257
+ return { data: _response.body, rawResponse: _response.rawResponse };
258
+ }
259
+ if (_response.error.reason === "status-code") {
260
+ switch (_response.error.statusCode) {
261
+ case 401:
262
+ throw new Sync.UnauthorizedError(_response.error.body, _response.rawResponse);
263
+ case 500:
264
+ throw new Sync.InternalServerError(_response.error.body, _response.rawResponse);
265
+ default:
266
+ throw new errors.SyncError({
267
+ statusCode: _response.error.statusCode,
268
+ body: _response.error.body,
269
+ rawResponse: _response.rawResponse,
270
+ });
271
+ }
272
+ }
273
+ switch (_response.error.reason) {
274
+ case "non-json":
275
+ throw new errors.SyncError({
276
+ statusCode: _response.error.statusCode,
277
+ body: _response.error.rawBody,
278
+ rawResponse: _response.rawResponse,
279
+ });
280
+ case "timeout":
281
+ throw new errors.SyncTimeoutError("Timeout exceeded when calling GET /v2/batch.");
282
+ case "unknown":
283
+ throw new errors.SyncError({
284
+ message: _response.error.errorMessage,
285
+ rawResponse: _response.rawResponse,
286
+ });
287
+ }
288
+ });
289
+ }
290
+ _getCustomAuthorizationHeaders() {
291
+ return __awaiter(this, void 0, void 0, function* () {
292
+ const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
293
+ return { "x-api-key": apiKeyValue };
294
+ });
295
+ }
296
+ }
297
+ exports.Batch = Batch;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
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("./requests"), exports);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * webhook_url: "https://your-webhook-url.com/batch-webhook",
8
+ * dry_run: false
9
+ * }
10
+ *
11
+ * @example
12
+ * {
13
+ * dry_run: true
14
+ * }
15
+ */
16
+ export interface CreateBatchRequest {
17
+ /** Optional webhook URL to receive batch completion notifications. A POST request will be sent when the batch completes or fails. */
18
+ webhook_url?: string;
19
+ /** When true, validates the input file without processing. Returns validation status without creating generations. */
20
+ dry_run?: boolean;
21
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Sync from "../../../../index";
5
+ /**
6
+ * @example
7
+ * {}
8
+ */
9
+ export interface ListBatchesRequest {
10
+ /**
11
+ * Filter batches by status
12
+ */
13
+ status?: Sync.BatchStatus;
14
+ /**
15
+ * Filter batches created after this datetime (ISO 8601 format)
16
+ */
17
+ created_after?: string;
18
+ /**
19
+ * Filter batches created before this datetime (ISO 8601 format)
20
+ */
21
+ created_before?: string;
22
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { type CreateBatchRequest } from "./CreateBatchRequest";
2
+ export { type ListBatchesRequest } from "./ListBatchesRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client";
@@ -0,0 +1,17 @@
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("./client"), exports);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as errors from "../../../../errors/index";
5
+ import * as Sync from "../../../index";
6
+ import * as core from "../../../../core";
7
+ export declare class PaymentRequiredError extends errors.SyncError {
8
+ constructor(body: Sync.GenerationError, rawResponse?: core.RawResponse);
9
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.PaymentRequiredError = void 0;
40
+ const errors = __importStar(require("../../../../errors/index"));
41
+ class PaymentRequiredError extends errors.SyncError {
42
+ constructor(body, rawResponse) {
43
+ super({
44
+ message: "PaymentRequiredError",
45
+ statusCode: 402,
46
+ body: body,
47
+ rawResponse: rawResponse,
48
+ });
49
+ Object.setPrototypeOf(this, PaymentRequiredError.prototype);
50
+ }
51
+ }
52
+ exports.PaymentRequiredError = PaymentRequiredError;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as errors from "../../../../errors/index";
5
+ import * as Sync from "../../../index";
6
+ import * as core from "../../../../core";
7
+ export declare class TooManyRequestsError extends errors.SyncError {
8
+ constructor(body: Sync.GenerationError, rawResponse?: core.RawResponse);
9
+ }