sonamu 0.4.14 → 0.5.0
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.
- package/.swcrc +15 -0
- package/dist/api/base-frame.d.ts +8 -0
- package/dist/api/base-frame.d.ts.map +1 -0
- package/dist/api/base-frame.js +2 -0
- package/dist/api/base-frame.js.map +1 -0
- package/dist/api/caster.d.ts +5 -0
- package/dist/api/caster.d.ts.map +1 -0
- package/dist/api/caster.js +2 -0
- package/dist/api/caster.js.map +1 -0
- package/dist/api/code-converters.d.ts +23 -0
- package/dist/api/code-converters.d.ts.map +1 -0
- package/dist/api/code-converters.js +2 -0
- package/dist/api/code-converters.js.map +1 -0
- package/dist/api/context.d.ts +16 -0
- package/dist/api/context.d.ts.map +1 -0
- package/dist/api/context.js +2 -0
- package/dist/api/context.js.map +1 -0
- package/dist/api/decorators.d.ts +50 -0
- package/dist/api/decorators.d.ts.map +1 -0
- package/dist/api/decorators.js +2 -0
- package/dist/api/decorators.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/sonamu.d.ts +83 -0
- package/dist/api/sonamu.d.ts.map +1 -0
- package/dist/api/sonamu.js +2 -0
- package/dist/api/sonamu.js.map +1 -0
- package/dist/api/sonamu.types.d.ts +30 -0
- package/dist/api/sonamu.types.d.ts.map +1 -0
- package/dist/api/sonamu.types.js +2 -0
- package/dist/api/sonamu.types.js.map +1 -0
- package/dist/bin/build-config.d.ts +5 -0
- package/dist/bin/build-config.d.ts.map +1 -0
- package/dist/bin/build-config.js +2 -0
- package/dist/bin/build-config.js.map +1 -0
- package/dist/bin/cli-wrapper.d.ts +2 -0
- package/dist/bin/cli-wrapper.d.ts.map +1 -0
- package/dist/bin/cli-wrapper.js +1 -38
- package/dist/bin/cli-wrapper.js.map +1 -1
- package/dist/bin/cli.d.ts +2 -2
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +1 -903
- package/dist/bin/cli.js.map +1 -1
- package/dist/database/_batch_update.d.ts +15 -0
- package/dist/database/_batch_update.d.ts.map +1 -0
- package/dist/database/_batch_update.js +2 -0
- package/dist/database/_batch_update.js.map +1 -0
- package/dist/database/base-model.d.ts +41 -0
- package/dist/database/base-model.d.ts.map +1 -0
- package/dist/database/base-model.js +2 -0
- package/dist/database/base-model.js.map +1 -0
- package/dist/database/code-generator.d.ts +13 -0
- package/dist/database/code-generator.d.ts.map +1 -0
- package/dist/database/code-generator.js +2 -0
- package/dist/database/code-generator.js.map +1 -0
- package/dist/database/db.d.ts +40 -0
- package/dist/database/db.d.ts.map +1 -0
- package/dist/database/db.js +2 -0
- package/dist/database/db.js.map +1 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts +2 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts.map +1 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.js +2 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.js.map +1 -0
- package/dist/database/puri-wrapper.d.ts +34 -0
- package/dist/database/puri-wrapper.d.ts.map +1 -0
- package/dist/database/puri-wrapper.js +2 -0
- package/dist/database/puri-wrapper.js.map +1 -0
- package/dist/database/puri.d.ts +83 -0
- package/dist/database/puri.d.ts.map +1 -0
- package/dist/database/puri.js +2 -0
- package/dist/database/puri.js.map +1 -0
- package/dist/database/puri.types.d.ts +60 -0
- package/dist/database/puri.types.d.ts.map +1 -0
- package/dist/database/puri.types.js +2 -0
- package/dist/database/puri.types.js.map +1 -0
- package/dist/database/transaction-context.d.ts +9 -0
- package/dist/database/transaction-context.d.ts.map +1 -0
- package/dist/database/transaction-context.js +2 -0
- package/dist/database/transaction-context.js.map +1 -0
- package/dist/database/types.d.ts +39 -0
- package/dist/database/types.d.ts.map +1 -0
- package/dist/database/types.js +2 -0
- package/dist/database/types.js.map +1 -0
- package/dist/database/upsert-builder.d.ts +34 -0
- package/dist/database/upsert-builder.d.ts.map +1 -0
- package/dist/database/upsert-builder.js +2 -0
- package/dist/database/upsert-builder.js.map +1 -0
- package/dist/entity/entity-manager.d.ts +32 -0
- package/dist/entity/entity-manager.d.ts.map +1 -0
- package/dist/entity/entity-manager.js +2 -0
- package/dist/entity/entity-manager.js.map +1 -0
- package/dist/entity/entity-utils.d.ts +61 -0
- package/dist/entity/entity-utils.d.ts.map +1 -0
- package/dist/entity/entity-utils.js +2 -0
- package/dist/entity/entity-utils.js.map +1 -0
- package/dist/entity/entity.d.ts +62 -0
- package/dist/entity/entity.d.ts.map +1 -0
- package/dist/entity/entity.js +2 -0
- package/dist/entity/entity.js.map +1 -0
- package/dist/entity/migrator.d.ts +135 -0
- package/dist/entity/migrator.d.ts.map +1 -0
- package/dist/entity/migrator.js +2 -0
- package/dist/entity/migrator.js.map +1 -0
- package/dist/exceptions/error-handler.d.ts +3 -0
- package/dist/exceptions/error-handler.d.ts.map +1 -0
- package/dist/exceptions/error-handler.js +2 -0
- package/dist/exceptions/error-handler.js.map +1 -0
- package/dist/exceptions/so-exceptions.d.ts +48 -0
- package/dist/exceptions/so-exceptions.d.ts.map +1 -0
- package/dist/exceptions/so-exceptions.js +2 -0
- package/dist/exceptions/so-exceptions.js.map +1 -0
- package/dist/file-storage/driver.d.ts +45 -0
- package/dist/file-storage/driver.d.ts.map +1 -0
- package/dist/file-storage/driver.js +2 -0
- package/dist/file-storage/driver.js.map +1 -0
- package/dist/file-storage/file-storage.d.ts +50 -0
- package/dist/file-storage/file-storage.d.ts.map +1 -0
- package/dist/file-storage/file-storage.js +2 -0
- package/dist/file-storage/file-storage.js.map +1 -0
- package/dist/index.d.ts +22 -813
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -433
- package/dist/index.js.map +1 -1
- package/dist/migration/code-generation.d.ts +15 -0
- package/dist/migration/code-generation.d.ts.map +1 -0
- package/dist/migration/code-generation.js +2 -0
- package/dist/migration/code-generation.js.map +1 -0
- package/dist/migration/migration-set.d.ts +17 -0
- package/dist/migration/migration-set.d.ts.map +1 -0
- package/dist/migration/migration-set.js +2 -0
- package/dist/migration/migration-set.js.map +1 -0
- package/dist/migration/migrator.d.ts +130 -0
- package/dist/migration/migrator.d.ts.map +1 -0
- package/dist/migration/migrator.js +2 -0
- package/dist/migration/migrator.js.map +1 -0
- package/dist/migration/types.d.ts +52 -0
- package/dist/migration/types.d.ts.map +1 -0
- package/dist/migration/types.js +2 -0
- package/dist/migration/types.js.map +1 -0
- package/dist/smd/smd-manager.d.ts +28 -0
- package/dist/smd/smd-manager.d.ts.map +1 -0
- package/dist/smd/smd-manager.js +2 -0
- package/dist/smd/smd-manager.js.map +1 -0
- package/dist/smd/smd.d.ts +40 -0
- package/dist/smd/smd.d.ts.map +1 -0
- package/dist/smd/smd.js +2 -0
- package/dist/smd/smd.js.map +1 -0
- package/dist/syncer/index.d.ts +2 -0
- package/dist/syncer/index.d.ts.map +1 -0
- package/dist/syncer/index.js +2 -0
- package/dist/syncer/index.js.map +1 -0
- package/dist/syncer/syncer.d.ts +127 -0
- package/dist/syncer/syncer.d.ts.map +1 -0
- package/dist/syncer/syncer.js +2 -0
- package/dist/syncer/syncer.js.map +1 -0
- package/dist/templates/base-template.d.ts +13 -0
- package/dist/templates/base-template.d.ts.map +1 -0
- package/dist/templates/base-template.js +2 -0
- package/dist/templates/base-template.js.map +1 -0
- package/dist/templates/entity.template.d.ts +17 -0
- package/dist/templates/entity.template.d.ts.map +1 -0
- package/dist/templates/entity.template.js +2 -0
- package/dist/templates/entity.template.js.map +1 -0
- package/dist/templates/generated.template.d.ts +27 -0
- package/dist/templates/generated.template.d.ts.map +1 -0
- package/dist/templates/generated.template.js +2 -0
- package/dist/templates/generated.template.js.map +1 -0
- package/dist/templates/generated_http.template.d.ts +24 -0
- package/dist/templates/generated_http.template.d.ts.map +1 -0
- package/dist/templates/generated_http.template.js +2 -0
- package/dist/templates/generated_http.template.js.map +1 -0
- package/dist/templates/generated_sso.template.d.ts +20 -0
- package/dist/templates/generated_sso.template.d.ts.map +1 -0
- package/dist/templates/generated_sso.template.js +2 -0
- package/dist/templates/generated_sso.template.js.map +1 -0
- package/dist/templates/index.d.ts +2 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +2 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/init_types.template.d.ts +17 -0
- package/dist/templates/init_types.template.d.ts.map +1 -0
- package/dist/templates/init_types.template.js +2 -0
- package/dist/templates/init_types.template.js.map +1 -0
- package/dist/templates/model.template.d.ts +17 -0
- package/dist/templates/model.template.d.ts.map +1 -0
- package/dist/templates/model.template.js +2 -0
- package/dist/templates/model.template.js.map +1 -0
- package/dist/templates/model_test.template.d.ts +17 -0
- package/dist/templates/model_test.template.d.ts.map +1 -0
- package/dist/templates/model_test.template.js +2 -0
- package/dist/templates/model_test.template.js.map +1 -0
- package/dist/templates/service.template.d.ts +29 -0
- package/dist/templates/service.template.d.ts.map +1 -0
- package/dist/templates/service.template.js +2 -0
- package/dist/templates/service.template.js.map +1 -0
- package/dist/templates/view_enums_buttonset.template.d.ts +17 -0
- package/dist/templates/view_enums_buttonset.template.d.ts.map +1 -0
- package/dist/templates/view_enums_buttonset.template.js +2 -0
- package/dist/templates/view_enums_buttonset.template.js.map +1 -0
- package/dist/templates/view_enums_dropdown.template.d.ts +18 -0
- package/dist/templates/view_enums_dropdown.template.d.ts.map +1 -0
- package/dist/templates/view_enums_dropdown.template.js +2 -0
- package/dist/templates/view_enums_dropdown.template.js.map +1 -0
- package/dist/templates/view_enums_select.template.d.ts +17 -0
- package/dist/templates/view_enums_select.template.d.ts.map +1 -0
- package/dist/templates/view_enums_select.template.js +2 -0
- package/dist/templates/view_enums_select.template.js.map +1 -0
- package/dist/templates/view_form.template.d.ts +26 -0
- package/dist/templates/view_form.template.d.ts.map +1 -0
- package/dist/templates/view_form.template.js +2 -0
- package/dist/templates/view_form.template.js.map +1 -0
- package/dist/templates/view_id_all_select.template.d.ts +17 -0
- package/dist/templates/view_id_all_select.template.d.ts.map +1 -0
- package/dist/templates/view_id_all_select.template.js +2 -0
- package/dist/templates/view_id_all_select.template.js.map +1 -0
- package/dist/templates/view_id_async_select.template.d.ts +17 -0
- package/dist/templates/view_id_async_select.template.d.ts.map +1 -0
- package/dist/templates/view_id_async_select.template.js +2 -0
- package/dist/templates/view_id_async_select.template.js.map +1 -0
- package/dist/templates/view_list.template.d.ts +38 -0
- package/dist/templates/view_list.template.d.ts.map +1 -0
- package/dist/templates/view_list.template.js +2 -0
- package/dist/templates/view_list.template.js.map +1 -0
- package/dist/templates/view_list_columns.template.d.ts +17 -0
- package/dist/templates/view_list_columns.template.d.ts.map +1 -0
- package/dist/templates/view_list_columns.template.js +2 -0
- package/dist/templates/view_list_columns.template.js.map +1 -0
- package/dist/templates/view_search_input.template.d.ts +17 -0
- package/dist/templates/view_search_input.template.d.ts.map +1 -0
- package/dist/templates/view_search_input.template.js +2 -0
- package/dist/templates/view_search_input.template.js.map +1 -0
- package/dist/testing/_relation-graph.d.ts +7 -0
- package/dist/testing/_relation-graph.d.ts.map +1 -0
- package/dist/testing/_relation-graph.js +2 -0
- package/dist/testing/_relation-graph.js.map +1 -0
- package/dist/testing/fixture-manager.d.ts +35 -0
- package/dist/testing/fixture-manager.d.ts.map +1 -0
- package/dist/testing/fixture-manager.js +2 -0
- package/dist/testing/fixture-manager.js.map +1 -0
- package/dist/types/types.d.ts +609 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/types/types.js.map +1 -0
- package/dist/typings/knex.d.js +2 -0
- package/dist/typings/knex.d.js.map +1 -0
- package/dist/utils/async-utils.d.ts +25 -0
- package/dist/utils/async-utils.d.ts.map +1 -0
- package/dist/utils/async-utils.js +2 -0
- package/dist/utils/async-utils.js.map +1 -0
- package/dist/utils/controller.d.ts +9 -0
- package/dist/utils/controller.d.ts.map +1 -0
- package/dist/utils/controller.js +2 -0
- package/dist/utils/controller.js.map +1 -0
- package/dist/utils/fs-utils.d.ts +9 -0
- package/dist/utils/fs-utils.d.ts.map +1 -0
- package/dist/utils/fs-utils.js +2 -0
- package/dist/utils/fs-utils.js.map +1 -0
- package/dist/utils/lodash-able.d.ts +2 -0
- package/dist/utils/lodash-able.d.ts.map +1 -0
- package/dist/utils/lodash-able.js +2 -0
- package/dist/utils/lodash-able.js.map +1 -0
- package/dist/utils/model.d.ts +17 -0
- package/dist/utils/model.d.ts.map +1 -0
- package/dist/utils/model.js +2 -0
- package/dist/utils/model.js.map +1 -0
- package/dist/utils/sql-parser.d.ts +4 -0
- package/dist/utils/sql-parser.d.ts.map +1 -0
- package/dist/utils/sql-parser.js +2 -0
- package/dist/utils/sql-parser.js.map +1 -0
- package/dist/utils/utils.d.ts +9 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +2 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist/utils/zod-error.d.ts +8 -0
- package/dist/utils/zod-error.d.ts.map +1 -0
- package/dist/utils/zod-error.js +2 -0
- package/dist/utils/zod-error.js.map +1 -0
- package/nodemon.json +6 -0
- package/package.json +29 -44
- package/src/api/base-frame.ts +3 -4
- package/src/api/caster.ts +22 -23
- package/src/api/code-converters.ts +170 -134
- package/src/api/context.ts +13 -6
- package/src/api/decorators.ts +146 -20
- package/src/api/index.ts +2 -0
- package/src/api/sonamu.ts +374 -165
- package/src/bin/build-config.ts +5 -0
- package/src/bin/cli-wrapper.ts +29 -40
- package/src/bin/cli.ts +132 -190
- package/src/database/_batch_update.ts +10 -15
- package/src/database/base-model.ts +300 -216
- package/src/database/db.ts +191 -21
- package/src/database/{drivers/knex/plugins → knex-plugins}/knex-on-duplicate-update.ts +1 -1
- package/src/database/puri-wrapper.ts +129 -0
- package/src/database/puri.ts +808 -0
- package/src/database/puri.types.ts +222 -0
- package/src/database/transaction-context.ts +18 -0
- package/src/database/upsert-builder.ts +32 -35
- package/src/entity/entity-manager.ts +7 -15
- package/src/entity/entity.ts +9 -31
- package/src/entity/migrator-/354/235/264/354/202/254/352/260/224/354/226/264/354/232/224.md +1 -0
- package/src/file-storage/driver.ts +121 -0
- package/src/file-storage/file-storage.ts +100 -0
- package/src/index.ts +14 -11
- package/src/migration/code-generation.ts +777 -0
- package/src/migration/migration-set.ts +453 -0
- package/src/migration/migrator.ts +823 -0
- package/src/migration/types.ts +53 -0
- package/src/shared/web.shared.ts.txt +33 -2
- package/src/syncer/syncer.ts +294 -127
- package/src/templates/generated.template.ts +13 -1
- package/src/templates/generated_http.template.ts +15 -12
- package/src/templates/generated_sso.template.ts +50 -2
- package/src/templates/model.template.ts +138 -2
- package/src/templates/service.template.ts +0 -1
- package/src/templates/view_form.template.ts +11 -7
- package/src/templates/view_list.template.ts +12 -4
- package/src/testing/fixture-manager.ts +229 -174
- package/src/types/types.ts +102 -14
- package/src/utils/async-utils.ts +64 -0
- package/src/utils/fs-utils.ts +17 -0
- package/src/utils/model.ts +0 -2
- package/src/utils/utils.ts +14 -58
- package/src/utils/zod-error.ts +12 -176
- package/tsconfig.json +2 -0
- package/tsup.config.js +4 -2
- package/.pnp.cjs +0 -14363
- package/.pnp.loader.mjs +0 -2047
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -9
- package/.yarnrc.yml +0 -5
- package/src/database/base-model.abstract.ts +0 -97
- package/src/database/db.abstract.ts +0 -75
- package/src/database/drivers/knex/base-model.ts +0 -55
- package/src/database/drivers/knex/client.ts +0 -209
- package/src/database/drivers/knex/db.ts +0 -232
- package/src/database/drivers/knex/generator.ts +0 -659
- package/src/database/drivers/kysely/base-model.ts +0 -89
- package/src/database/drivers/kysely/client.ts +0 -309
- package/src/database/drivers/kysely/db.ts +0 -238
- package/src/database/drivers/kysely/generator.ts +0 -714
- package/src/database/types.ts +0 -118
- package/src/entity/migrator.ts +0 -1400
- package/src/smd/smd-manager.ts +0 -139
- package/src/smd/smd.ts +0 -571
- package/src/templates/kysely_types.template.ts +0 -205
package/src/bin/cli-wrapper.ts
CHANGED
|
@@ -1,53 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env ts-node
|
|
2
2
|
|
|
3
|
-
import { spawnSync } from "child_process";
|
|
4
|
-
import {
|
|
5
|
-
import { existsSync
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// 환경 변수에서 ESM 여부 확인
|
|
20
|
-
if (process.env.USE_ESM === "true") {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// package.json에 "type": "module" 설정
|
|
25
|
-
if (existsSync(packageJsonPath)) {
|
|
26
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
27
|
-
return packageJson.type === "module";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// main 필드가 .mjs로 끝나는지 확인
|
|
31
|
-
if (packageJson.main && extname(packageJson.main) === ".mjs") {
|
|
32
|
-
return true;
|
|
3
|
+
import { spawnSync, execSync } from "child_process";
|
|
4
|
+
import { resolve } from "path";
|
|
5
|
+
import { existsSync } from "fs";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { SWC_BUILD_COMMAND } from "./build-config";
|
|
8
|
+
|
|
9
|
+
const scriptPath = resolve(__dirname, "cli.js");
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
|
|
12
|
+
// build 명령어는 dist 없이도 실행 가능하도록 cli.ts 외부에서 처리(Sonamu.init에서 dist 필요)
|
|
13
|
+
function build() {
|
|
14
|
+
try {
|
|
15
|
+
execSync(SWC_BUILD_COMMAND, { cwd: process.cwd(), stdio: "inherit" });
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error(chalk.red("Build failed."), error);
|
|
18
|
+
process.exit(1);
|
|
33
19
|
}
|
|
20
|
+
}
|
|
34
21
|
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
if (args[0] === "build") {
|
|
23
|
+
console.log(chalk.blue("Building the project..."));
|
|
24
|
+
build();
|
|
25
|
+
console.log(chalk.green("Build completed successfully."));
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
if (args[0] === "dev:serve") {
|
|
30
|
+
build();
|
|
31
|
+
}
|
|
39
32
|
|
|
40
33
|
if (!existsSync(scriptPath)) {
|
|
41
34
|
console.error(`Error: Script not found at ${scriptPath}`);
|
|
42
35
|
process.exit(1);
|
|
43
36
|
}
|
|
44
37
|
|
|
45
|
-
const result = spawnSync(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
stdio: "inherit",
|
|
50
|
-
}
|
|
51
|
-
);
|
|
38
|
+
const result = spawnSync(process.execPath, [scriptPath, ...args], {
|
|
39
|
+
stdio: "inherit",
|
|
40
|
+
});
|
|
52
41
|
|
|
53
42
|
process.exit(result.status ?? 1);
|
package/src/bin/cli.ts
CHANGED
|
@@ -8,25 +8,15 @@ dotenv.config();
|
|
|
8
8
|
import path from "path";
|
|
9
9
|
import { tsicli } from "tsicli";
|
|
10
10
|
import { execSync } from "child_process";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import prettier from "prettier";
|
|
11
|
+
import { mkdir, readFile, readdir, writeFile } from "fs/promises";
|
|
12
|
+
import { exists } from "../utils/fs-utils";
|
|
14
13
|
import process from "process";
|
|
15
|
-
import _ from "lodash";
|
|
16
14
|
import { Sonamu } from "../api";
|
|
15
|
+
import knex, { Knex } from "knex";
|
|
17
16
|
import { EntityManager } from "../entity/entity-manager";
|
|
18
|
-
import { Migrator } from "../
|
|
17
|
+
import { Migrator } from "../migration/migrator";
|
|
19
18
|
import { FixtureManager } from "../testing/fixture-manager";
|
|
20
|
-
import {
|
|
21
|
-
import { DB } from "../database/db";
|
|
22
|
-
import {
|
|
23
|
-
KnexConfig,
|
|
24
|
-
KyselyConfig,
|
|
25
|
-
SonamuKnexDBConfig,
|
|
26
|
-
SonamuKyselyDBConfig,
|
|
27
|
-
} from "../database/types";
|
|
28
|
-
import { KnexClient } from "../database/drivers/knex/client";
|
|
29
|
-
import { KyselyClient } from "../database/drivers/kysely/client";
|
|
19
|
+
import { SWC_BUILD_COMMAND } from "./build-config";
|
|
30
20
|
|
|
31
21
|
let migrator: Migrator;
|
|
32
22
|
|
|
@@ -64,7 +54,8 @@ async function bootstrap() {
|
|
|
64
54
|
["scaffold", "view_list", "#entityId"],
|
|
65
55
|
["scaffold", "view_form", "#entityId"],
|
|
66
56
|
["ui"],
|
|
67
|
-
["
|
|
57
|
+
["dev:serve"],
|
|
58
|
+
["serve"],
|
|
68
59
|
],
|
|
69
60
|
runners: {
|
|
70
61
|
migrate_run,
|
|
@@ -83,7 +74,8 @@ async function bootstrap() {
|
|
|
83
74
|
ui,
|
|
84
75
|
// scaffold_view_list,
|
|
85
76
|
// scaffold_view_form,
|
|
86
|
-
|
|
77
|
+
"dev:serve": dev_serve,
|
|
78
|
+
serve,
|
|
87
79
|
},
|
|
88
80
|
});
|
|
89
81
|
}
|
|
@@ -91,12 +83,73 @@ bootstrap().finally(async () => {
|
|
|
91
83
|
if (migrator) {
|
|
92
84
|
await migrator.destroy();
|
|
93
85
|
}
|
|
94
|
-
await FixtureManager.
|
|
86
|
+
await FixtureManager.destroy();
|
|
95
87
|
|
|
96
88
|
/* Global End */
|
|
97
89
|
console.log(chalk.bgBlue(`END ${new Date()}\n`));
|
|
98
90
|
});
|
|
99
91
|
|
|
92
|
+
async function dev_serve() {
|
|
93
|
+
const nodemon = await import("nodemon");
|
|
94
|
+
|
|
95
|
+
const nodemonConfig = await (async () => {
|
|
96
|
+
const projectNodemonPath = path.join(Sonamu.apiRootPath, "nodemon.json");
|
|
97
|
+
const hasProjectNodemon = await exists(projectNodemonPath);
|
|
98
|
+
|
|
99
|
+
if (hasProjectNodemon) {
|
|
100
|
+
return JSON.parse(await readFile(projectNodemonPath, "utf8"));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
watch: ["src/index.ts"],
|
|
105
|
+
ignore: ["dist/**", "**/*.js", "**/*.d.ts"],
|
|
106
|
+
exec: [
|
|
107
|
+
SWC_BUILD_COMMAND,
|
|
108
|
+
"node -r source-map-support/register -r dotenv/config dist/index.js",
|
|
109
|
+
].join(" && "),
|
|
110
|
+
};
|
|
111
|
+
})();
|
|
112
|
+
|
|
113
|
+
nodemon.default(nodemonConfig);
|
|
114
|
+
|
|
115
|
+
// 프로세스 종료 처리
|
|
116
|
+
const cleanup = async () => {
|
|
117
|
+
await Sonamu.server?.close();
|
|
118
|
+
process.exit(0);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
process.on("SIGINT", cleanup);
|
|
122
|
+
process.on("SIGTERM", cleanup);
|
|
123
|
+
process.on("SIGUSR2", cleanup);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function serve() {
|
|
127
|
+
const distIndexPath = path.join(Sonamu.apiRootPath, "dist", "index.js");
|
|
128
|
+
|
|
129
|
+
if (!(await exists(distIndexPath))) {
|
|
130
|
+
console.log(
|
|
131
|
+
chalk.red("dist/index.js not found. Please build your project first.")
|
|
132
|
+
);
|
|
133
|
+
console.log(chalk.blue("Run: yarn sonamu build"));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const { spawn } = await import("child_process");
|
|
138
|
+
const serverProcess = spawn(
|
|
139
|
+
"node",
|
|
140
|
+
["-r", "source-map-support/register", "-r", "dotenv/config", distIndexPath],
|
|
141
|
+
{
|
|
142
|
+
cwd: Sonamu.apiRootPath,
|
|
143
|
+
stdio: "inherit",
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
process.on("SIGINT", () => {
|
|
148
|
+
serverProcess.kill("SIGTERM");
|
|
149
|
+
process.exit(0);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
100
153
|
async function setupMigrator() {
|
|
101
154
|
// migrator
|
|
102
155
|
migrator = new Migrator({
|
|
@@ -149,97 +202,93 @@ async function migrate_reset() {
|
|
|
149
202
|
}
|
|
150
203
|
|
|
151
204
|
async function fixture_init() {
|
|
152
|
-
const
|
|
153
|
-
const srcConn = _db.connectionInfo;
|
|
154
|
-
|
|
205
|
+
const srcConfig = Sonamu.dbConfig.development_master;
|
|
155
206
|
const targets = [
|
|
156
207
|
{
|
|
157
208
|
label: "(REMOTE) Fixture DB",
|
|
158
|
-
|
|
209
|
+
config: Sonamu.dbConfig.fixture_remote,
|
|
159
210
|
},
|
|
160
211
|
{
|
|
161
212
|
label: "(LOCAL) Fixture DB",
|
|
162
|
-
|
|
213
|
+
config: Sonamu.dbConfig.fixture_local,
|
|
214
|
+
toSkip: (() => {
|
|
215
|
+
const remoteConn = Sonamu.dbConfig.fixture_remote
|
|
216
|
+
.connection as Knex.ConnectionConfig;
|
|
217
|
+
const localConn = Sonamu.dbConfig.fixture_local
|
|
218
|
+
.connection as Knex.ConnectionConfig;
|
|
219
|
+
return (
|
|
220
|
+
remoteConn.host === localConn.host &&
|
|
221
|
+
remoteConn.database === localConn.database
|
|
222
|
+
);
|
|
223
|
+
})(),
|
|
163
224
|
},
|
|
164
225
|
{
|
|
165
226
|
label: "(LOCAL) Testing DB",
|
|
166
|
-
|
|
227
|
+
config: Sonamu.dbConfig.test,
|
|
167
228
|
},
|
|
168
229
|
] as {
|
|
169
230
|
label: string;
|
|
170
|
-
|
|
231
|
+
config: Knex.Config;
|
|
232
|
+
toSkip?: boolean;
|
|
171
233
|
}[];
|
|
172
234
|
|
|
173
235
|
// 1. 기준DB 스키마를 덤프
|
|
174
236
|
console.log("DUMP...");
|
|
175
237
|
const dumpFilename = `/tmp/sonamu-fixture-init-${Date.now()}.sql`;
|
|
238
|
+
const srcConn = srcConfig.connection as Knex.ConnectionConfig;
|
|
176
239
|
const migrationsDump = `/tmp/sonamu-fixture-init-migrations-${Date.now()}.sql`;
|
|
177
240
|
execSync(
|
|
178
|
-
`mysqldump -h${srcConn.host} -
|
|
241
|
+
`mysqldump -h${srcConn.host} -u${srcConn.user} -p${srcConn.password} --single-transaction -d --no-create-db --triggers ${srcConn.database} > ${dumpFilename}`
|
|
179
242
|
);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const [migrations] = await _db.raw<{ count: number }>(
|
|
185
|
-
"SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = ? AND table_name = ?",
|
|
186
|
-
[srcConn.database, migrationTable]
|
|
243
|
+
const _db = knex(srcConfig);
|
|
244
|
+
const [[migrations]] = await _db.raw(
|
|
245
|
+
"SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = ? AND table_name = 'knex_migrations'",
|
|
246
|
+
[srcConn.database]
|
|
187
247
|
);
|
|
188
248
|
if (migrations.count > 0) {
|
|
189
249
|
execSync(
|
|
190
|
-
`mysqldump -h${srcConn.host} -
|
|
250
|
+
`mysqldump -h${srcConn.host} -u${srcConn.user} -p${srcConn.password} --single-transaction --no-create-db --triggers ${srcConn.database} knex_migrations knex_migrations_lock > ${migrationsDump}`
|
|
191
251
|
);
|
|
192
252
|
}
|
|
193
253
|
|
|
194
254
|
// 2. 대상DB 각각에 대하여 존재여부 확인 후 붓기
|
|
195
|
-
for await (const { label,
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
if (
|
|
199
|
-
label === "(LOCAL) Fixture DB" &&
|
|
200
|
-
targets.find(
|
|
201
|
-
(t) =>
|
|
202
|
-
t.label === "(REMOTE) Fixture DB" &&
|
|
203
|
-
DB.connectionInfo[t.connKey].host === config.host &&
|
|
204
|
-
DB.connectionInfo[t.connKey].database === config.database
|
|
205
|
-
)
|
|
206
|
-
) {
|
|
255
|
+
for await (const { label, config, toSkip } of targets) {
|
|
256
|
+
const conn = config.connection as Knex.ConnectionConfig;
|
|
257
|
+
|
|
258
|
+
if (toSkip === true) {
|
|
207
259
|
console.log(chalk.red(`${label}: Skipped!`));
|
|
208
260
|
continue;
|
|
209
261
|
}
|
|
210
262
|
|
|
211
|
-
const db = (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
config.connection
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return new KyselyClient(config);
|
|
220
|
-
}
|
|
221
|
-
})();
|
|
222
|
-
|
|
223
|
-
const [row] = await db.raw(`SHOW DATABASES LIKE "${config.database}"`);
|
|
263
|
+
const db = knex({
|
|
264
|
+
...config,
|
|
265
|
+
connection: {
|
|
266
|
+
...((config.connection ?? {}) as Knex.ConnectionConfig),
|
|
267
|
+
database: undefined,
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
const [[row]] = await db.raw(`SHOW DATABASES LIKE "${conn.database}"`);
|
|
224
271
|
if (row) {
|
|
225
272
|
console.log(
|
|
226
|
-
chalk.yellow(`${label}: Database "${
|
|
273
|
+
chalk.yellow(`${label}: Database "${conn.database}" Already exists`)
|
|
227
274
|
);
|
|
228
275
|
await db.destroy();
|
|
229
276
|
continue;
|
|
230
277
|
}
|
|
231
278
|
|
|
232
279
|
console.log(`SYNC to ${label}...`);
|
|
233
|
-
const mysqlCmd = `mysql -h${
|
|
234
|
-
execSync(`${mysqlCmd} -e 'DROP DATABASE IF EXISTS \`${
|
|
235
|
-
execSync(`${mysqlCmd} -e 'CREATE DATABASE \`${
|
|
236
|
-
execSync(`${mysqlCmd} ${
|
|
237
|
-
if (
|
|
238
|
-
execSync(`${mysqlCmd} ${
|
|
280
|
+
const mysqlCmd = `mysql -h${conn.host} -u${conn.user} -p${conn.password}`;
|
|
281
|
+
execSync(`${mysqlCmd} -e 'DROP DATABASE IF EXISTS \`${conn.database}\`'`);
|
|
282
|
+
execSync(`${mysqlCmd} -e 'CREATE DATABASE \`${conn.database}\`'`);
|
|
283
|
+
execSync(`${mysqlCmd} ${conn.database} < ${dumpFilename}`);
|
|
284
|
+
if (await exists(migrationsDump)) {
|
|
285
|
+
execSync(`${mysqlCmd} ${conn.database} < ${migrationsDump}`);
|
|
239
286
|
}
|
|
240
287
|
|
|
241
288
|
await db.destroy();
|
|
242
289
|
}
|
|
290
|
+
|
|
291
|
+
await _db.destroy();
|
|
243
292
|
}
|
|
244
293
|
|
|
245
294
|
async function fixture_import(entityId: string, recordIds: number[]) {
|
|
@@ -257,11 +306,11 @@ async function fixture_sync() {
|
|
|
257
306
|
|
|
258
307
|
async function stub_practice(name: string) {
|
|
259
308
|
const practiceDir = path.join(Sonamu.apiRootPath, "src", "practices");
|
|
260
|
-
const fileNames =
|
|
309
|
+
const fileNames = await readdir(practiceDir);
|
|
261
310
|
|
|
262
|
-
const maxSeqNo = (() => {
|
|
263
|
-
if (
|
|
264
|
-
|
|
311
|
+
const maxSeqNo = await (async () => {
|
|
312
|
+
if (!(await exists(practiceDir))) {
|
|
313
|
+
await mkdir(practiceDir, { recursive: true });
|
|
265
314
|
}
|
|
266
315
|
|
|
267
316
|
const filteredSeqs = fileNames
|
|
@@ -299,7 +348,7 @@ async function stub_practice(name: string) {
|
|
|
299
348
|
`await BaseModel.destroy();`,
|
|
300
349
|
`});`,
|
|
301
350
|
].join("\n");
|
|
302
|
-
|
|
351
|
+
await writeFile(dstPath, code);
|
|
303
352
|
|
|
304
353
|
execSync(`code ${dstPath}`);
|
|
305
354
|
|
|
@@ -329,10 +378,20 @@ async function scaffold_model_test(entityId: string) {
|
|
|
329
378
|
|
|
330
379
|
async function ui() {
|
|
331
380
|
try {
|
|
381
|
+
type StartServersOptions = {
|
|
382
|
+
projectName: string;
|
|
383
|
+
apiRootPath: string;
|
|
384
|
+
port: number;
|
|
385
|
+
};
|
|
332
386
|
const sonamuUI: {
|
|
333
|
-
startServers: (
|
|
387
|
+
startServers: (options: StartServersOptions) => void;
|
|
334
388
|
} = await import("@sonamu-kit/ui" as string);
|
|
335
|
-
sonamuUI.startServers(
|
|
389
|
+
sonamuUI.startServers({
|
|
390
|
+
projectName:
|
|
391
|
+
Sonamu.config.projectName ?? path.basename(Sonamu.apiRootPath),
|
|
392
|
+
apiRootPath: Sonamu.apiRootPath,
|
|
393
|
+
port: Sonamu.config.ui?.port ?? 57000,
|
|
394
|
+
});
|
|
336
395
|
} catch (e: unknown) {
|
|
337
396
|
if (e instanceof Error && e.message.includes("isn't declared")) {
|
|
338
397
|
console.log(`You need to install ${chalk.blue(`@sonamu-kit/ui`)} first.`);
|
|
@@ -341,120 +400,3 @@ async function ui() {
|
|
|
341
400
|
throw e;
|
|
342
401
|
}
|
|
343
402
|
}
|
|
344
|
-
|
|
345
|
-
async function smd_migration() {
|
|
346
|
-
await SMDManager.autoload();
|
|
347
|
-
const smdIds = SMDManager.getAllIds();
|
|
348
|
-
|
|
349
|
-
function enumLabelsToEntityEnums(
|
|
350
|
-
entityId: string,
|
|
351
|
-
enumLabels: {
|
|
352
|
-
[enumName: string]: { [name: string]: { ko: string } };
|
|
353
|
-
}
|
|
354
|
-
): { [enumName: string]: { [name: string]: string } } {
|
|
355
|
-
return Object.fromEntries(
|
|
356
|
-
Object.entries(enumLabels).map(([enumLabelName, enumLabel]) => {
|
|
357
|
-
const enumName =
|
|
358
|
-
entityId + inflection.camelize(enumLabelName.toLowerCase(), false);
|
|
359
|
-
return [
|
|
360
|
-
enumName,
|
|
361
|
-
Object.fromEntries(
|
|
362
|
-
Object.entries(enumLabel).map(([name, { ko }]) => [name, ko])
|
|
363
|
-
),
|
|
364
|
-
];
|
|
365
|
-
})
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
for await (const smdId of smdIds) {
|
|
369
|
-
const smd = SMDManager.get(smdId);
|
|
370
|
-
const entityJson = {
|
|
371
|
-
id: smd.id,
|
|
372
|
-
...(smd.parentId && { parentId: smd.parentId }),
|
|
373
|
-
title: smd.title,
|
|
374
|
-
props: smd.props,
|
|
375
|
-
indexes: smd.indexes,
|
|
376
|
-
subsets: smd.subsets,
|
|
377
|
-
enums: enumLabelsToEntityEnums(smd.id, smd.enumLabels),
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
const parentNames = SMDManager.getNamesFromId(smd.parentId ?? smd.id);
|
|
381
|
-
const names = SMDManager.getNamesFromId(smd.id);
|
|
382
|
-
const dstPath = path.join(
|
|
383
|
-
Sonamu.apiRootPath,
|
|
384
|
-
"src",
|
|
385
|
-
"application",
|
|
386
|
-
parentNames.fs,
|
|
387
|
-
`${names.fs}.entity.json`
|
|
388
|
-
);
|
|
389
|
-
|
|
390
|
-
const formatted = await prettier.format(JSON.stringify(entityJson), {
|
|
391
|
-
parser: "json",
|
|
392
|
-
});
|
|
393
|
-
fs.writeFileSync(dstPath, formatted);
|
|
394
|
-
console.log(chalk.blue(`CREATED: ${dstPath}`));
|
|
395
|
-
|
|
396
|
-
// smd.ts, enums.ts, genereated.ts 삭제 (트랜스파일 된 js파일도 삭제)
|
|
397
|
-
const srcSmdPath = path.join(
|
|
398
|
-
Sonamu.apiRootPath,
|
|
399
|
-
"src",
|
|
400
|
-
"application",
|
|
401
|
-
parentNames.fs,
|
|
402
|
-
`${names.fs}.smd.ts`
|
|
403
|
-
);
|
|
404
|
-
const dstSmdPath = srcSmdPath
|
|
405
|
-
.replace("/src/", "/dist/")
|
|
406
|
-
.replace(/\.ts$/, ".js");
|
|
407
|
-
const srcEnumsPath = path.join(
|
|
408
|
-
Sonamu.apiRootPath,
|
|
409
|
-
"src",
|
|
410
|
-
"application",
|
|
411
|
-
parentNames.fs,
|
|
412
|
-
`${names.fs}.enums.ts`
|
|
413
|
-
);
|
|
414
|
-
const dstEnumsPath = srcEnumsPath
|
|
415
|
-
.replace("/src/", "/dist/")
|
|
416
|
-
.replace(/\.ts$/, ".js");
|
|
417
|
-
const srcGeneratedPath = path.join(
|
|
418
|
-
Sonamu.apiRootPath,
|
|
419
|
-
"src",
|
|
420
|
-
"application",
|
|
421
|
-
parentNames.fs,
|
|
422
|
-
`${names.fs}.generated.ts`
|
|
423
|
-
);
|
|
424
|
-
const dstGeneratedPath = srcGeneratedPath
|
|
425
|
-
.replace("/src/", "/dist/")
|
|
426
|
-
.replace(/\.ts$/, ".js");
|
|
427
|
-
|
|
428
|
-
[
|
|
429
|
-
srcSmdPath,
|
|
430
|
-
dstSmdPath,
|
|
431
|
-
srcEnumsPath,
|
|
432
|
-
dstEnumsPath,
|
|
433
|
-
...Sonamu.config.sync.targets.map((target) =>
|
|
434
|
-
srcEnumsPath
|
|
435
|
-
.replace(Sonamu.apiRootPath, path.join(Sonamu.appRootPath, target))
|
|
436
|
-
.replace("/src/application/", "/src/services/")
|
|
437
|
-
),
|
|
438
|
-
srcGeneratedPath,
|
|
439
|
-
dstGeneratedPath,
|
|
440
|
-
].map((p) => {
|
|
441
|
-
if (fs.existsSync(p) === false) {
|
|
442
|
-
console.log(chalk.yellow(`NOT FOUND: ${p}`));
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
fs.unlinkSync(p);
|
|
446
|
-
console.log(chalk.red(`DELETED: ${p}`));
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// Entity로 reload
|
|
451
|
-
console.log("Entity로 다시 로드합니다.");
|
|
452
|
-
EntityManager.isAutoloaded = false;
|
|
453
|
-
await EntityManager.autoload();
|
|
454
|
-
|
|
455
|
-
// Entity를 통해 generated.ts 재생성
|
|
456
|
-
const entityIds = EntityManager.getAllParentIds();
|
|
457
|
-
for await (const entityId of entityIds) {
|
|
458
|
-
await Sonamu.syncer.generateTemplate("generated", { entityId });
|
|
459
|
-
}
|
|
460
|
-
}
|
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Knex } from "knex";
|
|
7
|
-
import { DB } from "./db";
|
|
8
|
-
import { KnexClient } from "./drivers/knex/client";
|
|
9
|
-
import { KyselyClient } from "./drivers/kysely/client";
|
|
10
|
-
import { Transaction } from "kysely";
|
|
11
|
-
import { Database } from "./types";
|
|
12
7
|
|
|
13
8
|
export type RowWithId<Id extends string> = {
|
|
14
9
|
[key in Id]: any;
|
|
@@ -24,12 +19,12 @@ export type RowWithId<Id extends string> = {
|
|
|
24
19
|
* @param trx
|
|
25
20
|
*/
|
|
26
21
|
export async function batchUpdate<Id extends string>(
|
|
27
|
-
|
|
22
|
+
knex: Knex,
|
|
28
23
|
tableName: string,
|
|
29
24
|
ids: Id[],
|
|
30
25
|
rows: RowWithId<Id>[],
|
|
31
26
|
chunkSize = 50,
|
|
32
|
-
trx: Knex.Transaction |
|
|
27
|
+
trx: Knex.Transaction | null = null
|
|
33
28
|
) {
|
|
34
29
|
const chunks: RowWithId<Id>[][] = [];
|
|
35
30
|
for (let i = 0; i < rows.length; i += chunkSize) {
|
|
@@ -38,18 +33,18 @@ export async function batchUpdate<Id extends string>(
|
|
|
38
33
|
|
|
39
34
|
const executeUpdate = async (
|
|
40
35
|
chunk: RowWithId<Id>[],
|
|
41
|
-
transaction:
|
|
36
|
+
transaction: Knex.Transaction
|
|
42
37
|
) => {
|
|
43
|
-
const sql = generateBatchUpdateSQL(
|
|
44
|
-
return
|
|
38
|
+
const sql = generateBatchUpdateSQL(knex, tableName, chunk, ids);
|
|
39
|
+
return knex.raw(sql).transacting(transaction);
|
|
45
40
|
};
|
|
46
41
|
|
|
47
42
|
if (trx) {
|
|
48
43
|
for (const chunk of chunks) {
|
|
49
|
-
await executeUpdate(chunk,
|
|
44
|
+
await executeUpdate(chunk, trx);
|
|
50
45
|
}
|
|
51
46
|
} else {
|
|
52
|
-
await
|
|
47
|
+
await knex.transaction(async (newTrx) => {
|
|
53
48
|
for (const chunk of chunks) {
|
|
54
49
|
await executeUpdate(chunk, newTrx);
|
|
55
50
|
}
|
|
@@ -75,7 +70,7 @@ function generateKeySetFromData(data: Record<string, any>[]) {
|
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
function generateBatchUpdateSQL<Id extends string>(
|
|
78
|
-
db:
|
|
73
|
+
db: Knex,
|
|
79
74
|
tableName: string,
|
|
80
75
|
data: Record<string, any>[],
|
|
81
76
|
identifiers: Id[]
|
|
@@ -117,10 +112,10 @@ function generateBatchUpdateSQL<Id extends string>(
|
|
|
117
112
|
data.map((row) => row[col])
|
|
118
113
|
);
|
|
119
114
|
|
|
120
|
-
const sql = db.
|
|
115
|
+
const sql = db.raw(
|
|
121
116
|
`UPDATE \`${tableName}\` SET ${cases.join(", ")} WHERE ${whereInClauses}`,
|
|
122
117
|
[...bindings, ...whereInBindings]
|
|
123
118
|
);
|
|
124
119
|
|
|
125
|
-
return sql;
|
|
120
|
+
return sql.toQuery();
|
|
126
121
|
}
|