diff --git a/src/components/helpers/SourceDBSelector.vue b/src/components/helpers/SourceDBSelector.vue index 940ce3c659189aca54fe9cff66d3c4e762f0712f..917ed434f208b85f3d32904afda1a7cf2d1523e5 100644 --- a/src/components/helpers/SourceDBSelector.vue +++ b/src/components/helpers/SourceDBSelector.vue @@ -2,7 +2,7 @@ import {computed} from "vue"; import {useConstantsStore} from "@/services/constantsStore"; -import {SourceDBType} from "@/services/api"; +import {SourceDBType} from "@/services/api-v2"; const constants = useConstantsStore() diff --git a/src/components/helpers/TableLabel.vue b/src/components/helpers/TableLabel.vue index a7afd4c67c7155328072b290ad855843a05cd72a..37141f8a57f77e0dba41058797a18fd86e574e6d 100644 --- a/src/components/helpers/TableLabel.vue +++ b/src/components/helpers/TableLabel.vue @@ -1,6 +1,6 @@ <script setup lang="ts"> -import {TableIdentifier} from "@/services/api"; +import {TableIdentifier} from "@/services/api-v2"; const {selectedTable} = defineProps<{ 'selectedTable': TableIdentifier }>() diff --git a/src/components/helpers/TableSelector.vue b/src/components/helpers/TableSelector.vue index 3ddfcb535d4e9b07feba11d1bcd45c19ff1b4ceb..d0c40a7ed01a7ac3625f69b7a8bdce6faf2b58b5 100644 --- a/src/components/helpers/TableSelector.vue +++ b/src/components/helpers/TableSelector.vue @@ -1,6 +1,6 @@ <script setup lang="ts"> -import {SourceDBType, TableIdentifier} from "@/services/api"; +import {SourceDBType, TableIdentifier} from "@/services/api-v2"; import {ref, watchEffect} from "vue"; import {useAllTables, useTablesInDB} from "@/services/convenienceStore"; diff --git a/src/components/subcomponents/map/AttributeSelector.vue b/src/components/subcomponents/map/AttributeSelector.vue index 4d10e5519aae41f3df2fb23a02e0d77e25fad752..53716ad991ac8272719b00c9859ce366c76cf1bf 100644 --- a/src/components/subcomponents/map/AttributeSelector.vue +++ b/src/components/subcomponents/map/AttributeSelector.vue @@ -1,6 +1,6 @@ <script setup lang="ts"> import {ExtendedColumnListItem, useMitMTypes} from "@/services/convenienceStore"; -import {MitMDataType} from "@/services/api"; +import {MITMDataType} from "@/services/api-v2"; import {TypedColumnSelection} from "@/services/mappingUtils"; const props = withDefaults(defineProps<{ diff --git a/src/components/subcomponents/map/InlineColumnMapper.vue b/src/components/subcomponents/map/InlineColumnMapper.vue index 785c4839cb68afd2f4f63c19f9b7faeea6ef429a..9984583dc75eaef7a0655e51f3ef0b8073aec4f7 100644 --- a/src/components/subcomponents/map/InlineColumnMapper.vue +++ b/src/components/subcomponents/map/InlineColumnMapper.vue @@ -1,12 +1,12 @@ <script setup lang="ts"> import {ExtendedColumnListItem} from "@/services/convenienceStore"; -import {MitMDefinition} from "@/services/api"; +import {MITMDefinition} from "@/services/api-v2"; import {getRequiredType, WithinTableMappings} from "@/services/mappingUtils"; import {ref, watch, watchEffect} from "vue"; const props = defineProps<{ - mitmDef: MitMDefinition + mitmDef: MITMDefinition toMap: { [name: string]: string }, diff --git a/src/components/subcomponents/map/RelationsColumnMapper.vue b/src/components/subcomponents/map/RelationsColumnMapper.vue index 530ef544fbad78a67ed3971fc01f605a1f60375b..b99827db4ba46952bca1eb0741c4bfccc45f0450 100644 --- a/src/components/subcomponents/map/RelationsColumnMapper.vue +++ b/src/components/subcomponents/map/RelationsColumnMapper.vue @@ -1,7 +1,7 @@ <script setup lang="ts"> import {ExtendedColumnListItem} from "@/services/convenienceStore"; -import {Mappings, MitMDefinition, TableIdentifier, TableMetaInfoResponse} from "@/services/api"; +import {MITMDataType, MITMDefinition, OwnedRelations, TableIdentifier, TableMetaInfoResponse} from "@/services/api-v2"; import {reactive, ref, Ref, unref, watchEffect} from "vue"; import {useMappingStore} from "@/services/mappingStore"; import {storeToRefs} from "pinia"; @@ -15,8 +15,8 @@ const store = useMainStore() const {currentMappings} = storeToRefs(useMappingStore()) const props = defineProps<{ - mitmDef: MitMDefinition, - toMap: Mappings.ForeignRelationDefs, + mitmDef: MITMDefinition, + toMap: OwnedRelations["foreign"], columnList: ExtendedColumnListItem[], baseTable: TableIdentifier, title: string, @@ -33,8 +33,8 @@ const fkRelationTargets = ref<{ targetConcept: string, fkLength: number, namesToMap: string[], - targetConcepts: string[], - targetTypes: string[] + targetConcepts: { [name: string]: string }, + targetTypes: { [name: string]: MITMDataType } } }>({}) @@ -70,24 +70,24 @@ watchEffect(() => { if (!toSkip || !frs || !fkRelTargets) isValid.value = false else { isValid.value = Object.entries(fkRelTargets).every(([fkRelName, fkRelTarget]) => - fkRelName in frs - && Object.entries(frs[fkRelName].fk_columns) - .every(([nameToMap, selectedCol]) => !!selectedCol && (fkRelTarget.targetTypes[nameToMap] === selectedCol.inferredType || (fkRelName in toSkip && toSkip[fkRelName].some(n => n === nameToMap))))) - && Object.values(fkValidity.requiredMappingExistence).every(v => v) + fkRelName in frs + && Object.entries(frs[fkRelName].fk_columns) + .every(([nameToMap, selectedCol]) => !!selectedCol && (fkRelTarget.targetTypes[nameToMap] === selectedCol.inferredType || (fkRelName in toSkip && toSkip[fkRelName].some(n => n === nameToMap))))) + && Object.values(fkValidity.requiredMappingExistence).every(v => v) } }, {flush: "post"}) -watchEffect(() => { +watchEffect(async () => { // check for existence of required concept mapping of selected table, and check for regular FK relation const frs = foreignRelations.value const selectedTables = !!frs ? Object.fromEntries(Object.entries(frs).map(([fkRelName, fkMapping]) => [fkRelName, unref(fkMapping.referred_table)])) : {} const fkRelTargets = fkRelationTargets.value const baseTable = unref(props.baseTable) - const tm: TableMetaInfoResponse = store.getTableMeta(baseTable) + const tm: TableMetaInfoResponse = await store.getTableMeta(baseTable) if (!!frs && !!baseTable && !!tm && !!fkRelTargets) { const toConsider = Object.entries(fkRelTargets).map(([fkRelName]) => [fkRelName, selectedTables[fkRelName]]) - fkValidity.fkExistence = Object.fromEntries(toConsider.map(([fkRelName, selectedTable]) => + fkValidity.fkExistence = Object.fromEntries(toConsider.map(([fkRelName, selectedTable]) => // type inference can't do mixed (but structured) arrays, I guess [fkRelName, !!selectedTable && baseTable.source === selectedTable.source diff --git a/src/components/subcomponents/transform/SimpleWhere.vue b/src/components/subcomponents/transform/SimpleWhere.vue index 4c1c42f2858114b60df2c2be1bda179782374177..71416daaf7c45e0573ab891daa8a9d7a6ec9b163 100644 --- a/src/components/subcomponents/transform/SimpleWhere.vue +++ b/src/components/subcomponents/transform/SimpleWhere.vue @@ -3,7 +3,7 @@ import {rules} from "@/services/utils"; import {reactive, watchEffect} from "vue"; import {useColumnsOfTableWithProbe, useMitMTypes} from "@/services/convenienceStore"; -import {TableIdentifier, Transforms} from "@/services/api"; +import {SimpleSQLOperator, SimpleWhere, TableIdentifier} from "@/services/api-v2"; import {useMainStore} from "@/services/mainStore"; import {useConstantsStore} from "@/services/constantsStore"; @@ -32,15 +32,15 @@ const {mitmTypes} = useMitMTypes() const {columnList} = useColumnsOfTableWithProbe(() => props.table) -const sqlOps: { title: string, value: Transforms.SimpleSQLOperator }[] = [{ +const sqlOps: { title: string, value: SimpleSQLOperator }[] = [{ title: "like", value: "like" }, {title: "ilike", value: "ilike"}, {title: "=", value: "eq"}, {title: "<", value: "lt"}, { title: "<=", value: "le" -}, {title: ">=", value: "ge"}, {title: ">", value: "gt"}, {title: "in", value: "in"}, {title: "notin", value: ""}] +}, {title: ">=", value: "ge"}, {title: ">", value: "gt"}, {title: "in", value: "in"}, {title: "notin", value: "notin"}] -function createWheres(): Transforms.SimpleWhere[] { +function createWheres(): SimpleWhere[] { let rhs_value = form.rhs.value; if (!!rhs_value && rhs_value.startsWith('(') && rhs_value.endsWith(')')) { @@ -48,7 +48,7 @@ function createWheres(): Transforms.SimpleWhere[] { } let rhsRequest = form.useLiteralRhs ? [rhs_value, form.rhs.type.wrapped] : form.rhs.col - return [{lhs: form.lhs, rhs: rhsRequest, operator: form.op}] as Transforms.SimpleWhere[] + return [{lhs: form.lhs, rhs: rhsRequest, operator: form.op}] as SimpleWhere[] } defineExpose({ diff --git a/src/services/api-schema/schemas.gen.ts b/src/services/api-schema/schemas.gen.ts new file mode 100644 index 0000000000000000000000000000000000000000..88ee2862f12fbba199c5006903a88a455c054ec6 --- /dev/null +++ b/src/services/api-schema/schemas.gen.ts @@ -0,0 +1,2702 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export const AddColumnSchema = { + properties: { + operation: { + type: 'string', + enum: ['add_column'], + const: 'add_column', + title: 'Operation', + default: 'add_column' + }, + col_name: { + type: 'string', + title: 'Col Name' + }, + value: { + title: 'Value' + }, + target_type: { + anyOf: [ + { + '$ref': '#/components/schemas/WrappedMITMDataType' + }, + { + type: 'string' + } + ], + title: 'Target Type' + } + }, + type: 'object', + required: ['col_name', 'value', 'target_type'], + title: 'AddColumn' +} as const; + +export const Body_connect_db_session_connect_db_postSchema = { + properties: { + db_url: { + type: 'string', + minLength: 1, + format: 'uri', + title: 'Db Url' + } + }, + type: 'object', + required: ['db_url'], + title: 'Body_connect_db_session_connect_db_post' +} as const; + +export const Body_raw_query_data_raw_query_postSchema = { + properties: { + query: { + type: 'string', + title: 'Query' + } + }, + type: 'object', + required: ['query'], + title: 'Body_raw_query_data_raw_query_post' +} as const; + +export const Body_upload_db_session_upload_db_postSchema = { + properties: { + sqlite: { + type: 'string', + format: 'binary', + title: 'Sqlite', + description: 'Upload a sqlite db file here.' + } + }, + type: 'object', + required: ['sqlite'], + title: 'Body_upload_db_session_upload_db_post' +} as const; + +export const CastColumnSchema = { + properties: { + operation: { + type: 'string', + enum: ['cast_column'], + const: 'cast_column', + title: 'Operation', + default: 'cast_column' + }, + target_type: { + anyOf: [ + { + '$ref': '#/components/schemas/WrappedMITMDataType' + }, + { + type: 'string' + } + ], + title: 'Target Type' + } + }, + type: 'object', + required: ['target_type'], + title: 'CastColumn' +} as const; + +export const CategoricalSummaryStatisticsSchema = { + properties: { + count: { + type: 'integer', + minimum: 0, + title: 'Count' + }, + unique: { + type: 'integer', + minimum: 0, + title: 'Unique' + }, + top: { + type: 'string', + title: 'Top' + }, + freq: { + type: 'integer', + minimum: 0, + title: 'Freq' + } + }, + type: 'object', + required: ['count', 'unique', 'top', 'freq'], + title: 'CategoricalSummaryStatistics' +} as const; + +export const ColumnPropertiesSchema = { + properties: { + nullable: { + type: 'boolean', + title: 'Nullable' + }, + unique: { + type: 'boolean', + title: 'Unique' + }, + part_of_pk: { + type: 'boolean', + title: 'Part Of Pk' + }, + part_of_fk: { + type: 'boolean', + title: 'Part Of Fk' + }, + part_of_index: { + type: 'boolean', + title: 'Part Of Index' + }, + mitm_data_type: { + '$ref': '#/components/schemas/MITMDataType' + } + }, + type: 'object', + required: ['nullable', 'unique', 'part_of_pk', 'part_of_fk', 'part_of_index', 'mitm_data_type'], + title: 'ColumnProperties' +} as const; + +export const CompiledVirtualViewSchema = { + properties: { + dialect: { + type: 'string', + title: 'Dialect' + }, + compiled_sql: { + type: 'string', + title: 'Compiled Sql' + }, + columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Columns' + }, + column_dtypes: { + items: { + anyOf: [ + { + '$ref': '#/components/schemas/WrappedMITMDataType' + }, + { + type: 'string' + } + ] + }, + type: 'array', + title: 'Column Dtypes' + }, + name: { + type: 'string', + title: 'Name' + }, + schema_name: { + type: 'string', + title: 'Schema Name' + } + }, + type: 'object', + required: ['dialect', 'compiled_sql', 'columns', 'column_dtypes', 'name', 'schema_name'], + title: 'CompiledVirtualView' +} as const; + +export const ConceptKindSchema = { + type: 'string', + enum: ['concrete', 'abstract'], + title: 'ConceptKind' +} as const; + +export const ConceptLevelSchema = { + type: 'string', + enum: ['main', 'sub', 'weak'], + title: 'ConceptLevel' +} as const; + +export const ConceptMappingSchema = { + properties: { + mitm: { + '$ref': '#/components/schemas/MITM' + }, + concept: { + type: 'string', + title: 'Concept' + }, + base_table: { + anyOf: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + prefixItems: [ + { + '$ref': '#/components/schemas/SourceDBType' + }, + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 3, + minItems: 3 + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Base Table' + }, + kind_col: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Kind Col' + }, + type_col: { + type: 'string', + title: 'Type Col' + }, + identity_columns: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + items: { + type: 'string' + }, + type: 'array' + } + ], + title: 'Identity Columns' + }, + inline_relations: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + items: { + type: 'string' + }, + type: 'array' + } + ], + title: 'Inline Relations' + }, + foreign_relations: { + additionalProperties: { + '$ref': '#/components/schemas/ForeignRelation' + }, + type: 'object', + title: 'Foreign Relations' + }, + attributes: { + items: { + type: 'string' + }, + type: 'array', + title: 'Attributes' + }, + attribute_dtypes: { + items: { + '$ref': '#/components/schemas/MITMDataType' + }, + type: 'array', + title: 'Attribute Dtypes' + } + }, + type: 'object', + required: ['mitm', 'concept', 'base_table', 'type_col'], + title: 'ConceptMapping' +} as const; + +export const ConceptMappingRequestSchema = { + properties: { + mitm: { + '$ref': '#/components/schemas/MITM' + }, + concept: { + type: 'string', + title: 'Concept' + }, + base_table: { + anyOf: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + prefixItems: [ + { + '$ref': '#/components/schemas/SourceDBType' + }, + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 3, + minItems: 3 + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Base Table' + }, + kind_col: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Kind Col' + }, + type_col: { + type: 'string', + title: 'Type Col' + }, + identity_columns: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + items: { + type: 'string' + }, + type: 'array' + } + ], + title: 'Identity Columns' + }, + inline_relations: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + items: { + type: 'string' + }, + type: 'array' + } + ], + title: 'Inline Relations' + }, + foreign_relations: { + additionalProperties: { + '$ref': '#/components/schemas/ForeignRelation' + }, + type: 'object', + title: 'Foreign Relations' + }, + attributes: { + items: { + type: 'string' + }, + type: 'array', + title: 'Attributes' + }, + attribute_dtypes: { + items: { + '$ref': '#/components/schemas/MITMDataType' + }, + type: 'array', + title: 'Attribute Dtypes' + } + }, + type: 'object', + required: ['mitm', 'concept', 'base_table', 'type_col'], + title: 'ConceptMappingRequest' +} as const; + +export const ConceptPropertiesSchema = { + properties: { + nature: { + prefixItems: [ + { + '$ref': '#/components/schemas/ConceptLevel' + }, + { + '$ref': '#/components/schemas/ConceptKind' + } + ], + type: 'array', + maxItems: 2, + minItems: 2, + title: 'Nature' + }, + key: { + type: 'string', + title: 'Key' + }, + plural: { + type: 'string', + title: 'Plural' + }, + typing_concept: { + type: 'string', + title: 'Typing Concept', + default: 'type' + }, + column_group_ordering: { + items: { + type: 'string', + enum: ['kind', 'type', 'identity-relations', 'inline-relations', 'foreign-relations', 'attributes'] + }, + type: 'array', + title: 'Column Group Ordering', + default: ['kind', 'type', 'identity-relations', 'inline-relations', 'foreign-relations', 'attributes'] + }, + permit_attributes: { + type: 'boolean', + title: 'Permit Attributes', + default: true + } + }, + type: 'object', + required: ['nature', 'key', 'plural'], + title: 'ConceptProperties' +} as const; + +export const DBConnTestResponseSchema = { + properties: { + db_url: { + type: 'string', + minLength: 1, + format: 'uri', + title: 'Db Url' + }, + success: { + type: 'boolean', + title: 'Success' + }, + error: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Error' + } + }, + type: 'object', + required: ['db_url', 'success'], + title: 'DBConnTestResponse' +} as const; + +export const DBMetaInfoBaseSchema = { + properties: { + db_structure: { + additionalProperties: { + additionalProperties: { + '$ref': '#/components/schemas/TableMetaInfoBase' + }, + type: 'object' + }, + type: 'object', + title: 'Db Structure' + }, + tables: { + additionalProperties: { + '$ref': '#/components/schemas/TableMetaInfoBase' + }, + type: 'object', + title: 'Tables', + readOnly: true + } + }, + type: 'object', + required: ['db_structure', 'tables'], + title: 'DBMetaInfoBase' +} as const; + +export const DBMetaInfoResponseSchema = { + properties: { + db_structure: { + additionalProperties: { + additionalProperties: { + '$ref': '#/components/schemas/TableMetaInfoBase' + }, + type: 'object' + }, + type: 'object', + title: 'Db Structure' + }, + tables: { + additionalProperties: { + '$ref': '#/components/schemas/TableMetaInfoBase' + }, + type: 'object', + title: 'Tables', + readOnly: true + } + }, + type: 'object', + required: ['db_structure', 'tables'], + title: 'DBMetaInfoResponse' +} as const; + +export const DBMetaQuerySchema = { + properties: { + syntactic_table_conditions: { + items: { + '$ref': '#/components/schemas/SyntacticTableCondition' + }, + type: 'array', + title: 'Syntactic Table Conditions' + }, + semantic_table_conditions: { + items: { + '$ref': '#/components/schemas/SemanticTableCondition' + }, + type: 'array', + title: 'Semantic Table Conditions' + }, + syntactic_column_conditions: { + items: { + '$ref': '#/components/schemas/SyntacticColumnCondition' + }, + type: 'array', + title: 'Syntactic Column Conditions' + }, + semantic_column_conditions: { + items: { + '$ref': '#/components/schemas/SemanticColumnCondition' + }, + type: 'array', + title: 'Semantic Column Conditions' + } + }, + type: 'object', + title: 'DBMetaQuery' +} as const; + +export const DBProbeResponseSchema = { + properties: { + table_probes: { + additionalProperties: { + '$ref': '#/components/schemas/TableProbeBase' + }, + type: 'object', + title: 'Table Probes' + }, + db_meta: { + '$ref': '#/components/schemas/DBMetaInfoBase' + } + }, + type: 'object', + required: ['db_meta'], + title: 'DBProbeResponse' +} as const; + +export const DBSchemaQueryRequestSchema = { + properties: { + query: { + '$ref': '#/components/schemas/DBMetaQuery' + }, + filter_columns: { + type: 'boolean', + title: 'Filter Columns', + default: false + } + }, + type: 'object', + required: ['query'], + title: 'DBSchemaQueryRequest' +} as const; + +export const DBSchemaSelectionRequestSchema = { + properties: { + selection: { + anyOf: [ + { + additionalProperties: { + items: { + type: 'string' + }, + type: 'array', + uniqueItems: true + }, + type: 'object' + }, + { + additionalProperties: { + additionalProperties: { + items: { + type: 'string' + }, + type: 'array', + uniqueItems: true + }, + type: 'object' + }, + type: 'object' + } + ], + title: 'Selection' + }, + filter_columns: { + type: 'boolean', + title: 'Filter Columns', + default: false + } + }, + type: 'object', + required: ['selection'], + title: 'DBSchemaSelectionRequest' +} as const; + +export const DatetimeSummaryStatisticsSchema = { + properties: { + count: { + type: 'integer', + title: 'Count' + }, + mean: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Mean' + }, + min: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Min' + }, + max: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Max' + }, + percentile_25: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Percentile 25' + }, + percentile_50: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Percentile 50' + }, + percentile_75: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Percentile 75' + } + }, + type: 'object', + required: ['count'], + title: 'DatetimeSummaryStatistics' +} as const; + +export const ERVariantSchema = { + type: 'string', + enum: ['image', 'mermaid'], + title: 'ERVariant' +} as const; + +export const EditColumnsSchema = { + properties: { + operation: { + type: 'string', + enum: ['edit_columns'], + const: 'edit_columns', + title: 'Operation', + default: 'edit_columns' + }, + transforms: { + additionalProperties: { + oneOf: [ + { + '$ref': '#/components/schemas/CastColumn' + } + ], + discriminator: { + propertyName: 'operation', + mapping: { + cast_column: '#/components/schemas/CastColumn' + } + } + }, + type: 'object', + title: 'Transforms' + }, + renames: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Renames' + }, + drops: { + items: { + type: 'string' + }, + type: 'array', + uniqueItems: true, + title: 'Drops' + }, + additions: { + additionalProperties: { + items: { + oneOf: [ + { + '$ref': '#/components/schemas/AddColumn' + }, + { + '$ref': '#/components/schemas/ExtractJson' + } + ], + discriminator: { + propertyName: 'operation', + mapping: { + add_column: '#/components/schemas/AddColumn', + extract_json: '#/components/schemas/ExtractJson' + } + } + }, + type: 'array' + }, + type: 'object', + title: 'Additions' + } + }, + type: 'object', + title: 'EditColumns' +} as const; + +export const ExistingTableSchema = { + properties: { + operation: { + type: 'string', + enum: ['existing'], + const: 'existing', + title: 'Operation', + default: 'existing' + }, + base_table: { + anyOf: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + prefixItems: [ + { + '$ref': '#/components/schemas/SourceDBType' + }, + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 3, + minItems: 3 + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Base Table' + } + }, + type: 'object', + required: ['base_table'], + title: 'ExistingTable' +} as const; + +export const ExtractJsonSchema = { + properties: { + operation: { + type: 'string', + enum: ['extract_json'], + const: 'extract_json', + title: 'Operation', + default: 'extract_json' + }, + json_col: { + type: 'string', + title: 'Json Col' + }, + attributes: { + additionalProperties: { + items: { + type: 'string' + }, + type: 'array' + }, + type: 'object', + title: 'Attributes' + } + }, + type: 'object', + required: ['json_col', 'attributes'], + title: 'ExtractJson' +} as const; + +export const FKCreationRequestSchema = { + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name' + }, + table: { + anyOf: [ + { + '$ref': '#/components/schemas/LocalTableIdentifier' + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Table' + }, + columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Columns' + }, + target_table: { + anyOf: [ + { + '$ref': '#/components/schemas/LocalTableIdentifier' + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Target Table' + }, + target_columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Target Columns' + } + }, + type: 'object', + required: ['table', 'columns', 'target_table', 'target_columns'], + title: 'FKCreationRequest' +} as const; + +export const FKCreationResponseSchema = { + properties: { + status: { + type: 'boolean', + title: 'Status' + }, + error: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Error' + } + }, + type: 'object', + required: ['status'], + title: 'FKCreationResponse' +} as const; + +export const ForeignKeyConstraintBaseSchema = { + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name' + }, + table: { + anyOf: [ + { + '$ref': '#/components/schemas/LocalTableIdentifier' + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Table' + }, + columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Columns' + }, + target_table: { + anyOf: [ + { + '$ref': '#/components/schemas/LocalTableIdentifier' + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Target Table' + }, + target_columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Target Columns' + } + }, + type: 'object', + required: ['table', 'columns', 'target_table', 'target_columns'], + title: 'ForeignKeyConstraintBase' +} as const; + +export const ForeignRelationSchema = { + properties: { + fk_columns: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + items: { + type: 'string' + }, + type: 'array' + } + ], + title: 'Fk Columns' + }, + referred_table: { + anyOf: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + prefixItems: [ + { + '$ref': '#/components/schemas/SourceDBType' + }, + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 3, + minItems: 3 + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Referred Table' + } + }, + type: 'object', + required: ['fk_columns', 'referred_table'], + title: 'ForeignRelation' +} as const; + +export const ForeignRelationInfoSchema = { + properties: { + target_concept: { + type: 'string', + title: 'Target Concept' + }, + fk_relations: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Fk Relations' + } + }, + type: 'object', + required: ['target_concept', 'fk_relations'], + title: 'ForeignRelationInfo' +} as const; + +export const GroupValidationResultSchema = { + properties: { + individual_validations: { + additionalProperties: { + items: { + prefixItems: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + '$ref': '#/components/schemas/IndividualValidationResult' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + }, + type: 'array' + }, + type: 'object', + title: 'Individual Validations' + }, + is_valid: { + type: 'boolean', + title: 'Is Valid', + readOnly: true + } + }, + type: 'object', + required: ['is_valid'], + title: 'GroupValidationResult' +} as const; + +export const HTTPValidationErrorSchema = { + properties: { + detail: { + items: { + '$ref': '#/components/schemas/ValidationError' + }, + type: 'array', + title: 'Detail' + } + }, + type: 'object', + title: 'HTTPValidationError' +} as const; + +export const IndividualValidationResultSchema = { + properties: { + is_valid: { + type: 'boolean', + title: 'Is Valid', + default: true + }, + violations: { + items: { + type: 'string' + }, + type: 'array', + title: 'Violations' + } + }, + type: 'object', + title: 'IndividualValidationResult' +} as const; + +export const KeepAliveResponseSchema = { + properties: { + server_status: { + type: 'string', + enum: ['available'], + const: 'available', + title: 'Server Status', + default: 'available' + }, + session_status: { + type: 'string', + enum: ['missing session cookie', 'session invalid', 'session valid'], + title: 'Session Status' + } + }, + type: 'object', + required: ['session_status'], + title: 'KeepAliveResponse' +} as const; + +export const LimitSchema = { + properties: { + operation: { + type: 'string', + enum: ['limit'], + const: 'limit', + title: 'Operation', + default: 'limit' + }, + limit: { + type: 'integer', + title: 'Limit' + } + }, + type: 'object', + required: ['limit'], + title: 'Limit' +} as const; + +export const LocalTableIdentifierSchema = { + properties: { + name: { + type: 'string', + title: 'Name' + }, + schema: { + type: 'string', + title: 'Schema', + default: 'main' + } + }, + type: 'object', + required: ['name'], + title: 'LocalTableIdentifier' +} as const; + +export const MITMSchema = { + type: 'string', + enum: ['MAED', 'OCEL2'], + title: 'MITM' +} as const; + +export const MITMDataTypeSchema = { + type: 'string', + enum: ['text', 'json', 'integer', 'numeric', 'boolean', 'datetime', 'unknown', 'infer'], + title: 'MITMDataType' +} as const; + +export const MITMDefinitionSchema = { + properties: { + main_concepts: { + items: { + type: 'string' + }, + type: 'array', + uniqueItems: true, + title: 'Main Concepts' + }, + weak_concepts: { + additionalProperties: { + '$ref': '#/components/schemas/MITMDataType' + }, + type: 'object', + title: 'Weak Concepts' + }, + sub_concepts: { + additionalProperties: { + items: { + type: 'string' + }, + type: 'array', + uniqueItems: true + }, + type: 'object', + title: 'Sub Concepts' + }, + concept_relations: { + additionalProperties: { + '$ref': '#/components/schemas/OwnedRelations' + }, + type: 'object', + title: 'Concept Relations' + }, + concept_properties: { + additionalProperties: { + '$ref': '#/components/schemas/ConceptProperties' + }, + type: 'object', + title: 'Concept Properties' + }, + leaf_concepts: { + items: { + type: 'string' + }, + type: 'array', + uniqueItems: true, + title: 'Leaf Concepts', + readOnly: true + }, + abstract_concepts: { + items: { + type: 'string' + }, + type: 'array', + uniqueItems: true, + title: 'Abstract Concepts', + readOnly: true + }, + parent_concepts_map: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Parent Concepts Map', + readOnly: true + } + }, + type: 'object', + required: ['main_concepts', 'weak_concepts', 'sub_concepts', 'concept_relations', 'concept_properties', 'leaf_concepts', 'abstract_concepts', 'parent_concepts_map'], + title: 'MITMDefinition' +} as const; + +export const MappingExportRequestSchema = { + properties: { + mitm: { + '$ref': '#/components/schemas/MITM' + }, + mapped_concepts: { + items: { + '$ref': '#/components/schemas/ConceptMapping' + }, + type: 'array', + title: 'Mapped Concepts' + }, + post_processing: { + anyOf: [ + { + '$ref': '#/components/schemas/PostProcessing' + }, + { + type: 'null' + } + ] + }, + filename: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Filename' + } + }, + type: 'object', + required: ['mitm', 'mapped_concepts'], + title: 'MappingExportRequest' +} as const; + +export const MappingGroupValidationResultSchema = { + properties: { + validation_result: { + '$ref': '#/components/schemas/GroupValidationResult' + } + }, + type: 'object', + required: ['validation_result'], + title: 'MappingGroupValidationResult' +} as const; + +export const MitMDataTypeInfoSchema = { + properties: { + sql_type: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Sql Type' + } + }, + type: 'object', + required: ['sql_type'], + title: 'MitMDataTypeInfo' +} as const; + +export const NumericSummaryStatisticsSchema = { + properties: { + count: { + type: 'integer', + title: 'Count' + }, + mean: { + type: 'number', + title: 'Mean' + }, + min: { + type: 'number', + title: 'Min' + }, + max: { + type: 'number', + title: 'Max' + }, + std: { + anyOf: [ + { + type: 'number' + }, + { + type: 'null' + } + ], + title: 'Std' + }, + percentile_25: { + type: 'number', + title: 'Percentile 25' + }, + percentile_50: { + type: 'number', + title: 'Percentile 50' + }, + percentile_75: { + type: 'number', + title: 'Percentile 75' + } + }, + type: 'object', + required: ['count', 'mean', 'min', 'max', 'percentile_25', 'percentile_50', 'percentile_75'], + title: 'NumericSummaryStatistics' +} as const; + +export const OwnedRelationsSchema = { + properties: { + identity: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Identity' + }, + inline: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Inline' + }, + foreign: { + additionalProperties: { + '$ref': '#/components/schemas/ForeignRelationInfo' + }, + type: 'object', + title: 'Foreign' + } + }, + type: 'object', + required: ['identity', 'inline', 'foreign'], + title: 'OwnedRelations' +} as const; + +export const PostProcessingSchema = { + properties: { + table_postprocessing: { + items: { + '$ref': '#/components/schemas/TablePostProcessing' + }, + type: 'array', + title: 'Table Postprocessing' + } + }, + type: 'object', + required: ['table_postprocessing'], + title: 'PostProcessing' +} as const; + +export const PublishedMitMResponseSchema = { + properties: { + url: { + type: 'string', + maxLength: 2083, + minLength: 1, + format: 'uri', + title: 'Url' + }, + relative_uri: { + type: 'string', + title: 'Relative Uri' + }, + deletion_request_url: { + type: 'string', + maxLength: 2083, + minLength: 1, + format: 'uri', + title: 'Deletion Request Url' + }, + export_id: { + type: 'integer', + title: 'Export Id' + } + }, + type: 'object', + required: ['url', 'relative_uri', 'deletion_request_url', 'export_id'], + title: 'PublishedMitMResponse' +} as const; + +export const RawCompiledSchema = { + properties: { + operation: { + type: 'string', + enum: ['raw'], + const: 'raw', + title: 'Operation', + default: 'raw' + }, + typed_query: { + '$ref': '#/components/schemas/TypedRawQuery' + } + }, + type: 'object', + required: ['typed_query'], + title: 'RawCompiled' +} as const; + +export const ReselectColumnsSchema = { + properties: { + operation: { + type: 'string', + enum: ['reselect_columns'], + const: 'reselect_columns', + title: 'Operation', + default: 'reselect_columns' + }, + selection: { + items: { + type: 'string' + }, + type: 'array', + title: 'Selection' + } + }, + type: 'object', + required: ['selection'], + title: 'ReselectColumns' +} as const; + +export const SampleSummarySchema = { + properties: { + sample_size: { + anyOf: [ + { + type: 'integer', + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Sample Size' + }, + na_fraction: { + anyOf: [ + { + type: 'number', + maximum: 1, + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Na Fraction' + }, + unique_fraction: { + anyOf: [ + { + type: 'number', + maximum: 1, + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Unique Fraction' + }, + value_counts: { + anyOf: [ + { + additionalProperties: { + type: 'integer' + }, + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Value Counts' + }, + summary_statistics: { + anyOf: [ + { + '$ref': '#/components/schemas/NumericSummaryStatistics' + }, + { + '$ref': '#/components/schemas/CategoricalSummaryStatistics' + }, + { + '$ref': '#/components/schemas/DatetimeSummaryStatistics' + }, + { + type: 'null' + } + ], + title: 'Summary Statistics' + }, + json_schema: { + anyOf: [ + { + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Json Schema' + } + }, + type: 'object', + title: 'SampleSummary' +} as const; + +export const SemanticColumnConditionSchema = { + properties: { + inferred_data_type: { + anyOf: [ + { + '$ref': '#/components/schemas/MITMDataType' + }, + { + type: 'null' + } + ] + }, + max_na_fraction: { + anyOf: [ + { + type: 'number', + maximum: 1, + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Max Na Fraction' + }, + value_in_range: { + anyOf: [ + {}, + { + type: 'null' + } + ], + title: 'Value In Range' + }, + contained_value: { + anyOf: [ + {}, + { + type: 'null' + } + ], + title: 'Contained Value' + }, + contained_datetime: { + anyOf: [ + { + type: 'string', + format: 'date-time' + }, + { + type: 'null' + } + ], + title: 'Contained Datetime' + } + }, + type: 'object', + title: 'SemanticColumnCondition' +} as const; + +export const SemanticTableConditionSchema = { + properties: { + min_row_count: { + anyOf: [ + { + type: 'integer', + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Min Row Count' + }, + max_row_count: { + anyOf: [ + { + type: 'integer', + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Max Row Count' + } + }, + type: 'object', + title: 'SemanticTableCondition' +} as const; + +export const SessionIdResponseSchema = { + properties: { + session_id: { + type: 'string', + format: 'uuid', + title: 'Session Id' + } + }, + type: 'object', + required: ['session_id'], + title: 'SessionIdResponse' +} as const; + +export const SimpleJoinSchema = { + properties: { + operation: { + type: 'string', + enum: ['join'], + const: 'join', + title: 'Operation', + default: 'join' + }, + left_table: { + anyOf: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + prefixItems: [ + { + '$ref': '#/components/schemas/SourceDBType' + }, + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 3, + minItems: 3 + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Left Table' + }, + right_table: { + anyOf: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + prefixItems: [ + { + '$ref': '#/components/schemas/SourceDBType' + }, + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 3, + minItems: 3 + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Right Table' + }, + on_cols_left: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'On Cols Left' + }, + on_cols_right: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'On Cols Right' + }, + is_outer: { + type: 'boolean', + title: 'Is Outer', + default: false + }, + full: { + type: 'boolean', + title: 'Full', + default: false + }, + selected_cols_left: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Selected Cols Left' + }, + selected_cols_right: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Selected Cols Right' + }, + left_alias: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Left Alias' + }, + right_alias: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Right Alias' + } + }, + type: 'object', + required: ['left_table', 'right_table'], + title: 'SimpleJoin' +} as const; + +export const SimpleSQLOperatorSchema = { + type: 'string', + enum: ['ilike', 'like', 'eq', 'ge', 'gt', 'le', 'lt', 'in', 'notin'], + title: 'SimpleSQLOperator' +} as const; + +export const SimpleWhereSchema = { + properties: { + lhs: { + type: 'string', + title: 'Lhs' + }, + operator: { + '$ref': '#/components/schemas/SimpleSQLOperator' + }, + rhs: { + anyOf: [ + { + type: 'string' + }, + { + prefixItems: [ + {}, + { + anyOf: [ + { + '$ref': '#/components/schemas/WrappedMITMDataType' + }, + { + type: 'string' + } + ] + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Rhs' + } + }, + type: 'object', + required: ['lhs', 'operator', 'rhs'], + title: 'SimpleWhere' +} as const; + +export const SourceDBTypeSchema = { + type: 'string', + enum: ['original', 'working', 'virtual'], + title: 'SourceDBType' +} as const; + +export const SyntacticColumnConditionSchema = { + properties: { + name_regex: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name Regex' + }, + sql_data_type: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Sql Data Type' + }, + mitm_data_type: { + anyOf: [ + { + '$ref': '#/components/schemas/MITMDataType' + }, + { + type: 'null' + } + ] + } + }, + type: 'object', + title: 'SyntacticColumnCondition' +} as const; + +export const SyntacticTableConditionSchema = { + properties: { + schema_regex: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Schema Regex' + }, + name_regex: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name Regex' + }, + min_col_count: { + anyOf: [ + { + type: 'integer', + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Min Col Count' + }, + max_col_count: { + anyOf: [ + { + type: 'integer', + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Max Col Count' + }, + has_foreign_key: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Has Foreign Key' + } + }, + type: 'object', + title: 'SyntacticTableCondition' +} as const; + +export const TableFilterSchema = { + properties: { + operation: { + type: 'string', + enum: ['table_filter'], + const: 'table_filter', + title: 'Operation', + default: 'table_filter' + }, + wheres: { + items: { + '$ref': '#/components/schemas/SimpleWhere' + }, + type: 'array', + title: 'Wheres' + }, + limit: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Limit' + } + }, + type: 'object', + required: ['wheres'], + title: 'TableFilter' +} as const; + +export const TableIdentifierSchema = { + properties: { + source: { + '$ref': '#/components/schemas/SourceDBType', + default: 'original' + }, + schema: { + type: 'string', + title: 'Schema', + default: 'main' + }, + name: { + type: 'string', + title: 'Name' + } + }, + type: 'object', + required: ['name'], + title: 'TableIdentifier' +} as const; + +export const TableMetaInfoBaseSchema = { + properties: { + schema_name: { + type: 'string', + title: 'Schema Name', + default: 'main' + }, + name: { + type: 'string', + title: 'Name' + }, + columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Columns' + }, + sql_column_types: { + items: { + type: 'string' + }, + type: 'array', + title: 'Sql Column Types' + }, + primary_key: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Primary Key' + }, + indexes: { + anyOf: [ + { + items: { + items: { + type: 'string' + }, + type: 'array' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Indexes' + }, + foreign_key_constraints: { + items: { + '$ref': '#/components/schemas/ForeignKeyConstraintBase' + }, + type: 'array', + title: 'Foreign Key Constraints' + }, + column_properties: { + additionalProperties: { + '$ref': '#/components/schemas/ColumnProperties' + }, + type: 'object', + title: 'Column Properties' + } + }, + type: 'object', + required: ['name', 'columns', 'sql_column_types'], + title: 'TableMetaInfoBase' +} as const; + +export const TableMetaInfoResponseSchema = { + properties: { + schema_name: { + type: 'string', + title: 'Schema Name', + default: 'main' + }, + name: { + type: 'string', + title: 'Name' + }, + columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Columns' + }, + sql_column_types: { + items: { + type: 'string' + }, + type: 'array', + title: 'Sql Column Types' + }, + primary_key: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Primary Key' + }, + indexes: { + anyOf: [ + { + items: { + items: { + type: 'string' + }, + type: 'array' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Indexes' + }, + foreign_key_constraints: { + items: { + '$ref': '#/components/schemas/ForeignKeyConstraintBase' + }, + type: 'array', + title: 'Foreign Key Constraints' + }, + column_properties: { + additionalProperties: { + '$ref': '#/components/schemas/ColumnProperties' + }, + type: 'object', + title: 'Column Properties' + } + }, + type: 'object', + required: ['name', 'columns', 'sql_column_types'], + title: 'TableMetaInfoResponse' +} as const; + +export const TablePostProcessingSchema = { + properties: { + target_table: { + anyOf: [ + { + '$ref': '#/components/schemas/TableIdentifier' + }, + { + prefixItems: [ + { + '$ref': '#/components/schemas/SourceDBType' + }, + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 3, + minItems: 3 + }, + { + prefixItems: [ + { + type: 'string' + }, + { + type: 'string' + } + ], + type: 'array', + maxItems: 2, + minItems: 2 + } + ], + title: 'Target Table' + }, + transforms: { + items: { + oneOf: [ + { + '$ref': '#/components/schemas/EditColumns' + }, + { + '$ref': '#/components/schemas/ReselectColumns' + }, + { + '$ref': '#/components/schemas/TableFilter' + }, + { + '$ref': '#/components/schemas/Limit' + } + ], + discriminator: { + propertyName: 'operation', + mapping: { + edit_columns: '#/components/schemas/EditColumns', + limit: '#/components/schemas/Limit', + reselect_columns: '#/components/schemas/ReselectColumns', + table_filter: '#/components/schemas/TableFilter' + } + } + }, + type: 'array', + title: 'Transforms' + } + }, + type: 'object', + required: ['target_table', 'transforms'], + title: 'TablePostProcessing' +} as const; + +export const TableProbeBaseSchema = { + properties: { + row_count: { + type: 'integer', + minimum: 0, + title: 'Row Count' + }, + inferred_types: { + additionalProperties: { + '$ref': '#/components/schemas/MITMDataType' + }, + type: 'object', + title: 'Inferred Types' + }, + sample_summaries: { + additionalProperties: { + '$ref': '#/components/schemas/SampleSummary' + }, + type: 'object', + title: 'Sample Summaries' + }, + table_meta: { + '$ref': '#/components/schemas/TableMetaInfoBase' + }, + sampled_values: { + additionalProperties: { + items: {}, + type: 'array' + }, + type: 'object', + title: 'Sampled Values' + } + }, + type: 'object', + required: ['row_count', 'inferred_types', 'sample_summaries', 'table_meta', 'sampled_values'], + title: 'TableProbeBase' +} as const; + +export const TableProbeResponseSchema = { + properties: { + row_count: { + type: 'integer', + minimum: 0, + title: 'Row Count' + }, + inferred_types: { + additionalProperties: { + '$ref': '#/components/schemas/MITMDataType' + }, + type: 'object', + title: 'Inferred Types' + }, + sample_summaries: { + additionalProperties: { + '$ref': '#/components/schemas/SampleSummary' + }, + type: 'object', + title: 'Sample Summaries' + }, + table_meta: { + '$ref': '#/components/schemas/TableMetaInfoBase' + }, + sampled_values: { + additionalProperties: { + items: {}, + type: 'array' + }, + type: 'object', + title: 'Sampled Values' + } + }, + type: 'object', + required: ['row_count', 'inferred_types', 'sample_summaries', 'table_meta', 'sampled_values'], + title: 'TableProbeResponse' +} as const; + +export const TableQueryResultSchema = { + properties: { + table_info: { + anyOf: [ + { + '$ref': '#/components/schemas/TableMetaInfoResponse' + }, + { + type: 'null' + } + ] + }, + rows: { + items: { + items: {}, + type: 'array' + }, + type: 'array', + title: 'Rows' + } + }, + type: 'object', + required: ['table_info', 'rows'], + title: 'TableQueryResult' +} as const; + +export const TypedRawQuerySchema = { + properties: { + dialect: { + type: 'string', + title: 'Dialect' + }, + compiled_sql: { + type: 'string', + title: 'Compiled Sql' + }, + columns: { + items: { + type: 'string' + }, + type: 'array', + title: 'Columns' + }, + column_dtypes: { + items: { + anyOf: [ + { + '$ref': '#/components/schemas/WrappedMITMDataType' + }, + { + type: 'string' + } + ] + }, + type: 'array', + title: 'Column Dtypes' + } + }, + type: 'object', + required: ['dialect', 'compiled_sql', 'columns', 'column_dtypes'], + title: 'TypedRawQuery' +} as const; + +export const ValidationErrorSchema = { + properties: { + loc: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Location' + }, + msg: { + type: 'string', + title: 'Message' + }, + type: { + type: 'string', + title: 'Error Type' + } + }, + type: 'object', + required: ['loc', 'msg', 'type'], + title: 'ValidationError' +} as const; + +export const VirtualViewCreationRequestSchema = { + properties: { + name: { + type: 'string', + title: 'Name' + }, + table_creation: { + oneOf: [ + { + '$ref': '#/components/schemas/SimpleJoin' + }, + { + '$ref': '#/components/schemas/ExistingTable' + }, + { + '$ref': '#/components/schemas/RawCompiled' + } + ], + title: 'Table Creation', + discriminator: { + propertyName: 'operation', + mapping: { + existing: '#/components/schemas/ExistingTable', + join: '#/components/schemas/SimpleJoin', + raw: '#/components/schemas/RawCompiled' + } + } + }, + transforms: { + anyOf: [ + { + items: { + oneOf: [ + { + '$ref': '#/components/schemas/EditColumns' + }, + { + '$ref': '#/components/schemas/ReselectColumns' + }, + { + '$ref': '#/components/schemas/TableFilter' + }, + { + '$ref': '#/components/schemas/Limit' + } + ], + discriminator: { + propertyName: 'operation', + mapping: { + edit_columns: '#/components/schemas/EditColumns', + limit: '#/components/schemas/Limit', + reselect_columns: '#/components/schemas/ReselectColumns', + table_filter: '#/components/schemas/TableFilter' + } + } + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Transforms' + }, + schema: { + type: 'string', + title: 'Schema', + default: 'virtual' + } + }, + type: 'object', + required: ['name', 'table_creation'], + title: 'VirtualViewCreationRequest' +} as const; + +export const VirtualViewResponseSchema = { + properties: { + table_meta: { + '$ref': '#/components/schemas/TableMetaInfoResponse' + } + }, + type: 'object', + required: ['table_meta'], + title: 'VirtualViewResponse' +} as const; + +export const WrappedMITMDataTypeSchema = { + properties: { + mitm: { + '$ref': '#/components/schemas/MITMDataType' + } + }, + type: 'object', + required: ['mitm'], + title: 'WrappedMITMDataType' +} as const; \ No newline at end of file diff --git a/src/services/api-schema/services.gen.ts b/src/services/api-schema/services.gen.ts new file mode 100644 index 0000000000000000000000000000000000000000..f331b3addf8ea41c642a5d8ac07b62d247e8fb91 --- /dev/null +++ b/src/services/api-schema/services.gen.ts @@ -0,0 +1,493 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createClient, createConfig, type Options, formDataBodySerializer } from '@hey-api/client-axios'; +import type { GetActiveSessionsResponse, GetMitmsResponse, GetMitmDefinitionData, GetMitmDefinitionError, GetMitmDefinitionResponse, GetMitmDataTypesResponse, StartSessionResponse, GetSessionError, GetSessionResponse, StopSessionError, UploadDbData, UploadDbError, ConnectDbData, ConnectDbError, TestDbConnError, TestDbConnResponse, KeepAliveResponse2, ReflectDbError, InitWorkingDbError, MarkForeignKeyData, MarkForeignKeyError, MarkForeignKeyResponse, DropVirtualViewData, DropVirtualViewError, GetVirtualViewData, GetVirtualViewError, GetVirtualViewResponse, CreateVirtualViewData, CreateVirtualViewError, CreateVirtualViewResponse, GetVirtualViewsError, GetVirtualViewsResponse, GetCompiledVirtualViewData, GetCompiledVirtualViewError, GetCompiledVirtualViewResponse, GetCompiledVirtualViewsError, GetCompiledVirtualViewsResponse, CreateVirtualViewsBatchData, CreateVirtualViewsBatchError, CreateVirtualViewsBatchResponse, RawQueryData, RawQueryError, RawQueryResponse, QueryTableData, QueryTableError, QueryTableResponse, QueryUniqueValuesData, QueryUniqueValuesError, QueryUniqueValuesResponse, MakeErdData, MakeErdError, MakeFilteredErdData, MakeFilteredErdError, GetTableSchemaData, GetTableSchemaError, GetTableSchemaResponse, GetDbSchemaData, GetDbSchemaError, GetDbSchemaResponse, FilterDbSchemaData, FilterDbSchemaError, FilterDbSchemaResponse, QueryDbSchemaData, QueryDbSchemaError, QueryDbSchemaResponse, SuggestJoinsData, SuggestJoinsError, SuggestJoinsResponse, ProbeTableData, ProbeTableError, ProbeTableResponse, ProbeDbData, ProbeDbError, ProbeDbResponse, ValidateConceptMappingsData, ValidateConceptMappingsError, ValidateConceptMappingsResponse, ExportMitmData, ExportMitmError, PublishMitmExportData, PublishMitmExportError, PublishMitmExportResponse, DeleteMitmExportData, DeleteMitmExportError, DeleteMitmExportsError } from './types.gen'; + +export const client = createClient(createConfig()); + +export class AdminService { + /** + * Clear Sessions + */ + public static clearSessions<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ + ...options, + url: '/admin/clear-sessions' + }); + } + + /** + * Get Active Sessions + */ + public static getActiveSessions<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<GetActiveSessionsResponse, unknown, ThrowOnError>({ + ...options, + url: '/admin/active-sessions' + }); + } + + /** + * Clear Exports + */ + public static clearExports<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ + ...options, + url: '/admin/clear-exports' + }); + } + +} + +export class DefinitionsService { + /** + * Get Mitms + */ + public static getMitms<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<GetMitmsResponse, unknown, ThrowOnError>({ + ...options, + url: '/definitions/mitms' + }); + } + + /** + * Get Mitm Definition + */ + public static getMitmDefinition<ThrowOnError extends boolean = false>(options: Options<GetMitmDefinitionData, ThrowOnError>) { + return (options?.client ?? client).get<GetMitmDefinitionResponse, GetMitmDefinitionError, ThrowOnError>({ + ...options, + url: '/definitions/mitm-definition' + }); + } + + /** + * Get Mitm Data Types + */ + public static getMitmDataTypes<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<GetMitmDataTypesResponse, unknown, ThrowOnError>({ + ...options, + url: '/definitions/mitm-data-types' + }); + } + +} + +export class SessionService { + /** + * Start Session + */ + public static startSession<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).post<StartSessionResponse, unknown, ThrowOnError>({ + ...options, + url: '/session/start-session' + }); + } + + /** + * Get Session + */ + public static getSession<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<GetSessionResponse, GetSessionError, ThrowOnError>({ + ...options, + url: '/session/get-session' + }); + } + + /** + * Stop Session + */ + public static stopSession<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).post<unknown, StopSessionError, ThrowOnError>({ + ...options, + url: '/session/stop-session' + }); + } + + /** + * Upload Db + */ + public static uploadDb<ThrowOnError extends boolean = false>(options: Options<UploadDbData, ThrowOnError>) { + return (options?.client ?? client).post<unknown, UploadDbError, ThrowOnError>({ + ...options, + ...formDataBodySerializer, + headers: { + 'Content-Type': null, + ...options?.headers + }, + url: '/session/upload-db' + }); + } + + /** + * Connect Db + */ + public static connectDb<ThrowOnError extends boolean = false>(options: Options<ConnectDbData, ThrowOnError>) { + return (options?.client ?? client).post<unknown, ConnectDbError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/session/connect-db' + }); + } + + /** + * Test Db Conn + */ + public static testDbConn<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<TestDbConnResponse, TestDbConnError, ThrowOnError>({ + ...options, + url: '/session/test-db-conn' + }); + } + + /** + * Keep Alive + */ + public static keepAlive<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<KeepAliveResponse2, unknown, ThrowOnError>({ + ...options, + url: '/session/keep-alive' + }); + } + +} + +export class ControlService { + /** + * Reflect Db + */ + public static reflectDb<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).post<unknown, ReflectDbError, ThrowOnError>({ + ...options, + url: '/control/reflect-db' + }); + } + + /** + * Init Working Db + */ + public static initWorkingDb<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).post<unknown, InitWorkingDbError, ThrowOnError>({ + ...options, + url: '/control/init-working-db' + }); + } + + /** + * Mark Foreign Key + */ + public static markForeignKey<ThrowOnError extends boolean = false>(options: Options<MarkForeignKeyData, ThrowOnError>) { + return (options?.client ?? client).post<MarkForeignKeyResponse, MarkForeignKeyError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/control/mark-foreign-key' + }); + } + + /** + * Drop Virtual View + */ + public static dropVirtualView<ThrowOnError extends boolean = false>(options: Options<DropVirtualViewData, ThrowOnError>) { + return (options?.client ?? client).delete<unknown, DropVirtualViewError, ThrowOnError>({ + ...options, + url: '/control/virtual-view' + }); + } + + /** + * Get Virtual View + */ + public static getVirtualView<ThrowOnError extends boolean = false>(options: Options<GetVirtualViewData, ThrowOnError>) { + return (options?.client ?? client).get<GetVirtualViewResponse, GetVirtualViewError, ThrowOnError>({ + ...options, + url: '/control/virtual-view' + }); + } + + /** + * Create Virtual View + */ + public static createVirtualView<ThrowOnError extends boolean = false>(options: Options<CreateVirtualViewData, ThrowOnError>) { + return (options?.client ?? client).put<CreateVirtualViewResponse, CreateVirtualViewError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/control/virtual-view' + }); + } + + /** + * Get Virtual Views + */ + public static getVirtualViews<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<GetVirtualViewsResponse, GetVirtualViewsError, ThrowOnError>({ + ...options, + url: '/control/virtual-views' + }); + } + + /** + * Get Compiled Virtual View + */ + public static getCompiledVirtualView<ThrowOnError extends boolean = false>(options: Options<GetCompiledVirtualViewData, ThrowOnError>) { + return (options?.client ?? client).get<GetCompiledVirtualViewResponse, GetCompiledVirtualViewError, ThrowOnError>({ + ...options, + url: '/control/compiled-virtual-view' + }); + } + + /** + * Get Compiled Virtual Views + */ + public static getCompiledVirtualViews<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<GetCompiledVirtualViewsResponse, GetCompiledVirtualViewsError, ThrowOnError>({ + ...options, + url: '/control/compiled-virtual-views' + }); + } + + /** + * Create Virtual Views Batch + */ + public static createVirtualViewsBatch<ThrowOnError extends boolean = false>(options: Options<CreateVirtualViewsBatchData, ThrowOnError>) { + return (options?.client ?? client).put<CreateVirtualViewsBatchResponse, CreateVirtualViewsBatchError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/control/virtual-views-batch' + }); + } + +} + +export class DataService { + /** + * Raw Query + */ + public static rawQuery<ThrowOnError extends boolean = false>(options: Options<RawQueryData, ThrowOnError>) { + return (options?.client ?? client).post<RawQueryResponse, RawQueryError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/data/raw-query' + }); + } + + /** + * Query Table + */ + public static queryTable<ThrowOnError extends boolean = false>(options: Options<QueryTableData, ThrowOnError>) { + return (options?.client ?? client).get<QueryTableResponse, QueryTableError, ThrowOnError>({ + ...options, + url: '/data/query-table' + }); + } + + /** + * Query Unique Values + */ + public static queryUniqueValues<ThrowOnError extends boolean = false>(options: Options<QueryUniqueValuesData, ThrowOnError>) { + return (options?.client ?? client).get<QueryUniqueValuesResponse, QueryUniqueValuesError, ThrowOnError>({ + ...options, + url: '/data/query-unique-values' + }); + } + + /** + * Make Erd + */ + public static makeErd<ThrowOnError extends boolean = false>(options: Options<MakeErdData, ThrowOnError>) { + return (options?.client ?? client).get<unknown, MakeErdError, ThrowOnError>({ + ...options, + url: '/data/er-diagram' + }); + } + + /** + * Make Filtered Erd + */ + public static makeFilteredErd<ThrowOnError extends boolean = false>(options: Options<MakeFilteredErdData, ThrowOnError>) { + return (options?.client ?? client).post<unknown, MakeFilteredErdError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/data/filtered-er-diagram' + }); + } + +} + +export class ReflectionService { + /** + * Get Table Schema + */ + public static getTableSchema<ThrowOnError extends boolean = false>(options: Options<GetTableSchemaData, ThrowOnError>) { + return (options?.client ?? client).get<GetTableSchemaResponse, GetTableSchemaError, ThrowOnError>({ + ...options, + url: '/reflection/table-schema' + }); + } + + /** + * Get Db Schema + */ + public static getDbSchema<ThrowOnError extends boolean = false>(options: Options<GetDbSchemaData, ThrowOnError>) { + return (options?.client ?? client).get<GetDbSchemaResponse, GetDbSchemaError, ThrowOnError>({ + ...options, + url: '/reflection/db-schema' + }); + } + + /** + * Filter Db Schema + */ + public static filterDbSchema<ThrowOnError extends boolean = false>(options: Options<FilterDbSchemaData, ThrowOnError>) { + return (options?.client ?? client).post<FilterDbSchemaResponse, FilterDbSchemaError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/reflection/filter-db-schema' + }); + } + + /** + * Query Db Schema + */ + public static queryDbSchema<ThrowOnError extends boolean = false>(options: Options<QueryDbSchemaData, ThrowOnError>) { + return (options?.client ?? client).post<QueryDbSchemaResponse, QueryDbSchemaError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/reflection/query-db-schema' + }); + } + + /** + * Suggest Joins + */ + public static suggestJoins<ThrowOnError extends boolean = false>(options: Options<SuggestJoinsData, ThrowOnError>) { + return (options?.client ?? client).get<SuggestJoinsResponse, SuggestJoinsError, ThrowOnError>({ + ...options, + url: '/reflection/suggest-joins' + }); + } + + /** + * Probe Table + */ + public static probeTable<ThrowOnError extends boolean = false>(options: Options<ProbeTableData, ThrowOnError>) { + return (options?.client ?? client).post<ProbeTableResponse, ProbeTableError, ThrowOnError>({ + ...options, + url: '/reflection/probe-table' + }); + } + + /** + * Probe Db + */ + public static probeDb<ThrowOnError extends boolean = false>(options: Options<ProbeDbData, ThrowOnError>) { + return (options?.client ?? client).post<ProbeDbResponse, ProbeDbError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/reflection/probe-db' + }); + } + +} + +export class MitmService { + /** + * Validate Concept Mappings + */ + public static validateConceptMappings<ThrowOnError extends boolean = false>(options: Options<ValidateConceptMappingsData, ThrowOnError>) { + return (options?.client ?? client).post<ValidateConceptMappingsResponse, ValidateConceptMappingsError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/mitm/validate-concept-mappings' + }); + } + + /** + * Export Mitm + */ + public static exportMitm<ThrowOnError extends boolean = false>(options: Options<ExportMitmData, ThrowOnError>) { + return (options?.client ?? client).post<unknown, ExportMitmError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/mitm/export-mitm' + }); + } + + /** + * Publish Mitm Export + */ + public static publishMitmExport<ThrowOnError extends boolean = false>(options: Options<PublishMitmExportData, ThrowOnError>) { + return (options?.client ?? client).post<PublishMitmExportResponse, PublishMitmExportError, ThrowOnError>({ + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + }, + url: '/mitm/publish-mitm-export' + }); + } + + /** + * Delete Mitm Export + */ + public static deleteMitmExport<ThrowOnError extends boolean = false>(options: Options<DeleteMitmExportData, ThrowOnError>) { + return (options?.client ?? client).post<unknown, DeleteMitmExportError, ThrowOnError>({ + ...options, + url: '/mitm/delete-mitm-export' + }); + } + + /** + * Delete Mitm Exports + */ + public static deleteMitmExports<ThrowOnError extends boolean = false>(options: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).post<unknown, DeleteMitmExportsError, ThrowOnError>({ + ...options, + url: '/mitm/delete-mitm-exports' + }); + } + +} + +export class DefaultService { + /** + * Check Health + */ + public static checkHealth<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) { + return (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ + ...options, + url: '/health' + }); + } + +} \ No newline at end of file diff --git a/src/services/api-schema/types.gen.ts b/src/services/api-schema/types.gen.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b7ed82f97da508a64d4851d280345ab56583168 --- /dev/null +++ b/src/services/api-schema/types.gen.ts @@ -0,0 +1,1035 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type operation = 'add_column'; + +export const operation = { + ADD_COLUMN: 'add_column' +} as const; + +export type AddColumn = { + operation?: 'add_column'; + col_name: string; + value: unknown; + target_type: WrappedMITMDataType | string; +}; + +export type Body_connect_db_session_connect_db_post = { + db_url: string; +}; + +export type Body_raw_query_data_raw_query_post = { + query: string; +}; + +export type Body_upload_db_session_upload_db_post = { + /** + * Upload a sqlite db file here. + */ + sqlite: Blob | File; +}; + +export type CastColumn = { + operation?: 'cast_column'; + target_type: WrappedMITMDataType | string; +}; + +export type CategoricalSummaryStatistics = { + count: number; + unique: number; + top: string; + freq: number; +}; + +export type ColumnProperties = { + nullable: boolean; + unique: boolean; + part_of_pk: boolean; + part_of_fk: boolean; + part_of_index: boolean; + mitm_data_type: MITMDataType; +}; + +export type CompiledVirtualView = { + dialect: string; + compiled_sql: string; + columns: Array<string>; + column_dtypes: Array<WrappedMITMDataType | string>; + name: string; + schema_name: string; +}; + +export type ConceptKind = 'concrete' | 'abstract'; + +export const ConceptKind = { + CONCRETE: 'concrete', + ABSTRACT: 'abstract' +} as const; + +export type ConceptLevel = 'main' | 'sub' | 'weak'; + +export const ConceptLevel = { + MAIN: 'main', + SUB: 'sub', + WEAK: 'weak' +} as const; + +export type ConceptMapping = { + mitm: MITM; + concept: string; + base_table: TableIdentifier | [ + SourceDBType, + string, + string + ] | [ + string, + string + ]; + kind_col?: string | null; + type_col: string; + identity_columns?: { + [key: string]: string; + } | Array<string>; + inline_relations?: { + [key: string]: string; + } | Array<string>; + foreign_relations?: { + [key: string]: ForeignRelation; + }; + attributes?: Array<string>; + attribute_dtypes?: Array<MITMDataType>; +}; + +export type ConceptMappingRequest = { + mitm: MITM; + concept: string; + base_table: TableIdentifier | [ + SourceDBType, + string, + string + ] | [ + string, + string + ]; + kind_col?: string | null; + type_col: string; + identity_columns?: { + [key: string]: string; + } | Array<string>; + inline_relations?: { + [key: string]: string; + } | Array<string>; + foreign_relations?: { + [key: string]: ForeignRelation; + }; + attributes?: Array<string>; + attribute_dtypes?: Array<MITMDataType>; +}; + +export type ConceptProperties = { + nature: [ + ConceptLevel, + ConceptKind + ]; + key: string; + plural: string; + typing_concept?: string; + column_group_ordering?: Array<'kind' | 'type' | 'identity-relations' | 'inline-relations' | 'foreign-relations' | 'attributes'>; + permit_attributes?: boolean; +}; + +export type DBConnTestResponse = { + db_url: string; + success: boolean; + error?: string | null; +}; + +export type DBMetaInfoBase = { + db_structure: { + [key: string]: { + [key: string]: TableMetaInfoBase; + }; + }; + readonly tables: { + [key: string]: TableMetaInfoBase; + }; +}; + +export type DBMetaInfoResponse = { + db_structure: { + [key: string]: { + [key: string]: TableMetaInfoBase; + }; + }; + readonly tables: { + [key: string]: TableMetaInfoBase; + }; +}; + +export type DBMetaQuery = { + syntactic_table_conditions?: Array<SyntacticTableCondition>; + semantic_table_conditions?: Array<SemanticTableCondition>; + syntactic_column_conditions?: Array<SyntacticColumnCondition>; + semantic_column_conditions?: Array<SemanticColumnCondition>; +}; + +export type DBProbeResponse = { + table_probes?: { + [key: string]: TableProbeBase; + }; + db_meta: DBMetaInfoBase; +}; + +export type DBSchemaQueryRequest = { + query: DBMetaQuery; + filter_columns?: boolean; +}; + +export type DBSchemaSelectionRequest = { + selection: { + [key: string]: Array<string>; + } | { + [key: string]: { + [key: string]: Array<string>; + }; + }; + filter_columns?: boolean; +}; + +export type DatetimeSummaryStatistics = { + count: number; + mean?: string | null; + min?: string | null; + max?: string | null; + percentile_25?: string | null; + percentile_50?: string | null; + percentile_75?: string | null; +}; + +export type ERVariant = 'image' | 'mermaid'; + +export const ERVariant = { + IMAGE: 'image', + MERMAID: 'mermaid' +} as const; + +export type EditColumns = { + operation?: 'edit_columns'; + transforms?: { + [key: string]: { + operation?: 'cast_column'; + } & CastColumn; + }; + renames?: { + [key: string]: string; + }; + drops?: Array<string>; + additions?: { + [key: string]: Array<({ + operation?: 'add_column'; + } & AddColumn) | ({ + operation?: 'extract_json'; + } & ExtractJson)>; + }; +}; + +export type ExistingTable = { + operation?: 'existing'; + base_table: TableIdentifier | [ + SourceDBType, + string, + string + ] | [ + string, + string + ]; +}; + +export type ExtractJson = { + operation?: 'extract_json'; + json_col: string; + attributes: { + [key: string]: Array<string>; + }; +}; + +export type FKCreationRequest = { + name?: string | null; + table: LocalTableIdentifier | [ + string, + string + ]; + columns: Array<string>; + target_table: LocalTableIdentifier | [ + string, + string + ]; + target_columns: Array<string>; +}; + +export type FKCreationResponse = { + status: boolean; + error?: string | null; +}; + +export type ForeignKeyConstraintBase = { + name?: string | null; + table: LocalTableIdentifier | [ + string, + string + ]; + columns: Array<string>; + target_table: LocalTableIdentifier | [ + string, + string + ]; + target_columns: Array<string>; +}; + +export type ForeignRelation = { + fk_columns: { + [key: string]: string; + } | Array<string>; + referred_table: TableIdentifier | [ + SourceDBType, + string, + string + ] | [ + string, + string + ]; +}; + +export type ForeignRelationInfo = { + target_concept: string; + fk_relations: { + [key: string]: string; + }; +}; + +export type GroupValidationResult = { + individual_validations?: { + [key: string]: Array<[ + TableIdentifier, + IndividualValidationResult + ]>; + }; + readonly is_valid: boolean; +}; + +export type HTTPValidationError = { + detail?: Array<ValidationError>; +}; + +export type IndividualValidationResult = { + is_valid?: boolean; + violations?: Array<string>; +}; + +export type server_status = 'available'; + +export const server_status = { + AVAILABLE: 'available' +} as const; + +export type session_status = 'missing session cookie' | 'session invalid' | 'session valid'; + +export const session_status = { + MISSING_SESSION_COOKIE: 'missing session cookie', + SESSION_INVALID: 'session invalid', + SESSION_VALID: 'session valid' +} as const; + +export type KeepAliveResponse = { + server_status?: 'available'; + session_status: 'missing session cookie' | 'session invalid' | 'session valid'; +}; + +export type Limit = { + operation?: 'limit'; + limit: number; +}; + +export type LocalTableIdentifier = { + name: string; + schema?: string; +}; + +export type MITM = 'MAED' | 'OCEL2'; + +export const MITM = { + MAED: 'MAED', + OCEL2: 'OCEL2' +} as const; + +export type MITMDataType = 'text' | 'json' | 'integer' | 'numeric' | 'boolean' | 'datetime' | 'unknown' | 'infer'; + +export const MITMDataType = { + TEXT: 'text', + JSON: 'json', + INTEGER: 'integer', + NUMERIC: 'numeric', + BOOLEAN: 'boolean', + DATETIME: 'datetime', + UNKNOWN: 'unknown', + INFER: 'infer' +} as const; + +export type MITMDefinition = { + main_concepts: Array<string>; + weak_concepts: { + [key: string]: MITMDataType; + }; + sub_concepts: { + [key: string]: Array<string>; + }; + concept_relations: { + [key: string]: OwnedRelations; + }; + concept_properties: { + [key: string]: ConceptProperties; + }; + readonly leaf_concepts: Array<string>; + readonly abstract_concepts: Array<string>; + readonly parent_concepts_map: { + [key: string]: string; + }; +}; + +export type MappingExportRequest = { + mitm: MITM; + mapped_concepts: Array<ConceptMapping>; + post_processing?: PostProcessing | null; + filename?: string | null; +}; + +export type MappingGroupValidationResult = { + validation_result: GroupValidationResult; +}; + +export type MitMDataTypeInfo = { + sql_type: string | null; +}; + +export type NumericSummaryStatistics = { + count: number; + mean: number; + min: number; + max: number; + std?: number | null; + percentile_25: number; + percentile_50: number; + percentile_75: number; +}; + +export type OwnedRelations = { + identity: { + [key: string]: string; + }; + inline: { + [key: string]: string; + }; + foreign: { + [key: string]: ForeignRelationInfo; + }; +}; + +export type PostProcessing = { + table_postprocessing: Array<TablePostProcessing>; +}; + +export type PublishedMitMResponse = { + url: string; + relative_uri: string; + deletion_request_url: string; + export_id: number; +}; + +export type RawCompiled = { + operation?: 'raw'; + typed_query: TypedRawQuery; +}; + +export type ReselectColumns = { + operation?: 'reselect_columns'; + selection: Array<string>; +}; + +export type SampleSummary = { + sample_size?: number | null; + na_fraction?: number | null; + unique_fraction?: number | null; + value_counts?: { + [key: string]: number; + } | null; + summary_statistics?: NumericSummaryStatistics | CategoricalSummaryStatistics | DatetimeSummaryStatistics | null; + json_schema?: {} | null; +}; + +export type SemanticColumnCondition = { + inferred_data_type?: MITMDataType | null; + max_na_fraction?: number | null; + value_in_range?: unknown | null; + contained_value?: unknown | null; + contained_datetime?: string | null; +}; + +export type SemanticTableCondition = { + min_row_count?: number | null; + max_row_count?: number | null; +}; + +export type SessionIdResponse = { + session_id: string; +}; + +export type SimpleJoin = { + operation?: 'join'; + left_table: TableIdentifier | [ + SourceDBType, + string, + string + ] | [ + string, + string + ]; + right_table: TableIdentifier | [ + SourceDBType, + string, + string + ] | [ + string, + string + ]; + on_cols_left?: Array<string> | null; + on_cols_right?: Array<string> | null; + is_outer?: boolean; + full?: boolean; + selected_cols_left?: Array<string> | null; + selected_cols_right?: Array<string> | null; + left_alias?: string | null; + right_alias?: string | null; +}; + +export type SimpleSQLOperator = 'ilike' | 'like' | 'eq' | 'ge' | 'gt' | 'le' | 'lt' | 'in' | 'notin'; + +export const SimpleSQLOperator = { + ILIKE: 'ilike', + LIKE: 'like', + EQ: 'eq', + GE: 'ge', + GT: 'gt', + LE: 'le', + LT: 'lt', + IN: 'in', + NOTIN: 'notin' +} as const; + +export type SimpleWhere = { + lhs: string; + operator: SimpleSQLOperator; + rhs: string | [ + unknown, + WrappedMITMDataType | string + ]; +}; + +export type SourceDBType = 'original' | 'working' | 'virtual'; + +export const SourceDBType = { + ORIGINAL: 'original', + WORKING: 'working', + VIRTUAL: 'virtual' +} as const; + +export type SyntacticColumnCondition = { + name_regex?: string | null; + sql_data_type?: string | null; + mitm_data_type?: MITMDataType | null; +}; + +export type SyntacticTableCondition = { + schema_regex?: string | null; + name_regex?: string | null; + min_col_count?: number | null; + max_col_count?: number | null; + has_foreign_key?: boolean | null; +}; + +export type TableFilter = { + operation?: 'table_filter'; + wheres: Array<SimpleWhere>; + limit?: number | null; +}; + +export type TableIdentifier = { + source?: SourceDBType; + schema?: string; + name: string; +}; + +export type TableMetaInfoBase = { + schema_name?: string; + name: string; + columns: Array<string>; + sql_column_types: Array<string>; + primary_key?: Array<string> | null; + indexes?: Array<Array<string>> | null; + foreign_key_constraints?: Array<ForeignKeyConstraintBase>; + column_properties?: { + [key: string]: ColumnProperties; + }; +}; + +export type TableMetaInfoResponse = { + schema_name?: string; + name: string; + columns: Array<string>; + sql_column_types: Array<string>; + primary_key?: Array<string> | null; + indexes?: Array<Array<string>> | null; + foreign_key_constraints?: Array<ForeignKeyConstraintBase>; + column_properties?: { + [key: string]: ColumnProperties; + }; +}; + +export type TablePostProcessing = { + target_table: TableIdentifier | [ + SourceDBType, + string, + string + ] | [ + string, + string + ]; + transforms: Array<({ + operation?: 'edit_columns'; + } & EditColumns) | ({ + operation?: 'reselect_columns'; + } & ReselectColumns) | ({ + operation?: 'table_filter'; + } & TableFilter) | ({ + operation?: 'limit'; + } & Limit)>; +}; + +export type TableProbeBase = { + row_count: number; + inferred_types: { + [key: string]: MITMDataType; + }; + sample_summaries: { + [key: string]: SampleSummary; + }; + table_meta: TableMetaInfoBase; + sampled_values: { + [key: string]: Array<unknown>; + }; +}; + +export type TableProbeResponse = { + row_count: number; + inferred_types: { + [key: string]: MITMDataType; + }; + sample_summaries: { + [key: string]: SampleSummary; + }; + table_meta: TableMetaInfoBase; + sampled_values: { + [key: string]: Array<unknown>; + }; +}; + +export type TableQueryResult = { + table_info: TableMetaInfoResponse | null; + rows: Array<Array<unknown>>; +}; + +export type TypedRawQuery = { + dialect: string; + compiled_sql: string; + columns: Array<string>; + column_dtypes: Array<WrappedMITMDataType | string>; +}; + +export type ValidationError = { + loc: Array<string | number>; + msg: string; + type: string; +}; + +export type VirtualViewCreationRequest = { + name: string; + table_creation: ({ + operation?: 'join'; + } & SimpleJoin) | ({ + operation?: 'existing'; + } & ExistingTable) | ({ + operation?: 'raw'; + } & RawCompiled); + transforms?: Array<({ + operation?: 'edit_columns'; + } & EditColumns) | ({ + operation?: 'reselect_columns'; + } & ReselectColumns) | ({ + operation?: 'table_filter'; + } & TableFilter) | ({ + operation?: 'limit'; + } & Limit)> | null; + schema?: string; +}; + +export type VirtualViewResponse = { + table_meta: TableMetaInfoResponse; +}; + +export type WrappedMITMDataType = { + mitm: MITMDataType; +}; + +export type GetActiveSessionsResponse = { + [key: string]: string; +}; + +export type GetMitmsResponse = Array<MITM>; + +export type GetMitmDefinitionData = { + body?: never; + path?: never; + query: { + mitm: MITM; + }; +}; + +export type GetMitmDefinitionError = HTTPValidationError; + +export type GetMitmDefinitionResponse = MITMDefinition; + +export type GetMitmDataTypesResponse = { + [key: string]: MitMDataTypeInfo; +}; + +export type StartSessionResponse = SessionIdResponse; + +export type GetSessionError = HTTPValidationError; + +export type GetSessionResponse = SessionIdResponse; + +export type StopSessionError = HTTPValidationError; + +export type UploadDbData = { + body: Body_upload_db_session_upload_db_post; + path?: never; + query?: never; +}; + +export type UploadDbError = HTTPValidationError; + +export type ConnectDbData = { + body: Body_connect_db_session_connect_db_post; + path?: never; + query?: never; +}; + +export type ConnectDbError = HTTPValidationError; + +export type TestDbConnError = HTTPValidationError; + +export type TestDbConnResponse = DBConnTestResponse; + +export type KeepAliveResponse2 = KeepAliveResponse; + +export type ReflectDbError = HTTPValidationError; + +export type InitWorkingDbError = HTTPValidationError; + +export type MarkForeignKeyData = { + body: FKCreationRequest; + path?: never; + query?: { + source?: SourceDBType; + }; +}; + +export type MarkForeignKeyError = HTTPValidationError; + +export type MarkForeignKeyResponse = FKCreationResponse; + +export type DropVirtualViewData = { + body?: never; + path?: never; + query: { + view: string; + schema?: string; + }; +}; + +export type DropVirtualViewError = HTTPValidationError; + +export type GetVirtualViewData = { + body?: never; + path?: never; + query: { + view: string; + schema?: string; + }; +}; + +export type GetVirtualViewError = HTTPValidationError; + +export type GetVirtualViewResponse = VirtualViewResponse; + +export type CreateVirtualViewData = { + body: VirtualViewCreationRequest; + path?: never; + query?: { + override_if_exists?: boolean; + verify_immediately?: boolean; + }; +}; + +export type CreateVirtualViewError = HTTPValidationError; + +export type CreateVirtualViewResponse = VirtualViewResponse; + +export type GetVirtualViewsError = HTTPValidationError; + +export type GetVirtualViewsResponse = Array<VirtualViewResponse>; + +export type GetCompiledVirtualViewData = { + body?: never; + path?: never; + query: { + view: string; + schema?: string; + }; +}; + +export type GetCompiledVirtualViewError = HTTPValidationError; + +export type GetCompiledVirtualViewResponse = CompiledVirtualView; + +export type GetCompiledVirtualViewsError = HTTPValidationError; + +export type GetCompiledVirtualViewsResponse = Array<CompiledVirtualView>; + +export type CreateVirtualViewsBatchData = { + body: Array<VirtualViewCreationRequest>; + path?: never; + query?: { + override_if_exists?: boolean; + }; +}; + +export type CreateVirtualViewsBatchError = HTTPValidationError; + +export type CreateVirtualViewsBatchResponse = Array<VirtualViewResponse>; + +export type RawQueryData = { + body: Body_raw_query_data_raw_query_post; + path?: never; + query?: never; +}; + +export type RawQueryError = HTTPValidationError; + +export type RawQueryResponse = Array<Array<unknown>>; + +export type QueryTableData = { + body?: never; + path?: never; + query: { + name: string; + schema?: string; + source?: SourceDBType; + offset?: number | null; + limit?: number | null; + include_table_meta?: boolean; + }; +}; + +export type QueryTableError = HTTPValidationError; + +export type QueryTableResponse = TableQueryResult; + +export type QueryUniqueValuesData = { + body?: never; + path?: never; + query: { + table: string; + column: string; + schema?: string; + source?: SourceDBType; + }; +}; + +export type QueryUniqueValuesError = HTTPValidationError; + +export type QueryUniqueValuesResponse = Array<unknown>; + +export type MakeErdData = { + body?: never; + path?: never; + query?: { + version?: ERVariant; + source?: SourceDBType; + }; +}; + +export type MakeErdError = HTTPValidationError; + +export type MakeFilteredErdData = { + body: DBSchemaSelectionRequest; + path?: never; + query?: { + version?: ERVariant; + source?: SourceDBType; + }; +}; + +export type MakeFilteredErdError = HTTPValidationError; + +export type GetTableSchemaData = { + body?: never; + path?: never; + query: { + name: string; + schema?: string; + source?: SourceDBType; + }; +}; + +export type GetTableSchemaError = HTTPValidationError; + +export type GetTableSchemaResponse = TableMetaInfoResponse; + +export type GetDbSchemaData = { + body?: never; + path?: never; + query?: { + source?: SourceDBType; + }; +}; + +export type GetDbSchemaError = HTTPValidationError; + +export type GetDbSchemaResponse = DBMetaInfoResponse; + +export type FilterDbSchemaData = { + body: DBSchemaSelectionRequest; + path?: never; + query?: { + source?: SourceDBType; + }; +}; + +export type FilterDbSchemaError = HTTPValidationError; + +export type FilterDbSchemaResponse = DBMetaInfoResponse; + +export type QueryDbSchemaData = { + body: DBSchemaQueryRequest; + path?: never; + query?: { + store_intermediate_table_probes?: boolean; + source?: SourceDBType; + }; +}; + +export type QueryDbSchemaError = HTTPValidationError; + +export type QueryDbSchemaResponse = DBMetaInfoResponse; + +export type SuggestJoinsData = { + body?: never; + path?: never; + query: { + name: string; + schema?: string; + source?: SourceDBType; + }; +}; + +export type SuggestJoinsError = HTTPValidationError; + +export type SuggestJoinsResponse = Array<[ + string, + string +]>; + +export type ProbeTableData = { + body?: never; + path?: never; + query: { + name: string; + schema?: string; + source?: SourceDBType; + sample_size?: number; + override_if_exists?: boolean; + store_results?: boolean; + }; +}; + +export type ProbeTableError = HTTPValidationError; + +export type ProbeTableResponse = TableProbeResponse; + +export type ProbeDbData = { + body: { + [key: string]: Array<string>; + }; + path?: never; + query?: { + source?: SourceDBType; + sample_size?: number; + override_if_exists?: boolean; + store_results?: boolean; + }; +}; + +export type ProbeDbError = HTTPValidationError; + +export type ProbeDbResponse = DBProbeResponse; + +export type ValidateConceptMappingsData = { + body: Array<ConceptMappingRequest>; + path?: never; + query?: never; +}; + +export type ValidateConceptMappingsError = HTTPValidationError; + +export type ValidateConceptMappingsResponse = MappingGroupValidationResult; + +export type ExportMitmData = { + body: MappingExportRequest; + path?: never; + query?: never; +}; + +export type ExportMitmError = HTTPValidationError; + +export type PublishMitmExportData = { + body: MappingExportRequest; + path?: never; + query?: { + use_streaming_export?: boolean; + }; +}; + +export type PublishMitmExportError = HTTPValidationError; + +export type PublishMitmExportResponse = PublishedMitMResponse; + +export type DeleteMitmExportData = { + body?: never; + path?: never; + query: { + export_id: number; + }; +}; + +export type DeleteMitmExportError = HTTPValidationError; + +export type DeleteMitmExportsError = HTTPValidationError; \ No newline at end of file diff --git a/src/services/api.ts b/src/services/api.ts deleted file mode 100644 index 8ad54c15de1046ac6ea7c12734c580a3acf2af08..0000000000000000000000000000000000000000 --- a/src/services/api.ts +++ /dev/null @@ -1,290 +0,0 @@ -import {AxiosResponse, OpenAPIClientAxios, OpenAPIV3} from 'openapi-client-axios'; -import {Client as MyBackendClient} from './api-schema/openapi'; -import APISpec from './api-schema/openapi.json' -import type {Components, Paths} from './api-schema/openapi'; - -export type SourceDBType = Components.Schemas.SourceDBType; -export type KeepAliveResponse = Components.Schemas.KeepAliveResponse; -export type ColumnProperties = Components.Schemas.ColumnProperties; -export type SampleSummary = Components.Schemas.SampleSummary; - -export type ForeignKeyParameters = Paths.MarkForeignKey.QueryParameters; -export type VirtualViewParameters = Paths.GetVirtualView.QueryParameters; -export type DBSchemaParameters = Paths.GetDbSchema.QueryParameters; -export type TableSchemaParameters = Paths.GetTableSchema.QueryParameters; -export type TableQueryParameters = Paths.QueryTable.QueryParameters; -export type TableProbeParameters = Paths.ProbeTable.QueryParameters; -export type DBProbeParameters = Paths.ProbeDb.QueryParameters; -export type DBQueryParameters = Paths.QueryDbSchema.QueryParameters; -export type ERDParameters = Paths.MakeErd.QueryParameters; - -export type DBProbeBody = Paths.ProbeDb.RequestBody; -export type DBQueryBody = Paths.QueryDbSchema.RequestBody; -export type ERDBody = Paths.MakeFilteredErd.RequestBody; -export type VirtualViewCreationBody = Paths.CreateVirtualView.RequestBody; -export type ForeignKeyBody = Paths.MarkForeignKey.RequestBody; - -export type MitM = Components.Schemas.MITM; -export type MitMDefinition = Components.Schemas.MITMDefinition; -export type MitMDataType = Components.Schemas.MITMDataType; -export type WrappedMitMDataType = Components.Schemas.WrappedMITMDataType; -export type MitMDataTypesDict = Paths.GetMitmDataTypes.Responses.$200; - -export type VirtualViewCreation = Components.Schemas.VirtualViewCreationRequest; -export type CompiledVirtualView = Components.Schemas.CompiledVirtualView; -export type ConceptMapping = Components.Schemas.ConceptMappingInput; -export type MappingGroupValidationResult = Components.Schemas.MappingGroupValidationResult; -export type IndividualValidationResult = Components.Schemas.IndividualValidationResult; -export type ExportRequest = Components.Schemas.ExportRequest; -export type PublishedMitMResponse = Components.Schemas.PublishedMitMResponse; -export type TableMetaInfoResponse = Components.Schemas.TableMetaInfoBase; -export type DBMetaInfoResponse = Components.Schemas.DBMetaInfoBase; -export type TableProbeResponse = Components.Schemas.TableProbeBase; -export type DBProbeResponse = Components.Schemas.DBProbeBase; -export type VirtualViewResponse = Components.Schemas.VirtualViewResponse; - -export type TableIdentifier = Components.Schemas.TableIdentifier - -export namespace Mappings { - export type ConceptMapping = Components.Schemas.ConceptMappingInput - export type ConceptProperties = Components.Schemas.ConceptProperties - export type OwnedRelations = Components.Schemas.OwnedRelations - export type ForeignRelation = Components.Schemas.ForeignRelationInput - export type ForeignRelationInfo = Components.Schemas.ForeignRelationInfo - export type ForeignRelationDefs = { - [relationName: string] : ForeignRelationInfo - } -} - -export namespace Transforms { - export type EditColumns = Components.Schemas.EditColumns - export type ReselectColumns = Components.Schemas.ReselectColumns - export type CastColumn = Components.Schemas.CastColumn - export type SimpleWhere = Components.Schemas.SimpleWhere - export type Limit = Components.Schemas.Limit - export type TableFilter = Components.Schemas.TableFilter - export type ExistingTable = Components.Schemas.ExistingTable - export type RawCompiled = Components.Schemas.RawCompiled - export type TypedRawQuery = Components.Schemas.TypedRawQuery - export type SimpleJoin = Components.Schemas.SimpleJoin - export type SimpleSQLOperator = Components.Schemas.SimpleSQLOperator - - export type ExtractJson = Components.Schemas.ExtractJson - export type AddColumn = Components.Schemas.AddColumn - - export type Base = ExistingTable | SimpleJoin | RawCompiled - export type Transform = EditColumns | ReselectColumns | TableFilter | Limit - export type ColumnCreations = AddColumn | ExtractJson -} - -const backendUrl = (process.env.VITE_API_HOST ?? window.location.origin) + (process.env.VITE_API_PREFIX ?? '/api') // process.env.API_URL ?? 'http://localhost:8080' // import.meta.env?.VITE_API_URL || -console.log(`Using following (backend) API_URL: ${backendUrl}`) - -const openAPIClient = new OpenAPIClientAxios({ - definition: APISpec as OpenAPIV3.Document, - withServer: {url: backendUrl, description: 'Backend Server'}, - axiosConfigDefaults: {withCredentials: true} -}) -const client = openAPIClient.initSync<MyBackendClient>() - -function toParamList(params, type = 'query') { - if (!params) return null; - const paramList = [] - for (const [k, v] of Object.entries(params)) { - paramList.push({ - name: k, value: v, in: type - }) - } - return paramList -} - -function errorHandler(msg?) { - return err => { - console.log(msg ?? "Request failed:", err); - return null as undefined - } -} - -export async function getClient(): Promise<MyBackendClient> { - return await openAPIClient.getClient<MyBackendClient>() -} - -export async function keepAlive(){ - return await client.keep_alive().catch(errorHandler('API is unreachable')) -} - -async function startSession() { - return await client.start_session().catch(errorHandler()) -} - - -async function stopSession() { - return await client.stop_session().catch(errorHandler()) -} - -async function uploadDB(sqliteFile) { - const formData = new FormData(); - formData.append('sqlite', sqliteFile); - return await client.upload_db(null, formData as any).catch(errorHandler('Error uploading file')) - /* - const formData = new FormData(); - formData.append('sqlite', sqliteFile); - return apiConnection.post('/setup/upload-db', formData, { - headers: { - 'Content-Type': 'multipart/form-data', - }, - }) - */ -} - -async function connectDB(url: string) { - return await client.connect_db(null, {db_url: url}).catch(errorHandler('Error connecting to DB')) - //return apiConnection.post('/setup/connect-db', {'db_url': url}).catch(err => console.error('Error connecting to DB:', err)) -} - -async function testDBConn() { - return await client.test_db_conn().catch(errorHandler()) -} - -// - -async function getMitMs() { - return await client.get_mitms().catch(errorHandler()) -} - -async function getMitMDefinition(mitm: MitM) { - return await client.get_mitm_definition(toParamList({mitm})).catch(errorHandler()) -} - -async function getMitMDataTypes() { - return await client.get_mitm_data_types().catch(errorHandler()) -} - -// - -async function reflectDB() { - return await client.reflect_db().catch(errorHandler('Error reflecting DB schema')) -} - -async function getDBSchema(params?: DBSchemaParameters) { - return await client.get_db_schema(toParamList(params)).catch(errorHandler('Error retrieving DB schema')) -} - -async function getTableSchema(params: TableSchemaParameters) { - return await client.get_table_schema(toParamList(params)).catch(errorHandler('Error retrieving DB schema')) -} - -async function queryTable(params: TableQueryParameters) { - return await client.query_table(toParamList(params)).catch(errorHandler()) -} - -async function probeTable(params: TableProbeParameters) { - return await client.probe_table(toParamList(params)).catch(errorHandler()) -} - -async function probeDB(body: DBProbeBody, params?: DBProbeParameters) { - return await client.probe_db(toParamList(params), body).catch(errorHandler()) -} - -async function searchDB(body: DBQueryBody, params?: DBQueryParameters) { - return await client.query_db_schema(toParamList(params), body).catch(errorHandler()) -} - -async function makeERD(params: ERDParameters, body?: ERDBody) { - if (!body) - return await client.make_erd(toParamList(params)).catch(errorHandler()) - else - return await client.make_filtered_erd(toParamList(params), body).catch(errorHandler()) -} - -// - -async function markForeignKey(body: ForeignKeyBody, params?: ForeignKeyParameters) { - return await client.mark_foreign_key(toParamList(params), body).catch(errorHandler('Foreign key constraint could not be created')) -} - -async function createVirtualView(body: VirtualViewCreation, params?: Paths.CreateVirtualView.QueryParameters) { - return await client.create_virtual_view(toParamList(params), body).catch(errorHandler('Error creating virtual view')) -} - -async function createVirtualViewsBatch(body: VirtualViewCreation[], params?: Paths.CreateVirtualView.QueryParameters) { - return await client.create_virtual_views_batch(toParamList(params), body).catch(errorHandler('Error creating virtual views')) -} - -async function dropVirtualView(params: Paths.DropVirtualView.QueryParameters) { - return await client.drop_virtual_view(toParamList(params)).catch(errorHandler('Error dropping virtual view')) -} - -async function getCompiledView(params: Paths.GetCompiledVirtualView.QueryParameters) { - return await client.get_compiled_virtual_view(toParamList(params)).catch(errorHandler('Requested virtual view could not be compiled')) -} - -async function getCompiledViews() { - return await client.get_compiled_virtual_views().catch(errorHandler('Virtual views could not be compiled')) -} - -async function validateMappings(body: ConceptMapping[]) { - return await client.validate_concept_mappings(null, body).catch(errorHandler('Error validating MitM concept mappings')) -} - -// -async function exportMitM(body: ExportRequest) { - return await client.export_mitm(null, body, {responseType: "blob"}).catch(errorHandler('Error exporting MitM mapped dataset')) -} - -async function publishMitMExport(body: ExportRequest, use_streaming_export: boolean) { - return await client.publish_mitm_export(toParamList({use_streaming_export: use_streaming_export}), body).catch(errorHandler('Error publishing MitM mapped dataset export')) -} - -async function deleteMitMExport(exportID: number) { - return await client.delete_mitm_export(toParamList({export_id: exportID} as Paths.DeleteMitmExport.QueryParameters)).catch(errorHandler('Error deleting MitM dataset export')) -} - -async function deleteMitMExports() { - return await client.delete_mitm_exports().catch(errorHandler('Error deleting MitM dataset exports')) -} - -export default { - async install(app, options) { - app.config.globalProperties.$apiClient = client - app.provide('apiClient', client) - //provide('apiClient', client) - //app.config.globalProperties.$apiConnection = apiConnection - } -} - -export function useAPIClient() { - return client -} - -export function useAPI() { - return { - startSession, - stopSession, - getDBSchema, - uploadDB, - connectDB, - getMitMs, - getMitMDefinition, - getMitMDataTypes, - reflectDB, - testDBConn, - queryTable, - probeTable, - probeDB, - searchDB, - makeERD, - getTableSchema, - markForeignKey, - createVirtualView, - createVirtualViewsBatch, - dropVirtualView, - validateMappings, - exportMitM, - publishMitMExport, - deleteMitMExport, - deleteMitMExports, - getCompiledView, - getCompiledViews - } -}