73 lines
3.3 KiB
JavaScript
73 lines
3.3 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.default = grabDirNames;
|
|
const path_1 = __importDefault(require("path"));
|
|
function grabDirNames(param) {
|
|
var _a;
|
|
const appDir = process.env.DSQL_APP_DIR;
|
|
const schemasDir = process.env.DSQL_DB_SCHEMA_DIR;
|
|
const tempDirName = ".tmp";
|
|
if (!appDir)
|
|
throw new Error("Please provide the `DSQL_APP_DIR` env variable.");
|
|
if (!schemasDir)
|
|
throw new Error("Please provide the `DSQL_DB_SCHEMA_DIR` env variable.");
|
|
const pakageSharedDir = path_1.default.join(appDir, `package-shared`);
|
|
const mainDbTypeDefFile = path_1.default.join(pakageSharedDir, `types/dsql.ts`);
|
|
const mainShemaJSONFilePath = path_1.default.join(schemasDir, `main.json`);
|
|
const defaultTableFieldsJSONFilePath = path_1.default.join(pakageSharedDir, `data/defaultFields.json`);
|
|
const usersSchemaDir = path_1.default.join(schemasDir, `users`);
|
|
const userDirPath = ((_a = param === null || param === void 0 ? void 0 : param.user) === null || _a === void 0 ? void 0 : _a.id)
|
|
? path_1.default.join(usersSchemaDir, `user-${param.user.id}`)
|
|
: (param === null || param === void 0 ? void 0 : param.userId)
|
|
? path_1.default.join(usersSchemaDir, `user-${param.userId}`)
|
|
: undefined;
|
|
const userSchemaMainJSONFilePath = userDirPath
|
|
? path_1.default.join(userDirPath, `main.json`)
|
|
: undefined;
|
|
const userPrivateMediaDir = userDirPath
|
|
? path_1.default.join(userDirPath, `media`)
|
|
: undefined;
|
|
const userPrivateExportsDir = userDirPath
|
|
? path_1.default.join(userDirPath, `export`)
|
|
: undefined;
|
|
const userPrivateSQLExportsDir = userPrivateExportsDir
|
|
? path_1.default.join(userPrivateExportsDir, `sql`)
|
|
: undefined;
|
|
const userPrivateTempSQLExportsDir = userPrivateSQLExportsDir
|
|
? path_1.default.join(userPrivateSQLExportsDir, tempDirName)
|
|
: undefined;
|
|
const userPrivateTempJSONSchemaFilePath = userPrivateTempSQLExportsDir
|
|
? path_1.default.join(userPrivateTempSQLExportsDir, `schema.json`)
|
|
: undefined;
|
|
const userPrivateDbExportZipFileName = `db-export.zip`;
|
|
const userPrivateDbExportZipFilePath = userPrivateSQLExportsDir
|
|
? path_1.default.join(userPrivateSQLExportsDir, userPrivateDbExportZipFileName)
|
|
: undefined;
|
|
const userPrivateDbImportZipFileName = `db-export.zip`;
|
|
const userPrivateDbImportZipFilePath = userPrivateSQLExportsDir
|
|
? path_1.default.join(userPrivateSQLExportsDir, userPrivateDbImportZipFileName)
|
|
: undefined;
|
|
return {
|
|
schemasDir,
|
|
userDirPath,
|
|
mainShemaJSONFilePath,
|
|
mainDbTypeDefFile,
|
|
tempDirName,
|
|
defaultTableFieldsJSONFilePath,
|
|
usersSchemaDir,
|
|
userSchemaMainJSONFilePath,
|
|
userPrivateMediaDir,
|
|
userPrivateExportsDir,
|
|
userPrivateSQLExportsDir,
|
|
userPrivateTempSQLExportsDir,
|
|
userPrivateTempJSONSchemaFilePath,
|
|
userPrivateDbExportZipFileName,
|
|
userPrivateDbExportZipFilePath,
|
|
userPrivateDbImportZipFileName,
|
|
userPrivateDbImportZipFilePath,
|
|
};
|
|
}
|