@sipgate/integration-bridge 0.22.7 → 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 -5
- package/dist/cache/storage-cache.js +6 -6
- 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/README.md
CHANGED
|
@@ -7,29 +7,33 @@ way to connect apps to any provider of external data management, like contacts o
|
|
|
7
7
|
|
|
8
8
|
To test your changes to the integration-bridge framework locally, follow these steps:
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
- Run `npm run dev` in sipgate-integration-bridge repo
|
|
11
|
+
- Run `npm link @sipgate/integration-bridge` in \*-integration-bridge-repo
|
|
12
|
+
- Add the following to your `tsconfig.json`:
|
|
13
13
|
```json
|
|
14
14
|
{
|
|
15
15
|
"compilerOptions": {
|
|
16
16
|
"paths": {
|
|
17
|
-
"@sipgate/integration-bridge": [
|
|
17
|
+
"@sipgate/integration-bridge": [
|
|
18
|
+
"node_modules/@sipgate/integration-bridge/src"
|
|
19
|
+
]
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
## Publishing a version
|
|
26
|
+
|
|
24
27
|
To publish a new framework version, simply create a new tag and push it:
|
|
28
|
+
|
|
25
29
|
```
|
|
26
30
|
|
|
27
31
|
npm version <minor|patch>
|
|
28
32
|
git push --follow-tags
|
|
29
33
|
|
|
30
34
|
```
|
|
31
|
-
This will automatically publish the package in the npm registry via the CI pipeline.
|
|
32
35
|
|
|
36
|
+
This will automatically publish the package in the npm registry via the CI pipeline.
|
|
33
37
|
|
|
34
38
|
## Bootstrapping a new bridge
|
|
35
39
|
|
|
@@ -48,30 +52,30 @@ yarn add @sipgate/integration-bridge
|
|
|
48
52
|
The minimum adapter implements the `getContacts` method:
|
|
49
53
|
|
|
50
54
|
```js
|
|
51
|
-
const bridge = require(
|
|
52
|
-
const fetch = require(
|
|
55
|
+
const bridge = require('@sipgate/integration-bridge');
|
|
56
|
+
const fetch = require('node-fetch');
|
|
53
57
|
|
|
54
|
-
const {ServerError} = bridge;
|
|
58
|
+
const { ServerError } = bridge;
|
|
55
59
|
|
|
56
60
|
const adapter = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
getContacts: async ({ apiKey, apiUrl }) => {
|
|
62
|
+
// Fetch contacts using apiUrl and apiKey
|
|
63
|
+
const response = await fetch(`${apiUrl}/api/contacts`, {
|
|
64
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (response.status === 401) {
|
|
68
|
+
throw new ServerError(401, 'Unauthorized');
|
|
69
|
+
}
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
throw new ServerError(500, 'Could not fetch contacts');
|
|
73
|
+
}
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
// TODO: Convert contacts to the structure below
|
|
76
|
+
const contacts = await response.json();
|
|
77
|
+
return contacts;
|
|
78
|
+
},
|
|
75
79
|
};
|
|
76
80
|
|
|
77
81
|
bridge.start(adapter);
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './storage-cache';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './memory-storage-adapter';
|
|
2
|
+
export * from './redis-storage-adapter';
|
|
@@ -20,22 +20,22 @@ class RedisStorageAdapter {
|
|
|
20
20
|
constructor(url) {
|
|
21
21
|
this.client = (0, redis_1.createClient)({ url });
|
|
22
22
|
console.log(`Initialized Redis storage with URL ${url}`);
|
|
23
|
-
this.client.on(
|
|
24
|
-
console.error(
|
|
23
|
+
this.client.on('error', (error) => {
|
|
24
|
+
console.error('Redis error: ', error.message);
|
|
25
25
|
});
|
|
26
|
-
this.client.on(
|
|
27
|
-
console.info(
|
|
26
|
+
this.client.on('ready', () => {
|
|
27
|
+
console.info('Redis is ready');
|
|
28
28
|
});
|
|
29
|
-
this.client.on(
|
|
30
|
-
console.warn(
|
|
29
|
+
this.client.on('reconnecting', () => {
|
|
30
|
+
console.warn('Redis is reconnecting');
|
|
31
31
|
});
|
|
32
32
|
this.client
|
|
33
33
|
.connect()
|
|
34
34
|
.then(() => {
|
|
35
|
-
console.info(
|
|
35
|
+
console.info('Redis successfully connected');
|
|
36
36
|
})
|
|
37
37
|
.catch((error) => {
|
|
38
|
-
console.warn(
|
|
38
|
+
console.warn('Redis connection error: ', error.message);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
get(key) {
|
|
@@ -44,7 +44,7 @@ class RedisStorageAdapter {
|
|
|
44
44
|
if (!value) {
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
|
-
const decompressed = yield inflate(Buffer.from(value,
|
|
47
|
+
const decompressed = yield inflate(Buffer.from(value, 'base64'));
|
|
48
48
|
const result = JSON.parse(decompressed.toString());
|
|
49
49
|
return result;
|
|
50
50
|
});
|
|
@@ -53,7 +53,7 @@ class RedisStorageAdapter {
|
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
const stringified = JSON.stringify(value);
|
|
55
55
|
const compressed = yield deflate(stringified);
|
|
56
|
-
yield this.client.set(key, compressed.toString(
|
|
56
|
+
yield this.client.set(key, compressed.toString('base64'), {
|
|
57
57
|
EX: ttl !== null && ttl !== void 0 ? ttl : DEFAULT_CACHE_TTL,
|
|
58
58
|
});
|
|
59
59
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Contact, ContactCache } from
|
|
2
|
-
import { CacheItemState } from
|
|
3
|
-
import { StorageAdapter } from
|
|
4
|
-
import { TokenCache } from
|
|
5
|
-
import { TokenWithStatus } from
|
|
1
|
+
import { Contact, ContactCache } from '../models';
|
|
2
|
+
import { CacheItemState } from '../models/cache-item-state.model';
|
|
3
|
+
import { StorageAdapter } from '../models/storage-adapter.model';
|
|
4
|
+
import { TokenCache } from '../models/token-cache.model';
|
|
5
|
+
import { TokenWithStatus } from '../models/token.model';
|
|
6
6
|
export declare class StorageCache implements ContactCache {
|
|
7
7
|
private LOG_PREFIX;
|
|
8
8
|
private storage;
|
|
@@ -12,11 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.TokenStorageCache = exports.StorageCache = void 0;
|
|
13
13
|
const cache_item_state_model_1 = require("../models/cache-item-state.model");
|
|
14
14
|
const util_1 = require("../util");
|
|
15
|
-
const CACHE_STATE_PREFIX =
|
|
15
|
+
const CACHE_STATE_PREFIX = 'cache-state:';
|
|
16
16
|
const CACHE_STATE_SECONDS_TTL = 1800; // 30 minutes
|
|
17
17
|
class StorageCache {
|
|
18
18
|
constructor(storageAdapter) {
|
|
19
|
-
this.LOG_PREFIX =
|
|
19
|
+
this.LOG_PREFIX = 'CONTACT CACHE';
|
|
20
20
|
this.cacheRefreshIntervalMs = 30 * 60 * 1000; // 30 minutes
|
|
21
21
|
this.storage = storageAdapter;
|
|
22
22
|
const { CACHE_REFRESH_INTERVAL } = process.env;
|
|
@@ -29,11 +29,11 @@ class StorageCache {
|
|
|
29
29
|
get(key, getFreshValue) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
try {
|
|
32
|
-
(0, util_1.infoLogger)(this.LOG_PREFIX,
|
|
32
|
+
(0, util_1.infoLogger)(this.LOG_PREFIX, 'Trying to get contacts from cache', key);
|
|
33
33
|
const cacheItemState = yield this.storage.get(this.getCacheItemKey(key));
|
|
34
34
|
const contacts = yield this.storage.get(key);
|
|
35
35
|
if ((cacheItemState === null || cacheItemState === void 0 ? void 0 : cacheItemState.state) === cache_item_state_model_1.CacheItemStateType.FETCHING) {
|
|
36
|
-
(0, util_1.infoLogger)(this.LOG_PREFIX,
|
|
36
|
+
(0, util_1.infoLogger)(this.LOG_PREFIX, 'Not refreshing contacts, because cache state is FETCHING', key);
|
|
37
37
|
// if we have old contacts saved in cache we return them instead
|
|
38
38
|
if (contacts && (contacts === null || contacts === void 0 ? void 0 : contacts.length) > 0) {
|
|
39
39
|
(0, util_1.infoLogger)(this.LOG_PREFIX, `Returning previously cached contacts (${contacts.length}), because new contacts are still being fetched`, key);
|
|
@@ -128,14 +128,14 @@ class StorageCache {
|
|
|
128
128
|
exports.StorageCache = StorageCache;
|
|
129
129
|
class TokenStorageCache {
|
|
130
130
|
constructor(storageAdapter) {
|
|
131
|
-
this.LOG_PREFIX =
|
|
131
|
+
this.LOG_PREFIX = 'TOKEN CACHE';
|
|
132
132
|
this.storage = storageAdapter;
|
|
133
133
|
(0, util_1.infoLogger)(this.LOG_PREFIX, `Initialized token storage cache.`, undefined);
|
|
134
134
|
}
|
|
135
135
|
get(key) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
137
|
try {
|
|
138
|
-
(0, util_1.infoLogger)(this.LOG_PREFIX,
|
|
138
|
+
(0, util_1.infoLogger)(this.LOG_PREFIX, 'Trying to get token from cache', key);
|
|
139
139
|
return yield this.storage.get(key);
|
|
140
140
|
}
|
|
141
141
|
catch (e) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Server } from
|
|
3
|
-
import { TokenStorageCache } from
|
|
4
|
-
import { Adapter } from
|
|
5
|
-
import { CustomRouter } from
|
|
6
|
-
import { CustomRoute } from
|
|
2
|
+
import { Server } from 'http';
|
|
3
|
+
import { TokenStorageCache } from './cache';
|
|
4
|
+
import { Adapter } from './models';
|
|
5
|
+
import { CustomRouter } from './models/custom-router.model';
|
|
6
|
+
import { CustomRoute } from './models/custom-routes.model';
|
|
7
7
|
export declare let tokenCache: TokenStorageCache;
|
|
8
8
|
export declare function start(adapter: Adapter, customRouters?: CustomRouter[], customRoutes?: CustomRoute[]): Server;
|
|
9
9
|
export declare const deleteContactCacheItem: (key: string) => Promise<void>;
|
|
10
10
|
export declare const getContactCacheItem: (key: string) => Promise<import("./models").Contact[] | import("./models/cache-item-state.model").CacheItemState>;
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
11
|
+
export * from './models';
|
|
12
|
+
export * from './util';
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ app.use((0, compression_1.default)());
|
|
|
41
41
|
app.use((0, cors_1.default)({
|
|
42
42
|
credentials: true,
|
|
43
43
|
origin: true,
|
|
44
|
-
allowedHeaders:
|
|
44
|
+
allowedHeaders: '*',
|
|
45
45
|
}));
|
|
46
46
|
app.use(body_parser_1.default.json());
|
|
47
47
|
app.use(middlewares_1.extractHeaderMiddleware);
|
|
@@ -50,50 +50,50 @@ function start(adapter, customRouters = [], customRoutes = []) {
|
|
|
50
50
|
contactCache = (0, get_contact_cache_1.getContactCache)();
|
|
51
51
|
exports.tokenCache = (0, util_1.getTokenCache)();
|
|
52
52
|
const controller = new models_1.Controller(adapter, contactCache);
|
|
53
|
-
app.get(
|
|
54
|
-
app.post(
|
|
55
|
-
app.put(
|
|
56
|
-
app.delete(
|
|
57
|
-
app.post(
|
|
58
|
-
app.get(
|
|
59
|
-
app.get(
|
|
60
|
-
app.post(
|
|
61
|
-
app.put(
|
|
62
|
-
app.delete(
|
|
63
|
-
app.post(
|
|
64
|
-
app.put(
|
|
65
|
-
app.post(
|
|
66
|
-
app.put(
|
|
67
|
-
app.put(
|
|
68
|
-
app.get(
|
|
69
|
-
app.get(
|
|
70
|
-
app.get(
|
|
53
|
+
app.get('/contacts', (req, res, next) => controller.getContacts(req, res, next));
|
|
54
|
+
app.post('/contacts', (req, res, next) => controller.createContact(req, res, next));
|
|
55
|
+
app.put('/contacts/:id', (req, res, next) => controller.updateContact(req, res, next));
|
|
56
|
+
app.delete('/contacts/:id', (req, res, next) => controller.deleteContact(req, res, next));
|
|
57
|
+
app.post('/contacts/stream', (req, res, next) => controller.streamContacts(req, res, next));
|
|
58
|
+
app.get('/entity/:type/:id', (req, res, next) => controller.getEntity(req, res, next));
|
|
59
|
+
app.get('/calendar', (req, res, next) => controller.getCalendarEvents(req, res, next));
|
|
60
|
+
app.post('/calendar', (req, res, next) => controller.createCalendarEvent(req, res, next));
|
|
61
|
+
app.put('/calendar/:id', (req, res, next) => controller.updateCalendarEvent(req, res, next));
|
|
62
|
+
app.delete('/calendar/:id', (req, res, next) => controller.deleteCalendarEvent(req, res, next));
|
|
63
|
+
app.post('/events/calls', (req, res, next) => controller.handleCallEvent(req, res, next));
|
|
64
|
+
app.put('/events/calls/:id', (req, res, next) => controller.updateCallEvent(req, res, next));
|
|
65
|
+
app.post('/events/connected', (req, res, next) => controller.handleConnectedEvent(req, res, next));
|
|
66
|
+
app.put('/call-log', (req, res, next) => controller.createOrUpdateCallLogsForEntities(req, res, next));
|
|
67
|
+
app.put('/call-log/phoneNumber', (req, res, next) => controller.createCallLogForPhoneNumber(req, res, next));
|
|
68
|
+
app.get('/health', (req, res, next) => controller.getHealth(req, res, next));
|
|
69
|
+
app.get('/oauth2/redirect', (req, res, next) => controller.oAuth2Redirect(req, res, next));
|
|
70
|
+
app.get('/oauth2/callback', (req, res) => controller.oAuth2Callback(req, res));
|
|
71
71
|
app.use(middlewares_1.errorHandlerMiddleware);
|
|
72
72
|
customRouters.forEach(({ path, router }) => app.use(path, router));
|
|
73
73
|
customRoutes.forEach(({ requestType, path, handler: customHandler }) => {
|
|
74
|
-
(0, util_1.infoLogger)(
|
|
74
|
+
(0, util_1.infoLogger)('start', `CustomRoute ${path} added.`, undefined);
|
|
75
75
|
const handler = (req, res, next) => {
|
|
76
76
|
try {
|
|
77
|
-
(0, util_1.infoLogger)(path,
|
|
77
|
+
(0, util_1.infoLogger)(path, 'START', undefined);
|
|
78
78
|
customHandler(req, res, next);
|
|
79
|
-
(0, util_1.infoLogger)(path,
|
|
79
|
+
(0, util_1.infoLogger)(path, 'END', undefined);
|
|
80
80
|
}
|
|
81
81
|
catch (error) {
|
|
82
|
-
(0, util_1.errorLogger)(path,
|
|
82
|
+
(0, util_1.errorLogger)(path, 'Error while executing custom route', undefined, error !== null && error !== void 0 ? error : undefined);
|
|
83
83
|
next(error);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
switch (requestType) {
|
|
87
|
-
case
|
|
87
|
+
case 'get':
|
|
88
88
|
app.get(path, handler);
|
|
89
89
|
break;
|
|
90
|
-
case
|
|
90
|
+
case 'post':
|
|
91
91
|
app.post(path, handler);
|
|
92
92
|
break;
|
|
93
|
-
case
|
|
93
|
+
case 'put':
|
|
94
94
|
app.put(path, handler);
|
|
95
95
|
break;
|
|
96
|
-
case
|
|
96
|
+
case 'delete':
|
|
97
97
|
app.delete(path, handler);
|
|
98
98
|
break;
|
|
99
99
|
default:
|
package/dist/index.test.js
CHANGED
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const _1 = require(".");
|
|
13
13
|
const testAdapter = {};
|
|
14
|
-
describe(
|
|
15
|
-
it(
|
|
14
|
+
describe('Framework', () => {
|
|
15
|
+
it('should start the server', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
const server = (0, _1.start)(testAdapter);
|
|
17
17
|
expect(server).toBeDefined();
|
|
18
18
|
server.close();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from
|
|
2
|
-
import { ServerError } from
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
import { ServerError } from '../models';
|
|
3
3
|
export declare function errorHandlerMiddleware(error: Error | ServerError, req: Request, res: Response, next: NextFunction): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NextFunction, Response } from
|
|
2
|
-
import { BridgeRequest } from
|
|
1
|
+
import { NextFunction, Response } from 'express';
|
|
2
|
+
import { BridgeRequest } from '../models';
|
|
3
3
|
export declare function extractHeaderMiddleware(req: BridgeRequest<any>, res: Response, next: NextFunction): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractHeaderMiddleware = void 0;
|
|
4
|
-
const DEFAULT_LOCALE =
|
|
4
|
+
const DEFAULT_LOCALE = 'en-GB';
|
|
5
5
|
function extractHeaderMiddleware(req, res, next) {
|
|
6
|
-
const userId = req.get(
|
|
7
|
-
const apiKey = req.get(
|
|
8
|
-
const apiUrl = req.get(
|
|
9
|
-
const locale = req.get(
|
|
6
|
+
const userId = req.get('x-user-id') || '';
|
|
7
|
+
const apiKey = req.get('x-provider-key') || '';
|
|
8
|
+
const apiUrl = req.get('x-provider-url') || '';
|
|
9
|
+
const locale = req.get('x-provider-locale') || DEFAULT_LOCALE;
|
|
10
10
|
req.providerConfig = {
|
|
11
11
|
userId,
|
|
12
12
|
apiKey,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './error-handler.middleware';
|
|
2
|
+
export * from './extract-header.middleware';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Request, Response } from
|
|
2
|
-
import { CalendarEvent, CalendarEventTemplate, CalendarFilterOptions, CallEvent, CallEventWithIntegrationEntities, Config, Contact, ContactTemplate, ContactUpdate, LabeledIntegrationEntity, LoggedIntegrationEntity } from
|
|
3
|
-
import { IntegrationEntityType } from
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { CalendarEvent, CalendarEventTemplate, CalendarFilterOptions, CallEvent, CallEventWithIntegrationEntities, Config, Contact, ContactTemplate, ContactUpdate, LabeledIntegrationEntity, LoggedIntegrationEntity } from '.';
|
|
3
|
+
import { IntegrationEntityType } from './integration-entity.model';
|
|
4
4
|
export interface Adapter {
|
|
5
5
|
getToken?: (config: Config) => Promise<{
|
|
6
6
|
apiKey: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseContact, ContactResult, PhoneNumberLabel, PhoneNumberType } from
|
|
1
|
+
import { BaseContact, ContactResult, PhoneNumberLabel, PhoneNumberType } from './contact.model';
|
|
2
2
|
export interface APIPhoneNumber {
|
|
3
3
|
label: PhoneNumberLabel | string;
|
|
4
4
|
type: PhoneNumberType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IntegrationEntityType } from
|
|
2
|
-
import { Request } from
|
|
3
|
-
import { Config } from
|
|
1
|
+
import { IntegrationEntityType } from './integration-entity.model';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
import { Config } from './config.model';
|
|
4
4
|
export interface BridgeRequest<BodyType> extends Request {
|
|
5
5
|
providerConfig?: Config;
|
|
6
6
|
body: BodyType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CacheItemState } from
|
|
2
|
-
import { Contact } from
|
|
1
|
+
import { CacheItemState } from './cache-item-state.model';
|
|
2
|
+
import { Contact } from './contact.model';
|
|
3
3
|
type FreshValueUpdater = (key: string) => Promise<Contact[]>;
|
|
4
4
|
export interface ContactCache {
|
|
5
5
|
get: (key: string, getFreshValue?: FreshValueUpdater) => Promise<Contact[] | CacheItemState>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationEntity, IntegrationEntityType, LabeledIntegrationEntity } from
|
|
1
|
+
import { IntegrationEntity, IntegrationEntityType, LabeledIntegrationEntity } from './integration-entity.model';
|
|
2
2
|
export declare enum PhoneNumberLabel {
|
|
3
3
|
WORK = "WORK",
|
|
4
4
|
MOBILE = "MOBILE",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from
|
|
2
|
-
import { Adapter, CalendarEventTemplate, CallEvent, CallEventWithIntegrationEntities, ContactCache, ContactTemplate, ContactUpdate } from
|
|
3
|
-
import { BridgeRequest, IdBridgeRequest, IntegrationEntityBridgeRequest } from
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
import { Adapter, CalendarEventTemplate, CallEvent, CallEventWithIntegrationEntities, ContactCache, ContactTemplate, ContactUpdate } from '.';
|
|
3
|
+
import { BridgeRequest, IdBridgeRequest, IntegrationEntityBridgeRequest } from './bridge-request.model';
|
|
4
4
|
export declare class Controller {
|
|
5
5
|
private adapter;
|
|
6
6
|
private contactCache;
|