crisp-api 9.12.1 → 10.0.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.
- package/CHANGELOG.md +14 -0
- package/README.md +6 -2
- package/dist/crisp.d.ts +167 -0
- package/dist/crisp.js +764 -0
- package/dist/resources/BaseResource.d.ts +15 -0
- package/dist/resources/BaseResource.js +20 -0
- package/dist/resources/BucketURL.d.ts +28 -0
- package/dist/resources/BucketURL.js +29 -0
- package/dist/resources/MediaAnimation.d.ts +14 -0
- package/dist/resources/MediaAnimation.js +32 -0
- package/dist/resources/PluginConnect.d.ts +50 -0
- package/dist/resources/PluginConnect.js +73 -0
- package/dist/resources/PluginSubscription.d.ts +103 -0
- package/dist/resources/PluginSubscription.js +122 -0
- package/dist/resources/WebsiteAnalytics.d.ts +14 -0
- package/dist/resources/WebsiteAnalytics.js +29 -0
- package/dist/resources/WebsiteAvailability.d.ts +31 -0
- package/dist/resources/WebsiteAvailability.js +36 -0
- package/dist/resources/WebsiteBase.d.ts +60 -0
- package/dist/resources/WebsiteBase.js +71 -0
- package/dist/resources/WebsiteBatch.d.ts +52 -0
- package/dist/resources/WebsiteBatch.js +70 -0
- package/dist/resources/WebsiteCampaign.d.ts +199 -0
- package/dist/resources/WebsiteCampaign.js +194 -0
- package/dist/resources/WebsiteConversation.d.ts +701 -0
- package/dist/resources/WebsiteConversation.js +595 -0
- package/dist/resources/WebsiteHelpdesk.d.ts +347 -0
- package/dist/resources/WebsiteHelpdesk.js +587 -0
- package/dist/resources/WebsiteOperator.d.ts +79 -0
- package/dist/resources/WebsiteOperator.js +93 -0
- package/dist/resources/WebsitePeople.d.ts +248 -0
- package/dist/resources/WebsitePeople.js +276 -0
- package/dist/resources/WebsiteSettings.d.ts +159 -0
- package/dist/resources/WebsiteSettings.js +36 -0
- package/dist/resources/WebsiteVerify.d.ts +38 -0
- package/dist/resources/WebsiteVerify.js +50 -0
- package/dist/resources/WebsiteVisitors.d.ts +113 -0
- package/dist/resources/WebsiteVisitors.js +88 -0
- package/dist/resources/index.d.ts +17 -0
- package/dist/resources/index.js +40 -0
- package/dist/services/bucket.d.ts +13 -0
- package/dist/services/bucket.js +28 -0
- package/dist/services/media.d.ts +13 -0
- package/dist/services/media.js +28 -0
- package/dist/services/plugin.d.ts +14 -0
- package/dist/services/plugin.js +30 -0
- package/dist/services/website.d.ts +24 -0
- package/dist/services/website.js +50 -0
- package/eslint.config.mjs +208 -0
- package/lib/crisp.ts +957 -0
- package/lib/resources/BaseResource.ts +29 -0
- package/lib/resources/BucketURL.ts +49 -0
- package/lib/resources/MediaAnimation.ts +34 -0
- package/lib/resources/PluginConnect.ts +128 -0
- package/lib/resources/PluginSubscription.ts +208 -0
- package/lib/resources/WebsiteAnalytics.ts +31 -0
- package/lib/resources/WebsiteAvailability.ts +54 -0
- package/lib/resources/WebsiteBase.ts +108 -0
- package/lib/resources/WebsiteBatch.ts +96 -0
- package/lib/resources/WebsiteCampaign.ts +399 -0
- package/lib/resources/WebsiteConversation.ts +1416 -0
- package/lib/resources/WebsiteHelpdesk.ts +982 -0
- package/lib/resources/WebsiteOperator.ts +161 -0
- package/lib/resources/WebsitePeople.ts +527 -0
- package/lib/resources/WebsiteSettings.ts +192 -0
- package/lib/resources/WebsiteVerify.ts +76 -0
- package/lib/resources/WebsiteVisitors.ts +196 -0
- package/lib/resources/index.ts +25 -0
- package/lib/services/bucket.ts +28 -0
- package/lib/services/media.ts +28 -0
- package/lib/services/plugin.ts +32 -0
- package/lib/services/website.ts +62 -0
- package/package.json +16 -11
- package/tsconfig.json +12 -5
- package/lib/crisp.js +0 -1168
- 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,20 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
## v10.0.1
|
|
5
|
+
|
|
6
|
+
* Routes supporting pagination can be used without page argument (page 1 by default)
|
|
7
|
+
|
|
8
|
+
## v10.0.0
|
|
9
|
+
|
|
10
|
+
* Typescript support (retrocompatible)
|
|
11
|
+
|
|
12
|
+
## v9.13.0
|
|
13
|
+
|
|
14
|
+
### New Features
|
|
15
|
+
|
|
16
|
+
* Added support for the `identity:verify:request` RTM API event.
|
|
17
|
+
|
|
4
18
|
## v9.12.1
|
|
5
19
|
|
|
6
20
|
### 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
|
|
|
@@ -3651,6 +3651,10 @@ Available events are listed below:
|
|
|
3651
3651
|
* **Call Request Rejected** [`user`, `plugin`]:
|
|
3652
3652
|
* `call:request:rejected`
|
|
3653
3653
|
|
|
3654
|
+
* #### **Identity Events**: [Reference](https://docs.crisp.chat/references/rtm-api/v1/#identity-events)
|
|
3655
|
+
* **Identity Verify Request** [`plugin`]:
|
|
3656
|
+
* `identity:verify:request`
|
|
3657
|
+
|
|
3654
3658
|
* #### **Widget Events**: [Reference](https://docs.crisp.chat/references/rtm-api/v1/#widget-events)
|
|
3655
3659
|
* **Widget Action Processed** [`user`]:
|
|
3656
3660
|
* `widget:action:processed`
|
package/dist/crisp.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Socket } from "socket.io-client";
|
|
2
|
+
import { Emitter } from "mitt";
|
|
3
|
+
import Bucket from "./services/bucket";
|
|
4
|
+
import Media from "./services/media";
|
|
5
|
+
import Plugin from "./services/plugin";
|
|
6
|
+
import { WebsiteServiceInterface } from "./services/website";
|
|
7
|
+
export * from "./resources";
|
|
8
|
+
export type RTM_MODES = "websockets" | "webhooks";
|
|
9
|
+
interface CrispAuth {
|
|
10
|
+
tier: CrispTier;
|
|
11
|
+
identifier: string | null;
|
|
12
|
+
key: string | null;
|
|
13
|
+
token: string | null;
|
|
14
|
+
}
|
|
15
|
+
export type CrispTier = "user" | "plugin";
|
|
16
|
+
/**
|
|
17
|
+
* Crisp API Library
|
|
18
|
+
*/
|
|
19
|
+
export declare class Crisp {
|
|
20
|
+
bucket: Bucket;
|
|
21
|
+
media: Media;
|
|
22
|
+
plugin: Plugin;
|
|
23
|
+
website: WebsiteServiceInterface;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use import { RTM_MODES } instead
|
|
26
|
+
*/
|
|
27
|
+
static RTM_MODES: {
|
|
28
|
+
WebSockets: RTM_MODES;
|
|
29
|
+
WebHooks: RTM_MODES;
|
|
30
|
+
};
|
|
31
|
+
auth: CrispAuth;
|
|
32
|
+
_rest: {
|
|
33
|
+
host: string;
|
|
34
|
+
basePath: string;
|
|
35
|
+
};
|
|
36
|
+
_rtm: {
|
|
37
|
+
host: string;
|
|
38
|
+
mode: RTM_MODES;
|
|
39
|
+
};
|
|
40
|
+
_useragent: string;
|
|
41
|
+
_emitter: Emitter<Record<import("mitt").EventType, unknown>>;
|
|
42
|
+
_socket: Socket | null;
|
|
43
|
+
_loopback: Emitter<Record<string, unknown>> | null;
|
|
44
|
+
_lastEventRebind: any;
|
|
45
|
+
_brokerScheduler: typeof setTimeout | null;
|
|
46
|
+
_brokerBindHooks: ((modeInstance: any, emitter: any) => void)[];
|
|
47
|
+
_boundEvents: {};
|
|
48
|
+
/**
|
|
49
|
+
* Constructor
|
|
50
|
+
*/
|
|
51
|
+
constructor();
|
|
52
|
+
/**
|
|
53
|
+
* Sets the REST API host
|
|
54
|
+
*/
|
|
55
|
+
setRestHost(host: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the RTM API host
|
|
58
|
+
*/
|
|
59
|
+
setRtmHost(host: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the RTM channel mode (ie. WebSockets or Web Hooks)
|
|
62
|
+
*/
|
|
63
|
+
setRtmMode(mode: "websockets" | "webhooks"): void;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the authentication tier
|
|
66
|
+
*/
|
|
67
|
+
setTier(tier: "user" | "plugin"): void;
|
|
68
|
+
/**
|
|
69
|
+
* Authenticates
|
|
70
|
+
*/
|
|
71
|
+
authenticate(identifier: string, key: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* Authenticates (with tier)
|
|
74
|
+
*/
|
|
75
|
+
authenticateTier(tier: CrispTier, identifier: string, key: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Method wrapper to HEAD a resource
|
|
78
|
+
*/
|
|
79
|
+
head(resource: string, query?: object | null): Promise<any>;
|
|
80
|
+
/**
|
|
81
|
+
* Method wrapper to GET a resource
|
|
82
|
+
*/
|
|
83
|
+
get(resource: string, query?: object): Promise<any>;
|
|
84
|
+
/**
|
|
85
|
+
* Method wrapper to POST a resource
|
|
86
|
+
*/
|
|
87
|
+
post(resource: string, query: object | null, body: object | null): Promise<any>;
|
|
88
|
+
/**
|
|
89
|
+
* Method wrapper to PATCH a resource
|
|
90
|
+
*/
|
|
91
|
+
patch(resource: string, query: object | null, body: object | null): Promise<any>;
|
|
92
|
+
/**
|
|
93
|
+
* Method wrapper to PUT a resource
|
|
94
|
+
*/
|
|
95
|
+
put(resource: string, query: object | null, body: object | null): Promise<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Method wrapper to DELETE a resource
|
|
98
|
+
*/
|
|
99
|
+
delete(resource: string, query?: object | null, body?: object | null): Promise<any>;
|
|
100
|
+
/**
|
|
101
|
+
* Binds RTM event
|
|
102
|
+
*/
|
|
103
|
+
on(event: string, callback: (data: any) => void): Promise<unknown>;
|
|
104
|
+
/**
|
|
105
|
+
* Receives a raw event and dispatches it to the listener (used for Web Hooks)
|
|
106
|
+
*/
|
|
107
|
+
receiveHook(body: Record<string, unknown>): Error;
|
|
108
|
+
/**
|
|
109
|
+
* Verifies an event string and checks that signatures match (used for Web \
|
|
110
|
+
* Hooks)
|
|
111
|
+
*/
|
|
112
|
+
verifyHook(secret: string, body: object, timestamp: number, signature: string): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Verifies an event string and checks that signatures match (used for \
|
|
115
|
+
* Widgets)
|
|
116
|
+
*/
|
|
117
|
+
verifyWidget(secret: string, body: object, timestamp: number, signature: string): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Rebinds socket events (used for WebSockets)
|
|
120
|
+
*/
|
|
121
|
+
rebindSocket(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Prepares a URI based from path segments
|
|
124
|
+
*/
|
|
125
|
+
prepareRestUrl(paths: string[]): string;
|
|
126
|
+
/**
|
|
127
|
+
* Binds services to the main object
|
|
128
|
+
*/
|
|
129
|
+
_prepareServices(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Binds resources to the service object
|
|
132
|
+
*/
|
|
133
|
+
private prepareResources;
|
|
134
|
+
/**
|
|
135
|
+
* Binds broker to the main object
|
|
136
|
+
*/
|
|
137
|
+
private prepareBroker;
|
|
138
|
+
/**
|
|
139
|
+
* Connects loopback (used for Web Hooks)
|
|
140
|
+
*/
|
|
141
|
+
private connectLoopback;
|
|
142
|
+
/**
|
|
143
|
+
* Connects socket, using preferred RTM API host (used for WebSockets)
|
|
144
|
+
*/
|
|
145
|
+
private connectSocket;
|
|
146
|
+
/**
|
|
147
|
+
* Authenticates client (used for WebSockets)
|
|
148
|
+
*/
|
|
149
|
+
private emitAuthenticateSocket;
|
|
150
|
+
/**
|
|
151
|
+
* Unstacks pending broker bind hooks
|
|
152
|
+
*/
|
|
153
|
+
private unstackBrokerBindHooks;
|
|
154
|
+
/**
|
|
155
|
+
* Performs a request to REST API
|
|
156
|
+
*/
|
|
157
|
+
private request;
|
|
158
|
+
/**
|
|
159
|
+
* Reads reason for error response
|
|
160
|
+
*/
|
|
161
|
+
private readErrorResponseReason;
|
|
162
|
+
/**
|
|
163
|
+
* Verifies an event string and checks that signatures match
|
|
164
|
+
*/
|
|
165
|
+
private verifySignature;
|
|
166
|
+
}
|
|
167
|
+
export default Crisp;
|