@phonghq/go-chat 1.0.44 → 1.0.46

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 (74) hide show
  1. package/dist/components/common/select/SelectBase.vue.d.ts +27 -1
  2. package/dist/components/ui/select/SelectItem.vue.d.ts +2 -2
  3. package/dist/composable/useListConversations.d.ts +1 -1
  4. package/dist/composable/useListentEvent.d.ts +2 -2
  5. package/dist/go-chat.es.js +6769 -6752
  6. package/dist/go-chat.umd.js +15 -15
  7. package/dist/plugins/sdk.d.ts +1 -2
  8. package/dist/style.css +1 -1
  9. package/dist/test/chat/App.vue.js +26 -58
  10. package/dist/test/chat/page/customer-appointment/CustomerAppointment.vue.js +1 -1
  11. package/dist/test/chat/page/customer-check-in/CustomerCheckIn.vue.js +1 -1
  12. package/dist/test/chat/page/customer-detail/CustomerDetail.vue.js +1 -1
  13. package/dist/test/chat/page/error/Error.vue.js +1 -1
  14. package/dist/test/chat/page/home/ChatList.vue.js +17 -15
  15. package/dist/test/chat/page/home/ChatMessage.vue.js +1 -1
  16. package/dist/test/chat/page/home/ChatMessageItem.vue.js +7 -5
  17. package/dist/test/chat/page/home/ChatMessageItem2.vue.js +1 -1
  18. package/dist/test/chat/page/home/Home.vue.js +2 -2
  19. package/dist/test/chat/page/home/HomeHeader.vue.js +6 -6
  20. package/dist/test/chat/page/home/InputChat.vue.js +3 -6
  21. package/dist/test/chat/page/setting/Setting.vue.js +1 -1
  22. package/dist/test/components/chat/ScrollEvent/ScrollEvent.vue.js +2 -0
  23. package/dist/test/components/chat/call/Calling.vue.js +4 -17
  24. package/dist/test/components/chat/common/input/InputSearch.vue.js +1 -1
  25. package/dist/test/components/chat/common/modal/Modal.vue.js +1 -1
  26. package/dist/test/components/chat/customer/Avatar.vue.js +1 -1
  27. package/dist/test/components/common/modal/ModalBase.vue.js +1 -1
  28. package/dist/test/components/common/select/SelectBase.vue.js +69 -106
  29. package/dist/test/components/ui/select/SelectContent.vue.js +2 -2
  30. package/dist/test/components/ui/select/SelectItem.vue.js +9 -22
  31. package/dist/test/components/ui/select/SelectTrigger.vue.js +3 -30
  32. package/dist/test/composable/useInitData.js +2 -2
  33. package/dist/test/composable/useListConversations.js +5 -5
  34. package/dist/test/composable/useListentEvent.js +8 -2
  35. package/dist/test/composable/usePlivo.js +2 -5
  36. package/dist/test/plugins/axios.js +0 -2
  37. package/dist/test/plugins/mqtt.js +12 -4
  38. package/dist/test/plugins/pocketbase.js +1 -2
  39. package/dist/test/plugins/sdk.js +2 -12
  40. package/dist/test/plugins/websocket.js +1 -1
  41. package/dist/test/utils/chat/cache.js +1 -1
  42. package/dist/test/utils/chat/{auth.js → store/auth.js} +14 -5
  43. package/dist/test/utils/chat/{call.js → store/call.js} +3 -3
  44. package/dist/test/utils/chat/{conversation.js → store/conversation.js} +6 -6
  45. package/dist/test/utils/chat/{message.js → store/message.js} +1 -1
  46. package/dist/test/utils/chat/{user.js → store/user.js} +2 -2
  47. package/dist/types/chat/auth.d.ts +1 -0
  48. package/dist/utils/chat/{auth.d.ts → store/auth.d.ts} +4 -1
  49. package/dist/utils/chat/{call.d.ts → store/call.d.ts} +1 -1
  50. package/dist/utils/chat/{conversation.d.ts → store/conversation.d.ts} +3 -3
  51. package/dist/utils/chat/{message.d.ts → store/message.d.ts} +2 -2
  52. package/dist/utils/chat/{user.d.ts → store/user.d.ts} +2 -2
  53. package/package.json +1 -1
  54. package/dist/composable/useCallHelper.d.ts +0 -48
  55. package/dist/test/composable/data.json +0 -32
  56. package/dist/test/composable/useCallHelper.js +0 -339
  57. /package/dist/assets/icons/{IconAiCheck.vue.d.ts → global/IconAiCheck.vue.d.ts} +0 -0
  58. /package/dist/assets/icons/{IconArrowLeft.vue.d.ts → global/IconArrowLeft.vue.d.ts} +0 -0
  59. /package/dist/assets/icons/{IconCloseCircle.vue.d.ts → global/IconCloseCircle.vue.d.ts} +0 -0
  60. /package/dist/assets/icons/{IconPhone.vue.d.ts → global/IconPhone.vue.d.ts} +0 -0
  61. /package/dist/assets/icons/{IconPlan.vue.d.ts → global/IconPlan.vue.d.ts} +0 -0
  62. /package/dist/assets/icons/{IconPlus.vue.d.ts → global/IconPlus.vue.d.ts} +0 -0
  63. /package/dist/assets/icons/{IconSearch.vue.d.ts → global/IconSearch.vue.d.ts} +0 -0
  64. /package/dist/assets/icons/{IconSms.vue.d.ts → global/IconSms.vue.d.ts} +0 -0
  65. /package/dist/assets/icons/{IconUser.vue.d.ts → global/IconUser.vue.d.ts} +0 -0
  66. /package/dist/test/assets/icons/{IconAiCheck.vue.js → global/IconAiCheck.vue.js} +0 -0
  67. /package/dist/test/assets/icons/{IconArrowLeft.vue.js → global/IconArrowLeft.vue.js} +0 -0
  68. /package/dist/test/assets/icons/{IconCloseCircle.vue.js → global/IconCloseCircle.vue.js} +0 -0
  69. /package/dist/test/assets/icons/{IconPhone.vue.js → global/IconPhone.vue.js} +0 -0
  70. /package/dist/test/assets/icons/{IconPlan.vue.js → global/IconPlan.vue.js} +0 -0
  71. /package/dist/test/assets/icons/{IconPlus.vue.js → global/IconPlus.vue.js} +0 -0
  72. /package/dist/test/assets/icons/{IconSearch.vue.js → global/IconSearch.vue.js} +0 -0
  73. /package/dist/test/assets/icons/{IconSms.vue.js → global/IconSms.vue.js} +0 -0
  74. /package/dist/test/assets/icons/{IconUser.vue.js → global/IconUser.vue.js} +0 -0
@@ -2,6 +2,7 @@ import mqtt from 'mqtt/dist/mqtt.min';
2
2
  const mqttOptions = { qos: 1, retain: false };
3
3
  // const mqttClient = ref<MqttClient | null>(null)
4
4
  let mqttClient = null;
5
+ let _isConnected = false;
5
6
  const subscribedTopics = new Set();
6
7
  let dataCallBack = [];
7
8
  let reconnectCount = 0;
@@ -9,7 +10,7 @@ const MAX_RECONNECT = 5;
9
10
  export const connectMqtt = () => {
10
11
  return new Promise((resolve, reject) => {
11
12
  reconnectCount = 0;
12
- if (mqttClient && mqttClient?.connected) {
13
+ if (mqttClient && _isConnected) {
13
14
  return resolve();
14
15
  }
15
16
  const userInfo = JSON.parse(localStorage.getItem('user') || '{}');
@@ -29,6 +30,7 @@ export const connectMqtt = () => {
29
30
  const connectUrl = `wss://${host}:${port}${path}`;
30
31
  mqttClient = mqtt.connect(connectUrl, options);
31
32
  mqttClient?.on('connect', () => {
33
+ _isConnected = true;
32
34
  subscribedTopics.forEach((topic) => mqttClient?.subscribe(topic));
33
35
  mqttClient?.on('message', (topic, message) => {
34
36
  try {
@@ -57,9 +59,15 @@ export const connectMqtt = () => {
57
59
  resolve();
58
60
  }
59
61
  });
62
+ mqttClient?.on('offline', () => {
63
+ _isConnected = false;
64
+ });
60
65
  mqttClient?.on('close', () => {
66
+ _isConnected = false;
61
67
  });
62
68
  mqttClient?.on('error', (err) => {
69
+ console.log('error', err);
70
+ _isConnected = false;
63
71
  reject(err);
64
72
  });
65
73
  });
@@ -75,7 +83,7 @@ export const subscribeToTopic = (topic) => {
75
83
  if (subscribedTopics.has(topic)) {
76
84
  return;
77
85
  }
78
- if (mqttClient?.connected || true) {
86
+ if (_isConnected) {
79
87
  mqttClient?.subscribe(topic, mqttOptions, (err) => {
80
88
  if (!err) {
81
89
  subscribedTopics.add(topic);
@@ -88,7 +96,7 @@ export const subscribeToTopic = (topic) => {
88
96
  }
89
97
  };
90
98
  export const unsubscribeFromTopic = (topic) => {
91
- if (mqttClient?.connected || true) {
99
+ if (_isConnected) {
92
100
  mqttClient?.unsubscribe(topic, (err) => {
93
101
  if (!err) {
94
102
  subscribedTopics.delete(topic);
@@ -104,7 +112,7 @@ export const unsubscribeFromTopic = (topic) => {
104
112
  }
105
113
  };
106
114
  export const publishMessage = (topic, payload) => {
107
- if (mqttClient?.connected && payload) {
115
+ if (_isConnected && payload) {
108
116
  const message = typeof payload !== 'string' ? JSON.stringify(payload) : payload;
109
117
  mqttClient?.publish(topic, message, { qos: 1, retain: false }, (err) => {
110
118
  if (!err) {
@@ -1,12 +1,11 @@
1
1
  import PocketBase from 'pocketbase';
2
- // const instance = new PocketBase("https://gap-calendar-data.srv01.dtsmart.dev");
3
2
  const instance = new PocketBase("https://gap-calendar-log.gci-app.dtsmart.dev/");
4
3
  export const createBusinessTenantPhone = async (data) => {
5
4
  await instance.collection('go_chat_service').create(data);
6
5
  };
7
6
  export const checkHasBusinessTenantPhone = async (id) => {
8
7
  try {
9
- const res = await instance.collection('go_chat_service').getFirstListItem(`tenant_id="${id}"`);
8
+ await instance.collection('go_chat_service').getFirstListItem(`tenant_id="${id}"`);
10
9
  return true;
11
10
  }
12
11
  catch (e) {
@@ -1,19 +1,9 @@
1
- import Gap, { GapApiVersion } from 'gap-nodejs-sdk';
2
1
  import { GapMiniAppSdk } from 'gap-miniapp-sdk';
3
2
  import logger from '../utils/logger';
4
- import { loginTenant, setDataLogin } from '../utils/chat/auth';
3
+ import { loginTenant, setDataLogin } from '../utils/chat/store/auth';
5
4
  import { setAxiosGciInstance } from '../plugins/axios-gci';
6
- const baseSdk = new Gap.BaseApi(GapApiVersion.V1);
7
5
  const gapMiniAppSdk = (function () {
8
6
  let instance;
9
- // let domain = '';
10
- // let gClient = '';
11
- // let token = '';
12
- // if (process.env.NODE_ENV === "development") {
13
- // domain = import.meta.env.VITE_DOMAIN;
14
- // gClient = import.meta.env.VITE_GCLIENT_ID;
15
- // token = import.meta.env.VITE_TOKEN;
16
- // }
17
7
  function createInstance() {
18
8
  return new GapMiniAppSdk(logger);
19
9
  }
@@ -80,4 +70,4 @@ const sdkInit = (data) => {
80
70
  }
81
71
  });
82
72
  };
83
- export { sdkInit, gapMiniAppSdk, baseSdk };
73
+ export { sdkInit, gapMiniAppSdk };
@@ -1,5 +1,5 @@
1
1
  import { tryParseJson } from '../utils/json';
2
- import { dataProfile } from '../utils/chat/auth';
2
+ import { dataProfile } from '../utils/chat/store/auth';
3
3
  let socket = null;
4
4
  let dataCallBack = [];
5
5
  let callId = '';
@@ -1,4 +1,4 @@
1
- import { dataProfile } from '../../utils/chat/auth';
1
+ import { dataProfile } from './store/auth';
2
2
  export function setCache(key, data, ttlMs = 1000) {
3
3
  if (!dataProfile.value?.id)
4
4
  return;
@@ -1,6 +1,7 @@
1
- import axios from '../../plugins/axios';
2
- import { gapMiniAppSdk } from '../../plugins/sdk';
1
+ import axios from '../../../plugins/axios';
2
+ import { gapMiniAppSdk } from '../../../plugins/sdk';
3
3
  import { ref } from 'vue';
4
+ import axios_gci from '../../../plugins/axios-gci';
4
5
  export const dataProfile = ref(null);
5
6
  export const dataLoginLink = ref(null);
6
7
  let dataLogin = {
@@ -41,13 +42,14 @@ export const getProfile = async () => {
41
42
  export const checkTenantPhoneOnGapInsight = async () => {
42
43
  const id = localStorage.getItem('chat_id');
43
44
  const res = await axios.get(`/api/v1/message/tenant/get-info?tenant_name=${id}`);
44
- if (res.error || !res?.data)
45
+ if (res?.error || !res?.data)
45
46
  throw new Error(res.error);
46
47
  if (dataProfile.value)
47
48
  dataProfile.value.tenant_phone = res?.data?.go_chat_phone ?? '';
48
- // if(dataProfile.value) dataProfile.value.tenant_phone = ''
49
49
  if (dataProfile.value)
50
50
  dataProfile.value.tenant_phone_limit = Number(res?.data?.go_chat_phone_limit ?? 0);
51
+ if (dataProfile.value)
52
+ dataProfile.value.tenant_phone_forwarding = res?.data?.go_chat_phone_forwarding ?? '';
51
53
  if (dataProfile.value?.phone != dataProfile.value?.tenant_phone &&
52
54
  dataProfile.value?.tenant_phone) {
53
55
  updateProfile({ phone: dataProfile.value?.tenant_phone });
@@ -60,11 +62,18 @@ export const submitTenantPhone = async (body) => {
60
62
  return res;
61
63
  };
62
64
  export const updateProfile = async (body) => {
63
- const res = await axios.post('/api/v1/message/tenant/update', { ...body, id: dataProfile.value?.id });
65
+ const res = await axios.post('/api/v1/message/tenant/update', {
66
+ ...body,
67
+ id: dataProfile.value?.id
68
+ });
64
69
  console.log(res);
65
70
  dataProfile.value = res;
66
71
  return res;
67
72
  };
73
+ export const getBusinessInfo = async () => {
74
+ const res = await axios_gci.get('/v1/pos/business/site/get-info');
75
+ return res;
76
+ };
68
77
  export const logout = async () => {
69
78
  dataLogin = { id: '', token: '', domain: '' };
70
79
  dataProfile.value = null;
@@ -1,6 +1,6 @@
1
- import axios from '../../plugins/axios';
2
- import { dataProfile } from '../../utils/chat/auth';
3
- import { showPageError } from '../../utils/chat/page-error';
1
+ import axios from '../../../plugins/axios';
2
+ import { dataProfile } from './auth';
3
+ import { showPageError } from '../page-error';
4
4
  const BARE_WEBSOCKET_URL = 'https://web-socket.dev01.dtsmart.dev';
5
5
  // const BARE_WEBSOCKET_URL = 'https://web-socket-test.dev01.dtsmart.dev'
6
6
  // const BARE_WEBSOCKET_URL = 'http://192.168.1.173:3000'
@@ -1,10 +1,10 @@
1
- import axios from '../../plugins/axios';
2
- import { getCountUnread } from '../../utils/chat/message';
1
+ import axios from '../../../plugins/axios';
2
+ import { getCountUnread } from './message';
3
3
  import dayjs from 'dayjs';
4
- import { DATE_FORMATS, TIME_ZONE_UTC } from '../../constant/datetime';
5
- import { dataProfile } from '../../utils/chat/auth';
6
- import { publishMessage } from '../../plugins/mqtt';
7
- import { TOPIC_HOME } from '../../constant/mqtt';
4
+ import { DATE_FORMATS, TIME_ZONE_UTC } from '../../../constant/datetime';
5
+ import { dataProfile } from './auth';
6
+ import { publishMessage } from '../../../plugins/mqtt';
7
+ import { TOPIC_HOME } from '../../../constant/mqtt';
8
8
  export const getConversation = async (param) => {
9
9
  const res = await axios.get('/api/v1/message/conversation/get-conversation', {
10
10
  params: param
@@ -1,4 +1,4 @@
1
- import axios from '../../plugins/axios';
1
+ import axios from '../../../plugins/axios';
2
2
  export const getMessage = async (params) => {
3
3
  const res = await axios.get('/api/v1/message/message/get-message', {
4
4
  params
@@ -1,6 +1,6 @@
1
1
  import { ref } from 'vue';
2
- import axios_gci from '../../plugins/axios-gci';
3
- import axios from '../../plugins/axios';
2
+ import axios_gci from '../../../plugins/axios-gci';
3
+ import axios from '../../../plugins/axios';
4
4
  import dayjs from 'dayjs';
5
5
  export const user = ref(null);
6
6
  export const userHistory = ref(null);
@@ -22,6 +22,7 @@ interface IResProfile {
22
22
  phone: string;
23
23
  tenant_phone: string;
24
24
  tenant_phone_limit: number;
25
+ tenant_phone_forwarding: string;
25
26
  avatar: string | null;
26
27
  user_type: 'customer' | 'tenant';
27
28
  has_business_tenant_phone?: boolean;
@@ -1,4 +1,4 @@
1
- import type { IResLoginLink, IResProfile } from '../../types/chat/auth';
1
+ import type { IResLoginLink, IResProfile } from '../../../types/chat/auth';
2
2
  interface IBodyLoginTenant {
3
3
  tenant_id: string;
4
4
  }
@@ -16,6 +16,7 @@ export declare const dataProfile: import("vue").Ref<{
16
16
  phone: string;
17
17
  tenant_phone: string;
18
18
  tenant_phone_limit: number;
19
+ tenant_phone_forwarding: string;
19
20
  avatar: string | null;
20
21
  user_type: "customer" | "tenant";
21
22
  has_business_tenant_phone?: boolean | undefined;
@@ -28,6 +29,7 @@ export declare const dataProfile: import("vue").Ref<{
28
29
  phone: string;
29
30
  tenant_phone: string;
30
31
  tenant_phone_limit: number;
32
+ tenant_phone_forwarding: string;
31
33
  avatar: string | null;
32
34
  user_type: "customer" | "tenant";
33
35
  has_business_tenant_phone?: boolean | undefined;
@@ -57,5 +59,6 @@ export declare const submitTenantPhone: (body: {
57
59
  export declare const updateProfile: (body: {
58
60
  phone: string;
59
61
  }) => Promise<any>;
62
+ export declare const getBusinessInfo: () => Promise<any>;
60
63
  export declare const logout: () => Promise<void>;
61
64
  export {};
@@ -1,4 +1,4 @@
1
- import type { IResUser } from '../../types/message';
1
+ import type { IResUser } from '../../../types/message';
2
2
  export declare const getIceService: () => Promise<import("axios").AxiosResponse<any, any>>;
3
3
  export declare const callClient: (data: {
4
4
  call_uuid: string;
@@ -1,6 +1,6 @@
1
- import type { IConversation, IParamGetConversation } from '../../types/conversation';
2
- import type { DataWithMetaResponse } from '../../types/global';
3
- import type { IResUser } from '../../types/message';
1
+ import type { IConversation, IParamGetConversation } from '../../../types/conversation';
2
+ import type { DataWithMetaResponse } from '../../../types/global';
3
+ import type { IResUser } from '../../../types/message';
4
4
  export declare const getConversation: (param: IParamGetConversation) => Promise<DataWithMetaResponse<IConversation[]>>;
5
5
  export declare const getConversationView: (id: any) => Promise<IConversation>;
6
6
  export declare const publicTopicConversationUpdate: (data: {
@@ -1,5 +1,5 @@
1
- import type { DataWithMetaResponse } from '../../types/global';
2
- import type { IResMessage, IResUser, IUploadFile } from '../../types/message';
1
+ import type { DataWithMetaResponse } from '../../../types/global';
2
+ import type { IResMessage, IResUser, IUploadFile } from '../../../types/message';
3
3
  interface IParamsMessage {
4
4
  page: number;
5
5
  receiver_id: string;
@@ -1,5 +1,5 @@
1
- import type { IResUser } from '../../types/message';
2
- import type { GetCustomerHistoryResponse } from '../../types/chat/user';
1
+ import type { IResUser } from '../../../types/message';
2
+ import type { GetCustomerHistoryResponse } from '../../../types/chat/user';
3
3
  export declare const user: import("vue").Ref<{
4
4
  id: string;
5
5
  username: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phonghq/go-chat",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"
@@ -1,48 +0,0 @@
1
- import type { IResUser } from '../types/message';
2
- type Offer = {
3
- link: string;
4
- offer: any;
5
- user: any;
6
- server: any;
7
- };
8
- export declare function useCallHelper(): {
9
- call: (user: IResUser) => Promise<void>;
10
- end: () => Promise<void>;
11
- handleOfferResponse: (data: {
12
- link: string;
13
- answer: any;
14
- }) => Promise<void>;
15
- handleOffer: (data: Offer) => Promise<void>;
16
- sendOfferOk: () => Promise<void>;
17
- handleMedia: (message: any) => Promise<void>;
18
- userRemoter: import("vue").Ref<{
19
- id: string;
20
- username: string;
21
- phone: string;
22
- avatar: string | null;
23
- tenant_id: string | null;
24
- conversation_id: number;
25
- color: string;
26
- status: number;
27
- last_offline_at: string;
28
- is_unknown: number;
29
- } | null, IResUser | {
30
- id: string;
31
- username: string;
32
- phone: string;
33
- avatar: string | null;
34
- tenant_id: string | null;
35
- conversation_id: number;
36
- color: string;
37
- status: number;
38
- last_offline_at: string;
39
- is_unknown: number;
40
- } | null>;
41
- testPlay: () => void;
42
- handleCallAnswer: (data: any) => void;
43
- callAnswer: (uuid_request: string) => Promise<void>;
44
- startPeerConnection: () => Promise<void>;
45
- startIncomingCall: (uuid_request: string) => Promise<void>;
46
- uuid: import("vue").Ref<string, string>;
47
- };
48
- export {};
@@ -1,32 +0,0 @@
1
- [
2
- {
3
- "type": "audio_chunk",
4
- "size_bytes": 160,
5
- "hex_preview": "36 25 39 bb c0 41 48 bc c3 32 27 3f c7 f6 ee aa 9f ae b3 9e",
6
- "samples_count": 160
7
- },
8
- {
9
- "type": "audio_chunk",
10
- "size_bytes": 160,
11
- "hex_preview": "3f d9 ac b3 3d 3b b9 a8 ac b4 b3 ac af bc ae 9e 9b a5 ac a9",
12
- "samples_count": 160
13
- },
14
- {
15
- "type": "audio_chunk",
16
- "size_bytes": 160,
17
- "hex_preview": "b1 a3 b3 a9 a8 a8 ae a3 a7 a6 a6 a8 a7 ab a9 ad af ae aa a6 ab",
18
- "samples_count": 160
19
- },
20
- {
21
- "type": "audio_chunk",
22
- "size_bytes": 160,
23
- "hex_preview": "b3 b1 b2 b0 ae ae b0 b2 b3 b1 b1 b0 b0 af af ae ae ae ad ac ac",
24
- "samples_count": 160
25
- },
26
- {
27
- "type": "audio_chunk",
28
- "size_bytes": 160,
29
- "hex_preview": "ad ad ad ad ad ad ad ad ad ad ad ad ad ad ad ad ad ad ad ad ad",
30
- "samples_count": 160
31
- }
32
- ]