@medipha/chat-core 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +65 -62
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -63,6 +63,9 @@ export declare function updateConversation(conversationId: string, payload: {
|
|
|
63
63
|
/** Pins/unpins a conversation for the current user only — a personal sidebar preference. */
|
|
64
64
|
export declare function setConversationPinned(conversationId: string, pinned: boolean): Promise<unknown>;
|
|
65
65
|
export declare function deleteConversation(conversationId: string): Promise<unknown>;
|
|
66
|
+
/** "Deletes" the conversation for the current user only — every message up to now is
|
|
67
|
+
* hidden from their own view, everyone else's history is unaffected. */
|
|
68
|
+
export declare function clearConversation(conversationId: string): Promise<unknown>;
|
|
66
69
|
export declare function addConversationMember(conversationId: string, userId: string): Promise<unknown>;
|
|
67
70
|
/** Adds several users in one request, which the server records as a single "đã thêm" notice
|
|
68
71
|
* naming the first couple of them and counting the rest — one call per user would post one
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("socket.io-client");function t(e){return e.map(([e,t])=>`${n(e)}=${n(String(t))}`).join(`&`)}function n(e){return encodeURIComponent(e).replace(/[!'()~]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g,`+`)}var r=class extends Error{constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`ChatApiError`}},i={apiBaseUrl:``,getAccessToken:()=>null};function a(e){i=e}var o=e=>`${i.apiBaseUrl}${e.startsWith(`/`)?e:`/${e}`}`,s=e=>o(`/data/docs/${e}`),c=(e,t)=>e?/^https?:\/\//i.test(e)?e:o(e):t?s(t):null;async function l(e,t={}){let n=new Headers(t.headers),a=i.getAccessToken(),s=t.auth!==!1,c={...t};delete c.auth,t.body instanceof FormData||n.set(`Content-Type`,`application/json`),s&&a&&n.set(`Authorization`,`Bearer ${a}`);let l=await fetch(o(e),{...c,headers:n}),u=l.headers.get(`content-type`)?.includes(`application/json`)?await l.json():null;if(!l.ok){let e=u;throw new r(e?.message??`Request failed with status ${l.status}`,l.status,e?.code)}return u}function u(e){return l(`/users/${e}`)}function d(e={}){let n=[];e.cursor&&n.push([`cursor`,e.cursor]),e.limit&&n.push([`limit`,String(e.limit)]),e.search&&n.push([`search`,e.search]),e.departmentId&&n.push([`departmentId`,e.departmentId]),e.branchId&&n.push([`branchId`,e.branchId]),e.workStatus?.forEach(e=>n.push([`workStatus`,e]));let r=t(n);return l(r?`/users?${r}`:`/users`)}function f(){return l(`/users/branches`)}function p(e){return l(`/departments/by-branch/${e}`)}function m(){return l(`/conversations`,{method:`GET`,auth:!0})}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("socket.io-client");function t(e){return e.map(([e,t])=>`${n(e)}=${n(String(t))}`).join(`&`)}function n(e){return encodeURIComponent(e).replace(/[!'()~]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g,`+`)}var r=class extends Error{constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`ChatApiError`}},i={apiBaseUrl:``,getAccessToken:()=>null};function a(e){i=e}var o=e=>`${i.apiBaseUrl}${e.startsWith(`/`)?e:`/${e}`}`,s=e=>o(`/data/docs/${e}`),c=(e,t)=>e?/^https?:\/\//i.test(e)?e:o(e):t?s(t):null;async function l(e,t={}){let n=new Headers(t.headers),a=i.getAccessToken(),s=t.auth!==!1,c={...t};delete c.auth,t.body instanceof FormData||n.set(`Content-Type`,`application/json`),s&&a&&n.set(`Authorization`,`Bearer ${a}`);let l=await fetch(o(e),{...c,headers:n}),u=l.headers.get(`content-type`)?.includes(`application/json`)?await l.json():null;if(!l.ok){let e=u;throw new r(e?.message??`Request failed with status ${l.status}`,l.status,e?.code)}return u}function u(e){return l(`/users/${e}`)}function d(e={}){let n=[];e.cursor&&n.push([`cursor`,e.cursor]),e.limit&&n.push([`limit`,String(e.limit)]),e.search&&n.push([`search`,e.search]),e.departmentId&&n.push([`departmentId`,e.departmentId]),e.branchId&&n.push([`branchId`,e.branchId]),e.workStatus?.forEach(e=>n.push([`workStatus`,e]));let r=t(n);return l(r?`/users?${r}`:`/users`)}function f(){return l(`/users/branches`)}function p(e){return l(`/departments/by-branch/${e}`)}function m(){return l(`/conversations`,{method:`GET`,auth:!0})}function ee(e){return l(`/conversations/${e}`)}function h(e){return l(`/conversations`,{method:`POST`,body:JSON.stringify(e)})}function g(e,t){return l(`/conversations/${e}`,{method:`PATCH`,body:JSON.stringify(t)})}function _(e,t){return l(`/conversations/${e}/pin`,{method:`PATCH`,body:JSON.stringify({pinned:t})})}function v(e){return l(`/conversations/${e}`,{method:`DELETE`})}function y(e){return l(`/conversations/${e}/clear`,{method:`POST`})}function b(e,t){return l(`/conversations/${e}/members`,{method:`POST`,body:JSON.stringify({userId:t})})}function x(e,t){return l(`/conversations/${e}/members`,{method:`POST`,body:JSON.stringify({userIds:t})})}function te(e,t){return l(`/conversations/${e}/members`,{method:`DELETE`,body:JSON.stringify({userIds:t})})}function S(e,n={}){let r=[[`limit`,String(n.limit??30)]];return n.cursorPosition!==void 0&&n.cursorPosition!==null&&r.push([`cursorPosition`,String(n.cursorPosition)]),l(`/messages/${e}/system-members?${t(r)}`)}function C(e,n={}){let r=[[`limit`,String(n.limit??30)]];return n.cursor&&r.push([`cursor`,String(n.cursor)]),n.search?.trim()&&r.push([`search`,n.search.trim()]),l(`/conversations/${e}/members?${t(r)}`)}function w(e,t){return l(`/conversations/${e}/members/${t}`,{method:`DELETE`})}function T(e,t){return l(`/conversations/${e}/leave`,{method:`PATCH`,body:JSON.stringify({nextOwnerId:t})})}function E(e){return l(`/messages/conversation/${e}/latest`)}function D(e,t){return l(`/messages/conversation/${e}/${t}`,{method:`DELETE`})}function O(e,n={}){let r=[],i=n.beforeSequence!==void 0&&n.beforeSequence!==null,a=n.afterSequence!==void 0&&n.afterSequence!==null;if(i===a)throw Error(`Message history requires exactly one cursor direction`);return i&&r.push([`beforeSequence`,String(n.beforeSequence)]),a&&r.push([`afterSequence`,String(n.afterSequence)]),r.push([`limit`,String(n.limit??20)]),l(`/messages/conversation/${e}?${t(r)}`)}function k(e,t){return l(`/messages/conversation/${e}/around/${t}`)}function A(e,n={}){let r=[[`limit`,String(n.limit??30)]];return n.type&&r.push([`type`,n.type]),n.cursorUpdatedAt&&n.cursorUserId&&(r.push([`cursorUpdatedAt`,n.cursorUpdatedAt]),r.push([`cursorUserId`,n.cursorUserId])),l(`/messages/${e}/reactions?${t(r)}`)}function j(e){return l(`/messages/conversation/${e}/pinned`)}function M(e,n={}){let r=String(n.q??``).trim();if(!r)throw Error(`Search keyword is required`);let i=[[`q`,r],[`messageLimit`,String(n.messageLimit??20)],[`documentLimit`,String(n.documentLimit??20)]];return n.messageBeforeSequence&&i.push([`messageBeforeSequence`,String(n.messageBeforeSequence)]),n.documentBeforeSequence&&i.push([`documentBeforeSequence`,String(n.documentBeforeSequence)]),n.senderId&&i.push([`senderId`,n.senderId]),n.fromDate&&i.push([`fromDate`,n.fromDate]),n.toDate&&i.push([`toDate`,n.toDate]),l(`/messages/conversation/${e}/search?${t(i)}`)}function N(e,n){let r=[[`type`,n.type]];return n.month&&r.push([`month`,n.month]),n.from&&r.push([`from`,n.from]),n.to&&r.push([`to`,n.to]),n.senderId&&r.push([`senderId`,n.senderId]),l(`/messages/conversation/${e}/archive?${t(r)}`)}async function P(e,t,n){let r=new FormData;r.append(`file`,e),r.append(`conversationId`,t),n&&r.append(`asDocument`,`true`);let i=await l(`/media/uploads`,{method:`POST`,body:r}),a=i?.id;if(!a)throw Error(`Not found media-id response`);return{mediaId:a,attachmentUrl:i?.url??null,response:i}}async function F(e,t){let{mediaId:n}=await P(e,t);return g(t,{avatarUrl:`/data/docs/${n}`})}var I=``,L=null,R=``,z=new Set,B=!1,V=!1;function H(e){I=e}function U(e){let t=L;if(!t)return()=>void 0;let n=[],r=(e,r)=>{r&&(t.on(e,r),n.push({event:e,listener:r}))};if(r(`conversation:new`,e.onConversationNew),r(`conversation:deleted`,e.onConversationDeleted),r(`conversation:updated`,e.onConversationUpdated),r(`conversation:pinned`,e.onConversationPinned),r(`conversation:membership:changed`,e.onConversationMembershipChanged),e.onMessageSent&&(r(`message:sent`,e.onMessageSent),r(`message:ack`,e.onMessageSent)),e.onMessageNew&&(r(`message:new`,e.onMessageNew),r(`message:created`,e.onMessageNew)),r(`message:removed`,e.onMessageRemoved),r(`message:reaction:updated`,e.onMessageReactionUpdated),r(`message:pinned`,e.onMessagePinned),r(`conversation:read`,e.onConversationRead),r(`conversation:unread`,e.onConversationUnread),r(`presence:changed`,e.onPresenceChanged),r(`typing:start`,e.onTypingStart),r(`typing:stop`,e.onTypingStop),(e.onConnected||e.onConnectionRestored)&&r(`connect`,()=>{e.onConnected?.(),V&&e.onConnectionRestored?.()}),r(`disconnect`,e.onConnectionLost),e.onConnectFailed){let t=t=>{e.onConnectFailed?.(t)};r(`connect_error`,t),r(`error`,t),r(`exception`,t)}return()=>{n.forEach(({event:e,listener:n})=>t.off(e,n))}}function W(e){let t={handlers:e,detach:()=>void 0};return z.add(t),t.detach=U(e),()=>{t.detach(),z.delete(t)}}function G(){z.forEach(e=>{e.detach(),e.detach=U(e.handlers)})}function K(t,n){let r=L?.auth?.token;return L&&r===t&&R===I?(n&&W(n),L):(L&&$(),L=(0,e.io)(I,{transports:[`websocket`],upgrade:!1,auth:{token:t}}),R=I,L.on(`connect`,()=>{V=B,B=!0}),G(),n&&W(n),L)}function q(){return L}function J(e,t,n){return L?.connected?(n?L.emit(e,t,n):L.emit(e,t),{ok:!0,status:`EMITTED`}):{ok:!1,status:`DISCONNECTED`}}function Y(e,t){return J(`conversation:create`,e,t)}function X(e){return J(`conversation:subscribe`,{conversationId:e})}function Z(e){return J(`conversation:unsubscribe`,{conversationId:e})}function Q(e,t){return J(`message:send`,e,t)}function ne(e){return J(`message:reaction:apply`,e)}function re(e){return J(`message:reaction:remove`,e)}function ie(e,t){return J(`message:pin`,e,t)}function ae(e,t){return J(`message:forward`,e,t)}function oe(e,t){return J(`conversation:read`,e,t)}function se(e){return J(`typing:start`,e)}function ce(e){return J(`typing:stop`,e)}function $(){L&&=(L.removeAllListeners(),L.disconnect(),null),R=``,B=!1,V=!1}exports.ChatApiError=r,exports.addConversationMember=b,exports.addConversationMembers=x,exports.clearConversation=y,exports.configureChatApi=a,exports.configureSocket=H,exports.connectSocket=K,exports.createConversation=h,exports.deleteConversation=v,exports.deleteConversationMember=w,exports.disconnectSocket=$,exports.emitConversationRead=oe,exports.emitCreateConversation=Y,exports.emitMessageForward=ae,exports.emitMessagePin=ie,exports.emitMessageReactionApply=ne,exports.emitMessageReactionRemove=re,exports.emitMessageSend=Q,exports.emitTypingStart=se,exports.emitTypingStop=ce,exports.getConversationArchive=N,exports.getConversationById=ee,exports.getConversationMembers=C,exports.getConversationsByUser=m,exports.getDepartmentsByBranch=p,exports.getLatestMessages=E,exports.getMediaUrl=s,exports.getMessageReactions=A,exports.getMessageSystemMembers=S,exports.getMessageWindowPage=O,exports.getMessagesAround=k,exports.getPinnedMessages=j,exports.getSocket=q,exports.getUserBranches=f,exports.getUserById=u,exports.getUsers=d,exports.leaveConversation=T,exports.removeConversationMembers=te,exports.removeMessage=D,exports.resolveMediaUrl=c,exports.searchConversationMessages=M,exports.setConversationPinned=_,exports.subscribeConversation=X,exports.subscribeSocketHandlers=W,exports.unsubscribeConversation=Z,exports.updateConversation=g,exports.uploadGroupAvatar=F,exports.uploadMedia=P;
|
package/dist/index.js
CHANGED
|
@@ -54,10 +54,10 @@ function m() {
|
|
|
54
54
|
auth: !0
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function ee(e) {
|
|
58
58
|
return l(`/conversations/${e}`);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function h(e) {
|
|
61
61
|
return l("/conversations", {
|
|
62
62
|
method: "POST",
|
|
63
63
|
body: JSON.stringify(e)
|
|
@@ -78,63 +78,66 @@ function _(e, t) {
|
|
|
78
78
|
function v(e) {
|
|
79
79
|
return l(`/conversations/${e}`, { method: "DELETE" });
|
|
80
80
|
}
|
|
81
|
-
function y(e
|
|
81
|
+
function y(e) {
|
|
82
|
+
return l(`/conversations/${e}/clear`, { method: "POST" });
|
|
83
|
+
}
|
|
84
|
+
function b(e, t) {
|
|
82
85
|
return l(`/conversations/${e}/members`, {
|
|
83
86
|
method: "POST",
|
|
84
87
|
body: JSON.stringify({ userId: t })
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
|
-
function
|
|
90
|
+
function x(e, t) {
|
|
88
91
|
return l(`/conversations/${e}/members`, {
|
|
89
92
|
method: "POST",
|
|
90
93
|
body: JSON.stringify({ userIds: t })
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
|
-
function
|
|
96
|
+
function te(e, t) {
|
|
94
97
|
return l(`/conversations/${e}/members`, {
|
|
95
98
|
method: "DELETE",
|
|
96
99
|
body: JSON.stringify({ userIds: t })
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
|
-
function
|
|
102
|
+
function S(e, n = {}) {
|
|
100
103
|
let r = [["limit", String(n.limit ?? 30)]];
|
|
101
104
|
return n.cursorPosition !== void 0 && n.cursorPosition !== null && r.push(["cursorPosition", String(n.cursorPosition)]), l(`/messages/${e}/system-members?${t(r)}`);
|
|
102
105
|
}
|
|
103
|
-
function
|
|
106
|
+
function C(e, n = {}) {
|
|
104
107
|
let r = [["limit", String(n.limit ?? 30)]];
|
|
105
108
|
return n.cursor && r.push(["cursor", String(n.cursor)]), n.search?.trim() && r.push(["search", n.search.trim()]), l(`/conversations/${e}/members?${t(r)}`);
|
|
106
109
|
}
|
|
107
|
-
function
|
|
110
|
+
function w(e, t) {
|
|
108
111
|
return l(`/conversations/${e}/members/${t}`, { method: "DELETE" });
|
|
109
112
|
}
|
|
110
|
-
function
|
|
113
|
+
function T(e, t) {
|
|
111
114
|
return l(`/conversations/${e}/leave`, {
|
|
112
115
|
method: "PATCH",
|
|
113
116
|
body: JSON.stringify({ nextOwnerId: t })
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
|
-
function
|
|
119
|
+
function E(e) {
|
|
117
120
|
return l(`/messages/conversation/${e}/latest`);
|
|
118
121
|
}
|
|
119
|
-
function
|
|
122
|
+
function D(e, t) {
|
|
120
123
|
return l(`/messages/conversation/${e}/${t}`, { method: "DELETE" });
|
|
121
124
|
}
|
|
122
|
-
function
|
|
125
|
+
function O(e, n = {}) {
|
|
123
126
|
let r = [], i = n.beforeSequence !== void 0 && n.beforeSequence !== null, a = n.afterSequence !== void 0 && n.afterSequence !== null;
|
|
124
127
|
if (i === a) throw Error("Message history requires exactly one cursor direction");
|
|
125
128
|
return i && r.push(["beforeSequence", String(n.beforeSequence)]), a && r.push(["afterSequence", String(n.afterSequence)]), r.push(["limit", String(n.limit ?? 20)]), l(`/messages/conversation/${e}?${t(r)}`);
|
|
126
129
|
}
|
|
127
|
-
function
|
|
130
|
+
function k(e, t) {
|
|
128
131
|
return l(`/messages/conversation/${e}/around/${t}`);
|
|
129
132
|
}
|
|
130
|
-
function
|
|
133
|
+
function A(e, n = {}) {
|
|
131
134
|
let r = [["limit", String(n.limit ?? 30)]];
|
|
132
135
|
return n.type && r.push(["type", n.type]), n.cursorUpdatedAt && n.cursorUserId && (r.push(["cursorUpdatedAt", n.cursorUpdatedAt]), r.push(["cursorUserId", n.cursorUserId])), l(`/messages/${e}/reactions?${t(r)}`);
|
|
133
136
|
}
|
|
134
|
-
function
|
|
137
|
+
function j(e) {
|
|
135
138
|
return l(`/messages/conversation/${e}/pinned`);
|
|
136
139
|
}
|
|
137
|
-
function
|
|
140
|
+
function M(e, n = {}) {
|
|
138
141
|
let r = String(n.q ?? "").trim();
|
|
139
142
|
if (!r) throw Error("Search keyword is required");
|
|
140
143
|
let i = [
|
|
@@ -144,11 +147,11 @@ function j(e, n = {}) {
|
|
|
144
147
|
];
|
|
145
148
|
return n.messageBeforeSequence && i.push(["messageBeforeSequence", String(n.messageBeforeSequence)]), n.documentBeforeSequence && i.push(["documentBeforeSequence", String(n.documentBeforeSequence)]), n.senderId && i.push(["senderId", n.senderId]), n.fromDate && i.push(["fromDate", n.fromDate]), n.toDate && i.push(["toDate", n.toDate]), l(`/messages/conversation/${e}/search?${t(i)}`);
|
|
146
149
|
}
|
|
147
|
-
function
|
|
150
|
+
function N(e, n) {
|
|
148
151
|
let r = [["type", n.type]];
|
|
149
152
|
return n.month && r.push(["month", n.month]), n.from && r.push(["from", n.from]), n.to && r.push(["to", n.to]), n.senderId && r.push(["senderId", n.senderId]), l(`/messages/conversation/${e}/archive?${t(r)}`);
|
|
150
153
|
}
|
|
151
|
-
async function
|
|
154
|
+
async function P(e, t, n) {
|
|
152
155
|
let r = new FormData();
|
|
153
156
|
r.append("file", e), r.append("conversationId", t), n && r.append("asDocument", "true");
|
|
154
157
|
let i = await l("/media/uploads", {
|
|
@@ -162,18 +165,18 @@ async function N(e, t, n) {
|
|
|
162
165
|
response: i
|
|
163
166
|
};
|
|
164
167
|
}
|
|
165
|
-
async function
|
|
166
|
-
let { mediaId: n } = await
|
|
168
|
+
async function F(e, t) {
|
|
169
|
+
let { mediaId: n } = await P(e, t);
|
|
167
170
|
return g(t, { avatarUrl: `/data/docs/${n}` });
|
|
168
171
|
}
|
|
169
172
|
//#endregion
|
|
170
173
|
//#region src/socket/chatSocket.ts
|
|
171
|
-
var
|
|
172
|
-
function V(e) {
|
|
173
|
-
F = e;
|
|
174
|
-
}
|
|
174
|
+
var I = "", L = null, R = "", z = /* @__PURE__ */ new Set(), B = !1, V = !1;
|
|
175
175
|
function H(e) {
|
|
176
|
-
|
|
176
|
+
I = e;
|
|
177
|
+
}
|
|
178
|
+
function U(e) {
|
|
179
|
+
let t = L;
|
|
177
180
|
if (!t) return () => void 0;
|
|
178
181
|
let n = [], r = (e, r) => {
|
|
179
182
|
r && (t.on(e, r), n.push({
|
|
@@ -182,7 +185,7 @@ function H(e) {
|
|
|
182
185
|
}));
|
|
183
186
|
};
|
|
184
187
|
if (r("conversation:new", e.onConversationNew), r("conversation:deleted", e.onConversationDeleted), r("conversation:updated", e.onConversationUpdated), r("conversation:pinned", e.onConversationPinned), r("conversation:membership:changed", e.onConversationMembershipChanged), e.onMessageSent && (r("message:sent", e.onMessageSent), r("message:ack", e.onMessageSent)), e.onMessageNew && (r("message:new", e.onMessageNew), r("message:created", e.onMessageNew)), r("message:removed", e.onMessageRemoved), r("message:reaction:updated", e.onMessageReactionUpdated), r("message:pinned", e.onMessagePinned), r("conversation:read", e.onConversationRead), r("conversation:unread", e.onConversationUnread), r("presence:changed", e.onPresenceChanged), r("typing:start", e.onTypingStart), r("typing:stop", e.onTypingStop), (e.onConnected || e.onConnectionRestored) && r("connect", () => {
|
|
185
|
-
e.onConnected?.(),
|
|
188
|
+
e.onConnected?.(), V && e.onConnectionRestored?.();
|
|
186
189
|
}), r("disconnect", e.onConnectionLost), e.onConnectFailed) {
|
|
187
190
|
let t = (t) => {
|
|
188
191
|
e.onConnectFailed?.(t);
|
|
@@ -193,35 +196,35 @@ function H(e) {
|
|
|
193
196
|
n.forEach(({ event: e, listener: n }) => t.off(e, n));
|
|
194
197
|
};
|
|
195
198
|
}
|
|
196
|
-
function
|
|
199
|
+
function W(e) {
|
|
197
200
|
let t = {
|
|
198
201
|
handlers: e,
|
|
199
202
|
detach: () => void 0
|
|
200
203
|
};
|
|
201
|
-
return
|
|
202
|
-
t.detach(),
|
|
204
|
+
return z.add(t), t.detach = U(e), () => {
|
|
205
|
+
t.detach(), z.delete(t);
|
|
203
206
|
};
|
|
204
207
|
}
|
|
205
|
-
function
|
|
206
|
-
|
|
207
|
-
e.detach(), e.detach =
|
|
208
|
+
function G() {
|
|
209
|
+
z.forEach((e) => {
|
|
210
|
+
e.detach(), e.detach = U(e.handlers);
|
|
208
211
|
});
|
|
209
212
|
}
|
|
210
|
-
function
|
|
211
|
-
let r =
|
|
212
|
-
return
|
|
213
|
+
function K(t, n) {
|
|
214
|
+
let r = L?.auth?.token;
|
|
215
|
+
return L && r === t && R === I ? (n && W(n), L) : (L && $(), L = e(I, {
|
|
213
216
|
transports: ["websocket"],
|
|
214
217
|
upgrade: !1,
|
|
215
218
|
auth: { token: t }
|
|
216
|
-
}),
|
|
217
|
-
|
|
218
|
-
}),
|
|
219
|
+
}), R = I, L.on("connect", () => {
|
|
220
|
+
V = B, B = !0;
|
|
221
|
+
}), G(), n && W(n), L);
|
|
219
222
|
}
|
|
220
|
-
function
|
|
221
|
-
return
|
|
223
|
+
function q() {
|
|
224
|
+
return L;
|
|
222
225
|
}
|
|
223
|
-
function
|
|
224
|
-
return
|
|
226
|
+
function J(e, t, n) {
|
|
227
|
+
return L?.connected ? (n ? L.emit(e, t, n) : L.emit(e, t), {
|
|
225
228
|
ok: !0,
|
|
226
229
|
status: "EMITTED"
|
|
227
230
|
}) : {
|
|
@@ -229,41 +232,41 @@ function q(e, t, n) {
|
|
|
229
232
|
status: "DISCONNECTED"
|
|
230
233
|
};
|
|
231
234
|
}
|
|
232
|
-
function
|
|
233
|
-
return
|
|
234
|
-
}
|
|
235
|
-
function Y(e) {
|
|
236
|
-
return q("conversation:subscribe", { conversationId: e });
|
|
235
|
+
function Y(e, t) {
|
|
236
|
+
return J("conversation:create", e, t);
|
|
237
237
|
}
|
|
238
238
|
function X(e) {
|
|
239
|
-
return
|
|
239
|
+
return J("conversation:subscribe", { conversationId: e });
|
|
240
240
|
}
|
|
241
|
-
function Z(e
|
|
242
|
-
return
|
|
241
|
+
function Z(e) {
|
|
242
|
+
return J("conversation:unsubscribe", { conversationId: e });
|
|
243
243
|
}
|
|
244
|
-
function Q(e) {
|
|
245
|
-
return
|
|
244
|
+
function Q(e, t) {
|
|
245
|
+
return J("message:send", e, t);
|
|
246
246
|
}
|
|
247
247
|
function ne(e) {
|
|
248
|
-
return
|
|
248
|
+
return J("message:reaction:apply", e);
|
|
249
249
|
}
|
|
250
|
-
function re(e
|
|
251
|
-
return
|
|
250
|
+
function re(e) {
|
|
251
|
+
return J("message:reaction:remove", e);
|
|
252
252
|
}
|
|
253
253
|
function ie(e, t) {
|
|
254
|
-
return
|
|
254
|
+
return J("message:pin", e, t);
|
|
255
255
|
}
|
|
256
256
|
function ae(e, t) {
|
|
257
|
-
return
|
|
257
|
+
return J("message:forward", e, t);
|
|
258
258
|
}
|
|
259
|
-
function oe(e) {
|
|
260
|
-
return
|
|
259
|
+
function oe(e, t) {
|
|
260
|
+
return J("conversation:read", e, t);
|
|
261
261
|
}
|
|
262
262
|
function se(e) {
|
|
263
|
-
return
|
|
263
|
+
return J("typing:start", e);
|
|
264
|
+
}
|
|
265
|
+
function ce(e) {
|
|
266
|
+
return J("typing:stop", e);
|
|
264
267
|
}
|
|
265
268
|
function $() {
|
|
266
|
-
|
|
269
|
+
L &&= (L.removeAllListeners(), L.disconnect(), null), R = "", B = !1, V = !1;
|
|
267
270
|
}
|
|
268
271
|
//#endregion
|
|
269
|
-
export { r as ChatApiError,
|
|
272
|
+
export { r as ChatApiError, b as addConversationMember, x as addConversationMembers, y as clearConversation, a as configureChatApi, H as configureSocket, K as connectSocket, h as createConversation, v as deleteConversation, w as deleteConversationMember, $ as disconnectSocket, oe as emitConversationRead, Y as emitCreateConversation, ae as emitMessageForward, ie as emitMessagePin, ne as emitMessageReactionApply, re as emitMessageReactionRemove, Q as emitMessageSend, se as emitTypingStart, ce as emitTypingStop, N as getConversationArchive, ee as getConversationById, C as getConversationMembers, m as getConversationsByUser, p as getDepartmentsByBranch, E as getLatestMessages, s as getMediaUrl, A as getMessageReactions, S as getMessageSystemMembers, O as getMessageWindowPage, k as getMessagesAround, j as getPinnedMessages, q as getSocket, f as getUserBranches, u as getUserById, d as getUsers, T as leaveConversation, te as removeConversationMembers, D as removeMessage, c as resolveMediaUrl, M as searchConversationMessages, _ as setConversationPinned, X as subscribeConversation, W as subscribeSocketHandlers, Z as unsubscribeConversation, g as updateConversation, F as uploadGroupAvatar, P as uploadMedia };
|