sonamu 0.5.7 → 0.7.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.project-default +18 -0
- package/bin/cli.js +24 -0
- package/dist/ai/agents/agent.d.ts +11 -0
- package/dist/ai/agents/agent.d.ts.map +1 -0
- package/dist/ai/agents/agent.js +65 -0
- package/dist/ai/agents/index.d.ts +3 -0
- package/dist/ai/agents/index.d.ts.map +1 -0
- package/dist/ai/agents/index.js +4 -0
- package/dist/ai/agents/types.d.ts +43 -0
- package/dist/ai/agents/types.d.ts.map +1 -0
- package/dist/ai/agents/types.js +3 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +3 -0
- package/dist/ai/providers/rtzr/api.d.ts +22 -0
- package/dist/ai/providers/rtzr/api.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/api.js +28 -0
- package/dist/ai/providers/rtzr/error.d.ts +18 -0
- package/dist/ai/providers/rtzr/error.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/error.js +29 -0
- package/dist/ai/providers/rtzr/index.d.ts +5 -0
- package/dist/ai/providers/rtzr/index.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/index.js +6 -0
- package/dist/ai/providers/rtzr/model.d.ts +52 -0
- package/dist/ai/providers/rtzr/model.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/model.js +137 -0
- package/dist/ai/providers/rtzr/options.d.ts +7 -0
- package/dist/ai/providers/rtzr/options.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/options.js +47 -0
- package/dist/ai/providers/rtzr/provider.d.ts +18 -0
- package/dist/ai/providers/rtzr/provider.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/provider.js +54 -0
- package/dist/ai/providers/rtzr/utils.d.ts +19 -0
- package/dist/ai/providers/rtzr/utils.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/utils.js +88 -0
- package/dist/api/base-frame.d.ts +2 -2
- package/dist/api/base-frame.d.ts.map +1 -1
- package/dist/api/base-frame.js +13 -2
- package/dist/api/caster.d.ts.map +1 -1
- package/dist/api/caster.js +71 -2
- package/dist/api/code-converters.d.ts +58 -14
- package/dist/api/code-converters.d.ts.map +1 -1
- package/dist/api/code-converters.js +258 -2
- package/dist/api/config.d.ts +90 -0
- package/dist/api/config.d.ts.map +1 -0
- package/dist/api/config.js +25 -0
- package/dist/api/context.d.ts +4 -2
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +3 -2
- package/dist/api/decorators.d.ts +20 -6
- package/dist/api/decorators.d.ts.map +1 -1
- package/dist/api/decorators.js +235 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +9 -2
- package/dist/api/sonamu.d.ts +10 -24
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +514 -2
- package/dist/api/validator.d.ts +6 -0
- package/dist/api/validator.d.ts.map +1 -0
- package/dist/api/validator.js +81 -0
- package/dist/bin/build-config.d.ts +6 -1
- package/dist/bin/build-config.d.ts.map +1 -1
- package/dist/bin/build-config.js +15 -2
- package/dist/bin/cli.js +519 -2
- package/dist/bin/hot-hook-register.d.ts +11 -0
- package/dist/bin/hot-hook-register.d.ts.map +1 -0
- package/dist/bin/hot-hook-register.js +21 -0
- package/dist/bin/loader-register.d.ts +2 -0
- package/dist/bin/loader-register.d.ts.map +1 -0
- package/dist/bin/loader-register.js +34 -0
- package/dist/database/_batch_update.d.ts +5 -3
- package/dist/database/_batch_update.d.ts.map +1 -1
- package/dist/database/_batch_update.js +95 -2
- package/dist/database/base-model.d.ts +96 -10
- package/dist/database/base-model.d.ts.map +1 -1
- package/dist/database/base-model.js +390 -2
- package/dist/database/base-model.types.d.ts +93 -0
- package/dist/database/base-model.types.d.ts.map +1 -0
- package/dist/database/base-model.types.js +10 -0
- package/dist/database/code-generator.d.ts +1 -1
- package/dist/database/code-generator.d.ts.map +1 -1
- package/dist/database/code-generator.js +54 -2
- package/dist/database/db.d.ts +6 -21
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +129 -2
- package/dist/database/puri-subset.test-d.js +81 -0
- package/dist/database/puri-subset.types.d.ts +123 -0
- package/dist/database/puri-subset.types.d.ts.map +1 -0
- package/dist/database/puri-subset.types.js +16 -0
- package/dist/database/puri-wrapper.d.ts +13 -11
- package/dist/database/puri-wrapper.d.ts.map +1 -1
- package/dist/database/puri-wrapper.js +109 -2
- package/dist/database/puri.d.ts +41 -23
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +601 -2
- package/dist/database/puri.types.d.ts +25 -6
- package/dist/database/puri.types.d.ts.map +1 -1
- package/dist/database/puri.types.js +6 -2
- package/dist/database/transaction-context.d.ts +1 -1
- package/dist/database/transaction-context.d.ts.map +1 -1
- package/dist/database/transaction-context.js +14 -2
- package/dist/database/upsert-builder.d.ts +9 -3
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +365 -2
- package/dist/entity/entity-manager.d.ts +167 -2
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +130 -2
- package/dist/entity/entity.d.ts +5 -3
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +750 -2
- package/dist/exceptions/error-handler.d.ts +1 -1
- package/dist/exceptions/error-handler.d.ts.map +1 -1
- package/dist/exceptions/error-handler.js +29 -2
- package/dist/exceptions/so-exceptions.d.ts +1 -1
- package/dist/exceptions/so-exceptions.d.ts.map +1 -1
- package/dist/exceptions/so-exceptions.js +85 -2
- package/dist/file-storage/driver.d.ts +1 -1
- package/dist/file-storage/driver.d.ts.map +1 -1
- package/dist/file-storage/driver.js +79 -2
- package/dist/file-storage/file-storage.js +75 -2
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -2
- package/dist/migration/code-generation.d.ts +1 -1
- package/dist/migration/code-generation.d.ts.map +1 -1
- package/dist/migration/code-generation.js +614 -2
- package/dist/migration/migration-set.d.ts +2 -10
- package/dist/migration/migration-set.d.ts.map +1 -1
- package/dist/migration/migration-set.js +213 -2
- package/dist/migration/migrator.d.ts +24 -82
- package/dist/migration/migrator.d.ts.map +1 -1
- package/dist/migration/migrator.js +330 -2
- package/dist/migration/postgresql-schema-reader.d.ts +51 -0
- package/dist/migration/postgresql-schema-reader.d.ts.map +1 -0
- package/dist/migration/postgresql-schema-reader.js +245 -0
- package/dist/migration/types.d.ts +6 -38
- package/dist/migration/types.d.ts.map +1 -1
- package/dist/migration/types.js +3 -2
- package/dist/naite/messaging-types.d.ts +43 -0
- package/dist/naite/messaging-types.d.ts.map +1 -0
- package/dist/naite/messaging-types.js +7 -0
- package/dist/naite/naite-reporter.d.ts +41 -0
- package/dist/naite/naite-reporter.d.ts.map +1 -0
- package/dist/naite/naite-reporter.js +102 -0
- package/dist/naite/naite.d.ts +95 -0
- package/dist/naite/naite.d.ts.map +1 -0
- package/dist/naite/naite.js +316 -0
- package/dist/stream/index.js +3 -2
- package/dist/stream/sse.d.ts +2 -2
- package/dist/stream/sse.d.ts.map +1 -1
- package/dist/stream/sse.js +38 -2
- package/dist/syncer/api-parser.d.ts +10 -0
- package/dist/syncer/api-parser.d.ts.map +1 -0
- package/dist/syncer/api-parser.js +240 -0
- package/dist/syncer/checksum.d.ts +21 -0
- package/dist/syncer/checksum.d.ts.map +1 -0
- package/dist/syncer/checksum.js +98 -0
- package/dist/syncer/code-generator.d.ts +20 -0
- package/dist/syncer/code-generator.d.ts.map +1 -0
- package/dist/syncer/code-generator.js +161 -0
- package/dist/syncer/entity-operations.d.ts +17 -0
- package/dist/syncer/entity-operations.d.ts.map +1 -0
- package/dist/syncer/entity-operations.js +59 -0
- package/dist/syncer/file-patterns.d.ts +29 -0
- package/dist/syncer/file-patterns.d.ts.map +1 -0
- package/dist/syncer/file-patterns.js +38 -0
- package/dist/syncer/index.d.ts +6 -0
- package/dist/syncer/index.d.ts.map +1 -1
- package/dist/syncer/index.js +9 -2
- package/dist/syncer/module-loader.d.ts +35 -0
- package/dist/syncer/module-loader.d.ts.map +1 -0
- package/dist/syncer/module-loader.js +87 -0
- package/dist/syncer/syncer.d.ts +98 -106
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +422 -2
- package/dist/template/entity-converter.d.ts +14 -0
- package/dist/template/entity-converter.d.ts.map +1 -0
- package/dist/template/entity-converter.js +108 -0
- package/dist/template/helpers.d.ts +23 -0
- package/dist/template/helpers.d.ts.map +1 -0
- package/dist/template/helpers.js +64 -0
- package/dist/{templates → template/implementations}/entity.template.d.ts +3 -3
- package/dist/template/implementations/entity.template.d.ts.map +1 -0
- package/dist/template/implementations/entity.template.js +86 -0
- package/dist/{templates → template/implementations}/generated.template.d.ts +3 -4
- package/dist/template/implementations/generated.template.d.ts.map +1 -0
- package/dist/template/implementations/generated.template.js +249 -0
- package/dist/{templates → template/implementations}/generated_http.template.d.ts +3 -4
- package/dist/template/implementations/generated_http.template.d.ts.map +1 -0
- package/dist/template/implementations/generated_http.template.js +131 -0
- package/dist/{templates → template/implementations}/generated_sso.template.d.ts +4 -5
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -0
- package/dist/template/implementations/generated_sso.template.js +134 -0
- package/dist/{templates → template/implementations}/init_types.template.d.ts +3 -3
- package/dist/template/implementations/init_types.template.d.ts.map +1 -0
- package/dist/template/implementations/init_types.template.js +38 -0
- package/dist/template/implementations/model.template.d.ts +17 -0
- package/dist/template/implementations/model.template.d.ts.map +1 -0
- package/dist/template/implementations/model.template.js +181 -0
- package/dist/{templates → template/implementations}/model_test.template.d.ts +3 -3
- package/dist/template/implementations/model_test.template.d.ts.map +1 -0
- package/dist/template/implementations/model_test.template.js +35 -0
- package/dist/{templates → template/implementations}/service.template.d.ts +6 -6
- package/dist/template/implementations/service.template.d.ts.map +1 -0
- package/dist/template/implementations/service.template.js +201 -0
- package/dist/{templates → template/implementations}/view_enums_buttonset.template.d.ts +3 -3
- package/dist/template/implementations/view_enums_buttonset.template.d.ts.map +1 -0
- package/dist/template/implementations/view_enums_buttonset.template.js +31 -0
- package/dist/{templates → template/implementations}/view_enums_dropdown.template.d.ts +3 -4
- package/dist/template/implementations/view_enums_dropdown.template.d.ts.map +1 -0
- package/dist/template/implementations/view_enums_dropdown.template.js +50 -0
- package/dist/{templates → template/implementations}/view_enums_select.template.d.ts +3 -3
- package/dist/template/implementations/view_enums_select.template.d.ts.map +1 -0
- package/dist/template/implementations/view_enums_select.template.js +55 -0
- package/dist/{templates → template/implementations}/view_form.template.d.ts +5 -5
- package/dist/template/implementations/view_form.template.d.ts.map +1 -0
- package/dist/template/implementations/view_form.template.js +337 -0
- package/dist/{templates → template/implementations}/view_id_all_select.template.d.ts +3 -3
- package/dist/template/implementations/view_id_all_select.template.d.ts.map +1 -0
- package/dist/template/implementations/view_id_all_select.template.js +31 -0
- package/dist/{templates → template/implementations}/view_id_async_select.template.d.ts +3 -3
- package/dist/template/implementations/view_id_async_select.template.d.ts.map +1 -0
- package/dist/template/implementations/view_id_async_select.template.js +105 -0
- package/dist/{templates → template/implementations}/view_list.template.d.ts +5 -13
- package/dist/template/implementations/view_list.template.d.ts.map +1 -0
- package/dist/template/implementations/view_list.template.js +475 -0
- package/dist/template/implementations/view_list_columns.template.d.ts +17 -0
- package/dist/template/implementations/view_list_columns.template.d.ts.map +1 -0
- package/dist/template/implementations/view_list_columns.template.js +49 -0
- package/dist/{templates → template/implementations}/view_search_input.template.d.ts +3 -3
- package/dist/template/implementations/view_search_input.template.d.ts.map +1 -0
- package/dist/template/implementations/view_search_input.template.js +64 -0
- package/dist/template/index.d.ts +7 -0
- package/dist/template/index.d.ts.map +1 -0
- package/dist/template/index.js +8 -0
- package/dist/template/template-manager.d.ts +56 -0
- package/dist/template/template-manager.d.ts.map +1 -0
- package/dist/template/template-manager.js +125 -0
- package/dist/template/template-types.d.ts +16 -0
- package/dist/template/template-types.d.ts.map +1 -0
- package/dist/template/template-types.js +7 -0
- package/dist/template/template.d.ts +49 -0
- package/dist/template/template.d.ts.map +1 -0
- package/dist/template/template.js +60 -0
- package/dist/template/zod-converter.d.ts +51 -0
- package/dist/template/zod-converter.d.ts.map +1 -0
- package/dist/template/zod-converter.js +449 -0
- package/dist/testing/_relation-graph.d.ts +1 -1
- package/dist/testing/_relation-graph.d.ts.map +1 -1
- package/dist/testing/_relation-graph.js +89 -2
- package/dist/testing/fixture-manager.d.ts +42 -11
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +623 -2
- package/dist/types/types.d.ts +747 -143
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +546 -2
- package/dist/typings/knex.d.js +3 -2
- package/dist/utils/async-utils.d.ts +7 -0
- package/dist/utils/async-utils.d.ts.map +1 -1
- package/dist/utils/async-utils.js +57 -2
- package/dist/utils/console-util.d.ts +2 -0
- package/dist/utils/console-util.d.ts.map +1 -0
- package/dist/utils/console-util.js +6 -0
- package/dist/utils/controller.d.ts +1 -0
- package/dist/utils/controller.d.ts.map +1 -1
- package/dist/utils/controller.js +29 -2
- package/dist/utils/esm-utils.d.ts +39 -0
- package/dist/utils/esm-utils.d.ts.map +1 -0
- package/dist/utils/esm-utils.js +49 -0
- package/dist/utils/formatter.d.ts +3 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +110 -0
- package/dist/utils/fs-utils.d.ts +1 -1
- package/dist/utils/fs-utils.d.ts.map +1 -1
- package/dist/utils/fs-utils.js +17 -2
- package/dist/utils/lodash-able.d.ts.map +1 -1
- package/dist/utils/lodash-able.js +6 -2
- package/dist/utils/model.js +22 -2
- package/dist/utils/object-utils.d.ts +44 -0
- package/dist/utils/object-utils.d.ts.map +1 -0
- package/dist/utils/object-utils.js +191 -0
- package/dist/utils/path-utils.d.ts +89 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/dist/utils/path-utils.js +60 -0
- package/dist/utils/process-utils.d.ts +13 -0
- package/dist/utils/process-utils.d.ts.map +1 -0
- package/dist/utils/process-utils.js +36 -0
- package/dist/utils/sql-parser.d.ts +5 -1
- package/dist/utils/sql-parser.d.ts.map +1 -1
- package/dist/utils/sql-parser.js +46 -2
- package/dist/utils/type-utils.d.ts +23 -0
- package/dist/utils/type-utils.d.ts.map +1 -0
- package/dist/utils/type-utils.js +45 -0
- package/dist/utils/utils.d.ts +10 -7
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +72 -2
- package/dist/utils/zod-error.d.ts +1 -1
- package/dist/utils/zod-error.d.ts.map +1 -1
- package/dist/utils/zod-error.js +19 -2
- package/package.json +65 -27
- package/src/ai/agents/agent.ts +87 -0
- package/src/ai/agents/index.ts +2 -0
- package/src/ai/agents/types.ts +47 -0
- package/src/ai/index.ts +1 -0
- package/src/ai/providers/rtzr/api.ts +37 -0
- package/src/ai/providers/rtzr/error.ts +34 -0
- package/src/ai/providers/rtzr/index.ts +4 -0
- package/src/ai/providers/rtzr/model.ts +201 -0
- package/src/ai/providers/rtzr/options.ts +49 -0
- package/src/ai/providers/rtzr/provider.ts +91 -0
- package/src/ai/providers/rtzr/utils.ts +127 -0
- package/src/api/base-frame.ts +4 -2
- package/src/api/caster.ts +17 -23
- package/src/api/code-converters.ts +178 -535
- package/src/api/config.ts +125 -0
- package/src/api/context.ts +7 -17
- package/src/api/decorators.ts +176 -46
- package/src/api/index.ts +2 -2
- package/src/api/sonamu.ts +190 -167
- package/src/api/validator.ts +83 -0
- package/src/bin/build-config.ts +8 -1
- package/src/bin/cli.ts +258 -124
- package/src/bin/hot-hook-register.ts +22 -0
- package/src/bin/loader-register.ts +38 -0
- package/src/database/_batch_update.ts +46 -31
- package/src/database/base-model.ts +390 -182
- package/src/database/base-model.types.ts +155 -0
- package/src/database/code-generator.ts +13 -32
- package/src/database/db.ts +40 -96
- package/src/database/puri-subset.test-d.ts +471 -0
- package/src/database/puri-subset.types.ts +195 -0
- package/src/database/puri-wrapper.ts +58 -67
- package/src/database/puri.ts +229 -148
- package/src/database/puri.types.ts +76 -30
- package/src/database/transaction-context.ts +1 -1
- package/src/database/upsert-builder.ts +262 -132
- package/src/entity/entity-manager.ts +48 -36
- package/src/entity/entity.ts +330 -248
- package/src/exceptions/error-handler.ts +3 -3
- package/src/exceptions/so-exceptions.ts +11 -11
- package/src/file-storage/driver.ts +5 -5
- package/src/file-storage/file-storage.ts +2 -2
- package/src/index.ts +18 -10
- package/src/migration/code-generation.ts +185 -172
- package/src/migration/migration-set.ts +80 -293
- package/src/migration/migrator.ts +199 -571
- package/src/migration/mysql-schema-reader.ts.txt +272 -0
- package/src/migration/postgresql-schema-reader.ts +310 -0
- package/src/migration/types.ts +6 -39
- package/src/naite/messaging-types.ts +51 -0
- package/src/naite/naite-reporter.ts +128 -0
- package/src/naite/naite.ts +415 -0
- package/src/shared/web.shared.ts.txt +20 -24
- package/src/stream/sse.ts +5 -5
- package/src/syncer/api-parser.ts +282 -0
- package/src/syncer/checksum.ts +140 -0
- package/src/syncer/code-generator.ts +198 -0
- package/src/syncer/entity-operations.ts +65 -0
- package/src/syncer/file-patterns.ts +56 -0
- package/src/syncer/index.ts +6 -0
- package/src/syncer/module-loader.ts +128 -0
- package/src/syncer/syncer.ts +389 -1453
- package/src/template/entity-converter.ts +114 -0
- package/src/template/helpers.ts +81 -0
- package/src/{templates → template/implementations}/entity.template.ts +7 -7
- package/src/{templates → template/implementations}/generated.template.ts +101 -101
- package/src/{templates → template/implementations}/generated_http.template.ts +27 -57
- package/src/template/implementations/generated_sso.template.ts +151 -0
- package/src/{templates → template/implementations}/init_types.template.ts +5 -7
- package/src/{templates → template/implementations}/model.template.ts +52 -43
- package/src/{templates → template/implementations}/model_test.template.ts +5 -5
- package/src/{templates → template/implementations}/service.template.ts +66 -82
- package/src/{templates → template/implementations}/view_enums_buttonset.template.ts +3 -3
- package/src/{templates → template/implementations}/view_enums_dropdown.template.ts +4 -20
- package/src/{templates → template/implementations}/view_enums_select.template.ts +4 -4
- package/src/{templates → template/implementations}/view_form.template.ts +40 -83
- package/src/{templates → template/implementations}/view_id_all_select.template.ts +3 -3
- package/src/{templates → template/implementations}/view_id_async_select.template.ts +10 -24
- package/src/{templates → template/implementations}/view_list.template.ts +60 -152
- package/src/{templates → template/implementations}/view_list_columns.template.ts +5 -11
- package/src/{templates → template/implementations}/view_search_input.template.ts +3 -3
- package/src/template/index.ts +6 -0
- package/src/template/template-manager.ts +166 -0
- package/src/template/template-types.ts +16 -0
- package/src/template/template.ts +105 -0
- package/src/template/zod-converter.ts +525 -0
- package/src/testing/_relation-graph.ts +18 -11
- package/src/testing/fixture-manager.ts +472 -359
- package/src/types/types.ts +553 -308
- package/src/typings/knex.d.ts +7 -9
- package/src/utils/async-utils.ts +23 -10
- package/src/utils/console-util.ts +4 -0
- package/src/utils/controller.ts +3 -0
- package/src/utils/esm-utils.ts +59 -0
- package/src/utils/formatter.ts +109 -0
- package/src/utils/fs-utils.ts +1 -1
- package/src/utils/lodash-able.ts +1 -4
- package/src/utils/object-utils.ts +217 -0
- package/src/utils/path-utils.ts +99 -0
- package/src/utils/process-utils.ts +46 -0
- package/src/utils/sql-parser.ts +23 -5
- package/src/utils/type-utils.ts +83 -0
- package/src/utils/utils.ts +66 -43
- package/src/utils/zod-error.ts +3 -4
- package/dist/api/base-frame.js.map +0 -1
- package/dist/api/caster.js.map +0 -1
- package/dist/api/code-converters.js.map +0 -1
- package/dist/api/context.js.map +0 -1
- package/dist/api/decorators.js.map +0 -1
- package/dist/api/index.js.map +0 -1
- package/dist/api/sonamu.js.map +0 -1
- package/dist/bin/build-config.js.map +0 -1
- package/dist/bin/cli-wrapper.d.ts +0 -3
- package/dist/bin/cli-wrapper.d.ts.map +0 -1
- package/dist/bin/cli-wrapper.js +0 -3
- package/dist/bin/cli-wrapper.js.map +0 -1
- package/dist/bin/cli.js.map +0 -1
- package/dist/database/_batch_update.js.map +0 -1
- package/dist/database/base-model.js.map +0 -1
- package/dist/database/code-generator.js.map +0 -1
- package/dist/database/db.js.map +0 -1
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts +0 -2
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts.map +0 -1
- package/dist/database/knex-plugins/knex-on-duplicate-update.js +0 -2
- package/dist/database/knex-plugins/knex-on-duplicate-update.js.map +0 -1
- package/dist/database/puri-wrapper.js.map +0 -1
- package/dist/database/puri.js.map +0 -1
- package/dist/database/puri.types.js.map +0 -1
- package/dist/database/transaction-context.js.map +0 -1
- package/dist/database/upsert-builder.js.map +0 -1
- package/dist/entity/entity-manager.js.map +0 -1
- package/dist/entity/entity-utils.d.ts +0 -61
- package/dist/entity/entity-utils.d.ts.map +0 -1
- package/dist/entity/entity-utils.js +0 -2
- package/dist/entity/entity-utils.js.map +0 -1
- package/dist/entity/entity.js.map +0 -1
- package/dist/exceptions/error-handler.js.map +0 -1
- package/dist/exceptions/so-exceptions.js.map +0 -1
- package/dist/file-storage/driver.js.map +0 -1
- package/dist/file-storage/file-storage.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/migration/code-generation.js.map +0 -1
- package/dist/migration/migration-set.js.map +0 -1
- package/dist/migration/migrator.js.map +0 -1
- package/dist/migration/types.js.map +0 -1
- package/dist/stream/index.js.map +0 -1
- package/dist/stream/sse.js.map +0 -1
- package/dist/syncer/index.js.map +0 -1
- package/dist/syncer/syncer.js.map +0 -1
- package/dist/templates/base-template.d.ts +0 -13
- package/dist/templates/base-template.d.ts.map +0 -1
- package/dist/templates/base-template.js +0 -2
- package/dist/templates/base-template.js.map +0 -1
- package/dist/templates/entity.template.d.ts.map +0 -1
- package/dist/templates/entity.template.js +0 -2
- package/dist/templates/entity.template.js.map +0 -1
- package/dist/templates/generated.template.d.ts.map +0 -1
- package/dist/templates/generated.template.js +0 -2
- package/dist/templates/generated.template.js.map +0 -1
- package/dist/templates/generated_http.template.d.ts.map +0 -1
- package/dist/templates/generated_http.template.js +0 -2
- package/dist/templates/generated_http.template.js.map +0 -1
- package/dist/templates/generated_sso.template.d.ts.map +0 -1
- package/dist/templates/generated_sso.template.js +0 -2
- package/dist/templates/generated_sso.template.js.map +0 -1
- package/dist/templates/index.d.ts +0 -2
- package/dist/templates/index.d.ts.map +0 -1
- package/dist/templates/index.js +0 -2
- package/dist/templates/index.js.map +0 -1
- package/dist/templates/init_types.template.d.ts.map +0 -1
- package/dist/templates/init_types.template.js +0 -2
- package/dist/templates/init_types.template.js.map +0 -1
- package/dist/templates/model.template.d.ts +0 -17
- package/dist/templates/model.template.d.ts.map +0 -1
- package/dist/templates/model.template.js +0 -2
- package/dist/templates/model.template.js.map +0 -1
- package/dist/templates/model_test.template.d.ts.map +0 -1
- package/dist/templates/model_test.template.js +0 -2
- package/dist/templates/model_test.template.js.map +0 -1
- package/dist/templates/service.template.d.ts.map +0 -1
- package/dist/templates/service.template.js +0 -2
- package/dist/templates/service.template.js.map +0 -1
- package/dist/templates/view_enums_buttonset.template.d.ts.map +0 -1
- package/dist/templates/view_enums_buttonset.template.js +0 -2
- package/dist/templates/view_enums_buttonset.template.js.map +0 -1
- package/dist/templates/view_enums_dropdown.template.d.ts.map +0 -1
- package/dist/templates/view_enums_dropdown.template.js +0 -2
- package/dist/templates/view_enums_dropdown.template.js.map +0 -1
- package/dist/templates/view_enums_select.template.d.ts.map +0 -1
- package/dist/templates/view_enums_select.template.js +0 -2
- package/dist/templates/view_enums_select.template.js.map +0 -1
- package/dist/templates/view_form.template.d.ts.map +0 -1
- package/dist/templates/view_form.template.js +0 -2
- package/dist/templates/view_form.template.js.map +0 -1
- package/dist/templates/view_id_all_select.template.d.ts.map +0 -1
- package/dist/templates/view_id_all_select.template.js +0 -2
- package/dist/templates/view_id_all_select.template.js.map +0 -1
- package/dist/templates/view_id_async_select.template.d.ts.map +0 -1
- package/dist/templates/view_id_async_select.template.js +0 -2
- package/dist/templates/view_id_async_select.template.js.map +0 -1
- package/dist/templates/view_list.template.d.ts.map +0 -1
- package/dist/templates/view_list.template.js +0 -2
- package/dist/templates/view_list.template.js.map +0 -1
- package/dist/templates/view_list_columns.template.d.ts +0 -17
- package/dist/templates/view_list_columns.template.d.ts.map +0 -1
- package/dist/templates/view_list_columns.template.js +0 -2
- package/dist/templates/view_list_columns.template.js.map +0 -1
- package/dist/templates/view_search_input.template.d.ts.map +0 -1
- package/dist/templates/view_search_input.template.js +0 -2
- package/dist/templates/view_search_input.template.js.map +0 -1
- package/dist/testing/_relation-graph.js.map +0 -1
- package/dist/testing/fixture-manager.js.map +0 -1
- package/dist/types/types.js.map +0 -1
- package/dist/typings/knex.d.js.map +0 -1
- package/dist/utils/async-utils.js.map +0 -1
- package/dist/utils/controller.js.map +0 -1
- package/dist/utils/fs-utils.js.map +0 -1
- package/dist/utils/lodash-able.js.map +0 -1
- package/dist/utils/model.js.map +0 -1
- package/dist/utils/sql-parser.js.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/zod-error.js.map +0 -1
- package/src/bin/cli-wrapper.ts +0 -75
- package/src/database/knex-plugins/knex-on-duplicate-update.ts +0 -45
- package/src/entity/entity-utils.ts +0 -291
- package/src/templates/base-template.ts +0 -19
- package/src/templates/generated_sso.template.ts +0 -138
- package/src/templates/index.ts +0 -1
|
@@ -1,274 +1,32 @@
|
|
|
1
|
-
import { Knex } from "knex";
|
|
2
|
-
import { DBColumn, DBForeign, DBIndex } from "./types";
|
|
3
|
-
import _ from "lodash";
|
|
4
1
|
import inflection from "inflection";
|
|
5
|
-
import { Entity } from "../entity/entity";
|
|
2
|
+
import type { Entity } from "../entity/entity";
|
|
6
3
|
import { EntityManager } from "../entity/entity-manager";
|
|
7
4
|
import {
|
|
8
|
-
|
|
9
|
-
MigrationSet,
|
|
10
|
-
RelationOn,
|
|
5
|
+
type EntityProp,
|
|
11
6
|
isBelongsToOneRelationProp,
|
|
12
|
-
isDecimalProp,
|
|
13
|
-
isEnumProp,
|
|
14
|
-
isFloatProp,
|
|
15
7
|
isHasManyRelationProp,
|
|
16
|
-
isIntegerProp,
|
|
17
8
|
isManyToManyRelationProp,
|
|
9
|
+
isNumberProp,
|
|
10
|
+
isNumericProp,
|
|
18
11
|
isOneToOneRelationProp,
|
|
19
12
|
isRelationProp,
|
|
20
13
|
isStringProp,
|
|
21
|
-
isTextProp,
|
|
22
14
|
isVirtualProp,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
MigrationForeign,
|
|
26
|
-
MigrationIndex,
|
|
27
|
-
MigrationJoinTable,
|
|
28
|
-
MigrationSetAndJoinTable,
|
|
15
|
+
type MigrationColumn,
|
|
16
|
+
type MigrationColumnType,
|
|
17
|
+
type MigrationForeign,
|
|
18
|
+
type MigrationIndex,
|
|
19
|
+
type MigrationJoinTable,
|
|
20
|
+
type MigrationSetAndJoinTable,
|
|
29
21
|
} from "../types/types";
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* DB에서 테이블 정보를 읽어서 MigrationSet을 만들어옵니다.
|
|
33
|
-
* @param compareDB Knex 인스턴스
|
|
34
|
-
* @param table 테이블 이름
|
|
35
|
-
* @returns MigrationSet 객체
|
|
36
|
-
*/
|
|
37
|
-
export async function getMigrationSetFromDB(
|
|
38
|
-
compareDB: Knex,
|
|
39
|
-
table: string
|
|
40
|
-
): Promise<MigrationSet | null> {
|
|
41
|
-
let dbColumns: DBColumn[], dbIndexes: DBIndex[], dbForeigns: DBForeign[];
|
|
42
|
-
try {
|
|
43
|
-
[dbColumns, dbIndexes, dbForeigns] = await readTable(compareDB, table);
|
|
44
|
-
} catch (e: unknown) {
|
|
45
|
-
if (isKnexError(e) && e.code === "ER_NO_SUCH_TABLE") {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
console.error(e);
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const columns: MigrationColumn[] = dbColumns.map((dbColumn) => {
|
|
53
|
-
const dbColType = resolveDBColType(dbColumn.Type, dbColumn.Field);
|
|
54
|
-
return {
|
|
55
|
-
name: dbColumn.Field,
|
|
56
|
-
nullable: dbColumn.Null !== "NO",
|
|
57
|
-
...dbColType,
|
|
58
|
-
...(() => {
|
|
59
|
-
if (dbColumn.Default !== null) {
|
|
60
|
-
return {
|
|
61
|
-
defaultTo: dbColumn.Default,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return {};
|
|
65
|
-
})(),
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const dbIndexesGroup = _.groupBy(
|
|
70
|
-
dbIndexes.filter(
|
|
71
|
-
(dbIndex) =>
|
|
72
|
-
dbIndex.Key_name !== "PRIMARY" &&
|
|
73
|
-
!dbForeigns.find((dbForeign) => dbForeign.keyName === dbIndex.Key_name)
|
|
74
|
-
),
|
|
75
|
-
(dbIndex) => dbIndex.Key_name
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const parseIndexType = (index: DBIndex) => {
|
|
79
|
-
if (index.Index_type === "FULLTEXT") {
|
|
80
|
-
return "fulltext";
|
|
81
|
-
}
|
|
82
|
-
return index.Non_unique === 1 ? "index" : "unique";
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// indexes 처리
|
|
86
|
-
const indexes: MigrationIndex[] = Object.keys(dbIndexesGroup).map(
|
|
87
|
-
(keyName) => {
|
|
88
|
-
const currentIndexes = dbIndexesGroup[keyName];
|
|
89
|
-
return {
|
|
90
|
-
type: parseIndexType(currentIndexes[0]),
|
|
91
|
-
columns: currentIndexes.map((currentIndex) => currentIndex.Column_name),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
// console.log(table);
|
|
96
|
-
// console.table(dbIndexes);
|
|
97
|
-
// console.table(dbForeigns);
|
|
98
|
-
|
|
99
|
-
// foreigns 처리
|
|
100
|
-
const foreigns: MigrationForeign[] = dbForeigns.map((dbForeign) => {
|
|
101
|
-
return {
|
|
102
|
-
columns: [dbForeign.from],
|
|
103
|
-
to: `${dbForeign.referencesTable}.${dbForeign.referencesField}`,
|
|
104
|
-
onUpdate: dbForeign.onUpdate as RelationOn,
|
|
105
|
-
onDelete: dbForeign.onDelete as RelationOn,
|
|
106
|
-
};
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
table,
|
|
111
|
-
columns,
|
|
112
|
-
indexes,
|
|
113
|
-
foreigns,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/*
|
|
118
|
-
* 기존 테이블 읽어서 cols, indexes 반환
|
|
119
|
-
*/
|
|
120
|
-
async function readTable(
|
|
121
|
-
compareDB: Knex,
|
|
122
|
-
tableName: string
|
|
123
|
-
): Promise<[DBColumn[], DBIndex[], DBForeign[]]> {
|
|
124
|
-
// 테이블 정보
|
|
125
|
-
try {
|
|
126
|
-
const [_cols] = (await compareDB.raw(`SHOW FIELDS FROM ${tableName}`)) as [
|
|
127
|
-
DBColumn[],
|
|
128
|
-
];
|
|
129
|
-
const cols = _cols.map((col) => ({
|
|
130
|
-
...col,
|
|
131
|
-
// Default 값은 숫자나 MySQL Expression이 아닌 경우 ""로 감싸줌
|
|
132
|
-
...(col.Default !== null && {
|
|
133
|
-
Default:
|
|
134
|
-
col.Default.replace(/[0-9]+/g, "").length > 0 &&
|
|
135
|
-
col.Extra !== "DEFAULT_GENERATED"
|
|
136
|
-
? `"${col.Default}"`
|
|
137
|
-
: col.Default,
|
|
138
|
-
}),
|
|
139
|
-
}));
|
|
140
|
-
|
|
141
|
-
const [indexes] = await compareDB.raw(`SHOW INDEX FROM ${tableName}`);
|
|
142
|
-
const [[row]] = await compareDB.raw(`SHOW CREATE TABLE ${tableName}`);
|
|
143
|
-
const ddl = row["Create Table"];
|
|
144
|
-
const matched = ddl.match(/CONSTRAINT .+/g);
|
|
145
|
-
const foreignKeys = (matched ?? []).map((line: string) => {
|
|
146
|
-
// 해당 라인을 정규식으로 파싱
|
|
147
|
-
const matched = line.match(
|
|
148
|
-
/CONSTRAINT `(.+)` FOREIGN KEY \(`(.+)`\) REFERENCES `(.+)` \(`(.+)`\)( ON [A-Z ]+)*/
|
|
149
|
-
);
|
|
150
|
-
if (!matched) {
|
|
151
|
-
throw new Error(`인식할 수 없는 FOREIGN KEY CONSTRAINT ${line}`);
|
|
152
|
-
}
|
|
153
|
-
const [, keyName, from, referencesTable, referencesField, onClause] =
|
|
154
|
-
matched;
|
|
155
|
-
// console.debug({ tableName, line, onClause });
|
|
156
|
-
|
|
157
|
-
const [onUpdateFull, _onUpdate] =
|
|
158
|
-
(onClause ?? "").match(/ON UPDATE ([A-Z ]+)$/) ?? [];
|
|
159
|
-
const onUpdate = _onUpdate ?? "NO ACTION";
|
|
160
|
-
|
|
161
|
-
const onDelete =
|
|
162
|
-
(onClause ?? "")
|
|
163
|
-
.replace(onUpdateFull ?? "", "")
|
|
164
|
-
.match(/ON DELETE ([A-Z ]+)/)?.[1]
|
|
165
|
-
?.trim() ?? "NO ACTION";
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
keyName,
|
|
169
|
-
from,
|
|
170
|
-
referencesTable,
|
|
171
|
-
referencesField,
|
|
172
|
-
onDelete,
|
|
173
|
-
onUpdate,
|
|
174
|
-
};
|
|
175
|
-
});
|
|
176
|
-
return [cols, indexes, foreignKeys];
|
|
177
|
-
} catch (e) {
|
|
178
|
-
throw e;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function resolveDBColType(
|
|
183
|
-
colType: string,
|
|
184
|
-
colField: string
|
|
185
|
-
): Pick<
|
|
186
|
-
MigrationColumn,
|
|
187
|
-
"type" | "unsigned" | "length" | "precision" | "scale"
|
|
188
|
-
> {
|
|
189
|
-
let [rawType, unsigned] = colType.split(" ");
|
|
190
|
-
const matched = rawType.match(/\(([0-9]+)\)/);
|
|
191
|
-
let length;
|
|
192
|
-
if (matched !== null && matched[1]) {
|
|
193
|
-
rawType = rawType.replace(/\(([0-9]+)\)/, "");
|
|
194
|
-
length = parseInt(matched[1]);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (rawType === "char" && colField === "uuid") {
|
|
198
|
-
return {
|
|
199
|
-
type: "uuid",
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
switch (rawType) {
|
|
204
|
-
case "int":
|
|
205
|
-
return {
|
|
206
|
-
type: "integer",
|
|
207
|
-
unsigned: unsigned === "unsigned",
|
|
208
|
-
};
|
|
209
|
-
case "varchar":
|
|
210
|
-
// case "char":
|
|
211
|
-
return {
|
|
212
|
-
type: "string",
|
|
213
|
-
...(length !== undefined && {
|
|
214
|
-
length,
|
|
215
|
-
}),
|
|
216
|
-
};
|
|
217
|
-
case "text":
|
|
218
|
-
case "mediumtext":
|
|
219
|
-
case "longtext":
|
|
220
|
-
case "timestamp":
|
|
221
|
-
case "json":
|
|
222
|
-
case "date":
|
|
223
|
-
case "time":
|
|
224
|
-
return {
|
|
225
|
-
type: rawType,
|
|
226
|
-
};
|
|
227
|
-
case "datetime":
|
|
228
|
-
return {
|
|
229
|
-
type: "datetime",
|
|
230
|
-
};
|
|
231
|
-
case "tinyint":
|
|
232
|
-
return {
|
|
233
|
-
type: "boolean",
|
|
234
|
-
};
|
|
235
|
-
default:
|
|
236
|
-
// decimal 처리
|
|
237
|
-
if (rawType.startsWith("decimal")) {
|
|
238
|
-
const [, precision, scale] =
|
|
239
|
-
rawType.match(/decimal\(([0-9]+),([0-9]+)\)/) ?? [];
|
|
240
|
-
return {
|
|
241
|
-
type: "decimal",
|
|
242
|
-
precision: parseInt(precision),
|
|
243
|
-
scale: parseInt(scale),
|
|
244
|
-
...(unsigned === "unsigned" && {
|
|
245
|
-
unsigned: true,
|
|
246
|
-
}),
|
|
247
|
-
};
|
|
248
|
-
} else if (rawType.startsWith("float")) {
|
|
249
|
-
const [, precision, scale] =
|
|
250
|
-
rawType.match(/float\(([0-9]+),([0-9]+)\)/) ?? [];
|
|
251
|
-
return {
|
|
252
|
-
type: "float",
|
|
253
|
-
precision: parseInt(precision),
|
|
254
|
-
scale: parseInt(scale),
|
|
255
|
-
...(unsigned === "unsigned" && {
|
|
256
|
-
unsigned: true,
|
|
257
|
-
}),
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
throw new Error(`resolve 불가능한 DB컬럼 타입 ${colType} ${rawType}`);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
22
|
+
import { exhaustive } from "../utils/utils";
|
|
263
23
|
|
|
264
24
|
/**
|
|
265
25
|
* Entity를 읽어서 MigrationSetAndJoinTable을 만들어옵니다.
|
|
266
26
|
* @param entity Entity 객체
|
|
267
27
|
* @returns MigrationSetAndJoinTable 객체
|
|
268
28
|
*/
|
|
269
|
-
export function getMigrationSetFromEntity(
|
|
270
|
-
entity: Entity
|
|
271
|
-
): MigrationSetAndJoinTable {
|
|
29
|
+
export function getMigrationSetFromEntity(entity: Entity): MigrationSetAndJoinTable {
|
|
272
30
|
const migrationSet: MigrationSetAndJoinTable = entity.props.reduce(
|
|
273
31
|
(r, prop) => {
|
|
274
32
|
// virtual 필드 제외
|
|
@@ -282,23 +40,9 @@ export function getMigrationSetFromEntity(
|
|
|
282
40
|
|
|
283
41
|
// 일반 컬럼
|
|
284
42
|
if (!isRelationProp(prop)) {
|
|
285
|
-
// type resolve
|
|
286
|
-
let type: KnexColumnType;
|
|
287
|
-
if (isTextProp(prop)) {
|
|
288
|
-
type = prop.textType;
|
|
289
|
-
} else if (isEnumProp(prop)) {
|
|
290
|
-
type = "string";
|
|
291
|
-
} else {
|
|
292
|
-
type = prop.type as KnexColumnType;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
43
|
const column = {
|
|
296
44
|
name: prop.name,
|
|
297
|
-
type,
|
|
298
|
-
...(isIntegerProp(prop) && { unsigned: prop.unsigned === true }),
|
|
299
|
-
...((isStringProp(prop) || isEnumProp(prop)) && {
|
|
300
|
-
length: prop.length,
|
|
301
|
-
}),
|
|
45
|
+
type: resolveEntityPropTypeToMigrationColumnType(prop),
|
|
302
46
|
nullable: prop.nullable === true,
|
|
303
47
|
...(() => {
|
|
304
48
|
if (prop.dbDefault !== undefined) {
|
|
@@ -308,11 +52,16 @@ export function getMigrationSetFromEntity(
|
|
|
308
52
|
}
|
|
309
53
|
return {};
|
|
310
54
|
})(),
|
|
311
|
-
//
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
55
|
+
// String 타입에 length 있는 경우 추가
|
|
56
|
+
...(isStringProp(prop) &&
|
|
57
|
+
prop.length !== undefined && {
|
|
58
|
+
length: prop.length,
|
|
59
|
+
}),
|
|
60
|
+
// Number/Numeric 타입의 경우 precision, scale 추가
|
|
61
|
+
...((isNumberProp(prop) || isNumericProp(prop)) && {
|
|
62
|
+
precision: prop.precision,
|
|
63
|
+
scale: prop.scale,
|
|
64
|
+
numberType: isNumberProp(prop) ? (prop.numberType ?? "numeric") : "numeric",
|
|
316
65
|
}),
|
|
317
66
|
};
|
|
318
67
|
|
|
@@ -345,14 +94,10 @@ export function getMigrationSetFromEntity(
|
|
|
345
94
|
},
|
|
346
95
|
// 조인 테이블에 걸린 인덱스 찾아와서 연결
|
|
347
96
|
...entity.indexes
|
|
348
|
-
.filter((index) =>
|
|
349
|
-
index.columns.find((col) => col.includes(prop.joinTable + "."))
|
|
350
|
-
)
|
|
97
|
+
.filter((index) => index.columns.find((col) => col.includes(`${prop.joinTable}.`)))
|
|
351
98
|
.map((index) => ({
|
|
352
99
|
...index,
|
|
353
|
-
columns: index.columns.map((col) =>
|
|
354
|
-
col.replace(prop.joinTable + ".", "")
|
|
355
|
-
),
|
|
100
|
+
columns: index.columns.map((col) => col.replace(`${prop.joinTable}.`, "")),
|
|
356
101
|
})),
|
|
357
102
|
],
|
|
358
103
|
columns: [
|
|
@@ -360,14 +105,12 @@ export function getMigrationSetFromEntity(
|
|
|
360
105
|
name: "id",
|
|
361
106
|
type: "integer",
|
|
362
107
|
nullable: false,
|
|
363
|
-
unsigned: true,
|
|
364
108
|
},
|
|
365
109
|
...fields.map((field) => {
|
|
366
110
|
return {
|
|
367
111
|
name: field.split(".")[1],
|
|
368
112
|
type: "integer",
|
|
369
113
|
nullable: false,
|
|
370
|
-
unsigned: true,
|
|
371
114
|
} as MigrationColumn;
|
|
372
115
|
}),
|
|
373
116
|
{
|
|
@@ -380,10 +123,7 @@ export function getMigrationSetFromEntity(
|
|
|
380
123
|
// 현재 필드가 어떤 테이블에 속하는지 판단
|
|
381
124
|
const col = field.split(".")[1];
|
|
382
125
|
const to = (() => {
|
|
383
|
-
if (
|
|
384
|
-
inflection.singularize(join.to.split(".")[0]) + "_id" ===
|
|
385
|
-
col
|
|
386
|
-
) {
|
|
126
|
+
if (`${inflection.singularize(join.to.split(".")[0])}_id` === col) {
|
|
387
127
|
return join.to;
|
|
388
128
|
} else {
|
|
389
129
|
return join.from;
|
|
@@ -403,19 +143,16 @@ export function getMigrationSetFromEntity(
|
|
|
403
143
|
(isOneToOneRelationProp(prop) && prop.hasJoinColumn)
|
|
404
144
|
) {
|
|
405
145
|
// -OneRelation 케이스
|
|
406
|
-
const idColumnName = prop.name
|
|
146
|
+
const idColumnName = `${prop.name}_id`;
|
|
407
147
|
r.columns.push({
|
|
408
148
|
name: idColumnName,
|
|
409
149
|
type: "integer",
|
|
410
|
-
unsigned: true,
|
|
411
150
|
nullable: prop.nullable ?? false,
|
|
412
151
|
});
|
|
413
152
|
if ((prop.useConstraint ?? true) === true) {
|
|
414
153
|
r.foreigns.push({
|
|
415
154
|
columns: [idColumnName],
|
|
416
|
-
to: `${inflection
|
|
417
|
-
.underscore(inflection.pluralize(prop.with))
|
|
418
|
-
.toLowerCase()}.id`,
|
|
155
|
+
to: `${inflection.underscore(inflection.pluralize(prop.with)).toLowerCase()}.id`,
|
|
419
156
|
onUpdate: prop.onUpdate ?? "RESTRICT",
|
|
420
157
|
onDelete: prop.onDelete ?? "RESTRICT",
|
|
421
158
|
});
|
|
@@ -430,12 +167,12 @@ export function getMigrationSetFromEntity(
|
|
|
430
167
|
indexes: [] as MigrationIndex[],
|
|
431
168
|
foreigns: [] as MigrationForeign[],
|
|
432
169
|
joinTables: [] as MigrationJoinTable[],
|
|
433
|
-
}
|
|
170
|
+
},
|
|
434
171
|
);
|
|
435
172
|
|
|
436
173
|
// indexes
|
|
437
174
|
migrationSet.indexes = entity.indexes.filter((index) =>
|
|
438
|
-
index.columns.find((col) => col.includes(".") === false)
|
|
175
|
+
index.columns.find((col) => col.includes(".") === false),
|
|
439
176
|
);
|
|
440
177
|
|
|
441
178
|
// uuid
|
|
@@ -451,3 +188,53 @@ export function getMigrationSetFromEntity(
|
|
|
451
188
|
|
|
452
189
|
return migrationSet;
|
|
453
190
|
}
|
|
191
|
+
|
|
192
|
+
function resolveEntityPropTypeToMigrationColumnType(prop: EntityProp): MigrationColumnType {
|
|
193
|
+
if (prop.type === "relation" || prop.type === "virtual") {
|
|
194
|
+
throw new Error(`Unresolved column type: ${prop.type}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
switch (prop.type) {
|
|
198
|
+
case "string":
|
|
199
|
+
return "string";
|
|
200
|
+
case "string[]":
|
|
201
|
+
return "string[]";
|
|
202
|
+
case "enum":
|
|
203
|
+
return "string";
|
|
204
|
+
case "enum[]":
|
|
205
|
+
return "string[]";
|
|
206
|
+
case "integer":
|
|
207
|
+
return "integer";
|
|
208
|
+
case "integer[]":
|
|
209
|
+
return "integer[]";
|
|
210
|
+
case "bigInteger":
|
|
211
|
+
return "bigInteger";
|
|
212
|
+
case "bigInteger[]":
|
|
213
|
+
return "bigInteger[]";
|
|
214
|
+
case "number":
|
|
215
|
+
return "numberOrNumeric";
|
|
216
|
+
case "number[]":
|
|
217
|
+
return "numberOrNumeric[]";
|
|
218
|
+
case "numeric":
|
|
219
|
+
return "numberOrNumeric";
|
|
220
|
+
case "numeric[]":
|
|
221
|
+
return "numberOrNumeric[]";
|
|
222
|
+
case "boolean":
|
|
223
|
+
return "boolean";
|
|
224
|
+
case "boolean[]":
|
|
225
|
+
return "boolean[]";
|
|
226
|
+
case "date":
|
|
227
|
+
return "date";
|
|
228
|
+
case "date[]":
|
|
229
|
+
return "date[]";
|
|
230
|
+
case "uuid":
|
|
231
|
+
return "uuid";
|
|
232
|
+
case "uuid[]":
|
|
233
|
+
return "uuid[]";
|
|
234
|
+
case "json":
|
|
235
|
+
return "json";
|
|
236
|
+
default:
|
|
237
|
+
exhaustive(prop);
|
|
238
|
+
throw new Error(`Unknown entity prop type: ${(prop as { type: string }).type}`);
|
|
239
|
+
}
|
|
240
|
+
}
|