sasat 0.22.3 → 0.22.5

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) => {
@@ -182,7 +182,7 @@ const comparisonExpressionToSql = (exp) => {
182
182
  }
183
183
  if (value[0] === "BETWEEN") return `${column} BETWEEN ${sqlstring.escape(value[1])} AND ${sqlstring.escape(value[2])}`;
184
184
  if (Object.keys(Comparison).includes(value[0])) return `${column} ${value[0]} ${sqlstring.escape(value[1])}`;
185
- throw new require_migrate.SasatError("SQL PARSE ERROR");
185
+ throw new require_util.SasatError("SQL PARSE ERROR");
186
186
  }).join(` ${type} `);
187
187
  };
188
188
  //#endregion
@@ -210,65 +210,6 @@ var CompositeCondition = class CompositeCondition {
210
210
  }
211
211
  };
212
212
  //#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
213
  //#region src/runtime/createTypeDef.ts
273
214
  const makeArgs = (args) => {
274
215
  if (!args || args.length === 0) return "";
@@ -294,7 +235,7 @@ const createTypeDef = (typeDefs, inputs) => {
294
235
  //#endregion
295
236
  //#region src/runtime/dsl/factory.ts
296
237
  const compound = (expr, operator) => {
297
- const active = expr.filter(require_migrate.nonNullable);
238
+ const active = expr.filter(require_util.nonNullable);
298
239
  if (active.length === 0) return conditions.eq(literal(1), literal(1));
299
240
  return active.reduce((acc, current) => ({
300
241
  kind: 4,
@@ -564,19 +505,19 @@ const makeParamsMiddleware = (update) => {
564
505
  };
565
506
  //#endregion
566
507
  //#region src/runtime/dsl/mutation/mutation.ts
567
- const escapeId = require_migrate.SqlString.escapeId;
508
+ const escapeId = require_util.SqlString.escapeId;
568
509
  const onDuplicateKeyUpdate = (columns) => {
569
510
  if (!columns || columns.length === 0) return "";
570
511
  return " ON DUPLICATE KEY UPDATE " + columns.map(escapeId).map((it) => `${it} = VALUES(${it})`).join(",");
571
512
  };
572
513
  const createToSql = (dsl, tableInfo) => {
573
514
  const map = tableInfo[dsl.table].columnMap;
574
- const values = dsl.entities.map((it) => `(${it.map((it) => require_migrate.SqlString.escape(it)).join(",")})`).join(",");
515
+ const values = dsl.entities.map((it) => `(${it.map((it) => require_util.SqlString.escape(it)).join(",")})`).join(",");
575
516
  return `INSERT ${dsl.ignore ? "IGNORE " : ""}INTO ${escapeId(dsl.table)}(${dsl.fields.map((it) => escapeId(map[it]))}) VALUES ${values} ${onDuplicateKeyUpdate(dsl.upsert)}`;
576
517
  };
577
518
  const updateToSql = (dsl, tableInfo) => {
578
519
  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)}`;
520
+ 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
521
  };
581
522
  const deleteToSql = (dsl) => {
582
523
  return `DELETE FROM ${escapeId(dsl.table)} WHERE ${Sql.booleanValue(dsl.where)}`;
@@ -590,7 +531,7 @@ const joinToQueryResolveInfo = (parentTableAlias, property, fields, map, tableIn
590
531
  tableAlias: fields.tableAlias || info.table,
591
532
  isArray: info.array,
592
533
  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),
534
+ joins: Object.entries(fields.relations || {}).filter(([, value]) => value).map(([key, value]) => joinToQueryResolveInfo(info.table, key, value, map, tableInfo)).filter(require_util.nonNullable),
594
535
  property
595
536
  };
596
537
  };
@@ -599,7 +540,7 @@ const createQueryResolveInfo = (tableName, fields, map, tableInfo) => {
599
540
  tableAlias: fields.tableAlias || tableName,
600
541
  isArray: true,
601
542
  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),
543
+ joins: Object.entries(fields.relations || {}).filter(([, value]) => value).map(([key, value]) => joinToQueryResolveInfo(tableName, key, value, map, tableInfo)).filter(require_util.nonNullable),
603
544
  property: ""
604
545
  };
605
546
  };
@@ -671,7 +612,7 @@ const createQuery = (baseTableName, fields, options, tableInfo, relationMap, con
671
612
  table.tableAlias = tableAlias;
672
613
  tableCount++;
673
614
  const info = tableInfo[tableName];
674
- select.push(...require_migrate.unique([...table.fields.filter((it) => {
615
+ select.push(...require_util.unique([...table.fields.filter((it) => {
675
616
  return notTypeName(it) && info.columnMap[it];
676
617
  }), ...info.identifiableFields]).map((it) => {
677
618
  const realName = info.columnMap[it] || it;
@@ -686,7 +627,7 @@ const createQuery = (baseTableName, fields, options, tableInfo, relationMap, con
686
627
  childTableAlias: table.tableAlias || "t" + current,
687
628
  context
688
629
  }), table.joinOn), "LEFT");
689
- }).filter(require_migrate.nonNullable), tableAlias);
630
+ }).filter(require_util.nonNullable), tableAlias);
690
631
  };
691
632
  return {
692
633
  select,
@@ -697,7 +638,7 @@ const createQuery = (baseTableName, fields, options, tableInfo, relationMap, con
697
638
  const createPagingInnerQuery = (tableName, tableAlias, fields, option, tableInfo, relationMap) => {
698
639
  const map = tableInfo[tableName].columnMap;
699
640
  return {
700
- select: require_migrate.unique([
641
+ select: require_util.unique([
701
642
  ...tableInfo[tableName].identifiableKeys,
702
643
  ...Object.keys(fields.relations || {}).flatMap((key) => {
703
644
  return relationMap[tableName][key]?.requiredColumns || [];
@@ -726,7 +667,7 @@ const createPagingFieldQuery = ({ baseTableName, fields, queryOption, pagingOpti
726
667
  //#endregion
727
668
  //#region src/runtime/sasatDBDatasource.ts
728
669
  var SasatDBDatasource = class {
729
- constructor(client = require_migrate.getDbClient()) {
670
+ constructor(client = require_util.getDbClient()) {
730
671
  this.client = client;
731
672
  }
732
673
  async create(entity, option) {
@@ -863,33 +804,29 @@ const pagingOption = (option) => {
863
804
  };
864
805
  //#endregion
865
806
  exports.CompositeCondition = CompositeCondition;
866
- exports.Conditions = require_migrate.Conditions;
867
- exports.Mutations = Mutations;
868
807
  exports.MysqlClient = MysqlClient;
869
808
  exports.QExpr = QExpr;
870
- exports.Queries = Queries;
871
809
  exports.SasatDBDatasource = SasatDBDatasource;
872
810
  exports.Sql = Sql;
873
- exports.SqlString = require_migrate.SqlString;
874
- exports.assignDeep = require_migrate.assignDeep;
811
+ exports.SqlString = require_util.SqlString;
812
+ exports.assignDeep = require_util.assignDeep;
875
813
  exports.createTypeDef = createTypeDef;
876
814
  exports.dateOffset = dateOffset;
877
815
  exports.dateToDateString = dateToDateString;
878
816
  exports.dateToDatetimeString = dateToDatetimeString;
879
- exports.formatQuery = require_migrate.formatQuery;
817
+ exports.formatQuery = require_util.formatQuery;
880
818
  exports.getCurrentDateTimeString = getCurrentDateTimeString;
881
819
  exports.getDayRange = getDayRange;
882
820
  exports.getDayRangeQExpr = getDayRangeQExpr;
883
- exports.getDbClient = require_migrate.getDbClient;
821
+ exports.getDbClient = require_util.getDbClient;
884
822
  exports.getTodayDateString = getTodayDateString;
885
823
  exports.getTodayDateTimeString = getTodayDateTimeString;
886
824
  exports.gqlResolveInfoToField = gqlResolveInfoToField;
887
825
  exports.makeNumberIdEncoder = makeNumberIdEncoder;
888
826
  exports.makeParamsMiddleware = makeParamsMiddleware;
889
827
  exports.makeResolver = makeResolver;
890
- exports.migrate = require_migrate.migrate;
891
828
  exports.pagingOption = pagingOption;
892
- exports.pick = require_migrate.pick;
829
+ exports.pick = require_util.pick;
893
830
  exports.qe = QExpr;
894
831
  exports.queryToSql = queryToSql;
895
- exports.setConfig = require_migrate.setConfig;
832
+ exports.setConfig = require_util.setConfig;