sonamu 0.6.0 → 0.7.1
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 +2 -1
- package/dist/api/caster.d.ts.map +1 -1
- package/dist/api/caster.js +6 -1
- 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 +178 -409
- package/dist/api/config.d.ts +27 -13
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +19 -26
- package/dist/api/context.d.ts +4 -3
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +1 -1
- package/dist/api/decorators.d.ts +20 -6
- package/dist/api/decorators.d.ts.map +1 -1
- package/dist/api/decorators.js +111 -18
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/sonamu.d.ts +7 -7
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +83 -51
- 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 +5 -1
- package/dist/bin/build-config.d.ts.map +1 -1
- package/dist/bin/build-config.js +5 -2
- package/dist/bin/cli.js +165 -64
- 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 +30 -13
- 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 +232 -89
- 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 +11 -10
- package/dist/database/db.d.ts +5 -6
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +22 -25
- 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 +2 -2
- package/dist/database/puri.d.ts +25 -14
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +83 -21
- package/dist/database/puri.types.d.ts +21 -7
- package/dist/database/puri.types.d.ts.map +1 -1
- package/dist/database/puri.types.js +4 -1
- 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 +1 -1
- 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 +227 -78
- package/dist/entity/entity-manager.d.ts +165 -2
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +26 -10
- package/dist/entity/entity.d.ts +5 -3
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +153 -54
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/file-storage/file-storage.js +2 -2
- package/dist/index.d.ts +18 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -13
- 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 +123 -67
- 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 +67 -218
- package/dist/migration/migrator.d.ts +24 -73
- package/dist/migration/migrator.d.ts.map +1 -1
- package/dist/migration/migrator.js +121 -301
- 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 +1 -1
- 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 +91 -8
- package/dist/naite/naite.d.ts.map +1 -1
- package/dist/naite/naite.js +285 -41
- package/dist/stream/sse.d.ts +2 -2
- package/dist/stream/sse.d.ts.map +1 -1
- package/dist/stream/sse.js +1 -1
- package/dist/syncer/api-parser.d.ts +3 -13
- package/dist/syncer/api-parser.d.ts.map +1 -1
- package/dist/syncer/api-parser.js +67 -56
- package/dist/syncer/checksum.d.ts +2 -2
- package/dist/syncer/checksum.d.ts.map +1 -1
- package/dist/syncer/checksum.js +11 -11
- package/dist/syncer/code-generator.d.ts +3 -3
- package/dist/syncer/code-generator.d.ts.map +1 -1
- package/dist/syncer/code-generator.js +37 -17
- package/dist/syncer/entity-operations.d.ts +2 -2
- package/dist/syncer/entity-operations.d.ts.map +1 -1
- package/dist/syncer/entity-operations.js +9 -8
- package/dist/syncer/file-patterns.d.ts +1 -1
- package/dist/syncer/file-patterns.d.ts.map +1 -1
- package/dist/syncer/file-patterns.js +1 -1
- package/dist/syncer/index.d.ts +4 -4
- package/dist/syncer/index.d.ts.map +1 -1
- package/dist/syncer/index.js +5 -5
- package/dist/syncer/module-loader.d.ts +4 -4
- package/dist/syncer/module-loader.d.ts.map +1 -1
- package/dist/syncer/module-loader.js +17 -12
- package/dist/syncer/syncer.d.ts +31 -24
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +92 -45
- package/dist/template/entity-converter.d.ts +1 -1
- package/dist/template/entity-converter.d.ts.map +1 -1
- package/dist/template/entity-converter.js +15 -8
- package/dist/template/helpers.d.ts +2 -2
- package/dist/template/helpers.d.ts.map +1 -1
- package/dist/template/helpers.js +3 -3
- package/dist/template/implementations/entity.template.d.ts +2 -2
- package/dist/template/implementations/entity.template.d.ts.map +1 -1
- package/dist/template/implementations/entity.template.js +4 -5
- package/dist/template/implementations/generated.template.d.ts +2 -3
- package/dist/template/implementations/generated.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.js +46 -29
- package/dist/template/implementations/generated_http.template.d.ts +2 -3
- package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_http.template.js +9 -9
- package/dist/template/implementations/generated_sso.template.d.ts +3 -4
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_sso.template.js +54 -25
- package/dist/template/implementations/init_types.template.d.ts +2 -2
- package/dist/template/implementations/init_types.template.d.ts.map +1 -1
- package/dist/template/implementations/init_types.template.js +2 -2
- package/dist/template/implementations/model.template.d.ts +2 -2
- package/dist/template/implementations/model.template.d.ts.map +1 -1
- package/dist/template/implementations/model.template.js +47 -37
- package/dist/template/implementations/model_test.template.d.ts +2 -2
- package/dist/template/implementations/model_test.template.d.ts.map +1 -1
- package/dist/template/implementations/model_test.template.js +2 -2
- package/dist/template/implementations/service.template.d.ts +4 -4
- package/dist/template/implementations/service.template.d.ts.map +1 -1
- package/dist/template/implementations/service.template.js +24 -16
- package/dist/template/implementations/view_enums_buttonset.template.d.ts +2 -2
- package/dist/template/implementations/view_enums_buttonset.template.d.ts.map +1 -1
- package/dist/template/implementations/view_enums_buttonset.template.js +1 -1
- package/dist/template/implementations/view_enums_dropdown.template.d.ts +2 -2
- package/dist/template/implementations/view_enums_dropdown.template.d.ts.map +1 -1
- package/dist/template/implementations/view_enums_dropdown.template.js +2 -2
- package/dist/template/implementations/view_enums_select.template.d.ts +2 -2
- package/dist/template/implementations/view_enums_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_enums_select.template.js +2 -2
- package/dist/template/implementations/view_form.template.d.ts +2 -2
- package/dist/template/implementations/view_form.template.d.ts.map +1 -1
- package/dist/template/implementations/view_form.template.js +4 -4
- package/dist/template/implementations/view_id_all_select.template.d.ts +2 -2
- package/dist/template/implementations/view_id_all_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_id_all_select.template.js +1 -1
- package/dist/template/implementations/view_id_async_select.template.d.ts +2 -2
- package/dist/template/implementations/view_id_async_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_id_async_select.template.js +1 -1
- package/dist/template/implementations/view_list.template.d.ts +2 -2
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +29 -19
- package/dist/template/implementations/view_list_columns.template.d.ts +3 -3
- package/dist/template/implementations/view_list_columns.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list_columns.template.js +1 -1
- package/dist/template/implementations/view_search_input.template.d.ts +2 -2
- package/dist/template/implementations/view_search_input.template.d.ts.map +1 -1
- package/dist/template/implementations/view_search_input.template.js +1 -1
- package/dist/template/index.d.ts +4 -2
- package/dist/template/index.d.ts.map +1 -1
- package/dist/template/index.js +5 -3
- 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 +12 -2
- package/dist/template/template.d.ts.map +1 -1
- package/dist/template/template.js +19 -6
- package/dist/template/zod-converter.d.ts +40 -7
- package/dist/template/zod-converter.d.ts.map +1 -1
- package/dist/template/zod-converter.js +386 -58
- 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 +12 -3
- 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 +338 -236
- package/dist/types/types.d.ts +709 -104
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +309 -52
- package/dist/typings/knex.d.js +2 -2
- package/dist/utils/async-utils.d.ts.map +1 -1
- package/dist/utils/async-utils.js +3 -3
- package/dist/utils/console-util.js +1 -1
- package/dist/utils/controller.d.ts +1 -0
- package/dist/utils/controller.d.ts.map +1 -1
- package/dist/utils/controller.js +4 -1
- package/dist/utils/esm-utils.d.ts +0 -6
- package/dist/utils/esm-utils.d.ts.map +1 -1
- package/dist/utils/esm-utils.js +2 -9
- 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 +1 -1
- package/dist/utils/lodash-able.d.ts.map +1 -1
- package/dist/utils/lodash-able.js +1 -1
- 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 +1 -1
- package/dist/utils/path-utils.d.ts.map +1 -1
- package/dist/utils/path-utils.js +3 -3
- package/dist/utils/process-utils.js +1 -1
- 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 +14 -3
- 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 +7 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +44 -5
- 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 +1 -1
- package/package.json +55 -30
- 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 +176 -533
- package/src/api/config.ts +39 -56
- package/src/api/context.ts +7 -18
- package/src/api/decorators.ts +175 -46
- package/src/api/index.ts +2 -2
- package/src/api/sonamu.ts +133 -124
- package/src/api/validator.ts +83 -0
- package/src/bin/build-config.ts +7 -1
- package/src/bin/cli.ts +192 -110
- 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 +36 -50
- 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 +182 -126
- package/src/database/puri.types.ts +64 -31
- package/src/database/transaction-context.ts +1 -1
- package/src/database/upsert-builder.ts +261 -132
- package/src/entity/entity-manager.ts +36 -28
- package/src/entity/entity.ts +330 -249
- 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 -12
- package/src/migration/code-generation.ts +185 -172
- package/src/migration/migration-set.ts +80 -293
- package/src/migration/migrator.ts +182 -425
- 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 +378 -33
- package/src/shared/web.shared.ts.txt +20 -24
- package/src/stream/sse.ts +5 -5
- package/src/syncer/api-parser.ts +52 -69
- package/src/syncer/checksum.ts +25 -37
- package/src/syncer/code-generator.ts +58 -62
- package/src/syncer/entity-operations.ts +12 -15
- package/src/syncer/file-patterns.ts +2 -2
- package/src/syncer/index.ts +4 -4
- package/src/syncer/module-loader.ts +28 -25
- package/src/syncer/syncer.ts +155 -162
- package/src/template/entity-converter.ts +18 -27
- package/src/template/helpers.ts +8 -11
- package/src/template/implementations/entity.template.ts +6 -6
- package/src/template/implementations/generated.template.ts +99 -99
- package/src/template/implementations/generated_http.template.ts +21 -54
- package/src/template/implementations/generated_sso.template.ts +78 -65
- package/src/template/implementations/init_types.template.ts +4 -6
- package/src/template/implementations/model.template.ts +47 -38
- package/src/template/implementations/model_test.template.ts +3 -3
- package/src/template/implementations/service.template.ts +56 -80
- package/src/template/implementations/view_enums_buttonset.template.ts +2 -2
- package/src/template/implementations/view_enums_dropdown.template.ts +4 -4
- package/src/template/implementations/view_enums_select.template.ts +3 -3
- package/src/template/implementations/view_form.template.ts +34 -75
- package/src/template/implementations/view_id_all_select.template.ts +2 -2
- package/src/template/implementations/view_id_async_select.template.ts +9 -23
- package/src/template/implementations/view_list.template.ts +54 -95
- package/src/template/implementations/view_list_columns.template.ts +4 -10
- package/src/template/implementations/view_search_input.template.ts +2 -2
- package/src/template/index.ts +4 -2
- package/src/template/template-manager.ts +166 -0
- package/src/template/template-types.ts +16 -0
- package/src/template/template.ts +29 -10
- package/src/template/zod-converter.ts +459 -101
- package/src/testing/_relation-graph.ts +18 -11
- package/src/testing/fixture-manager.ts +468 -362
- package/src/types/types.ts +516 -248
- package/src/typings/knex.d.ts +7 -9
- package/src/utils/async-utils.ts +8 -12
- package/src/utils/console-util.ts +1 -1
- package/src/utils/controller.ts +3 -0
- package/src/utils/esm-utils.ts +8 -18
- 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 +3 -6
- package/src/utils/process-utils.ts +1 -1
- package/src/utils/sql-parser.ts +23 -5
- package/src/utils/type-utils.ts +83 -0
- package/src/utils/utils.ts +58 -9
- package/src/utils/zod-error.ts +3 -3
- 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 -72
- 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 -39
- 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 -210
- package/src/bin/cli-wrapper.ts +0 -82
- package/src/database/knex-plugins/knex-on-duplicate-update.ts +0 -45
- package/src/entity/entity-utils.ts +0 -291
package/src/template/helpers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import inflection from "inflection";
|
|
2
|
-
import { EntityManager, EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
-
import { isEnumProp, isRelationProp, RelationProp } from "../types/types";
|
|
2
|
+
import { EntityManager, type EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { isEnumProp, isRelationProp, type RelationProp } from "../types/types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Enum의 표시용 라벨을 가져옵니다.
|
|
@@ -13,9 +13,9 @@ export function getLabel(entityId: string, enumId: string): string {
|
|
|
13
13
|
return "검색";
|
|
14
14
|
} else {
|
|
15
15
|
const enumProp = EntityManager.get(entityId).props.find(
|
|
16
|
-
(prop) => `${entityId}${inflection.camelize(prop.name)}` === enumId
|
|
16
|
+
(prop) => `${entityId}${inflection.camelize(prop.name)}` === enumId,
|
|
17
17
|
);
|
|
18
|
-
if (enumProp
|
|
18
|
+
if (enumProp?.desc) {
|
|
19
19
|
return enumProp.desc;
|
|
20
20
|
}
|
|
21
21
|
return enumId;
|
|
@@ -28,7 +28,7 @@ export function getLabel(entityId: string, enumId: string): string {
|
|
|
28
28
|
*/
|
|
29
29
|
export function getEnumInfoFromColName(
|
|
30
30
|
entityId: string,
|
|
31
|
-
colName: string
|
|
31
|
+
colName: string,
|
|
32
32
|
): {
|
|
33
33
|
id: string;
|
|
34
34
|
targetEntityNames: EntityNamesRecord;
|
|
@@ -46,8 +46,8 @@ export function getEnumInfoFromColName(
|
|
|
46
46
|
};
|
|
47
47
|
} else {
|
|
48
48
|
const idCandidate = inflection.camelize(
|
|
49
|
-
inflection.underscore(entityId)
|
|
50
|
-
false
|
|
49
|
+
`${inflection.underscore(entityId)}_${inflection.underscore(colName)}`,
|
|
50
|
+
false,
|
|
51
51
|
);
|
|
52
52
|
try {
|
|
53
53
|
const targetEntityNames = EntityManager.getNamesFromId(entityId);
|
|
@@ -66,10 +66,7 @@ export function getEnumInfoFromColName(
|
|
|
66
66
|
* 컬럼 이름으로부터 Relation prop 정보를 가져옵니다.
|
|
67
67
|
* 관계형 prop이 아닌 경우 에러를 발생시킵니다.
|
|
68
68
|
*/
|
|
69
|
-
export function getRelationPropFromColName(
|
|
70
|
-
entityId: string,
|
|
71
|
-
colName: string
|
|
72
|
-
): RelationProp {
|
|
69
|
+
export function getRelationPropFromColName(entityId: string, colName: string): RelationProp {
|
|
73
70
|
const baseEntity = EntityManager.get(entityId);
|
|
74
71
|
const relProp = baseEntity.props.find((prop) => prop.name === colName);
|
|
75
72
|
if (isRelationProp(relProp)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TemplateOptions } from "../../types/types";
|
|
2
|
-
import { EntityManager, EntityNamesRecord } from "../../entity/entity-manager";
|
|
3
|
-
import { Template } from "../template";
|
|
4
1
|
import { Sonamu } from "../../api";
|
|
2
|
+
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
3
|
+
import type { TemplateOptions } from "../../types/types";
|
|
4
|
+
import { Template } from "../template";
|
|
5
5
|
|
|
6
6
|
export class Template__entity extends Template {
|
|
7
7
|
constructor() {
|
|
@@ -38,11 +38,11 @@ export class Template__entity extends Template {
|
|
|
38
38
|
id: entityId,
|
|
39
39
|
title: title ?? entityId,
|
|
40
40
|
parentId,
|
|
41
|
-
table: table ?? names.fsPlural.replace(
|
|
41
|
+
table: table ?? names.fsPlural.replace(/-/g, "_"),
|
|
42
42
|
props: options.props?.length
|
|
43
43
|
? options.props
|
|
44
44
|
: [
|
|
45
|
-
{ name: "id", type: "integer",
|
|
45
|
+
{ name: "id", type: "integer", desc: "ID" },
|
|
46
46
|
...(parent
|
|
47
47
|
? [
|
|
48
48
|
{
|
|
@@ -58,7 +58,7 @@ export class Template__entity extends Template {
|
|
|
58
58
|
: []),
|
|
59
59
|
{
|
|
60
60
|
name: "created_at",
|
|
61
|
-
type: "
|
|
61
|
+
type: "date",
|
|
62
62
|
desc: "등록일시",
|
|
63
63
|
dbDefault: "CURRENT_TIMESTAMP",
|
|
64
64
|
},
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { unique } from "radashi";
|
|
3
|
+
import { Sonamu } from "../../api";
|
|
4
|
+
import type { Entity } from "../../entity/entity";
|
|
3
5
|
import { EntityManager } from "../../entity/entity-manager";
|
|
4
|
-
import {
|
|
5
|
-
import { EntityPropNode } from "../../types/types";
|
|
6
|
-
import { propNodeToZodTypeDef, zodTypeToZodCode } from "../../api/code-converters";
|
|
7
|
-
import { Template } from "../template";
|
|
6
|
+
import { Naite } from "../../naite/naite";
|
|
7
|
+
import { type EntityPropNode, isVirtualProp } from "../../types/types";
|
|
8
8
|
import { nonNullable } from "../../utils/utils";
|
|
9
|
-
import {
|
|
9
|
+
import { Template } from "../template";
|
|
10
|
+
import { propNodeToZodTypeDef, zodTypeToZodCode } from "../zod-converter";
|
|
10
11
|
|
|
11
12
|
export type SourceCode = {
|
|
12
13
|
label: string;
|
|
@@ -20,37 +21,28 @@ export class Template__generated extends Template {
|
|
|
20
21
|
|
|
21
22
|
getTargetAndPath() {
|
|
22
23
|
const { dir } = Sonamu.config.api;
|
|
23
|
-
|
|
24
24
|
return {
|
|
25
25
|
target: `${dir}/src/application`,
|
|
26
26
|
path: `sonamu.generated.ts`,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
render({}: TemplateOptions["generated"]) {
|
|
29
|
+
render() {
|
|
31
30
|
const entityIds = EntityManager.getAllIds();
|
|
32
31
|
const entities = entityIds.map((id) => EntityManager.get(id));
|
|
33
32
|
|
|
34
33
|
// 전체 SourceCode 생성
|
|
35
|
-
const sourceCodes = entities
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.flat();
|
|
34
|
+
const sourceCodes = entities.flatMap((entity) => {
|
|
35
|
+
return [
|
|
36
|
+
this.getEnumsSourceCode(entity),
|
|
37
|
+
this.getBaseSchemaSourceCode(entity),
|
|
38
|
+
this.getBaseListParamsSourceCode(entity),
|
|
39
|
+
this.getSubsetSourceCode(entity),
|
|
40
|
+
].filter(nonNullable);
|
|
41
|
+
});
|
|
42
|
+
Naite.t("Template__generated:sourceCodes", sourceCodes);
|
|
45
43
|
|
|
46
44
|
// Sort
|
|
47
|
-
const LABEL_KEY_ORDER = [
|
|
48
|
-
"Enums",
|
|
49
|
-
"BaseSchema",
|
|
50
|
-
"BaseListParams",
|
|
51
|
-
"Subsets",
|
|
52
|
-
"SubsetQueries",
|
|
53
|
-
];
|
|
45
|
+
const LABEL_KEY_ORDER = ["Enums", "BaseSchema", "BaseListParams", "Subsets", "SubsetQueries"];
|
|
54
46
|
sourceCodes.sort((a, b) => {
|
|
55
47
|
const [aKey] = a.label.split(":");
|
|
56
48
|
const [bKey] = b.label.split(":");
|
|
@@ -71,47 +63,45 @@ export class Template__generated extends Template {
|
|
|
71
63
|
return result;
|
|
72
64
|
}
|
|
73
65
|
return {
|
|
74
|
-
lines: [...result
|
|
75
|
-
importKeys:
|
|
66
|
+
lines: [...result.lines, `// ${ts.label}`, ...ts.lines, ""],
|
|
67
|
+
importKeys: unique([...result.importKeys, ...ts.importKeys].sort()),
|
|
76
68
|
};
|
|
77
69
|
},
|
|
78
70
|
{
|
|
79
71
|
lines: [],
|
|
80
72
|
importKeys: [],
|
|
81
|
-
} as Omit<SourceCode, "label"
|
|
73
|
+
} as Omit<SourceCode, "label">,
|
|
82
74
|
);
|
|
83
75
|
|
|
84
76
|
// .types.ts의 타입을 참조하는 경우 순환참조(상호참조)가 발생하므로 타입을 가져와 인라인 처리
|
|
85
|
-
const allTypeKeys = entities
|
|
86
|
-
.map((entity) => Object.keys(entity.types))
|
|
87
|
-
.flat();
|
|
77
|
+
const allTypeKeys = entities.flatMap((entity) => Object.keys(entity.types));
|
|
88
78
|
const cdImportKeys = sourceCode.importKeys.filter((importKey) =>
|
|
89
|
-
allTypeKeys.includes(importKey)
|
|
79
|
+
allTypeKeys.includes(importKey),
|
|
90
80
|
);
|
|
91
81
|
if (cdImportKeys.length > 0) {
|
|
92
|
-
const customScalarLines = cdImportKeys
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.flat();
|
|
82
|
+
const customScalarLines = cdImportKeys.flatMap((importKey) => {
|
|
83
|
+
const entity = entities.find((entity) => entity.types[importKey]);
|
|
84
|
+
if (!entity) {
|
|
85
|
+
throw new Error(`ZodType not found ${importKey}`);
|
|
86
|
+
}
|
|
87
|
+
const zodType = entity.types[importKey];
|
|
88
|
+
assert(zodType);
|
|
89
|
+
|
|
90
|
+
return [
|
|
91
|
+
`// CustomScalar: ${importKey}`,
|
|
92
|
+
`const ${importKey} = ${zodTypeToZodCode(zodType)};`,
|
|
93
|
+
`type ${importKey} = z.infer<typeof ${importKey}>`,
|
|
94
|
+
"",
|
|
95
|
+
];
|
|
96
|
+
});
|
|
108
97
|
sourceCode.lines = [...customScalarLines, ...sourceCode.lines];
|
|
109
98
|
sourceCode.importKeys = sourceCode.importKeys.filter(
|
|
110
|
-
(importKey) => !cdImportKeys.includes(importKey)
|
|
99
|
+
(importKey) => !cdImportKeys.includes(importKey),
|
|
111
100
|
);
|
|
112
101
|
}
|
|
113
102
|
|
|
114
103
|
const body = sourceCode.lines.join("\n");
|
|
104
|
+
Naite.t("Template__generated:body", body);
|
|
115
105
|
|
|
116
106
|
// import
|
|
117
107
|
const sonamuImports = [
|
|
@@ -126,6 +116,9 @@ export class Template__generated extends Template {
|
|
|
126
116
|
body,
|
|
127
117
|
importKeys: sourceCode.importKeys,
|
|
128
118
|
customHeaders: [
|
|
119
|
+
"/** biome-ignore-all lint: generated는 무시 */",
|
|
120
|
+
"/** biome-ignore-all assist: generated는 무시 */",
|
|
121
|
+
"",
|
|
129
122
|
`import { z } from 'zod';`,
|
|
130
123
|
`import { ${sonamuImports.join(",")} } from "sonamu";`,
|
|
131
124
|
],
|
|
@@ -141,23 +134,19 @@ export class Template__generated extends Template {
|
|
|
141
134
|
lines: [
|
|
142
135
|
...Object.entries(entity.enumLabels)
|
|
143
136
|
.filter(([_, enumLabel]) => Object.keys(enumLabel).length > 0)
|
|
144
|
-
.
|
|
137
|
+
.flatMap(([enumId, enumLabel]) => [
|
|
145
138
|
`export const ${enumId} = z.enum([${Object.keys(enumLabel).map(
|
|
146
|
-
(el) => `"${el}"
|
|
139
|
+
(el) => `"${el}"`,
|
|
147
140
|
)}]).describe("${enumId}");`,
|
|
148
|
-
`export type ${enumId} = z.infer<typeof ${enumId}
|
|
149
|
-
`export const ${enumId}Label = ${JSON.stringify(enumLabel)}
|
|
150
|
-
])
|
|
151
|
-
.flat(),
|
|
141
|
+
`export type ${enumId} = z.infer<typeof ${enumId}>;`,
|
|
142
|
+
`export const ${enumId}Label = ${JSON.stringify(enumLabel)};`,
|
|
143
|
+
]),
|
|
152
144
|
],
|
|
153
145
|
importKeys: [],
|
|
154
146
|
};
|
|
155
147
|
}
|
|
156
148
|
|
|
157
|
-
getBaseSchemaSourceCode(
|
|
158
|
-
entity: Entity,
|
|
159
|
-
importKeys: string[] = []
|
|
160
|
-
): SourceCode {
|
|
149
|
+
getBaseSchemaSourceCode(entity: Entity, importKeys: string[] = []): SourceCode {
|
|
161
150
|
const schemaName = `${entity.names.module}BaseSchema`;
|
|
162
151
|
const propNode: EntityPropNode = {
|
|
163
152
|
nodeType: "object",
|
|
@@ -169,23 +158,39 @@ export class Template__generated extends Template {
|
|
|
169
158
|
}),
|
|
170
159
|
};
|
|
171
160
|
|
|
172
|
-
const schemaBody =
|
|
161
|
+
const schemaBody = (() => {
|
|
162
|
+
const result = propNodeToZodTypeDef(propNode, importKeys);
|
|
163
|
+
if (result.endsWith(",")) {
|
|
164
|
+
return result.slice(0, -1);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return result;
|
|
168
|
+
})();
|
|
173
169
|
|
|
174
170
|
// fulltext index에 포함된 컬럼들 추출
|
|
175
|
-
const fulltextColumns =
|
|
176
|
-
entity.indexes
|
|
177
|
-
.filter((index) => index.type === "fulltext")
|
|
178
|
-
.flatMap((index) => index.columns)
|
|
171
|
+
const fulltextColumns = unique(
|
|
172
|
+
entity.indexes.filter((index) => index.type === "fulltext").flatMap((index) => index.columns),
|
|
179
173
|
);
|
|
180
174
|
|
|
175
|
+
// virtual props
|
|
176
|
+
const virtualProps = entity.props
|
|
177
|
+
.filter((prop) => isVirtualProp(prop))
|
|
178
|
+
.map((prop) => prop.name);
|
|
179
|
+
|
|
181
180
|
const lines = [
|
|
182
|
-
`export const ${schemaName} = ${schemaBody}
|
|
181
|
+
`export const ${schemaName} = ${schemaBody};`,
|
|
183
182
|
`export type ${schemaName} = z.infer<typeof ${schemaName}>` +
|
|
184
183
|
(fulltextColumns.length > 0
|
|
185
184
|
? ` & { readonly __fulltext__: readonly [${fulltextColumns
|
|
186
185
|
.map((col) => `"${col}"`)
|
|
187
186
|
.join(", ")}] }`
|
|
188
|
-
: "")
|
|
187
|
+
: "") +
|
|
188
|
+
(virtualProps.length > 0
|
|
189
|
+
? ` & { readonly __virtual__: readonly [${virtualProps
|
|
190
|
+
.map((prop) => `"${prop}"`)
|
|
191
|
+
.join(", ")}] }`
|
|
192
|
+
: "") +
|
|
193
|
+
";",
|
|
189
194
|
];
|
|
190
195
|
|
|
191
196
|
return {
|
|
@@ -234,7 +239,7 @@ z.object({
|
|
|
234
239
|
|
|
235
240
|
const lines = [
|
|
236
241
|
`export const ${schemaName} = ${schemaBody}`,
|
|
237
|
-
`export type ${schemaName} = z.infer<typeof ${schemaName}
|
|
242
|
+
`export type ${schemaName} = z.infer<typeof ${schemaName}>;`,
|
|
238
243
|
];
|
|
239
244
|
|
|
240
245
|
return {
|
|
@@ -245,7 +250,7 @@ z.object({
|
|
|
245
250
|
}
|
|
246
251
|
|
|
247
252
|
getSubsetSourceCode(entity: Entity): SourceCode | null {
|
|
248
|
-
if (Object.keys(entity.subsets).length
|
|
253
|
+
if (Object.keys(entity.subsets).length === 0) {
|
|
249
254
|
return null;
|
|
250
255
|
} else if (entity.parentId !== undefined) {
|
|
251
256
|
return null;
|
|
@@ -254,45 +259,40 @@ z.object({
|
|
|
254
259
|
const subsetKeys = Object.keys(entity.subsets);
|
|
255
260
|
const importKeys: string[] = [];
|
|
256
261
|
const lines: string[] = [
|
|
257
|
-
...subsetKeys
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
})
|
|
278
|
-
.flat(),
|
|
262
|
+
...subsetKeys.flatMap((subsetKey) => {
|
|
263
|
+
// 서브셋에서 FieldExpr[] 가져옴
|
|
264
|
+
const fieldExprs = entity.subsets[subsetKey];
|
|
265
|
+
|
|
266
|
+
// FieldExpr[]로 EntityPropNode[] 가져옴
|
|
267
|
+
const propNodes = entity.fieldExprsToPropNodes(fieldExprs);
|
|
268
|
+
const schemaName = `${entity.names.module}Subset${subsetKey}`;
|
|
269
|
+
const propNode: EntityPropNode = {
|
|
270
|
+
nodeType: "object",
|
|
271
|
+
children: propNodes,
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// EntityPropNode[]로 ZodTypeDef(string)을 가져옴
|
|
275
|
+
const body = propNodeToZodTypeDef(propNode, importKeys);
|
|
276
|
+
|
|
277
|
+
return [
|
|
278
|
+
`export const ${schemaName} = ${body.replace(/,$/, "")};`,
|
|
279
|
+
`export type ${schemaName} = z.infer<typeof ${schemaName}>;`,
|
|
280
|
+
];
|
|
281
|
+
}),
|
|
279
282
|
`export type ${entity.names.module}SubsetMapping = {`,
|
|
280
|
-
...subsetKeys.map(
|
|
281
|
-
|
|
282
|
-
` ${subsetKey}: ${entity.names.module}Subset${subsetKey};`
|
|
283
|
-
),
|
|
284
|
-
"}",
|
|
283
|
+
...subsetKeys.map((subsetKey) => ` ${subsetKey}: ${entity.names.module}Subset${subsetKey};`),
|
|
284
|
+
"};",
|
|
285
285
|
`export const ${entity.names.module}SubsetKey = z.enum([${subsetKeys
|
|
286
286
|
.map((k) => `"${k}"`)
|
|
287
287
|
.join(",")}]);`,
|
|
288
|
-
`export type ${entity.names.module}SubsetKey = z.infer<typeof ${entity.names.module}SubsetKey
|
|
288
|
+
`export type ${entity.names.module}SubsetKey = z.infer<typeof ${entity.names.module}SubsetKey>;`,
|
|
289
289
|
"",
|
|
290
290
|
];
|
|
291
291
|
|
|
292
292
|
return {
|
|
293
293
|
label: `Subsets: ${entity.id}`,
|
|
294
294
|
lines,
|
|
295
|
-
importKeys:
|
|
295
|
+
importKeys: unique(importKeys),
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import qs from "qs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { TemplateOptions } from "../../types/types";
|
|
4
3
|
import { getZodObjectFromApi } from "../../api/code-converters";
|
|
5
|
-
import { ExtendedApi } from "../../api/decorators";
|
|
6
|
-
import { Template } from "../template";
|
|
7
|
-
import prettier from "prettier";
|
|
4
|
+
import type { ExtendedApi } from "../../api/decorators";
|
|
8
5
|
import { Sonamu } from "../../api/sonamu";
|
|
6
|
+
import { Template } from "../template";
|
|
9
7
|
|
|
10
8
|
export class Template__generated_http extends Template {
|
|
11
9
|
constructor() {
|
|
@@ -21,7 +19,7 @@ export class Template__generated_http extends Template {
|
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
async render(
|
|
22
|
+
async render() {
|
|
25
23
|
const {
|
|
26
24
|
syncer: { types, apis },
|
|
27
25
|
config: {
|
|
@@ -38,23 +36,13 @@ export class Template__generated_http extends Template {
|
|
|
38
36
|
const dataLines = await (async () => {
|
|
39
37
|
if ((api.options.httpMethod ?? "GET") === "GET") {
|
|
40
38
|
return {
|
|
41
|
-
querystring: [
|
|
42
|
-
qs
|
|
43
|
-
.stringify(reqObject, { encode: false })
|
|
44
|
-
.split("&")
|
|
45
|
-
.join("\n\t&"),
|
|
46
|
-
],
|
|
39
|
+
querystring: [qs.stringify(reqObject, { encode: false }).split("&").join("\n\t&")],
|
|
47
40
|
body: [],
|
|
48
41
|
};
|
|
49
42
|
} else {
|
|
50
43
|
return {
|
|
51
44
|
querystring: [],
|
|
52
|
-
body: [
|
|
53
|
-
"",
|
|
54
|
-
await prettier.format(JSON.stringify(reqObject), {
|
|
55
|
-
parser: "json",
|
|
56
|
-
}),
|
|
57
|
-
],
|
|
45
|
+
body: ["", JSON.stringify(reqObject, null, 2)],
|
|
58
46
|
};
|
|
59
47
|
}
|
|
60
48
|
})();
|
|
@@ -67,7 +55,7 @@ export class Template__generated_http extends Template {
|
|
|
67
55
|
`Content-Type: ${api.options.contentType ?? "application/json"}`,
|
|
68
56
|
...dataLines.body,
|
|
69
57
|
].join("\n");
|
|
70
|
-
})
|
|
58
|
+
}),
|
|
71
59
|
);
|
|
72
60
|
|
|
73
61
|
return {
|
|
@@ -83,15 +71,10 @@ export class Template__generated_http extends Template {
|
|
|
83
71
|
Object.keys(zodType.shape).map((key) => [
|
|
84
72
|
key,
|
|
85
73
|
this.zodTypeToReqDefault(zodType.shape[key], key),
|
|
86
|
-
])
|
|
74
|
+
]),
|
|
87
75
|
);
|
|
88
76
|
} else if (zodType instanceof z.ZodArray) {
|
|
89
|
-
return [
|
|
90
|
-
this.zodTypeToReqDefault(
|
|
91
|
-
(zodType as z.ZodArray<z.ZodType>).element,
|
|
92
|
-
name
|
|
93
|
-
),
|
|
94
|
-
];
|
|
77
|
+
return [this.zodTypeToReqDefault((zodType as z.ZodArray<z.ZodType>).element, name)];
|
|
95
78
|
} else if (zodType instanceof z.ZodString) {
|
|
96
79
|
if (name.endsWith("_at") || name.endsWith("_date") || name === "range") {
|
|
97
80
|
return "2000-01-01";
|
|
@@ -110,51 +93,36 @@ export class Template__generated_http extends Template {
|
|
|
110
93
|
} else if (zodType instanceof z.ZodEnum) {
|
|
111
94
|
return zodType.options[0];
|
|
112
95
|
} else if (zodType instanceof z.ZodOptional) {
|
|
113
|
-
return this.zodTypeToReqDefault(
|
|
114
|
-
(zodType as z.ZodOptional<z.ZodType>).def.innerType,
|
|
115
|
-
name
|
|
116
|
-
);
|
|
96
|
+
return this.zodTypeToReqDefault((zodType as z.ZodOptional<z.ZodType>).def.innerType, name);
|
|
117
97
|
} else if (zodType instanceof z.ZodNullable) {
|
|
118
98
|
return null;
|
|
119
99
|
} else if (zodType instanceof z.ZodUnion) {
|
|
120
|
-
return this.zodTypeToReqDefault(
|
|
121
|
-
(zodType as z.ZodUnion<z.ZodType[]>).def.options[0],
|
|
122
|
-
name
|
|
123
|
-
);
|
|
100
|
+
return this.zodTypeToReqDefault((zodType as z.ZodUnion<z.ZodType[]>).def.options[0], name);
|
|
124
101
|
} else if (zodType instanceof z.ZodUnknown) {
|
|
125
102
|
return "unknown";
|
|
126
103
|
} else if (zodType instanceof z.ZodTuple) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
);
|
|
104
|
+
/** biome-ignore lint/suspicious/noExplicitAny: ZodTuple 타입 사용 */
|
|
105
|
+
return zodType.def.items.map((item: any) => this.zodTypeToReqDefault(item, name));
|
|
130
106
|
} else if (zodType instanceof z.ZodDate) {
|
|
131
107
|
return "2000-01-01";
|
|
132
108
|
} else if (zodType instanceof z.ZodLiteral) {
|
|
133
109
|
return zodType.value;
|
|
134
110
|
} else if (zodType instanceof z.ZodRecord || zodType instanceof z.ZodMap) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
111
|
+
// biome-ignore lint/suspicious/noExplicitAny: ZodRecord 타입 사용
|
|
112
|
+
const kvDef = (zodType as z.ZodRecord<any, z.ZodType> | z.ZodMap<z.ZodType, z.ZodType>).def;
|
|
113
|
+
// biome-ignore lint/suspicious/noExplicitAny: ZodIntersection 타입 사용
|
|
138
114
|
const key = this.zodTypeToReqDefault(kvDef.keyType, name) as any;
|
|
139
115
|
const value = this.zodTypeToReqDefault(kvDef.valueType, name);
|
|
140
116
|
return { [key]: value };
|
|
141
117
|
} else if (zodType instanceof z.ZodSet) {
|
|
142
|
-
return [
|
|
143
|
-
this.zodTypeToReqDefault(
|
|
144
|
-
(zodType as z.ZodSet<z.ZodType>).def.valueType,
|
|
145
|
-
name
|
|
146
|
-
),
|
|
147
|
-
];
|
|
118
|
+
return [this.zodTypeToReqDefault((zodType as z.ZodSet<z.ZodType>).def.valueType, name)];
|
|
148
119
|
} else if (zodType instanceof z.ZodIntersection) {
|
|
149
120
|
return this.zodTypeToReqDefault(
|
|
150
121
|
(zodType as z.ZodIntersection<z.ZodType, z.ZodType>).def.right,
|
|
151
|
-
name
|
|
122
|
+
name,
|
|
152
123
|
);
|
|
153
124
|
} else if (zodType instanceof z.ZodDefault) {
|
|
154
|
-
return this.zodTypeToReqDefault(
|
|
155
|
-
(zodType as z.ZodDefault<z.ZodType>).def.innerType,
|
|
156
|
-
name
|
|
157
|
-
);
|
|
125
|
+
return this.zodTypeToReqDefault((zodType as z.ZodDefault<z.ZodType>).def.innerType, name);
|
|
158
126
|
} else {
|
|
159
127
|
// console.log(zodType);
|
|
160
128
|
return `unknown-${zodType.type}`;
|
|
@@ -163,7 +131,8 @@ export class Template__generated_http extends Template {
|
|
|
163
131
|
|
|
164
132
|
resolveApiParams(
|
|
165
133
|
api: ExtendedApi,
|
|
166
|
-
|
|
134
|
+
// biome-ignore lint/suspicious/noExplicitAny: ZodObject 타입 사용
|
|
135
|
+
references: { [typeName: string]: z.ZodObject<any> },
|
|
167
136
|
): { [key: string]: unknown } {
|
|
168
137
|
const reqType = getZodObjectFromApi(api, references);
|
|
169
138
|
try {
|
|
@@ -173,9 +142,7 @@ export class Template__generated_http extends Template {
|
|
|
173
142
|
return def;
|
|
174
143
|
} catch (error) {
|
|
175
144
|
console.error(error);
|
|
176
|
-
throw new Error(
|
|
177
|
-
`Invalid zod type detected on ${api.modelName}:${api.methodName}`
|
|
178
|
-
);
|
|
145
|
+
throw new Error(`Invalid zod type detected on ${api.modelName}:${api.methodName}`);
|
|
179
146
|
}
|
|
180
147
|
}
|
|
181
148
|
}
|