@unito/integrations-platform-client 0.44.3 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/api.js CHANGED
@@ -1,42 +1,17 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.HttpError = exports.getHealthAlive = exports.getHealthReady = 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.deleteCredential = exports.updateCredential = exports.getCredentialById = exports.createCredential = exports.getCredentials = exports.getIntegrationLogo = exports.getIntegrationEvents = exports.deleteIntegration = exports.updateIntegration = exports.getIntegrationById = exports.inviteUser = exports.getIntegrationByName = exports.publishIntegration = exports.createIntegration = exports.getIntegrations = exports.servers = exports.defaults = void 0;
27
1
  /**
28
2
  * Integrations Platform API
29
3
  * 0.1.0
30
4
  * DO NOT MODIFY - This file has been generated using oazapfts.
31
5
  * See https://www.npmjs.com/package/oazapfts
32
6
  */
33
- const Oazapfts = __importStar(require("oazapfts/lib/runtime"));
34
- const QS = __importStar(require("oazapfts/lib/runtime/query"));
35
- exports.defaults = {
7
+ import * as Oazapfts from 'oazapfts/lib/runtime';
8
+ import * as QS from 'oazapfts/lib/runtime/query';
9
+ export const defaults = {
10
+ headers: {},
36
11
  baseUrl: 'http://localhost:9000',
37
12
  };
38
- const oazapfts = Oazapfts.runtime(exports.defaults);
39
- exports.servers = {
13
+ const oazapfts = Oazapfts.runtime(defaults);
14
+ export const servers = {
40
15
  local: 'http://localhost:9000',
41
16
  staging: 'https://staging-integrations-platform.unito.io',
42
17
  production: 'https://integrations-platform.unito.io',
@@ -44,7 +19,7 @@ exports.servers = {
44
19
  /**
45
20
  * Get all the integrations
46
21
  */
47
- function getIntegrations({ pagination, unitoOrganizationId, search, } = {}, opts) {
22
+ export function getIntegrations({ pagination, unitoOrganizationId, search, } = {}, opts) {
48
23
  return oazapfts.ok(oazapfts.fetchJson(`/integrations${QS.query(QS.explode({
49
24
  pagination,
50
25
  unitoOrganizationId,
@@ -53,73 +28,76 @@ function getIntegrations({ pagination, unitoOrganizationId, search, } = {}, opts
53
28
  ...opts,
54
29
  }));
55
30
  }
56
- exports.getIntegrations = getIntegrations;
57
31
  /**
58
32
  * Create an integration
59
33
  */
60
- function createIntegration(body, opts) {
34
+ export function createIntegration(body, opts) {
61
35
  return oazapfts.ok(oazapfts.fetchJson('/integrations', oazapfts.json({
62
36
  ...opts,
63
37
  method: 'POST',
64
38
  body,
65
39
  })));
66
40
  }
67
- exports.createIntegration = createIntegration;
68
41
  /**
69
42
  * Publish an integration
70
43
  */
71
- function publishIntegration(body, opts) {
44
+ export function publishIntegration(body, opts) {
72
45
  return oazapfts.ok(oazapfts.fetchJson('/integrations/publish', oazapfts.multipart({
73
46
  ...opts,
74
47
  method: 'POST',
75
48
  body,
76
49
  })));
77
50
  }
78
- exports.publishIntegration = publishIntegration;
79
51
  /**
80
52
  * Find an integration by exact name
81
53
  */
82
- function getIntegrationByName(integrationName, opts) {
54
+ export function getIntegrationByName(integrationName, opts) {
83
55
  return oazapfts.ok(oazapfts.fetchJson(`/integrations/find/${encodeURIComponent(integrationName)}`, {
84
56
  ...opts,
85
57
  }));
86
58
  }
87
- exports.getIntegrationByName = getIntegrationByName;
88
59
  /**
89
60
  * Invite a user to an integration
90
61
  */
91
- function inviteUser(integrationId, body, opts) {
62
+ export function inviteUser(integrationId, body, opts) {
92
63
  return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/users/invite`, oazapfts.json({
93
64
  ...opts,
94
65
  method: 'POST',
95
66
  body,
96
67
  })));
97
68
  }
98
- exports.inviteUser = inviteUser;
69
+ /**
70
+ * Invite a unito organization to an integration
71
+ */
72
+ export function inviteOrganization(integrationId, body, opts) {
73
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/organizations/invite`, oazapfts.json({
74
+ ...opts,
75
+ method: 'POST',
76
+ body,
77
+ })));
78
+ }
99
79
  /**
100
80
  * Get an integration
101
81
  */
102
- function getIntegrationById(integrationId, opts) {
82
+ export function getIntegrationById(integrationId, opts) {
103
83
  return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, {
104
84
  ...opts,
105
85
  }));
106
86
  }
107
- exports.getIntegrationById = getIntegrationById;
108
87
  /**
109
88
  * Update an integration
110
89
  */
111
- function updateIntegration(integrationId, body, opts) {
90
+ export function updateIntegration(integrationId, body, opts) {
112
91
  return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, oazapfts.json({
113
92
  ...opts,
114
93
  method: 'PATCH',
115
94
  body,
116
95
  })));
117
96
  }
118
- exports.updateIntegration = updateIntegration;
119
97
  /**
120
98
  * Delete an integration
121
99
  */
122
- function deleteIntegration(integrationId, name, opts) {
100
+ export function deleteIntegration(integrationId, name, opts) {
123
101
  return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}${QS.query(QS.explode({
124
102
  name,
125
103
  }))}`, {
@@ -127,29 +105,26 @@ function deleteIntegration(integrationId, name, opts) {
127
105
  method: 'DELETE',
128
106
  }));
129
107
  }
130
- exports.deleteIntegration = deleteIntegration;
131
108
  /**
132
109
  * Get the events associated with this integration.
133
110
  */
134
- function getIntegrationEvents(integrationId, opts) {
111
+ export function getIntegrationEvents(integrationId, opts) {
135
112
  return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/events`, {
136
113
  ...opts,
137
114
  }));
138
115
  }
139
- exports.getIntegrationEvents = getIntegrationEvents;
140
116
  /**
141
117
  * Get the logo of the integration, in SVG format.
142
118
  */
143
- function getIntegrationLogo(integrationName, opts) {
119
+ export function getIntegrationLogo(integrationName, opts) {
144
120
  return oazapfts.ok(oazapfts.fetchJson(`/public/${encodeURIComponent(integrationName)}/logo.svg`, {
145
121
  ...opts,
146
122
  }));
147
123
  }
148
- exports.getIntegrationLogo = getIntegrationLogo;
149
124
  /**
150
125
  * Get all the credentials
151
126
  */
152
- function getCredentials({ pagination, filters, } = {}, opts) {
127
+ export function getCredentials({ pagination, filters, } = {}, opts) {
153
128
  return oazapfts.ok(oazapfts.fetchJson(`/credentials${QS.query(QS.explode({
154
129
  pagination,
155
130
  filters,
@@ -157,295 +132,264 @@ function getCredentials({ pagination, filters, } = {}, opts) {
157
132
  ...opts,
158
133
  }));
159
134
  }
160
- exports.getCredentials = getCredentials;
161
135
  /**
162
136
  * Create a credential
163
137
  */
164
- function createCredential(body, opts) {
138
+ export function createCredential(body, opts) {
165
139
  return oazapfts.ok(oazapfts.fetchJson('/credentials', oazapfts.json({
166
140
  ...opts,
167
141
  method: 'POST',
168
142
  body,
169
143
  })));
170
144
  }
171
- exports.createCredential = createCredential;
172
145
  /**
173
146
  * Get a credential
174
147
  */
175
- function getCredentialById(credentialId, opts) {
148
+ export function getCredentialById(credentialId, opts) {
176
149
  return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
177
150
  ...opts,
178
151
  }));
179
152
  }
180
- exports.getCredentialById = getCredentialById;
181
153
  /**
182
154
  * Update a credential
183
155
  */
184
- function updateCredential(credentialId, body, opts) {
156
+ export function updateCredential(credentialId, body, opts) {
185
157
  return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, oazapfts.json({
186
158
  ...opts,
187
159
  method: 'PATCH',
188
160
  body,
189
161
  })));
190
162
  }
191
- exports.updateCredential = updateCredential;
192
163
  /**
193
164
  * Delete a credential
194
165
  */
195
- function deleteCredential(credentialId, opts) {
166
+ export function deleteCredential(credentialId, opts) {
196
167
  return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
197
168
  ...opts,
198
169
  method: 'DELETE',
199
170
  }));
200
171
  }
201
- exports.deleteCredential = deleteCredential;
202
172
  /**
203
173
  * Used by the frontend to send analytics data
204
174
  */
205
- function postTrack(body, opts) {
175
+ export function postTrack(body, opts) {
206
176
  return oazapfts.ok(oazapfts.fetchJson('/track', oazapfts.json({
207
177
  ...opts,
208
178
  method: 'POST',
209
179
  body,
210
180
  })));
211
181
  }
212
- exports.postTrack = postTrack;
213
182
  /**
214
183
  * Encrypt data
215
184
  */
216
- function encryptData(body, opts) {
185
+ export function encryptData(body, opts) {
217
186
  return oazapfts.ok(oazapfts.fetchJson('/encryptions/encrypt', oazapfts.json({
218
187
  ...opts,
219
188
  method: 'POST',
220
189
  body,
221
190
  })));
222
191
  }
223
- exports.encryptData = encryptData;
224
192
  /**
225
193
  * Decrypt data
226
194
  */
227
- function decryptData(body, opts) {
195
+ export function decryptData(body, opts) {
228
196
  return oazapfts.ok(oazapfts.fetchJson('/encryptions/decrypt', oazapfts.json({
229
197
  ...opts,
230
198
  method: 'POST',
231
199
  body,
232
200
  })));
233
201
  }
234
- exports.decryptData = decryptData;
235
202
  /**
236
203
  * Decrypt and encrypt data
237
204
  */
238
- function reencryptData(body, opts) {
205
+ export function reencryptData(body, opts) {
239
206
  return oazapfts.ok(oazapfts.fetchJson('/encryptions/reencrypt', oazapfts.json({
240
207
  ...opts,
241
208
  method: 'POST',
242
209
  body,
243
210
  })));
244
211
  }
245
- exports.reencryptData = reencryptData;
246
212
  /**
247
213
  * Get my profile
248
214
  */
249
- function getProfile(opts) {
215
+ export function getProfile(opts) {
250
216
  return oazapfts.ok(oazapfts.fetchJson('/profile', {
251
217
  ...opts,
252
218
  }));
253
219
  }
254
- exports.getProfile = getProfile;
255
220
  /**
256
221
  * Update my profile
257
222
  */
258
- function updateProfile(body, opts) {
223
+ export function updateProfile(body, opts) {
259
224
  return oazapfts.ok(oazapfts.fetchJson('/profile', oazapfts.json({
260
225
  ...opts,
261
226
  method: 'PATCH',
262
227
  body,
263
228
  })));
264
229
  }
265
- exports.updateProfile = updateProfile;
266
230
  /**
267
231
  * Call an integration's me
268
232
  */
269
- function getProxyMe(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
233
+ export function getProxyMe(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
270
234
  return oazapfts.ok(oazapfts.fetchJson('/proxy/me', {
271
235
  ...opts,
272
- headers: {
273
- ...(opts && opts.headers),
236
+ headers: oazapfts.mergeHeaders(opts?.headers, {
274
237
  'X-Unito-Credential-Id': xUnitoCredentialId,
275
238
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
276
239
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
277
- },
240
+ }),
278
241
  }));
279
242
  }
280
- exports.getProxyMe = getProxyMe;
281
243
  /**
282
244
  * Update a webhook subscription
283
245
  */
284
- function updateWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
246
+ export function updateWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
285
247
  return oazapfts.ok(oazapfts.fetchJson('/proxy/webhooks/subscriptions', oazapfts.json({
286
248
  ...opts,
287
249
  method: 'PUT',
288
250
  body,
289
- headers: {
290
- ...(opts && opts.headers),
251
+ headers: oazapfts.mergeHeaders(opts?.headers, {
291
252
  'X-Unito-Credential-Id': xUnitoCredentialId,
292
253
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
293
254
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
294
- },
255
+ }),
295
256
  })));
296
257
  }
297
- exports.updateWebhookSubscription = updateWebhookSubscription;
298
258
  /**
299
259
  * Call an integration's graph
300
260
  */
301
- function getProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
261
+ export function getProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
302
262
  return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
303
263
  path,
304
264
  }))}`, {
305
265
  ...opts,
306
- headers: {
307
- ...(opts && opts.headers),
266
+ headers: oazapfts.mergeHeaders(opts?.headers, {
308
267
  'X-Unito-Credential-Id': xUnitoCredentialId,
309
268
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
310
269
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
311
- },
270
+ }),
312
271
  }));
313
272
  }
314
- exports.getProxyGraph = getProxyGraph;
315
273
  /**
316
274
  * Call an integration's graph
317
275
  */
318
- function patchProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
276
+ export function patchProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
319
277
  return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
320
278
  path,
321
279
  }))}`, oazapfts.json({
322
280
  ...opts,
323
281
  method: 'PATCH',
324
282
  body,
325
- headers: {
326
- ...(opts && opts.headers),
283
+ headers: oazapfts.mergeHeaders(opts?.headers, {
327
284
  'X-Unito-Credential-Id': xUnitoCredentialId,
328
285
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
329
286
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
330
- },
287
+ }),
331
288
  })));
332
289
  }
333
- exports.patchProxyGraph = patchProxyGraph;
334
290
  /**
335
291
  * Call an integration's graph
336
292
  */
337
- function postProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
293
+ export function postProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
338
294
  return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
339
295
  path,
340
296
  }))}`, oazapfts.json({
341
297
  ...opts,
342
298
  method: 'POST',
343
299
  body,
344
- headers: {
345
- ...(opts && opts.headers),
300
+ headers: oazapfts.mergeHeaders(opts?.headers, {
346
301
  'X-Unito-Credential-Id': xUnitoCredentialId,
347
302
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
348
303
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
349
- },
304
+ }),
350
305
  })));
351
306
  }
352
- exports.postProxyGraph = postProxyGraph;
353
307
  /**
354
308
  * Call an integration's graph
355
309
  */
356
- function deleteProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
310
+ export function deleteProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
357
311
  return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({
358
312
  path,
359
313
  }))}`, {
360
314
  ...opts,
361
315
  method: 'DELETE',
362
- headers: {
363
- ...(opts && opts.headers),
316
+ headers: oazapfts.mergeHeaders(opts?.headers, {
364
317
  'X-Unito-Credential-Id': xUnitoCredentialId,
365
318
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
366
319
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
367
- },
320
+ }),
368
321
  }));
369
322
  }
370
- exports.deleteProxyGraph = deleteProxyGraph;
371
323
  /**
372
324
  * Get all the users
373
325
  */
374
- function getUsers({ pagination, } = {}, opts) {
326
+ export function getUsers({ pagination, } = {}, opts) {
375
327
  return oazapfts.ok(oazapfts.fetchJson(`/users${QS.query(QS.explode({
376
328
  pagination,
377
329
  }))}`, {
378
330
  ...opts,
379
331
  }));
380
332
  }
381
- exports.getUsers = getUsers;
382
333
  /**
383
334
  * Create a user
384
335
  */
385
- function createUser(body, opts) {
336
+ export function createUser(body, opts) {
386
337
  return oazapfts.ok(oazapfts.fetchJson('/users', oazapfts.json({
387
338
  ...opts,
388
339
  method: 'POST',
389
340
  body,
390
341
  })));
391
342
  }
392
- exports.createUser = createUser;
393
343
  /**
394
344
  * Get a user
395
345
  */
396
- function getUserById(userId, opts) {
346
+ export function getUserById(userId, opts) {
397
347
  return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, {
398
348
  ...opts,
399
349
  }));
400
350
  }
401
- exports.getUserById = getUserById;
402
351
  /**
403
352
  * Update a user
404
353
  */
405
- function updateUser(userId, body, opts) {
354
+ export function updateUser(userId, body, opts) {
406
355
  return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, oazapfts.json({
407
356
  ...opts,
408
357
  method: 'PATCH',
409
358
  body,
410
359
  })));
411
360
  }
412
- exports.updateUser = updateUser;
413
361
  /**
414
362
  * Regenerate the api key of a user
415
363
  */
416
- function regenerateApiKey(userId, opts) {
364
+ export function regenerateApiKey(userId, opts) {
417
365
  return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}/apiKey`, {
418
366
  ...opts,
419
367
  method: 'POST',
420
368
  }));
421
369
  }
422
- exports.regenerateApiKey = regenerateApiKey;
423
370
  /**
424
371
  * Get a user by its email address
425
372
  */
426
- function getUserByEmail(email, opts) {
373
+ export function getUserByEmail(email, opts) {
427
374
  return oazapfts.ok(oazapfts.fetchJson(`/users/find/${encodeURIComponent(email)}`, {
428
375
  ...opts,
429
376
  }));
430
377
  }
431
- exports.getUserByEmail = getUserByEmail;
432
378
  /**
433
379
  * Whether the service is ready to serve requests
434
380
  */
435
- function getHealthReady(opts) {
381
+ export function getHealthReady(opts) {
436
382
  return oazapfts.ok(oazapfts.fetchText('/health/ready', {
437
383
  ...opts,
438
384
  }));
439
385
  }
440
- exports.getHealthReady = getHealthReady;
441
386
  /**
442
387
  * Whether the service is responsive
443
388
  */
444
- function getHealthAlive(opts) {
389
+ export function getHealthAlive(opts) {
445
390
  return oazapfts.ok(oazapfts.fetchText('/health/alive', {
446
391
  ...opts,
447
392
  }));
448
393
  }
449
- exports.getHealthAlive = getHealthAlive;
450
- const oazapfts_1 = require("oazapfts");
451
- Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return oazapfts_1.HttpError; } });
394
+ import { HttpError } from './httpError.js';
395
+ export { HttpError };
@@ -0,0 +1,6 @@
1
+ export declare class HttpError extends Error {
2
+ status: number;
3
+ data?: unknown;
4
+ headers: Headers;
5
+ constructor(status: number, data: unknown, headers: Headers);
6
+ }
@@ -0,0 +1,11 @@
1
+ export class HttpError extends Error {
2
+ status;
3
+ data;
4
+ headers;
5
+ constructor(status, data, headers) {
6
+ super(`Error: ${status}`);
7
+ this.status = status;
8
+ this.data = data;
9
+ this.headers = headers;
10
+ }
11
+ }