crisp-api 10.0.17 → 10.1.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +7 -3
  3. package/dist/crisp.d.ts +8 -2
  4. package/dist/crisp.js +31 -10
  5. package/dist/resources/BaseResource.js +3 -3
  6. package/dist/resources/BucketURL.js +3 -3
  7. package/dist/resources/MediaAnimation.js +3 -3
  8. package/dist/resources/PluginConnect.d.ts +4 -0
  9. package/dist/resources/PluginConnect.js +3 -3
  10. package/dist/resources/PluginSubscription.js +3 -3
  11. package/dist/resources/WebsiteAnalytics.js +3 -3
  12. package/dist/resources/WebsiteAvailability.js +3 -3
  13. package/dist/resources/WebsiteBase.js +3 -3
  14. package/dist/resources/WebsiteBatch.js +3 -3
  15. package/dist/resources/WebsiteCampaign.js +3 -3
  16. package/dist/resources/WebsiteConversation.d.ts +34 -1
  17. package/dist/resources/WebsiteConversation.js +7 -5
  18. package/dist/resources/WebsiteHelpdesk.js +3 -3
  19. package/dist/resources/WebsiteOperator.js +3 -3
  20. package/dist/resources/WebsitePeople.js +3 -3
  21. package/dist/resources/WebsiteSettings.js +3 -3
  22. package/dist/resources/WebsiteVerify.js +3 -3
  23. package/dist/resources/WebsiteVisitors.js +3 -3
  24. package/dist/resources/index.js +3 -3
  25. package/dist/services/bucket.js +3 -3
  26. package/dist/services/media.js +3 -3
  27. package/dist/services/plugin.js +3 -3
  28. package/dist/services/website.js +3 -3
  29. package/lib/crisp.ts +36 -7
  30. package/lib/resources/BaseResource.ts +3 -3
  31. package/lib/resources/BucketURL.ts +3 -3
  32. package/lib/resources/MediaAnimation.ts +3 -3
  33. package/lib/resources/PluginConnect.ts +8 -3
  34. package/lib/resources/PluginSubscription.ts +3 -3
  35. package/lib/resources/WebsiteAnalytics.ts +3 -3
  36. package/lib/resources/WebsiteAvailability.ts +3 -3
  37. package/lib/resources/WebsiteBase.ts +3 -3
  38. package/lib/resources/WebsiteBatch.ts +3 -3
  39. package/lib/resources/WebsiteCampaign.ts +3 -3
  40. package/lib/resources/WebsiteConversation.ts +50 -5
  41. package/lib/resources/WebsiteHelpdesk.ts +3 -3
  42. package/lib/resources/WebsiteOperator.ts +3 -3
  43. package/lib/resources/WebsitePeople.ts +3 -3
  44. package/lib/resources/WebsiteSettings.ts +3 -3
  45. package/lib/resources/WebsiteVerify.ts +3 -3
  46. package/lib/resources/WebsiteVisitors.ts +3 -3
  47. package/lib/resources/index.ts +3 -3
  48. package/lib/services/bucket.ts +3 -3
  49. package/lib/services/media.ts +3 -3
  50. package/lib/services/plugin.ts +3 -3
  51. package/lib/services/website.ts +3 -3
  52. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,12 +1,28 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## v10.1.0
5
+
6
+ ### New Features
7
+
8
+ * Added `options` to `CrispClient.website.listConversations`.
9
+
10
+ ## v10.0.18
11
+
12
+ ### New Features
13
+
14
+ * Added the new `CrispClient.setCustomHeaders` method to set custom headers for all API requests.
15
+
4
16
  ## v10.0.17
5
17
 
6
- * Add `stamped` to `ConversationMessage`
18
+ ### New Features
19
+
20
+ * Add `stamped` to `ConversationMessage`.
7
21
 
8
22
  ## v10.0.16
9
23
 
24
+ ### Changes
25
+
10
26
  * Harden types on `ConversationVerifyIdentityRequest` and `ConversationVerifyIdentityRedeem`.
11
27
 
12
28
  ## v10.0.15
package/README.md CHANGED
@@ -6,7 +6,7 @@ The Crisp API Node wrapper. Authenticate, send messages, fetch conversations, ac
6
6
 
7
7
  Copyright 2025 Crisp IM SAS. See LICENSE for copying information.
8
8
 
9
- * **📝 Implements**: [REST API Reference (V1)](https://docs.crisp.chat/references/rest-api/v1/) at revision: 17/03/2025
9
+ * **📝 Implements**: [REST API Reference (V1)](https://docs.crisp.chat/references/rest-api/v1/) at revision: 22/11/2025
10
10
  * **😘 Maintainers**: [@baptistejamin](https://github.com/baptistejamin), [@eliottvincent](https://github.com/eliottvincent), [@valeriansaliou](https://github.com/valeriansaliou)
11
11
 
12
12
  ## Installation
@@ -168,7 +168,7 @@ All methods that you will most likely need when building a Crisp integration are
168
168
 
169
169
  * #### **Website Conversations**
170
170
  * **⭐ List Conversations** [`user`, `plugin`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-conversations)
171
- * `CrispClient.website.listConversations(websiteID, pageNumber)`
171
+ * `CrispClient.website.listConversations(websiteID, pageNumber, options)`
172
172
  * <details>
173
173
  <summary>See Example</summary>
174
174
 
@@ -176,7 +176,11 @@ All methods that you will most likely need when building a Crisp integration are
176
176
  var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
177
177
  var pageNumber = 1;
178
178
 
179
- CrispClient.website.listConversations(websiteID, pageNumber);
179
+ var options = {
180
+ per_page: 50
181
+ }
182
+
183
+ CrispClient.website.listConversations(websiteID, pageNumber, options);
180
184
  ```
181
185
  </details>
182
186
 
package/dist/crisp.d.ts CHANGED
@@ -22,9 +22,9 @@ interface CrispAuth {
22
22
  * CLASSES
23
23
  ***************************************************************************/
24
24
  /**
25
- *
25
+ * Crisp
26
26
  */
27
- export declare class Crisp {
27
+ declare class Crisp {
28
28
  bucket: BucketServiceInterface;
29
29
  media: MediaServiceInterface;
30
30
  plugin: PluginServiceInterface;
@@ -46,6 +46,7 @@ export declare class Crisp {
46
46
  mode: RTM_MODES;
47
47
  };
48
48
  protected _useragent: string;
49
+ protected _customHeaders: Record<string, string>;
49
50
  protected _emitter: Emitter<Record<import("mitt").EventType, unknown>>;
50
51
  protected _socket: Socket | null;
51
52
  protected _loopback: Emitter<Record<string, unknown>> | null;
@@ -69,6 +70,10 @@ export declare class Crisp {
69
70
  * Sets the RTM channel mode (ie. WebSockets or Web Hooks)
70
71
  */
71
72
  setRtmMode(mode: "websockets" | "webhooks"): void;
73
+ /**
74
+ * Sets custom headers to be included in all API requests
75
+ */
76
+ setCustomHeaders(headers: Record<string, string>): void;
72
77
  /**
73
78
  * Sets the authentication tier
74
79
  */
@@ -176,4 +181,5 @@ export declare class Crisp {
176
181
  * EXPORTS
177
182
  ***************************************************************************/
178
183
  export * from "./resources";
184
+ export { Crisp };
179
185
  export default Crisp;
package/dist/crisp.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
9
  if (k2 === undefined) k2 = k;
@@ -45,7 +45,7 @@ const AVAILABLE_RTM_MODES = [
45
45
  "websockets",
46
46
  "webhooks"
47
47
  ];
48
- const VERSION = "10.0.17";
48
+ const VERSION = "10.1.0";
49
49
  // Base configuration
50
50
  const DEFAULT_REQUEST_TIMEOUT = 10000;
51
51
  const DEFAULT_SOCKET_TIMEOUT = 10000;
@@ -167,7 +167,7 @@ const services = {
167
167
  * CLASSES
168
168
  ***************************************************************************/
169
169
  /**
170
- *
170
+ * Crisp
171
171
  */
172
172
  class Crisp {
173
173
  /**
@@ -193,6 +193,7 @@ class Crisp {
193
193
  mode: DEFAULT_RTM_MODE
194
194
  };
195
195
  this._useragent = (DEFAULT_USERAGENT_PREFIX + VERSION);
196
+ this._customHeaders = {};
196
197
  this._emitter = (0, mitt_1.default)();
197
198
  this._socket = null;
198
199
  this._loopback = null;
@@ -237,6 +238,17 @@ class Crisp {
237
238
  AVAILABLE_RTM_MODES.join(", "));
238
239
  }
239
240
  }
241
+ /**
242
+ * Sets custom headers to be included in all API requests
243
+ */
244
+ setCustomHeaders(headers) {
245
+ if (typeof headers === "object" && headers !== null) {
246
+ this._customHeaders = headers;
247
+ }
248
+ else {
249
+ throw new Error("[Crisp] setCustomHeaders: parameter headers should be an object");
250
+ }
251
+ }
240
252
  /**
241
253
  * Sets the authentication tier
242
254
  */
@@ -658,10 +670,7 @@ class Crisp {
658
670
  let requestParameters = {
659
671
  responseType: "json",
660
672
  timeout: DEFAULT_REQUEST_TIMEOUT,
661
- headers: {
662
- "User-Agent": this._useragent,
663
- "X-Crisp-Tier": this.auth.tier
664
- },
673
+ headers: Object.assign({ "User-Agent": this._useragent, "X-Crisp-Tier": this.auth.tier }, this._customHeaders),
665
674
  throwHttpErrors: false
666
675
  };
667
676
  // Add authorization?
@@ -676,8 +685,20 @@ class Crisp {
676
685
  }
677
686
  // Add query?
678
687
  if (query) {
688
+ const params = new URLSearchParams();
689
+ Object.entries(query).forEach(([key, value]) => {
690
+ if (value === null || value === undefined) {
691
+ return;
692
+ }
693
+ if (typeof value === "object") {
694
+ params.append(key, JSON.stringify(value));
695
+ }
696
+ else {
697
+ params.append(key, String(value));
698
+ }
699
+ });
679
700
  // @ts-ignore
680
- requestParameters.searchParams = query;
701
+ requestParameters.searchParams = params;
681
702
  }
682
703
  // Proceed request
683
704
  got_1.default[method](resource, requestParameters)
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  /**************************************************************************
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -21,10 +21,14 @@ export type PluginConnectWebsitesSince = {
21
21
  };
22
22
  export type PluginConnectEndpoints = {
23
23
  socket?: PluginConnectEndpointsSocket;
24
+ rescue?: PluginConnectEndpointsRescue;
24
25
  };
25
26
  export type PluginConnectEndpointsSocket = {
26
27
  app?: string;
27
28
  };
29
+ export type PluginConnectEndpointsRescue = {
30
+ socket?: PluginConnectEndpointsSocket;
31
+ };
28
32
  /**************************************************************************
29
33
  * CLASSES
30
34
  ***************************************************************************/
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -396,6 +396,39 @@ export interface ConversationBrowsing {
396
396
  export interface ConversationCall {
397
397
  call_id?: string;
398
398
  }
399
+ export interface BaseConversationsListOptions {
400
+ per_page?: number;
401
+ include_empty?: 0 | 1;
402
+ filter_inbox_id?: string;
403
+ filter_unread?: 0 | 1;
404
+ filter_resolved?: 0 | 1;
405
+ filter_not_resolved?: 0 | 1;
406
+ filter_mention?: 0 | 1;
407
+ filter_assigned?: string;
408
+ filter_unassigned?: 0 | 1;
409
+ filter_date_start?: string;
410
+ filter_date_end?: string;
411
+ order_date_created?: 0 | 1;
412
+ order_date_updated?: 0 | 1;
413
+ order_date_waiting?: 0 | 1;
414
+ }
415
+ export interface StandardSearchOptions extends BaseConversationsListOptions {
416
+ search_type: "text" | "segment";
417
+ search_query: string;
418
+ search_operator?: never;
419
+ }
420
+ export interface FilterSearchOptions extends BaseConversationsListOptions {
421
+ search_type: "filter";
422
+ search_query: FilterSearchQuery[];
423
+ search_operator?: "and" | "or";
424
+ }
425
+ export interface FilterSearchQuery {
426
+ criterion: string;
427
+ query: string[];
428
+ model: string;
429
+ operator: string;
430
+ }
431
+ export type ConversationsListOptions = BaseConversationsListOptions | StandardSearchOptions | FilterSearchOptions;
399
432
  /**************************************************************************
400
433
  * CLASSES
401
434
  ***************************************************************************/
@@ -407,7 +440,7 @@ declare class WebsiteConversation extends BaseResource {
407
440
  /**
408
441
  * List Conversations
409
442
  */
410
- listConversations(websiteID: string, pageNumber?: number): Promise<Conversation[]>;
443
+ listConversations(websiteID: string, pageNumber?: number, options?: ConversationsListOptions): Promise<Conversation[]>;
411
444
  /**
412
445
  * List Suggested Conversation Segments
413
446
  */
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -25,8 +25,10 @@ class WebsiteConversation extends BaseResource_1.default {
25
25
  /**
26
26
  * List Conversations
27
27
  */
28
- listConversations(websiteID, pageNumber = 1) {
29
- return this.crisp.get(this.crisp.prepareRestUrl(["website", websiteID, "conversations", String(pageNumber)]));
28
+ listConversations(websiteID, pageNumber = 1, options) {
29
+ return this.crisp.get(this.crisp.prepareRestUrl([
30
+ "website", websiteID, "conversations", String(pageNumber)
31
+ ]), options);
30
32
  }
31
33
  ;
32
34
  /**
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2023, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
9
  if (k2 === undefined) k2 = k;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- * node-crisp-api
3
+ * This file is part of node-crisp-api
4
4
  *
5
- * Copyright 2022, Crisp IM SAS
6
- * Author: Baptiste Jamin <baptiste@crisp.chat>
5
+ * Copyright (c) 2025 Crisp IM SAS
6
+ * All rights belong to Crisp IM SAS
7
7
  */
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
package/lib/crisp.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -194,9 +194,9 @@ interface CrispAuth {
194
194
  ***************************************************************************/
195
195
 
196
196
  /**
197
- *
197
+ * Crisp
198
198
  */
199
- export class Crisp {
199
+ class Crisp {
200
200
  public bucket: BucketServiceInterface = (
201
201
  new Bucket() as unknown as BucketServiceInterface
202
202
  );
@@ -240,6 +240,8 @@ export class Crisp {
240
240
 
241
241
  protected _useragent = (DEFAULT_USERAGENT_PREFIX + VERSION);
242
242
 
243
+ protected _customHeaders: Record<string, string> = {};
244
+
243
245
  protected _emitter = mitt();
244
246
 
245
247
  protected _socket: Socket | null = null;
@@ -297,6 +299,17 @@ export class Crisp {
297
299
  }
298
300
  }
299
301
 
302
+ /**
303
+ * Sets custom headers to be included in all API requests
304
+ */
305
+ setCustomHeaders(headers: Record<string, string>) {
306
+ if (typeof headers === "object" && headers !== null) {
307
+ this._customHeaders = headers;
308
+ } else {
309
+ throw new Error("[Crisp] setCustomHeaders: parameter headers should be an object");
310
+ }
311
+ }
312
+
300
313
  /**
301
314
  * Sets the authentication tier
302
315
  */
@@ -866,7 +879,8 @@ export class Crisp {
866
879
 
867
880
  headers: {
868
881
  "User-Agent": this._useragent,
869
- "X-Crisp-Tier": this.auth.tier
882
+ "X-Crisp-Tier": this.auth.tier,
883
+ ...this._customHeaders
870
884
  },
871
885
 
872
886
  throwHttpErrors: false
@@ -886,8 +900,22 @@ export class Crisp {
886
900
 
887
901
  // Add query?
888
902
  if (query) {
903
+ const params = new URLSearchParams();
904
+
905
+ Object.entries(query).forEach(([ key, value ]) => {
906
+ if (value === null || value === undefined) {
907
+ return;
908
+ }
909
+
910
+ if (typeof value === "object") {
911
+ params.append(key, JSON.stringify(value));
912
+ } else {
913
+ params.append(key, String(value));
914
+ }
915
+ });
916
+
889
917
  // @ts-ignore
890
- requestParameters.searchParams = query;
918
+ requestParameters.searchParams = params;
891
919
  }
892
920
 
893
921
  // Proceed request
@@ -1003,4 +1031,5 @@ export class Crisp {
1003
1031
  ***************************************************************************/
1004
1032
 
1005
1033
  export * from "@/resources";
1034
+ export { Crisp };
1006
1035
  export default Crisp;
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -35,12 +35,17 @@ export type PluginConnectWebsitesSince = {
35
35
 
36
36
  export type PluginConnectEndpoints = {
37
37
  socket?: PluginConnectEndpointsSocket;
38
+ rescue?: PluginConnectEndpointsRescue;
38
39
  }
39
40
 
40
41
  export type PluginConnectEndpointsSocket = {
41
42
  app?: string;
42
43
  }
43
44
 
45
+ export type PluginConnectEndpointsRescue = {
46
+ socket?: PluginConnectEndpointsSocket;
47
+ }
48
+
44
49
  /**************************************************************************
45
50
  * CLASSES
46
51
  ***************************************************************************/
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -511,6 +511,47 @@ export interface ConversationCall {
511
511
  call_id?: string;
512
512
  }
513
513
 
514
+ export interface BaseConversationsListOptions {
515
+ per_page?: number;
516
+ include_empty?: 0 | 1;
517
+ filter_inbox_id?: string;
518
+ filter_unread?: 0 | 1;
519
+ filter_resolved?: 0 | 1;
520
+ filter_not_resolved?: 0 | 1;
521
+ filter_mention?: 0 | 1;
522
+ filter_assigned?: string;
523
+ filter_unassigned?: 0 | 1;
524
+ filter_date_start?: string;
525
+ filter_date_end?: string;
526
+ order_date_created?: 0 | 1;
527
+ order_date_updated?: 0 | 1;
528
+ order_date_waiting?: 0 | 1;
529
+ }
530
+
531
+ export interface StandardSearchOptions extends BaseConversationsListOptions {
532
+ search_type: "text" | "segment";
533
+ search_query: string;
534
+ search_operator?: never;
535
+ }
536
+
537
+ export interface FilterSearchOptions extends BaseConversationsListOptions {
538
+ search_type: "filter";
539
+ search_query: FilterSearchQuery[];
540
+ search_operator?: "and" | "or";
541
+ }
542
+
543
+ export interface FilterSearchQuery {
544
+ criterion: string;
545
+ query: string[];
546
+ model: string;
547
+ operator: string;
548
+ }
549
+
550
+ export type ConversationsListOptions =
551
+ | BaseConversationsListOptions
552
+ | StandardSearchOptions
553
+ | FilterSearchOptions;
554
+
514
555
  /**************************************************************************
515
556
  * CLASSES
516
557
  ***************************************************************************/
@@ -524,10 +565,14 @@ class WebsiteConversation extends BaseResource {
524
565
  * List Conversations
525
566
  */
526
567
  listConversations(
527
- websiteID: string, pageNumber: number = 1
568
+ websiteID: string, pageNumber: number = 1, options?: ConversationsListOptions
528
569
  ): Promise<Conversation[]> {
529
570
  return this.crisp.get(
530
- this.crisp.prepareRestUrl(["website", websiteID, "conversations", String(pageNumber)])
571
+ this.crisp.prepareRestUrl([
572
+ "website", websiteID, "conversations", String(pageNumber)
573
+ ]),
574
+
575
+ options
531
576
  );
532
577
  };
533
578
 
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2023, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
@@ -1,8 +1,8 @@
1
1
  /*
2
- * node-crisp-api
2
+ * This file is part of node-crisp-api
3
3
  *
4
- * Copyright 2022, Crisp IM SAS
5
- * Author: Baptiste Jamin <baptiste@crisp.chat>
4
+ * Copyright (c) 2025 Crisp IM SAS
5
+ * All rights belong to Crisp IM SAS
6
6
  */
7
7
 
8
8
  /**************************************************************************
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "crisp-api",
3
3
  "description": "Crisp API wrapper for Node - official, maintained by Crisp",
4
- "version": "10.0.17",
4
+ "version": "10.1.0",
5
5
  "homepage": "https://github.com/crisp-im/node-crisp-api",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -53,9 +53,9 @@
53
53
  "devDependencies": {
54
54
  "@typescript-eslint/eslint-plugin": "8.39.1",
55
55
  "tsc-alias": "1.8.16",
56
- "typescript": "5.9.2",
56
+ "typescript": "5.9.3",
57
57
  "eslint": "9.29.0",
58
- "eslint-plugin-crisp": "1.1.13",
58
+ "eslint-plugin-crisp": "1.2.12",
59
59
  "eslint-plugin-jsdoc": "50.8.0",
60
60
  "globals": "15.15.0"
61
61
  },