crisp-api 10.10.6 → 10.11.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/CHANGELOG.md +6 -1
- package/EXAMPLES.md +74 -0
- package/README.md +101 -0
- package/dist/crisp.js +16 -23
- package/dist/events/Events.d.ts +2 -2
- package/dist/resources/PluginConnect.js +3 -3
- package/dist/resources/WebsiteBase.d.ts +0 -10
- package/dist/resources/WebsiteBase.js +0 -10
- package/dist/resources/WebsiteBatch.d.ts +0 -18
- package/dist/resources/WebsiteBatch.js +0 -18
- package/dist/resources/WebsiteCampaign.d.ts +0 -1
- package/dist/resources/WebsiteCampaign.js +0 -1
- package/dist/resources/WebsiteConversation.js +17 -20
- package/dist/resources/WebsiteHelpdesk.d.ts +2 -2
- package/dist/resources/WebsiteHelpdesk.js +8 -15
- package/dist/resources/WebsiteInbox.d.ts +2 -0
- package/dist/resources/WebsitePeople.js +1 -6
- package/dist/resources/WebsiteSettings.d.ts +6 -0
- package/dist/resources/WebsiteTeams.d.ts +54 -0
- package/dist/resources/WebsiteTeams.js +73 -0
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.js +1 -0
- package/dist/services/website.d.ts +2 -1
- package/dist/services/website.js +2 -0
- package/eslint.config.mjs +13 -184
- package/lib/crisp.ts +17 -22
- package/lib/events/Events.ts +2 -2
- package/lib/resources/PluginConnect.ts +3 -3
- package/lib/resources/WebsiteBase.ts +0 -10
- package/lib/resources/WebsiteBatch.ts +0 -18
- package/lib/resources/WebsiteCampaign.ts +0 -1
- package/lib/resources/WebsiteConversation.ts +17 -20
- package/lib/resources/WebsiteHelpdesk.ts +8 -15
- package/lib/resources/WebsiteInbox.ts +2 -0
- package/lib/resources/WebsitePeople.ts +1 -6
- package/lib/resources/WebsiteSettings.ts +6 -0
- package/lib/resources/WebsiteTeams.ts +109 -0
- package/lib/resources/index.ts +1 -0
- package/lib/services/bucket.ts +1 -0
- package/lib/services/media.ts +1 -0
- package/lib/services/plan.ts +1 -0
- package/lib/services/website.ts +3 -0
- package/package.json +4 -4
package/eslint.config.mjs
CHANGED
|
@@ -10,199 +10,28 @@
|
|
|
10
10
|
***************************************************************************/
|
|
11
11
|
|
|
12
12
|
// NPM
|
|
13
|
-
import globals from "globals";
|
|
14
13
|
import { defineConfig, globalIgnores } from "eslint/config";
|
|
15
14
|
import crisp from "eslint-plugin-crisp";
|
|
16
|
-
import tseslint from "@typescript-eslint/eslint-plugin";
|
|
17
|
-
import tsparser from "@typescript-eslint/parser";
|
|
18
|
-
import jsdoc from "eslint-plugin-jsdoc";
|
|
19
15
|
|
|
20
16
|
/**************************************************************************
|
|
21
17
|
* CONFIGURATION
|
|
22
18
|
***************************************************************************/
|
|
23
19
|
|
|
24
20
|
export default defineConfig([
|
|
25
|
-
// Additional TypeScript configuration
|
|
26
|
-
{
|
|
27
|
-
files: ["lib/*.ts", "lib/**/*.ts"],
|
|
28
|
-
languageOptions: {
|
|
29
|
-
parser: tsparser,
|
|
30
|
-
sourceType: "module",
|
|
31
|
-
ecmaVersion: 2020,
|
|
32
|
-
|
|
33
|
-
globals: {
|
|
34
|
-
...globals.browser,
|
|
35
|
-
...globals.node
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
plugins: {
|
|
39
|
-
crisp: crisp,
|
|
40
|
-
"@typescript-eslint": tseslint,
|
|
41
|
-
jsdoc: jsdoc
|
|
42
|
-
},
|
|
43
|
-
rules: {
|
|
44
|
-
"@typescript-eslint/no-explicit-any": "error",
|
|
45
|
-
|
|
46
|
-
// General JS rules
|
|
47
|
-
"arrow-parens": ["error", "always"],
|
|
48
|
-
"brace-style": [
|
|
49
|
-
"error",
|
|
50
|
-
"1tbs",
|
|
51
|
-
{
|
|
52
|
-
"allowSingleLine": true
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"comma-dangle": ["error", "never"],
|
|
56
|
-
"comma-spacing": ["error", { "before": false, "after": true }],
|
|
57
|
-
"comma-style": ["error", "last"],
|
|
58
|
-
"curly": "error",
|
|
59
|
-
"computed-property-spacing": ["error", "never"],
|
|
60
|
-
"default-param-last": "error",
|
|
61
|
-
"default-case-last": "error",
|
|
62
|
-
"dot-notation": "error",
|
|
63
|
-
"eqeqeq": "error",
|
|
64
|
-
"eol-last": "error",
|
|
65
|
-
"for-direction": "error",
|
|
66
|
-
"indent": [
|
|
67
|
-
"error",
|
|
68
|
-
2,
|
|
69
|
-
{
|
|
70
|
-
"SwitchCase": 1,
|
|
71
|
-
"FunctionDeclaration": {
|
|
72
|
-
"parameters": "off"
|
|
73
|
-
},
|
|
74
|
-
"FunctionExpression": {
|
|
75
|
-
"parameters": "off"
|
|
76
|
-
},
|
|
77
|
-
"CallExpression": {
|
|
78
|
-
"arguments": "off"
|
|
79
|
-
},
|
|
80
|
-
"VariableDeclarator": 1,
|
|
81
|
-
"outerIIFEBody": 0,
|
|
82
|
-
"ArrayExpression": 1,
|
|
83
|
-
"ObjectExpression": 1,
|
|
84
|
-
"ImportDeclaration": 1,
|
|
85
|
-
"flatTernaryExpressions": false,
|
|
86
|
-
"offsetTernaryExpressions": true
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
|
|
90
|
-
"keyword-spacing": "error",
|
|
91
|
-
"linebreak-style": ["error", "unix"],
|
|
92
|
-
"newline-per-chained-call": "error",
|
|
93
|
-
"no-console": "warn",
|
|
94
|
-
"no-debugger": "warn",
|
|
95
|
-
"no-eval": "error",
|
|
96
|
-
"no-implicit-coercion": "error",
|
|
97
|
-
"no-multi-str": "error",
|
|
98
|
-
"no-multiple-empty-lines": ["error", { max: 1 }],
|
|
99
|
-
"no-mixed-spaces-and-tabs": "error",
|
|
100
|
-
"no-restricted-syntax": [
|
|
101
|
-
"error",
|
|
102
|
-
{
|
|
103
|
-
"selector": "SwitchCase > *.consequent[type!='BlockStatement']",
|
|
104
|
-
"message": "Switch cases without braces are disallowed."
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
"no-tabs": "error",
|
|
108
|
-
"no-trailing-spaces": "error",
|
|
109
|
-
"no-undef": "error",
|
|
110
|
-
"no-unused-vars": "warn",
|
|
111
|
-
"no-unsafe-optional-chaining": "error",
|
|
112
|
-
"object-curly-newline": [
|
|
113
|
-
"error",
|
|
114
|
-
{
|
|
115
|
-
"multiline": true, "consistent": true
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
"object-curly-spacing": ["error", "always"],
|
|
119
|
-
"padded-blocks": ["error", "never"],
|
|
120
|
-
"padding-line-between-statements": [
|
|
121
|
-
"error",
|
|
122
|
-
{ "blankLine": "always", "prev": "let", "next": "*" },
|
|
123
|
-
{ "blankLine": "any", "prev": "let", "next": "let" },
|
|
124
|
-
{ "blankLine": "always", "prev": "const", "next": "*" },
|
|
125
|
-
{ "blankLine": "any", "prev": "const", "next": "const" },
|
|
126
|
-
{ "blankLine": "always", "prev": "block-like", "next": "*" },
|
|
127
|
-
{ "blankLine": "always", "prev": "*", "next": "break" },
|
|
128
|
-
{ "blankLine": "any", "prev": "empty", "next": "break" },
|
|
129
|
-
{ "blankLine": "always", "prev": "*", "next": "block-like" },
|
|
130
|
-
{ "blankLine": "any", "prev": "case", "next": "case" },
|
|
131
|
-
{ "blankLine": "always", "prev": "continue", "next": "*" },
|
|
132
|
-
{ "blankLine": "always", "prev": "break", "next": "*" }
|
|
133
|
-
],
|
|
134
|
-
"prefer-arrow-callback": "error",
|
|
135
|
-
"quotes": [
|
|
136
|
-
"error",
|
|
137
|
-
"double",
|
|
138
|
-
{
|
|
139
|
-
"avoidEscape": true, "allowTemplateLiterals": true
|
|
140
|
-
}
|
|
141
|
-
],
|
|
142
|
-
"quote-props": ["error", "as-needed"],
|
|
143
|
-
"semi": ["error", "always"],
|
|
144
|
-
"semi-style": ["error", "last"],
|
|
145
|
-
"semi-spacing": ["error", { "before": false, "after": true }],
|
|
146
|
-
"space-before-blocks": "error",
|
|
147
|
-
"space-in-parens": ["error", "never"],
|
|
148
|
-
"space-infix-ops": "error",
|
|
149
|
-
|
|
150
|
-
// Crisp JS rules
|
|
151
|
-
"crisp/align-comments": "error",
|
|
152
|
-
"crisp/enforce-optional": "error",
|
|
153
|
-
"crisp/header-check": "error",
|
|
154
|
-
"crisp/header-comments-check": "error",
|
|
155
|
-
"crisp/import-group-comment": "error",
|
|
156
|
-
"crisp/import-group-order": "error",
|
|
157
|
-
"crisp/methods-naming": "error",
|
|
158
|
-
"crisp/methods-ordering": "error",
|
|
159
|
-
"crisp/multiline-comment-end-backslash": "error",
|
|
160
|
-
"crisp/newline-after-switch-case": "error",
|
|
161
|
-
"crisp/no-async": "off",
|
|
162
|
-
"crisp/no-extra-line-within-function": "error",
|
|
163
|
-
"crisp/no-short-parameters": [
|
|
164
|
-
"error",
|
|
165
|
-
{
|
|
166
|
-
"exceptions": ["_", "$", "x", "y"]
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
"crisp/no-snake-case": "error",
|
|
170
|
-
"crisp/no-useless-template-literals": "error",
|
|
171
|
-
"crisp/no-var-in-blocks": "error",
|
|
172
|
-
"crisp/one-space-after-operator": [
|
|
173
|
-
"error",
|
|
174
|
-
{
|
|
175
|
-
"checkColon": false
|
|
176
|
-
}
|
|
177
|
-
],
|
|
178
|
-
"crisp/regex-in-constructor": "error",
|
|
179
|
-
"crisp/ternary-parenthesis": "error",
|
|
180
|
-
|
|
181
|
-
// General JSDoc rules
|
|
182
|
-
"jsdoc/require-description": "error",
|
|
183
|
-
"jsdoc/require-param-description": "off",
|
|
184
|
-
"jsdoc/require-property-description": "off",
|
|
185
|
-
"jsdoc/require-jsdoc": [
|
|
186
|
-
"error",
|
|
187
|
-
{
|
|
188
|
-
"require": {
|
|
189
|
-
"FunctionDeclaration": true,
|
|
190
|
-
"MethodDefinition": true,
|
|
191
|
-
"ClassDeclaration": true,
|
|
192
|
-
"ArrowFunctionExpression": false,
|
|
193
|
-
"FunctionExpression": false
|
|
194
|
-
},
|
|
195
|
-
"contexts": [
|
|
196
|
-
"Property[key.name=\"getters\"] > ObjectExpression > Property",
|
|
197
|
-
"Property[key.name=\"methods\"] > ObjectExpression > Property"
|
|
198
|
-
]
|
|
199
|
-
}
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
|
|
204
21
|
globalIgnores([
|
|
205
22
|
"dist/*",
|
|
206
23
|
"node_modules/*"
|
|
207
|
-
])
|
|
24
|
+
]),
|
|
25
|
+
|
|
26
|
+
{
|
|
27
|
+
files: ["lib/**/*.ts"],
|
|
28
|
+
extends: [crisp.configs["recommended-ts"]],
|
|
29
|
+
rules: {
|
|
30
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
31
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
32
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
33
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
34
|
+
"@typescript-eslint/no-redundant-type-constituents": "off"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
208
37
|
]);
|
package/lib/crisp.ts
CHANGED
|
@@ -263,7 +263,7 @@ class Crisp {
|
|
|
263
263
|
|
|
264
264
|
protected _brokerScheduler: typeof setTimeout | null = null;
|
|
265
265
|
|
|
266
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
267
|
protected _brokerBindHooks: ((modeInstance: any, emitter: any) => void)[] = [];
|
|
268
268
|
|
|
269
269
|
protected _boundEvents = {};
|
|
@@ -431,7 +431,6 @@ class Crisp {
|
|
|
431
431
|
* Binds RTM event (typed variant)
|
|
432
432
|
*/
|
|
433
433
|
on<Name extends EventName>(
|
|
434
|
-
// eslint-disable-next-line no-unused-vars
|
|
435
434
|
event: Name, callback: (data: EventsMap[Name]) => unknown
|
|
436
435
|
): Promise<unknown>;
|
|
437
436
|
|
|
@@ -439,14 +438,14 @@ class Crisp {
|
|
|
439
438
|
* Binds RTM event (loose variant)
|
|
440
439
|
*/
|
|
441
440
|
on(
|
|
442
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
443
442
|
event: string, callback: (data: any) => unknown
|
|
444
443
|
): Promise<unknown>;
|
|
445
444
|
|
|
446
445
|
/**
|
|
447
446
|
* Binds RTM event
|
|
448
447
|
*/
|
|
449
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
448
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
450
449
|
on(event: string, callback: (data: any) => any) {
|
|
451
450
|
// Ensure all input arguments are set
|
|
452
451
|
if (typeof event !== "string") {
|
|
@@ -481,7 +480,7 @@ class Crisp {
|
|
|
481
480
|
|
|
482
481
|
// Subscribe event on the broker
|
|
483
482
|
if (this._boundEvents[event] !== true) {
|
|
484
|
-
|
|
483
|
+
const rtmMode = this._rtm.mode;
|
|
485
484
|
|
|
486
485
|
// Mark event as bound
|
|
487
486
|
this._boundEvents[event] = true;
|
|
@@ -676,7 +675,7 @@ class Crisp {
|
|
|
676
675
|
* Binds broker to the main object
|
|
677
676
|
*/
|
|
678
677
|
private __prepareBroker(
|
|
679
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
678
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
680
679
|
fnBindHook: (modeInstance: any, emitter: any) => void
|
|
681
680
|
) {
|
|
682
681
|
return new Promise((resolve, reject) => {
|
|
@@ -698,7 +697,7 @@ class Crisp {
|
|
|
698
697
|
);
|
|
699
698
|
}
|
|
700
699
|
|
|
701
|
-
// @ts-
|
|
700
|
+
// @ts-expect-error - rtmMode is a string
|
|
702
701
|
this._brokerScheduler = setTimeout(() => {
|
|
703
702
|
switch (rtmMode) {
|
|
704
703
|
case "websockets": {
|
|
@@ -723,7 +722,7 @@ class Crisp {
|
|
|
723
722
|
default: {
|
|
724
723
|
const unsupportedError = new Error(
|
|
725
724
|
"[Crisp] prepareBroker: mode of RTM broker unsupported " +
|
|
726
|
-
"('" + rtmMode + "')"
|
|
725
|
+
"('" + String(rtmMode) + "')"
|
|
727
726
|
);
|
|
728
727
|
|
|
729
728
|
reject(unsupportedError);
|
|
@@ -798,7 +797,6 @@ class Crisp {
|
|
|
798
797
|
});
|
|
799
798
|
})
|
|
800
799
|
.then((endpoints) => {
|
|
801
|
-
// @ts-ignore
|
|
802
800
|
const rtmHostAffinity = (endpoints?.socket?.app || null);
|
|
803
801
|
|
|
804
802
|
// No RTM API host acquired?
|
|
@@ -813,7 +811,6 @@ class Crisp {
|
|
|
813
811
|
const rtmHostUrl = new URL(rtmHostAffinity);
|
|
814
812
|
|
|
815
813
|
// Connect to socket
|
|
816
|
-
// @ts-ignore
|
|
817
814
|
this._socket = socketio(rtmHostUrl.origin, {
|
|
818
815
|
path: (rtmHostUrl.pathname || "/"),
|
|
819
816
|
transports: ["websocket"],
|
|
@@ -902,12 +899,10 @@ class Crisp {
|
|
|
902
899
|
method: string,
|
|
903
900
|
query: object,
|
|
904
901
|
body: object | null,
|
|
905
|
-
// eslint-disable-next-line no-unused-vars
|
|
906
902
|
resolve: (value: unknown) => void,
|
|
907
|
-
// eslint-disable-next-line no-unused-vars
|
|
908
903
|
reject: (reason?: unknown) => void
|
|
909
904
|
) {
|
|
910
|
-
|
|
905
|
+
const requestParameters = {
|
|
911
906
|
responseType: "json",
|
|
912
907
|
timeout: DEFAULT_REQUEST_TIMEOUT,
|
|
913
908
|
|
|
@@ -922,13 +917,13 @@ class Crisp {
|
|
|
922
917
|
|
|
923
918
|
// Add authorization?
|
|
924
919
|
if (this.auth.token) {
|
|
925
|
-
// @ts-
|
|
920
|
+
// @ts-expect-error - requestParameters.headers is a Record<string, string>
|
|
926
921
|
requestParameters.headers.Authorization = ("Basic " + this.auth.token);
|
|
927
922
|
}
|
|
928
923
|
|
|
929
924
|
// Add body?
|
|
930
925
|
if (body) {
|
|
931
|
-
// @ts-
|
|
926
|
+
// @ts-expect-error - requestParameters.json is a Record<string, unknown>
|
|
932
927
|
requestParameters.json = body;
|
|
933
928
|
}
|
|
934
929
|
|
|
@@ -948,7 +943,7 @@ class Crisp {
|
|
|
948
943
|
}
|
|
949
944
|
});
|
|
950
945
|
|
|
951
|
-
// @ts-
|
|
946
|
+
// @ts-expect-error - requestParameters.searchParams is a URLSearchParams
|
|
952
947
|
requestParameters.searchParams = params;
|
|
953
948
|
}
|
|
954
949
|
|
|
@@ -977,7 +972,7 @@ class Crisp {
|
|
|
977
972
|
|
|
978
973
|
// Response error?
|
|
979
974
|
if (response.statusCode >= 400) {
|
|
980
|
-
|
|
975
|
+
const reasonMessage = this.__readErrorResponseReason(
|
|
981
976
|
method, response.statusCode, response
|
|
982
977
|
);
|
|
983
978
|
|
|
@@ -1009,7 +1004,8 @@ class Crisp {
|
|
|
1009
1004
|
* Reads reason for error response
|
|
1010
1005
|
*/
|
|
1011
1006
|
private __readErrorResponseReason(
|
|
1012
|
-
method: string, statusCode: number,
|
|
1007
|
+
method: string, statusCode: number,
|
|
1008
|
+
response: { body?: { reason?: string } }
|
|
1013
1009
|
) {
|
|
1014
1010
|
// HEAD method? As HEAD requests do not expect any response body, then we \
|
|
1015
1011
|
// cannot map a reason from the response.
|
|
@@ -1027,7 +1023,6 @@ class Crisp {
|
|
|
1027
1023
|
|
|
1028
1024
|
// Other methods must hold a response body, therefore we can fallback on \
|
|
1029
1025
|
// an HTTP error if we fail to acquire any reason at all.
|
|
1030
|
-
// @ts-ignore
|
|
1031
1026
|
return ((response?.body?.reason || "http_error"));
|
|
1032
1027
|
}
|
|
1033
1028
|
|
|
@@ -1044,15 +1039,15 @@ class Crisp {
|
|
|
1044
1039
|
}
|
|
1045
1040
|
|
|
1046
1041
|
// Compute local trace
|
|
1047
|
-
|
|
1042
|
+
const localTrace = ("[" + timestamp + ";" + JSON.stringify(body) + "]");
|
|
1048
1043
|
|
|
1049
1044
|
// Create local HMAC
|
|
1050
|
-
|
|
1045
|
+
const localMac = Crypto.createHmac("sha256", secret);
|
|
1051
1046
|
|
|
1052
1047
|
localMac.update(localTrace);
|
|
1053
1048
|
|
|
1054
1049
|
// Compute local signature, and compare
|
|
1055
|
-
|
|
1050
|
+
const localSignature = localMac.digest("hex");
|
|
1056
1051
|
|
|
1057
1052
|
return (
|
|
1058
1053
|
(signature === localSignature) ? true : false
|
package/lib/events/Events.ts
CHANGED
|
@@ -655,7 +655,7 @@ export interface EventsPlanSubscriptionUpdated extends EventsWebsiteGeneric {
|
|
|
655
655
|
***************************************************************************/
|
|
656
656
|
|
|
657
657
|
/**
|
|
658
|
-
* Maps each event name to the shape of the payload delivered to its listener,
|
|
658
|
+
* Maps each event name to the shape of the payload delivered to its listener, \
|
|
659
659
|
* whether received over WebSockets or Web Hooks.
|
|
660
660
|
*/
|
|
661
661
|
export interface EventsMap {
|
|
@@ -780,7 +780,7 @@ export interface EventsMap {
|
|
|
780
780
|
export type EventName = keyof EventsMap;
|
|
781
781
|
|
|
782
782
|
/**
|
|
783
|
-
* Shape of a Web Hook body, as received on the HTTP endpoint before being
|
|
783
|
+
* Shape of a Web Hook body, as received on the HTTP endpoint before being \
|
|
784
784
|
* dispatched with 'receiveHook'.
|
|
785
785
|
*/
|
|
786
786
|
export type EventsWebHookBody<Name extends EventName = EventName> = {
|
|
@@ -83,7 +83,7 @@ class PluginConnect extends BaseResource {
|
|
|
83
83
|
pageNumber: number, filterConfigured: boolean, includePlan: boolean
|
|
84
84
|
): Promise<PluginConnectWebsite[]> {
|
|
85
85
|
// Generate query
|
|
86
|
-
|
|
86
|
+
const query = {
|
|
87
87
|
filter_configured: (
|
|
88
88
|
(filterConfigured === true) ? "1" : "0"
|
|
89
89
|
),
|
|
@@ -109,7 +109,7 @@ class PluginConnect extends BaseResource {
|
|
|
109
109
|
dateSince: string, filterConfigured: boolean, includePlan: boolean
|
|
110
110
|
): Promise<PluginConnectWebsite[]> {
|
|
111
111
|
// Generate query
|
|
112
|
-
|
|
112
|
+
const query = {
|
|
113
113
|
filter_configured: (
|
|
114
114
|
(filterConfigured === true) ? "1" : "0"
|
|
115
115
|
),
|
|
@@ -120,7 +120,7 @@ class PluginConnect extends BaseResource {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
if (dateSince) {
|
|
123
|
-
// @ts-
|
|
123
|
+
// @ts-expect-error - dateSince is a string
|
|
124
124
|
query.date_since = dateSince;
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -52,11 +52,6 @@ export type WebsiteFilter = {
|
|
|
52
52
|
class WebsiteBase extends BaseResource {
|
|
53
53
|
/**
|
|
54
54
|
* Check If Website Exists
|
|
55
|
-
* @memberof WebsiteBase
|
|
56
|
-
* @public
|
|
57
|
-
* @method checkWebsiteExists
|
|
58
|
-
* @param {string} domain
|
|
59
|
-
* @return {Promise}
|
|
60
55
|
*/
|
|
61
56
|
checkWebsiteExists(domain: string) {
|
|
62
57
|
return this.crisp.head(
|
|
@@ -79,11 +74,6 @@ class WebsiteBase extends BaseResource {
|
|
|
79
74
|
|
|
80
75
|
/**
|
|
81
76
|
* Get A Website
|
|
82
|
-
* @memberof WebsiteBase
|
|
83
|
-
* @public
|
|
84
|
-
* @method getWebsite
|
|
85
|
-
* @param {string} websiteID
|
|
86
|
-
* @return {Promise}
|
|
87
77
|
*/
|
|
88
78
|
getWebsite(websiteID: string): Promise<Website> {
|
|
89
79
|
return this.crisp.get(
|
|
@@ -98,12 +98,6 @@ class WebsiteBatch extends BaseResource {
|
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Batch Read Conversations
|
|
101
|
-
* @memberof WebsiteBatch
|
|
102
|
-
* @public
|
|
103
|
-
* @method batchReadConversations
|
|
104
|
-
* @param {string} websiteID
|
|
105
|
-
* @param {object} operation
|
|
106
|
-
* @return {Promise}
|
|
107
101
|
*/
|
|
108
102
|
batchReadConversations(
|
|
109
103
|
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
@@ -130,12 +124,6 @@ class WebsiteBatch extends BaseResource {
|
|
|
130
124
|
|
|
131
125
|
/**
|
|
132
126
|
* Batch Remove Conversations
|
|
133
|
-
* @memberof WebsiteBatch
|
|
134
|
-
* @public
|
|
135
|
-
* @method batchRemoveConversations
|
|
136
|
-
* @param {string} websiteID
|
|
137
|
-
* @param {object} operation
|
|
138
|
-
* @return {Promise}
|
|
139
127
|
*/
|
|
140
128
|
batchRemoveConversations(
|
|
141
129
|
websiteID: string, operation: WebsiteBatchConversationsOperation
|
|
@@ -149,12 +137,6 @@ class WebsiteBatch extends BaseResource {
|
|
|
149
137
|
|
|
150
138
|
/**
|
|
151
139
|
* Batch Remove People
|
|
152
|
-
* @memberof WebsiteBatch
|
|
153
|
-
* @public
|
|
154
|
-
* @method batchRemovePeople
|
|
155
|
-
* @param {string} websiteID
|
|
156
|
-
* @param {object} people
|
|
157
|
-
* @return {Promise}
|
|
158
140
|
*/
|
|
159
141
|
batchRemovePeople(
|
|
160
142
|
websiteID: string, people: WebsiteBatchPeopleOperationInner
|
|
@@ -763,20 +763,17 @@ class WebsiteConversation extends BaseResource {
|
|
|
763
763
|
timestampAfter?: string|number, timestampAround?: string|number
|
|
764
764
|
): Promise<ConversationMessage[]> {
|
|
765
765
|
// Generate query
|
|
766
|
-
|
|
766
|
+
const query: Record<string, unknown> = {};
|
|
767
767
|
|
|
768
768
|
if (timestampBefore) {
|
|
769
|
-
// @ts-ignore
|
|
770
769
|
query.timestamp_before = String(timestampBefore);
|
|
771
770
|
}
|
|
772
771
|
|
|
773
772
|
if (timestampAfter) {
|
|
774
|
-
// @ts-ignore
|
|
775
773
|
query.timestamp_after = String(timestampAfter);
|
|
776
774
|
}
|
|
777
775
|
|
|
778
776
|
if (timestampAround) {
|
|
779
|
-
// @ts-ignore
|
|
780
777
|
query.timestamp_around = String(timestampAround);
|
|
781
778
|
}
|
|
782
779
|
|
|
@@ -1074,13 +1071,13 @@ class WebsiteConversation extends BaseResource {
|
|
|
1074
1071
|
user?: ConversationMessageUser, origin?: string
|
|
1075
1072
|
) {
|
|
1076
1073
|
// Generate body
|
|
1077
|
-
|
|
1074
|
+
const body = {
|
|
1078
1075
|
state: state,
|
|
1079
1076
|
user: user
|
|
1080
1077
|
};
|
|
1081
1078
|
|
|
1082
1079
|
if (origin) {
|
|
1083
|
-
// @ts-
|
|
1080
|
+
// @ts-expect-error - origin is a string
|
|
1084
1081
|
body.origin = origin;
|
|
1085
1082
|
}
|
|
1086
1083
|
|
|
@@ -1155,13 +1152,13 @@ class WebsiteConversation extends BaseResource {
|
|
|
1155
1152
|
user?: ConversationMessageUser, origin?: string
|
|
1156
1153
|
) {
|
|
1157
1154
|
// Generate body
|
|
1158
|
-
|
|
1155
|
+
const body = {
|
|
1159
1156
|
blocked: (blocked || false),
|
|
1160
1157
|
user: user
|
|
1161
1158
|
};
|
|
1162
1159
|
|
|
1163
1160
|
if (origin) {
|
|
1164
|
-
// @ts-
|
|
1161
|
+
// @ts-expect-error - body is a Record<string, unknown>
|
|
1165
1162
|
body.origin = origin;
|
|
1166
1163
|
}
|
|
1167
1164
|
|
|
@@ -1246,12 +1243,12 @@ class WebsiteConversation extends BaseResource {
|
|
|
1246
1243
|
websiteID: string, sessionID: string, to: string, email?: string
|
|
1247
1244
|
) {
|
|
1248
1245
|
// Generate body
|
|
1249
|
-
|
|
1246
|
+
const body = {
|
|
1250
1247
|
to: to
|
|
1251
1248
|
};
|
|
1252
1249
|
|
|
1253
1250
|
if (email) {
|
|
1254
|
-
// @ts-
|
|
1251
|
+
// @ts-expect-error - email is a string
|
|
1255
1252
|
body.email = email;
|
|
1256
1253
|
}
|
|
1257
1254
|
|
|
@@ -1367,13 +1364,13 @@ class WebsiteConversation extends BaseResource {
|
|
|
1367
1364
|
user?: ConversationMessageUser, origin?: string
|
|
1368
1365
|
) {
|
|
1369
1366
|
// Generate body
|
|
1370
|
-
|
|
1367
|
+
const body = {
|
|
1371
1368
|
mode: (mode || "audio"),
|
|
1372
1369
|
user: user
|
|
1373
1370
|
};
|
|
1374
1371
|
|
|
1375
1372
|
if (origin) {
|
|
1376
|
-
// @ts-
|
|
1373
|
+
// @ts-expect-error - origin is a string
|
|
1377
1374
|
body.origin = origin;
|
|
1378
1375
|
}
|
|
1379
1376
|
|
|
@@ -1407,12 +1404,12 @@ class WebsiteConversation extends BaseResource {
|
|
|
1407
1404
|
user?: ConversationMessageUser, origin?: string
|
|
1408
1405
|
) {
|
|
1409
1406
|
// Generate body
|
|
1410
|
-
|
|
1407
|
+
const body = {
|
|
1411
1408
|
user: user
|
|
1412
1409
|
};
|
|
1413
1410
|
|
|
1414
1411
|
if (origin) {
|
|
1415
|
-
// @ts-
|
|
1412
|
+
// @ts-expect-error - origin is a string
|
|
1416
1413
|
body.origin = origin;
|
|
1417
1414
|
}
|
|
1418
1415
|
|
|
@@ -1447,12 +1444,12 @@ class WebsiteConversation extends BaseResource {
|
|
|
1447
1444
|
websiteID: string, sessionID: string, command: string, payload?: object
|
|
1448
1445
|
) {
|
|
1449
1446
|
// Generate body
|
|
1450
|
-
|
|
1447
|
+
const body = {
|
|
1451
1448
|
command: command
|
|
1452
1449
|
};
|
|
1453
1450
|
|
|
1454
1451
|
if (payload) {
|
|
1455
|
-
// @ts-
|
|
1452
|
+
// @ts-expect-error - payload is a Record<string, unknown>
|
|
1456
1453
|
body.payload = payload;
|
|
1457
1454
|
}
|
|
1458
1455
|
|
|
@@ -1473,14 +1470,14 @@ class WebsiteConversation extends BaseResource {
|
|
|
1473
1470
|
itemID: string, data: object, value?: string
|
|
1474
1471
|
) {
|
|
1475
1472
|
// Generate body
|
|
1476
|
-
|
|
1473
|
+
const body = {
|
|
1477
1474
|
section_id: sectionID,
|
|
1478
1475
|
item_id: itemID,
|
|
1479
1476
|
data: data
|
|
1480
1477
|
};
|
|
1481
1478
|
|
|
1482
1479
|
if (typeof value !== "undefined") {
|
|
1483
|
-
// @ts-
|
|
1480
|
+
// @ts-expect-error - value is a string
|
|
1484
1481
|
body.value = value;
|
|
1485
1482
|
}
|
|
1486
1483
|
|
|
@@ -1548,14 +1545,14 @@ class WebsiteConversation extends BaseResource {
|
|
|
1548
1545
|
user?: ConversationMessageUser, origin?: string
|
|
1549
1546
|
) {
|
|
1550
1547
|
// Generate body
|
|
1551
|
-
|
|
1548
|
+
const body = {
|
|
1552
1549
|
date: date,
|
|
1553
1550
|
note: note,
|
|
1554
1551
|
user: user
|
|
1555
1552
|
};
|
|
1556
1553
|
|
|
1557
1554
|
if (origin) {
|
|
1558
|
-
// @ts-
|
|
1555
|
+
// @ts-expect-error - origin is a string
|
|
1559
1556
|
body.origin = origin;
|
|
1560
1557
|
}
|
|
1561
1558
|
|