import path from "path"; import queryDSQLAPI from "../../functions/api/query-dsql-api"; import { APIConnectionOptions, APIResponseObject, DSQL_DatabaseSchemaType, DSQL_FieldSchemaType, DSQL_TableSchemaType, } from "../../types"; import grabAPIBasePath from "../../utils/grab-api-base-path"; import { GrabHostNamesReturn } from "../../utils/grab-host-names"; type Params = { dbName: string; tableName?: string; fieldName?: string; apiKey?: string; apiConnectionConfig?: APIConnectionOptions; grabbedHostnames?: GrabHostNamesReturn; useDefault?: boolean; }; export default async function < T extends | DSQL_DatabaseSchemaType | DSQL_TableSchemaType | DSQL_FieldSchemaType = DSQL_DatabaseSchemaType >({ dbName, tableName, apiKey, useDefault, fieldName, apiConnectionConfig, grabbedHostnames, }: Params): Promise> { const basePath = grabAPIBasePath({ paradigm: "schema" }); const finalPath = path.join( basePath, dbName, tableName || "", fieldName || "" ); const GET_RES = await queryDSQLAPI({ method: "GET", path: finalPath, apiKey, useDefault, apiConnectionConfig, grabbedHostnames, }); return GET_RES; }