sonamu 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc.project-default +18 -0
- package/bin/cli.js +24 -0
- package/dist/ai/agents/agent.d.ts +11 -0
- package/dist/ai/agents/agent.d.ts.map +1 -0
- package/dist/ai/agents/agent.js +65 -0
- package/dist/ai/agents/index.d.ts +3 -0
- package/dist/ai/agents/index.d.ts.map +1 -0
- package/dist/ai/agents/index.js +4 -0
- package/dist/ai/agents/types.d.ts +43 -0
- package/dist/ai/agents/types.d.ts.map +1 -0
- package/dist/ai/agents/types.js +3 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +3 -0
- package/dist/ai/providers/rtzr/api.d.ts +22 -0
- package/dist/ai/providers/rtzr/api.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/api.js +28 -0
- package/dist/ai/providers/rtzr/error.d.ts +18 -0
- package/dist/ai/providers/rtzr/error.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/error.js +29 -0
- package/dist/ai/providers/rtzr/index.d.ts +5 -0
- package/dist/ai/providers/rtzr/index.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/index.js +6 -0
- package/dist/ai/providers/rtzr/model.d.ts +52 -0
- package/dist/ai/providers/rtzr/model.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/model.js +137 -0
- package/dist/ai/providers/rtzr/options.d.ts +7 -0
- package/dist/ai/providers/rtzr/options.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/options.js +47 -0
- package/dist/ai/providers/rtzr/provider.d.ts +18 -0
- package/dist/ai/providers/rtzr/provider.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/provider.js +54 -0
- package/dist/ai/providers/rtzr/utils.d.ts +19 -0
- package/dist/ai/providers/rtzr/utils.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/utils.js +88 -0
- package/dist/api/base-frame.d.ts +2 -2
- package/dist/api/base-frame.d.ts.map +1 -1
- package/dist/api/base-frame.js +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 +228 -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 +341 -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 +54 -29
- 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 +262 -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 +407 -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
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import knex from "knex";
|
|
2
|
-
|
|
3
|
-
export function attachOnDuplicateUpdate() {
|
|
4
|
-
try {
|
|
5
|
-
knex.QueryBuilder.extend("onDuplicateUpdate", function (...columns) {
|
|
6
|
-
if (columns.length === 0) {
|
|
7
|
-
// 업데이트 할 컬럼이 없으면 onDuplicateUpdate 구문 처리 패스
|
|
8
|
-
const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
|
|
9
|
-
return this.client.raw(originalSQL, originalBindings);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { placeholders, bindings } = columns.reduce(
|
|
13
|
-
(result, column) => {
|
|
14
|
-
if (typeof column === "string") {
|
|
15
|
-
result.placeholders.push(`?? = Values(??)`);
|
|
16
|
-
result.bindings.push(column, column);
|
|
17
|
-
} else if (column && typeof column === "object") {
|
|
18
|
-
Object.keys(column).forEach((key) => {
|
|
19
|
-
result.placeholders.push(`?? = ?`);
|
|
20
|
-
result.bindings.push(key, column[key]);
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
throw new Error(
|
|
24
|
-
"onDuplicateUpdate error: expected column name to be string or object."
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return result;
|
|
29
|
-
},
|
|
30
|
-
{ placeholders: [], bindings: [] }
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
|
|
34
|
-
|
|
35
|
-
const newBindings = [...originalBindings, ...bindings];
|
|
36
|
-
|
|
37
|
-
return this.client.raw(
|
|
38
|
-
`${originalSQL} ON DUPLICATE KEY UPDATE ${placeholders.join(", ")}`,
|
|
39
|
-
newBindings
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
} catch {
|
|
43
|
-
// ignored
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import inflection from "inflection";
|
|
2
|
-
import {
|
|
3
|
-
BelongsToOneRelationProp,
|
|
4
|
-
BigIntegerProp,
|
|
5
|
-
BooleanProp,
|
|
6
|
-
DateProp,
|
|
7
|
-
DateTimeProp,
|
|
8
|
-
DecimalProp,
|
|
9
|
-
DistributiveOmit,
|
|
10
|
-
DoubleProp,
|
|
11
|
-
EnumProp,
|
|
12
|
-
FloatProp,
|
|
13
|
-
HasManyRelationProp,
|
|
14
|
-
IntegerProp,
|
|
15
|
-
JsonProp,
|
|
16
|
-
ManyToManyRelationProp,
|
|
17
|
-
OneToOneRelationProp,
|
|
18
|
-
EntityIndex,
|
|
19
|
-
StringProp,
|
|
20
|
-
TextProp,
|
|
21
|
-
TimeProp,
|
|
22
|
-
TimestampProp,
|
|
23
|
-
UuidProp,
|
|
24
|
-
VirtualProp,
|
|
25
|
-
} from "../types/types";
|
|
26
|
-
import { asArray } from "../utils/model";
|
|
27
|
-
|
|
28
|
-
export const p = {
|
|
29
|
-
integer,
|
|
30
|
-
bigInteger,
|
|
31
|
-
text,
|
|
32
|
-
string,
|
|
33
|
-
float,
|
|
34
|
-
double,
|
|
35
|
-
decimal,
|
|
36
|
-
boolean,
|
|
37
|
-
date,
|
|
38
|
-
dateTime,
|
|
39
|
-
time,
|
|
40
|
-
timestamp,
|
|
41
|
-
json,
|
|
42
|
-
uuid,
|
|
43
|
-
enums,
|
|
44
|
-
virtual,
|
|
45
|
-
relationOneToOne,
|
|
46
|
-
relationBelongsToOne,
|
|
47
|
-
relationHasMany,
|
|
48
|
-
relationManyToMany,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
function integer(
|
|
52
|
-
name: string,
|
|
53
|
-
option?: Omit<IntegerProp, "name" | "type">
|
|
54
|
-
): IntegerProp {
|
|
55
|
-
return {
|
|
56
|
-
name,
|
|
57
|
-
type: "integer",
|
|
58
|
-
...option,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function bigInteger(
|
|
62
|
-
name: string,
|
|
63
|
-
option?: Omit<BigIntegerProp, "name" | "type">
|
|
64
|
-
): BigIntegerProp {
|
|
65
|
-
return {
|
|
66
|
-
name,
|
|
67
|
-
type: "bigInteger",
|
|
68
|
-
...option,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function text(name: string, option: Omit<TextProp, "name" | "type">): TextProp {
|
|
72
|
-
return {
|
|
73
|
-
name,
|
|
74
|
-
type: "text",
|
|
75
|
-
...option,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function string(
|
|
79
|
-
name: string,
|
|
80
|
-
option: Omit<StringProp, "name" | "type">
|
|
81
|
-
): StringProp {
|
|
82
|
-
return {
|
|
83
|
-
name,
|
|
84
|
-
type: "string",
|
|
85
|
-
...option,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function float(
|
|
89
|
-
name: string,
|
|
90
|
-
option?: Omit<FloatProp, "name" | "type">
|
|
91
|
-
): FloatProp {
|
|
92
|
-
return {
|
|
93
|
-
name,
|
|
94
|
-
type: "float",
|
|
95
|
-
precision: 8,
|
|
96
|
-
scale: 2,
|
|
97
|
-
...option,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function double(
|
|
101
|
-
name: string,
|
|
102
|
-
option?: Omit<DoubleProp, "name" | "type">
|
|
103
|
-
): DoubleProp {
|
|
104
|
-
return {
|
|
105
|
-
name,
|
|
106
|
-
type: "double",
|
|
107
|
-
precision: 8,
|
|
108
|
-
scale: 2,
|
|
109
|
-
...option,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function decimal(
|
|
113
|
-
name: string,
|
|
114
|
-
option?: Omit<DecimalProp, "name" | "type">
|
|
115
|
-
): DecimalProp {
|
|
116
|
-
return {
|
|
117
|
-
name,
|
|
118
|
-
type: "decimal",
|
|
119
|
-
precision: 8,
|
|
120
|
-
scale: 2,
|
|
121
|
-
...option,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function boolean(
|
|
125
|
-
name: string,
|
|
126
|
-
option?: Omit<BooleanProp, "name" | "type">
|
|
127
|
-
): BooleanProp {
|
|
128
|
-
return {
|
|
129
|
-
name,
|
|
130
|
-
type: "boolean",
|
|
131
|
-
...option,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function date(
|
|
135
|
-
name: string,
|
|
136
|
-
option?: Omit<DateProp, "name" | "type"> & { now?: true }
|
|
137
|
-
): DateProp {
|
|
138
|
-
if (option?.now === true) {
|
|
139
|
-
delete option.now;
|
|
140
|
-
option.dbDefault = "CURRENT_TIMESTAMP";
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
name,
|
|
144
|
-
type: "date",
|
|
145
|
-
...option,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function dateTime(
|
|
149
|
-
name: string,
|
|
150
|
-
option?: Omit<DateTimeProp, "name" | "type"> & { now?: true }
|
|
151
|
-
): DateTimeProp {
|
|
152
|
-
if (option?.now === true) {
|
|
153
|
-
delete option.now;
|
|
154
|
-
option.dbDefault = "CURRENT_TIMESTAMP";
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
name,
|
|
158
|
-
type: "datetime",
|
|
159
|
-
...option,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
function time(
|
|
163
|
-
name: string,
|
|
164
|
-
option?: Omit<TimeProp, "name" | "type"> & { now?: true }
|
|
165
|
-
): TimeProp {
|
|
166
|
-
if (option?.now === true) {
|
|
167
|
-
delete option.now;
|
|
168
|
-
option.dbDefault = "CURRENT_TIMESTAMP";
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
name,
|
|
172
|
-
type: "time",
|
|
173
|
-
...option,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function timestamp(
|
|
177
|
-
name: string,
|
|
178
|
-
option?: Omit<TimestampProp, "name" | "type"> & { now?: true }
|
|
179
|
-
): TimestampProp {
|
|
180
|
-
if (option?.now === true) {
|
|
181
|
-
delete option.now;
|
|
182
|
-
option.dbDefault = "CURRENT_TIMESTAMP";
|
|
183
|
-
}
|
|
184
|
-
return {
|
|
185
|
-
name,
|
|
186
|
-
type: "timestamp",
|
|
187
|
-
...option,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
function json(name: string, option: Omit<JsonProp, "name" | "type">): JsonProp {
|
|
191
|
-
return {
|
|
192
|
-
name,
|
|
193
|
-
type: "json",
|
|
194
|
-
...option,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
function uuid(name: string, option: Omit<UuidProp, "name" | "type">): UuidProp {
|
|
198
|
-
return {
|
|
199
|
-
name,
|
|
200
|
-
type: "uuid",
|
|
201
|
-
...option,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function enums(
|
|
205
|
-
name: string,
|
|
206
|
-
option: Omit<EnumProp, "name" | "type" | "id"> & { id?: string }
|
|
207
|
-
): EnumProp {
|
|
208
|
-
return {
|
|
209
|
-
name,
|
|
210
|
-
type: "enum",
|
|
211
|
-
id: option.id ?? `$Model${inflection.camelize(name)}`,
|
|
212
|
-
...option,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function virtual(
|
|
216
|
-
name: string,
|
|
217
|
-
option: Omit<VirtualProp, "name" | "type" | "dbDefault" | "toFilter">
|
|
218
|
-
): VirtualProp {
|
|
219
|
-
return {
|
|
220
|
-
name,
|
|
221
|
-
type: "virtual",
|
|
222
|
-
...option,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function relationOneToOne(
|
|
226
|
-
name: string,
|
|
227
|
-
option: DistributiveOmit<
|
|
228
|
-
OneToOneRelationProp,
|
|
229
|
-
"name" | "type" | "relationType"
|
|
230
|
-
>
|
|
231
|
-
): OneToOneRelationProp {
|
|
232
|
-
return {
|
|
233
|
-
name,
|
|
234
|
-
type: "relation",
|
|
235
|
-
relationType: "OneToOne",
|
|
236
|
-
...option,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
function relationBelongsToOne(
|
|
240
|
-
name: string,
|
|
241
|
-
option: Omit<BelongsToOneRelationProp, "name" | "type" | "relationType">
|
|
242
|
-
): BelongsToOneRelationProp {
|
|
243
|
-
option.useConstraint = (option.useConstraint ?? true) as false;
|
|
244
|
-
return {
|
|
245
|
-
name,
|
|
246
|
-
type: "relation",
|
|
247
|
-
relationType: "BelongsToOne",
|
|
248
|
-
...option,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
function relationHasMany(
|
|
252
|
-
name: string,
|
|
253
|
-
option: Omit<HasManyRelationProp, "name" | "type" | "relationType">
|
|
254
|
-
): HasManyRelationProp {
|
|
255
|
-
return {
|
|
256
|
-
name,
|
|
257
|
-
type: "relation",
|
|
258
|
-
relationType: "HasMany",
|
|
259
|
-
...option,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
function relationManyToMany(
|
|
263
|
-
name: string,
|
|
264
|
-
option: Omit<ManyToManyRelationProp, "name" | "type" | "relationType">
|
|
265
|
-
): ManyToManyRelationProp {
|
|
266
|
-
return {
|
|
267
|
-
name,
|
|
268
|
-
type: "relation",
|
|
269
|
-
relationType: "ManyToMany",
|
|
270
|
-
...option,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export const i = {
|
|
275
|
-
index,
|
|
276
|
-
unique,
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
function index(columns: string | string[]): EntityIndex {
|
|
280
|
-
return {
|
|
281
|
-
type: "index",
|
|
282
|
-
columns: asArray(columns),
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function unique(columns: string | string[]): EntityIndex {
|
|
287
|
-
return {
|
|
288
|
-
type: "unique",
|
|
289
|
-
columns: asArray(columns),
|
|
290
|
-
};
|
|
291
|
-
}
|