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,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Template } from "
|
|
1
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
+
import type { TemplateOptions } from "../../types/types";
|
|
3
|
+
import { Template } from "../template";
|
|
4
4
|
|
|
5
5
|
export class Template__view_id_async_select extends Template {
|
|
6
6
|
constructor() {
|
|
@@ -19,15 +19,11 @@ export class Template__view_id_async_select extends Template {
|
|
|
19
19
|
|
|
20
20
|
const entity = EntityManager.get(entityId);
|
|
21
21
|
if (!textField) {
|
|
22
|
-
const pickedProp = entity.props.find((prop) =>
|
|
23
|
-
["name", "title"].includes(prop.name)
|
|
24
|
-
);
|
|
22
|
+
const pickedProp = entity.props.find((prop) => ["name", "title"].includes(prop.name));
|
|
25
23
|
if (pickedProp) {
|
|
26
24
|
textField = pickedProp.name;
|
|
27
25
|
} else {
|
|
28
|
-
const candidateProp = entity.props.find(
|
|
29
|
-
(prop) => prop.type === "string"
|
|
30
|
-
);
|
|
26
|
+
const candidateProp = entity.props.find((prop) => prop.type === "string");
|
|
31
27
|
if (candidateProp) {
|
|
32
28
|
textField = candidateProp.name;
|
|
33
29
|
} else {
|
|
@@ -44,16 +40,10 @@ import { DropdownProps, DropdownItemProps, DropdownOnSearchChangeData, Dropdown
|
|
|
44
40
|
import { ${names.capital}SubsetKey, ${
|
|
45
41
|
names.capital
|
|
46
42
|
}SubsetMapping } from "src/services/sonamu.generated";
|
|
47
|
-
import { ${names.capital}Service } from "src/services/${names.fs}/${
|
|
48
|
-
|
|
49
|
-
}.service";
|
|
50
|
-
import { ${names.capital}ListParams } from "src/services/${names.fs}/${
|
|
51
|
-
names.fs
|
|
52
|
-
}.types";
|
|
43
|
+
import { ${names.capital}Service } from "src/services/${names.fs}/${names.fs}.service";
|
|
44
|
+
import { ${names.capital}ListParams } from "src/services/${names.fs}/${names.fs}.types";
|
|
53
45
|
|
|
54
|
-
export function ${names.capital}IdAsyncSelect<T extends ${
|
|
55
|
-
names.capital
|
|
56
|
-
}SubsetKey>(
|
|
46
|
+
export function ${names.capital}IdAsyncSelect<T extends ${names.capital}SubsetKey>(
|
|
57
47
|
{ subset, baseListParams, textField, valueField, ...props }: DropdownProps & {
|
|
58
48
|
subset: T;
|
|
59
49
|
baseListParams?: ${names.capital}ListParams;
|
|
@@ -66,9 +56,7 @@ export function ${names.capital}IdAsyncSelect<T extends ${
|
|
|
66
56
|
baseListParams ?? {},
|
|
67
57
|
);
|
|
68
58
|
|
|
69
|
-
const { data, error } = ${names.capital}Service.use${
|
|
70
|
-
names.capitalPlural
|
|
71
|
-
}(subset, listParams);
|
|
59
|
+
const { data, error } = ${names.capital}Service.use${names.capitalPlural}(subset, listParams);
|
|
72
60
|
const { rows: ${names.camelPlural}, total } = data ?? {};
|
|
73
61
|
|
|
74
62
|
useEffect(() => {
|
|
@@ -77,9 +65,7 @@ export function ${names.capital}IdAsyncSelect<T extends ${
|
|
|
77
65
|
return {
|
|
78
66
|
key: ${names.camel}.id,
|
|
79
67
|
value: ${names.camel}[valueField ?? 'id'] as string | number,
|
|
80
|
-
text: String(${names.camel}[textField${
|
|
81
|
-
textField ? ` ?? '${textField}'` : ""
|
|
82
|
-
}]),
|
|
68
|
+
text: String(${names.camel}[textField${textField ? ` ?? '${textField}'` : ""}]),
|
|
83
69
|
};
|
|
84
70
|
}),
|
|
85
71
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import assert from "assert";
|
|
1
2
|
import inflection from "inflection";
|
|
2
|
-
import
|
|
3
|
+
import { flat, unique } from "radashi";
|
|
3
4
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
6
|
+
import type { RenderingNode, TemplateKey, TemplateOptions } from "../../types/types";
|
|
7
|
+
import { getColumnsNode } from "../entity-converter";
|
|
8
|
+
import { getEnumInfoFromColName, getRelationPropFromColName } from "../helpers";
|
|
9
|
+
import type { RenderedTemplate } from "../template";
|
|
10
|
+
import { Template } from "../template";
|
|
11
|
+
import { getZodTypeById, zodTypeToRenderingNode } from "../zod-converter";
|
|
9
12
|
|
|
10
13
|
export class Template__view_list extends Template {
|
|
11
14
|
constructor() {
|
|
@@ -19,12 +22,7 @@ export class Template__view_list extends Template {
|
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
wrapTc(
|
|
23
|
-
body: string,
|
|
24
|
-
key: string,
|
|
25
|
-
collapsing: boolean = true,
|
|
26
|
-
className: string = ""
|
|
27
|
-
) {
|
|
25
|
+
wrapTc(body: string, key: string, collapsing: boolean = true, className: string = "") {
|
|
28
26
|
return `<Table.Cell key="${key}"${collapsing ? " collapsing" : ""}${
|
|
29
27
|
className ? ` className={\`${className}\`}` : ""
|
|
30
28
|
}>${body}</Table.Cell>`;
|
|
@@ -35,7 +33,7 @@ export class Template__view_list extends Template {
|
|
|
35
33
|
col: RenderingNode,
|
|
36
34
|
names: EntityNamesRecord,
|
|
37
35
|
parentObj: string = "row",
|
|
38
|
-
withoutName: boolean = false
|
|
36
|
+
withoutName: boolean = false,
|
|
39
37
|
): string {
|
|
40
38
|
const colName = withoutName ? `${parentObj}` : `${parentObj}.${col.name}`;
|
|
41
39
|
|
|
@@ -44,16 +42,12 @@ export class Template__view_list extends Template {
|
|
|
44
42
|
case "string-date":
|
|
45
43
|
case "number-id":
|
|
46
44
|
return `<>{${colName}}</>`;
|
|
47
|
-
case "number-fk_id":
|
|
48
|
-
const relPropFk = getRelationPropFromColName(
|
|
49
|
-
entityId,
|
|
50
|
-
col.name.replace("_id", "")
|
|
51
|
-
);
|
|
45
|
+
case "number-fk_id": {
|
|
46
|
+
const relPropFk = getRelationPropFromColName(entityId, col.name.replace("_id", ""));
|
|
52
47
|
return `<>${relPropFk.with}#{${colName}}</>`;
|
|
48
|
+
}
|
|
53
49
|
case "string-image":
|
|
54
|
-
return `<>{${
|
|
55
|
-
col.nullable ? `${colName} && ` : ""
|
|
56
|
-
}<img src={${colName}} />}</>`;
|
|
50
|
+
return `<>{${col.nullable ? `${colName} && ` : ""}<img src={${colName}} />}</>`;
|
|
57
51
|
case "datetime":
|
|
58
52
|
if (col.nullable) {
|
|
59
53
|
return `<span className="text-tiny">{${colName} === null ? '-' : formatDateTime(${colName})}</span>`;
|
|
@@ -68,23 +62,18 @@ export class Template__view_list extends Template {
|
|
|
68
62
|
}
|
|
69
63
|
case "boolean":
|
|
70
64
|
return `<>{${colName} ? <Label color='green' circular>O</Label> : <Label color='grey' circular>X</Label> }</>`;
|
|
71
|
-
case "enums":
|
|
65
|
+
case "enums": {
|
|
72
66
|
const { id: enumId } = getEnumInfoFromColName(entityId, col.name);
|
|
73
|
-
return `<>{${
|
|
74
|
-
|
|
75
|
-
}${enumId}Label[${colName}]}</>`;
|
|
67
|
+
return `<>{${col.nullable ? `${colName} && ` : ""}${enumId}Label[${colName}]}</>`;
|
|
68
|
+
}
|
|
76
69
|
case "array-images":
|
|
77
|
-
return `<>{ ${colName}.map(r => ${
|
|
78
|
-
col.nullable ? `r && ` : ""
|
|
79
|
-
}<img src={r} />) }</>`;
|
|
70
|
+
return `<>{ ${colName}.map(r => ${col.nullable ? `r && ` : ""}<img src={r} />) }</>`;
|
|
80
71
|
case "number-plain":
|
|
81
72
|
return `<>{${col.nullable ? `${colName} && ` : ""}numF(${colName})}</>`;
|
|
82
73
|
case "object":
|
|
83
74
|
return `<>{/* object ${colName} */}</>`;
|
|
84
|
-
case "object-pick":
|
|
85
|
-
const pickedChild = col.children
|
|
86
|
-
(child) => child.name === col.config?.picked
|
|
87
|
-
);
|
|
75
|
+
case "object-pick": {
|
|
76
|
+
const pickedChild = col.children?.find((child) => child.name === col.config?.picked);
|
|
88
77
|
if (!pickedChild) {
|
|
89
78
|
throw new Error(`object-pick 선택 실패 (오브젝트: ${col.name})`);
|
|
90
79
|
}
|
|
@@ -92,8 +81,9 @@ export class Template__view_list extends Template {
|
|
|
92
81
|
entityId,
|
|
93
82
|
pickedChild,
|
|
94
83
|
names,
|
|
95
|
-
`${colName}${col.nullable ? "?" : ""}
|
|
84
|
+
`${colName}${col.nullable ? "?" : ""}`,
|
|
96
85
|
);
|
|
86
|
+
}
|
|
97
87
|
case "array":
|
|
98
88
|
return `<>{ /* array ${colName} */ }</>`;
|
|
99
89
|
default:
|
|
@@ -104,49 +94,44 @@ export class Template__view_list extends Template {
|
|
|
104
94
|
renderColumnImport(
|
|
105
95
|
entityId: string,
|
|
106
96
|
col: RenderingNode,
|
|
107
|
-
names: EntityNamesRecord
|
|
97
|
+
names: EntityNamesRecord,
|
|
108
98
|
): (string | null)[] {
|
|
109
99
|
if (col.renderType === "enums") {
|
|
110
100
|
const { id: enumId } = getEnumInfoFromColName(names.capital, col.name);
|
|
111
|
-
return [
|
|
112
|
-
`import { ${enumId}Label } from 'src/services/sonamu.generated';`,
|
|
113
|
-
];
|
|
101
|
+
return [`import { ${enumId}Label } from 'src/services/sonamu.generated';`];
|
|
114
102
|
} else if (col.renderType === "object") {
|
|
115
103
|
try {
|
|
116
104
|
const relProp = getRelationPropFromColName(entityId, col.name);
|
|
117
|
-
const result = col.children
|
|
105
|
+
const result = col.children?.map((child) => {
|
|
118
106
|
entityId = relProp.with;
|
|
119
107
|
names = EntityManager.getNamesFromId(relProp.with);
|
|
120
108
|
return this.renderColumnImport(entityId, child, names);
|
|
121
109
|
});
|
|
122
|
-
return
|
|
110
|
+
return flat(result ?? []);
|
|
123
111
|
} catch {
|
|
124
112
|
return [null];
|
|
125
113
|
}
|
|
126
114
|
} else if (col.renderType === "array") {
|
|
127
|
-
|
|
115
|
+
assert(col.element);
|
|
116
|
+
return this.renderColumnImport(entityId, col.element, names);
|
|
128
117
|
}
|
|
129
118
|
|
|
130
119
|
return [null];
|
|
131
120
|
}
|
|
132
121
|
|
|
133
|
-
renderFilterImport(
|
|
134
|
-
entityId: string,
|
|
135
|
-
col: RenderingNode,
|
|
136
|
-
names: EntityNamesRecord
|
|
137
|
-
) {
|
|
122
|
+
renderFilterImport(entityId: string, col: RenderingNode, names: EntityNamesRecord) {
|
|
138
123
|
if (col.name === "search") {
|
|
139
124
|
return `import { ${names.capital}SearchInput } from "src/components/${names.fs}/${names.capital}SearchInput";`;
|
|
140
125
|
} else if (col.renderType === "enums") {
|
|
141
126
|
if (col.name === "orderBy") {
|
|
142
|
-
const componentId = `${names.capital}${inflection.camelize(
|
|
143
|
-
col.name
|
|
144
|
-
)}Select`;
|
|
127
|
+
const componentId = `${names.capital}${inflection.camelize(col.name)}Select`;
|
|
145
128
|
return `import { ${componentId} } from "src/components/${names.fs}/${componentId}";`;
|
|
146
129
|
} else {
|
|
147
130
|
try {
|
|
148
|
-
const { id, targetEntityNames: targetMDNames } =
|
|
149
|
-
|
|
131
|
+
const { id, targetEntityNames: targetMDNames } = getEnumInfoFromColName(
|
|
132
|
+
entityId,
|
|
133
|
+
col.name,
|
|
134
|
+
);
|
|
150
135
|
const componentId = `${id}Select`;
|
|
151
136
|
return `import { ${componentId} } from "src/components/${targetMDNames.fs}/${componentId}";`;
|
|
152
137
|
} catch {
|
|
@@ -155,10 +140,7 @@ export class Template__view_list extends Template {
|
|
|
155
140
|
}
|
|
156
141
|
} else if (col.renderType === "number-fk_id") {
|
|
157
142
|
try {
|
|
158
|
-
const relProp = getRelationPropFromColName(
|
|
159
|
-
entityId,
|
|
160
|
-
col.name.replace("_id", "")
|
|
161
|
-
);
|
|
143
|
+
const relProp = getRelationPropFromColName(entityId, col.name.replace("_id", ""));
|
|
162
144
|
const targetNames = EntityManager.getNamesFromId(relProp.with);
|
|
163
145
|
const componentId = `${relProp.with}IdAsyncSelect`;
|
|
164
146
|
return `import { ${componentId} } from "src/components/${targetNames.fs}/${componentId}";`;
|
|
@@ -166,9 +148,7 @@ export class Template__view_list extends Template {
|
|
|
166
148
|
return "";
|
|
167
149
|
}
|
|
168
150
|
} else {
|
|
169
|
-
throw new Error(
|
|
170
|
-
`렌더 불가능한 필터 임포트 ${col.name} ${col.renderType}`
|
|
171
|
-
);
|
|
151
|
+
throw new Error(`렌더 불가능한 필터 임포트 ${col.name} ${col.renderType}`);
|
|
172
152
|
}
|
|
173
153
|
}
|
|
174
154
|
|
|
@@ -190,15 +170,10 @@ export class Template__view_list extends Template {
|
|
|
190
170
|
return "";
|
|
191
171
|
}
|
|
192
172
|
}
|
|
193
|
-
return `<${componentId} {...register('${col.name}')} ${
|
|
194
|
-
isClearable ? "clearable" : ""
|
|
195
|
-
} />`;
|
|
173
|
+
return `<${componentId} {...register('${col.name}')} ${isClearable ? "clearable" : ""} />`;
|
|
196
174
|
} else if (col.renderType === "number-fk_id") {
|
|
197
175
|
try {
|
|
198
|
-
const relProp = getRelationPropFromColName(
|
|
199
|
-
entityId,
|
|
200
|
-
col.name.replace("_id", "")
|
|
201
|
-
);
|
|
176
|
+
const relProp = getRelationPropFromColName(entityId, col.name.replace("_id", ""));
|
|
202
177
|
componentId = `${relProp.with}IdAsyncSelect`;
|
|
203
178
|
return `<${componentId} {...register('${col.name}')} ${
|
|
204
179
|
isClearable ? "clearable" : ""
|
|
@@ -207,9 +182,7 @@ export class Template__view_list extends Template {
|
|
|
207
182
|
return "";
|
|
208
183
|
}
|
|
209
184
|
} else {
|
|
210
|
-
throw new Error(
|
|
211
|
-
`렌더 불가능한 필터 임포트 ${col.name} ${col.renderType}`
|
|
212
|
-
);
|
|
185
|
+
throw new Error(`렌더 불가능한 필터 임포트 ${col.name} ${col.renderType}`);
|
|
213
186
|
}
|
|
214
187
|
}
|
|
215
188
|
|
|
@@ -221,9 +194,7 @@ export class Template__view_list extends Template {
|
|
|
221
194
|
orderBy: "id-desc",
|
|
222
195
|
search: "title",
|
|
223
196
|
};
|
|
224
|
-
const orderByZodType = columns.find(
|
|
225
|
-
(col) => col.name === "orderBy"
|
|
226
|
-
)?.zodType;
|
|
197
|
+
const orderByZodType = columns.find((col) => col.name === "orderBy")?.zodType;
|
|
227
198
|
if (orderByZodType && orderByZodType instanceof z.ZodEnum) {
|
|
228
199
|
def.orderBy = orderByZodType.options[0].toString();
|
|
229
200
|
}
|
|
@@ -234,11 +205,11 @@ export class Template__view_list extends Template {
|
|
|
234
205
|
return def;
|
|
235
206
|
}
|
|
236
207
|
|
|
237
|
-
render(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
listParamsNode
|
|
241
|
-
|
|
208
|
+
async render({ entityId }: TemplateOptions["view_list"]) {
|
|
209
|
+
const columnsNode = await getColumnsNode(entityId, "A");
|
|
210
|
+
const listParamsZodType = await getZodTypeById(`${entityId}ListParams`);
|
|
211
|
+
const listParamsNode = zodTypeToRenderingNode(listParamsZodType);
|
|
212
|
+
|
|
242
213
|
const names = EntityManager.getNamesFromId(entityId);
|
|
243
214
|
const entity = EntityManager.get(entityId);
|
|
244
215
|
|
|
@@ -260,17 +231,16 @@ export class Template__view_list extends Template {
|
|
|
260
231
|
(col) =>
|
|
261
232
|
col.name !== "id" &&
|
|
262
233
|
col.name !== "queryMode" &&
|
|
263
|
-
(["enums", "number-id"].includes(col.renderType) ||
|
|
264
|
-
col.name.endsWith("_id"))
|
|
234
|
+
(["enums", "number-id"].includes(col.renderType) || col.name.endsWith("_id")),
|
|
265
235
|
)
|
|
266
236
|
// orderBy가 가장 뒤로 오게 순서 조정
|
|
267
237
|
.sort((a) => {
|
|
268
|
-
return a.name
|
|
238
|
+
return a.name === "orderBy" ? 1 : -1;
|
|
269
239
|
});
|
|
270
240
|
|
|
271
241
|
// 필터 컬럼을 프리 템플릿으로 설정
|
|
272
242
|
const preTemplates: RenderedTemplate["preTemplates"] = [];
|
|
273
|
-
for (
|
|
243
|
+
for (const col of filterColumns) {
|
|
274
244
|
let key: TemplateKey;
|
|
275
245
|
let targetEntityId = entityId;
|
|
276
246
|
let enumId: string | undefined;
|
|
@@ -283,10 +253,7 @@ export class Template__view_list extends Template {
|
|
|
283
253
|
} else {
|
|
284
254
|
key = "view_enums_select";
|
|
285
255
|
try {
|
|
286
|
-
const { targetEntityNames, id } = getEnumInfoFromColName(
|
|
287
|
-
entityId,
|
|
288
|
-
col.name
|
|
289
|
-
);
|
|
256
|
+
const { targetEntityNames, id } = getEnumInfoFromColName(entityId, col.name);
|
|
290
257
|
targetEntityId = targetEntityNames.capital;
|
|
291
258
|
enumId = id;
|
|
292
259
|
} catch {
|
|
@@ -296,10 +263,7 @@ export class Template__view_list extends Template {
|
|
|
296
263
|
} else {
|
|
297
264
|
key = "view_id_async_select";
|
|
298
265
|
try {
|
|
299
|
-
const relProp = getRelationPropFromColName(
|
|
300
|
-
entityId,
|
|
301
|
-
col.name.replace("_id", "")
|
|
302
|
-
);
|
|
266
|
+
const relProp = getRelationPropFromColName(entityId, col.name.replace("_id", ""));
|
|
303
267
|
targetEntityId = relProp.with;
|
|
304
268
|
} catch {
|
|
305
269
|
continue;
|
|
@@ -316,17 +280,18 @@ export class Template__view_list extends Template {
|
|
|
316
280
|
}
|
|
317
281
|
|
|
318
282
|
// 리스트 컬럼
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
283
|
+
assert(columnsNode.children);
|
|
284
|
+
const columnImports = unique(
|
|
285
|
+
columnsNode.children
|
|
286
|
+
.flatMap((col) => {
|
|
322
287
|
return this.renderColumnImport(entityId, col, names);
|
|
323
288
|
})
|
|
324
|
-
.
|
|
325
|
-
.filter((col) => col !== null)
|
|
289
|
+
.filter((col) => col !== null),
|
|
326
290
|
).join("\n");
|
|
327
291
|
|
|
328
292
|
// SearchInput
|
|
329
|
-
preTemplates
|
|
293
|
+
assert(preTemplates);
|
|
294
|
+
preTemplates.push({
|
|
330
295
|
key: "view_search_input",
|
|
331
296
|
options: {
|
|
332
297
|
entityId,
|
|
@@ -358,12 +323,8 @@ import { DateTime } from "luxon";
|
|
|
358
323
|
import { DelButton, EditButton, AppBreadcrumbs, AddButton, useSelection, useListParams, SonamuCol, numF, formatDate, formatDateTime } from '@sonamu-kit/react-sui';
|
|
359
324
|
|
|
360
325
|
import { ${names.capital}SubsetA } from "src/services/sonamu.generated";
|
|
361
|
-
import { ${names.capital}Service } from 'src/services/${names.fs}/${
|
|
362
|
-
|
|
363
|
-
}.service';
|
|
364
|
-
import { ${names.capital}ListParams } from 'src/services/${names.fs}/${
|
|
365
|
-
names.fs
|
|
366
|
-
}.types';
|
|
326
|
+
import { ${names.capital}Service } from 'src/services/${names.fs}/${names.fs}.service';
|
|
327
|
+
import { ${names.capital}ListParams } from 'src/services/${names.fs}/${names.fs}.types';
|
|
367
328
|
${columnImports}
|
|
368
329
|
${filterColumns
|
|
369
330
|
.map((col) => {
|
|
@@ -565,56 +526,3 @@ export default function ${names.capital}List({}: ${names.capital}ListProps) {
|
|
|
565
526
|
};
|
|
566
527
|
}
|
|
567
528
|
}
|
|
568
|
-
|
|
569
|
-
export function getEnumInfoFromColName(
|
|
570
|
-
entityId: string,
|
|
571
|
-
colName: string
|
|
572
|
-
): {
|
|
573
|
-
id: string;
|
|
574
|
-
targetEntityNames: EntityNamesRecord;
|
|
575
|
-
targetEntityId: string;
|
|
576
|
-
title: string;
|
|
577
|
-
} {
|
|
578
|
-
const baseEntity = EntityManager.get(entityId);
|
|
579
|
-
const prop = baseEntity.props.find((p) => p.name === colName);
|
|
580
|
-
if (prop && isEnumProp(prop)) {
|
|
581
|
-
return {
|
|
582
|
-
id: prop.id,
|
|
583
|
-
targetEntityId: entityId,
|
|
584
|
-
targetEntityNames: EntityManager.getNamesFromId(entityId),
|
|
585
|
-
title: prop.desc ?? prop.id,
|
|
586
|
-
};
|
|
587
|
-
} else {
|
|
588
|
-
const idCandidate = inflection.camelize(
|
|
589
|
-
inflection.underscore(entityId) + "_" + inflection.underscore(colName),
|
|
590
|
-
false
|
|
591
|
-
);
|
|
592
|
-
try {
|
|
593
|
-
const targetEntityNames = EntityManager.getNamesFromId(entityId);
|
|
594
|
-
return {
|
|
595
|
-
id: idCandidate,
|
|
596
|
-
targetEntityId: entityId,
|
|
597
|
-
targetEntityNames: targetEntityNames,
|
|
598
|
-
title: idCandidate,
|
|
599
|
-
};
|
|
600
|
-
} catch {}
|
|
601
|
-
throw new Error(`찾을 수 없는 EnumProp ${colName}`);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
export function getRelationPropFromColName(
|
|
606
|
-
entityId: string,
|
|
607
|
-
colName: string
|
|
608
|
-
): RelationProp {
|
|
609
|
-
const baseEntity = EntityManager.get(entityId);
|
|
610
|
-
const relProp = baseEntity.props.find((prop) => prop.name === colName);
|
|
611
|
-
if (isRelationProp(relProp)) {
|
|
612
|
-
const relEntity = EntityManager.get(relProp.with);
|
|
613
|
-
if (relEntity.parentId !== undefined) {
|
|
614
|
-
throw new Error("Only parent entities can be used as relation props");
|
|
615
|
-
}
|
|
616
|
-
return relProp;
|
|
617
|
-
} else {
|
|
618
|
-
throw new Error(`찾을 수 없는 Relation ${colName}`);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Template } from "
|
|
1
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
+
import type { TemplateOptions } from "../../types/types";
|
|
3
|
+
import { Template } from "../template";
|
|
4
4
|
|
|
5
5
|
export class Template__view_list_columns extends Template {
|
|
6
6
|
constructor() {
|
|
@@ -15,11 +15,7 @@ export class Template__view_list_columns extends Template {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// 컬럼
|
|
18
|
-
render({
|
|
19
|
-
entityId,
|
|
20
|
-
columns,
|
|
21
|
-
columnImports,
|
|
22
|
-
}: TemplateOptions["view_list_columns"]) {
|
|
18
|
+
render({ entityId, columns, columnImports }: TemplateOptions["view_list_columns"]) {
|
|
23
19
|
const names = EntityManager.getNamesFromId(entityId);
|
|
24
20
|
|
|
25
21
|
return {
|
|
@@ -35,9 +31,7 @@ import {
|
|
|
35
31
|
} from 'semantic-ui-react';
|
|
36
32
|
import { DateTime } from "luxon";
|
|
37
33
|
import { TFColumn } from "src/typeframe/iso-types";
|
|
38
|
-
import { ${names.capital}SubsetA } from "src/services/${names.fs}/${
|
|
39
|
-
names.fs
|
|
40
|
-
}.generated";
|
|
34
|
+
import { ${names.capital}SubsetA } from "src/services/${names.fs}/${names.fs}.generated";
|
|
41
35
|
${columnImports}
|
|
42
36
|
|
|
43
37
|
const columns: { [key in Exclude<keyof ${
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Template } from "
|
|
1
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
+
import type { TemplateOptions } from "../../types/types";
|
|
3
|
+
import { Template } from "../template";
|
|
4
4
|
|
|
5
5
|
export class Template__view_search_input extends Template {
|
|
6
6
|
constructor() {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import type { TemplateKey } from "../types/types";
|
|
3
|
+
import { globAsync } from "../utils/async-utils";
|
|
4
|
+
import { importMembers } from "../utils/esm-utils";
|
|
5
|
+
import { Template } from "./template";
|
|
6
|
+
|
|
7
|
+
class TemplateManagerClass {
|
|
8
|
+
private templates: Map<TemplateKey | string, Template> = new Map();
|
|
9
|
+
isAutoloaded: boolean = false;
|
|
10
|
+
|
|
11
|
+
// ================================
|
|
12
|
+
// 기본 메서드
|
|
13
|
+
// ================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 빌트인 템플릿 로드 (implementations/*.template.js)
|
|
17
|
+
*/
|
|
18
|
+
async autoload(): Promise<void> {
|
|
19
|
+
if (this.isAutoloaded) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const templateFiles = await globAsync(
|
|
23
|
+
path.join(import.meta.dirname, "implementations/*.template.js"),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
for (const templateFile of templateFiles) {
|
|
27
|
+
const templates = await importMembers<unknown>(templateFile);
|
|
28
|
+
if (
|
|
29
|
+
templates.length === 1 &&
|
|
30
|
+
typeof templates[0].value === "function" &&
|
|
31
|
+
templates[0].value.prototype instanceof Template
|
|
32
|
+
) {
|
|
33
|
+
const instance = new (templates[0].value as new () => Template)();
|
|
34
|
+
this.templates.set(instance.key, instance);
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Template ${templateFile} should export only one class that extends Template`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const [key, template] of this.templates) {
|
|
43
|
+
Template._getTemplatesMap().set(key as TemplateKey, template);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.isAutoloaded = true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 템플릿 다시 로드
|
|
51
|
+
*/
|
|
52
|
+
async reload(): Promise<void> {
|
|
53
|
+
this.templates.clear();
|
|
54
|
+
Template._clearTemplates();
|
|
55
|
+
this.isAutoloaded = false;
|
|
56
|
+
await this.autoload();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 프로젝트 디렉토리에서 커스텀 템플릿 로드
|
|
61
|
+
*/
|
|
62
|
+
async loadFromDirectory(dir: string): Promise<number> {
|
|
63
|
+
const templateFiles = await globAsync(path.join(dir, "*.template.{ts,js}"));
|
|
64
|
+
let count = 0;
|
|
65
|
+
|
|
66
|
+
for (const file of templateFiles) {
|
|
67
|
+
const templates = await importMembers<unknown>(file);
|
|
68
|
+
for (const { value } of templates) {
|
|
69
|
+
if (this.isTemplateClass(value)) {
|
|
70
|
+
const instance = new (value as new () => Template)();
|
|
71
|
+
this.register(instance);
|
|
72
|
+
count++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return count;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private isTemplateClass(value: unknown): boolean {
|
|
81
|
+
return typeof value === "function" && value.prototype instanceof Template;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ================================
|
|
85
|
+
// 템플릿 등록
|
|
86
|
+
// ================================
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 템플릿 등록
|
|
90
|
+
*/
|
|
91
|
+
register(template: Template): void {
|
|
92
|
+
this.templates.set(template.key, template);
|
|
93
|
+
// 하위 호환
|
|
94
|
+
Template._getTemplatesMap().set(template.key as TemplateKey, template);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 여러 템플릿 등록
|
|
99
|
+
*/
|
|
100
|
+
registerAll(templates: Template[]): void {
|
|
101
|
+
for (const template of templates) {
|
|
102
|
+
this.register(template);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ================================
|
|
107
|
+
// 템플릿 조회
|
|
108
|
+
// ================================
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 템플릿 조회
|
|
112
|
+
* 빌트인 : 자동완성 지원
|
|
113
|
+
* 커스텀 : 임의 문자열 지원
|
|
114
|
+
*/
|
|
115
|
+
get(key: TemplateKey | (string & {})): Template {
|
|
116
|
+
const template = this.templates.get(key);
|
|
117
|
+
if (!template) {
|
|
118
|
+
throw new Error(`Template '${key}' not found. Available: [${this.getAllKeys().join(", ")}]`);
|
|
119
|
+
}
|
|
120
|
+
return template;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 템플릿 존재 여부
|
|
125
|
+
*/
|
|
126
|
+
exists(key: string): boolean {
|
|
127
|
+
return this.templates.has(key);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 모든 템플릿 키 목록
|
|
132
|
+
*/
|
|
133
|
+
getAllKeys(): string[] {
|
|
134
|
+
return Array.from(this.templates.keys()).sort();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 등록된 템플릿 개수
|
|
139
|
+
*/
|
|
140
|
+
get size(): number {
|
|
141
|
+
return this.templates.size;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ================================
|
|
145
|
+
// 테스트 유틸리티
|
|
146
|
+
// ================================
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 모든 상태 초기화 (테스트용)
|
|
150
|
+
*/
|
|
151
|
+
reset(): void {
|
|
152
|
+
this.templates.clear();
|
|
153
|
+
this.isAutoloaded = false;
|
|
154
|
+
Template._clearTemplates();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 격리된 인스턴스 생성 (테스트용)
|
|
159
|
+
*/
|
|
160
|
+
static createInstance(): TemplateManagerClass {
|
|
161
|
+
return new TemplateManagerClass();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const TemplateManager = new TemplateManagerClass();
|
|
166
|
+
export { TemplateManagerClass };
|