@webitel/chat-web-sdk 0.0.12 → 0.0.13
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +120 -88
- package/dist/index.js.map +1 -1
- package/dist/modules/threads/api/Threads.api.d.ts +2 -2
- package/dist/modules/threads/api/Threads.api.d.ts.map +1 -1
- package/dist/modules/threads/classes/Thread.class.d.ts.map +1 -1
- package/dist/modules/threads/index.d.ts +1 -1
- package/dist/modules/threads/index.d.ts.map +1 -1
- package/dist/modules/threads/modules/members/classes/ThreadMember.class.d.ts +8 -0
- package/dist/modules/threads/modules/members/classes/ThreadMember.class.d.ts.map +1 -0
- package/dist/modules/threads/modules/members/index.d.ts +2 -1
- package/dist/modules/threads/modules/members/index.d.ts.map +1 -1
- package/dist/modules/threads/types/Thread.types.d.ts +9 -5
- package/dist/modules/threads/types/Thread.types.d.ts.map +1 -1
- package/dist/modules/threads/utils/fetchThreads.d.ts +2 -2
- package/dist/modules/threads/utils/fetchThreads.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ useMessagesService, } from './modules/messages';
|
|
|
11
11
|
export { ChatsSocketConnectionStatus, ChatsSocketMessage, // enum for socket message types
|
|
12
12
|
createChatsSocketClient, } from './modules/socket';
|
|
13
13
|
export { type IThread, // Thread class
|
|
14
|
+
type IThreadMember, // ThreadMember class
|
|
14
15
|
type ThreadAddMemberParams, type ThreadMemberContact, type ThreadMemberModel, ThreadMemberRole, // enum for thread member roles
|
|
15
16
|
type ThreadModel, // Thread backend response type
|
|
16
17
|
type ThreadRemoveMemberParams, type ThreadSearchParams, type ThreadSearchResult, useThreadsService, } from './modules/threads';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAAE,sDAAsD;AACzE,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEN,mBAAmB,EAEnB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,uBAAuB,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACN,KAAK,YAAY,EAAE,gCAAgC;AACnD,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EAAE,gBAAgB;AAC/B,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,KAAK,QAAQ,EAAE,gBAAgB;AAC/B,qBAAqB,EAAE,oCAAoC;AAC3D,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EAAE,gCAAgC;AAEnD,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,2BAA2B,EAC3B,kBAAkB,EAAE,gCAAgC;AACpD,uBAAuB,GAIvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,OAAO,EAAE,eAAe;AAC7B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,gBAAgB,EAAE,+BAA+B;AACjD,KAAK,WAAW,EAAE,+BAA+B;AACjD,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,iBAAiB,GACjB,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAAE,sDAAsD;AACzE,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEN,mBAAmB,EAEnB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,uBAAuB,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACN,KAAK,YAAY,EAAE,gCAAgC;AACnD,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EAAE,gBAAgB;AAC/B,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,KAAK,QAAQ,EAAE,gBAAgB;AAC/B,qBAAqB,EAAE,oCAAoC;AAC3D,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EAAE,gCAAgC;AAEnD,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,2BAA2B,EAC3B,kBAAkB,EAAE,gCAAgC;AACpD,uBAAuB,GAIvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,OAAO,EAAE,eAAe;AAC7B,KAAK,aAAa,EAAE,qBAAqB;AACzC,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,gBAAgB,EAAE,+BAA+B;AACjD,KAAK,WAAW,EAAE,+BAA+B;AACjD,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,iBAAiB,GACjB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1559,7 +1559,7 @@ function jn(e) {
|
|
|
1559
1559
|
}
|
|
1560
1560
|
//#endregion
|
|
1561
1561
|
//#region node_modules/axios/lib/env/data.js
|
|
1562
|
-
var Mn = "1.13.6",
|
|
1562
|
+
var Mn = "1.13.6", Nn = {};
|
|
1563
1563
|
[
|
|
1564
1564
|
"object",
|
|
1565
1565
|
"boolean",
|
|
@@ -1568,23 +1568,23 @@ var Mn = "1.13.6", q = {};
|
|
|
1568
1568
|
"string",
|
|
1569
1569
|
"symbol"
|
|
1570
1570
|
].forEach((e, t) => {
|
|
1571
|
-
|
|
1571
|
+
Nn[e] = function(n) {
|
|
1572
1572
|
return typeof n === e || "a" + (t < 1 ? "n " : " ") + e;
|
|
1573
1573
|
};
|
|
1574
1574
|
});
|
|
1575
|
-
var
|
|
1576
|
-
|
|
1575
|
+
var Pn = {};
|
|
1576
|
+
Nn.transitional = function(e, t, n) {
|
|
1577
1577
|
function r(e, t) {
|
|
1578
1578
|
return "[Axios v" + Mn + "] Transitional option '" + e + "'" + t + (n ? ". " + n : "");
|
|
1579
1579
|
}
|
|
1580
1580
|
return (n, i, a) => {
|
|
1581
1581
|
if (e === !1) throw new B(r(i, " has been removed" + (t ? " in " + t : "")), B.ERR_DEPRECATED);
|
|
1582
|
-
return t && !
|
|
1582
|
+
return t && !Pn[i] && (Pn[i] = !0, console.warn(r(i, " has been deprecated since v" + t + " and will be removed in the near future"))), e ? e(n, i, a) : !0;
|
|
1583
1583
|
};
|
|
1584
|
-
},
|
|
1584
|
+
}, Nn.spelling = function(e) {
|
|
1585
1585
|
return (t, n) => (console.warn(`${n} is likely a misspelling of ${e}`), !0);
|
|
1586
1586
|
};
|
|
1587
|
-
function
|
|
1587
|
+
function Fn(e, t, n) {
|
|
1588
1588
|
if (typeof e != "object") throw new B("options must be an object", B.ERR_BAD_OPTION_VALUE);
|
|
1589
1589
|
let r = Object.keys(e), i = r.length;
|
|
1590
1590
|
for (; i-- > 0;) {
|
|
@@ -1597,10 +1597,10 @@ function Pn(e, t, n) {
|
|
|
1597
1597
|
if (n !== !0) throw new B("Unknown option " + a, B.ERR_BAD_OPTION);
|
|
1598
1598
|
}
|
|
1599
1599
|
}
|
|
1600
|
-
var
|
|
1601
|
-
assertOptions:
|
|
1602
|
-
validators:
|
|
1603
|
-
},
|
|
1600
|
+
var In = {
|
|
1601
|
+
assertOptions: Fn,
|
|
1602
|
+
validators: Nn
|
|
1603
|
+
}, q = In.validators, J = class {
|
|
1604
1604
|
constructor(e) {
|
|
1605
1605
|
this.defaults = e || {}, this.interceptors = {
|
|
1606
1606
|
request: new wt(),
|
|
@@ -1625,17 +1625,17 @@ var Fn = {
|
|
|
1625
1625
|
_request(e, t) {
|
|
1626
1626
|
typeof e == "string" ? (t ||= {}, t.url = e) : t = e || {}, t = K(this.defaults, t);
|
|
1627
1627
|
let { transitional: n, paramsSerializer: r, headers: i } = t;
|
|
1628
|
-
n !== void 0 &&
|
|
1629
|
-
silentJSONParsing:
|
|
1630
|
-
forcedJSONParsing:
|
|
1631
|
-
clarifyTimeoutError:
|
|
1632
|
-
legacyInterceptorReqResOrdering:
|
|
1633
|
-
}, !1), r != null && (z.isFunction(r) ? t.paramsSerializer = { serialize: r } :
|
|
1634
|
-
encode:
|
|
1635
|
-
serialize:
|
|
1636
|
-
}, !0)), t.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls === void 0 ? t.allowAbsoluteUrls = !0 : t.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls),
|
|
1637
|
-
baseUrl:
|
|
1638
|
-
withXsrfToken:
|
|
1628
|
+
n !== void 0 && In.assertOptions(n, {
|
|
1629
|
+
silentJSONParsing: q.transitional(q.boolean),
|
|
1630
|
+
forcedJSONParsing: q.transitional(q.boolean),
|
|
1631
|
+
clarifyTimeoutError: q.transitional(q.boolean),
|
|
1632
|
+
legacyInterceptorReqResOrdering: q.transitional(q.boolean)
|
|
1633
|
+
}, !1), r != null && (z.isFunction(r) ? t.paramsSerializer = { serialize: r } : In.assertOptions(r, {
|
|
1634
|
+
encode: q.function,
|
|
1635
|
+
serialize: q.function
|
|
1636
|
+
}, !0)), t.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls === void 0 ? t.allowAbsoluteUrls = !0 : t.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls), In.assertOptions(t, {
|
|
1637
|
+
baseUrl: q.spelling("baseURL"),
|
|
1638
|
+
withXsrfToken: q.spelling("withXSRFToken")
|
|
1639
1639
|
}, !0), t.method = (t.method || this.defaults.method || "get").toLowerCase();
|
|
1640
1640
|
let a = i && z.merge(i.common, i[t.method]);
|
|
1641
1641
|
i && z.forEach([
|
|
@@ -1695,7 +1695,7 @@ z.forEach([
|
|
|
1695
1695
|
"head",
|
|
1696
1696
|
"options"
|
|
1697
1697
|
], function(e) {
|
|
1698
|
-
|
|
1698
|
+
J.prototype[e] = function(t, n) {
|
|
1699
1699
|
return this.request(K(n || {}, {
|
|
1700
1700
|
method: e,
|
|
1701
1701
|
url: t,
|
|
@@ -1717,11 +1717,11 @@ z.forEach([
|
|
|
1717
1717
|
}));
|
|
1718
1718
|
};
|
|
1719
1719
|
}
|
|
1720
|
-
|
|
1720
|
+
J.prototype[e] = t(), J.prototype[e + "Form"] = t(!0);
|
|
1721
1721
|
});
|
|
1722
1722
|
//#endregion
|
|
1723
1723
|
//#region node_modules/axios/lib/cancel/CancelToken.js
|
|
1724
|
-
var
|
|
1724
|
+
var Ln = class e {
|
|
1725
1725
|
constructor(e) {
|
|
1726
1726
|
if (typeof e != "function") throw TypeError("executor must be a function.");
|
|
1727
1727
|
let t;
|
|
@@ -1778,19 +1778,19 @@ var In = class e {
|
|
|
1778
1778
|
};
|
|
1779
1779
|
//#endregion
|
|
1780
1780
|
//#region node_modules/axios/lib/helpers/spread.js
|
|
1781
|
-
function
|
|
1781
|
+
function Rn(e) {
|
|
1782
1782
|
return function(t) {
|
|
1783
1783
|
return e.apply(null, t);
|
|
1784
1784
|
};
|
|
1785
1785
|
}
|
|
1786
1786
|
//#endregion
|
|
1787
1787
|
//#region node_modules/axios/lib/helpers/isAxiosError.js
|
|
1788
|
-
function
|
|
1788
|
+
function zn(e) {
|
|
1789
1789
|
return z.isObject(e) && e.isAxiosError === !0;
|
|
1790
1790
|
}
|
|
1791
1791
|
//#endregion
|
|
1792
1792
|
//#region node_modules/axios/lib/helpers/HttpStatusCode.js
|
|
1793
|
-
var
|
|
1793
|
+
var Bn = {
|
|
1794
1794
|
Continue: 100,
|
|
1795
1795
|
SwitchingProtocols: 101,
|
|
1796
1796
|
Processing: 102,
|
|
@@ -1861,29 +1861,29 @@ var zn = {
|
|
|
1861
1861
|
SslHandshakeFailed: 525,
|
|
1862
1862
|
InvalidSslCertificate: 526
|
|
1863
1863
|
};
|
|
1864
|
-
Object.entries(
|
|
1865
|
-
|
|
1864
|
+
Object.entries(Bn).forEach(([e, t]) => {
|
|
1865
|
+
Bn[t] = e;
|
|
1866
1866
|
});
|
|
1867
1867
|
//#endregion
|
|
1868
1868
|
//#region node_modules/axios/lib/axios.js
|
|
1869
|
-
function
|
|
1870
|
-
let t = new
|
|
1871
|
-
return z.extend(n,
|
|
1872
|
-
return
|
|
1869
|
+
function Vn(e) {
|
|
1870
|
+
let t = new J(e), n = ue(J.prototype.request, t);
|
|
1871
|
+
return z.extend(n, J.prototype, t, { allOwnKeys: !0 }), z.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(t) {
|
|
1872
|
+
return Vn(K(e, t));
|
|
1873
1873
|
}, n;
|
|
1874
1874
|
}
|
|
1875
|
-
var
|
|
1876
|
-
|
|
1875
|
+
var Y = Vn(H);
|
|
1876
|
+
Y.Axios = J, Y.CanceledError = G, Y.CancelToken = Ln, Y.isCancel = Jt, Y.VERSION = Mn, Y.toFormData = vt, Y.AxiosError = B, Y.Cancel = Y.CanceledError, Y.all = function(e) {
|
|
1877
1877
|
return Promise.all(e);
|
|
1878
|
-
},
|
|
1878
|
+
}, Y.spread = Rn, Y.isAxiosError = zn, Y.mergeConfig = K, Y.AxiosHeaders = W, Y.formToJSON = (e) => It(z.isHTMLForm(e) ? new FormData(e) : e), Y.getAdapter = kn.getAdapter, Y.HttpStatusCode = Bn, Y.default = Y;
|
|
1879
1879
|
//#endregion
|
|
1880
1880
|
//#region src/modules/configs/serviceConfig/ServiceConfig.class.ts
|
|
1881
|
-
var
|
|
1881
|
+
var Hn = class {
|
|
1882
1882
|
baseUrl;
|
|
1883
1883
|
accessToken;
|
|
1884
1884
|
axiosInstance;
|
|
1885
1885
|
constructor({ baseUrl: e, accessToken: t }) {
|
|
1886
|
-
this.baseUrl = e, this.accessToken = t, this.axiosInstance =
|
|
1886
|
+
this.baseUrl = e, this.accessToken = t, this.axiosInstance = Y.create({
|
|
1887
1887
|
baseURL: this.baseUrl,
|
|
1888
1888
|
paramsSerializer: (e) => ie(e, { allowDots: !0 })
|
|
1889
1889
|
}), this.setupAxiosTokenHandler();
|
|
@@ -1892,24 +1892,24 @@ var Vn = class {
|
|
|
1892
1892
|
typeof this.accessToken == "function" ? this.axiosInstance.interceptors.request.use(async (e) => (e.headers["X-Webitel-Access"] = await this.accessToken(), e)) : this.axiosInstance.defaults.headers.common["X-Webitel-Access"] = this.accessToken;
|
|
1893
1893
|
}
|
|
1894
1894
|
};
|
|
1895
|
-
function
|
|
1896
|
-
return new
|
|
1895
|
+
function Un(e) {
|
|
1896
|
+
return new Hn(e);
|
|
1897
1897
|
}
|
|
1898
1898
|
//#endregion
|
|
1899
1899
|
//#region src/modules/configs/socketConfig/SocketConfig.class.ts
|
|
1900
|
-
var
|
|
1900
|
+
var Wn = class {
|
|
1901
1901
|
baseUrl;
|
|
1902
1902
|
accessToken;
|
|
1903
1903
|
constructor({ baseUrl: e, accessToken: t }) {
|
|
1904
1904
|
this.baseUrl = e, this.accessToken = t;
|
|
1905
1905
|
}
|
|
1906
1906
|
};
|
|
1907
|
-
function
|
|
1908
|
-
return new
|
|
1907
|
+
function Gn(e) {
|
|
1908
|
+
return new Wn(e);
|
|
1909
1909
|
}
|
|
1910
1910
|
//#endregion
|
|
1911
1911
|
//#region src/modules/messages/classes/Message.class.ts
|
|
1912
|
-
var
|
|
1912
|
+
var Kn = class {
|
|
1913
1913
|
_serviceConfig;
|
|
1914
1914
|
constructor(e, { serviceConfig: t }) {
|
|
1915
1915
|
Object.assign(this, e), this._serviceConfig = t;
|
|
@@ -1921,15 +1921,15 @@ var Gn = class {
|
|
|
1921
1921
|
throw Error("Method not implemented.");
|
|
1922
1922
|
}
|
|
1923
1923
|
};
|
|
1924
|
-
function
|
|
1925
|
-
return new
|
|
1924
|
+
function qn(e, { serviceConfig: t }) {
|
|
1925
|
+
return new Kn(e, { serviceConfig: t });
|
|
1926
1926
|
}
|
|
1927
1927
|
//#endregion
|
|
1928
1928
|
//#region src/modules/messages/enums/MessageAttachmentType.enum.ts
|
|
1929
|
-
var
|
|
1929
|
+
var X = {
|
|
1930
1930
|
Documents: "documents",
|
|
1931
1931
|
Images: "images"
|
|
1932
|
-
},
|
|
1932
|
+
}, Z = ({ axiosInstance: e }) => {
|
|
1933
1933
|
async function t(t, n = {}) {
|
|
1934
1934
|
let i = r(n, [l()]);
|
|
1935
1935
|
return r((await e.get(`/v1/${t}/messages`, { params: i })).data, [A()]);
|
|
@@ -1959,7 +1959,7 @@ var Z = {
|
|
|
1959
1959
|
sendDocumentMessage: a,
|
|
1960
1960
|
sendImageMessage: o
|
|
1961
1961
|
};
|
|
1962
|
-
}, Jn = (e) => async (t, n = {}) => await
|
|
1962
|
+
}, Jn = (e) => async (t, n = {}) => await Z(e).getMessageHistory(t, n), Yn = (e, { serviceConfig: t }) => e.map((e) => qn(e, { serviceConfig: t })), Xn = async (e, t, n = {}) => {
|
|
1963
1963
|
let r = await Jn(e)(t, n);
|
|
1964
1964
|
return {
|
|
1965
1965
|
...r,
|
|
@@ -1973,7 +1973,7 @@ var Z = {
|
|
|
1973
1973
|
}, Qn = async (e, t) => {
|
|
1974
1974
|
let { files: n, body: r, ...i } = t, a = oe(n), o = Zn(i.to);
|
|
1975
1975
|
if (a.length === 0) throw Error("At least one file is required to send a document message");
|
|
1976
|
-
let s =
|
|
1976
|
+
let s = Z(e), c = (await s.uploadFiles(o, a)).map((e) => ({
|
|
1977
1977
|
fileName: e.name,
|
|
1978
1978
|
id: `${e.id}`,
|
|
1979
1979
|
mimeType: e.mime,
|
|
@@ -1987,7 +1987,7 @@ var Z = {
|
|
|
1987
1987
|
}, $n = async (e, t) => {
|
|
1988
1988
|
let { files: n, body: r, ...i } = t, a = oe(n), o = Zn(i.to);
|
|
1989
1989
|
if (a.length === 0) throw Error("At least one file is required to send an image message");
|
|
1990
|
-
let s =
|
|
1990
|
+
let s = Z(e), c = (await s.uploadFiles(o, a)).map((e) => ({
|
|
1991
1991
|
id: `${e.id}`,
|
|
1992
1992
|
mimeType: e.mime,
|
|
1993
1993
|
name: e.name
|
|
@@ -1997,7 +1997,7 @@ var Z = {
|
|
|
1997
1997
|
body: r,
|
|
1998
1998
|
images: c
|
|
1999
1999
|
});
|
|
2000
|
-
}, er = async (e, t) =>
|
|
2000
|
+
}, er = async (e, t) => Z(e).sendTextMessage(t);
|
|
2001
2001
|
//#endregion
|
|
2002
2002
|
//#region src/modules/messages/messagesSevice.ts
|
|
2003
2003
|
function tr(e) {
|
|
@@ -2023,13 +2023,13 @@ var nr = class {
|
|
|
2023
2023
|
iss: this.iss
|
|
2024
2024
|
} };
|
|
2025
2025
|
switch (t?.type) {
|
|
2026
|
-
case
|
|
2026
|
+
case X.Images: return r.sendImageMessage({
|
|
2027
2027
|
files: t.files,
|
|
2028
2028
|
body: e,
|
|
2029
2029
|
sendId: n,
|
|
2030
2030
|
to: i
|
|
2031
2031
|
});
|
|
2032
|
-
case
|
|
2032
|
+
case X.Documents: return r.sendDocumentMessage({
|
|
2033
2033
|
files: t.files,
|
|
2034
2034
|
body: e,
|
|
2035
2035
|
sendId: n,
|
|
@@ -2114,9 +2114,34 @@ var Q = {
|
|
|
2114
2114
|
role: i
|
|
2115
2115
|
})).data, [A()]),
|
|
2116
2116
|
removeMember: async (t, { id: n }) => r((await e.delete(`/v1/threads/${t}/members/${n}`)).data, [A()])
|
|
2117
|
-
}), dr = (e) => async (t, n) => ur(e).
|
|
2117
|
+
}), dr = (e) => async (t, n) => ur(e).removeMember(t, n), fr = class {
|
|
2118
2118
|
_serviceConfig;
|
|
2119
|
+
threadId;
|
|
2119
2120
|
id;
|
|
2121
|
+
contact;
|
|
2122
|
+
constructor(e, { serviceConfig: t, threadId: n }) {
|
|
2123
|
+
Object.assign(this, e), this._serviceConfig = t, this.threadId = n;
|
|
2124
|
+
}
|
|
2125
|
+
async removeFromThread() {
|
|
2126
|
+
return dr(this._serviceConfig)(this.threadId, { id: this.id });
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
function pr(e, { serviceConfig: t, threadId: n }) {
|
|
2130
|
+
let r = rr(e.contact, { serviceConfig: t });
|
|
2131
|
+
return new fr({
|
|
2132
|
+
...e,
|
|
2133
|
+
contact: r
|
|
2134
|
+
}, {
|
|
2135
|
+
serviceConfig: t,
|
|
2136
|
+
threadId: n
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
//#endregion
|
|
2140
|
+
//#region src/modules/threads/modules/members/utils/addMember.ts
|
|
2141
|
+
var mr = (e) => async (t, n) => ur(e).addMember(t, n), hr = class {
|
|
2142
|
+
_serviceConfig;
|
|
2143
|
+
id;
|
|
2144
|
+
members = [];
|
|
2120
2145
|
constructor(e, { serviceConfig: t }) {
|
|
2121
2146
|
Object.assign(this, e), this._serviceConfig = t;
|
|
2122
2147
|
}
|
|
@@ -2126,13 +2151,13 @@ var Q = {
|
|
|
2126
2151
|
async sendMessage({ body: e, attachments: t }, { sendId: n } = {}) {
|
|
2127
2152
|
let r = tr(this.serviceConfig), i = { threadId: this.id };
|
|
2128
2153
|
switch (t?.type) {
|
|
2129
|
-
case
|
|
2154
|
+
case X.Images: return r.sendImageMessage({
|
|
2130
2155
|
files: t.files,
|
|
2131
2156
|
body: e,
|
|
2132
2157
|
sendId: n,
|
|
2133
2158
|
to: i
|
|
2134
2159
|
});
|
|
2135
|
-
case
|
|
2160
|
+
case X.Documents: return r.sendDocumentMessage({
|
|
2136
2161
|
files: t.files,
|
|
2137
2162
|
body: e,
|
|
2138
2163
|
sendId: n,
|
|
@@ -2146,26 +2171,33 @@ var Q = {
|
|
|
2146
2171
|
}
|
|
2147
2172
|
}
|
|
2148
2173
|
async addMember(e) {
|
|
2149
|
-
return
|
|
2174
|
+
return mr(this.serviceConfig)(this.id, e);
|
|
2150
2175
|
}
|
|
2151
2176
|
async removeMember(e) {
|
|
2152
|
-
return
|
|
2177
|
+
return dr(this.serviceConfig)(this.id, e);
|
|
2153
2178
|
}
|
|
2154
2179
|
get serviceConfig() {
|
|
2155
2180
|
return this._serviceConfig;
|
|
2156
2181
|
}
|
|
2157
2182
|
};
|
|
2158
|
-
function
|
|
2159
|
-
|
|
2183
|
+
function gr(e, { serviceConfig: t }) {
|
|
2184
|
+
let n = (e.members ?? []).map((n) => pr(n, {
|
|
2185
|
+
serviceConfig: t,
|
|
2186
|
+
threadId: e.id
|
|
2187
|
+
}));
|
|
2188
|
+
return new hr({
|
|
2189
|
+
...e,
|
|
2190
|
+
members: n
|
|
2191
|
+
}, { serviceConfig: t });
|
|
2160
2192
|
}
|
|
2161
2193
|
//#endregion
|
|
2162
2194
|
//#region src/modules/socket/utils/instantiateSocketEventEntities.ts
|
|
2163
|
-
function
|
|
2164
|
-
return e.name === $.ThreadMessage ?
|
|
2195
|
+
function _r(e, { serviceConfig: t }) {
|
|
2196
|
+
return e.name === $.ThreadMessage ? qn(e.payload, { serviceConfig: t }) : gr(e.payload, { serviceConfig: t });
|
|
2165
2197
|
}
|
|
2166
2198
|
//#endregion
|
|
2167
2199
|
//#region src/modules/socket/utils/processSocketEventPayload.ts
|
|
2168
|
-
function
|
|
2200
|
+
function vr(e) {
|
|
2169
2201
|
if (e.connectedEvent) return $.Connected;
|
|
2170
2202
|
if (e.disconnectedEvent) return $.Disconnected;
|
|
2171
2203
|
if (e.errorEvent) return $.Error;
|
|
@@ -2175,7 +2207,7 @@ function gr(e) {
|
|
|
2175
2207
|
if (e.pingEvent) return $.Ping;
|
|
2176
2208
|
throw Error(`Unknown event: ${JSON.stringify(e)}`);
|
|
2177
2209
|
}
|
|
2178
|
-
function
|
|
2210
|
+
function yr(e, t) {
|
|
2179
2211
|
switch (t) {
|
|
2180
2212
|
case $.Connected: return e.connectedEvent;
|
|
2181
2213
|
case $.Disconnected: return e.disconnectedEvent;
|
|
@@ -2186,25 +2218,25 @@ function _r(e, t) {
|
|
|
2186
2218
|
case $.Ping: return e.pingEvent;
|
|
2187
2219
|
}
|
|
2188
2220
|
}
|
|
2189
|
-
function
|
|
2190
|
-
let n =
|
|
2221
|
+
function br(e, { serviceConfig: t }) {
|
|
2222
|
+
let n = vr(e);
|
|
2191
2223
|
return {
|
|
2192
2224
|
eventName: n,
|
|
2193
|
-
eventPayload:
|
|
2225
|
+
eventPayload: xr({
|
|
2194
2226
|
name: n,
|
|
2195
|
-
payload:
|
|
2227
|
+
payload: yr(e, n)
|
|
2196
2228
|
}, { serviceConfig: t })
|
|
2197
2229
|
};
|
|
2198
2230
|
}
|
|
2199
|
-
function
|
|
2200
|
-
return e === $.ThreadMessage || e === $.ThreadCreated ?
|
|
2231
|
+
function xr({ name: e, payload: t }, { serviceConfig: n }) {
|
|
2232
|
+
return e === $.ThreadMessage || e === $.ThreadCreated ? _r({
|
|
2201
2233
|
name: e,
|
|
2202
2234
|
payload: t
|
|
2203
2235
|
}, { serviceConfig: n }) : t;
|
|
2204
2236
|
}
|
|
2205
2237
|
//#endregion
|
|
2206
2238
|
//#region src/modules/socket/classes/ChatsSoketClient.ts
|
|
2207
|
-
var
|
|
2239
|
+
var Sr = class {
|
|
2208
2240
|
emitter = lr();
|
|
2209
2241
|
stateEmitter = lr();
|
|
2210
2242
|
socketConfig;
|
|
@@ -2230,7 +2262,7 @@ var br = class {
|
|
|
2230
2262
|
}, this.ws.onclose = () => {
|
|
2231
2263
|
this.setConnectionState(Q.Disconnected), this.ws = null, t(/* @__PURE__ */ Error("socket disconnected"));
|
|
2232
2264
|
}, this.ws.onmessage = (t) => {
|
|
2233
|
-
let { eventName: n, eventPayload: i } =
|
|
2265
|
+
let { eventName: n, eventPayload: i } = br(r(JSON.parse(t.data), [A()]).payload, { serviceConfig: this.serviceConfig });
|
|
2234
2266
|
n === $.Connected && e(), this.emitter.emit(n, i);
|
|
2235
2267
|
};
|
|
2236
2268
|
});
|
|
@@ -2248,21 +2280,21 @@ var br = class {
|
|
|
2248
2280
|
this.stateEmitter.on(e, t);
|
|
2249
2281
|
}
|
|
2250
2282
|
};
|
|
2251
|
-
function
|
|
2252
|
-
return new
|
|
2283
|
+
function Cr({ socketConfig: e, serviceConfig: t }) {
|
|
2284
|
+
return new Sr({
|
|
2253
2285
|
socketConfig: e,
|
|
2254
2286
|
serviceConfig: t
|
|
2255
2287
|
});
|
|
2256
2288
|
}
|
|
2257
2289
|
//#endregion
|
|
2258
2290
|
//#region node_modules/@webitel/api-services/src/gen/_models/webitelImApiGatewayV1ThreadRole.ts
|
|
2259
|
-
var
|
|
2291
|
+
var wr = {
|
|
2260
2292
|
RoleUnspecified: "ROLE_UNSPECIFIED",
|
|
2261
2293
|
RoleMember: "ROLE_MEMBER",
|
|
2262
2294
|
RoleAdmin: "ROLE_ADMIN",
|
|
2263
2295
|
RoleOwner: "ROLE_OWNER",
|
|
2264
2296
|
RoleSupervisor: "ROLE_SUPERVISOR"
|
|
2265
|
-
},
|
|
2297
|
+
}, Tr = ({ axiosInstance: e }) => ({
|
|
2266
2298
|
getThreadsList: async (t = {}) => {
|
|
2267
2299
|
let n = r(t, [l()]);
|
|
2268
2300
|
return r((await e.get("/v1/threads", { params: n })).data, [A()]);
|
|
@@ -2272,24 +2304,24 @@ var Sr = {
|
|
|
2272
2304
|
if (!i) throw Error(`Thread not found: ${t}`);
|
|
2273
2305
|
return i;
|
|
2274
2306
|
}
|
|
2275
|
-
}),
|
|
2276
|
-
let n = await
|
|
2307
|
+
}), Er = (e) => async (t = {}) => await Tr(e).getThreadsList(t), Dr = (e, { serviceConfig: t }) => e.map((e) => gr(e, { serviceConfig: t })), Or = async (e, t = {}) => {
|
|
2308
|
+
let n = await Er(e)(t);
|
|
2277
2309
|
return {
|
|
2278
2310
|
...n,
|
|
2279
|
-
items:
|
|
2311
|
+
items: Dr(n.items ?? [], { serviceConfig: e })
|
|
2280
2312
|
};
|
|
2281
|
-
},
|
|
2313
|
+
}, kr = (e) => async (t) => Tr(e).getThread(t), Ar = async (e, t) => gr(await kr(e)(t), { serviceConfig: e });
|
|
2282
2314
|
//#endregion
|
|
2283
2315
|
//#region src/modules/threads/threadsSevice.ts
|
|
2284
|
-
function
|
|
2316
|
+
function jr(e) {
|
|
2285
2317
|
return {
|
|
2286
|
-
fetchThread: (t) =>
|
|
2287
|
-
fetchThreads: (t) =>
|
|
2288
|
-
addMember: (t, n) =>
|
|
2289
|
-
removeMember: (t, n) =>
|
|
2318
|
+
fetchThread: (t) => Ar(e, t),
|
|
2319
|
+
fetchThreads: (t) => Or(e, t ?? {}),
|
|
2320
|
+
addMember: (t, n) => mr(e)(t, n),
|
|
2321
|
+
removeMember: (t, n) => dr(e)(t, n)
|
|
2290
2322
|
};
|
|
2291
2323
|
}
|
|
2292
2324
|
//#endregion
|
|
2293
|
-
export { Q as ChatsSocketConnectionStatus, $ as ChatsSocketMessage,
|
|
2325
|
+
export { Q as ChatsSocketConnectionStatus, $ as ChatsSocketMessage, X as MessageAttachmentType, wr as ThreadMemberRole, Cr as createChatsSocketClient, Un as createServiceConfig, Gn as createSocketConfig, le as useAccountService, cr as useContactsService, tr as useMessagesService, jr as useThreadsService };
|
|
2294
2326
|
|
|
2295
2327
|
//# sourceMappingURL=index.js.map
|