crisp-api 9.13.0 → 10.0.3
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 +12 -0
- package/README.md +2 -2
- package/dist/crisp.d.ts +179 -0
- package/dist/crisp.js +773 -0
- package/dist/resources/BaseResource.d.ts +21 -0
- package/dist/resources/BaseResource.js +26 -0
- package/dist/resources/BucketURL.d.ts +37 -0
- package/dist/resources/BucketURL.js +35 -0
- package/dist/resources/MediaAnimation.d.ts +20 -0
- package/dist/resources/MediaAnimation.js +40 -0
- package/dist/resources/PluginConnect.d.ts +59 -0
- package/dist/resources/PluginConnect.js +79 -0
- package/dist/resources/PluginSubscription.d.ts +112 -0
- package/dist/resources/PluginSubscription.js +130 -0
- package/dist/resources/WebsiteAnalytics.d.ts +20 -0
- package/dist/resources/WebsiteAnalytics.js +37 -0
- package/dist/resources/WebsiteAvailability.d.ts +40 -0
- package/dist/resources/WebsiteAvailability.js +46 -0
- package/dist/resources/WebsiteBase.d.ts +69 -0
- package/dist/resources/WebsiteBase.js +77 -0
- package/dist/resources/WebsiteBatch.d.ts +61 -0
- package/dist/resources/WebsiteBatch.js +76 -0
- package/dist/resources/WebsiteCampaign.d.ts +208 -0
- package/dist/resources/WebsiteCampaign.js +201 -0
- package/dist/resources/WebsiteConversation.d.ts +710 -0
- package/dist/resources/WebsiteConversation.js +607 -0
- package/dist/resources/WebsiteHelpdesk.d.ts +356 -0
- package/dist/resources/WebsiteHelpdesk.js +593 -0
- package/dist/resources/WebsiteOperator.d.ts +88 -0
- package/dist/resources/WebsiteOperator.js +99 -0
- package/dist/resources/WebsitePeople.d.ts +257 -0
- package/dist/resources/WebsitePeople.js +282 -0
- package/dist/resources/WebsiteSettings.d.ts +168 -0
- package/dist/resources/WebsiteSettings.js +42 -0
- package/dist/resources/WebsiteVerify.d.ts +47 -0
- package/dist/resources/WebsiteVerify.js +56 -0
- package/dist/resources/WebsiteVisitors.d.ts +122 -0
- package/dist/resources/WebsiteVisitors.js +98 -0
- package/dist/resources/index.d.ts +20 -0
- package/dist/resources/index.js +42 -0
- package/dist/services/bucket.d.ts +19 -0
- package/dist/services/bucket.js +31 -0
- package/dist/services/media.d.ts +19 -0
- package/dist/services/media.js +31 -0
- package/dist/services/plugin.d.ts +20 -0
- package/dist/services/plugin.js +33 -0
- package/dist/services/website.d.ts +30 -0
- package/dist/services/website.js +53 -0
- package/eslint.config.mjs +208 -0
- package/lib/crisp.ts +1006 -0
- package/lib/resources/BaseResource.ts +37 -0
- package/lib/resources/BucketURL.ts +58 -0
- package/lib/resources/MediaAnimation.ts +44 -0
- package/lib/resources/PluginConnect.ts +135 -0
- package/lib/resources/PluginSubscription.ts +236 -0
- package/lib/resources/WebsiteAnalytics.ts +41 -0
- package/lib/resources/WebsiteAvailability.ts +74 -0
- package/lib/resources/WebsiteBase.ts +119 -0
- package/lib/resources/WebsiteBatch.ts +116 -0
- package/lib/resources/WebsiteCampaign.ts +432 -0
- package/lib/resources/WebsiteConversation.ts +1507 -0
- package/lib/resources/WebsiteHelpdesk.ts +1024 -0
- package/lib/resources/WebsiteOperator.ts +183 -0
- package/lib/resources/WebsitePeople.ts +568 -0
- package/lib/resources/WebsiteSettings.ts +207 -0
- package/lib/resources/WebsiteVerify.ts +90 -0
- package/lib/resources/WebsiteVisitors.ts +219 -0
- package/lib/resources/index.ts +28 -0
- package/lib/services/bucket.ts +36 -0
- package/lib/services/media.ts +36 -0
- package/lib/services/plugin.ts +40 -0
- package/lib/services/website.ts +70 -0
- package/package.json +16 -11
- package/tsconfig.json +12 -5
- package/lib/crisp.js +0 -1171
- package/lib/resources/BucketURL.js +0 -34
- package/lib/resources/MediaAnimation.js +0 -41
- package/lib/resources/PluginConnect.js +0 -119
- package/lib/resources/PluginSubscription.js +0 -234
- package/lib/resources/WebsiteAnalytics.js +0 -37
- package/lib/resources/WebsiteAvailability.js +0 -48
- package/lib/resources/WebsiteBase.js +0 -100
- package/lib/resources/WebsiteBatch.js +0 -92
- package/lib/resources/WebsiteCampaign.js +0 -396
- package/lib/resources/WebsiteConversation.js +0 -1261
- package/lib/resources/WebsiteHelpdesk.js +0 -1198
- package/lib/resources/WebsiteOperator.js +0 -167
- package/lib/resources/WebsitePeople.js +0 -516
- package/lib/resources/WebsiteSettings.js +0 -50
- package/lib/resources/WebsiteVerify.js +0 -79
- package/lib/resources/WebsiteVisitors.js +0 -148
- package/lib/services/Bucket.js +0 -28
- package/lib/services/Media.js +0 -28
- package/lib/services/Plugin.js +0 -29
- package/lib/services/Website.js +0 -39
- package/types/crisp.d.ts +0 -151
- package/types/resources/BucketURL.d.ts +0 -15
- package/types/resources/MediaAnimation.d.ts +0 -15
- package/types/resources/PluginConnect.d.ts +0 -15
- package/types/resources/PluginSubscription.d.ts +0 -15
- package/types/resources/WebsiteAnalytics.d.ts +0 -15
- package/types/resources/WebsiteAvailability.d.ts +0 -15
- package/types/resources/WebsiteBase.d.ts +0 -15
- package/types/resources/WebsiteBatch.d.ts +0 -15
- package/types/resources/WebsiteCampaign.d.ts +0 -15
- package/types/resources/WebsiteConversation.d.ts +0 -15
- package/types/resources/WebsiteHelpdesk.d.ts +0 -15
- package/types/resources/WebsiteOperator.d.ts +0 -15
- package/types/resources/WebsitePeople.d.ts +0 -15
- package/types/resources/WebsiteSettings.d.ts +0 -15
- package/types/resources/WebsiteVerify.d.ts +0 -15
- package/types/resources/WebsiteVisitors.d.ts +0 -15
- package/types/services/Bucket.d.ts +0 -14
- package/types/services/Media.d.ts +0 -14
- package/types/services/Plugin.d.ts +0 -14
- package/types/services/Website.d.ts +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
## v10.0.3
|
|
5
|
+
|
|
6
|
+
# Return missing type on website.listHelpdeskLocales
|
|
7
|
+
|
|
8
|
+
## v10.0.1
|
|
9
|
+
|
|
10
|
+
* Routes supporting pagination can be used without a page argument (page is set to `1` by default).
|
|
11
|
+
|
|
12
|
+
## v10.0.0
|
|
13
|
+
|
|
14
|
+
* Added TypeScript support (retro-compatible).
|
|
15
|
+
|
|
4
16
|
## v9.13.0
|
|
5
17
|
|
|
6
18
|
### New Features
|
package/README.md
CHANGED
|
@@ -3496,7 +3496,7 @@ To start listening for events and bind a handler, check out the [events over Web
|
|
|
3496
3496
|
|
|
3497
3497
|
You will need to adjust your code so that:
|
|
3498
3498
|
|
|
3499
|
-
1. The RTM events mode is set to Web Hooks: `CrispClient.setRtmMode(
|
|
3499
|
+
1. The RTM events mode is set to Web Hooks: `CrispClient.setRtmMode("webhooks")`
|
|
3500
3500
|
2. Your HTTP endpoint mounts a route listening for POST requests, and upon receiving requests:
|
|
3501
3501
|
1. It verifies the requests with: `CrispClient.verifyHook(secret, body, timestamp, signature)`
|
|
3502
3502
|
2. It receives the Web Hook with: `CrispClient.receiveHook(body)`
|
|
@@ -3509,7 +3509,7 @@ To start listening for events and bind a handler, check out the [events over Web
|
|
|
3509
3509
|
|
|
3510
3510
|
You will need to adjust your code so that:
|
|
3511
3511
|
|
|
3512
|
-
1. The RTM events mode is set to WebSockets: `CrispClient.setRtmMode(
|
|
3512
|
+
1. The RTM events mode is set to WebSockets: `CrispClient.setRtmMode("websockets")`
|
|
3513
3513
|
|
|
3514
3514
|
### Available realtime events
|
|
3515
3515
|
|
package/dist/crisp.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Socket } from "socket.io-client";
|
|
2
|
+
import { Emitter } from "mitt";
|
|
3
|
+
import { BucketServiceInterface } from "./services/bucket";
|
|
4
|
+
import { MediaServiceInterface } from "./services/media";
|
|
5
|
+
import { PluginServiceInterface } from "./services/plugin";
|
|
6
|
+
import { WebsiteServiceInterface } from "./services/website";
|
|
7
|
+
/**************************************************************************
|
|
8
|
+
* TYPES
|
|
9
|
+
***************************************************************************/
|
|
10
|
+
export type RTM_MODES = "websockets" | "webhooks";
|
|
11
|
+
export type CrispTier = "user" | "plugin";
|
|
12
|
+
/**************************************************************************
|
|
13
|
+
* INTERFACES
|
|
14
|
+
***************************************************************************/
|
|
15
|
+
interface CrispAuth {
|
|
16
|
+
tier: CrispTier;
|
|
17
|
+
identifier: string | null;
|
|
18
|
+
key: string | null;
|
|
19
|
+
token: string | null;
|
|
20
|
+
}
|
|
21
|
+
/**************************************************************************
|
|
22
|
+
* CLASSES
|
|
23
|
+
***************************************************************************/
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
export declare class Crisp {
|
|
28
|
+
bucket: BucketServiceInterface;
|
|
29
|
+
media: MediaServiceInterface;
|
|
30
|
+
plugin: PluginServiceInterface;
|
|
31
|
+
website: WebsiteServiceInterface;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use import { RTM_MODES } instead
|
|
34
|
+
*/
|
|
35
|
+
static RTM_MODES: {
|
|
36
|
+
WebSockets: RTM_MODES;
|
|
37
|
+
WebHooks: RTM_MODES;
|
|
38
|
+
};
|
|
39
|
+
auth: CrispAuth;
|
|
40
|
+
protected _rest: {
|
|
41
|
+
host: string;
|
|
42
|
+
basePath: string;
|
|
43
|
+
};
|
|
44
|
+
protected _rtm: {
|
|
45
|
+
host: string;
|
|
46
|
+
mode: RTM_MODES;
|
|
47
|
+
};
|
|
48
|
+
protected _useragent: string;
|
|
49
|
+
protected _emitter: Emitter<Record<import("mitt").EventType, unknown>>;
|
|
50
|
+
protected _socket: Socket | null;
|
|
51
|
+
protected _loopback: Emitter<Record<string, unknown>> | null;
|
|
52
|
+
protected _lastEventRebind: any;
|
|
53
|
+
protected _brokerScheduler: typeof setTimeout | null;
|
|
54
|
+
protected _brokerBindHooks: ((modeInstance: any, emitter: any) => void)[];
|
|
55
|
+
protected _boundEvents: {};
|
|
56
|
+
/**
|
|
57
|
+
* Constructor
|
|
58
|
+
*/
|
|
59
|
+
constructor();
|
|
60
|
+
/**
|
|
61
|
+
* Sets the REST API host
|
|
62
|
+
*/
|
|
63
|
+
setRestHost(host: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the RTM API host
|
|
66
|
+
*/
|
|
67
|
+
setRtmHost(host: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the RTM channel mode (ie. WebSockets or Web Hooks)
|
|
70
|
+
*/
|
|
71
|
+
setRtmMode(mode: "websockets" | "webhooks"): void;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the authentication tier
|
|
74
|
+
*/
|
|
75
|
+
setTier(tier: "user" | "plugin"): void;
|
|
76
|
+
/**
|
|
77
|
+
* Authenticates
|
|
78
|
+
*/
|
|
79
|
+
authenticate(identifier: string, key: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Authenticates (with tier)
|
|
82
|
+
*/
|
|
83
|
+
authenticateTier(tier: CrispTier, identifier: string, key: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Method wrapper to HEAD a resource
|
|
86
|
+
*/
|
|
87
|
+
head(resource: string, query?: object | null): Promise<any>;
|
|
88
|
+
/**
|
|
89
|
+
* Method wrapper to GET a resource
|
|
90
|
+
*/
|
|
91
|
+
get(resource: string, query?: object): Promise<any>;
|
|
92
|
+
/**
|
|
93
|
+
* Method wrapper to POST a resource
|
|
94
|
+
*/
|
|
95
|
+
post(resource: string, query: object | null, body: object | null): Promise<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Method wrapper to PATCH a resource
|
|
98
|
+
*/
|
|
99
|
+
patch(resource: string, query: object | null, body: object | null): Promise<any>;
|
|
100
|
+
/**
|
|
101
|
+
* Method wrapper to PUT a resource
|
|
102
|
+
*/
|
|
103
|
+
put(resource: string, query: object | null, body: object | null): Promise<any>;
|
|
104
|
+
/**
|
|
105
|
+
* Method wrapper to DELETE a resource
|
|
106
|
+
*/
|
|
107
|
+
delete(resource: string, query?: object | null, body?: object | null): Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* Binds RTM event
|
|
110
|
+
*/
|
|
111
|
+
on(event: string, callback: (data: any) => void): Promise<unknown>;
|
|
112
|
+
/**
|
|
113
|
+
* Receives a raw event and dispatches it to the listener (used for Web Hooks)
|
|
114
|
+
*/
|
|
115
|
+
receiveHook(body: Record<string, unknown>): Error;
|
|
116
|
+
/**
|
|
117
|
+
* Verifies an event string and checks that signatures match (used for Web \
|
|
118
|
+
* Hooks)
|
|
119
|
+
*/
|
|
120
|
+
verifyHook(secret: string, body: object, timestamp: number, signature: string): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Verifies an event string and checks that signatures match (used for \
|
|
123
|
+
* Widgets)
|
|
124
|
+
*/
|
|
125
|
+
verifyWidget(secret: string, body: object, timestamp: number, signature: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Rebinds socket events (used for WebSockets)
|
|
128
|
+
*/
|
|
129
|
+
rebindSocket(): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Prepares a URI based from path segments
|
|
132
|
+
*/
|
|
133
|
+
prepareRestUrl(paths: string[]): string;
|
|
134
|
+
/**
|
|
135
|
+
* Binds services to the main object
|
|
136
|
+
*/
|
|
137
|
+
protected _prepareServices(): void;
|
|
138
|
+
/**
|
|
139
|
+
* Binds resources to the service object
|
|
140
|
+
*/
|
|
141
|
+
private __prepareResources;
|
|
142
|
+
/**
|
|
143
|
+
* Binds broker to the main object
|
|
144
|
+
*/
|
|
145
|
+
private __prepareBroker;
|
|
146
|
+
/**
|
|
147
|
+
* Connects loopback (used for Web Hooks)
|
|
148
|
+
*/
|
|
149
|
+
private __connectLoopback;
|
|
150
|
+
/**
|
|
151
|
+
* Connects socket, using preferred RTM API host (used for WebSockets)
|
|
152
|
+
*/
|
|
153
|
+
private __connectSocket;
|
|
154
|
+
/**
|
|
155
|
+
* Authenticates client (used for WebSockets)
|
|
156
|
+
*/
|
|
157
|
+
private __emitAuthenticateSocket;
|
|
158
|
+
/**
|
|
159
|
+
* Unstacks pending broker bind hooks
|
|
160
|
+
*/
|
|
161
|
+
private __unstackBrokerBindHooks;
|
|
162
|
+
/**
|
|
163
|
+
* Performs a request to REST API
|
|
164
|
+
*/
|
|
165
|
+
private __request;
|
|
166
|
+
/**
|
|
167
|
+
* Reads reason for error response
|
|
168
|
+
*/
|
|
169
|
+
private __readErrorResponseReason;
|
|
170
|
+
/**
|
|
171
|
+
* Verifies an event string and checks that signatures match
|
|
172
|
+
*/
|
|
173
|
+
private __verifySignature;
|
|
174
|
+
}
|
|
175
|
+
/**************************************************************************
|
|
176
|
+
* EXPORTS
|
|
177
|
+
***************************************************************************/
|
|
178
|
+
export * from "./resources";
|
|
179
|
+
export default Crisp;
|