Skip to content

Commit 97cc1ff

Browse files
committed
parameter name fix
1 parent b65ed7f commit 97cc1ff

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

libs/constants/errorMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
"MISSING_UPLOAD_FILENAME_PARAMETER": { message: "Missing fileName parameter for upload", help: "" },
1919
"JOB_ID_MISSING": { message: "Missing jobId parameter", help: "" },
2020
"INVALID_DESTINATION_FOLDER_PATH": { messages: "Invalid destinationPath value", help: "It should be a string like '/path/to/folder'" },
21-
"INVALID_INCLUDE_VERSION": { messages: "Invalid includeVersions value", help: "It should be a boolean" },
21+
"INVALID_INCLUDE_VERSION": { messages: "Invalid includeFileVersions value", help: "It should be a boolean" },
2222
"INVALID_SOURCE_FILE_PATH": { messages: "Invalid sourceFilePath value", help: "It should be a string like /path/to/file.jpg'" },
2323
"INVALID_SOURCE_FOLDER_PATH": { messages: "Invalid sourceFolderPath value", help: "It should be a string like '/path/to/folder'" },
2424
"INVALID_FOLDER_NAME": { messages: "Invalid folderName value", help: "" },

libs/interfaces/CopyFile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export interface CopyFileOptions {
1111
* Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied.
1212
* Default value is false
1313
*/
14-
includeVersions?: boolean;
14+
includeFileVersions?: boolean;
1515
}

libs/interfaces/CopyFolder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ export interface CopyFolderOptions {
4040
* Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied.
4141
* Default value - false
4242
*/
43-
includeVersions?: boolean;
43+
includeFileVersions?: boolean;
4444
}

libs/manage/file.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ const copyFile = function (
410410
defaultOptions: ImageKitOptions,
411411
callback?: IKCallback<void>,
412412
) {
413-
const { sourceFilePath, destinationPath, includeVersions = false } = copyFileOptions;
413+
const { sourceFilePath, destinationPath, includeFileVersions = false } = copyFileOptions;
414414

415415
if (typeof sourceFilePath !== "string" || sourceFilePath.length === 0) {
416416
respond(true, errorMessages.INVALID_SOURCE_FILE_PATH, callback);
@@ -422,15 +422,15 @@ const copyFile = function (
422422
return;
423423
}
424424

425-
if (typeof includeVersions !== "boolean") {
425+
if (typeof includeFileVersions !== "boolean") {
426426
respond(true, errorMessages.INVALID_INCLUDE_VERSION, callback);
427427
return;
428428
}
429429

430430
const data = {
431431
sourceFilePath,
432432
destinationPath,
433-
includeVersions
433+
includeFileVersions
434434
};
435435

436436
const requestOptions = {
@@ -483,7 +483,7 @@ const copyFolder = function (
483483
defaultOptions: ImageKitOptions,
484484
callback?: IKCallback<CopyFolderResponse>,
485485
) {
486-
const { sourceFolderPath, destinationPath, includeVersions = false } = copyFolderOptions;
486+
const { sourceFolderPath, destinationPath, includeFileVersions = false } = copyFolderOptions;
487487
if (typeof sourceFolderPath !== "string" || sourceFolderPath.length === 0) {
488488
respond(true, errorMessages.INVALID_SOURCE_FOLDER_PATH, callback);
489489
return;
@@ -494,10 +494,15 @@ const copyFolder = function (
494494
return;
495495
}
496496

497+
if (typeof includeFileVersions !== "boolean") {
498+
respond(true, errorMessages.INVALID_INCLUDE_VERSION, callback);
499+
return;
500+
}
501+
497502
const data = {
498503
sourceFolderPath,
499504
destinationPath,
500-
includeVersions
505+
includeFileVersions
501506
};
502507

503508
const requestOptions = {

tests/mediaLibrary.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ describe("Media library APIs", function () {
108108
});
109109
});
110110

111+
it('Copy file invalid includeFileVersions value', function (done) {
112+
var sourceFilePath = "/sdf";
113+
var destinationPath = "/";
114+
imagekit.copyFile({ sourceFilePath, destinationPath, includeFileVersions: "sdf" }, function (err, response) {
115+
expect(err).to.deep.equal({
116+
messages: "Invalid includeFileVersions value",
117+
help: "It should be a boolean"
118+
})
119+
done();
120+
});
121+
});
122+
111123
it('Move file invalid folder path', function (done) {
112124
var sourceFilePath = "/file.jpg";
113125
imagekit.moveFile({ sourceFilePath, destinationPath: null }, function (err, response) {
@@ -152,6 +164,17 @@ describe("Media library APIs", function () {
152164
});
153165
});
154166

167+
it('Copy folder invalid includeFileVersions', function (done) {
168+
var sourceFolderPath = "/";
169+
imagekit.copyFolder({ sourceFolderPath, destinationPath: "/sdf", includeFileVersions: "sdf" }, function (err, response) {
170+
expect(err).to.deep.equal({
171+
messages: "Invalid includeFileVersions value",
172+
help: "It should be a boolean"
173+
})
174+
done();
175+
});
176+
});
177+
155178
it('Move folder invalid destinationPath', function (done) {
156179
var sourceFolderPath = "/";
157180
imagekit.moveFolder({ sourceFolderPath, destinationPath: null }, function (err, response) {

0 commit comments

Comments
 (0)