@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.
@@ -0,0 +1,473 @@
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, opts) {
147
+ return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/events`, {
148
+ ...opts,
149
+ }));
150
+ }
151
+ /**
152
+ * Get the logo of the integration, in SVG format.
153
+ */
154
+ function getIntegrationLogo(integrationName, opts) {
155
+ return oazapfts.ok(oazapfts.fetchJson(`/public/${encodeURIComponent(integrationName)}/logo.svg`, {
156
+ ...opts,
157
+ }));
158
+ }
159
+ /**
160
+ * Get all the credentials
161
+ */
162
+ function getCredentials({ pagination, filters, } = {}, opts) {
163
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials${QS__namespace.query(QS__namespace.explode({
164
+ pagination,
165
+ filters,
166
+ }))}`, {
167
+ ...opts,
168
+ }));
169
+ }
170
+ /**
171
+ * Create a credential
172
+ */
173
+ function createCredential(body, opts) {
174
+ return oazapfts.ok(oazapfts.fetchJson('/credentials', oazapfts.json({
175
+ ...opts,
176
+ method: 'POST',
177
+ body,
178
+ })));
179
+ }
180
+ /**
181
+ * Get a credential
182
+ */
183
+ function getCredentialById(credentialId, opts) {
184
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
185
+ ...opts,
186
+ }));
187
+ }
188
+ /**
189
+ * Update a credential
190
+ */
191
+ function updateCredential(credentialId, body, opts) {
192
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, oazapfts.json({
193
+ ...opts,
194
+ method: 'PATCH',
195
+ body,
196
+ })));
197
+ }
198
+ /**
199
+ * Delete a credential
200
+ */
201
+ function deleteCredential(credentialId, opts) {
202
+ return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
203
+ ...opts,
204
+ method: 'DELETE',
205
+ }));
206
+ }
207
+ /**
208
+ * Used by the frontend to send analytics data
209
+ */
210
+ function postTrack(body, opts) {
211
+ return oazapfts.ok(oazapfts.fetchJson('/track', oazapfts.json({
212
+ ...opts,
213
+ method: 'POST',
214
+ body,
215
+ })));
216
+ }
217
+ /**
218
+ * Encrypt data
219
+ */
220
+ function encryptData(body, opts) {
221
+ return oazapfts.ok(oazapfts.fetchJson('/encryptions/encrypt', oazapfts.json({
222
+ ...opts,
223
+ method: 'POST',
224
+ body,
225
+ })));
226
+ }
227
+ /**
228
+ * Decrypt data
229
+ */
230
+ function decryptData(body, opts) {
231
+ return oazapfts.ok(oazapfts.fetchJson('/encryptions/decrypt', oazapfts.json({
232
+ ...opts,
233
+ method: 'POST',
234
+ body,
235
+ })));
236
+ }
237
+ /**
238
+ * Decrypt and encrypt data
239
+ */
240
+ function reencryptData(body, opts) {
241
+ return oazapfts.ok(oazapfts.fetchJson('/encryptions/reencrypt', oazapfts.json({
242
+ ...opts,
243
+ method: 'POST',
244
+ body,
245
+ })));
246
+ }
247
+ /**
248
+ * Get my profile
249
+ */
250
+ function getProfile(opts) {
251
+ return oazapfts.ok(oazapfts.fetchJson('/profile', {
252
+ ...opts,
253
+ }));
254
+ }
255
+ /**
256
+ * Update my profile
257
+ */
258
+ function updateProfile(body, opts) {
259
+ return oazapfts.ok(oazapfts.fetchJson('/profile', oazapfts.json({
260
+ ...opts,
261
+ method: 'PATCH',
262
+ body,
263
+ })));
264
+ }
265
+ /**
266
+ * Call an integration's me
267
+ */
268
+ function getProxyMe(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
269
+ return oazapfts.ok(oazapfts.fetchJson('/proxy/me', {
270
+ ...opts,
271
+ headers: oazapfts.mergeHeaders(opts?.headers, {
272
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
273
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
274
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
275
+ }),
276
+ }));
277
+ }
278
+ /**
279
+ * Update a webhook subscription
280
+ */
281
+ function updateWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
282
+ return oazapfts.ok(oazapfts.fetchJson('/proxy/webhooks/subscriptions', oazapfts.json({
283
+ ...opts,
284
+ method: 'PUT',
285
+ body,
286
+ headers: oazapfts.mergeHeaders(opts?.headers, {
287
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
288
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
289
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
290
+ }),
291
+ })));
292
+ }
293
+ /**
294
+ * Call an integration's graph
295
+ */
296
+ function getProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
297
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
298
+ path,
299
+ }))}`, {
300
+ ...opts,
301
+ headers: oazapfts.mergeHeaders(opts?.headers, {
302
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
303
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
304
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
305
+ }),
306
+ }));
307
+ }
308
+ /**
309
+ * Call an integration's graph
310
+ */
311
+ function patchProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
312
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
313
+ path,
314
+ }))}`, oazapfts.json({
315
+ ...opts,
316
+ method: 'PATCH',
317
+ body,
318
+ headers: oazapfts.mergeHeaders(opts?.headers, {
319
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
320
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
321
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
322
+ }),
323
+ })));
324
+ }
325
+ /**
326
+ * Call an integration's graph
327
+ */
328
+ function postProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
329
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
330
+ path,
331
+ }))}`, oazapfts.json({
332
+ ...opts,
333
+ method: 'POST',
334
+ body,
335
+ headers: oazapfts.mergeHeaders(opts?.headers, {
336
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
337
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
338
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
339
+ }),
340
+ })));
341
+ }
342
+ /**
343
+ * Call an integration's graph
344
+ */
345
+ function deleteProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
346
+ return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
347
+ path,
348
+ }))}`, {
349
+ ...opts,
350
+ method: 'DELETE',
351
+ headers: oazapfts.mergeHeaders(opts?.headers, {
352
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
353
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
354
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
355
+ }),
356
+ }));
357
+ }
358
+ /**
359
+ * Get all the users
360
+ */
361
+ function getUsers({ pagination, } = {}, opts) {
362
+ return oazapfts.ok(oazapfts.fetchJson(`/users${QS__namespace.query(QS__namespace.explode({
363
+ pagination,
364
+ }))}`, {
365
+ ...opts,
366
+ }));
367
+ }
368
+ /**
369
+ * Create a user
370
+ */
371
+ function createUser(body, opts) {
372
+ return oazapfts.ok(oazapfts.fetchJson('/users', oazapfts.json({
373
+ ...opts,
374
+ method: 'POST',
375
+ body,
376
+ })));
377
+ }
378
+ /**
379
+ * Get a user
380
+ */
381
+ function getUserById(userId, opts) {
382
+ return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, {
383
+ ...opts,
384
+ }));
385
+ }
386
+ /**
387
+ * Update a user
388
+ */
389
+ function updateUser(userId, body, opts) {
390
+ return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, oazapfts.json({
391
+ ...opts,
392
+ method: 'PATCH',
393
+ body,
394
+ })));
395
+ }
396
+ /**
397
+ * Regenerate the api key of a user
398
+ */
399
+ function regenerateApiKey(userId, opts) {
400
+ return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}/apiKey`, {
401
+ ...opts,
402
+ method: 'POST',
403
+ }));
404
+ }
405
+ /**
406
+ * Get a user by its email address
407
+ */
408
+ function getUserByEmail(email, opts) {
409
+ return oazapfts.ok(oazapfts.fetchJson(`/users/find/${encodeURIComponent(email)}`, {
410
+ ...opts,
411
+ }));
412
+ }
413
+ /**
414
+ * Whether the service is ready to serve requests
415
+ */
416
+ function getHealthReady(opts) {
417
+ return oazapfts.ok(oazapfts.fetchText('/health/ready', {
418
+ ...opts,
419
+ }));
420
+ }
421
+ /**
422
+ * Whether the service is responsive
423
+ */
424
+ function getHealthAlive(opts) {
425
+ return oazapfts.ok(oazapfts.fetchText('/health/alive', {
426
+ ...opts,
427
+ }));
428
+ }
429
+
430
+ var api = /*#__PURE__*/Object.freeze({
431
+ __proto__: null,
432
+ HttpError: HttpError,
433
+ createCredential: createCredential,
434
+ createIntegration: createIntegration,
435
+ createUser: createUser,
436
+ decryptData: decryptData,
437
+ defaults: defaults,
438
+ deleteCredential: deleteCredential,
439
+ deleteIntegration: deleteIntegration,
440
+ deleteProxyGraph: deleteProxyGraph,
441
+ encryptData: encryptData,
442
+ getCredentialById: getCredentialById,
443
+ getCredentials: getCredentials,
444
+ getHealthAlive: getHealthAlive,
445
+ getHealthReady: getHealthReady,
446
+ getIntegrationById: getIntegrationById,
447
+ getIntegrationByName: getIntegrationByName,
448
+ getIntegrationEvents: getIntegrationEvents,
449
+ getIntegrationLogo: getIntegrationLogo,
450
+ getIntegrations: getIntegrations,
451
+ getProfile: getProfile,
452
+ getProxyGraph: getProxyGraph,
453
+ getProxyMe: getProxyMe,
454
+ getUserByEmail: getUserByEmail,
455
+ getUserById: getUserById,
456
+ getUsers: getUsers,
457
+ inviteOrganization: inviteOrganization,
458
+ inviteUser: inviteUser,
459
+ patchProxyGraph: patchProxyGraph,
460
+ postProxyGraph: postProxyGraph,
461
+ postTrack: postTrack,
462
+ publishIntegration: publishIntegration,
463
+ reencryptData: reencryptData,
464
+ regenerateApiKey: regenerateApiKey,
465
+ servers: servers,
466
+ updateCredential: updateCredential,
467
+ updateIntegration: updateIntegration,
468
+ updateProfile: updateProfile,
469
+ updateUser: updateUser,
470
+ updateWebhookSubscription: updateWebhookSubscription
471
+ });
472
+
473
+ 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.3",
3
+ "version": "0.45.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,10 +22,11 @@
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",
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",
18
30
  "ci:test": "nyc npm run test"
19
31
  },
20
32
  "author": {
@@ -22,31 +34,22 @@
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",
39
44
  "eslint": "8.x",
40
- "mocha": "10.x",
41
45
  "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
  }