@integration-app/sdk
Advanced tools
Comparing version 0.16.12 to 0.16.13
@@ -9,3 +9,3 @@ import Pusher from 'pusher-js'; | ||
import { FieldMappingAccessor, FieldMappingInstanceAccessor, FieldMappingsAccessor, FieldMappingInstancesAccessor } from './field-mappings/accessors'; | ||
import { DataSourcesAccessor, DataSourceAccessor, DataSourceInstancesAccessor, DataSourceInstanceAccessor } from './data-sources/accessors'; | ||
import { DataSourceInstancesAccessor, DataSourceInstanceAccessor } from './data-sources/accessors'; | ||
import { FlowInstanceSelector } from './flows/api'; | ||
@@ -40,4 +40,4 @@ import { FieldMappingInstanceSelector } from './field-mappings/api'; | ||
flowInstance(selector: string | FlowInstanceSelector): FlowInstanceAccessor; | ||
get dataSources(): DataSourcesAccessor; | ||
dataSource(idOrKey: string): DataSourceAccessor; | ||
get dataSources(): DataSourceInstancesAccessor; | ||
dataSource(selector: string | DataSourceInstanceSelector): DataSourceInstanceAccessor; | ||
get dataSourceInstances(): DataSourceInstancesAccessor; | ||
@@ -44,0 +44,0 @@ dataSourceInstance(selector: string | DataSourceInstanceSelector): DataSourceInstanceAccessor; |
@@ -63,6 +63,6 @@ "use strict"; | ||
get dataSources() { | ||
return new accessors_6.DataSourcesAccessor(this); | ||
return new accessors_6.DataSourceInstancesAccessor(this); | ||
} | ||
dataSource(idOrKey) { | ||
return new accessors_6.DataSourceAccessor(this, idOrKey); | ||
dataSource(selector) { | ||
return new accessors_6.DataSourceInstanceAccessor(this, selector); | ||
} | ||
@@ -69,0 +69,0 @@ get dataSourceInstances() { |
@@ -134,3 +134,3 @@ import { DataCollectionEvent, DataRecord } from '../data-collections'; | ||
export interface DataDirectoryListResponse { | ||
locations: DataLocationSpec[]; | ||
locations: DataLocation[]; | ||
cursor?: string; | ||
@@ -137,0 +137,0 @@ } |
import { IntegrationAppClient } from '..'; | ||
import { DataSource, DataSourceInstance } from '.'; | ||
import { FindDataSourcesQuery, UpdateDataSourceRequest, FindDataSourceInstancesQuery, UpdateDataSourceInstanceRequest, DataSourceInstanceSelector, CreateDataSourceRequest, CreateDataSourceInstanceRequest } from './api'; | ||
import { DataCollectionCreateRequest, DataCollectionCreateResponse, DataCollectionDeleteRequest, DataCollectionDeleteResponse, DataCollectionFindRequest, DataCollectionFindResponse, DataCollectionUpdateRequest, DataCollectionUpdateResponse } from '../connector-api'; | ||
import { DataSourceInstance } from '.'; | ||
import { FindDataSourceInstancesQuery, UpdateDataSourceInstanceRequest, DataSourceInstanceSelector, CreateDataSourceInstanceRequest } from './api'; | ||
import { DataCollectionCreateRequest, DataCollectionCreateResponse, DataCollectionDeleteRequest, DataCollectionDeleteResponse, DataCollectionFindRequest, DataCollectionFindResponse, DataCollectionSpec, DataCollectionUpdateRequest, DataCollectionUpdateResponse, DataDirectoryListRequest, DataDirectoryListResponse } from '../connector-api'; | ||
import { OpenConfigurationOptions } from '../iframe'; | ||
import { ElementListAccessor, ElementAccessor, ElementInstanceListAccessor, ElementInstanceAccessor } from '../accessors'; | ||
import { ElementInstanceListAccessor, ElementInstanceAccessor } from '../accessors'; | ||
interface OpenDataSourceInstanceConfiguration extends OpenConfigurationOptions { | ||
} | ||
export declare class DataSourcesAccessor extends ElementListAccessor<DataSource, FindDataSourcesQuery, CreateDataSourceRequest> { | ||
constructor(client: IntegrationAppClient); | ||
} | ||
export declare class DataSourceAccessor extends ElementAccessor<DataSource, CreateDataSourceRequest, UpdateDataSourceRequest> { | ||
constructor(client: IntegrationAppClient, idOrKey: string); | ||
} | ||
export declare class DataSourceInstancesAccessor extends ElementInstanceListAccessor<DataSourceInstance, FindDataSourceInstancesQuery> { | ||
@@ -19,6 +13,12 @@ constructor(client: IntegrationAppClient); | ||
export declare class DataSourceInstanceAccessor extends ElementInstanceAccessor<DataSourceInstance, DataSourceInstanceSelector, CreateDataSourceInstanceRequest, UpdateDataSourceInstanceRequest> { | ||
private client; | ||
client: IntegrationAppClient; | ||
constructor(client: IntegrationAppClient, selector: string | DataSourceInstanceSelector); | ||
setup(): Promise<void>; | ||
openConfiguration(options?: OpenDataSourceInstanceConfiguration): Promise<void>; | ||
getCollection(request: { | ||
path?: string; | ||
}): Promise<DataCollectionSpec>; | ||
getLocations(request: DataDirectoryListRequest & { | ||
path?: string; | ||
}): Promise<DataDirectoryListResponse>; | ||
findRecords(request?: DataCollectionFindRequest): Promise<DataCollectionFindResponse>; | ||
@@ -25,0 +25,0 @@ createRecord(request: DataCollectionCreateRequest): Promise<DataCollectionCreateResponse>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DataSourceInstanceAccessor = exports.DataSourceInstancesAccessor = exports.DataSourceAccessor = exports.DataSourcesAccessor = void 0; | ||
exports.DataSourceInstanceAccessor = exports.DataSourceInstancesAccessor = void 0; | ||
const iframe_1 = require("../iframe"); | ||
const accessors_1 = require("../accessors"); | ||
class DataSourcesAccessor extends accessors_1.ElementListAccessor { | ||
constructor(client) { | ||
super(client, 'data-sources'); | ||
} | ||
} | ||
exports.DataSourcesAccessor = DataSourcesAccessor; | ||
class DataSourceAccessor extends accessors_1.ElementAccessor { | ||
constructor(client, idOrKey) { | ||
super({ | ||
client, | ||
path: 'data-sources', | ||
idOrKey, | ||
}); | ||
} | ||
} | ||
exports.DataSourceAccessor = DataSourceAccessor; | ||
class DataSourceInstancesAccessor extends accessors_1.ElementInstanceListAccessor { | ||
@@ -49,2 +33,10 @@ constructor(client) { | ||
} | ||
async getCollection(request) { | ||
const id = await this.getId(); | ||
return this.client.get(`/data-source-instances/${id}/collection`, request); | ||
} | ||
async getLocations(request) { | ||
const id = await this.getId(); | ||
return this.client.get(`/data-source-instances/${id}/locations`, request); | ||
} | ||
async findRecords(request = {}) { | ||
@@ -51,0 +43,0 @@ const baseUri = await this.getRecordsBaseUri(); |
import { PaginationQuery, PaginationResponse } from '../entity-repository'; | ||
import { DataSource, DataSourceEvent, DataSourceInstance } from '.'; | ||
import { DataSourceEvent, DataSourceInstance } from '.'; | ||
import { ConnectionSelector } from '../connections/api'; | ||
export interface DataSourceInstanceSelector extends ConnectionSelector { | ||
dataSourceKey?: string; | ||
dataSourceId?: string; | ||
udm?: string; | ||
instanceKey?: string; | ||
autoCreate?: boolean; | ||
dataSourceKey?: string; | ||
} | ||
export interface FindDataSourcesQuery extends PaginationQuery { | ||
} | ||
export declare type FindDataSourcesResponse = PaginationResponse<DataSource>; | ||
export interface FindDataSourceInstancesQuery extends PaginationQuery { | ||
@@ -19,4 +16,2 @@ userId?: string; | ||
export declare type FindDataSourceInstancesResponse = PaginationResponse<DataSourceInstance>; | ||
export declare type CreateDataSourceRequest = Omit<DataSource, 'id'>; | ||
export declare type UpdateDataSourceRequest = Partial<CreateDataSourceRequest>; | ||
export interface CreateDataSourceInstanceRequest { | ||
@@ -32,3 +27,3 @@ dataSourceId: string; | ||
userId?: string; | ||
dataSourceId?: string; | ||
udm?: string; | ||
dataSourceInstanceId?: string; | ||
@@ -35,0 +30,0 @@ startDatetime?: string; |
@@ -5,8 +5,2 @@ import { User } from '../users'; | ||
import { ErrorData } from '../errors'; | ||
export interface DataSource { | ||
id: string; | ||
name: string; | ||
key: string; | ||
udm?: string; | ||
} | ||
export interface DataSourceInstance { | ||
@@ -17,5 +11,3 @@ id: string; | ||
user?: User; | ||
dataSourceId?: string; | ||
dataSource?: DataSource; | ||
instanceKey?: string; | ||
udm?: string; | ||
connectionId: string; | ||
@@ -25,3 +17,3 @@ connection?: Connection; | ||
integration?: Integration; | ||
udm?: string; | ||
instanceKey?: string; | ||
rootPath?: string; | ||
@@ -43,4 +35,2 @@ path?: string; | ||
user?: User; | ||
dataSourceId: string; | ||
dataSource?: DataSource; | ||
dataSourceInstanceId: string; | ||
@@ -47,0 +37,0 @@ dataSourceInstance?: DataSourceInstance; |
@@ -23,4 +23,6 @@ export declare enum ErrorType { | ||
data?: any; | ||
docsLink?: string; | ||
stack?: any; | ||
causedByError?: ErrorData; | ||
logs?: any[]; | ||
} | ||
@@ -27,0 +29,0 @@ declare type ErrorConstructorArg = string | ErrorDataFields | Error; |
@@ -20,3 +20,3 @@ import { PaginationQuery, PaginationResponse } from '../entity-repository'; | ||
instanceKey?: string; | ||
externalElementInstanceKey?: string; | ||
dataSourceInstanceKey?: string; | ||
appElementInstanceKey?: string; | ||
@@ -33,6 +33,7 @@ importValue?: any; | ||
fieldMappingId?: string; | ||
externalElementInstanceKey?: string; | ||
dataSourceInstanceKey?: string; | ||
appElementInstanceKey?: string; | ||
instanceKey?: string; | ||
autoCreate?: boolean; | ||
externalElementInstanceKey?: string; | ||
} |
@@ -6,2 +6,3 @@ import { IntegrationElement, IntegrationElementInstance } from '../integration-elements'; | ||
import { ErrorData } from '../errors'; | ||
import { DataSourceInstance } from '../data-sources'; | ||
export declare enum FieldMappingDirection { | ||
@@ -16,3 +17,3 @@ IMPORT = "import", | ||
key: string; | ||
externalElement: IntegrationElement; | ||
udm: string; | ||
appElement: IntegrationElement; | ||
@@ -26,4 +27,4 @@ direction: FieldMappingDirection; | ||
direction: FieldMappingDirection; | ||
udm: string; | ||
appElement?: IntegrationElement; | ||
externalElement?: IntegrationElement; | ||
defaultExportValue?: any; | ||
@@ -44,4 +45,4 @@ defaultImportValue?: any; | ||
adHocFieldMapping?: AdHocFieldMapping; | ||
externalElementInstanceKey?: string; | ||
externalElementInstance?: IntegrationElementInstance; | ||
dataSourceId?: string; | ||
dataSource?: DataSourceInstance; | ||
externalSchema?: any; | ||
@@ -48,0 +49,0 @@ appElementInstanceKey?: string; |
import { ErrorData } from '../errors'; | ||
import { PaginationResponse, PaginationQuery } from '../entity-repository'; | ||
import { FlowNodeRun } from './flow-node-runs'; | ||
import { IntegrationAppClient } from '../client'; | ||
import { IntegrationAppClient, SubscribeOptions } from '../client'; | ||
import { User } from '../users'; | ||
@@ -70,2 +70,7 @@ import { FlowInstance } from '../flows'; | ||
getOutput(): Promise<any>; | ||
subscribe(options: SubscribeOptions): Promise<void>; | ||
unsubscribe(): Promise<void>; | ||
repeat({ onUpdate, }?: { | ||
onUpdate?: (flowRun: FlowRun) => void; | ||
}): Promise<FlowRun>; | ||
} |
@@ -49,4 +49,24 @@ "use strict"; | ||
} | ||
async subscribe(options) { | ||
const channelKey = `${exports.FLOW_RUN_CHANNEL_PREFIX}${this.id}`; | ||
await this.client.subscribeToChannel(channelKey, options); | ||
} | ||
async unsubscribe() { | ||
const channelKey = `${exports.FLOW_RUN_CHANNEL_PREFIX}${this.id}`; | ||
await this.client.unsubscribeFromChannel(channelKey); | ||
} | ||
async repeat({ onUpdate, } = {}) { | ||
const flowRun = await this.get(); | ||
if (flowRun.state === FlowRunState.RUNNING) { | ||
throw new Error('Cannot repeat a running flow run.'); | ||
} | ||
const flowInstanceAccessor = await this.client.flowInstance(flowRun.flowInstanceId); | ||
return flowInstanceAccessor.run({ | ||
nodeKey: flowRun.startNodeKey, | ||
input: flowRun.input, | ||
onUpdate, | ||
}); | ||
} | ||
} | ||
exports.FlowRunAccessor = FlowRunAccessor; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@integration-app/sdk", | ||
"version": "0.16.12", | ||
"version": "0.16.13", | ||
"description": "JavaScript SDK for Integration.app", | ||
@@ -16,4 +16,3 @@ "main": "index.js", | ||
"test:watch": "jest --watch", | ||
"version": "npm version", | ||
"publish": "npm publish --access public" | ||
"version": "npm version" | ||
}, | ||
@@ -20,0 +19,0 @@ "devDependencies": { |
@@ -35,4 +35,2 @@ import Pusher, { Channel } from 'pusher-js' | ||
import { | ||
DataSourcesAccessor, | ||
DataSourceAccessor, | ||
DataSourceInstancesAccessor, | ||
@@ -125,8 +123,10 @@ DataSourceInstanceAccessor, | ||
get dataSources(): DataSourcesAccessor { | ||
return new DataSourcesAccessor(this) | ||
get dataSources(): DataSourceInstancesAccessor { | ||
return new DataSourceInstancesAccessor(this) | ||
} | ||
dataSource(idOrKey: string): DataSourceAccessor { | ||
return new DataSourceAccessor(this, idOrKey) | ||
dataSource( | ||
selector: string | DataSourceInstanceSelector, | ||
): DataSourceInstanceAccessor { | ||
return new DataSourceInstanceAccessor(this, selector) | ||
} | ||
@@ -133,0 +133,0 @@ |
@@ -196,3 +196,3 @@ import urljoin from 'url-join' | ||
export interface DataDirectoryListResponse { | ||
locations: DataLocationSpec[] | ||
locations: DataLocation[] | ||
cursor?: string | ||
@@ -199,0 +199,0 @@ } |
import { IntegrationAppClient } from '..' | ||
import { DataSource, DataSourceInstance } from '.' | ||
import { DataSourceInstance } from '.' | ||
import { | ||
FindDataSourcesQuery, | ||
UpdateDataSourceRequest, | ||
FindDataSourceInstancesQuery, | ||
UpdateDataSourceInstanceRequest, | ||
DataSourceInstanceSelector, | ||
CreateDataSourceRequest, | ||
CreateDataSourceInstanceRequest, | ||
@@ -19,9 +16,10 @@ } from './api' | ||
DataCollectionFindResponse, | ||
DataCollectionSpec, | ||
DataCollectionUpdateRequest, | ||
DataCollectionUpdateResponse, | ||
DataDirectoryListRequest, | ||
DataDirectoryListResponse, | ||
} from '../connector-api' | ||
import { OpenConfigurationOptions, openIframe } from '../iframe' | ||
import { | ||
ElementListAccessor, | ||
ElementAccessor, | ||
ElementInstanceListAccessor, | ||
@@ -34,26 +32,2 @@ ElementInstanceAccessor, | ||
export class DataSourcesAccessor extends ElementListAccessor< | ||
DataSource, | ||
FindDataSourcesQuery, | ||
CreateDataSourceRequest | ||
> { | ||
constructor(client: IntegrationAppClient) { | ||
super(client, 'data-sources') | ||
} | ||
} | ||
export class DataSourceAccessor extends ElementAccessor< | ||
DataSource, | ||
CreateDataSourceRequest, | ||
UpdateDataSourceRequest | ||
> { | ||
constructor(client: IntegrationAppClient, idOrKey: string) { | ||
super({ | ||
client, | ||
path: 'data-sources', | ||
idOrKey, | ||
}) | ||
} | ||
} | ||
export class DataSourceInstancesAccessor extends ElementInstanceListAccessor< | ||
@@ -75,3 +49,3 @@ DataSourceInstance, | ||
constructor( | ||
private client: IntegrationAppClient, | ||
public client: IntegrationAppClient, | ||
selector: string | DataSourceInstanceSelector, | ||
@@ -104,2 +78,16 @@ ) { | ||
async getCollection(request: { path?: string }): Promise<DataCollectionSpec> { | ||
const id = await this.getId() | ||
return this.client.get(`/data-source-instances/${id}/collection`, request) | ||
} | ||
async getLocations( | ||
request: DataDirectoryListRequest & { | ||
path?: string | ||
}, | ||
): Promise<DataDirectoryListResponse> { | ||
const id = await this.getId() | ||
return this.client.get(`/data-source-instances/${id}/locations`, request) | ||
} | ||
async findRecords( | ||
@@ -106,0 +94,0 @@ request: DataCollectionFindRequest = {}, |
import { PaginationQuery, PaginationResponse } from '../entity-repository' | ||
import { DataSource, DataSourceEvent, DataSourceInstance } from '.' | ||
import { DataSourceEvent, DataSourceInstance } from '.' | ||
import { ConnectionSelector } from '../connections/api' | ||
export interface DataSourceInstanceSelector extends ConnectionSelector { | ||
dataSourceKey?: string | ||
dataSourceId?: string | ||
udm?: string | ||
@@ -12,8 +11,9 @@ instanceKey?: string | ||
autoCreate?: boolean | ||
/** | ||
* @deprecated - use `udm` | ||
*/ | ||
dataSourceKey?: string | ||
} | ||
export interface FindDataSourcesQuery extends PaginationQuery {} | ||
export type FindDataSourcesResponse = PaginationResponse<DataSource> | ||
export interface FindDataSourceInstancesQuery extends PaginationQuery { | ||
@@ -30,6 +30,2 @@ userId?: string | ||
export type CreateDataSourceRequest = Omit<DataSource, 'id'> | ||
export type UpdateDataSourceRequest = Partial<CreateDataSourceRequest> | ||
export interface CreateDataSourceInstanceRequest { | ||
@@ -49,3 +45,3 @@ dataSourceId: string | ||
userId?: string | ||
dataSourceId?: string | ||
udm?: string | ||
dataSourceInstanceId?: string | ||
@@ -52,0 +48,0 @@ startDatetime?: string |
@@ -6,12 +6,2 @@ import { User } from '../users' | ||
export interface DataSource { | ||
id: string | ||
name: string | ||
key: string | ||
udm?: string | ||
} | ||
export interface DataSourceInstance { | ||
@@ -26,8 +16,4 @@ id: string | ||
dataSourceId?: string | ||
udm?: string | ||
dataSource?: DataSource | ||
instanceKey?: string | ||
connectionId: string | ||
@@ -41,3 +27,3 @@ | ||
udm?: string | ||
instanceKey?: string | ||
@@ -81,6 +67,2 @@ /** | ||
dataSourceId: string | ||
dataSource?: DataSource | ||
dataSourceInstanceId: string | ||
@@ -87,0 +69,0 @@ |
@@ -26,4 +26,6 @@ export enum ErrorType { | ||
data?: any | ||
docsLink?: string | ||
stack?: any | ||
causedByError?: ErrorData | ||
logs?: any[] | ||
} | ||
@@ -30,0 +32,0 @@ |
@@ -33,3 +33,3 @@ import { PaginationQuery, PaginationResponse } from '../entity-repository' | ||
externalElementInstanceKey?: string | ||
dataSourceInstanceKey?: string | ||
@@ -53,3 +53,3 @@ appElementInstanceKey?: string | ||
externalElementInstanceKey?: string | ||
dataSourceInstanceKey?: string | ||
@@ -61,2 +61,7 @@ appElementInstanceKey?: string | ||
autoCreate?: boolean | ||
/** | ||
* @deprecated - use dataSourceInstanceKey | ||
*/ | ||
externalElementInstanceKey?: string | ||
} |
@@ -9,2 +9,3 @@ import { | ||
import { ErrorData } from '../errors' | ||
import { DataSourceInstance } from '../data-sources' | ||
@@ -24,3 +25,3 @@ export enum FieldMappingDirection { | ||
externalElement: IntegrationElement | ||
udm: string | ||
@@ -40,4 +41,4 @@ appElement: IntegrationElement | ||
direction: FieldMappingDirection | ||
udm: string | ||
appElement?: IntegrationElement | ||
externalElement?: IntegrationElement | ||
defaultExportValue?: any | ||
@@ -70,5 +71,5 @@ defaultImportValue?: any | ||
externalElementInstanceKey?: string | ||
dataSourceId?: string | ||
externalElementInstance?: IntegrationElementInstance | ||
dataSource?: DataSourceInstance | ||
@@ -75,0 +76,0 @@ externalSchema?: any |
import { ErrorData } from '../errors' | ||
import { PaginationResponse, PaginationQuery } from '../entity-repository' | ||
import { FlowNodeRun } from './flow-node-runs' | ||
import { IntegrationAppClient } from '../client' | ||
import { IntegrationAppClient, SubscribeOptions } from '../client' | ||
import { User } from '../users' | ||
@@ -116,2 +116,34 @@ import { FlowInstance } from '../flows' | ||
} | ||
async subscribe(options: SubscribeOptions) { | ||
const channelKey = `${FLOW_RUN_CHANNEL_PREFIX}${this.id}` | ||
await this.client.subscribeToChannel(channelKey, options) | ||
} | ||
async unsubscribe() { | ||
const channelKey = `${FLOW_RUN_CHANNEL_PREFIX}${this.id}` | ||
await this.client.unsubscribeFromChannel(channelKey) | ||
} | ||
async repeat({ | ||
onUpdate, | ||
}: { | ||
onUpdate?: (flowRun: FlowRun) => void | ||
} = {}): Promise<FlowRun> { | ||
const flowRun = await this.get() | ||
if (flowRun.state === FlowRunState.RUNNING) { | ||
throw new Error('Cannot repeat a running flow run.') | ||
} | ||
const flowInstanceAccessor = await this.client.flowInstance( | ||
flowRun.flowInstanceId, | ||
) | ||
return flowInstanceAccessor.run({ | ||
nodeKey: flowRun.startNodeKey, | ||
input: flowRun.input, | ||
onUpdate, | ||
}) | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3346254
587
44379