crisp-api 10.0.2 → 10.0.4

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 (71) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/dist/crisp.d.ts +41 -29
  3. package/dist/crisp.js +43 -34
  4. package/dist/resources/BaseResource.d.ts +6 -0
  5. package/dist/resources/BaseResource.js +6 -0
  6. package/dist/resources/BucketURL.d.ts +9 -0
  7. package/dist/resources/BucketURL.js +6 -0
  8. package/dist/resources/MediaAnimation.d.ts +6 -0
  9. package/dist/resources/MediaAnimation.js +9 -1
  10. package/dist/resources/PluginConnect.d.ts +9 -0
  11. package/dist/resources/PluginConnect.js +6 -0
  12. package/dist/resources/PluginSubscription.d.ts +9 -0
  13. package/dist/resources/PluginSubscription.js +9 -1
  14. package/dist/resources/WebsiteAnalytics.d.ts +6 -0
  15. package/dist/resources/WebsiteAnalytics.js +9 -1
  16. package/dist/resources/WebsiteAvailability.d.ts +9 -0
  17. package/dist/resources/WebsiteAvailability.js +12 -2
  18. package/dist/resources/WebsiteBase.d.ts +9 -0
  19. package/dist/resources/WebsiteBase.js +6 -0
  20. package/dist/resources/WebsiteBatch.d.ts +9 -0
  21. package/dist/resources/WebsiteBatch.js +6 -0
  22. package/dist/resources/WebsiteCampaign.d.ts +9 -0
  23. package/dist/resources/WebsiteCampaign.js +8 -1
  24. package/dist/resources/WebsiteConversation.d.ts +9 -0
  25. package/dist/resources/WebsiteConversation.js +15 -3
  26. package/dist/resources/WebsiteHelpdesk.d.ts +15 -2
  27. package/dist/resources/WebsiteHelpdesk.js +6 -0
  28. package/dist/resources/WebsiteOperator.d.ts +9 -0
  29. package/dist/resources/WebsiteOperator.js +6 -0
  30. package/dist/resources/WebsitePeople.d.ts +9 -0
  31. package/dist/resources/WebsitePeople.js +6 -0
  32. package/dist/resources/WebsiteSettings.d.ts +9 -0
  33. package/dist/resources/WebsiteSettings.js +6 -0
  34. package/dist/resources/WebsiteVerify.d.ts +9 -0
  35. package/dist/resources/WebsiteVerify.js +6 -0
  36. package/dist/resources/WebsiteVisitors.d.ts +9 -0
  37. package/dist/resources/WebsiteVisitors.js +12 -2
  38. package/dist/resources/index.d.ts +3 -0
  39. package/dist/resources/index.js +3 -1
  40. package/dist/services/bucket.d.ts +6 -0
  41. package/dist/services/bucket.js +3 -0
  42. package/dist/services/media.d.ts +6 -0
  43. package/dist/services/media.js +3 -0
  44. package/dist/services/plugin.d.ts +6 -0
  45. package/dist/services/plugin.js +3 -0
  46. package/dist/services/website.d.ts +6 -0
  47. package/dist/services/website.js +3 -0
  48. package/lib/crisp.ts +123 -74
  49. package/lib/resources/BaseResource.ts +8 -0
  50. package/lib/resources/BucketURL.ts +12 -3
  51. package/lib/resources/MediaAnimation.ts +11 -1
  52. package/lib/resources/PluginConnect.ts +12 -5
  53. package/lib/resources/PluginSubscription.ts +36 -8
  54. package/lib/resources/WebsiteAnalytics.ts +11 -1
  55. package/lib/resources/WebsiteAvailability.ts +24 -4
  56. package/lib/resources/WebsiteBase.ts +14 -3
  57. package/lib/resources/WebsiteBatch.ts +24 -4
  58. package/lib/resources/WebsiteCampaign.ts +49 -16
  59. package/lib/resources/WebsiteConversation.ts +136 -45
  60. package/lib/resources/WebsiteHelpdesk.ts +81 -34
  61. package/lib/resources/WebsiteOperator.ts +28 -6
  62. package/lib/resources/WebsitePeople.ts +60 -19
  63. package/lib/resources/WebsiteSettings.ts +17 -2
  64. package/lib/resources/WebsiteVerify.ts +17 -3
  65. package/lib/resources/WebsiteVisitors.ts +32 -9
  66. package/lib/resources/index.ts +4 -1
  67. package/lib/services/bucket.ts +8 -0
  68. package/lib/services/media.ts +8 -0
  69. package/lib/services/plugin.ts +8 -0
  70. package/lib/services/website.ts +8 -0
  71. package/package.json +1 -1
@@ -20,7 +20,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- // Used to export all types
23
+ /**************************************************************************
24
+ * EXPORTS
25
+ ***************************************************************************/
24
26
  __exportStar(require("./BaseResource"), exports);
25
27
  __exportStar(require("./BucketURL"), exports);
26
28
  __exportStar(require("./MediaAnimation"), exports);
@@ -2,12 +2,18 @@
2
2
  * IMPORTS
3
3
  ***************************************************************************/
4
4
  import BucketURL from "../resources/BucketURL";
5
+ /**************************************************************************
6
+ * CLASSES
7
+ ***************************************************************************/
5
8
  /**
6
9
  * Bucket Service
7
10
  */
8
11
  declare class BucketService {
9
12
  __resources: any[];
10
13
  }
14
+ /**************************************************************************
15
+ * EXPORTS
16
+ ***************************************************************************/
11
17
  export interface BucketServiceInterface extends BucketURL {
12
18
  }
13
19
  export default BucketService;
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  ***************************************************************************/
15
15
  // PROJECT: RESOURCES
16
16
  const BucketURL_1 = __importDefault(require("../resources/BucketURL"));
17
+ /**************************************************************************
18
+ * CLASSES
19
+ ***************************************************************************/
17
20
  /**
18
21
  * Bucket Service
19
22
  */
@@ -2,12 +2,18 @@
2
2
  * IMPORTS
3
3
  ***************************************************************************/
4
4
  import MediaAnimation from "../resources/MediaAnimation";
5
+ /**************************************************************************
6
+ * CLASSES
7
+ ***************************************************************************/
5
8
  /**
6
9
  * Crisp Media Service
7
10
  */
8
11
  declare class MediaService {
9
12
  __resources: any[];
10
13
  }
14
+ /**************************************************************************
15
+ * EXPORTS
16
+ ***************************************************************************/
11
17
  export interface MediaServiceInterface extends MediaAnimation {
12
18
  }
13
19
  export default MediaService;
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  ***************************************************************************/
15
15
  // PROJECT: RESOURCES
16
16
  const MediaAnimation_1 = __importDefault(require("../resources/MediaAnimation"));
17
+ /**************************************************************************
18
+ * CLASSES
19
+ ***************************************************************************/
17
20
  /**
18
21
  * Crisp Media Service
19
22
  */
@@ -3,12 +3,18 @@
3
3
  ***************************************************************************/
4
4
  import PluginConnect from "../resources/PluginConnect";
5
5
  import PluginSubscription from "../resources/PluginSubscription";
6
+ /**************************************************************************
7
+ * CLASSES
8
+ ***************************************************************************/
6
9
  /**
7
10
  * Crisp Plugin Service
8
11
  */
9
12
  declare class PluginService {
10
13
  __resources: any[];
11
14
  }
15
+ /**************************************************************************
16
+ * EXPORTS
17
+ ***************************************************************************/
12
18
  export interface PluginServiceInterface extends PluginConnect, PluginSubscription {
13
19
  }
14
20
  export default PluginService;
@@ -15,6 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  // PROJECT: RESOURCES
16
16
  const PluginConnect_1 = __importDefault(require("../resources/PluginConnect"));
17
17
  const PluginSubscription_1 = __importDefault(require("../resources/PluginSubscription"));
18
+ /**************************************************************************
19
+ * CLASSES
20
+ ***************************************************************************/
18
21
  /**
19
22
  * Crisp Plugin Service
20
23
  */
@@ -13,12 +13,18 @@ import WebsiteHelpdesk from "../resources/WebsiteHelpdesk";
13
13
  import WebsiteSettings from "../resources/WebsiteSettings";
14
14
  import WebsiteVerify from "../resources/WebsiteVerify";
15
15
  import WebsiteVisitors from "../resources/WebsiteVisitors";
16
+ /**************************************************************************
17
+ * CLASSES
18
+ ***************************************************************************/
16
19
  /**
17
20
  * Website Service
18
21
  */
19
22
  declare class WebsiteService {
20
23
  __resources: any[];
21
24
  }
25
+ /**************************************************************************
26
+ * EXPORTS
27
+ ***************************************************************************/
22
28
  export interface WebsiteServiceInterface extends WebsiteBase, WebsiteAnalytics, WebsiteAvailability, WebsiteBatch, WebsiteCampaign, WebsiteConversation, WebsiteOperator, WebsitePeople, WebsiteHelpdesk, WebsiteSettings, WebsiteVerify, WebsiteVisitors {
23
29
  }
24
30
  export default WebsiteService;
@@ -25,6 +25,9 @@ const WebsiteHelpdesk_1 = __importDefault(require("../resources/WebsiteHelpdesk"
25
25
  const WebsiteSettings_1 = __importDefault(require("../resources/WebsiteSettings"));
26
26
  const WebsiteVerify_1 = __importDefault(require("../resources/WebsiteVerify"));
27
27
  const WebsiteVisitors_1 = __importDefault(require("../resources/WebsiteVisitors"));
28
+ /**************************************************************************
29
+ * CLASSES
30
+ ***************************************************************************/
28
31
  /**
29
32
  * Website Service
30
33
  */
package/lib/crisp.ts CHANGED
@@ -10,26 +10,32 @@
10
10
  ***************************************************************************/
11
11
 
12
12
  // NPM
13
- import got from "got";
14
- import { io as socketio } from "socket.io-client";
15
- import { Socket } from "socket.io-client";
13
+ import { URL } from "url";
14
+ import Crypto from "crypto";
16
15
 
17
- import { URL } from "url";
18
- import Crypto from "crypto";
16
+ import got from "got";
17
+ import { io as socketio } from "socket.io-client";
18
+ import { Socket } from "socket.io-client";
19
19
  import mitt, { Emitter } from "mitt";
20
20
 
21
21
  // PROJECT: SERVICES
22
- import Bucket from "@/services/bucket";
23
- import Media from "@/services/media";
24
- import Plugin from "@/services/plugin";
22
+ import Bucket, { BucketServiceInterface } from "@/services/bucket";
23
+ import Media, { MediaServiceInterface } from "@/services/media";
24
+ import Plugin, { PluginServiceInterface } from "@/services/plugin";
25
25
  import Website, { WebsiteServiceInterface } from "@/services/website";
26
26
 
27
- // PROJECT: MAIN
28
- // Export all types from resources
29
- export * from "@/resources";
27
+ /**************************************************************************
28
+ * TYPES
29
+ ***************************************************************************/
30
30
 
31
31
  export type RTM_MODES = "websockets" | "webhooks";
32
32
 
33
+ export type CrispTier = "user" | "plugin";
34
+
35
+ /**************************************************************************
36
+ * CONSTANTS
37
+ ***************************************************************************/
38
+
33
39
  const AVAILABLE_RTM_MODES = [
34
40
  "websockets",
35
41
  "webhooks"
@@ -38,21 +44,21 @@ const AVAILABLE_RTM_MODES = [
38
44
  const VERSION = "__PKG_VERSION_PLACEHOLDER__";
39
45
 
40
46
  // Base configuration
41
- const DEFAULT_REQUEST_TIMEOUT = 10000;
42
- const DEFAULT_SOCKET_TIMEOUT = 10000;
43
- const DEFAULT_SOCKET_RECONNECT_DELAY = 5000;
47
+ const DEFAULT_REQUEST_TIMEOUT = 10000;
48
+ const DEFAULT_SOCKET_TIMEOUT = 10000;
49
+ const DEFAULT_SOCKET_RECONNECT_DELAY = 5000;
44
50
  const DEFAULT_SOCKET_RECONNECT_DELAY_MAX = 10000;
45
- const DEFAULT_SOCKET_RECONNECT_FACTOR = 0.75;
46
- const DEFAULT_BROKER_SCHEDULE = 500;
47
- const DEFAULT_EVENT_REBIND_INTERVAL_MIN = 2500;
48
- const DEFAULT_USERAGENT_PREFIX = "node-crisp-api/";
51
+ const DEFAULT_SOCKET_RECONNECT_FACTOR = 0.75;
52
+ const DEFAULT_BROKER_SCHEDULE = 500;
53
+ const DEFAULT_EVENT_REBIND_INTERVAL_MIN = 2500;
54
+ const DEFAULT_USERAGENT_PREFIX = "node-crisp-api/";
49
55
 
50
56
  // REST API defaults
51
- const DEFAULT_REST_HOST = "https://api.crisp.chat";
57
+ const DEFAULT_REST_HOST = "https://api.crisp.chat";
52
58
  const DEFAULT_REST_BASE_PATH = "/v1/";
53
59
 
54
60
  // RTM API defaults
55
- const DEFAULT_RTM_MODE = "websockets";
61
+ const DEFAULT_RTM_MODE = "websockets";
56
62
 
57
63
  const DEFAULT_RTM_EVENTS = [
58
64
  // Session Events
@@ -172,6 +178,10 @@ const services = {
172
178
  Website: Website
173
179
  };
174
180
 
181
+ /**************************************************************************
182
+ * INTERFACES
183
+ ***************************************************************************/
184
+
175
185
  interface CrispAuth {
176
186
  tier: CrispTier;
177
187
  identifier: string | null;
@@ -179,17 +189,29 @@ interface CrispAuth {
179
189
  token: string | null;
180
190
  }
181
191
 
182
- export type CrispTier = "user" | "plugin";
192
+ /**************************************************************************
193
+ * CLASSES
194
+ ***************************************************************************/
183
195
 
184
196
  /**
185
- * Crisp API Library
197
+ *
186
198
  */
187
199
  export class Crisp {
188
- public bucket: Bucket = new Bucket();
189
- public media: Media = new Media();
190
- public plugin: Plugin = new Plugin();
200
+ public bucket: BucketServiceInterface = (
201
+ new Bucket() as unknown as BucketServiceInterface
202
+ );
191
203
 
192
- public website: WebsiteServiceInterface = new Website() as unknown as WebsiteServiceInterface;
204
+ public media: MediaServiceInterface = (
205
+ new Media() as unknown as MediaServiceInterface
206
+ );
207
+
208
+ public plugin: PluginServiceInterface = (
209
+ new Plugin() as unknown as PluginServiceInterface
210
+ );
211
+
212
+ public website: WebsiteServiceInterface = (
213
+ new Website() as unknown as WebsiteServiceInterface
214
+ );
193
215
 
194
216
  /**
195
217
  * @deprecated Use import { RTM_MODES } instead
@@ -206,31 +228,31 @@ export class Crisp {
206
228
  token: null
207
229
  };
208
230
 
209
- public _rest = {
231
+ protected _rest = {
210
232
  host: DEFAULT_REST_HOST,
211
233
  basePath: DEFAULT_REST_BASE_PATH
212
234
  };
213
235
 
214
- public _rtm = {
236
+ protected _rtm = {
215
237
  host: "",
216
238
  mode: DEFAULT_RTM_MODE as RTM_MODES
217
239
  };
218
240
 
219
- public _useragent = (DEFAULT_USERAGENT_PREFIX + VERSION);
241
+ protected _useragent = (DEFAULT_USERAGENT_PREFIX + VERSION);
220
242
 
221
- public _emitter = mitt();
243
+ protected _emitter = mitt();
222
244
 
223
- public _socket: Socket | null = null;
224
- public _loopback: Emitter<Record<string, unknown>> | null = null;
245
+ protected _socket: Socket | null = null;
246
+ protected _loopback: Emitter<Record<string, unknown>> | null = null;
225
247
 
226
- public _lastEventRebind = null;
248
+ protected _lastEventRebind = null;
227
249
 
228
- public _brokerScheduler: typeof setTimeout | null = null;
250
+ protected _brokerScheduler: typeof setTimeout | null = null;
229
251
 
230
252
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-unused-vars
231
- public _brokerBindHooks: ((modeInstance: any, emitter: any) => void)[] = [];
253
+ protected _brokerBindHooks: ((modeInstance: any, emitter: any) => void)[] = [];
232
254
 
233
- public _boundEvents = {};
255
+ protected _boundEvents = {};
234
256
 
235
257
  /**
236
258
  * Constructor
@@ -309,7 +331,7 @@ export class Crisp {
309
331
  */
310
332
  head(resource: string, query?: object | null): Promise<any> {
311
333
  return new Promise((resolve, reject) => {
312
- this.request(
334
+ this.__request(
313
335
  resource, "head", (query || {}), null, resolve, reject
314
336
  );
315
337
  });
@@ -320,7 +342,7 @@ export class Crisp {
320
342
  */
321
343
  get(resource: string, query?: object): Promise<any> {
322
344
  return new Promise((resolve, reject) => {
323
- this.request(
345
+ this.__request(
324
346
  resource, "get", (query || {}), null, resolve, reject
325
347
  );
326
348
  });
@@ -329,9 +351,11 @@ export class Crisp {
329
351
  /**
330
352
  * Method wrapper to POST a resource
331
353
  */
332
- post(resource: string, query: object | null, body: object | null): Promise<any> {
354
+ post(
355
+ resource: string, query: object | null, body: object | null
356
+ ): Promise<any> {
333
357
  return new Promise((resolve, reject) => {
334
- this.request(
358
+ this.__request(
335
359
  resource, "post", (query || {}), (body || {}), resolve, reject
336
360
  );
337
361
  });
@@ -340,9 +364,11 @@ export class Crisp {
340
364
  /**
341
365
  * Method wrapper to PATCH a resource
342
366
  */
343
- patch(resource: string, query: object | null, body: object | null): Promise<any> {
367
+ patch(
368
+ resource: string, query: object | null, body: object | null
369
+ ): Promise<any> {
344
370
  return new Promise((resolve, reject) => {
345
- this.request(
371
+ this.__request(
346
372
  resource, "patch", (query || {}), (body || {}), resolve, reject
347
373
  );
348
374
  });
@@ -351,9 +377,11 @@ export class Crisp {
351
377
  /**
352
378
  * Method wrapper to PUT a resource
353
379
  */
354
- put(resource: string, query: object | null, body: object | null): Promise<any> {
380
+ put(
381
+ resource: string, query: object | null, body: object | null
382
+ ): Promise<any> {
355
383
  return new Promise((resolve, reject) => {
356
- this.request(
384
+ this.__request(
357
385
  resource, "put", (query || {}), (body || {}), resolve, reject
358
386
  );
359
387
  });
@@ -362,9 +390,11 @@ export class Crisp {
362
390
  /**
363
391
  * Method wrapper to DELETE a resource
364
392
  */
365
- delete(resource: string, query?: object | null, body?: object | null): Promise<any> {
393
+ delete(
394
+ resource: string, query?: object | null, body?: object | null
395
+ ): Promise<any> {
366
396
  return new Promise((resolve, reject) => {
367
- this.request(
397
+ this.__request(
368
398
  resource, "delete", (query || {}), (body || null), resolve, reject
369
399
  );
370
400
  });
@@ -416,7 +446,7 @@ export class Crisp {
416
446
  this._boundEvents[event] = true;
417
447
 
418
448
  // Broker not connected? Connect now.
419
- return this.prepareBroker(
449
+ return this.__prepareBroker(
420
450
  (instance, emitter) => {
421
451
  // Listen for event? (once instance is bound)
422
452
  switch (rtmMode) {
@@ -478,9 +508,11 @@ export class Crisp {
478
508
  * Verifies an event string and checks that signatures match (used for Web \
479
509
  * Hooks)
480
510
  */
481
- verifyHook(secret: string, body: object, timestamp: number, signature: string) {
511
+ verifyHook(
512
+ secret: string, body: object, timestamp: number, signature: string
513
+ ) {
482
514
  if (this._loopback) {
483
- return this.verifySignature(secret, body, timestamp, signature);
515
+ return this.__verifySignature(secret, body, timestamp, signature);
484
516
  }
485
517
 
486
518
  // Default: not verified (loopback not /yet?/ bound)
@@ -491,8 +523,10 @@ export class Crisp {
491
523
  * Verifies an event string and checks that signatures match (used for \
492
524
  * Widgets)
493
525
  */
494
- verifyWidget(secret: string, body: object, timestamp: number, signature: string) {
495
- return this.verifySignature(secret, body, timestamp, signature);
526
+ verifyWidget(
527
+ secret: string, body: object, timestamp: number, signature: string
528
+ ) {
529
+ return this.__verifySignature(secret, body, timestamp, signature);
496
530
  }
497
531
 
498
532
  /**
@@ -549,7 +583,7 @@ export class Crisp {
549
583
  /**
550
584
  * Binds services to the main object
551
585
  */
552
- _prepareServices() {
586
+ protected _prepareServices() {
553
587
  // Bind services
554
588
  for (const name in services) {
555
589
  const serviceInstance = new services[name]();
@@ -567,7 +601,7 @@ export class Crisp {
567
601
  }
568
602
 
569
603
  // Prepare all resources (for service)
570
- this.prepareResources(
604
+ this.__prepareResources(
571
605
  serviceMap, serviceInstance.__resources
572
606
  );
573
607
  }
@@ -577,16 +611,21 @@ export class Crisp {
577
611
  * Binds resources to the service object
578
612
  */
579
613
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
580
- private prepareResources(serviceMap: any, resources: any) {
614
+ private __prepareResources(serviceMap: any, resources: any) {
581
615
  for (let i = 0; i < resources.length; i++) {
582
616
  const resourceConstructor = resources[i];
583
-
584
617
  const resourceInstance = new resourceConstructor(this);
585
618
 
586
619
  // Bind each method of the resource instance to the service map
587
- for (const methodName of Object.getOwnPropertyNames(Object.getPrototypeOf(resourceInstance))) {
620
+ const methodNames = Object.getOwnPropertyNames(
621
+ Object.getPrototypeOf(resourceInstance)
622
+ );
623
+
624
+ for (const methodName of methodNames) {
588
625
  if (methodName !== "constructor") {
589
- serviceMap[methodName] = resourceInstance[methodName].bind(resourceInstance);
626
+ serviceMap[methodName] = resourceInstance[methodName].bind(
627
+ resourceInstance
628
+ );
590
629
  }
591
630
  }
592
631
  }
@@ -595,8 +634,10 @@ export class Crisp {
595
634
  /**
596
635
  * Binds broker to the main object
597
636
  */
598
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-unused-vars
599
- private prepareBroker(fnBindHook: (modeInstance: any, emitter: any) => void) {
637
+ private __prepareBroker(
638
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-unused-vars
639
+ fnBindHook: (modeInstance: any, emitter: any) => void
640
+ ) {
600
641
  return new Promise((resolve, reject) => {
601
642
  const rtmMode = this._rtm.mode;
602
643
  const rtmHostOverride = this._rtm.host;
@@ -622,7 +663,7 @@ export class Crisp {
622
663
  case "websockets": {
623
664
  // Connect to socket now
624
665
  // Notice: will unstack broker bind hooks once ready
625
- this.connectSocket(rtmHostOverride)
666
+ this.__connectSocket(rtmHostOverride)
626
667
  .then(resolve)
627
668
  .catch(reject);
628
669
 
@@ -631,7 +672,7 @@ export class Crisp {
631
672
 
632
673
  case "webhooks": {
633
674
  // Connect to loopback now
634
- this.connectLoopback()
675
+ this.__connectLoopback()
635
676
  .then(resolve)
636
677
  .catch(reject);
637
678
 
@@ -658,14 +699,14 @@ export class Crisp {
658
699
  /**
659
700
  * Connects loopback (used for Web Hooks)
660
701
  */
661
- private connectLoopback() {
702
+ private __connectLoopback() {
662
703
  return Promise.resolve()
663
704
  .then(() => {
664
705
  // Assign emitter to loopback
665
706
  this._loopback = this._emitter;
666
707
 
667
708
  // Unstack broker bind hooks immediately
668
- this.unstackBrokerBindHooks(this._loopback);
709
+ this.__unstackBrokerBindHooks(this._loopback);
669
710
 
670
711
  return Promise.resolve();
671
712
  });
@@ -674,7 +715,7 @@ export class Crisp {
674
715
  /**
675
716
  * Connects socket, using preferred RTM API host (used for WebSockets)
676
717
  */
677
- private connectSocket(rtmHostOverride: string) {
718
+ private __connectSocket(rtmHostOverride: string) {
678
719
  return Promise.resolve()
679
720
  .then(() => {
680
721
  // Any override RTM API host?
@@ -736,11 +777,11 @@ export class Crisp {
736
777
  randomizationFactor: DEFAULT_SOCKET_RECONNECT_FACTOR
737
778
  });
738
779
 
739
- this.emitAuthenticateSocket();
780
+ this.__emitAuthenticateSocket();
740
781
 
741
782
  // Setup base socket event listeners
742
783
  this._socket?.io.on("reconnect", () => {
743
- this.emitAuthenticateSocket();
784
+ this.__emitAuthenticateSocket();
744
785
  });
745
786
 
746
787
  this._socket?.on("unauthorized", () => {
@@ -751,7 +792,7 @@ export class Crisp {
751
792
  });
752
793
 
753
794
  // Setup user socket event listeners
754
- this.unstackBrokerBindHooks(this._socket);
795
+ this.__unstackBrokerBindHooks(this._socket);
755
796
 
756
797
  return Promise.resolve();
757
798
  });
@@ -760,7 +801,7 @@ export class Crisp {
760
801
  /**
761
802
  * Authenticates client (used for WebSockets)
762
803
  */
763
- private emitAuthenticateSocket() {
804
+ private __emitAuthenticateSocket() {
764
805
  const auth = this.auth;
765
806
  const boundEvents = Object.keys(this._boundEvents);
766
807
 
@@ -797,7 +838,7 @@ export class Crisp {
797
838
  * Unstacks pending broker bind hooks
798
839
  */
799
840
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
800
- private unstackBrokerBindHooks(modeInstance: any) {
841
+ private __unstackBrokerBindHooks(modeInstance: any) {
801
842
  // Setup user socket event listeners
802
843
  while (this._brokerBindHooks.length > 0) {
803
844
  this._brokerBindHooks.shift()?.(
@@ -809,7 +850,7 @@ export class Crisp {
809
850
  /**
810
851
  * Performs a request to REST API
811
852
  */
812
- private request(
853
+ private __request(
813
854
  resource: string,
814
855
  method: string,
815
856
  query: object,
@@ -874,7 +915,7 @@ export class Crisp {
874
915
 
875
916
  // Response error?
876
917
  if (response.statusCode >= 400) {
877
- let reasonMessage = this.readErrorResponseReason(
918
+ let reasonMessage = this.__readErrorResponseReason(
878
919
  method, response.statusCode, response
879
920
  );
880
921
 
@@ -905,7 +946,9 @@ export class Crisp {
905
946
  /**
906
947
  * Reads reason for error response
907
948
  */
908
- private readErrorResponseReason(method: string, statusCode: number, response: object) {
949
+ private __readErrorResponseReason(
950
+ method: string, statusCode: number, response: object
951
+ ) {
909
952
  // HEAD method? As HEAD requests do not expect any response body, then we \
910
953
  // cannot map a reason from the response.
911
954
  if (method === "head") {
@@ -929,7 +972,9 @@ export class Crisp {
929
972
  /**
930
973
  * Verifies an event string and checks that signatures match
931
974
  */
932
- private verifySignature(secret: string, body: object, timestamp: number, signature: string) {
975
+ private __verifySignature(
976
+ secret: string, body: object, timestamp: number, signature: string
977
+ ) {
933
978
  // Ensure all provided data is valid
934
979
  if (!secret || !signature || !body || typeof body !== "object" ||
935
980
  !timestamp || isNaN(timestamp) === true) {
@@ -953,5 +998,9 @@ export class Crisp {
953
998
  }
954
999
  };
955
1000
 
956
- export default Crisp;
1001
+ /**************************************************************************
1002
+ * EXPORTS
1003
+ ***************************************************************************/
957
1004
 
1005
+ export * from "@/resources";
1006
+ export default Crisp;
@@ -12,6 +12,10 @@
12
12
  // PROJECT: MAIN
13
13
  import Crisp from "@/crisp";
14
14
 
15
+ /**************************************************************************
16
+ * CLASSES
17
+ ***************************************************************************/
18
+
15
19
  /**
16
20
  * Crisp Base Resource
17
21
  */
@@ -26,4 +30,8 @@ class BaseResource {
26
30
  }
27
31
  }
28
32
 
33
+ /**************************************************************************
34
+ * EXPORTS
35
+ ***************************************************************************/
36
+
29
37
  export default BaseResource;
@@ -12,19 +12,20 @@
12
12
  // PROJECT: RESOURCES
13
13
  import BaseResource from "./BaseResource";
14
14
 
15
- // BucketURLRequestFile mapping
15
+ /**************************************************************************
16
+ * TYPES
17
+ ***************************************************************************/
18
+
16
19
  export type BucketURLRequestFile = {
17
20
  name?: string;
18
21
  type?: string;
19
22
  };
20
23
 
21
- // BucketURLRequestResource mapping
22
24
  export type BucketURLRequestResource = {
23
25
  type?: string;
24
26
  id?: string;
25
27
  };
26
28
 
27
- // BucketURLRequest mapping
28
29
  export type BucketURLRequest = {
29
30
  namespace?: string;
30
31
  id?: string;
@@ -32,6 +33,10 @@ export type BucketURLRequest = {
32
33
  resource?: BucketURLRequestResource;
33
34
  };
34
35
 
36
+ /**************************************************************************
37
+ * CLASSES
38
+ ***************************************************************************/
39
+
35
40
  /**
36
41
  * Crisp BucketURL Resource
37
42
  */
@@ -46,4 +51,8 @@ class BucketURL extends BaseResource {
46
51
  };
47
52
  }
48
53
 
54
+ /**************************************************************************
55
+ * EXPORTS
56
+ ***************************************************************************/
57
+
49
58
  export default BucketURL;