@sipgate/integration-bridge 0.22.6 → 0.22.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -24
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/storage/index.d.ts +2 -2
- package/dist/cache/storage/memory-storage-adapter.d.ts +1 -1
- package/dist/cache/storage/redis-storage-adapter.d.ts +1 -1
- package/dist/cache/storage/redis-storage-adapter.js +10 -10
- package/dist/cache/storage-cache.d.ts +5 -6
- package/dist/cache/storage-cache.js +8 -14
- package/dist/cache/storage-cache.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +27 -27
- package/dist/index.test.js +2 -2
- package/dist/middlewares/error-handler.middleware.d.ts +2 -2
- package/dist/middlewares/extract-header.middleware.d.ts +2 -2
- package/dist/middlewares/extract-header.middleware.js +5 -5
- package/dist/middlewares/index.d.ts +2 -2
- package/dist/models/adapter.model.d.ts +3 -3
- package/dist/models/api-contact.model.d.ts +1 -1
- package/dist/models/bridge-request.model.d.ts +3 -3
- package/dist/models/call-event.model.d.ts +1 -1
- package/dist/models/contact-cache.model.d.ts +2 -2
- package/dist/models/contact.model.d.ts +1 -1
- package/dist/models/controller.model.d.ts +3 -3
- package/dist/models/controller.model.js +156 -156
- package/dist/models/controller.model.test.js +125 -125
- package/dist/models/custom-router.model.d.ts +1 -1
- package/dist/models/custom-routes.model.d.ts +2 -2
- package/dist/models/index.d.ts +16 -16
- package/dist/models/pubsub-client.model.d.ts +1 -1
- package/dist/models/pubsub-client.model.js +2 -2
- package/dist/models/pubsub-contacts-message.model.d.ts +1 -1
- package/dist/models/server-error.model.js +1 -1
- package/dist/models/token-cache.model.d.ts +1 -1
- package/dist/schemas/calendar-events.js +10 -10
- package/dist/schemas/contacts.js +26 -26
- package/dist/schemas/index.d.ts +2 -2
- package/dist/util/anonymize-key.js +2 -2
- package/dist/util/anonymize-key.test.js +8 -8
- package/dist/util/call-comment.d.ts +1 -1
- package/dist/util/call-comment.js +12 -12
- package/dist/util/call-event.test.js +20 -20
- package/dist/util/call-event.util.d.ts +1 -1
- package/dist/util/callEventHelper.d.ts +1 -1
- package/dist/util/callEventHelper.js +6 -6
- package/dist/util/env.js +11 -11
- package/dist/util/error.d.ts +2 -2
- package/dist/util/error.js +3 -3
- package/dist/util/gdpr/gdprSlackNotification.d.ts +2 -2
- package/dist/util/gdpr/gdprSlackNotification.js +6 -6
- package/dist/util/gdpr/index.d.ts +2 -2
- package/dist/util/get-contact-cache.d.ts +1 -1
- package/dist/util/get-contact-cache.js +4 -4
- package/dist/util/get-contact-cache.js.map +1 -1
- package/dist/util/http/index.d.ts +6 -6
- package/dist/util/http/pagination.d.ts +1 -1
- package/dist/util/http/pagination.js +1 -1
- package/dist/util/http/rate-limited-axios.d.ts +2 -2
- package/dist/util/http/rate-limited-axios.js +2 -2
- package/dist/util/http/url.js +2 -2
- package/dist/util/index.d.ts +20 -20
- package/dist/util/integration-entity.d.ts +1 -1
- package/dist/util/integration-entity.js +1 -1
- package/dist/util/lang/index.d.ts +1 -1
- package/dist/util/logger.util.js +3 -3
- package/dist/util/oauth.d.ts +2 -2
- package/dist/util/oauth.js +7 -7
- package/dist/util/phone-number-utils.d.ts +2 -2
- package/dist/util/phone-number-utils.js +5 -5
- package/dist/util/phone-number-utils.test.js +49 -49
- package/dist/util/security/index.d.ts +2 -2
- package/dist/util/security/nonce.d.ts +1 -1
- package/dist/util/security/nonce.js +2 -2
- package/dist/util/size-of.js +4 -4
- package/dist/util/token-util.d.ts +3 -3
- package/dist/util/token-util.js +7 -7
- package/dist/util/validate.d.ts +1 -1
- package/dist/util/validate.js +2 -2
- package/package.json +1 -1
package/dist/models/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
1
|
+
export * from './adapter.model';
|
|
2
|
+
export * from './bridge-request.model';
|
|
3
|
+
export * from './calendar-event.model';
|
|
4
|
+
export * from './calendar-filter-options.model';
|
|
5
|
+
export * from './call-direction.enum';
|
|
6
|
+
export * from './call-event.model';
|
|
7
|
+
export * from './config.model';
|
|
8
|
+
export * from './contact-cache.model';
|
|
9
|
+
export * from './contact.model';
|
|
10
|
+
export * from './controller.model';
|
|
11
|
+
export * from './custom-router.model';
|
|
12
|
+
export * from './server-error.model';
|
|
13
|
+
export * from './user.model';
|
|
14
|
+
export * from './integration-error.model';
|
|
15
|
+
export * from './integration-entity.model';
|
|
16
|
+
export * from './token.model';
|
|
@@ -21,14 +21,14 @@ class PubSubClient {
|
|
|
21
21
|
publishMessage(message) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
if (!this.topicName) {
|
|
24
|
-
throw new Error(
|
|
24
|
+
throw new Error('No pubsub topic name provided.');
|
|
25
25
|
}
|
|
26
26
|
const json = JSON.stringify(message);
|
|
27
27
|
const dataBuffer = Buffer.from(json);
|
|
28
28
|
const topic = this.client.topic(this.topicName);
|
|
29
29
|
yield Promise.race([
|
|
30
30
|
topic.publishMessage({ data: dataBuffer }),
|
|
31
|
-
(0, timeout_1.timeout)(PUBLISH_TIMEOUT,
|
|
31
|
+
(0, timeout_1.timeout)(PUBLISH_TIMEOUT, 'Could not publish message in time. Did you forget to authenticate with GCP? (gcloud auth application-default login)'),
|
|
32
32
|
]);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ServerError = void 0;
|
|
4
4
|
class ServerError extends Error {
|
|
5
5
|
constructor(status, message) {
|
|
6
|
-
super(message ||
|
|
6
|
+
super(message || 'Unknown Error');
|
|
7
7
|
this.status = status || 500;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -2,32 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calendarEventsSchema = void 0;
|
|
4
4
|
exports.calendarEventsSchema = {
|
|
5
|
-
title:
|
|
6
|
-
type:
|
|
5
|
+
title: 'CalendarEvents',
|
|
6
|
+
type: 'array',
|
|
7
7
|
items: {
|
|
8
|
-
type:
|
|
8
|
+
type: 'object',
|
|
9
9
|
properties: {
|
|
10
10
|
fillDefaults: true,
|
|
11
11
|
id: {
|
|
12
|
-
type:
|
|
12
|
+
type: 'string',
|
|
13
13
|
},
|
|
14
14
|
title: {
|
|
15
|
-
type: [
|
|
15
|
+
type: ['string', 'null'],
|
|
16
16
|
},
|
|
17
17
|
description: {
|
|
18
|
-
type: [
|
|
18
|
+
type: ['string', 'null'],
|
|
19
19
|
},
|
|
20
20
|
eventUrl: {
|
|
21
|
-
type: [
|
|
21
|
+
type: ['string', 'null'],
|
|
22
22
|
},
|
|
23
23
|
start: {
|
|
24
|
-
type: [
|
|
24
|
+
type: ['number', 'null'],
|
|
25
25
|
},
|
|
26
26
|
end: {
|
|
27
|
-
type: [
|
|
27
|
+
type: ['number', 'null'],
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
|
-
required: [
|
|
30
|
+
required: ['id', 'title', 'description', 'eventUrl', 'start', 'end'],
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=calendar-events.js.map
|
package/dist/schemas/contacts.js
CHANGED
|
@@ -2,66 +2,66 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contactsSchema = void 0;
|
|
4
4
|
exports.contactsSchema = {
|
|
5
|
-
title:
|
|
6
|
-
type:
|
|
5
|
+
title: 'Contacts',
|
|
6
|
+
type: 'array',
|
|
7
7
|
items: {
|
|
8
|
-
type:
|
|
8
|
+
type: 'object',
|
|
9
9
|
properties: {
|
|
10
10
|
fillDefaults: true,
|
|
11
11
|
id: {
|
|
12
|
-
type:
|
|
12
|
+
type: 'string',
|
|
13
13
|
},
|
|
14
14
|
email: {
|
|
15
|
-
type: [
|
|
15
|
+
type: ['string', 'null'],
|
|
16
16
|
},
|
|
17
17
|
organization: {
|
|
18
|
-
type: [
|
|
18
|
+
type: ['string', 'null'],
|
|
19
19
|
},
|
|
20
20
|
contactUrl: {
|
|
21
|
-
type: [
|
|
21
|
+
type: ['string', 'null'],
|
|
22
22
|
},
|
|
23
23
|
avatarUrl: {
|
|
24
|
-
type: [
|
|
24
|
+
type: ['string', 'null'],
|
|
25
25
|
},
|
|
26
26
|
name: {
|
|
27
|
-
type: [
|
|
27
|
+
type: ['string', 'null'],
|
|
28
28
|
},
|
|
29
29
|
firstName: {
|
|
30
|
-
type: [
|
|
30
|
+
type: ['string', 'null'],
|
|
31
31
|
},
|
|
32
32
|
lastName: {
|
|
33
|
-
type: [
|
|
33
|
+
type: ['string', 'null'],
|
|
34
34
|
},
|
|
35
35
|
readonly: {
|
|
36
|
-
type: [
|
|
36
|
+
type: ['boolean'],
|
|
37
37
|
},
|
|
38
38
|
phoneNumbers: {
|
|
39
|
-
type:
|
|
39
|
+
type: 'array',
|
|
40
40
|
items: {
|
|
41
|
-
type:
|
|
41
|
+
type: 'object',
|
|
42
42
|
properties: {
|
|
43
43
|
fillDefaults: true,
|
|
44
44
|
label: {
|
|
45
|
-
type:
|
|
45
|
+
type: 'string',
|
|
46
46
|
},
|
|
47
47
|
phoneNumber: {
|
|
48
|
-
type:
|
|
48
|
+
type: 'string',
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
|
-
required: [
|
|
51
|
+
required: ['label', 'phoneNumber'],
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
55
|
required: [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
'id',
|
|
57
|
+
'name',
|
|
58
|
+
'firstName',
|
|
59
|
+
'lastName',
|
|
60
|
+
'email',
|
|
61
|
+
'organization',
|
|
62
|
+
'contactUrl',
|
|
63
|
+
'avatarUrl',
|
|
64
|
+
'phoneNumbers',
|
|
65
65
|
],
|
|
66
66
|
},
|
|
67
67
|
};
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './calendar-events';
|
|
2
|
+
export * from './contacts';
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.anonymizeKey = void 0;
|
|
4
4
|
const ANONYMIZED_KEY_LENGTH = 10;
|
|
5
5
|
function anonymizeKey(key) {
|
|
6
|
-
if (!key || typeof key !==
|
|
7
|
-
return
|
|
6
|
+
if (!key || typeof key !== 'string') {
|
|
7
|
+
return 'UNKNOWN';
|
|
8
8
|
}
|
|
9
9
|
return `***${key.slice(key.length - ANONYMIZED_KEY_LENGTH)}`;
|
|
10
10
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const anonymize_key_1 = require("./anonymize-key");
|
|
4
|
-
it(
|
|
5
|
-
const originalKey =
|
|
6
|
-
const anonymizedKey =
|
|
4
|
+
it('anonymizes valid key correctly', () => {
|
|
5
|
+
const originalKey = '1n2n3k23j43j23j4bdnc';
|
|
6
|
+
const anonymizedKey = '***3j23j4bdnc';
|
|
7
7
|
expect((0, anonymize_key_1.anonymizeKey)(originalKey)).toEqual(anonymizedKey);
|
|
8
8
|
});
|
|
9
|
-
it(
|
|
10
|
-
const originalKey =
|
|
11
|
-
const anonymizedKey =
|
|
9
|
+
it('anonymizes empty key correctly', () => {
|
|
10
|
+
const originalKey = '';
|
|
11
|
+
const anonymizedKey = 'UNKNOWN';
|
|
12
12
|
expect((0, anonymize_key_1.anonymizeKey)(originalKey)).toEqual(anonymizedKey);
|
|
13
13
|
});
|
|
14
|
-
it(
|
|
14
|
+
it('anonymizes not-string key correctly', () => {
|
|
15
15
|
const originalKey = {};
|
|
16
|
-
const anonymizedKey =
|
|
16
|
+
const anonymizedKey = 'UNKNOWN';
|
|
17
17
|
expect((0, anonymize_key_1.anonymizeKey)(originalKey)).toEqual(anonymizedKey);
|
|
18
18
|
});
|
|
19
19
|
//# sourceMappingURL=anonymize-key.test.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallDirection, CallState } from
|
|
1
|
+
import { CallDirection, CallState } from '../models';
|
|
2
2
|
export declare function getCommentSubject(state: CallState, direction: CallDirection, locale: string, htmlOpen?: string, htmlClose?: string): string;
|
|
3
3
|
export declare function getProductName(): string;
|
|
4
4
|
export declare function getCommentHeader(locale: string): string;
|
|
@@ -7,16 +7,16 @@ exports.getCallDuration = exports.getCommentContent = exports.getCommentHeader =
|
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
8
|
const models_1 = require("../models");
|
|
9
9
|
const logger_util_1 = require("./logger.util");
|
|
10
|
-
function getCommentSubject(state, direction, locale, htmlOpen =
|
|
11
|
-
const isGerman = locale.startsWith(
|
|
10
|
+
function getCommentSubject(state, direction, locale, htmlOpen = '', htmlClose = '') {
|
|
11
|
+
const isGerman = locale.startsWith('de');
|
|
12
12
|
const isIncoming = direction == models_1.CallDirection.IN;
|
|
13
13
|
const directionString = isGerman
|
|
14
14
|
? isIncoming
|
|
15
|
-
?
|
|
16
|
-
:
|
|
15
|
+
? 'eingehender'
|
|
16
|
+
: 'ausgehender'
|
|
17
17
|
: isIncoming
|
|
18
|
-
?
|
|
19
|
-
:
|
|
18
|
+
? 'incoming'
|
|
19
|
+
: 'outgoing';
|
|
20
20
|
const titleEndGerman = `${directionString} Anruf (${getProductName()})`;
|
|
21
21
|
const titleEndEnglish = `${directionString} Call (${getProductName()})`;
|
|
22
22
|
switch (state) {
|
|
@@ -42,13 +42,13 @@ exports.getCommentSubject = getCommentSubject;
|
|
|
42
42
|
function getProductName() {
|
|
43
43
|
const productName = process.env.PRODUCT_NAME;
|
|
44
44
|
if (!productName)
|
|
45
|
-
(0, logger_util_1.errorLogger)(
|
|
46
|
-
return productName ||
|
|
45
|
+
(0, logger_util_1.errorLogger)('getProductName', 'Missing environment variable PRODUCT_NAME, using CLINQ.');
|
|
46
|
+
return productName || 'CLINQ';
|
|
47
47
|
}
|
|
48
48
|
exports.getProductName = getProductName;
|
|
49
49
|
function getCommentHeader(locale) {
|
|
50
|
-
const isGerman = locale.startsWith(
|
|
51
|
-
return `<h1>${isGerman ?
|
|
50
|
+
const isGerman = locale.startsWith('de');
|
|
51
|
+
return `<h1>${isGerman ? 'Notizen' : 'Note'} (${getProductName()}):</h1>`;
|
|
52
52
|
}
|
|
53
53
|
exports.getCommentHeader = getCommentHeader;
|
|
54
54
|
function getCommentContent(note, locale) {
|
|
@@ -59,9 +59,9 @@ function getCallDuration(startTime, endTime, locale) {
|
|
|
59
59
|
const start = (0, moment_1.default)(startTime);
|
|
60
60
|
const end = (0, moment_1.default)(endTime);
|
|
61
61
|
const diff = end.diff(start);
|
|
62
|
-
return `${locale.startsWith(
|
|
62
|
+
return `${locale.startsWith('de') ? 'Dauer' : 'Duration'}: ${moment_1.default
|
|
63
63
|
.utc(diff)
|
|
64
|
-
.format(
|
|
64
|
+
.format('HH:mm:ss')}`;
|
|
65
65
|
}
|
|
66
66
|
exports.getCallDuration = getCallDuration;
|
|
67
67
|
//# sourceMappingURL=call-comment.js.map
|
|
@@ -2,83 +2,83 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const models_1 = require("../models");
|
|
4
4
|
const call_event_util_1 = require("./call-event.util");
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
5
|
+
describe('shouldSkipCallEvent', () => {
|
|
6
|
+
it('should return false if the call event has no remote participant', () => {
|
|
7
7
|
const callEvent = {
|
|
8
8
|
participants: [
|
|
9
9
|
{
|
|
10
10
|
type: models_1.CallParticipantType.LOCAL,
|
|
11
|
-
phoneNumber:
|
|
11
|
+
phoneNumber: '1234567890',
|
|
12
12
|
},
|
|
13
13
|
],
|
|
14
|
-
id:
|
|
14
|
+
id: '',
|
|
15
15
|
startTime: 0,
|
|
16
16
|
endTime: 0,
|
|
17
17
|
direction: models_1.CallDirection.IN,
|
|
18
|
-
note:
|
|
18
|
+
note: '',
|
|
19
19
|
state: models_1.CallState.BUSY,
|
|
20
20
|
};
|
|
21
21
|
expect((0, call_event_util_1.shouldSkipCallEvent)(callEvent)).toBe(false);
|
|
22
22
|
});
|
|
23
|
-
it(
|
|
23
|
+
it('should return false if the call event has no direct dial', () => {
|
|
24
24
|
const callEvent = {
|
|
25
25
|
participants: [
|
|
26
26
|
{
|
|
27
27
|
type: models_1.CallParticipantType.LOCAL,
|
|
28
|
-
phoneNumber:
|
|
28
|
+
phoneNumber: '1234567890',
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
type: models_1.CallParticipantType.REMOTE,
|
|
32
|
-
phoneNumber:
|
|
32
|
+
phoneNumber: '1234567890',
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
|
-
id:
|
|
35
|
+
id: '',
|
|
36
36
|
startTime: 0,
|
|
37
37
|
endTime: 0,
|
|
38
38
|
direction: models_1.CallDirection.IN,
|
|
39
|
-
note:
|
|
39
|
+
note: '',
|
|
40
40
|
state: models_1.CallState.BUSY,
|
|
41
41
|
};
|
|
42
42
|
expect((0, call_event_util_1.shouldSkipCallEvent)(callEvent)).toBe(false);
|
|
43
43
|
});
|
|
44
|
-
it(
|
|
44
|
+
it('should return false if the call event has a direct dial with the local party', () => {
|
|
45
45
|
const callEvent = {
|
|
46
46
|
participants: [
|
|
47
47
|
{
|
|
48
48
|
type: models_1.CallParticipantType.LOCAL,
|
|
49
|
-
phoneNumber:
|
|
49
|
+
phoneNumber: '13',
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
type: models_1.CallParticipantType.REMOTE,
|
|
53
|
-
phoneNumber:
|
|
53
|
+
phoneNumber: '1234567890',
|
|
54
54
|
},
|
|
55
55
|
],
|
|
56
|
-
id:
|
|
56
|
+
id: '',
|
|
57
57
|
startTime: 0,
|
|
58
58
|
endTime: 0,
|
|
59
59
|
direction: models_1.CallDirection.IN,
|
|
60
|
-
note:
|
|
60
|
+
note: '',
|
|
61
61
|
state: models_1.CallState.BUSY,
|
|
62
62
|
};
|
|
63
63
|
expect((0, call_event_util_1.shouldSkipCallEvent)(callEvent)).toBe(false);
|
|
64
64
|
});
|
|
65
|
-
it(
|
|
65
|
+
it('should return true if the call is with a remote direct dial', () => {
|
|
66
66
|
const callEvent = {
|
|
67
67
|
participants: [
|
|
68
68
|
{
|
|
69
69
|
type: models_1.CallParticipantType.LOCAL,
|
|
70
|
-
phoneNumber:
|
|
70
|
+
phoneNumber: '1234567890',
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
type: models_1.CallParticipantType.REMOTE,
|
|
74
|
-
phoneNumber:
|
|
74
|
+
phoneNumber: '13',
|
|
75
75
|
},
|
|
76
76
|
],
|
|
77
|
-
id:
|
|
77
|
+
id: '',
|
|
78
78
|
startTime: 0,
|
|
79
79
|
endTime: 0,
|
|
80
80
|
direction: models_1.CallDirection.IN,
|
|
81
|
-
note:
|
|
81
|
+
note: '',
|
|
82
82
|
state: models_1.CallState.BUSY,
|
|
83
83
|
};
|
|
84
84
|
expect((0, call_event_util_1.shouldSkipCallEvent)(callEvent)).toBe(true);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CallEvent } from
|
|
1
|
+
import { CallEvent } from '../models';
|
|
2
2
|
export declare function shouldSkipCallEvent(event: CallEvent): boolean;
|
|
@@ -18,7 +18,7 @@ function formatDuration(durationInMilliSeconds) {
|
|
|
18
18
|
const minutes = Math.floor(durationInMilliSeconds / (60 * 1000));
|
|
19
19
|
const seconds = Math.floor((durationInMilliSeconds - minutes * 60) / 1000)
|
|
20
20
|
.toString()
|
|
21
|
-
.padStart(2,
|
|
21
|
+
.padStart(2, '0')
|
|
22
22
|
.substring(0, 2);
|
|
23
23
|
return `${minutes}:${seconds} min`;
|
|
24
24
|
}
|
|
@@ -26,12 +26,12 @@ const getTextDescriptionForCallevent = (callEvent) => {
|
|
|
26
26
|
var _a;
|
|
27
27
|
const date = new Date(callEvent.startTime);
|
|
28
28
|
const duration = formatDuration(callEvent.endTime - callEvent.startTime);
|
|
29
|
-
const directionInfo = callEvent.direction === models_1.CallDirection.IN ?
|
|
30
|
-
const remoteParticipantDescription = (callEvent.direction === models_1.CallDirection.IN ?
|
|
29
|
+
const directionInfo = callEvent.direction === models_1.CallDirection.IN ? 'eingehender' : 'ausgehender';
|
|
30
|
+
const remoteParticipantDescription = (callEvent.direction === models_1.CallDirection.IN ? ' von ' : ' an ') +
|
|
31
31
|
((_a = callEvent.participants.find((x) => x.type == models_1.CallParticipantType.REMOTE)) === null || _a === void 0 ? void 0 : _a.phoneNumber);
|
|
32
|
-
const callState = callEvent.state ===
|
|
33
|
-
const durationInfo = callEvent.state ===
|
|
34
|
-
return `${callState} ${directionInfo} Anruf ${remoteParticipantDescription} am ${date.toLocaleString(
|
|
32
|
+
const callState = callEvent.state === 'MISSED' ? 'Nicht angenommener ' : 'Angenommener';
|
|
33
|
+
const durationInfo = callEvent.state === 'MISSED' ? '' : ` ,Dauer: ${duration}`;
|
|
34
|
+
return `${callState} ${directionInfo} Anruf ${remoteParticipantDescription} am ${date.toLocaleString('de', { timeZone: 'Europe/Berlin' })} ${durationInfo}`;
|
|
35
35
|
};
|
|
36
36
|
exports.getTextDescriptionForCallevent = getTextDescriptionForCallevent;
|
|
37
37
|
//# sourceMappingURL=callEventHelper.js.map
|
package/dist/util/env.js
CHANGED
|
@@ -26,43 +26,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.parseOAuthOptionFromEnvironment = exports.parseEnvironment = exports.isProduction = void 0;
|
|
27
27
|
const dotenv = __importStar(require("dotenv"));
|
|
28
28
|
function isProduction() {
|
|
29
|
-
return process.env.NODE_ENV ===
|
|
29
|
+
return process.env.NODE_ENV === 'production';
|
|
30
30
|
}
|
|
31
31
|
exports.isProduction = isProduction;
|
|
32
32
|
const parseEnvironment = () => {
|
|
33
|
-
if (process.env.NODE_ENV ===
|
|
33
|
+
if (process.env.NODE_ENV === 'development')
|
|
34
34
|
dotenv.config();
|
|
35
35
|
const { API_URL } = process.env;
|
|
36
36
|
if (!API_URL) {
|
|
37
|
-
throw new Error(
|
|
37
|
+
throw new Error('Missing API_URL in environment.');
|
|
38
38
|
}
|
|
39
39
|
return {
|
|
40
40
|
API_URL,
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
43
|
exports.parseEnvironment = parseEnvironment;
|
|
44
|
-
const DEFAULT_COOKIE_NAME =
|
|
44
|
+
const DEFAULT_COOKIE_NAME = 'oauth_nonce';
|
|
45
45
|
const parseOAuthOptionFromEnvironment = () => {
|
|
46
|
-
if (process.env.NODE_ENV ===
|
|
46
|
+
if (process.env.NODE_ENV === 'development')
|
|
47
47
|
dotenv.config();
|
|
48
48
|
const { APP_ID, APP_SECRET, APP_REDIRECT_URL, API_URL, APP_AUTHORIZE_URL, APP_ACCESSTOKEN_URL, NONCE_COOKIE_NAME, } = process.env;
|
|
49
49
|
if (!APP_ID) {
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error('Missing APP_ID in environment.');
|
|
51
51
|
}
|
|
52
52
|
if (!APP_SECRET) {
|
|
53
|
-
throw new Error(
|
|
53
|
+
throw new Error('Missing APP_SECRET in environment.');
|
|
54
54
|
}
|
|
55
55
|
if (!APP_REDIRECT_URL) {
|
|
56
|
-
throw new Error(
|
|
56
|
+
throw new Error('Missing APP_REDIRECT_URL in environment.');
|
|
57
57
|
}
|
|
58
58
|
if (!API_URL) {
|
|
59
|
-
throw new Error(
|
|
59
|
+
throw new Error('Missing API_URL in environment.');
|
|
60
60
|
}
|
|
61
61
|
if (!APP_AUTHORIZE_URL) {
|
|
62
|
-
throw new Error(
|
|
62
|
+
throw new Error('Missing APP_AUTHORIZE_URL in environment.');
|
|
63
63
|
}
|
|
64
64
|
if (!APP_ACCESSTOKEN_URL) {
|
|
65
|
-
throw new Error(
|
|
65
|
+
throw new Error('Missing APP_ACCESSTOKEN_URL in environment.');
|
|
66
66
|
}
|
|
67
67
|
return {
|
|
68
68
|
APP_ID,
|
package/dist/util/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AxiosError } from
|
|
2
|
-
import { IntegrationErrorType, ServerError } from
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { IntegrationErrorType, ServerError } from '../models';
|
|
3
3
|
export declare const throwAndDelegateError: (error: AxiosError | DelegateToFrontedError | ServerError | Error, source: string, apiKey: string | undefined, logMessage?: string) => never;
|
|
4
4
|
export declare class DelegateToFrontedError extends ServerError {
|
|
5
5
|
errorType: IntegrationErrorType;
|
package/dist/util/error.js
CHANGED
|
@@ -55,17 +55,17 @@ const throwAndDelegateError = (error, source, apiKey, logMessage) => {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
if (errorType !== undefined) {
|
|
58
|
-
(0, logger_util_1.errorLogger)(
|
|
58
|
+
(0, logger_util_1.errorLogger)('throwAndDelegateError', `Delegating error to frontend with code ${models_1.DELEGATE_TO_FRONTEND_CODE} and type ${errorType}`, apiKey);
|
|
59
59
|
throw new models_1.ServerError(models_1.DELEGATE_TO_FRONTEND_CODE, errorType);
|
|
60
60
|
}
|
|
61
|
-
throw new models_1.ServerError(500,
|
|
61
|
+
throw new models_1.ServerError(500, 'An internal error occurred');
|
|
62
62
|
};
|
|
63
63
|
exports.throwAndDelegateError = throwAndDelegateError;
|
|
64
64
|
class DelegateToFrontedError extends models_1.ServerError {
|
|
65
65
|
constructor(errorType) {
|
|
66
66
|
super(models_1.DELEGATE_TO_FRONTEND_CODE, errorType);
|
|
67
67
|
this.errorType = errorType;
|
|
68
|
-
this.name =
|
|
68
|
+
this.name = 'DelegateToFrontedError';
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
exports.DelegateToFrontedError = DelegateToFrontedError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Router } from
|
|
2
|
-
import { CustomRouter } from
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { CustomRouter } from '../../models/custom-router.model';
|
|
3
3
|
export declare function slackNotificationRoute(slackWebhookUrl: string, path: string): Router;
|
|
4
4
|
export declare function getGDPRSlackNotificationRouter(slackWebhookUrl: string): CustomRouter[];
|
|
@@ -61,16 +61,16 @@ exports.slackNotificationRoute = slackNotificationRoute;
|
|
|
61
61
|
function getGDPRSlackNotificationRouter(slackWebhookUrl) {
|
|
62
62
|
const gdprRouter = [
|
|
63
63
|
{
|
|
64
|
-
path:
|
|
65
|
-
router: slackNotificationRoute(slackWebhookUrl,
|
|
64
|
+
path: '/gdpr/',
|
|
65
|
+
router: slackNotificationRoute(slackWebhookUrl, '/customers/data_request/'),
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
|
-
path:
|
|
69
|
-
router: slackNotificationRoute(slackWebhookUrl,
|
|
68
|
+
path: '/gdpr/',
|
|
69
|
+
router: slackNotificationRoute(slackWebhookUrl, '/customers/redact/'),
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
path:
|
|
73
|
-
router: slackNotificationRoute(slackWebhookUrl,
|
|
72
|
+
path: '/gdpr/',
|
|
73
|
+
router: slackNotificationRoute(slackWebhookUrl, '/shop/redact/'),
|
|
74
74
|
},
|
|
75
75
|
];
|
|
76
76
|
return gdprRouter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as GDPRSlackNotification from
|
|
1
|
+
import * as GDPRSlackNotification from './gdprSlackNotification';
|
|
2
2
|
export { GDPRSlackNotification };
|
|
3
|
-
export * from
|
|
3
|
+
export * from './gdprSlackNotification';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ContactCache } from
|
|
1
|
+
import { ContactCache } from '../models';
|
|
2
2
|
export declare function getContactCache(): ContactCache | null;
|
|
@@ -5,15 +5,15 @@ const cache_1 = require("../cache");
|
|
|
5
5
|
const storage_1 = require("../cache/storage");
|
|
6
6
|
function getContactCache() {
|
|
7
7
|
const { REDIS_URL, CACHE_DISABLED } = process.env;
|
|
8
|
-
if (CACHE_DISABLED && CACHE_DISABLED ===
|
|
9
|
-
console.log(
|
|
8
|
+
if (CACHE_DISABLED && CACHE_DISABLED === 'true') {
|
|
9
|
+
console.log('[CONTACT CACHE] Caching disabled');
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
if (REDIS_URL) {
|
|
13
|
-
console.log(
|
|
13
|
+
console.log('[CONTACT CACHE] Using Redis cache');
|
|
14
14
|
return new cache_1.StorageCache(new storage_1.RedisStorageAdapter(REDIS_URL));
|
|
15
15
|
}
|
|
16
|
-
console.log(
|
|
16
|
+
console.log('[CONTACT CACHE] Using memory cache');
|
|
17
17
|
return new cache_1.StorageCache(new storage_1.MemoryStorageAdapter());
|
|
18
18
|
}
|
|
19
19
|
exports.getContactCache = getContactCache;
|