Skip to content

Commit d93435e

Browse files
feat(api): update via SDK Studio
1 parent 0427698 commit d93435e

File tree

8 files changed

+44
-50
lines changed

8 files changed

+44
-50
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The full API of this library can be found in [api.md](api.md).
2626
import Zeroentropy from 'zeroentropy';
2727

2828
const client = new Zeroentropy({
29-
bearerToken: process.env['ZEROENTROPY_API_KEY'], // This is the default and can be omitted
29+
apiKey: process.env['ZEROENTROPY_API_KEY'], // This is the default and can be omitted
3030
});
3131

3232
async function main() {
@@ -47,7 +47,7 @@ This library includes TypeScript definitions for all request params and response
4747
import Zeroentropy from 'zeroentropy';
4848

4949
const client = new Zeroentropy({
50-
bearerToken: process.env['ZEROENTROPY_API_KEY'], // This is the default and can be omitted
50+
apiKey: process.env['ZEROENTROPY_API_KEY'], // This is the default and can be omitted
5151
});
5252

5353
async function main() {

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface ClientOptions {
4747
/**
4848
* API Key for accessing the ZeroEntropy API.
4949
*/
50-
bearerToken?: string | undefined;
50+
apiKey?: string | undefined;
5151

5252
/**
5353
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
@@ -110,14 +110,14 @@ export interface ClientOptions {
110110
* API Client for interfacing with the Zeroentropy API.
111111
*/
112112
export class Zeroentropy extends Core.APIClient {
113-
bearerToken: string;
113+
apiKey: string;
114114

115115
private _options: ClientOptions;
116116

117117
/**
118118
* API Client for interfacing with the Zeroentropy API.
119119
*
120-
* @param {string | undefined} [opts.bearerToken=process.env['ZEROENTROPY_API_KEY'] ?? undefined]
120+
* @param {string | undefined} [opts.apiKey=process.env['ZEROENTROPY_API_KEY'] ?? undefined]
121121
* @param {string} [opts.baseURL=process.env['ZEROENTROPY_BASE_URL'] ?? https://api.zeroentropy.dev/v1] - Override the default base URL for the API.
122122
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
123123
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
@@ -128,17 +128,17 @@ export class Zeroentropy extends Core.APIClient {
128128
*/
129129
constructor({
130130
baseURL = Core.readEnv('ZEROENTROPY_BASE_URL'),
131-
bearerToken = Core.readEnv('ZEROENTROPY_API_KEY'),
131+
apiKey = Core.readEnv('ZEROENTROPY_API_KEY'),
132132
...opts
133133
}: ClientOptions = {}) {
134-
if (bearerToken === undefined) {
134+
if (apiKey === undefined) {
135135
throw new Errors.ZeroentropyError(
136-
"The ZEROENTROPY_API_KEY environment variable is missing or empty; either provide it, or instantiate the Zeroentropy client with an bearerToken option, like new Zeroentropy({ bearerToken: 'My Bearer Token' }).",
136+
"The ZEROENTROPY_API_KEY environment variable is missing or empty; either provide it, or instantiate the Zeroentropy client with an apiKey option, like new Zeroentropy({ apiKey: 'My API Key' }).",
137137
);
138138
}
139139

140140
const options: ClientOptions = {
141-
bearerToken,
141+
apiKey,
142142
...opts,
143143
baseURL: baseURL || `https://api.zeroentropy.dev/v1`,
144144
};
@@ -153,7 +153,7 @@ export class Zeroentropy extends Core.APIClient {
153153

154154
this._options = options;
155155

156-
this.bearerToken = bearerToken;
156+
this.apiKey = apiKey;
157157
}
158158

159159
status: API.Status = new API.Status(this);
@@ -175,7 +175,7 @@ export class Zeroentropy extends Core.APIClient {
175175
}
176176

177177
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
178-
return { Authorization: `Bearer ${this.bearerToken}` };
178+
return { Authorization: `Bearer ${this.apiKey}` };
179179
}
180180

181181
static Zeroentropy = this;

tests/api-resources/collections.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Zeroentropy from 'zeroentropy';
44
import { Response } from 'node-fetch';
55

66
const client = new Zeroentropy({
7-
bearerToken: 'My Bearer Token',
7+
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

tests/api-resources/documents.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Zeroentropy from 'zeroentropy';
44
import { Response } from 'node-fetch';
55

66
const client = new Zeroentropy({
7-
bearerToken: 'My Bearer Token',
7+
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

tests/api-resources/parsers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Zeroentropy from 'zeroentropy';
44
import { Response } from 'node-fetch';
55

66
const client = new Zeroentropy({
7-
bearerToken: 'My Bearer Token',
7+
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

tests/api-resources/queries.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Zeroentropy from 'zeroentropy';
44
import { Response } from 'node-fetch';
55

66
const client = new Zeroentropy({
7-
bearerToken: 'My Bearer Token',
7+
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

tests/api-resources/status.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Zeroentropy from 'zeroentropy';
44
import { Response } from 'node-fetch';
55

66
const client = new Zeroentropy({
7-
bearerToken: 'My Bearer Token',
7+
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

tests/index.test.ts

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

211205
describe('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

Comments
 (0)