@technicity/data-service-generator 0.18.1 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -86,7 +86,7 @@ async function generate(input) {
|
|
|
86
86
|
]));
|
|
87
87
|
const artifacts = await getArtifacts(tables, includeMappedFields, specialCaseUuidColumn);
|
|
88
88
|
const artifactsSource = getArtifactsSource(artifacts);
|
|
89
|
-
const sdkSource = await getSDKSource(data, specialCaseUuidColumn, supplementClientOpts, artifacts);
|
|
89
|
+
const sdkSource = await getSDKSource(data, specialCaseUuidColumn, supplementClientOpts, artifacts, input.outputSqliteSchema);
|
|
90
90
|
const sdkFilename = "index.ts";
|
|
91
91
|
const sourceIRuntimeFilePath = fs.existsSync(path.join(__dirname, "../runtime", "IRuntime.ts"))
|
|
92
92
|
? path.join(__dirname, "../runtime", "IRuntime.ts")
|
|
@@ -214,7 +214,7 @@ function init(input) {
|
|
|
214
214
|
}
|
|
215
215
|
// It's a bit awkward to put __whereNeedsProcessing, __prepareWhere on the class,
|
|
216
216
|
// but it allows us to share the same database pool, clientOpts, etc.
|
|
217
|
-
async function getSDKSource(input, specialCaseUuidColumn, supplementClientOpts, artifacts) {
|
|
217
|
+
async function getSDKSource(input, specialCaseUuidColumn, supplementClientOpts, artifacts, outputSqliteSchema) {
|
|
218
218
|
function getTypeImports() {
|
|
219
219
|
let set = new Set();
|
|
220
220
|
for (let d of input) {
|
|
@@ -255,7 +255,9 @@ async function getSDKSource(input, specialCaseUuidColumn, supplementClientOpts,
|
|
|
255
255
|
}) {
|
|
256
256
|
let otherOpts = opts.otherOpts ?? {};
|
|
257
257
|
if (opts.clientOpts.filename === ":memory:") {
|
|
258
|
-
|
|
258
|
+
${outputSqliteSchema === true
|
|
259
|
+
? `otherOpts = { ...otherOpts, createTablesString: require("./artifacts.sqlite").schema }`
|
|
260
|
+
: `throw new Error("SQLite artifacts not available. Please regenerate the SDK with \`outputSqliteSchema: true\`.")`}
|
|
259
261
|
}
|
|
260
262
|
this.runtime = new opts.runtime(opts.clientOpts, ${supplementClientOpts === true
|
|
261
263
|
? "{ supplementClientOpts: true, ...otherOpts }"
|
|
@@ -27,7 +27,12 @@ exports.MySQL = void 0;
|
|
|
27
27
|
const mysql = __importStar(require("mysql2/promise"));
|
|
28
28
|
class MySQL {
|
|
29
29
|
constructor(opts) {
|
|
30
|
-
this.pool = mysql.createPool(
|
|
30
|
+
this.pool = mysql.createPool({
|
|
31
|
+
...opts,
|
|
32
|
+
// For backward compat with the previous mysql implementation https://github.com/mysqljs/mysql
|
|
33
|
+
// https://sidorares.github.io/node-mysql2/docs/documentation#known-incompatibilities-with-node-mysql
|
|
34
|
+
jsonStrings: true
|
|
35
|
+
});
|
|
31
36
|
if (opts.debug) {
|
|
32
37
|
this.pool.on("acquire", (connection) => {
|
|
33
38
|
console.log("Connection %d acquired", connection.threadId);
|