File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,26 +12,32 @@ type UnsupportedCometAPIOption = (typeof UNSUPPORTED_COMETAPI_OPTIONS)[number];
1212function sanitizeOptions < T extends Partial < ClientOptions > > (
1313 options : T ,
1414) : Omit < T , UnsupportedCometAPIOption > {
15- const {
16- provider,
17- workloadIdentity,
18- dangerouslyAllowBrowser,
19- ...supportedOptions
20- } = options ;
21- const unsupportedOptions = {
22- provider,
23- workloadIdentity,
24- dangerouslyAllowBrowser,
25- } ;
26-
2715 for ( const option of UNSUPPORTED_COMETAPI_OPTIONS ) {
28- if ( unsupportedOptions [ option ] !== undefined ) {
16+ if ( Reflect . get ( options , option ) !== undefined ) {
2917 throw new OpenAIError (
3018 `The \`${ option } \` option is not supported by CometAPI.` ,
3119 ) ;
3220 }
3321 }
3422
23+ const supportedOptions = { } as Omit < T , UnsupportedCometAPIOption > ;
24+ for ( const option of Reflect . ownKeys ( options ) ) {
25+ if (
26+ UNSUPPORTED_COMETAPI_OPTIONS . includes (
27+ option as UnsupportedCometAPIOption ,
28+ ) ||
29+ ! Object . prototype . propertyIsEnumerable . call ( options , option )
30+ ) {
31+ continue ;
32+ }
33+ Object . defineProperty ( supportedOptions , option , {
34+ configurable : true ,
35+ enumerable : true ,
36+ value : Reflect . get ( options , option ) ,
37+ writable : true ,
38+ } ) ;
39+ }
40+
3541 return supportedOptions ;
3642}
3743
Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ describe("CometAPI configuration", () => {
309309 options as unknown as CometAPIOptions ,
310310 ) ;
311311
312- expect ( reads ) . toBeGreaterThan ( 0 ) ;
312+ expect ( reads ) . toBe ( 1 ) ;
313313 expect ( error . message ) . toMatch ( / b r o w s e r - l i k e e n v i r o n m e n t / i) ;
314314 expectSecretFreeError ( error , [ browserKey ] , logger ) ;
315315 } ) ;
You can’t perform that action at this time.
0 commit comments