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,18 +1,21 @@
|
|
|
1
|
+
import assert from "assert";
|
|
1
2
|
import inflection from "inflection";
|
|
2
|
-
import
|
|
3
|
-
import { TemplateOptions } from "../types/types";
|
|
4
|
-
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
5
|
-
import { ApiParamType, ApiParam } from "../types/types";
|
|
3
|
+
import { diff, group, sort, unique } from "radashi";
|
|
6
4
|
import {
|
|
7
|
-
apiParamTypeToTsType,
|
|
8
5
|
apiParamToTsCode,
|
|
9
|
-
unwrapPromiseOnce,
|
|
10
|
-
zodTypeToTsTypeDef,
|
|
11
6
|
apiParamToTsCodeAsObject,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
7
|
+
apiParamTypeToTsType,
|
|
8
|
+
unwrapPromiseOnce,
|
|
9
|
+
} from "../../api/code-converters";
|
|
10
|
+
import type { ExtendedApi } from "../../api/decorators";
|
|
11
|
+
import { Sonamu } from "../../api/sonamu";
|
|
12
|
+
import type { EntityNamesRecord } from "../../entity/entity-manager";
|
|
13
|
+
import { Naite } from "../../naite/naite";
|
|
14
|
+
import type { TemplateOptions } from "../../types/types";
|
|
15
|
+
import { type ApiParam, ApiParamType } from "../../types/types";
|
|
16
|
+
import { assertDefined } from "../../utils/utils";
|
|
17
|
+
import { Template } from "../template";
|
|
18
|
+
import { zodTypeToTsTypeDef } from "../zod-converter";
|
|
16
19
|
|
|
17
20
|
export class Template__service extends Template {
|
|
18
21
|
constructor() {
|
|
@@ -26,29 +29,33 @@ export class Template__service extends Template {
|
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
render({ namesRecord }: TemplateOptions["service"]
|
|
32
|
+
render({ namesRecord }: TemplateOptions["service"]) {
|
|
33
|
+
Naite.t("render", { namesRecord });
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
syncer: { apis },
|
|
37
|
+
} = Sonamu;
|
|
38
|
+
|
|
39
|
+
const apisForThisModel = apis.filter((api) => api.modelName === `${namesRecord.capital}Model`);
|
|
40
|
+
|
|
30
41
|
// 서비스 TypeSource
|
|
31
|
-
const { lines, importKeys } = this.getTypeSource(
|
|
42
|
+
const { lines, importKeys } = this.getTypeSource(apisForThisModel);
|
|
32
43
|
|
|
33
44
|
// AxiosProgressEvent 있는지 확인
|
|
34
45
|
const hasAxiosProgressEvent = apis.find((api) =>
|
|
35
|
-
(api.options.clients ?? []).includes("axios-multipart")
|
|
46
|
+
(api.options.clients ?? []).includes("axios-multipart"),
|
|
36
47
|
);
|
|
37
48
|
|
|
38
49
|
return {
|
|
39
50
|
...this.getTargetAndPath(namesRecord),
|
|
40
51
|
body: lines.join("\n"),
|
|
41
|
-
importKeys: importKeys.filter(
|
|
42
|
-
(key) => ["ListResult"].includes(key) === false
|
|
43
|
-
),
|
|
52
|
+
importKeys: importKeys.filter((key) => ["ListResult"].includes(key) === false),
|
|
44
53
|
customHeaders: [
|
|
45
54
|
`import { z } from 'zod';`,
|
|
46
55
|
`import qs from "qs";`,
|
|
47
|
-
`import useSWR, { SWRResponse } from "swr";`,
|
|
56
|
+
`import useSWR, { type SWRResponse } from "swr";`,
|
|
48
57
|
`import { fetch, ListResult, SWRError, SwrOptions, handleConditional, swrPostFetcher, EventHandlers, SSEStreamOptions, useSSEStream } from '../sonamu.shared';`,
|
|
49
|
-
...(hasAxiosProgressEvent
|
|
50
|
-
? [`import { AxiosProgressEvent } from 'axios';`]
|
|
51
|
-
: []),
|
|
58
|
+
...(hasAxiosProgressEvent ? [`import { type AxiosProgressEvent } from 'axios';`] : []),
|
|
52
59
|
],
|
|
53
60
|
};
|
|
54
61
|
}
|
|
@@ -62,10 +69,11 @@ export class Template__service extends Template {
|
|
|
62
69
|
// 제네릭에서 선언한 타입, importKeys에서 제외 필요
|
|
63
70
|
let typeParamNames: string[] = [];
|
|
64
71
|
|
|
65
|
-
const groups =
|
|
72
|
+
const groups = group(apis, (api) => api.modelName);
|
|
66
73
|
const body = Object.keys(groups)
|
|
67
74
|
.map((modelName) => {
|
|
68
75
|
const methods = groups[modelName];
|
|
76
|
+
assert(methods);
|
|
69
77
|
const methodCodes = methods
|
|
70
78
|
.map((api) => {
|
|
71
79
|
// 컨텍스트 제외된 파라미터 리스트
|
|
@@ -73,7 +81,7 @@ export class Template__service extends Template {
|
|
|
73
81
|
(param) =>
|
|
74
82
|
!ApiParamType.isContext(param.type) &&
|
|
75
83
|
!ApiParamType.isRefKnex(param.type) &&
|
|
76
|
-
!(param.optional === true && param.name.startsWith("_")) // _로 시작하는 파라미터는 제외
|
|
84
|
+
!(param.optional === true && param.name.startsWith("_")), // _로 시작하는 파라미터는 제외
|
|
77
85
|
);
|
|
78
86
|
|
|
79
87
|
// 파라미터 타입 정의
|
|
@@ -83,40 +91,31 @@ export class Template__service extends Template {
|
|
|
83
91
|
})
|
|
84
92
|
.join(", ");
|
|
85
93
|
typeParamNames = typeParamNames.concat(
|
|
86
|
-
api.typeParameters.map((typeParam) => typeParam.id)
|
|
94
|
+
api.typeParameters.map((typeParam) => typeParam.id),
|
|
87
95
|
);
|
|
88
96
|
|
|
89
97
|
// 파라미터 정의
|
|
90
|
-
const paramsDef = apiParamToTsCode(
|
|
91
|
-
paramsWithoutContext,
|
|
92
|
-
importKeys
|
|
93
|
-
);
|
|
98
|
+
const paramsDef = apiParamToTsCode(paramsWithoutContext, importKeys);
|
|
94
99
|
|
|
95
100
|
// 파라미터 정의 (객체 형태)
|
|
96
|
-
const paramsDefAsObject = apiParamToTsCodeAsObject(
|
|
97
|
-
paramsWithoutContext,
|
|
98
|
-
importKeys
|
|
99
|
-
);
|
|
101
|
+
const paramsDefAsObject = apiParamToTsCodeAsObject(paramsWithoutContext, importKeys);
|
|
100
102
|
|
|
101
103
|
// 리턴 타입 정의
|
|
102
104
|
const returnTypeDef = apiParamTypeToTsType(
|
|
103
|
-
unwrapPromiseOnce(api.returnType),
|
|
104
|
-
importKeys
|
|
105
|
+
assertDefined(unwrapPromiseOnce(api.returnType)),
|
|
106
|
+
importKeys,
|
|
105
107
|
);
|
|
106
108
|
|
|
107
109
|
// 페이로드 데이터 정의
|
|
108
|
-
const payloadDef = `{ ${paramsWithoutContext
|
|
109
|
-
.map((param) => param.name)
|
|
110
|
-
.join(", ")} }`;
|
|
110
|
+
const payloadDef = `{ ${paramsWithoutContext.map((param) => param.name).join(", ")} }`;
|
|
111
111
|
|
|
112
112
|
// 기본 URL
|
|
113
|
-
const apiBaseUrl = `${Sonamu.config.route.prefix}${api.path}`;
|
|
113
|
+
const apiBaseUrl = `${Sonamu.config.api.route.prefix}${api.path}`;
|
|
114
114
|
|
|
115
|
+
const clients = api.options.clients ?? [];
|
|
115
116
|
return [
|
|
116
117
|
// 클라이언트별로 생성
|
|
117
|
-
...
|
|
118
|
-
client === "swr" ? 0 : 1
|
|
119
|
-
).map((client) => {
|
|
118
|
+
...sort(clients, (client) => (client === "swr" ? 0 : 1)).map((client) => {
|
|
120
119
|
switch (client) {
|
|
121
120
|
case "axios":
|
|
122
121
|
return this.renderAxios(
|
|
@@ -125,7 +124,7 @@ export class Template__service extends Template {
|
|
|
125
124
|
typeParamsDef,
|
|
126
125
|
paramsDef,
|
|
127
126
|
returnTypeDef,
|
|
128
|
-
payloadDef
|
|
127
|
+
payloadDef,
|
|
129
128
|
);
|
|
130
129
|
case "axios-multipart":
|
|
131
130
|
return this.renderAxiosMultipart(
|
|
@@ -134,7 +133,7 @@ export class Template__service extends Template {
|
|
|
134
133
|
typeParamsDef,
|
|
135
134
|
paramsDef,
|
|
136
135
|
returnTypeDef,
|
|
137
|
-
paramsWithoutContext
|
|
136
|
+
paramsWithoutContext,
|
|
138
137
|
);
|
|
139
138
|
case "swr":
|
|
140
139
|
return this.renderSwr(
|
|
@@ -143,7 +142,7 @@ export class Template__service extends Template {
|
|
|
143
142
|
typeParamsDef,
|
|
144
143
|
paramsDef,
|
|
145
144
|
returnTypeDef,
|
|
146
|
-
payloadDef
|
|
145
|
+
payloadDef,
|
|
147
146
|
);
|
|
148
147
|
case "window-fetch":
|
|
149
148
|
return this.renderWindowFetch(
|
|
@@ -151,16 +150,14 @@ export class Template__service extends Template {
|
|
|
151
150
|
apiBaseUrl,
|
|
152
151
|
typeParamsDef,
|
|
153
152
|
paramsDef,
|
|
154
|
-
payloadDef
|
|
153
|
+
payloadDef,
|
|
155
154
|
);
|
|
156
155
|
default:
|
|
157
156
|
return `// Not supported ${inflection.camelize(client, true)} yet.`;
|
|
158
157
|
}
|
|
159
158
|
}),
|
|
160
159
|
// 스트리밍인 경우
|
|
161
|
-
...(api.streamOptions
|
|
162
|
-
? [this.renderStream(api, apiBaseUrl, paramsDefAsObject)]
|
|
163
|
-
: []),
|
|
160
|
+
...(api.streamOptions ? [this.renderStream(api, apiBaseUrl, paramsDefAsObject)] : []),
|
|
164
161
|
].join("\n");
|
|
165
162
|
})
|
|
166
163
|
.join("\n\n");
|
|
@@ -173,7 +170,7 @@ ${methodCodes}
|
|
|
173
170
|
|
|
174
171
|
return {
|
|
175
172
|
lines: [body],
|
|
176
|
-
importKeys:
|
|
173
|
+
importKeys: diff(unique(importKeys), typeParamNames),
|
|
177
174
|
};
|
|
178
175
|
}
|
|
179
176
|
|
|
@@ -183,10 +180,10 @@ ${methodCodes}
|
|
|
183
180
|
typeParamsDef: string,
|
|
184
181
|
paramsDef: string,
|
|
185
182
|
returnTypeDef: string,
|
|
186
|
-
payloadDef: string
|
|
183
|
+
payloadDef: string,
|
|
187
184
|
) {
|
|
188
185
|
const methodNameAxios = api.options.resourceName
|
|
189
|
-
?
|
|
186
|
+
? `get${inflection.camelize(api.options.resourceName)}`
|
|
190
187
|
: api.methodName;
|
|
191
188
|
|
|
192
189
|
if (api.options.httpMethod === "GET") {
|
|
@@ -219,7 +216,7 @@ export async function ${methodNameAxios}${typeParamsDef}(${paramsDef}): Promise<
|
|
|
219
216
|
typeParamsDef: string,
|
|
220
217
|
paramsDef: string,
|
|
221
218
|
returnTypeDef: string,
|
|
222
|
-
paramsWithoutContext: ApiParam[]
|
|
219
|
+
paramsWithoutContext: ApiParam[],
|
|
223
220
|
) {
|
|
224
221
|
const isMultiple = api.uploadOptions?.mode === "multiple";
|
|
225
222
|
const fileParamName = isMultiple ? "files" : "file";
|
|
@@ -227,17 +224,15 @@ export async function ${methodNameAxios}${typeParamsDef}(${paramsDef}): Promise<
|
|
|
227
224
|
|
|
228
225
|
const formDataDef = isMultiple
|
|
229
226
|
? [
|
|
230
|
-
`${fileParamName}.forEach(f => formData.append("${fileParamName}", f))
|
|
227
|
+
`${fileParamName}.forEach(f => { formData.append("${fileParamName}", f) } ); `,
|
|
231
228
|
...paramsWithoutContext.map(
|
|
232
|
-
(param) =>
|
|
233
|
-
`formData.append('${param.name}', String(${param.name}));`
|
|
229
|
+
(param) => `formData.append('${param.name}', String(${param.name}));`,
|
|
234
230
|
),
|
|
235
231
|
].join("\n")
|
|
236
232
|
: [
|
|
237
233
|
`formData.append("${fileParamName}", ${fileParamName});`,
|
|
238
234
|
...paramsWithoutContext.map(
|
|
239
|
-
(param) =>
|
|
240
|
-
`formData.append('${param.name}', String(${param.name}));`
|
|
235
|
+
(param) => `formData.append('${param.name}', String(${param.name}));`,
|
|
241
236
|
),
|
|
242
237
|
].join("\n");
|
|
243
238
|
|
|
@@ -270,23 +265,21 @@ export async function ${api.methodName}${typeParamsDef}(
|
|
|
270
265
|
typeParamsDef: string,
|
|
271
266
|
paramsDef: string,
|
|
272
267
|
returnTypeDef: string,
|
|
273
|
-
payloadDef: string
|
|
268
|
+
payloadDef: string,
|
|
274
269
|
) {
|
|
275
270
|
const methodNameSwr = api.options.resourceName
|
|
276
|
-
?
|
|
277
|
-
:
|
|
278
|
-
return ` export function ${inflection.camelize(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
271
|
+
? `use${inflection.camelize(api.options.resourceName)}`
|
|
272
|
+
: `use${inflection.camelize(api.methodName)}`;
|
|
273
|
+
return ` export function ${inflection.camelize(methodNameSwr, true)}${typeParamsDef}(${[
|
|
274
|
+
paramsDef,
|
|
275
|
+
"swrOptions?: SwrOptions",
|
|
276
|
+
]
|
|
282
277
|
.filter((p) => p !== "")
|
|
283
278
|
.join(",")}, ): SWRResponse<${returnTypeDef}, SWRError> {
|
|
284
279
|
return useSWR(handleConditional([
|
|
285
280
|
\`${apiBaseUrl}\`,
|
|
286
281
|
${payloadDef},
|
|
287
|
-
], swrOptions?.conditional)${
|
|
288
|
-
api.options.httpMethod === "POST" ? ", swrPostFetcher" : ""
|
|
289
|
-
}${
|
|
282
|
+
], swrOptions?.conditional)${api.options.httpMethod === "POST" ? ", swrPostFetcher" : ""}${
|
|
290
283
|
api.options.timeout ? `, { loadingTimeout: ${api.options.timeout} }` : ""
|
|
291
284
|
});
|
|
292
285
|
}`;
|
|
@@ -297,35 +290,26 @@ export async function ${api.methodName}${typeParamsDef}(
|
|
|
297
290
|
apiBaseUrl: string,
|
|
298
291
|
typeParamsDef: string,
|
|
299
292
|
paramsDef: string,
|
|
300
|
-
payloadDef: string
|
|
293
|
+
payloadDef: string,
|
|
301
294
|
) {
|
|
302
295
|
return `
|
|
303
296
|
export async function ${api.methodName}${typeParamsDef}(${paramsDef}): Promise<Response> {
|
|
304
297
|
return window.fetch(\`${apiBaseUrl}?\${qs.stringify(${payloadDef})}\`${
|
|
305
|
-
api.options.timeout
|
|
306
|
-
? `, { signal: AbortSignal.timeout(${api.options.timeout}) }`
|
|
307
|
-
: ""
|
|
298
|
+
api.options.timeout ? `, { signal: AbortSignal.timeout(${api.options.timeout}) }` : ""
|
|
308
299
|
});
|
|
309
300
|
}
|
|
310
301
|
`.trim();
|
|
311
302
|
}
|
|
312
303
|
|
|
313
|
-
renderStream(
|
|
314
|
-
api: ExtendedApi,
|
|
315
|
-
apiBaseUrl: string,
|
|
316
|
-
paramsDefAsObject: string
|
|
317
|
-
) {
|
|
304
|
+
renderStream(api: ExtendedApi, apiBaseUrl: string, paramsDefAsObject: string) {
|
|
318
305
|
if (!api.streamOptions) {
|
|
319
306
|
return "// streamOptions not found";
|
|
320
307
|
}
|
|
321
308
|
|
|
322
309
|
const methodNameStream = api.options.resourceName
|
|
323
|
-
?
|
|
324
|
-
:
|
|
325
|
-
const methodNameStreamCamelized = inflection.camelize(
|
|
326
|
-
methodNameStream,
|
|
327
|
-
true
|
|
328
|
-
);
|
|
310
|
+
? `use${inflection.camelize(api.options.resourceName)}`
|
|
311
|
+
: `use${inflection.camelize(api.methodName)}`;
|
|
312
|
+
const methodNameStreamCamelized = inflection.camelize(methodNameStream, true);
|
|
329
313
|
|
|
330
314
|
const eventsTypeDef = zodTypeToTsTypeDef(api.streamOptions.events);
|
|
331
315
|
|
|
@@ -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_enums_buttonset extends Template {
|
|
6
6
|
constructor() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
+
import type { TemplateOptions } from "../../types/types";
|
|
3
|
+
import { getLabel } from "../helpers";
|
|
4
|
+
import { Template } from "../template";
|
|
5
5
|
|
|
6
6
|
export class Template__view_enums_dropdown extends Template {
|
|
7
7
|
constructor() {
|
|
@@ -51,19 +51,3 @@ export function ${enumId}Dropdown(props: DropdownProps) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
export function getLabel(entityId: string, enumId: string): string {
|
|
56
|
-
if (enumId.endsWith("OrderBy")) {
|
|
57
|
-
return "정렬";
|
|
58
|
-
} else if (enumId.endsWith("SearchField")) {
|
|
59
|
-
return "검색";
|
|
60
|
-
} else {
|
|
61
|
-
const enumProp = EntityManager.get(entityId).props.find(
|
|
62
|
-
(prop) => `${entityId}${inflection.camelize(prop.name)}` === enumId
|
|
63
|
-
);
|
|
64
|
-
if (enumProp && enumProp.desc) {
|
|
65
|
-
return enumProp.desc;
|
|
66
|
-
}
|
|
67
|
-
return enumId;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
+
import type { TemplateOptions } from "../../types/types";
|
|
3
|
+
import { getLabel } from "../helpers";
|
|
4
|
+
import { Template } from "../template";
|
|
5
5
|
|
|
6
6
|
export class Template__view_enums_select extends Template {
|
|
7
7
|
constructor() {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import inflection from "inflection";
|
|
2
|
+
import { unique } from "radashi";
|
|
2
3
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
getRelationPropFromColName,
|
|
10
|
-
} from "./view_list.template";
|
|
11
|
-
import _ from "lodash";
|
|
4
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
5
|
+
import type { RenderingNode, TemplateKey, TemplateOptions } from "../../types/types";
|
|
6
|
+
import { getEnumInfoFromColName, getRelationPropFromColName } from "../helpers";
|
|
7
|
+
import type { RenderedTemplate } from "../template";
|
|
8
|
+
import { Template } from "../template";
|
|
9
|
+
import { getZodTypeById, zodTypeToRenderingNode } from "../zod-converter";
|
|
12
10
|
|
|
13
11
|
export class Template__view_form extends Template {
|
|
14
12
|
constructor() {
|
|
@@ -30,27 +28,17 @@ export class Template__view_form extends Template {
|
|
|
30
28
|
].join("\n");
|
|
31
29
|
}
|
|
32
30
|
wrapFG(body: string, label?: string): string {
|
|
33
|
-
return [
|
|
34
|
-
`<Form.Group widths="equal">`,
|
|
35
|
-
this.wrapFC(body, label),
|
|
36
|
-
`</Form.Group>`,
|
|
37
|
-
].join("\n");
|
|
31
|
+
return [`<Form.Group widths="equal">`, this.wrapFC(body, label), `</Form.Group>`].join("\n");
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
renderColumnImport(entityId: string, col: RenderingNode) {
|
|
41
35
|
if (col.renderType === "enums") {
|
|
42
|
-
const { id, targetEntityNames } = getEnumInfoFromColName(
|
|
43
|
-
entityId,
|
|
44
|
-
col.name
|
|
45
|
-
);
|
|
36
|
+
const { id, targetEntityNames } = getEnumInfoFromColName(entityId, col.name);
|
|
46
37
|
const componentId = `${id}Select`;
|
|
47
38
|
return `import { ${componentId} } from "src/components/${targetEntityNames.fs}/${componentId}";`;
|
|
48
39
|
} else if (col.renderType === "number-fk_id") {
|
|
49
40
|
try {
|
|
50
|
-
const relProp = getRelationPropFromColName(
|
|
51
|
-
entityId,
|
|
52
|
-
col.name.replace("_id", "")
|
|
53
|
-
);
|
|
41
|
+
const relProp = getRelationPropFromColName(entityId, col.name.replace("_id", ""));
|
|
54
42
|
const targetNames = EntityManager.getNamesFromId(relProp.with);
|
|
55
43
|
const componentId = `${relProp.with}IdAsyncSelect`;
|
|
56
44
|
return `import { ${componentId} } from "src/components/${targetNames.fs}/${componentId}";`;
|
|
@@ -66,17 +54,14 @@ export class Template__view_form extends Template {
|
|
|
66
54
|
entityId: string,
|
|
67
55
|
col: RenderingNode,
|
|
68
56
|
names: EntityNamesRecord,
|
|
69
|
-
parent: string = ""
|
|
57
|
+
parent: string = "",
|
|
70
58
|
): string {
|
|
71
59
|
let regExpr: string = "";
|
|
72
60
|
regExpr = `{...register(\`${parent}${col.name}\`)}`;
|
|
73
61
|
|
|
74
62
|
switch (col.renderType) {
|
|
75
63
|
case "string-plain":
|
|
76
|
-
if (
|
|
77
|
-
col.zodType instanceof z.ZodString &&
|
|
78
|
-
(col.zodType.maxLength ?? 0) <= 512
|
|
79
|
-
) {
|
|
64
|
+
if (col.zodType instanceof z.ZodString && (col.zodType.maxLength ?? 0) <= 512) {
|
|
80
65
|
return `<Input placeholder="${col.label}" ${regExpr} />`;
|
|
81
66
|
} else {
|
|
82
67
|
return `<TextArea rows={8} placeholder="${col.label}" ${regExpr} />`;
|
|
@@ -114,10 +99,7 @@ export class Template__view_form extends Template {
|
|
|
114
99
|
}
|
|
115
100
|
case "number-fk_id":
|
|
116
101
|
try {
|
|
117
|
-
const relProp = getRelationPropFromColName(
|
|
118
|
-
entityId,
|
|
119
|
-
col.name.replace("_id", "")
|
|
120
|
-
);
|
|
102
|
+
const relProp = getRelationPropFromColName(entityId, col.name.replace("_id", ""));
|
|
121
103
|
const fkId = `${relProp.with}IdAsyncSelect`;
|
|
122
104
|
return `<${fkId} {...register('${col.name}')} ${
|
|
123
105
|
col.optional || col.nullable ? "clearable" : ""
|
|
@@ -130,9 +112,7 @@ export class Template__view_form extends Template {
|
|
|
130
112
|
case "object":
|
|
131
113
|
return `<>${col.name} object</>`;
|
|
132
114
|
default:
|
|
133
|
-
throw new Error(
|
|
134
|
-
`대응 불가능한 렌더 타입 ${col.renderType} on ${col.name}`
|
|
135
|
-
);
|
|
115
|
+
throw new Error(`대응 불가능한 렌더 타입 ${col.renderType} on ${col.name}`);
|
|
136
116
|
}
|
|
137
117
|
}
|
|
138
118
|
|
|
@@ -169,22 +149,20 @@ export class Template__view_form extends Template {
|
|
|
169
149
|
result[col.name] = value;
|
|
170
150
|
return result;
|
|
171
151
|
},
|
|
172
|
-
{} as { [key: string]: unknown }
|
|
152
|
+
{} as { [key: string]: unknown },
|
|
173
153
|
);
|
|
174
154
|
}
|
|
175
155
|
|
|
176
|
-
render(
|
|
177
|
-
{
|
|
178
|
-
saveParamsNode
|
|
179
|
-
|
|
156
|
+
async render({ entityId }: TemplateOptions["view_form"]) {
|
|
157
|
+
const saveParamsZodType = await getZodTypeById(`${entityId}SaveParams`);
|
|
158
|
+
const saveParamsNode = zodTypeToRenderingNode(saveParamsZodType);
|
|
159
|
+
|
|
180
160
|
const entity = EntityManager.get(entityId);
|
|
181
161
|
const names = EntityManager.getNamesFromId(entityId);
|
|
182
162
|
const columns = (saveParamsNode.children as RenderingNode[])
|
|
183
163
|
.filter((col) => col.name !== "id")
|
|
184
164
|
.map((col) => {
|
|
185
|
-
const propCandidate = entity.props.find(
|
|
186
|
-
(prop) => prop.name === col.name
|
|
187
|
-
);
|
|
165
|
+
const propCandidate = entity.props.find((prop) => prop.name === col.name);
|
|
188
166
|
col.label = propCandidate?.desc ?? col.label;
|
|
189
167
|
return col;
|
|
190
168
|
});
|
|
@@ -192,9 +170,7 @@ export class Template__view_form extends Template {
|
|
|
192
170
|
const defaultValue = this.resolveDefaultValue(columns);
|
|
193
171
|
|
|
194
172
|
// 프리 템플릿
|
|
195
|
-
const preTemplates: RenderedTemplate["preTemplates"] = (
|
|
196
|
-
columns as RenderingNode[]
|
|
197
|
-
)
|
|
173
|
+
const preTemplates: RenderedTemplate["preTemplates"] = (columns as RenderingNode[])
|
|
198
174
|
.filter((col) => {
|
|
199
175
|
if (col.name === "id") {
|
|
200
176
|
return false;
|
|
@@ -221,16 +197,15 @@ export class Template__view_form extends Template {
|
|
|
221
197
|
let enumId: string | undefined;
|
|
222
198
|
if (col.renderType === "enums") {
|
|
223
199
|
key = "view_enums_select";
|
|
224
|
-
const { targetEntityNames: targetMDNames, id } =
|
|
225
|
-
|
|
200
|
+
const { targetEntityNames: targetMDNames, id } = getEnumInfoFromColName(
|
|
201
|
+
entityId,
|
|
202
|
+
col.name,
|
|
203
|
+
);
|
|
226
204
|
targetMdId = targetMDNames.capital;
|
|
227
205
|
enumId = id;
|
|
228
206
|
} else {
|
|
229
207
|
key = "view_id_async_select";
|
|
230
|
-
const relProp = getRelationPropFromColName(
|
|
231
|
-
entityId,
|
|
232
|
-
col.name.replace("_id", "")
|
|
233
|
-
);
|
|
208
|
+
const relProp = getRelationPropFromColName(entityId, col.name.replace("_id", ""));
|
|
234
209
|
targetMdId = relProp.with;
|
|
235
210
|
}
|
|
236
211
|
|
|
@@ -277,19 +252,15 @@ import { defaultCatch } from 'src/services/sonamu.shared';
|
|
|
277
252
|
// import { ImageUploader } from 'src/admin-common/ImageUploader';
|
|
278
253
|
// import { useCommonModal } from "src/admin-common/CommonModal";
|
|
279
254
|
|
|
280
|
-
import { ${names.capital}SaveParams } from 'src/services/${names.fs}/${
|
|
281
|
-
|
|
282
|
-
}.types';
|
|
283
|
-
import { ${names.capital}Service } from 'src/services/${names.fs}/${
|
|
284
|
-
names.fs
|
|
285
|
-
}.service';
|
|
255
|
+
import { ${names.capital}SaveParams } from 'src/services/${names.fs}/${names.fs}.types';
|
|
256
|
+
import { ${names.capital}Service } from 'src/services/${names.fs}/${names.fs}.service';
|
|
286
257
|
import { ${names.capital}SubsetA } from 'src/services/sonamu.generated';
|
|
287
|
-
${
|
|
258
|
+
${unique(
|
|
288
259
|
columns
|
|
289
260
|
.filter((col) => ["number-fk_id", "enums"].includes(col.renderType))
|
|
290
261
|
.map((col) => {
|
|
291
262
|
return this.renderColumnImport(entityId, col);
|
|
292
|
-
})
|
|
263
|
+
}),
|
|
293
264
|
).join("\n")}
|
|
294
265
|
|
|
295
266
|
export default function ${names.capitalPlural}FormPage() {
|
|
@@ -299,27 +270,20 @@ export default function ${names.capitalPlural}FormPage() {
|
|
|
299
270
|
id: searchParams.get('id') ?? undefined,
|
|
300
271
|
};
|
|
301
272
|
|
|
302
|
-
return <${
|
|
303
|
-
names.capitalPlural
|
|
304
|
-
}Form id={query?.id ? Number(query.id) : undefined} />;
|
|
273
|
+
return <${names.capitalPlural}Form id={query?.id ? Number(query.id) : undefined} />;
|
|
305
274
|
}
|
|
306
275
|
type ${names.capitalPlural}FormProps = {
|
|
307
276
|
id?: number;
|
|
308
277
|
mode?: 'page' | 'modal';
|
|
309
278
|
};
|
|
310
|
-
export function ${names.capitalPlural}Form({ id, mode }: ${
|
|
311
|
-
names.capitalPlural
|
|
312
|
-
}FormProps) {
|
|
279
|
+
export function ${names.capitalPlural}Form({ id, mode }: ${names.capitalPlural}FormProps) {
|
|
313
280
|
// 편집시 기존 row
|
|
314
281
|
const [row, setRow] = useState<${names.capital}SubsetA | undefined>();
|
|
315
282
|
|
|
316
283
|
// ${names.capital}SaveParams 폼
|
|
317
|
-
const { form, setForm, register } = useTypeForm(${
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
/"now\(\)"/g,
|
|
321
|
-
"DateTime.local().toSQL()!.slice(0, 19)"
|
|
322
|
-
)});
|
|
284
|
+
const { form, setForm, register } = useTypeForm(${names.capital}SaveParams, ${JSON.stringify(
|
|
285
|
+
defaultValue,
|
|
286
|
+
).replace(/"now\(\)"/g, "DateTime.local().toSQL()!.slice(0, 19)")});
|
|
323
287
|
|
|
324
288
|
// 수정일 때 기존 row 콜
|
|
325
289
|
useEffect(() => {
|
|
@@ -332,10 +296,7 @@ export function ${names.capitalPlural}Form({ id, mode }: ${
|
|
|
332
296
|
.filter((col) => col.renderType === "number-fk_id")
|
|
333
297
|
.map((col) => {
|
|
334
298
|
if (col.nullable) {
|
|
335
|
-
return `${col.name}: row.${col.name.replace(
|
|
336
|
-
"_id",
|
|
337
|
-
"?.id"
|
|
338
|
-
)} ?? null`;
|
|
299
|
+
return `${col.name}: row.${col.name.replace("_id", "?.id")} ?? null`;
|
|
339
300
|
} else {
|
|
340
301
|
return `${col.name}: row.${col.name.replace("_id", ".id")}`;
|
|
341
302
|
}
|
|
@@ -363,9 +324,7 @@ export function ${names.capitalPlural}Form({ id, mode }: ${
|
|
|
363
324
|
|
|
364
325
|
// 페이지
|
|
365
326
|
const PAGE = {
|
|
366
|
-
title: \`${
|
|
367
|
-
entity.title ?? names.capital
|
|
368
|
-
}\${id ? \`#\${id} 수정\` : ' 등록'}\`,
|
|
327
|
+
title: \`${entity.title ?? names.capital}\${id ? \`#\${id} 수정\` : ' 등록'}\`,
|
|
369
328
|
}
|
|
370
329
|
|
|
371
330
|
return (
|
|
@@ -388,7 +347,7 @@ export function ${names.capitalPlural}Form({ id, mode }: ${
|
|
|
388
347
|
if (col.name === "created_at") {
|
|
389
348
|
return `{form.id && (${this.wrapFG(
|
|
390
349
|
`<div className="p-8px">{formatDateTime(form.${col.name})}</div>`,
|
|
391
|
-
"등록일시"
|
|
350
|
+
"등록일시",
|
|
392
351
|
)})}`;
|
|
393
352
|
} else {
|
|
394
353
|
return this.wrapFG(
|
|
@@ -396,16 +355,14 @@ export function ${names.capitalPlural}Form({ id, mode }: ${
|
|
|
396
355
|
(() => {
|
|
397
356
|
if (col.label.endsWith("Id")) {
|
|
398
357
|
try {
|
|
399
|
-
const entity = EntityManager.get(
|
|
400
|
-
col.label.replace("Id", "")
|
|
401
|
-
);
|
|
358
|
+
const entity = EntityManager.get(col.label.replace("Id", ""));
|
|
402
359
|
return entity.title ?? col.label;
|
|
403
360
|
} catch {
|
|
404
361
|
return col.label;
|
|
405
362
|
}
|
|
406
363
|
}
|
|
407
364
|
return col.label;
|
|
408
|
-
})()
|
|
365
|
+
})(),
|
|
409
366
|
);
|
|
410
367
|
}
|
|
411
368
|
})
|
|
@@ -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_all_select extends Template {
|
|
6
6
|
constructor() {
|