@botpress/webchat-client 0.3.1 → 0.5.0
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 +7 -7
- package/dist/index.d.ts +902 -114
- package/dist/webchat-client9.js +26 -26
- package/eslint.config.mjs +10 -0
- package/package.json +4 -3
- package/src/client/client.ts +1 -1
- package/.eslintrc.cjs +0 -11
package/dist/webchat-client9.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
class E extends Error {
|
|
2
|
-
constructor(d,
|
|
3
|
-
super(d), this.name = "ParseError", this.type =
|
|
2
|
+
constructor(d, i) {
|
|
3
|
+
super(d), this.name = "ParseError", this.type = i.type, this.field = i.field, this.value = i.value, this.line = i.line;
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
function x(n) {
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function w(n) {
|
|
9
9
|
if (typeof n == "function")
|
|
10
10
|
throw new TypeError(
|
|
11
11
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
12
12
|
);
|
|
13
|
-
const { onEvent: d = x, onError:
|
|
14
|
-
let
|
|
13
|
+
const { onEvent: d = x, onError: i = x, onRetry: r = x, onComment: c } = n;
|
|
14
|
+
let o = "", s = !0, f, a = "", p = "";
|
|
15
15
|
function b(e) {
|
|
16
|
-
const t =
|
|
16
|
+
const t = s ? e.replace(/^\xEF\xBB\xBF/, "") : e, [l, u] = g(`${o}${t}`);
|
|
17
17
|
for (const h of l)
|
|
18
18
|
y(h);
|
|
19
|
-
|
|
19
|
+
o = u, s = !1;
|
|
20
20
|
}
|
|
21
21
|
function y(e) {
|
|
22
22
|
if (e === "") {
|
|
@@ -24,7 +24,7 @@ function I(n) {
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
if (e.startsWith(":")) {
|
|
27
|
-
|
|
27
|
+
c && c(e.slice(e.startsWith(": ") ? 2 : 1));
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const t = e.indexOf(":");
|
|
@@ -41,14 +41,14 @@ function I(n) {
|
|
|
41
41
|
p = t;
|
|
42
42
|
break;
|
|
43
43
|
case "data":
|
|
44
|
-
|
|
44
|
+
a = `${a}${t}
|
|
45
45
|
`;
|
|
46
46
|
break;
|
|
47
47
|
case "id":
|
|
48
48
|
f = t.includes("\0") ? void 0 : t;
|
|
49
49
|
break;
|
|
50
50
|
case "retry":
|
|
51
|
-
/^\d+$/.test(t) ? r(parseInt(t, 10)) :
|
|
51
|
+
/^\d+$/.test(t) ? r(parseInt(t, 10)) : i(
|
|
52
52
|
new E(`Invalid \`retry\` value: "${t}"`, {
|
|
53
53
|
type: "invalid-retry",
|
|
54
54
|
value: t,
|
|
@@ -57,7 +57,7 @@ function I(n) {
|
|
|
57
57
|
);
|
|
58
58
|
break;
|
|
59
59
|
default:
|
|
60
|
-
|
|
60
|
+
i(
|
|
61
61
|
new E(
|
|
62
62
|
`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}…` : e}"`,
|
|
63
63
|
{ type: "unknown-field", field: e, value: t, line: l }
|
|
@@ -67,39 +67,39 @@ function I(n) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
function v() {
|
|
70
|
-
|
|
70
|
+
a.length > 0 && d({
|
|
71
71
|
id: f,
|
|
72
72
|
event: p || void 0,
|
|
73
73
|
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
|
|
74
74
|
// then remove the last character from the data buffer.
|
|
75
|
-
data:
|
|
76
|
-
`) ?
|
|
77
|
-
}), f = void 0,
|
|
75
|
+
data: a.endsWith(`
|
|
76
|
+
`) ? a.slice(0, -1) : a
|
|
77
|
+
}), f = void 0, a = "", p = "";
|
|
78
78
|
}
|
|
79
79
|
function $(e = {}) {
|
|
80
|
-
|
|
80
|
+
o && e.consume && y(o), s = !0, f = void 0, a = "", p = "", o = "";
|
|
81
81
|
}
|
|
82
82
|
return { feed: b, reset: $ };
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function g(n) {
|
|
85
85
|
const d = [];
|
|
86
|
-
let
|
|
86
|
+
let i = "", r = 0;
|
|
87
87
|
for (; r < n.length; ) {
|
|
88
|
-
const
|
|
88
|
+
const c = n.indexOf("\r", r), o = n.indexOf(`
|
|
89
89
|
`, r);
|
|
90
|
-
let
|
|
91
|
-
if (
|
|
92
|
-
|
|
90
|
+
let s = -1;
|
|
91
|
+
if (c !== -1 && o !== -1 ? s = Math.min(c, o) : c !== -1 ? c === n.length - 1 ? s = -1 : s = c : o !== -1 && (s = o), s === -1) {
|
|
92
|
+
i = n.slice(r);
|
|
93
93
|
break;
|
|
94
94
|
} else {
|
|
95
|
-
const f = n.slice(r,
|
|
96
|
-
d.push(f), r =
|
|
95
|
+
const f = n.slice(r, s);
|
|
96
|
+
d.push(f), r = s + 1, n[r - 1] === "\r" && n[r] === `
|
|
97
97
|
` && r++;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
return [d,
|
|
100
|
+
return [d, i];
|
|
101
101
|
}
|
|
102
102
|
export {
|
|
103
103
|
E as ParseError,
|
|
104
|
-
|
|
104
|
+
w as createParser
|
|
105
105
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { clientInternalConfig } from '@repo/eslint-config/client-internal'
|
|
2
|
+
import { defineConfig } from 'eslint/config'
|
|
3
|
+
|
|
4
|
+
export default defineConfig([clientInternalConfig], {
|
|
5
|
+
languageOptions: {
|
|
6
|
+
parserOptions: {
|
|
7
|
+
tsconfigRootDir: import.meta.dirname,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/webchat-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"import": "./dist/webchat-client.js",
|
|
22
|
+
"require": "./dist/webchat-client.js",
|
|
22
23
|
"types": "./dist/index.d.ts"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"eventsource": "^3.0.6"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@bpinternal/webchat-http-client": "0.
|
|
33
|
+
"@bpinternal/webchat-http-client": "0.10.0",
|
|
33
34
|
"@hey-api/client-fetch": "^0.10.0",
|
|
34
35
|
"@hey-api/openapi-ts": "^0.66.4",
|
|
35
36
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -39,6 +40,6 @@
|
|
|
39
40
|
"glob": "^11.0.1",
|
|
40
41
|
"rollup-plugin-tree-shakeable": "^1.0.3",
|
|
41
42
|
"vite": "^5.4.8",
|
|
42
|
-
"vite-plugin-dts": "^
|
|
43
|
+
"vite-plugin-dts": "^4.5.4"
|
|
43
44
|
}
|
|
44
45
|
}
|
package/src/client/client.ts
CHANGED
|
@@ -65,7 +65,7 @@ export type Client = {
|
|
|
65
65
|
deleteMessage: (params: MessageIdParam) => Promise<ClientTypes.DeleteMessageResponse>
|
|
66
66
|
createFile: (params: ClientTypes.CreateFileBody) => Promise<ClientTypes.CreateFileResponse>
|
|
67
67
|
getUser: () => Promise<ClientTypes.GetUserResponse>
|
|
68
|
-
updateUser: (params: ClientTypes.
|
|
68
|
+
updateUser: (params: ClientTypes.UpdateUserBody) => Promise<ClientTypes.UpdateUserResponse>
|
|
69
69
|
deleteUser: (params: UserIdParam) => Promise<ClientTypes.DeleteUserResponse>
|
|
70
70
|
createEvent: (params: ClientTypes.CreateEventBody) => Promise<ClientTypes.CreateEventResponse>
|
|
71
71
|
getEvent: (params: EventIdParam) => Promise<ClientTypes.GetEventResponse>
|
package/.eslintrc.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** @type {import("eslint").Linter.Config} */
|
|
2
|
-
module.exports = {
|
|
3
|
-
root: true,
|
|
4
|
-
extends: ["@repo/eslint-config/react-internal.js"],
|
|
5
|
-
parser: "@typescript-eslint/parser",
|
|
6
|
-
ignorePatterns: ["dist", "node_modules", "storybook-static", ".turbo", "turbo/*"],
|
|
7
|
-
parserOptions: {
|
|
8
|
-
project: "./tsconfig.json",
|
|
9
|
-
tsconfigRootDir: __dirname,
|
|
10
|
-
},
|
|
11
|
-
};
|