From 54ecb3dc51478a26db1a13b2b848b6b2cb75636a Mon Sep 17 00:00:00 2001 From: Teal Larson Date: Wed, 29 Jun 2022 15:01:30 -0400 Subject: [PATCH] new airbyte client --- .../src/core/request/AirbyteClient.ts | 260 +++++++++--------- 1 file changed, 137 insertions(+), 123 deletions(-) diff --git a/airbyte-webapp/src/core/request/AirbyteClient.ts b/airbyte-webapp/src/core/request/AirbyteClient.ts index 6a29147b24ac..edc01276b56e 100644 --- a/airbyte-webapp/src/core/request/AirbyteClient.ts +++ b/airbyte-webapp/src/core/request/AirbyteClient.ts @@ -418,15 +418,22 @@ export interface FieldSchema { [key: string]: any; } +/** + * A field name is a list of strings that form the path to the field. + */ +export type FieldName = string[]; + export interface FieldSchemaUpdate { - fieldName: string[]; oldSchema: FieldSchema; newSchema: FieldSchema; } -export interface FieldNameAndSchema { - fieldName: string[]; - fieldSchema: FieldSchema; +export interface FieldRemove { + schema?: FieldSchema; +} + +export interface FieldAdd { + schema?: FieldSchema; } export type FieldTransformTransformType = typeof FieldTransformTransformType[keyof typeof FieldTransformTransformType]; @@ -443,8 +450,9 @@ export const FieldTransformTransformType = { */ export interface FieldTransform { transformType: FieldTransformTransformType; - addField?: FieldNameAndSchema; - removeField?: FieldNameAndSchema; + fieldName: FieldName; + addField?: FieldAdd; + removeField?: FieldRemove; updateFieldSchema?: FieldSchemaUpdate; } @@ -458,6 +466,13 @@ export const StreamTransformTransformType = { update_stream: "update_stream", } as const; +export interface StreamTransform { + transformType: StreamTransformTransformType; + streamDescriptor: StreamDescriptor; + /** list of field transformations. order does not matter. */ + updateStream?: FieldTransform[]; +} + /** * Describes the difference between two Airbyte catalogs. */ @@ -480,6 +495,16 @@ export interface StateBlob { [key: string]: any; } +export interface StreamState { + streamDescriptor: StreamDescriptor; + streamState?: StateBlob; +} + +export interface GlobalState { + shared_state?: StateBlob; + streamStates: StreamState[]; +} + /** * Contains the state for a connection. The stateType field identifies what type of state it is. Only the field corresponding to that type will be set, the rest will be null. If stateType=not_set, then none of the fields will be set. */ @@ -544,6 +569,10 @@ export interface JobInfoRead { attempts: AttemptInfoRead[]; } +export interface JobReadList { + jobs: JobWithAttemptsRead[]; +} + export type AttemptStatus = typeof AttemptStatus[keyof typeof AttemptStatus]; // eslint-disable-next-line @typescript-eslint/no-redeclare @@ -635,27 +664,31 @@ export const JobStatus = { cancelled: "cancelled", } as const; -export interface StreamDescriptor { - name: string; - namespace?: string; +export interface JobWithAttemptsRead { + job?: JobRead; + attempts?: AttemptRead[]; } -export interface StreamTransform { - transformType: StreamTransformTransformType; - addStream?: StreamDescriptor; - removeStream?: StreamDescriptor; - /** list of field transformations. order does not matter. */ - updateStream?: FieldTransform[]; +export interface JobDebugRead { + id: JobId; + configType: JobConfigType; + configId: string; + status: JobStatus; + airbyteVersion: string; + sourceDefinition: SourceDefinitionRead; + destinationDefinition: DestinationDefinitionRead; } -export interface StreamState { - streamDescriptor: StreamDescriptor; - streamState?: StateBlob; +export interface StreamDescriptor { + name: string; + namespace?: string; } -export interface GlobalState { - shared_state?: StateBlob; - streamStates: StreamState[]; +/** + * contains information about how a reset was configured. only populated if the job was a reset. + */ +export interface ResetConfig { + streamsToReset?: StreamDescriptor[]; } export interface JobIdRequestBody { @@ -674,16 +707,14 @@ export const JobConfigType = { reset_connection: "reset_connection", } as const; -export interface JobDebugRead { - id: JobId; - configType: JobConfigType; +export interface JobListRequestBody { + configTypes: JobConfigType[]; configId: string; - status: JobStatus; - airbyteVersion: string; - sourceDefinition: SourceDefinitionRead; - destinationDefinition: DestinationDefinitionRead; + pagination?: Pagination; } +export type JobId = number; + export interface JobRead { id: JobId; configType: JobConfigType; @@ -691,26 +722,9 @@ export interface JobRead { createdAt: number; updatedAt: number; status: JobStatus; - streams?: StreamDescriptor[]; + resetConfig?: ResetConfig; } -export interface JobWithAttemptsRead { - job?: JobRead; - attempts?: AttemptRead[]; -} - -export interface JobReadList { - jobs: JobWithAttemptsRead[]; -} - -export interface JobListRequestBody { - configTypes: JobConfigType[]; - configId: string; - pagination?: Pagination; -} - -export type JobId = number; - export type DataType = typeof DataType[keyof typeof DataType]; // eslint-disable-next-line @typescript-eslint/no-redeclare @@ -916,6 +930,10 @@ export const ConnectionStatus = { deprecated: "deprecated", } as const; +export interface ConnectionReadList { + connections: ConnectionRead[]; +} + export interface WebBackendConnectionCreate { /** Optional name of the connection */ name?: string; @@ -959,6 +977,38 @@ export interface DbMigrationRequestBody { export type ConnectionId = string; +export interface WebBackendConnectionSearch { + connectionId?: ConnectionId; + name?: string; + namespaceDefinition?: NamespaceDefinitionType; + /** Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. */ + namespaceFormat?: string; + /** Prefix that will be prepended to the name of each stream when it is written to the destination. */ + prefix?: string; + sourceId?: SourceId; + destinationId?: DestinationId; + schedule?: ConnectionSchedule; + status?: ConnectionStatus; + source?: SourceSearch; + destination?: DestinationSearch; +} + +export interface ConnectionSearch { + connectionId?: ConnectionId; + name?: string; + namespaceDefinition?: NamespaceDefinitionType; + /** Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. */ + namespaceFormat?: string; + /** Prefix that will be prepended to the name of each stream when it is written to the destination. */ + prefix?: string; + sourceId?: SourceId; + destinationId?: DestinationId; + schedule?: ConnectionSchedule; + status?: ConnectionStatus; + source?: SourceSearch; + destination?: DestinationSearch; +} + export interface ConnectionRead { connectionId: ConnectionId; name: string; @@ -977,10 +1027,6 @@ export interface ConnectionRead { sourceCatalogId?: string; } -export interface ConnectionReadList { - connections: ConnectionRead[]; -} - export interface WebBackendConnectionUpdate { /** Name that will be set to the connection */ name?: string; @@ -1045,6 +1091,15 @@ export interface DestinationReadList { */ export type DestinationConfiguration = unknown; +export interface DestinationSearch { + destinationDefinitionId?: DestinationDefinitionId; + destinationId?: DestinationId; + workspaceId?: WorkspaceId; + connectionConfiguration?: DestinationConfiguration; + name?: string; + destinationName?: string; +} + export interface DestinationUpdate { destinationId: DestinationId; connectionConfiguration: DestinationConfiguration; @@ -1065,47 +1120,6 @@ export interface DestinationCoreConfig { export type DestinationId = string; -export interface DestinationSearch { - destinationDefinitionId?: DestinationDefinitionId; - destinationId?: DestinationId; - workspaceId?: WorkspaceId; - connectionConfiguration?: DestinationConfiguration; - name?: string; - destinationName?: string; -} - -export interface WebBackendConnectionSearch { - connectionId?: ConnectionId; - name?: string; - namespaceDefinition?: NamespaceDefinitionType; - /** Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. */ - namespaceFormat?: string; - /** Prefix that will be prepended to the name of each stream when it is written to the destination. */ - prefix?: string; - sourceId?: SourceId; - destinationId?: DestinationId; - schedule?: ConnectionSchedule; - status?: ConnectionStatus; - source?: SourceSearch; - destination?: DestinationSearch; -} - -export interface ConnectionSearch { - connectionId?: ConnectionId; - name?: string; - namespaceDefinition?: NamespaceDefinitionType; - /** Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. */ - namespaceFormat?: string; - /** Prefix that will be prepended to the name of each stream when it is written to the destination. */ - prefix?: string; - sourceId?: SourceId; - destinationId?: DestinationId; - schedule?: ConnectionSchedule; - status?: ConnectionStatus; - source?: SourceSearch; - destination?: DestinationSearch; -} - export interface DestinationRead { destinationDefinitionId: DestinationDefinitionId; destinationId: DestinationId; @@ -1136,15 +1150,16 @@ export interface DestinationDefinitionSpecificationRead { supportsNormalization?: boolean; } -export interface PrivateDestinationDefinitionReadList { - destinationDefinitions: PrivateDestinationDefinitionRead[]; -} - export interface DestinationDefinitionIdWithWorkspaceId { destinationDefinitionId: DestinationDefinitionId; workspaceId: WorkspaceId; } +export interface CustomDestinationDefinitionUpdate { + workspaceId: WorkspaceId; + destinationDefinition: DestinationDefinitionUpdate; +} + export interface CustomDestinationDefinitionCreate { workspaceId: WorkspaceId; destinationDefinition: DestinationDefinitionCreate; @@ -1168,6 +1183,10 @@ export interface PrivateDestinationDefinitionRead { granted: boolean; } +export interface PrivateDestinationDefinitionReadList { + destinationDefinitions: PrivateDestinationDefinitionRead[]; +} + export interface DestinationDefinitionReadList { destinationDefinitions: DestinationDefinitionRead[]; } @@ -1178,11 +1197,6 @@ export interface DestinationDefinitionUpdate { resourceRequirements?: ActorDefinitionResourceRequirements; } -export interface CustomDestinationDefinitionUpdate { - workspaceId: WorkspaceId; - destinationDefinition: DestinationDefinitionUpdate; -} - export interface DestinationDefinitionCreate { name: string; dockerRepository: string; @@ -1192,14 +1206,14 @@ export interface DestinationDefinitionCreate { resourceRequirements?: ActorDefinitionResourceRequirements; } -export interface DestinationDefinitionIdRequestBody { - destinationDefinitionId: DestinationDefinitionId; -} - export type DestinationAuthSpecification = AuthSpecification; export type DestinationDefinitionId = string; +export interface DestinationDefinitionIdRequestBody { + destinationDefinitionId: DestinationDefinitionId; +} + export interface SourceSearch { sourceDefinitionId?: SourceDefinitionId; sourceId?: SourceId; @@ -2549,24 +2563,6 @@ export const getState = ( ); }; -/** - * @summary Fetch the current type for a connection. - */ -export const getStateType = ( - connectionIdRequestBody: ConnectionIdRequestBody, - options?: SecondParameter -) => { - return apiOverride( - { - url: `/v1/state/type/get`, - method: "post", - headers: { "Content-Type": "application/json" }, - data: connectionIdRequestBody, - }, - options - ); -}; - /** * @summary Search connections */ @@ -3050,6 +3046,24 @@ export const webBackendSearchConnections = ( ); }; +/** + * @summary Fetch the current state type for a connection. + */ +export const getStateType = ( + connectionIdRequestBody: ConnectionIdRequestBody, + options?: SecondParameter +) => { + return apiOverride( + { + url: `/v1/web_backend/state/get_type`, + method: "post", + headers: { "Content-Type": "application/json" }, + data: connectionIdRequestBody, + }, + options + ); +}; + /** * @summary Returns the current state of a workspace */ @@ -3324,7 +3338,6 @@ export type ListAllConnectionsForWorkspaceResult = NonNullable< >; export type GetConnectionResult = NonNullable>>; export type GetStateResult = NonNullable>>; -export type GetStateTypeResult = NonNullable>>; export type SearchConnectionsResult = NonNullable>>; export type DeleteConnectionResult = NonNullable>>; export type SyncConnectionResult = NonNullable>>; @@ -3362,6 +3375,7 @@ export type WebBackendGetConnectionResult = NonNullable>>; export type WebBackendUpdateConnectionResult = NonNullable>>; export type WebBackendSearchConnectionsResult = NonNullable>>; +export type GetStateTypeResult = NonNullable>>; export type WebBackendGetWorkspaceStateResult = NonNullable>>; export type ListJobsForResult = NonNullable>>; export type GetJobInfoResult = NonNullable>>;