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/types/types.ts
CHANGED
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
import type { GuardKey } from "./../api/decorators";
|
|
2
1
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
import type { ApiDecoratorOptions, AuthContext, Context } from "../api";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
Enums
|
|
8
|
-
*/
|
|
9
|
-
export type EnumsLabel<T extends string, L extends "ko" | "en"> = {
|
|
10
|
-
[key in T]: { [lang in L]: string };
|
|
11
|
-
};
|
|
12
|
-
export type EnumsLabelKo<T extends string> = EnumsLabel<T, "ko">;
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
Custom Scalars
|
|
16
|
-
*/
|
|
17
|
-
export const SQLDateTimeString = z
|
|
18
|
-
.string()
|
|
19
|
-
.regex(/([0-9]{4}-[0-9]{2}-[0-9]{2}( [0-9]{2}:[0-9]{2}:[0-9]{2})*)$/, {
|
|
20
|
-
message: "잘못된 SQLDate 타입",
|
|
21
|
-
})
|
|
22
|
-
.min(10)
|
|
23
|
-
.max(19)
|
|
24
|
-
.describe("SQLDateTimeString");
|
|
25
|
-
export type SQLDateTimeString = z.infer<typeof SQLDateTimeString>;
|
|
4
|
+
import type { GuardKey } from "./../api/decorators";
|
|
26
5
|
|
|
27
6
|
/*
|
|
28
7
|
Utility Types
|
|
29
8
|
*/
|
|
30
|
-
export function zArrayable<T extends z.ZodTypeAny>(
|
|
31
|
-
shape: T
|
|
32
|
-
): z.ZodUnion<[T, z.ZodArray<T>]> {
|
|
9
|
+
export function zArrayable<T extends z.ZodTypeAny>(shape: T): z.ZodUnion<[T, z.ZodArray<T>]> {
|
|
33
10
|
return z.union([shape, shape.array()]);
|
|
34
11
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
: 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;
|
|
38
14
|
|
|
39
15
|
/*
|
|
40
16
|
Model-Defintion
|
|
@@ -48,81 +24,84 @@ export type CommonProp = {
|
|
|
48
24
|
};
|
|
49
25
|
export type IntegerProp = CommonProp & {
|
|
50
26
|
type: "integer";
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
}; // PG: integer / TS: number / JSON: number
|
|
28
|
+
export type IntegerArrayProp = CommonProp & {
|
|
29
|
+
type: "integer[]";
|
|
30
|
+
}; // PG: integer[] / TS: number[] / JSON: number[]
|
|
53
31
|
export type BigIntegerProp = CommonProp & {
|
|
54
32
|
type: "bigInteger";
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
textType: "text" | "mediumtext" | "longtext";
|
|
60
|
-
};
|
|
33
|
+
}; // PG: bigint / TS: bigint / JSON: bigint
|
|
34
|
+
export type BigIntegerArrayProp = CommonProp & {
|
|
35
|
+
type: "bigInteger[]";
|
|
36
|
+
}; // PG: bigint[] / TS: bigint[] / JSON: bigint[]
|
|
61
37
|
export type StringProp = CommonProp & {
|
|
62
38
|
type: "string";
|
|
63
|
-
length
|
|
64
|
-
};
|
|
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[]
|
|
65
45
|
export type EnumProp = CommonProp & {
|
|
66
46
|
type: "enum";
|
|
67
|
-
length: number;
|
|
68
47
|
id: string;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
precision
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
precision
|
|
86
|
-
|
|
87
|
-
|
|
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[]
|
|
88
76
|
export type BooleanProp = CommonProp & {
|
|
89
77
|
type: "boolean";
|
|
90
|
-
};
|
|
78
|
+
}; // PG: boolean / TS: boolean / JSON: boolean
|
|
79
|
+
export type BooleanArrayProp = CommonProp & {
|
|
80
|
+
type: "boolean[]";
|
|
81
|
+
}; // PG: boolean[] / TS: boolean[] / JSON: boolean[]
|
|
91
82
|
export type DateProp = CommonProp & {
|
|
92
83
|
type: "date";
|
|
93
|
-
};
|
|
94
|
-
export type
|
|
95
|
-
type: "
|
|
96
|
-
};
|
|
97
|
-
export type TimeProp = CommonProp & {
|
|
98
|
-
type: "time";
|
|
99
|
-
};
|
|
100
|
-
export type TimestampProp = CommonProp & {
|
|
101
|
-
type: "timestamp";
|
|
102
|
-
};
|
|
84
|
+
}; // PG: timestampz / TS: Date / JSON: string(ISOString)
|
|
85
|
+
export type DateArrayProp = CommonProp & {
|
|
86
|
+
type: "date[]";
|
|
87
|
+
}; // PG: timestamptz[] / TS: Date[] / JSON: string[]
|
|
103
88
|
export type JsonProp = CommonProp & {
|
|
104
89
|
type: "json";
|
|
105
90
|
id: string;
|
|
106
|
-
};
|
|
91
|
+
}; // PG: json / TS: any(id) / JSON: any
|
|
107
92
|
export type UuidProp = CommonProp & {
|
|
108
93
|
type: "uuid";
|
|
109
|
-
};
|
|
94
|
+
}; // PG: uuid / TS: string / JSON: string
|
|
95
|
+
export type UuidArrayProp = CommonProp & {
|
|
96
|
+
type: "uuid[]";
|
|
97
|
+
}; // PG: uuid[] / TS: string[] / JSON: string[]
|
|
110
98
|
export type VirtualProp = CommonProp & {
|
|
111
99
|
type: "virtual";
|
|
112
100
|
id: string;
|
|
113
|
-
};
|
|
101
|
+
}; // PG: none / TS: any(id) / JSON: any
|
|
114
102
|
|
|
115
|
-
export type RelationType =
|
|
116
|
-
|
|
117
|
-
| "BelongsToOne"
|
|
118
|
-
| "ManyToMany"
|
|
119
|
-
| "OneToOne";
|
|
120
|
-
export type RelationOn =
|
|
121
|
-
| "CASCADE"
|
|
122
|
-
| "SET NULL"
|
|
123
|
-
| "NO ACTION"
|
|
124
|
-
| "SET DEFAULT"
|
|
125
|
-
| "RESTRICT";
|
|
103
|
+
export type RelationType = "HasMany" | "BelongsToOne" | "ManyToMany" | "OneToOne";
|
|
104
|
+
export type RelationOn = "CASCADE" | "SET NULL" | "NO ACTION" | "SET DEFAULT" | "RESTRICT";
|
|
126
105
|
type _RelationProp = {
|
|
127
106
|
type: "relation";
|
|
128
107
|
name: string;
|
|
@@ -171,20 +150,25 @@ export type RelationProp =
|
|
|
171
150
|
|
|
172
151
|
export type EntityProp =
|
|
173
152
|
| IntegerProp
|
|
153
|
+
| IntegerArrayProp
|
|
174
154
|
| BigIntegerProp
|
|
175
|
-
|
|
|
155
|
+
| BigIntegerArrayProp
|
|
176
156
|
| StringProp
|
|
177
|
-
|
|
|
178
|
-
|
|
|
179
|
-
|
|
|
157
|
+
| StringArrayProp
|
|
158
|
+
| EnumProp
|
|
159
|
+
| EnumArrayProp
|
|
160
|
+
| NumberProp
|
|
161
|
+
| NumberArrayProp
|
|
162
|
+
| NumericProp
|
|
163
|
+
| NumericArrayProp
|
|
164
|
+
| NumericProp
|
|
180
165
|
| BooleanProp
|
|
166
|
+
| BooleanArrayProp
|
|
181
167
|
| DateProp
|
|
182
|
-
|
|
|
183
|
-
| TimeProp
|
|
184
|
-
| TimestampProp
|
|
185
|
-
| JsonProp
|
|
168
|
+
| DateArrayProp
|
|
186
169
|
| UuidProp
|
|
187
|
-
|
|
|
170
|
+
| UuidArrayProp
|
|
171
|
+
| JsonProp
|
|
188
172
|
| VirtualProp
|
|
189
173
|
| RelationProp;
|
|
190
174
|
|
|
@@ -222,19 +206,6 @@ export type EntitySubsetRow = {
|
|
|
222
206
|
};
|
|
223
207
|
export type FlattenSubsetRow = Omit<EntitySubsetRow, "children">;
|
|
224
208
|
|
|
225
|
-
// SMD Legacy
|
|
226
|
-
export type SMDInput<T extends string> = {
|
|
227
|
-
id: string;
|
|
228
|
-
parentId?: string;
|
|
229
|
-
table?: string;
|
|
230
|
-
title?: string;
|
|
231
|
-
props?: EntityProp[];
|
|
232
|
-
indexes?: EntityIndex[];
|
|
233
|
-
subsets?: {
|
|
234
|
-
[subset: string]: T[];
|
|
235
|
-
};
|
|
236
|
-
};
|
|
237
|
-
|
|
238
209
|
/*
|
|
239
210
|
PropNode
|
|
240
211
|
*/
|
|
@@ -269,70 +240,107 @@ export type EntityPropNode =
|
|
|
269
240
|
/*
|
|
270
241
|
Prop Type Guards
|
|
271
242
|
*/
|
|
272
|
-
export function
|
|
273
|
-
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);
|
|
251
|
+
}
|
|
252
|
+
export function isBigIntegerSingleProp(p: unknown): p is BigIntegerProp {
|
|
253
|
+
return (p as BigIntegerProp)?.type === "bigInteger";
|
|
254
|
+
}
|
|
255
|
+
export function isBigIntegerArrayProp(p: unknown): p is BigIntegerArrayProp {
|
|
256
|
+
return (p as BigIntegerArrayProp)?.type === "bigInteger[]";
|
|
257
|
+
}
|
|
258
|
+
export function isBigIntegerProp(p: unknown): p is BigIntegerProp | BigIntegerArrayProp {
|
|
259
|
+
return isBigIntegerSingleProp(p) || isBigIntegerArrayProp(p);
|
|
260
|
+
}
|
|
261
|
+
export function isStringSingleProp(p: unknown): p is StringProp {
|
|
262
|
+
return (p as StringProp)?.type === "string";
|
|
263
|
+
}
|
|
264
|
+
export function isStringArrayProp(p: unknown): p is StringArrayProp {
|
|
265
|
+
return (p as StringArrayProp)?.type === "string[]";
|
|
266
|
+
}
|
|
267
|
+
export function isStringProp(p: unknown): p is StringProp | StringArrayProp {
|
|
268
|
+
return isStringSingleProp(p) || isStringArrayProp(p);
|
|
269
|
+
}
|
|
270
|
+
export function isEnumSingleProp(p: unknown): p is EnumProp {
|
|
271
|
+
return (p as EnumProp)?.type === "enum";
|
|
272
|
+
}
|
|
273
|
+
export function isEnumArrayProp(p: unknown): p is EnumArrayProp {
|
|
274
|
+
return (p as EnumArrayProp)?.type === "enum[]";
|
|
275
|
+
}
|
|
276
|
+
export function isEnumProp(p: unknown): p is EnumProp | EnumArrayProp {
|
|
277
|
+
return isEnumSingleProp(p) || isEnumArrayProp(p);
|
|
278
|
+
}
|
|
279
|
+
export function isNumberSingleProp(p: unknown): p is NumberProp {
|
|
280
|
+
return (p as NumberProp)?.type === "number";
|
|
274
281
|
}
|
|
275
|
-
export function
|
|
276
|
-
return p?.type === "
|
|
282
|
+
export function isNumberArrayProp(p: unknown): p is NumberArrayProp {
|
|
283
|
+
return (p as NumberArrayProp)?.type === "number[]";
|
|
277
284
|
}
|
|
278
|
-
export function
|
|
279
|
-
return p
|
|
285
|
+
export function isNumberProp(p: unknown): p is NumberProp | NumberArrayProp {
|
|
286
|
+
return isNumberSingleProp(p) || isNumberArrayProp(p);
|
|
280
287
|
}
|
|
281
|
-
export function
|
|
282
|
-
return p?.type === "
|
|
288
|
+
export function isNumericSingleProp(p: unknown): p is NumericProp {
|
|
289
|
+
return (p as NumericProp)?.type === "numeric";
|
|
283
290
|
}
|
|
284
|
-
export function
|
|
285
|
-
return p?.type === "
|
|
291
|
+
export function isNumericArrayProp(p: unknown): p is NumericArrayProp {
|
|
292
|
+
return (p as NumericArrayProp)?.type === "numeric[]";
|
|
286
293
|
}
|
|
287
|
-
export function
|
|
288
|
-
return p
|
|
294
|
+
export function isNumericProp(p: unknown): p is NumericProp | NumericArrayProp {
|
|
295
|
+
return isNumericSingleProp(p) || isNumericArrayProp(p);
|
|
289
296
|
}
|
|
290
|
-
export function
|
|
291
|
-
return p?.type === "
|
|
297
|
+
export function isBooleanSingleProp(p: unknown): p is BooleanProp {
|
|
298
|
+
return (p as BooleanProp)?.type === "boolean";
|
|
292
299
|
}
|
|
293
|
-
export function
|
|
294
|
-
return p?.type === "
|
|
300
|
+
export function isBooleanArrayProp(p: unknown): p is BooleanArrayProp {
|
|
301
|
+
return (p as BooleanArrayProp)?.type === "boolean[]";
|
|
295
302
|
}
|
|
296
|
-
export function isBooleanProp(p:
|
|
297
|
-
return p
|
|
303
|
+
export function isBooleanProp(p: unknown): p is BooleanProp | BooleanArrayProp {
|
|
304
|
+
return isBooleanSingleProp(p) || isBooleanArrayProp(p);
|
|
298
305
|
}
|
|
299
|
-
export function
|
|
300
|
-
return p?.type === "date";
|
|
306
|
+
export function isDateSingleProp(p: unknown): p is DateProp {
|
|
307
|
+
return (p as DateProp)?.type === "date";
|
|
301
308
|
}
|
|
302
|
-
export function
|
|
303
|
-
return p?.type === "
|
|
309
|
+
export function isDateArrayProp(p: unknown): p is DateArrayProp {
|
|
310
|
+
return (p as DateArrayProp)?.type === "date[]";
|
|
304
311
|
}
|
|
305
|
-
export function
|
|
306
|
-
return p
|
|
312
|
+
export function isDateProp(p: unknown): p is DateProp | DateArrayProp {
|
|
313
|
+
return isDateSingleProp(p) || isDateArrayProp(p);
|
|
307
314
|
}
|
|
308
|
-
export function
|
|
309
|
-
return p?.type === "
|
|
315
|
+
export function isUuidSingleProp(p: unknown): p is UuidProp {
|
|
316
|
+
return (p as UuidProp)?.type === "uuid";
|
|
310
317
|
}
|
|
311
|
-
export function
|
|
312
|
-
return p?.type === "
|
|
318
|
+
export function isUuidArrayProp(p: unknown): p is UuidArrayProp {
|
|
319
|
+
return (p as UuidArrayProp)?.type === "uuid[]";
|
|
313
320
|
}
|
|
314
|
-
export function isUuidProp(p:
|
|
315
|
-
return p
|
|
321
|
+
export function isUuidProp(p: unknown): p is UuidProp | UuidArrayProp {
|
|
322
|
+
return isUuidSingleProp(p) || isUuidArrayProp(p);
|
|
316
323
|
}
|
|
317
|
-
export function
|
|
318
|
-
return p?.type === "
|
|
324
|
+
export function isJsonProp(p: unknown): p is JsonProp {
|
|
325
|
+
return (p as JsonProp)?.type === "json";
|
|
319
326
|
}
|
|
320
|
-
export function
|
|
321
|
-
return p?.type === "
|
|
327
|
+
export function isVirtualProp(p: unknown): p is VirtualProp {
|
|
328
|
+
return (p as VirtualProp)?.type === "virtual";
|
|
322
329
|
}
|
|
323
|
-
export function
|
|
324
|
-
return p?.
|
|
330
|
+
export function isRelationProp(p: unknown): p is RelationProp {
|
|
331
|
+
return (p as RelationProp)?.type === "relation";
|
|
325
332
|
}
|
|
326
|
-
export function
|
|
327
|
-
p
|
|
328
|
-
): p is BelongsToOneRelationProp {
|
|
329
|
-
return p?.relationType === "BelongsToOne";
|
|
333
|
+
export function isOneToOneRelationProp(p: unknown): p is OneToOneRelationProp {
|
|
334
|
+
return (p as OneToOneRelationProp)?.relationType === "OneToOne";
|
|
330
335
|
}
|
|
331
|
-
export function
|
|
332
|
-
return p?.relationType === "
|
|
336
|
+
export function isBelongsToOneRelationProp(p: unknown): p is BelongsToOneRelationProp {
|
|
337
|
+
return (p as BelongsToOneRelationProp)?.relationType === "BelongsToOne";
|
|
333
338
|
}
|
|
334
|
-
export function
|
|
335
|
-
return p?.relationType === "
|
|
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";
|
|
336
344
|
}
|
|
337
345
|
|
|
338
346
|
type JoinClause =
|
|
@@ -343,44 +351,9 @@ type JoinClause =
|
|
|
343
351
|
| {
|
|
344
352
|
custom: string;
|
|
345
353
|
};
|
|
346
|
-
export function isCustomJoinClause(p:
|
|
347
|
-
return p?.custom;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/* 서브셋 */
|
|
351
|
-
// type SubsetLoader = {
|
|
352
|
-
// as: string;
|
|
353
|
-
// table: string;
|
|
354
|
-
// manyJoin: {
|
|
355
|
-
// fromTable: string;
|
|
356
|
-
// fromCol: string;
|
|
357
|
-
// idField: string;
|
|
358
|
-
// toTable: string;
|
|
359
|
-
// toCol: string;
|
|
360
|
-
// through?: {
|
|
361
|
-
// table: string;
|
|
362
|
-
// fromCol: string;
|
|
363
|
-
// toCol: string;
|
|
364
|
-
// };
|
|
365
|
-
// };
|
|
366
|
-
// oneJoins: ({
|
|
367
|
-
// as: string;
|
|
368
|
-
// join: "inner" | "outer";
|
|
369
|
-
// table: string;
|
|
370
|
-
// } & JoinClause)[];
|
|
371
|
-
// select: (string | Knex.Raw)[];
|
|
372
|
-
// loaders?: SubsetLoader[];
|
|
373
|
-
// };
|
|
374
|
-
// export type SubsetQuery = {
|
|
375
|
-
// select: (string | Knex.Raw)[];
|
|
376
|
-
// virtual: string[];
|
|
377
|
-
// joins: ({
|
|
378
|
-
// as: string;
|
|
379
|
-
// join: "inner" | "outer";
|
|
380
|
-
// table: string;
|
|
381
|
-
// } & JoinClause)[];
|
|
382
|
-
// loaders: SubsetLoader[];
|
|
383
|
-
// };
|
|
354
|
+
export function isCustomJoinClause(p: unknown): p is { custom: string } {
|
|
355
|
+
return !!(p as { custom: string })?.custom;
|
|
356
|
+
}
|
|
384
357
|
|
|
385
358
|
type SubsetLoader = {
|
|
386
359
|
as: string;
|
|
@@ -429,8 +402,8 @@ export type KnexError = {
|
|
|
429
402
|
sqlMessage: string;
|
|
430
403
|
sqlState: string;
|
|
431
404
|
};
|
|
432
|
-
export function isKnexError(e:
|
|
433
|
-
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;
|
|
434
407
|
}
|
|
435
408
|
|
|
436
409
|
export type KnexColumnType =
|
|
@@ -451,11 +424,27 @@ export type KnexColumnType =
|
|
|
451
424
|
| "date"
|
|
452
425
|
| "time"
|
|
453
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";
|
|
454
443
|
export type MigrationColumn = {
|
|
455
444
|
name: string;
|
|
456
|
-
type:
|
|
445
|
+
type: MigrationColumnType;
|
|
457
446
|
nullable: boolean;
|
|
458
|
-
|
|
447
|
+
numberType?: "real" | "double precision" | "numeric";
|
|
459
448
|
length?: number;
|
|
460
449
|
defaultTo?: string;
|
|
461
450
|
precision?: number;
|
|
@@ -566,53 +555,83 @@ export namespace ApiParamType {
|
|
|
566
555
|
constraint?: ApiParamType;
|
|
567
556
|
};
|
|
568
557
|
|
|
569
|
-
export function isObject(v:
|
|
570
|
-
return v?.t === "object";
|
|
558
|
+
export function isObject(v: unknown): v is ApiParamType.Object {
|
|
559
|
+
return (v as ApiParamType.Object)?.t === "object";
|
|
571
560
|
}
|
|
572
|
-
export function isUnion(v:
|
|
573
|
-
return v?.t === "union";
|
|
561
|
+
export function isUnion(v: unknown): v is ApiParamType.Union {
|
|
562
|
+
return (v as ApiParamType.Union)?.t === "union";
|
|
574
563
|
}
|
|
575
|
-
export function isIntersection(v:
|
|
576
|
-
return v?.t === "intersection";
|
|
564
|
+
export function isIntersection(v: unknown): v is ApiParamType.Intersection {
|
|
565
|
+
return (v as ApiParamType.Intersection)?.t === "intersection";
|
|
577
566
|
}
|
|
578
|
-
export function isStringLiteral(v:
|
|
579
|
-
return v?.t === "string-literal";
|
|
567
|
+
export function isStringLiteral(v: unknown): v is ApiParamType.StringLiteral {
|
|
568
|
+
return (v as ApiParamType.StringLiteral)?.t === "string-literal";
|
|
580
569
|
}
|
|
581
|
-
export function isNumericLiteral(v:
|
|
582
|
-
return v?.t === "numeric-literal";
|
|
570
|
+
export function isNumericLiteral(v: unknown): v is ApiParamType.NumericLiteral {
|
|
571
|
+
return (v as ApiParamType.NumericLiteral)?.t === "numeric-literal";
|
|
583
572
|
}
|
|
584
|
-
export function isArray(v:
|
|
585
|
-
return v?.t === "array";
|
|
573
|
+
export function isArray(v: unknown): v is ApiParamType.Array {
|
|
574
|
+
return (v as ApiParamType.Array)?.t === "array";
|
|
586
575
|
}
|
|
587
|
-
export function isRef(v:
|
|
588
|
-
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";
|
|
589
578
|
}
|
|
590
|
-
export function isIndexedAccess(v:
|
|
591
|
-
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";
|
|
592
581
|
}
|
|
593
|
-
export function isTupleType(v:
|
|
594
|
-
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";
|
|
595
584
|
}
|
|
596
|
-
export function isPick(v:
|
|
597
|
-
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
|
+
);
|
|
598
592
|
}
|
|
599
|
-
export function isOmit(v:
|
|
600
|
-
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
|
+
);
|
|
601
600
|
}
|
|
602
|
-
export function isPartial(v:
|
|
603
|
-
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
|
+
);
|
|
604
608
|
}
|
|
605
|
-
export function isPromise(v:
|
|
606
|
-
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
|
+
);
|
|
607
616
|
}
|
|
608
|
-
export function isContext(v:
|
|
609
|
-
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
|
+
);
|
|
610
624
|
}
|
|
611
|
-
export function isRefKnex(v:
|
|
612
|
-
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
|
+
);
|
|
613
632
|
}
|
|
614
|
-
export function isTypeParam(v:
|
|
615
|
-
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";
|
|
616
635
|
}
|
|
617
636
|
}
|
|
618
637
|
export type ApiParamType =
|
|
@@ -689,17 +708,270 @@ export type RenderingNode = {
|
|
|
689
708
|
nullable?: boolean;
|
|
690
709
|
};
|
|
691
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
|
+
|
|
692
963
|
export const TemplateOptions = z.object({
|
|
693
|
-
entity:
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
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
|
+
}),
|
|
703
975
|
init_types: z.object({
|
|
704
976
|
entityId: z.string(),
|
|
705
977
|
}),
|
|
@@ -710,8 +982,8 @@ export const TemplateOptions = z.object({
|
|
|
710
982
|
}),
|
|
711
983
|
model: z.object({
|
|
712
984
|
entityId: z.string(),
|
|
713
|
-
defaultSearchField: z.string(),
|
|
714
|
-
defaultOrderBy: z.string(),
|
|
985
|
+
defaultSearchField: z.string().optional(),
|
|
986
|
+
defaultOrderBy: z.string().optional(),
|
|
715
987
|
}),
|
|
716
988
|
model_test: z.object({
|
|
717
989
|
entityId: z.string(),
|
|
@@ -815,6 +1087,7 @@ export type FixtureSearchOptions = {
|
|
|
815
1087
|
searchType: "equals" | "like";
|
|
816
1088
|
};
|
|
817
1089
|
|
|
1090
|
+
type ColumnValue = string | number | boolean | Date | null;
|
|
818
1091
|
export type FixtureRecord = {
|
|
819
1092
|
fixtureId: string;
|
|
820
1093
|
entityId: string;
|
|
@@ -822,7 +1095,7 @@ export type FixtureRecord = {
|
|
|
822
1095
|
columns: {
|
|
823
1096
|
[key: string]: {
|
|
824
1097
|
prop: EntityProp;
|
|
825
|
-
value:
|
|
1098
|
+
value: ColumnValue | ColumnValue[];
|
|
826
1099
|
};
|
|
827
1100
|
};
|
|
828
1101
|
fetchedRecords: string[];
|
|
@@ -835,7 +1108,7 @@ export type FixtureRecord = {
|
|
|
835
1108
|
export type FixtureImportResult = {
|
|
836
1109
|
entityId: string;
|
|
837
1110
|
data: {
|
|
838
|
-
[key: string]:
|
|
1111
|
+
[key: string]: ColumnValue;
|
|
839
1112
|
};
|
|
840
1113
|
};
|
|
841
1114
|
|
|
@@ -845,11 +1118,9 @@ export type RelationNode = {
|
|
|
845
1118
|
related: Set<string>;
|
|
846
1119
|
};
|
|
847
1120
|
|
|
1121
|
+
// biome-ignore lint/suspicious/noEmptyInterface: sonamu.generated.sso 에서 확장을 위해 준비된 빈 인터페이스
|
|
848
1122
|
export interface DatabaseSchemaExtend {}
|
|
849
|
-
export type ManyToManyBaseSchema<
|
|
850
|
-
FromIdKey extends string,
|
|
851
|
-
ToIdKey extends string,
|
|
852
|
-
> = {
|
|
1123
|
+
export type ManyToManyBaseSchema<FromIdKey extends string, ToIdKey extends string> = {
|
|
853
1124
|
id: number;
|
|
854
1125
|
} & {
|
|
855
1126
|
[K in `${FromIdKey}_id`]: number;
|
|
@@ -859,13 +1130,10 @@ export type ManyToManyBaseSchema<
|
|
|
859
1130
|
|
|
860
1131
|
export type SonamuFastifyConfig = {
|
|
861
1132
|
contextProvider: (
|
|
862
|
-
defaultContext: Pick<
|
|
863
|
-
Context,
|
|
864
|
-
"request" | "reply" | "headers" | "createSSE" | "naiteStore"
|
|
865
|
-
> &
|
|
1133
|
+
defaultContext: Pick<Context, "request" | "reply" | "headers" | "createSSE" | "naiteStore"> &
|
|
866
1134
|
AuthContext,
|
|
867
1135
|
request: FastifyRequest,
|
|
868
|
-
reply: FastifyReply
|
|
1136
|
+
reply: FastifyReply,
|
|
869
1137
|
) => Context | Promise<Context>;
|
|
870
1138
|
guardHandler: (
|
|
871
1139
|
guard: GuardKey,
|
|
@@ -878,7 +1146,7 @@ export type SonamuFastifyConfig = {
|
|
|
878
1146
|
methodName: string;
|
|
879
1147
|
path: string;
|
|
880
1148
|
options: ApiDecoratorOptions;
|
|
881
|
-
}
|
|
1149
|
+
},
|
|
882
1150
|
) => void;
|
|
883
1151
|
cache?: {
|
|
884
1152
|
get: (key: string) => Promise<unknown | null>;
|
|
@@ -887,7 +1155,7 @@ export type SonamuFastifyConfig = {
|
|
|
887
1155
|
path: string,
|
|
888
1156
|
reqBody: {
|
|
889
1157
|
[key: string]: unknown;
|
|
890
|
-
}
|
|
1158
|
+
},
|
|
891
1159
|
) =>
|
|
892
1160
|
| {
|
|
893
1161
|
cache: false;
|