@unito/integration-cli
Version:
Integration CLI
536 lines (535 loc) • 19.2 kB
TypeScript
/**
* Integrations Platform API
* 0.1.0
* DO NOT MODIFY - This file has been generated using oazapfts.
* See https://www.npmjs.com/package/oazapfts
*/
import * as Oazapfts from '@oazapfts/runtime';
export declare const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders>;
export declare const servers: {
local: string;
staging: string;
production: string;
};
export type Pagination = {
/** The total number of results. */
total: number;
};
export type Base = {
createdAt: string;
updatedAt: string;
archivedAt: string | null;
};
export type IntegrationSummary = Base & {
/** The id of the integration. */
id: number;
/** The name of the integration. */
name: string;
/** The base URL where the integration is located. */
baseUrl: string | null;
/** The relative URL (to the baseUrl) where the graph of items of the integration is located. */
graphRelativeUrl: string;
/** The relative URL (to the baseUrl) to fetch the current integration's authenticated user. */
credentialAccountRelativeUrl: string;
/** The relative URL (to the baseUrl) to parse a webhook payload. */
webhookParsingRelativeUrl?: string | null;
/** The relative URL (to the baseUrl) to operate on webhook subscriptions. */
webhookSubscriptionsRelativeUrl?: string | null;
/** The relative URL (to the baseUrl) to acknowledge a webhook reception. */
webhookAcknowledgeRelativeUrl?: string | null;
/** The visibility of the integration. */
visibility: 'private' | 'public';
/** The list of organization ids for which this integration is visibile. */
unitoOrganizationIds: string[];
/** The UI-related information of the integration. */
ui: {
/** The name of the integration, as it should be displayed in a UI. */
displayName: string;
/** The logo of the integration, in SVG format. */
logo: string | null;
};
/** The encrypted secrets of the integration. */
secrets?: {
[key: string]: string;
};
/** The date at which the integration has been disabled */
disabledAt?: string | null;
};
export type Error = {
/** The message of the error. */
message: string;
/** The details of the error. */
details?: {
[key: string]: any;
};
/** The stack trace of the error. */
stack?: string[];
};
export type AuthorizationMethod = 'custom' | 'oauth2';
export type AuthorizationGrantType = 'authorization_code' | 'password' | 'client_credentials' | 'urn:ietf:params:oauth:grant-type:jwt-bearer';
export type AuthorizationScope = {
/** The name of the scope. */
name: string;
/** Message to the end-user to explain the usage of the scope by Unito. */
help?: string;
};
export type AuthorizationOAuth2ContentType = 'application/x-www-form-urlencoded' | 'application/json';
export type AuthorizationOAuth2RequestParameters = {
/** Extra information to include in the HTTP request headers. */
header?: {
[key: string]: string | number | boolean;
};
/** Extra information to include in the HTTP request body. */
body?: {
[key: string]: string | number | boolean;
};
};
export type AuthorizationOAuth2 = {
/** The Client Secret obtained from the provider. */
clientSecret?: string;
/** The Client Id obtained from the provider. */
clientId?: string;
/** The URL to grant or deny access to the user account. */
authorizationUrl?: string;
/** The URL to obtain or refresh an access token. */
tokenUrl: string;
/** The callback URL which the provider will redirect the user after granting or denying access. */
legacyRedirectUrl?: string;
grantType: AuthorizationGrantType;
scopes: AuthorizationScope[];
requestContentType: AuthorizationOAuth2ContentType;
responseContentType: AuthorizationOAuth2ContentType;
refreshRequestParameters?: AuthorizationOAuth2RequestParameters;
tokenRequestParameters?: AuthorizationOAuth2RequestParameters;
} | null;
export type AuthorizationVariables = {
[key: string]: {
type: 'boolean' | 'number' | 'password' | 'string' | 'text';
format?: 'uri' | 'email';
pattern?: string;
label?: string;
required?: boolean;
placeholder?: string;
defaultValue?: string | number | boolean;
help?: string;
documentationUrl?: string;
};
};
export type Authorization = Base & {
id: number;
integrationId: number;
name: string;
method: AuthorizationMethod;
oauth2: AuthorizationOAuth2;
variables: AuthorizationVariables;
/** The Base64-encoded data URL of an <img> src content. For example: 'data:image/png;base64,<base64>' */
instructionsImage?: string | null;
/** A string representing a markdown document. */
instructionsMarkdown?: string | null;
};
export type Integration = IntegrationSummary & {
/** The authorizations of the integration. */
authorizations: Authorization[];
/** The ids of the developers of the integration. */
userIds: number[];
};
export type IntegrationEvent = {
/** The date at which the event took place. */
date: string;
/** The text of the event. */
text: string;
/** The tags associated with the event. */
tags: string[];
/** The title of the event. */
title: string;
};
export type Credential = Base & {
/** The id of the credential. */
id: string;
/** The id of the integration. */
integrationId: number;
/** The name of the integration. */
integrationName: string;
/** The display name of the integration. */
integrationDisplayName?: string;
/** The id of the authorization. */
authorizationId: number;
/** The scope of the credential. */
scope: 'development' | 'compliance' | 'production' | 'service';
/** The id of the Unito User for which this credential belongs to. */
unitoUserId: string | null;
/** The id of the credential account. */
credentialAccountId?: string | null;
/** The last time we tried to obtain the latest credential account. */
lastCredentialAccountAccessAt?: string | null;
/** The first time obtaining the latest credential account failed. */
firstFailedCredentialAccountAccessAt?: string | null;
/** The last time the credential was refreshed. */
lastRefreshedAt?: string | null;
/** The payload of the credential, which conforms to the schema (ex. variables) of the authorization. */
payload: {
[key: string]: any;
};
/** The partition used to divide data into different buckets. */
partitionKey?: string | null;
};
export type CredentialAccount = {
/** The native id of the provider account. */
id: string;
/** The display name of the provider account. */
displayName: string;
/** The emails associated with the provider account. */
emails: string[];
/** The partition used to divide data into different buckets. */
partition?: string;
};
export type UserRole = 'unitoAdministrator' | 'unitoService' | 'developer';
export type UserSummary = Base & {
/** The id of the user. */
id: number;
/** The email of the user. */
email: string;
/** The ID of the organization which will have access to integrations created by this user. */
defaultUnitoOrganizationId: string | null;
/** The date & time at which the user accepted the terms & conditions of the SDK. */
termsAcceptedAt: string | null;
role: UserRole;
};
export type User = UserSummary & {
/** The API key of the user. */
apiKey: string;
};
/**
* Get all the integrations
*/
export declare function getIntegrations({ pagination, unitoOrganizationId, search, }?: {
pagination?: {
/** Number of 'first results' to skip */
offset?: number;
/** Maximum number of results after the offset */
limit?: number;
};
unitoOrganizationId?: string;
search?: string;
}, opts?: Oazapfts.RequestOpts): Promise<Pagination & {
/** The integrations. */
data: IntegrationSummary[];
}>;
/**
* Create an integration
*/
export declare function createIntegration(body?: {
name: string;
baseUrl?: string | null;
graphRelativeUrl?: string | null;
credentialAccountRelativeUrl?: string | null;
webhookParsingRelativeUrl?: string | null;
webhookSubscriptionsRelativeUrl?: string | null;
webhookAcknowledgeRelativeUrl?: string | null;
}, opts?: Oazapfts.RequestOpts): Promise<Integration>;
/**
* Publish an integration
*/
export declare function publishIntegration(body?: {
/** The archive of the integration, including the .unito.json file. */
file?: Blob;
}, opts?: Oazapfts.RequestOpts): Promise<Integration>;
/**
* Find an integration by exact name
*/
export declare function getIntegrationByName(integrationName: string, opts?: Oazapfts.RequestOpts): Promise<Integration>;
/**
* Invite a user to an integration
*/
export declare function inviteUser(integrationId: number, body?: {
email?: string;
}, opts?: Oazapfts.RequestOpts): Promise<unknown>;
/**
* Invite a unito organization to an integration
*/
export declare function inviteOrganization(integrationId: number, body?: {
unitoOrganizationId?: string;
}, opts?: Oazapfts.RequestOpts): Promise<Integration>;
/**
* Get an integration
*/
export declare function getIntegrationById(integrationId: number, opts?: Oazapfts.RequestOpts): Promise<Integration>;
/**
* Update an integration
*/
export declare function updateIntegration(integrationId: number, body?: {
baseUrl?: string | null;
graphRelativeUrl?: string | null;
credentialAccountRelativeUrl?: string | null;
webhookParsingRelativeUrl?: string | null;
webhookSubscriptionsRelativeUrl?: string | null;
webhookAcknowledgeRelativeUrl?: string | null;
authorizations?: {
id?: number;
name: string;
method: AuthorizationMethod;
oauth2?: AuthorizationOAuth2;
variables?: AuthorizationVariables;
archived?: boolean;
}[];
userIds?: number[];
archived?: boolean;
disabled?: boolean;
ui?: {
displayName?: string | null;
logo?: string | null;
};
visibility?: 'private' | 'public';
unitoOrganizationIds?: string[];
/** The encrypted secrets of the integration. */
secrets?: {
[key: string]: string;
};
}, opts?: Oazapfts.RequestOpts): Promise<Integration>;
/**
* Delete an integration
*/
export declare function deleteIntegration(integrationId: number, name: string, opts?: Oazapfts.RequestOpts): Promise<unknown>;
/**
* Get the events associated with this integration.
*/
export declare function getIntegrationEvents(integrationId: number, { search, $from, limit, }?: {
search?: string;
$from?: number;
limit?: number;
}, opts?: Oazapfts.RequestOpts): Promise<Pagination & {
/** The integration events. */
data: IntegrationEvent[];
}>;
/**
* Get the logo of the integration, in SVG format.
*/
export declare function getIntegrationLogo(integrationName: string, opts?: Oazapfts.RequestOpts): Promise<Blob>;
/**
* Get all the credentials
*/
export declare function getCredentials({ pagination, filters, }?: {
pagination?: {
/** Number of 'first results' to skip */
offset?: number;
/** Maximum number of results after the offset */
limit?: number;
};
filters?: {
/** The authorization id of the credential. */
authorizationId?: number;
/** The integration id of the credential. */
integrationId?: number;
/** List of credential ids. */
id?: string[];
/** The scope of the credential. */
credentialScope?: 'development' | 'compliance' | 'production' | 'service';
/** The id of the Unito User for which this credential belongs to. */
unitoUserId?: string;
/** The id of the credential account for which this credential belongs to. */
credentialAccountId?: string;
/** The last access to the credential account occured before the provided date. */
lastCredentialAccountAccessAtBefore?: string;
/** The first failure to access the credential account occured after the provided date. */
firstFailedCredentialAccountAccessAtAfter?: string;
};
}, opts?: Oazapfts.RequestOpts): Promise<Pagination & {
/** The credentials. */
data: Credential[];
}>;
/**
* Create a credential
*/
export declare function createCredential(body?: {
authorizationId: number;
scope?: 'development' | 'compliance' | 'production' | 'service';
payload: {
[key: string]: any;
};
unitoUserId?: string;
credentialAccountId?: string;
}, opts?: Oazapfts.RequestOpts): Promise<Credential>;
/**
* Get a credential
*/
export declare function getCredentialById(credentialId: string, opts?: Oazapfts.RequestOpts): Promise<Credential>;
/**
* Update a credential
*/
export declare function updateCredential(credentialId: string, body?: {
payload?: {
[key: string]: any;
};
scope?: 'development' | 'compliance' | 'production' | 'service';
archived?: boolean;
unitoUserId?: string;
credentialAccountId?: string;
}, opts?: Oazapfts.RequestOpts): Promise<Credential>;
/**
* Delete a credential
*/
export declare function deleteCredential(credentialId: string, opts?: Oazapfts.RequestOpts): Promise<unknown>;
/**
* Returns the credentialAccount either from the integration's /me endpoint, if available, or the credential's latestCredentialAccount
*/
export declare function getCredentialAccount(xUnitoCredentialId: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
}, opts?: Oazapfts.RequestOpts): Promise<CredentialAccount>;
/**
* Used by the frontend to send analytics data
*/
export declare function postTrack(body: {
jwtToken: string;
event: 'AUTH_START' | 'AUTH_SUBMIT' | 'AUTH_ACTION' | 'AUTH_BLOCKED' | 'USER_SUCCEEDS_CONNECTION' | 'USER_FAILED_CONNECTION' | 'AUTH_CHOOSE_CONNECTION_SUBMIT';
payload?: {
[key: string]: any;
};
}, opts?: Oazapfts.RequestOpts): Promise<unknown>;
/**
* Encrypt data
*/
export declare function encryptData(body: {
data: string;
integrationName: string;
sensitive?: boolean;
}, opts?: Oazapfts.RequestOpts): Promise<{
encryptedData: string;
}>;
/**
* Decrypt data
*/
export declare function decryptData(body: {
data: string;
integrationName: string;
}, opts?: Oazapfts.RequestOpts): Promise<{
decryptedData: string;
}>;
/**
* Decrypt and encrypt data
*/
export declare function reencryptData(body: {
encryptedData: string;
integrationName: string;
newIntegrationName: string;
}, opts?: Oazapfts.RequestOpts): Promise<{
encryptedData: string;
}>;
/**
* Get my profile
*/
export declare function getProfile(opts?: Oazapfts.RequestOpts): Promise<User>;
/**
* Update my profile
*/
export declare function updateProfile(body?: {
termsAccepted?: boolean;
}, opts?: Oazapfts.RequestOpts): Promise<User>;
/**
* Call an integration's me
*/
export declare function getProxyMe(xUnitoCredentialId: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
}, opts?: Oazapfts.RequestOpts): Promise<CredentialAccount>;
/**
* Update a webhook subscription
*/
export declare function updateWebhookSubscription(xUnitoCredentialId: string, body: {
itemPath: string;
targetUrl: string;
action: 'start' | 'stop';
}, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
}, opts?: Oazapfts.RequestOpts): Promise<unknown>;
/**
* Call an integration's graph
*/
export declare function getProxyGraph(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, accept, xUnitoOperationDeadline, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
accept?: string;
xUnitoOperationDeadline?: string;
}, opts?: Oazapfts.RequestOpts): Promise<any>;
/**
* Call an integration's graph
*/
export declare function patchProxyGraph(xUnitoCredentialId: string, path: string, body?: object, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, contentType, xUnitoOperationDeadline, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
contentType?: string;
xUnitoOperationDeadline?: string;
}, opts?: Oazapfts.RequestOpts): Promise<any>;
/**
* Call an integration's graph
*/
export declare function postProxyGraph(xUnitoCredentialId: string, path: string, body?: object, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, contentType, xUnitoOperationDeadline, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
contentType?: string;
xUnitoOperationDeadline?: string;
}, opts?: Oazapfts.RequestOpts): Promise<any>;
/**
* Call an integration's graph
*/
export declare function deleteProxyGraph(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, xUnitoOperationDeadline, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
xUnitoOperationDeadline?: string;
}, opts?: Oazapfts.RequestOpts): Promise<any>;
/**
* Call an integration's graph with multipart/form-data
*/
export declare function postProxyGraphMultipart(xUnitoCredentialId: string, path: string, body?: {
[key: string]: any;
}, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, xUnitoOperationDeadline, }?: {
xUnitoCorrelationId?: string;
xUnitoAdditionalLoggingContext?: string;
xUnitoOperationDeadline?: string;
}, opts?: Oazapfts.RequestOpts): Promise<any>;
/**
* Get all the users
*/
export declare function getUsers({ pagination, }?: {
pagination?: {
/** Number of 'first results' to skip */
offset?: number;
/** Maximum number of results after the offset */
limit?: number;
};
}, opts?: Oazapfts.RequestOpts): Promise<Pagination & {
/** The users. */
data: UserSummary[];
}>;
/**
* Create a user
*/
export declare function createUser(body: {
email: string;
defaultUnitoOrganizationId?: string | null;
role: UserRole;
}, opts?: Oazapfts.RequestOpts): Promise<User>;
/**
* Get a user
*/
export declare function getUserById(userId: number, opts?: Oazapfts.RequestOpts): Promise<User>;
/**
* Update a user
*/
export declare function updateUser(userId: number, body: {
email?: string;
role?: UserRole;
archived?: boolean;
defaultUnitoOrganizationId?: string | null;
}, opts?: Oazapfts.RequestOpts): Promise<User>;
/**
* Regenerate the api key of a user
*/
export declare function regenerateApiKey(userId: number, opts?: Oazapfts.RequestOpts): Promise<User>;
/**
* Get a user by its email address
*/
export declare function getUserByEmail(email: string, opts?: Oazapfts.RequestOpts): Promise<User>;
import { HttpError } from '@oazapfts/runtime';
export { HttpError };