@zenify-omni/chat-js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/api/campaign.js +19 -0
  4. package/api/chat.js +518 -0
  5. package/api/chatroom.js +254 -0
  6. package/api/contact.js +45 -0
  7. package/api/crm-organization.js +101 -0
  8. package/api/customer.js +143 -0
  9. package/api/facebook-labels.js +11 -0
  10. package/api/field.js +11 -0
  11. package/api/file.js +17 -0
  12. package/api/filter.js +50 -0
  13. package/api/group.js +11 -0
  14. package/api/iam.js +23 -0
  15. package/api/index.js +54 -0
  16. package/api/orgTree.js +45 -0
  17. package/api/post.js +111 -0
  18. package/api/queue.js +15 -0
  19. package/api/report.js +422 -0
  20. package/api/send.js +21 -0
  21. package/api/session-event.js +30 -0
  22. package/api/session.js +249 -0
  23. package/api/settings/assign-task.js +10 -0
  24. package/api/settings/channel.js +136 -0
  25. package/api/settings/chat-layout.js +37 -0
  26. package/api/settings/chat-timeout.js +10 -0
  27. package/api/settings/common.js +32 -0
  28. package/api/settings/config.js +19 -0
  29. package/api/settings/index.js +24 -0
  30. package/api/settings/ivr.js +25 -0
  31. package/api/settings/queue-v3.js +56 -0
  32. package/api/settings/queue.js +48 -0
  33. package/api/settings/routing.js +32 -0
  34. package/api/settings/service.js +31 -0
  35. package/api/settings.js +567 -0
  36. package/api/shipping.js +19 -0
  37. package/api/shopee.js +21 -0
  38. package/api/smart-qc/index.js +4 -0
  39. package/api/smart-qc/keyword.js +10 -0
  40. package/api/tag.js +11 -0
  41. package/api/user.js +177 -0
  42. package/client.js +391 -0
  43. package/config/env.js +76 -0
  44. package/constants/advance-filter.js +358 -0
  45. package/constants/auto-assign-tag.js +13 -0
  46. package/constants/chat-message.js +423 -0
  47. package/constants/chat-room-tag.js +7 -0
  48. package/constants/chat-source.js +68 -0
  49. package/constants/chatbot.js +58 -0
  50. package/constants/common.js +4 -0
  51. package/constants/crm-organization.js +75 -0
  52. package/constants/distribute.js +8 -0
  53. package/constants/distribution-log.js +14 -0
  54. package/constants/events.js +27 -0
  55. package/constants/file-upload.js +86 -0
  56. package/constants/lead.js +111 -0
  57. package/constants/mask-data-config.js +16 -0
  58. package/constants/month.js +78 -0
  59. package/constants/quick-filter.js +49 -0
  60. package/constants/regex.js +34 -0
  61. package/constants/setting.js +62 -0
  62. package/constants/shipping.js +12 -0
  63. package/constants/social.js +21 -0
  64. package/constants/sortable-fields.js +146 -0
  65. package/constants/tenant_config.js +154 -0
  66. package/constants/use-query-key.js +470 -0
  67. package/constants/user.js +293 -0
  68. package/exceptions/axios-error.js +24 -0
  69. package/exceptions/https-error.js +28 -0
  70. package/exceptions/validator-error.js +20 -0
  71. package/lib/avatar-color.js +31 -0
  72. package/lib/i18n/index.js +85 -0
  73. package/lib/i18n/language-store.js +74 -0
  74. package/lib/i18n/locales/en/campaign.json +3 -0
  75. package/lib/i18n/locales/en/chat.json +656 -0
  76. package/lib/i18n/locales/en/common.json +1846 -0
  77. package/lib/i18n/locales/en/customer.json +20 -0
  78. package/lib/i18n/locales/en/lead.json +5 -0
  79. package/lib/i18n/locales/en/lumi.json +4 -0
  80. package/lib/i18n/locales/en/notification.json +107 -0
  81. package/lib/i18n/locales/en/org.json +4 -0
  82. package/lib/i18n/locales/en/posts.json +8 -0
  83. package/lib/i18n/locales/en/settings.json +39 -0
  84. package/lib/i18n/locales/vi/campaign.json +3 -0
  85. package/lib/i18n/locales/vi/chat.json +660 -0
  86. package/lib/i18n/locales/vi/common.json +1846 -0
  87. package/lib/i18n/locales/vi/customer.json +20 -0
  88. package/lib/i18n/locales/vi/lead.json +5 -0
  89. package/lib/i18n/locales/vi/lumi.json +4 -0
  90. package/lib/i18n/locales/vi/notification.json +107 -0
  91. package/lib/i18n/locales/vi/org.json +4 -0
  92. package/lib/i18n/locales/vi/posts.json +8 -0
  93. package/lib/i18n/locales/vi/settings.json +39 -0
  94. package/lib/i18n/server-label.js +33 -0
  95. package/lib/phone.js +70 -0
  96. package/lib/user-avatar.js +21 -0
  97. package/package.json +45 -0
  98. package/socket/index.js +30 -0
  99. package/transport-registry.js +77 -0
  100. package/utils/access-detail.js +119 -0
  101. package/utils/auth.js +205 -0
  102. package/utils/chunk-reload-guard.js +4 -0
  103. package/utils/concurrency-limiter.js +30 -0
  104. package/utils/crm-organization.js +0 -0
  105. package/utils/currency.js +14 -0
  106. package/utils/customers.js +42 -0
  107. package/utils/data.js +178 -0
  108. package/utils/date.js +144 -0
  109. package/utils/debounced-invalidate.js +15 -0
  110. package/utils/emoticon.js +134 -0
  111. package/utils/export.js +7 -0
  112. package/utils/field-layout.js +33 -0
  113. package/utils/filter-adapters.js +9 -0
  114. package/utils/filter.js +18 -0
  115. package/utils/formatters.js +6 -0
  116. package/utils/image-compression.js +169 -0
  117. package/utils/leads.js +13 -0
  118. package/utils/microlink.js +20 -0
  119. package/utils/org-tree.js +108 -0
  120. package/utils/request.js +461 -0
  121. package/utils/session-end.js +19 -0
  122. package/utils/string.js +154 -0
  123. package/utils/table-display-config.js +80 -0
  124. package/utils/validation.js +49 -0
package/api/session.js ADDED
@@ -0,0 +1,249 @@
1
+ import { requestApi, requestAuthApi } from "../utils/request.js";
2
+ import { getDeviceId, getUser } from "../utils/auth.js";
3
+ const LOGIN_ENDPOINT = "/auth/login";
4
+ const SDK_SIGN_IN_ENDPOINT = "/auth/sdk/sign-in";
5
+ const LOGOUT_ENDPOINT = "/auth/logout";
6
+ const LEGACY_LOGOUT_ENDPOINT = "/v2/logout";
7
+ const LEGACY_LOGIN_ENDPOINT = "/v2/login";
8
+ const LEGACY_TTL_IN_SECOND = 2592e3;
9
+ const CREDENTIAL_REJECTION_STATUSES = /* @__PURE__ */ new Set([400, 401, 403, 422, 429]);
10
+ const errorStatus = (error) => error?.status ?? error?.statusCode;
11
+ const isAuthServiceUnavailable = (error) => {
12
+ const status = errorStatus(error);
13
+ if (status === void 0 || status === null) return true;
14
+ if (CREDENTIAL_REJECTION_STATUSES.has(status)) return false;
15
+ return status === 404 || status === 408 || status >= 500;
16
+ };
17
+ const legacyLogin = ({ domain, email, password }) => requestApi({
18
+ isPublicApi: true,
19
+ method: "post",
20
+ endpoint: LEGACY_LOGIN_ENDPOINT,
21
+ data: { domain, email, password, ttl_in_second: LEGACY_TTL_IN_SECOND }
22
+ });
23
+ const DEFAULT_SDK_TTL_SECONDS = 7 * 24 * 60 * 60;
24
+ const signInWithApiKey = async ({
25
+ email,
26
+ apiKey,
27
+ ttlInSecond = DEFAULT_SDK_TTL_SECONDS
28
+ }) => requestAuthApi({
29
+ method: "post",
30
+ endpoint: SDK_SIGN_IN_ENDPOINT,
31
+ customHeaders: { "api-key": apiKey },
32
+ data: { email, ttl_in_second: ttlInSecond }
33
+ });
34
+ const login = async (credentials) => {
35
+ const { domain, email, password } = credentials;
36
+ try {
37
+ return await requestAuthApi({
38
+ method: "post",
39
+ endpoint: LOGIN_ENDPOINT,
40
+ data: {
41
+ domain,
42
+ email,
43
+ password,
44
+ // Selects the web timeout pair + the web access-token TTL server-side.
45
+ device_type: "web",
46
+ // One id per browser, so N tabs share ONE session row.
47
+ device_id: getDeviceId()
48
+ }
49
+ });
50
+ } catch (error) {
51
+ if (!isAuthServiceUnavailable(error)) throw error;
52
+ console.warn(
53
+ "[auth] POST /auth/login unavailable \u2014 falling back to legacy POST /v2/login",
54
+ {
55
+ status: errorStatus(error),
56
+ code: error?.code,
57
+ message: error?.message
58
+ }
59
+ );
60
+ return legacyLogin({ domain, email, password });
61
+ }
62
+ };
63
+ const authHeader = () => {
64
+ const user = getUser();
65
+ return { Authorization: `Bearer ${user?.token}` };
66
+ };
67
+ const listMySessions = () => requestAuthApi({
68
+ method: "get",
69
+ endpoint: "/auth/sessions",
70
+ customHeaders: authHeader()
71
+ });
72
+ const updateCurrentSessionAppVersion = (version) => requestAuthApi({
73
+ method: "post",
74
+ endpoint: "/auth/sessions/current/app-version",
75
+ timeout: 3e3,
76
+ customHeaders: { ...authHeader(), "x-app-version": version }
77
+ });
78
+ const revokeMySession = (sid) => requestAuthApi({
79
+ method: "delete",
80
+ endpoint: `/auth/sessions/${sid}`,
81
+ customHeaders: authHeader()
82
+ });
83
+ const listUserSessions = (userId) => requestAuthApi({
84
+ method: "get",
85
+ endpoint: `/auth/admin/users/${userId}/sessions`,
86
+ customHeaders: authHeader()
87
+ });
88
+ const revokeUserSession = (userId, sid) => requestAuthApi({
89
+ method: "delete",
90
+ endpoint: `/auth/admin/users/${userId}/sessions/${sid}`,
91
+ customHeaders: authHeader()
92
+ });
93
+ const forceLogoutUser = (userId) => requestAuthApi({
94
+ method: "post",
95
+ endpoint: `/auth/admin/users/${userId}/logout-all`,
96
+ customHeaders: authHeader()
97
+ });
98
+ const adminSessionTrace = (userId, { from, to } = {}) => {
99
+ const params = {};
100
+ if (from) params.from = from;
101
+ if (to) params.to = to;
102
+ return requestAuthApi({
103
+ method: "get",
104
+ endpoint: `/auth/admin/users/${userId}/session-trace`,
105
+ params: Object.keys(params).length ? params : void 0,
106
+ customHeaders: authHeader()
107
+ });
108
+ };
109
+ const getOnlineUserList = ({
110
+ tenantId,
111
+ limit,
112
+ offset,
113
+ q,
114
+ activityBucket
115
+ } = {}) => {
116
+ const params = {};
117
+ if (tenantId) params.tenant_id = tenantId;
118
+ if (limit !== void 0) params.limit = limit;
119
+ if (offset !== void 0) params.offset = offset;
120
+ if (q) params.q = q;
121
+ if (activityBucket) params.activity_bucket = activityBucket;
122
+ return requestAuthApi({
123
+ method: "get",
124
+ endpoint: "/auth/admin/online-user-list",
125
+ params: Object.keys(params).length ? params : void 0,
126
+ customHeaders: authHeader()
127
+ });
128
+ };
129
+ const getOnlineCounts = () => requestAuthApi({
130
+ method: "get",
131
+ endpoint: "/auth/admin/online-users",
132
+ customHeaders: authHeader()
133
+ });
134
+ const getSuperAdmins = () => requestAuthApi({
135
+ method: "get",
136
+ endpoint: "/auth/admin/superadmins",
137
+ customHeaders: authHeader()
138
+ });
139
+ const getSessionTimeline = ({ range } = {}) => requestAuthApi({
140
+ method: "get",
141
+ endpoint: "/auth/admin/session-timeline",
142
+ params: range ? { range } : void 0,
143
+ customHeaders: authHeader()
144
+ });
145
+ const getSessionPolicy = (tenantId) => requestAuthApi({
146
+ method: "get",
147
+ endpoint: "/auth/admin/session-policy",
148
+ params: { tenant_id: tenantId },
149
+ customHeaders: authHeader()
150
+ });
151
+ const updateSessionPolicy = (tenantId, rules) => requestAuthApi({
152
+ method: "put",
153
+ endpoint: "/auth/admin/session-policy",
154
+ data: { tenant_id: tenantId, rules },
155
+ customHeaders: authHeader()
156
+ });
157
+ const getMyTenantSessionPolicy = () => requestAuthApi({
158
+ method: "get",
159
+ endpoint: "/auth/session-policy",
160
+ customHeaders: authHeader()
161
+ });
162
+ const updateMyTenantSessionPolicy = (rules) => requestAuthApi({
163
+ method: "put",
164
+ endpoint: "/auth/session-policy",
165
+ data: { rules },
166
+ customHeaders: authHeader()
167
+ });
168
+ const tenantListUserSessions = (userId) => requestAuthApi({
169
+ method: "get",
170
+ endpoint: `/auth/users/${userId}/sessions`,
171
+ customHeaders: authHeader()
172
+ });
173
+ const tenantRevokeUserSession = (userId, sid) => requestAuthApi({
174
+ method: "delete",
175
+ endpoint: `/auth/users/${userId}/sessions/${sid}`,
176
+ customHeaders: authHeader()
177
+ });
178
+ const tenantForceLogoutUser = (userId) => requestAuthApi({
179
+ method: "post",
180
+ endpoint: `/auth/users/${userId}/logout-all`,
181
+ customHeaders: authHeader()
182
+ });
183
+ const tenantSessionTrace = (userId, { from, to } = {}) => {
184
+ const params = {};
185
+ if (from) params.from = from;
186
+ if (to) params.to = to;
187
+ return requestAuthApi({
188
+ method: "get",
189
+ endpoint: `/auth/users/${userId}/session-trace`,
190
+ params: Object.keys(params).length ? params : void 0,
191
+ customHeaders: authHeader()
192
+ });
193
+ };
194
+ const updateSessionLimits = (tenantId, limits) => requestAuthApi({
195
+ method: "put",
196
+ endpoint: "/auth/admin/session-limits",
197
+ data: { tenant_id: tenantId, ...limits },
198
+ customHeaders: authHeader()
199
+ });
200
+ const forceLogoutTenant = (tenantId) => requestAuthApi({
201
+ method: "post",
202
+ endpoint: `/auth/admin/tenants/${tenantId}/logout-all`,
203
+ customHeaders: authHeader()
204
+ });
205
+ const logoutSession = () => {
206
+ const user = getUser();
207
+ const token = user?.token;
208
+ if (!token) return Promise.resolve();
209
+ if (!user.refresh_token) {
210
+ return requestApi({
211
+ method: "get",
212
+ endpoint: LEGACY_LOGOUT_ENDPOINT,
213
+ customHeaders: { Authorization: token }
214
+ });
215
+ }
216
+ return requestAuthApi({
217
+ method: "post",
218
+ endpoint: LOGOUT_ENDPOINT,
219
+ data: { refresh_token: user.refresh_token },
220
+ customHeaders: { Authorization: `Bearer ${token}` }
221
+ });
222
+ };
223
+ export {
224
+ DEFAULT_SDK_TTL_SECONDS,
225
+ adminSessionTrace,
226
+ forceLogoutTenant,
227
+ forceLogoutUser,
228
+ getMyTenantSessionPolicy,
229
+ getOnlineCounts,
230
+ getOnlineUserList,
231
+ getSessionPolicy,
232
+ getSessionTimeline,
233
+ getSuperAdmins,
234
+ listMySessions,
235
+ listUserSessions,
236
+ login,
237
+ logoutSession,
238
+ revokeMySession,
239
+ revokeUserSession,
240
+ signInWithApiKey,
241
+ tenantForceLogoutUser,
242
+ tenantListUserSessions,
243
+ tenantRevokeUserSession,
244
+ tenantSessionTrace,
245
+ updateCurrentSessionAppVersion,
246
+ updateMyTenantSessionPolicy,
247
+ updateSessionLimits,
248
+ updateSessionPolicy
249
+ };
@@ -0,0 +1,10 @@
1
+ import { requestHubApi } from "../../utils/request.js";
2
+ function getAssignTaskPolicy({ id }) {
3
+ return requestHubApi({
4
+ method: "get",
5
+ endpoint: `/api/v3/assignment-policies/${id}`
6
+ });
7
+ }
8
+ export {
9
+ getAssignTaskPolicy
10
+ };
@@ -0,0 +1,136 @@
1
+ import { requestApi, requestZaloApi } from "../../utils/request.js";
2
+ import { env } from "../../config/env.js";
3
+ const getPages = ({ params }) => requestApi({
4
+ method: "get",
5
+ endpoint: `/v2/social/pages`,
6
+ params
7
+ });
8
+ const getPageDetail = (pageId) => requestApi({
9
+ method: "get",
10
+ endpoint: `/v2/social/pages/${pageId}`
11
+ });
12
+ function getEmail({ params }) {
13
+ return requestApi({
14
+ method: "get",
15
+ endpoint: "/v2/email/accounts",
16
+ params
17
+ });
18
+ }
19
+ function getZNS({ params }) {
20
+ return requestApi({
21
+ method: "get",
22
+ endpoint: "/v2/zalo/zns/templates",
23
+ params
24
+ });
25
+ }
26
+ function getSMS({ params }) {
27
+ return requestApi({
28
+ method: "get",
29
+ endpoint: "/v2/sms",
30
+ params
31
+ });
32
+ }
33
+ function getZaloLoginQr(id, type) {
34
+ return requestZaloApi({
35
+ method: "get",
36
+ endpoint: type === "general" ? "/zalo-general/gen-qr-login" : "/gen-qr-login",
37
+ params: {
38
+ id,
39
+ type
40
+ }
41
+ });
42
+ }
43
+ function addFriendZalo({
44
+ user_id,
45
+ phone,
46
+ first_message,
47
+ old_ticket_id,
48
+ customer_id,
49
+ zalo_user_id,
50
+ page_id
51
+ }) {
52
+ return requestZaloApi({
53
+ method: "post",
54
+ endpoint: `/send-friend-request/${user_id}`,
55
+ data: {
56
+ phone,
57
+ first_message,
58
+ old_ticket_id,
59
+ customer_id,
60
+ zalo_user_id,
61
+ source_id: page_id
62
+ }
63
+ });
64
+ }
65
+ function sendMessageZalo({
66
+ user_id,
67
+ phone,
68
+ first_message,
69
+ old_ticket_id,
70
+ page_id,
71
+ user_zalo_id,
72
+ is_group
73
+ }) {
74
+ return requestZaloApi({
75
+ method: "post",
76
+ endpoint: `/send-message`,
77
+ data: {
78
+ phone,
79
+ first_message,
80
+ old_ticket_id,
81
+ source_id: page_id,
82
+ user_zalo_id,
83
+ is_group
84
+ }
85
+ });
86
+ }
87
+ function findUserZalo({ user_id, phone, zalo_customer_id, page_id }) {
88
+ return requestZaloApi({
89
+ method: "post",
90
+ endpoint: `/find-user/${user_id}`,
91
+ data: {
92
+ phone,
93
+ zalo_customer_id,
94
+ source_id: page_id
95
+ }
96
+ });
97
+ }
98
+ function getZaloLoginStatus(sessionId, type, options = {}) {
99
+ return requestZaloApi({
100
+ method: "get",
101
+ endpoint: type === "general" ? `/zalo-general/get-login-status/${sessionId}` : `/get-login-status/${sessionId}`,
102
+ ...options
103
+ });
104
+ }
105
+ const hubOttUrl = () => `${env.HUB_URL || "https://apihub.zenify.vn"}/api/v3`;
106
+ function getZalosAllocated({
107
+ user_id,
108
+ agent_id,
109
+ tenant_id,
110
+ page_id,
111
+ customer_id
112
+ }) {
113
+ return requestZaloApi({
114
+ method: "post",
115
+ endpoint: `/get-zalos-allocated/${user_id}`,
116
+ data: {
117
+ agent_id,
118
+ tenant_id,
119
+ page_id,
120
+ customer_id
121
+ }
122
+ });
123
+ }
124
+ export {
125
+ addFriendZalo,
126
+ findUserZalo,
127
+ getEmail,
128
+ getPageDetail,
129
+ getPages,
130
+ getSMS,
131
+ getZNS,
132
+ getZaloLoginQr,
133
+ getZaloLoginStatus,
134
+ getZalosAllocated,
135
+ sendMessageZalo
136
+ };
@@ -0,0 +1,37 @@
1
+ import { requestApi } from "../../utils/request.js";
2
+ const getChatLayouts = (params) => requestApi({
3
+ method: "get",
4
+ endpoint: "/v2/chat-layouts/filter",
5
+ params
6
+ });
7
+ const getChatConfigs = (workspaceId) => requestApi({
8
+ method: "get",
9
+ endpoint: "/v2/chat-configs",
10
+ params: { workspace_id: workspaceId }
11
+ });
12
+ const getChatLayout = (id) => requestApi({
13
+ method: "get",
14
+ endpoint: `/v2/chat-layouts/${id}`
15
+ });
16
+ const createChatLayout = (data) => requestApi({
17
+ method: "post",
18
+ endpoint: "/v2/chat-layouts",
19
+ data
20
+ });
21
+ const updateChatLayout = (id, data) => requestApi({
22
+ method: "put",
23
+ endpoint: `/v2/chat-layouts/${id}`,
24
+ data
25
+ });
26
+ const deleteChatLayout = (id) => requestApi({
27
+ method: "delete",
28
+ endpoint: `/v2/chat-layouts/${id}`
29
+ });
30
+ export {
31
+ createChatLayout,
32
+ deleteChatLayout,
33
+ getChatConfigs,
34
+ getChatLayout,
35
+ getChatLayouts,
36
+ updateChatLayout
37
+ };
@@ -0,0 +1,10 @@
1
+ import { requestHubApi } from "../../utils/request.js";
2
+ function getChatTimeoutConfig({ channelType }) {
3
+ return requestHubApi({
4
+ method: "get",
5
+ endpoint: `/api/v3/chat-timeout/${channelType}`
6
+ }).then(({ data }) => data);
7
+ }
8
+ export {
9
+ getChatTimeoutConfig
10
+ };
@@ -0,0 +1,32 @@
1
+ import { requestApi } from "../../utils/request.js";
2
+ const getSettingCommon = ({ params }) => requestApi({
3
+ method: "get",
4
+ endpoint: `/v2/setting-common`,
5
+ params
6
+ });
7
+ const getSettingDashboard = ({ params }) => requestApi({
8
+ method: "get",
9
+ endpoint: "/v2/setting-dashboard"
10
+ });
11
+ const settingUserConfig = ({ data }) => requestApi({
12
+ method: "post",
13
+ endpoint: `/v2/setting-user-config`,
14
+ data
15
+ });
16
+ const getSettingUserConfig = () => requestApi({
17
+ method: "get",
18
+ endpoint: `/v2/setting-user-config`
19
+ });
20
+ const searchGlobal = ({ params, data }) => requestApi({
21
+ method: "post",
22
+ endpoint: `/v2/global-search`,
23
+ params,
24
+ data
25
+ });
26
+ export {
27
+ getSettingCommon,
28
+ getSettingDashboard,
29
+ getSettingUserConfig,
30
+ searchGlobal,
31
+ settingUserConfig
32
+ };
@@ -0,0 +1,19 @@
1
+ import { requestApi } from "../../utils/request.js";
2
+ const getConfigs = (params) => {
3
+ return requestApi({
4
+ method: "get",
5
+ endpoint: "/v2/settings/configs",
6
+ params
7
+ });
8
+ };
9
+ const createOrUpdateConfig = (data) => {
10
+ return requestApi({
11
+ method: "put",
12
+ endpoint: "/v2/settings/config",
13
+ data
14
+ });
15
+ };
16
+ export {
17
+ createOrUpdateConfig,
18
+ getConfigs
19
+ };
@@ -0,0 +1,24 @@
1
+ import * as assignTask from "./assign-task.js";
2
+ import * as channel from "./channel.js";
3
+ import * as chatLayout from "./chat-layout.js";
4
+ import * as chatTimeout from "./chat-timeout.js";
5
+ import * as common from "./common.js";
6
+ import * as config from "./config.js";
7
+ import * as ivr from "./ivr.js";
8
+ import * as queueV3 from "./queue-v3.js";
9
+ import * as queue from "./queue.js";
10
+ import * as routing from "./routing.js";
11
+ import * as service from "./service.js";
12
+ export {
13
+ assignTask,
14
+ channel,
15
+ chatLayout,
16
+ chatTimeout,
17
+ common,
18
+ config,
19
+ ivr,
20
+ queue,
21
+ queueV3,
22
+ routing,
23
+ service
24
+ };
@@ -0,0 +1,25 @@
1
+ import { requestApi } from "../../utils/request.js";
2
+ function getState(cpId) {
3
+ return requestApi({
4
+ method: "get",
5
+ endpoint: "/v2/ivr-config/states/" + cpId
6
+ });
7
+ }
8
+ function getStateTypes() {
9
+ return requestApi({
10
+ method: "get",
11
+ endpoint: "/v2/ivr-config/state-types"
12
+ });
13
+ }
14
+ function getAudio(params) {
15
+ return requestApi({
16
+ method: "get",
17
+ endpoint: "/v2/ivr/audio",
18
+ params
19
+ });
20
+ }
21
+ export {
22
+ getAudio,
23
+ getState,
24
+ getStateTypes
25
+ };
@@ -0,0 +1,56 @@
1
+ import { requestHubApi } from "../../utils/request.js";
2
+ function getQueue({ params }) {
3
+ return requestHubApi({
4
+ method: "get",
5
+ endpoint: "/api/v3/queues/filter",
6
+ params
7
+ }).then(({ data }) => data);
8
+ }
9
+ function getQueueDetail({ id }) {
10
+ return requestHubApi({
11
+ method: "get",
12
+ endpoint: `/api/v3/queues/${id}`
13
+ }).then(({ data }) => data);
14
+ }
15
+ function createQueue({ data }) {
16
+ return requestHubApi({
17
+ method: "post",
18
+ endpoint: "/api/v3/queues",
19
+ data
20
+ }).then(({ data: data2 }) => data2);
21
+ }
22
+ function editQueue({ id, data }) {
23
+ return requestHubApi({
24
+ method: "put",
25
+ endpoint: `/api/v3/queues/${id}`,
26
+ data
27
+ }).then(({ data: data2 }) => data2);
28
+ }
29
+ function deleteQueue({ id }) {
30
+ return requestHubApi({
31
+ method: "delete",
32
+ endpoint: `/api/v3/queues/${id}`
33
+ }).then(({ data }) => data);
34
+ }
35
+ function getParamsInQueue({ id }) {
36
+ return requestHubApi({
37
+ method: "get",
38
+ endpoint: `/api/v3/queue-params/by-queue/${id}`
39
+ });
40
+ }
41
+ function getUsersInQueues({ queueIds }) {
42
+ return requestHubApi({
43
+ method: "get",
44
+ endpoint: "/api/v3/queues/users-in-queues",
45
+ params: { queue_ids: queueIds.join(",") }
46
+ });
47
+ }
48
+ export {
49
+ createQueue,
50
+ deleteQueue,
51
+ editQueue,
52
+ getParamsInQueue,
53
+ getQueue,
54
+ getQueueDetail,
55
+ getUsersInQueues
56
+ };
@@ -0,0 +1,48 @@
1
+ import { requestApi } from "../../utils/request.js";
2
+ function getQueue({ params }) {
3
+ return requestApi({
4
+ method: "get",
5
+ endpoint: "/v2/queues",
6
+ params
7
+ });
8
+ }
9
+ function createQueue({ data }) {
10
+ return requestApi({
11
+ method: "post",
12
+ endpoint: "/v2/queue",
13
+ data
14
+ });
15
+ }
16
+ function editQueue({ id, data }) {
17
+ return requestApi({
18
+ method: "put",
19
+ endpoint: `/v2/queue/${id}`,
20
+ data
21
+ });
22
+ }
23
+ function deleteQueue({ id }) {
24
+ return requestApi({
25
+ method: "delete",
26
+ endpoint: `/v2/queue/${id}`
27
+ });
28
+ }
29
+ function getAgentInQueue({ id }) {
30
+ return requestApi({
31
+ method: "get",
32
+ endpoint: `/v2/agent-in-queue/${id}`
33
+ });
34
+ }
35
+ function getParamsInQueue({ id }) {
36
+ return requestApi({
37
+ method: "get",
38
+ endpoint: `/v2/all-param?queue_id=${id}`
39
+ });
40
+ }
41
+ export {
42
+ createQueue,
43
+ deleteQueue,
44
+ editQueue,
45
+ getAgentInQueue,
46
+ getParamsInQueue,
47
+ getQueue
48
+ };
@@ -0,0 +1,32 @@
1
+ import { requestHubApi } from "../../utils/request.js";
2
+ function getTenantConfigs({ keys }) {
3
+ return requestHubApi({
4
+ method: "get",
5
+ endpoint: "/api/v3/tenant-configs",
6
+ params: { keys, type: "CONFIG" }
7
+ }).then(({ data }) => data);
8
+ }
9
+ function updateTenantConfig(configs) {
10
+ return requestHubApi({
11
+ method: "put",
12
+ endpoint: "/api/v3/tenant-configs",
13
+ data: {
14
+ items: configs.map(({ key, rules }) => ({
15
+ key,
16
+ type: "CONFIG",
17
+ rules
18
+ }))
19
+ }
20
+ }).then(({ data }) => data);
21
+ }
22
+ async function getRoutingRuleDetail({ id }) {
23
+ return requestHubApi({
24
+ method: "get",
25
+ endpoint: `/api/v3/routing-rules/${id}`
26
+ }).then(({ data }) => data);
27
+ }
28
+ export {
29
+ getRoutingRuleDetail,
30
+ getTenantConfigs,
31
+ updateTenantConfig
32
+ };