@integration-app/sdk
Advanced tools
Comparing version 0.16.56 to 0.16.57
132
bundle.d.ts
@@ -9,2 +9,3 @@ declare class PaginationQuery { | ||
} | ||
type OmitCommonNotEditableFields<T> = Omit<T, 'id' | 'archivedAt' | 'versionKey' | 'revision' | 'publishedRevision'>; | ||
@@ -124,3 +125,2 @@ interface IntegrationAppClientOptions { | ||
declare enum DataCollectionEventType { | ||
ALL = "all", | ||
CREATED = "created", | ||
@@ -164,5 +164,5 @@ UPDATED = "updated", | ||
interface OperationMapping<OperationArgs = any> { | ||
interface OperationMapping { | ||
operationKey: string; | ||
inputMapping?: OperationArgs; | ||
inputMapping?: any; | ||
outputMapping?: any; | ||
@@ -178,4 +178,4 @@ } | ||
tags?: string[]; | ||
argsSchema?: DataSchema; | ||
resultSchema?: DataSchema; | ||
inputSchema?: DataSchema; | ||
outputSchema?: DataSchema; | ||
methods?: Record<'run', ConnectorOperationMethod>; | ||
@@ -200,5 +200,5 @@ } | ||
interface RestApiMapping { | ||
inputMapping: { | ||
path: any; | ||
method: any; | ||
path: string; | ||
method: string; | ||
requestMapping: { | ||
pathParameters?: any; | ||
@@ -209,3 +209,3 @@ query?: any; | ||
}; | ||
outputMapping?: any; | ||
responseMapping?: any; | ||
} | ||
@@ -223,20 +223,21 @@ | ||
implementationType?: ConnectorMethodImplementationType; | ||
filePath?: string; | ||
} | ||
interface ConnectorMethodImplementationMapping { | ||
interface ConnectorMethodImplementationMapping extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.mapping; | ||
mapping: MappingBase; | ||
} | ||
interface ConnectorMethodImplementationOperationMapping { | ||
interface ConnectorMethodImplementationOperationMapping extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.operationMapping; | ||
mapping: OperationMapping; | ||
} | ||
interface ConnectorMethodImplementationRestApiMapping { | ||
interface ConnectorMethodImplementationRestApiMapping extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.restApiMapping; | ||
mapping: RestApiMapping; | ||
} | ||
interface ConnectorMethodImplementationJavascript { | ||
interface ConnectorMethodImplementationJavascript extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.javascript; | ||
code: string; | ||
} | ||
interface ConnectorMethodImplementationNotSupported { | ||
interface ConnectorMethodImplementationNotSupported extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.notSupported; | ||
@@ -330,2 +331,4 @@ } | ||
[value in DataCollectionEventType]: DataCollectionEventTypeSpec; | ||
} & { | ||
all: DataCollectionEventTypeSpec; | ||
}; | ||
@@ -381,12 +384,35 @@ interface DataCollectionFindRequest { | ||
declare const CONNECTOR_AUTH_TYPES: readonly ["oauth2", "client-credentials"]; | ||
type ConnectorAuthType = typeof CONNECTOR_AUTH_TYPES[number]; | ||
interface ConnectorAuthBase { | ||
type: ConnectorAuthType; | ||
credentialsSchema?: DataSchema; | ||
refreshCredentials?: ConnectorMethodImplementationBase; | ||
test: ConnectorMethodImplementationBase; | ||
} | ||
interface ConnectorAuthOAuth2 extends ConnectorAuthBase { | ||
type: 'oauth2'; | ||
oAuthConfig?: ConnectorMethodImplementationBase; | ||
getOAuthConfig?: ConnectorMethodImplementationBase; | ||
getTokenData?: ConnectorMethodImplementationBase; | ||
getCredentialsFromTokenResponse?: ConnectorMethodImplementationBase; | ||
} | ||
interface ConnectorAuthClientCredentials extends ConnectorAuthBase { | ||
type: 'client-credentials'; | ||
getCredentialsFromConnectionParameters?: ConnectorMethodImplementationBase; | ||
} | ||
type ConnectorAuth = ConnectorAuthOAuth2 | ConnectorAuthClientCredentials; | ||
declare const CONNECTOR_TYPES: readonly ["package"]; | ||
type ConnectorType = typeof CONNECTOR_TYPES[number]; | ||
interface ConnectorAuthSpec { | ||
mode?: ConnectionMode; | ||
credentialsSchema?: DataSchema; | ||
authorizeUri: string; | ||
tokenUri: string; | ||
authorizeUri?: string; | ||
tokenUri?: string; | ||
test?: boolean; | ||
} | ||
interface ConnectorUiSpec { | ||
schema?: DataSchema; | ||
description?: string; | ||
schema?: any; | ||
helpUri?: string; | ||
@@ -410,7 +436,8 @@ test?: boolean; | ||
apiDocsUri?: string; | ||
auth: ConnectorAuthSpec; | ||
ui?: ConnectorUiSpec; | ||
auth?: ConnectorAuthSpec | ConnectorAuth; | ||
parametersSchema?: DataSchema; | ||
data?: ConnectorDataSpec; | ||
operations?: ConnectorOperation[]; | ||
test?: ConnectorMethodImplementation; | ||
connectionMode?: ConnectionMode; | ||
@@ -462,2 +489,5 @@ } | ||
name: string; | ||
connectorType?: ConnectorType; | ||
authType?: ConnectorAuthType; | ||
parameters?: any; | ||
baseUri: string; | ||
@@ -562,2 +592,3 @@ auth: IntegrationAuth; | ||
integration?: Integration; | ||
credentials?: string; | ||
accessToken?: string; | ||
@@ -765,3 +796,3 @@ refreshToken?: string; | ||
constructor(client: IntegrationAppApiClient, idOrKey: string); | ||
apply(integrationKeys: string[]): Promise<FlowInstance>; | ||
apply(integrationKeys: string[]): Promise<any>; | ||
} | ||
@@ -960,8 +991,3 @@ declare class FlowAccessor extends ElementAccessor<Flow, CreateFlowRequest, UpdateFlowRequest> { | ||
} | ||
interface CreateDataSourceRequest { | ||
key: string; | ||
name: string; | ||
udm?: UDM; | ||
pullIntervalSeconds?: number; | ||
} | ||
type CreateDataSourceRequest = Omit<DataSource, 'id' | 'dataSourceTemplateId' | 'archivedAt' | 'versionKey' | 'revision' | 'publishedRevision'>; | ||
type UpdateDataSourceRequest = Partial<CreateDataSourceRequest>; | ||
@@ -994,2 +1020,6 @@ interface DataSourceInstanceSelector extends ConnectionSelector, FlowInstanceSelector, ElementInstanceSelector { | ||
} | ||
type CreateDataSourceTemplateRequest = Omit<DataSourceTemplate, 'id' | 'archivedAt' | 'versionKey' | 'revision' | 'publishedRevision'>; | ||
type UpdateDataSourceTemplateRequest = Partial<CreateDataSourceTemplateRequest>; | ||
interface FindDataSourceTemplatesQuery extends PaginationQuery { | ||
} | ||
@@ -1001,5 +1031,12 @@ interface OpenDataSourceConfigurationOptions extends OpenConfigurationOptions, CommonConfigurationOptions { | ||
} | ||
declare class DataSourceTemplatesAccessor extends ElementListAccessor<DataSourceTemplate, FindDataSourceTemplatesQuery, CreateDataSourceTemplateRequest> { | ||
constructor(client: IntegrationAppApiClient); | ||
} | ||
declare class DataSourceAccessor extends ElementAccessor<DataSource, CreateDataSourceRequest, UpdateDataSourceRequest> { | ||
constructor(client: IntegrationAppApiClient, idOrKey: string); | ||
} | ||
declare class DataSourceTemplateAccessor extends ElementAccessor<DataSourceTemplate, CreateDataSourceTemplateRequest, UpdateDataSourceTemplateRequest> { | ||
constructor(client: IntegrationAppApiClient, idOrKey: string); | ||
apply(integrationKeys: string[]): Promise<any>; | ||
} | ||
declare class DataSourceInstancesAccessor extends ElementInstanceListAccessor<DataSourceInstance, FindDataSourceInstancesQuery> { | ||
@@ -1044,2 +1081,11 @@ constructor(client: IntegrationAppApiClient); | ||
} | ||
interface DataSourceTemplate { | ||
id: string; | ||
key: string; | ||
name: string; | ||
archivedAt?: string; | ||
udm?: string; | ||
pullUpdatesIntervalSeconds?: number; | ||
fullSyncIntervalSeconds?: number; | ||
} | ||
interface DataSourceEventSubscription { | ||
@@ -1099,3 +1145,3 @@ type: SubscriptionType; | ||
} | ||
type CreateFieldMappingRequest = Omit<FieldMapping, 'id'>; | ||
type CreateFieldMappingRequest = OmitCommonNotEditableFields<FieldMapping>; | ||
type UpdateFieldMappingRequest = Partial<CreateFieldMappingRequest>; | ||
@@ -1120,2 +1166,6 @@ interface CreateFieldMappingInstanceRequest { | ||
} | ||
type CreateFieldMappingTemplateRequest = OmitCommonNotEditableFields<FieldMappingTemplate>; | ||
type UpdateFieldMappingTemplateRequest = Partial<CreateFieldMappingTemplateRequest>; | ||
interface FindFieldMappingTemplatesQuery extends PaginationQuery { | ||
} | ||
@@ -1127,5 +1177,14 @@ interface OpenFieldMappingInstanceConfigurationOptions extends OpenConfigurationOptions, CommonConfigurationOptions { | ||
} | ||
declare class FieldMappingTemplatesAccessor extends ElementListAccessor<FieldMappingTemplate, FindFieldMappingTemplatesQuery, CreateFieldMappingTemplateRequest> { | ||
constructor(client: IntegrationAppApiClient); | ||
} | ||
declare class FieldMappingAccessor extends ElementAccessor<FieldMapping, CreateFieldMappingRequest, UpdateFieldMappingRequest> { | ||
constructor(client: IntegrationAppApiClient, idOrKey: string); | ||
getAppSchema(): Promise<any>; | ||
} | ||
declare class FieldMappingTemplateAccessor extends ElementAccessor<FieldMappingTemplate, CreateFieldMappingTemplateRequest, UpdateFieldMappingTemplateRequest> { | ||
constructor(client: IntegrationAppApiClient, idOrKey: string); | ||
getAppSchema(): Promise<any>; | ||
apply(integrationKeys: string[]): Promise<any>; | ||
} | ||
declare class FieldMappingInstancesAccessor extends ElementInstanceListAccessor<IFieldMappingInstance, FindFieldMappingInstancesQuery> { | ||
@@ -1159,4 +1218,17 @@ constructor(client: IntegrationAppApiClient); | ||
frozenUnifiedExportFields?: any; | ||
archivedAt?: Date; | ||
archivedAt?: string; | ||
} | ||
interface FieldMappingTemplate { | ||
id: string; | ||
name: string; | ||
key: string; | ||
archivedAt?: string; | ||
dataSourceTemplateId?: string; | ||
appSchema?: DataSchema; | ||
direction?: FieldMappingDirection; | ||
defaultImportValue?: any; | ||
defaultExportValue?: any; | ||
frozenImportFields?: any; | ||
frozenUnifiedExportFields?: any; | ||
} | ||
interface IFieldMappingInstance extends EntityInstanceVersionFields { | ||
@@ -1279,2 +1351,3 @@ id: string; | ||
instanceKey?: string; | ||
autoCreate?: boolean; | ||
} | ||
@@ -1310,2 +1383,3 @@ interface IAppDataSchemaInstanceUpdate { | ||
request?: HttpRequestSpec; | ||
code?: string; | ||
} | ||
@@ -1369,7 +1443,11 @@ interface AppDataSchemaInstance { | ||
get dataSources(): DataSourcesAccessor; | ||
get dataSourceTemplates(): DataSourceTemplatesAccessor; | ||
dataSource(keyOrId: string): DataSourceAccessor; | ||
dataSourceTemplate(keyOrId: string): DataSourceTemplateAccessor; | ||
dataSourceInstance(selector: string | DataSourceInstanceSelector): DataSourceInstanceAccessor; | ||
get dataSourceEvents(): DataSourceEventsAccessor; | ||
get fieldMappings(): FieldMappingsAccessor; | ||
get fieldMappingTemplates(): FieldMappingTemplatesAccessor; | ||
fieldMapping(idOrKey: string): FieldMappingAccessor; | ||
fieldMappingTemplate(idOrKey: string): FieldMappingTemplateAccessor; | ||
get fieldMappingInstances(): FieldMappingInstancesAccessor; | ||
@@ -1376,0 +1454,0 @@ fieldMappingInstance(selector: string | FieldMappingInstanceSelector): FieldMappingInstanceAccessor; |
{ | ||
"name": "@integration-app/sdk", | ||
"version": "0.16.56", | ||
"version": "0.16.57", | ||
"description": "JavaScript SDK for Integration.app", | ||
@@ -17,3 +17,5 @@ "author": "Integration.app", | ||
"scripts": { | ||
"build": "npm run clean && rollup -c rollup.config.mjs", | ||
"build": "npm run clean && npm run build:bundle && npm run build:dts", | ||
"build:bundle": "rollup -c rollup.config.mjs", | ||
"build:dts": "rollup -c rollup.dts.config.mjs", | ||
"cleanPrevVersionFiles": "find . -type f \\( -name \"*.js\" -o -name \"*.d.ts\" -o -name \"*.js.map\" \\) -not -name \".eslintrc.js\" -not -path \"./node_modules/*\" -exec rm {} \\;", | ||
@@ -23,3 +25,5 @@ "clean": "exec rm -rf ./dist ./bundle.js* ./bundle.d.ts", | ||
"docs:dev": "typedoc --plugin typedoc-plugin-missing-exports --tsconfig tsconfig.json --watch", | ||
"dev": "npm run clean && rollup -c rollup.config.mjs --watch", | ||
"dev": "npm run build && concurrently 'npm run dev:bundle' 'npm run dev:dts'", | ||
"dev:bundle": "rollup -c rollup.config.mjs --watch", | ||
"dev:dts": "rollup -c rollup.dts.config.mjs --watch", | ||
"lint": "eslint -c .eslintrc.js src", | ||
@@ -33,15 +37,15 @@ "publish-dist": "npm publish --access public", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^24.0.1", | ||
"@rollup/plugin-commonjs": "^24.1.0", | ||
"@rollup/plugin-json": "^6.0.0", | ||
"@rollup/plugin-node-resolve": "^15.0.2", | ||
"@rollup/plugin-typescript": "^11.1.0", | ||
"@types/insert-css": "^2.0.0", | ||
"@types/insert-css": "^2.0.1", | ||
"@types/jest": "^27.0.2", | ||
"concurrently": "^8.0.1", | ||
"eslint-plugin-jest": "^24.4.0", | ||
"jest": "^29.5.0", | ||
"rollup": "^3.20.2", | ||
"rollup": "^3.21.3", | ||
"rollup-plugin-dts": "^5.3.0", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.2.0", | ||
"tsconfig-paths": "^3.10.1", | ||
"typedoc": "^0.24.6", | ||
@@ -54,3 +58,3 @@ "typedoc-plugin-missing-exports": "^2.0.0", | ||
"@types/node": "^18.16.2", | ||
"@ungap/structured-clone": "^1.0.2", | ||
"@ungap/structured-clone": "^1.1.0", | ||
"axios": "^0.21.4", | ||
@@ -61,3 +65,3 @@ "fast-deep-equal": "^3.1.3", | ||
"js-convert-case": "^4.2.0", | ||
"penpal": "^6.2.1", | ||
"penpal": "^6.2.2", | ||
"query-string": "^7.1.1", | ||
@@ -64,0 +68,0 @@ "tslib": "^2.3.1", |
@@ -10,16 +10,32 @@ ## Releasing Package | ||
# Rollup config | ||
# Rollup Configuration | ||
Check out the [rollup.config.mjs](rollup.config.mjs) file for the full config. | ||
To see the complete configuration, refer to the `rollup.config.mjs` and `rollup.dts.config.mjs` files. Although these files are self-explanatory, here's some additional information: | ||
It's pretty self-explanatory, but here's some additional info: | ||
In `rollup.config.mjs`, we set `{external: [/node_modules/]}` to exclude our dependencies from being bundled. | ||
We set `{external: [/node_modules/]}` because we don't want to bundle any of our dependencies. | ||
If we need to bundle some dependencies and some not, we can use [`rollup-plugin-peer-deps-external`](https://www.npmjs.com/package/rollup-plugin-peer-deps-external) plugin instead of this. | ||
## Bundle and DTS File Generation Workflow | ||
## DTS | ||
When using `rollup-plugin-dts` and `@rollup/plugin-typescript` in the same configuration, we experienced issues with generating incorrect DTS files. To solve this, we use two Rollup configurations: | ||
- `rollup.config.mjs` for generating bundles | ||
- `rollup.dts.config.mjs` for generating DTS files. | ||
DTS files are generated by `tsc` and placed in `dist/dts` folder. | ||
After that plugin `rollup-plugin-dts` is used to generate `*.d.ts` files for each bundle. | ||
### Build | ||
For build, the following steps are taken: | ||
- Clean the `/dist` folder and `./bundle.*` files. | ||
- Rollup with `rollup.config.mjs` configuration generates bundle files and basic DTS files, which are placed in the `dist/dts` folder. | ||
- Rollup with `rollup.dts.config.mjs` configuration uses the basic DTS files to generate `*.d.ts` files for each bundle. | ||
### Development | ||
During development, the following steps are taken: | ||
- Run `build` to generate bundle and DTS files. | ||
- If not, Rollup with `rollup.dts.config.mjs` in watch mode fails due to missing DTS files (race condition). | ||
- Concurrently run two Rollup processes **in watch mode**: | ||
- Rollup with `rollup.config.mjs` configuration to generate bundle files and basic DTS files. | ||
- Rollup with `rollup.dts.config.mjs` configuration to generate DTS files for each bundle. | ||
# Package.json exports | ||
@@ -26,0 +42,0 @@ |
@@ -6,3 +6,3 @@ import Axios, { AxiosRequestConfig } from 'axios' | ||
const DEFAULT_API_URI = 'https://engine-api.integration.app' | ||
const DEFAULT_API_URI = 'https://api.integration.app' | ||
const DEFAULT_UI_URI = 'https://ui.integration.app' | ||
@@ -9,0 +9,0 @@ |
@@ -15,2 +15,3 @@ import { AppDataSchema } from '.' | ||
instanceKey?: string | ||
autoCreate?: boolean | ||
} | ||
@@ -17,0 +18,0 @@ |
@@ -18,2 +18,4 @@ import { ErrorData } from '../errors' | ||
request?: HttpRequestSpec | ||
code?: string | ||
} | ||
@@ -20,0 +22,0 @@ |
@@ -22,2 +22,4 @@ import { ConnectionAccessor, ConnectionsAccessor } from './connections' | ||
FieldMappingInstancesAccessor, | ||
FieldMappingTemplatesAccessor, | ||
FieldMappingTemplateAccessor, | ||
} from './field-mappings' | ||
@@ -30,2 +32,4 @@ import { | ||
DataSourceAccessor, | ||
DataSourceTemplatesAccessor, | ||
DataSourceTemplateAccessor, | ||
} from './data-sources' | ||
@@ -133,2 +137,6 @@ import { FlowInstanceSelector } from './flows' | ||
get dataSourceTemplates(): DataSourceTemplatesAccessor { | ||
return new DataSourceTemplatesAccessor(this) | ||
} | ||
/** | ||
@@ -144,2 +152,9 @@ * @group Accessors | ||
*/ | ||
dataSourceTemplate(keyOrId: string): DataSourceTemplateAccessor { | ||
return new DataSourceTemplateAccessor(this, keyOrId) | ||
} | ||
/** | ||
* @group Accessors | ||
*/ | ||
dataSourceInstance( | ||
@@ -158,2 +173,7 @@ selector: string | DataSourceInstanceSelector, | ||
} | ||
get fieldMappingTemplates(): FieldMappingTemplatesAccessor { | ||
return new FieldMappingTemplatesAccessor(this) | ||
} | ||
/** | ||
@@ -166,2 +186,9 @@ * @group Accessors | ||
/** | ||
* @group Accessors | ||
*/ | ||
fieldMappingTemplate(idOrKey: string): FieldMappingTemplateAccessor { | ||
return new FieldMappingTemplateAccessor(this, idOrKey) | ||
} | ||
get fieldMappingInstances(): FieldMappingInstancesAccessor { | ||
@@ -168,0 +195,0 @@ return new FieldMappingInstancesAccessor(this) |
@@ -43,3 +43,10 @@ import { User } from '../users' | ||
credentials?: string | ||
/** | ||
* @deprecated | ||
*/ | ||
accessToken?: string | ||
/** | ||
* @deprecated | ||
*/ | ||
refreshToken?: string | ||
@@ -46,0 +53,0 @@ |
@@ -17,4 +17,9 @@ import { DataSchema } from '../../../../../data-schema' | ||
{ | ||
key: 'custom-pull-subscribe', | ||
getInputSchema: () => null, | ||
filePath: 'custom-pull-subscribe', | ||
getInputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
}, | ||
}), | ||
getOutputSchema: ({ collection }) => ({ | ||
@@ -39,6 +44,7 @@ type: 'object', | ||
{ | ||
key: 'custom-pull-collect-events', | ||
getInputSchema: () => ({ | ||
filePath: 'custom-pull-collect-events', | ||
getInputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
cursor: { type: 'string' }, | ||
@@ -45,0 +51,0 @@ }, |
@@ -15,6 +15,7 @@ import { ConnectorMethodImplementationType } from '../../../../methods' | ||
{ | ||
key: 'pull-latest-records', | ||
getInputSchema: () => ({ | ||
filePath: 'pull-latest-records', | ||
getInputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
cursor: { type: 'string' }, | ||
@@ -21,0 +22,0 @@ }, |
@@ -8,4 +8,4 @@ import { DataSchema } from '../../../../../data-schema' | ||
implementationType: 'webhook' | ||
payloadSchema: DataSchema | ||
stateSchema: DataSchema | ||
payloadSchema?: DataSchema | ||
stateSchema?: DataSchema | ||
methods: Record< | ||
@@ -19,6 +19,7 @@ keyof typeof WebhookEventImplementationType.methods, | ||
{ | ||
key: 'webhook-subscribe', | ||
getInputSchema: () => ({ | ||
filePath: 'webhook-subscribe', | ||
getInputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
webhookUri: { type: 'string' }, | ||
@@ -42,6 +43,7 @@ }, | ||
{ | ||
key: 'webhook-unsubscribe', | ||
getInputSchema: ({ event }) => ({ | ||
filePath: 'webhook-unsubscribe', | ||
getInputSchema: ({ collection, event }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
state: event.stateSchema, | ||
@@ -60,3 +62,3 @@ }, | ||
{ | ||
key: 'webhook-handle', | ||
filePath: 'webhook-handle', | ||
getInputSchema: ({ event }) => ({ | ||
@@ -87,4 +89,4 @@ type: 'object', | ||
unsubscribe: WebhookUnsubscribeMethod, | ||
handler: WebhookHandleMethod, | ||
handle: WebhookHandleMethod, | ||
}, | ||
} |
@@ -1,10 +0,40 @@ | ||
import { CustomPullEventImplementationType } from './implementation-types/custom-pull' | ||
import { FullScanEventImplementationType } from './implementation-types/full-scan' | ||
import { PullLatestRecordsEventImplementationType } from './implementation-types/pull-latest-records' | ||
import { WebhookEventImplementationType } from './implementation-types/webhook' | ||
import { | ||
CustomPullEventImplementationFields, | ||
CustomPullEventImplementationType, | ||
} from './implementation-types/custom-pull' | ||
import { | ||
FullScanEventImplementationFields, | ||
FullScanEventImplementationType, | ||
} from './implementation-types/full-scan' | ||
import { | ||
PullLatestRecordsEventImplementationFields, | ||
PullLatestRecordsEventImplementationType, | ||
} from './implementation-types/pull-latest-records' | ||
import { | ||
WebhookEventImplementationFields, | ||
WebhookEventImplementationType, | ||
} from './implementation-types/webhook' | ||
export type ConnectorDataCollectionEvent<ImplementationFields = unknown> = { | ||
// ToDo: common event fields | ||
interface BaseConnectorDataCollectionEventImplementationFields { | ||
implementationType: keyof typeof ConnectorDataCollectionEventImplementationType | ||
} | ||
export type ConnectorDataCollectionEvent< | ||
ImplementationFields = BaseConnectorDataCollectionEventImplementationFields, | ||
> = { | ||
inheritedFromKey?: string | ||
} & ImplementationFields | ||
export type ConnectorDataCollectionEventWebhook = | ||
ConnectorDataCollectionEvent<WebhookEventImplementationFields> | ||
export type ConnectorDataCollectionEventPullLatestRecords = | ||
ConnectorDataCollectionEvent<PullLatestRecordsEventImplementationFields> | ||
export type ConnectorDataCollectionEventCustomPull = | ||
ConnectorDataCollectionEvent<CustomPullEventImplementationFields> | ||
export type ConnectorDataCollectionEventFullScan = | ||
ConnectorDataCollectionEvent<FullScanEventImplementationFields> | ||
export const ConnectorDataCollectionEventImplementationType = { | ||
@@ -16,1 +46,79 @@ webhook: WebhookEventImplementationType, | ||
} | ||
export type ConnectorDataCollectionEventType = 'created' | 'updated' | 'deleted' | ||
export type ConnectorDataCollectionEventImplementationTypeKey = | ||
keyof typeof ConnectorDataCollectionEventImplementationType | ||
export function getEventMethodFilePath( | ||
eventType: ConnectorDataCollectionEventType, | ||
eventImplementationType: ConnectorDataCollectionEventImplementationTypeKey, | ||
methodKey: string, | ||
) { | ||
const methodType = | ||
ConnectorDataCollectionEventImplementationType[eventImplementationType] | ||
.methods[methodKey] | ||
return `events-${eventType}-${methodType.filePath}` | ||
} | ||
/** | ||
* Return a list of possible file paths for a given event type, implementation type, and method key. | ||
* Takes backward compatibility into account. Retuns the most up-to-date path first. | ||
*/ | ||
export function getAllEventMethodFilePaths( | ||
eventType: ConnectorDataCollectionEventType | 'all', | ||
eventImplementationType: ConnectorDataCollectionEventImplementationTypeKey, | ||
methodKey: string, | ||
) { | ||
return [ | ||
eventType === 'all' | ||
? undefined | ||
: getEventMethodFilePath(eventType, eventImplementationType, methodKey), | ||
getLegacyEventMethodFielPath(eventType, eventImplementationType, methodKey), | ||
].filter(Boolean) | ||
} | ||
/** | ||
* Backward compatibility for event method file paths used in `connector-sdk/handlers/data-collections/loader.ts` | ||
* @param eventType | ||
* @param eventImplementationType | ||
* @param methodKey | ||
*/ | ||
function getLegacyEventMethodFielPath( | ||
eventType: ConnectorDataCollectionEventType | 'all', | ||
eventImplementationType: ConnectorDataCollectionEventImplementationTypeKey, | ||
methodKey: string, | ||
) { | ||
const prefix = eventType === 'all' ? 'events' : eventType | ||
switch (eventImplementationType) { | ||
case 'webhook': | ||
switch (methodKey) { | ||
case 'handle': | ||
return `${prefix}-webhook-handle` | ||
case 'subscribe': | ||
return `${prefix}-webhook-subscribe` | ||
case 'unsubscribe': | ||
return `${prefix}-webhook-unsubscribe` | ||
default: | ||
return null | ||
} | ||
case 'pull-latest-records': | ||
switch (methodKey) { | ||
case 'pullLatestRecords': | ||
return `${prefix}-pull-latest-records` | ||
default: | ||
return null | ||
} | ||
case 'custom-pull': | ||
switch (methodKey) { | ||
case 'subscribe': | ||
return `${prefix}-custom-pull-subscribe` | ||
case 'collectEvents': | ||
return `${prefix}-custom-pull-collect-events` | ||
default: | ||
return null | ||
} | ||
default: | ||
return null | ||
} | ||
} |
@@ -16,3 +16,3 @@ import { ConnectorDataCollectionEvent } from '.' | ||
> { | ||
key?: string | ||
filePath?: string | ||
getInputSchema?: ( | ||
@@ -19,0 +19,0 @@ args: ConnectorDataCollectionEventMethodTypeArgs<ImplementationFields>, |
import { DataSchema } from '../../../data-schema' | ||
import { ConnectorMethodImplementationType } from '../../methods' | ||
import { ConnectorDataLocationBase } from '../base' | ||
import { ConnectorDataLocationMethod } from '../methods' | ||
import { ConnectorDataCollectionEvent } from './events' | ||
import { ConnectorDataCollectionMethodType } from './methods/base' | ||
import { DataCollectionMethodCreate } from './methods/create' | ||
@@ -15,3 +18,38 @@ import { DataCollectionMethodDelete } from './methods/delete' | ||
const DataCollectionCustomSpecMethod: ConnectorDataCollectionMethodType = { | ||
supportedImplementationTypes: [ConnectorMethodImplementationType.javascript], | ||
} | ||
const DataCollectionRecordFromApiMethod: ConnectorDataCollectionMethodType = { | ||
supportedImplementationTypes: [ | ||
ConnectorMethodImplementationType.mapping, | ||
ConnectorMethodImplementationType.javascript, | ||
], | ||
} | ||
const DataCollectionRecordFromApiMappingMethod: ConnectorDataCollectionMethodType = | ||
{ | ||
fileKey: 'record-from-api', | ||
supportedImplementationTypes: [ConnectorMethodImplementationType.mapping], | ||
} | ||
const DataCollectionRecordFromApiCodeMethod: ConnectorDataCollectionMethodType = | ||
{ | ||
fileKey: 'record-from-api', | ||
supportedImplementationTypes: [ | ||
ConnectorMethodImplementationType.javascript, | ||
], | ||
} | ||
const DataCollectionRecordToApiMethod: ConnectorDataCollectionMethodType = { | ||
supportedImplementationTypes: [ | ||
ConnectorMethodImplementationType.mapping, | ||
ConnectorMethodImplementationType.javascript, | ||
], | ||
} | ||
export const DataLocationTypeCollection = { | ||
spec: DataCollectionCustomSpecMethod, | ||
recordToApi: DataCollectionRecordToApiMethod, | ||
recordFromApi: DataCollectionRecordFromApiMethod, | ||
methods: { | ||
@@ -30,17 +68,31 @@ list: DataCollectionMethodList, | ||
}, | ||
/** | ||
* @deprecated | ||
*/ | ||
fieldsToApi: DataCollectionRecordToApiMethod, | ||
recordFromApiMapping: DataCollectionRecordFromApiMappingMethod, | ||
recordFromApiCode: DataCollectionRecordFromApiCodeMethod, | ||
} | ||
export interface ConnectorDataCollection { | ||
export interface ConnectorDataCollection extends ConnectorDataLocationBase { | ||
type: 'collection' | ||
key: string | ||
name: string | ||
apiSchema?: DataSchema | ||
fieldsSchema: DataSchema | ||
methods: Record< | ||
keyof typeof DataLocationTypeCollection.methods, | ||
ConnectorDataLocationMethod | ||
spec?: ConnectorDataLocationMethod | ||
recordFromApi?: ConnectorDataLocationMethod | ||
recordToApi?: ConnectorDataLocationMethod | ||
methods: Partial< | ||
Record< | ||
keyof typeof DataLocationTypeCollection.methods, | ||
ConnectorDataLocationMethod | ||
> | ||
> | ||
events: Record< | ||
'created' | 'updated' | 'deleted', | ||
ConnectorDataCollectionEvent | ||
events: Partial< | ||
Record<'created' | 'updated' | 'deleted', ConnectorDataCollectionEvent> | ||
> | ||
/** | ||
* @deprecated | ||
*/ | ||
recordFromApiCode?: ConnectorDataLocationMethod | ||
recordFromApiMapping?: ConnectorDataLocationMethod | ||
} | ||
@@ -47,0 +99,0 @@ |
@@ -6,9 +6,13 @@ import { ConnectorDataCollection } from '..' | ||
export interface ConnectorDataCollectionMethodType<ConfigType = unknown> { | ||
configSchema?: DataSchema | ||
export interface ConnectorDataCollectionMethodType<ConfigFields = unknown> { | ||
// If not specified, the key will be generated from the method key | ||
fileKey?: string | ||
getConfigSchema?: ( | ||
args: ConnectorDataCollectionMethodTypeArgs<ConfigFields>, | ||
) => DataSchema | ||
getInputSchema?: ( | ||
args: ConnectorDataCollectionMethodTypeArgs<ConfigType>, | ||
args: ConnectorDataCollectionMethodTypeArgs<ConfigFields>, | ||
) => DataSchema | ||
getOutputSchema?: ( | ||
args: ConnectorDataCollectionMethodTypeArgs<ConfigType>, | ||
args: ConnectorDataCollectionMethodTypeArgs<ConfigFields>, | ||
) => DataSchema | ||
@@ -18,5 +22,5 @@ supportedImplementationTypes: ConnectorMethodImplementationType[] | ||
interface ConnectorDataCollectionMethodTypeArgs<ConfigType = unknown> { | ||
method: ConnectorDataLocationMethod<ConfigType> | ||
interface ConnectorDataCollectionMethodTypeArgs<ConfigFields = unknown> { | ||
method: ConnectorDataLocationMethod<ConfigFields> | ||
collection: ConnectorDataCollection | ||
} |
@@ -8,2 +8,3 @@ import { Type, Static } from '@sinclair/typebox' | ||
import { DataLocationMethodImplementationTypes } from '../../methods' | ||
import { locatorToField } from '../../../../data-builder' | ||
@@ -23,12 +24,30 @@ const DataCollectionCreateConfigSchema = Type.Partial( | ||
{ | ||
configSchema: DataCollectionCreateConfigSchema, | ||
getConfigSchema: ({ collection }) => { | ||
const fields = Object.keys(collection.fieldsSchema?.properties ?? {}).map( | ||
locatorToField, | ||
) | ||
return { | ||
type: 'object', | ||
properties: { | ||
fields: { | ||
type: 'array', | ||
items: { type: 'string', enum: fields }, | ||
}, | ||
excludedFields: { | ||
type: 'array', | ||
items: { type: 'string', enum: fields }, | ||
}, | ||
}, | ||
} | ||
}, | ||
getInputSchema: ({ collection, method }) => { | ||
let fieldsSchema = collection.fieldsSchema | ||
if (method.config?.fields) { | ||
fieldsSchema = pickFieldsFromSchema(fieldsSchema, method.config.fields) | ||
if (method?.fields) { | ||
fieldsSchema = pickFieldsFromSchema(fieldsSchema, method.fields) | ||
} | ||
if (method.config?.excludedFields) { | ||
if (method?.excludedFields) { | ||
fieldsSchema = excludeFieldsFromSchema( | ||
fieldsSchema, | ||
method.config.excludedFields, | ||
method.excludedFields, | ||
) | ||
@@ -39,2 +58,3 @@ } | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
fields: fieldsSchema, | ||
@@ -41,0 +61,0 @@ }, |
@@ -5,6 +5,7 @@ import { ConnectorDataCollectionMethodType } from './base' | ||
export const DataCollectionMethodDelete: ConnectorDataCollectionMethodType = { | ||
getInputSchema: () => { | ||
getInputSchema: ({ collection }) => { | ||
return { | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
id: { type: 'string' }, | ||
@@ -11,0 +12,0 @@ }, |
@@ -5,5 +5,6 @@ import { ConnectorDataCollectionMethodType } from './base' | ||
export const DataCollectionMethodFindById: ConnectorDataCollectionMethodType = { | ||
getInputSchema: () => ({ | ||
getInputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
id: { type: 'string' }, | ||
@@ -15,6 +16,3 @@ }, | ||
properties: { | ||
record: { | ||
type: 'array', | ||
items: collection.fieldsSchema, | ||
}, | ||
record: collection.apiSchema, | ||
}, | ||
@@ -21,0 +19,0 @@ }), |
@@ -5,2 +5,3 @@ import { Type, Static } from '@sinclair/typebox' | ||
import { DataLocationMethodImplementationTypes } from '../../methods' | ||
import { locatorToField } from '../../../../data-builder' | ||
@@ -19,7 +20,21 @@ const DataCollectionFindConfigSchema = Type.Partial( | ||
{ | ||
configSchema: DataCollectionFindConfigSchema, | ||
getConfigSchema: ({ collection }) => { | ||
const fields = Object.keys(collection.fieldsSchema?.properties ?? {}).map( | ||
locatorToField, | ||
) | ||
return { | ||
type: 'object', | ||
properties: { | ||
queryFields: { | ||
type: 'array', | ||
items: { type: 'string', enum: fields }, | ||
}, | ||
}, | ||
} | ||
}, | ||
getInputSchema: ({ collection, method }) => { | ||
const queryFieldsSchema = pickFieldsFromSchema( | ||
collection.fieldsSchema, | ||
method.config?.queryFields, | ||
method?.queryFields, | ||
) | ||
@@ -29,2 +44,3 @@ const schema: DataSchema = { | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
cursor: { type: 'string' }, | ||
@@ -46,3 +62,3 @@ }, | ||
type: 'array', | ||
items: collection.fieldsSchema, | ||
items: collection.apiSchema, | ||
}, | ||
@@ -49,0 +65,0 @@ cursor: { |
import { ConnectorDataCollectionMethodType } from './base' | ||
import { DataLocationMethodImplementationTypes } from '../../methods' | ||
export const DataCollectionMethodList: ConnectorDataCollectionMethodType<null> = | ||
{ | ||
configSchema: null, | ||
getInputSchema: () => ({ | ||
type: 'object', | ||
properties: { | ||
cursor: { type: 'string' }, | ||
export const DataCollectionMethodList: ConnectorDataCollectionMethodType = { | ||
getInputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
cursor: { type: 'string' }, | ||
}, | ||
}), | ||
getOutputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
records: { | ||
type: 'array', | ||
items: collection.apiSchema, | ||
}, | ||
}), | ||
getOutputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
records: { | ||
type: 'array', | ||
items: collection.fieldsSchema, | ||
}, | ||
cursor: { | ||
type: 'string', | ||
}, | ||
cursor: { | ||
type: 'string', | ||
}, | ||
}), | ||
supportedImplementationTypes: DataLocationMethodImplementationTypes, | ||
} | ||
}, | ||
}), | ||
supportedImplementationTypes: DataLocationMethodImplementationTypes, | ||
} |
@@ -5,2 +5,3 @@ import { Type, Static } from '@sinclair/typebox' | ||
import { DataLocationMethodImplementationTypes } from '../../methods' | ||
import { locatorToField } from '../../../../data-builder' | ||
@@ -17,7 +18,21 @@ const DataCollectionMatchConfigSchema = Type.Object({ | ||
{ | ||
configSchema: DataCollectionMatchConfigSchema, | ||
getConfigSchema: ({ collection }) => { | ||
const fields = Object.keys(collection.fieldsSchema?.properties ?? {}).map( | ||
locatorToField, | ||
) | ||
return { | ||
type: 'object', | ||
properties: { | ||
fields: { | ||
type: 'array', | ||
items: { type: 'string', enum: fields }, | ||
}, | ||
}, | ||
} | ||
}, | ||
getInputSchema: ({ collection, method }) => { | ||
const fieldsSchema = pickFieldsFromSchema( | ||
collection.fieldsSchema, | ||
method.config?.fields, | ||
method?.fields, | ||
) | ||
@@ -27,2 +42,3 @@ return { | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
query: fieldsSchema, | ||
@@ -35,3 +51,3 @@ }, | ||
properties: { | ||
record: collection.fieldsSchema, | ||
record: collection.apiSchema, | ||
}, | ||
@@ -38,0 +54,0 @@ }), |
@@ -5,5 +5,6 @@ import { ConnectorDataCollectionMethodType } from './base' | ||
export const DataCollectionMethodSearch: ConnectorDataCollectionMethodType = { | ||
getInputSchema: () => ({ | ||
getInputSchema: ({ collection }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
query: { type: 'string' }, | ||
@@ -16,3 +17,3 @@ cursor: { type: 'string' }, | ||
properties: { | ||
records: { type: 'array', items: collection.fieldsSchema }, | ||
records: { type: 'array', items: collection.apiSchema }, | ||
cursor: { type: 'string' }, | ||
@@ -19,0 +20,0 @@ }, |
@@ -8,2 +8,3 @@ import { Type, Static } from '@sinclair/typebox' | ||
import { DataLocationMethodImplementationTypes } from '../../methods' | ||
import { locatorToField } from '../../../../data-builder' | ||
@@ -23,12 +24,30 @@ const DataCollectionUpdateConfigSchema = Type.Partial( | ||
{ | ||
configSchema: DataCollectionUpdateConfigSchema, | ||
getConfigSchema: ({ collection }) => { | ||
const fields = Object.keys(collection.fieldsSchema?.properties ?? {}).map( | ||
locatorToField, | ||
) | ||
return { | ||
type: 'object', | ||
properties: { | ||
fields: { | ||
type: 'array', | ||
items: { type: 'string', enum: fields }, | ||
}, | ||
excludedFields: { | ||
type: 'array', | ||
items: { type: 'string', enum: fields }, | ||
}, | ||
}, | ||
} | ||
}, | ||
getInputSchema: ({ collection, method }) => { | ||
let fieldsSchema = collection.fieldsSchema | ||
if (method.config?.fields) { | ||
fieldsSchema = pickFieldsFromSchema(fieldsSchema, method.config.fields) | ||
if (method?.fields) { | ||
fieldsSchema = pickFieldsFromSchema(fieldsSchema, method.fields) | ||
} | ||
if (method.config?.excludedFields) { | ||
if (method?.excludedFields) { | ||
fieldsSchema = excludeFieldsFromSchema( | ||
fieldsSchema, | ||
method.config.excludedFields, | ||
method.excludedFields, | ||
) | ||
@@ -39,2 +58,3 @@ } | ||
properties: { | ||
parameters: collection.parametersSchema, | ||
id: { type: 'string' }, | ||
@@ -41,0 +61,0 @@ fields: fieldsSchema, |
@@ -0,1 +1,2 @@ | ||
import { ConnectorDataLocationBase } from '../base' | ||
import { ConnectorDataLocationMethod } from '../methods' | ||
@@ -10,9 +11,9 @@ import { DataDirectoryMethodList } from './methods/list' | ||
export interface ConnectorDataDirectory { | ||
export interface ConnectorDataDirectory extends ConnectorDataLocationBase { | ||
type: 'directory' | ||
key: string | ||
name: string | ||
methods: Record< | ||
keyof typeof DataLocationTypeDirectory.methods, | ||
ConnectorDataLocationMethod | ||
methods: Partial< | ||
Record< | ||
keyof typeof DataLocationTypeDirectory.methods, | ||
ConnectorDataLocationMethod | ||
> | ||
> | ||
@@ -19,0 +20,0 @@ } |
@@ -7,3 +7,7 @@ import { ConnectorDataDirectory } from '..' | ||
export interface ConnectorDataDirectoryMethodType<ConfigType = unknown> { | ||
configSchema?: DataSchema | ||
// If not specified, the key will be generated from the method key | ||
filePath?: string | ||
getConfigSchema?: ( | ||
args: ConnectorDataDirectoryMethodTypeArgs<ConfigType>, | ||
) => DataSchema | ||
getInputSchema?: ( | ||
@@ -10,0 +14,0 @@ args: ConnectorDataDirectoryMethodTypeArgs<ConfigType>, |
@@ -7,6 +7,6 @@ import { ConnectorDataDirectoryMethodType } from './base' | ||
export const DataDirectoryMethodList: ConnectorDataDirectoryMethodType<null> = { | ||
configSchema: null, | ||
getInputSchema: () => ({ | ||
getInputSchema: ({ directory }) => ({ | ||
type: 'object', | ||
properties: { | ||
parameters: directory.parametersSchema, | ||
cursor: { type: 'string' }, | ||
@@ -13,0 +13,0 @@ }, |
@@ -11,2 +11,3 @@ import { toKebabCase } from 'js-convert-case' | ||
export * from './base' | ||
export * from './collections' | ||
@@ -13,0 +14,0 @@ export * from './directories' |
@@ -8,3 +8,3 @@ import { | ||
export type ConnectorDataLocationMethod< | ||
ConfigType = never, | ||
ConfigFields = unknown, | ||
ImplementationFields extends | ||
@@ -14,6 +14,6 @@ | ConnectorMethodImplementation | ||
> = { | ||
inheritedFromLocationKey?: string | ||
config?: ConfigType | ||
inheritedFromKey?: string | ||
isIncomplete?: boolean | ||
} & ImplementationFields | ||
} & ImplementationFields & | ||
ConfigFields | ||
@@ -20,0 +20,0 @@ export const DataLocationMethodImplementationTypes = [ |
@@ -145,2 +145,4 @@ import { | ||
[value in DataCollectionEventType]: DataCollectionEventTypeSpec | ||
} & { | ||
all: DataCollectionEventTypeSpec | ||
} | ||
@@ -147,0 +149,0 @@ |
@@ -35,9 +35,5 @@ import { DataSchema } from '../data-schema' | ||
}, | ||
...(fieldsSchema | ||
? { | ||
fields: fieldsSchema, | ||
} | ||
: {}), | ||
fields: fieldsSchema ?? { type: 'object' }, | ||
}, | ||
} | ||
} |
import { DataSchema } from '../data-schema' | ||
import { ConnectionMode } from '../integrations' | ||
import { UDM } from '../udm' | ||
import { ConnectorAuth } from './auth' | ||
import { DataLocation, DataLocationSpec } from './data-locations' | ||
import { ConnectorMethodImplementation } from './methods' | ||
import { ConnectorOperation } from './operations' | ||
export * from './auth' | ||
export * from './operations' | ||
export * from './data-locations' | ||
export * from './data-records' | ||
export * from './operations' | ||
@@ -14,2 +18,5 @@ export * from './rest-api' | ||
export const CONNECTOR_TYPES = ['package'] as const | ||
export type ConnectorType = typeof CONNECTOR_TYPES[number] | ||
export enum ConnectorStatus { | ||
@@ -24,4 +31,4 @@ production = 'production', | ||
credentialsSchema?: DataSchema | ||
authorizeUri: string | ||
tokenUri: string | ||
authorizeUri?: string | ||
tokenUri?: string | ||
test?: boolean | ||
@@ -31,5 +38,8 @@ } | ||
export interface ConnectorUiSpec { | ||
schema?: DataSchema | ||
description?: string | ||
schema?: any | ||
helpUri?: string | ||
/** | ||
* @deprecated | ||
*/ | ||
test?: boolean | ||
@@ -66,6 +76,6 @@ } | ||
auth: ConnectorAuthSpec | ||
ui?: ConnectorUiSpec | ||
auth?: ConnectorAuthSpec | ConnectorAuth | ||
parametersSchema?: DataSchema | ||
@@ -77,2 +87,4 @@ | ||
test?: ConnectorMethodImplementation | ||
/** | ||
@@ -79,0 +91,0 @@ * @deprecated - use auth.mode instead |
@@ -22,5 +22,7 @@ import { MappingBase } from './mappings' | ||
implementationType?: ConnectorMethodImplementationType | ||
filePath?: string | ||
} | ||
export interface ConnectorMethodImplementationMapping { | ||
export interface ConnectorMethodImplementationMapping | ||
extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.mapping | ||
@@ -30,3 +32,4 @@ mapping: MappingBase | ||
export interface ConnectorMethodImplementationOperationMapping { | ||
export interface ConnectorMethodImplementationOperationMapping | ||
extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.operationMapping | ||
@@ -36,3 +39,4 @@ mapping: OperationMapping | ||
export interface ConnectorMethodImplementationRestApiMapping { | ||
export interface ConnectorMethodImplementationRestApiMapping | ||
extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.restApiMapping | ||
@@ -42,3 +46,4 @@ mapping: RestApiMapping | ||
export interface ConnectorMethodImplementationJavascript { | ||
export interface ConnectorMethodImplementationJavascript | ||
extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.javascript | ||
@@ -48,4 +53,5 @@ code: string | ||
export interface ConnectorMethodImplementationNotSupported { | ||
export interface ConnectorMethodImplementationNotSupported | ||
extends ConnectorMethodImplementationBase { | ||
implementationType: ConnectorMethodImplementationType.notSupported | ||
} |
@@ -11,5 +11,5 @@ import { DataSchema } from '../data-schema' | ||
*/ | ||
export interface OperationMapping<OperationArgs = any> { | ||
export interface OperationMapping { | ||
operationKey: string | ||
inputMapping?: OperationArgs | ||
inputMapping?: any | ||
outputMapping?: any | ||
@@ -37,4 +37,4 @@ } | ||
tags?: string[] | ||
argsSchema?: DataSchema | ||
resultSchema?: DataSchema | ||
inputSchema?: DataSchema | ||
outputSchema?: DataSchema | ||
methods?: Record<'run', ConnectorOperationMethod> | ||
@@ -47,4 +47,4 @@ } | ||
tags?: string[] | ||
argsSchema?: DataSchema | ||
resultSchema?: DataSchema | ||
inputSchema?: DataSchema | ||
outputSchema?: DataSchema | ||
} | ||
@@ -51,0 +51,0 @@ |
import { HttpRequestMethod } from '../http-requests' | ||
export interface RestApiInput { | ||
export interface RestApiClientInput { | ||
path: string | ||
@@ -11,3 +11,3 @@ method: HttpRequestMethod | ||
export interface RestApiOutput { | ||
export interface RestApiClientOutput { | ||
statusCode: number | ||
@@ -19,11 +19,8 @@ headers?: Record<string, string> | ||
/** | ||
* Mapping of any data to a Rest API request. | ||
* | ||
* It uses 'any' for all fields because they can be formulas and not simple values. | ||
* Mapping of any input to a Rest API request. | ||
*/ | ||
export interface RestApiMapping { | ||
inputMapping: { | ||
path: any | ||
method: any | ||
// Path can have placeholders (like {id}) and pathParameters will be used to replace them. | ||
path: string | ||
method: string | ||
requestMapping: { | ||
pathParameters?: any | ||
@@ -34,3 +31,3 @@ query?: any | ||
} | ||
outputMapping?: any | ||
responseMapping?: any | ||
} |
@@ -46,4 +46,2 @@ export interface DataRecord { | ||
export enum DataCollectionEventType { | ||
/** @deprecated */ | ||
ALL = 'all', | ||
CREATED = 'created', | ||
@@ -50,0 +48,0 @@ UPDATED = 'updated', |
@@ -142,2 +142,21 @@ import { | ||
/** | ||
* Returns properties for object schema, skipping ones that are not defined | ||
* @param properties | ||
*/ | ||
export function nonEmptyObjectProperties( | ||
properties: Record<string, DataSchema | undefined | null>, | ||
): Record<string, DataSchema> { | ||
if (!properties) { | ||
return {} | ||
} | ||
const result: Record<string, DataSchema> = {} | ||
for (const [key, value] of Object.entries(properties)) { | ||
if (value) { | ||
result[key] = value | ||
} | ||
} | ||
return result | ||
} | ||
export function getSchemaFromValue( | ||
@@ -144,0 +163,0 @@ value: any, |
@@ -1,3 +0,11 @@ | ||
import { DataSourceInstance, DataSourceEvent, DataSource } from '.' | ||
import { | ||
DataSourceInstance, | ||
DataSourceEvent, | ||
DataSource, | ||
DataSourceTemplate, | ||
FindDataSourceTemplatesQuery, | ||
CreateDataSourceTemplateRequest, | ||
UpdateDataSourceTemplateRequest, | ||
} from '.' | ||
import { | ||
FindDataSourceInstancesQuery, | ||
@@ -52,2 +60,12 @@ UpdateDataSourceInstanceRequest, | ||
export class DataSourceTemplatesAccessor extends ElementListAccessor< | ||
DataSourceTemplate, | ||
FindDataSourceTemplatesQuery, | ||
CreateDataSourceTemplateRequest | ||
> { | ||
constructor(client: IntegrationAppApiClient) { | ||
super(client, 'data-source-templates') | ||
} | ||
} | ||
export class DataSourceAccessor extends ElementAccessor< | ||
@@ -67,2 +85,23 @@ DataSource, | ||
export class DataSourceTemplateAccessor extends ElementAccessor< | ||
DataSourceTemplate, | ||
CreateDataSourceTemplateRequest, | ||
UpdateDataSourceTemplateRequest | ||
> { | ||
constructor(client: IntegrationAppApiClient, idOrKey: string) { | ||
super({ | ||
client, | ||
path: 'data-source-templates', | ||
idOrKey, | ||
}) | ||
} | ||
async apply(integrationKeys: string[]) { | ||
const { path, idOrKey } = this.options | ||
return this.options.client.post(`/${path}/${idOrKey}/apply`, { | ||
integrationKeys, | ||
}) | ||
} | ||
} | ||
export class DataSourceInstancesAccessor extends ElementInstanceListAccessor< | ||
@@ -69,0 +108,0 @@ DataSourceInstance, |
import { PaginationQuery, PaginationResponse } from '../entity-repository' | ||
import { DataSource, DataSourceEvent, DataSourceInstance } from '.' | ||
import { | ||
DataSource, | ||
DataSourceEvent, | ||
DataSourceInstance, | ||
DataSourceTemplate, | ||
} from '.' | ||
import { ConnectionSelector } from '../connections/api' | ||
import { ElementInstanceSelector } from '../accessors' | ||
import { FlowInstanceSelector } from '../flows/api' | ||
import { UDM } from '../udm' | ||
@@ -12,12 +16,12 @@ export interface FindDataSourcesQuery extends PaginationQuery {} | ||
export interface CreateDataSourceRequest { | ||
key: string | ||
export type CreateDataSourceRequest = Omit< | ||
DataSource, | ||
| 'id' | ||
| 'dataSourceTemplateId' | ||
| 'archivedAt' | ||
| 'versionKey' | ||
| 'revision' | ||
| 'publishedRevision' | ||
> | ||
name: string | ||
udm?: UDM | ||
pullIntervalSeconds?: number | ||
} | ||
export type UpdateDataSourceRequest = Partial<CreateDataSourceRequest> | ||
@@ -86,1 +90,11 @@ | ||
extends PaginationResponse<DataSourceEvent> {} | ||
export type CreateDataSourceTemplateRequest = Omit< | ||
DataSourceTemplate, | ||
'id' | 'archivedAt' | 'versionKey' | 'revision' | 'publishedRevision' | ||
> | ||
export type UpdateDataSourceTemplateRequest = | ||
Partial<CreateDataSourceTemplateRequest> | ||
export interface FindDataSourceTemplatesQuery extends PaginationQuery {} |
@@ -10,1 +10,6 @@ export class PaginationQuery { | ||
} | ||
export type OmitCommonNotEditableFields<T> = Omit< | ||
T, | ||
'id' | 'archivedAt' | 'versionKey' | 'revision' | 'publishedRevision' | ||
> |
@@ -1,3 +0,10 @@ | ||
import { FieldMapping, IFieldMappingInstance } from '.' | ||
import { | ||
CreateFieldMappingTemplateRequest, | ||
FieldMapping, | ||
FieldMappingTemplate, | ||
FindFieldMappingTemplatesQuery, | ||
IFieldMappingInstance, | ||
UpdateFieldMappingTemplateRequest, | ||
} from '.' | ||
import { | ||
FindFieldMappingInstancesQuery, | ||
@@ -38,2 +45,12 @@ FindFieldMappingsQuery, | ||
export class FieldMappingTemplatesAccessor extends ElementListAccessor< | ||
FieldMappingTemplate, | ||
FindFieldMappingTemplatesQuery, | ||
CreateFieldMappingTemplateRequest | ||
> { | ||
constructor(client: IntegrationAppApiClient) { | ||
super(client, 'field-mapping-templates') | ||
} | ||
} | ||
export class FieldMappingAccessor extends ElementAccessor< | ||
@@ -51,4 +68,35 @@ FieldMapping, | ||
} | ||
async getAppSchema() { | ||
const { path, idOrKey } = this.options | ||
return this.options.client.get(`/${path}/${idOrKey}/app-schema`) | ||
} | ||
} | ||
export class FieldMappingTemplateAccessor extends ElementAccessor< | ||
FieldMappingTemplate, | ||
CreateFieldMappingTemplateRequest, | ||
UpdateFieldMappingTemplateRequest | ||
> { | ||
constructor(client: IntegrationAppApiClient, idOrKey: string) { | ||
super({ | ||
client, | ||
path: 'field-mapping-templates', | ||
idOrKey, | ||
}) | ||
} | ||
async getAppSchema() { | ||
const { path, idOrKey } = this.options | ||
return this.options.client.get(`/${path}/${idOrKey}/app-schema`) | ||
} | ||
async apply(integrationKeys: string[]) { | ||
const { path, idOrKey } = this.options | ||
return this.options.client.post(`/${path}/${idOrKey}/apply`, { | ||
integrationKeys, | ||
}) | ||
} | ||
} | ||
export class FieldMappingInstancesAccessor extends ElementInstanceListAccessor< | ||
@@ -55,0 +103,0 @@ IFieldMappingInstance, |
@@ -1,3 +0,7 @@ | ||
import { PaginationQuery, PaginationResponse } from '../entity-repository' | ||
import { FieldMapping, IFieldMappingInstance } from '.' | ||
import { | ||
OmitCommonNotEditableFields, | ||
PaginationQuery, | ||
PaginationResponse, | ||
} from '../entity-repository' | ||
import { FieldMapping, FieldMappingTemplate, IFieldMappingInstance } from '.' | ||
import { ConnectionSelector } from '../connections/api' | ||
@@ -24,3 +28,4 @@ import { ElementInstanceSelector } from '../accessors' | ||
export type CreateFieldMappingRequest = Omit<FieldMapping, 'id'> | ||
export type CreateFieldMappingRequest = | ||
OmitCommonNotEditableFields<FieldMapping> | ||
@@ -62,1 +67,9 @@ export type UpdateFieldMappingRequest = Partial<CreateFieldMappingRequest> | ||
} | ||
export type CreateFieldMappingTemplateRequest = | ||
OmitCommonNotEditableFields<FieldMappingTemplate> | ||
export type UpdateFieldMappingTemplateRequest = | ||
Partial<CreateFieldMappingTemplateRequest> | ||
export interface FindFieldMappingTemplatesQuery extends PaginationQuery {} |
@@ -44,5 +44,29 @@ import { User } from '../users' | ||
archivedAt?: Date | ||
archivedAt?: string | ||
} | ||
export interface FieldMappingTemplate { | ||
id: string | ||
name: string | ||
key: string | ||
archivedAt?: string | ||
dataSourceTemplateId?: string | ||
appSchema?: DataSchema | ||
direction?: FieldMappingDirection | ||
defaultImportValue?: any | ||
defaultExportValue?: any | ||
frozenImportFields?: any | ||
frozenUnifiedExportFields?: any | ||
} | ||
export interface IFieldMappingInstance extends EntityInstanceVersionFields { | ||
@@ -49,0 +73,0 @@ id: string |
@@ -75,3 +75,3 @@ import { FlowRun, FlowRunState } from '../flow-runs' | ||
async apply(integrationKeys: string[]): Promise<FlowInstance> { | ||
async apply(integrationKeys: string[]) { | ||
const { path, idOrKey } = this.options | ||
@@ -78,0 +78,0 @@ return this.options.client.post(`/${path}/${idOrKey}/apply`, { |
@@ -74,13 +74,24 @@ import { Connection } from '../connections' | ||
async createConnection({ parameters }): Promise<Connection> { | ||
const spec = await this.getConnectorSpec() | ||
const integration = await this.get() | ||
const connectionMode = | ||
integration.connectionMode ?? | ||
(integration.authType === 'client-credentials' | ||
? ConnectionMode.IFRAME | ||
: ConnectionMode.POPUP) | ||
let iframeElement | ||
if (spec.connectionMode === ConnectionMode.IFRAME) { | ||
if (connectionMode === ConnectionMode.IFRAME) { | ||
iframeElement = createIframeElement() | ||
} | ||
let popupPath = `oauth/new/${this.idOrKey}` | ||
if (integration.connectorType === 'package') { | ||
popupPath = 'connection-popup?integrationKey=' + integration.key | ||
} | ||
return new Promise((resolve, reject) => { | ||
const connectionUrl = urljoin( | ||
this.client.apiUri, | ||
`oauth/new/${this.idOrKey}`, | ||
popupPath, | ||
`?token=${this.client.token}&connectionParameters=${JSON.stringify( | ||
@@ -141,3 +152,4 @@ parameters, | ||
reject({ | ||
message: 'Popup has been blocked', | ||
message: | ||
'Popup has been blocked. Press Connect button to proceed.', | ||
}) | ||
@@ -144,0 +156,0 @@ } |
import { PaginationQuery, PaginationResponse } from '../entity-repository' | ||
import { Connection } from '../connections' | ||
import { CommonConfigurationOptions } from '../iframe' | ||
import { ConnectorSpec } from '../connectors' | ||
import { ConnectorAuthType, ConnectorSpec, ConnectorType } from '../connectors' | ||
@@ -40,2 +40,8 @@ export * from './api' | ||
connectorType?: ConnectorType | ||
authType?: ConnectorAuthType | ||
parameters?: any | ||
baseUri: string | ||
@@ -42,0 +48,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1852474
208
38140
54
Updatedpenpal@^6.2.2