@botpress/webchat-client 0.1.1 → 0.2.0-beta.2

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.
@@ -1,5 +1,6 @@
1
- import { createClient as t, createUser as a } from "./webchat-client2.js";
1
+ import { createClient as t, createUser as a, generateUserKey as c } from "./webchat-client2.js";
2
2
  export {
3
3
  t as createClient,
4
- a as createUser
4
+ a as createUser,
5
+ c as generateUserKey
5
6
  };
@@ -0,0 +1,218 @@
1
+ var R = Object.defineProperty;
2
+ var T = (t, r, e) => r in t ? R(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
+ var j = (t, r, e) => T(t, typeof r != "symbol" ? r + "" : r, e);
4
+ var U = async (t, r) => {
5
+ let e = typeof r == "function" ? await r(t) : r;
6
+ if (e) return t.scheme === "bearer" ? `Bearer ${e}` : t.scheme === "basic" ? `Basic ${btoa(e)}` : e;
7
+ }, A = { bodySerializer: (t) => JSON.stringify(t, (r, e) => typeof e == "bigint" ? e.toString() : e) }, _ = (t) => {
8
+ switch (t) {
9
+ case "label":
10
+ return ".";
11
+ case "matrix":
12
+ return ";";
13
+ case "simple":
14
+ return ",";
15
+ default:
16
+ return "&";
17
+ }
18
+ }, z = (t) => {
19
+ switch (t) {
20
+ case "form":
21
+ return ",";
22
+ case "pipeDelimited":
23
+ return "|";
24
+ case "spaceDelimited":
25
+ return "%20";
26
+ default:
27
+ return ",";
28
+ }
29
+ }, E = (t) => {
30
+ switch (t) {
31
+ case "label":
32
+ return ".";
33
+ case "matrix":
34
+ return ";";
35
+ case "simple":
36
+ return ",";
37
+ default:
38
+ return "&";
39
+ }
40
+ }, x = ({ allowReserved: t, explode: r, name: e, style: l, value: n }) => {
41
+ if (!r) {
42
+ let s = (t ? n : n.map((i) => encodeURIComponent(i))).join(z(l));
43
+ switch (l) {
44
+ case "label":
45
+ return `.${s}`;
46
+ case "matrix":
47
+ return `;${e}=${s}`;
48
+ case "simple":
49
+ return s;
50
+ default:
51
+ return `${e}=${s}`;
52
+ }
53
+ }
54
+ let o = _(l), a = n.map((s) => l === "label" || l === "simple" ? t ? s : encodeURIComponent(s) : b({ allowReserved: t, name: e, value: s })).join(o);
55
+ return l === "label" || l === "matrix" ? o + a : a;
56
+ }, b = ({ allowReserved: t, name: r, value: e }) => {
57
+ if (e == null) return "";
58
+ if (typeof e == "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
59
+ return `${r}=${t ? e : encodeURIComponent(e)}`;
60
+ }, $ = ({ allowReserved: t, explode: r, name: e, style: l, value: n }) => {
61
+ if (n instanceof Date) return `${e}=${n.toISOString()}`;
62
+ if (l !== "deepObject" && !r) {
63
+ let s = [];
64
+ Object.entries(n).forEach(([d, f]) => {
65
+ s = [...s, d, t ? f : encodeURIComponent(f)];
66
+ });
67
+ let i = s.join(",");
68
+ switch (l) {
69
+ case "form":
70
+ return `${e}=${i}`;
71
+ case "label":
72
+ return `.${i}`;
73
+ case "matrix":
74
+ return `;${e}=${i}`;
75
+ default:
76
+ return i;
77
+ }
78
+ }
79
+ let o = E(l), a = Object.entries(n).map(([s, i]) => b({ allowReserved: t, name: l === "deepObject" ? `${e}[${s}]` : s, value: i })).join(o);
80
+ return l === "label" || l === "matrix" ? o + a : a;
81
+ }, W = /\{[^{}]+\}/g, D = ({ path: t, url: r }) => {
82
+ let e = r, l = r.match(W);
83
+ if (l) for (let n of l) {
84
+ let o = !1, a = n.substring(1, n.length - 1), s = "simple";
85
+ a.endsWith("*") && (o = !0, a = a.substring(0, a.length - 1)), a.startsWith(".") ? (a = a.substring(1), s = "label") : a.startsWith(";") && (a = a.substring(1), s = "matrix");
86
+ let i = t[a];
87
+ if (i == null) continue;
88
+ if (Array.isArray(i)) {
89
+ e = e.replace(n, x({ explode: o, name: a, style: s, value: i }));
90
+ continue;
91
+ }
92
+ if (typeof i == "object") {
93
+ e = e.replace(n, $({ explode: o, name: a, style: s, value: i }));
94
+ continue;
95
+ }
96
+ if (s === "matrix") {
97
+ e = e.replace(n, `;${b({ name: a, value: i })}`);
98
+ continue;
99
+ }
100
+ let d = encodeURIComponent(s === "label" ? `.${i}` : i);
101
+ e = e.replace(n, d);
102
+ }
103
+ return e;
104
+ }, q = ({ allowReserved: t, array: r, object: e } = {}) => (l) => {
105
+ let n = [];
106
+ if (l && typeof l == "object") for (let o in l) {
107
+ let a = l[o];
108
+ if (a != null) {
109
+ if (Array.isArray(a)) {
110
+ n = [...n, x({ allowReserved: t, explode: !0, name: o, style: "form", value: a, ...r })];
111
+ continue;
112
+ }
113
+ if (typeof a == "object") {
114
+ n = [...n, $({ allowReserved: t, explode: !0, name: o, style: "deepObject", value: a, ...e })];
115
+ continue;
116
+ }
117
+ n = [...n, b({ allowReserved: t, name: o, value: a })];
118
+ }
119
+ }
120
+ return n.join("&");
121
+ }, I = (t) => {
122
+ var e;
123
+ if (!t) return "stream";
124
+ let r = (e = t.split(";")[0]) == null ? void 0 : e.trim();
125
+ if (r) {
126
+ if (r.startsWith("application/json") || r.endsWith("+json")) return "json";
127
+ if (r === "multipart/form-data") return "formData";
128
+ if (["application/", "audio/", "image/", "video/"].some((l) => r.startsWith(l))) return "blob";
129
+ if (r.startsWith("text/")) return "text";
130
+ }
131
+ }, k = async ({ security: t, ...r }) => {
132
+ for (let e of t) {
133
+ let l = await U(e, r.auth);
134
+ if (!l) continue;
135
+ let n = e.name ?? "Authorization";
136
+ switch (e.in) {
137
+ case "query":
138
+ r.query || (r.query = {}), r.query[n] = l;
139
+ break;
140
+ case "cookie":
141
+ r.headers.append("Cookie", `${n}=${l}`);
142
+ break;
143
+ case "header":
144
+ default:
145
+ r.headers.set(n, l);
146
+ break;
147
+ }
148
+ return;
149
+ }
150
+ }, v = (t) => N({ baseUrl: t.baseUrl, path: t.path, query: t.query, querySerializer: typeof t.querySerializer == "function" ? t.querySerializer : q(t.querySerializer), url: t.url }), N = ({ baseUrl: t, path: r, query: e, querySerializer: l, url: n }) => {
151
+ let o = n.startsWith("/") ? n : `/${n}`, a = (t ?? "") + o;
152
+ r && (a = D({ path: r, url: a }));
153
+ let s = e ? l(e) : "";
154
+ return s.startsWith("?") && (s = s.substring(1)), s && (a += `?${s}`), a;
155
+ }, g = (t, r) => {
156
+ var l;
157
+ let e = { ...t, ...r };
158
+ return (l = e.baseUrl) != null && l.endsWith("/") && (e.baseUrl = e.baseUrl.substring(0, e.baseUrl.length - 1)), e.headers = C(t.headers, r.headers), e;
159
+ }, C = (...t) => {
160
+ let r = new Headers();
161
+ for (let e of t) {
162
+ if (!e || typeof e != "object") continue;
163
+ let l = e instanceof Headers ? e.entries() : Object.entries(e);
164
+ for (let [n, o] of l) if (o === null) r.delete(n);
165
+ else if (Array.isArray(o)) for (let a of o) r.append(n, a);
166
+ else o !== void 0 && r.set(n, typeof o == "object" ? JSON.stringify(o) : o);
167
+ }
168
+ return r;
169
+ }, w = class {
170
+ constructor() {
171
+ j(this, "_fns");
172
+ this._fns = [];
173
+ }
174
+ clear() {
175
+ this._fns = [];
176
+ }
177
+ exists(t) {
178
+ return this._fns.indexOf(t) !== -1;
179
+ }
180
+ eject(t) {
181
+ let r = this._fns.indexOf(t);
182
+ r !== -1 && (this._fns = [...this._fns.slice(0, r), ...this._fns.slice(r + 1)]);
183
+ }
184
+ use(t) {
185
+ this._fns = [...this._fns, t];
186
+ }
187
+ }, P = () => ({ error: new w(), request: new w(), response: new w() }), H = /* @__PURE__ */ q({ allowReserved: !1, array: { explode: !0, style: "form" }, object: { explode: !0, style: "deepObject" } }), J = { "Content-Type": "application/json" }, O = (t = {}) => ({ ...A, headers: J, parseAs: "auto", querySerializer: H, ...t }), B = (t = {}) => {
188
+ let r = g(O(), t), e = () => ({ ...r }), l = (a) => (r = g(r, a), e()), n = P(), o = async (a) => {
189
+ let s = { ...r, ...a, fetch: a.fetch ?? r.fetch ?? globalThis.fetch, headers: C(r.headers, a.headers) };
190
+ s.security && await k({ ...s, security: s.security }), s.body && s.bodySerializer && (s.body = s.bodySerializer(s.body)), (s.body === void 0 || s.body === "") && s.headers.delete("Content-Type");
191
+ let i = v(s), d = { redirect: "follow", ...s }, f = new Request(i, d);
192
+ for (let c of n.request._fns) f = await c(f, s);
193
+ let S = s.fetch, u = await S(f);
194
+ for (let c of n.response._fns) u = await c(u, f, s);
195
+ let h = { request: f, response: u };
196
+ if (u.ok) {
197
+ if (u.status === 204 || u.headers.get("Content-Length") === "0") return { data: {}, ...h };
198
+ let c = (s.parseAs === "auto" ? I(u.headers.get("Content-Type")) : s.parseAs) ?? "json";
199
+ if (c === "stream") return { data: u.body, ...h };
200
+ let m = await u[c]();
201
+ return c === "json" && (s.responseValidator && await s.responseValidator(m), s.responseTransformer && (m = await s.responseTransformer(m))), { data: m, ...h };
202
+ }
203
+ let y = await u.text();
204
+ try {
205
+ y = JSON.parse(y);
206
+ } catch {
207
+ }
208
+ let p = y;
209
+ for (let c of n.error._fns) p = await c(y, u, f, s);
210
+ if (p = p || {}, s.throwOnError) throw p;
211
+ return { error: p, ...h };
212
+ };
213
+ return { buildUrl: v, connect: (a) => o({ ...a, method: "CONNECT" }), delete: (a) => o({ ...a, method: "DELETE" }), get: (a) => o({ ...a, method: "GET" }), getConfig: e, head: (a) => o({ ...a, method: "HEAD" }), interceptors: n, options: (a) => o({ ...a, method: "OPTIONS" }), patch: (a) => o({ ...a, method: "PATCH" }), post: (a) => o({ ...a, method: "POST" }), put: (a) => o({ ...a, method: "PUT" }), request: o, setConfig: l, trace: (a) => o({ ...a, method: "TRACE" }) };
214
+ }, V = B, G = O;
215
+ export {
216
+ V as createClient,
217
+ G as createConfig
218
+ };
@@ -1,59 +1,85 @@
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 = {
1
+ import { createUser as U, generateUserKey as y, removeMessageFeedback as M, addMessageFeedback as b, getEvent as $, createEvent as R, deleteUser as P, updateUser as k, getUser as T, createFile as _, deleteMessage as x, getMessage as F, updateMessage as I, createMessage as S, listParticipants as A, getParticipant as q, removeParticipant as w, addParticipant as K, listConversationMessages as N, listConversations as J, deleteConversation as L, getConversation as O, createConversation as V } from "./webchat-client3.js";
2
+ import { client as i } from "./webchat-client4.js";
3
+ import { EventSource as X } from "./webchat-client5.js";
4
+ import { throwErrorInterceptor as E } from "./webchat-client6.js";
5
+ import { createEventEmitter as Y } from "./webchat-client7.js";
6
+ const n = (a) => a.data, v = {
6
7
  throwOnError: !0
7
- }, z = ({ clientId: a, apiUrl: d }) => {
8
- const p = `${d || m.getConfig().baseUrl}/${a}`, t = {
9
- ...E,
10
- baseUrl: p
8
+ }, W = async ({
9
+ clientId: a,
10
+ apiUrl: p,
11
+ adminKey: c
12
+ }) => {
13
+ const t = `${p || i.getConfig().baseUrl}/${a}`;
14
+ i.interceptors.response._fns.length === 0 && i.interceptors.response.use(E);
15
+ const d = {
16
+ ...v,
17
+ baseUrl: t
18
+ };
19
+ return U({
20
+ ...d,
21
+ body: {},
22
+ headers: c ? { "x-admin-key": c } : void 0
23
+ }).then(n);
24
+ }, Z = async ({
25
+ adminKey: a,
26
+ expiresAt: p,
27
+ userId: c,
28
+ apiUrl: t,
29
+ clientId: d
30
+ }) => {
31
+ const s = { "x-admin-key": a }, m = `${t || i.getConfig().baseUrl}/${d}`, e = {
32
+ ...v,
33
+ baseUrl: m
11
34
  };
12
- return u({ ...t, body: {} }).then(n);
13
- }, B = ({
35
+ return y({ ...e, headers: s, body: { id: c, expiresAt: p } }).then(n);
36
+ }, ee = ({
14
37
  userKey: a,
15
- clientId: d,
16
- apiUrl: p
38
+ clientId: p,
39
+ apiUrl: c
17
40
  }) => {
18
41
  const t = {
19
42
  "x-user-key": a
20
- }, g = `${p || m.getConfig().baseUrl}/${d}`, r = {
21
- ...E,
22
- baseUrl: g
43
+ }, d = `${c || i.getConfig().baseUrl}/${p}`, s = {
44
+ ...v,
45
+ baseUrl: d
23
46
  };
24
- return {
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
- ...r,
47
+ return i.interceptors.response._fns.length === 0 && i.interceptors.response.use(E), {
48
+ createConversation: () => V({ ...s, headers: t, body: {} }).then(n),
49
+ getConversation: ({ conversationId: e }) => O({ ...s, headers: t, path: { id: e } }).then(n),
50
+ deleteConversation: ({ conversationId: e }) => L({ ...s, headers: t, path: { id: e } }).then(n),
51
+ listConversations: ({ nextToken: e }) => J({ ...s, headers: t, query: { nextToken: e } }).then(n),
52
+ listConversationMessages: ({ conversationId: e, nextToken: r }) => N({
53
+ ...s,
31
54
  headers: t,
32
55
  path: { id: e },
33
- query: { nextToken: s }
56
+ query: { nextToken: r }
34
57
  }).then(n),
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
- createFile: (e) => b({ ...r, headers: t, body: e }).then(n),
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),
58
+ addParticipant: ({ conversationId: e, userId: r }) => K({ ...s, headers: t, path: { id: e }, body: { userId: r } }).then(n),
59
+ removeParticipant: ({ conversationId: e, userId: r }) => w({ ...s, headers: t, path: { id: e, userId: r } }).then(n),
60
+ getParticipant: ({ conversationId: e, userId: r }) => q({ ...s, headers: t, path: { id: e, userId: r } }).then(n),
61
+ listParticipants: ({ conversationId: e, nextToken: r }) => A({ ...s, headers: t, path: { id: e }, query: { nextToken: r } }).then(n),
62
+ createMessage: (e) => S({ ...s, headers: t, body: e }).then(n),
63
+ updateMessage: ({ messageId: e, ...r }) => I({ ...s, headers: t, path: { id: e }, body: r }).then(n),
64
+ getMessage: ({ messageId: e }) => F({ ...s, headers: t, path: { id: e } }).then(n),
65
+ deleteMessage: ({ messageId: e }) => x({ ...s, headers: t, path: { id: e } }).then(n),
66
+ createFile: (e) => _({ ...s, headers: t, body: e }).then(n),
67
+ createUser: (e) => U({ ...s, headers: t, body: e }).then(n),
68
+ getUser: () => T({ ...s, headers: t }).then(n),
69
+ updateUser: (e) => k({ ...s, headers: t, body: e }).then(n),
70
+ deleteUser: () => P({ ...s, headers: t }).then(n),
71
+ createEvent: (e) => R({ ...s, headers: t, body: e }).then(n),
72
+ getEvent: ({ eventId: e }) => $({ ...s, headers: t, path: { id: e } }).then(n),
73
+ addMessageFeedback: ({ messageId: e, ...r }) => b({ ...s, headers: t, path: { id: e }, body: r }).then(n),
74
+ removeMessageFeedback: ({ messageId: e }) => M({ ...s, headers: t, path: { id: e } }).then(n),
75
+ generateUserKey: ({ adminKey: e, ...r }) => y({ ...s, headers: { "x-admin-key": e }, body: r }).then(n),
50
76
  listenConversation: ({ conversationId: e }) => {
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, {
77
+ let u = 0, h = null;
78
+ const l = Y(), f = () => {
79
+ h && h.close();
80
+ const C = `${d}/conversations/${e}/listen`;
81
+ h = new X(C, {
82
+ fetch: (g, o) => fetch(g, {
57
83
  ...o,
58
84
  headers: {
59
85
  ...o == null ? void 0 : o.headers,
@@ -61,17 +87,17 @@ const n = (a) => a.data, E = {
61
87
  timeout: "60_000"
62
88
  }
63
89
  })
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);
90
+ }), h.onopen = () => l.emit("open"), h.onerror = (g) => {
91
+ l.emit("error", g), u < 10 && (u++, setTimeout(() => f(), 3e3));
92
+ }, h.onmessage = (g) => {
93
+ const o = D(g.data);
94
+ l.emit(o.type, o.data);
69
95
  };
70
96
  };
71
- return v(), c.on.bind(c);
97
+ return f(), l.on;
72
98
  }
73
99
  };
74
- }, V = (a) => {
100
+ }, D = (a) => {
75
101
  try {
76
102
  return JSON.parse(a);
77
103
  } catch {
@@ -79,6 +105,7 @@ const n = (a) => a.data, E = {
79
105
  }
80
106
  };
81
107
  export {
82
- B as createClient,
83
- z as createUser
108
+ ee as createClient,
109
+ W as createUser,
110
+ Z as generateUserKey
84
111
  };
@@ -1,14 +1,14 @@
1
1
  import { client as r } from "./webchat-client4.js";
2
- const a = (e) => (e.client ?? r).delete({
2
+ const t = (e) => (e.client ?? r).delete({
3
3
  url: "/conversations/{id}",
4
4
  ...e
5
5
  }), c = (e) => (e.client ?? r).get({
6
6
  url: "/conversations/{id}",
7
7
  ...e
8
- }), n = (e) => (e.client ?? r).get({
8
+ }), l = (e) => (e.client ?? r).get({
9
9
  url: "/conversations",
10
10
  ...e
11
- }), l = (e) => (e.client ?? r).post({
11
+ }), n = (e) => (e.client ?? r).post({
12
12
  url: "/conversations",
13
13
  ...e,
14
14
  headers: {
@@ -31,60 +31,77 @@ const a = (e) => (e.client ?? r).delete({
31
31
  }), g = (e) => (e.client ?? r).delete({
32
32
  url: "/conversations/{id}/participants/{userId}",
33
33
  ...e
34
- }), i = (e) => (e.client ?? r).get({
34
+ }), h = (e) => (e.client ?? r).get({
35
35
  url: "/conversations/{id}/participants/{userId}",
36
36
  ...e
37
37
  }), v = (e) => (e.client ?? r).delete({
38
38
  url: "/messages/{id}",
39
39
  ...e
40
- }), h = (e) => (e.client ?? r).get({
40
+ }), C = (e) => (e.client ?? r).get({
41
41
  url: "/messages/{id}",
42
42
  ...e
43
- }), C = (e) => (e.client ?? r).put({
43
+ }), m = (e) => (e.client ?? r).put({
44
44
  url: "/messages/{id}",
45
45
  ...e,
46
46
  headers: {
47
47
  "Content-Type": "application/json",
48
48
  ...e == null ? void 0 : e.headers
49
49
  }
50
- }), m = (e) => (e.client ?? r).post({
50
+ }), i = (e) => (e.client ?? r).post({
51
51
  url: "/messages",
52
52
  ...e,
53
53
  headers: {
54
54
  "Content-Type": "application/json",
55
55
  ...e == null ? void 0 : e.headers
56
56
  }
57
- }), j = (e) => (e.client ?? r).delete({
57
+ }), y = (e) => (e.client ?? r).delete({
58
+ url: "/messages/{id}/feedback",
59
+ ...e
60
+ }), j = (e) => (e.client ?? r).put({
61
+ url: "/messages/{id}/feedback",
62
+ ...e,
63
+ headers: {
64
+ "Content-Type": "application/json",
65
+ ...e == null ? void 0 : e.headers
66
+ }
67
+ }), T = (e) => (e.client ?? r).delete({
58
68
  url: "/users/me",
59
69
  ...e
60
- }), y = (e) => (e.client ?? r).get({
70
+ }), M = (e) => (e.client ?? r).get({
61
71
  url: "/users/me",
62
72
  ...e
63
- }), T = (e) => (e.client ?? r).put({
73
+ }), k = (e) => (e.client ?? r).put({
64
74
  url: "/users/me",
65
75
  ...e,
66
76
  headers: {
67
77
  "Content-Type": "application/json",
68
78
  ...e == null ? void 0 : e.headers
69
79
  }
70
- }), M = (e) => ((e == null ? void 0 : e.client) ?? r).post({
80
+ }), U = (e) => ((e == null ? void 0 : e.client) ?? r).post({
71
81
  url: "/users",
72
82
  ...e,
73
83
  headers: {
74
84
  "Content-Type": "application/json",
75
85
  ...e == null ? void 0 : e.headers
76
86
  }
77
- }), P = (e) => (e.client ?? r).get({
87
+ }), b = (e) => ((e == null ? void 0 : e.client) ?? r).post({
88
+ url: "/users/key",
89
+ ...e,
90
+ headers: {
91
+ "Content-Type": "application/json",
92
+ ...e == null ? void 0 : e.headers
93
+ }
94
+ }), f = (e) => (e.client ?? r).get({
78
95
  url: "/events/{id}",
79
96
  ...e
80
- }), U = (e) => (e.client ?? r).post({
97
+ }), P = (e) => (e.client ?? r).post({
81
98
  url: "/events",
82
99
  ...e,
83
100
  headers: {
84
101
  "Content-Type": "application/json",
85
102
  ...e == null ? void 0 : e.headers
86
103
  }
87
- }), f = (e) => (e.client ?? r).post({
104
+ }), F = (e) => (e.client ?? r).post({
88
105
  url: "/files",
89
106
  ...e,
90
107
  headers: {
@@ -93,24 +110,27 @@ const a = (e) => (e.client ?? r).delete({
93
110
  }
94
111
  });
95
112
  export {
113
+ j as addMessageFeedback,
96
114
  d as addParticipant,
97
- l as createConversation,
98
- U as createEvent,
99
- f as createFile,
100
- m as createMessage,
101
- M as createUser,
102
- a as deleteConversation,
115
+ n as createConversation,
116
+ P as createEvent,
117
+ F as createFile,
118
+ i as createMessage,
119
+ U as createUser,
120
+ t as deleteConversation,
103
121
  v as deleteMessage,
104
- j as deleteUser,
122
+ T as deleteUser,
123
+ b as generateUserKey,
105
124
  c as getConversation,
106
- P as getEvent,
107
- h as getMessage,
108
- i as getParticipant,
109
- y as getUser,
125
+ f as getEvent,
126
+ C as getMessage,
127
+ h as getParticipant,
128
+ M as getUser,
110
129
  s as listConversationMessages,
111
- n as listConversations,
130
+ l as listConversations,
112
131
  u as listParticipants,
132
+ y as removeMessageFeedback,
113
133
  g as removeParticipant,
114
- C as updateMessage,
115
- T as updateUser
134
+ m as updateMessage,
135
+ k as updateUser
116
136
  };
@@ -1,5 +1,5 @@
1
- import { createClient as t, createConfig as e } from "./webchat-client9.js";
2
- import { createClientConfig as o } from "./webchat-client7.js";
1
+ import { createClient as t, createConfig as e } from "./webchat-client10.js";
2
+ import { createClientConfig as o } from "./webchat-client8.js";
3
3
  const i = /* @__PURE__ */ t(/* @__PURE__ */ o(/* @__PURE__ */ e({
4
4
  baseUrl: "https://webchat.botpress.cloud/"
5
5
  })));
@@ -1,4 +1,4 @@
1
- import { createParser as X } from "./webchat-client8.js";
1
+ import { createParser as X } from "./webchat-client9.js";
2
2
  class q extends Event {
3
3
  /**
4
4
  * Constructs a new `ErrorEvent` instance. This is typically not called directly,
@@ -1,23 +1,12 @@
1
- class h {
2
- constructor() {
3
- this.eventMap = {};
4
- }
5
- on(t, e) {
6
- var a;
7
- return this.eventMap[t] || (this.eventMap[t] = /* @__PURE__ */ new Set()), (a = this.eventMap[t]) == null || a.add(e), () => {
8
- var i;
9
- (i = this.eventMap[t]) == null || i.delete(e);
10
- };
11
- }
12
- emit(t, e) {
13
- var a, i;
14
- (a = this.eventMap[t]) == null || a.forEach((p) => {
15
- p(e);
16
- }), (i = this.eventMap["*"]) == null || i.forEach((p) => {
17
- p({ type: t, payload: e });
18
- });
1
+ async function c(r) {
2
+ var t;
3
+ const e = await r.clone().json();
4
+ if ((t = e == null ? void 0 : e.id) != null && t.startsWith("err_")) {
5
+ const o = new Error(e.message);
6
+ throw o.id = e.id, o.code = e.code, o.type = e.type, o;
19
7
  }
8
+ return r;
20
9
  }
21
10
  export {
22
- h as EventEmitter
11
+ c as throwErrorInterceptor
23
12
  };
@@ -1,11 +1,16 @@
1
- const e = (t) => ({
2
- ...t,
3
- withCredentials: !0,
4
- timeout: 6e4,
5
- maxBodyLength: 104857600,
6
- maxContentLength: 104857600,
7
- throwOnError: !0
8
- });
1
+ const i = () => {
2
+ const o = {};
3
+ return { on: (t, e) => {
4
+ var r;
5
+ return o[t] || (o[t] = /* @__PURE__ */ new Set()), (r = o[t]) == null || r.add(e), () => {
6
+ var n;
7
+ return (n = o[t]) == null ? void 0 : n.delete(e);
8
+ };
9
+ }, emit: (t, e) => {
10
+ var r, n;
11
+ (r = o[t]) == null || r.forEach((c) => c(e)), (n = o["*"]) == null || n.forEach((c) => c({ type: t, payload: e }));
12
+ } };
13
+ };
9
14
  export {
10
- e as createClientConfig
15
+ i as createEventEmitter
11
16
  };