Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Changelog

### SDK Version 5.3.0

### Breaking changes

**1. `listFiles` API response type**
* The `listFiles` method now returns a unified response type, ListFileResponse, which is an array of both `FileObject` and `FolderObject`. Previously, the response contained only `FileObject`. The `type` property in the response object indicates whether the object is a file or a folder. Even though this change has been made to just the type of the return object, it can be considered a breaking change so it may require require any code relying on the `listFiles` response to be updated.

```
const result = await imagekit.listFiles({ skip: 0, limit: 10 });

# Before (Pre-version 5.3.0)
result.forEach((item) => {
console.log(item);
});

# After (Version 5.3.0 and above)
result.forEach((item) => {
if (item.type === "folder") {
console.log(item) // item is of type FolderObject
} else {
console.log(item) // item is of type FileObject
}
});
```


### SDK Version 5.0.0

#### Breaking changes

**1. Overlay syntax update**
* In version 5.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly.
* You can migrate to the new layers syntax using the `raw` transformation parameter.

**2. Remove Node.js 10.x support**
* In version 5.0.0, we've removed support for Node.js version 10.x.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ ImageKit is complete media storage, optimization, and transformation solution th
* [Support](#support)
* [Links](#links)

## Changelog

### SDK Version 5.0.0

#### Breaking changes

**1. Overlay syntax update**
* In version 5.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly.
* You can migrate to the new layers syntax using the `raw` transformation parameter.

**2. Remove Node.js 10.x support**
* In version 5.0.0, we've removed support for Node.js version 10.x.

## Installation

Use the following command to download this module. Use the optional `--save` parameter if you wish to save the dependency in your `package.json` file.
Expand Down
11 changes: 6 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CopyFolderResponse,
FileDetailsOptions,
FileObject,
FolderObject,
FileMetadataResponse,
ImageKitOptions,
ListFileOptions,
Expand Down Expand Up @@ -135,13 +136,13 @@ class ImageKit {
*
* @param listFilesOptions
*/
listFiles(listOptions: ListFileOptions): Promise<IKResponse<FileObject[]>>;
listFiles(listOptions: ListFileOptions, callback: IKCallback<IKResponse<FileObject[]>>): void;
listFiles(listOptions: ListFileOptions): Promise<IKResponse<ListFileResponse>>;
listFiles(listOptions: ListFileOptions, callback: IKCallback<IKResponse<ListFileResponse>>): void;
listFiles(
listOptions: ListFileOptions,
callback?: IKCallback<IKResponse<FileObject[]>>,
): void | Promise<IKResponse<FileObject[]>> {
return promisify<IKResponse<FileObject[]>>(this, manage.listFiles)(listOptions, this.options, callback);
callback?: IKCallback<IKResponse<ListFileResponse>>,
): void | Promise<IKResponse<ListFileResponse>> {
return promisify<IKResponse<ListFileResponse>>(this, manage.listFiles)(listOptions, this.options, callback);
}

/**
Expand Down
49 changes: 40 additions & 9 deletions libs/interfaces/FileDetails.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FileType } from "./FileType";
import { Item } from "./Item";

export interface EmbeddedMetadataValues {
[key: string]:
Expand Down Expand Up @@ -56,13 +55,13 @@ export interface FileDetailsOptions {
* Example - 50,50,500,500
*/
customCoordinates?: string;
/*
* Object with array of extensions to be processed on the image.
*/
/*
* Object with array of extensions to be processed on the image.
*/
extensions?: Extension;
/*
* Final status of pending extensions will be sent to this URL.
*/
* Final status of pending extensions will be sent to this URL.
*/
webhookUrl?: string
/*
* Array of AI tags to remove from the asset.
Expand Down Expand Up @@ -93,9 +92,9 @@ export interface FileObject {
*/
fileId: string;
/**
* Type of item. It can be either file or folder.
* Type of item. It can be either file, file-version or folder.
*/
type: Item;
type: "file" | "file-version";
/**
* Name of the file or folder.
*/
Expand Down Expand Up @@ -180,6 +179,38 @@ export interface FileObject {
versionInfo?: { name: string; id: string };
}

/**
*
* Folder object.
*
* @see {@link https://docs.imagekit.io/api-reference/media-api#file-object-structure}
*/
export interface FolderObject {
/**
* The unique fileId of the folder.
*/
folderId: string;
/**
* Type of item. It can be either file, file-version or folder.
*/
type: "folder";
/**
* Name of the file or folder.
*/
name: string;
/**
* The relative path of the folder.
*/
folderPath: string;
/*
* The date and time when the folder was first created. The format is YYYY-MM-DDTHH:mm:ss.sssZ
*/
createdAt: string;
/*
* The date and time when the folder was last updated. The format is YYYY-MM-DDTHH:mm:ss.sssZ
*/
updatedAt: string;
}

export interface FileVersionDetailsOptions {
/**
Expand All @@ -190,4 +221,4 @@ export interface FileVersionDetailsOptions {
* The unique versionId of the uploaded file's version. This is returned in list files API and upload API as id within the versionInfo parameter.
*/
versionId: string;
}
}
4 changes: 0 additions & 4 deletions libs/interfaces/Item.ts

This file was deleted.

50 changes: 2 additions & 48 deletions libs/interfaces/ListFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FileObject, FolderObject } from "./FileDetails";
import { FileType } from "./FileType";
import { Item } from "./Item";

/**
* List and search files options
Expand Down Expand Up @@ -76,50 +76,4 @@ export interface ListFileOptions {
*
* @see {@link https://docs.imagekit.io/api-reference/media-api/list-and-search-files#response-structure-and-status-code-application-json}
*/
export interface ListFileResponse {
/**
* The unique fileId of the uploaded file.
*/
fileId: string;
/**
* Type of item. It can be either file or folder.
*/
type: Item;
/**
* Name of the file or folder.
*/
name: string;
/**
* The date and time when the file was first uploaded. The format is `YYYY-MM-DDTHH:mm:ss.sssZ`.
*/
createdAt: string;
/**
* The relative path of the file. In the case of an image, you can use this
* path to construct different transformations.
*/
filePath: string;
/**
* Array of tags associated with the image. If no tags are set, it will be null.
*/
tags: string[] | null;
/**
* Is the file marked as private. It can be either true or false.
*/
isPrivateFile: boolean;
/**
* Value of custom coordinates associated with the image in format x,y,width,height. If customCoordinates are not defined then it is null.
*/
customCoordinates: string | null;
/**
* A publicly accessible URL of the file.
*/
url: string;
/**
* In case of an image, a small thumbnail URL.
*/
thumbnail: string;
/**
* The type of file, it could be either image or non-image.
*/
fileType: FileType;
}
export type ListFileResponse = Array<FileObject | FolderObject>;
3 changes: 2 additions & 1 deletion libs/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ListFileOptions, ListFileResponse } from "./ListFile";
import { CopyFileOptions } from "./CopyFile";
import { MoveFileOptions } from "./MoveFile";
import { CreateFolderOptions } from "./CreateFolder";
import { FileDetailsOptions, FileVersionDetailsOptions, FileObject } from "./FileDetails";
import { FileDetailsOptions, FileVersionDetailsOptions, FileObject, FolderObject } from "./FileDetails";
import { FileMetadataResponse } from "./FileMetadata";
import { PurgeCacheResponse, PurgeCacheStatusResponse } from "./PurgeCache";
import { BulkDeleteFilesResponse, BulkDeleteFilesError } from "./BulkDeleteFiles";
Expand Down Expand Up @@ -44,6 +44,7 @@ export type {
FileDetailsOptions,
FileVersionDetailsOptions,
FileObject,
FolderObject,
FileMetadataResponse,
PurgeCacheResponse,
PurgeCacheStatusResponse,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imagekit",
"version": "5.2.1",
"version": "5.3.0",
"description": "Offical NodeJS SDK for ImageKit.io integration",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down