ss-support-widget 1.0.9 → 1.0.11

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/src/service.ts DELETED
@@ -1,68 +0,0 @@
1
- import { Config } from "./element";
2
- import { MsgDelta } from "./MsgDelta";
3
-
4
- export async function getHistoryMessages(config: Config, threadId: string, onSucces: (delta: MsgDelta[]) => void): Promise<void> {
5
- fetch(config.apiBaseUrl + "api/chat-support-history", {
6
- method: "GET",
7
- headers: {
8
- "Content-Type": "application/json",
9
- ...(config.clientId ? { "X-Client-Id": config.clientId } : {}),
10
- "X-Thread-Id": threadId,
11
- },
12
- })
13
- .then(res => {
14
- if (!res.ok) {
15
- throw new Error("Request failed");
16
- }
17
- return res.json();
18
- })
19
- .then(data => {
20
- onSucces(data.map((d: any) => JSON.parse(d) as MsgDelta));
21
- })
22
- .catch(err => {
23
- console.error(err);
24
- });
25
- }
26
-
27
- export async function getApiStatus(config: Config): Promise<boolean> {
28
-
29
- const res = await fetch(config.apiBaseUrl + "api/health", {
30
- method: "GET",
31
- headers: {
32
- "Content-Type": "application/json",
33
- ...(config.clientId ? { "X-Client-Id": config.clientId } : {}),
34
- },
35
- });
36
-
37
- return res.ok;
38
- }
39
-
40
- export async function getClientActivityStatus(config: Config): Promise<boolean> {
41
-
42
- const res = await fetch(config.apiBaseUrl + "api/client-activity-status", {
43
- method: "GET",
44
- headers: {
45
- "Content-Type": "application/json",
46
- ...(config.clientId ? { "X-Client-Id": config.clientId } : {}),
47
- },
48
- });
49
-
50
- if (!res.ok) {
51
- return false;
52
- }
53
-
54
- return res.body ? await res.json() as boolean : false;
55
- }
56
-
57
- export async function getHideChatForUrls(config: Config): Promise<string[]> {
58
-
59
- const res = await fetch(config.apiBaseUrl + "api/hide-chat-for", {
60
- method: "GET",
61
- headers: {
62
- "Content-Type": "application/json",
63
- ...(config.clientId ? { "X-Client-Id": config.clientId } : {}),
64
- },
65
- });
66
-
67
- return res.body ? await res.json() as string[] : [];
68
- }
@@ -1,17 +0,0 @@
1
- export function saveThreadId(threadId: string) {
2
- sessionStorage.setItem("threadId", threadId);
3
- }
4
-
5
- export function getThreadId() : string | null {
6
- return sessionStorage.getItem("threadId");
7
- }
8
-
9
-
10
- // export function saveUrlPaths(urls: string[]) {
11
- // sessionStorage.setItem("urlPaths", JSON.stringify(urls));
12
- // }
13
-
14
- // export function getUrlPaths() : string[] | [] {
15
- // const item = sessionStorage.getItem("urlPaths");
16
- // return item ? JSON.parse(item) : [];
17
- // }