kcommons 15.4.0 → 15.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/configs/response.typings.d.ts +15 -0
- package/build/configs/response.typings.js +2 -0
- package/build/enums/upload.enum.d.ts +6 -0
- package/build/enums/upload.enum.js +15 -0
- package/build/index.d.ts +5 -1
- package/build/index.js +7 -1
- package/build/typings/common/uploadMedia.typings.d.ts +16 -2
- package/build/typings/common/uploadMedia.typings.js +1 -0
- package/build/utils/extractMediaFilenameFromLink.util.d.ts +1 -0
- package/build/utils/extractMediaFilenameFromLink.util.js +17 -0
- package/build/utils/extractMediaFilenameFromLink.util.spec.d.ts +1 -0
- package/build/utils/extractMediaFilenameFromLink.util.spec.js +17 -0
- package/build/utils/getFileExtension.util.d.ts +1 -0
- package/build/utils/getFileExtension.util.js +10 -0
- package/build/utils/getMediaName.util.d.ts +3 -1
- package/build/utils/getMediaName.util.js +14 -8
- package/build/utils/getMediaName.util.spec.js +24 -12
- package/build/utils/stripQueryParams.util.d.ts +1 -0
- package/build/utils/stripQueryParams.util.js +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IResponse<T = any> {
|
|
2
|
+
result?: T;
|
|
3
|
+
error?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
err_code?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IResponseWithPagination<T = any> {
|
|
8
|
+
data: T[];
|
|
9
|
+
limit: number;
|
|
10
|
+
page: number;
|
|
11
|
+
total: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ISuccessResponse {
|
|
14
|
+
success: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare enum UPLOAD_PATH_IDS {
|
|
2
|
+
USER_PROFILE_IMAGE = "USER_PROFILE_IMAGE",
|
|
3
|
+
INDENT_ATTACHMENT = "INDENT_ATTACHMENT",
|
|
4
|
+
INDENT_ITEM_ATTACHMENT = "INDENT_ITEM_ATTACHMENT"
|
|
5
|
+
}
|
|
6
|
+
export declare const UPLOAD_PATHS_CONFIG: Record<UPLOAD_PATH_IDS, (fileExtension: string) => string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UPLOAD_PATHS_CONFIG = exports.UPLOAD_PATH_IDS = void 0;
|
|
4
|
+
const uploadMedia_typings_1 = require("../typings/common/uploadMedia.typings");
|
|
5
|
+
var UPLOAD_PATH_IDS;
|
|
6
|
+
(function (UPLOAD_PATH_IDS) {
|
|
7
|
+
UPLOAD_PATH_IDS["USER_PROFILE_IMAGE"] = "USER_PROFILE_IMAGE";
|
|
8
|
+
UPLOAD_PATH_IDS["INDENT_ATTACHMENT"] = "INDENT_ATTACHMENT";
|
|
9
|
+
UPLOAD_PATH_IDS["INDENT_ITEM_ATTACHMENT"] = "INDENT_ITEM_ATTACHMENT";
|
|
10
|
+
})(UPLOAD_PATH_IDS || (exports.UPLOAD_PATH_IDS = UPLOAD_PATH_IDS = {}));
|
|
11
|
+
exports.UPLOAD_PATHS_CONFIG = {
|
|
12
|
+
INDENT_ATTACHMENT: (extension) => `v2/company/indents/attachments/indent_attachment_${Date.now()}.${extension}?mediaAccessType=${uploadMedia_typings_1.MEDIA_ACCEESS_TYPE.PRIVATE}`,
|
|
13
|
+
INDENT_ITEM_ATTACHMENT: (extension) => `v2/company/indent-items/attachments/indent_item_attachment_${Date.now()}.${extension}?mediaAccessType=${uploadMedia_typings_1.MEDIA_ACCEESS_TYPE.PRIVATE}`,
|
|
14
|
+
USER_PROFILE_IMAGE: (extension) => `v2/company/users/profile-image/user_profile_image_${Date.now()}.${extension}?mediaAccessType=${uploadMedia_typings_1.MEDIA_ACCEESS_TYPE.PUBLIC}`,
|
|
15
|
+
};
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "date-fns";
|
|
2
2
|
export * from "./typings/releaseNote.typings";
|
|
3
|
+
export * from "./configs/response.typings";
|
|
3
4
|
export * from "./typings/roles.typings";
|
|
4
5
|
export * from "./typings/companyVendors.typings";
|
|
5
6
|
export * from "./typings/department.typings";
|
|
@@ -95,12 +96,13 @@ export * from "./constants/date.constants";
|
|
|
95
96
|
export * from "./constants/companyDocumentUplodPath.constants";
|
|
96
97
|
export * from "./constants/vendorPermission.constants";
|
|
97
98
|
export * from "./classes/asnWrapper.class";
|
|
99
|
+
export * from "./enums/upload.enum";
|
|
98
100
|
export * from "./utils/permission.utils";
|
|
99
101
|
export * from "./utils/taxes.util";
|
|
100
102
|
export * from "./utils/parseQueryParams.util";
|
|
101
103
|
export * from "./utils/getContactPerson.util";
|
|
102
104
|
export * from "./utils/quote.util";
|
|
103
|
-
export * from "./utils/
|
|
105
|
+
export * from "./utils/extractMediaFilenameFromLink.util";
|
|
104
106
|
export * from "./utils/removeQueryParamsFromReqStr.util";
|
|
105
107
|
export * from "./utils/toFixedDecimal.util";
|
|
106
108
|
export * from "./utils/convertToINS.util";
|
|
@@ -109,6 +111,8 @@ export * from "./utils/extra-form/formatValidationSchema.util";
|
|
|
109
111
|
export * from "./utils/extra-form/getFormProps.util";
|
|
110
112
|
export * from "./utils/extra-form/getDefaultVAlues.util";
|
|
111
113
|
export * from "./utils/generateId.util";
|
|
114
|
+
export * from "./utils/getFileExtension.util";
|
|
115
|
+
export * from "./utils/stripQueryParams.util";
|
|
112
116
|
export * from "./typings/verification_apis/pincode.typings";
|
|
113
117
|
export * from "./typings/verification_apis/gstVerification.typings";
|
|
114
118
|
export * from "./typings/verification_apis/udyamVerification.typings";
|
package/build/index.js
CHANGED
|
@@ -18,6 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
__exportStar(require("date-fns"), exports);
|
|
19
19
|
//superadmin
|
|
20
20
|
__exportStar(require("./typings/releaseNote.typings"), exports);
|
|
21
|
+
// Configs
|
|
22
|
+
__exportStar(require("./configs/response.typings"), exports);
|
|
21
23
|
// Includes
|
|
22
24
|
__exportStar(require("./typings/roles.typings"), exports);
|
|
23
25
|
__exportStar(require("./typings/companyVendors.typings"), exports);
|
|
@@ -118,13 +120,15 @@ __exportStar(require("./constants/companyDocumentUplodPath.constants"), exports)
|
|
|
118
120
|
__exportStar(require("./constants/vendorPermission.constants"), exports);
|
|
119
121
|
// Classes
|
|
120
122
|
__exportStar(require("./classes/asnWrapper.class"), exports);
|
|
123
|
+
// Enums
|
|
124
|
+
__exportStar(require("./enums/upload.enum"), exports);
|
|
121
125
|
// Utils
|
|
122
126
|
__exportStar(require("./utils/permission.utils"), exports);
|
|
123
127
|
__exportStar(require("./utils/taxes.util"), exports);
|
|
124
128
|
__exportStar(require("./utils/parseQueryParams.util"), exports);
|
|
125
129
|
__exportStar(require("./utils/getContactPerson.util"), exports);
|
|
126
130
|
__exportStar(require("./utils/quote.util"), exports);
|
|
127
|
-
__exportStar(require("./utils/
|
|
131
|
+
__exportStar(require("./utils/extractMediaFilenameFromLink.util"), exports);
|
|
128
132
|
__exportStar(require("./utils/removeQueryParamsFromReqStr.util"), exports);
|
|
129
133
|
__exportStar(require("./utils/toFixedDecimal.util"), exports);
|
|
130
134
|
__exportStar(require("./utils/convertToINS.util"), exports);
|
|
@@ -133,6 +137,8 @@ __exportStar(require("./utils/extra-form/formatValidationSchema.util"), exports)
|
|
|
133
137
|
__exportStar(require("./utils/extra-form/getFormProps.util"), exports);
|
|
134
138
|
__exportStar(require("./utils/extra-form/getDefaultVAlues.util"), exports);
|
|
135
139
|
__exportStar(require("./utils/generateId.util"), exports);
|
|
140
|
+
__exportStar(require("./utils/getFileExtension.util"), exports);
|
|
141
|
+
__exportStar(require("./utils/stripQueryParams.util"), exports);
|
|
136
142
|
// Verification APIs
|
|
137
143
|
__exportStar(require("./typings/verification_apis/pincode.typings"), exports);
|
|
138
144
|
__exportStar(require("./typings/verification_apis/gstVerification.typings"), exports);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** @deprecated */
|
|
2
2
|
export interface IRequestDownloadURLReq {
|
|
3
3
|
key: string;
|
|
4
4
|
}
|
|
5
|
+
/** @deprecated */
|
|
5
6
|
export interface IRequestDownloadURLRes {
|
|
6
7
|
publicUrl: string;
|
|
7
8
|
}
|
|
@@ -14,18 +15,31 @@ export declare enum MEDIA_ACCEESS_TYPE {
|
|
|
14
15
|
PUBLIC = "public",
|
|
15
16
|
PRIVATE = "private"
|
|
16
17
|
}
|
|
18
|
+
/** @deprecated */
|
|
17
19
|
export interface IUploadMediaResponse {
|
|
18
20
|
uploadUrl: string;
|
|
19
21
|
uploadPath: string;
|
|
20
22
|
}
|
|
23
|
+
/** @deprecated */
|
|
21
24
|
export interface IUploadMediaRequest {
|
|
22
25
|
path: string;
|
|
23
26
|
mimetype: string;
|
|
24
27
|
mediaAccessType: MEDIA_ACCEESS_TYPE;
|
|
25
28
|
}
|
|
26
|
-
export interface IMediaPathQueryParams
|
|
29
|
+
export interface IMediaPathQueryParams {
|
|
30
|
+
mediaAccessType: MEDIA_ACCEESS_TYPE;
|
|
27
31
|
}
|
|
28
32
|
export declare enum OPEN_DOCUMENT_TYPE {
|
|
29
33
|
QUOTE = "QUOTE",
|
|
30
34
|
PO = "PO"
|
|
31
35
|
}
|
|
36
|
+
export interface IUploadPathV2Response {
|
|
37
|
+
upload_presigned_url: string;
|
|
38
|
+
upload_path: string;
|
|
39
|
+
}
|
|
40
|
+
export interface IDownloadPathV2Request {
|
|
41
|
+
media_path: string;
|
|
42
|
+
}
|
|
43
|
+
export interface IDownloadPathV2Response {
|
|
44
|
+
download_presigned_url: string;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractMediaFilenameFromLink(link?: string | null): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractMediaFilenameFromLink = extractMediaFilenameFromLink;
|
|
4
|
+
function extractMediaFilenameFromLink(link) {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!link)
|
|
7
|
+
return null;
|
|
8
|
+
const linkBase = (_a = link === null || link === void 0 ? void 0 : link.split("?")) === null || _a === void 0 ? void 0 : _a[0];
|
|
9
|
+
const mediaName = linkBase === null || linkBase === void 0 ? void 0 : linkBase.split("/").pop();
|
|
10
|
+
// const mediaNameWithoutExt = mediaName
|
|
11
|
+
// ?.split(".")
|
|
12
|
+
// .reverse()
|
|
13
|
+
// .slice(1)
|
|
14
|
+
// .reverse()
|
|
15
|
+
// .join(".");
|
|
16
|
+
return mediaName || null;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const extractMediaFilenameFromLink_util_1 = require("./extractMediaFilenameFromLink.util");
|
|
4
|
+
describe("Get Media Name From Link", () => {
|
|
5
|
+
it("If link is Null it gives null", () => {
|
|
6
|
+
expect((0, extractMediaFilenameFromLink_util_1.extractMediaFilenameFromLink)()).toBe(null);
|
|
7
|
+
});
|
|
8
|
+
it("if gives Image URL is present it gives Media Name", () => {
|
|
9
|
+
expect((0, extractMediaFilenameFromLink_util_1.extractMediaFilenameFromLink)("https://example.com/images/my-awesome-photo.jpg?size=large")).toBe("my-awesome-photo");
|
|
10
|
+
});
|
|
11
|
+
it("if gives Video URL is present it gives Media Name", () => {
|
|
12
|
+
expect((0, extractMediaFilenameFromLink_util_1.extractMediaFilenameFromLink)("https://cdn.videos.net/clips/holiday-vacation-clip.mp4")).toBe("holiday-vacation-clip");
|
|
13
|
+
});
|
|
14
|
+
it("if gives Video URL is present it gives Media Name", () => {
|
|
15
|
+
expect((0, extractMediaFilenameFromLink_util_1.extractMediaFilenameFromLink)("https://docs.storage.org/reports/quarterly_report_2025.pdf")).toBe("quarterly_report_2025");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileExtension(filename: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFileExtension = getFileExtension;
|
|
4
|
+
function getFileExtension(filename) {
|
|
5
|
+
const strParts = filename === null || filename === void 0 ? void 0 : filename.split(".");
|
|
6
|
+
const extension = strParts.pop();
|
|
7
|
+
if (strParts.length < 2 || !extension)
|
|
8
|
+
throw new Error(`### Failed to find extension for filename: ${filename}`);
|
|
9
|
+
return extension;
|
|
10
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
exports.extractMediaFilenameFromLink = extractMediaFilenameFromLink;
|
|
4
|
+
function extractMediaFilenameFromLink(link) {
|
|
5
|
+
if (!link) return null;
|
|
6
|
+
const linkBase =
|
|
7
|
+
link === null || link === void 0 ? void 0 : link.split("?")[0];
|
|
8
|
+
const mediaName =
|
|
9
|
+
linkBase === null || linkBase === void 0
|
|
10
|
+
? void 0
|
|
11
|
+
: linkBase.split("/").pop();
|
|
12
|
+
const mediaNameWithoutExt =
|
|
13
|
+
mediaName === null || mediaName === void 0
|
|
14
|
+
? void 0
|
|
15
|
+
: mediaName.split(".").reverse().slice(1).reverse().join(".");
|
|
16
|
+
return mediaNameWithoutExt || null;
|
|
11
17
|
}
|
|
@@ -2,16 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getMediaName_util_1 = require("./getMediaName.util");
|
|
4
4
|
describe("Get Media Name From Link", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
it("If link is Null it gives null", () => {
|
|
6
|
+
expect((0, getMediaName_util_1.extractMediaFilenameFromLink)()).toBe(null);
|
|
7
|
+
});
|
|
8
|
+
it("if gives Image URL is present it gives Media Name", () => {
|
|
9
|
+
expect(
|
|
10
|
+
(0, getMediaName_util_1.extractMediaFilenameFromLink)(
|
|
11
|
+
"https://example.com/images/my-awesome-photo.jpg?size=large",
|
|
12
|
+
),
|
|
13
|
+
).toBe("my-awesome-photo");
|
|
14
|
+
});
|
|
15
|
+
it("if gives Video URL is present it gives Media Name", () => {
|
|
16
|
+
expect(
|
|
17
|
+
(0, getMediaName_util_1.extractMediaFilenameFromLink)(
|
|
18
|
+
"https://cdn.videos.net/clips/holiday-vacation-clip.mp4",
|
|
19
|
+
),
|
|
20
|
+
).toBe("holiday-vacation-clip");
|
|
21
|
+
});
|
|
22
|
+
it("if gives Video URL is present it gives Media Name", () => {
|
|
23
|
+
expect(
|
|
24
|
+
(0, getMediaName_util_1.extractMediaFilenameFromLink)(
|
|
25
|
+
"https://docs.storage.org/reports/quarterly_report_2025.pdf",
|
|
26
|
+
),
|
|
27
|
+
).toBe("quarterly_report_2025");
|
|
28
|
+
});
|
|
17
29
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripQueryParams(url: string): string;
|