@peacom/core 0.0.60 → 0.0.62

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 (75) hide show
  1. package/README.md +11 -11
  2. package/package.json +1 -1
  3. package/src/index.d.ts +4 -4
  4. package/src/index.js +7 -7
  5. package/src/lib/api/api.constant.d.ts +58 -58
  6. package/src/lib/api/api.constant.js +19 -19
  7. package/src/lib/api/core.api.d.ts +9 -9
  8. package/src/lib/api/core.api.js +77 -77
  9. package/src/lib/api/core.api.js.map +1 -1
  10. package/src/lib/api/index.d.ts +4 -4
  11. package/src/lib/api/index.js +7 -7
  12. package/src/lib/api/micro-service.api.d.ts +2 -2
  13. package/src/lib/api/micro-service.api.js +37 -37
  14. package/src/lib/api/queue/queue.api.d.ts +5 -5
  15. package/src/lib/api/queue/queue.api.js +23 -23
  16. package/src/lib/core.d.ts +1 -1
  17. package/src/lib/core.js +7 -7
  18. package/src/lib/error/FormError.d.ts +53 -53
  19. package/src/lib/error/FormError.js +57 -57
  20. package/src/lib/error/HttpError.d.ts +4 -4
  21. package/src/lib/error/HttpError.js +11 -11
  22. package/src/lib/model/Application.d.ts +49 -49
  23. package/src/lib/model/Application.js +56 -56
  24. package/src/lib/model/Billing.d.ts +10 -10
  25. package/src/lib/model/Billing.js +15 -15
  26. package/src/lib/model/Currency.d.ts +4 -4
  27. package/src/lib/model/Currency.js +8 -8
  28. package/src/lib/model/FileInfo.d.ts +9 -9
  29. package/src/lib/model/FileInfo.js +2 -2
  30. package/src/lib/model/conversation/constant.d.ts +21 -21
  31. package/src/lib/model/conversation/constant.js +15 -15
  32. package/src/lib/model/conversation/index.d.ts +1 -1
  33. package/src/lib/model/conversation/index.js +4 -4
  34. package/src/lib/model/index.d.ts +9 -9
  35. package/src/lib/model/index.js +12 -12
  36. package/src/lib/model/message/Message.d.ts +117 -117
  37. package/src/lib/model/message/Message.js +83 -83
  38. package/src/lib/model/message/TemplateMessage.d.ts +4 -4
  39. package/src/lib/model/message/TemplateMessage.js +8 -8
  40. package/src/lib/model/message/index.d.ts +4 -4
  41. package/src/lib/model/message/index.js +7 -7
  42. package/src/lib/model/message/sinch/SinchWhatsappTemplate.d.ts +22 -22
  43. package/src/lib/model/message/sinch/SinchWhatsappTemplate.js +13 -13
  44. package/src/lib/model/message/zalo/ZaloZNSTemplate.d.ts +23 -23
  45. package/src/lib/model/message/zalo/ZaloZNSTemplate.js +2 -2
  46. package/src/lib/model/queue/QueueMessage.d.ts +28 -28
  47. package/src/lib/model/queue/QueueMessage.js +8 -8
  48. package/src/lib/model/queue/index.d.ts +2 -2
  49. package/src/lib/model/queue/index.js +5 -5
  50. package/src/lib/model/queue/queue.constant.d.ts +5 -5
  51. package/src/lib/model/queue/queue.constant.js +9 -9
  52. package/src/lib/model/template/Template.d.ts +43 -43
  53. package/src/lib/model/template/Template.js +88 -88
  54. package/src/lib/model/template/index.d.ts +1 -1
  55. package/src/lib/model/template/index.js +4 -4
  56. package/src/lib/model/viber-business/constant.d.ts +4 -4
  57. package/src/lib/model/viber-business/constant.js +8 -8
  58. package/src/lib/model/viber-business/index.d.ts +1 -1
  59. package/src/lib/model/viber-business/index.js +4 -4
  60. package/src/lib/util/date/constant.d.ts +3 -3
  61. package/src/lib/util/date/constant.js +6 -6
  62. package/src/lib/util/date/date.util.d.ts +15 -15
  63. package/src/lib/util/date/date.util.js +40 -40
  64. package/src/lib/util/file/file.util.d.ts +5 -5
  65. package/src/lib/util/file/file.util.js +34 -34
  66. package/src/lib/util/general.util.d.ts +1 -1
  67. package/src/lib/util/general.util.js +7 -7
  68. package/src/lib/util/index.d.ts +5 -5
  69. package/src/lib/util/index.js +8 -8
  70. package/src/lib/util/message/message.util.d.ts +89 -89
  71. package/src/lib/util/message/message.util.js +65 -65
  72. package/src/lib/util/phone.util.d.ts +24 -24
  73. package/src/lib/util/phone.util.js +50 -50
  74. package/src/lib/util/string.util.d.ts +13 -13
  75. package/src/lib/util/string.util.js +107 -107
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # core
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build core` to build the library.
8
-
9
- ## Running unit tests
10
-
11
- Run `nx test core` to execute the unit tests via [Jest](https://jestjs.io).
1
+ # core
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build core` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test core` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peacom/core",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "type": "commonjs",
5
5
  "dependencies": {
6
6
  "moment": "^2.29.4",
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './lib/core';
2
- export * from './lib/model';
3
- export * from './lib/util';
4
- export * from './lib/api';
1
+ export * from './lib/core';
2
+ export * from './lib/model';
3
+ export * from './lib/util';
4
+ export * from './lib/api';
package/src/index.js CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/core"), exports);
5
- tslib_1.__exportStar(require("./lib/model"), exports);
6
- tslib_1.__exportStar(require("./lib/util"), exports);
7
- tslib_1.__exportStar(require("./lib/api"), exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/core"), exports);
5
+ tslib_1.__exportStar(require("./lib/model"), exports);
6
+ tslib_1.__exportStar(require("./lib/util"), exports);
7
+ tslib_1.__exportStar(require("./lib/api"), exports);
8
8
  //# sourceMappingURL=index.js.map
@@ -1,58 +1,58 @@
1
- import { Application, ApplicationInfo, Message, RawMessage, SEND_MESSAGE_VIA } from '../model/';
2
- import { Conversation } from "../model";
3
- interface Contact {
4
- id: string;
5
- name?: string;
6
- phone?: string;
7
- isSubscribed: boolean;
8
- extraData: Record<string, unknown>;
9
- avatarUrl?: string;
10
- language: string;
11
- country: string;
12
- }
13
- export interface ApiCoreHandleParams {
14
- to: ApplicationInfo;
15
- rawMessage: RawMessage;
16
- replyToApplicationMessageId?: string;
17
- sentTime: number;
18
- extraData?: Record<string, unknown>;
19
- applicationMessageId: string;
20
- from: Contact;
21
- conversation?: Conversation;
22
- }
23
- export interface ApiCoreLiveAgentParams {
24
- to: ApplicationInfo;
25
- sentTime: number;
26
- extraData?: Record<string, unknown>;
27
- applicationMessageId?: string;
28
- from: Contact;
29
- conversation?: Conversation;
30
- }
31
- export interface ApiCoreLiveAgentResponse {
32
- conversation?: Conversation;
33
- }
34
- export interface ApiCoreHandleResponse {
35
- receiverId: string;
36
- messages: Array<Message>;
37
- contact: unknown;
38
- applicationInfo: ApplicationInfo;
39
- conversation?: Conversation;
40
- }
41
- export interface ApiChannelMessageParams {
42
- applicationInfo?: ApplicationInfo;
43
- message: Message;
44
- receiverId: string;
45
- sendVia?: SEND_MESSAGE_VIA;
46
- conversation?: Conversation;
47
- queueOption?: Record<string, unknown>;
48
- [key: string]: unknown;
49
- }
50
- export interface ApiChannelMessageResponse {
51
- applicationMessageId: string;
52
- extraData?: Record<string, unknown>;
53
- [key: string]: unknown;
54
- }
55
- export declare type LOG_FUNCTION = ((t: unknown) => void) | null;
56
- export declare const MICROSERVICE_URL: Record<Application, string>;
57
- export declare const INTEGRATED_CHANNEL: Application[];
58
- export {};
1
+ import { Application, ApplicationInfo, Message, RawMessage, SEND_MESSAGE_VIA } from '../model/';
2
+ import { Conversation } from "../model";
3
+ interface Contact {
4
+ id: string;
5
+ name?: string;
6
+ phone?: string;
7
+ isSubscribed: boolean;
8
+ extraData: Record<string, unknown>;
9
+ avatarUrl?: string;
10
+ language: string;
11
+ country: string;
12
+ }
13
+ export interface ApiCoreHandleParams {
14
+ to: ApplicationInfo;
15
+ rawMessage: RawMessage;
16
+ replyToApplicationMessageId?: string;
17
+ sentTime: number;
18
+ extraData?: Record<string, unknown>;
19
+ applicationMessageId: string;
20
+ from: Contact;
21
+ conversation?: Conversation;
22
+ }
23
+ export interface ApiCoreLiveAgentParams {
24
+ to: ApplicationInfo;
25
+ sentTime: number;
26
+ extraData?: Record<string, unknown>;
27
+ applicationMessageId?: string;
28
+ from: Contact;
29
+ conversation?: Conversation;
30
+ }
31
+ export interface ApiCoreLiveAgentResponse {
32
+ conversation?: Conversation;
33
+ }
34
+ export interface ApiCoreHandleResponse {
35
+ receiverId: string;
36
+ messages: Array<Message>;
37
+ contact: unknown;
38
+ applicationInfo: ApplicationInfo;
39
+ conversation?: Conversation;
40
+ }
41
+ export interface ApiChannelMessageParams {
42
+ applicationInfo?: ApplicationInfo;
43
+ message: Message;
44
+ receiverId: string;
45
+ sendVia?: SEND_MESSAGE_VIA;
46
+ conversation?: Conversation;
47
+ queueOption?: Record<string, unknown>;
48
+ [key: string]: unknown;
49
+ }
50
+ export interface ApiChannelMessageResponse {
51
+ applicationMessageId: string;
52
+ extraData?: Record<string, unknown>;
53
+ [key: string]: unknown;
54
+ }
55
+ export declare type LOG_FUNCTION = ((t: unknown) => void) | null;
56
+ export declare const MICROSERVICE_URL: Record<Application, string>;
57
+ export declare const INTEGRATED_CHANNEL: Application[];
58
+ export {};
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INTEGRATED_CHANNEL = exports.MICROSERVICE_URL = void 0;
4
- const model_1 = require("../model/");
5
- exports.MICROSERVICE_URL = {
6
- [model_1.Application.APPLE]: process.env['APPLE_INTEGRATION'] || 'http://127.0.0.1:4005/eip/apple',
7
- [model_1.Application.ZALO]: process.env['ZALO_INTEGRATION'] || 'http://127.0.0.1:4001/eip/zalo/bot',
8
- [model_1.Application.ZALO_ZNS]: process.env['ZALO_ZNS_INTEGRATION'] || 'http://127.0.0.1:4001/eip/zalo/zns',
9
- [model_1.Application.RCS]: process.env['RCS_INTEGRATION'] || 'http://127.0.0.1:4006',
10
- [model_1.Application.VIBER]: process.env['VIBER_BOT_INTEGRATION'] || 'http://127.0.0.1:4001/eip/viber/bot',
11
- [model_1.Application.VIBER_BUSINESS]: process.env['VIBER_BUSINESS_INTEGRATION'] || 'http://127.0.0.1:4001/eip/viber/business',
12
- [model_1.Application.TELEGRAM]: process.env['TELEGRAM_INTEGRATION'] || 'http://127.0.0.1:4009',
13
- [model_1.Application.FACEBOOK]: process.env['FACEBOOK_INTEGRATION'] || 'http://127.0.0.1:4010',
14
- [model_1.Application.SMS]: process.env['SMS_INTEGRATION'] || 'http://127.0.0.1:4011',
15
- [model_1.Application.VIBER_BOT]: process.env['VIBER_BOT_INTEGRATION'] || 'http://127.0.0.1:4001/eip/viber/bot',
16
- [model_1.Application.WHATSAPP]: process.env['WHATSAPP_INTEGRATION'] || 'http://127.0.0.1:4001/eip/whatsapp',
17
- [model_1.Application.GOOGLE_BUSINESS]: process.env['GOOGLE_BUSINESS_INTEGRATION'] || 'http://127.0.0.1:4006/eip/google/business',
18
- };
19
- exports.INTEGRATED_CHANNEL = [model_1.Application.APPLE, model_1.Application.ZALO, model_1.Application.ZALO_ZNS, model_1.Application.GOOGLE_BUSINESS];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INTEGRATED_CHANNEL = exports.MICROSERVICE_URL = void 0;
4
+ const model_1 = require("../model/");
5
+ exports.MICROSERVICE_URL = {
6
+ [model_1.Application.APPLE]: process.env['APPLE_INTEGRATION'] || 'http://127.0.0.1:4005/eip/apple',
7
+ [model_1.Application.ZALO]: process.env['ZALO_INTEGRATION'] || 'http://127.0.0.1:4003/eip/zalo/bot',
8
+ [model_1.Application.ZALO_ZNS]: process.env['ZALO_ZNS_INTEGRATION'] || 'http://127.0.0.1:4003/eip/zalo/zns',
9
+ [model_1.Application.RCS]: process.env['RCS_INTEGRATION'] || 'http://127.0.0.1:4006',
10
+ [model_1.Application.VIBER]: process.env['VIBER_BOT_INTEGRATION'] || 'http://127.0.0.1:4001/eip/viber/bot',
11
+ [model_1.Application.VIBER_BUSINESS]: process.env['VIBER_BUSINESS_INTEGRATION'] || 'http://127.0.0.1:4001/eip/viber/business',
12
+ [model_1.Application.TELEGRAM]: process.env['TELEGRAM_INTEGRATION'] || 'http://127.0.0.1:4009',
13
+ [model_1.Application.FACEBOOK]: process.env['FACEBOOK_INTEGRATION'] || 'http://127.0.0.1:4010',
14
+ [model_1.Application.SMS]: process.env['SMS_INTEGRATION'] || 'http://127.0.0.1:4011',
15
+ [model_1.Application.VIBER_BOT]: process.env['VIBER_BOT_INTEGRATION'] || 'http://127.0.0.1:4001/eip/viber/bot',
16
+ [model_1.Application.WHATSAPP]: process.env['WHATSAPP_INTEGRATION'] || 'http://127.0.0.1:4008/eip/whatsapp',
17
+ [model_1.Application.GOOGLE_BUSINESS]: process.env['GOOGLE_BUSINESS_INTEGRATION'] || 'http://127.0.0.1:4006/eip/google/business',
18
+ };
19
+ exports.INTEGRATED_CHANNEL = [model_1.Application.APPLE, model_1.Application.ZALO, model_1.Application.ZALO_ZNS, model_1.Application.GOOGLE_BUSINESS];
20
20
  //# sourceMappingURL=api.constant.js.map
@@ -1,9 +1,9 @@
1
- import { ApiCoreHandleParams, ApiCoreHandleResponse, ApiCoreLiveAgentParams, ApiCoreLiveAgentResponse, LOG_FUNCTION } from "./api.constant";
2
- export declare enum CORE_API_PATH {
3
- MESSAGE = "/message",
4
- LIVE_AGENT = "/conversation/live-agent",
5
- CONVERSATION_CLOSE = "/conversation/close"
6
- }
7
- export declare const handleCoreMessage: (CORE_URL: string, params: ApiCoreHandleParams, log?: LOG_FUNCTION) => Promise<ApiCoreHandleResponse>;
8
- export declare const handleCoreLiveAgent: (CORE_URL: string, params: ApiCoreLiveAgentParams, log?: LOG_FUNCTION) => Promise<ApiCoreLiveAgentResponse>;
9
- export declare const handleCoreConversationClose: (CORE_URL: string, params: ApiCoreLiveAgentParams, log?: LOG_FUNCTION) => Promise<ApiCoreLiveAgentResponse>;
1
+ import { ApiCoreHandleParams, ApiCoreHandleResponse, ApiCoreLiveAgentParams, ApiCoreLiveAgentResponse, LOG_FUNCTION } from "./api.constant";
2
+ export declare enum CORE_API_PATH {
3
+ MESSAGE = "/message",
4
+ LIVE_AGENT = "/conversation/live-agent",
5
+ CONVERSATION_CLOSE = "/conversation/close"
6
+ }
7
+ export declare const handleCoreMessage: (CORE_URL: string, params: ApiCoreHandleParams, log?: LOG_FUNCTION) => Promise<ApiCoreHandleResponse>;
8
+ export declare const handleCoreLiveAgent: (CORE_URL: string, params: ApiCoreLiveAgentParams, log?: LOG_FUNCTION) => Promise<ApiCoreLiveAgentResponse>;
9
+ export declare const handleCoreConversationClose: (CORE_URL: string, params: ApiCoreLiveAgentParams, log?: LOG_FUNCTION) => Promise<ApiCoreLiveAgentResponse>;
@@ -1,78 +1,78 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleCoreConversationClose = exports.handleCoreLiveAgent = exports.handleCoreMessage = exports.CORE_API_PATH = void 0;
4
- const tslib_1 = require("tslib");
5
- const FormError_1 = require("../error/FormError");
6
- var CORE_API_PATH;
7
- (function (CORE_API_PATH) {
8
- CORE_API_PATH["MESSAGE"] = "/message";
9
- CORE_API_PATH["LIVE_AGENT"] = "/conversation/live-agent";
10
- CORE_API_PATH["CONVERSATION_CLOSE"] = "/conversation/close";
11
- })(CORE_API_PATH = exports.CORE_API_PATH || (exports.CORE_API_PATH = {}));
12
- const handleCoreMessage = (CORE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
- const url = `${CORE_URL}/${CORE_API_PATH.MESSAGE}`;
14
- if (log) {
15
- log(`CORE REQUEST: ${url} - ${JSON.stringify(params)}`);
16
- }
17
- const rs = yield fetch(url, {
18
- method: "POST",
19
- body: JSON.stringify(params),
20
- headers: {
21
- "content-type": "application/json"
22
- }
23
- });
24
- const bodyStr = yield rs.text();
25
- if (log) {
26
- log(`CORE RESPONSE: ${url} - ${bodyStr}`);
27
- }
28
- if (!rs.ok) {
29
- throw new FormError_1.FormError(JSON.parse(bodyStr));
30
- }
31
- return JSON.parse(bodyStr);
32
- });
33
- exports.handleCoreMessage = handleCoreMessage;
34
- const handleCoreLiveAgent = (CORE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
- const url = `${CORE_URL}/${CORE_API_PATH.LIVE_AGENT}`;
36
- if (log) {
37
- log(`CORE LIVE AGENT REQUEST: ${url} - ${JSON.stringify(params)}`);
38
- }
39
- const rs = yield fetch(url, {
40
- method: "POST",
41
- body: JSON.stringify(params),
42
- headers: {
43
- "content-type": "application/json"
44
- }
45
- });
46
- const bodyStr = yield rs.text();
47
- if (log) {
48
- log(`CORE LIVE AGENT RESPONSE: ${url} - ${bodyStr}`);
49
- }
50
- if (!rs.ok) {
51
- throw new FormError_1.FormError(JSON.parse(bodyStr));
52
- }
53
- return JSON.parse(bodyStr);
54
- });
55
- exports.handleCoreLiveAgent = handleCoreLiveAgent;
56
- const handleCoreConversationClose = (CORE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
- const url = `${CORE_URL}/${CORE_API_PATH.CONVERSATION_CLOSE}`;
58
- if (log) {
59
- log(`CORE CONVERSATION CLOSE REQUEST: ${url} - ${JSON.stringify(params)}`);
60
- }
61
- const rs = yield fetch(url, {
62
- method: "POST",
63
- body: JSON.stringify(params),
64
- headers: {
65
- "content-type": "application/json"
66
- }
67
- });
68
- const bodyStr = yield rs.text();
69
- if (log) {
70
- log(`CORE CONVERSATION CLOSE RESPONSE: ${url} - ${bodyStr}`);
71
- }
72
- if (!rs.ok) {
73
- throw new FormError_1.FormError(JSON.parse(bodyStr));
74
- }
75
- return JSON.parse(bodyStr);
76
- });
77
- exports.handleCoreConversationClose = handleCoreConversationClose;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleCoreConversationClose = exports.handleCoreLiveAgent = exports.handleCoreMessage = exports.CORE_API_PATH = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const FormError_1 = require("../error/FormError");
6
+ var CORE_API_PATH;
7
+ (function (CORE_API_PATH) {
8
+ CORE_API_PATH["MESSAGE"] = "/message";
9
+ CORE_API_PATH["LIVE_AGENT"] = "/conversation/live-agent";
10
+ CORE_API_PATH["CONVERSATION_CLOSE"] = "/conversation/close";
11
+ })(CORE_API_PATH = exports.CORE_API_PATH || (exports.CORE_API_PATH = {}));
12
+ const handleCoreMessage = (CORE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
+ const url = `${CORE_URL}${CORE_API_PATH.MESSAGE}`;
14
+ if (log) {
15
+ log(`CORE REQUEST: ${url} - ${JSON.stringify(params)}`);
16
+ }
17
+ const rs = yield fetch(url, {
18
+ method: "POST",
19
+ body: JSON.stringify(params),
20
+ headers: {
21
+ "content-type": "application/json"
22
+ }
23
+ });
24
+ const bodyStr = yield rs.text();
25
+ if (log) {
26
+ log(`CORE RESPONSE: ${url} - ${bodyStr}`);
27
+ }
28
+ if (!rs.ok) {
29
+ throw new FormError_1.FormError(JSON.parse(bodyStr));
30
+ }
31
+ return JSON.parse(bodyStr);
32
+ });
33
+ exports.handleCoreMessage = handleCoreMessage;
34
+ const handleCoreLiveAgent = (CORE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
+ const url = `${CORE_URL}${CORE_API_PATH.LIVE_AGENT}`;
36
+ if (log) {
37
+ log(`CORE LIVE AGENT REQUEST: ${url} - ${JSON.stringify(params)}`);
38
+ }
39
+ const rs = yield fetch(url, {
40
+ method: "POST",
41
+ body: JSON.stringify(params),
42
+ headers: {
43
+ "content-type": "application/json"
44
+ }
45
+ });
46
+ const bodyStr = yield rs.text();
47
+ if (log) {
48
+ log(`CORE LIVE AGENT RESPONSE: ${url} - ${bodyStr}`);
49
+ }
50
+ if (!rs.ok) {
51
+ throw new FormError_1.FormError(JSON.parse(bodyStr));
52
+ }
53
+ return JSON.parse(bodyStr);
54
+ });
55
+ exports.handleCoreLiveAgent = handleCoreLiveAgent;
56
+ const handleCoreConversationClose = (CORE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ const url = `${CORE_URL}${CORE_API_PATH.CONVERSATION_CLOSE}`;
58
+ if (log) {
59
+ log(`CORE CONVERSATION CLOSE REQUEST: ${url} - ${JSON.stringify(params)}`);
60
+ }
61
+ const rs = yield fetch(url, {
62
+ method: "POST",
63
+ body: JSON.stringify(params),
64
+ headers: {
65
+ "content-type": "application/json"
66
+ }
67
+ });
68
+ const bodyStr = yield rs.text();
69
+ if (log) {
70
+ log(`CORE CONVERSATION CLOSE RESPONSE: ${url} - ${bodyStr}`);
71
+ }
72
+ if (!rs.ok) {
73
+ throw new FormError_1.FormError(JSON.parse(bodyStr));
74
+ }
75
+ return JSON.parse(bodyStr);
76
+ });
77
+ exports.handleCoreConversationClose = handleCoreConversationClose;
78
78
  //# sourceMappingURL=core.api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.api.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/api/core.api.ts"],"names":[],"mappings":";;;;AAOA,kDAA6C;AAE7C,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,qCAAoB,CAAA;IACpB,wDAAuC,CAAA;IACvC,2DAA0C,CAAA;AAC5C,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB;AAEM,MAAM,iBAAiB,GAAG,CAAO,QAAgB,EAAE,MAA2B,EAAE,MAAoB,IAAI,EAAkC,EAAE;IACjJ,MAAM,GAAG,GAAG,GAAG,QAAQ,IAAI,aAAa,CAAC,OAAO,EAAE,CAAA;IAClD,IAAI,GAAG,EAAE;QACP,GAAG,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;KACxD;IAED,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,G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,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;AAtBY,QAAA,2BAA2B,+BAsBvC"}
@@ -1,4 +1,4 @@
1
- export * from './api.constant';
2
- export * from './queue/queue.api';
3
- export * from './core.api';
4
- export * from './micro-service.api';
1
+ export * from './api.constant';
2
+ export * from './queue/queue.api';
3
+ export * from './core.api';
4
+ export * from './micro-service.api';
@@ -1,8 +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/queue.api"), exports);
6
- tslib_1.__exportStar(require("./core.api"), exports);
7
- tslib_1.__exportStar(require("./micro-service.api"), exports);
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/queue.api"), exports);
6
+ tslib_1.__exportStar(require("./core.api"), exports);
7
+ tslib_1.__exportStar(require("./micro-service.api"), exports);
8
8
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import { ApiChannelMessageParams, ApiChannelMessageResponse, LOG_FUNCTION } from "./api.constant";
2
- export declare const sendChannelMessage: (MICROSERVICE_URL: string, params: ApiChannelMessageParams, log?: LOG_FUNCTION) => Promise<ApiChannelMessageResponse>;
1
+ import { ApiChannelMessageParams, ApiChannelMessageResponse, LOG_FUNCTION } from "./api.constant";
2
+ export declare const sendChannelMessage: (MICROSERVICE_URL: string, params: ApiChannelMessageParams, log?: LOG_FUNCTION) => Promise<ApiChannelMessageResponse>;
@@ -1,38 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendChannelMessage = void 0;
4
- const tslib_1 = require("tslib");
5
- const sendChannelMessage = (MICROSERVICE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
6
- var _a;
7
- const url = `${MICROSERVICE_URL}/message`;
8
- if (log) {
9
- log(`SERVICE REQUEST: ${url} - ${JSON.stringify(params)}`);
10
- }
11
- const rs = yield fetch(url, {
12
- method: "POST",
13
- body: JSON.stringify(params),
14
- headers: {
15
- "content-type": "application/json"
16
- }
17
- });
18
- const bodyStr = yield rs.text();
19
- if (log) {
20
- log(`SERVICE RESPONSE: ${url} - ${bodyStr}`);
21
- }
22
- if (!rs.ok) {
23
- let errorMessage = '';
24
- try {
25
- const errors = JSON.parse(bodyStr);
26
- if (errors.length) {
27
- errorMessage = (_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message;
28
- }
29
- }
30
- catch (e) {
31
- errorMessage = bodyStr;
32
- }
33
- throw new Error(errorMessage);
34
- }
35
- return JSON.parse(bodyStr);
36
- });
37
- exports.sendChannelMessage = sendChannelMessage;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendChannelMessage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const sendChannelMessage = (MICROSERVICE_URL, params, log = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
6
+ var _a;
7
+ const url = `${MICROSERVICE_URL}/message`;
8
+ if (log) {
9
+ log(`SERVICE REQUEST: ${url} - ${JSON.stringify(params)}`);
10
+ }
11
+ const rs = yield fetch(url, {
12
+ method: "POST",
13
+ body: JSON.stringify(params),
14
+ headers: {
15
+ "content-type": "application/json"
16
+ }
17
+ });
18
+ const bodyStr = yield rs.text();
19
+ if (log) {
20
+ log(`SERVICE RESPONSE: ${url} - ${bodyStr}`);
21
+ }
22
+ if (!rs.ok) {
23
+ let errorMessage = '';
24
+ try {
25
+ const errors = JSON.parse(bodyStr);
26
+ if (errors.length) {
27
+ errorMessage = (_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message;
28
+ }
29
+ }
30
+ catch (e) {
31
+ errorMessage = bodyStr;
32
+ }
33
+ throw new Error(errorMessage);
34
+ }
35
+ return JSON.parse(bodyStr);
36
+ });
37
+ exports.sendChannelMessage = sendChannelMessage;
38
38
  //# sourceMappingURL=micro-service.api.js.map
@@ -1,5 +1,5 @@
1
- import { QueueMessageStatus, QueueOutgoingMessage } from "../../model";
2
- import { Queue } from "bullmq";
3
- export declare const queueAddMessageStatus: (queue: Queue, message: QueueMessageStatus) => Promise<import("bullmq").Job<any, any, string>>;
4
- export declare const queueAddBulkMessageStatus: (queue: Queue, messages: Array<QueueMessageStatus>) => Promise<import("bullmq").Job<any, any, string>[]>;
5
- export declare const queueAddOutgoingMessage: (queue: Queue, message: QueueOutgoingMessage) => Promise<import("bullmq").Job<any, any, string>>;
1
+ import { QueueMessageStatus, QueueOutgoingMessage } from "../../model";
2
+ import { Queue } from "bullmq";
3
+ export declare const queueAddMessageStatus: (queue: Queue, message: QueueMessageStatus) => Promise<import("bullmq").Job<any, any, string>>;
4
+ export declare const queueAddBulkMessageStatus: (queue: Queue, messages: Array<QueueMessageStatus>) => Promise<import("bullmq").Job<any, any, string>[]>;
5
+ export declare const queueAddOutgoingMessage: (queue: Queue, message: QueueOutgoingMessage) => Promise<import("bullmq").Job<any, any, string>>;
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queueAddOutgoingMessage = exports.queueAddBulkMessageStatus = exports.queueAddMessageStatus = void 0;
4
- const uuid_1 = require("uuid");
5
- const toBullQueueMessage = (message) => {
6
- const jobId = `${message.applicationInfo.applicationId}_${message.applicationMessageId || ''}_${message.status}_${message.sentTime}`;
7
- return {
8
- name: jobId, data: message, opts: Object.assign(Object.assign({}, (message.jobOpt || {})), { jobId })
9
- };
10
- };
11
- const queueAddMessageStatus = (queue, message) => {
12
- const queueMessage = toBullQueueMessage(message);
13
- return queue.add(queueMessage.name, queueMessage.data, queueMessage.opts);
14
- };
15
- exports.queueAddMessageStatus = queueAddMessageStatus;
16
- const queueAddBulkMessageStatus = (queue, messages) => {
17
- return queue.addBulk(messages.map(t => toBullQueueMessage(t)));
18
- };
19
- exports.queueAddBulkMessageStatus = queueAddBulkMessageStatus;
20
- const queueAddOutgoingMessage = (queue, message) => {
21
- return queue.add(message.name || (0, uuid_1.v4)(), message, message.jobOpt);
22
- };
23
- exports.queueAddOutgoingMessage = queueAddOutgoingMessage;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queueAddOutgoingMessage = exports.queueAddBulkMessageStatus = exports.queueAddMessageStatus = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const toBullQueueMessage = (message) => {
6
+ const jobId = `${message.applicationInfo.applicationId}_${message.applicationMessageId || ''}_${message.status}_${message.sentTime}`;
7
+ return {
8
+ name: jobId, data: message, opts: Object.assign(Object.assign({}, (message.jobOpt || {})), { jobId })
9
+ };
10
+ };
11
+ const queueAddMessageStatus = (queue, message) => {
12
+ const queueMessage = toBullQueueMessage(message);
13
+ return queue.add(queueMessage.name, queueMessage.data, queueMessage.opts);
14
+ };
15
+ exports.queueAddMessageStatus = queueAddMessageStatus;
16
+ const queueAddBulkMessageStatus = (queue, messages) => {
17
+ return queue.addBulk(messages.map(t => toBullQueueMessage(t)));
18
+ };
19
+ exports.queueAddBulkMessageStatus = queueAddBulkMessageStatus;
20
+ const queueAddOutgoingMessage = (queue, message) => {
21
+ return queue.add(message.name || (0, uuid_1.v4)(), message, message.jobOpt);
22
+ };
23
+ exports.queueAddOutgoingMessage = queueAddOutgoingMessage;
24
24
  //# sourceMappingURL=queue.api.js.map
package/src/lib/core.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function core(): string;
1
+ export declare function core(): string;
package/src/lib/core.js CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.core = void 0;
4
- function core() {
5
- return 'core';
6
- }
7
- exports.core = core;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.core = void 0;
4
+ function core() {
5
+ return 'core';
6
+ }
7
+ exports.core = core;
8
8
  //# sourceMappingURL=core.js.map