@peacom/core 0.0.85 → 0.0.87
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/.eslintrc.json +18 -0
- package/data/Chuyen-de-1.pdf +63386 -304
- package/data/report_bulk_campaign_Kplus_1665394311017.xlsx +0 -0
- package/jest.config.ts +16 -0
- package/package.json +9 -10
- package/project.json +41 -0
- package/src/index.ts +5 -0
- package/src/lib/api/api.constant.ts +82 -0
- package/src/lib/api/core.api.ts +86 -0
- package/src/lib/api/index.ts +4 -0
- package/src/lib/api/micro-service.api.ts +35 -0
- package/src/lib/api/micro-service.spec.ts +29 -0
- package/src/lib/api/queue/queue.api.ts +39 -0
- package/src/lib/core.spec.ts +7 -0
- package/src/lib/core.ts +3 -0
- package/src/lib/error/FormError.ts +64 -0
- package/src/lib/error/HttpError.ts +9 -0
- package/src/lib/model/Application.ts +63 -0
- package/src/lib/model/BackgroundTask.ts +5 -0
- package/src/lib/model/Billing.ts +11 -0
- package/src/lib/model/Currency.ts +5 -0
- package/src/lib/model/FileInfo.ts +9 -0
- package/src/lib/model/conversation/constant.ts +34 -0
- package/src/lib/model/conversation/index.ts +1 -0
- package/src/lib/model/index.ts +11 -0
- package/src/lib/model/message/Message.ts +159 -0
- package/src/lib/model/message/TemplateMessage.ts +4 -0
- package/src/lib/model/message/index.ts +4 -0
- package/src/lib/model/message/sinch/SinchWhatsappTemplate.ts +27 -0
- package/src/lib/model/message/zalo/ZaloZNSTemplate.ts +26 -0
- package/src/lib/model/partner/PartnerEvent.ts +24 -0
- package/src/lib/model/partner/index.ts +6 -0
- package/src/lib/model/queue/QueueMessage.ts +31 -0
- package/src/lib/model/queue/index.ts +2 -0
- package/src/lib/model/queue/queue.constant.ts +6 -0
- package/src/lib/model/template/Template.ts +86 -0
- package/src/lib/model/template/index.ts +1 -0
- package/src/lib/model/viber-business/constant.ts +4 -0
- package/src/lib/model/viber-business/index.ts +1 -0
- package/src/lib/service/index.ts +1 -0
- package/src/lib/service/storage/aws/constants.ts +22 -0
- package/src/lib/service/storage/aws/index.ts +2 -0
- package/src/lib/service/storage/aws/s3.service.ts +128 -0
- package/src/lib/service/storage/aws/s3.spec.ts +12 -0
- package/src/lib/service/storage/index.ts +1 -0
- package/src/lib/util/date/constant.ts +3 -0
- package/src/lib/util/date/date.spec.ts +22 -0
- package/src/lib/util/date/date.util.ts +64 -0
- package/src/lib/util/date/index.ts +2 -0
- package/src/lib/util/file/file.spec.ts +40 -0
- package/src/lib/util/file/file.util.ts +60 -0
- package/src/lib/util/general.util.ts +3 -0
- package/src/lib/util/index.ts +6 -0
- package/src/lib/util/message/message.util.ts +118 -0
- package/src/lib/util/phone.spec.ts +48 -0
- package/src/lib/util/phone.util.ts +51 -0
- package/src/lib/util/string.spec.ts +15 -0
- package/src/lib/util/string.util.ts +118 -0
- package/tsconfig.json +22 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/src/index.d.ts +0 -4
- package/src/index.js +0 -8
- package/src/index.js.map +0 -1
- package/src/lib/api/api.constant.d.ts +0 -58
- package/src/lib/api/api.constant.js +0 -20
- package/src/lib/api/api.constant.js.map +0 -1
- package/src/lib/api/core.api.d.ts +0 -9
- package/src/lib/api/core.api.js +0 -78
- package/src/lib/api/core.api.js.map +0 -1
- package/src/lib/api/index.d.ts +0 -4
- package/src/lib/api/index.js +0 -8
- package/src/lib/api/index.js.map +0 -1
- package/src/lib/api/micro-service.api.d.ts +0 -2
- package/src/lib/api/micro-service.api.js +0 -38
- package/src/lib/api/micro-service.api.js.map +0 -1
- package/src/lib/api/queue/queue.api.d.ts +0 -7
- package/src/lib/api/queue/queue.api.js +0 -37
- package/src/lib/api/queue/queue.api.js.map +0 -1
- package/src/lib/core.d.ts +0 -1
- package/src/lib/core.js +0 -8
- package/src/lib/core.js.map +0 -1
- package/src/lib/error/FormError.d.ts +0 -53
- package/src/lib/error/FormError.js +0 -58
- package/src/lib/error/FormError.js.map +0 -1
- package/src/lib/error/HttpError.d.ts +0 -4
- package/src/lib/error/HttpError.js +0 -12
- package/src/lib/error/HttpError.js.map +0 -1
- package/src/lib/model/Application.d.ts +0 -52
- package/src/lib/model/Application.js +0 -59
- package/src/lib/model/Application.js.map +0 -1
- package/src/lib/model/Billing.d.ts +0 -10
- package/src/lib/model/Billing.js +0 -16
- package/src/lib/model/Billing.js.map +0 -1
- package/src/lib/model/Currency.d.ts +0 -4
- package/src/lib/model/Currency.js +0 -9
- package/src/lib/model/Currency.js.map +0 -1
- package/src/lib/model/FileInfo.d.ts +0 -9
- package/src/lib/model/FileInfo.js +0 -3
- package/src/lib/model/FileInfo.js.map +0 -1
- package/src/lib/model/conversation/constant.d.ts +0 -25
- package/src/lib/model/conversation/constant.js +0 -25
- package/src/lib/model/conversation/constant.js.map +0 -1
- package/src/lib/model/conversation/index.d.ts +0 -1
- package/src/lib/model/conversation/index.js +0 -5
- package/src/lib/model/conversation/index.js.map +0 -1
- package/src/lib/model/index.d.ts +0 -10
- package/src/lib/model/index.js +0 -14
- package/src/lib/model/index.js.map +0 -1
- package/src/lib/model/message/Message.d.ts +0 -129
- package/src/lib/model/message/Message.js +0 -88
- package/src/lib/model/message/Message.js.map +0 -1
- package/src/lib/model/message/TemplateMessage.d.ts +0 -4
- package/src/lib/model/message/TemplateMessage.js +0 -9
- package/src/lib/model/message/TemplateMessage.js.map +0 -1
- package/src/lib/model/message/index.d.ts +0 -4
- package/src/lib/model/message/index.js +0 -8
- package/src/lib/model/message/index.js.map +0 -1
- package/src/lib/model/message/sinch/SinchWhatsappTemplate.d.ts +0 -22
- package/src/lib/model/message/sinch/SinchWhatsappTemplate.js +0 -14
- package/src/lib/model/message/sinch/SinchWhatsappTemplate.js.map +0 -1
- package/src/lib/model/message/zalo/ZaloZNSTemplate.d.ts +0 -23
- package/src/lib/model/message/zalo/ZaloZNSTemplate.js +0 -3
- package/src/lib/model/message/zalo/ZaloZNSTemplate.js.map +0 -1
- package/src/lib/model/partner/PartnerEvent.d.ts +0 -22
- package/src/lib/model/partner/PartnerEvent.js +0 -3
- package/src/lib/model/partner/PartnerEvent.js.map +0 -1
- package/src/lib/model/partner/index.d.ts +0 -5
- package/src/lib/model/partner/index.js +0 -11
- package/src/lib/model/partner/index.js.map +0 -1
- package/src/lib/model/queue/QueueMessage.d.ts +0 -28
- package/src/lib/model/queue/QueueMessage.js +0 -9
- package/src/lib/model/queue/QueueMessage.js.map +0 -1
- package/src/lib/model/queue/index.d.ts +0 -2
- package/src/lib/model/queue/index.js +0 -6
- package/src/lib/model/queue/index.js.map +0 -1
- package/src/lib/model/queue/queue.constant.d.ts +0 -6
- package/src/lib/model/queue/queue.constant.js +0 -11
- package/src/lib/model/queue/queue.constant.js.map +0 -1
- package/src/lib/model/template/Template.d.ts +0 -43
- package/src/lib/model/template/Template.js +0 -89
- package/src/lib/model/template/Template.js.map +0 -1
- package/src/lib/model/template/index.d.ts +0 -1
- package/src/lib/model/template/index.js +0 -5
- package/src/lib/model/template/index.js.map +0 -1
- package/src/lib/model/viber-business/constant.d.ts +0 -4
- package/src/lib/model/viber-business/constant.js +0 -9
- package/src/lib/model/viber-business/constant.js.map +0 -1
- package/src/lib/model/viber-business/index.d.ts +0 -1
- package/src/lib/model/viber-business/index.js +0 -5
- package/src/lib/model/viber-business/index.js.map +0 -1
- package/src/lib/util/date/constant.d.ts +0 -3
- package/src/lib/util/date/constant.js +0 -7
- package/src/lib/util/date/constant.js.map +0 -1
- package/src/lib/util/date/date.util.d.ts +0 -19
- package/src/lib/util/date/date.util.js +0 -59
- package/src/lib/util/date/date.util.js.map +0 -1
- package/src/lib/util/date/index.d.ts +0 -2
- package/src/lib/util/date/index.js +0 -6
- package/src/lib/util/date/index.js.map +0 -1
- package/src/lib/util/file/file.util.d.ts +0 -5
- package/src/lib/util/file/file.util.js +0 -35
- package/src/lib/util/file/file.util.js.map +0 -1
- package/src/lib/util/general.util.d.ts +0 -1
- package/src/lib/util/general.util.js +0 -8
- package/src/lib/util/general.util.js.map +0 -1
- package/src/lib/util/index.d.ts +0 -6
- package/src/lib/util/index.js +0 -10
- package/src/lib/util/index.js.map +0 -1
- package/src/lib/util/message/message.util.d.ts +0 -90
- package/src/lib/util/message/message.util.js +0 -72
- package/src/lib/util/message/message.util.js.map +0 -1
- package/src/lib/util/phone.util.d.ts +0 -24
- package/src/lib/util/phone.util.js +0 -51
- package/src/lib/util/phone.util.js.map +0 -1
- package/src/lib/util/string.util.d.ts +0 -14
- package/src/lib/util/string.util.js +0 -118
- package/src/lib/util/string.util.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
export * from './Template';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/model/template/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B"}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.VIBER_SEND_MESSAGE_TYPE = void 0;
|
4
|
-
var VIBER_SEND_MESSAGE_TYPE;
|
5
|
-
(function (VIBER_SEND_MESSAGE_TYPE) {
|
6
|
-
VIBER_SEND_MESSAGE_TYPE[VIBER_SEND_MESSAGE_TYPE["PROMOTION"] = 1] = "PROMOTION";
|
7
|
-
VIBER_SEND_MESSAGE_TYPE[VIBER_SEND_MESSAGE_TYPE["SESSION"] = 2] = "SESSION";
|
8
|
-
})(VIBER_SEND_MESSAGE_TYPE = exports.VIBER_SEND_MESSAGE_TYPE || (exports.VIBER_SEND_MESSAGE_TYPE = {}));
|
9
|
-
//# sourceMappingURL=constant.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/model/viber-business/constant.ts"],"names":[],"mappings":";;;AAAA,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IACjC,+EAAa,CAAA;IACb,2EAAW,CAAA;AACb,CAAC,EAHW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAGlC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './constant';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/model/viber-business/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DATE_TIME_FORMAT = exports.DATE_FORMAT = exports.DEFAULT_TIME_ZONE = void 0;
|
4
|
-
exports.DEFAULT_TIME_ZONE = 'Asia/Ho_Chi_Minh';
|
5
|
-
exports.DATE_FORMAT = "YYYY-MM-DD";
|
6
|
-
exports.DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
7
|
-
//# sourceMappingURL=constant.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/date/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,kBAAkB,CAAA;AACtC,QAAA,WAAW,GAAG,YAAY,CAAC;AAC3B,QAAA,gBAAgB,GAAG,qBAAqB,CAAC"}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import * as moment from "moment-timezone";
|
2
|
-
declare type DateType = Date | string;
|
3
|
-
export declare function formatDateTimeTZ(date: DateType, timezone?: string, format?: string): string;
|
4
|
-
export declare const getDate: (date: DateType, tz?: string) => moment.Moment;
|
5
|
-
export declare function endOfDate(date: DateType, tz?: string): Date;
|
6
|
-
export declare function startOfDate(date: DateType, tz?: string): Date;
|
7
|
-
export declare function addHours(date: DateType, hours: number, tz?: string): Date;
|
8
|
-
/**
|
9
|
-
* Week start from sunday
|
10
|
-
* @param date
|
11
|
-
* @param tz
|
12
|
-
*/
|
13
|
-
export declare function startOfWeeks(date: DateType, tz?: string): Date;
|
14
|
-
export declare function endOfWeek(date: DateType, tz?: string): Date;
|
15
|
-
export declare function lastWeek(date: DateType, tz?: string): Date;
|
16
|
-
export declare function differentMinute(date: DateType, date1: DateType): number;
|
17
|
-
export declare function formatTimeTZ(date: DateType, timezone?: string, format?: string): string;
|
18
|
-
export declare const parseDateTimeByFormat: (dateStr: string, format?: string, timezone?: string) => Date;
|
19
|
-
export {};
|
@@ -1,59 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.parseDateTimeByFormat = exports.formatTimeTZ = exports.differentMinute = exports.lastWeek = exports.endOfWeek = exports.startOfWeeks = exports.addHours = exports.startOfDate = exports.endOfDate = exports.getDate = exports.formatDateTimeTZ = void 0;
|
4
|
-
const constant_1 = require("./constant");
|
5
|
-
const moment = require("moment-timezone");
|
6
|
-
function formatDateTimeTZ(date, timezone = constant_1.DEFAULT_TIME_ZONE, format = constant_1.DATE_TIME_FORMAT) {
|
7
|
-
return moment(date).tz(timezone).format(format);
|
8
|
-
}
|
9
|
-
exports.formatDateTimeTZ = formatDateTimeTZ;
|
10
|
-
const getDate = (date, tz = "") => {
|
11
|
-
if (!tz)
|
12
|
-
return moment(date);
|
13
|
-
return moment(date).tz(tz);
|
14
|
-
};
|
15
|
-
exports.getDate = getDate;
|
16
|
-
function endOfDate(date, tz = "") {
|
17
|
-
return (0, exports.getDate)(date, tz).endOf("date").toDate();
|
18
|
-
}
|
19
|
-
exports.endOfDate = endOfDate;
|
20
|
-
function startOfDate(date, tz = "") {
|
21
|
-
return (0, exports.getDate)(date, tz).startOf("date").toDate();
|
22
|
-
}
|
23
|
-
exports.startOfDate = startOfDate;
|
24
|
-
function addHours(date, hours, tz = "") {
|
25
|
-
return (0, exports.getDate)(date, tz).add(hours, "hours").toDate();
|
26
|
-
}
|
27
|
-
exports.addHours = addHours;
|
28
|
-
/**
|
29
|
-
* Week start from sunday
|
30
|
-
* @param date
|
31
|
-
* @param tz
|
32
|
-
*/
|
33
|
-
function startOfWeeks(date, tz = "") {
|
34
|
-
return (0, exports.getDate)(date, tz).startOf("week").toDate();
|
35
|
-
}
|
36
|
-
exports.startOfWeeks = startOfWeeks;
|
37
|
-
function endOfWeek(date, tz = "") {
|
38
|
-
return (0, exports.getDate)(date, tz).endOf("week").toDate();
|
39
|
-
}
|
40
|
-
exports.endOfWeek = endOfWeek;
|
41
|
-
function lastWeek(date, tz = "") {
|
42
|
-
return (0, exports.getDate)(date, tz).subtract(1, "week").startOf("week").toDate();
|
43
|
-
}
|
44
|
-
exports.lastWeek = lastWeek;
|
45
|
-
function differentMinute(date, date1) {
|
46
|
-
return Math.ceil(moment(date).diff(moment(date1), "minutes", true));
|
47
|
-
}
|
48
|
-
exports.differentMinute = differentMinute;
|
49
|
-
function formatTimeTZ(date, timezone = constant_1.DEFAULT_TIME_ZONE, format = "LT") {
|
50
|
-
return moment(date).tz(timezone).format(format);
|
51
|
-
}
|
52
|
-
exports.formatTimeTZ = formatTimeTZ;
|
53
|
-
const parseDateTimeByFormat = (dateStr, format = constant_1.DATE_TIME_FORMAT, timezone = constant_1.DEFAULT_TIME_ZONE) => {
|
54
|
-
return moment
|
55
|
-
.tz(`${dateStr}`, constant_1.DATE_TIME_FORMAT, timezone)
|
56
|
-
.toDate();
|
57
|
-
};
|
58
|
-
exports.parseDateTimeByFormat = parseDateTimeByFormat;
|
59
|
-
//# sourceMappingURL=date.util.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"date.util.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/date/date.util.ts"],"names":[],"mappings":";;;AAAA,yCAA+D;AAC/D,0CAA0C;AAI1C,SAAgB,gBAAgB,CAC9B,IAAc,EACd,QAAQ,GAAG,4BAAiB,EAC5B,MAAM,GAAG,2BAAgB;IAEzB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAND,4CA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D,8BAEC;AAED,SAAgB,QAAQ,CAAC,IAAc,EAAE,EAAE,GAAG,EAAE;IAC9C,OAAO,IAAA,eAAO,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;AACvE,CAAC;AAFD,4BAEC;AAED,SAAgB,eAAe,CAAC,IAAc,EAAE,KAAe;IAC7D,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC;AAFD,0CAEC;AAED,SAAgB,YAAY,CAAC,IAAc,EAAE,QAAQ,GAAG,4BAAiB,EAAE,MAAM,GAAG,IAAI;IACtF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAFD,oCAEC;AAEM,MAAM,qBAAqB,GAAG,CACnC,OAAe,EACf,MAAM,GAAG,2BAAgB,EACzB,QAAQ,GAAG,4BAAiB,EAC5B,EAAE;IACF,OAAO,MAAM;SACV,EAAE,CAAC,GAAG,OAAO,EAAE,EAAE,2BAAgB,EAAE,QAAQ,CAAC;SAC5C,MAAM,EAAE,CAAC;AACd,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/date/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,sDAA2B"}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { FileInfo } from "../../model/";
|
2
|
-
export declare const isImage: (mimetype: string) => boolean;
|
3
|
-
export declare const isVideo: (mimetype: string) => boolean;
|
4
|
-
export declare const isAudio: (mimetype: string) => boolean;
|
5
|
-
export declare const getFileInfoFromUrl: (url: string, defaultMimeType?: string) => FileInfo;
|
@@ -1,35 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getFileInfoFromUrl = exports.isAudio = exports.isVideo = exports.isImage = void 0;
|
4
|
-
const mime = require("mime-types");
|
5
|
-
const isImage = (mimetype) => {
|
6
|
-
const regex = /(^image)(\/)[a-zA-Z0-9_]*/gm;
|
7
|
-
return regex.test(mimetype);
|
8
|
-
};
|
9
|
-
exports.isImage = isImage;
|
10
|
-
const isVideo = (mimetype) => {
|
11
|
-
const regex = /(^video)(\/)[a-zA-Z0-9_]*/gm;
|
12
|
-
return regex.test(mimetype);
|
13
|
-
};
|
14
|
-
exports.isVideo = isVideo;
|
15
|
-
const isAudio = (mimetype) => {
|
16
|
-
const regex = /(^audio)(\/)[a-zA-Z0-9_]*/gm;
|
17
|
-
return regex.test(mimetype);
|
18
|
-
};
|
19
|
-
exports.isAudio = isAudio;
|
20
|
-
const getFileInfoFromUrl = (url, defaultMimeType = "application/binary") => {
|
21
|
-
const rs = {
|
22
|
-
name: "",
|
23
|
-
type: defaultMimeType,
|
24
|
-
extension: "",
|
25
|
-
url
|
26
|
-
};
|
27
|
-
rs.name = new URL(url).pathname.split("/").pop() || url;
|
28
|
-
rs.extension = rs.name.split(".").pop();
|
29
|
-
if (rs.extension) {
|
30
|
-
rs.type = mime.lookup(rs.extension) || defaultMimeType;
|
31
|
-
}
|
32
|
-
return rs;
|
33
|
-
};
|
34
|
-
exports.getFileInfoFromUrl = getFileInfoFromUrl;
|
35
|
-
//# sourceMappingURL=file.util.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"file.util.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/file/file.util.ts"],"names":[],"mappings":";;;AAEA,mCAAoC;AAE7B,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC1C,MAA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@
|
|
1
|
-
{"version":3,"file":"general.util.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/general.util.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAC,IAAY;IAChC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC;AAFD,sBAEC"}
|
package/src/lib/util/index.d.ts
DELETED
package/src/lib/util/index.js
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
tslib_1.__exportStar(require("./message/message.util"), exports);
|
5
|
-
tslib_1.__exportStar(require("./file/file.util"), exports);
|
6
|
-
tslib_1.__exportStar(require("./string.util"), exports);
|
7
|
-
tslib_1.__exportStar(require("./general.util"), exports);
|
8
|
-
tslib_1.__exportStar(require("./phone.util"), exports);
|
9
|
-
tslib_1.__exportStar(require("./date/index"), exports);
|
10
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,2DAAgC;AAChC,wDAA6B;AAC7B,yDAA8B;AAC9B,uDAA4B;AAC5B,uDAA4B"}
|
@@ -1,90 +0,0 @@
|
|
1
|
-
import { ContactMessage, FileInfo, MESSAGE_TYPE, RawMessage, RawMessageSuggestion } from "../../model";
|
2
|
-
interface ImageMessage {
|
3
|
-
imageUrl: string;
|
4
|
-
fileName?: string;
|
5
|
-
fileSize?: number;
|
6
|
-
message?: string;
|
7
|
-
}
|
8
|
-
interface VideoMessage {
|
9
|
-
fileUrl: string;
|
10
|
-
thumbnailUrl?: string;
|
11
|
-
duration?: number;
|
12
|
-
message?: string;
|
13
|
-
}
|
14
|
-
interface TextMessage {
|
15
|
-
attachments?: Array<FileInfo>;
|
16
|
-
message: string;
|
17
|
-
suggestions?: Array<RawMessageSuggestion>;
|
18
|
-
}
|
19
|
-
interface Location {
|
20
|
-
longitude: number;
|
21
|
-
latitude: number;
|
22
|
-
}
|
23
|
-
interface LocationMessage {
|
24
|
-
location: Location;
|
25
|
-
message?: string;
|
26
|
-
}
|
27
|
-
export declare const buildLocationMessage: ({ location, message }: LocationMessage, extra?: null) => {
|
28
|
-
type: MESSAGE_TYPE;
|
29
|
-
message: string;
|
30
|
-
location: Location;
|
31
|
-
extra: null;
|
32
|
-
};
|
33
|
-
interface FileMessage {
|
34
|
-
fileUrl: string;
|
35
|
-
fileName: string;
|
36
|
-
fileSize?: number;
|
37
|
-
message?: string;
|
38
|
-
}
|
39
|
-
export declare const buildFileMessage: ({ message, fileUrl, fileName, fileSize }: FileMessage, extra?: null) => {
|
40
|
-
type: MESSAGE_TYPE;
|
41
|
-
message: string;
|
42
|
-
fileName: string;
|
43
|
-
fileUrl: string;
|
44
|
-
fileSize: number;
|
45
|
-
extra: null;
|
46
|
-
};
|
47
|
-
interface RichCardMessage {
|
48
|
-
richCards: Array<unknown>;
|
49
|
-
}
|
50
|
-
export declare const buildTextMessage: ({ message, attachments, suggestions }: TextMessage, extra?: null) => {
|
51
|
-
type: MESSAGE_TYPE;
|
52
|
-
message: string;
|
53
|
-
suggestions: RawMessageSuggestion[] | undefined;
|
54
|
-
attachments: FileInfo[] | undefined;
|
55
|
-
extra: null;
|
56
|
-
};
|
57
|
-
export declare const buildRichCardMessage: ({ richCards }: RichCardMessage, extra?: null) => {
|
58
|
-
message: string;
|
59
|
-
type: MESSAGE_TYPE;
|
60
|
-
richCards: unknown[];
|
61
|
-
extra: null;
|
62
|
-
};
|
63
|
-
export declare const buildTypingIndicatorStartMessage: (extra?: null) => {
|
64
|
-
message: string;
|
65
|
-
type: MESSAGE_TYPE;
|
66
|
-
extra: null;
|
67
|
-
};
|
68
|
-
export declare const buildTypingIndicatorStopMessage: (extra?: null) => {
|
69
|
-
message: string;
|
70
|
-
type: MESSAGE_TYPE;
|
71
|
-
extra: null;
|
72
|
-
};
|
73
|
-
export declare const buildImageMessage: ({ imageUrl, fileName, fileSize, message }: ImageMessage, extra?: null) => {
|
74
|
-
type: MESSAGE_TYPE;
|
75
|
-
fileName: string;
|
76
|
-
fileSize: number | undefined;
|
77
|
-
fileUrl: string;
|
78
|
-
message: string;
|
79
|
-
extra: null;
|
80
|
-
};
|
81
|
-
export declare const buildVideoMessage: ({ fileUrl, duration, thumbnailUrl, message }: VideoMessage, extra?: null) => {
|
82
|
-
type: MESSAGE_TYPE;
|
83
|
-
duration: number | undefined;
|
84
|
-
fileUrl: string;
|
85
|
-
thumbnailUrl: string | undefined;
|
86
|
-
message: string;
|
87
|
-
extra: null;
|
88
|
-
};
|
89
|
-
export declare const buildContactMessage: (contactMessages: Array<ContactMessage>, extra?: null) => RawMessage;
|
90
|
-
export {};
|
@@ -1,72 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.buildContactMessage = exports.buildVideoMessage = exports.buildImageMessage = exports.buildTypingIndicatorStopMessage = exports.buildTypingIndicatorStartMessage = exports.buildRichCardMessage = exports.buildTextMessage = exports.buildFileMessage = exports.buildLocationMessage = void 0;
|
4
|
-
const model_1 = require("../../model");
|
5
|
-
const buildLocationMessage = ({ location, message = "" }, extra = null) => ({
|
6
|
-
type: model_1.MESSAGE_TYPE.LOCATION,
|
7
|
-
message,
|
8
|
-
location,
|
9
|
-
extra
|
10
|
-
});
|
11
|
-
exports.buildLocationMessage = buildLocationMessage;
|
12
|
-
const buildFileMessage = ({ message = "", fileUrl, fileName = "", fileSize = 0 }, extra = null) => ({
|
13
|
-
type: model_1.MESSAGE_TYPE.FILE,
|
14
|
-
message,
|
15
|
-
fileName,
|
16
|
-
fileUrl,
|
17
|
-
fileSize,
|
18
|
-
extra
|
19
|
-
});
|
20
|
-
exports.buildFileMessage = buildFileMessage;
|
21
|
-
const buildTextMessage = ({ message, attachments, suggestions }, extra = null) => ({
|
22
|
-
type: model_1.MESSAGE_TYPE.TEXT,
|
23
|
-
message,
|
24
|
-
suggestions,
|
25
|
-
attachments,
|
26
|
-
extra
|
27
|
-
});
|
28
|
-
exports.buildTextMessage = buildTextMessage;
|
29
|
-
const buildRichCardMessage = ({ richCards }, extra = null) => ({
|
30
|
-
message: "",
|
31
|
-
type: model_1.MESSAGE_TYPE.RICH_CARD,
|
32
|
-
richCards,
|
33
|
-
extra
|
34
|
-
});
|
35
|
-
exports.buildRichCardMessage = buildRichCardMessage;
|
36
|
-
const buildTypingIndicatorStartMessage = (extra = null) => ({
|
37
|
-
message: "",
|
38
|
-
type: model_1.MESSAGE_TYPE.TYPING_INDICATOR_START,
|
39
|
-
extra
|
40
|
-
});
|
41
|
-
exports.buildTypingIndicatorStartMessage = buildTypingIndicatorStartMessage;
|
42
|
-
const buildTypingIndicatorStopMessage = (extra = null) => ({
|
43
|
-
message: "",
|
44
|
-
type: model_1.MESSAGE_TYPE.TYPING_INDICATOR_STOP,
|
45
|
-
extra
|
46
|
-
});
|
47
|
-
exports.buildTypingIndicatorStopMessage = buildTypingIndicatorStopMessage;
|
48
|
-
const buildImageMessage = ({ imageUrl, fileName = "", fileSize, message = "" }, extra = null) => ({
|
49
|
-
type: model_1.MESSAGE_TYPE.PICTURE,
|
50
|
-
fileName: fileName,
|
51
|
-
fileSize: fileSize,
|
52
|
-
fileUrl: imageUrl,
|
53
|
-
message: message,
|
54
|
-
extra
|
55
|
-
});
|
56
|
-
exports.buildImageMessage = buildImageMessage;
|
57
|
-
const buildVideoMessage = ({ fileUrl, duration, thumbnailUrl, message = "" }, extra = null) => ({
|
58
|
-
type: model_1.MESSAGE_TYPE.VIDEO,
|
59
|
-
duration,
|
60
|
-
fileUrl,
|
61
|
-
thumbnailUrl,
|
62
|
-
message,
|
63
|
-
extra
|
64
|
-
});
|
65
|
-
exports.buildVideoMessage = buildVideoMessage;
|
66
|
-
const buildContactMessage = (contactMessages, extra = null) => ({
|
67
|
-
type: model_1.MESSAGE_TYPE.SHARE_INFO,
|
68
|
-
contacts: contactMessages,
|
69
|
-
extra
|
70
|
-
});
|
71
|
-
exports.buildContactMessage = buildContactMessage;
|
72
|
-
//# sourceMappingURL=message.util.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"message.util.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/message/message.util.ts"],"names":[],"mappings":";;;AAAA,uCAA8G;AAgCvG,MAAM,oBAAoB,GAAG,CAClC,EAAC,QAAQ,EAAE,OAAO,GAAG,EAAE,EAAkB,EACzC,KAAK,GAAG,IAAI,EACZ,EAAE,CAAC,CAAC;IACJ,IAAI,EAAE,oBAAY,CAAC,QAAQ;IAC3B,OAAO;IACP,QAAQ;IACR,KAAK;CACN,CAAC,CAAC;AARU,QAAA,oBAAoB,wBAQ9B;AASI,MAAM,gBAAgB,GAAG,CAC9B,EAAC,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,GAAG,EAAE,EAAE,QAAQ,GAAG,CAAC,EAAc,EACjE,KAAK,GAAG,IAAI,EACZ,EAAE,CAAC,CAAC;IACJ,IAAI,EAAE,oBAAY,CAAC,IAAI;IACvB,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,KAAK;CACN,CAAC,CAAC;AAVU,QAAA,gBAAgB,oBAU1B;AAMI,MAAM,gBAAgB,GAAG,CAAC,EAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAc,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC;IACnG,IAAI,EAAE,oBAAY,CAAC,IAAI;IACvB,OAAO;IACP,WAAW;IACX,WAAW;IACX,KAAK;CACN,CAAC,CAAC;AANU,QAAA,gBAAgB,oBAM1B;AAEI,MAAM,oBAAoB,GAAG,CAAC,EAAC,SAAS,EAAkB,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC,C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,IAAI,EAAc,EAAE,CAAC,CAAC;IACxG,IAAI,EAAE,oBAAY,CAAC,UAAU;IAC7B,QAAQ,EAAE,eAAe;IACzB,KAAK;CACN,CAAC,CAAC;AAJU,QAAA,mBAAmB,uBAI7B"}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
export declare const DEFAULT_PHONE_COUNTRY = "VN";
|
2
|
-
export declare const PHONE_COUNTRY_SUPPORT: {
|
3
|
-
84: {
|
4
|
-
countries: {
|
5
|
-
ios2: string;
|
6
|
-
}[];
|
7
|
-
};
|
8
|
-
1: {
|
9
|
-
countries: ({
|
10
|
-
iso2: string;
|
11
|
-
regions: string[];
|
12
|
-
} | {
|
13
|
-
iso2: string;
|
14
|
-
regions?: undefined;
|
15
|
-
})[];
|
16
|
-
};
|
17
|
-
};
|
18
|
-
export declare function isPhoneValid(phone: string, country?: string): {
|
19
|
-
countryCode: number | undefined;
|
20
|
-
nationalNumber: string;
|
21
|
-
e164: string;
|
22
|
-
network: number;
|
23
|
-
region: string | undefined;
|
24
|
-
};
|
@@ -1,51 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isPhoneValid = exports.PHONE_COUNTRY_SUPPORT = exports.DEFAULT_PHONE_COUNTRY = void 0;
|
4
|
-
const google_libphonenumber_1 = require("google-libphonenumber");
|
5
|
-
const _1 = require("./");
|
6
|
-
const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
|
7
|
-
exports.DEFAULT_PHONE_COUNTRY = "VN";
|
8
|
-
exports.PHONE_COUNTRY_SUPPORT = {
|
9
|
-
84: {
|
10
|
-
countries: [{
|
11
|
-
ios2: "VN"
|
12
|
-
}]
|
13
|
-
},
|
14
|
-
1: {
|
15
|
-
countries: [
|
16
|
-
{
|
17
|
-
iso2: "US",
|
18
|
-
regions: [""]
|
19
|
-
}, {
|
20
|
-
iso2: "CA"
|
21
|
-
}
|
22
|
-
]
|
23
|
-
}
|
24
|
-
};
|
25
|
-
function isPhoneValid(phone, country = exports.DEFAULT_PHONE_COUNTRY) {
|
26
|
-
if (!phone || !(0, _1.hasText)(phone)) {
|
27
|
-
throw new Error(`Invalid phone ${phone}`);
|
28
|
-
}
|
29
|
-
let _phone = phone;
|
30
|
-
const phone2Prefix = phone.substring(0, 2);
|
31
|
-
if (phone2Prefix !== "00") {
|
32
|
-
const phone1Prefix = phone[0];
|
33
|
-
if (phone1Prefix !== "0") {
|
34
|
-
_phone = `+${phone}`;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
const number = phoneUtil.parse(_phone, country);
|
38
|
-
const existPhone = phoneUtil.isValidNumber(number);
|
39
|
-
if (!existPhone) {
|
40
|
-
throw new Error(`Invalid phone ${phone}`);
|
41
|
-
}
|
42
|
-
return {
|
43
|
-
countryCode: number.getCountryCode(),
|
44
|
-
nationalNumber: `0${number.getNationalNumber()}`,
|
45
|
-
e164: `${number.getCountryCode()}${number.getNationalNumber()}`,
|
46
|
-
network: number.preferredDomesticCarrierCodeCount(),
|
47
|
-
region: phoneUtil.getRegionCodeForNumber(number)
|
48
|
-
};
|
49
|
-
}
|
50
|
-
exports.isPhoneValid = isPhoneValid;
|
51
|
-
//# sourceMappingURL=phone.util.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"phone.util.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/phone.util.ts"],"names":[],"mappings":";;;AAAA,iEAAsD;AACtD,yBAA2B;AAE3B,MAAM,SAAS,GAAG,uCAAe,CAAC,WAAW,EAAE,CAAC;AAEnC,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAE7B,QAAA,qBAAqB,GAAG;IACnC,EAAE,EAAE;QACF,SAAS,EAAE,CAAC;gBACV,IAAI,EAAE,IAAI;aACX,CAAC;KACH;IACD,CAAC,EAAE;QACD,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,CAAC,EAAE,CAAC;aACd,EAAE;gBACD,IAAI,EAAE,IAAI;aACX;SACF;KACF;CACF,CAAC;AAEF,SAAgB,YAAY,CAAC,KAAa,EAAE,OAAO,GAAG,6BAAqB;IACzE,IAAI,CAAC,KAAK,IAAI,CAAC,IAAA,UAAO,EAAC,KAAK,CAAC,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;KAC3C;IACD,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3C,IAAI,YAAY,KAAK,IAAI,EAAE;QACzB,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,YAAY,KAAK,GAAG,EAAE;YACxB,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;SACtB;KACF;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACnD,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;KAC3C;IAED,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,cAAc,EAAE;QACpC,cAAc,EAAE,IAAI,MAAM,CAAC,iBAAiB,EAAE,EAAE;QAChD,IAAI,EAAE,GAAG,MAAM,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,iBAAiB,EAAE,EAAE;QAC/D,OAAO,EAAE,MAAM,CAAC,iCAAiC,EAAE;QACnD,MAAM,EAAE,SAAS,CAAC,sBAAsB,CAAC,MAAM,CAAC;KACjD,CAAC;AACJ,CAAC;AAzBD,oCAyBC"}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
export declare function generateRandomCode(length: number): string;
|
2
|
-
export declare const hasText: (str: string) => boolean;
|
3
|
-
export declare function markKey(keyStr: string): string;
|
4
|
-
export declare function unescapeHTML(str: string): string;
|
5
|
-
export declare const filterForNumberOnly: (str: string) => string;
|
6
|
-
export declare function isNumberOnly(str: string): boolean;
|
7
|
-
export declare function filterForInvalidCharacter(str: string, replaceCharacter?: string): string;
|
8
|
-
export declare function filterNotNumberAndDivideChar(str: string): string;
|
9
|
-
export declare function stringNumberToList(str: string): number[];
|
10
|
-
export declare function htmlEncode(rawStr: string): string;
|
11
|
-
export declare function filterNonAlphaNumeric(str: string): string;
|
12
|
-
export declare const leftString: (string: string, count: number) => string;
|
13
|
-
export declare const rightString: (string: string, count: number) => string;
|
14
|
-
export declare function alphaNumericToListString(str: string): string[];
|
@@ -1,118 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.alphaNumericToListString = exports.rightString = exports.leftString = exports.filterNonAlphaNumeric = exports.htmlEncode = exports.stringNumberToList = exports.filterNotNumberAndDivideChar = exports.filterForInvalidCharacter = exports.isNumberOnly = exports.filterForNumberOnly = exports.unescapeHTML = exports.markKey = exports.hasText = exports.generateRandomCode = void 0;
|
4
|
-
function generateRandomCode(length) {
|
5
|
-
let text = "";
|
6
|
-
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
7
|
-
for (let i = 0; i < length; i += 1)
|
8
|
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
9
|
-
return text;
|
10
|
-
}
|
11
|
-
exports.generateRandomCode = generateRandomCode;
|
12
|
-
const hasText = (str) => {
|
13
|
-
const testStr = `${str || ""}`;
|
14
|
-
return !!str && testStr.length > 0;
|
15
|
-
};
|
16
|
-
exports.hasText = hasText;
|
17
|
-
function markKey(keyStr) {
|
18
|
-
return `**** ${keyStr.substring(keyStr.length - 4, keyStr.length)}`;
|
19
|
-
}
|
20
|
-
exports.markKey = markKey;
|
21
|
-
const htmlEntities = {
|
22
|
-
nbsp: " ",
|
23
|
-
cent: "¢",
|
24
|
-
pound: "£",
|
25
|
-
yen: "¥",
|
26
|
-
euro: "€",
|
27
|
-
copy: "©",
|
28
|
-
reg: "®",
|
29
|
-
lt: "<",
|
30
|
-
gt: ">",
|
31
|
-
quot: '"',
|
32
|
-
amp: "&",
|
33
|
-
apos: "'"
|
34
|
-
};
|
35
|
-
function unescapeHTML(str) {
|
36
|
-
return str.replace(/&([^;]+);/g, (entity, entityCode) => {
|
37
|
-
let match;
|
38
|
-
if (entityCode in htmlEntities) {
|
39
|
-
return htmlEntities[entityCode];
|
40
|
-
}
|
41
|
-
// eslint-disable-next-line no-cond-assign
|
42
|
-
if ((match = entityCode.match(/^#x([\da-fA-F]+)$/))) {
|
43
|
-
return String.fromCharCode(parseInt(match[1], 16));
|
44
|
-
}
|
45
|
-
// eslint-disable-next-line no-cond-assign
|
46
|
-
if ((match = entityCode.match(/^#(\d+)$/))) {
|
47
|
-
// eslint-disable-next-line no-bitwise
|
48
|
-
return String.fromCharCode(~~match[1]);
|
49
|
-
}
|
50
|
-
return entity;
|
51
|
-
});
|
52
|
-
}
|
53
|
-
exports.unescapeHTML = unescapeHTML;
|
54
|
-
const filterForNumberOnly = (str) => str.replace(/\D+/g, "");
|
55
|
-
exports.filterForNumberOnly = filterForNumberOnly;
|
56
|
-
function isNumberOnly(str) {
|
57
|
-
const pattern = /^\d+$/;
|
58
|
-
return pattern.test(str);
|
59
|
-
}
|
60
|
-
exports.isNumberOnly = isNumberOnly;
|
61
|
-
function filterForInvalidCharacter(str, replaceCharacter = "_") {
|
62
|
-
let rs = str.replace(/[^\p{L}\s]/giu, " ");
|
63
|
-
rs = rs.trim();
|
64
|
-
rs = rs.replace(/ +/g, replaceCharacter);
|
65
|
-
return rs;
|
66
|
-
}
|
67
|
-
exports.filterForInvalidCharacter = filterForInvalidCharacter;
|
68
|
-
function filterNotNumberAndDivideChar(str) {
|
69
|
-
let rs = str.replace(/\D+/g, " ");
|
70
|
-
rs = rs.trim();
|
71
|
-
rs = rs.replace(/ +/g, ",");
|
72
|
-
return rs;
|
73
|
-
}
|
74
|
-
exports.filterNotNumberAndDivideChar = filterNotNumberAndDivideChar;
|
75
|
-
function stringNumberToList(str) {
|
76
|
-
return filterNotNumberAndDivideChar(str)
|
77
|
-
.split(/[ _\-,]/)
|
78
|
-
.filter((t) => (0, exports.hasText)(t))
|
79
|
-
.map((t) => Number(t));
|
80
|
-
}
|
81
|
-
exports.stringNumberToList = stringNumberToList;
|
82
|
-
function htmlEncode(rawStr) {
|
83
|
-
return rawStr.replace(/[\u00A0-\u9999<>&]/g, (i) => {
|
84
|
-
return `&#${i.charCodeAt(0)};`;
|
85
|
-
});
|
86
|
-
}
|
87
|
-
exports.htmlEncode = htmlEncode;
|
88
|
-
function filterNonAlphaNumeric(str) {
|
89
|
-
return str.replace(/\W/g, "");
|
90
|
-
}
|
91
|
-
exports.filterNonAlphaNumeric = filterNonAlphaNumeric;
|
92
|
-
const leftString = (string, count) => {
|
93
|
-
const str = `${string || ""}`;
|
94
|
-
if (str.length > count) {
|
95
|
-
return str.substring(0, count);
|
96
|
-
}
|
97
|
-
return str;
|
98
|
-
};
|
99
|
-
exports.leftString = leftString;
|
100
|
-
const rightString = (string, count) => {
|
101
|
-
const str = `${string || ""}`;
|
102
|
-
if (str.length > count) {
|
103
|
-
return str.substring(str.length - count);
|
104
|
-
}
|
105
|
-
return str;
|
106
|
-
};
|
107
|
-
exports.rightString = rightString;
|
108
|
-
function alphaNumericToListString(str) {
|
109
|
-
if (!(0, exports.hasText)(str)) {
|
110
|
-
return [];
|
111
|
-
}
|
112
|
-
return str
|
113
|
-
.split(/[ _\-,]/)
|
114
|
-
.map((t) => filterNonAlphaNumeric(t))
|
115
|
-
.filter((t) => (0, exports.hasText)(t));
|
116
|
-
}
|
117
|
-
exports.alphaNumericToListString = alphaNumericToListString;
|
118
|
-
//# sourceMappingURL=string.util.js.map
|