"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setSchemaDataToGlobalAsync = void 0;
exports.setSchemaDataToGlobal = setSchemaDataToGlobal;
exports.getTableSchema = getTableSchema;
exports.getSystemSchema = getSystemSchema;
const systemSchema_json_1 = __importDefault(require("../json/systemSchema.json"));
const util_1 = require("util");
const databases_ts_1 = require("../resources/databases.js");
exports.setSchemaDataToGlobalAsync = (0, util_1.promisify)(setSchemaDataToGlobal);
function setSchemaDataToGlobal(callback) {
    global.hdb_schema = (0, databases_ts_1.getDatabases)();
    if (callback)
        callback();
}
function getTableSchema(schemaName, tableName, callback) {
    const database = (0, databases_ts_1.getDatabases)()[schemaName];
    if (!database) {
        return callback(`schema ${schemaName} does not exist`);
    }
    const table = database[tableName];
    if (!table) {
        return callback(`table ${schemaName}.${tableName} does not exist`);
    }
    return callback(null, {
        schema: schemaName,
        name: tableName,
        hash_attribute: table.primaryKey,
    });
}
function getSystemSchema() {
    return systemSchema_json_1.default;
}
//# sourceMappingURL=globalSchema.js.map