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
package/src/types/types.ts
CHANGED
|
@@ -1,57 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { FastifyCorsOptions } from "@fastify/cors";
|
|
3
|
-
import type { FastifyFormbodyOptions } from "@fastify/formbody";
|
|
4
|
-
import type {
|
|
5
|
-
FastifyInstance,
|
|
6
|
-
FastifyReply,
|
|
7
|
-
FastifyRequest,
|
|
8
|
-
FastifyServerOptions,
|
|
9
|
-
} from "fastify";
|
|
10
|
-
import type { QsPluginOptions } from "fastify-qs";
|
|
1
|
+
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
11
2
|
import { z } from "zod";
|
|
12
3
|
import type { ApiDecoratorOptions, AuthContext, Context } from "../api";
|
|
13
|
-
import type {
|
|
14
|
-
import type { Driver } from "../file-storage/driver";
|
|
15
|
-
import type { SsePluginOptions } from "fastify-sse-v2/lib/types";
|
|
16
|
-
import type { FastifyStaticOptions } from "@fastify/static";
|
|
17
|
-
import { SecureSessionPluginOptions } from "@fastify/secure-session";
|
|
18
|
-
import {
|
|
19
|
-
DeserializeFunction,
|
|
20
|
-
SerializeFunction,
|
|
21
|
-
} from "@fastify/passport/dist/Authenticator";
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
Enums
|
|
25
|
-
*/
|
|
26
|
-
export type EnumsLabel<T extends string, L extends "ko" | "en"> = {
|
|
27
|
-
[key in T]: { [lang in L]: string };
|
|
28
|
-
};
|
|
29
|
-
export type EnumsLabelKo<T extends string> = EnumsLabel<T, "ko">;
|
|
30
|
-
|
|
31
|
-
/*
|
|
32
|
-
Custom Scalars
|
|
33
|
-
*/
|
|
34
|
-
export const SQLDateTimeString = z
|
|
35
|
-
.string()
|
|
36
|
-
.regex(/([0-9]{4}-[0-9]{2}-[0-9]{2}( [0-9]{2}:[0-9]{2}:[0-9]{2})*)$/, {
|
|
37
|
-
message: "잘못된 SQLDate 타입",
|
|
38
|
-
})
|
|
39
|
-
.min(10)
|
|
40
|
-
.max(19)
|
|
41
|
-
.describe("SQLDateTimeString");
|
|
42
|
-
export type SQLDateTimeString = z.infer<typeof SQLDateTimeString>;
|
|
4
|
+
import type { GuardKey } from "./../api/decorators";
|
|
43
5
|
|
|
44
6
|
/*
|
|
45
7
|
Utility Types
|
|
46
8
|
*/
|
|
47
|
-
export function zArrayable<T extends z.ZodTypeAny>(
|
|
48
|
-
shape: T
|
|
49
|
-
): z.ZodUnion<[T, z.ZodArray<T>]> {
|
|
9
|
+
export function zArrayable<T extends z.ZodTypeAny>(shape: T): z.ZodUnion<[T, z.ZodArray<T>]> {
|
|
50
10
|
return z.union([shape, shape.array()]);
|
|
51
11
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
: never;
|
|
12
|
+
// biome-ignore lint/suspicious/noExplicitAny: any is used to make the type distributive
|
|
13
|
+
export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
|
|
55
14
|
|
|
56
15
|
/*
|
|
57
16
|
Model-Defintion
|
|
@@ -65,81 +24,84 @@ export type CommonProp = {
|
|
|
65
24
|
};
|
|
66
25
|
export type IntegerProp = CommonProp & {
|
|
67
26
|
type: "integer";
|
|
68
|
-
|
|
69
|
-
|
|
27
|
+
}; // PG: integer / TS: number / JSON: number
|
|
28
|
+
export type IntegerArrayProp = CommonProp & {
|
|
29
|
+
type: "integer[]";
|
|
30
|
+
}; // PG: integer[] / TS: number[] / JSON: number[]
|
|
70
31
|
export type BigIntegerProp = CommonProp & {
|
|
71
32
|
type: "bigInteger";
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
textType: "text" | "mediumtext" | "longtext";
|
|
77
|
-
};
|
|
33
|
+
}; // PG: bigint / TS: bigint / JSON: bigint
|
|
34
|
+
export type BigIntegerArrayProp = CommonProp & {
|
|
35
|
+
type: "bigInteger[]";
|
|
36
|
+
}; // PG: bigint[] / TS: bigint[] / JSON: bigint[]
|
|
78
37
|
export type StringProp = CommonProp & {
|
|
79
38
|
type: "string";
|
|
80
|
-
length
|
|
81
|
-
};
|
|
39
|
+
length?: number; // PG: varchar(n), text / TS: string / JSON: string
|
|
40
|
+
}; // PG: text / TS: string / JSON: string
|
|
41
|
+
export type StringArrayProp = CommonProp & {
|
|
42
|
+
type: "string[]";
|
|
43
|
+
length?: number; // PG: varchar(n)[], text[] / TS: string[] / JSON: string[]
|
|
44
|
+
}; // PG: varchar(n)[], text[] / TS: string[] / JSON: string[]
|
|
82
45
|
export type EnumProp = CommonProp & {
|
|
83
46
|
type: "enum";
|
|
84
|
-
length: number;
|
|
85
47
|
id: string;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
precision
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
precision
|
|
103
|
-
|
|
104
|
-
|
|
48
|
+
length?: number;
|
|
49
|
+
}; // PG: text / TS: string / JSON: string
|
|
50
|
+
export type EnumArrayProp = CommonProp & {
|
|
51
|
+
type: "enum[]";
|
|
52
|
+
id: string;
|
|
53
|
+
}; // PG: text[] / TS: string[] / JSON: string[]
|
|
54
|
+
export type NumberProp = CommonProp & {
|
|
55
|
+
type: "number";
|
|
56
|
+
precision?: number; // PG: numeric(p, s) / TS: number / JSON: number
|
|
57
|
+
scale?: number; // PG: numeric(p, s) / TS: number / JSON: number
|
|
58
|
+
numberType?: "real" | "double precision" | "numeric"; // 기본값: numeric
|
|
59
|
+
}; // PG: numeric(p, s) / TS: number / JSON: number
|
|
60
|
+
export type NumberArrayProp = CommonProp & {
|
|
61
|
+
type: "number[]";
|
|
62
|
+
precision?: number;
|
|
63
|
+
scale?: number;
|
|
64
|
+
numberType?: "real" | "double precision" | "numeric"; // 기본값: numeric
|
|
65
|
+
}; // PG: numeric(p, s)[] / TS: number[] / JSON: number[]
|
|
66
|
+
export type NumericProp = CommonProp & {
|
|
67
|
+
type: "numeric";
|
|
68
|
+
precision?: number;
|
|
69
|
+
scale?: number;
|
|
70
|
+
}; // PG: numeric(p, s) / TS: string / JSON: string
|
|
71
|
+
export type NumericArrayProp = CommonProp & {
|
|
72
|
+
type: "numeric[]";
|
|
73
|
+
precision?: number;
|
|
74
|
+
scale?: number;
|
|
75
|
+
}; // PG: numeric(p, s)[] / TS: string[] / JSON: string[]
|
|
105
76
|
export type BooleanProp = CommonProp & {
|
|
106
77
|
type: "boolean";
|
|
107
|
-
};
|
|
78
|
+
}; // PG: boolean / TS: boolean / JSON: boolean
|
|
79
|
+
export type BooleanArrayProp = CommonProp & {
|
|
80
|
+
type: "boolean[]";
|
|
81
|
+
}; // PG: boolean[] / TS: boolean[] / JSON: boolean[]
|
|
108
82
|
export type DateProp = CommonProp & {
|
|
109
83
|
type: "date";
|
|
110
|
-
};
|
|
111
|
-
export type
|
|
112
|
-
type: "
|
|
113
|
-
};
|
|
114
|
-
export type TimeProp = CommonProp & {
|
|
115
|
-
type: "time";
|
|
116
|
-
};
|
|
117
|
-
export type TimestampProp = CommonProp & {
|
|
118
|
-
type: "timestamp";
|
|
119
|
-
};
|
|
84
|
+
}; // PG: timestampz / TS: Date / JSON: string(ISOString)
|
|
85
|
+
export type DateArrayProp = CommonProp & {
|
|
86
|
+
type: "date[]";
|
|
87
|
+
}; // PG: timestamptz[] / TS: Date[] / JSON: string[]
|
|
120
88
|
export type JsonProp = CommonProp & {
|
|
121
89
|
type: "json";
|
|
122
90
|
id: string;
|
|
123
|
-
};
|
|
91
|
+
}; // PG: json / TS: any(id) / JSON: any
|
|
124
92
|
export type UuidProp = CommonProp & {
|
|
125
93
|
type: "uuid";
|
|
126
|
-
};
|
|
94
|
+
}; // PG: uuid / TS: string / JSON: string
|
|
95
|
+
export type UuidArrayProp = CommonProp & {
|
|
96
|
+
type: "uuid[]";
|
|
97
|
+
}; // PG: uuid[] / TS: string[] / JSON: string[]
|
|
127
98
|
export type VirtualProp = CommonProp & {
|
|
128
99
|
type: "virtual";
|
|
129
100
|
id: string;
|
|
130
|
-
};
|
|
101
|
+
}; // PG: none / TS: any(id) / JSON: any
|
|
131
102
|
|
|
132
|
-
export type RelationType =
|
|
133
|
-
|
|
134
|
-
| "BelongsToOne"
|
|
135
|
-
| "ManyToMany"
|
|
136
|
-
| "OneToOne";
|
|
137
|
-
export type RelationOn =
|
|
138
|
-
| "CASCADE"
|
|
139
|
-
| "SET NULL"
|
|
140
|
-
| "NO ACTION"
|
|
141
|
-
| "SET DEFAULT"
|
|
142
|
-
| "RESTRICT";
|
|
103
|
+
export type RelationType = "HasMany" | "BelongsToOne" | "ManyToMany" | "OneToOne";
|
|
104
|
+
export type RelationOn = "CASCADE" | "SET NULL" | "NO ACTION" | "SET DEFAULT" | "RESTRICT";
|
|
143
105
|
type _RelationProp = {
|
|
144
106
|
type: "relation";
|
|
145
107
|
name: string;
|
|
@@ -188,20 +150,25 @@ export type RelationProp =
|
|
|
188
150
|
|
|
189
151
|
export type EntityProp =
|
|
190
152
|
| IntegerProp
|
|
153
|
+
| IntegerArrayProp
|
|
191
154
|
| BigIntegerProp
|
|
192
|
-
|
|
|
155
|
+
| BigIntegerArrayProp
|
|
193
156
|
| StringProp
|
|
194
|
-
|
|
|
195
|
-
|
|
|
196
|
-
|
|
|
157
|
+
| StringArrayProp
|
|
158
|
+
| EnumProp
|
|
159
|
+
| EnumArrayProp
|
|
160
|
+
| NumberProp
|
|
161
|
+
| NumberArrayProp
|
|
162
|
+
| NumericProp
|
|
163
|
+
| NumericArrayProp
|
|
164
|
+
| NumericProp
|
|
197
165
|
| BooleanProp
|
|
166
|
+
| BooleanArrayProp
|
|
198
167
|
| DateProp
|
|
199
|
-
|
|
|
200
|
-
| TimeProp
|
|
201
|
-
| TimestampProp
|
|
202
|
-
| JsonProp
|
|
168
|
+
| DateArrayProp
|
|
203
169
|
| UuidProp
|
|
204
|
-
|
|
|
170
|
+
| UuidArrayProp
|
|
171
|
+
| JsonProp
|
|
205
172
|
| VirtualProp
|
|
206
173
|
| RelationProp;
|
|
207
174
|
|
|
@@ -239,23 +206,26 @@ export type EntitySubsetRow = {
|
|
|
239
206
|
};
|
|
240
207
|
export type FlattenSubsetRow = Omit<EntitySubsetRow, "children">;
|
|
241
208
|
|
|
242
|
-
// SMD Legacy
|
|
243
|
-
export type SMDInput<T extends string> = {
|
|
244
|
-
id: string;
|
|
245
|
-
parentId?: string;
|
|
246
|
-
table?: string;
|
|
247
|
-
title?: string;
|
|
248
|
-
props?: EntityProp[];
|
|
249
|
-
indexes?: EntityIndex[];
|
|
250
|
-
subsets?: {
|
|
251
|
-
[subset: string]: T[];
|
|
252
|
-
};
|
|
253
|
-
};
|
|
254
|
-
|
|
255
209
|
/*
|
|
256
210
|
PropNode
|
|
257
211
|
*/
|
|
258
212
|
|
|
213
|
+
/**
|
|
214
|
+
* 엔티티의 필드 구조를 트리 형태로 표현하는 중간 노드입니다.
|
|
215
|
+
*
|
|
216
|
+
* **목적**: Entity의 subset 필드 표현식(예: "id", "user.name", "tags[]")을
|
|
217
|
+
* 재귀적인 트리 구조로 파싱하여 Zod 스키마 생성의 중간 단계로 사용합니다.
|
|
218
|
+
*
|
|
219
|
+
* **변환 흐름**:
|
|
220
|
+
* Entity subset → EntityPropNode (트리 구조) → Zod 스키마 → RenderingNode (UI용)
|
|
221
|
+
*
|
|
222
|
+
* **nodeType**:
|
|
223
|
+
* - "plain": 단일 필드 (예: "id", "name")
|
|
224
|
+
* - "object": 중첩 객체 (예: "user.name" → user 객체)
|
|
225
|
+
* - "array": 배열 (예: "tags[]" → tags 배열)
|
|
226
|
+
*
|
|
227
|
+
* **사용 위치**: entity-converter.ts의 propNodeToZodType()
|
|
228
|
+
*/
|
|
259
229
|
export type EntityPropNode =
|
|
260
230
|
| {
|
|
261
231
|
nodeType: "plain";
|
|
@@ -270,70 +240,107 @@ export type EntityPropNode =
|
|
|
270
240
|
/*
|
|
271
241
|
Prop Type Guards
|
|
272
242
|
*/
|
|
273
|
-
export function
|
|
274
|
-
return p?.type === "integer";
|
|
243
|
+
export function isIntegerSingleProp(p: unknown): p is IntegerProp {
|
|
244
|
+
return (p as IntegerProp)?.type === "integer";
|
|
245
|
+
}
|
|
246
|
+
export function isIntegerArrayProp(p: unknown): p is IntegerArrayProp {
|
|
247
|
+
return (p as IntegerArrayProp)?.type === "integer[]";
|
|
248
|
+
}
|
|
249
|
+
export function isIntegerProp(p: unknown): p is IntegerProp | IntegerArrayProp {
|
|
250
|
+
return isIntegerSingleProp(p) || isIntegerArrayProp(p);
|
|
275
251
|
}
|
|
276
|
-
export function
|
|
277
|
-
return p?.type === "bigInteger";
|
|
252
|
+
export function isBigIntegerSingleProp(p: unknown): p is BigIntegerProp {
|
|
253
|
+
return (p as BigIntegerProp)?.type === "bigInteger";
|
|
278
254
|
}
|
|
279
|
-
export function
|
|
280
|
-
return p?.type === "
|
|
255
|
+
export function isBigIntegerArrayProp(p: unknown): p is BigIntegerArrayProp {
|
|
256
|
+
return (p as BigIntegerArrayProp)?.type === "bigInteger[]";
|
|
281
257
|
}
|
|
282
|
-
export function
|
|
283
|
-
return p
|
|
258
|
+
export function isBigIntegerProp(p: unknown): p is BigIntegerProp | BigIntegerArrayProp {
|
|
259
|
+
return isBigIntegerSingleProp(p) || isBigIntegerArrayProp(p);
|
|
284
260
|
}
|
|
285
|
-
export function
|
|
286
|
-
return p?.type === "
|
|
261
|
+
export function isStringSingleProp(p: unknown): p is StringProp {
|
|
262
|
+
return (p as StringProp)?.type === "string";
|
|
287
263
|
}
|
|
288
|
-
export function
|
|
289
|
-
return p?.type === "
|
|
264
|
+
export function isStringArrayProp(p: unknown): p is StringArrayProp {
|
|
265
|
+
return (p as StringArrayProp)?.type === "string[]";
|
|
290
266
|
}
|
|
291
|
-
export function
|
|
292
|
-
return p
|
|
267
|
+
export function isStringProp(p: unknown): p is StringProp | StringArrayProp {
|
|
268
|
+
return isStringSingleProp(p) || isStringArrayProp(p);
|
|
293
269
|
}
|
|
294
|
-
export function
|
|
295
|
-
return p?.type === "
|
|
270
|
+
export function isEnumSingleProp(p: unknown): p is EnumProp {
|
|
271
|
+
return (p as EnumProp)?.type === "enum";
|
|
296
272
|
}
|
|
297
|
-
export function
|
|
298
|
-
return p?.type === "
|
|
273
|
+
export function isEnumArrayProp(p: unknown): p is EnumArrayProp {
|
|
274
|
+
return (p as EnumArrayProp)?.type === "enum[]";
|
|
299
275
|
}
|
|
300
|
-
export function
|
|
301
|
-
return p
|
|
276
|
+
export function isEnumProp(p: unknown): p is EnumProp | EnumArrayProp {
|
|
277
|
+
return isEnumSingleProp(p) || isEnumArrayProp(p);
|
|
302
278
|
}
|
|
303
|
-
export function
|
|
304
|
-
return p?.type === "
|
|
279
|
+
export function isNumberSingleProp(p: unknown): p is NumberProp {
|
|
280
|
+
return (p as NumberProp)?.type === "number";
|
|
305
281
|
}
|
|
306
|
-
export function
|
|
307
|
-
return p?.type === "
|
|
282
|
+
export function isNumberArrayProp(p: unknown): p is NumberArrayProp {
|
|
283
|
+
return (p as NumberArrayProp)?.type === "number[]";
|
|
308
284
|
}
|
|
309
|
-
export function
|
|
310
|
-
return p
|
|
285
|
+
export function isNumberProp(p: unknown): p is NumberProp | NumberArrayProp {
|
|
286
|
+
return isNumberSingleProp(p) || isNumberArrayProp(p);
|
|
311
287
|
}
|
|
312
|
-
export function
|
|
313
|
-
return p?.type === "
|
|
288
|
+
export function isNumericSingleProp(p: unknown): p is NumericProp {
|
|
289
|
+
return (p as NumericProp)?.type === "numeric";
|
|
314
290
|
}
|
|
315
|
-
export function
|
|
316
|
-
return p?.type === "
|
|
291
|
+
export function isNumericArrayProp(p: unknown): p is NumericArrayProp {
|
|
292
|
+
return (p as NumericArrayProp)?.type === "numeric[]";
|
|
317
293
|
}
|
|
318
|
-
export function
|
|
319
|
-
return p
|
|
294
|
+
export function isNumericProp(p: unknown): p is NumericProp | NumericArrayProp {
|
|
295
|
+
return isNumericSingleProp(p) || isNumericArrayProp(p);
|
|
320
296
|
}
|
|
321
|
-
export function
|
|
322
|
-
return p?.type === "
|
|
297
|
+
export function isBooleanSingleProp(p: unknown): p is BooleanProp {
|
|
298
|
+
return (p as BooleanProp)?.type === "boolean";
|
|
323
299
|
}
|
|
324
|
-
export function
|
|
325
|
-
return p?.
|
|
300
|
+
export function isBooleanArrayProp(p: unknown): p is BooleanArrayProp {
|
|
301
|
+
return (p as BooleanArrayProp)?.type === "boolean[]";
|
|
326
302
|
}
|
|
327
|
-
export function
|
|
328
|
-
p
|
|
329
|
-
): p is BelongsToOneRelationProp {
|
|
330
|
-
return p?.relationType === "BelongsToOne";
|
|
303
|
+
export function isBooleanProp(p: unknown): p is BooleanProp | BooleanArrayProp {
|
|
304
|
+
return isBooleanSingleProp(p) || isBooleanArrayProp(p);
|
|
331
305
|
}
|
|
332
|
-
export function
|
|
333
|
-
return p?.
|
|
306
|
+
export function isDateSingleProp(p: unknown): p is DateProp {
|
|
307
|
+
return (p as DateProp)?.type === "date";
|
|
334
308
|
}
|
|
335
|
-
export function
|
|
336
|
-
return p?.
|
|
309
|
+
export function isDateArrayProp(p: unknown): p is DateArrayProp {
|
|
310
|
+
return (p as DateArrayProp)?.type === "date[]";
|
|
311
|
+
}
|
|
312
|
+
export function isDateProp(p: unknown): p is DateProp | DateArrayProp {
|
|
313
|
+
return isDateSingleProp(p) || isDateArrayProp(p);
|
|
314
|
+
}
|
|
315
|
+
export function isUuidSingleProp(p: unknown): p is UuidProp {
|
|
316
|
+
return (p as UuidProp)?.type === "uuid";
|
|
317
|
+
}
|
|
318
|
+
export function isUuidArrayProp(p: unknown): p is UuidArrayProp {
|
|
319
|
+
return (p as UuidArrayProp)?.type === "uuid[]";
|
|
320
|
+
}
|
|
321
|
+
export function isUuidProp(p: unknown): p is UuidProp | UuidArrayProp {
|
|
322
|
+
return isUuidSingleProp(p) || isUuidArrayProp(p);
|
|
323
|
+
}
|
|
324
|
+
export function isJsonProp(p: unknown): p is JsonProp {
|
|
325
|
+
return (p as JsonProp)?.type === "json";
|
|
326
|
+
}
|
|
327
|
+
export function isVirtualProp(p: unknown): p is VirtualProp {
|
|
328
|
+
return (p as VirtualProp)?.type === "virtual";
|
|
329
|
+
}
|
|
330
|
+
export function isRelationProp(p: unknown): p is RelationProp {
|
|
331
|
+
return (p as RelationProp)?.type === "relation";
|
|
332
|
+
}
|
|
333
|
+
export function isOneToOneRelationProp(p: unknown): p is OneToOneRelationProp {
|
|
334
|
+
return (p as OneToOneRelationProp)?.relationType === "OneToOne";
|
|
335
|
+
}
|
|
336
|
+
export function isBelongsToOneRelationProp(p: unknown): p is BelongsToOneRelationProp {
|
|
337
|
+
return (p as BelongsToOneRelationProp)?.relationType === "BelongsToOne";
|
|
338
|
+
}
|
|
339
|
+
export function isHasManyRelationProp(p: unknown): p is HasManyRelationProp {
|
|
340
|
+
return (p as HasManyRelationProp)?.relationType === "HasMany";
|
|
341
|
+
}
|
|
342
|
+
export function isManyToManyRelationProp(p: unknown): p is ManyToManyRelationProp {
|
|
343
|
+
return (p as ManyToManyRelationProp)?.relationType === "ManyToMany";
|
|
337
344
|
}
|
|
338
345
|
|
|
339
346
|
type JoinClause =
|
|
@@ -344,44 +351,9 @@ type JoinClause =
|
|
|
344
351
|
| {
|
|
345
352
|
custom: string;
|
|
346
353
|
};
|
|
347
|
-
export function isCustomJoinClause(p:
|
|
348
|
-
return p?.custom;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/* 서브셋 */
|
|
352
|
-
// type SubsetLoader = {
|
|
353
|
-
// as: string;
|
|
354
|
-
// table: string;
|
|
355
|
-
// manyJoin: {
|
|
356
|
-
// fromTable: string;
|
|
357
|
-
// fromCol: string;
|
|
358
|
-
// idField: string;
|
|
359
|
-
// toTable: string;
|
|
360
|
-
// toCol: string;
|
|
361
|
-
// through?: {
|
|
362
|
-
// table: string;
|
|
363
|
-
// fromCol: string;
|
|
364
|
-
// toCol: string;
|
|
365
|
-
// };
|
|
366
|
-
// };
|
|
367
|
-
// oneJoins: ({
|
|
368
|
-
// as: string;
|
|
369
|
-
// join: "inner" | "outer";
|
|
370
|
-
// table: string;
|
|
371
|
-
// } & JoinClause)[];
|
|
372
|
-
// select: (string | Knex.Raw)[];
|
|
373
|
-
// loaders?: SubsetLoader[];
|
|
374
|
-
// };
|
|
375
|
-
// export type SubsetQuery = {
|
|
376
|
-
// select: (string | Knex.Raw)[];
|
|
377
|
-
// virtual: string[];
|
|
378
|
-
// joins: ({
|
|
379
|
-
// as: string;
|
|
380
|
-
// join: "inner" | "outer";
|
|
381
|
-
// table: string;
|
|
382
|
-
// } & JoinClause)[];
|
|
383
|
-
// loaders: SubsetLoader[];
|
|
384
|
-
// };
|
|
354
|
+
export function isCustomJoinClause(p: unknown): p is { custom: string } {
|
|
355
|
+
return !!(p as { custom: string })?.custom;
|
|
356
|
+
}
|
|
385
357
|
|
|
386
358
|
type SubsetLoader = {
|
|
387
359
|
as: string;
|
|
@@ -430,8 +402,8 @@ export type KnexError = {
|
|
|
430
402
|
sqlMessage: string;
|
|
431
403
|
sqlState: string;
|
|
432
404
|
};
|
|
433
|
-
export function isKnexError(e:
|
|
434
|
-
return e
|
|
405
|
+
export function isKnexError(e: unknown): e is KnexError {
|
|
406
|
+
return !!(e as KnexError)?.code && !!(e as KnexError)?.sqlMessage && !!(e as KnexError)?.sqlState;
|
|
435
407
|
}
|
|
436
408
|
|
|
437
409
|
export type KnexColumnType =
|
|
@@ -452,11 +424,27 @@ export type KnexColumnType =
|
|
|
452
424
|
| "date"
|
|
453
425
|
| "time"
|
|
454
426
|
| "datetime";
|
|
427
|
+
export type MigrationColumnType =
|
|
428
|
+
| "string"
|
|
429
|
+
| "string[]"
|
|
430
|
+
| "integer"
|
|
431
|
+
| "integer[]"
|
|
432
|
+
| "bigInteger"
|
|
433
|
+
| "bigInteger[]"
|
|
434
|
+
| "numberOrNumeric"
|
|
435
|
+
| "numberOrNumeric[]"
|
|
436
|
+
| "boolean"
|
|
437
|
+
| "boolean[]"
|
|
438
|
+
| "date"
|
|
439
|
+
| "date[]"
|
|
440
|
+
| "uuid"
|
|
441
|
+
| "uuid[]"
|
|
442
|
+
| "json";
|
|
455
443
|
export type MigrationColumn = {
|
|
456
444
|
name: string;
|
|
457
|
-
type:
|
|
445
|
+
type: MigrationColumnType;
|
|
458
446
|
nullable: boolean;
|
|
459
|
-
|
|
447
|
+
numberType?: "real" | "double precision" | "numeric";
|
|
460
448
|
length?: number;
|
|
461
449
|
defaultTo?: string;
|
|
462
450
|
precision?: number;
|
|
@@ -567,53 +555,83 @@ export namespace ApiParamType {
|
|
|
567
555
|
constraint?: ApiParamType;
|
|
568
556
|
};
|
|
569
557
|
|
|
570
|
-
export function isObject(v:
|
|
571
|
-
return v?.t === "object";
|
|
558
|
+
export function isObject(v: unknown): v is ApiParamType.Object {
|
|
559
|
+
return (v as ApiParamType.Object)?.t === "object";
|
|
572
560
|
}
|
|
573
|
-
export function isUnion(v:
|
|
574
|
-
return v?.t === "union";
|
|
561
|
+
export function isUnion(v: unknown): v is ApiParamType.Union {
|
|
562
|
+
return (v as ApiParamType.Union)?.t === "union";
|
|
575
563
|
}
|
|
576
|
-
export function isIntersection(v:
|
|
577
|
-
return v?.t === "intersection";
|
|
564
|
+
export function isIntersection(v: unknown): v is ApiParamType.Intersection {
|
|
565
|
+
return (v as ApiParamType.Intersection)?.t === "intersection";
|
|
578
566
|
}
|
|
579
|
-
export function isStringLiteral(v:
|
|
580
|
-
return v?.t === "string-literal";
|
|
567
|
+
export function isStringLiteral(v: unknown): v is ApiParamType.StringLiteral {
|
|
568
|
+
return (v as ApiParamType.StringLiteral)?.t === "string-literal";
|
|
581
569
|
}
|
|
582
|
-
export function isNumericLiteral(v:
|
|
583
|
-
return v?.t === "numeric-literal";
|
|
570
|
+
export function isNumericLiteral(v: unknown): v is ApiParamType.NumericLiteral {
|
|
571
|
+
return (v as ApiParamType.NumericLiteral)?.t === "numeric-literal";
|
|
584
572
|
}
|
|
585
|
-
export function isArray(v:
|
|
586
|
-
return v?.t === "array";
|
|
573
|
+
export function isArray(v: unknown): v is ApiParamType.Array {
|
|
574
|
+
return (v as ApiParamType.Array)?.t === "array";
|
|
587
575
|
}
|
|
588
|
-
export function isRef(v:
|
|
589
|
-
return v
|
|
576
|
+
export function isRef(v: unknown): v is ApiParamType.Ref {
|
|
577
|
+
return typeof v === "object" && v !== null && (v as { t?: unknown }).t === "ref";
|
|
590
578
|
}
|
|
591
|
-
export function isIndexedAccess(v:
|
|
592
|
-
return v
|
|
579
|
+
export function isIndexedAccess(v: unknown): v is ApiParamType.IndexedAccess {
|
|
580
|
+
return typeof v === "object" && v !== null && (v as { t?: unknown }).t === "indexed-access";
|
|
593
581
|
}
|
|
594
|
-
export function isTupleType(v:
|
|
595
|
-
return v
|
|
582
|
+
export function isTupleType(v: unknown): v is ApiParamType.TupleType {
|
|
583
|
+
return typeof v === "object" && v !== null && (v as { t?: unknown }).t === "tuple-type";
|
|
596
584
|
}
|
|
597
|
-
export function isPick(v:
|
|
598
|
-
return
|
|
585
|
+
export function isPick(v: unknown): v is ApiParamType.Pick {
|
|
586
|
+
return (
|
|
587
|
+
typeof v === "object" &&
|
|
588
|
+
v !== null &&
|
|
589
|
+
(v as { t?: unknown }).t === "ref" &&
|
|
590
|
+
(v as { id?: unknown }).id === "Pick"
|
|
591
|
+
);
|
|
599
592
|
}
|
|
600
|
-
export function isOmit(v:
|
|
601
|
-
return
|
|
593
|
+
export function isOmit(v: unknown): v is ApiParamType.Omit {
|
|
594
|
+
return (
|
|
595
|
+
typeof v === "object" &&
|
|
596
|
+
v !== null &&
|
|
597
|
+
(v as { t?: unknown }).t === "ref" &&
|
|
598
|
+
(v as { id?: unknown }).id === "Omit"
|
|
599
|
+
);
|
|
602
600
|
}
|
|
603
|
-
export function isPartial(v:
|
|
604
|
-
return
|
|
601
|
+
export function isPartial(v: unknown): v is ApiParamType.Partial {
|
|
602
|
+
return (
|
|
603
|
+
typeof v === "object" &&
|
|
604
|
+
v !== null &&
|
|
605
|
+
(v as { t?: unknown }).t === "ref" &&
|
|
606
|
+
(v as { id?: unknown }).id === "Partial"
|
|
607
|
+
);
|
|
605
608
|
}
|
|
606
|
-
export function isPromise(v:
|
|
607
|
-
return
|
|
609
|
+
export function isPromise(v: unknown): v is ApiParamType.Promise {
|
|
610
|
+
return (
|
|
611
|
+
typeof v === "object" &&
|
|
612
|
+
v !== null &&
|
|
613
|
+
(v as { t?: unknown }).t === "ref" &&
|
|
614
|
+
(v as { id?: unknown }).id === "Promise"
|
|
615
|
+
);
|
|
608
616
|
}
|
|
609
|
-
export function isContext(v:
|
|
610
|
-
return
|
|
617
|
+
export function isContext(v: unknown): v is ApiParamType.Context {
|
|
618
|
+
return (
|
|
619
|
+
typeof v === "object" &&
|
|
620
|
+
v !== null &&
|
|
621
|
+
(v as { t?: unknown }).t === "ref" &&
|
|
622
|
+
(v as { id?: unknown }).id === "Context"
|
|
623
|
+
);
|
|
611
624
|
}
|
|
612
|
-
export function isRefKnex(v:
|
|
613
|
-
return
|
|
625
|
+
export function isRefKnex(v: unknown): v is ApiParamType.Ref {
|
|
626
|
+
return (
|
|
627
|
+
typeof v === "object" &&
|
|
628
|
+
v !== null &&
|
|
629
|
+
(v as { t?: unknown }).t === "ref" &&
|
|
630
|
+
(v as { id?: unknown }).id === "Knex"
|
|
631
|
+
);
|
|
614
632
|
}
|
|
615
|
-
export function isTypeParam(v:
|
|
616
|
-
return v
|
|
633
|
+
export function isTypeParam(v: unknown): v is ApiParamType.TypeParam {
|
|
634
|
+
return typeof v === "object" && v !== null && (v as { t?: unknown }).t === "type-param";
|
|
617
635
|
}
|
|
618
636
|
}
|
|
619
637
|
export type ApiParamType =
|
|
@@ -639,6 +657,26 @@ export type ApiParamType =
|
|
|
639
657
|
| ApiParamType.TupleType;
|
|
640
658
|
|
|
641
659
|
/* Template */
|
|
660
|
+
/**
|
|
661
|
+
* UI 컴포넌트 렌더링을 위한 메타데이터 노드입니다.
|
|
662
|
+
*
|
|
663
|
+
* **목적**: Zod 스키마로부터 프론트엔드 UI 컴포넌트를 자동 생성하기 위한
|
|
664
|
+
* 렌더링 정보를 담은 트리 구조입니다. 각 필드가 어떤 UI 컴포넌트로
|
|
665
|
+
* 표현되어야 하는지(텍스트, 이미지, 날짜, Enum 선택 등)를 명시합니다.
|
|
666
|
+
*
|
|
667
|
+
* **변환 흐름**:
|
|
668
|
+
* Entity subset → EntityPropNode → Zod 스키마 → RenderingNode (UI용) → React 컴포넌트 코드 생성
|
|
669
|
+
*
|
|
670
|
+
* **주요 필드**:
|
|
671
|
+
* - `renderType`: UI 컴포넌트 유형 (string-plain, number-fk_id, enums, array 등)
|
|
672
|
+
* - `zodType`: 원본 Zod 스키마 (validation 용)
|
|
673
|
+
* - `children`: 중첩된 객체 필드들 (object일 때)
|
|
674
|
+
* - `element`: 배열 요소 타입 (array일 때)
|
|
675
|
+
*
|
|
676
|
+
* **사용 위치**:
|
|
677
|
+
* - zod-converter.ts의 zodTypeToRenderingNode()에서 생성
|
|
678
|
+
* - view_form.template.ts, view_list.template.ts 등에서 React 컴포넌트 코드 생성에 사용
|
|
679
|
+
*/
|
|
642
680
|
// 셀프 참조 타입이므로 Zod 생략하고 직접 정의
|
|
643
681
|
export const RenderingNode = z.any();
|
|
644
682
|
export type RenderingNode = {
|
|
@@ -670,17 +708,270 @@ export type RenderingNode = {
|
|
|
670
708
|
nullable?: boolean;
|
|
671
709
|
};
|
|
672
710
|
|
|
711
|
+
const BasePropFields = {
|
|
712
|
+
name: z.string(),
|
|
713
|
+
desc: z.string().optional(),
|
|
714
|
+
nullable: z.boolean().optional(),
|
|
715
|
+
toFilter: z.literal(true).optional(),
|
|
716
|
+
dbDefault: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
// 부가 필드가 필요없는 prop
|
|
720
|
+
const BasePropFieldsWithoutAdditional = z
|
|
721
|
+
.object({
|
|
722
|
+
...BasePropFields,
|
|
723
|
+
type: z.union([
|
|
724
|
+
z.literal("integer"),
|
|
725
|
+
z.literal("integer[]"),
|
|
726
|
+
z.literal("bigInteger"),
|
|
727
|
+
z.literal("bigInteger[]"),
|
|
728
|
+
z.literal("boolean"),
|
|
729
|
+
z.literal("boolean[]"),
|
|
730
|
+
z.literal("date"),
|
|
731
|
+
z.literal("date[]"),
|
|
732
|
+
z.literal("uuid"),
|
|
733
|
+
z.literal("uuid[]"),
|
|
734
|
+
]),
|
|
735
|
+
})
|
|
736
|
+
.strict();
|
|
737
|
+
|
|
738
|
+
// precision/scale 필드
|
|
739
|
+
const PrecisionScaleFields = {
|
|
740
|
+
precision: z.number().optional(),
|
|
741
|
+
scale: z.number().optional(),
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
// 각 타입별 스키마 정의
|
|
745
|
+
|
|
746
|
+
const StringPropSchema = z
|
|
747
|
+
.object({
|
|
748
|
+
...BasePropFields,
|
|
749
|
+
type: z.literal("string"),
|
|
750
|
+
length: z.number().optional(),
|
|
751
|
+
})
|
|
752
|
+
.strict();
|
|
753
|
+
const StringArrayPropSchema = z
|
|
754
|
+
.object({
|
|
755
|
+
...BasePropFields,
|
|
756
|
+
type: z.literal("string[]"),
|
|
757
|
+
length: z.number().optional(),
|
|
758
|
+
})
|
|
759
|
+
.strict();
|
|
760
|
+
|
|
761
|
+
const EnumPropSchema = z
|
|
762
|
+
.object({
|
|
763
|
+
...BasePropFields,
|
|
764
|
+
type: z.literal("enum"),
|
|
765
|
+
id: z.string(),
|
|
766
|
+
})
|
|
767
|
+
.strict();
|
|
768
|
+
const EnumArrayPropSchema = z
|
|
769
|
+
.object({
|
|
770
|
+
...BasePropFields,
|
|
771
|
+
type: z.literal("enum[]"),
|
|
772
|
+
id: z.string(),
|
|
773
|
+
})
|
|
774
|
+
.strict();
|
|
775
|
+
|
|
776
|
+
const NumberPropSchema = z
|
|
777
|
+
.object({
|
|
778
|
+
...BasePropFields,
|
|
779
|
+
type: z.literal("number"),
|
|
780
|
+
...PrecisionScaleFields,
|
|
781
|
+
numberType: z.enum(["real", "double precision", "numeric"]).optional(),
|
|
782
|
+
})
|
|
783
|
+
.strict();
|
|
784
|
+
const NumberArrayPropSchema = z
|
|
785
|
+
.object({
|
|
786
|
+
...BasePropFields,
|
|
787
|
+
type: z.literal("number[]"),
|
|
788
|
+
...PrecisionScaleFields,
|
|
789
|
+
numberType: z.enum(["real", "double precision", "numeric"]).optional(),
|
|
790
|
+
})
|
|
791
|
+
.strict();
|
|
792
|
+
|
|
793
|
+
const NumericPropSchema = z
|
|
794
|
+
.object({
|
|
795
|
+
...BasePropFields,
|
|
796
|
+
type: z.literal("numeric"),
|
|
797
|
+
...PrecisionScaleFields,
|
|
798
|
+
})
|
|
799
|
+
.strict();
|
|
800
|
+
const NumericArrayPropSchema = z
|
|
801
|
+
.object({
|
|
802
|
+
...BasePropFields,
|
|
803
|
+
type: z.literal("numeric[]"),
|
|
804
|
+
...PrecisionScaleFields,
|
|
805
|
+
})
|
|
806
|
+
.strict();
|
|
807
|
+
|
|
808
|
+
const JsonPropSchema = z
|
|
809
|
+
.object({
|
|
810
|
+
...BasePropFields,
|
|
811
|
+
type: z.literal("json"),
|
|
812
|
+
id: z.string(),
|
|
813
|
+
})
|
|
814
|
+
.strict();
|
|
815
|
+
|
|
816
|
+
const VirtualPropSchema = z
|
|
817
|
+
.object({
|
|
818
|
+
...BasePropFields,
|
|
819
|
+
type: z.literal("virtual"),
|
|
820
|
+
id: z.string(),
|
|
821
|
+
})
|
|
822
|
+
.strict();
|
|
823
|
+
|
|
824
|
+
// Relation 타입은 relationType에 따라 세분화
|
|
825
|
+
const BaseRelationFields = {
|
|
826
|
+
...BasePropFields,
|
|
827
|
+
type: z.literal("relation"),
|
|
828
|
+
with: z.string(),
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// RelationOn 타입
|
|
832
|
+
const RelationOnSchema = z.enum(["CASCADE", "SET NULL", "NO ACTION", "SET DEFAULT", "RESTRICT"]);
|
|
833
|
+
|
|
834
|
+
const BelongsToOneRelationPropSchema = z
|
|
835
|
+
.object({
|
|
836
|
+
...BaseRelationFields,
|
|
837
|
+
relationType: z.literal("BelongsToOne"),
|
|
838
|
+
customJoinClause: z.string().optional(),
|
|
839
|
+
useConstraint: z.boolean().optional(),
|
|
840
|
+
onUpdate: RelationOnSchema.optional(),
|
|
841
|
+
onDelete: RelationOnSchema.optional(),
|
|
842
|
+
})
|
|
843
|
+
.strict();
|
|
844
|
+
|
|
845
|
+
const HasManyRelationPropSchema = z
|
|
846
|
+
.object({
|
|
847
|
+
...BaseRelationFields,
|
|
848
|
+
relationType: z.literal("HasMany"),
|
|
849
|
+
joinColumn: z.string(),
|
|
850
|
+
fromColumn: z.string().optional(),
|
|
851
|
+
})
|
|
852
|
+
.strict();
|
|
853
|
+
|
|
854
|
+
const ManyToManyRelationPropSchema = z
|
|
855
|
+
.object({
|
|
856
|
+
...BaseRelationFields,
|
|
857
|
+
relationType: z.literal("ManyToMany"),
|
|
858
|
+
joinTable: z.string(),
|
|
859
|
+
onUpdate: RelationOnSchema,
|
|
860
|
+
onDelete: RelationOnSchema,
|
|
861
|
+
})
|
|
862
|
+
.strict();
|
|
863
|
+
|
|
864
|
+
const OneToOneRelationPropSchema = z
|
|
865
|
+
.object({
|
|
866
|
+
...BaseRelationFields,
|
|
867
|
+
relationType: z.literal("OneToOne"),
|
|
868
|
+
customJoinClause: z.string().optional(),
|
|
869
|
+
hasJoinColumn: z.boolean().optional(),
|
|
870
|
+
useConstraint: z.boolean().optional(),
|
|
871
|
+
onUpdate: RelationOnSchema.optional(),
|
|
872
|
+
onDelete: RelationOnSchema.optional(),
|
|
873
|
+
})
|
|
874
|
+
.strict();
|
|
875
|
+
|
|
876
|
+
const RelationTypes = ["BelongsToOne", "HasMany", "ManyToMany", "OneToOne"] as const;
|
|
877
|
+
export const RelationPropSchema = z.discriminatedUnion(
|
|
878
|
+
"relationType",
|
|
879
|
+
[
|
|
880
|
+
BelongsToOneRelationPropSchema,
|
|
881
|
+
HasManyRelationPropSchema,
|
|
882
|
+
ManyToManyRelationPropSchema,
|
|
883
|
+
OneToOneRelationPropSchema,
|
|
884
|
+
],
|
|
885
|
+
{
|
|
886
|
+
error: (iss) =>
|
|
887
|
+
`relationType은 ${RelationTypes.map((t) => `'${t}'`).join(", ")} 중 하나여야 합니다. 입력값: "${(iss.input as Record<string, unknown>)?.relationType}"`,
|
|
888
|
+
},
|
|
889
|
+
);
|
|
890
|
+
|
|
891
|
+
const NormalPropTypes = [
|
|
892
|
+
"integer",
|
|
893
|
+
"integer[]",
|
|
894
|
+
"bigInteger",
|
|
895
|
+
"bigInteger[]",
|
|
896
|
+
"string",
|
|
897
|
+
"string[]",
|
|
898
|
+
"enum",
|
|
899
|
+
"enum[]",
|
|
900
|
+
"number",
|
|
901
|
+
"number[]",
|
|
902
|
+
"numeric",
|
|
903
|
+
"numeric[]",
|
|
904
|
+
"boolean",
|
|
905
|
+
"boolean[]",
|
|
906
|
+
"date",
|
|
907
|
+
"date[]",
|
|
908
|
+
"uuid",
|
|
909
|
+
"uuid[]",
|
|
910
|
+
"json",
|
|
911
|
+
"virtual",
|
|
912
|
+
] as const;
|
|
913
|
+
export const NormalPropSchema = z.discriminatedUnion(
|
|
914
|
+
"type",
|
|
915
|
+
[
|
|
916
|
+
BasePropFieldsWithoutAdditional,
|
|
917
|
+
StringPropSchema,
|
|
918
|
+
StringArrayPropSchema,
|
|
919
|
+
EnumPropSchema,
|
|
920
|
+
EnumArrayPropSchema,
|
|
921
|
+
NumberPropSchema,
|
|
922
|
+
NumberArrayPropSchema,
|
|
923
|
+
NumericPropSchema,
|
|
924
|
+
NumericArrayPropSchema,
|
|
925
|
+
JsonPropSchema,
|
|
926
|
+
VirtualPropSchema,
|
|
927
|
+
],
|
|
928
|
+
{
|
|
929
|
+
error: (iss) =>
|
|
930
|
+
`type은 ${NormalPropTypes.map((t) => `'${t}'`).join(", ")} 중 하나여야 합니다. 입력값: "${(iss.input as Record<string, unknown>)?.type}"`,
|
|
931
|
+
},
|
|
932
|
+
);
|
|
933
|
+
|
|
934
|
+
const AllPropTypes = [...NormalPropTypes, "relation"] as const;
|
|
935
|
+
const EntityPropSchema = z.discriminatedUnion("type", [NormalPropSchema, RelationPropSchema], {
|
|
936
|
+
error: (iss) =>
|
|
937
|
+
`type은 ${AllPropTypes.map((t) => `'${t}'`).join(", ")} 중 하나여야 합니다. 입력값: "${(iss.input as Record<string, unknown>)?.type}"`,
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
// EntityIndex 스키마 정의
|
|
941
|
+
const EntityIndexSchema = z
|
|
942
|
+
.object({
|
|
943
|
+
type: z.enum(["index", "unique", "fulltext"]),
|
|
944
|
+
columns: z.array(z.string()),
|
|
945
|
+
name: z.string().optional(),
|
|
946
|
+
parser: z.enum(["built-in", "ngram"]).optional(),
|
|
947
|
+
})
|
|
948
|
+
.strict();
|
|
949
|
+
|
|
950
|
+
export const EntityJsonSchema = z
|
|
951
|
+
.object({
|
|
952
|
+
id: z.string().describe("PascalCase로 된 Entity ID"),
|
|
953
|
+
title: z.string().describe("Entity 이름"),
|
|
954
|
+
table: z.string().describe("snake_case로 된 테이블명"),
|
|
955
|
+
parentId: z.string().optional().describe("부모 Entity ID"),
|
|
956
|
+
props: z.array(EntityPropSchema),
|
|
957
|
+
indexes: z.array(EntityIndexSchema),
|
|
958
|
+
subsets: z.record(z.string(), z.array(z.string())),
|
|
959
|
+
enums: z.record(z.string(), z.record(z.string(), z.string())),
|
|
960
|
+
})
|
|
961
|
+
.strict();
|
|
962
|
+
|
|
673
963
|
export const TemplateOptions = z.object({
|
|
674
|
-
entity:
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
964
|
+
entity: EntityJsonSchema.omit({ id: true })
|
|
965
|
+
.extend({
|
|
966
|
+
entityId: z.string(),
|
|
967
|
+
})
|
|
968
|
+
.partial({
|
|
969
|
+
table: true,
|
|
970
|
+
props: true,
|
|
971
|
+
indexes: true,
|
|
972
|
+
subsets: true,
|
|
973
|
+
enums: true,
|
|
974
|
+
}),
|
|
684
975
|
init_types: z.object({
|
|
685
976
|
entityId: z.string(),
|
|
686
977
|
}),
|
|
@@ -691,8 +982,8 @@ export const TemplateOptions = z.object({
|
|
|
691
982
|
}),
|
|
692
983
|
model: z.object({
|
|
693
984
|
entityId: z.string(),
|
|
694
|
-
defaultSearchField: z.string(),
|
|
695
|
-
defaultOrderBy: z.string(),
|
|
985
|
+
defaultSearchField: z.string().optional(),
|
|
986
|
+
defaultOrderBy: z.string().optional(),
|
|
696
987
|
}),
|
|
697
988
|
model_test: z.object({
|
|
698
989
|
entityId: z.string(),
|
|
@@ -796,6 +1087,7 @@ export type FixtureSearchOptions = {
|
|
|
796
1087
|
searchType: "equals" | "like";
|
|
797
1088
|
};
|
|
798
1089
|
|
|
1090
|
+
type ColumnValue = string | number | boolean | Date | null;
|
|
799
1091
|
export type FixtureRecord = {
|
|
800
1092
|
fixtureId: string;
|
|
801
1093
|
entityId: string;
|
|
@@ -803,7 +1095,7 @@ export type FixtureRecord = {
|
|
|
803
1095
|
columns: {
|
|
804
1096
|
[key: string]: {
|
|
805
1097
|
prop: EntityProp;
|
|
806
|
-
value:
|
|
1098
|
+
value: ColumnValue | ColumnValue[];
|
|
807
1099
|
};
|
|
808
1100
|
};
|
|
809
1101
|
fetchedRecords: string[];
|
|
@@ -816,7 +1108,7 @@ export type FixtureRecord = {
|
|
|
816
1108
|
export type FixtureImportResult = {
|
|
817
1109
|
entityId: string;
|
|
818
1110
|
data: {
|
|
819
|
-
[key: string]:
|
|
1111
|
+
[key: string]: ColumnValue;
|
|
820
1112
|
};
|
|
821
1113
|
};
|
|
822
1114
|
|
|
@@ -826,11 +1118,9 @@ export type RelationNode = {
|
|
|
826
1118
|
related: Set<string>;
|
|
827
1119
|
};
|
|
828
1120
|
|
|
1121
|
+
// biome-ignore lint/suspicious/noEmptyInterface: sonamu.generated.sso 에서 확장을 위해 준비된 빈 인터페이스
|
|
829
1122
|
export interface DatabaseSchemaExtend {}
|
|
830
|
-
export type ManyToManyBaseSchema<
|
|
831
|
-
FromIdKey extends string,
|
|
832
|
-
ToIdKey extends string,
|
|
833
|
-
> = {
|
|
1123
|
+
export type ManyToManyBaseSchema<FromIdKey extends string, ToIdKey extends string> = {
|
|
834
1124
|
id: number;
|
|
835
1125
|
} & {
|
|
836
1126
|
[K in `${FromIdKey}_id`]: number;
|
|
@@ -840,13 +1130,10 @@ export type ManyToManyBaseSchema<
|
|
|
840
1130
|
|
|
841
1131
|
export type SonamuFastifyConfig = {
|
|
842
1132
|
contextProvider: (
|
|
843
|
-
defaultContext: Pick<
|
|
844
|
-
Context,
|
|
845
|
-
"request" | "reply" | "headers" | "createSSE"
|
|
846
|
-
> &
|
|
1133
|
+
defaultContext: Pick<Context, "request" | "reply" | "headers" | "createSSE" | "naiteStore"> &
|
|
847
1134
|
AuthContext,
|
|
848
1135
|
request: FastifyRequest,
|
|
849
|
-
reply: FastifyReply
|
|
1136
|
+
reply: FastifyReply,
|
|
850
1137
|
) => Context | Promise<Context>;
|
|
851
1138
|
guardHandler: (
|
|
852
1139
|
guard: GuardKey,
|
|
@@ -859,7 +1146,7 @@ export type SonamuFastifyConfig = {
|
|
|
859
1146
|
methodName: string;
|
|
860
1147
|
path: string;
|
|
861
1148
|
options: ApiDecoratorOptions;
|
|
862
|
-
}
|
|
1149
|
+
},
|
|
863
1150
|
) => void;
|
|
864
1151
|
cache?: {
|
|
865
1152
|
get: (key: string) => Promise<unknown | null>;
|
|
@@ -868,7 +1155,7 @@ export type SonamuFastifyConfig = {
|
|
|
868
1155
|
path: string,
|
|
869
1156
|
reqBody: {
|
|
870
1157
|
[key: string]: unknown;
|
|
871
|
-
}
|
|
1158
|
+
},
|
|
872
1159
|
) =>
|
|
873
1160
|
| {
|
|
874
1161
|
cache: false;
|
|
@@ -880,45 +1167,3 @@ export type SonamuFastifyConfig = {
|
|
|
880
1167
|
};
|
|
881
1168
|
};
|
|
882
1169
|
};
|
|
883
|
-
|
|
884
|
-
export type SonamuServerOptions = {
|
|
885
|
-
fastify?: FastifyServerOptions;
|
|
886
|
-
|
|
887
|
-
listen?: {
|
|
888
|
-
port: number;
|
|
889
|
-
host?: string;
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
plugins?: {
|
|
893
|
-
cors?: boolean | FastifyCorsOptions;
|
|
894
|
-
formbody?: boolean | FastifyFormbodyOptions;
|
|
895
|
-
multipart?: boolean | FastifyMultipartOptions;
|
|
896
|
-
qs?: boolean | QsPluginOptions;
|
|
897
|
-
sse?: boolean | SsePluginOptions;
|
|
898
|
-
static?: boolean | FastifyStaticOptions;
|
|
899
|
-
session?: boolean | SecureSessionPluginOptions;
|
|
900
|
-
|
|
901
|
-
custom?: (server: FastifyInstance) => void;
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
auth?:
|
|
905
|
-
| boolean
|
|
906
|
-
| {
|
|
907
|
-
userSerializer: SerializeFunction<unknown, unknown>;
|
|
908
|
-
userDeserializer: DeserializeFunction<unknown, unknown>;
|
|
909
|
-
};
|
|
910
|
-
|
|
911
|
-
apiConfig: SonamuFastifyConfig;
|
|
912
|
-
|
|
913
|
-
storage?: Driver;
|
|
914
|
-
|
|
915
|
-
lifecycle?: {
|
|
916
|
-
onStart?: (server: FastifyInstance) => Promise<void> | void;
|
|
917
|
-
onShutdown?: (server: FastifyInstance) => Promise<void> | void;
|
|
918
|
-
onError?: (
|
|
919
|
-
error: Error,
|
|
920
|
-
request: FastifyRequest,
|
|
921
|
-
reply: FastifyReply
|
|
922
|
-
) => Promise<void> | void;
|
|
923
|
-
};
|
|
924
|
-
};
|