@unito/integrations-platform-client 0.48.2 → 0.48.4

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.d.ts CHANGED
@@ -66,7 +66,7 @@ export type Error = {
66
66
  stack?: string[];
67
67
  };
68
68
  export type AuthorizationMethod = 'custom' | 'oauth2';
69
- export type AuthorizationGrantType = 'authorization_code' | 'password';
69
+ export type AuthorizationGrantType = 'authorization_code' | 'password' | 'client_credentials';
70
70
  export type AuthorizationScope = {
71
71
  /** The name of the scope. */
72
72
  name: string;
@@ -161,6 +161,16 @@ export type Credential = Base & {
161
161
  /** The partition used to divide data into different buckets. */
162
162
  partitionKey?: string | null;
163
163
  };
164
+ export type CredentialAccount = {
165
+ /** The native id of the provider account. */
166
+ id: string;
167
+ /** The display name of the provider account. */
168
+ displayName: string;
169
+ /** The emails associated with the provider account. */
170
+ emails: string[];
171
+ /** The partition used to divide data into different buckets. */
172
+ partition?: string;
173
+ };
164
174
  export type UserRole = 'unitoAdministrator' | 'unitoService' | 'developer';
165
175
  export type UserSummary = Base & {
166
176
  /** The id of the user. */
@@ -177,16 +187,6 @@ export type User = UserSummary & {
177
187
  /** The API key of the user. */
178
188
  apiKey: string;
179
189
  };
180
- export type CredentialAccount = {
181
- /** The native id of the provider account. */
182
- id: string;
183
- /** The display name of the provider account. */
184
- displayName: string;
185
- /** The emails associated with the provider account. */
186
- emails: string[];
187
- /** The partition used to divide data into different buckets. */
188
- partition?: string;
189
- };
190
190
  /**
191
191
  * Get all the integrations
192
192
  */
@@ -353,12 +353,19 @@ export declare function updateCredential(credentialId: number, body?: {
353
353
  * Delete a credential
354
354
  */
355
355
  export declare function deleteCredential(credentialId: number, opts?: Oazapfts.RequestOpts): Promise<unknown>;
356
+ /**
357
+ * Returns the credentialAccount either from the integration's /me endpoint, if available, or the credential's latestCredentialAccount
358
+ */
359
+ export declare function getCredentialAccount(xUnitoCredentialId: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
360
+ xUnitoCorrelationId?: string;
361
+ xUnitoAdditionalLoggingContext?: string;
362
+ }, opts?: Oazapfts.RequestOpts): Promise<CredentialAccount>;
356
363
  /**
357
364
  * Used by the frontend to send analytics data
358
365
  */
359
366
  export declare function postTrack(body: {
360
367
  jwtToken: string;
361
- event: 'AUTH_START' | 'AUTH_SUBMIT' | 'AUTH_ACTION' | 'AUTH_BLOCKED' | 'AUTH_CHOOSE_CONNECTION_START' | 'AUTH_CHOOSE_CONNECTION_SUBMIT';
368
+ event: 'AUTH_START' | 'AUTH_SUBMIT' | 'AUTH_ACTION' | 'AUTH_BLOCKED' | 'USER_SUCCEEDS_CONNECTION' | 'USER_FAILED_CONNECTION';
362
369
  payload?: {
363
370
  [key: string]: any;
364
371
  };
@@ -493,3 +500,39 @@ export declare function regenerateApiKey(userId: number, opts?: Oazapfts.Request
493
500
  export declare function getUserByEmail(email: string, opts?: Oazapfts.RequestOpts): Promise<User>;
494
501
  import { HttpError } from '@oazapfts/runtime';
495
502
  export { HttpError };
503
+ import * as IntegrationApi from '@unito/integration-api';
504
+ /**
505
+ * Return true if object has the shape of an item, false otherwise.
506
+ * @param object
507
+ */
508
+ export declare function isIntegrationApiItem(object: any): object is IntegrationApi.Item;
509
+ /**
510
+ * Return true if object has the shape of an item, false otherwise.
511
+ * @param object
512
+ */
513
+ export declare function isIntegrationApiItemSummary(object: any): object is IntegrationApi.ItemSummary;
514
+ /**
515
+ * Return true if object has the shape of a collection, false otherwise.
516
+ * @param object
517
+ */
518
+ export declare function isIntegrationApiCollection(object: any): object is IntegrationApi.Collection;
519
+ export declare function getProxyGraphItem(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
520
+ xUnitoCorrelationId?: string;
521
+ xUnitoAdditionalLoggingContext?: string;
522
+ }, opts?: Oazapfts.RequestOpts): Promise<IntegrationApi.Item>;
523
+ export declare function getProxyGraphCollection(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
524
+ xUnitoCorrelationId?: string;
525
+ xUnitoAdditionalLoggingContext?: string;
526
+ }, opts?: Oazapfts.RequestOpts): Promise<IntegrationApi.Collection>;
527
+ export declare function patchProxyGraphItem(xUnitoCredentialId: string, path: string, body?: object, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
528
+ xUnitoCorrelationId?: string;
529
+ xUnitoAdditionalLoggingContext?: string;
530
+ }, opts?: Oazapfts.RequestOpts): Promise<IntegrationApi.Item>;
531
+ export declare function postProxyGraphCollection(xUnitoCredentialId: string, path: string, body?: object, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
532
+ xUnitoCorrelationId?: string;
533
+ xUnitoAdditionalLoggingContext?: string;
534
+ }, opts?: Oazapfts.RequestOpts): Promise<IntegrationApi.ItemSummary>;
535
+ export declare function deleteProxyGraphItem(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
536
+ xUnitoCorrelationId?: string;
537
+ xUnitoAdditionalLoggingContext?: string;
538
+ }, opts?: Oazapfts.RequestOpts): Promise<void>;
package/dist/src/api.js CHANGED
@@ -173,6 +173,19 @@ export function deleteCredential(credentialId, opts) {
173
173
  method: 'DELETE',
174
174
  }));
175
175
  }
176
+ /**
177
+ * Returns the credentialAccount either from the integration's /me endpoint, if available, or the credential's latestCredentialAccount
178
+ */
179
+ export function getCredentialAccount(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
180
+ return oazapfts.ok(oazapfts.fetchJson('/credentialAccount', {
181
+ ...opts,
182
+ headers: oazapfts.mergeHeaders(opts?.headers, {
183
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
184
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
185
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
186
+ }),
187
+ }));
188
+ }
176
189
  /**
177
190
  * Used by the frontend to send analytics data
178
191
  */
@@ -379,5 +392,81 @@ export function getUserByEmail(email, opts) {
379
392
  ...opts,
380
393
  }));
381
394
  }
395
+ // MANUAL ADDONS
382
396
  import { HttpError } from '@oazapfts/runtime';
383
397
  export { HttpError };
398
+ /**
399
+ * Return true if object has the shape of an item, false otherwise.
400
+ * @param object
401
+ */
402
+ export function isIntegrationApiItem(object) {
403
+ return object && typeof object === 'object' && 'fields' in object && 'relations' in object;
404
+ }
405
+ /**
406
+ * Return true if object has the shape of an item, false otherwise.
407
+ * @param object
408
+ */
409
+ export function isIntegrationApiItemSummary(object) {
410
+ return object && typeof object === 'object' && 'path' in object;
411
+ }
412
+ /**
413
+ * Return true if object has the shape of a collection, false otherwise.
414
+ * @param object
415
+ */
416
+ export function isIntegrationApiCollection(object) {
417
+ return object && typeof object === 'object' && 'info' in object && 'data' in object && Array.isArray(object.data);
418
+ }
419
+ export async function getProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
420
+ const response = await getProxyGraph(xUnitoCredentialId, path, {
421
+ xUnitoCorrelationId,
422
+ xUnitoAdditionalLoggingContext,
423
+ }, opts);
424
+ if (isIntegrationApiItem(response)) {
425
+ return response;
426
+ }
427
+ else {
428
+ throw new Error(`Response does not match expected Item shape`);
429
+ }
430
+ }
431
+ export async function getProxyGraphCollection(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
432
+ const response = await getProxyGraph(xUnitoCredentialId, path, {
433
+ xUnitoCorrelationId,
434
+ xUnitoAdditionalLoggingContext,
435
+ }, opts);
436
+ if (isIntegrationApiCollection(response)) {
437
+ return response;
438
+ }
439
+ else {
440
+ throw new Error(`Response does not match expected Collection shape`);
441
+ }
442
+ }
443
+ export async function patchProxyGraphItem(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
444
+ const response = await patchProxyGraph(xUnitoCredentialId, path, body, {
445
+ xUnitoCorrelationId,
446
+ xUnitoAdditionalLoggingContext,
447
+ }, opts);
448
+ if (isIntegrationApiItem(response)) {
449
+ return response;
450
+ }
451
+ else {
452
+ throw new Error(`Response does not match expected Item shape`);
453
+ }
454
+ }
455
+ export async function postProxyGraphCollection(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
456
+ const response = await postProxyGraph(xUnitoCredentialId, path, body, {
457
+ xUnitoCorrelationId,
458
+ xUnitoAdditionalLoggingContext,
459
+ }, opts);
460
+ if (isIntegrationApiItemSummary(response)) {
461
+ return response;
462
+ }
463
+ else {
464
+ throw new Error(`Response does not match expected ItemSummary shape`);
465
+ }
466
+ }
467
+ export async function deleteProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
468
+ await deleteProxyGraph(xUnitoCredentialId, path, {
469
+ xUnitoCorrelationId,
470
+ xUnitoAdditionalLoggingContext,
471
+ }, opts);
472
+ }
@@ -196,6 +196,19 @@ function deleteCredential(credentialId, opts) {
196
196
  method: 'DELETE',
197
197
  }));
198
198
  }
199
+ /**
200
+ * Returns the credentialAccount either from the integration's /me endpoint, if available, or the credential's latestCredentialAccount
201
+ */
202
+ function getCredentialAccount(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
203
+ return oazapfts.ok(oazapfts.fetchJson('/credentialAccount', {
204
+ ...opts,
205
+ headers: oazapfts.mergeHeaders(opts?.headers, {
206
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
207
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
208
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
209
+ }),
210
+ }));
211
+ }
199
212
  /**
200
213
  * Used by the frontend to send analytics data
201
214
  */
@@ -402,6 +415,81 @@ function getUserByEmail(email, opts) {
402
415
  ...opts,
403
416
  }));
404
417
  }
418
+ /**
419
+ * Return true if object has the shape of an item, false otherwise.
420
+ * @param object
421
+ */
422
+ function isIntegrationApiItem(object) {
423
+ return object && typeof object === 'object' && 'fields' in object && 'relations' in object;
424
+ }
425
+ /**
426
+ * Return true if object has the shape of an item, false otherwise.
427
+ * @param object
428
+ */
429
+ function isIntegrationApiItemSummary(object) {
430
+ return object && typeof object === 'object' && 'path' in object;
431
+ }
432
+ /**
433
+ * Return true if object has the shape of a collection, false otherwise.
434
+ * @param object
435
+ */
436
+ function isIntegrationApiCollection(object) {
437
+ return object && typeof object === 'object' && 'info' in object && 'data' in object && Array.isArray(object.data);
438
+ }
439
+ async function getProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
440
+ const response = await getProxyGraph(xUnitoCredentialId, path, {
441
+ xUnitoCorrelationId,
442
+ xUnitoAdditionalLoggingContext,
443
+ }, opts);
444
+ if (isIntegrationApiItem(response)) {
445
+ return response;
446
+ }
447
+ else {
448
+ throw new Error(`Response does not match expected Item shape`);
449
+ }
450
+ }
451
+ async function getProxyGraphCollection(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
452
+ const response = await getProxyGraph(xUnitoCredentialId, path, {
453
+ xUnitoCorrelationId,
454
+ xUnitoAdditionalLoggingContext,
455
+ }, opts);
456
+ if (isIntegrationApiCollection(response)) {
457
+ return response;
458
+ }
459
+ else {
460
+ throw new Error(`Response does not match expected Collection shape`);
461
+ }
462
+ }
463
+ async function patchProxyGraphItem(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
464
+ const response = await patchProxyGraph(xUnitoCredentialId, path, body, {
465
+ xUnitoCorrelationId,
466
+ xUnitoAdditionalLoggingContext,
467
+ }, opts);
468
+ if (isIntegrationApiItem(response)) {
469
+ return response;
470
+ }
471
+ else {
472
+ throw new Error(`Response does not match expected Item shape`);
473
+ }
474
+ }
475
+ async function postProxyGraphCollection(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
476
+ const response = await postProxyGraph(xUnitoCredentialId, path, body, {
477
+ xUnitoCorrelationId,
478
+ xUnitoAdditionalLoggingContext,
479
+ }, opts);
480
+ if (isIntegrationApiItemSummary(response)) {
481
+ return response;
482
+ }
483
+ else {
484
+ throw new Error(`Response does not match expected ItemSummary shape`);
485
+ }
486
+ }
487
+ async function deleteProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
488
+ await deleteProxyGraph(xUnitoCredentialId, path, {
489
+ xUnitoCorrelationId,
490
+ xUnitoAdditionalLoggingContext,
491
+ }, opts);
492
+ }
405
493
 
406
494
  var api = {
407
495
  __proto__: null,
@@ -414,7 +502,9 @@ var api = {
414
502
  deleteCredential: deleteCredential,
415
503
  deleteIntegration: deleteIntegration,
416
504
  deleteProxyGraph: deleteProxyGraph,
505
+ deleteProxyGraphItem: deleteProxyGraphItem,
417
506
  encryptData: encryptData,
507
+ getCredentialAccount: getCredentialAccount,
418
508
  getCredentialById: getCredentialById,
419
509
  getCredentials: getCredentials,
420
510
  getIntegrationById: getIntegrationById,
@@ -424,14 +514,21 @@ var api = {
424
514
  getIntegrations: getIntegrations,
425
515
  getProfile: getProfile,
426
516
  getProxyGraph: getProxyGraph,
517
+ getProxyGraphCollection: getProxyGraphCollection,
518
+ getProxyGraphItem: getProxyGraphItem,
427
519
  getProxyMe: getProxyMe,
428
520
  getUserByEmail: getUserByEmail,
429
521
  getUserById: getUserById,
430
522
  getUsers: getUsers,
431
523
  inviteOrganization: inviteOrganization,
432
524
  inviteUser: inviteUser,
525
+ isIntegrationApiCollection: isIntegrationApiCollection,
526
+ isIntegrationApiItem: isIntegrationApiItem,
527
+ isIntegrationApiItemSummary: isIntegrationApiItemSummary,
433
528
  patchProxyGraph: patchProxyGraph,
529
+ patchProxyGraphItem: patchProxyGraphItem,
434
530
  postProxyGraph: postProxyGraph,
531
+ postProxyGraphCollection: postProxyGraphCollection,
435
532
  postTrack: postTrack,
436
533
  publishIntegration: publishIntegration,
437
534
  reencryptData: reencryptData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integrations-platform-client",
3
- "version": "0.48.2",
3
+ "version": "0.48.4",
4
4
  "description": "The Unito Integrations Platform Client",
5
5
  "type": "module",
6
6
  "types": "./dist/src/index.d.ts",
@@ -48,6 +48,7 @@
48
48
  "typescript": "5.x"
49
49
  },
50
50
  "dependencies": {
51
- "@oazapfts/runtime": "1.x"
51
+ "@oazapfts/runtime": "1.x",
52
+ "@unito/integration-api": "0.x"
52
53
  }
53
54
  }