@integration-app/react
Advanced tools
Comparing version 0.2.1 to 0.3.1
import * as _integration_app_sdk from '@integration-app/sdk'; | ||
import { IntegrationAppClient, ConnectionSpec, Integration, IntegrationAccessor, FindIntegrationsQuery, Connection, ConnectionAccessor, FindConnectionsQuery, FieldMapping, FieldMappingAccessor, FindFieldMappingsQuery, FieldMappingInstanceSelector, FieldMappingInstance, FieldMappingInstanceAccessor, OpenFieldMappingInstanceConfigurationOptions, FindFieldMappingInstancesQuery, DataSource, DataSourceAccessor, FindDataSourcesQuery, DataSourceInstanceSelector, DataSourceInstance, DataSourceInstanceAccessor, OpenDataSourceConfigurationOptions, DataCollectionFindRequest, DataCollectionCreateRequest, DataCollectionUpdateRequest, FindDataSourceInstancesQuery, DataCollectionSpec, FindDataSourceEventsQuery, DataSourceEvent, FindAppEventsQuery, AppEvent, AppEventType, AppEventTypeAccessor, FindAppEventTypesQuery, AppEventSubscriptionSelector, AppEventSubscription, AppEventSubscriptionAccessor, FindAppEventSubscriptionsQuery, FlowSelector, Flow, FlowAccessor, FindFlowsRequest, FlowInstanceSelector, FlowInstance, FlowInstanceAccessor, FindFlowInstancesQuery, FlowRun, FlowRunAccessor, FindFlowRunsRequest } from '@integration-app/sdk'; | ||
import { IntegrationAppClient, ConnectionAccessor, Connection, CreateConnectionRequest, UpdateConnectionRequest, FindConnectionsQuery, ConnectionSpec, IntegrationAccessor, Integration, CreateIntegrationRequest, UpdateIntegrationRequest, FindIntegrationsQuery, FieldMappingSelector, CreateFieldMappingRequest, FieldMapping, UpdateFieldMappingRequest, FieldMappingAccessor, FieldMappingInstanceSelector, CreateFieldMappingInstanceRequest, FieldMappingInstance, UpdateFieldMappingInstanceRequest, FieldMappingInstanceAccessor, OpenFieldMappingInstanceConfigurationOptions, FindFieldMappingInstancesQuery, FindFieldMappingsQuery, DataSourceSelector, CreateDataSourceRequest, DataSource, DataSourceAccessor, FindDataSourceEventsQuery, DataSourceEvent, DataSourceInstanceSelector, CreateDataSourceInstanceRequest, DataSourceInstance, UpdateDataSourceInstanceRequest, DataSourceInstanceAccessor, OpenDataSourceConfigurationOptions, DataCollectionListRequest, DataCollectionFindRequest, DataCollectionCreateRequest, DataCollectionUpdateRequest, DataDirectoryListRequest, DataCollectionSpec, DataDirectoryListResponse, FindDataSourceInstancesQuery, FindDataSourcesQuery, AppEventSubscriptionSelector, AppEventSubscriptionAccessor, AppEventSubscription, IAppEventSubscriptionUpdate, FindAppEventSubscriptionsQuery, AppEventTypeAccessor, AppEventType, CreateAppEventTypeRequest, FindAppEventTypesQuery, FindAppEventsQuery, AppEvent, FlowSelector, CreateFlowRequest, Flow, UpdateFlowRequest, FlowAccessor, FindFlowsRequest, FlowInstanceSelector, UpdateFlowInstanceRequest, FlowInstance, FlowInstanceAccessor, OpenFlowInstanceConfigurationOptions, RunFlowOptions, FindFlowInstancesQuery, FlowRun, FindFlowRunsRequest, DataLinkTableAccessor, DataLinkTable, CreateDataLinkTableRequest, DataLinkTableInstanceSelector, CreateDataLinkTableInstanceRequest, DataLinkTableInstance, UpdateDataLinkTableInstanceRequest, DataLinkTableInstanceAccessor, FindDataLinkTableInstancesQuery, FindDataLinkTablesQuery, ActionSelector, CreateActionRequest, Action, UpdateActionRequest, ActionAccessor, ActionInstanceSelector, CreateActionInstanceRequest, ActionInstance, UpdateActionInstanceRequest, ActionInstanceAccessor, OpenActionConfigurationOptions, FindActionInstancesQuery, FindActionsQuery, ScreenSelector, ScreenAccessor, Screen, CreateScreenRequest, UpdateScreenRequest } from '@integration-app/sdk'; | ||
export { DataForm } from '@integration-app/sdk'; | ||
import { ReactNode } from 'react'; | ||
import * as swr__internal from 'swr/_internal'; | ||
@@ -18,80 +19,88 @@ interface IntegrationAppProviderProps { | ||
declare function useConnectorSpec(integrationKey: string): { | ||
data: ConnectionSpec; | ||
declare function useIntegrationAppSWR(path: string, options?: any): swr__internal.SWRResponse<any, any, any>; | ||
declare function useConnection(id: string): { | ||
accessor: ConnectionAccessor; | ||
loading: boolean; | ||
error: Error; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Connection>; | ||
refreshing: boolean; | ||
create: (data: CreateConnectionRequest) => Promise<Connection>; | ||
patch: (data: Partial<UpdateConnectionRequest>) => Promise<void>; | ||
put: (data: UpdateConnectionRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
connection: Connection; | ||
}; | ||
declare function useIntegration(idOrKey: string): { | ||
declare function useConnections(query?: FindConnectionsQuery): { | ||
items: Connection[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateIntegrationRequest) => Promise<Integration>; | ||
patch: (data: _integration_app_sdk.UpdateIntegrationRequest) => Promise<Integration>; | ||
put: (data: _integration_app_sdk.CreateIntegrationRequest) => Promise<Integration>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: IntegrationAccessor; | ||
integration: Integration; | ||
error: any; | ||
connections: Connection[]; | ||
}; | ||
declare function useIntegrations(query?: FindIntegrationsQuery): { | ||
items: Integration[]; | ||
declare function useConnectorSpec(integrationIdOrKey: string): { | ||
data: ConnectionSpec; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
}; | ||
declare function useConnection(id: string): { | ||
declare function useIntegration(id: string): { | ||
accessor: IntegrationAccessor; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<Connection>) => Promise<Connection>; | ||
patch: (data: Partial<Connection>) => Promise<Connection>; | ||
put: (data: Partial<Connection>) => Promise<Connection>; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Integration>; | ||
refreshing: boolean; | ||
create: (data: CreateIntegrationRequest) => Promise<Integration>; | ||
patch: (data: Partial<UpdateIntegrationRequest>) => Promise<void>; | ||
put: (data: UpdateIntegrationRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: ConnectionAccessor; | ||
connection: Connection; | ||
integration: Integration; | ||
}; | ||
declare function useConnections(query?: FindConnectionsQuery): { | ||
items: Connection[]; | ||
declare function useIntegrations(query?: FindIntegrationsQuery): { | ||
items: Integration[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
integrations: Integration[]; | ||
}; | ||
declare function useFieldMapping(idOrKey: string): { | ||
declare function useFieldMapping(selector: FieldMappingSelector | string): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
patch: (data: Partial<_integration_app_sdk.CreateFieldMappingRequest>) => Promise<FieldMapping>; | ||
put: (data: _integration_app_sdk.CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
patch: (data: Partial<UpdateFieldMappingRequest>) => Promise<void>; | ||
put: (data: UpdateFieldMappingRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
fieldMapping: FieldMapping; | ||
apply: (integrationKeys: string[]) => Promise<FieldMapping[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<FieldMapping>; | ||
accessor: FieldMappingAccessor; | ||
fieldMapping: FieldMapping; | ||
}; | ||
declare function useFieldMappings(query?: FindFieldMappingsQuery): { | ||
items: FieldMapping[]; | ||
declare function useFieldMappingInstance(selector: string | FieldMappingInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useFieldMappingInstance(selector: FieldMappingInstanceSelector | { | ||
id: string; | ||
}): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
patch: (data: _integration_app_sdk.UpdateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
put: (data: _integration_app_sdk.CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
patch: (data: Partial<UpdateFieldMappingInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateFieldMappingInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
fieldMappingInstance: FieldMappingInstance; | ||
accessor: FieldMappingInstanceAccessor; | ||
fieldMappingInstance: FieldMappingInstance; | ||
refresh: () => Promise<FieldMappingInstance>; | ||
setup: () => Promise<void>; | ||
@@ -104,41 +113,71 @@ reset: () => Promise<void>; | ||
items: FieldMappingInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
fieldMappingInstances: FieldMappingInstance[]; | ||
}; | ||
declare function useDataSource(idOrKey: string): { | ||
declare function useFieldMappings(query?: FindFieldMappingsQuery): { | ||
items: FieldMapping[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateDataSourceRequest) => Promise<DataSource>; | ||
patch: (data: Partial<_integration_app_sdk.CreateDataSourceRequest>) => Promise<DataSource>; | ||
put: (data: _integration_app_sdk.CreateDataSourceRequest) => Promise<DataSource>; | ||
error: any; | ||
fieldMappings: FieldMapping[]; | ||
}; | ||
declare function useDataSource(selector: string | DataSourceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataSourceRequest) => Promise<DataSource>; | ||
patch: (data: Partial<Partial<CreateDataSourceRequest>>) => Promise<void>; | ||
put: (data: Partial<CreateDataSourceRequest>) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
dataSource: DataSource; | ||
apply: (integrationKeys: string[]) => Promise<DataSource[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<DataSource>; | ||
accessor: DataSourceAccessor; | ||
dataSource: DataSource; | ||
}; | ||
declare function useDataSources(query?: FindDataSourcesQuery): { | ||
items: DataSource[]; | ||
declare function useDataSourceEvents(query?: FindDataSourceEventsQuery): { | ||
items: DataSourceEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSourceEvents: { | ||
items: DataSourceEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
}; | ||
}; | ||
declare function useDataSourceInstance(selector: DataSourceInstanceSelector | { | ||
id: string; | ||
}): { | ||
declare function useDataSourceInstance(selector: string | DataSourceInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
patch: (data: _integration_app_sdk.UpdateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
put: (data: _integration_app_sdk.CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
patch: (data: Partial<UpdateDataSourceInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateDataSourceInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
dataSourceInstance: DataSourceInstance; | ||
accessor: DataSourceInstanceAccessor; | ||
dataSourceInstance: DataSourceInstance; | ||
refresh: () => Promise<DataSourceInstance>; | ||
setup: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
subscribe: (eventType: any) => Promise<void>; | ||
@@ -149,4 +188,5 @@ resubscribe: (eventType: any) => Promise<void>; | ||
fullSync: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
getSyncsList: () => Promise<_integration_app_sdk.DataSourceSync[]>; | ||
openConfiguration: (options?: OpenDataSourceConfigurationOptions) => Promise<void>; | ||
listRecords: (request?: DataCollectionListRequest) => Promise<_integration_app_sdk.DataCollectionListResponse>; | ||
findRecords: (request?: DataCollectionFindRequest) => Promise<_integration_app_sdk.DataCollectionFindResponse>; | ||
@@ -158,17 +198,13 @@ findRecordById: (id: string) => Promise<_integration_app_sdk.DataCollectionFindByIdResponse>; | ||
unifiedFieldsToNative: (unifiedFields: any) => Promise<any>; | ||
getLocations: (request: DataDirectoryListRequest & { | ||
path?: string; | ||
}) => Promise<_integration_app_sdk.DataDirectoryListResponse>; | ||
getCollection: () => Promise<_integration_app_sdk.DataCollectionSpec>; | ||
}; | ||
declare function useDataSourceInstances(query?: FindDataSourceInstancesQuery): { | ||
items: DataSourceInstance[]; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useDataSourceInstanceCollection(dataSourceInstance: DataSourceInstance): { | ||
collection: DataCollectionSpec; | ||
refresh: () => Promise<DataCollectionSpec>; | ||
error: any; | ||
loading: boolean; | ||
error: Error; | ||
refresh: () => void; | ||
collection: DataCollectionSpec; | ||
}; | ||
@@ -180,33 +216,66 @@ | ||
}): { | ||
locations: _integration_app_sdk.DataLocation[]; | ||
refresh: () => Promise<DataDirectoryListResponse>; | ||
error: any; | ||
loading: boolean; | ||
error: Error; | ||
refresh: () => void; | ||
locations: _integration_app_sdk.DataLocation[]; | ||
}; | ||
declare function useDataSourceEvents(query?: FindDataSourceEventsQuery): { | ||
items: DataSourceEvent[]; | ||
declare function useDataSourceInstances(query?: FindDataSourceInstancesQuery): { | ||
items: DataSourceInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSourceInstances: DataSourceInstance[]; | ||
}; | ||
declare function useAppEvents(query?: FindAppEventsQuery): { | ||
items: AppEvent[]; | ||
declare function useDataSources(query?: FindDataSourcesQuery): { | ||
items: DataSource[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSources: DataSource[]; | ||
}; | ||
declare function useAppEventType(idOrKey: string): { | ||
declare function useAppEventSubscription(selector: string | AppEventSubscriptionSelector): { | ||
accessor: AppEventSubscriptionAccessor; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
patch: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
put: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<AppEventSubscription>; | ||
refreshing: boolean; | ||
create: (data: IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
patch: (data: Partial<IAppEventSubscriptionUpdate>) => Promise<void>; | ||
put: (data: IAppEventSubscriptionUpdate) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
appEventSubscription: AppEventSubscription; | ||
}; | ||
declare function useAppEventSubscriptions(query?: FindAppEventSubscriptionsQuery): { | ||
items: AppEventSubscription[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
appEventSubscriptions: AppEventSubscription[]; | ||
}; | ||
declare function useAppEventType(id: string): { | ||
accessor: AppEventTypeAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<AppEventType>; | ||
refreshing: boolean; | ||
create: (data: CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
patch: (data: Partial<CreateAppEventTypeRequest>) => Promise<void>; | ||
put: (data: CreateAppEventTypeRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
appEventType: AppEventType; | ||
@@ -217,40 +286,36 @@ }; | ||
items: AppEventType[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
appEventTypes: AppEventType[]; | ||
}; | ||
declare function useAppEventSubscription(selector: AppEventSubscriptionSelector | { | ||
id: string; | ||
}): { | ||
declare function useAppEvents(query?: FindAppEventsQuery): { | ||
items: AppEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
patch: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
put: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: AppEventSubscriptionAccessor; | ||
appEventSubscription: AppEventSubscription; | ||
error: any; | ||
appEvents: AppEvent[]; | ||
}; | ||
declare function useAppEventSubscriptions(query?: FindAppEventSubscriptionsQuery): { | ||
items: AppEventSubscription[]; | ||
declare function useFlow(selector: string | FlowSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useFlow(idOrSelector: string | FlowSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<Flow>) => Promise<Flow>; | ||
patch: (data: Partial<Flow>) => Promise<Flow>; | ||
put: (data: Partial<Flow>) => Promise<Flow>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFlowRequest) => Promise<Flow>; | ||
patch: (data: Partial<UpdateFlowRequest>) => Promise<void>; | ||
put: (data: UpdateFlowRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
flow: Flow; | ||
apply: (integrationKeys: string[]) => Promise<Flow[]>; | ||
reset: () => Promise<Flow>; | ||
refresh: () => Promise<Flow>; | ||
accessor: FlowAccessor; | ||
flow: Flow; | ||
}; | ||
@@ -260,20 +325,30 @@ | ||
items: Flow[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flows: Flow[]; | ||
}; | ||
declare function useFlowInstance(props: FlowInstanceSelector | { | ||
id: string; | ||
}): { | ||
declare function useFlowInstance(selector: string | FlowInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFlowInstanceRequest) => Promise<FlowInstance>; | ||
patch: (data: _integration_app_sdk.UpdateFlowInstanceRequest) => Promise<FlowInstance>; | ||
put: (data: _integration_app_sdk.CreateFlowInstanceRequest) => Promise<FlowInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: UpdateFlowInstanceRequest) => Promise<FlowInstance>; | ||
patch: (data: Partial<UpdateFlowInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateFlowInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
flowInstance: FlowInstance; | ||
accessor: FlowInstanceAccessor; | ||
flowInstance: FlowInstance; | ||
refresh: () => Promise<FlowInstance>; | ||
enable: () => Promise<void>; | ||
disable: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
setup: () => Promise<void>; | ||
openConfiguration: (options: OpenFlowInstanceConfigurationOptions) => Promise<void>; | ||
run: (options?: RunFlowOptions) => Promise<_integration_app_sdk.FlowRun>; | ||
startRun: (options?: RunFlowOptions) => Promise<_integration_app_sdk.FlowRun>; | ||
}; | ||
@@ -283,18 +358,17 @@ | ||
items: FlowInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flowInstances: FlowInstance[]; | ||
}; | ||
declare function useFlowRun(id: string): { | ||
flowRun: FlowRun; | ||
error: any; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
patch: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
put: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
refresh: () => Promise<FlowRun>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: FlowRunAccessor; | ||
flowRun: FlowRun; | ||
}; | ||
@@ -304,8 +378,140 @@ | ||
items: FlowRun[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flowRuns: FlowRun[]; | ||
}; | ||
export { IntegrationAppProvider, useAppEventSubscription, useAppEventSubscriptions, useAppEventType, useAppEventTypes, useAppEvents, useConnection, useConnections, useConnectorSpec, useDataSource, useDataSourceInstanceCollection as useDataSourceCollection, useDataSourceEvents, useDataSourceInstance, useDataSourceInstances, useDataSourceInstanceLocations as useDataSourceLocations, useDataSources, useFieldMapping, useFieldMappingInstance, useFieldMappingInstances, useFieldMappings, useFlow, useFlowInstance, useFlowInstances, useFlowRun, useFlowRuns, useFlows, useIntegration, useIntegrationApp, useIntegrations }; | ||
declare function useDataLinkTable(selector: string): { | ||
accessor: DataLinkTableAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<DataLinkTable>; | ||
refreshing: boolean; | ||
create: (data: CreateDataLinkTableRequest) => Promise<DataLinkTable>; | ||
patch: (data: Partial<CreateDataLinkTableRequest>) => Promise<void>; | ||
put: (data: CreateDataLinkTableRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
dataLinkTable: DataLinkTable; | ||
}; | ||
declare function useDataLinkTableInstance(selector: string | DataLinkTableInstanceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataLinkTableInstanceRequest) => Promise<DataLinkTableInstance>; | ||
patch: (data: Partial<UpdateDataLinkTableInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateDataLinkTableInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
dataLinkTableInstance: DataLinkTableInstance; | ||
accessor: DataLinkTableInstanceAccessor; | ||
refresh: () => Promise<DataLinkTableInstance>; | ||
findLinks: (query?: _integration_app_sdk.FindDataLinksInTableQuery) => Promise<_integration_app_sdk.FindDataLinksResponse>; | ||
createLink: (data: _integration_app_sdk.CreateDataLinkRequest) => Promise<void>; | ||
deleteLink: (data: _integration_app_sdk.DeleteDataLinkRequest) => Promise<void>; | ||
}; | ||
declare function useDataLinkTableInstances(query?: FindDataLinkTableInstancesQuery): { | ||
items: DataLinkTableInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
dataLinkTableInstances: DataLinkTableInstance[]; | ||
}; | ||
declare function useDataLinkTables(query?: FindDataLinkTablesQuery): { | ||
items: DataLinkTable[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
dataLinkTables: DataLinkTable[]; | ||
}; | ||
declare function useAction(selector: ActionSelector | string): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateActionRequest) => Promise<Action>; | ||
patch: (data: Partial<UpdateActionRequest>) => Promise<void>; | ||
put: (data: UpdateActionRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
action: Action; | ||
apply: (integrationKeys: string[]) => Promise<Action[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<Action>; | ||
accessor: ActionAccessor; | ||
}; | ||
declare function useActionInstance(selector: string | ActionInstanceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateActionInstanceRequest) => Promise<ActionInstance>; | ||
patch: (data: Partial<UpdateActionInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateActionInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
actionInstance: ActionInstance; | ||
accessor: ActionInstanceAccessor; | ||
refresh: () => Promise<ActionInstance>; | ||
setup: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
openConfiguration: (options?: OpenActionConfigurationOptions) => Promise<void>; | ||
run: (input?: any) => Promise<_integration_app_sdk.ActionRunResponse>; | ||
}; | ||
declare function useActionInstances(query?: FindActionInstancesQuery): { | ||
items: ActionInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
actionInstances: ActionInstance[]; | ||
}; | ||
declare function useActions(query?: FindActionsQuery): { | ||
items: Action[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
actions: Action[]; | ||
}; | ||
declare function useScreen(selector: ScreenSelector | string): { | ||
accessor: ScreenAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Screen>; | ||
refreshing: boolean; | ||
create: (data: CreateScreenRequest) => Promise<Screen>; | ||
patch: (data: Partial<UpdateScreenRequest>) => Promise<void>; | ||
put: (data: UpdateScreenRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
screen: Screen; | ||
}; | ||
declare function useDataCollectionSpec({ path, key, integrationId, }: { | ||
path?: string; | ||
key?: string; | ||
integrationId: string; | ||
}): DataCollectionSpec; | ||
export { IntegrationAppProvider, useAction, useActionInstance, useActionInstances, useActions, useAppEventSubscription, useAppEventSubscriptions, useAppEventType, useAppEventTypes, useAppEvents, useConnection, useConnections, useConnectorSpec, useDataCollectionSpec, useDataLinkTable, useDataLinkTableInstance, useDataLinkTableInstances, useDataLinkTables, useDataSource, useDataSourceEvents, useDataSourceInstance, useDataSourceInstanceCollection, useDataSourceInstanceLocations, useDataSourceInstances, useDataSources, useFieldMapping, useFieldMappingInstance, useFieldMappingInstances, useFieldMappings, useFlow, useFlowInstance, useFlowInstances, useFlowRun, useFlowRuns, useFlows, useIntegration, useIntegrationApp, useIntegrationAppSWR, useIntegrations, useScreen }; |
@@ -6,2 +6,6 @@ 'use strict'; | ||
var react = require('react'); | ||
var useSWR = require('swr'); | ||
var AwesomeDebouncePromise = require('awesome-debounce-promise'); | ||
var useSWRInfinite = require('swr/infinite'); | ||
var qs = require('query-string'); | ||
@@ -25,90 +29,96 @@ const IntegrationAppContext = react.createContext(null); | ||
function useConnectorSpec(integrationKey) { | ||
const integrationApp = useIntegrationApp(); | ||
const [data, setData] = react.useState(null); | ||
const [loading, setLoading] = react.useState(true); | ||
const [error, setError] = react.useState(null); | ||
react.useEffect(() => { | ||
if (!integrationApp) { | ||
return; | ||
} | ||
integrationApp | ||
.integration(integrationKey) | ||
.getConnectorSpec() | ||
.then(setData) | ||
.catch(setError) | ||
.finally(() => setLoading(false)); | ||
}, [integrationApp, integrationKey]); | ||
return { data, loading, error }; | ||
function useIntegrationAppSWR(path, options) { | ||
const client = useIntegrationApp(); | ||
const fetcher = async () => { | ||
const response = await client.get(path, options); | ||
return response; | ||
}; | ||
return useSWR(client ? path : undefined, fetcher, options); | ||
} | ||
function useElement(props, accessorGenerator) { | ||
const elementStateCache = new Map(); | ||
function useElement(selector, accessorGenerator) { | ||
const integrationApp = useIntegrationApp(); | ||
const [data, setData] = react.useState(); | ||
const [loading, setLoading] = react.useState(true); | ||
const [error, setError] = react.useState(null); | ||
const [refreshCounter, setRefreshCounter] = react.useState(0); | ||
function updateDataWith(newData) { | ||
if (data !== undefined) { | ||
setData({ | ||
...data, | ||
...newData, | ||
}); | ||
} | ||
const elementKeyData = { | ||
token: integrationApp.token, | ||
selector, | ||
}; | ||
const elementKey = JSON.stringify(elementKeyData); | ||
if (!elementStateCache.has(elementKey)) { | ||
elementStateCache.set(elementKey, { | ||
updatedLocally: false, | ||
savingToServer: false, | ||
debouncedPut: AwesomeDebouncePromise(async (data) => { | ||
elementState.updatedLocally = false; | ||
elementState.savingToServer = true; | ||
try { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.put(data)); | ||
if (!elementState.updatedLocally) { | ||
elementState.savingToServer = false; | ||
await mutate(result, false); | ||
} | ||
} | ||
catch (e) { | ||
elementState.updatedLocally = true; | ||
throw e; | ||
} | ||
finally { | ||
elementState.savingToServer = false; | ||
} | ||
}, 500), | ||
}); | ||
} | ||
function replaceDataWith(newData) { | ||
setData(newData); | ||
const elementState = elementStateCache.get(elementKey); | ||
const accessor = integrationApp ? accessorGenerator(integrationApp) : null; | ||
const swrKey = accessor && selector ? `element:${elementKey}` : null; | ||
const { data: item, mutate, error, isLoading, isValidating, } = useSWR(swrKey, () => accessor === null || accessor === void 0 ? void 0 : accessor.get(), { | ||
isPaused: () => elementState.updatedLocally || elementState.savingToServer, | ||
}); | ||
const loading = isLoading; | ||
const refreshing = isValidating; | ||
async function refresh() { | ||
return await mutate(); | ||
} | ||
const selector = (props === null || props === void 0 ? void 0 : props.id) | ||
? props.id | ||
: props; | ||
const accessor = integrationApp | ||
? accessorGenerator(integrationApp)(selector) | ||
: null; | ||
react.useEffect(() => { | ||
setLoading(true); | ||
setError(null); | ||
if (integrationApp && selector) { | ||
accessor | ||
.get() | ||
.then(setData) | ||
.catch(setError) | ||
.finally(() => setLoading(false)); | ||
async function put(data) { | ||
if (!(accessor === null || accessor === void 0 ? void 0 : accessor.put)) { | ||
throw new Error(`"put method is not supported for accessor ${accessor.constructor.name}`); | ||
} | ||
else { | ||
setError(new Error('IntegrationApp not found. Was this component wrapped in <IntegrationAppProvider>?')); | ||
} | ||
}, [ | ||
integrationApp, | ||
JSON.stringify(selector), | ||
JSON.stringify(props), | ||
refreshCounter, | ||
]); | ||
async function create(createData) { | ||
const returnedData = await accessor.create(createData); | ||
replaceDataWith(returnedData); | ||
return returnedData; | ||
elementState.updatedLocally = true; | ||
const newLocalData = { | ||
...item, | ||
...data, | ||
}; | ||
await mutate(newLocalData, false); | ||
await elementState.debouncedPut(data); | ||
} | ||
function refresh() { | ||
setRefreshCounter(refreshCounter + 1); | ||
async function patch(data) { | ||
const newData = { | ||
...item, | ||
...data, | ||
}; | ||
return put(newData); | ||
} | ||
async function patch(patch) { | ||
if (typeof patch === 'object') { | ||
updateDataWith(patch !== null && patch !== void 0 ? patch : {}); | ||
return accessor.patch(patch); | ||
async function archive() { | ||
if (!(accessor === null || accessor === void 0 ? void 0 : accessor.archive)) { | ||
return; | ||
} | ||
else { | ||
return data; | ||
await mutate({ ...item, archivedAt: new Date().toISOString() }, false); | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.archive()); | ||
await mutate(); | ||
} | ||
async function create(data) { | ||
if (!(accessor === null || accessor === void 0 ? void 0 : accessor.create)) { | ||
throw new Error(`"create method is not supported for accessor ${accessor.constructor.name}`); | ||
} | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.create(data)); | ||
return await mutate(result); | ||
} | ||
async function put(putData) { | ||
updateDataWith(putData); | ||
return await accessor.put(putData); | ||
} | ||
async function archive() { | ||
setData(null); | ||
return accessor.archive(); | ||
} | ||
return { | ||
data, | ||
accessor, | ||
item, | ||
loading, | ||
saving: elementState.updatedLocally || elementState.savingToServer, | ||
error, | ||
refresh, | ||
refreshing, | ||
create, | ||
@@ -118,57 +128,47 @@ patch, | ||
archive, | ||
refresh, | ||
loading, | ||
error, | ||
accessor, | ||
}; | ||
} | ||
function useIntegration(idOrKey) { | ||
const { data: integration, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.integration.bind(integrationApp)); | ||
return { integration, ...rest }; | ||
function useConnection(id) { | ||
const { item: connection, ...rest } = useElement(id, (integrationApp) => integrationApp.connection(id)); | ||
return { | ||
connection, | ||
...rest, | ||
}; | ||
} | ||
function useElements(initialQuery, accessorGenerator) { | ||
const LIMIT = 25; | ||
function useElements(route, query = {}) { | ||
const integrationApp = useIntegrationApp(); | ||
const refreshId = react.useRef(0); | ||
const [items, setItems] = react.useState([]); | ||
const [nextCursor, setNextCursor] = react.useState(undefined); | ||
const [loading, setLoading] = react.useState(false); | ||
const [error, setError] = react.useState(null); | ||
function getKey(page, previousPageData) { | ||
var _a; | ||
if (page === 0) | ||
return `/${route}?${qs.stringify({ | ||
...query, | ||
limit: LIMIT, | ||
})}`; | ||
if (((_a = previousPageData.items) === null || _a === void 0 ? void 0 : _a.length) < LIMIT) | ||
return null; | ||
return `/${route}?${qs.stringify({ | ||
...query, | ||
limit: LIMIT, | ||
cursor: previousPageData.cursor, | ||
})}`; | ||
} | ||
const [loadingMore, setIsLoadingMore] = react.useState(false); | ||
const { data, size, setSize, isLoading, error, mutate, isValidating } = useSWRInfinite(getKey, (url) => integrationApp.get(url)); | ||
const items = data ? data.map((page) => page.items).flat() : []; | ||
const loading = isLoading; | ||
const refreshing = isValidating; | ||
async function loadMore() { | ||
const startingRefreshId = refreshId.current; | ||
const isFirstPage = !nextCursor; | ||
function setStateIfCurrentRefresh(stateSetter, valueGetter) { | ||
stateSetter((value) => startingRefreshId === refreshId.current ? valueGetter(value) : value); | ||
var _a, _b; | ||
const hasMoreToLoad = ((_b = (_a = data[size - 1]) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) === LIMIT; | ||
if (hasMoreToLoad) { | ||
setIsLoadingMore(true); | ||
await setSize(size + 1); | ||
setIsLoadingMore(false); | ||
} | ||
setStateIfCurrentRefresh(setError, () => null); | ||
setStateIfCurrentRefresh(setLoading, () => true); | ||
const queryParams = { | ||
...initialQuery, | ||
}; | ||
if (nextCursor) | ||
queryParams.cursor = nextCursor; | ||
try { | ||
const data = await accessorGenerator(integrationApp).find(queryParams); | ||
setStateIfCurrentRefresh(setNextCursor, () => data.cursor); | ||
setStateIfCurrentRefresh(setItems, (items) => isFirstPage ? data.items : [...items, ...data.items]); | ||
} | ||
catch (e) { | ||
setStateIfCurrentRefresh(setError, () => e); | ||
} | ||
finally { | ||
setStateIfCurrentRefresh(setLoading, () => false); | ||
} | ||
} | ||
react.useEffect(() => { | ||
if (!integrationApp) { | ||
setError(new Error('IntegrationApp not found. Was this component wrapped in <IntegrationAppProvider>?')); | ||
return; | ||
} | ||
refresh(); | ||
}, [integrationApp, JSON.stringify(initialQuery)]); | ||
async function refresh() { | ||
refreshId.current += 1; | ||
setNextCursor(undefined); | ||
await loadMore(); | ||
await mutate(); | ||
} | ||
@@ -178,3 +178,5 @@ return { | ||
refresh, | ||
refreshing, | ||
loadMore, | ||
loadingMore, | ||
loading, | ||
@@ -185,5 +187,6 @@ error, | ||
function useIntegrations(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.integrations); | ||
function useConnections(query) { | ||
const { ...rest } = useElements('connections', query); | ||
return { | ||
connections: rest.items, | ||
...rest, | ||
@@ -193,10 +196,17 @@ }; | ||
function useConnection(id) { | ||
const { data: connection, ...rest } = useElement(id, (integrationApp) => integrationApp.connection.bind(integrationApp)); | ||
return { connection, ...rest }; | ||
function useConnectorSpec(integrationIdOrKey) { | ||
const integrationApp = useIntegrationApp(); | ||
const { data, isLoading, error } = useSWR(`/integrations/${integrationIdOrKey}/connector-spec`, () => integrationApp.integration(integrationIdOrKey).getConnectorSpec()); | ||
return { data, loading: isLoading, error }; | ||
} | ||
function useConnections(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.connections); | ||
function useIntegration(id) { | ||
const { item: integration, ...rest } = useElement(id, (integrationApp) => integrationApp.integration(id)); | ||
return { integration, ...rest }; | ||
} | ||
function useIntegrations(query) { | ||
const { ...rest } = useElements('integrations', query); | ||
return { | ||
integrations: rest.items, | ||
...rest, | ||
@@ -206,10 +216,36 @@ }; | ||
function useFieldMapping(idOrKey) { | ||
const { data: fieldMapping, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.fieldMapping.bind(integrationApp)); | ||
return { fieldMapping, ...rest }; | ||
function useFieldMapping(selector) { | ||
const { item: fieldMapping, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.fieldMapping(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
return { fieldMapping, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useFieldMappings(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.fieldMappings); | ||
function useFieldMappingInstance(selector) { | ||
const { item: fieldMappingInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.fieldMappingInstance(selector)); | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.openConfiguration(options); | ||
} | ||
return { | ||
fieldMappingInstance, | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
openConfiguration, | ||
...rest, | ||
@@ -219,10 +255,6 @@ }; | ||
function useFieldMappingInstance(selector) { | ||
const { data: fieldMappingInstance, ...rest } = useElement(selector, (integrationApp) => integrationApp.fieldMappingInstance.bind(integrationApp)); | ||
const accessor = rest.accessor; | ||
function useFieldMappingInstances(query) { | ||
const { ...rest } = useElements('field-mapping-instances', query); | ||
return { | ||
fieldMappingInstance, | ||
setup: () => accessor.setup(), | ||
reset: () => accessor.reset(), | ||
openConfiguration: (options) => accessor.openConfiguration(options), | ||
fieldMappingInstances: rest.items, | ||
...rest, | ||
@@ -232,5 +264,6 @@ }; | ||
function useFieldMappingInstances(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.fieldMappingInstances); | ||
function useFieldMappings(query) { | ||
const { ...rest } = useElements('field-mappings', query); | ||
return { | ||
fieldMappings: rest.items, | ||
...rest, | ||
@@ -240,10 +273,20 @@ }; | ||
function useDataSource(idOrKey) { | ||
const { data: dataSource, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.dataSource.bind(integrationApp)); | ||
return { dataSource, ...rest }; | ||
function useDataSource(selector) { | ||
const { item: dataSource, refresh, accessor, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataSource(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
return { dataSource, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useDataSources(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.dataSources); | ||
function useDataSourceEvents(query) { | ||
const { ...rest } = useElements('data-source-events', query); | ||
return { | ||
dataSourceEvents: rest, | ||
...rest, | ||
@@ -254,20 +297,86 @@ }; | ||
function useDataSourceInstance(selector) { | ||
const { data: dataSourceInstance, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataSourceInstance.bind(integrationApp)); | ||
const accessor = rest.accessor; | ||
const { item: dataSourceInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataSourceInstance(selector)); | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function subscribe(eventType) { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.subscribe(eventType)); | ||
await refresh(); | ||
} | ||
async function resubscribe(eventType) { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.resubscribe(eventType)); | ||
await refresh(); | ||
} | ||
async function unsubscribe(eventType) { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.unsubscribe(eventType)); | ||
await refresh(); | ||
} | ||
async function pullUpdates() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.pullUpdates()); | ||
await refresh(); | ||
} | ||
async function fullSync() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.fullSync()); | ||
await refresh(); | ||
} | ||
async function getSyncsList() { | ||
return await (accessor === null || accessor === void 0 ? void 0 : accessor.getSyncsList()); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.openConfiguration(options); | ||
} | ||
async function listRecords(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.listRecords(request); | ||
} | ||
async function findRecords(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.findRecords(request); | ||
} | ||
async function findRecordById(id) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.findRecordById(id); | ||
} | ||
async function createRecord(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.createRecord(request); | ||
} | ||
async function updateRecord(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.updateRecord(request); | ||
} | ||
async function deleteRecord(id) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.deleteRecord(id); | ||
} | ||
async function unifiedFieldsToNative(unifiedFields) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.unifiedFieldsToNative(unifiedFields); | ||
} | ||
async function getCollection() { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.getCollection(); | ||
} | ||
async function getLocations(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.getLocations(request); | ||
} | ||
return { | ||
dataSourceInstance, | ||
setup: () => accessor.setup(), | ||
subscribe: (eventType) => accessor.subscribe(eventType), | ||
resubscribe: (eventType) => accessor.resubscribe(eventType), | ||
unsubscribe: (eventType) => accessor.unsubscribe(eventType), | ||
pullUpdates: () => accessor.pullUpdates(), | ||
fullSync: () => accessor.fullSync(), | ||
reset: () => accessor.reset(), | ||
openConfiguration: (options) => accessor.openConfiguration(options), | ||
findRecords: (request) => accessor.findRecords(request), | ||
findRecordById: (id) => accessor.findRecordById(id), | ||
createRecord: (request) => accessor.createRecord(request), | ||
updateRecord: (request) => accessor.updateRecord(request), | ||
deleteRecord: (id) => accessor.deleteRecord(id), | ||
unifiedFieldsToNative: (unifiedFields) => accessor.unifiedFieldsToNative(unifiedFields), | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
subscribe, | ||
resubscribe, | ||
unsubscribe, | ||
pullUpdates, | ||
fullSync, | ||
getSyncsList, | ||
openConfiguration, | ||
listRecords, | ||
findRecords, | ||
findRecordById, | ||
createRecord, | ||
updateRecord, | ||
deleteRecord, | ||
unifiedFieldsToNative, | ||
getLocations, | ||
getCollection, | ||
...rest, | ||
@@ -277,42 +386,14 @@ }; | ||
function useDataSourceInstances(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.dataSourceInstances); | ||
return { | ||
...rest, | ||
}; | ||
} | ||
function useGetter(key, getter) { | ||
function useDataSourceInstanceCollection(dataSourceInstance) { | ||
const integrationApp = useIntegrationApp(); | ||
const [data, setData] = react.useState(); | ||
const [loading, setLoading] = react.useState(true); | ||
const [error, setError] = react.useState(null); | ||
const [refreshCounter, setRefreshCounter] = react.useState(0); | ||
function refresh() { | ||
setRefreshCounter(refreshCounter + 1); | ||
const { data, error, isLoading, mutate } = useSWR(dataSourceInstance ? `${dataSourceInstance.id}/collection` : null, () => integrationApp.dataSourceInstance(dataSourceInstance.id).getCollection()); | ||
async function refresh() { | ||
return await mutate(); | ||
} | ||
react.useEffect(() => { | ||
if (key !== undefined) { | ||
setLoading(true); | ||
setError(null); | ||
if (integrationApp) { | ||
getter() | ||
.then(setData) | ||
.catch(setError) | ||
.finally(() => setLoading(false)); | ||
} | ||
else { | ||
setError(new Error('IntegrationApp not found. Was this component wrapped in <IntegrationAppProvider>?')); | ||
} | ||
} | ||
}, [integrationApp, key, refreshCounter]); | ||
return { data, loading, error, refresh }; | ||
} | ||
function useDataSourceInstanceCollection(dataSourceInstance) { | ||
const integrationApp = useIntegrationApp(); | ||
const { data: collection, ...rest } = useGetter(dataSourceInstance === null || dataSourceInstance === void 0 ? void 0 : dataSourceInstance.id, () => integrationApp.dataSourceInstance(dataSourceInstance.id).getCollection()); | ||
const collection = data; | ||
return { | ||
collection, | ||
...rest, | ||
refresh, | ||
error, | ||
loading: isLoading, | ||
}; | ||
@@ -324,9 +405,23 @@ } | ||
const integrationApp = useIntegrationApp(); | ||
const { data, ...rest } = useGetter(dataSourceInstance | ||
? `${dataSourceInstance.id}/${JSON.stringify(args)}` | ||
: undefined, () => integrationApp | ||
const { data, error, isLoading, mutate } = useSWR(dataSourceInstance | ||
? `${dataSourceInstance.id}/locations?${qs.stringify(args)}` | ||
: null, () => integrationApp | ||
.dataSourceInstance(dataSourceInstance.id) | ||
.getLocations(args)); | ||
async function refresh() { | ||
return await mutate(); | ||
} | ||
const locations = (_a = data === null || data === void 0 ? void 0 : data.locations) !== null && _a !== void 0 ? _a : []; | ||
return { | ||
locations: (_a = data === null || data === void 0 ? void 0 : data.locations) !== null && _a !== void 0 ? _a : [], | ||
locations, | ||
refresh, | ||
error, | ||
loading: isLoading, | ||
}; | ||
} | ||
function useDataSourceInstances(query) { | ||
const { ...rest } = useElements('data-source-instances', query); | ||
return { | ||
dataSourceInstances: rest.items, | ||
...rest, | ||
@@ -336,5 +431,6 @@ }; | ||
function useDataSourceEvents(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.dataSourceEvents); | ||
function useDataSources(query) { | ||
const { ...rest } = useElements('data-sources', query); | ||
return { | ||
dataSources: rest.items, | ||
...rest, | ||
@@ -344,5 +440,11 @@ }; | ||
function useAppEvents(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.appEvents); | ||
function useAppEventSubscription(selector) { | ||
const { item: appEventSubscription, ...rest } = useElement(selector, (integrationApp) => integrationApp.appEventSubscription(selector)); | ||
return { appEventSubscription, ...rest }; | ||
} | ||
function useAppEventSubscriptions(query) { | ||
const { ...rest } = useElements('app-event-subscriptions', query); | ||
return { | ||
appEventSubscriptions: rest.items, | ||
...rest, | ||
@@ -352,4 +454,4 @@ }; | ||
function useAppEventType(idOrKey) { | ||
const { data: appEventType, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.appEventType.bind(integrationApp)); | ||
function useAppEventType(id) { | ||
const { item: appEventType, ...rest } = useElement(id, (integrationApp) => integrationApp.appEventType(id)); | ||
return { appEventType, ...rest }; | ||
@@ -359,4 +461,5 @@ } | ||
function useAppEventTypes(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.appEventTypes); | ||
const { ...rest } = useElements('app-event-types', query); | ||
return { | ||
appEventTypes: rest.items, | ||
...rest, | ||
@@ -366,10 +469,6 @@ }; | ||
function useAppEventSubscription(selector) { | ||
const { data: appEventSubscription, ...rest } = useElement(selector, (integrationApp) => integrationApp.appEventSubscription.bind(integrationApp)); | ||
return { appEventSubscription, ...rest }; | ||
} | ||
function useAppEventSubscriptions(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.appEventSubscriptions); | ||
function useAppEvents(query) { | ||
const { ...rest } = useElements('app-events', query); | ||
return { | ||
appEvents: rest.items, | ||
...rest, | ||
@@ -379,20 +478,70 @@ }; | ||
function useFlow(idOrSelector) { | ||
const { data: flow, ...rest } = useElement(idOrSelector, (integrationApp) => integrationApp.flow.bind(integrationApp)); | ||
return { flow, ...rest }; | ||
function useFlow(selector) { | ||
const { item: flow, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.flow(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
return await refresh(); | ||
} | ||
return { flow, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useFlows(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.flows); | ||
return { ...rest }; | ||
const { ...rest } = useElements('flows', query); | ||
return { | ||
flows: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useFlowInstance(props) { | ||
const { data: flowInstance, ...rest } = useElement(props, (integrationApp) => integrationApp.flowInstance.bind(integrationApp)); | ||
return { flowInstance, ...rest }; | ||
function useFlowInstance(selector) { | ||
const { item: flowInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.flowInstance(selector)); | ||
async function enable() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.enable()); | ||
await refresh(); | ||
} | ||
async function disable() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.disable()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.openConfiguration(options); | ||
} | ||
async function run(options = {}) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.run(options); | ||
} | ||
async function startRun(options = {}) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.startRun(options); | ||
} | ||
return { | ||
flowInstance, | ||
accessor, | ||
refresh, | ||
enable, | ||
disable, | ||
reset, | ||
setup, | ||
openConfiguration, | ||
run, | ||
startRun, | ||
...rest, | ||
}; | ||
} | ||
function useFlowInstances(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.flowInstances); | ||
const { ...rest } = useElements('flow-instances', query); | ||
return { | ||
flowInstances: rest.items, | ||
...rest, | ||
@@ -403,11 +552,127 @@ }; | ||
function useFlowRun(id) { | ||
const { data: flowRun, ...rest } = useElement(id, (integrationApp) => integrationApp.flowRun.bind(integrationApp)); | ||
return { flowRun, ...rest }; | ||
const { item: flowRun, archive, refresh, error, loading, } = useElement(id, (integrationApp) => integrationApp.flowRun(id)); | ||
return { | ||
flowRun, | ||
error, | ||
loading, | ||
refresh, | ||
archive, | ||
}; | ||
} | ||
function useFlowRuns(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.flowRuns); | ||
return { ...rest }; | ||
const { ...rest } = useElements('flow-runs', query); | ||
return { | ||
flowRuns: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useDataLinkTable(selector) { | ||
const { item: dataLinkTable, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataLinkTable(selector)); | ||
return { dataLinkTable, ...rest }; | ||
} | ||
function useDataLinkTableInstance(selector) { | ||
const { item: dataLinkTableInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataLinkTableInstance(selector)); | ||
return { | ||
dataLinkTableInstance, | ||
accessor, | ||
refresh, | ||
findLinks: accessor === null || accessor === void 0 ? void 0 : accessor.findLinks, | ||
createLink: accessor === null || accessor === void 0 ? void 0 : accessor.createLink, | ||
deleteLink: accessor === null || accessor === void 0 ? void 0 : accessor.deleteLink, | ||
...rest, | ||
}; | ||
} | ||
function useDataLinkTableInstances(query) { | ||
const { ...rest } = useElements('data-link-table-instances', query); | ||
return { | ||
dataLinkTableInstances: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useDataLinkTables(query) { | ||
const { ...rest } = useElements('data-link-tables', query); | ||
return { | ||
dataLinkTables: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useAction(selector) { | ||
const { item: action, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.action(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
return { action, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useActionInstance(selector) { | ||
const { item: actionInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.actionInstance(selector)); | ||
async function run(input) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.run(input); | ||
} | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.open(options); | ||
} | ||
return { | ||
actionInstance, | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
openConfiguration, | ||
run, | ||
...rest, | ||
}; | ||
} | ||
function useActionInstances(query) { | ||
const { ...rest } = useElements('action-instances', query); | ||
return { | ||
actionInstances: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useActions(query) { | ||
const { ...rest } = useElements('actions', query); | ||
return { | ||
actions: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useScreen(selector) { | ||
const { item: screen, ...rest } = useElement(selector, (integrationApp) => integrationApp.screen(selector)); | ||
return { screen, ...rest }; | ||
} | ||
function useDataCollectionSpec({ path, key, integrationId, }) { | ||
var _a; | ||
const client = useIntegrationApp(); | ||
const dataCollectionKey = key !== null && key !== void 0 ? key : (_a = sdk.parseDataLocationPath(path)) === null || _a === void 0 ? void 0 : _a.key; | ||
const { data: dataCollectionSpec } = useSWR(dataCollectionKey && integrationId | ||
? `/integrations/${integrationId}/data/${dataCollectionKey}` | ||
: null, () => client.integration(integrationId).getDataLocation(dataCollectionKey)); | ||
return dataCollectionSpec; | ||
} | ||
Object.defineProperty(exports, 'DataForm', { | ||
@@ -418,2 +683,6 @@ enumerable: true, | ||
exports.IntegrationAppProvider = IntegrationAppProvider; | ||
exports.useAction = useAction; | ||
exports.useActionInstance = useActionInstance; | ||
exports.useActionInstances = useActionInstances; | ||
exports.useActions = useActions; | ||
exports.useAppEventSubscription = useAppEventSubscription; | ||
@@ -427,8 +696,13 @@ exports.useAppEventSubscriptions = useAppEventSubscriptions; | ||
exports.useConnectorSpec = useConnectorSpec; | ||
exports.useDataCollectionSpec = useDataCollectionSpec; | ||
exports.useDataLinkTable = useDataLinkTable; | ||
exports.useDataLinkTableInstance = useDataLinkTableInstance; | ||
exports.useDataLinkTableInstances = useDataLinkTableInstances; | ||
exports.useDataLinkTables = useDataLinkTables; | ||
exports.useDataSource = useDataSource; | ||
exports.useDataSourceCollection = useDataSourceInstanceCollection; | ||
exports.useDataSourceEvents = useDataSourceEvents; | ||
exports.useDataSourceInstance = useDataSourceInstance; | ||
exports.useDataSourceInstanceCollection = useDataSourceInstanceCollection; | ||
exports.useDataSourceInstanceLocations = useDataSourceInstanceLocations; | ||
exports.useDataSourceInstances = useDataSourceInstances; | ||
exports.useDataSourceLocations = useDataSourceInstanceLocations; | ||
exports.useDataSources = useDataSources; | ||
@@ -447,3 +721,5 @@ exports.useFieldMapping = useFieldMapping; | ||
exports.useIntegrationApp = useIntegrationApp; | ||
exports.useIntegrationAppSWR = useIntegrationAppSWR; | ||
exports.useIntegrations = useIntegrations; | ||
exports.useScreen = useScreen; | ||
//# sourceMappingURL=index.js.map |
import * as _integration_app_sdk from '@integration-app/sdk'; | ||
import { IntegrationAppClient, ConnectionSpec, Integration, IntegrationAccessor, FindIntegrationsQuery, Connection, ConnectionAccessor, FindConnectionsQuery, FieldMapping, FieldMappingAccessor, FindFieldMappingsQuery, FieldMappingInstanceSelector, FieldMappingInstance, FieldMappingInstanceAccessor, OpenFieldMappingInstanceConfigurationOptions, FindFieldMappingInstancesQuery, DataSource, DataSourceAccessor, FindDataSourcesQuery, DataSourceInstanceSelector, DataSourceInstance, DataSourceInstanceAccessor, OpenDataSourceConfigurationOptions, DataCollectionFindRequest, DataCollectionCreateRequest, DataCollectionUpdateRequest, FindDataSourceInstancesQuery, DataCollectionSpec, FindDataSourceEventsQuery, DataSourceEvent, FindAppEventsQuery, AppEvent, AppEventType, AppEventTypeAccessor, FindAppEventTypesQuery, AppEventSubscriptionSelector, AppEventSubscription, AppEventSubscriptionAccessor, FindAppEventSubscriptionsQuery, FlowSelector, Flow, FlowAccessor, FindFlowsRequest, FlowInstanceSelector, FlowInstance, FlowInstanceAccessor, FindFlowInstancesQuery, FlowRun, FlowRunAccessor, FindFlowRunsRequest } from '@integration-app/sdk'; | ||
import { IntegrationAppClient, ConnectionAccessor, Connection, CreateConnectionRequest, UpdateConnectionRequest, FindConnectionsQuery, ConnectionSpec, IntegrationAccessor, Integration, CreateIntegrationRequest, UpdateIntegrationRequest, FindIntegrationsQuery, FieldMappingSelector, CreateFieldMappingRequest, FieldMapping, UpdateFieldMappingRequest, FieldMappingAccessor, FieldMappingInstanceSelector, CreateFieldMappingInstanceRequest, FieldMappingInstance, UpdateFieldMappingInstanceRequest, FieldMappingInstanceAccessor, OpenFieldMappingInstanceConfigurationOptions, FindFieldMappingInstancesQuery, FindFieldMappingsQuery, DataSourceSelector, CreateDataSourceRequest, DataSource, DataSourceAccessor, FindDataSourceEventsQuery, DataSourceEvent, DataSourceInstanceSelector, CreateDataSourceInstanceRequest, DataSourceInstance, UpdateDataSourceInstanceRequest, DataSourceInstanceAccessor, OpenDataSourceConfigurationOptions, DataCollectionListRequest, DataCollectionFindRequest, DataCollectionCreateRequest, DataCollectionUpdateRequest, DataDirectoryListRequest, DataCollectionSpec, DataDirectoryListResponse, FindDataSourceInstancesQuery, FindDataSourcesQuery, AppEventSubscriptionSelector, AppEventSubscriptionAccessor, AppEventSubscription, IAppEventSubscriptionUpdate, FindAppEventSubscriptionsQuery, AppEventTypeAccessor, AppEventType, CreateAppEventTypeRequest, FindAppEventTypesQuery, FindAppEventsQuery, AppEvent, FlowSelector, CreateFlowRequest, Flow, UpdateFlowRequest, FlowAccessor, FindFlowsRequest, FlowInstanceSelector, UpdateFlowInstanceRequest, FlowInstance, FlowInstanceAccessor, OpenFlowInstanceConfigurationOptions, RunFlowOptions, FindFlowInstancesQuery, FlowRun, FindFlowRunsRequest, DataLinkTableAccessor, DataLinkTable, CreateDataLinkTableRequest, DataLinkTableInstanceSelector, CreateDataLinkTableInstanceRequest, DataLinkTableInstance, UpdateDataLinkTableInstanceRequest, DataLinkTableInstanceAccessor, FindDataLinkTableInstancesQuery, FindDataLinkTablesQuery, ActionSelector, CreateActionRequest, Action, UpdateActionRequest, ActionAccessor, ActionInstanceSelector, CreateActionInstanceRequest, ActionInstance, UpdateActionInstanceRequest, ActionInstanceAccessor, OpenActionConfigurationOptions, FindActionInstancesQuery, FindActionsQuery, ScreenSelector, ScreenAccessor, Screen, CreateScreenRequest, UpdateScreenRequest } from '@integration-app/sdk'; | ||
export { DataForm } from '@integration-app/sdk'; | ||
import { ReactNode } from 'react'; | ||
import * as swr__internal from 'swr/_internal'; | ||
@@ -18,80 +19,88 @@ interface IntegrationAppProviderProps { | ||
declare function useConnectorSpec(integrationKey: string): { | ||
data: ConnectionSpec; | ||
declare function useIntegrationAppSWR(path: string, options?: any): swr__internal.SWRResponse<any, any, any>; | ||
declare function useConnection(id: string): { | ||
accessor: ConnectionAccessor; | ||
loading: boolean; | ||
error: Error; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Connection>; | ||
refreshing: boolean; | ||
create: (data: CreateConnectionRequest) => Promise<Connection>; | ||
patch: (data: Partial<UpdateConnectionRequest>) => Promise<void>; | ||
put: (data: UpdateConnectionRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
connection: Connection; | ||
}; | ||
declare function useIntegration(idOrKey: string): { | ||
declare function useConnections(query?: FindConnectionsQuery): { | ||
items: Connection[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateIntegrationRequest) => Promise<Integration>; | ||
patch: (data: _integration_app_sdk.UpdateIntegrationRequest) => Promise<Integration>; | ||
put: (data: _integration_app_sdk.CreateIntegrationRequest) => Promise<Integration>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: IntegrationAccessor; | ||
integration: Integration; | ||
error: any; | ||
connections: Connection[]; | ||
}; | ||
declare function useIntegrations(query?: FindIntegrationsQuery): { | ||
items: Integration[]; | ||
declare function useConnectorSpec(integrationIdOrKey: string): { | ||
data: ConnectionSpec; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
}; | ||
declare function useConnection(id: string): { | ||
declare function useIntegration(id: string): { | ||
accessor: IntegrationAccessor; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<Connection>) => Promise<Connection>; | ||
patch: (data: Partial<Connection>) => Promise<Connection>; | ||
put: (data: Partial<Connection>) => Promise<Connection>; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Integration>; | ||
refreshing: boolean; | ||
create: (data: CreateIntegrationRequest) => Promise<Integration>; | ||
patch: (data: Partial<UpdateIntegrationRequest>) => Promise<void>; | ||
put: (data: UpdateIntegrationRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: ConnectionAccessor; | ||
connection: Connection; | ||
integration: Integration; | ||
}; | ||
declare function useConnections(query?: FindConnectionsQuery): { | ||
items: Connection[]; | ||
declare function useIntegrations(query?: FindIntegrationsQuery): { | ||
items: Integration[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
integrations: Integration[]; | ||
}; | ||
declare function useFieldMapping(idOrKey: string): { | ||
declare function useFieldMapping(selector: FieldMappingSelector | string): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
patch: (data: Partial<_integration_app_sdk.CreateFieldMappingRequest>) => Promise<FieldMapping>; | ||
put: (data: _integration_app_sdk.CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
patch: (data: Partial<UpdateFieldMappingRequest>) => Promise<void>; | ||
put: (data: UpdateFieldMappingRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
fieldMapping: FieldMapping; | ||
apply: (integrationKeys: string[]) => Promise<FieldMapping[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<FieldMapping>; | ||
accessor: FieldMappingAccessor; | ||
fieldMapping: FieldMapping; | ||
}; | ||
declare function useFieldMappings(query?: FindFieldMappingsQuery): { | ||
items: FieldMapping[]; | ||
declare function useFieldMappingInstance(selector: string | FieldMappingInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useFieldMappingInstance(selector: FieldMappingInstanceSelector | { | ||
id: string; | ||
}): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
patch: (data: _integration_app_sdk.UpdateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
put: (data: _integration_app_sdk.CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
patch: (data: Partial<UpdateFieldMappingInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateFieldMappingInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
fieldMappingInstance: FieldMappingInstance; | ||
accessor: FieldMappingInstanceAccessor; | ||
fieldMappingInstance: FieldMappingInstance; | ||
refresh: () => Promise<FieldMappingInstance>; | ||
setup: () => Promise<void>; | ||
@@ -104,41 +113,71 @@ reset: () => Promise<void>; | ||
items: FieldMappingInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
fieldMappingInstances: FieldMappingInstance[]; | ||
}; | ||
declare function useDataSource(idOrKey: string): { | ||
declare function useFieldMappings(query?: FindFieldMappingsQuery): { | ||
items: FieldMapping[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateDataSourceRequest) => Promise<DataSource>; | ||
patch: (data: Partial<_integration_app_sdk.CreateDataSourceRequest>) => Promise<DataSource>; | ||
put: (data: _integration_app_sdk.CreateDataSourceRequest) => Promise<DataSource>; | ||
error: any; | ||
fieldMappings: FieldMapping[]; | ||
}; | ||
declare function useDataSource(selector: string | DataSourceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataSourceRequest) => Promise<DataSource>; | ||
patch: (data: Partial<Partial<CreateDataSourceRequest>>) => Promise<void>; | ||
put: (data: Partial<CreateDataSourceRequest>) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
dataSource: DataSource; | ||
apply: (integrationKeys: string[]) => Promise<DataSource[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<DataSource>; | ||
accessor: DataSourceAccessor; | ||
dataSource: DataSource; | ||
}; | ||
declare function useDataSources(query?: FindDataSourcesQuery): { | ||
items: DataSource[]; | ||
declare function useDataSourceEvents(query?: FindDataSourceEventsQuery): { | ||
items: DataSourceEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSourceEvents: { | ||
items: DataSourceEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
}; | ||
}; | ||
declare function useDataSourceInstance(selector: DataSourceInstanceSelector | { | ||
id: string; | ||
}): { | ||
declare function useDataSourceInstance(selector: string | DataSourceInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
patch: (data: _integration_app_sdk.UpdateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
put: (data: _integration_app_sdk.CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
patch: (data: Partial<UpdateDataSourceInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateDataSourceInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
dataSourceInstance: DataSourceInstance; | ||
accessor: DataSourceInstanceAccessor; | ||
dataSourceInstance: DataSourceInstance; | ||
refresh: () => Promise<DataSourceInstance>; | ||
setup: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
subscribe: (eventType: any) => Promise<void>; | ||
@@ -149,4 +188,5 @@ resubscribe: (eventType: any) => Promise<void>; | ||
fullSync: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
getSyncsList: () => Promise<_integration_app_sdk.DataSourceSync[]>; | ||
openConfiguration: (options?: OpenDataSourceConfigurationOptions) => Promise<void>; | ||
listRecords: (request?: DataCollectionListRequest) => Promise<_integration_app_sdk.DataCollectionListResponse>; | ||
findRecords: (request?: DataCollectionFindRequest) => Promise<_integration_app_sdk.DataCollectionFindResponse>; | ||
@@ -158,17 +198,13 @@ findRecordById: (id: string) => Promise<_integration_app_sdk.DataCollectionFindByIdResponse>; | ||
unifiedFieldsToNative: (unifiedFields: any) => Promise<any>; | ||
getLocations: (request: DataDirectoryListRequest & { | ||
path?: string; | ||
}) => Promise<_integration_app_sdk.DataDirectoryListResponse>; | ||
getCollection: () => Promise<_integration_app_sdk.DataCollectionSpec>; | ||
}; | ||
declare function useDataSourceInstances(query?: FindDataSourceInstancesQuery): { | ||
items: DataSourceInstance[]; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useDataSourceInstanceCollection(dataSourceInstance: DataSourceInstance): { | ||
collection: DataCollectionSpec; | ||
refresh: () => Promise<DataCollectionSpec>; | ||
error: any; | ||
loading: boolean; | ||
error: Error; | ||
refresh: () => void; | ||
collection: DataCollectionSpec; | ||
}; | ||
@@ -180,33 +216,66 @@ | ||
}): { | ||
locations: _integration_app_sdk.DataLocation[]; | ||
refresh: () => Promise<DataDirectoryListResponse>; | ||
error: any; | ||
loading: boolean; | ||
error: Error; | ||
refresh: () => void; | ||
locations: _integration_app_sdk.DataLocation[]; | ||
}; | ||
declare function useDataSourceEvents(query?: FindDataSourceEventsQuery): { | ||
items: DataSourceEvent[]; | ||
declare function useDataSourceInstances(query?: FindDataSourceInstancesQuery): { | ||
items: DataSourceInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSourceInstances: DataSourceInstance[]; | ||
}; | ||
declare function useAppEvents(query?: FindAppEventsQuery): { | ||
items: AppEvent[]; | ||
declare function useDataSources(query?: FindDataSourcesQuery): { | ||
items: DataSource[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSources: DataSource[]; | ||
}; | ||
declare function useAppEventType(idOrKey: string): { | ||
declare function useAppEventSubscription(selector: string | AppEventSubscriptionSelector): { | ||
accessor: AppEventSubscriptionAccessor; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
patch: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
put: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<AppEventSubscription>; | ||
refreshing: boolean; | ||
create: (data: IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
patch: (data: Partial<IAppEventSubscriptionUpdate>) => Promise<void>; | ||
put: (data: IAppEventSubscriptionUpdate) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
appEventSubscription: AppEventSubscription; | ||
}; | ||
declare function useAppEventSubscriptions(query?: FindAppEventSubscriptionsQuery): { | ||
items: AppEventSubscription[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
appEventSubscriptions: AppEventSubscription[]; | ||
}; | ||
declare function useAppEventType(id: string): { | ||
accessor: AppEventTypeAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<AppEventType>; | ||
refreshing: boolean; | ||
create: (data: CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
patch: (data: Partial<CreateAppEventTypeRequest>) => Promise<void>; | ||
put: (data: CreateAppEventTypeRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
appEventType: AppEventType; | ||
@@ -217,40 +286,36 @@ }; | ||
items: AppEventType[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
appEventTypes: AppEventType[]; | ||
}; | ||
declare function useAppEventSubscription(selector: AppEventSubscriptionSelector | { | ||
id: string; | ||
}): { | ||
declare function useAppEvents(query?: FindAppEventsQuery): { | ||
items: AppEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
patch: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
put: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: AppEventSubscriptionAccessor; | ||
appEventSubscription: AppEventSubscription; | ||
error: any; | ||
appEvents: AppEvent[]; | ||
}; | ||
declare function useAppEventSubscriptions(query?: FindAppEventSubscriptionsQuery): { | ||
items: AppEventSubscription[]; | ||
declare function useFlow(selector: string | FlowSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useFlow(idOrSelector: string | FlowSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<Flow>) => Promise<Flow>; | ||
patch: (data: Partial<Flow>) => Promise<Flow>; | ||
put: (data: Partial<Flow>) => Promise<Flow>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFlowRequest) => Promise<Flow>; | ||
patch: (data: Partial<UpdateFlowRequest>) => Promise<void>; | ||
put: (data: UpdateFlowRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
flow: Flow; | ||
apply: (integrationKeys: string[]) => Promise<Flow[]>; | ||
reset: () => Promise<Flow>; | ||
refresh: () => Promise<Flow>; | ||
accessor: FlowAccessor; | ||
flow: Flow; | ||
}; | ||
@@ -260,20 +325,30 @@ | ||
items: Flow[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flows: Flow[]; | ||
}; | ||
declare function useFlowInstance(props: FlowInstanceSelector | { | ||
id: string; | ||
}): { | ||
declare function useFlowInstance(selector: string | FlowInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFlowInstanceRequest) => Promise<FlowInstance>; | ||
patch: (data: _integration_app_sdk.UpdateFlowInstanceRequest) => Promise<FlowInstance>; | ||
put: (data: _integration_app_sdk.CreateFlowInstanceRequest) => Promise<FlowInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: UpdateFlowInstanceRequest) => Promise<FlowInstance>; | ||
patch: (data: Partial<UpdateFlowInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateFlowInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
flowInstance: FlowInstance; | ||
accessor: FlowInstanceAccessor; | ||
flowInstance: FlowInstance; | ||
refresh: () => Promise<FlowInstance>; | ||
enable: () => Promise<void>; | ||
disable: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
setup: () => Promise<void>; | ||
openConfiguration: (options: OpenFlowInstanceConfigurationOptions) => Promise<void>; | ||
run: (options?: RunFlowOptions) => Promise<_integration_app_sdk.FlowRun>; | ||
startRun: (options?: RunFlowOptions) => Promise<_integration_app_sdk.FlowRun>; | ||
}; | ||
@@ -283,18 +358,17 @@ | ||
items: FlowInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flowInstances: FlowInstance[]; | ||
}; | ||
declare function useFlowRun(id: string): { | ||
flowRun: FlowRun; | ||
error: any; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
patch: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
put: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
refresh: () => Promise<FlowRun>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: FlowRunAccessor; | ||
flowRun: FlowRun; | ||
}; | ||
@@ -304,8 +378,140 @@ | ||
items: FlowRun[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flowRuns: FlowRun[]; | ||
}; | ||
export { IntegrationAppProvider, useAppEventSubscription, useAppEventSubscriptions, useAppEventType, useAppEventTypes, useAppEvents, useConnection, useConnections, useConnectorSpec, useDataSource, useDataSourceInstanceCollection as useDataSourceCollection, useDataSourceEvents, useDataSourceInstance, useDataSourceInstances, useDataSourceInstanceLocations as useDataSourceLocations, useDataSources, useFieldMapping, useFieldMappingInstance, useFieldMappingInstances, useFieldMappings, useFlow, useFlowInstance, useFlowInstances, useFlowRun, useFlowRuns, useFlows, useIntegration, useIntegrationApp, useIntegrations }; | ||
declare function useDataLinkTable(selector: string): { | ||
accessor: DataLinkTableAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<DataLinkTable>; | ||
refreshing: boolean; | ||
create: (data: CreateDataLinkTableRequest) => Promise<DataLinkTable>; | ||
patch: (data: Partial<CreateDataLinkTableRequest>) => Promise<void>; | ||
put: (data: CreateDataLinkTableRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
dataLinkTable: DataLinkTable; | ||
}; | ||
declare function useDataLinkTableInstance(selector: string | DataLinkTableInstanceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataLinkTableInstanceRequest) => Promise<DataLinkTableInstance>; | ||
patch: (data: Partial<UpdateDataLinkTableInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateDataLinkTableInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
dataLinkTableInstance: DataLinkTableInstance; | ||
accessor: DataLinkTableInstanceAccessor; | ||
refresh: () => Promise<DataLinkTableInstance>; | ||
findLinks: (query?: _integration_app_sdk.FindDataLinksInTableQuery) => Promise<_integration_app_sdk.FindDataLinksResponse>; | ||
createLink: (data: _integration_app_sdk.CreateDataLinkRequest) => Promise<void>; | ||
deleteLink: (data: _integration_app_sdk.DeleteDataLinkRequest) => Promise<void>; | ||
}; | ||
declare function useDataLinkTableInstances(query?: FindDataLinkTableInstancesQuery): { | ||
items: DataLinkTableInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
dataLinkTableInstances: DataLinkTableInstance[]; | ||
}; | ||
declare function useDataLinkTables(query?: FindDataLinkTablesQuery): { | ||
items: DataLinkTable[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
dataLinkTables: DataLinkTable[]; | ||
}; | ||
declare function useAction(selector: ActionSelector | string): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateActionRequest) => Promise<Action>; | ||
patch: (data: Partial<UpdateActionRequest>) => Promise<void>; | ||
put: (data: UpdateActionRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
action: Action; | ||
apply: (integrationKeys: string[]) => Promise<Action[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<Action>; | ||
accessor: ActionAccessor; | ||
}; | ||
declare function useActionInstance(selector: string | ActionInstanceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateActionInstanceRequest) => Promise<ActionInstance>; | ||
patch: (data: Partial<UpdateActionInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateActionInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
actionInstance: ActionInstance; | ||
accessor: ActionInstanceAccessor; | ||
refresh: () => Promise<ActionInstance>; | ||
setup: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
openConfiguration: (options?: OpenActionConfigurationOptions) => Promise<void>; | ||
run: (input?: any) => Promise<_integration_app_sdk.ActionRunResponse>; | ||
}; | ||
declare function useActionInstances(query?: FindActionInstancesQuery): { | ||
items: ActionInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
actionInstances: ActionInstance[]; | ||
}; | ||
declare function useActions(query?: FindActionsQuery): { | ||
items: Action[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
actions: Action[]; | ||
}; | ||
declare function useScreen(selector: ScreenSelector | string): { | ||
accessor: ScreenAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Screen>; | ||
refreshing: boolean; | ||
create: (data: CreateScreenRequest) => Promise<Screen>; | ||
patch: (data: Partial<UpdateScreenRequest>) => Promise<void>; | ||
put: (data: UpdateScreenRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
screen: Screen; | ||
}; | ||
declare function useDataCollectionSpec({ path, key, integrationId, }: { | ||
path?: string; | ||
key?: string; | ||
integrationId: string; | ||
}): DataCollectionSpec; | ||
export { IntegrationAppProvider, useAction, useActionInstance, useActionInstances, useActions, useAppEventSubscription, useAppEventSubscriptions, useAppEventType, useAppEventTypes, useAppEvents, useConnection, useConnections, useConnectorSpec, useDataCollectionSpec, useDataLinkTable, useDataLinkTableInstance, useDataLinkTableInstances, useDataLinkTables, useDataSource, useDataSourceEvents, useDataSourceInstance, useDataSourceInstanceCollection, useDataSourceInstanceLocations, useDataSourceInstances, useDataSources, useFieldMapping, useFieldMappingInstance, useFieldMappingInstances, useFieldMappings, useFlow, useFlowInstance, useFlowInstances, useFlowRun, useFlowRuns, useFlows, useIntegration, useIntegrationApp, useIntegrationAppSWR, useIntegrations, useScreen }; |
import * as _integration_app_sdk from '@integration-app/sdk'; | ||
import { IntegrationAppClient, ConnectionSpec, Integration, IntegrationAccessor, FindIntegrationsQuery, Connection, ConnectionAccessor, FindConnectionsQuery, FieldMapping, FieldMappingAccessor, FindFieldMappingsQuery, FieldMappingInstanceSelector, FieldMappingInstance, FieldMappingInstanceAccessor, OpenFieldMappingInstanceConfigurationOptions, FindFieldMappingInstancesQuery, DataSource, DataSourceAccessor, FindDataSourcesQuery, DataSourceInstanceSelector, DataSourceInstance, DataSourceInstanceAccessor, OpenDataSourceConfigurationOptions, DataCollectionFindRequest, DataCollectionCreateRequest, DataCollectionUpdateRequest, FindDataSourceInstancesQuery, DataCollectionSpec, FindDataSourceEventsQuery, DataSourceEvent, FindAppEventsQuery, AppEvent, AppEventType, AppEventTypeAccessor, FindAppEventTypesQuery, AppEventSubscriptionSelector, AppEventSubscription, AppEventSubscriptionAccessor, FindAppEventSubscriptionsQuery, FlowSelector, Flow, FlowAccessor, FindFlowsRequest, FlowInstanceSelector, FlowInstance, FlowInstanceAccessor, FindFlowInstancesQuery, FlowRun, FlowRunAccessor, FindFlowRunsRequest } from '@integration-app/sdk'; | ||
import { IntegrationAppClient, ConnectionAccessor, Connection, CreateConnectionRequest, UpdateConnectionRequest, FindConnectionsQuery, ConnectionSpec, IntegrationAccessor, Integration, CreateIntegrationRequest, UpdateIntegrationRequest, FindIntegrationsQuery, FieldMappingSelector, CreateFieldMappingRequest, FieldMapping, UpdateFieldMappingRequest, FieldMappingAccessor, FieldMappingInstanceSelector, CreateFieldMappingInstanceRequest, FieldMappingInstance, UpdateFieldMappingInstanceRequest, FieldMappingInstanceAccessor, OpenFieldMappingInstanceConfigurationOptions, FindFieldMappingInstancesQuery, FindFieldMappingsQuery, DataSourceSelector, CreateDataSourceRequest, DataSource, DataSourceAccessor, FindDataSourceEventsQuery, DataSourceEvent, DataSourceInstanceSelector, CreateDataSourceInstanceRequest, DataSourceInstance, UpdateDataSourceInstanceRequest, DataSourceInstanceAccessor, OpenDataSourceConfigurationOptions, DataCollectionListRequest, DataCollectionFindRequest, DataCollectionCreateRequest, DataCollectionUpdateRequest, DataDirectoryListRequest, DataCollectionSpec, DataDirectoryListResponse, FindDataSourceInstancesQuery, FindDataSourcesQuery, AppEventSubscriptionSelector, AppEventSubscriptionAccessor, AppEventSubscription, IAppEventSubscriptionUpdate, FindAppEventSubscriptionsQuery, AppEventTypeAccessor, AppEventType, CreateAppEventTypeRequest, FindAppEventTypesQuery, FindAppEventsQuery, AppEvent, FlowSelector, CreateFlowRequest, Flow, UpdateFlowRequest, FlowAccessor, FindFlowsRequest, FlowInstanceSelector, UpdateFlowInstanceRequest, FlowInstance, FlowInstanceAccessor, OpenFlowInstanceConfigurationOptions, RunFlowOptions, FindFlowInstancesQuery, FlowRun, FindFlowRunsRequest, DataLinkTableAccessor, DataLinkTable, CreateDataLinkTableRequest, DataLinkTableInstanceSelector, CreateDataLinkTableInstanceRequest, DataLinkTableInstance, UpdateDataLinkTableInstanceRequest, DataLinkTableInstanceAccessor, FindDataLinkTableInstancesQuery, FindDataLinkTablesQuery, ActionSelector, CreateActionRequest, Action, UpdateActionRequest, ActionAccessor, ActionInstanceSelector, CreateActionInstanceRequest, ActionInstance, UpdateActionInstanceRequest, ActionInstanceAccessor, OpenActionConfigurationOptions, FindActionInstancesQuery, FindActionsQuery, ScreenSelector, ScreenAccessor, Screen, CreateScreenRequest, UpdateScreenRequest } from '@integration-app/sdk'; | ||
export { DataForm } from '@integration-app/sdk'; | ||
import { ReactNode } from 'react'; | ||
import * as swr__internal from 'swr/_internal'; | ||
@@ -18,80 +19,88 @@ interface IntegrationAppProviderProps { | ||
declare function useConnectorSpec(integrationKey: string): { | ||
data: ConnectionSpec; | ||
declare function useIntegrationAppSWR(path: string, options?: any): swr__internal.SWRResponse<any, any, any>; | ||
declare function useConnection(id: string): { | ||
accessor: ConnectionAccessor; | ||
loading: boolean; | ||
error: Error; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Connection>; | ||
refreshing: boolean; | ||
create: (data: CreateConnectionRequest) => Promise<Connection>; | ||
patch: (data: Partial<UpdateConnectionRequest>) => Promise<void>; | ||
put: (data: UpdateConnectionRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
connection: Connection; | ||
}; | ||
declare function useIntegration(idOrKey: string): { | ||
declare function useConnections(query?: FindConnectionsQuery): { | ||
items: Connection[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateIntegrationRequest) => Promise<Integration>; | ||
patch: (data: _integration_app_sdk.UpdateIntegrationRequest) => Promise<Integration>; | ||
put: (data: _integration_app_sdk.CreateIntegrationRequest) => Promise<Integration>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: IntegrationAccessor; | ||
integration: Integration; | ||
error: any; | ||
connections: Connection[]; | ||
}; | ||
declare function useIntegrations(query?: FindIntegrationsQuery): { | ||
items: Integration[]; | ||
declare function useConnectorSpec(integrationIdOrKey: string): { | ||
data: ConnectionSpec; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
}; | ||
declare function useConnection(id: string): { | ||
declare function useIntegration(id: string): { | ||
accessor: IntegrationAccessor; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<Connection>) => Promise<Connection>; | ||
patch: (data: Partial<Connection>) => Promise<Connection>; | ||
put: (data: Partial<Connection>) => Promise<Connection>; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Integration>; | ||
refreshing: boolean; | ||
create: (data: CreateIntegrationRequest) => Promise<Integration>; | ||
patch: (data: Partial<UpdateIntegrationRequest>) => Promise<void>; | ||
put: (data: UpdateIntegrationRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: ConnectionAccessor; | ||
connection: Connection; | ||
integration: Integration; | ||
}; | ||
declare function useConnections(query?: FindConnectionsQuery): { | ||
items: Connection[]; | ||
declare function useIntegrations(query?: FindIntegrationsQuery): { | ||
items: Integration[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
integrations: Integration[]; | ||
}; | ||
declare function useFieldMapping(idOrKey: string): { | ||
declare function useFieldMapping(selector: FieldMappingSelector | string): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
patch: (data: Partial<_integration_app_sdk.CreateFieldMappingRequest>) => Promise<FieldMapping>; | ||
put: (data: _integration_app_sdk.CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFieldMappingRequest) => Promise<FieldMapping>; | ||
patch: (data: Partial<UpdateFieldMappingRequest>) => Promise<void>; | ||
put: (data: UpdateFieldMappingRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
fieldMapping: FieldMapping; | ||
apply: (integrationKeys: string[]) => Promise<FieldMapping[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<FieldMapping>; | ||
accessor: FieldMappingAccessor; | ||
fieldMapping: FieldMapping; | ||
}; | ||
declare function useFieldMappings(query?: FindFieldMappingsQuery): { | ||
items: FieldMapping[]; | ||
declare function useFieldMappingInstance(selector: string | FieldMappingInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useFieldMappingInstance(selector: FieldMappingInstanceSelector | { | ||
id: string; | ||
}): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
patch: (data: _integration_app_sdk.UpdateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
put: (data: _integration_app_sdk.CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFieldMappingInstanceRequest) => Promise<FieldMappingInstance>; | ||
patch: (data: Partial<UpdateFieldMappingInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateFieldMappingInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
fieldMappingInstance: FieldMappingInstance; | ||
accessor: FieldMappingInstanceAccessor; | ||
fieldMappingInstance: FieldMappingInstance; | ||
refresh: () => Promise<FieldMappingInstance>; | ||
setup: () => Promise<void>; | ||
@@ -104,41 +113,71 @@ reset: () => Promise<void>; | ||
items: FieldMappingInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
fieldMappingInstances: FieldMappingInstance[]; | ||
}; | ||
declare function useDataSource(idOrKey: string): { | ||
declare function useFieldMappings(query?: FindFieldMappingsQuery): { | ||
items: FieldMapping[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateDataSourceRequest) => Promise<DataSource>; | ||
patch: (data: Partial<_integration_app_sdk.CreateDataSourceRequest>) => Promise<DataSource>; | ||
put: (data: _integration_app_sdk.CreateDataSourceRequest) => Promise<DataSource>; | ||
error: any; | ||
fieldMappings: FieldMapping[]; | ||
}; | ||
declare function useDataSource(selector: string | DataSourceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataSourceRequest) => Promise<DataSource>; | ||
patch: (data: Partial<Partial<CreateDataSourceRequest>>) => Promise<void>; | ||
put: (data: Partial<CreateDataSourceRequest>) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
dataSource: DataSource; | ||
apply: (integrationKeys: string[]) => Promise<DataSource[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<DataSource>; | ||
accessor: DataSourceAccessor; | ||
dataSource: DataSource; | ||
}; | ||
declare function useDataSources(query?: FindDataSourcesQuery): { | ||
items: DataSource[]; | ||
declare function useDataSourceEvents(query?: FindDataSourceEventsQuery): { | ||
items: DataSourceEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSourceEvents: { | ||
items: DataSourceEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
}; | ||
}; | ||
declare function useDataSourceInstance(selector: DataSourceInstanceSelector | { | ||
id: string; | ||
}): { | ||
declare function useDataSourceInstance(selector: string | DataSourceInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
patch: (data: _integration_app_sdk.UpdateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
put: (data: _integration_app_sdk.CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataSourceInstanceRequest) => Promise<DataSourceInstance>; | ||
patch: (data: Partial<UpdateDataSourceInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateDataSourceInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
dataSourceInstance: DataSourceInstance; | ||
accessor: DataSourceInstanceAccessor; | ||
dataSourceInstance: DataSourceInstance; | ||
refresh: () => Promise<DataSourceInstance>; | ||
setup: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
subscribe: (eventType: any) => Promise<void>; | ||
@@ -149,4 +188,5 @@ resubscribe: (eventType: any) => Promise<void>; | ||
fullSync: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
getSyncsList: () => Promise<_integration_app_sdk.DataSourceSync[]>; | ||
openConfiguration: (options?: OpenDataSourceConfigurationOptions) => Promise<void>; | ||
listRecords: (request?: DataCollectionListRequest) => Promise<_integration_app_sdk.DataCollectionListResponse>; | ||
findRecords: (request?: DataCollectionFindRequest) => Promise<_integration_app_sdk.DataCollectionFindResponse>; | ||
@@ -158,17 +198,13 @@ findRecordById: (id: string) => Promise<_integration_app_sdk.DataCollectionFindByIdResponse>; | ||
unifiedFieldsToNative: (unifiedFields: any) => Promise<any>; | ||
getLocations: (request: DataDirectoryListRequest & { | ||
path?: string; | ||
}) => Promise<_integration_app_sdk.DataDirectoryListResponse>; | ||
getCollection: () => Promise<_integration_app_sdk.DataCollectionSpec>; | ||
}; | ||
declare function useDataSourceInstances(query?: FindDataSourceInstancesQuery): { | ||
items: DataSourceInstance[]; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useDataSourceInstanceCollection(dataSourceInstance: DataSourceInstance): { | ||
collection: DataCollectionSpec; | ||
refresh: () => Promise<DataCollectionSpec>; | ||
error: any; | ||
loading: boolean; | ||
error: Error; | ||
refresh: () => void; | ||
collection: DataCollectionSpec; | ||
}; | ||
@@ -180,33 +216,66 @@ | ||
}): { | ||
locations: _integration_app_sdk.DataLocation[]; | ||
refresh: () => Promise<DataDirectoryListResponse>; | ||
error: any; | ||
loading: boolean; | ||
error: Error; | ||
refresh: () => void; | ||
locations: _integration_app_sdk.DataLocation[]; | ||
}; | ||
declare function useDataSourceEvents(query?: FindDataSourceEventsQuery): { | ||
items: DataSourceEvent[]; | ||
declare function useDataSourceInstances(query?: FindDataSourceInstancesQuery): { | ||
items: DataSourceInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSourceInstances: DataSourceInstance[]; | ||
}; | ||
declare function useAppEvents(query?: FindAppEventsQuery): { | ||
items: AppEvent[]; | ||
declare function useDataSources(query?: FindDataSourcesQuery): { | ||
items: DataSource[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
dataSources: DataSource[]; | ||
}; | ||
declare function useAppEventType(idOrKey: string): { | ||
declare function useAppEventSubscription(selector: string | AppEventSubscriptionSelector): { | ||
accessor: AppEventSubscriptionAccessor; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
patch: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
put: (data: _integration_app_sdk.CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<AppEventSubscription>; | ||
refreshing: boolean; | ||
create: (data: IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
patch: (data: Partial<IAppEventSubscriptionUpdate>) => Promise<void>; | ||
put: (data: IAppEventSubscriptionUpdate) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
appEventSubscription: AppEventSubscription; | ||
}; | ||
declare function useAppEventSubscriptions(query?: FindAppEventSubscriptionsQuery): { | ||
items: AppEventSubscription[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
appEventSubscriptions: AppEventSubscription[]; | ||
}; | ||
declare function useAppEventType(id: string): { | ||
accessor: AppEventTypeAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<AppEventType>; | ||
refreshing: boolean; | ||
create: (data: CreateAppEventTypeRequest) => Promise<AppEventType>; | ||
patch: (data: Partial<CreateAppEventTypeRequest>) => Promise<void>; | ||
put: (data: CreateAppEventTypeRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
appEventType: AppEventType; | ||
@@ -217,40 +286,36 @@ }; | ||
items: AppEventType[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
appEventTypes: AppEventType[]; | ||
}; | ||
declare function useAppEventSubscription(selector: AppEventSubscriptionSelector | { | ||
id: string; | ||
}): { | ||
declare function useAppEvents(query?: FindAppEventsQuery): { | ||
items: AppEvent[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
patch: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
put: (data: _integration_app_sdk.IAppEventSubscriptionUpdate) => Promise<AppEventSubscription>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: AppEventSubscriptionAccessor; | ||
appEventSubscription: AppEventSubscription; | ||
error: any; | ||
appEvents: AppEvent[]; | ||
}; | ||
declare function useAppEventSubscriptions(query?: FindAppEventSubscriptionsQuery): { | ||
items: AppEventSubscription[]; | ||
declare function useFlow(selector: string | FlowSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
}; | ||
declare function useFlow(idOrSelector: string | FlowSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<Flow>) => Promise<Flow>; | ||
patch: (data: Partial<Flow>) => Promise<Flow>; | ||
put: (data: Partial<Flow>) => Promise<Flow>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateFlowRequest) => Promise<Flow>; | ||
patch: (data: Partial<UpdateFlowRequest>) => Promise<void>; | ||
put: (data: UpdateFlowRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
flow: Flow; | ||
apply: (integrationKeys: string[]) => Promise<Flow[]>; | ||
reset: () => Promise<Flow>; | ||
refresh: () => Promise<Flow>; | ||
accessor: FlowAccessor; | ||
flow: Flow; | ||
}; | ||
@@ -260,20 +325,30 @@ | ||
items: Flow[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flows: Flow[]; | ||
}; | ||
declare function useFlowInstance(props: FlowInstanceSelector | { | ||
id: string; | ||
}): { | ||
declare function useFlowInstance(selector: string | FlowInstanceSelector): { | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: _integration_app_sdk.CreateFlowInstanceRequest) => Promise<FlowInstance>; | ||
patch: (data: _integration_app_sdk.UpdateFlowInstanceRequest) => Promise<FlowInstance>; | ||
put: (data: _integration_app_sdk.CreateFlowInstanceRequest) => Promise<FlowInstance>; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: UpdateFlowInstanceRequest) => Promise<FlowInstance>; | ||
patch: (data: Partial<UpdateFlowInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateFlowInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
flowInstance: FlowInstance; | ||
accessor: FlowInstanceAccessor; | ||
flowInstance: FlowInstance; | ||
refresh: () => Promise<FlowInstance>; | ||
enable: () => Promise<void>; | ||
disable: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
setup: () => Promise<void>; | ||
openConfiguration: (options: OpenFlowInstanceConfigurationOptions) => Promise<void>; | ||
run: (options?: RunFlowOptions) => Promise<_integration_app_sdk.FlowRun>; | ||
startRun: (options?: RunFlowOptions) => Promise<_integration_app_sdk.FlowRun>; | ||
}; | ||
@@ -283,18 +358,17 @@ | ||
items: FlowInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flowInstances: FlowInstance[]; | ||
}; | ||
declare function useFlowRun(id: string): { | ||
flowRun: FlowRun; | ||
error: any; | ||
loading: boolean; | ||
error?: Error; | ||
create: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
patch: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
put: (data: Partial<FlowRun>) => Promise<FlowRun>; | ||
refresh: () => Promise<FlowRun>; | ||
archive: () => Promise<void>; | ||
refresh: () => void; | ||
accessor: FlowRunAccessor; | ||
flowRun: FlowRun; | ||
}; | ||
@@ -304,8 +378,140 @@ | ||
items: FlowRun[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error?: Error; | ||
refresh(): Promise<void>; | ||
loadMore(): Promise<void>; | ||
error: any; | ||
flowRuns: FlowRun[]; | ||
}; | ||
export { IntegrationAppProvider, useAppEventSubscription, useAppEventSubscriptions, useAppEventType, useAppEventTypes, useAppEvents, useConnection, useConnections, useConnectorSpec, useDataSource, useDataSourceInstanceCollection as useDataSourceCollection, useDataSourceEvents, useDataSourceInstance, useDataSourceInstances, useDataSourceInstanceLocations as useDataSourceLocations, useDataSources, useFieldMapping, useFieldMappingInstance, useFieldMappingInstances, useFieldMappings, useFlow, useFlowInstance, useFlowInstances, useFlowRun, useFlowRuns, useFlows, useIntegration, useIntegrationApp, useIntegrations }; | ||
declare function useDataLinkTable(selector: string): { | ||
accessor: DataLinkTableAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<DataLinkTable>; | ||
refreshing: boolean; | ||
create: (data: CreateDataLinkTableRequest) => Promise<DataLinkTable>; | ||
patch: (data: Partial<CreateDataLinkTableRequest>) => Promise<void>; | ||
put: (data: CreateDataLinkTableRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
dataLinkTable: DataLinkTable; | ||
}; | ||
declare function useDataLinkTableInstance(selector: string | DataLinkTableInstanceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateDataLinkTableInstanceRequest) => Promise<DataLinkTableInstance>; | ||
patch: (data: Partial<UpdateDataLinkTableInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateDataLinkTableInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
dataLinkTableInstance: DataLinkTableInstance; | ||
accessor: DataLinkTableInstanceAccessor; | ||
refresh: () => Promise<DataLinkTableInstance>; | ||
findLinks: (query?: _integration_app_sdk.FindDataLinksInTableQuery) => Promise<_integration_app_sdk.FindDataLinksResponse>; | ||
createLink: (data: _integration_app_sdk.CreateDataLinkRequest) => Promise<void>; | ||
deleteLink: (data: _integration_app_sdk.DeleteDataLinkRequest) => Promise<void>; | ||
}; | ||
declare function useDataLinkTableInstances(query?: FindDataLinkTableInstancesQuery): { | ||
items: DataLinkTableInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
dataLinkTableInstances: DataLinkTableInstance[]; | ||
}; | ||
declare function useDataLinkTables(query?: FindDataLinkTablesQuery): { | ||
items: DataLinkTable[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
dataLinkTables: DataLinkTable[]; | ||
}; | ||
declare function useAction(selector: ActionSelector | string): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateActionRequest) => Promise<Action>; | ||
patch: (data: Partial<UpdateActionRequest>) => Promise<void>; | ||
put: (data: UpdateActionRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
action: Action; | ||
apply: (integrationKeys: string[]) => Promise<Action[]>; | ||
reset: () => Promise<void>; | ||
refresh: () => Promise<Action>; | ||
accessor: ActionAccessor; | ||
}; | ||
declare function useActionInstance(selector: string | ActionInstanceSelector): { | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refreshing: boolean; | ||
create: (data: CreateActionInstanceRequest) => Promise<ActionInstance>; | ||
patch: (data: Partial<UpdateActionInstanceRequest>) => Promise<void>; | ||
put: (data: UpdateActionInstanceRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
actionInstance: ActionInstance; | ||
accessor: ActionInstanceAccessor; | ||
refresh: () => Promise<ActionInstance>; | ||
setup: () => Promise<void>; | ||
reset: () => Promise<void>; | ||
openConfiguration: (options?: OpenActionConfigurationOptions) => Promise<void>; | ||
run: (input?: any) => Promise<_integration_app_sdk.ActionRunResponse>; | ||
}; | ||
declare function useActionInstances(query?: FindActionInstancesQuery): { | ||
items: ActionInstance[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
actionInstances: ActionInstance[]; | ||
}; | ||
declare function useActions(query?: FindActionsQuery): { | ||
items: Action[]; | ||
refresh: () => Promise<void>; | ||
refreshing: boolean; | ||
loadMore: () => Promise<void>; | ||
loadingMore: boolean; | ||
loading: boolean; | ||
error: any; | ||
actions: Action[]; | ||
}; | ||
declare function useScreen(selector: ScreenSelector | string): { | ||
accessor: ScreenAccessor; | ||
loading: boolean; | ||
saving: boolean; | ||
error: any; | ||
refresh: () => Promise<Screen>; | ||
refreshing: boolean; | ||
create: (data: CreateScreenRequest) => Promise<Screen>; | ||
patch: (data: Partial<UpdateScreenRequest>) => Promise<void>; | ||
put: (data: UpdateScreenRequest) => Promise<void>; | ||
archive: () => Promise<void>; | ||
screen: Screen; | ||
}; | ||
declare function useDataCollectionSpec({ path, key, integrationId, }: { | ||
path?: string; | ||
key?: string; | ||
integrationId: string; | ||
}): DataCollectionSpec; | ||
export { IntegrationAppProvider, useAction, useActionInstance, useActionInstances, useActions, useAppEventSubscription, useAppEventSubscriptions, useAppEventType, useAppEventTypes, useAppEvents, useConnection, useConnections, useConnectorSpec, useDataCollectionSpec, useDataLinkTable, useDataLinkTableInstance, useDataLinkTableInstances, useDataLinkTables, useDataSource, useDataSourceEvents, useDataSourceInstance, useDataSourceInstanceCollection, useDataSourceInstanceLocations, useDataSourceInstances, useDataSources, useFieldMapping, useFieldMappingInstance, useFieldMappingInstances, useFieldMappings, useFlow, useFlowInstance, useFlowInstances, useFlowRun, useFlowRuns, useFlows, useIntegration, useIntegrationApp, useIntegrationAppSWR, useIntegrations, useScreen }; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@integration-app/sdk'), require('react')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@integration-app/sdk', 'react'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.integrationAppReact = {}, global.jsxRuntime, global.sdk, global.react)); | ||
})(this, (function (exports, jsxRuntime, sdk, react) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@integration-app/sdk'), require('react'), require('swr'), require('awesome-debounce-promise'), require('swr/infinite'), require('query-string')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@integration-app/sdk', 'react', 'swr', 'awesome-debounce-promise', 'swr/infinite', 'query-string'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.integrationAppReact = {}, global.jsxRuntime, global.sdk, global.react, global.useSWR, global.AwesomeDebouncePromise, global.useSWRInfinite, global.qs)); | ||
})(this, (function (exports, jsxRuntime, sdk, react, useSWR, AwesomeDebouncePromise, useSWRInfinite, qs) { 'use strict'; | ||
@@ -24,90 +24,96 @@ const IntegrationAppContext = react.createContext(null); | ||
function useConnectorSpec(integrationKey) { | ||
const integrationApp = useIntegrationApp(); | ||
const [data, setData] = react.useState(null); | ||
const [loading, setLoading] = react.useState(true); | ||
const [error, setError] = react.useState(null); | ||
react.useEffect(() => { | ||
if (!integrationApp) { | ||
return; | ||
} | ||
integrationApp | ||
.integration(integrationKey) | ||
.getConnectorSpec() | ||
.then(setData) | ||
.catch(setError) | ||
.finally(() => setLoading(false)); | ||
}, [integrationApp, integrationKey]); | ||
return { data, loading, error }; | ||
function useIntegrationAppSWR(path, options) { | ||
const client = useIntegrationApp(); | ||
const fetcher = async () => { | ||
const response = await client.get(path, options); | ||
return response; | ||
}; | ||
return useSWR(client ? path : undefined, fetcher, options); | ||
} | ||
function useElement(props, accessorGenerator) { | ||
const elementStateCache = new Map(); | ||
function useElement(selector, accessorGenerator) { | ||
const integrationApp = useIntegrationApp(); | ||
const [data, setData] = react.useState(); | ||
const [loading, setLoading] = react.useState(true); | ||
const [error, setError] = react.useState(null); | ||
const [refreshCounter, setRefreshCounter] = react.useState(0); | ||
function updateDataWith(newData) { | ||
if (data !== undefined) { | ||
setData({ | ||
...data, | ||
...newData, | ||
}); | ||
} | ||
const elementKeyData = { | ||
token: integrationApp.token, | ||
selector, | ||
}; | ||
const elementKey = JSON.stringify(elementKeyData); | ||
if (!elementStateCache.has(elementKey)) { | ||
elementStateCache.set(elementKey, { | ||
updatedLocally: false, | ||
savingToServer: false, | ||
debouncedPut: AwesomeDebouncePromise(async (data) => { | ||
elementState.updatedLocally = false; | ||
elementState.savingToServer = true; | ||
try { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.put(data)); | ||
if (!elementState.updatedLocally) { | ||
elementState.savingToServer = false; | ||
await mutate(result, false); | ||
} | ||
} | ||
catch (e) { | ||
elementState.updatedLocally = true; | ||
throw e; | ||
} | ||
finally { | ||
elementState.savingToServer = false; | ||
} | ||
}, 500), | ||
}); | ||
} | ||
function replaceDataWith(newData) { | ||
setData(newData); | ||
const elementState = elementStateCache.get(elementKey); | ||
const accessor = integrationApp ? accessorGenerator(integrationApp) : null; | ||
const swrKey = accessor && selector ? `element:${elementKey}` : null; | ||
const { data: item, mutate, error, isLoading, isValidating, } = useSWR(swrKey, () => accessor === null || accessor === void 0 ? void 0 : accessor.get(), { | ||
isPaused: () => elementState.updatedLocally || elementState.savingToServer, | ||
}); | ||
const loading = isLoading; | ||
const refreshing = isValidating; | ||
async function refresh() { | ||
return await mutate(); | ||
} | ||
const selector = (props === null || props === void 0 ? void 0 : props.id) | ||
? props.id | ||
: props; | ||
const accessor = integrationApp | ||
? accessorGenerator(integrationApp)(selector) | ||
: null; | ||
react.useEffect(() => { | ||
setLoading(true); | ||
setError(null); | ||
if (integrationApp && selector) { | ||
accessor | ||
.get() | ||
.then(setData) | ||
.catch(setError) | ||
.finally(() => setLoading(false)); | ||
async function put(data) { | ||
if (!(accessor === null || accessor === void 0 ? void 0 : accessor.put)) { | ||
throw new Error(`"put method is not supported for accessor ${accessor.constructor.name}`); | ||
} | ||
else { | ||
setError(new Error('IntegrationApp not found. Was this component wrapped in <IntegrationAppProvider>?')); | ||
} | ||
}, [ | ||
integrationApp, | ||
JSON.stringify(selector), | ||
JSON.stringify(props), | ||
refreshCounter, | ||
]); | ||
async function create(createData) { | ||
const returnedData = await accessor.create(createData); | ||
replaceDataWith(returnedData); | ||
return returnedData; | ||
elementState.updatedLocally = true; | ||
const newLocalData = { | ||
...item, | ||
...data, | ||
}; | ||
await mutate(newLocalData, false); | ||
await elementState.debouncedPut(data); | ||
} | ||
function refresh() { | ||
setRefreshCounter(refreshCounter + 1); | ||
async function patch(data) { | ||
const newData = { | ||
...item, | ||
...data, | ||
}; | ||
return put(newData); | ||
} | ||
async function patch(patch) { | ||
if (typeof patch === 'object') { | ||
updateDataWith(patch !== null && patch !== void 0 ? patch : {}); | ||
return accessor.patch(patch); | ||
async function archive() { | ||
if (!(accessor === null || accessor === void 0 ? void 0 : accessor.archive)) { | ||
return; | ||
} | ||
else { | ||
return data; | ||
await mutate({ ...item, archivedAt: new Date().toISOString() }, false); | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.archive()); | ||
await mutate(); | ||
} | ||
async function create(data) { | ||
if (!(accessor === null || accessor === void 0 ? void 0 : accessor.create)) { | ||
throw new Error(`"create method is not supported for accessor ${accessor.constructor.name}`); | ||
} | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.create(data)); | ||
return await mutate(result); | ||
} | ||
async function put(putData) { | ||
updateDataWith(putData); | ||
return await accessor.put(putData); | ||
} | ||
async function archive() { | ||
setData(null); | ||
return accessor.archive(); | ||
} | ||
return { | ||
data, | ||
accessor, | ||
item, | ||
loading, | ||
saving: elementState.updatedLocally || elementState.savingToServer, | ||
error, | ||
refresh, | ||
refreshing, | ||
create, | ||
@@ -117,57 +123,47 @@ patch, | ||
archive, | ||
refresh, | ||
loading, | ||
error, | ||
accessor, | ||
}; | ||
} | ||
function useIntegration(idOrKey) { | ||
const { data: integration, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.integration.bind(integrationApp)); | ||
return { integration, ...rest }; | ||
function useConnection(id) { | ||
const { item: connection, ...rest } = useElement(id, (integrationApp) => integrationApp.connection(id)); | ||
return { | ||
connection, | ||
...rest, | ||
}; | ||
} | ||
function useElements(initialQuery, accessorGenerator) { | ||
const LIMIT = 25; | ||
function useElements(route, query = {}) { | ||
const integrationApp = useIntegrationApp(); | ||
const refreshId = react.useRef(0); | ||
const [items, setItems] = react.useState([]); | ||
const [nextCursor, setNextCursor] = react.useState(undefined); | ||
const [loading, setLoading] = react.useState(false); | ||
const [error, setError] = react.useState(null); | ||
function getKey(page, previousPageData) { | ||
var _a; | ||
if (page === 0) | ||
return `/${route}?${qs.stringify({ | ||
...query, | ||
limit: LIMIT, | ||
})}`; | ||
if (((_a = previousPageData.items) === null || _a === void 0 ? void 0 : _a.length) < LIMIT) | ||
return null; | ||
return `/${route}?${qs.stringify({ | ||
...query, | ||
limit: LIMIT, | ||
cursor: previousPageData.cursor, | ||
})}`; | ||
} | ||
const [loadingMore, setIsLoadingMore] = react.useState(false); | ||
const { data, size, setSize, isLoading, error, mutate, isValidating } = useSWRInfinite(getKey, (url) => integrationApp.get(url)); | ||
const items = data ? data.map((page) => page.items).flat() : []; | ||
const loading = isLoading; | ||
const refreshing = isValidating; | ||
async function loadMore() { | ||
const startingRefreshId = refreshId.current; | ||
const isFirstPage = !nextCursor; | ||
function setStateIfCurrentRefresh(stateSetter, valueGetter) { | ||
stateSetter((value) => startingRefreshId === refreshId.current ? valueGetter(value) : value); | ||
var _a, _b; | ||
const hasMoreToLoad = ((_b = (_a = data[size - 1]) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) === LIMIT; | ||
if (hasMoreToLoad) { | ||
setIsLoadingMore(true); | ||
await setSize(size + 1); | ||
setIsLoadingMore(false); | ||
} | ||
setStateIfCurrentRefresh(setError, () => null); | ||
setStateIfCurrentRefresh(setLoading, () => true); | ||
const queryParams = { | ||
...initialQuery, | ||
}; | ||
if (nextCursor) | ||
queryParams.cursor = nextCursor; | ||
try { | ||
const data = await accessorGenerator(integrationApp).find(queryParams); | ||
setStateIfCurrentRefresh(setNextCursor, () => data.cursor); | ||
setStateIfCurrentRefresh(setItems, (items) => isFirstPage ? data.items : [...items, ...data.items]); | ||
} | ||
catch (e) { | ||
setStateIfCurrentRefresh(setError, () => e); | ||
} | ||
finally { | ||
setStateIfCurrentRefresh(setLoading, () => false); | ||
} | ||
} | ||
react.useEffect(() => { | ||
if (!integrationApp) { | ||
setError(new Error('IntegrationApp not found. Was this component wrapped in <IntegrationAppProvider>?')); | ||
return; | ||
} | ||
refresh(); | ||
}, [integrationApp, JSON.stringify(initialQuery)]); | ||
async function refresh() { | ||
refreshId.current += 1; | ||
setNextCursor(undefined); | ||
await loadMore(); | ||
await mutate(); | ||
} | ||
@@ -177,3 +173,5 @@ return { | ||
refresh, | ||
refreshing, | ||
loadMore, | ||
loadingMore, | ||
loading, | ||
@@ -184,5 +182,6 @@ error, | ||
function useIntegrations(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.integrations); | ||
function useConnections(query) { | ||
const { ...rest } = useElements('connections', query); | ||
return { | ||
connections: rest.items, | ||
...rest, | ||
@@ -192,10 +191,17 @@ }; | ||
function useConnection(id) { | ||
const { data: connection, ...rest } = useElement(id, (integrationApp) => integrationApp.connection.bind(integrationApp)); | ||
return { connection, ...rest }; | ||
function useConnectorSpec(integrationIdOrKey) { | ||
const integrationApp = useIntegrationApp(); | ||
const { data, isLoading, error } = useSWR(`/integrations/${integrationIdOrKey}/connector-spec`, () => integrationApp.integration(integrationIdOrKey).getConnectorSpec()); | ||
return { data, loading: isLoading, error }; | ||
} | ||
function useConnections(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.connections); | ||
function useIntegration(id) { | ||
const { item: integration, ...rest } = useElement(id, (integrationApp) => integrationApp.integration(id)); | ||
return { integration, ...rest }; | ||
} | ||
function useIntegrations(query) { | ||
const { ...rest } = useElements('integrations', query); | ||
return { | ||
integrations: rest.items, | ||
...rest, | ||
@@ -205,10 +211,36 @@ }; | ||
function useFieldMapping(idOrKey) { | ||
const { data: fieldMapping, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.fieldMapping.bind(integrationApp)); | ||
return { fieldMapping, ...rest }; | ||
function useFieldMapping(selector) { | ||
const { item: fieldMapping, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.fieldMapping(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
return { fieldMapping, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useFieldMappings(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.fieldMappings); | ||
function useFieldMappingInstance(selector) { | ||
const { item: fieldMappingInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.fieldMappingInstance(selector)); | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.openConfiguration(options); | ||
} | ||
return { | ||
fieldMappingInstance, | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
openConfiguration, | ||
...rest, | ||
@@ -218,10 +250,6 @@ }; | ||
function useFieldMappingInstance(selector) { | ||
const { data: fieldMappingInstance, ...rest } = useElement(selector, (integrationApp) => integrationApp.fieldMappingInstance.bind(integrationApp)); | ||
const accessor = rest.accessor; | ||
function useFieldMappingInstances(query) { | ||
const { ...rest } = useElements('field-mapping-instances', query); | ||
return { | ||
fieldMappingInstance, | ||
setup: () => accessor.setup(), | ||
reset: () => accessor.reset(), | ||
openConfiguration: (options) => accessor.openConfiguration(options), | ||
fieldMappingInstances: rest.items, | ||
...rest, | ||
@@ -231,5 +259,6 @@ }; | ||
function useFieldMappingInstances(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.fieldMappingInstances); | ||
function useFieldMappings(query) { | ||
const { ...rest } = useElements('field-mappings', query); | ||
return { | ||
fieldMappings: rest.items, | ||
...rest, | ||
@@ -239,10 +268,20 @@ }; | ||
function useDataSource(idOrKey) { | ||
const { data: dataSource, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.dataSource.bind(integrationApp)); | ||
return { dataSource, ...rest }; | ||
function useDataSource(selector) { | ||
const { item: dataSource, refresh, accessor, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataSource(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
return { dataSource, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useDataSources(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.dataSources); | ||
function useDataSourceEvents(query) { | ||
const { ...rest } = useElements('data-source-events', query); | ||
return { | ||
dataSourceEvents: rest, | ||
...rest, | ||
@@ -253,20 +292,86 @@ }; | ||
function useDataSourceInstance(selector) { | ||
const { data: dataSourceInstance, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataSourceInstance.bind(integrationApp)); | ||
const accessor = rest.accessor; | ||
const { item: dataSourceInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataSourceInstance(selector)); | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function subscribe(eventType) { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.subscribe(eventType)); | ||
await refresh(); | ||
} | ||
async function resubscribe(eventType) { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.resubscribe(eventType)); | ||
await refresh(); | ||
} | ||
async function unsubscribe(eventType) { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.unsubscribe(eventType)); | ||
await refresh(); | ||
} | ||
async function pullUpdates() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.pullUpdates()); | ||
await refresh(); | ||
} | ||
async function fullSync() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.fullSync()); | ||
await refresh(); | ||
} | ||
async function getSyncsList() { | ||
return await (accessor === null || accessor === void 0 ? void 0 : accessor.getSyncsList()); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.openConfiguration(options); | ||
} | ||
async function listRecords(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.listRecords(request); | ||
} | ||
async function findRecords(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.findRecords(request); | ||
} | ||
async function findRecordById(id) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.findRecordById(id); | ||
} | ||
async function createRecord(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.createRecord(request); | ||
} | ||
async function updateRecord(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.updateRecord(request); | ||
} | ||
async function deleteRecord(id) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.deleteRecord(id); | ||
} | ||
async function unifiedFieldsToNative(unifiedFields) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.unifiedFieldsToNative(unifiedFields); | ||
} | ||
async function getCollection() { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.getCollection(); | ||
} | ||
async function getLocations(request) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.getLocations(request); | ||
} | ||
return { | ||
dataSourceInstance, | ||
setup: () => accessor.setup(), | ||
subscribe: (eventType) => accessor.subscribe(eventType), | ||
resubscribe: (eventType) => accessor.resubscribe(eventType), | ||
unsubscribe: (eventType) => accessor.unsubscribe(eventType), | ||
pullUpdates: () => accessor.pullUpdates(), | ||
fullSync: () => accessor.fullSync(), | ||
reset: () => accessor.reset(), | ||
openConfiguration: (options) => accessor.openConfiguration(options), | ||
findRecords: (request) => accessor.findRecords(request), | ||
findRecordById: (id) => accessor.findRecordById(id), | ||
createRecord: (request) => accessor.createRecord(request), | ||
updateRecord: (request) => accessor.updateRecord(request), | ||
deleteRecord: (id) => accessor.deleteRecord(id), | ||
unifiedFieldsToNative: (unifiedFields) => accessor.unifiedFieldsToNative(unifiedFields), | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
subscribe, | ||
resubscribe, | ||
unsubscribe, | ||
pullUpdates, | ||
fullSync, | ||
getSyncsList, | ||
openConfiguration, | ||
listRecords, | ||
findRecords, | ||
findRecordById, | ||
createRecord, | ||
updateRecord, | ||
deleteRecord, | ||
unifiedFieldsToNative, | ||
getLocations, | ||
getCollection, | ||
...rest, | ||
@@ -276,42 +381,14 @@ }; | ||
function useDataSourceInstances(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.dataSourceInstances); | ||
return { | ||
...rest, | ||
}; | ||
} | ||
function useGetter(key, getter) { | ||
function useDataSourceInstanceCollection(dataSourceInstance) { | ||
const integrationApp = useIntegrationApp(); | ||
const [data, setData] = react.useState(); | ||
const [loading, setLoading] = react.useState(true); | ||
const [error, setError] = react.useState(null); | ||
const [refreshCounter, setRefreshCounter] = react.useState(0); | ||
function refresh() { | ||
setRefreshCounter(refreshCounter + 1); | ||
const { data, error, isLoading, mutate } = useSWR(dataSourceInstance ? `${dataSourceInstance.id}/collection` : null, () => integrationApp.dataSourceInstance(dataSourceInstance.id).getCollection()); | ||
async function refresh() { | ||
return await mutate(); | ||
} | ||
react.useEffect(() => { | ||
if (key !== undefined) { | ||
setLoading(true); | ||
setError(null); | ||
if (integrationApp) { | ||
getter() | ||
.then(setData) | ||
.catch(setError) | ||
.finally(() => setLoading(false)); | ||
} | ||
else { | ||
setError(new Error('IntegrationApp not found. Was this component wrapped in <IntegrationAppProvider>?')); | ||
} | ||
} | ||
}, [integrationApp, key, refreshCounter]); | ||
return { data, loading, error, refresh }; | ||
} | ||
function useDataSourceInstanceCollection(dataSourceInstance) { | ||
const integrationApp = useIntegrationApp(); | ||
const { data: collection, ...rest } = useGetter(dataSourceInstance === null || dataSourceInstance === void 0 ? void 0 : dataSourceInstance.id, () => integrationApp.dataSourceInstance(dataSourceInstance.id).getCollection()); | ||
const collection = data; | ||
return { | ||
collection, | ||
...rest, | ||
refresh, | ||
error, | ||
loading: isLoading, | ||
}; | ||
@@ -323,9 +400,23 @@ } | ||
const integrationApp = useIntegrationApp(); | ||
const { data, ...rest } = useGetter(dataSourceInstance | ||
? `${dataSourceInstance.id}/${JSON.stringify(args)}` | ||
: undefined, () => integrationApp | ||
const { data, error, isLoading, mutate } = useSWR(dataSourceInstance | ||
? `${dataSourceInstance.id}/locations?${qs.stringify(args)}` | ||
: null, () => integrationApp | ||
.dataSourceInstance(dataSourceInstance.id) | ||
.getLocations(args)); | ||
async function refresh() { | ||
return await mutate(); | ||
} | ||
const locations = (_a = data === null || data === void 0 ? void 0 : data.locations) !== null && _a !== void 0 ? _a : []; | ||
return { | ||
locations: (_a = data === null || data === void 0 ? void 0 : data.locations) !== null && _a !== void 0 ? _a : [], | ||
locations, | ||
refresh, | ||
error, | ||
loading: isLoading, | ||
}; | ||
} | ||
function useDataSourceInstances(query) { | ||
const { ...rest } = useElements('data-source-instances', query); | ||
return { | ||
dataSourceInstances: rest.items, | ||
...rest, | ||
@@ -335,5 +426,6 @@ }; | ||
function useDataSourceEvents(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.dataSourceEvents); | ||
function useDataSources(query) { | ||
const { ...rest } = useElements('data-sources', query); | ||
return { | ||
dataSources: rest.items, | ||
...rest, | ||
@@ -343,5 +435,11 @@ }; | ||
function useAppEvents(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.appEvents); | ||
function useAppEventSubscription(selector) { | ||
const { item: appEventSubscription, ...rest } = useElement(selector, (integrationApp) => integrationApp.appEventSubscription(selector)); | ||
return { appEventSubscription, ...rest }; | ||
} | ||
function useAppEventSubscriptions(query) { | ||
const { ...rest } = useElements('app-event-subscriptions', query); | ||
return { | ||
appEventSubscriptions: rest.items, | ||
...rest, | ||
@@ -351,4 +449,4 @@ }; | ||
function useAppEventType(idOrKey) { | ||
const { data: appEventType, ...rest } = useElement(idOrKey, (integrationApp) => integrationApp.appEventType.bind(integrationApp)); | ||
function useAppEventType(id) { | ||
const { item: appEventType, ...rest } = useElement(id, (integrationApp) => integrationApp.appEventType(id)); | ||
return { appEventType, ...rest }; | ||
@@ -358,4 +456,5 @@ } | ||
function useAppEventTypes(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.appEventTypes); | ||
const { ...rest } = useElements('app-event-types', query); | ||
return { | ||
appEventTypes: rest.items, | ||
...rest, | ||
@@ -365,10 +464,6 @@ }; | ||
function useAppEventSubscription(selector) { | ||
const { data: appEventSubscription, ...rest } = useElement(selector, (integrationApp) => integrationApp.appEventSubscription.bind(integrationApp)); | ||
return { appEventSubscription, ...rest }; | ||
} | ||
function useAppEventSubscriptions(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.appEventSubscriptions); | ||
function useAppEvents(query) { | ||
const { ...rest } = useElements('app-events', query); | ||
return { | ||
appEvents: rest.items, | ||
...rest, | ||
@@ -378,20 +473,70 @@ }; | ||
function useFlow(idOrSelector) { | ||
const { data: flow, ...rest } = useElement(idOrSelector, (integrationApp) => integrationApp.flow.bind(integrationApp)); | ||
return { flow, ...rest }; | ||
function useFlow(selector) { | ||
const { item: flow, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.flow(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
return await refresh(); | ||
} | ||
return { flow, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useFlows(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.flows); | ||
return { ...rest }; | ||
const { ...rest } = useElements('flows', query); | ||
return { | ||
flows: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useFlowInstance(props) { | ||
const { data: flowInstance, ...rest } = useElement(props, (integrationApp) => integrationApp.flowInstance.bind(integrationApp)); | ||
return { flowInstance, ...rest }; | ||
function useFlowInstance(selector) { | ||
const { item: flowInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.flowInstance(selector)); | ||
async function enable() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.enable()); | ||
await refresh(); | ||
} | ||
async function disable() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.disable()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.openConfiguration(options); | ||
} | ||
async function run(options = {}) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.run(options); | ||
} | ||
async function startRun(options = {}) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.startRun(options); | ||
} | ||
return { | ||
flowInstance, | ||
accessor, | ||
refresh, | ||
enable, | ||
disable, | ||
reset, | ||
setup, | ||
openConfiguration, | ||
run, | ||
startRun, | ||
...rest, | ||
}; | ||
} | ||
function useFlowInstances(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.flowInstances); | ||
const { ...rest } = useElements('flow-instances', query); | ||
return { | ||
flowInstances: rest.items, | ||
...rest, | ||
@@ -402,11 +547,127 @@ }; | ||
function useFlowRun(id) { | ||
const { data: flowRun, ...rest } = useElement(id, (integrationApp) => integrationApp.flowRun.bind(integrationApp)); | ||
return { flowRun, ...rest }; | ||
const { item: flowRun, archive, refresh, error, loading, } = useElement(id, (integrationApp) => integrationApp.flowRun(id)); | ||
return { | ||
flowRun, | ||
error, | ||
loading, | ||
refresh, | ||
archive, | ||
}; | ||
} | ||
function useFlowRuns(query) { | ||
const { ...rest } = useElements(query, (integrationApp) => integrationApp.flowRuns); | ||
return { ...rest }; | ||
const { ...rest } = useElements('flow-runs', query); | ||
return { | ||
flowRuns: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useDataLinkTable(selector) { | ||
const { item: dataLinkTable, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataLinkTable(selector)); | ||
return { dataLinkTable, ...rest }; | ||
} | ||
function useDataLinkTableInstance(selector) { | ||
const { item: dataLinkTableInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.dataLinkTableInstance(selector)); | ||
return { | ||
dataLinkTableInstance, | ||
accessor, | ||
refresh, | ||
findLinks: accessor === null || accessor === void 0 ? void 0 : accessor.findLinks, | ||
createLink: accessor === null || accessor === void 0 ? void 0 : accessor.createLink, | ||
deleteLink: accessor === null || accessor === void 0 ? void 0 : accessor.deleteLink, | ||
...rest, | ||
}; | ||
} | ||
function useDataLinkTableInstances(query) { | ||
const { ...rest } = useElements('data-link-table-instances', query); | ||
return { | ||
dataLinkTableInstances: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useDataLinkTables(query) { | ||
const { ...rest } = useElements('data-link-tables', query); | ||
return { | ||
dataLinkTables: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useAction(selector) { | ||
const { item: action, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.action(selector)); | ||
async function apply(integrationKeys) { | ||
const result = await (accessor === null || accessor === void 0 ? void 0 : accessor.apply(integrationKeys)); | ||
await refresh(); | ||
return result; | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
return { action, apply, reset, refresh, accessor, ...rest }; | ||
} | ||
function useActionInstance(selector) { | ||
const { item: actionInstance, accessor, refresh, ...rest } = useElement(selector, (integrationApp) => integrationApp.actionInstance(selector)); | ||
async function run(input) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.run(input); | ||
} | ||
async function setup() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.setup()); | ||
await refresh(); | ||
} | ||
async function reset() { | ||
await (accessor === null || accessor === void 0 ? void 0 : accessor.reset()); | ||
await refresh(); | ||
} | ||
async function openConfiguration(options) { | ||
return accessor === null || accessor === void 0 ? void 0 : accessor.open(options); | ||
} | ||
return { | ||
actionInstance, | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
openConfiguration, | ||
run, | ||
...rest, | ||
}; | ||
} | ||
function useActionInstances(query) { | ||
const { ...rest } = useElements('action-instances', query); | ||
return { | ||
actionInstances: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useActions(query) { | ||
const { ...rest } = useElements('actions', query); | ||
return { | ||
actions: rest.items, | ||
...rest, | ||
}; | ||
} | ||
function useScreen(selector) { | ||
const { item: screen, ...rest } = useElement(selector, (integrationApp) => integrationApp.screen(selector)); | ||
return { screen, ...rest }; | ||
} | ||
function useDataCollectionSpec({ path, key, integrationId, }) { | ||
var _a; | ||
const client = useIntegrationApp(); | ||
const dataCollectionKey = key !== null && key !== void 0 ? key : (_a = sdk.parseDataLocationPath(path)) === null || _a === void 0 ? void 0 : _a.key; | ||
const { data: dataCollectionSpec } = useSWR(dataCollectionKey && integrationId | ||
? `/integrations/${integrationId}/data/${dataCollectionKey}` | ||
: null, () => client.integration(integrationId).getDataLocation(dataCollectionKey)); | ||
return dataCollectionSpec; | ||
} | ||
Object.defineProperty(exports, 'DataForm', { | ||
@@ -417,2 +678,6 @@ enumerable: true, | ||
exports.IntegrationAppProvider = IntegrationAppProvider; | ||
exports.useAction = useAction; | ||
exports.useActionInstance = useActionInstance; | ||
exports.useActionInstances = useActionInstances; | ||
exports.useActions = useActions; | ||
exports.useAppEventSubscription = useAppEventSubscription; | ||
@@ -426,8 +691,13 @@ exports.useAppEventSubscriptions = useAppEventSubscriptions; | ||
exports.useConnectorSpec = useConnectorSpec; | ||
exports.useDataCollectionSpec = useDataCollectionSpec; | ||
exports.useDataLinkTable = useDataLinkTable; | ||
exports.useDataLinkTableInstance = useDataLinkTableInstance; | ||
exports.useDataLinkTableInstances = useDataLinkTableInstances; | ||
exports.useDataLinkTables = useDataLinkTables; | ||
exports.useDataSource = useDataSource; | ||
exports.useDataSourceCollection = useDataSourceInstanceCollection; | ||
exports.useDataSourceEvents = useDataSourceEvents; | ||
exports.useDataSourceInstance = useDataSourceInstance; | ||
exports.useDataSourceInstanceCollection = useDataSourceInstanceCollection; | ||
exports.useDataSourceInstanceLocations = useDataSourceInstanceLocations; | ||
exports.useDataSourceInstances = useDataSourceInstances; | ||
exports.useDataSourceLocations = useDataSourceInstanceLocations; | ||
exports.useDataSources = useDataSources; | ||
@@ -446,5 +716,7 @@ exports.useFieldMapping = useFieldMapping; | ||
exports.useIntegrationApp = useIntegrationApp; | ||
exports.useIntegrationAppSWR = useIntegrationAppSWR; | ||
exports.useIntegrations = useIntegrations; | ||
exports.useScreen = useScreen; | ||
})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@integration-app/react", | ||
"version": "0.2.1", | ||
"version": "0.3.1", | ||
"description": "", | ||
@@ -37,3 +37,6 @@ "author": "Integration.app", | ||
"dependencies": { | ||
"@integration-app/sdk": "^0.16.65" | ||
"@integration-app/sdk": "^0.16.71", | ||
"awesome-debounce-promise": "^2.1.0", | ||
"query-string": "^7.1.1", | ||
"swr": "^2.2.0" | ||
}, | ||
@@ -40,0 +43,0 @@ "peerDependencies": { |
@@ -5,10 +5,8 @@ import { AppEvent, FindAppEventsQuery } from '@integration-app/sdk' | ||
export function useAppEvents(query?: FindAppEventsQuery) { | ||
const { ...rest } = useElements<AppEvent, FindAppEventsQuery>( | ||
query, | ||
(integrationApp) => integrationApp.appEvents, | ||
) | ||
const { ...rest } = useElements<AppEvent>('app-events', query) | ||
return { | ||
appEvents: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -5,2 +5,3 @@ import { | ||
AppEventSubscriptionSelector, | ||
IAppEventSubscriptionUpdate, | ||
} from '@integration-app/sdk' | ||
@@ -10,13 +11,12 @@ import { useElement } from '../hooks/useElement' | ||
export function useAppEventSubscription( | ||
selector: AppEventSubscriptionSelector | { id: string }, | ||
selector: string | AppEventSubscriptionSelector, | ||
) { | ||
const { data: appEventSubscription, ...rest } = useElement< | ||
const { item: appEventSubscription, ...rest } = useElement< | ||
AppEventSubscription, | ||
AppEventSubscriptionSelector, | ||
IAppEventSubscriptionUpdate, | ||
IAppEventSubscriptionUpdate, | ||
AppEventSubscriptionAccessor | ||
>(selector, (integrationApp) => | ||
integrationApp.appEventSubscription.bind(integrationApp), | ||
) | ||
>(selector, (integrationApp) => integrationApp.appEventSubscription(selector)) | ||
return { appEventSubscription, ...rest } | ||
} |
@@ -10,10 +10,11 @@ import { | ||
) { | ||
const { ...rest } = useElements< | ||
AppEventSubscription, | ||
FindAppEventSubscriptionsQuery | ||
>(query, (integrationApp) => integrationApp.appEventSubscriptions) | ||
const { ...rest } = useElements<AppEventSubscription>( | ||
'app-event-subscriptions', | ||
query, | ||
) | ||
return { | ||
appEventSubscriptions: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -1,15 +0,18 @@ | ||
import { AppEventType } from '@integration-app/sdk' | ||
import { | ||
AppEventType, | ||
CreateAppEventTypeRequest, | ||
UpdateAppEventTypeRequest, | ||
} from '@integration-app/sdk' | ||
import { AppEventTypeAccessor } from '@integration-app/sdk' | ||
import { useElement } from '../hooks/useElement' | ||
export function useAppEventType(idOrKey: string) { | ||
const { data: appEventType, ...rest } = useElement< | ||
export function useAppEventType(id: string) { | ||
const { item: appEventType, ...rest } = useElement< | ||
AppEventType, | ||
string, | ||
UpdateAppEventTypeRequest, | ||
CreateAppEventTypeRequest, | ||
AppEventTypeAccessor | ||
>(idOrKey, (integrationApp) => | ||
integrationApp.appEventType.bind(integrationApp), | ||
) | ||
>(id, (integrationApp) => integrationApp.appEventType(id)) | ||
return { appEventType, ...rest } | ||
} |
@@ -5,10 +5,8 @@ import { AppEventType, FindAppEventTypesQuery } from '@integration-app/sdk' | ||
export function useAppEventTypes(query?: FindAppEventTypesQuery) { | ||
const { ...rest } = useElements<AppEventType, FindAppEventTypesQuery>( | ||
query, | ||
(integrationApp) => integrationApp.appEventTypes, | ||
) | ||
const { ...rest } = useElements<AppEventType>('app-event-types', query) | ||
return { | ||
appEventTypes: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -1,12 +0,35 @@ | ||
import { DataSource, DataSourceAccessor } from '@integration-app/sdk' | ||
import { | ||
CreateDataSourceRequest, | ||
DataSource, | ||
DataSourceAccessor, | ||
DataSourceSelector, | ||
UpdateDataSourceRequest, | ||
} from '@integration-app/sdk' | ||
import { useElement } from '../hooks/useElement' | ||
export function useDataSource(idOrKey: string) { | ||
const { data: dataSource, ...rest } = useElement< | ||
export function useDataSource(selector: string | DataSourceSelector) { | ||
const { | ||
item: dataSource, | ||
refresh, | ||
accessor, | ||
...rest | ||
} = useElement< | ||
DataSource, | ||
string, | ||
UpdateDataSourceRequest, | ||
CreateDataSourceRequest, | ||
DataSourceAccessor | ||
>(idOrKey, (integrationApp) => integrationApp.dataSource.bind(integrationApp)) | ||
>(selector, (integrationApp) => integrationApp.dataSource(selector)) | ||
return { dataSource, ...rest } | ||
async function apply(integrationKeys: string[]) { | ||
const result = await accessor?.apply(integrationKeys) | ||
await refresh() | ||
return result | ||
} | ||
async function reset() { | ||
await accessor?.reset() | ||
await refresh() | ||
} | ||
return { dataSource, apply, reset, refresh, accessor, ...rest } | ||
} |
@@ -8,10 +8,8 @@ import { | ||
export function useDataSourceEvents(query?: FindDataSourceEventsQuery) { | ||
const { ...rest } = useElements<DataSourceEvent, FindDataSourceEventsQuery>( | ||
query, | ||
(integrationApp) => integrationApp.dataSourceEvents, | ||
) | ||
const { ...rest } = useElements<DataSourceEvent>('data-source-events', query) | ||
return { | ||
dataSourceEvents: rest, | ||
...rest, | ||
} | ||
} |
@@ -9,2 +9,6 @@ import { | ||
DataSourceInstance, | ||
UpdateDataSourceInstanceRequest, | ||
DataDirectoryListRequest, | ||
DataCollectionListRequest, | ||
CreateDataSourceInstanceRequest, | ||
} from '@integration-app/sdk' | ||
@@ -14,37 +18,127 @@ import { useElement } from '../hooks/useElement' | ||
export function useDataSourceInstance( | ||
selector: DataSourceInstanceSelector | { id: string }, | ||
selector: string | DataSourceInstanceSelector, | ||
) { | ||
const { data: dataSourceInstance, ...rest } = useElement< | ||
const { | ||
item: dataSourceInstance, | ||
accessor, | ||
refresh, | ||
...rest | ||
} = useElement< | ||
DataSourceInstance, | ||
DataSourceInstanceSelector, | ||
UpdateDataSourceInstanceRequest, | ||
CreateDataSourceInstanceRequest, | ||
DataSourceInstanceAccessor | ||
>(selector, (integrationApp) => | ||
integrationApp.dataSourceInstance.bind(integrationApp), | ||
) | ||
>(selector, (integrationApp) => integrationApp.dataSourceInstance(selector)) | ||
const accessor = rest.accessor | ||
async function setup() { | ||
await accessor?.setup() | ||
await refresh() | ||
} | ||
async function reset() { | ||
await accessor?.reset() | ||
await refresh() | ||
} | ||
async function subscribe(eventType) { | ||
await accessor?.subscribe(eventType) | ||
await refresh() | ||
} | ||
async function resubscribe(eventType) { | ||
await accessor?.resubscribe(eventType) | ||
await refresh() | ||
} | ||
async function unsubscribe(eventType) { | ||
await accessor?.unsubscribe(eventType) | ||
await refresh() | ||
} | ||
async function pullUpdates() { | ||
await accessor?.pullUpdates() | ||
await refresh() | ||
} | ||
async function fullSync() { | ||
await accessor?.fullSync() | ||
await refresh() | ||
} | ||
async function getSyncsList() { | ||
return await accessor?.getSyncsList() | ||
} | ||
async function openConfiguration( | ||
options?: OpenDataSourceConfigurationOptions, | ||
) { | ||
return accessor?.openConfiguration(options) | ||
} | ||
async function listRecords(request?: DataCollectionListRequest) { | ||
return accessor?.listRecords(request) | ||
} | ||
async function findRecords(request?: DataCollectionFindRequest) { | ||
return accessor?.findRecords(request) | ||
} | ||
async function findRecordById(id: string) { | ||
return accessor?.findRecordById(id) | ||
} | ||
async function createRecord(request?: DataCollectionCreateRequest) { | ||
return accessor?.createRecord(request) | ||
} | ||
async function updateRecord(request?: DataCollectionUpdateRequest) { | ||
return accessor?.updateRecord(request) | ||
} | ||
async function deleteRecord(id?: string) { | ||
return accessor?.deleteRecord(id) | ||
} | ||
async function unifiedFieldsToNative(unifiedFields: any) { | ||
return accessor?.unifiedFieldsToNative(unifiedFields) | ||
} | ||
async function getCollection() { | ||
return accessor?.getCollection() | ||
} | ||
async function getLocations( | ||
request: DataDirectoryListRequest & { | ||
path?: string | ||
}, | ||
) { | ||
return accessor?.getLocations(request) | ||
} | ||
return { | ||
dataSourceInstance, | ||
setup: () => accessor.setup(), | ||
subscribe: (eventType) => accessor.subscribe(eventType), | ||
resubscribe: (eventType) => accessor.resubscribe(eventType), | ||
unsubscribe: (eventType) => accessor.unsubscribe(eventType), | ||
pullUpdates: () => accessor.pullUpdates(), | ||
fullSync: () => accessor.fullSync(), | ||
reset: () => accessor.reset(), | ||
openConfiguration: (options?: OpenDataSourceConfigurationOptions) => | ||
accessor.openConfiguration(options), | ||
findRecords: (request?: DataCollectionFindRequest) => | ||
accessor.findRecords(request), | ||
findRecordById: (id: string) => accessor.findRecordById(id), | ||
createRecord: (request?: DataCollectionCreateRequest) => | ||
accessor.createRecord(request), | ||
updateRecord: (request?: DataCollectionUpdateRequest) => | ||
accessor.updateRecord(request), | ||
deleteRecord: (id?: string) => accessor.deleteRecord(id), | ||
unifiedFieldsToNative: (unifiedFields: any) => | ||
accessor.unifiedFieldsToNative(unifiedFields), | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
subscribe, | ||
resubscribe, | ||
unsubscribe, | ||
pullUpdates, | ||
fullSync, | ||
getSyncsList, | ||
openConfiguration, | ||
listRecords, | ||
findRecords, | ||
findRecordById, | ||
createRecord, | ||
updateRecord, | ||
deleteRecord, | ||
unifiedFieldsToNative, | ||
getLocations, | ||
getCollection, | ||
...rest, | ||
} | ||
} |
import { DataCollectionSpec, DataSourceInstance } from '@integration-app/sdk' | ||
import { useIntegrationApp } from '../contexts/integration-app-context' | ||
import useGetter from '../hooks/useGetter' | ||
import useSWR from 'swr' | ||
@@ -9,4 +9,5 @@ export function useDataSourceInstanceCollection( | ||
const integrationApp = useIntegrationApp() | ||
const { data: collection, ...rest } = useGetter<DataCollectionSpec>( | ||
dataSourceInstance?.id, | ||
const { data, error, isLoading, mutate } = useSWR<DataCollectionSpec>( | ||
dataSourceInstance ? `${dataSourceInstance.id}/collection` : null, | ||
() => | ||
@@ -16,6 +17,15 @@ integrationApp.dataSourceInstance(dataSourceInstance.id).getCollection(), | ||
async function refresh() { | ||
return await mutate() | ||
} | ||
const collection = data | ||
return { | ||
collection, | ||
...rest, | ||
refresh, | ||
error, | ||
loading: isLoading, | ||
} | ||
} |
@@ -6,3 +6,4 @@ import { | ||
import { useIntegrationApp } from '../contexts/integration-app-context' | ||
import useGetter from '../hooks/useGetter' | ||
import useSWR from 'swr' | ||
import qs from 'query-string' | ||
@@ -17,6 +18,7 @@ export function useDataSourceInstanceLocations( | ||
const integrationApp = useIntegrationApp() | ||
const { data, ...rest } = useGetter<DataDirectoryListResponse>( | ||
const { data, error, isLoading, mutate } = useSWR<DataDirectoryListResponse>( | ||
dataSourceInstance | ||
? `${dataSourceInstance.id}/${JSON.stringify(args)}` | ||
: undefined, | ||
? `${dataSourceInstance.id}/locations?${qs.stringify(args)}` | ||
: null, | ||
() => | ||
@@ -28,6 +30,15 @@ integrationApp | ||
async function refresh() { | ||
return await mutate() | ||
} | ||
const locations = data?.locations ?? [] | ||
return { | ||
locations: data?.locations ?? [], | ||
...rest, | ||
locations, | ||
refresh, | ||
error, | ||
loading: isLoading, | ||
} | ||
} |
@@ -8,10 +8,11 @@ import { | ||
export function useDataSourceInstances(query?: FindDataSourceInstancesQuery) { | ||
const { ...rest } = useElements< | ||
DataSourceInstance, | ||
FindDataSourceInstancesQuery | ||
>(query, (integrationApp) => integrationApp.dataSourceInstances) | ||
const { ...rest } = useElements<DataSourceInstance>( | ||
'data-source-instances', | ||
query, | ||
) | ||
return { | ||
dataSourceInstances: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -5,10 +5,8 @@ import { DataSource, FindDataSourcesQuery } from '@integration-app/sdk' | ||
export function useDataSources(query?: FindDataSourcesQuery) { | ||
const { ...rest } = useElements<DataSource, FindDataSourcesQuery>( | ||
query, | ||
(integrationApp) => integrationApp.dataSources, | ||
) | ||
const { ...rest } = useElements<DataSource>('data-sources', query) | ||
return { | ||
dataSources: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -1,14 +0,35 @@ | ||
import { FieldMapping, FieldMappingAccessor } from '@integration-app/sdk' | ||
import { | ||
CreateFieldMappingRequest, | ||
FieldMapping, | ||
FieldMappingAccessor, | ||
FieldMappingSelector, | ||
UpdateFieldMappingRequest, | ||
} from '@integration-app/sdk' | ||
import { useElement } from '../hooks/useElement' | ||
export function useFieldMapping(idOrKey: string) { | ||
const { data: fieldMapping, ...rest } = useElement< | ||
export function useFieldMapping(selector: FieldMappingSelector | string) { | ||
const { | ||
item: fieldMapping, | ||
accessor, | ||
refresh, | ||
...rest | ||
} = useElement< | ||
FieldMapping, | ||
string, | ||
UpdateFieldMappingRequest, | ||
CreateFieldMappingRequest, | ||
FieldMappingAccessor | ||
>(idOrKey, (integrationApp) => | ||
integrationApp.fieldMapping.bind(integrationApp), | ||
) | ||
>(selector, (integrationApp) => integrationApp.fieldMapping(selector)) | ||
return { fieldMapping, ...rest } | ||
async function apply(integrationKeys: string[]): Promise<FieldMapping[]> { | ||
const result = await accessor?.apply(integrationKeys) | ||
await refresh() | ||
return result | ||
} | ||
async function reset() { | ||
await accessor?.reset() | ||
await refresh() | ||
} | ||
return { fieldMapping, apply, reset, refresh, accessor, ...rest } | ||
} |
@@ -6,2 +6,4 @@ import { | ||
OpenFieldMappingInstanceConfigurationOptions, | ||
UpdateFieldMappingInstanceRequest, | ||
CreateFieldMappingInstanceRequest, | ||
} from '@integration-app/sdk' | ||
@@ -11,23 +13,44 @@ import { useElement } from '../hooks/useElement' | ||
export function useFieldMappingInstance( | ||
selector: FieldMappingInstanceSelector | { id: string }, | ||
selector: string | FieldMappingInstanceSelector, | ||
) { | ||
const { data: fieldMappingInstance, ...rest } = useElement< | ||
const { | ||
item: fieldMappingInstance, | ||
accessor, | ||
refresh, | ||
...rest | ||
} = useElement< | ||
FieldMappingInstance, | ||
FieldMappingInstanceSelector, | ||
UpdateFieldMappingInstanceRequest, | ||
CreateFieldMappingInstanceRequest, | ||
FieldMappingInstanceAccessor | ||
>(selector, (integrationApp) => | ||
integrationApp.fieldMappingInstance.bind(integrationApp), | ||
) | ||
>(selector, (integrationApp) => integrationApp.fieldMappingInstance(selector)) | ||
const accessor = rest.accessor | ||
async function setup() { | ||
await accessor?.setup() | ||
await refresh() | ||
} | ||
async function reset() { | ||
await accessor?.reset() | ||
await refresh() | ||
} | ||
async function openConfiguration( | ||
options?: OpenFieldMappingInstanceConfigurationOptions, | ||
) { | ||
return accessor?.openConfiguration(options) | ||
} | ||
return { | ||
fieldMappingInstance, | ||
setup: () => accessor.setup(), | ||
reset: () => accessor.reset(), | ||
openConfiguration: ( | ||
options?: OpenFieldMappingInstanceConfigurationOptions, | ||
) => accessor.openConfiguration(options), | ||
accessor, | ||
refresh, | ||
setup, | ||
reset, | ||
openConfiguration, | ||
...rest, | ||
} | ||
} |
@@ -10,10 +10,11 @@ import { | ||
) { | ||
const { ...rest } = useElements< | ||
FieldMappingInstance, | ||
FindFieldMappingInstancesQuery | ||
>(query, (integrationApp) => integrationApp.fieldMappingInstances) | ||
const { ...rest } = useElements<FieldMappingInstance>( | ||
'field-mapping-instances', | ||
query, | ||
) | ||
return { | ||
fieldMappingInstances: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -5,10 +5,8 @@ import { FieldMapping, FindFieldMappingsQuery } from '@integration-app/sdk' | ||
export function useFieldMappings(query?: FindFieldMappingsQuery) { | ||
const { ...rest } = useElements<FieldMapping, FindFieldMappingsQuery>( | ||
query, | ||
(integrationApp) => integrationApp.fieldMappings, | ||
) | ||
const { ...rest } = useElements<FieldMapping>('field-mappings', query) | ||
return { | ||
fieldMappings: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -1,12 +0,33 @@ | ||
import { Flow, FlowAccessor, FlowSelector } from '@integration-app/sdk' | ||
import { | ||
CreateFlowRequest, | ||
Flow, | ||
FlowAccessor, | ||
FlowSelector, | ||
UpdateFlowRequest, | ||
} from '@integration-app/sdk' | ||
import { useElement } from '../hooks/useElement' | ||
export function useFlow(idOrSelector: string | FlowSelector) { | ||
const { data: flow, ...rest } = useElement< | ||
Flow, | ||
string | FlowSelector, | ||
FlowAccessor | ||
>(idOrSelector, (integrationApp) => integrationApp.flow.bind(integrationApp)) | ||
export function useFlow(selector: string | FlowSelector) { | ||
const { | ||
item: flow, | ||
accessor, | ||
refresh, | ||
...rest | ||
} = useElement<Flow, UpdateFlowRequest, CreateFlowRequest, FlowAccessor>( | ||
selector, | ||
(integrationApp) => integrationApp.flow(selector), | ||
) | ||
return { flow, ...rest } | ||
async function apply(integrationKeys: string[]): Promise<Flow[]> { | ||
const result = await accessor?.apply(integrationKeys) | ||
await refresh() | ||
return result | ||
} | ||
async function reset(): Promise<Flow> { | ||
await accessor?.reset() | ||
return await refresh() | ||
} | ||
return { flow, apply, reset, refresh, accessor, ...rest } | ||
} |
@@ -5,13 +5,70 @@ import { | ||
FlowInstanceSelector, | ||
OpenFlowInstanceConfigurationOptions, | ||
RunFlowOptions, | ||
UpdateFlowInstanceRequest, | ||
} from '@integration-app/sdk' | ||
import { useElement } from '../hooks/useElement' | ||
export function useFlowInstance(props: FlowInstanceSelector | { id: string }) { | ||
const { data: flowInstance, ...rest } = useElement< | ||
export function useFlowInstance(selector: string | FlowInstanceSelector) { | ||
const { | ||
item: flowInstance, | ||
accessor, | ||
refresh, | ||
...rest | ||
} = useElement< | ||
FlowInstance, | ||
FlowInstanceSelector, | ||
UpdateFlowInstanceRequest, | ||
UpdateFlowInstanceRequest, | ||
FlowInstanceAccessor | ||
>(props, (integrationApp) => integrationApp.flowInstance.bind(integrationApp)) | ||
>(selector, (integrationApp) => integrationApp.flowInstance(selector)) | ||
return { flowInstance, ...rest } | ||
async function enable() { | ||
await accessor?.enable() | ||
await refresh() | ||
} | ||
async function disable() { | ||
await accessor?.disable() | ||
await refresh() | ||
} | ||
async function reset() { | ||
await accessor?.reset() | ||
await refresh() | ||
} | ||
async function setup() { | ||
await accessor?.setup() | ||
await refresh() | ||
} | ||
async function openConfiguration( | ||
options: OpenFlowInstanceConfigurationOptions, | ||
) { | ||
return accessor?.openConfiguration(options) | ||
} | ||
async function run(options: RunFlowOptions = {}) { | ||
return accessor?.run(options) | ||
} | ||
async function startRun(options: RunFlowOptions = {}) { | ||
return accessor?.startRun(options) | ||
} | ||
return { | ||
flowInstance, | ||
accessor, | ||
refresh, | ||
enable, | ||
disable, | ||
reset, | ||
setup, | ||
openConfiguration, | ||
run, | ||
startRun, | ||
...rest, | ||
} | ||
} |
@@ -5,10 +5,8 @@ import { FindFlowInstancesQuery, FlowInstance } from '@integration-app/sdk' | ||
export function useFlowInstances(query?: FindFlowInstancesQuery) { | ||
const { ...rest } = useElements<FlowInstance, FindFlowInstancesQuery>( | ||
query, | ||
(integrationApp) => integrationApp.flowInstances, | ||
) | ||
const { ...rest } = useElements<FlowInstance>('flow-instances', query) | ||
return { | ||
flowInstances: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -5,9 +5,21 @@ import { FlowRun, FlowRunAccessor } from '@integration-app/sdk' | ||
export function useFlowRun(id: string) { | ||
const { data: flowRun, ...rest } = useElement< | ||
FlowRun, | ||
string, | ||
FlowRunAccessor | ||
>(id, (integrationApp) => integrationApp.flowRun.bind(integrationApp)) | ||
const { | ||
item: flowRun, | ||
archive, | ||
refresh, | ||
error, | ||
loading, | ||
} = useElement<FlowRun, never, never, FlowRunAccessor>(id, (integrationApp) => | ||
integrationApp.flowRun(id), | ||
) | ||
return { flowRun, ...rest } | ||
return { | ||
flowRun, | ||
error, | ||
loading, | ||
refresh, | ||
archive, | ||
} | ||
} |
@@ -5,8 +5,8 @@ import { FindFlowRunsRequest, FlowRun } from '@integration-app/sdk' | ||
export function useFlowRuns(query?: FindFlowRunsRequest) { | ||
const { ...rest } = useElements<FlowRun, FindFlowRunsRequest>( | ||
query, | ||
(integrationApp) => integrationApp.flowRuns, | ||
) | ||
const { ...rest } = useElements<FlowRun>('flow-runs', query) | ||
return { ...rest } | ||
return { | ||
flowRuns: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -5,8 +5,8 @@ import { useElements } from '../hooks/useElements' | ||
export function useFlows(query?: FindFlowsRequest) { | ||
const { ...rest } = useElements<Flow, FindFlowsRequest>( | ||
query, | ||
(integrationApp) => integrationApp.flows, | ||
) | ||
const { ...rest } = useElements<Flow>('flows', query) | ||
return { ...rest } | ||
return { | ||
flows: rest.items, | ||
...rest, | ||
} | ||
} |
@@ -1,12 +0,21 @@ | ||
import { Connection, ConnectionAccessor } from '@integration-app/sdk' | ||
import { | ||
Connection, | ||
ConnectionAccessor, | ||
CreateConnectionRequest, | ||
UpdateConnectionRequest, | ||
} from '@integration-app/sdk' | ||
import { useElement } from '../hooks/useElement' | ||
export function useConnection(id: string) { | ||
const { data: connection, ...rest } = useElement< | ||
const { item: connection, ...rest } = useElement< | ||
Connection, | ||
string, | ||
UpdateConnectionRequest, | ||
CreateConnectionRequest, | ||
ConnectionAccessor | ||
>(id, (integrationApp) => integrationApp.connection.bind(integrationApp)) | ||
>(id, (integrationApp) => integrationApp.connection(id)) | ||
return { connection, ...rest } | ||
return { | ||
connection, | ||
...rest, | ||
} | ||
} |
@@ -5,10 +5,9 @@ import { Connection, FindConnectionsQuery } from '@integration-app/sdk' | ||
export function useConnections(query?: FindConnectionsQuery) { | ||
const { ...rest } = useElements<Connection, FindConnectionsQuery>( | ||
query, | ||
(integrationApp) => integrationApp.connections, | ||
) | ||
const { ...rest } = useElements<Connection>('connections', query) | ||
return { | ||
connections: rest.items, | ||
...rest, | ||
} | ||
} |
import { ConnectionSpec } from '@integration-app/sdk' | ||
import { useEffect, useState } from 'react' | ||
import { useIntegrationApp } from '../contexts/integration-app-context' | ||
import useSWR from 'swr' | ||
export function useConnectorSpec(integrationKey: string) { | ||
export function useConnectorSpec(integrationIdOrKey: string) { | ||
const integrationApp = useIntegrationApp() | ||
const [data, setData] = useState<ConnectionSpec | null>(null) | ||
const [loading, setLoading] = useState(true) | ||
const [error, setError] = useState<Error>(null) | ||
useEffect(() => { | ||
if (!integrationApp) { | ||
return | ||
} | ||
const { data, isLoading, error } = useSWR<ConnectionSpec>( | ||
`/integrations/${integrationIdOrKey}/connector-spec`, | ||
() => integrationApp.integration(integrationIdOrKey).getConnectorSpec(), | ||
) | ||
integrationApp | ||
.integration(integrationKey) | ||
.getConnectorSpec() | ||
.then(setData) | ||
.catch(setError) | ||
.finally(() => setLoading(false)) | ||
}, [integrationApp, integrationKey]) | ||
return { data, loading, error } | ||
return { data, loading: isLoading, error } | ||
} |
@@ -1,14 +0,18 @@ | ||
import { Integration, IntegrationAccessor } from '@integration-app/sdk' | ||
import { | ||
CreateIntegrationRequest, | ||
Integration, | ||
IntegrationAccessor, | ||
UpdateIntegrationRequest, | ||
} from '@integration-app/sdk' | ||
import { useElement } from '../hooks/useElement' | ||
export function useIntegration(idOrKey: string) { | ||
const { data: integration, ...rest } = useElement< | ||
export function useIntegration(id: string) { | ||
const { item: integration, ...rest } = useElement< | ||
Integration, | ||
string, | ||
UpdateIntegrationRequest, | ||
CreateIntegrationRequest, | ||
IntegrationAccessor | ||
>(idOrKey, (integrationApp) => | ||
integrationApp.integration.bind(integrationApp), | ||
) | ||
>(id, (integrationApp) => integrationApp.integration(id)) | ||
return { integration, ...rest } | ||
} |
@@ -5,10 +5,9 @@ import { FindIntegrationsQuery, Integration } from '@integration-app/sdk' | ||
export function useIntegrations(query?: FindIntegrationsQuery) { | ||
const { ...rest } = useElements<Integration, FindIntegrationsQuery>( | ||
query, | ||
(integrationApp) => integrationApp.integrations, | ||
) | ||
const { ...rest } = useElements<Integration>('integrations', query) | ||
return { | ||
integrations: rest.items, | ||
...rest, | ||
} | ||
} |
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
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
250556
56
4537
6
2
+ Addedquery-string@^7.1.1
+ Addedswr@^2.2.0
+ Added@types/debounce-promise@3.1.9(transitive)
+ Addedawesome-debounce-promise@2.1.0(transitive)
+ Addedawesome-imperative-promise@1.0.1(transitive)
+ Addedawesome-only-resolves-last-promise@1.0.3(transitive)
+ Addeddebounce-promise@3.1.2(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addedfilter-obj@1.1.0(transitive)
+ Addedquery-string@7.1.3(transitive)
+ Addedsplit-on-first@1.1.0(transitive)
+ Addedstrict-uri-encode@2.0.0(transitive)
+ Addedswr@2.3.0(transitive)
+ Addeduse-sync-external-store@1.4.0(transitive)