@peacom/core 0.0.2 → 0.0.3

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.
Files changed (46) hide show
  1. package/package.json +5 -2
  2. package/src/index.d.ts +1 -0
  3. package/src/index.js +1 -0
  4. package/src/index.js.map +1 -1
  5. package/src/lib/api/api.constant.d.ts +37 -0
  6. package/src/lib/api/api.constant.js +3 -0
  7. package/src/lib/api/api.constant.js.map +1 -0
  8. package/src/lib/api/core.api.d.ts +2 -0
  9. package/src/lib/api/core.api.js +24 -0
  10. package/src/lib/api/core.api.js.map +1 -0
  11. package/src/lib/api/index.d.ts +4 -0
  12. package/src/lib/api/index.js +8 -0
  13. package/src/lib/api/index.js.map +1 -0
  14. package/src/lib/api/micro-service.api.d.ts +2 -0
  15. package/src/lib/api/micro-service.api.js +24 -0
  16. package/src/lib/api/micro-service.api.js.map +1 -0
  17. package/src/lib/api/queue.api.d.ts +7 -0
  18. package/src/lib/api/queue.api.js +9 -0
  19. package/src/lib/api/queue.api.js.map +1 -0
  20. package/src/lib/error/FormError.d.ts +53 -0
  21. package/src/lib/error/FormError.js +58 -0
  22. package/src/lib/error/FormError.js.map +1 -0
  23. package/src/lib/error/HttpError.d.ts +4 -0
  24. package/src/lib/error/HttpError.js +12 -0
  25. package/src/lib/error/HttpError.js.map +1 -0
  26. package/src/lib/model/Message.d.ts +58 -0
  27. package/src/lib/model/Message.js +7 -1
  28. package/src/lib/model/Message.js.map +1 -1
  29. package/src/lib/model/queue/QueueMessage.d.ts +10 -0
  30. package/src/lib/model/queue/QueueMessage.js +3 -0
  31. package/src/lib/model/queue/QueueMessage.js.map +1 -0
  32. package/src/lib/model/queue/queue.constant.d.ts +5 -0
  33. package/src/lib/model/queue/queue.constant.js +10 -0
  34. package/src/lib/model/queue/queue.constant.js.map +1 -0
  35. package/src/lib/util/date/constant.d.ts +3 -0
  36. package/src/lib/util/date/constant.js +7 -0
  37. package/src/lib/util/date/constant.js.map +1 -0
  38. package/src/lib/util/date/date.util.d.ts +15 -0
  39. package/src/lib/util/date/date.util.js +41 -0
  40. package/src/lib/util/date/date.util.js.map +1 -0
  41. package/src/lib/util/index.d.ts +1 -0
  42. package/src/lib/util/index.js +1 -0
  43. package/src/lib/util/index.js.map +1 -1
  44. package/src/lib/util/string.util.d.ts +13 -0
  45. package/src/lib/util/string.util.js +108 -0
  46. package/src/lib/util/string.util.js.map +1 -0
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@peacom/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "commonjs",
5
+ "dependencies": {
6
+ "moment": "^2.29.4",
7
+ "moment-timezone": "^0.5.40"
8
+ },
5
9
  "main": "./src/index.js",
6
10
  "types": "./src/index.d.ts",
7
- "dependencies": {},
8
11
  "peerDependencies": {
9
12
  "tslib": "2.4.1"
10
13
  }
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './lib/core';
2
2
  export * from './lib/model';
3
3
  export * from './lib/util';
4
+ export * from './lib/api';
package/src/index.js CHANGED
@@ -4,4 +4,5 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./lib/core"), exports);
5
5
  tslib_1.__exportStar(require("./lib/model"), exports);
6
6
  tslib_1.__exportStar(require("./lib/util"), exports);
7
+ tslib_1.__exportStar(require("./lib/api"), exports);
7
8
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,sDAA4B;AAC5B,qDAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,sDAA4B;AAC5B,qDAA0B;AAC1B,oDAAyB"}
@@ -0,0 +1,37 @@
1
+ import { Application, PARTNER, SEND_MESSAGE_VIA } from '../model/';
2
+ import { RawMessage } from "../model/";
3
+ interface ApplicationInfo {
4
+ application: Application;
5
+ id: string;
6
+ }
7
+ interface Contact {
8
+ id: string;
9
+ name?: string;
10
+ phone?: string;
11
+ isSubscribed: boolean;
12
+ extraData: Record<string, unknown>;
13
+ avatarUrl?: string;
14
+ language: string;
15
+ country: string;
16
+ }
17
+ export interface ApiCoreHandleParams {
18
+ to: ApplicationInfo;
19
+ rawMessage: RawMessage;
20
+ replyToApplicationMessageId?: string;
21
+ sentTime: number;
22
+ extraData?: Record<string, unknown>;
23
+ applicationMessageId: string;
24
+ from: Contact;
25
+ }
26
+ export interface ApiChannelMessageParams {
27
+ applicationId: Application;
28
+ application: Record<string, unknown>;
29
+ partnerId: PARTNER;
30
+ rawMessage: RawMessage;
31
+ messageId: string;
32
+ receiverId: string;
33
+ sendVia: SEND_MESSAGE_VIA;
34
+ queueOption?: Record<string, unknown>;
35
+ }
36
+ export declare type LOG_FUNCTION = ((t: unknown) => void) | null;
37
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.constant.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/api/api.constant.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { ApiCoreHandleParams, LOG_FUNCTION } from "./api.constant";
2
+ export declare const handleCoreMessage: (CORE_URL: string, params: ApiCoreHandleParams, log?: LOG_FUNCTION) => Promise<any>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleCoreMessage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const FormError_1 = require("../error/FormError");
6
+ const handleCoreMessage = (CORE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
7
+ if (log) {
8
+ log(`CORE REQUEST: ${CORE_URL} - ${JSON.stringify(params)}`);
9
+ }
10
+ const rs = yield fetch(CORE_URL, {
11
+ method: "POST",
12
+ body: JSON.stringify(params)
13
+ });
14
+ const bodyStr = yield rs.text();
15
+ if (log) {
16
+ log(`CORE RESPONSE: ${CORE_URL} - ${bodyStr}`);
17
+ }
18
+ if (!rs.ok) {
19
+ throw new FormError_1.FormError(JSON.parse(bodyStr));
20
+ }
21
+ return JSON.parse(bodyStr);
22
+ });
23
+ exports.handleCoreMessage = handleCoreMessage;
24
+ //# sourceMappingURL=core.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.api.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/api/core.api.ts"],"names":[],"mappings":";;;;AACA,kDAA6C;AAItC,MAAM,iBAAiB,GAAG,CAAO,QAAgB,EAAE,MAA2B,EAAE,MAAoB,IAAI,EAAE,EAAE;IACjH,IAAI,GAAG,EAAE;QACP,GAAG,CAAC,iBAAiB,QAAQ,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;KAC7D;IAED,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;QAC/B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;KAC7B,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,GAAG,EAAE;QACP,GAAG,CAAC,kBAAkB,QAAQ,MAAM,OAAO,EAAE,CAAC,CAAA;KAC/C;IAED,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACV,MAAM,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;KACzC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAC5B,CAAC,CAAA,CAAA;AAlBY,QAAA,iBAAiB,qBAkB7B"}
@@ -0,0 +1,4 @@
1
+ export * from './api.constant';
2
+ export * from './queue.api';
3
+ export * from './core.api';
4
+ export * from './micro-service.api';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./api.constant"), exports);
5
+ tslib_1.__exportStar(require("./queue.api"), exports);
6
+ tslib_1.__exportStar(require("./core.api"), exports);
7
+ tslib_1.__exportStar(require("./micro-service.api"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/api/index.ts"],"names":[],"mappings":";;;AAAA,yDAA8B;AAC9B,sDAA2B;AAC3B,qDAA0B;AAC1B,8DAAmC"}
@@ -0,0 +1,2 @@
1
+ import { ApiChannelMessageParams, LOG_FUNCTION } from "./api.constant";
2
+ export declare const sendChannelMessage: (MICROSERVICE_URL: string, params: ApiChannelMessageParams, log?: LOG_FUNCTION) => Promise<any>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendChannelMessage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const FormError_1 = require("../error/FormError");
6
+ const sendChannelMessage = (MICROSERVICE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
7
+ if (log) {
8
+ log(`SERVICE REQUEST: ${MICROSERVICE_URL} - ${JSON.stringify(params)}`);
9
+ }
10
+ const rs = yield fetch(MICROSERVICE_URL, {
11
+ method: "POST",
12
+ body: JSON.stringify(params)
13
+ });
14
+ const bodyStr = yield rs.text();
15
+ if (log) {
16
+ log(`SERVICE RESPONSE: ${MICROSERVICE_URL} - ${bodyStr}`);
17
+ }
18
+ if (!rs.ok) {
19
+ throw new FormError_1.FormError(JSON.parse(bodyStr));
20
+ }
21
+ return JSON.parse(bodyStr);
22
+ });
23
+ exports.sendChannelMessage = sendChannelMessage;
24
+ //# sourceMappingURL=micro-service.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"micro-service.api.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/api/micro-service.api.ts"],"names":[],"mappings":";;;;AACA,kDAA6C;AAEtC,MAAM,kBAAkB,GAAG,CAAO,gBAAwB,EAAE,MAA+B,EAAE,MAAoB,IAAI,EAAE,EAAE;IAC9H,IAAI,GAAG,EAAE;QACP,GAAG,CAAC,oBAAoB,gBAAgB,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;KACxE;IAED,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE;QACvC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;KAC7B,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,GAAG,EAAE;QACP,GAAG,CAAC,qBAAqB,gBAAgB,MAAM,OAAO,EAAE,CAAC,CAAA;KAC1D;IAED,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACV,MAAM,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;KACzC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAC5B,CAAC,CAAA,CAAA;AAlBY,QAAA,kBAAkB,sBAkB9B"}
@@ -0,0 +1,7 @@
1
+ import { QueueMessageStatus } from "../model/queue/QueueMessage";
2
+ declare type addQueue = (name: string, data: unknown, opts?: unknown) => Promise<unknown>;
3
+ declare type Queue = {
4
+ add: addQueue;
5
+ };
6
+ export declare const queueAddMessageStatus: (queue: Queue, params: QueueMessageStatus, jobOpts: Record<string, unknown>) => Promise<unknown>;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queueAddMessageStatus = void 0;
4
+ const queueAddMessageStatus = (queue, params, jobOpts) => {
5
+ const jobId = `${params.applicationId}_${params.applicationMessageId}_${params.status}_${params.date}`;
6
+ return queue.add(jobId, params, Object.assign(Object.assign({}, jobOpts), { jobId }));
7
+ };
8
+ exports.queueAddMessageStatus = queueAddMessageStatus;
9
+ //# sourceMappingURL=queue.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.api.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/api/queue.api.ts"],"names":[],"mappings":";;;AAYO,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAE,MAA0B,EAAE,OAAgC,EAAE,EAAE;IAClH,MAAM,KAAK,GAAG,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,oBAAoB,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAA;IACtG,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,kCACzB,OAAO,KAAE,KAAK,IACjB,CAAA;AACJ,CAAC,CAAA;AALY,QAAA,qBAAqB,yBAKjC"}
@@ -0,0 +1,53 @@
1
+ import { HttpError } from "./HttpError";
2
+ export declare enum HTTP_ERROR {
3
+ ACCESS_DENIED = 403,
4
+ NOT_FOUND = 404,
5
+ TIME_OUT = 402,
6
+ BAD_REQUEST = 400,
7
+ NOT_AUTHENTICATE = 401,
8
+ INTERNAL_SERVER_ERROR = 500
9
+ }
10
+ interface FieldError {
11
+ name: string;
12
+ code: string;
13
+ message: string;
14
+ }
15
+ export declare const FIELD_ERROR: {
16
+ INVALID: string;
17
+ EMAIL_NOT_ACTIVE: string;
18
+ USER_NOT_ACTIVE: string;
19
+ WRONG_PASSWORD: string;
20
+ USER_NOT_FOUND: string;
21
+ EMAIL_INVALID: string;
22
+ EMAIL_NOT_ALLOW_REGISTER: string;
23
+ INVALID_TOKEN: string;
24
+ EMAIL_NOT_FOUND: string;
25
+ EMAIL_EXISTED: string;
26
+ TOKEN_EXPIRED: string;
27
+ PASSWORD_NOT_MATCH: string;
28
+ SIGNED_URL_FAILED: string;
29
+ UPLOAD_FAILED: string;
30
+ USER_NAME_IS_EXITED: string;
31
+ CURRENT_PASSWORD_NOT_MATCH: string;
32
+ CURRENT_EMAIL_NOT_MATCH: string;
33
+ CONFIRM_EMAIL_NOT_MATCH: string;
34
+ NEW_EMAIL_SAME_OLD_EMAIL: string;
35
+ USERNAME_IS_A_REQUIRED_FIELD: string;
36
+ USER_NOT_ACTIVE_KYC: string;
37
+ EXISTED: string;
38
+ COMPANY_IS_NOT_ACTIVE: string;
39
+ BAD_REQUEST: string;
40
+ NOT_AUTHENTICATE: string;
41
+ FORBIDDEN_ERROR: string;
42
+ RESOURCE_NOT_FOUND: string;
43
+ INTERNAL_SERVER_ERROR: string;
44
+ SERVICE_UNAVAILABLE: string;
45
+ LOGIN_REQUIRED_OTP: string;
46
+ API_KEY_NOT_FOUND: string;
47
+ };
48
+ export declare class FormError extends HttpError {
49
+ errors: Array<FieldError>;
50
+ constructor(_errors: FieldError | Array<FieldError>);
51
+ }
52
+ export declare function badRequest(name: string, code: string, message: string): FormError;
53
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.badRequest = exports.FormError = exports.FIELD_ERROR = exports.HTTP_ERROR = void 0;
4
+ const HttpError_1 = require("./HttpError");
5
+ var HTTP_ERROR;
6
+ (function (HTTP_ERROR) {
7
+ HTTP_ERROR[HTTP_ERROR["ACCESS_DENIED"] = 403] = "ACCESS_DENIED";
8
+ HTTP_ERROR[HTTP_ERROR["NOT_FOUND"] = 404] = "NOT_FOUND";
9
+ HTTP_ERROR[HTTP_ERROR["TIME_OUT"] = 402] = "TIME_OUT";
10
+ HTTP_ERROR[HTTP_ERROR["BAD_REQUEST"] = 400] = "BAD_REQUEST";
11
+ HTTP_ERROR[HTTP_ERROR["NOT_AUTHENTICATE"] = 401] = "NOT_AUTHENTICATE";
12
+ HTTP_ERROR[HTTP_ERROR["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
13
+ })(HTTP_ERROR = exports.HTTP_ERROR || (exports.HTTP_ERROR = {}));
14
+ exports.FIELD_ERROR = {
15
+ INVALID: 'INVALID',
16
+ EMAIL_NOT_ACTIVE: 'EMAIL_NOT_ACTIVE',
17
+ USER_NOT_ACTIVE: 'USER_NOT_ACTIVE',
18
+ WRONG_PASSWORD: 'WRONG_PASSWORD',
19
+ USER_NOT_FOUND: 'USER_NOT_FOUND',
20
+ EMAIL_INVALID: 'EMAIL_INVALID',
21
+ EMAIL_NOT_ALLOW_REGISTER: 'EMAIL_NOT_ALLOW_REGISTER',
22
+ INVALID_TOKEN: 'INVALID_TOKEN',
23
+ EMAIL_NOT_FOUND: 'EMAIL_NOT_FOUND',
24
+ EMAIL_EXISTED: 'EMAIL_EXISTED',
25
+ TOKEN_EXPIRED: 'TOKEN_EXPIRED',
26
+ PASSWORD_NOT_MATCH: 'PASSWORD_NOT_MATCH',
27
+ SIGNED_URL_FAILED: 'SIGNED_URL_FAILED',
28
+ UPLOAD_FAILED: 'UPLOAD_FAILED',
29
+ USER_NAME_IS_EXITED: 'USER_NAME_IS_EXITED',
30
+ CURRENT_PASSWORD_NOT_MATCH: 'CURRENT_PASSWORD_NOT_MATCH',
31
+ CURRENT_EMAIL_NOT_MATCH: 'CURRENT_EMAIL_NOT_MATCH',
32
+ CONFIRM_EMAIL_NOT_MATCH: 'CONFIRM_EMAIL_NOT_MATCH',
33
+ NEW_EMAIL_SAME_OLD_EMAIL: 'NEW_EMAIL_SAME_OLD_EMAIL',
34
+ USERNAME_IS_A_REQUIRED_FIELD: 'USERNAME_IS_A_REQUIRED_FIELD',
35
+ USER_NOT_ACTIVE_KYC: 'USER_NOT_ACTIVE_KYC',
36
+ EXISTED: 'EXISTED',
37
+ COMPANY_IS_NOT_ACTIVE: 'COMPANY_IS_NOT_ACTIVE',
38
+ BAD_REQUEST: 'BAD_REQUEST',
39
+ NOT_AUTHENTICATE: 'NOT_AUTHENTICATE',
40
+ FORBIDDEN_ERROR: 'FORBIDDEN_ERROR',
41
+ RESOURCE_NOT_FOUND: 'RESOURCE_NOT_FOUND',
42
+ INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR',
43
+ SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE',
44
+ LOGIN_REQUIRED_OTP: 'LOGIN_REQUIRED_OTP',
45
+ API_KEY_NOT_FOUND: 'API_KEY_NOT_FOUND'
46
+ };
47
+ class FormError extends HttpError_1.HttpError {
48
+ constructor(_errors) {
49
+ super(HTTP_ERROR.BAD_REQUEST, 'Bad request');
50
+ this.errors = Array.isArray(_errors) ? [..._errors] : [_errors];
51
+ }
52
+ }
53
+ exports.FormError = FormError;
54
+ function badRequest(name, code, message) {
55
+ return new FormError({ name, code, message });
56
+ }
57
+ exports.badRequest = badRequest;
58
+ //# sourceMappingURL=FormError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormError.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/error/FormError.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AAEtC,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,+DAAmB,CAAA;IACnB,uDAAe,CAAA;IACf,qDAAc,CAAA;IACd,2DAAiB,CAAA;IACjB,qEAAsB,CAAA;IACtB,+EAA2B,CAAA;AAC7B,CAAC,EAPW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAOrB;AAQY,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,wBAAwB,EAAE,0BAA0B;IACpD,aAAa,EAAE,eAAe;IAC9B,eAAe,EAAE,iBAAiB;IAClC,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;IAC9B,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;IACtC,aAAa,EAAE,eAAe;IAC9B,mBAAmB,EAAE,qBAAqB;IAC1C,0BAA0B,EAAE,4BAA4B;IACxD,uBAAuB,EAAE,yBAAyB;IAClD,uBAAuB,EAAE,yBAAyB;IAClD,wBAAwB,EAAE,0BAA0B;IACpD,4BAA4B,EAAE,8BAA8B;IAC5D,mBAAmB,EAAE,qBAAqB;IAC1C,OAAO,EAAE,SAAS;IAClB,qBAAqB,EAAE,uBAAuB;IAC9C,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;CACvC,CAAC;AAGF,MAAa,SAAU,SAAQ,qBAAS;IAGtC,YAAY,OAAuC;QACjD,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;CACF;AAPD,8BAOC;AAED,SAAgB,UAAU,CAAC,IAAY,EAAE,IAAY,EAAE,OAAe;IACpE,OAAO,IAAI,SAAS,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC;AAC9C,CAAC;AAFD,gCAEC"}
@@ -0,0 +1,4 @@
1
+ export declare class HttpError extends Error {
2
+ code: number;
3
+ constructor(code: number, message: string);
4
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpError = void 0;
4
+ class HttpError extends Error {
5
+ constructor(code, message) {
6
+ super(message);
7
+ Error.captureStackTrace(this, this.constructor);
8
+ this.code = code;
9
+ }
10
+ }
11
+ exports.HttpError = HttpError;
12
+ //# sourceMappingURL=HttpError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/error/HttpError.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAGlC,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,8BAQC"}
@@ -25,3 +25,61 @@ export declare enum MESSAGE_REACTION {
25
25
  LIKE = 2,
26
26
  SUGGESTION_CLICK = 3
27
27
  }
28
+ export declare enum SuggestionActionType {
29
+ OPEN_URL = "open-url",
30
+ REPLY = "reply",
31
+ DIAL = "dial"
32
+ }
33
+ export interface FileInfo {
34
+ type: string;
35
+ name: string;
36
+ size: number;
37
+ url: string;
38
+ uuid: string;
39
+ preview?: string;
40
+ }
41
+ export interface RawMessageSuggestion {
42
+ action: SuggestionActionType;
43
+ text: string;
44
+ postbackData: string;
45
+ }
46
+ export interface RichCard {
47
+ title?: string;
48
+ titleRow?: number;
49
+ description?: string;
50
+ descriptionRow?: number;
51
+ image?: string;
52
+ imageRow?: number;
53
+ suggestions: RawMessageSuggestion[];
54
+ }
55
+ export interface PickListItem {
56
+ title: string;
57
+ value: string;
58
+ subtitle?: string;
59
+ image?: string;
60
+ }
61
+ declare type ReceivedMessage = PickListItem;
62
+ declare type ReplyMessage = PickListItem;
63
+ export interface RawMessage {
64
+ type: MESSAGE_TYPE;
65
+ message?: string;
66
+ file?: FileInfo;
67
+ fileUrl?: string;
68
+ fileName?: string;
69
+ fileSize?: string | number;
70
+ trackingData?: "";
71
+ richCards?: RichCard[];
72
+ viberRichCardRow?: number;
73
+ viberRichCardCol?: number;
74
+ fileResolution?: string;
75
+ thumbnailUrl?: string;
76
+ thumbnailFile?: FileInfo;
77
+ suggestions?: Array<RawMessageSuggestion>;
78
+ allowMultiple?: boolean;
79
+ attachments?: Array<FileInfo>;
80
+ listPicker?: Array<PickListItem>;
81
+ receivedMessage?: ReceivedMessage;
82
+ replyMessage?: ReplyMessage;
83
+ richLinkUrl?: string;
84
+ }
85
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MESSAGE_REACTION = exports.SEND_MESSAGE_VIA = exports.MESSAGE_TYPE = exports.MESSAGE_STATUS = void 0;
3
+ exports.SuggestionActionType = exports.MESSAGE_REACTION = exports.SEND_MESSAGE_VIA = exports.MESSAGE_TYPE = exports.MESSAGE_STATUS = void 0;
4
4
  var MESSAGE_STATUS;
5
5
  (function (MESSAGE_STATUS) {
6
6
  MESSAGE_STATUS[MESSAGE_STATUS["PENDING"] = 1] = "PENDING";
@@ -32,4 +32,10 @@ var MESSAGE_REACTION;
32
32
  MESSAGE_REACTION[MESSAGE_REACTION["LIKE"] = 2] = "LIKE";
33
33
  MESSAGE_REACTION[MESSAGE_REACTION["SUGGESTION_CLICK"] = 3] = "SUGGESTION_CLICK";
34
34
  })(MESSAGE_REACTION = exports.MESSAGE_REACTION || (exports.MESSAGE_REACTION = {}));
35
+ var SuggestionActionType;
36
+ (function (SuggestionActionType) {
37
+ SuggestionActionType["OPEN_URL"] = "open-url";
38
+ SuggestionActionType["REPLY"] = "reply";
39
+ SuggestionActionType["DIAL"] = "dial";
40
+ })(SuggestionActionType = exports.SuggestionActionType || (exports.SuggestionActionType = {}));
35
41
  //# sourceMappingURL=Message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/model/Message.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,yDAAW,CAAA;IACX,yDAAW,CAAA;IACX,mDAAQ,CAAA;IACR,6DAAa,CAAA;IACb,mDAAQ,CAAA;AACV,CAAC,EANW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAMzB;AAED,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,6BAAa,CAAA;IACb,sCAAsB,CAAA;IACtB,0CAA0B,CAAA;IAC1B,0CAA0B,CAAA;IAC1B,qCAAqB,CAAA;AACvB,CAAC,EAVW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAUvB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,yDAAS,CAAA;IACT,+DAAY,CAAA;AACd,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAED,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,yDAAS,CAAA;IACT,uDAAQ,CAAA;IACR,+EAAoB,CAAA;AACtB,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B"}
1
+ {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/model/Message.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,yDAAW,CAAA;IACX,yDAAW,CAAA;IACX,mDAAQ,CAAA;IACR,6DAAa,CAAA;IACb,mDAAQ,CAAA;AACV,CAAC,EANW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAMzB;AAED,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,6BAAa,CAAA;IACb,sCAAsB,CAAA;IACtB,0CAA0B,CAAA;IAC1B,0CAA0B,CAAA;IAC1B,qCAAqB,CAAA;AACvB,CAAC,EAVW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAUvB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,yDAAS,CAAA;IACT,+DAAY,CAAA;AACd,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAED,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,yDAAS,CAAA;IACT,uDAAQ,CAAA;IACR,+EAAoB,CAAA;AACtB,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B;AAED,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,6CAAqB,CAAA;IACrB,uCAAe,CAAA;IACf,qCAAa,CAAA;AACf,CAAC,EAJW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAI/B"}
@@ -0,0 +1,10 @@
1
+ import { Application } from "../";
2
+ import { MESSAGE_STATUS } from "../Message";
3
+ export interface QueueMessageStatus {
4
+ applicationMessageId: string;
5
+ applicationId: Application;
6
+ status: MESSAGE_STATUS;
7
+ date: number;
8
+ extraData: Record<string, unknown>;
9
+ deliveryStatus?: string;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=QueueMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueMessage.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/model/queue/QueueMessage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare enum PEACOM_CORE_QUEUE {
2
+ BILLING = "PEACOM_CORE_BILLING",
3
+ STATUS = "PEACOM_CORE_MESSAGE_STATUS",
4
+ FALLBACK = "PEACOM_CORE_FALLBACK"
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PEACOM_CORE_QUEUE = void 0;
4
+ var PEACOM_CORE_QUEUE;
5
+ (function (PEACOM_CORE_QUEUE) {
6
+ PEACOM_CORE_QUEUE["BILLING"] = "PEACOM_CORE_BILLING";
7
+ PEACOM_CORE_QUEUE["STATUS"] = "PEACOM_CORE_MESSAGE_STATUS";
8
+ PEACOM_CORE_QUEUE["FALLBACK"] = "PEACOM_CORE_FALLBACK";
9
+ })(PEACOM_CORE_QUEUE = exports.PEACOM_CORE_QUEUE || (exports.PEACOM_CORE_QUEUE = {}));
10
+ //# sourceMappingURL=queue.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.constant.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/model/queue/queue.constant.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,oDAA+B,CAAA;IAC/B,0DAAqC,CAAA;IACrC,sDAAiC,CAAA;AACnC,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B"}
@@ -0,0 +1,3 @@
1
+ export declare const DEFAULT_TIME_ZONE = "Asia/Ho_Chi_Minh";
2
+ export declare const DATE_FORMAT = "YYYY-MM-DD";
3
+ export declare const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,15 @@
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
+ /**
8
+ * Week start from sunday
9
+ * @param date
10
+ * @param tz
11
+ */
12
+ export declare function startOfWeeks(date: DateType, tz?: string): Date;
13
+ export declare function endOfWeek(date: DateType, tz?: string): Date;
14
+ export declare function lastWeek(date: DateType, tz?: string): Date;
15
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lastWeek = exports.endOfWeek = exports.startOfWeeks = 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
+ /**
25
+ * Week start from sunday
26
+ * @param date
27
+ * @param tz
28
+ */
29
+ function startOfWeeks(date, tz = "") {
30
+ return (0, exports.getDate)(date, tz).startOf("week").toDate();
31
+ }
32
+ exports.startOfWeeks = startOfWeeks;
33
+ function endOfWeek(date, tz = "") {
34
+ return (0, exports.getDate)(date, tz).endOf("week").toDate();
35
+ }
36
+ exports.endOfWeek = endOfWeek;
37
+ function lastWeek(date, tz = "") {
38
+ return (0, exports.getDate)(date, tz).subtract(1, "week").startOf("week").toDate();
39
+ }
40
+ exports.lastWeek = lastWeek;
41
+ //# sourceMappingURL=date.util.js.map
@@ -0,0 +1 @@
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,4CAMC;AAEM,MAAM,OAAO,GAAG,CAAC,IAAc,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IACjD,IAAI,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;AAC5B,CAAC,CAAA;AAHY,QAAA,OAAO,WAGnB;AAED,SAAgB,SAAS,CAAC,IAAc,EAAE,EAAE,GAAG,EAAE;IAC/C,OAAO,IAAA,eAAO,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;AACjD,CAAC;AAFD,8BAEC;AAED,SAAgB,WAAW,CAAC,IAAc,EAAE,EAAE,GAAG,EAAE;IACjD,OAAO,IAAA,eAAO,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AACpD,CAAC;AAFD,kCAEC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAc,EAAE,EAAE,GAAG,EAAE;IAClD,OAAO,IAAA,eAAO,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;AACnD,CAAC;AAFD,oCAEC;AAED,SAAgB,SAAS,CAAC,IAAc,EAAE,EAAE,GAAG,EAAE;IAC/C,OAAO,IAAA,eAAO,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;AACjD,CAAC;AAFD,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"}
@@ -1 +1,2 @@
1
1
  export * from './message/message.util';
2
+ export * from './string.util';
@@ -2,4 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./message/message.util"), exports);
5
+ tslib_1.__exportStar(require("./string.util"), exports);
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,wDAA6B"}
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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
+ //# sourceMappingURL=string.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.util.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/string.util.ts"],"names":[],"mappings":";;;AAAA,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,MAAM,QAAQ,GACZ,gEAAgE,CAAC;IAEnE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC;QAChC,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvE,OAAO,IAAI,CAAC;AACd,CAAC;AATD,gDASC;AAEM,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;IACrC,MAAM,OAAO,GAAG,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC;IAC/B,OAAO,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AACrC,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB;AAEF,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AACtE,CAAC;AAFD,0BAEC;AAED,MAAM,YAAY,GAA2B;IAC3C,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,GAAG;IACV,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,UAAkB,EAAE,EAAE;QAC9D,IAAI,KAAK,CAAC;QAEV,IAAI,UAAU,IAAI,YAAY,EAAE;YAC9B,OAAO,YAAY,CAAC,UAAU,CAAC,CAAC;SACjC;QACD,0CAA0C;QAC1C,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,EAAE;YACnD,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;SACpD;QACD,0CAA0C;QAC1C,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE;YAC1C,sCAAsC;YACtC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACxC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAlBD,oCAkBC;AAEM,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAA/D,QAAA,mBAAmB,uBAA4C;AAE5E,SAAgB,YAAY,CAAC,GAAW;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC;IACxB,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAHD,oCAGC;AAED,SAAgB,yBAAyB,CAAC,GAAW,EAAE,gBAAgB,GAAG,GAAG;IAC3E,IAAI,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IAC3C,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACf,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACzC,OAAO,EAAE,CAAC;AACZ,CAAC;AALD,8DAKC;AAED,SAAgB,4BAA4B,CAAC,GAAW;IACtD,IAAI,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACf,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC;AACZ,CAAC;AALD,oEAKC;AAED,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,OAAO,4BAA4B,CAAC,GAAG,CAAC;SACrC,KAAK,CAAC,SAAS,CAAC;SAChB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,eAAO,EAAC,CAAC,CAAC,CAAC;SACzB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AALD,gDAKC;AAED,SAAgB,UAAU,CAAC,MAAc;IACvC,OAAO,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC,EAAE,EAAE;QACjD,OAAO,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,gCAIC;AAED,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAFD,sDAEC;AAEM,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,KAAa,EAAE,EAAE;IAC1D,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC;IAC9B,IAAI,GAAG,CAAC,MAAM,GAAG,KAAK,EAAE;QACtB,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;KAChC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB;AAEK,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,KAAa,EAAE,EAAE;IAC3D,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC;IAC9B,IAAI,GAAG,CAAC,MAAM,GAAG,KAAK,EAAE;QACtB,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;KAC1C;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB"}