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