@sipgate/integration-bridge 0.22.7 → 0.22.9

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 (78) hide show
  1. package/README.md +28 -24
  2. package/dist/cache/index.d.ts +1 -1
  3. package/dist/cache/storage/index.d.ts +2 -2
  4. package/dist/cache/storage/memory-storage-adapter.d.ts +1 -1
  5. package/dist/cache/storage/redis-storage-adapter.d.ts +1 -1
  6. package/dist/cache/storage/redis-storage-adapter.js +10 -10
  7. package/dist/cache/storage-cache.d.ts +5 -5
  8. package/dist/cache/storage-cache.js +6 -6
  9. package/dist/index.d.ts +7 -7
  10. package/dist/index.js +27 -27
  11. package/dist/index.test.js +2 -2
  12. package/dist/middlewares/error-handler.middleware.d.ts +2 -2
  13. package/dist/middlewares/extract-header.middleware.d.ts +2 -2
  14. package/dist/middlewares/extract-header.middleware.js +5 -5
  15. package/dist/middlewares/index.d.ts +2 -2
  16. package/dist/models/adapter.model.d.ts +3 -3
  17. package/dist/models/api-contact.model.d.ts +1 -1
  18. package/dist/models/bridge-request.model.d.ts +3 -3
  19. package/dist/models/call-event.model.d.ts +1 -1
  20. package/dist/models/contact-cache.model.d.ts +2 -2
  21. package/dist/models/contact.model.d.ts +1 -1
  22. package/dist/models/controller.model.d.ts +3 -3
  23. package/dist/models/controller.model.js +156 -156
  24. package/dist/models/controller.model.test.js +125 -125
  25. package/dist/models/custom-router.model.d.ts +1 -1
  26. package/dist/models/custom-routes.model.d.ts +2 -2
  27. package/dist/models/index.d.ts +16 -16
  28. package/dist/models/pubsub-client.model.d.ts +1 -1
  29. package/dist/models/pubsub-client.model.js +2 -2
  30. package/dist/models/pubsub-contacts-message.model.d.ts +1 -1
  31. package/dist/models/server-error.model.js +1 -1
  32. package/dist/models/token-cache.model.d.ts +1 -1
  33. package/dist/schemas/calendar-events.js +10 -10
  34. package/dist/schemas/contacts.js +26 -26
  35. package/dist/schemas/index.d.ts +2 -2
  36. package/dist/util/anonymize-key.js +2 -2
  37. package/dist/util/anonymize-key.test.js +8 -8
  38. package/dist/util/call-comment.d.ts +1 -1
  39. package/dist/util/call-comment.js +12 -12
  40. package/dist/util/call-event.test.js +20 -20
  41. package/dist/util/call-event.util.d.ts +1 -1
  42. package/dist/util/callEventHelper.d.ts +1 -1
  43. package/dist/util/callEventHelper.js +6 -6
  44. package/dist/util/env.js +11 -11
  45. package/dist/util/error.d.ts +2 -2
  46. package/dist/util/error.js +3 -3
  47. package/dist/util/gdpr/gdprSlackNotification.d.ts +2 -2
  48. package/dist/util/gdpr/gdprSlackNotification.js +6 -6
  49. package/dist/util/gdpr/index.d.ts +2 -2
  50. package/dist/util/get-contact-cache.d.ts +1 -1
  51. package/dist/util/get-contact-cache.js +4 -4
  52. package/dist/util/get-contact-cache.js.map +1 -1
  53. package/dist/util/http/index.d.ts +6 -6
  54. package/dist/util/http/pagination.d.ts +1 -1
  55. package/dist/util/http/pagination.js +1 -1
  56. package/dist/util/http/rate-limited-axios.d.ts +2 -2
  57. package/dist/util/http/rate-limited-axios.js +2 -2
  58. package/dist/util/http/url.js +2 -2
  59. package/dist/util/index.d.ts +20 -20
  60. package/dist/util/integration-entity.d.ts +1 -1
  61. package/dist/util/integration-entity.js +1 -1
  62. package/dist/util/lang/index.d.ts +1 -1
  63. package/dist/util/logger.util.js +3 -3
  64. package/dist/util/oauth.d.ts +2 -2
  65. package/dist/util/oauth.js +7 -7
  66. package/dist/util/phone-number-utils.d.ts +2 -2
  67. package/dist/util/phone-number-utils.js +5 -5
  68. package/dist/util/phone-number-utils.test.js +49 -49
  69. package/dist/util/security/index.d.ts +2 -2
  70. package/dist/util/security/nonce.d.ts +1 -1
  71. package/dist/util/security/nonce.js +2 -2
  72. package/dist/util/size-of.js +4 -4
  73. package/dist/util/token-util.d.ts +3 -3
  74. package/dist/util/token-util.js +11 -8
  75. package/dist/util/token-util.js.map +1 -1
  76. package/dist/util/validate.d.ts +1 -1
  77. package/dist/util/validate.js +2 -2
  78. package/package.json +1 -1
@@ -16,65 +16,65 @@ const storage_1 = require("../cache/storage");
16
16
  const contact_model_1 = require("./contact.model");
17
17
  const contactsMock = [
18
18
  {
19
- id: "abc123",
20
- name: "Walter Geoffrey",
19
+ id: 'abc123',
20
+ name: 'Walter Geoffrey',
21
21
  firstName: null,
22
22
  lastName: null,
23
- email: "walter@example.com",
24
- organization: "Rocket Science Inc.",
25
- contactUrl: "http://myapp.com/contacts/abc123",
26
- avatarUrl: "http://myapp.com/avatar/abc123.png",
23
+ email: 'walter@example.com',
24
+ organization: 'Rocket Science Inc.',
25
+ contactUrl: 'http://myapp.com/contacts/abc123',
26
+ avatarUrl: 'http://myapp.com/avatar/abc123.png',
27
27
  phoneNumbers: [
28
28
  {
29
29
  label: contact_model_1.PhoneNumberLabel.MOBILE,
30
30
  type: contact_model_1.PhoneNumberType.STANDARD,
31
- phoneNumber: "+4915791234567",
32
- e164: "+4915791234567",
33
- localized: "01579 1234567",
31
+ phoneNumber: '+4915791234567',
32
+ e164: '+4915791234567',
33
+ localized: '01579 1234567',
34
34
  },
35
35
  ],
36
36
  },
37
37
  ];
38
38
  const contactsReadonlyMock = [
39
39
  {
40
- id: "abc123",
41
- name: "Walter Geoffrey",
40
+ id: 'abc123',
41
+ name: 'Walter Geoffrey',
42
42
  firstName: null,
43
43
  lastName: null,
44
- email: "walter@example.com",
45
- organization: "Rocket Science Inc.",
46
- contactUrl: "http://myapp.com/contacts/abc123",
47
- avatarUrl: "http://myapp.com/avatar/abc123.png",
44
+ email: 'walter@example.com',
45
+ organization: 'Rocket Science Inc.',
46
+ contactUrl: 'http://myapp.com/contacts/abc123',
47
+ avatarUrl: 'http://myapp.com/avatar/abc123.png',
48
48
  phoneNumbers: [
49
49
  {
50
50
  label: contact_model_1.PhoneNumberLabel.MOBILE,
51
51
  type: contact_model_1.PhoneNumberType.STANDARD,
52
- phoneNumber: "+4915791234567",
53
- e164: "+4915791234567",
54
- localized: "01579 1234567",
52
+ phoneNumber: '+4915791234567',
53
+ e164: '+4915791234567',
54
+ localized: '01579 1234567',
55
55
  },
56
56
  ],
57
57
  readonly: true,
58
58
  },
59
59
  ];
60
60
  const calendarEventMock = {
61
- id: "abc123",
62
- title: "My Event",
63
- description: "Awesome event",
64
- eventUrl: "https://wwww.google.com",
61
+ id: 'abc123',
62
+ title: 'My Event',
63
+ description: 'Awesome event',
64
+ eventUrl: 'https://wwww.google.com',
65
65
  start: 123456789,
66
66
  end: 123456789,
67
67
  };
68
68
  const calendarWithMissingField = {
69
- title: "My Event",
70
- description: "Awesome event",
71
- eventUrl: "https://wwww.google.com",
69
+ title: 'My Event',
70
+ description: 'Awesome event',
71
+ eventUrl: 'https://wwww.google.com',
72
72
  start: 123456789,
73
73
  end: 123456789,
74
74
  };
75
75
  const contactsMinimumMock = [
76
76
  {
77
- id: "123",
77
+ id: '123',
78
78
  email: null,
79
79
  name: null,
80
80
  firstName: null,
@@ -86,16 +86,16 @@ const contactsMinimumMock = [
86
86
  {
87
87
  label: contact_model_1.PhoneNumberLabel.WORK,
88
88
  type: contact_model_1.PhoneNumberType.STANDARD,
89
- phoneNumber: "+4915791234567",
90
- e164: "+4915791234567",
91
- localized: "01579 1234567",
89
+ phoneNumber: '+4915791234567',
90
+ e164: '+4915791234567',
91
+ localized: '01579 1234567',
92
92
  },
93
93
  ],
94
94
  },
95
95
  ];
96
96
  const contactsWithMissingField = [
97
97
  {
98
- id: "123",
98
+ id: '123',
99
99
  name: null,
100
100
  firstName: null,
101
101
  lastName: null,
@@ -105,34 +105,34 @@ const contactsWithMissingField = [
105
105
  phoneNumbers: [
106
106
  {
107
107
  label: contact_model_1.PhoneNumberLabel.WORK,
108
- phoneNumber: "+4915799912345",
108
+ phoneNumber: '+4915799912345',
109
109
  },
110
110
  ],
111
111
  },
112
112
  ];
113
- const ERROR_MESSAGE = "Error!";
113
+ const ERROR_MESSAGE = 'Error!';
114
114
  console.log = jest.fn();
115
115
  jest.useFakeTimers();
116
- describe("getContacts", () => {
116
+ describe('getContacts', () => {
117
117
  let request;
118
118
  let response;
119
119
  let next;
120
120
  beforeAll(() => {
121
- process.env.OAUTH2_REDIRECT_URL = "http://example.com";
122
- process.env.OAUTH2_IDENTIFIER = "TEST";
121
+ process.env.OAUTH2_REDIRECT_URL = 'http://example.com';
122
+ process.env.OAUTH2_IDENTIFIER = 'TEST';
123
123
  });
124
124
  beforeEach(() => {
125
125
  request = (0, node_mocks_http_1.createRequest)({
126
126
  providerConfig: {
127
- apiKey: "a1b2c3",
128
- apiUrl: "http://example.com",
129
- locale: "de_DE",
127
+ apiKey: 'a1b2c3',
128
+ apiUrl: 'http://example.com',
129
+ locale: 'de_DE',
130
130
  },
131
131
  });
132
132
  response = (0, node_mocks_http_1.createResponse)();
133
133
  next = jest.fn();
134
134
  });
135
- it("should handle contacts", () => __awaiter(void 0, void 0, void 0, function* () {
135
+ it('should handle contacts', () => __awaiter(void 0, void 0, void 0, function* () {
136
136
  const controller = new _1.Controller({
137
137
  getContacts: () => Promise.resolve(contactsMock),
138
138
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -141,7 +141,7 @@ describe("getContacts", () => {
141
141
  expect(next).not.toBeCalled();
142
142
  expect(data).toEqual(contactsMock);
143
143
  }));
144
- it("should handle readonly contacts", () => __awaiter(void 0, void 0, void 0, function* () {
144
+ it('should handle readonly contacts', () => __awaiter(void 0, void 0, void 0, function* () {
145
145
  const controller = new _1.Controller({
146
146
  getContacts: () => Promise.resolve(contactsReadonlyMock),
147
147
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -150,7 +150,7 @@ describe("getContacts", () => {
150
150
  expect(next).not.toBeCalled();
151
151
  expect(data).toEqual(contactsReadonlyMock);
152
152
  }));
153
- it("should handle contacts with minimum fields", () => __awaiter(void 0, void 0, void 0, function* () {
153
+ it('should handle contacts with minimum fields', () => __awaiter(void 0, void 0, void 0, function* () {
154
154
  const controller = new _1.Controller({
155
155
  getContacts: () => Promise.resolve(contactsMinimumMock),
156
156
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -159,7 +159,7 @@ describe("getContacts", () => {
159
159
  expect(next).not.toBeCalled();
160
160
  expect(data).toEqual(contactsMinimumMock);
161
161
  }));
162
- it("should handle invalid contacts with missing fields", () => __awaiter(void 0, void 0, void 0, function* () {
162
+ it('should handle invalid contacts with missing fields', () => __awaiter(void 0, void 0, void 0, function* () {
163
163
  console.error = jest.fn();
164
164
  const contactsBrokenMock = [...contactsWithMissingField];
165
165
  const controller = new _1.Controller({
@@ -168,7 +168,7 @@ describe("getContacts", () => {
168
168
  yield controller.getContacts(request, response, next);
169
169
  expect(next).toBeCalled();
170
170
  }));
171
- it("should handle an error when retrieving contacts", () => __awaiter(void 0, void 0, void 0, function* () {
171
+ it('should handle an error when retrieving contacts', () => __awaiter(void 0, void 0, void 0, function* () {
172
172
  console.error = jest.fn();
173
173
  const controller = new _1.Controller({
174
174
  getContacts: () => Promise.reject(ERROR_MESSAGE),
@@ -177,22 +177,22 @@ describe("getContacts", () => {
177
177
  expect(next).toBeCalledWith(ERROR_MESSAGE);
178
178
  }));
179
179
  });
180
- describe("getCalendarEvents", () => {
180
+ describe('getCalendarEvents', () => {
181
181
  let request;
182
182
  let response;
183
183
  let next;
184
184
  beforeEach(() => {
185
185
  request = (0, node_mocks_http_1.createRequest)({
186
186
  providerConfig: {
187
- apiKey: "a1b2c3",
188
- apiUrl: "http://example.com",
189
- locale: "de_DE",
187
+ apiKey: 'a1b2c3',
188
+ apiUrl: 'http://example.com',
189
+ locale: 'de_DE',
190
190
  },
191
191
  });
192
192
  response = (0, node_mocks_http_1.createResponse)();
193
193
  next = jest.fn();
194
194
  });
195
- it("should handle calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
195
+ it('should handle calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
196
196
  const controller = new _1.Controller({
197
197
  getCalendarEvents: () => Promise.resolve([calendarEventMock]),
198
198
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -201,7 +201,7 @@ describe("getCalendarEvents", () => {
201
201
  expect(next).not.toBeCalled();
202
202
  expect(data).toEqual([calendarEventMock]);
203
203
  }));
204
- it("should handle invalid calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
204
+ it('should handle invalid calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
205
205
  console.error = jest.fn();
206
206
  const calendarEventsBrokenMock = [
207
207
  Object.assign({}, calendarWithMissingField),
@@ -212,7 +212,7 @@ describe("getCalendarEvents", () => {
212
212
  yield controller.getCalendarEvents(request, response, next);
213
213
  expect(next).toBeCalled();
214
214
  }));
215
- it("should handle an error when retrieving calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
215
+ it('should handle an error when retrieving calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
216
216
  console.error = jest.fn();
217
217
  const controller = new _1.Controller({
218
218
  getCalendarEvents: () => Promise.reject(ERROR_MESSAGE),
@@ -221,22 +221,22 @@ describe("getCalendarEvents", () => {
221
221
  expect(next).toBeCalledWith(ERROR_MESSAGE);
222
222
  }));
223
223
  });
224
- describe("createCalendarEvent", () => {
224
+ describe('createCalendarEvent', () => {
225
225
  let request;
226
226
  let response;
227
227
  let next;
228
228
  beforeEach(() => {
229
229
  request = (0, node_mocks_http_1.createRequest)({
230
230
  providerConfig: {
231
- apiKey: "a1b2c3",
232
- apiUrl: "http://example.com",
233
- locale: "de_DE",
231
+ apiKey: 'a1b2c3',
232
+ apiUrl: 'http://example.com',
233
+ locale: 'de_DE',
234
234
  },
235
235
  });
236
236
  response = (0, node_mocks_http_1.createResponse)();
237
237
  next = jest.fn();
238
238
  });
239
- it("should create calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
239
+ it('should create calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
240
240
  const controller = new _1.Controller({
241
241
  createCalendarEvent: () => Promise.resolve(calendarEventMock),
242
242
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -245,7 +245,7 @@ describe("createCalendarEvent", () => {
245
245
  expect(next).not.toBeCalled();
246
246
  expect(data).toEqual(calendarEventMock);
247
247
  }));
248
- it("should handle invalid calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
248
+ it('should handle invalid calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
249
249
  console.error = jest.fn();
250
250
  const calendarEventBrokenMock = Object.assign({}, calendarWithMissingField);
251
251
  const controller = new _1.Controller({
@@ -254,7 +254,7 @@ describe("createCalendarEvent", () => {
254
254
  yield controller.createCalendarEvent(request, response, next);
255
255
  expect(next).toBeCalled();
256
256
  }));
257
- it("should handle an error when creating calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
257
+ it('should handle an error when creating calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
258
258
  console.error = jest.fn();
259
259
  const controller = new _1.Controller({
260
260
  createCalendarEvent: () => Promise.reject(ERROR_MESSAGE),
@@ -263,22 +263,22 @@ describe("createCalendarEvent", () => {
263
263
  expect(next).toBeCalledWith(ERROR_MESSAGE);
264
264
  }));
265
265
  });
266
- describe("updateCalendarEvent", () => {
266
+ describe('updateCalendarEvent', () => {
267
267
  let request;
268
268
  let response;
269
269
  let next;
270
270
  beforeEach(() => {
271
271
  request = (0, node_mocks_http_1.createRequest)({
272
272
  providerConfig: {
273
- apiKey: "a1b2c3",
274
- apiUrl: "http://example.com",
275
- locale: "de_DE",
273
+ apiKey: 'a1b2c3',
274
+ apiUrl: 'http://example.com',
275
+ locale: 'de_DE',
276
276
  },
277
277
  });
278
278
  response = (0, node_mocks_http_1.createResponse)();
279
279
  next = jest.fn();
280
280
  });
281
- it("should update calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
281
+ it('should update calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
282
282
  const controller = new _1.Controller({
283
283
  updateCalendarEvent: () => Promise.resolve(calendarEventMock),
284
284
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -287,7 +287,7 @@ describe("updateCalendarEvent", () => {
287
287
  expect(next).not.toBeCalled();
288
288
  expect(data).toEqual(calendarEventMock);
289
289
  }));
290
- it("should handle invalid calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
290
+ it('should handle invalid calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
291
291
  console.error = jest.fn();
292
292
  const calendarEventBrokenMock = Object.assign({}, calendarWithMissingField);
293
293
  const controller = new _1.Controller({
@@ -296,7 +296,7 @@ describe("updateCalendarEvent", () => {
296
296
  yield controller.updateCalendarEvent(request, response, next);
297
297
  expect(next).toBeCalled();
298
298
  }));
299
- it("should handle an error when updating calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
299
+ it('should handle an error when updating calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
300
300
  console.error = jest.fn();
301
301
  const controller = new _1.Controller({
302
302
  updateCalendarEvent: () => Promise.reject(ERROR_MESSAGE),
@@ -305,22 +305,22 @@ describe("updateCalendarEvent", () => {
305
305
  expect(next).toBeCalledWith(ERROR_MESSAGE);
306
306
  }));
307
307
  });
308
- describe("deleteCalendarEvent", () => {
308
+ describe('deleteCalendarEvent', () => {
309
309
  let request;
310
310
  let response;
311
311
  let next;
312
312
  beforeEach(() => {
313
313
  request = (0, node_mocks_http_1.createRequest)({
314
314
  providerConfig: {
315
- apiKey: "a1b2c3",
316
- apiUrl: "http://example.com",
317
- locale: "de_DE",
315
+ apiKey: 'a1b2c3',
316
+ apiUrl: 'http://example.com',
317
+ locale: 'de_DE',
318
318
  },
319
319
  });
320
320
  response = (0, node_mocks_http_1.createResponse)();
321
321
  next = jest.fn();
322
322
  });
323
- it("should delete calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
323
+ it('should delete calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
324
324
  const controller = new _1.Controller({
325
325
  deleteCalendarEvent: () => Promise.resolve(),
326
326
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -328,7 +328,7 @@ describe("deleteCalendarEvent", () => {
328
328
  expect(next).not.toBeCalled();
329
329
  expect(response._getStatusCode()).toEqual(200);
330
330
  }));
331
- it("should handle an error when deleting calendar events", () => __awaiter(void 0, void 0, void 0, function* () {
331
+ it('should handle an error when deleting calendar events', () => __awaiter(void 0, void 0, void 0, function* () {
332
332
  console.error = jest.fn();
333
333
  const controller = new _1.Controller({
334
334
  deleteCalendarEvent: () => Promise.reject(ERROR_MESSAGE),
@@ -337,7 +337,7 @@ describe("deleteCalendarEvent", () => {
337
337
  expect(next).toBeCalledWith(ERROR_MESSAGE);
338
338
  }));
339
339
  });
340
- describe("getOAuth2RedirectUrl", () => {
340
+ describe('getOAuth2RedirectUrl', () => {
341
341
  let request;
342
342
  let response;
343
343
  let next;
@@ -346,11 +346,11 @@ describe("getOAuth2RedirectUrl", () => {
346
346
  response = (0, node_mocks_http_1.createResponse)();
347
347
  next = jest.fn();
348
348
  });
349
- it("should handle OAuth2 callback", () => __awaiter(void 0, void 0, void 0, function* () {
349
+ it('should handle OAuth2 callback', () => __awaiter(void 0, void 0, void 0, function* () {
350
350
  const mockHandleOAuth2Callback = jest.fn(() => __awaiter(void 0, void 0, void 0, function* () {
351
351
  return Promise.resolve({
352
- apiKey: "key",
353
- apiUrl: "url",
352
+ apiKey: 'key',
353
+ apiUrl: 'url',
354
354
  });
355
355
  }));
356
356
  const controller = new _1.Controller({
@@ -360,13 +360,13 @@ describe("getOAuth2RedirectUrl", () => {
360
360
  expect(mockHandleOAuth2Callback).toBeCalled();
361
361
  expect(next).not.toBeCalled();
362
362
  }));
363
- it("should handle a custom redirect url", () => __awaiter(void 0, void 0, void 0, function* () {
364
- const mockRedirectUrl = "http://example.com?name=TEST&key=key&url=url";
363
+ it('should handle a custom redirect url', () => __awaiter(void 0, void 0, void 0, function* () {
364
+ const mockRedirectUrl = 'http://example.com?name=TEST&key=key&url=url';
365
365
  const mockRedirect = jest.fn();
366
366
  const mockHandleOAuth2Callback = jest.fn((req) => __awaiter(void 0, void 0, void 0, function* () {
367
367
  return Promise.resolve({
368
- apiKey: "key",
369
- apiUrl: "url",
368
+ apiKey: 'key',
369
+ apiUrl: 'url',
370
370
  });
371
371
  }));
372
372
  const controller = new _1.Controller({
@@ -384,7 +384,7 @@ describe("getOAuth2RedirectUrl", () => {
384
384
  expect(next).not.toBeCalled();
385
385
  }));
386
386
  });
387
- describe("getHealth", () => {
387
+ describe('getHealth', () => {
388
388
  let request;
389
389
  let response;
390
390
  let next;
@@ -393,7 +393,7 @@ describe("getHealth", () => {
393
393
  response = (0, node_mocks_http_1.createResponse)();
394
394
  next = jest.fn();
395
395
  });
396
- it("should implement a default function", () => __awaiter(void 0, void 0, void 0, function* () {
396
+ it('should implement a default function', () => __awaiter(void 0, void 0, void 0, function* () {
397
397
  const controller = new _1.Controller({
398
398
  getContacts: () => Promise.resolve(contactsMock),
399
399
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
@@ -401,7 +401,7 @@ describe("getHealth", () => {
401
401
  expect(next).not.toBeCalled();
402
402
  expect(response.statusCode).toBe(200);
403
403
  }));
404
- it("should accept a custom function", () => __awaiter(void 0, void 0, void 0, function* () {
404
+ it('should accept a custom function', () => __awaiter(void 0, void 0, void 0, function* () {
405
405
  const getHealthMock = jest.fn();
406
406
  const controller = new _1.Controller({
407
407
  getContacts: () => Promise.resolve(contactsMock),
@@ -412,17 +412,17 @@ describe("getHealth", () => {
412
412
  expect(next).not.toBeCalled();
413
413
  expect(response.statusCode).toBe(200);
414
414
  }));
415
- it("should handle an error", () => __awaiter(void 0, void 0, void 0, function* () {
415
+ it('should handle an error', () => __awaiter(void 0, void 0, void 0, function* () {
416
416
  console.error = jest.fn();
417
417
  const controller = new _1.Controller({
418
418
  getContacts: () => Promise.reject(),
419
- getHealth: () => Promise.reject(new Error("Error")),
419
+ getHealth: () => Promise.reject(new Error('Error')),
420
420
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
421
421
  yield controller.getHealth(request, response, next);
422
422
  expect(next).toBeCalled();
423
423
  }));
424
424
  });
425
- describe("handleCallEvent", () => {
425
+ describe('handleCallEvent', () => {
426
426
  let request;
427
427
  let response;
428
428
  let next;
@@ -430,96 +430,96 @@ describe("handleCallEvent", () => {
430
430
  response = (0, node_mocks_http_1.createResponse)();
431
431
  next = jest.fn();
432
432
  });
433
- it("should ignore a call event with a remote direct dial", () => __awaiter(void 0, void 0, void 0, function* () {
433
+ it('should ignore a call event with a remote direct dial', () => __awaiter(void 0, void 0, void 0, function* () {
434
434
  request = (0, node_mocks_http_1.createRequest)({
435
435
  providerConfig: {
436
- apiKey: "a1b2c3",
437
- apiUrl: "http://example.com",
438
- locale: "de_DE",
436
+ apiKey: 'a1b2c3',
437
+ apiUrl: 'http://example.com',
438
+ locale: 'de_DE',
439
439
  },
440
440
  body: {
441
441
  participants: [
442
442
  {
443
443
  type: _1.CallParticipantType.LOCAL,
444
- phoneNumber: "1234567890",
444
+ phoneNumber: '1234567890',
445
445
  },
446
446
  {
447
447
  type: _1.CallParticipantType.REMOTE,
448
- phoneNumber: "13",
448
+ phoneNumber: '13',
449
449
  },
450
450
  ],
451
- id: "",
451
+ id: '',
452
452
  startTime: 0,
453
453
  endTime: 0,
454
454
  direction: _1.CallDirection.IN,
455
- note: "",
455
+ note: '',
456
456
  state: _1.CallState.BUSY,
457
457
  },
458
458
  });
459
459
  const controller = new _1.Controller({
460
- handleCallEvent: (config, event) => Promise.resolve(""),
460
+ handleCallEvent: (config, event) => Promise.resolve(''),
461
461
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
462
462
  yield controller.handleCallEvent(request, response, next);
463
463
  const data = response._getData();
464
464
  expect(next).not.toBeCalled();
465
- expect(data).toEqual("Skipping call event");
465
+ expect(data).toEqual('Skipping call event');
466
466
  }));
467
- it("should handle a call event", () => __awaiter(void 0, void 0, void 0, function* () {
467
+ it('should handle a call event', () => __awaiter(void 0, void 0, void 0, function* () {
468
468
  request = (0, node_mocks_http_1.createRequest)({
469
469
  providerConfig: {
470
- apiKey: "a1b2c3",
471
- apiUrl: "http://example.com",
472
- locale: "de_DE",
470
+ apiKey: 'a1b2c3',
471
+ apiUrl: 'http://example.com',
472
+ locale: 'de_DE',
473
473
  },
474
474
  body: {
475
475
  participants: [
476
476
  {
477
477
  type: _1.CallParticipantType.LOCAL,
478
- phoneNumber: "1234567890",
478
+ phoneNumber: '1234567890',
479
479
  },
480
480
  {
481
481
  type: _1.CallParticipantType.REMOTE,
482
- phoneNumber: "0123456789",
482
+ phoneNumber: '0123456789',
483
483
  },
484
484
  ],
485
- id: "",
485
+ id: '',
486
486
  startTime: 0,
487
487
  endTime: 0,
488
488
  direction: _1.CallDirection.IN,
489
- note: "",
489
+ note: '',
490
490
  state: _1.CallState.BUSY,
491
491
  },
492
492
  });
493
493
  const controller = new _1.Controller({
494
- handleCallEvent: (config, event) => Promise.resolve("callRef"),
494
+ handleCallEvent: (config, event) => Promise.resolve('callRef'),
495
495
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
496
496
  yield controller.handleCallEvent(request, response, next);
497
497
  const data = response._getData();
498
498
  expect(next).not.toBeCalled();
499
- expect(data).toEqual("callRef");
499
+ expect(data).toEqual('callRef');
500
500
  }));
501
- it("should handle adapter not implementing the feature", () => __awaiter(void 0, void 0, void 0, function* () {
501
+ it('should handle adapter not implementing the feature', () => __awaiter(void 0, void 0, void 0, function* () {
502
502
  request = (0, node_mocks_http_1.createRequest)({
503
503
  providerConfig: {
504
- apiKey: "a1b2c3",
505
- apiUrl: "http://example.com",
506
- locale: "de_DE",
504
+ apiKey: 'a1b2c3',
505
+ apiUrl: 'http://example.com',
506
+ locale: 'de_DE',
507
507
  },
508
508
  });
509
509
  const controller = new _1.Controller({}, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
510
510
  yield controller.handleCallEvent(request, response, next);
511
511
  expect(next).toBeCalled();
512
512
  }));
513
- it("should handle config being missing", () => __awaiter(void 0, void 0, void 0, function* () {
513
+ it('should handle config being missing', () => __awaiter(void 0, void 0, void 0, function* () {
514
514
  request = (0, node_mocks_http_1.createRequest)({});
515
515
  const controller = new _1.Controller({
516
- handleCallEvent: (config, event) => Promise.resolve("callRef"),
516
+ handleCallEvent: (config, event) => Promise.resolve('callRef'),
517
517
  }, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
518
518
  yield controller.handleCallEvent(request, response, next);
519
519
  expect(next).toBeCalled();
520
520
  }));
521
521
  });
522
- describe("updateCallEvent", () => {
522
+ describe('updateCallEvent', () => {
523
523
  let request;
524
524
  let response;
525
525
  let next;
@@ -527,29 +527,29 @@ describe("updateCallEvent", () => {
527
527
  response = (0, node_mocks_http_1.createResponse)();
528
528
  next = jest.fn();
529
529
  });
530
- it("should handle a call event", () => __awaiter(void 0, void 0, void 0, function* () {
530
+ it('should handle a call event', () => __awaiter(void 0, void 0, void 0, function* () {
531
531
  request = (0, node_mocks_http_1.createRequest)({
532
532
  providerConfig: {
533
- apiKey: "a1b2c3",
534
- apiUrl: "http://example.com",
535
- locale: "de_DE",
533
+ apiKey: 'a1b2c3',
534
+ apiUrl: 'http://example.com',
535
+ locale: 'de_DE',
536
536
  },
537
537
  body: {
538
538
  participants: [
539
539
  {
540
540
  type: _1.CallParticipantType.LOCAL,
541
- phoneNumber: "1234567890",
541
+ phoneNumber: '1234567890',
542
542
  },
543
543
  {
544
544
  type: _1.CallParticipantType.REMOTE,
545
- phoneNumber: "0123456789",
545
+ phoneNumber: '0123456789',
546
546
  },
547
547
  ],
548
- id: "",
548
+ id: '',
549
549
  startTime: 0,
550
550
  endTime: 0,
551
551
  direction: _1.CallDirection.IN,
552
- note: "",
552
+ note: '',
553
553
  state: _1.CallState.BUSY,
554
554
  },
555
555
  });
@@ -559,21 +559,21 @@ describe("updateCallEvent", () => {
559
559
  yield controller.updateCallEvent(request, response, next);
560
560
  const data = response._getData();
561
561
  expect(next).not.toBeCalled();
562
- expect(data).toEqual("");
562
+ expect(data).toEqual('');
563
563
  }));
564
- it("should handle adapter not implementing the feature", () => __awaiter(void 0, void 0, void 0, function* () {
564
+ it('should handle adapter not implementing the feature', () => __awaiter(void 0, void 0, void 0, function* () {
565
565
  request = (0, node_mocks_http_1.createRequest)({
566
566
  providerConfig: {
567
- apiKey: "a1b2c3",
568
- apiUrl: "http://example.com",
569
- locale: "de_DE",
567
+ apiKey: 'a1b2c3',
568
+ apiUrl: 'http://example.com',
569
+ locale: 'de_DE',
570
570
  },
571
571
  });
572
572
  const controller = new _1.Controller({}, new cache_1.StorageCache(new storage_1.MemoryStorageAdapter()));
573
573
  yield controller.updateCallEvent(request, response, next);
574
574
  expect(next).toBeCalled();
575
575
  }));
576
- it("should handle config being missing", () => __awaiter(void 0, void 0, void 0, function* () {
576
+ it('should handle config being missing', () => __awaiter(void 0, void 0, void 0, function* () {
577
577
  request = (0, node_mocks_http_1.createRequest)({});
578
578
  const controller = new _1.Controller({
579
579
  updateCallEvent: (config, id, event) => Promise.resolve(),
@@ -1,4 +1,4 @@
1
- import { Router } from "express";
1
+ import { Router } from 'express';
2
2
  export type CustomRouter = {
3
3
  path: string;
4
4
  router: Router;
@@ -1,6 +1,6 @@
1
- import { RequestHandler } from "express";
1
+ import { RequestHandler } from 'express';
2
2
  export type CustomRoute = {
3
- requestType: "get" | "post" | "put" | "delete";
3
+ requestType: 'get' | 'post' | 'put' | 'delete';
4
4
  path: string;
5
5
  handler: RequestHandler;
6
6
  };