44
55import { UnstructuredClientCore } from "../core.js" ;
66import { appendForm , encodeSimple } from "../lib/encodings.js" ;
7- import { readableStreamToArrayBuffer } from "../lib/files.js" ;
7+ import {
8+ getContentTypeFromFileName ,
9+ readableStreamToArrayBuffer ,
10+ } from "../lib/files.js" ;
811import * as M from "../lib/matchers.js" ;
912import { compactMap } from "../lib/primitives.js" ;
1013import { safeParse } from "../lib/schemas.js" ;
@@ -19,8 +22,9 @@ import {
1922 UnexpectedClientError ,
2023} from "../sdk/models/errors/httpclienterrors.js" ;
2124import * as errors from "../sdk/models/errors/index.js" ;
22- import { SDKError } from "../sdk/models/errors/sdkerror .js" ;
25+ import { ResponseValidationError } from "../sdk/models/errors/responsevalidationerror .js" ;
2326import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js" ;
27+ import { UnstructuredClientError } from "../sdk/models/errors/unstructuredclienterror.js" ;
2428import * as operations from "../sdk/models/operations/index.js" ;
2529import { APICall , APIPromise } from "../sdk/types/async.js" ;
2630import { isBlobLike } from "../sdk/types/blobs.js" ;
@@ -47,13 +51,14 @@ export function generalPartition(
4751 operations . PartitionResponse ,
4852 | errors . HTTPValidationError
4953 | errors . ServerError
50- | SDKError
51- | SDKValidationError
52- | UnexpectedClientError
53- | InvalidRequestError
54+ | UnstructuredClientError
55+ | ResponseValidationError
56+ | ConnectionError
5457 | RequestAbortedError
5558 | RequestTimeoutError
56- | ConnectionError
59+ | InvalidRequestError
60+ | UnexpectedClientError
61+ | SDKValidationError
5762 >
5863> {
5964 return new APIPromise ( $do (
@@ -73,13 +78,14 @@ async function $do(
7378 operations . PartitionResponse ,
7479 | errors . HTTPValidationError
7580 | errors . ServerError
76- | SDKError
77- | SDKValidationError
78- | UnexpectedClientError
79- | InvalidRequestError
81+ | UnstructuredClientError
82+ | ResponseValidationError
83+ | ConnectionError
8084 | RequestAbortedError
8185 | RequestTimeoutError
82- | ConnectionError
86+ | InvalidRequestError
87+ | UnexpectedClientError
88+ | SDKValidationError
8389 > ,
8490 APICall ,
8591 ]
@@ -101,14 +107,25 @@ async function $do(
101107 const buffer = await readableStreamToArrayBuffer (
102108 payload . partition_parameters . files . content ,
103109 ) ;
104- const blob = new Blob ( [ buffer ] , { type : "application/octet-stream" } ) ;
105- appendForm ( body , "files" , blob ) ;
110+ const contentType =
111+ getContentTypeFromFileName ( payload . partition_parameters . files . fileName )
112+ || "application/octet-stream" ;
113+ const blob = new Blob ( [ buffer ] , { type : contentType } ) ;
114+ appendForm (
115+ body ,
116+ "files" ,
117+ blob ,
118+ payload . partition_parameters . files . fileName ,
119+ ) ;
106120 } else {
121+ const contentType =
122+ getContentTypeFromFileName ( payload . partition_parameters . files . fileName )
123+ || "application/octet-stream" ;
107124 appendForm (
108125 body ,
109126 "files" ,
110127 new Blob ( [ payload . partition_parameters . files . content ] , {
111- type : "application/octet-stream" ,
128+ type : contentType ,
112129 } ) ,
113130 payload . partition_parameters . files . fileName ,
114131 ) ;
@@ -415,13 +432,14 @@ async function $do(
415432 operations . PartitionResponse ,
416433 | errors . HTTPValidationError
417434 | errors . ServerError
418- | SDKError
419- | SDKValidationError
420- | UnexpectedClientError
421- | InvalidRequestError
435+ | UnstructuredClientError
436+ | ResponseValidationError
437+ | ConnectionError
422438 | RequestAbortedError
423439 | RequestTimeoutError
424- | ConnectionError
440+ | InvalidRequestError
441+ | UnexpectedClientError
442+ | SDKValidationError
425443 > (
426444 M . json ( 200 , operations . PartitionResponse$inboundSchema ) ,
427445 M . text ( 200 , operations . PartitionResponse$inboundSchema , {
@@ -430,7 +448,7 @@ async function $do(
430448 M . jsonErr ( 422 , errors . HTTPValidationError$inboundSchema ) ,
431449 M . fail ( "4XX" ) ,
432450 M . jsonErr ( "5XX" , errors . ServerError$inboundSchema ) ,
433- ) ( response , { extraFields : responseFields } ) ;
451+ ) ( response , req , { extraFields : responseFields } ) ;
434452 if ( ! result . ok ) {
435453 return [ result , { status : "complete" , request : req , response } ] ;
436454 }
0 commit comments