Updates
This commit is contained in:
@@ -23,6 +23,11 @@ const args = parseArgs({
|
||||
default: process.env.DSQL_DB_NAME,
|
||||
short: "d",
|
||||
},
|
||||
userid: {
|
||||
type: "string",
|
||||
default: process.env.DSQL_API_USER_ID,
|
||||
short: "i",
|
||||
},
|
||||
outfile: {
|
||||
type: "string",
|
||||
short: "o",
|
||||
@@ -58,11 +63,14 @@ if (args.values.envfile && typeof args.values.envfile == "string") {
|
||||
}
|
||||
|
||||
const finalEnv = { ...process.env, ...appendedEnv };
|
||||
process.env = { ...process.env, ...appendedEnv };
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const key = args.values.apiKey || finalEnv["DSQL_FULL_ACCESS_API_KEY"];
|
||||
const database = args.values.database || finalEnv["DSQL_DB_NAME"];
|
||||
const user_id =
|
||||
args.values.userid || finalEnv["DSQL_API_USER_ID"] || "1";
|
||||
|
||||
if (args.values.debug) {
|
||||
debugLog({
|
||||
@@ -91,15 +99,26 @@ const finalEnv = { ...process.env, ...appendedEnv };
|
||||
throw new Error("API key is required");
|
||||
if (!args.values.outfile || typeof args.values.outfile !== "string")
|
||||
throw new Error("Outfile are required");
|
||||
if (!user_id || typeof user_id !== "string")
|
||||
throw new Error("Outfile are required");
|
||||
|
||||
const schema = await datasquirel.getSchema({
|
||||
key,
|
||||
database,
|
||||
user_id: 1,
|
||||
user_id,
|
||||
});
|
||||
|
||||
const dbSchema = schema.payload as DSQL_DatabaseSchemaType | undefined;
|
||||
|
||||
if (args.values.debug) {
|
||||
debugLog({
|
||||
log: schema,
|
||||
label: "schema",
|
||||
title: "Schema to Typedef",
|
||||
addTime: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (!dbSchema) throw new Error("No schema found");
|
||||
|
||||
const definitions = dbSchemaToType({ dbSchema });
|
||||
|
||||
Reference in New Issue
Block a user