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.
Files changed (116) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/dist/crisp.d.ts +179 -0
  4. package/dist/crisp.js +773 -0
  5. package/dist/resources/BaseResource.d.ts +21 -0
  6. package/dist/resources/BaseResource.js +26 -0
  7. package/dist/resources/BucketURL.d.ts +37 -0
  8. package/dist/resources/BucketURL.js +35 -0
  9. package/dist/resources/MediaAnimation.d.ts +20 -0
  10. package/dist/resources/MediaAnimation.js +40 -0
  11. package/dist/resources/PluginConnect.d.ts +59 -0
  12. package/dist/resources/PluginConnect.js +79 -0
  13. package/dist/resources/PluginSubscription.d.ts +112 -0
  14. package/dist/resources/PluginSubscription.js +130 -0
  15. package/dist/resources/WebsiteAnalytics.d.ts +20 -0
  16. package/dist/resources/WebsiteAnalytics.js +37 -0
  17. package/dist/resources/WebsiteAvailability.d.ts +40 -0
  18. package/dist/resources/WebsiteAvailability.js +46 -0
  19. package/dist/resources/WebsiteBase.d.ts +69 -0
  20. package/dist/resources/WebsiteBase.js +77 -0
  21. package/dist/resources/WebsiteBatch.d.ts +61 -0
  22. package/dist/resources/WebsiteBatch.js +76 -0
  23. package/dist/resources/WebsiteCampaign.d.ts +208 -0
  24. package/dist/resources/WebsiteCampaign.js +201 -0
  25. package/dist/resources/WebsiteConversation.d.ts +710 -0
  26. package/dist/resources/WebsiteConversation.js +607 -0
  27. package/dist/resources/WebsiteHelpdesk.d.ts +356 -0
  28. package/dist/resources/WebsiteHelpdesk.js +593 -0
  29. package/dist/resources/WebsiteOperator.d.ts +88 -0
  30. package/dist/resources/WebsiteOperator.js +99 -0
  31. package/dist/resources/WebsitePeople.d.ts +257 -0
  32. package/dist/resources/WebsitePeople.js +282 -0
  33. package/dist/resources/WebsiteSettings.d.ts +168 -0
  34. package/dist/resources/WebsiteSettings.js +42 -0
  35. package/dist/resources/WebsiteVerify.d.ts +47 -0
  36. package/dist/resources/WebsiteVerify.js +56 -0
  37. package/dist/resources/WebsiteVisitors.d.ts +122 -0
  38. package/dist/resources/WebsiteVisitors.js +98 -0
  39. package/dist/resources/index.d.ts +20 -0
  40. package/dist/resources/index.js +42 -0
  41. package/dist/services/bucket.d.ts +19 -0
  42. package/dist/services/bucket.js +31 -0
  43. package/dist/services/media.d.ts +19 -0
  44. package/dist/services/media.js +31 -0
  45. package/dist/services/plugin.d.ts +20 -0
  46. package/dist/services/plugin.js +33 -0
  47. package/dist/services/website.d.ts +30 -0
  48. package/dist/services/website.js +53 -0
  49. package/eslint.config.mjs +208 -0
  50. package/lib/crisp.ts +1006 -0
  51. package/lib/resources/BaseResource.ts +37 -0
  52. package/lib/resources/BucketURL.ts +58 -0
  53. package/lib/resources/MediaAnimation.ts +44 -0
  54. package/lib/resources/PluginConnect.ts +135 -0
  55. package/lib/resources/PluginSubscription.ts +236 -0
  56. package/lib/resources/WebsiteAnalytics.ts +41 -0
  57. package/lib/resources/WebsiteAvailability.ts +74 -0
  58. package/lib/resources/WebsiteBase.ts +119 -0
  59. package/lib/resources/WebsiteBatch.ts +116 -0
  60. package/lib/resources/WebsiteCampaign.ts +432 -0
  61. package/lib/resources/WebsiteConversation.ts +1507 -0
  62. package/lib/resources/WebsiteHelpdesk.ts +1024 -0
  63. package/lib/resources/WebsiteOperator.ts +183 -0
  64. package/lib/resources/WebsitePeople.ts +568 -0
  65. package/lib/resources/WebsiteSettings.ts +207 -0
  66. package/lib/resources/WebsiteVerify.ts +90 -0
  67. package/lib/resources/WebsiteVisitors.ts +219 -0
  68. package/lib/resources/index.ts +28 -0
  69. package/lib/services/bucket.ts +36 -0
  70. package/lib/services/media.ts +36 -0
  71. package/lib/services/plugin.ts +40 -0
  72. package/lib/services/website.ts +70 -0
  73. package/package.json +16 -11
  74. package/tsconfig.json +12 -5
  75. package/lib/crisp.js +0 -1171
  76. package/lib/resources/BucketURL.js +0 -34
  77. package/lib/resources/MediaAnimation.js +0 -41
  78. package/lib/resources/PluginConnect.js +0 -119
  79. package/lib/resources/PluginSubscription.js +0 -234
  80. package/lib/resources/WebsiteAnalytics.js +0 -37
  81. package/lib/resources/WebsiteAvailability.js +0 -48
  82. package/lib/resources/WebsiteBase.js +0 -100
  83. package/lib/resources/WebsiteBatch.js +0 -92
  84. package/lib/resources/WebsiteCampaign.js +0 -396
  85. package/lib/resources/WebsiteConversation.js +0 -1261
  86. package/lib/resources/WebsiteHelpdesk.js +0 -1198
  87. package/lib/resources/WebsiteOperator.js +0 -167
  88. package/lib/resources/WebsitePeople.js +0 -516
  89. package/lib/resources/WebsiteSettings.js +0 -50
  90. package/lib/resources/WebsiteVerify.js +0 -79
  91. package/lib/resources/WebsiteVisitors.js +0 -148
  92. package/lib/services/Bucket.js +0 -28
  93. package/lib/services/Media.js +0 -28
  94. package/lib/services/Plugin.js +0 -29
  95. package/lib/services/Website.js +0 -39
  96. package/types/crisp.d.ts +0 -151
  97. package/types/resources/BucketURL.d.ts +0 -15
  98. package/types/resources/MediaAnimation.d.ts +0 -15
  99. package/types/resources/PluginConnect.d.ts +0 -15
  100. package/types/resources/PluginSubscription.d.ts +0 -15
  101. package/types/resources/WebsiteAnalytics.d.ts +0 -15
  102. package/types/resources/WebsiteAvailability.d.ts +0 -15
  103. package/types/resources/WebsiteBase.d.ts +0 -15
  104. package/types/resources/WebsiteBatch.d.ts +0 -15
  105. package/types/resources/WebsiteCampaign.d.ts +0 -15
  106. package/types/resources/WebsiteConversation.d.ts +0 -15
  107. package/types/resources/WebsiteHelpdesk.d.ts +0 -15
  108. package/types/resources/WebsiteOperator.d.ts +0 -15
  109. package/types/resources/WebsitePeople.d.ts +0 -15
  110. package/types/resources/WebsiteSettings.d.ts +0 -15
  111. package/types/resources/WebsiteVerify.d.ts +0 -15
  112. package/types/resources/WebsiteVisitors.d.ts +0 -15
  113. package/types/services/Bucket.d.ts +0 -14
  114. package/types/services/Media.d.ts +0 -14
  115. package/types/services/Plugin.d.ts +0 -14
  116. 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(Crisp.RTM_MODES.WebHooks)`
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(Crisp.RTM_MODES.WebSockets)`
3512
+ 1. The RTM events mode is set to WebSockets: `CrispClient.setRtmMode("websockets")`
3513
3513
 
3514
3514
  ### Available realtime events
3515
3515
 
@@ -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;