UNPKG

@unito/integration-cli

Version:

Integration CLI

462 lines (461 loc) 14.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpError = exports.servers = exports.defaults = void 0; exports.getIntegrations = getIntegrations; exports.createIntegration = createIntegration; exports.publishIntegration = publishIntegration; exports.getIntegrationByName = getIntegrationByName; exports.inviteUser = inviteUser; exports.inviteOrganization = inviteOrganization; exports.getIntegrationById = getIntegrationById; exports.updateIntegration = updateIntegration; exports.deleteIntegration = deleteIntegration; exports.getIntegrationEvents = getIntegrationEvents; exports.getIntegrationLogo = getIntegrationLogo; exports.getCredentials = getCredentials; exports.createCredential = createCredential; exports.getCredentialById = getCredentialById; exports.updateCredential = updateCredential; exports.deleteCredential = deleteCredential; exports.getCredentialAccount = getCredentialAccount; exports.postTrack = postTrack; exports.encryptData = encryptData; exports.decryptData = decryptData; exports.reencryptData = reencryptData; exports.getProfile = getProfile; exports.updateProfile = updateProfile; exports.getProxyMe = getProxyMe; exports.updateWebhookSubscription = updateWebhookSubscription; exports.getProxyGraph = getProxyGraph; exports.patchProxyGraph = patchProxyGraph; exports.postProxyGraph = postProxyGraph; exports.deleteProxyGraph = deleteProxyGraph; exports.postProxyGraphMultipart = postProxyGraphMultipart; exports.getUsers = getUsers; exports.createUser = createUser; exports.getUserById = getUserById; exports.updateUser = updateUser; exports.regenerateApiKey = regenerateApiKey; exports.getUserByEmail = getUserByEmail; const tslib_1 = require("tslib"); /** * Integrations Platform API * 0.1.0 * DO NOT MODIFY - This file has been generated using oazapfts. * See https://www.npmjs.com/package/oazapfts */ const Oazapfts = tslib_1.__importStar(require("@oazapfts/runtime")); const QS = tslib_1.__importStar(require("@oazapfts/runtime/query")); exports.defaults = { headers: {}, baseUrl: 'http://localhost:9000', }; const oazapfts = Oazapfts.runtime(exports.defaults); exports.servers = { local: 'http://localhost:9000', staging: 'https://staging-integrations-platform.unito.io', production: 'https://integrations-platform.unito.io', }; /** * Get all the integrations */ function getIntegrations({ pagination, unitoOrganizationId, search, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations${QS.query(QS.explode({ pagination, unitoOrganizationId, search, }))}`, { ...opts, })); } /** * Create an integration */ function createIntegration(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/integrations', oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Publish an integration */ function publishIntegration(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/integrations/publish', oazapfts.multipart({ ...opts, method: 'POST', body, }))); } /** * Find an integration by exact name */ function getIntegrationByName(integrationName, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations/find/${encodeURIComponent(integrationName)}`, { ...opts, })); } /** * Invite a user to an integration */ function inviteUser(integrationId, body, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/users/invite`, oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Invite a unito organization to an integration */ function inviteOrganization(integrationId, body, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/organizations/invite`, oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Get an integration */ function getIntegrationById(integrationId, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, { ...opts, })); } /** * Update an integration */ function updateIntegration(integrationId, body, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, oazapfts.json({ ...opts, method: 'PATCH', body, }))); } /** * Delete an integration */ function deleteIntegration(integrationId, name, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}${QS.query(QS.explode({ name, }))}`, { ...opts, method: 'DELETE', })); } /** * Get the events associated with this integration. */ function getIntegrationEvents(integrationId, { search, $from, limit, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/events${QS.query(QS.explode({ search, from: $from, limit, }))}`, { ...opts, })); } /** * Get the logo of the integration, in SVG format. */ function getIntegrationLogo(integrationName, opts) { return oazapfts.ok(oazapfts.fetchJson(`/public/${encodeURIComponent(integrationName)}/logo.svg`, { ...opts, })); } /** * Get all the credentials */ function getCredentials({ pagination, filters, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/credentials${QS.query(QS.explode({ pagination, filters, }))}`, { ...opts, })); } /** * Create a credential */ function createCredential(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/credentials', oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Get a credential */ function getCredentialById(credentialId, opts) { return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, { ...opts, })); } /** * Update a credential */ function updateCredential(credentialId, body, opts) { return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, oazapfts.json({ ...opts, method: 'PATCH', body, }))); } /** * Delete a credential */ function deleteCredential(credentialId, opts) { return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, { ...opts, method: 'DELETE', })); } /** * Returns the credentialAccount either from the integration's /me endpoint, if available, or the credential's latestCredentialAccount */ function getCredentialAccount(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson('/credentialAccount', { ...opts, headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, }), })); } /** * Used by the frontend to send analytics data */ function postTrack(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/track', oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Encrypt data */ function encryptData(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/encryptions/encrypt', oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Decrypt data */ function decryptData(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/encryptions/decrypt', oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Decrypt and encrypt data */ function reencryptData(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/encryptions/reencrypt', oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Get my profile */ function getProfile(opts) { return oazapfts.ok(oazapfts.fetchJson('/profile', { ...opts, })); } /** * Update my profile */ function updateProfile(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/profile', oazapfts.json({ ...opts, method: 'PATCH', body, }))); } /** * Call an integration's me */ function getProxyMe(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson('/proxy/me', { ...opts, headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, }), })); } /** * Update a webhook subscription */ function updateWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson('/proxy/webhooks/subscriptions', oazapfts.json({ ...opts, method: 'PUT', body, headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, }), }))); } /** * Call an integration's graph */ function getProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, accept, xUnitoOperationDeadline, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({ path, }))}`, { ...opts, headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, Accept: accept, 'X-Unito-Operation-Deadline': xUnitoOperationDeadline, }), })); } /** * Call an integration's graph */ function patchProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, contentType, xUnitoOperationDeadline, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({ path, }))}`, oazapfts.json({ ...opts, method: 'PATCH', body, headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, 'Content-Type': contentType, 'X-Unito-Operation-Deadline': xUnitoOperationDeadline, }), }))); } /** * Call an integration's graph */ function postProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, contentType, xUnitoOperationDeadline, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({ path, }))}`, oazapfts.json({ ...opts, method: 'POST', body, headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, 'Content-Type': contentType, 'X-Unito-Operation-Deadline': xUnitoOperationDeadline, }), }))); } /** * Call an integration's graph */ function deleteProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, xUnitoOperationDeadline, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS.query(QS.explode({ path, }))}`, { ...opts, method: 'DELETE', headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, 'X-Unito-Operation-Deadline': xUnitoOperationDeadline, }), })); } /** * Call an integration's graph with multipart/form-data */ function postProxyGraphMultipart(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, xUnitoOperationDeadline, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph/multipart${QS.query(QS.explode({ path, }))}`, oazapfts.multipart({ ...opts, method: 'POST', body, headers: oazapfts.mergeHeaders(opts?.headers, { 'X-Unito-Credential-Id': xUnitoCredentialId, 'X-Unito-Correlation-Id': xUnitoCorrelationId, 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext, 'X-Unito-Operation-Deadline': xUnitoOperationDeadline, }), }))); } /** * Get all the users */ function getUsers({ pagination, } = {}, opts) { return oazapfts.ok(oazapfts.fetchJson(`/users${QS.query(QS.explode({ pagination, }))}`, { ...opts, })); } /** * Create a user */ function createUser(body, opts) { return oazapfts.ok(oazapfts.fetchJson('/users', oazapfts.json({ ...opts, method: 'POST', body, }))); } /** * Get a user */ function getUserById(userId, opts) { return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, { ...opts, })); } /** * Update a user */ function updateUser(userId, body, opts) { return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, oazapfts.json({ ...opts, method: 'PATCH', body, }))); } /** * Regenerate the api key of a user */ function regenerateApiKey(userId, opts) { return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}/apiKey`, { ...opts, method: 'POST', })); } /** * Get a user by its email address */ function getUserByEmail(email, opts) { return oazapfts.ok(oazapfts.fetchJson(`/users/find/${encodeURIComponent(email)}`, { ...opts, })); } const runtime_1 = require("@oazapfts/runtime"); Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return runtime_1.HttpError; } });