Updates
This commit is contained in:
parent
16cc7bede5
commit
cf2cbe452b
@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = generateTypeDefinition;
|
||||
const slugify_1 = __importDefault(require("../../utils/slugify"));
|
||||
const default_fields_regexp_1 = __importDefault(require("./default-fields-regexp"));
|
||||
function generateTypeDefinition({ paradigm, table, query, typeDefName, allValuesOptional, addExport, dbName, }) {
|
||||
let typeDefinition = ``;
|
||||
@ -12,8 +13,8 @@ function generateTypeDefinition({ paradigm, table, query, typeDefName, allValues
|
||||
tdName = typeDefName
|
||||
? typeDefName
|
||||
: dbName
|
||||
? `DSQL_${dbName}_${table.tableName}`.toUpperCase()
|
||||
: `DSQL_${query.single}_${query.single_table}`.toUpperCase();
|
||||
? (0, slugify_1.default)(`DSQL_${dbName}_${table.tableName}`, "_").toUpperCase()
|
||||
: (0, slugify_1.default)(`DSQL_${query.single}_${query.single_table}`, "_").toUpperCase();
|
||||
const fields = table.fields;
|
||||
function typeMap(schemaType) {
|
||||
var _a, _b, _c;
|
||||
@ -45,6 +46,9 @@ function generateTypeDefinition({ paradigm, table, query, typeDefName, allValues
|
||||
typesArrayJavascript.push(`/**\n * @typedef {object} ${tdName}`);
|
||||
fields.forEach((field) => {
|
||||
var _a;
|
||||
if (field.fieldDescription) {
|
||||
typesArrayTypeScript.push(` /** \n * ${field.fieldDescription}\n */`);
|
||||
}
|
||||
const nullValue = allValuesOptional
|
||||
? "?"
|
||||
: ((_a = field.fieldName) === null || _a === void 0 ? void 0 : _a.match(default_fields_regexp_1.default))
|
||||
|
||||
@ -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
|
||||
}`
|
||||
}`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "5.7.47",
|
||||
"version": "5.7.48",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user