/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@rkesters/schemats@7.0.1/src/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Options=exports.getDatabase=exports.typescriptOfSchema=exports.typescriptOfTable=void 0;const typescript_1=require("./typescript"),schema_1=require("./schema"),options_1=require("./options");exports.Options=options_1.default;const pkgVersion=require("../package.json").version;function getTime(){let e=e=>`0${e}`.slice(-2),t=new Date;return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())} ${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}`}function buildHeader(e,t,s,r){let a=["schemats","generate","-c",e.connectionString.replace(/:\/\/.*@/,"://username:password@")];return r.camelCase&&a.push("-C"),t.length>0&&t.forEach((e=>{a.push("-t",e)})),s&&a.push("-s",s),`\n        /**\n         * AUTO-GENERATED FILE @ ${getTime()} - DO NOT EDIT!\n         *\n         * This file was automatically generated by schemats v.${pkgVersion}\n         * $ ${a.join(" ")}\n         *\n         */\n\n    `}async function typescriptOfTable(e,t,s,r){"string"==typeof e&&(e=schema_1.getDatabase(e,r.options));let a="",n=await e.getTableTypes(t,s,r);return r.options.tableNamespaces?(a+=typescript_1.generateTableTypes(t,n,r),a+=typescript_1.generateTableInterface(t,n,r)):a+=typescript_1.generateTableInterfaceOnly(t,n,r),a}async function typescriptOfSchema(e,t=[],s=null,r={}){var a;"string"==typeof e&&(e=schema_1.getDatabase(e,r)),s||(s=e.getDefaultSchema()),0===t.length&&(t=await e.getSchemaTables(s)),(null===(a=r.skipTables)||void 0===a?void 0:a.length)&&(t=t.filter((e=>{var t;return!(null===(t=r.skipTables)||void 0===t?void 0:t.includes(e))})));const n=new options_1.default(r),i=typescript_1.generateEnumType(await e.getEnumTypes(s),n),p=t.map((t=>typescriptOfTable(e,t,s,n))),o=await Promise.all(p).then((e=>e.join("")));let c="";if(n.options.customHeader?(c+=n.options.customHeader,c+="\n"):(c+="/* tslint:disable */\n\n",n.options.writeHeader&&(c+=buildHeader(e,t,s,r))),c+=i,c+=o,n.options.prettier)try{return(await Promise.resolve().then((()=>require("prettier")))).format(c,Object.assign({parser:"typescript"},n.options.prettierConfig||{}))}catch(e){throw new Error("Install prettier as a devDependency, or pass prettier:false to the schemats options")}return c}exports.typescriptOfTable=typescriptOfTable,exports.typescriptOfSchema=typescriptOfSchema;var schema_2=require("./schema");Object.defineProperty(exports,"getDatabase",{enumerable:!0,get:function(){return schema_2.getDatabase}});
//# sourceMappingURL=/sm/d418fc8532b84f83b5b2c7d795d3bc28027a994150afb41e7e80a9ee187cbeab.map