Skip to content

Commit 78f9507

Browse files
feat(api): manual updates
1 parent af5fd2f commit 78f9507

18 files changed

+74
-95
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml
33
openapi_spec_hash: 1d382866fce3284f26d341f112988d9d
4-
config_hash: 54c05a157f2cc730fac9e1df5dc3ca29
4+
config_hash: 29a2351fe2be89392b15719be8bc964f

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 ImageKit from '@imagekit/nodejs';
2727

2828
const client = new ImageKit({
29-
privateAPIKey: process.env['IMAGEKIT_PRIVATE_API_KEY'], // This is the default and can be omitted
29+
privateKey: process.env['IMAGEKIT_PRIVATE_API_KEY'], // This is the default and can be omitted
3030
password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted
3131
});
3232

@@ -47,7 +47,7 @@ This library includes TypeScript definitions for all request params and response
4747
import ImageKit from '@imagekit/nodejs';
4848

4949
const client = new ImageKit({
50-
privateAPIKey: process.env['IMAGEKIT_PRIVATE_API_KEY'], // This is the default and can be omitted
50+
privateKey: process.env['IMAGEKIT_PRIVATE_API_KEY'], // This is the default and can be omitted
5151
password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted
5252
});
5353

src/client.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@ export interface ClientOptions {
9292
* You can view and manage API keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys).
9393
*
9494
*/
95-
privateAPIKey?: string | undefined;
95+
privateKey?: string | undefined;
9696

9797
/**
98-
* ImageKit Basic Auth only uses the username field and ignores the password.
99-
* This field is unused.
98+
* ImageKit Basic Auth only uses the `private_key` as username and ignores the password.
10099
*
101100
*/
102101
password?: string | null | undefined;
@@ -183,7 +182,7 @@ export interface ClientOptions {
183182
* API Client for interfacing with the Image Kit API.
184183
*/
185184
export class ImageKit {
186-
privateAPIKey: string;
185+
privateKey: string;
187186
password: string | null;
188187
webhookSecret: string | null;
189188

@@ -202,7 +201,7 @@ export class ImageKit {
202201
/**
203202
* API Client for interfacing with the Image Kit API.
204203
*
205-
* @param {string | undefined} [opts.privateAPIKey=process.env['IMAGEKIT_PRIVATE_API_KEY'] ?? undefined]
204+
* @param {string | undefined} [opts.privateKey=process.env['IMAGEKIT_PRIVATE_API_KEY'] ?? undefined]
206205
* @param {string | null | undefined} [opts.password=process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'] ?? do_not_set]
207206
* @param {string | null | undefined} [opts.webhookSecret=process.env['IMAGEKIT_WEBHOOK_SECRET'] ?? null]
208207
* @param {string} [opts.baseURL=process.env['IMAGE_KIT_BASE_URL'] ?? https://api.imagekit.io] - Override the default base URL for the API.
@@ -215,19 +214,19 @@ export class ImageKit {
215214
*/
216215
constructor({
217216
baseURL = readEnv('IMAGE_KIT_BASE_URL'),
218-
privateAPIKey = readEnv('IMAGEKIT_PRIVATE_API_KEY'),
217+
privateKey = readEnv('IMAGEKIT_PRIVATE_API_KEY'),
219218
password = readEnv('OPTIONAL_IMAGEKIT_IGNORES_THIS') ?? 'do_not_set',
220219
webhookSecret = readEnv('IMAGEKIT_WEBHOOK_SECRET') ?? null,
221220
...opts
222221
}: ClientOptions = {}) {
223-
if (privateAPIKey === undefined) {
222+
if (privateKey === undefined) {
224223
throw new Errors.ImageKitError(
225-
"The IMAGEKIT_PRIVATE_API_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateAPIKey option, like new ImageKit({ privateAPIKey: 'My Private API Key' }).",
224+
"The IMAGEKIT_PRIVATE_API_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateKey option, like new ImageKit({ privateKey: 'My Private Key' }).",
226225
);
227226
}
228227

229228
const options: ClientOptions = {
230-
privateAPIKey,
229+
privateKey,
231230
password,
232231
webhookSecret,
233232
...opts,
@@ -251,7 +250,7 @@ export class ImageKit {
251250

252251
this._options = options;
253252

254-
this.privateAPIKey = privateAPIKey;
253+
this.privateKey = privateKey;
255254
this.password = password;
256255
this.webhookSecret = webhookSecret;
257256
}
@@ -269,7 +268,7 @@ export class ImageKit {
269268
logLevel: this.logLevel,
270269
fetch: this.fetch,
271270
fetchOptions: this.fetchOptions,
272-
privateAPIKey: this.privateAPIKey,
271+
privateKey: this.privateKey,
273272
password: this.password,
274273
webhookSecret: this.webhookSecret,
275274
...options,
@@ -289,28 +288,28 @@ export class ImageKit {
289288
}
290289

291290
protected validateHeaders({ values, nulls }: NullableHeaders) {
292-
if (this.privateAPIKey && this.password && values.get('authorization')) {
291+
if (this.privateKey && this.password && values.get('authorization')) {
293292
return;
294293
}
295294
if (nulls.has('authorization')) {
296295
return;
297296
}
298297

299298
throw new Error(
300-
'Could not resolve authentication method. Expected the privateAPIKey or password to be set. Or for the "Authorization" headers to be explicitly omitted',
299+
'Could not resolve authentication method. Expected the privateKey or password to be set. Or for the "Authorization" headers to be explicitly omitted',
301300
);
302301
}
303302

304303
protected async authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
305-
if (!this.privateAPIKey) {
304+
if (!this.privateKey) {
306305
return undefined;
307306
}
308307

309308
if (!this.password) {
310309
return undefined;
311310
}
312311

313-
const credentials = `${this.privateAPIKey}:${this.password}`;
312+
const credentials = `${this.privateKey}:${this.password}`;
314313
const Authorization = `Basic ${toBase64(credentials)}`;
315314
return buildHeaders([{ Authorization }]);
316315
}

tests/api-resources/accounts/origins.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ImageKit from '@imagekit/nodejs';
44

55
const client = new ImageKit({
6-
privateAPIKey: 'My Private API Key',
6+
privateKey: 'My Private Key',
77
password: 'My Password',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});

tests/api-resources/accounts/url-endpoints.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ImageKit from '@imagekit/nodejs';
44

55
const client = new ImageKit({
6-
privateAPIKey: 'My Private API Key',
6+
privateKey: 'My Private Key',
77
password: 'My Password',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});

tests/api-resources/accounts/usage.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ImageKit from '@imagekit/nodejs';
44

55
const client = new ImageKit({
6-
privateAPIKey: 'My Private API Key',
6+
privateKey: 'My Private Key',
77
password: 'My Password',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});

tests/api-resources/assets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ImageKit from '@imagekit/nodejs';
44

55
const client = new ImageKit({
6-
privateAPIKey: 'My Private API Key',
6+
privateKey: 'My Private Key',
77
password: 'My Password',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});

tests/api-resources/beta/v2/files.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ImageKit, { toFile } from '@imagekit/nodejs';
44

55
const client = new ImageKit({
6-
privateAPIKey: 'My Private API Key',
6+
privateKey: 'My Private Key',
77
password: 'My Password',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});

tests/api-resources/cache/invalidation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ImageKit from '@imagekit/nodejs';
44

55
const client = new ImageKit({
6-
privateAPIKey: 'My Private API Key',
6+
privateKey: 'My Private Key',
77
password: 'My Password',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});

tests/api-resources/custom-metadata-fields.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import ImageKit from '@imagekit/nodejs';
44

55
const client = new ImageKit({
6-
privateAPIKey: 'My Private API Key',
6+
privateKey: 'My Private Key',
77
password: 'My Password',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});

0 commit comments

Comments
 (0)