@botpress/webchat-client 0.1.0 → 0.1.1
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/.turbo/turbo-build.log +4 -4
- package/dist/webchat-client2.js +51 -51
- package/package.json +1 -1
- package/src/client/client.ts +2 -4
- package/vite.config.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> @botpress/webchat-client@0.1.
|
2
|
+
> @botpress/webchat-client@0.1.1 build /home/runner/work/genisys/genisys/packages/webchat-client
|
3
3
|
> openapi-ts && vite build
|
4
4
|
|
5
5
|
⏳ Generating from raw OpenAPI specification
|
@@ -17,12 +17,12 @@ computing gzip size...
|
|
17
17
|
[2mdist/[22m[36mwebchat-client6.js [39m[1m[2m 0.53 kB[22m[1m[22m[2m │ gzip: 0.26 kB[22m
|
18
18
|
[2mdist/[22m[36mwebchat-client8.js [39m[1m[2m 2.63 kB[22m[1m[22m[2m │ gzip: 1.15 kB[22m
|
19
19
|
[2mdist/[22m[36mwebchat-client3.js [39m[1m[2m 2.78 kB[22m[1m[22m[2m │ gzip: 0.52 kB[22m
|
20
|
-
[2mdist/[22m[36mwebchat-client2.js [39m[1m[2m 3.
|
20
|
+
[2mdist/[22m[36mwebchat-client2.js [39m[1m[2m 3.74 kB[22m[1m[22m[2m │ gzip: 1.06 kB[22m
|
21
21
|
[2mdist/[22m[36mwebchat-client9.js [39m[1m[2m 8.58 kB[22m[1m[22m[2m │ gzip: 2.91 kB[22m
|
22
22
|
[2mdist/[22m[36mwebchat-client5.js [39m[1m[2m10.93 kB[22m[1m[22m[2m │ gzip: 3.47 kB[22m
|
23
23
|
[vite:dts] Start rollup declaration files...
|
24
24
|
Analysis will use the bundled TypeScript version 5.4.2
|
25
25
|
*** The target project appears to use TypeScript 5.6.2 which is newer than the bundled compiler engine; consider upgrading API Extractor.
|
26
|
-
[vite:dts] Declaration files built in
|
26
|
+
[vite:dts] Declaration files built in 5765ms.
|
27
27
|
|
28
|
-
[32m✓ built in 6.
|
28
|
+
[32m✓ built in 6.16s[39m
|
package/dist/webchat-client2.js
CHANGED
@@ -1,60 +1,59 @@
|
|
1
|
-
import { createUser as
|
2
|
-
import { client as
|
3
|
-
import { EventSource as
|
4
|
-
import { EventEmitter as
|
5
|
-
const n = (a) => a.data,
|
1
|
+
import { createUser as u, getEvent as f, createEvent as U, deleteUser as M, updateUser as y, getUser as R, createFile as b, deleteMessage as P, getMessage as T, updateMessage as $, createMessage as S, listParticipants as _, getParticipant as A, removeParticipant as I, addParticipant as q, listConversationMessages as w, listConversations as x, deleteConversation as N, getConversation as F, createConversation as J } from "./webchat-client3.js";
|
2
|
+
import { client as m } from "./webchat-client4.js";
|
3
|
+
import { EventSource as L } from "./webchat-client5.js";
|
4
|
+
import { EventEmitter as O } from "./webchat-client6.js";
|
5
|
+
const n = (a) => a.data, E = {
|
6
6
|
throwOnError: !0
|
7
|
-
},
|
8
|
-
const
|
9
|
-
...
|
10
|
-
baseUrl:
|
7
|
+
}, z = ({ clientId: a, apiUrl: d }) => {
|
8
|
+
const p = `${d || m.getConfig().baseUrl}/${a}`, t = {
|
9
|
+
...E,
|
10
|
+
baseUrl: p
|
11
11
|
};
|
12
|
-
return
|
13
|
-
},
|
12
|
+
return u({ ...t, body: {} }).then(n);
|
13
|
+
}, B = ({
|
14
14
|
userKey: a,
|
15
|
-
clientId:
|
16
|
-
apiUrl:
|
15
|
+
clientId: d,
|
16
|
+
apiUrl: p
|
17
17
|
}) => {
|
18
18
|
const t = {
|
19
19
|
"x-user-key": a
|
20
|
-
},
|
21
|
-
...
|
22
|
-
baseUrl:
|
20
|
+
}, g = `${p || m.getConfig().baseUrl}/${d}`, r = {
|
21
|
+
...E,
|
22
|
+
baseUrl: g
|
23
23
|
};
|
24
24
|
return {
|
25
|
-
createConversation: () =>
|
26
|
-
getConversation: ({ conversationId: e }) =>
|
27
|
-
deleteConversation: ({ conversationId: e }) =>
|
28
|
-
listConversations: ({ nextToken: e }) =>
|
29
|
-
listConversationMessages: ({ conversationId: e, nextToken: s }) =>
|
25
|
+
createConversation: () => J({ ...r, headers: t, body: {} }).then(n),
|
26
|
+
getConversation: ({ conversationId: e }) => F({ ...r, headers: t, path: { id: e } }).then(n),
|
27
|
+
deleteConversation: ({ conversationId: e }) => N({ ...r, headers: t, path: { id: e } }).then(n),
|
28
|
+
listConversations: ({ nextToken: e }) => x({ ...r, headers: t, query: { nextToken: e } }).then(n),
|
29
|
+
listConversationMessages: ({ conversationId: e, nextToken: s }) => w({
|
30
30
|
...r,
|
31
31
|
headers: t,
|
32
32
|
path: { id: e },
|
33
33
|
query: { nextToken: s }
|
34
34
|
}).then(n),
|
35
|
-
addParticipant: ({ conversationId: e, userId: s }) =>
|
36
|
-
removeParticipant: ({ conversationId: e, userId: s }) =>
|
37
|
-
getParticipant: ({ conversationId: e, userId: s }) =>
|
38
|
-
listParticipants: ({ conversationId: e, nextToken: s }) =>
|
39
|
-
createMessage: (e) =>
|
40
|
-
updateMessage: ({ messageId: e, ...s }) =>
|
41
|
-
getMessage: ({ messageId: e }) =>
|
42
|
-
deleteMessage: ({ messageId: e }) =>
|
35
|
+
addParticipant: ({ conversationId: e, userId: s }) => q({ ...r, headers: t, path: { id: e }, body: { userId: s } }).then(n),
|
36
|
+
removeParticipant: ({ conversationId: e, userId: s }) => I({ ...r, headers: t, path: { id: e, userId: s } }).then(n),
|
37
|
+
getParticipant: ({ conversationId: e, userId: s }) => A({ ...r, headers: t, path: { id: e, userId: s } }).then(n),
|
38
|
+
listParticipants: ({ conversationId: e, nextToken: s }) => _({ ...r, headers: t, path: { id: e }, query: { nextToken: s } }).then(n),
|
39
|
+
createMessage: (e) => S({ ...r, headers: t, body: e }).then(n),
|
40
|
+
updateMessage: ({ messageId: e, ...s }) => $({ ...r, headers: t, path: { id: e }, body: s }).then(n),
|
41
|
+
getMessage: ({ messageId: e }) => T({ ...r, headers: t, path: { id: e } }).then(n),
|
42
|
+
deleteMessage: ({ messageId: e }) => P({ ...r, headers: t, path: { id: e } }).then(n),
|
43
43
|
createFile: (e) => b({ ...r, headers: t, body: e }).then(n),
|
44
|
-
createUser: (e) =>
|
45
|
-
getUser: () =>
|
46
|
-
updateUser: (e) =>
|
47
|
-
deleteUser: () =>
|
48
|
-
createEvent: (e) =>
|
49
|
-
getEvent: ({ eventId: e }) =>
|
44
|
+
createUser: (e) => u({ ...r, headers: t, body: e }).then(n),
|
45
|
+
getUser: () => R({ ...r, headers: t }).then(n),
|
46
|
+
updateUser: (e) => y({ ...r, headers: t, body: e }).then(n),
|
47
|
+
deleteUser: () => M({ ...r, headers: t }).then(n),
|
48
|
+
createEvent: (e) => U({ ...r, headers: t, body: e }).then(n),
|
49
|
+
getEvent: ({ eventId: e }) => f({ ...r, headers: t, path: { id: e } }).then(n),
|
50
50
|
listenConversation: ({ conversationId: e }) => {
|
51
|
-
let
|
52
|
-
const
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
fetch: (c, o) => fetch(c, {
|
51
|
+
let l = 0, i = null;
|
52
|
+
const c = new O(), v = () => {
|
53
|
+
i && i.close();
|
54
|
+
const C = `${g}/conversations/${e}/listen`;
|
55
|
+
i = new L(C, {
|
56
|
+
fetch: (h, o) => fetch(h, {
|
58
57
|
...o,
|
59
58
|
headers: {
|
60
59
|
...o == null ? void 0 : o.headers,
|
@@ -62,16 +61,17 @@ const n = (a) => a.data, v = {
|
|
62
61
|
timeout: "60_000"
|
63
62
|
}
|
64
63
|
})
|
65
|
-
}),
|
66
|
-
|
67
|
-
},
|
68
|
-
const o =
|
69
|
-
|
64
|
+
}), i.onopen = () => c.emit("open"), i.onerror = (h) => {
|
65
|
+
c.emit("error", h), l < 10 && (l++, setTimeout(() => v(), 3e3));
|
66
|
+
}, i.onmessage = (h) => {
|
67
|
+
const o = V(h.data);
|
68
|
+
c.emit(o.type, o.data);
|
70
69
|
};
|
71
|
-
}
|
70
|
+
};
|
71
|
+
return v(), c.on.bind(c);
|
72
72
|
}
|
73
73
|
};
|
74
|
-
},
|
74
|
+
}, V = (a) => {
|
75
75
|
try {
|
76
76
|
return JSON.parse(a);
|
77
77
|
} catch {
|
@@ -79,6 +79,6 @@ const n = (a) => a.data, v = {
|
|
79
79
|
}
|
80
80
|
};
|
81
81
|
export {
|
82
|
-
|
83
|
-
|
82
|
+
B as createClient,
|
83
|
+
z as createUser
|
84
84
|
};
|
package/package.json
CHANGED
package/src/client/client.ts
CHANGED
@@ -137,7 +137,7 @@ export const createClient = ({
|
|
137
137
|
createEvent: (body) => sdk.createEvent({ ...configs, headers, body }).then(extractData),
|
138
138
|
getEvent: ({ eventId }) => sdk.getEvent({ ...configs, headers, path: { id: eventId } }).then(extractData),
|
139
139
|
listenConversation: ({ conversationId }) => {
|
140
|
-
const MAX_RETRIES =
|
140
|
+
const MAX_RETRIES = 10
|
141
141
|
const RETRY_INTERVAL = 3000 // ms
|
142
142
|
let retryCount = 0
|
143
143
|
let eventSource: EventSource | null = null
|
@@ -166,11 +166,9 @@ export const createClient = ({
|
|
166
166
|
eventSource.onerror = (err) => {
|
167
167
|
eventEmitter.emit('error', err)
|
168
168
|
|
169
|
-
// Attempt reconnect with limit
|
170
169
|
if (retryCount < MAX_RETRIES) {
|
171
170
|
retryCount++
|
172
|
-
|
173
|
-
// setTimeout(() => connect(), RETRY_INTERVAL)
|
171
|
+
setTimeout(() => connect(), RETRY_INTERVAL)
|
174
172
|
}
|
175
173
|
}
|
176
174
|
eventSource.onmessage = (ev) => {
|
package/vite.config.ts
CHANGED
@@ -4,7 +4,7 @@ import treeShakeable from 'rollup-plugin-tree-shakeable'
|
|
4
4
|
import dts from 'vite-plugin-dts'
|
5
5
|
|
6
6
|
export default defineConfig({
|
7
|
-
plugins: [treeShakeable(), dts({ rollupTypes: true })],
|
7
|
+
plugins: [treeShakeable() as any, dts({ rollupTypes: true })],
|
8
8
|
build: {
|
9
9
|
lib: {
|
10
10
|
entry: resolve(__dirname, 'src/index.ts'),
|