New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@integration-app/sdk

Package Overview
Dependencies
Maintainers
1
Versions
445
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@integration-app/sdk - npm Package Compare versions

Comparing version 0.0.17 to 0.1.0

dist/client.d.ts

52

dist/index.d.ts

@@ -1,48 +0,4 @@

export declare function init(options: InitOptions): void;
export declare function startImport(options: NewImportOptions): void;
export declare function findIntegratedApps(options?: InitOptions): Promise<any>;
export declare function findConnections(options?: InitOptions): Promise<any>;
export declare function findFlowInstances(options: FindFlowInstancesOptions): Promise<any>;
export declare function deleteConnection(options: DeleteConnectionOptions): Promise<any>;
export declare function createFlowInstance(options: NewFlowInstanceOptions): Promise<any>;
export declare function openNewConnection(options: NewConnectionOptions): void;
export declare function openFlowInstance(options: OpenFlowInstanceOptions): void;
export declare function openNewFlowInstance(options: NewFlowInstanceOptions): void;
export declare const openNewFlow: typeof openNewFlowInstance;
interface InitOptions {
apiUri?: string;
uiUri?: string;
appKey?: string;
userAccessToken?: string;
}
interface NewImportOptions extends InitOptions {
schema: any;
onData: (...args: any) => void;
onClose?: (...args: any) => void;
}
interface NewFlowInstanceOptions extends InitOptions {
blueprintKey?: string;
flowKey: string;
parameters: any;
onFlowRunComplete?: (...args: any) => void;
onClose?: (...args: any) => void;
}
interface NewConnectionOptions extends InitOptions {
integratedAppKey: string;
onSuccess?: (connection: any) => void;
onCancel?: () => void;
onFailure?: (error: any) => void;
}
interface DeleteConnectionOptions extends InitOptions {
id: string;
}
interface OpenFlowInstanceOptions extends InitOptions {
id: string;
onFlowRunComplete?: (...args: any) => void;
onClose?: (...args: any) => void;
}
interface FindFlowInstancesOptions extends InitOptions {
flowKey: string;
parameters?: Record<string, any>;
}
export {};
import { IntegrationEngineClient } from './client';
export { IntegrationEngineClient } from './client';
declare const _default: IntegrationEngineClient;
export default _default;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.openNewFlow = exports.openNewFlowInstance = exports.openFlowInstance = exports.openNewConnection = exports.createFlowInstance = exports.deleteConnection = exports.findFlowInstances = exports.findConnections = exports.findIntegratedApps = exports.startImport = exports.init = void 0;
const axios_1 = __importDefault(require("axios"));
const iframe_1 = require("./iframe");
const DEFAULT_API_URI = 'https://engine-api.integration.app';
const DEFAULT_UI_URI = 'https://ui.integration.app';
const IMPORT_BLUEPRINT_KEY = 'import-data-to-browser';
// Global values set in .init
let appKey;
let apiUri;
let uiUri;
let userAccessToken;
function init(options) {
;
({ apiUri, uiUri, userAccessToken, appKey } = options);
}
exports.init = init;
function startImport(options) {
const uri = getEmbedUri('flows/new', options, {
blueprintKey: IMPORT_BLUEPRINT_KEY,
parameters: JSON.stringify({
schema: options.schema,
}),
});
iframe_1.openIframe(uri, {
onData: options.onData,
onClose: options.onClose,
});
}
exports.startImport = startImport;
function findIntegratedApps(options = {}) {
return get('integrated-apps', options);
}
exports.findIntegratedApps = findIntegratedApps;
function findConnections(options = {}) {
return get('connections', options);
}
exports.findConnections = findConnections;
function findFlowInstances(options) {
const queryParams = {
flowKey: options.flowKey,
};
if (options.parameters) {
queryParams.parameters = JSON.stringify(options.parameters);
}
const queryString = new URLSearchParams(queryParams).toString();
return get(`flow-instances?${queryString}`, options);
}
exports.findFlowInstances = findFlowInstances;
function deleteConnection(options) {
return del(`connections/${options.id}`, options);
}
exports.deleteConnection = deleteConnection;
function createFlowInstance(options) {
return post('flow-instances', {
blueprintKey: options.flowKey,
parameters: options.parameters,
}, options);
}
exports.createFlowInstance = createFlowInstance;
function openNewConnection(options) {
const requestId = (Math.random() + 1).toString(36).substring(12);
const listenerFunc = (event) => __awaiter(this, void 0, void 0, function* () {
const message = event.data || {};
if (message.source == 'integration.app' && message.requestId == requestId) {
if (message.type == 'newConnectionCreated') {
options.onSuccess && options.onSuccess(message.connection);
}
else if (message.type == 'newConnectionCancel') {
options.onCancel && options.onCancel();
}
else if (message.type == 'newConnectionFailure') {
options.onFailure && options.onFailure(message.error);
}
cleanup();
}
});
window.addEventListener('message', listenerFunc);
const url = new URL(`oauth/new/${options.integratedAppKey}`, getApiUri(options));
url.searchParams.append('token', getUserAccessToken(options));
url.searchParams.append('requestId', requestId);
const popup = window.open(url.toString());
const cancelCheckInterval = setInterval(() => {
if (popup === null || popup === void 0 ? void 0 : popup.closed) {
options.onCancel && options.onCancel();
cleanup();
}
}, 1000);
function cleanup() {
clearInterval(cancelCheckInterval);
window.removeEventListener('message', listenerFunc);
}
}
exports.openNewConnection = openNewConnection;
function openFlowInstance(options) {
const uri = getEmbedUri(`flows/${options.id}`, options);
iframe_1.openIframe(uri, {
onFlowRunComplete: options.onFlowRunComplete,
onClose: options.onClose,
});
}
exports.openFlowInstance = openFlowInstance;
function openNewFlowInstance(options) {
const uri = getEmbedUri('flows/new', options, {
blueprintKey: options.flowKey || options.blueprintKey,
parameters: JSON.stringify(options.parameters),
});
iframe_1.openIframe(uri, {
onFlowRunComplete: options.onFlowRunComplete,
onClose: options.onClose,
});
}
exports.openNewFlowInstance = openNewFlowInstance;
// Deprecated
exports.openNewFlow = openNewFlowInstance;
function getEmbedUri(page, options, params) {
const key = appKey || options.appKey;
const baseUri = uiUri || options.uiUri || DEFAULT_UI_URI;
const token = userAccessToken || options.userAccessToken;
if (!key && !token) {
throw Error('Either appKey or userAccessToken must be provided to use Integration.app UI');
}
const embedUrl = new URL(`${baseUri}/embed/${page}`);
if (token) {
embedUrl.searchParams.set('token', token);
}
if (key) {
embedUrl.searchParams.set('appKey', key);
}
if (params) {
for (const [key, value] of Object.entries(params)) {
embedUrl.searchParams.set(key, value);
}
}
return embedUrl.href;
}
function get(uri, options) {
return __awaiter(this, void 0, void 0, function* () {
return makeApiRequest('GET', { url: uri }, options);
});
}
function post(uri, data, options) {
return __awaiter(this, void 0, void 0, function* () {
return makeApiRequest('POST', { url: uri, data }, options);
});
}
function put(uri, data, options) {
return __awaiter(this, void 0, void 0, function* () {
return makeApiRequest('PUT', { url: uri, data }, options);
});
}
function patch(uri, data, options) {
return __awaiter(this, void 0, void 0, function* () {
return makeApiRequest('PATCH', { url: uri, data }, options);
});
}
function del(uri, options) {
return __awaiter(this, void 0, void 0, function* () {
return makeApiRequest('DELETE', { url: uri }, options);
});
}
function makeApiRequest(method, params = {}, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
params.method = method;
params.baseURL = getApiUri(options);
params.headers = Object.assign(Object.assign({}, (params.headers || {})), { Authorization: `Bearer ${options.userAccessToken}` });
const response = yield axios_1.default.request(params);
return response.data;
});
}
function getApiUri(options = {}) {
return options.apiUri || apiUri || DEFAULT_API_URI;
}
function getUserAccessToken(options = {}) {
const token = options.userAccessToken || userAccessToken;
if (!token) {
throw new Error('userAccessToken is not provided');
}
return token;
}
exports.IntegrationEngineClient = void 0;
const client_1 = require("./client");
var client_2 = require("./client");
Object.defineProperty(exports, "IntegrationEngineClient", { enumerable: true, get: function () { return client_2.IntegrationEngineClient; } });
// For loading via <script> tag and for people who just want to `import IntegraionApp from '@integration-app/sdk'`
exports.default = new client_1.IntegrationEngineClient({});
{
"name": "@integration-app/sdk",
"version": "0.0.17",
"version": "0.1.0",
"description": "JavaScript SDK for Integration.app",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,245 +0,6 @@

import Axios, { AxiosRequestConfig } from 'axios'
import { openIframe } from './iframe'
import { IntegrationEngineClient } from './client'
const DEFAULT_API_URI = 'https://engine-api.integration.app'
const DEFAULT_UI_URI = 'https://ui.integration.app'
const IMPORT_BLUEPRINT_KEY = 'import-data-to-browser'
export { IntegrationEngineClient } from './client'
// Global values set in .init
let appKey: string | undefined
let apiUri: string | undefined
let uiUri: string | undefined
let userAccessToken: string | undefined
type HttpMethod = 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH'
export function init(options: InitOptions) {
;({ apiUri, uiUri, userAccessToken, appKey } = options)
}
export function startImport(options: NewImportOptions) {
const uri = getEmbedUri('flows/new', options, {
blueprintKey: IMPORT_BLUEPRINT_KEY,
parameters: JSON.stringify({
schema: options.schema,
}),
})
openIframe(uri, {
onData: options.onData,
onClose: options.onClose,
})
}
export function findIntegratedApps(options: InitOptions = {}) {
return get('integrated-apps', options)
}
export function findConnections(options: InitOptions = {}) {
return get('connections', options)
}
export function findFlowInstances(options: FindFlowInstancesOptions) {
const queryParams: Record<string, string> = {
flowKey: options.flowKey,
}
if (options.parameters) {
queryParams.parameters = JSON.stringify(options.parameters)
}
const queryString = new URLSearchParams(queryParams).toString()
return get(`flow-instances?${queryString}`, options)
}
export function deleteConnection(options: DeleteConnectionOptions) {
return del(`connections/${options.id}`, options)
}
export function createFlowInstance(options: NewFlowInstanceOptions) {
return post(
'flow-instances',
{
blueprintKey: options.flowKey,
parameters: options.parameters,
},
options,
)
}
export function openNewConnection(options: NewConnectionOptions) {
const requestId = (Math.random() + 1).toString(36).substring(12)
const listenerFunc = async (event: any) => {
const message = event.data || {}
if (message.source == 'integration.app' && message.requestId == requestId) {
if (message.type == 'newConnectionCreated') {
options.onSuccess && options.onSuccess(message.connection)
} else if (message.type == 'newConnectionCancel') {
options.onCancel && options.onCancel()
} else if (message.type == 'newConnectionFailure') {
options.onFailure && options.onFailure(message.error)
}
cleanup()
}
}
window.addEventListener('message', listenerFunc)
const url = new URL(
`oauth/new/${options.integratedAppKey}`,
getApiUri(options),
)
url.searchParams.append('token', getUserAccessToken(options))
url.searchParams.append('requestId', requestId)
const popup = window.open(url.toString())
const cancelCheckInterval = setInterval(() => {
if (popup?.closed) {
options.onCancel && options.onCancel()
cleanup()
}
}, 1000)
function cleanup() {
clearInterval(cancelCheckInterval)
window.removeEventListener('message', listenerFunc)
}
}
export function openFlowInstance(options: OpenFlowInstanceOptions) {
const uri = getEmbedUri(`flows/${options.id}`, options)
openIframe(uri, {
onFlowRunComplete: options.onFlowRunComplete,
onClose: options.onClose,
})
}
export function openNewFlowInstance(options: NewFlowInstanceOptions) {
const uri = getEmbedUri('flows/new', options, {
blueprintKey: options.flowKey || options.blueprintKey,
parameters: JSON.stringify(options.parameters),
})
openIframe(uri, {
onFlowRunComplete: options.onFlowRunComplete,
onClose: options.onClose,
})
}
// Deprecated
export const openNewFlow = openNewFlowInstance
function getEmbedUri(page: string, options: InitOptions, params?: any) {
const key = appKey || options.appKey
const baseUri = uiUri || options.uiUri || DEFAULT_UI_URI
const token = userAccessToken || options.userAccessToken
if (!key && !token) {
throw Error(
'Either appKey or userAccessToken must be provided to use Integration.app UI',
)
}
const embedUrl = new URL(`${baseUri}/embed/${page}`)
if (token) {
embedUrl.searchParams.set('token', token)
}
if (key) {
embedUrl.searchParams.set('appKey', key)
}
if (params) {
for (const [key, value] of Object.entries(params)) {
embedUrl.searchParams.set(key, value as string)
}
}
return embedUrl.href
}
async function get(uri: string, options: InitOptions) {
return makeApiRequest('GET', { url: uri }, options)
}
async function post(uri: string, data: any, options: InitOptions) {
return makeApiRequest('POST', { url: uri, data }, options)
}
async function put(uri: string, data: any, options: InitOptions) {
return makeApiRequest('PUT', { url: uri, data }, options)
}
async function patch(uri: string, data: any, options: InitOptions) {
return makeApiRequest('PATCH', { url: uri, data }, options)
}
async function del(uri: string, options: InitOptions) {
return makeApiRequest('DELETE', { url: uri }, options)
}
async function makeApiRequest(
method: HttpMethod,
params: Partial<AxiosRequestConfig> = {},
options: InitOptions = {},
) {
params.method = method
params.baseURL = getApiUri(options)
params.headers = {
...(params.headers || {}),
Authorization: `Bearer ${options.userAccessToken}`,
}
const response = await Axios.request(params)
return response.data
}
function getApiUri(options: InitOptions = {}) {
return options.apiUri || apiUri || DEFAULT_API_URI
}
function getUserAccessToken(options: InitOptions = {}) {
const token = options.userAccessToken || userAccessToken
if (!token) {
throw new Error('userAccessToken is not provided')
}
return token
}
interface InitOptions {
apiUri?: string
uiUri?: string
appKey?: string
userAccessToken?: string
}
interface NewImportOptions extends InitOptions {
schema: any
onData: (...args: any) => void
onClose?: (...args: any) => void
}
interface NewFlowInstanceOptions extends InitOptions {
blueprintKey?: string
flowKey: string
parameters: any
onFlowRunComplete?: (...args: any) => void
onClose?: (...args: any) => void
}
interface NewConnectionOptions extends InitOptions {
integratedAppKey: string
onSuccess?: (connection: any) => void
onCancel?: () => void
onFailure?: (error: any) => void
}
interface DeleteConnectionOptions extends InitOptions {
id: string
}
interface OpenFlowInstanceOptions extends InitOptions {
id: string
onFlowRunComplete?: (...args: any) => void
onClose?: (...args: any) => void
}
interface FindFlowInstancesOptions extends InitOptions {
flowKey: string
parameters?: Record<string, any>
}
// For loading via <script> tag and for people who just want to `import IntegraionApp from '@integration-app/sdk'`
export default new IntegrationEngineClient({})

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc