@@ -23,7 +23,7 @@ describe('instantiate client', () => {
2323 const client = new Zeroentropy ( {
2424 baseURL : 'http://localhost:5000/' ,
2525 defaultHeaders : { 'X-My-Default-Header' : '2' } ,
26- bearerToken : 'My Bearer Token ' ,
26+ apiKey : 'My API Key ' ,
2727 } ) ;
2828
2929 test ( 'they are used in the request' , ( ) => {
@@ -55,7 +55,7 @@ describe('instantiate client', () => {
5555 const client = new Zeroentropy ( {
5656 baseURL : 'http://localhost:5000/' ,
5757 defaultQuery : { apiVersion : 'foo' } ,
58- bearerToken : 'My Bearer Token ' ,
58+ apiKey : 'My API Key ' ,
5959 } ) ;
6060 expect ( client . buildURL ( '/foo' , null ) ) . toEqual ( 'http://localhost:5000/foo?apiVersion=foo' ) ;
6161 } ) ;
@@ -64,7 +64,7 @@ describe('instantiate client', () => {
6464 const client = new Zeroentropy ( {
6565 baseURL : 'http://localhost:5000/' ,
6666 defaultQuery : { apiVersion : 'foo' , hello : 'world' } ,
67- bearerToken : 'My Bearer Token ' ,
67+ apiKey : 'My API Key ' ,
6868 } ) ;
6969 expect ( client . buildURL ( '/foo' , null ) ) . toEqual ( 'http://localhost:5000/foo?apiVersion=foo&hello=world' ) ;
7070 } ) ;
@@ -73,7 +73,7 @@ describe('instantiate client', () => {
7373 const client = new Zeroentropy ( {
7474 baseURL : 'http://localhost:5000/' ,
7575 defaultQuery : { hello : 'world' } ,
76- bearerToken : 'My Bearer Token ' ,
76+ apiKey : 'My API Key ' ,
7777 } ) ;
7878 expect ( client . buildURL ( '/foo' , { hello : undefined } ) ) . toEqual ( 'http://localhost:5000/foo' ) ;
7979 } ) ;
@@ -82,7 +82,7 @@ describe('instantiate client', () => {
8282 test ( 'custom fetch' , async ( ) => {
8383 const client = new Zeroentropy ( {
8484 baseURL : 'http://localhost:5000/' ,
85- bearerToken : 'My Bearer Token ' ,
85+ apiKey : 'My API Key ' ,
8686 fetch : ( url ) => {
8787 return Promise . resolve (
8888 new Response ( JSON . stringify ( { url, custom : true } ) , {
@@ -99,7 +99,7 @@ describe('instantiate client', () => {
9999 test ( 'custom signal' , async ( ) => {
100100 const client = new Zeroentropy ( {
101101 baseURL : process . env [ 'TEST_API_BASE_URL' ] ?? 'http://127.0.0.1:4010' ,
102- bearerToken : 'My Bearer Token ' ,
102+ apiKey : 'My API Key ' ,
103103 fetch : ( ...args ) => {
104104 return new Promise ( ( resolve , reject ) =>
105105 setTimeout (
@@ -131,7 +131,7 @@ describe('instantiate client', () => {
131131
132132 const client = new Zeroentropy ( {
133133 baseURL : 'http://localhost:5000/' ,
134- bearerToken : 'My Bearer Token ' ,
134+ apiKey : 'My API Key ' ,
135135 fetch : testFetch ,
136136 } ) ;
137137
@@ -141,18 +141,12 @@ describe('instantiate client', () => {
141141
142142 describe ( 'baseUrl' , ( ) => {
143143 test ( 'trailing slash' , ( ) => {
144- const client = new Zeroentropy ( {
145- baseURL : 'http://localhost:5000/custom/path/' ,
146- bearerToken : 'My Bearer Token' ,
147- } ) ;
144+ const client = new Zeroentropy ( { baseURL : 'http://localhost:5000/custom/path/' , apiKey : 'My API Key' } ) ;
148145 expect ( client . buildURL ( '/foo' , null ) ) . toEqual ( 'http://localhost:5000/custom/path/foo' ) ;
149146 } ) ;
150147
151148 test ( 'no trailing slash' , ( ) => {
152- const client = new Zeroentropy ( {
153- baseURL : 'http://localhost:5000/custom/path' ,
154- bearerToken : 'My Bearer Token' ,
155- } ) ;
149+ const client = new Zeroentropy ( { baseURL : 'http://localhost:5000/custom/path' , apiKey : 'My API Key' } ) ;
156150 expect ( client . buildURL ( '/foo' , null ) ) . toEqual ( 'http://localhost:5000/custom/path/foo' ) ;
157151 } ) ;
158152
@@ -161,55 +155,55 @@ describe('instantiate client', () => {
161155 } ) ;
162156
163157 test ( 'explicit option' , ( ) => {
164- const client = new Zeroentropy ( { baseURL : 'https://example.com' , bearerToken : 'My Bearer Token ' } ) ;
158+ const client = new Zeroentropy ( { baseURL : 'https://example.com' , apiKey : 'My API Key ' } ) ;
165159 expect ( client . baseURL ) . toEqual ( 'https://example.com' ) ;
166160 } ) ;
167161
168162 test ( 'env variable' , ( ) => {
169163 process . env [ 'ZEROENTROPY_BASE_URL' ] = 'https://example.com/from_env' ;
170- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' } ) ;
164+ const client = new Zeroentropy ( { apiKey : 'My API Key ' } ) ;
171165 expect ( client . baseURL ) . toEqual ( 'https://example.com/from_env' ) ;
172166 } ) ;
173167
174168 test ( 'empty env variable' , ( ) => {
175169 process . env [ 'ZEROENTROPY_BASE_URL' ] = '' ; // empty
176- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' } ) ;
170+ const client = new Zeroentropy ( { apiKey : 'My API Key ' } ) ;
177171 expect ( client . baseURL ) . toEqual ( 'https://api.zeroentropy.dev/v1' ) ;
178172 } ) ;
179173
180174 test ( 'blank env variable' , ( ) => {
181175 process . env [ 'ZEROENTROPY_BASE_URL' ] = ' ' ; // blank
182- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' } ) ;
176+ const client = new Zeroentropy ( { apiKey : 'My API Key ' } ) ;
183177 expect ( client . baseURL ) . toEqual ( 'https://api.zeroentropy.dev/v1' ) ;
184178 } ) ;
185179 } ) ;
186180
187181 test ( 'maxRetries option is correctly set' , ( ) => {
188- const client = new Zeroentropy ( { maxRetries : 4 , bearerToken : 'My Bearer Token ' } ) ;
182+ const client = new Zeroentropy ( { maxRetries : 4 , apiKey : 'My API Key ' } ) ;
189183 expect ( client . maxRetries ) . toEqual ( 4 ) ;
190184
191185 // default
192- const client2 = new Zeroentropy ( { bearerToken : 'My Bearer Token ' } ) ;
186+ const client2 = new Zeroentropy ( { apiKey : 'My API Key ' } ) ;
193187 expect ( client2 . maxRetries ) . toEqual ( 2 ) ;
194188 } ) ;
195189
196190 test ( 'with environment variable arguments' , ( ) => {
197191 // set options via env var
198- process . env [ 'ZEROENTROPY_API_KEY' ] = 'My Bearer Token ' ;
192+ process . env [ 'ZEROENTROPY_API_KEY' ] = 'My API Key ' ;
199193 const client = new Zeroentropy ( ) ;
200- expect ( client . bearerToken ) . toBe ( 'My Bearer Token ' ) ;
194+ expect ( client . apiKey ) . toBe ( 'My API Key ' ) ;
201195 } ) ;
202196
203197 test ( 'with overridden environment variable arguments' , ( ) => {
204198 // set options via env var
205- process . env [ 'ZEROENTROPY_API_KEY' ] = 'another My Bearer Token ' ;
206- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' } ) ;
207- expect ( client . bearerToken ) . toBe ( 'My Bearer Token ' ) ;
199+ process . env [ 'ZEROENTROPY_API_KEY' ] = 'another My API Key ' ;
200+ const client = new Zeroentropy ( { apiKey : 'My API Key ' } ) ;
201+ expect ( client . apiKey ) . toBe ( 'My API Key ' ) ;
208202 } ) ;
209203} ) ;
210204
211205describe ( 'request building' , ( ) => {
212- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' } ) ;
206+ const client = new Zeroentropy ( { apiKey : 'My API Key ' } ) ;
213207
214208 describe ( 'Content-Length' , ( ) => {
215209 test ( 'handles multi-byte characters' , ( ) => {
@@ -251,7 +245,7 @@ describe('retries', () => {
251245 return new Response ( JSON . stringify ( { a : 1 } ) , { headers : { 'Content-Type' : 'application/json' } } ) ;
252246 } ;
253247
254- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' , timeout : 10 , fetch : testFetch } ) ;
248+ const client = new Zeroentropy ( { apiKey : 'My API Key ' , timeout : 10 , fetch : testFetch } ) ;
255249
256250 expect ( await client . request ( { path : '/foo' , method : 'get' } ) ) . toEqual ( { a : 1 } ) ;
257251 expect ( count ) . toEqual ( 2 ) ;
@@ -281,7 +275,7 @@ describe('retries', () => {
281275 return new Response ( JSON . stringify ( { a : 1 } ) , { headers : { 'Content-Type' : 'application/json' } } ) ;
282276 } ;
283277
284- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' , fetch : testFetch , maxRetries : 4 } ) ;
278+ const client = new Zeroentropy ( { apiKey : 'My API Key ' , fetch : testFetch , maxRetries : 4 } ) ;
285279
286280 expect ( await client . request ( { path : '/foo' , method : 'get' } ) ) . toEqual ( { a : 1 } ) ;
287281
@@ -305,7 +299,7 @@ describe('retries', () => {
305299 capturedRequest = init ;
306300 return new Response ( JSON . stringify ( { a : 1 } ) , { headers : { 'Content-Type' : 'application/json' } } ) ;
307301 } ;
308- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' , fetch : testFetch , maxRetries : 4 } ) ;
302+ const client = new Zeroentropy ( { apiKey : 'My API Key ' , fetch : testFetch , maxRetries : 4 } ) ;
309303
310304 expect (
311305 await client . request ( {
@@ -335,7 +329,7 @@ describe('retries', () => {
335329 return new Response ( JSON . stringify ( { a : 1 } ) , { headers : { 'Content-Type' : 'application/json' } } ) ;
336330 } ;
337331 const client = new Zeroentropy ( {
338- bearerToken : 'My Bearer Token ' ,
332+ apiKey : 'My API Key ' ,
339333 fetch : testFetch ,
340334 maxRetries : 4 ,
341335 defaultHeaders : { 'X-Stainless-Retry-Count' : null } ,
@@ -367,7 +361,7 @@ describe('retries', () => {
367361 capturedRequest = init ;
368362 return new Response ( JSON . stringify ( { a : 1 } ) , { headers : { 'Content-Type' : 'application/json' } } ) ;
369363 } ;
370- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' , fetch : testFetch , maxRetries : 4 } ) ;
364+ const client = new Zeroentropy ( { apiKey : 'My API Key ' , fetch : testFetch , maxRetries : 4 } ) ;
371365
372366 expect (
373367 await client . request ( {
@@ -394,7 +388,7 @@ describe('retries', () => {
394388 return new Response ( JSON . stringify ( { a : 1 } ) , { headers : { 'Content-Type' : 'application/json' } } ) ;
395389 } ;
396390
397- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' , fetch : testFetch } ) ;
391+ const client = new Zeroentropy ( { apiKey : 'My API Key ' , fetch : testFetch } ) ;
398392
399393 expect ( await client . request ( { path : '/foo' , method : 'get' } ) ) . toEqual ( { a : 1 } ) ;
400394 expect ( count ) . toEqual ( 2 ) ;
@@ -421,7 +415,7 @@ describe('retries', () => {
421415 return new Response ( JSON . stringify ( { a : 1 } ) , { headers : { 'Content-Type' : 'application/json' } } ) ;
422416 } ;
423417
424- const client = new Zeroentropy ( { bearerToken : 'My Bearer Token ' , fetch : testFetch } ) ;
418+ const client = new Zeroentropy ( { apiKey : 'My API Key ' , fetch : testFetch } ) ;
425419
426420 expect ( await client . request ( { path : '/foo' , method : 'get' } ) ) . toEqual ( { a : 1 } ) ;
427421 expect ( count ) . toEqual ( 2 ) ;
0 commit comments