@unito/integration-cli 0.60.1 → 0.60.3

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.
@@ -0,0 +1,435 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpError = exports.getUserByEmail = exports.regenerateApiKey = exports.updateUser = exports.getUserById = exports.createUser = exports.getUsers = exports.deleteProxyGraph = exports.postProxyGraph = exports.patchProxyGraph = exports.getProxyGraph = exports.updateWebhookSubscription = exports.getProxyMe = exports.updateProfile = exports.getProfile = exports.reencryptData = exports.decryptData = exports.encryptData = exports.postTrack = exports.getCredentialAccount = exports.deleteCredential = exports.updateCredential = exports.getCredentialById = exports.createCredential = exports.getCredentials = exports.getIntegrationLogo = exports.getIntegrationEvents = exports.deleteIntegration = exports.updateIntegration = exports.getIntegrationById = exports.inviteOrganization = exports.inviteUser = exports.getIntegrationByName = exports.publishIntegration = exports.createIntegration = exports.getIntegrations = exports.servers = exports.defaults = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * Integrations Platform API
7
+ * 0.1.0
8
+ * DO NOT MODIFY - This file has been generated using oazapfts.
9
+ * See https://www.npmjs.com/package/oazapfts
10
+ */
11
+ const Oazapfts = tslib_1.__importStar(require("@oazapfts/runtime"));
12
+ const QS = tslib_1.__importStar(require("@oazapfts/runtime/query"));
13
+ exports.defaults = {
14
+ headers: {},
15
+ baseUrl: 'http://localhost:9000',
16
+ };
17
+ const oazapfts = Oazapfts.runtime(exports.defaults);
18
+ exports.servers = {
19
+ local: 'http://localhost:9000',
20
+ staging: 'https://staging-integrations-platform.unito.io',
21
+ production: 'https://integrations-platform.unito.io',
22
+ };
23
+ /**
24
+ * Get all the integrations
25
+ */
26
+ function getIntegrations({ pagination, unitoOrganizationId, search, } = {}, opts) {
27
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations${QS.query(QS.explode({
28
+ pagination,
29
+ unitoOrganizationId,
30
+ search,
31
+ }))}`, {
32
+ ...opts,
33
+ }));
34
+ }
35
+ exports.getIntegrations = getIntegrations;
36
+ /**
37
+ * Create an integration
38
+ */
39
+ function createIntegration(body, opts) {
40
+ return oazapfts.ok(oazapfts.fetchJson('/integrations', oazapfts.json({
41
+ ...opts,
42
+ method: 'POST',
43
+ body,
44
+ })));
45
+ }
46
+ exports.createIntegration = createIntegration;
47
+ /**
48
+ * Publish an integration
49
+ */
50
+ function publishIntegration(body, opts) {
51
+ return oazapfts.ok(oazapfts.fetchJson('/integrations/publish', oazapfts.multipart({
52
+ ...opts,
53
+ method: 'POST',
54
+ body,
55
+ })));
56
+ }
57
+ exports.publishIntegration = publishIntegration;
58
+ /**
59
+ * Find an integration by exact name
60
+ */
61
+ function getIntegrationByName(integrationName, opts) {
62
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/find/${encodeURIComponent(integrationName)}`, {
63
+ ...opts,
64
+ }));
65
+ }
66
+ exports.getIntegrationByName = getIntegrationByName;
67
+ /**
68
+ * Invite a user to an integration
69
+ */
70
+ function inviteUser(integrationId, body, opts) {
71
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/users/invite`, oazapfts.json({
72
+ ...opts,
73
+ method: 'POST',
74
+ body,
75
+ })));
76
+ }
77
+ exports.inviteUser = inviteUser;
78
+ /**
79
+ * Invite a unito organization to an integration
80
+ */
81
+ function inviteOrganization(integrationId, body, opts) {
82
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/organizations/invite`, oazapfts.json({
83
+ ...opts,
84
+ method: 'POST',
85
+ body,
86
+ })));
87
+ }
88
+ exports.inviteOrganization = inviteOrganization;
89
+ /**
90
+ * Get an integration
91
+ */
92
+ function getIntegrationById(integrationId, opts) {
93
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, {
94
+ ...opts,
95
+ }));
96
+ }
97
+ exports.getIntegrationById = getIntegrationById;
98
+ /**
99
+ * Update an integration
100
+ */
101
+ function updateIntegration(integrationId, body, opts) {
102
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, oazapfts.json({
103
+ ...opts,
104
+ method: 'PATCH',
105
+ body,
106
+ })));
107
+ }
108
+ exports.updateIntegration = updateIntegration;
109
+ /**
110
+ * Delete an integration
111
+ */
112
+ function deleteIntegration(integrationId, name, opts) {
113
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}${QS.query(QS.explode({
114
+ name,
115
+ }))}`, {
116
+ ...opts,
117
+ method: 'DELETE',
118
+ }));
119
+ }
120
+ exports.deleteIntegration = deleteIntegration;
121
+ /**
122
+ * Get the events associated with this integration.
123
+ */
124
+ function getIntegrationEvents(integrationId, { search, $from, limit, } = {}, opts) {
125
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/events${QS.query(QS.explode({
126
+ search,
127
+ from: $from,
128
+ limit,
129
+ }))}`, {
130
+ ...opts,
131
+ }));
132
+ }
133
+ exports.getIntegrationEvents = getIntegrationEvents;
134
+ /**
135
+ * Get the logo of the integration, in SVG format.
136
+ */
137
+ function getIntegrationLogo(integrationName, opts) {
138
+ return oazapfts.ok(oazapfts.fetchJson(`/public/${encodeURIComponent(integrationName)}/logo.svg`, {
139
+ ...opts,
140
+ }));
141
+ }
142
+ exports.getIntegrationLogo = getIntegrationLogo;
143
+ /**
144
+ * Get all the credentials
145
+ */
146
+ function getCredentials({ pagination, filters, } = {}, opts) {
147
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials${QS.query(QS.explode({
148
+ pagination,
149
+ filters,
150
+ }))}`, {
151
+ ...opts,
152
+ }));
153
+ }
154
+ exports.getCredentials = getCredentials;
155
+ /**
156
+ * Create a credential
157
+ */
158
+ function createCredential(body, opts) {
159
+ return oazapfts.ok(oazapfts.fetchJson('/credentials', oazapfts.json({
160
+ ...opts,
161
+ method: 'POST',
162
+ body,
163
+ })));
164
+ }
165
+ exports.createCredential = createCredential;
166
+ /**
167
+ * Get a credential
168
+ */
169
+ function getCredentialById(credentialId, opts) {
170
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
171
+ ...opts,
172
+ }));
173
+ }
174
+ exports.getCredentialById = getCredentialById;
175
+ /**
176
+ * Update a credential
177
+ */
178
+ function updateCredential(credentialId, body, opts) {
179
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, oazapfts.json({
180
+ ...opts,
181
+ method: 'PATCH',
182
+ body,
183
+ })));
184
+ }
185
+ exports.updateCredential = updateCredential;
186
+ /**
187
+ * Delete a credential
188
+ */
189
+ function deleteCredential(credentialId, opts) {
190
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
191
+ ...opts,
192
+ method: 'DELETE',
193
+ }));
194
+ }
195
+ exports.deleteCredential = deleteCredential;
196
+ /**
197
+ * Returns the credentialAccount either from the integration's /me endpoint, if available, or the credential's latestCredentialAccount
198
+ */
199
+ function getCredentialAccount(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
200
+ return oazapfts.ok(oazapfts.fetchJson('/credentialAccount', {
201
+ ...opts,
202
+ headers: oazapfts.mergeHeaders(opts?.headers, {
203
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
204
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
205
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
206
+ }),
207
+ }));
208
+ }
209
+ exports.getCredentialAccount = getCredentialAccount;
210
+ /**
211
+ * Used by the frontend to send analytics data
212
+ */
213
+ function postTrack(body, opts) {
214
+ return oazapfts.ok(oazapfts.fetchJson('/track', oazapfts.json({
215
+ ...opts,
216
+ method: 'POST',
217
+ body,
218
+ })));
219
+ }
220
+ exports.postTrack = postTrack;
221
+ /**
222
+ * Encrypt data
223
+ */
224
+ function encryptData(body, opts) {
225
+ return oazapfts.ok(oazapfts.fetchJson('/encryptions/encrypt', oazapfts.json({
226
+ ...opts,
227
+ method: 'POST',
228
+ body,
229
+ })));
230
+ }
231
+ exports.encryptData = encryptData;
232
+ /**
233
+ * Decrypt data
234
+ */
235
+ function decryptData(body, opts) {
236
+ return oazapfts.ok(oazapfts.fetchJson('/encryptions/decrypt', oazapfts.json({
237
+ ...opts,
238
+ method: 'POST',
239
+ body,
240
+ })));
241
+ }
242
+ exports.decryptData = decryptData;
243
+ /**
244
+ * Decrypt and encrypt data
245
+ */
246
+ function reencryptData(body, opts) {
247
+ return oazapfts.ok(oazapfts.fetchJson('/encryptions/reencrypt', oazapfts.json({
248
+ ...opts,
249
+ method: 'POST',
250
+ body,
251
+ })));
252
+ }
253
+ exports.reencryptData = reencryptData;
254
+ /**
255
+ * Get my profile
256
+ */
257
+ function getProfile(opts) {
258
+ return oazapfts.ok(oazapfts.fetchJson('/profile', {
259
+ ...opts,
260
+ }));
261
+ }
262
+ exports.getProfile = getProfile;
263
+ /**
264
+ * Update my profile
265
+ */
266
+ function updateProfile(body, opts) {
267
+ return oazapfts.ok(oazapfts.fetchJson('/profile', oazapfts.json({
268
+ ...opts,
269
+ method: 'PATCH',
270
+ body,
271
+ })));
272
+ }
273
+ exports.updateProfile = updateProfile;
274
+ /**
275
+ * Call an integration's me
276
+ */
277
+ function getProxyMe(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
278
+ return oazapfts.ok(oazapfts.fetchJson('/proxy/me', {
279
+ ...opts,
280
+ headers: oazapfts.mergeHeaders(opts?.headers, {
281
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
282
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
283
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
284
+ }),
285
+ }));
286
+ }
287
+ exports.getProxyMe = getProxyMe;
288
+ /**
289
+ * Update a webhook subscription
290
+ */
291
+ function updateWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
292
+ return oazapfts.ok(oazapfts.fetchJson('/proxy/webhooks/subscriptions', oazapfts.json({
293
+ ...opts,
294
+ method: 'PUT',
295
+ body,
296
+ headers: oazapfts.mergeHeaders(opts?.headers, {
297
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
298
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
299
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
300
+ }),
301
+ })));
302
+ }
303
+ exports.updateWebhookSubscription = updateWebhookSubscription;
304
+ /**
305
+ * Call an integration's graph
306
+ */
307
+ function getProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
308
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
309
+ path,
310
+ }))}`, {
311
+ ...opts,
312
+ headers: oazapfts.mergeHeaders(opts?.headers, {
313
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
314
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
315
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
316
+ }),
317
+ }));
318
+ }
319
+ exports.getProxyGraph = getProxyGraph;
320
+ /**
321
+ * Call an integration's graph
322
+ */
323
+ function patchProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
324
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
325
+ path,
326
+ }))}`, oazapfts.json({
327
+ ...opts,
328
+ method: 'PATCH',
329
+ body,
330
+ headers: oazapfts.mergeHeaders(opts?.headers, {
331
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
332
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
333
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
334
+ }),
335
+ })));
336
+ }
337
+ exports.patchProxyGraph = patchProxyGraph;
338
+ /**
339
+ * Call an integration's graph
340
+ */
341
+ function postProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
342
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
343
+ path,
344
+ }))}`, oazapfts.json({
345
+ ...opts,
346
+ method: 'POST',
347
+ body,
348
+ headers: oazapfts.mergeHeaders(opts?.headers, {
349
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
350
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
351
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
352
+ }),
353
+ })));
354
+ }
355
+ exports.postProxyGraph = postProxyGraph;
356
+ /**
357
+ * Call an integration's graph
358
+ */
359
+ function deleteProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
360
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
361
+ path,
362
+ }))}`, {
363
+ ...opts,
364
+ method: 'DELETE',
365
+ headers: oazapfts.mergeHeaders(opts?.headers, {
366
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
367
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
368
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
369
+ }),
370
+ }));
371
+ }
372
+ exports.deleteProxyGraph = deleteProxyGraph;
373
+ /**
374
+ * Get all the users
375
+ */
376
+ function getUsers({ pagination, } = {}, opts) {
377
+ return oazapfts.ok(oazapfts.fetchJson(`/users${QS.query(QS.explode({
378
+ pagination,
379
+ }))}`, {
380
+ ...opts,
381
+ }));
382
+ }
383
+ exports.getUsers = getUsers;
384
+ /**
385
+ * Create a user
386
+ */
387
+ function createUser(body, opts) {
388
+ return oazapfts.ok(oazapfts.fetchJson('/users', oazapfts.json({
389
+ ...opts,
390
+ method: 'POST',
391
+ body,
392
+ })));
393
+ }
394
+ exports.createUser = createUser;
395
+ /**
396
+ * Get a user
397
+ */
398
+ function getUserById(userId, opts) {
399
+ return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, {
400
+ ...opts,
401
+ }));
402
+ }
403
+ exports.getUserById = getUserById;
404
+ /**
405
+ * Update a user
406
+ */
407
+ function updateUser(userId, body, opts) {
408
+ return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, oazapfts.json({
409
+ ...opts,
410
+ method: 'PATCH',
411
+ body,
412
+ })));
413
+ }
414
+ exports.updateUser = updateUser;
415
+ /**
416
+ * Regenerate the api key of a user
417
+ */
418
+ function regenerateApiKey(userId, opts) {
419
+ return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}/apiKey`, {
420
+ ...opts,
421
+ method: 'POST',
422
+ }));
423
+ }
424
+ exports.regenerateApiKey = regenerateApiKey;
425
+ /**
426
+ * Get a user by its email address
427
+ */
428
+ function getUserByEmail(email, opts) {
429
+ return oazapfts.ok(oazapfts.fetchJson(`/users/find/${encodeURIComponent(email)}`, {
430
+ ...opts,
431
+ }));
432
+ }
433
+ exports.getUserByEmail = getUserByEmail;
434
+ const runtime_1 = require("@oazapfts/runtime");
435
+ Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return runtime_1.HttpError; } });
@@ -41,9 +41,6 @@ class OAuth2Service {
41
41
  */
42
42
  constructor(authorizationInfo, environment = globalConfiguration_1.Environment.Production, credentialPayload) {
43
43
  const { clientId, clientSecret, authorizationUrl, scopes, tokenUrl, grantType, requestContentType, refreshRequestParameters, tokenRequestParameters, } = authorizationInfo;
44
- this.startServer = this.startServer.bind(this);
45
- this.stopServer = this.stopServer.bind(this);
46
- this.handleCallback = this.handleCallback.bind(this);
47
44
  this.clientId = clientId;
48
45
  this.clientSecret = clientSecret;
49
46
  this.providerAuthorizationUrl = authorizationUrl;
@@ -99,7 +96,8 @@ class OAuth2Service {
99
96
  // Error response: https://www.rfc-editor.org/rfc/rfc6749#section-4.1.2.1
100
97
  const error = req.query.error;
101
98
  if (error) {
102
- res.setHeader('Content-Type', 'text/html').send(exports.HTML_ERROR_MSG);
99
+ res.setHeader('Content-Type', 'text/html');
100
+ res.send(exports.HTML_ERROR_MSG);
103
101
  return;
104
102
  }
105
103
  // We keep all the non-standard query parameters of the authorization response
@@ -130,16 +128,17 @@ class OAuth2Service {
130
128
  ])),
131
129
  };
132
130
  try {
133
- const fetchResult = await fetch((0, template_1.expandTemplate)(this.tokenUrl, templateVariables, { urlEncodeVariables: true }), {
131
+ const tokenResponse = await fetch((0, template_1.expandTemplate)(this.tokenUrl, templateVariables, { urlEncodeVariables: true }), {
134
132
  headers: tokenRequestHeaders,
135
133
  body: this.encodeBody(tokenRequestPayload, this.requestContentType),
136
134
  method: 'POST',
137
135
  });
138
- if (fetchResult.status !== 200) {
136
+ if (tokenResponse.status !== 200) {
139
137
  res.setHeader('Content-Type', 'text/html');
140
138
  res.send(exports.HTML_ERROR_MSG);
139
+ return;
141
140
  }
142
- const response = await fetchResult.json();
141
+ const response = await tokenResponse.json();
143
142
  this.oauth2Response = {
144
143
  accessToken: response.access_token,
145
144
  refreshToken: response.refresh_token,
@@ -148,8 +147,10 @@ class OAuth2Service {
148
147
  res.send(exports.HTML_SUCCESS_MSG);
149
148
  }
150
149
  catch (error) {
151
- res.setHeader('Content-Type', 'text/html');
152
- res.send(exports.HTML_ERROR_MSG);
150
+ if (!res.headersSent) {
151
+ res.setHeader('Content-Type', 'text/html');
152
+ res.send(exports.HTML_ERROR_MSG);
153
+ }
153
154
  }
154
155
  }
155
156
  /**
@@ -194,25 +195,23 @@ class OAuth2Service {
194
195
  if (this.clientSecret) {
195
196
  bodyData.client_secret = this.clientSecret;
196
197
  }
197
- const fetchOptions = {
198
- headers: {
199
- 'Content-Type': this.requestContentType,
200
- ...(this.refreshRequestParameters?.header ?? {}),
201
- },
202
- body: this.encodeBody(bodyData, this.requestContentType),
203
- method: 'POST',
204
- };
205
198
  try {
206
- const fetchResult = await fetch(this.tokenUrl, fetchOptions);
207
- if (fetchResult.status !== 200) {
208
- throw new errors_1.FailedToRetrieveAccessTokenError(await fetchResult.text());
199
+ const tokenResponse = await fetch(this.tokenUrl, {
200
+ headers: {
201
+ 'Content-Type': this.requestContentType,
202
+ ...(this.refreshRequestParameters?.header ?? {}),
203
+ },
204
+ body: this.encodeBody(bodyData, this.requestContentType),
205
+ method: 'POST',
206
+ });
207
+ if (tokenResponse.status !== 200) {
208
+ throw new errors_1.FailedToRetrieveAccessTokenError(await tokenResponse.text());
209
209
  }
210
- const response = await fetchResult.json();
211
- const credentialsInfo = {
210
+ const response = await tokenResponse.json();
211
+ return {
212
212
  accessToken: response.access_token,
213
213
  refreshToken: response.refresh_token,
214
214
  };
215
- return credentialsInfo;
216
215
  }
217
216
  catch (error) {
218
217
  throw new errors_1.FailedToRetrieveAccessTokenError(JSON.stringify(error));
@@ -21,6 +21,6 @@ export declare function generateIntegration(overrides?: Partial<IntegrationsPlat
21
21
  [key: string]: string;
22
22
  } | undefined;
23
23
  disabledAt?: string | null | undefined;
24
- authorizations: import("@unito/integrations-platform-client/dist/src/api").Authorization[];
24
+ authorizations: import("../../src/services/integrationsPlatformClient").Authorization[];
25
25
  userIds: number[];
26
26
  };
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
5
5
  const sinon = tslib_1.__importStar(require("sinon"));
6
- const integrations_platform_client_1 = tslib_1.__importDefault(require("@unito/integrations-platform-client"));
6
+ const IntegrationsPlatformClient = tslib_1.__importStar(require("../../src/services/integrationsPlatformClient"));
7
7
  const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
8
8
  const globalConfiguration_1 = require("../../src/resources/globalConfiguration");
9
9
  const configurationTypes_1 = require("../../src/configurationTypes");
@@ -45,49 +45,49 @@ describe('integrations platform', function () {
45
45
  });
46
46
  it('environment', function () {
47
47
  IntegrationsPlatform.setEnvironment(globalConfiguration_1.Environment.Local);
48
- strict_1.default.equal(integrations_platform_client_1.default.defaults.baseUrl, integrations_platform_client_1.default.servers.local);
48
+ strict_1.default.equal(IntegrationsPlatformClient.defaults.baseUrl, IntegrationsPlatformClient.servers.local);
49
49
  IntegrationsPlatform.setEnvironment(globalConfiguration_1.Environment.Production);
50
- strict_1.default.equal(integrations_platform_client_1.default.defaults.baseUrl, integrations_platform_client_1.default.servers.production);
50
+ strict_1.default.equal(IntegrationsPlatformClient.defaults.baseUrl, IntegrationsPlatformClient.servers.production);
51
51
  });
52
52
  it('apiKey', function () {
53
53
  IntegrationsPlatform.setApiKey('foo');
54
54
  strict_1.default.equal(IntegrationsPlatform.getApiKey(), 'foo');
55
- strict_1.default.deepEqual(integrations_platform_client_1.default.defaults.headers, {
55
+ strict_1.default.deepEqual(IntegrationsPlatformClient.defaults.headers, {
56
56
  Authorization: 'Bearer foo',
57
57
  });
58
58
  IntegrationsPlatform.setApiKey(undefined);
59
59
  strict_1.default.equal(IntegrationsPlatform.getApiKey(), undefined);
60
- strict_1.default.deepEqual(integrations_platform_client_1.default.defaults.headers, {});
60
+ strict_1.default.deepEqual(IntegrationsPlatformClient.defaults.headers, {});
61
61
  });
62
62
  it('getProfile', async function () {
63
- sinon.stub(integrations_platform_client_1.default, 'getProfile').resolves(user);
63
+ sinon.stub(IntegrationsPlatformClient, 'getProfile').resolves(user);
64
64
  strict_1.default.deepEqual(await IntegrationsPlatform.getProfile(), user);
65
65
  });
66
66
  it('getIntegration', async function () {
67
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves(integration);
67
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationById').resolves(integration);
68
68
  strict_1.default.deepEqual(await IntegrationsPlatform.getIntegration(1), integration);
69
69
  });
70
70
  it('getIntegrationByName', async function () {
71
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationByName').resolves(integration);
71
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationByName').resolves(integration);
72
72
  strict_1.default.deepEqual(await IntegrationsPlatform.getIntegrationByName('foo'), integration);
73
73
  });
74
74
  it('getIntegrations', async function () {
75
- sinon.stub(integrations_platform_client_1.default, 'getIntegrations').resolves({ total: 1, data: [integrationSummary] });
75
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrations').resolves({ total: 1, data: [integrationSummary] });
76
76
  strict_1.default.deepEqual(await IntegrationsPlatform.getIntegrations(), [integrationSummary]);
77
77
  });
78
78
  it('createIntegration', async function () {
79
- sinon.stub(integrations_platform_client_1.default, 'createIntegration').resolves(integration);
80
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves(integration);
81
- sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
79
+ sinon.stub(IntegrationsPlatformClient, 'createIntegration').resolves(integration);
80
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationById').resolves(integration);
81
+ sinon.stub(IntegrationsPlatformClient, 'updateIntegration').resolves(integration);
82
82
  strict_1.default.deepEqual(await IntegrationsPlatform.createIntegration({ name: 'foo' }), integration);
83
83
  });
84
84
  it('updateIntegration', async function () {
85
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves(integration);
86
- sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
85
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationById').resolves(integration);
86
+ sinon.stub(IntegrationsPlatformClient, 'updateIntegration').resolves(integration);
87
87
  strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, { name: 'foo' }), integration);
88
88
  });
89
89
  it('updateIntegration - create / archive authorization', async function () {
90
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({
90
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationById').resolves({
91
91
  ...integration,
92
92
  authorizations: [
93
93
  {
@@ -103,14 +103,14 @@ describe('integrations platform', function () {
103
103
  },
104
104
  ],
105
105
  });
106
- sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
106
+ sinon.stub(IntegrationsPlatformClient, 'updateIntegration').resolves(integration);
107
107
  strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, {
108
108
  name: 'foo',
109
109
  authorizations: [{ name: 'bar', method: configurationTypes_1.Method.CUSTOM }],
110
110
  }), integration);
111
111
  });
112
112
  it('updateIntegration - update authorization', async function () {
113
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({
113
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationById').resolves({
114
114
  ...integration,
115
115
  authorizations: [
116
116
  {
@@ -126,7 +126,7 @@ describe('integrations platform', function () {
126
126
  },
127
127
  ],
128
128
  });
129
- sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
129
+ sinon.stub(IntegrationsPlatformClient, 'updateIntegration').resolves(integration);
130
130
  strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, { name: 'foo' }), integration);
131
131
  strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, {
132
132
  name: 'foo',
@@ -134,8 +134,8 @@ describe('integrations platform', function () {
134
134
  }), integration);
135
135
  });
136
136
  it('updateIntegration - update secrets', async function () {
137
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({ ...integration });
138
- const mockUpdateIntegration = sinon.stub(integrations_platform_client_1.default, 'updateIntegration');
137
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationById').resolves({ ...integration });
138
+ const mockUpdateIntegration = sinon.stub(IntegrationsPlatformClient, 'updateIntegration');
139
139
  const integrationId = 1;
140
140
  const configuration = {
141
141
  name: 'foo',
@@ -158,8 +158,8 @@ describe('integrations platform', function () {
158
158
  });
159
159
  });
160
160
  it('updateIntegration - unarchive', async function () {
161
- sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({ ...integration });
162
- const mockUpdateIntegration = sinon.stub(integrations_platform_client_1.default, 'updateIntegration');
161
+ sinon.stub(IntegrationsPlatformClient, 'getIntegrationById').resolves({ ...integration });
162
+ const mockUpdateIntegration = sinon.stub(IntegrationsPlatformClient, 'updateIntegration');
163
163
  const integrationId = 1;
164
164
  const archived = false;
165
165
  const configuration = {
@@ -183,7 +183,7 @@ describe('integrations platform', function () {
183
183
  });
184
184
  });
185
185
  it('encryptData', async function () {
186
- sinon.stub(integrations_platform_client_1.default, 'encryptData').resolves({ encryptedData: 'encryptedFoo' });
186
+ sinon.stub(IntegrationsPlatformClient, 'encryptData').resolves({ encryptedData: 'encryptedFoo' });
187
187
  strict_1.default.deepEqual(await IntegrationsPlatform.encryptData('mySuperIntegration', 'foo', false), {
188
188
  encryptedData: 'encryptedFoo',
189
189
  });