Updates
This commit is contained in:
Vendored
+1
@@ -44,6 +44,7 @@ function default_1() {
|
||||
(0, schema_to_typedef_1.default)({
|
||||
dbSchema: finaldbSchema,
|
||||
dst_file: out_file,
|
||||
config,
|
||||
});
|
||||
}
|
||||
console.log(`${chalk_1.default.bold(chalk_1.default.green(`DB Schema setup success!`))}`);
|
||||
|
||||
Vendored
+2
-1
@@ -25,7 +25,7 @@ function default_1() {
|
||||
.description("Build DB From Schema")
|
||||
.action((opts) => __awaiter(this, void 0, void 0, function* () {
|
||||
console.log(`Creating Type Definition From DB Schema ...`);
|
||||
const { config, dbSchema } = yield (0, init_1.default)();
|
||||
const { config, dbSchema } = (0, init_1.default)();
|
||||
const { ROOT_DIR } = (0, grab_dir_names_1.default)();
|
||||
const finaldbSchema = (0, append_default_fields_to_db_schema_1.default)({ dbSchema });
|
||||
if (config.typedef_file_path) {
|
||||
@@ -33,6 +33,7 @@ function default_1() {
|
||||
(0, schema_to_typedef_1.default)({
|
||||
dbSchema: finaldbSchema,
|
||||
dst_file: out_file,
|
||||
config,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
import type { NSQLITE_DatabaseSchemaType } from "../../types";
|
||||
import type { NSQLITE_DatabaseSchemaType, NSQLiteConfig } from "../../types";
|
||||
type Params = {
|
||||
dbSchema?: NSQLITE_DatabaseSchemaType;
|
||||
dbSchema: NSQLITE_DatabaseSchemaType;
|
||||
config: NSQLiteConfig;
|
||||
};
|
||||
export default function dbSchemaToType(params?: Params): string[] | undefined;
|
||||
export default function dbSchemaToType({ config, dbSchema, }: Params): string[] | undefined;
|
||||
export {};
|
||||
|
||||
+3
-3
@@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = dbSchemaToType;
|
||||
const lodash_1 = __importDefault(require("lodash"));
|
||||
const db_generate_type_defs_1 = __importDefault(require("./db-generate-type-defs"));
|
||||
function dbSchemaToType(params) {
|
||||
function dbSchemaToType({ config, dbSchema, }) {
|
||||
var _a;
|
||||
let datasquirelSchema = params === null || params === void 0 ? void 0 : params.dbSchema;
|
||||
let datasquirelSchema = dbSchema;
|
||||
if (!datasquirelSchema)
|
||||
return;
|
||||
let tableNames = `export const NSQLiteTables = [\n${datasquirelSchema.tables
|
||||
.map((tbl) => ` "${tbl.tableName}",`)
|
||||
.join("\n")}\n] as const`;
|
||||
const dbTablesSchemas = datasquirelSchema.tables;
|
||||
const defDbName = (_a = datasquirelSchema.dbName) === null || _a === void 0 ? void 0 : _a.toUpperCase().replace(/ |\-/g, "_");
|
||||
const defDbName = (_a = config.db_name) === null || _a === void 0 ? void 0 : _a.toUpperCase().replace(/ |\-/g, "_");
|
||||
const defNames = [];
|
||||
const schemas = dbTablesSchemas
|
||||
.map((table) => {
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
import type { NSQLITE_DatabaseSchemaType } from "../../types";
|
||||
import type { NSQLITE_DatabaseSchemaType, NSQLiteConfig } from "../../types";
|
||||
type Params = {
|
||||
dbSchema: NSQLITE_DatabaseSchemaType;
|
||||
dst_file: string;
|
||||
config: NSQLiteConfig;
|
||||
};
|
||||
export default function dbSchemaToTypeDef({ dbSchema, dst_file }: Params): void;
|
||||
export default function dbSchemaToTypeDef({ dbSchema, dst_file, config, }: Params): void;
|
||||
export {};
|
||||
|
||||
Vendored
+2
-2
@@ -7,11 +7,11 @@ exports.default = dbSchemaToTypeDef;
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const node_fs_1 = require("node:fs");
|
||||
const db_schema_to_typedef_1 = __importDefault(require("./db-schema-to-typedef"));
|
||||
function dbSchemaToTypeDef({ dbSchema, dst_file }) {
|
||||
function dbSchemaToTypeDef({ dbSchema, dst_file, config, }) {
|
||||
try {
|
||||
if (!dbSchema)
|
||||
throw new Error("No schema found");
|
||||
const definitions = (0, db_schema_to_typedef_1.default)({ dbSchema });
|
||||
const definitions = (0, db_schema_to_typedef_1.default)({ dbSchema, config });
|
||||
const ourfileDir = node_path_1.default.dirname(dst_file);
|
||||
if (!(0, node_fs_1.existsSync)(ourfileDir)) {
|
||||
(0, node_fs_1.mkdirSync)(ourfileDir, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user