This commit is contained in:
2026-02-13 18:53:31 +01:00
parent 16cc7bede5
commit cf2cbe452b
4 changed files with 28 additions and 14 deletions
@@ -15,7 +15,7 @@ export type HandleNodemailerParam = Mail.Options & {
* # Handle mails With Nodemailer
*/
export default async function handleNodemailer(
params: HandleNodemailerParam
params: HandleNodemailerParam,
): Promise<SMTPTransport.SentMessageInfo | boolean | undefined> {
if (
!process.env.DSQL_MAIL_HOST ||
@@ -1,4 +1,5 @@
import { DSQL_FieldSchemaType, DSQL_TableSchemaType } from "../../types";
import slugify from "../../utils/slugify";
import defaultFieldsRegexp from "./default-fields-regexp";
type Param = {
@@ -27,8 +28,11 @@ export default function generateTypeDefinition({
tdName = typeDefName
? typeDefName
: dbName
? `DSQL_${dbName}_${table.tableName}`.toUpperCase()
: `DSQL_${query.single}_${query.single_table}`.toUpperCase();
? slugify(`DSQL_${dbName}_${table.tableName}`, "_").toUpperCase()
: slugify(
`DSQL_${query.single}_${query.single_table}`,
"_",
).toUpperCase();
const fields = table.fields;
@@ -39,7 +43,7 @@ export default function generateTypeDefinition({
schemaType.dataType?.match(/int/i) ||
typeof opt == "number"
? `${opt}`
: `"${opt}"`
: `"${opt}"`,
)
.join(" | ");
}
@@ -63,27 +67,33 @@ export default function generateTypeDefinition({
const typesArrayJavascript = [];
typesArrayTypeScript.push(
`${addExport ? "export " : ""}type ${tdName} = {`
`${addExport ? "export " : ""}type ${tdName} = {`,
);
typesArrayJavascript.push(`/**\n * @typedef {object} ${tdName}`);
fields.forEach((field) => {
if (field.fieldDescription) {
typesArrayTypeScript.push(
` /** \n * ${field.fieldDescription}\n */`,
);
}
const nullValue = allValuesOptional
? "?"
: field.fieldName?.match(defaultFieldsRegexp)
? "?"
: field.notNullValue
? ""
: "?";
? "?"
: field.notNullValue
? ""
: "?";
typesArrayTypeScript.push(
` ${field.fieldName}${nullValue}: ${typeMap(field)};`
` ${field.fieldName}${nullValue}: ${typeMap(field)};`,
);
typesArrayJavascript.push(
` * @property {${typeMap(field)}${nullValue}} ${
field.fieldName
}`
}`,
);
});