sarvamai 1.1.2-alpha.13 → 1.1.2-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/api/resources/documentIntelligence/DocumentIntelligenceJob.d.ts +5 -1
- package/dist/cjs/api/resources/documentIntelligence/DocumentIntelligenceJob.js +44 -21
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/api/resources/documentIntelligence/DocumentIntelligenceJob.d.mts +5 -1
- package/dist/esm/api/resources/documentIntelligence/DocumentIntelligenceJob.mjs +44 -21
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
|
|
|
43
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
44
44
|
"X-Fern-Language": "JavaScript",
|
|
45
45
|
"X-Fern-SDK-Name": "sarvamai",
|
|
46
|
-
"X-Fern-SDK-Version": "1.1.2-alpha.
|
|
47
|
-
"User-Agent": "sarvamai/1.1.2-alpha.
|
|
46
|
+
"X-Fern-SDK-Version": "1.1.2-alpha.14",
|
|
47
|
+
"User-Agent": "sarvamai/1.1.2-alpha.14",
|
|
48
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
49
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
50
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -73,8 +73,12 @@ export declare class DocumentIntelligenceJob {
|
|
|
73
73
|
getPageMetrics(): PageMetrics;
|
|
74
74
|
/**
|
|
75
75
|
* Download the output file(s) to the specified path.
|
|
76
|
+
* The output is a ZIP file containing the processed documents.
|
|
77
|
+
*
|
|
78
|
+
* @param outputPath - Path where the output file will be saved
|
|
79
|
+
* @returns The path to the downloaded file
|
|
76
80
|
*/
|
|
77
|
-
downloadOutput(outputPath: string): Promise<
|
|
81
|
+
downloadOutput(outputPath: string): Promise<string>;
|
|
78
82
|
/**
|
|
79
83
|
* Get download links for the output files.
|
|
80
84
|
*/
|
|
@@ -203,6 +203,10 @@ class DocumentIntelligenceJob {
|
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
205
|
* Download the output file(s) to the specified path.
|
|
206
|
+
* The output is a ZIP file containing the processed documents.
|
|
207
|
+
*
|
|
208
|
+
* @param outputPath - Path where the output file will be saved
|
|
209
|
+
* @returns The path to the downloaded file
|
|
206
210
|
*/
|
|
207
211
|
downloadOutput(outputPath) {
|
|
208
212
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -216,28 +220,47 @@ class DocumentIntelligenceJob {
|
|
|
216
220
|
if (!(downloadInfo === null || downloadInfo === void 0 ? void 0 : downloadInfo.file_url)) {
|
|
217
221
|
throw new Error("Invalid download URL response");
|
|
218
222
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
// Fetch with timeout (matching Python SDK's 300s timeout)
|
|
224
|
+
const controller = new AbortController();
|
|
225
|
+
const timeoutId = setTimeout(() => controller.abort(), 300000);
|
|
226
|
+
try {
|
|
227
|
+
const response = yield fetch(downloadInfo.file_url, {
|
|
228
|
+
signal: controller.signal,
|
|
229
|
+
});
|
|
230
|
+
if (!response.ok) {
|
|
231
|
+
throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
|
|
232
|
+
}
|
|
233
|
+
// Use arrayBuffer for binary data (ZIP files)
|
|
234
|
+
const arrayBuffer = yield response.arrayBuffer();
|
|
235
|
+
const content = new Uint8Array(arrayBuffer);
|
|
236
|
+
// Save to file (Node.js) or trigger download (browser)
|
|
237
|
+
if (typeof window === "undefined") {
|
|
238
|
+
// Node.js
|
|
239
|
+
const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
|
|
240
|
+
const path = yield Promise.resolve().then(() => __importStar(require("path")));
|
|
241
|
+
// Ensure output directory exists (matching Python SDK behavior)
|
|
242
|
+
const outputDir = path.dirname(outputPath);
|
|
243
|
+
if (outputDir) {
|
|
244
|
+
yield fs.promises.mkdir(outputDir, { recursive: true });
|
|
245
|
+
}
|
|
246
|
+
yield fs.promises.writeFile(outputPath, content);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
// Browser - trigger download
|
|
250
|
+
const blob = new Blob([content], { type: "application/zip" });
|
|
251
|
+
const url = URL.createObjectURL(blob);
|
|
252
|
+
const a = document.createElement("a");
|
|
253
|
+
a.href = url;
|
|
254
|
+
a.download = outputPath;
|
|
255
|
+
document.body.appendChild(a);
|
|
256
|
+
a.click();
|
|
257
|
+
a.remove();
|
|
258
|
+
URL.revokeObjectURL(url);
|
|
259
|
+
}
|
|
260
|
+
return outputPath;
|
|
229
261
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const blob = new Blob([content], { type: "text/html" });
|
|
233
|
-
const url = URL.createObjectURL(blob);
|
|
234
|
-
const a = document.createElement("a");
|
|
235
|
-
a.href = url;
|
|
236
|
-
a.download = outputPath;
|
|
237
|
-
document.body.appendChild(a);
|
|
238
|
-
a.click();
|
|
239
|
-
a.remove();
|
|
240
|
-
URL.revokeObjectURL(url);
|
|
262
|
+
finally {
|
|
263
|
+
clearTimeout(timeoutId);
|
|
241
264
|
}
|
|
242
265
|
});
|
|
243
266
|
}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.1.2-alpha.
|
|
1
|
+
export declare const SDK_VERSION = "1.1.2-alpha.14";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
|
|
|
6
6
|
const headers = mergeHeaders({
|
|
7
7
|
"X-Fern-Language": "JavaScript",
|
|
8
8
|
"X-Fern-SDK-Name": "sarvamai",
|
|
9
|
-
"X-Fern-SDK-Version": "1.1.2-alpha.
|
|
10
|
-
"User-Agent": "sarvamai/1.1.2-alpha.
|
|
9
|
+
"X-Fern-SDK-Version": "1.1.2-alpha.14",
|
|
10
|
+
"User-Agent": "sarvamai/1.1.2-alpha.14",
|
|
11
11
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
12
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
13
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -73,8 +73,12 @@ export declare class DocumentIntelligenceJob {
|
|
|
73
73
|
getPageMetrics(): PageMetrics;
|
|
74
74
|
/**
|
|
75
75
|
* Download the output file(s) to the specified path.
|
|
76
|
+
* The output is a ZIP file containing the processed documents.
|
|
77
|
+
*
|
|
78
|
+
* @param outputPath - Path where the output file will be saved
|
|
79
|
+
* @returns The path to the downloaded file
|
|
76
80
|
*/
|
|
77
|
-
downloadOutput(outputPath: string): Promise<
|
|
81
|
+
downloadOutput(outputPath: string): Promise<string>;
|
|
78
82
|
/**
|
|
79
83
|
* Get download links for the output files.
|
|
80
84
|
*/
|
|
@@ -167,6 +167,10 @@ export class DocumentIntelligenceJob {
|
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* Download the output file(s) to the specified path.
|
|
170
|
+
* The output is a ZIP file containing the processed documents.
|
|
171
|
+
*
|
|
172
|
+
* @param outputPath - Path where the output file will be saved
|
|
173
|
+
* @returns The path to the downloaded file
|
|
170
174
|
*/
|
|
171
175
|
downloadOutput(outputPath) {
|
|
172
176
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -180,28 +184,47 @@ export class DocumentIntelligenceJob {
|
|
|
180
184
|
if (!(downloadInfo === null || downloadInfo === void 0 ? void 0 : downloadInfo.file_url)) {
|
|
181
185
|
throw new Error("Invalid download URL response");
|
|
182
186
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
// Fetch with timeout (matching Python SDK's 300s timeout)
|
|
188
|
+
const controller = new AbortController();
|
|
189
|
+
const timeoutId = setTimeout(() => controller.abort(), 300000);
|
|
190
|
+
try {
|
|
191
|
+
const response = yield fetch(downloadInfo.file_url, {
|
|
192
|
+
signal: controller.signal,
|
|
193
|
+
});
|
|
194
|
+
if (!response.ok) {
|
|
195
|
+
throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
|
|
196
|
+
}
|
|
197
|
+
// Use arrayBuffer for binary data (ZIP files)
|
|
198
|
+
const arrayBuffer = yield response.arrayBuffer();
|
|
199
|
+
const content = new Uint8Array(arrayBuffer);
|
|
200
|
+
// Save to file (Node.js) or trigger download (browser)
|
|
201
|
+
if (typeof window === "undefined") {
|
|
202
|
+
// Node.js
|
|
203
|
+
const fs = yield import("fs");
|
|
204
|
+
const path = yield import("path");
|
|
205
|
+
// Ensure output directory exists (matching Python SDK behavior)
|
|
206
|
+
const outputDir = path.dirname(outputPath);
|
|
207
|
+
if (outputDir) {
|
|
208
|
+
yield fs.promises.mkdir(outputDir, { recursive: true });
|
|
209
|
+
}
|
|
210
|
+
yield fs.promises.writeFile(outputPath, content);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
// Browser - trigger download
|
|
214
|
+
const blob = new Blob([content], { type: "application/zip" });
|
|
215
|
+
const url = URL.createObjectURL(blob);
|
|
216
|
+
const a = document.createElement("a");
|
|
217
|
+
a.href = url;
|
|
218
|
+
a.download = outputPath;
|
|
219
|
+
document.body.appendChild(a);
|
|
220
|
+
a.click();
|
|
221
|
+
a.remove();
|
|
222
|
+
URL.revokeObjectURL(url);
|
|
223
|
+
}
|
|
224
|
+
return outputPath;
|
|
193
225
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const blob = new Blob([content], { type: "text/html" });
|
|
197
|
-
const url = URL.createObjectURL(blob);
|
|
198
|
-
const a = document.createElement("a");
|
|
199
|
-
a.href = url;
|
|
200
|
-
a.download = outputPath;
|
|
201
|
-
document.body.appendChild(a);
|
|
202
|
-
a.click();
|
|
203
|
-
a.remove();
|
|
204
|
-
URL.revokeObjectURL(url);
|
|
226
|
+
finally {
|
|
227
|
+
clearTimeout(timeoutId);
|
|
205
228
|
}
|
|
206
229
|
});
|
|
207
230
|
}
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.1.2-alpha.
|
|
1
|
+
export declare const SDK_VERSION = "1.1.2-alpha.14";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.1.2-alpha.
|
|
1
|
+
export const SDK_VERSION = "1.1.2-alpha.14";
|