Skip to content

Commit 6a0ff10

Browse files
committed
base
1 parent c1bc59b commit 6a0ff10

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

src/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ export class ImageKit {
806806
accounts: API.Accounts = new API.Accounts(this);
807807
beta: API.Beta = new API.Beta(this);
808808
webhooks: API.Webhooks = new API.Webhooks(this);
809+
helper: API.Helper = new API.Helper(this);
809810
}
810811

811812
ImageKit.CustomMetadataFields = CustomMetadataFields;

src/resources/helper.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Helper resource for additional utility functions
2+
// File manually created for helper functions - not generated
3+
4+
import { APIResource } from '../core/resource';
5+
import type { ImageKit } from '../client';
6+
7+
export class Helper extends APIResource {
8+
constructor(client: ImageKit) {
9+
super(client);
10+
}
11+
12+
/**
13+
* Build ImageKit URL - currently returns input as-is
14+
*/
15+
buildSrc(input: string): string {
16+
return input;
17+
}
18+
19+
/**
20+
* Build transformation string - currently returns input as-is
21+
*/
22+
buildTransformationString(input: string): string {
23+
return input;
24+
}
25+
}

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ export {
5555
type UnsafeUnwrapWebhookEvent,
5656
type UnwrapWebhookEvent,
5757
} from './webhooks';
58+
export { Helper } from './helper';

tests/api-resources/helper.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Test for the Helper resource following TDD approach
2+
3+
import ImageKit from '@imagekit/nodejs';
4+
5+
const client = new ImageKit({
6+
privateAPIKey: 'My Private API Key',
7+
password: 'My Password',
8+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
9+
});
10+
11+
describe('resource helper', () => {
12+
describe('buildSrc', () => {
13+
test('should exist as a method', () => {
14+
expect(typeof client.helper.buildSrc).toBe('function');
15+
});
16+
17+
test('should return the input string as-is', () => {
18+
const input = '/test-image.jpg';
19+
const result = client.helper.buildSrc(input);
20+
21+
expect(result).toBe(input);
22+
});
23+
});
24+
25+
describe('buildTransformationString', () => {
26+
test('should exist as a method', () => {
27+
expect(typeof client.helper.buildTransformationString).toBe('function');
28+
});
29+
30+
test('should return the input string as-is', () => {
31+
const input = 'w-300,h-200';
32+
const result = client.helper.buildTransformationString(input);
33+
34+
expect(result).toBe(input);
35+
});
36+
37+
test('should handle different string inputs', () => {
38+
const inputs = [
39+
'w-300,h-200,c-at_max',
40+
'f-webp,q-80',
41+
'r-10,b-5_black',
42+
'',
43+
'single-param'
44+
];
45+
46+
inputs.forEach(input => {
47+
const result = client.helper.buildTransformationString(input);
48+
expect(result).toBe(input);
49+
});
50+
});
51+
52+
test('should handle empty string', () => {
53+
const result = client.helper.buildTransformationString('');
54+
expect(result).toBe('');
55+
});
56+
});
57+
});

0 commit comments

Comments
 (0)