Bugfix
This commit is contained in:
parent
e6702c7f82
commit
ca65327527
@ -20,7 +20,7 @@ const createTable_1 = __importDefault(require("./utils/createTable"));
|
||||
const updateTable_1 = __importDefault(require("./utils/updateTable"));
|
||||
const dbHandler_1 = __importDefault(require("./utils/dbHandler"));
|
||||
const ejson_1 = __importDefault(require("../utils/ejson"));
|
||||
const grab_dir_names_1 = __importDefault(require("../../utils/backend/names/grab-dir-names"));
|
||||
const grab_dir_names_1 = __importDefault(require("../utils/backend/names/grab-dir-names"));
|
||||
/**
|
||||
* # Create database from Schema Function
|
||||
* @requires DSQL_DB_CONN - Gobal Variable for Datasquirel Database
|
||||
|
23
dist/package-shared/utils/backend/names/grab-dir-names.d.ts
vendored
Normal file
23
dist/package-shared/utils/backend/names/grab-dir-names.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import { DATASQUIREL_LoggedInUser, UserType } from "../../../types";
|
||||
type Param = {
|
||||
user?: DATASQUIREL_LoggedInUser | UserType;
|
||||
userId?: string | number | null;
|
||||
};
|
||||
export default function grabDirNames(param?: Param): {
|
||||
schemasDir: string;
|
||||
userDirPath: string | undefined;
|
||||
mainShemaJSONFilePath: string;
|
||||
mainDbTypeDefFile: string;
|
||||
tempDirName: string;
|
||||
defaultTableFieldsJSONFilePath: string;
|
||||
usersSchemaDir: string;
|
||||
userSchemaMainJSONFilePath: string | undefined;
|
||||
userPrivateMediaDir: string | undefined;
|
||||
userPrivateExportsDir: string | undefined;
|
||||
userPrivateSQLExportsDir: string | undefined;
|
||||
userPrivateTempSQLExportsDir: string | undefined;
|
||||
userPrivateTempJSONSchemaFilePath: string | undefined;
|
||||
userPrivateDbExportZipFileName: string;
|
||||
userPrivateDbExportZipFilePath: string | undefined;
|
||||
};
|
||||
export {};
|
66
dist/package-shared/utils/backend/names/grab-dir-names.js
vendored
Normal file
66
dist/package-shared/utils/backend/names/grab-dir-names.js
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
"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(appDir, `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;
|
||||
return {
|
||||
schemasDir,
|
||||
userDirPath,
|
||||
mainShemaJSONFilePath,
|
||||
mainDbTypeDefFile,
|
||||
tempDirName,
|
||||
defaultTableFieldsJSONFilePath,
|
||||
usersSchemaDir,
|
||||
userSchemaMainJSONFilePath,
|
||||
userPrivateMediaDir,
|
||||
userPrivateExportsDir,
|
||||
userPrivateSQLExportsDir,
|
||||
userPrivateTempSQLExportsDir,
|
||||
userPrivateTempJSONSchemaFilePath,
|
||||
userPrivateDbExportZipFileName,
|
||||
userPrivateDbExportZipFilePath,
|
||||
};
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
import noDatabaseDbHandler from "./utils/noDatabaseDbHandler";
|
||||
@ -8,7 +7,7 @@ import updateTable from "./utils/updateTable";
|
||||
import dbHandler from "./utils/dbHandler";
|
||||
import EJSON from "../utils/ejson";
|
||||
import { DSQL_DatabaseSchemaType } from "../types";
|
||||
import grabDirNames from "../../utils/backend/names/grab-dir-names";
|
||||
import grabDirNames from "../utils/backend/names/grab-dir-names";
|
||||
|
||||
type Param = {
|
||||
userId?: number | string | null;
|
||||
|
77
package-shared/utils/backend/names/grab-dir-names.ts
Normal file
77
package-shared/utils/backend/names/grab-dir-names.ts
Normal file
@ -0,0 +1,77 @@
|
||||
import { DATASQUIREL_LoggedInUser, UserType } from "../../../types";
|
||||
import path from "path";
|
||||
|
||||
type Param = {
|
||||
user?: DATASQUIREL_LoggedInUser | UserType;
|
||||
userId?: string | number | null;
|
||||
};
|
||||
export default function grabDirNames(param?: Param) {
|
||||
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.join(appDir, `package-shared`);
|
||||
|
||||
const mainDbTypeDefFile = path.join(appDir, `types/dsql.ts`);
|
||||
const mainShemaJSONFilePath = path.join(schemasDir, `main.json`);
|
||||
const defaultTableFieldsJSONFilePath = path.join(
|
||||
pakageSharedDir,
|
||||
`data/defaultFields.json`
|
||||
);
|
||||
|
||||
const usersSchemaDir = path.join(schemasDir, `users`);
|
||||
|
||||
const userDirPath = param?.user?.id
|
||||
? path.join(usersSchemaDir, `user-${param.user.id}`)
|
||||
: param?.userId
|
||||
? path.join(usersSchemaDir, `user-${param.userId}`)
|
||||
: undefined;
|
||||
const userSchemaMainJSONFilePath = userDirPath
|
||||
? path.join(userDirPath, `main.json`)
|
||||
: undefined;
|
||||
const userPrivateMediaDir = userDirPath
|
||||
? path.join(userDirPath, `media`)
|
||||
: undefined;
|
||||
const userPrivateExportsDir = userDirPath
|
||||
? path.join(userDirPath, `export`)
|
||||
: undefined;
|
||||
const userPrivateSQLExportsDir = userPrivateExportsDir
|
||||
? path.join(userPrivateExportsDir, `sql`)
|
||||
: undefined;
|
||||
const userPrivateTempSQLExportsDir = userPrivateSQLExportsDir
|
||||
? path.join(userPrivateSQLExportsDir, tempDirName)
|
||||
: undefined;
|
||||
const userPrivateTempJSONSchemaFilePath = userPrivateTempSQLExportsDir
|
||||
? path.join(userPrivateTempSQLExportsDir, `schema.json`)
|
||||
: undefined;
|
||||
const userPrivateDbExportZipFileName = `db-export.zip`;
|
||||
const userPrivateDbExportZipFilePath = userPrivateSQLExportsDir
|
||||
? path.join(userPrivateSQLExportsDir, userPrivateDbExportZipFileName)
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
schemasDir,
|
||||
userDirPath,
|
||||
mainShemaJSONFilePath,
|
||||
mainDbTypeDefFile,
|
||||
tempDirName,
|
||||
defaultTableFieldsJSONFilePath,
|
||||
usersSchemaDir,
|
||||
userSchemaMainJSONFilePath,
|
||||
userPrivateMediaDir,
|
||||
userPrivateExportsDir,
|
||||
userPrivateSQLExportsDir,
|
||||
userPrivateTempSQLExportsDir,
|
||||
userPrivateTempJSONSchemaFilePath,
|
||||
userPrivateDbExportZipFileName,
|
||||
userPrivateDbExportZipFilePath,
|
||||
};
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "4.0.6",
|
||||
"version": "4.0.7",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
Loading…
Reference in New Issue
Block a user