Skip to content

Commit d1cf79d

Browse files
authored
Merge pull request #57 from imagekit-developer/dev
Dev
2 parents 20d0028 + 3b29b0b commit d1cf79d

File tree

19 files changed

+276
-65
lines changed

19 files changed

+276
-65
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [10.x, 12.x, 14.x]
12+
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
1313

1414
steps:
1515
- uses: actions/checkout@v1
@@ -22,6 +22,7 @@ jobs:
2222
npm i -g yarn
2323
yarn install
2424
yarn test
25+
yarn test-e2e
2526
yarn report-coverage
2627
env:
2728
CI: true

.github/workflows/npmpublish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
npm i -g yarn
2626
yarn install
2727
yarn test
28+
yarn test-e2e
2829
env:
2930
CI: true
3031

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,12 @@ node_modules
44
coverage.lcov
55
coverage
66
.DS_Store
7-
dist*
7+
dist*
8+
tests/e2e/node-js/package.json
9+
tests/e2e/node-js/yarn.lock
10+
tests/e2e/typescript/package.json
11+
tests/e2e/typescript/yarn.lock
12+
tests/e2e/typescript/index.js
13+
.cache
14+
yarn-error.log
15+
*.tgz

.npmignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ babel-register.js
99
.vscode
1010
.DS_Store
1111
.mocharc.json
12-
.nycrc
12+
.nycrc
13+
libs/*
14+
utils/*
15+
tsconfig*
16+
fixup.sh
17+
index.ts
18+
*.tgz
19+
test-e2e.sh

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Node.js SDK for [ImageKit](https://imagekit.io/) implements the new APIs and int
1313

1414
ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.
1515

16-
This SDK supports both CommonJS and ESM.
1716
##### Table of contents
1817
* [Installation](#installation)
1918
* [Initialization](#initialization)

index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ class ImageKit {
9999
}
100100

101101
/**
102-
* You can add multiple origins in the same ImageKit.io account.
103-
* URL endpoints allow you to configure which origins are accessible through your account and set their preference order as well.
102+
* This method allows you to create an URL to access a file using the relative or absolute path and the ImageKit URL endpoint (urlEndpoint). The file can be an image, video or any other static file supported by ImageKit.
104103
*
105104
* @see {@link https://github.com/imagekit-developer/imagekit-nodejs#url-generation}
106105
* @see {@link https://docs.imagekit.io/integration/url-endpoints}
@@ -113,10 +112,7 @@ class ImageKit {
113112
}
114113

115114
/**
116-
* You can upload files to ImageKit.io media library from your server-side using private API key authentication.
117-
*
118-
* File size limit
119-
* The maximum upload file size is limited to 25MB.
115+
* You can upload file to ImageKit.io media library from your server-side using private API key authentication.
120116
*
121117
* @see {@link https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload}
122118
*
@@ -133,7 +129,7 @@ class ImageKit {
133129

134130
/**
135131
* This API can list all the uploaded files in your ImageKit.io media library.
136-
* For searching and filtering, you can use query parameters as described below.
132+
* For searching and filtering, you can use query parameters as described in docs.
137133
*
138134
* @see {@link https://docs.imagekit.io/api-reference/media-api/list-and-search-files}
139135
*
@@ -165,7 +161,7 @@ class ImageKit {
165161
}
166162

167163
/**
168-
* Get all versions of an assset API
164+
* Get all versions of an assset.
169165
*
170166
* @see {@link https://docs.imagekit.io/api-reference/media-api/get-file-versions}
171167
*
@@ -181,7 +177,7 @@ class ImageKit {
181177
}
182178

183179
/**
184-
* Get file version details API
180+
* Get file details of a specific version.
185181
*
186182
* @see {@link https://docs.imagekit.io/api-reference/media-api/get-file-version-details}
187183
*
@@ -673,4 +669,4 @@ class ImageKit {
673669
}
674670
}
675671

676-
export default ImageKit;
672+
export = ImageKit;

libs/constants/supportedTransforms.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @see {@link https://docs.imagekit.io/features/image-transformations}
33
*/
4-
const supportedTransforms: { [key: string]: string } = {
4+
const supportedTransforms = {
55
/**
66
* @see {@link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#width-w}
77
*/
@@ -286,4 +286,5 @@ const supportedTransforms: { [key: string]: string } = {
286286
original: "orig",
287287
};
288288

289-
export default supportedTransforms;
289+
export default supportedTransforms as { [key: string]: string };
290+
export type SupportedTransformsParam = keyof typeof supportedTransforms;

libs/interfaces/Transformation.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import supportedTransforms from "../constants/supportedTransforms";
1+
import { SupportedTransformsParam } from "../constants/supportedTransforms";
22

33
export type TransformationPosition = "path" | "query";
44

5-
export type Transformation = Partial<typeof supportedTransforms>;
5+
export type Transformation = Partial<
6+
| {
7+
[key in SupportedTransformsParam]: string | boolean | number;
8+
}
9+
| { [key: string]: string | boolean | number }
10+
>;

libs/url/builder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ const buildURL = function (opts: FinalUrlOptions): string {
113113
return url.format(urlObject);
114114
};
115115

116-
function constructTransformationString(transformation: Array<Transformation> | undefined) {
116+
function constructTransformationString(inputTransformation: Array<Transformation> | undefined) {
117+
118+
const transformation = inputTransformation as Array<{ [key: string]: string | boolean | number }> | undefined;
117119
if (!Array.isArray(transformation)) {
118120
return "";
119121
}

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
{
22
"name": "imagekit",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Offical NodeJS SDK for ImageKit.io integration",
5-
"main": "./dist/cjs/index.js",
6-
"types": "./dist/types/index.d.ts",
7-
"module": "./dist/esm/index.js",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
87
"scripts": {
9-
"compile": "concurrently 'yarn:compile:cjs' 'yarn:compile:esm' 'yarn:compile:types'",
10-
"compile:cjs": "rm -rf dist/cjs & tsc -p tsconfig.cjs.json",
11-
"compile:esm": "rm -rf dist/esm & tsc -p tsconfig.esm.json",
12-
"compile:types": "rm -rf dist/types & tsc -p tsconfig.types.json",
8+
"compile": "rm -rf dist/ & tsc -p tsconfig.json",
139
"test": "export NODE_ENV=test; nyc ./node_modules/mocha/bin/mocha --exit -t 40000 tests/*.js;ex=$?;unset NODE_ENV; exit $ex;",
10+
"test-e2e": "sh test-e2e.sh; exit $?;",
1411
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
1512
"prepack": "npm run compile"
1613
},
@@ -56,9 +53,12 @@
5653
"@babel/preset-env": "^7.14.5",
5754
"@babel/preset-typescript": "^7.14.5",
5855
"@babel/register": "^7.14.5",
56+
"@types/chai": "^4.3.1",
5957
"@types/lodash": "^4.14.170",
58+
"@types/mocha": "^9.1.1",
6059
"@types/node": "^15.12.2",
6160
"@types/request": "^2.48.5",
61+
"@types/sinon": "^10.0.12",
6262
"@types/uuid": "^8.3.4",
6363
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
6464
"chai": "^4.2.0",

0 commit comments

Comments
 (0)