sasat 0.22.4 → 0.22.6

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.
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
- const require_migrate = require("../migrate-BRNxkHCx.cjs");
2
+ const require_util = require("../util-C5Jevn5B.cjs");
3
+ const require_migrate = require("../migrate-BDE07ocG.cjs");
3
4
  let node_fs = require("node:fs");
4
- node_fs = require_migrate.__toESM(node_fs, 1);
5
+ node_fs = require_util.__toESM(node_fs, 1);
5
6
  let node_path = require("node:path");
6
- node_path = require_migrate.__toESM(node_path, 1);
7
+ node_path = require_util.__toESM(node_path, 1);
7
8
  let cac = require("cac");
8
9
  //#region src/cli/commands/createMigration.ts
9
10
  const getMigrationFile = (className) => `import { SasatMigration, MigrationStore } from "sasat";
@@ -23,8 +24,8 @@ const createMigrationFile = (migrationName) => {
23
24
  const date = /* @__PURE__ */ new Date();
24
25
  const pad = (val) => val.toString().padStart(2, "0");
25
26
  const fileName = date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) + `_` + pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + migrationName;
26
- const outDir = (0, node_path.join)(require_migrate.config().migration.dir);
27
- require_migrate.mkDirIfNotExist(outDir);
27
+ const outDir = (0, node_path.join)(require_util.config().migration.dir);
28
+ require_util.mkDirIfNotExist(outDir);
28
29
  node_fs.writeFileSync((0, node_path.join)(outDir, fileName) + ".ts", getMigrationFile(migrationName));
29
30
  return fileName;
30
31
  };
@@ -471,11 +472,11 @@ const serializeCreateTable = (str) => {
471
472
  //#endregion
472
473
  //#region src/cli/commands/dumpDb.ts
473
474
  const dumpDB = async () => {
474
- const con = require_migrate.getDbClient();
475
+ const con = require_util.getDbClient();
475
476
  try {
476
477
  const tables = await con.rawQuery("show tables").then((it) => it.flatMap((it) => Object.values(it)));
477
478
  const serialized = await Promise.all(tables.map((table) => {
478
- return con.rawQuery("show create table " + require_migrate.SqlString.escapeId(table)).then((it) => it[0]["Create Table"]).then(serializeCreateTable);
479
+ return con.rawQuery("show create table " + require_util.SqlString.escapeId(table)).then((it) => it[0]["Create Table"]).then(serializeCreateTable);
479
480
  }));
480
481
  const supportedTypes = Object.values(require_migrate.DBColumnTypes);
481
482
  const store = { tables: serialized.filter((it) => {
@@ -490,7 +491,7 @@ const dumpDB = async () => {
490
491
  }
491
492
  return true;
492
493
  }) };
493
- require_migrate.writeYmlFile(require_migrate.config().migration.dir, "initialSchema.yml", store);
494
+ require_util.writeYmlFile(require_util.config().migration.dir, "initialSchema.yml", store);
494
495
  } catch (e) {
495
496
  require_migrate.Console.error(e.message);
496
497
  throw e;
@@ -503,7 +504,7 @@ const dumpDB = async () => {
503
504
  async function getCurrentStore() {
504
505
  await require_migrate.compileMigrationFiles();
505
506
  const files = require_migrate.getMigrationFileNames();
506
- return (await require_migrate.createCurrentMigrationDataStore(files.find((it) => it === require_migrate.config().migration.target) || files[files.length - 1])).serialize();
507
+ return (await require_migrate.createCurrentMigrationDataStore(files.find((it) => it === require_util.config().migration.target) || files[files.length - 1])).serialize();
507
508
  }
508
509
  //#endregion
509
510
  //#region src/cli/commands/erDiagram.ts
@@ -513,7 +514,7 @@ const writeDiagram = async () => {
513
514
  const result = `erDiagram
514
515
  ${store.tables.map((it) => processTable(store, it)).join("\n")}
515
516
  `;
516
- node_fs.default.writeFileSync(node_path.default.join(require_migrate.config().migration.out, require_migrate.Directory.paths.GENERATED, "er-diagram.mermaid"), result);
517
+ node_fs.default.writeFileSync(node_path.default.join(require_util.config().migration.out, require_migrate.Directory.paths.GENERATED, "er-diagram.mermaid"), result);
517
518
  } catch (e) {
518
519
  require_migrate.Console.error(e.message);
519
520
  throw e;
@@ -549,12 +550,12 @@ const generate = async () => {
549
550
  try {
550
551
  await require_migrate.compileMigrationFiles();
551
552
  const files = require_migrate.getMigrationFileNames();
552
- const targetFile = files.find((it) => it === require_migrate.config().migration.target) || files[files.length - 1];
553
+ const targetFile = files.find((it) => it === require_util.config().migration.target) || files[files.length - 1];
553
554
  const store = await getCurrentStore();
554
555
  const storeHandler = new require_migrate.DataStoreHandler(store);
555
- require_migrate.writeCurrentSchema(store);
556
+ require_util.writeCurrentSchema(store);
556
557
  await new require_migrate.CodeGen_v2(storeHandler).generate();
557
- require_migrate.Console.success(`code generated. DIR: ${require_migrate.config().migration.out}\nmigration target: ${targetFile}`);
558
+ require_migrate.Console.success(`code generated. DIR: ${require_util.config().migration.out}\nmigration target: ${targetFile}`);
558
559
  } catch (e) {
559
560
  require_migrate.Console.error(e.message);
560
561
  throw e;
@@ -567,7 +568,7 @@ const init = () => {
567
568
  require_migrate.Console.error("sasat.yml already exist");
568
569
  return;
569
570
  }
570
- require_migrate.writeYmlFile("./", "sasat.yml", require_migrate.defaultConf);
571
+ require_util.writeYmlFile("./", "sasat.yml", require_util.defaultConf);
571
572
  require_migrate.Console.success("sasat.yml created");
572
573
  };
573
574
  //#endregion
@@ -582,7 +583,7 @@ const migrationBuild = async () => {
582
583
  const index = (0, cac.cac)();
583
584
  try {
584
585
  index.usage("yarn sasat <command> [options]\n").command("migrate", "execute migration").option("-g, --generateFiles", "migrate with generate files").option("-d, --dry", "dry run").option("-s, --silent", "do not print logs").option("-b, --skipBuild", "skip compile migration files").action(async (options) => {
585
- const client = require_migrate.getDbClient();
586
+ const client = require_util.getDbClient();
586
587
  await require_migrate.migrate(client, options).catch((e) => {
587
588
  console.error(e);
588
589
  process.exit(1);
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { A as writeYmlFile, C as Directory, E as defaultConf, O as mkDirIfNotExist, S as capitalizeFirstLetter, T as config, _ as Console, a as getDbClient, f as getMigrationFileNames, g as defaultGQLOption, h as columnTypeToGqlPrimitive, i as compileMigrationFiles, k as writeCurrentSchema, l as defaultColumnOption, n as DataStoreHandler, p as CodeGen_v2, r as createCurrentMigrationDataStore, t as migrate, u as SqlString, w as DBColumnTypes, x as camelize } from "../migrate-Cbj2OVbY.mjs";
2
+ import { _ as writeYmlFile, a as getDbClient, d as defaultConf, h as writeCurrentSchema, l as SqlString, p as mkDirIfNotExist, u as config } from "../util-Dkw5bD7a.mjs";
3
+ import { a as getMigrationFileNames, c as defaultColumnOption, d as DBColumnTypes, f as Console, i as compileMigrationFiles, l as defaultGQLOption, m as capitalizeFirstLetter, n as CodeGen_v2, o as DataStoreHandler, p as camelize, r as createCurrentMigrationDataStore, s as Directory, t as migrate, u as columnTypeToGqlPrimitive } from "../migrate-DnqBdQ6r.mjs";
3
4
  import * as fs$1 from "node:fs";
4
5
  import fs from "node:fs";
5
6
  import path, { join } from "node:path";
@@ -0,0 +1,42 @@
1
+ //#region src/util/type.d.ts
2
+ type NestedPartial<T> = { [K in keyof T]?: T[K] extends Array<infer R> ? Array<NestedPartial<R>> : NestedPartial<T[K]> };
3
+ //#endregion
4
+ //#region src/config/config.d.ts
5
+ interface SasatConfigDb {
6
+ host: string;
7
+ port: number;
8
+ user: string;
9
+ password?: string;
10
+ database: string;
11
+ ssl?: {
12
+ ca?: string[];
13
+ };
14
+ }
15
+ interface SasatConfigMigration {
16
+ table: string;
17
+ dir: string;
18
+ out: string;
19
+ target?: string;
20
+ db?: SasatConfigDb;
21
+ }
22
+ interface SasatConfigGenerator {
23
+ addJsExtToImportStatement: boolean;
24
+ gql: {
25
+ subscription: boolean;
26
+ };
27
+ }
28
+ interface SasatConfig {
29
+ db: SasatConfigDb;
30
+ migration: SasatConfigMigration;
31
+ generator: SasatConfigGenerator;
32
+ }
33
+ declare function setConfig(update: NestedPartial<SasatConfig>): SasatConfig;
34
+ //#endregion
35
+ //#region src/db/sql/expression/comparison.d.ts
36
+ type ComparisonOperators = "=" | ">" | "<" | ">=" | "<=" | "<>";
37
+ type AndOr = "AND" | "OR";
38
+ type ComparisonExpression<T> = Partial<{ [P in keyof T]: T[P] | [ComparisonOperators | "LIKE" | "NOT LIKE", T[P]] | ["BETWEEN", T[P], T[P]] | ["IN", ...T[P][]] | ["IS NULL"] | ["IS NOT NULL"] }> & {
39
+ __type?: AndOr;
40
+ };
41
+ //#endregion
42
+ export { NestedPartial as a, setConfig as i, ComparisonOperators as n, SasatConfig as r, ComparisonExpression as t };
@@ -0,0 +1,42 @@
1
+ //#region src/util/type.d.ts
2
+ type NestedPartial<T> = { [K in keyof T]?: T[K] extends Array<infer R> ? Array<NestedPartial<R>> : NestedPartial<T[K]> };
3
+ //#endregion
4
+ //#region src/config/config.d.ts
5
+ interface SasatConfigDb {
6
+ host: string;
7
+ port: number;
8
+ user: string;
9
+ password?: string;
10
+ database: string;
11
+ ssl?: {
12
+ ca?: string[];
13
+ };
14
+ }
15
+ interface SasatConfigMigration {
16
+ table: string;
17
+ dir: string;
18
+ out: string;
19
+ target?: string;
20
+ db?: SasatConfigDb;
21
+ }
22
+ interface SasatConfigGenerator {
23
+ addJsExtToImportStatement: boolean;
24
+ gql: {
25
+ subscription: boolean;
26
+ };
27
+ }
28
+ interface SasatConfig {
29
+ db: SasatConfigDb;
30
+ migration: SasatConfigMigration;
31
+ generator: SasatConfigGenerator;
32
+ }
33
+ declare function setConfig(update: NestedPartial<SasatConfig>): SasatConfig;
34
+ //#endregion
35
+ //#region src/db/sql/expression/comparison.d.ts
36
+ type ComparisonOperators = "=" | ">" | "<" | ">=" | "<=" | "<>";
37
+ type AndOr = "AND" | "OR";
38
+ type ComparisonExpression<T> = Partial<{ [P in keyof T]: T[P] | [ComparisonOperators | "LIKE" | "NOT LIKE", T[P]] | ["BETWEEN", T[P], T[P]] | ["IN", ...T[P][]] | ["IS NULL"] | ["IS NOT NULL"] }> & {
39
+ __type?: AndOr;
40
+ };
41
+ //#endregion
42
+ export { NestedPartial as a, setConfig as i, ComparisonOperators as n, SasatConfig as r, ComparisonExpression as t };
@@ -0,0 +1,35 @@
1
+ //#region src/db/connectors/dbClient.d.ts
2
+ type QueryResponse = Array<{
3
+ [key: string]: SqlValueType;
4
+ }>;
5
+ interface CommandResponse {
6
+ insertId: number;
7
+ affectedRows: number;
8
+ changedRows: number;
9
+ }
10
+ type SqlValueType = string | number | boolean | null;
11
+ interface SQLExecutor {
12
+ rawQuery(sql: string): Promise<QueryResponse>;
13
+ rawCommand(sql: string): Promise<CommandResponse>;
14
+ }
15
+ declare abstract class SQLClient implements SQLExecutor {
16
+ protected logger: (query: string) => void;
17
+ rawQuery(sql: string): Promise<QueryResponse>;
18
+ rawCommand(sql: string): Promise<CommandResponse>;
19
+ query(templateString: TemplateStringsArray, ...params: any[]): Promise<QueryResponse>;
20
+ command(templateString: TemplateStringsArray, ...params: any[]): Promise<CommandResponse>;
21
+ protected abstract execSql(sql: string): Promise<QueryResponse | CommandResponse>;
22
+ }
23
+ declare abstract class SQLTransaction extends SQLClient {
24
+ abstract commit(): Promise<void>;
25
+ abstract rollback(): Promise<void>;
26
+ }
27
+ declare abstract class DBClient extends SQLClient {
28
+ protected _released: boolean;
29
+ protected constructor(logger?: (query: string) => void);
30
+ isReleased(): boolean;
31
+ abstract transaction(): Promise<SQLTransaction>;
32
+ abstract release(): Promise<void>;
33
+ }
34
+ //#endregion
35
+ export { SQLExecutor as a, SQLClient as i, DBClient as n, SQLTransaction as o, QueryResponse as r, SqlValueType as s, CommandResponse as t };
@@ -0,0 +1,35 @@
1
+ //#region src/db/connectors/dbClient.d.ts
2
+ type QueryResponse = Array<{
3
+ [key: string]: SqlValueType;
4
+ }>;
5
+ interface CommandResponse {
6
+ insertId: number;
7
+ affectedRows: number;
8
+ changedRows: number;
9
+ }
10
+ type SqlValueType = string | number | boolean | null;
11
+ interface SQLExecutor {
12
+ rawQuery(sql: string): Promise<QueryResponse>;
13
+ rawCommand(sql: string): Promise<CommandResponse>;
14
+ }
15
+ declare abstract class SQLClient implements SQLExecutor {
16
+ protected logger: (query: string) => void;
17
+ rawQuery(sql: string): Promise<QueryResponse>;
18
+ rawCommand(sql: string): Promise<CommandResponse>;
19
+ query(templateString: TemplateStringsArray, ...params: any[]): Promise<QueryResponse>;
20
+ command(templateString: TemplateStringsArray, ...params: any[]): Promise<CommandResponse>;
21
+ protected abstract execSql(sql: string): Promise<QueryResponse | CommandResponse>;
22
+ }
23
+ declare abstract class SQLTransaction extends SQLClient {
24
+ abstract commit(): Promise<void>;
25
+ abstract rollback(): Promise<void>;
26
+ }
27
+ declare abstract class DBClient extends SQLClient {
28
+ protected _released: boolean;
29
+ protected constructor(logger?: (query: string) => void);
30
+ isReleased(): boolean;
31
+ abstract transaction(): Promise<SQLTransaction>;
32
+ abstract release(): Promise<void>;
33
+ }
34
+ //#endregion
35
+ export { SQLExecutor as a, SQLClient as i, DBClient as n, SQLTransaction as o, QueryResponse as r, SqlValueType as s, CommandResponse as t };
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_migrate = require("./migrate-BRNxkHCx.cjs");
3
- let sqlstring = require("sqlstring");
4
- sqlstring = require_migrate.__toESM(sqlstring, 1);
2
+ const require_util = require("./util-C5Jevn5B.cjs");
5
3
  let mysql2_promise = require("mysql2/promise");
4
+ let sqlstring = require("sqlstring");
5
+ sqlstring = require_util.__toESM(sqlstring, 1);
6
6
  //#region src/db/connectors/mysql/client.ts
7
- var MysqlClient = class extends require_migrate.DBClient {
7
+ var MysqlClient = class extends require_util.DBClient {
8
8
  async release() {}
9
9
  constructor(connectionOption, logger) {
10
10
  super(logger);
@@ -19,7 +19,7 @@ var MysqlClient = class extends require_migrate.DBClient {
19
19
  async transaction() {
20
20
  const connection = await this.getConnection();
21
21
  await connection.beginTransaction();
22
- return new require_migrate.MySqlTransaction(connection);
22
+ return new require_util.MySqlTransaction(connection);
23
23
  }
24
24
  async execSql(sql) {
25
25
  const connection = await this.getConnection();
@@ -60,14 +60,14 @@ const Sql = {
60
60
  case 1: return Sql.fn(expr);
61
61
  }
62
62
  },
63
- literal: (literal) => require_migrate.SqlString.escape(literal.value),
64
- fieldInCondition: (identifier) => require_migrate.SqlString.escapeId(identifier.table) + "." + require_migrate.SqlString.escapeId(identifier.name),
63
+ literal: (literal) => require_util.SqlString.escape(literal.value),
64
+ fieldInCondition: (identifier) => require_util.SqlString.escapeId(identifier.table) + "." + require_util.SqlString.escapeId(identifier.name),
65
65
  fieldInSelect: (identifier) => {
66
- const alias = identifier.alias && identifier.name !== identifier.alias ? " AS " + require_migrate.SqlString.escapeId(identifier.alias) : "";
67
- return require_migrate.SqlString.escapeId(identifier.table) + "." + require_migrate.SqlString.escapeId(identifier.name) + alias;
66
+ const alias = identifier.alias && identifier.name !== identifier.alias ? " AS " + require_util.SqlString.escapeId(identifier.alias) : "";
67
+ return require_util.SqlString.escapeId(identifier.table) + "." + require_util.SqlString.escapeId(identifier.name) + alias;
68
68
  },
69
69
  identifier: (ident) => {
70
- return require_migrate.SqlString.escapeId(ident.identifier);
70
+ return require_util.SqlString.escapeId(ident.identifier);
71
71
  },
72
72
  fn: (fn) => `${fn.fnName}(${fn.args.map(Sql.value).join(",")})${over(fn.over)}${fn.alias ? ` AS ${fn.alias}` : ""}`,
73
73
  value: (v) => {
@@ -84,7 +84,7 @@ const Sql = {
84
84
  if (type === "start") return "%" + value;
85
85
  return value + "%";
86
86
  };
87
- return `${Sql.value(expr.left)} ${operator} ${require_migrate.SqlString.escape(val(expr.right, expr.type))}`;
87
+ return `${Sql.value(expr.left)} ${operator} ${require_util.SqlString.escape(val(expr.right, expr.type))}`;
88
88
  },
89
89
  in: (expr) => {
90
90
  if ("right" in expr) return `${Sql.value(expr.left)} ${expr.operator} (${expr.right.map(Sql.value).join(", ")})`;
@@ -96,10 +96,10 @@ const Sql = {
96
96
  paren: (expr) => "(" + Sql.booleanValue(expr.expression) + ")",
97
97
  table: (table) => {
98
98
  if (!table.subquery) {
99
- if (table.alias === table.name) return require_migrate.SqlString.escapeId(table.name);
100
- return require_migrate.SqlString.escapeId(table.name) + " AS " + require_migrate.SqlString.escapeId(table.alias);
99
+ if (table.alias === table.name) return require_util.SqlString.escapeId(table.name);
100
+ return require_util.SqlString.escapeId(table.name) + " AS " + require_util.SqlString.escapeId(table.alias);
101
101
  }
102
- return `(${queryToSql(table.query)}) AS ${require_migrate.SqlString.escapeId(table.alias)}`;
102
+ return `(${queryToSql(table.query)}) AS ${require_util.SqlString.escapeId(table.alias)}`;
103
103
  },
104
104
  join: (join) => `${join.type ? join.type + " " : ""}JOIN ${Sql.table(join.table)} ON ` + Sql.booleanValue(join.conditions),
105
105
  booleanValue: (expr) => {
@@ -112,6 +112,7 @@ const Sql = {
112
112
  case 8: return Sql.in(expr);
113
113
  case 6: return Sql.isNull(expr);
114
114
  case 14: return Sql.exists(expr);
115
+ case 15: return expr.expr;
115
116
  }
116
117
  },
117
118
  exists: (expr) => {
@@ -182,7 +183,7 @@ const comparisonExpressionToSql = (exp) => {
182
183
  }
183
184
  if (value[0] === "BETWEEN") return `${column} BETWEEN ${sqlstring.escape(value[1])} AND ${sqlstring.escape(value[2])}`;
184
185
  if (Object.keys(Comparison).includes(value[0])) return `${column} ${value[0]} ${sqlstring.escape(value[1])}`;
185
- throw new require_migrate.SasatError("SQL PARSE ERROR");
186
+ throw new require_util.SasatError("SQL PARSE ERROR");
186
187
  }).join(` ${type} `);
187
188
  };
188
189
  //#endregion
@@ -210,65 +211,6 @@ var CompositeCondition = class CompositeCondition {
210
211
  }
211
212
  };
212
213
  //#endregion
213
- //#region src/migration/makeMutaion.ts
214
- const formatSubscription = (subscription) => {
215
- if (subscription === void 0 || subscription === false) return {
216
- enabled: false,
217
- subscriptionFilter: []
218
- };
219
- if (subscription === true) return {
220
- enabled: true,
221
- subscriptionFilter: []
222
- };
223
- return {
224
- enabled: subscription.enabled,
225
- subscriptionFilter: subscription.subscriptionFilter || []
226
- };
227
- };
228
- const formatOptions = (type, option) => ({
229
- type,
230
- noReFetch: option?.noRefetch || false,
231
- middlewares: option?.middlewares || [],
232
- contextFields: option?.contextFields || [],
233
- subscription: formatSubscription(option?.subscription)
234
- });
235
- const Mutations = {
236
- create: (options) => formatOptions("create", options),
237
- update: (options) => formatOptions("update", options),
238
- delete: (options) => formatOptions("delete", options)
239
- };
240
- //#endregion
241
- //#region src/migration/makeQuery.ts
242
- const single = (name, options) => ({
243
- type: "single",
244
- name,
245
- conditions: options?.conditions || [],
246
- middlewares: options?.middlewares || []
247
- });
248
- const listAll = (name, options) => ({
249
- type: "list-all",
250
- name,
251
- conditions: options?.conditions || [],
252
- middlewares: options?.middlewares || []
253
- });
254
- const paging = (name, options) => ({
255
- type: "list-paging",
256
- name,
257
- conditions: options?.conditions || [],
258
- middlewares: options?.middlewares || []
259
- });
260
- const primary = (middlewares = []) => ({
261
- type: "primary",
262
- conditions: [],
263
- middlewares
264
- });
265
- const Queries = {
266
- single,
267
- listAll,
268
- paging,
269
- primary
270
- };
271
- //#endregion
272
214
  //#region src/runtime/createTypeDef.ts
273
215
  const makeArgs = (args) => {
274
216
  if (!args || args.length === 0) return "";
@@ -294,7 +236,7 @@ const createTypeDef = (typeDefs, inputs) => {
294
236
  //#endregion
295
237
  //#region src/runtime/dsl/factory.ts
296
238
  const compound = (expr, operator) => {
297
- const active = expr.filter(require_migrate.nonNullable);
239
+ const active = expr.filter(require_util.nonNullable);
298
240
  if (active.length === 0) return conditions.eq(literal(1), literal(1));
299
241
  return active.reduce((acc, current) => ({
300
242
  kind: 4,
@@ -564,19 +506,19 @@ const makeParamsMiddleware = (update) => {
564
506
  };
565
507
  //#endregion
566
508
  //#region src/runtime/dsl/mutation/mutation.ts
567
- const escapeId = require_migrate.SqlString.escapeId;
509
+ const escapeId = require_util.SqlString.escapeId;
568
510
  const onDuplicateKeyUpdate = (columns) => {
569
511
  if (!columns || columns.length === 0) return "";
570
512
  return " ON DUPLICATE KEY UPDATE " + columns.map(escapeId).map((it) => `${it} = VALUES(${it})`).join(",");
571
513
  };
572
514
  const createToSql = (dsl, tableInfo) => {
573
515
  const map = tableInfo[dsl.table].columnMap;
574
- const values = dsl.entities.map((it) => `(${it.map((it) => require_migrate.SqlString.escape(it)).join(",")})`).join(",");
516
+ const values = dsl.entities.map((it) => `(${it.map((it) => require_util.SqlString.escape(it)).join(",")})`).join(",");
575
517
  return `INSERT ${dsl.ignore ? "IGNORE " : ""}INTO ${escapeId(dsl.table)}(${dsl.fields.map((it) => escapeId(map[it]))}) VALUES ${values} ${onDuplicateKeyUpdate(dsl.upsert)}`;
576
518
  };
577
519
  const updateToSql = (dsl, tableInfo) => {
578
520
  const map = tableInfo[dsl.table].columnMap;
579
- return `UPDATE ${escapeId(dsl.table)} SET ${dsl.values.map((it) => escapeId(map[it.field]) + " = " + require_migrate.SqlString.escape(it.value)).join(", ")} WHERE ${Sql.booleanValue(dsl.where)}`;
521
+ return `UPDATE ${escapeId(dsl.table)} SET ${dsl.values.map((it) => escapeId(map[it.field]) + " = " + require_util.SqlString.escape(it.value)).join(", ")} WHERE ${Sql.booleanValue(dsl.where)}`;
580
522
  };
581
523
  const deleteToSql = (dsl) => {
582
524
  return `DELETE FROM ${escapeId(dsl.table)} WHERE ${Sql.booleanValue(dsl.where)}`;
@@ -590,7 +532,7 @@ const joinToQueryResolveInfo = (parentTableAlias, property, fields, map, tableIn
590
532
  tableAlias: fields.tableAlias || info.table,
591
533
  isArray: info.array,
592
534
  keyAliases: tableInfo[info.table].identifiableFields,
593
- joins: Object.entries(fields.relations || {}).filter(([, value]) => value).map(([key, value]) => joinToQueryResolveInfo(info.table, key, value, map, tableInfo)).filter(require_migrate.nonNullable),
535
+ joins: Object.entries(fields.relations || {}).filter(([, value]) => value).map(([key, value]) => joinToQueryResolveInfo(info.table, key, value, map, tableInfo)).filter(require_util.nonNullable),
594
536
  property
595
537
  };
596
538
  };
@@ -599,7 +541,7 @@ const createQueryResolveInfo = (tableName, fields, map, tableInfo) => {
599
541
  tableAlias: fields.tableAlias || tableName,
600
542
  isArray: true,
601
543
  keyAliases: tableInfo[tableName].identifiableFields,
602
- joins: Object.entries(fields.relations || {}).filter(([, value]) => value).map(([key, value]) => joinToQueryResolveInfo(tableName, key, value, map, tableInfo)).filter(require_migrate.nonNullable),
544
+ joins: Object.entries(fields.relations || {}).filter(([, value]) => value).map(([key, value]) => joinToQueryResolveInfo(tableName, key, value, map, tableInfo)).filter(require_util.nonNullable),
603
545
  property: ""
604
546
  };
605
547
  };
@@ -671,7 +613,7 @@ const createQuery = (baseTableName, fields, options, tableInfo, relationMap, con
671
613
  table.tableAlias = tableAlias;
672
614
  tableCount++;
673
615
  const info = tableInfo[tableName];
674
- select.push(...require_migrate.unique([...table.fields.filter((it) => {
616
+ select.push(...require_util.unique([...table.fields.filter((it) => {
675
617
  return notTypeName(it) && info.columnMap[it];
676
618
  }), ...info.identifiableFields]).map((it) => {
677
619
  const realName = info.columnMap[it] || it;
@@ -685,8 +627,8 @@ const createQuery = (baseTableName, fields, options, tableInfo, relationMap, con
685
627
  parentTableAlias: tableAlias,
686
628
  childTableAlias: table.tableAlias || "t" + current,
687
629
  context
688
- }), table.joinOn), "LEFT");
689
- }).filter(require_migrate.nonNullable), tableAlias);
630
+ }), table.joinOn), table.joinType ?? "LEFT");
631
+ }).filter(require_util.nonNullable), tableAlias);
690
632
  };
691
633
  return {
692
634
  select,
@@ -697,7 +639,7 @@ const createQuery = (baseTableName, fields, options, tableInfo, relationMap, con
697
639
  const createPagingInnerQuery = (tableName, tableAlias, fields, option, tableInfo, relationMap) => {
698
640
  const map = tableInfo[tableName].columnMap;
699
641
  return {
700
- select: require_migrate.unique([
642
+ select: require_util.unique([
701
643
  ...tableInfo[tableName].identifiableKeys,
702
644
  ...Object.keys(fields.relations || {}).flatMap((key) => {
703
645
  return relationMap[tableName][key]?.requiredColumns || [];
@@ -726,7 +668,7 @@ const createPagingFieldQuery = ({ baseTableName, fields, queryOption, pagingOpti
726
668
  //#endregion
727
669
  //#region src/runtime/sasatDBDatasource.ts
728
670
  var SasatDBDatasource = class {
729
- constructor(client = require_migrate.getDbClient()) {
671
+ constructor(client = require_util.getDbClient()) {
730
672
  this.client = client;
731
673
  }
732
674
  async create(entity, option) {
@@ -863,33 +805,29 @@ const pagingOption = (option) => {
863
805
  };
864
806
  //#endregion
865
807
  exports.CompositeCondition = CompositeCondition;
866
- exports.Conditions = require_migrate.Conditions;
867
- exports.Mutations = Mutations;
868
808
  exports.MysqlClient = MysqlClient;
869
809
  exports.QExpr = QExpr;
870
- exports.Queries = Queries;
871
810
  exports.SasatDBDatasource = SasatDBDatasource;
872
811
  exports.Sql = Sql;
873
- exports.SqlString = require_migrate.SqlString;
874
- exports.assignDeep = require_migrate.assignDeep;
812
+ exports.SqlString = require_util.SqlString;
813
+ exports.assignDeep = require_util.assignDeep;
875
814
  exports.createTypeDef = createTypeDef;
876
815
  exports.dateOffset = dateOffset;
877
816
  exports.dateToDateString = dateToDateString;
878
817
  exports.dateToDatetimeString = dateToDatetimeString;
879
- exports.formatQuery = require_migrate.formatQuery;
818
+ exports.formatQuery = require_util.formatQuery;
880
819
  exports.getCurrentDateTimeString = getCurrentDateTimeString;
881
820
  exports.getDayRange = getDayRange;
882
821
  exports.getDayRangeQExpr = getDayRangeQExpr;
883
- exports.getDbClient = require_migrate.getDbClient;
822
+ exports.getDbClient = require_util.getDbClient;
884
823
  exports.getTodayDateString = getTodayDateString;
885
824
  exports.getTodayDateTimeString = getTodayDateTimeString;
886
825
  exports.gqlResolveInfoToField = gqlResolveInfoToField;
887
826
  exports.makeNumberIdEncoder = makeNumberIdEncoder;
888
827
  exports.makeParamsMiddleware = makeParamsMiddleware;
889
828
  exports.makeResolver = makeResolver;
890
- exports.migrate = require_migrate.migrate;
891
829
  exports.pagingOption = pagingOption;
892
- exports.pick = require_migrate.pick;
830
+ exports.pick = require_util.pick;
893
831
  exports.qe = QExpr;
894
832
  exports.queryToSql = queryToSql;
895
- exports.setConfig = require_migrate.setConfig;
833
+ exports.setConfig = require_util.setConfig;