sonamu 0.8.26 → 0.9.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/bin/cli.js +60 -13
- package/dist/_virtual/rolldown_runtime.js +39 -0
- package/dist/ai/agents/agent.d.ts +3 -3
- package/dist/ai/agents/agent.d.ts.map +1 -1
- package/dist/ai/agents/agent.js +76 -73
- package/dist/ai/agents/index.js +3 -3
- package/dist/ai/agents/types.d.ts +3 -3
- package/dist/ai/agents/types.d.ts.map +1 -1
- package/dist/ai/agents/types.js +1 -3
- package/dist/ai/index.js +3 -2
- package/dist/ai/providers/rtzr/api.js +25 -25
- package/dist/ai/providers/rtzr/error.js +25 -26
- package/dist/ai/providers/rtzr/index.js +5 -5
- package/dist/ai/providers/rtzr/model.d.ts +1 -1
- package/dist/ai/providers/rtzr/model.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/model.js +117 -133
- package/dist/ai/providers/rtzr/options.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/options.js +35 -41
- package/dist/ai/providers/rtzr/provider.d.ts +1 -1
- package/dist/ai/providers/rtzr/provider.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/provider.js +53 -51
- package/dist/ai/providers/rtzr/utils.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/utils.js +84 -84
- 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 +29 -19
- package/dist/api/caster.d.ts +1 -1
- package/dist/api/caster.d.ts.map +1 -1
- package/dist/api/caster.js +51 -61
- package/dist/api/code-converters.d.ts +4 -3
- package/dist/api/code-converters.d.ts.map +1 -1
- package/dist/api/code-converters.js +226 -249
- package/dist/api/config.d.ts +17 -17
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +37 -30
- package/dist/api/context.d.ts +10 -10
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +8 -2
- package/dist/api/decorators.d.ts +8 -8
- package/dist/api/decorators.d.ts.map +1 -1
- package/dist/api/decorators.js +245 -268
- package/dist/api/index.js +39 -7
- package/dist/api/secret.js +22 -15
- package/dist/api/sonamu.d.ts +15 -15
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +1012 -1131
- package/dist/api/validator.js +88 -79
- package/dist/auth/auth-generator.d.ts.map +1 -1
- package/dist/auth/auth-generator.js +203 -200
- package/dist/auth/better-auth-entities.d.ts +2 -2
- package/dist/auth/better-auth-entities.d.ts.map +1 -1
- package/dist/auth/better-auth-entities.js +369 -429
- package/dist/auth/index.js +21 -6
- package/dist/auth/knex-adapter.d.ts +2 -2
- package/dist/auth/knex-adapter.d.ts.map +1 -1
- package/dist/auth/knex-adapter.js +153 -157
- package/dist/auth/plugins/entity-definitions/admin.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/admin.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/admin.js +58 -56
- package/dist/auth/plugins/entity-definitions/anonymous.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/anonymous.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/anonymous.js +20 -20
- package/dist/auth/plugins/entity-definitions/api-key.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/api-key.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/api-key.js +185 -196
- package/dist/auth/plugins/entity-definitions/index.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/index.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/index.js +26 -29
- package/dist/auth/plugins/entity-definitions/jwt.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/jwt.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/jwt.js +62 -64
- package/dist/auth/plugins/entity-definitions/organization.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/organization.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/organization.js +362 -421
- package/dist/auth/plugins/entity-definitions/passkey.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/passkey.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/passkey.js +115 -126
- package/dist/auth/plugins/entity-definitions/phone-number.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/phone-number.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/phone-number.js +31 -40
- package/dist/auth/plugins/entity-definitions/sso.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/sso.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/sso.js +94 -107
- package/dist/auth/plugins/entity-definitions/two-factor.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/two-factor.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/two-factor.js +78 -92
- package/dist/auth/plugins/entity-definitions/types.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/types.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/types.js +1 -10
- package/dist/auth/plugins/entity-definitions/username.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/username.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/username.js +31 -40
- package/dist/auth/plugins/index.js +12 -3
- package/dist/auth/plugins/wrappers/admin.d.ts +2 -2
- package/dist/auth/plugins/wrappers/admin.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/admin.js +28 -29
- package/dist/auth/plugins/wrappers/anonymous.d.ts +2 -1
- package/dist/auth/plugins/wrappers/anonymous.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/anonymous.js +23 -22
- package/dist/auth/plugins/wrappers/api-key.d.ts +2 -1
- package/dist/auth/plugins/wrappers/api-key.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/api-key.js +39 -34
- package/dist/auth/plugins/wrappers/index.js +11 -11
- package/dist/auth/plugins/wrappers/jwt.d.ts +2 -1
- package/dist/auth/plugins/wrappers/jwt.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/jwt.js +31 -26
- package/dist/auth/plugins/wrappers/organization.d.ts +2 -1
- package/dist/auth/plugins/wrappers/organization.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/organization.js +65 -62
- package/dist/auth/plugins/wrappers/passkey.d.ts +2 -1
- package/dist/auth/plugins/wrappers/passkey.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/passkey.js +33 -28
- package/dist/auth/plugins/wrappers/phone-number.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/phone-number.js +26 -23
- package/dist/auth/plugins/wrappers/sso.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/sso.js +37 -31
- package/dist/auth/plugins/wrappers/two-factor.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/two-factor.js +31 -28
- package/dist/auth/plugins/wrappers/username.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/username.js +23 -23
- package/dist/bin/build-config.js +31 -31
- package/dist/bin/cli.js +1063 -1204
- package/dist/bin/fixture.d.ts.map +1 -1
- package/dist/bin/fixture.js +266 -259
- package/dist/bin/hmr-hook-register.d.ts.map +1 -1
- package/dist/bin/hmr-hook-register.js +19 -18
- package/dist/bin/test-command.d.ts.map +1 -1
- package/dist/bin/test-command.js +180 -177
- package/dist/bin/ts-loader-register.js +13 -6
- package/dist/bin/ts-loader-registration.d.ts.map +1 -1
- package/dist/bin/ts-loader-registration.js +28 -38
- package/dist/cache/cache-manager.d.ts +1 -1
- package/dist/cache/cache-manager.d.ts.map +1 -1
- package/dist/cache/cache-manager.js +20 -15
- package/dist/cache/decorator.d.ts +1 -1
- package/dist/cache/decorator.d.ts.map +1 -1
- package/dist/cache/decorator.js +84 -76
- package/dist/cache/drivers.js +21 -34
- package/dist/cache/index.js +10 -7
- package/dist/cache/types.d.ts +2 -2
- package/dist/cache/types.d.ts.map +1 -1
- package/dist/cache/types.js +1 -6
- package/dist/cache-control/cache-control.d.ts +2 -2
- package/dist/cache-control/cache-control.d.ts.map +1 -1
- package/dist/cache-control/cache-control.js +106 -122
- package/dist/cache-control/types.d.ts +2 -2
- package/dist/cache-control/types.d.ts.map +1 -1
- package/dist/cache-control/types.js +1 -19
- package/dist/compress/compress.d.ts +1 -1
- package/dist/compress/compress.d.ts.map +1 -1
- package/dist/compress/compress.js +58 -56
- package/dist/compress/index.js +7 -2
- package/dist/compress/types.js +1 -11
- package/dist/cone/cone-generator.d.ts +1 -1
- package/dist/cone/cone-generator.d.ts.map +1 -1
- package/dist/cone/cone-generator.js +216 -219
- package/dist/database/_batch_update.d.ts +1 -1
- package/dist/database/_batch_update.d.ts.map +1 -1
- package/dist/database/_batch_update.js +107 -102
- package/dist/database/base-model.d.ts +8 -9
- package/dist/database/base-model.d.ts.map +1 -1
- package/dist/database/base-model.js +371 -392
- package/dist/database/base-model.types.d.ts +5 -5
- package/dist/database/base-model.types.d.ts.map +1 -1
- package/dist/database/base-model.types.js +1 -20
- package/dist/database/db.d.ts +5 -2
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +185 -171
- package/dist/database/knex.d.ts +1 -1
- package/dist/database/knex.d.ts.map +1 -1
- package/dist/database/knex.js +48 -42
- package/dist/database/puri-subset.types.d.ts +6 -7
- package/dist/database/puri-subset.types.d.ts.map +1 -1
- package/dist/database/puri-subset.types.js +1 -16
- package/dist/database/puri-wrapper.d.ts +6 -6
- package/dist/database/puri-wrapper.d.ts.map +1 -1
- package/dist/database/puri-wrapper.js +99 -101
- package/dist/database/puri.d.ts +4 -5
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +1021 -1227
- package/dist/database/puri.types.d.ts +6 -6
- package/dist/database/puri.types.d.ts.map +1 -1
- package/dist/database/puri.types.js +15 -6
- package/dist/database/transaction-context.d.ts +2 -2
- package/dist/database/transaction-context.d.ts.map +1 -1
- package/dist/database/transaction-context.js +22 -13
- package/dist/database/upsert-builder.d.ts +3 -3
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +405 -465
- package/dist/dict/en.js +72 -74
- package/dist/dict/index.js +13 -13
- package/dist/dict/ko.js +72 -74
- package/dist/dict/rc-keys.js +150 -168
- package/dist/dict/sd.d.ts +3 -1
- package/dist/dict/sd.d.ts.map +1 -1
- package/dist/dict/sd.js +54 -40
- package/dist/dict/sonamu-dictionary.d.ts +1 -1
- package/dist/dict/sonamu-dictionary.d.ts.map +1 -1
- package/dist/dict/sonamu-dictionary.js +887 -955
- package/dist/dict/types.js +1 -7
- package/dist/dict/utils.js +26 -24
- package/dist/entity/entity-manager.d.ts +9 -9
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +226 -223
- package/dist/entity/entity-template-cone.d.ts +1 -1
- package/dist/entity/entity-template-cone.d.ts.map +1 -1
- package/dist/entity/entity-template-cone.js +152 -151
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +952 -1089
- 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 +32 -27
- 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 +61 -68
- package/dist/filter/index.js +9 -3
- package/dist/filter/types.js +92 -88
- package/dist/filter/utils.d.ts +1 -1
- package/dist/filter/utils.d.ts.map +1 -1
- package/dist/filter/utils.js +147 -161
- package/dist/index.js +87 -40
- package/dist/logger/category.d.ts.map +1 -1
- package/dist/logger/category.js +30 -29
- package/dist/logger/configure.d.ts.map +1 -1
- package/dist/logger/configure.js +83 -107
- package/dist/migration/code-generation.d.ts +2 -2
- package/dist/migration/code-generation.d.ts.map +1 -1
- package/dist/migration/code-generation.js +1385 -1578
- package/dist/migration/migration-set.d.ts +1 -1
- package/dist/migration/migration-set.d.ts.map +1 -1
- package/dist/migration/migration-set.js +177 -227
- package/dist/migration/migrator.d.ts +4 -3
- package/dist/migration/migrator.d.ts.map +1 -1
- package/dist/migration/migrator.js +340 -345
- package/dist/migration/postgresql-schema-reader.d.ts +2 -2
- package/dist/migration/postgresql-schema-reader.d.ts.map +1 -1
- package/dist/migration/postgresql-schema-reader.js +506 -564
- package/dist/migration/slack-confirm.d.ts +2 -2
- package/dist/migration/slack-confirm.d.ts.map +1 -1
- package/dist/migration/slack-confirm.js +205 -193
- package/dist/migration/types.d.ts +2 -2
- package/dist/migration/types.d.ts.map +1 -1
- package/dist/migration/types.js +1 -3
- package/dist/naite/messaging-types.d.ts +1 -0
- package/dist/naite/messaging-types.d.ts.map +1 -1
- package/dist/naite/messaging-types.js +1 -7
- package/dist/naite/naite-reporter.d.ts +2 -2
- package/dist/naite/naite-reporter.d.ts.map +1 -1
- package/dist/naite/naite-reporter.js +127 -120
- package/dist/naite/naite.d.ts +3 -2
- package/dist/naite/naite.d.ts.map +1 -1
- package/dist/naite/naite.js +266 -300
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +13 -3
- package/dist/ssr/registry.d.ts +1 -1
- package/dist/ssr/registry.d.ts.map +1 -1
- package/dist/ssr/registry.js +45 -37
- package/dist/ssr/renderer.d.ts +4 -4
- package/dist/ssr/renderer.d.ts.map +1 -1
- package/dist/ssr/renderer.js +84 -91
- package/dist/ssr/types.d.ts +2 -2
- package/dist/ssr/types.d.ts.map +1 -1
- package/dist/ssr/types.js +1 -3
- package/dist/storage/base-file.js +54 -41
- package/dist/storage/buffered-file.d.ts +2 -2
- package/dist/storage/buffered-file.d.ts.map +1 -1
- package/dist/storage/buffered-file.js +51 -44
- package/dist/storage/drivers.d.ts +2 -2
- package/dist/storage/drivers.d.ts.map +1 -1
- package/dist/storage/drivers.js +12 -7
- package/dist/storage/index.js +14 -7
- package/dist/storage/s3-driver.d.ts +2 -2
- package/dist/storage/s3-driver.d.ts.map +1 -1
- package/dist/storage/s3-driver.js +52 -48
- package/dist/storage/storage-manager.d.ts +2 -2
- package/dist/storage/storage-manager.d.ts.map +1 -1
- package/dist/storage/storage-manager.js +33 -25
- package/dist/storage/types.d.ts +2 -2
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/types.js +1 -5
- package/dist/storage/uploaded-file.d.ts +1 -1
- package/dist/storage/uploaded-file.d.ts.map +1 -1
- package/dist/storage/uploaded-file.js +45 -35
- package/dist/stream/index.js +7 -2
- package/dist/stream/sse.d.ts +2 -2
- package/dist/stream/sse.d.ts.map +1 -1
- package/dist/stream/sse.js +72 -67
- package/dist/syncer/api-parser.d.ts +1 -1
- package/dist/syncer/api-parser.d.ts.map +1 -1
- package/dist/syncer/api-parser.js +224 -245
- package/dist/syncer/checksum.d.ts +1 -1
- package/dist/syncer/checksum.d.ts.map +1 -1
- package/dist/syncer/checksum.js +86 -72
- package/dist/syncer/code-generator.d.ts +2 -2
- package/dist/syncer/code-generator.d.ts.map +1 -1
- package/dist/syncer/code-generator.js +154 -160
- package/dist/syncer/entity-operations.d.ts +1 -1
- package/dist/syncer/entity-operations.d.ts.map +1 -1
- package/dist/syncer/entity-operations.js +63 -54
- 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 +38 -38
- package/dist/syncer/index.js +19 -8
- package/dist/syncer/module-loader.d.ts +5 -5
- package/dist/syncer/module-loader.d.ts.map +1 -1
- package/dist/syncer/module-loader.js +83 -78
- package/dist/syncer/syncer-actions.d.ts +2 -2
- package/dist/syncer/syncer-actions.d.ts.map +1 -1
- package/dist/syncer/syncer-actions.js +76 -91
- package/dist/syncer/syncer.d.ts +7 -6
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +426 -492
- package/dist/tasks/decorator.d.ts +3 -3
- package/dist/tasks/decorator.d.ts.map +1 -1
- package/dist/tasks/decorator.js +32 -28
- package/dist/tasks/step-wrapper.d.ts +1 -1
- package/dist/tasks/step-wrapper.d.ts.map +1 -1
- package/dist/tasks/step-wrapper.js +42 -41
- package/dist/tasks/workflow-manager.d.ts +2 -2
- package/dist/tasks/workflow-manager.d.ts.map +1 -1
- package/dist/tasks/workflow-manager.js +192 -221
- 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 +103 -103
- package/dist/template/helpers.d.ts.map +1 -1
- package/dist/template/helpers.js +163 -163
- package/dist/template/implementations/entity.template.d.ts +1 -1
- package/dist/template/implementations/entity.template.d.ts.map +1 -1
- package/dist/template/implementations/entity.template.js +76 -85
- package/dist/template/implementations/entry-server.template.d.ts +1 -1
- package/dist/template/implementations/entry-server.template.d.ts.map +1 -1
- package/dist/template/implementations/entry-server.template.js +32 -27
- package/dist/template/implementations/generated.template.d.ts +1 -1
- package/dist/template/implementations/generated.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.js +254 -275
- package/dist/template/implementations/generated_http.template.d.ts +2 -2
- package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_http.template.js +114 -133
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_sso.template.js +249 -275
- package/dist/template/implementations/init_types.template.d.ts +1 -1
- package/dist/template/implementations/init_types.template.d.ts.map +1 -1
- package/dist/template/implementations/init_types.template.js +40 -34
- package/dist/template/implementations/model.template.d.ts +1 -1
- package/dist/template/implementations/model.template.d.ts.map +1 -1
- package/dist/template/implementations/model.template.js +56 -53
- package/dist/template/implementations/model_test.template.d.ts +1 -1
- package/dist/template/implementations/model_test.template.d.ts.map +1 -1
- package/dist/template/implementations/model_test.template.js +32 -24
- package/dist/template/implementations/queries.template.d.ts +1 -1
- package/dist/template/implementations/queries.template.d.ts.map +1 -1
- package/dist/template/implementations/queries.template.js +84 -89
- package/dist/template/implementations/sd.template.d.ts +1 -1
- package/dist/template/implementations/sd.template.d.ts.map +1 -1
- package/dist/template/implementations/sd.template.js +137 -144
- package/dist/template/implementations/services.template.d.ts +1 -1
- package/dist/template/implementations/services.template.d.ts.map +1 -1
- package/dist/template/implementations/services.template.js +164 -189
- package/dist/template/implementations/view_form.template.d.ts +1 -1
- package/dist/template/implementations/view_form.template.d.ts.map +1 -1
- package/dist/template/implementations/view_form.template.js +258 -285
- package/dist/template/implementations/view_id_all_select.template.d.ts +1 -1
- package/dist/template/implementations/view_id_all_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_id_all_select.template.js +31 -25
- package/dist/template/implementations/view_list.template.d.ts +1 -1
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +304 -355
- package/dist/template/implementations/view_search_input.template.d.ts +1 -1
- package/dist/template/implementations/view_search_input.template.d.ts.map +1 -1
- package/dist/template/implementations/view_search_input.template.js +31 -27
- package/dist/template/index.js +21 -7
- package/dist/template/template-manager.d.ts +1 -1
- package/dist/template/template-manager.d.ts.map +1 -1
- package/dist/template/template-manager.js +132 -123
- package/dist/template/template-types.js +8 -6
- package/dist/template/template.d.ts +2 -2
- package/dist/template/template.d.ts.map +1 -1
- package/dist/template/template.js +73 -68
- package/dist/template/zod-converter.d.ts.map +1 -1
- package/dist/template/zod-converter.js +603 -657
- 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 +93 -88
- package/dist/testing/bootstrap.d.ts +22 -13
- package/dist/testing/bootstrap.d.ts.map +1 -1
- package/dist/testing/bootstrap.js +114 -114
- package/dist/testing/data-explorer.d.ts +3 -3
- package/dist/testing/data-explorer.d.ts.map +1 -1
- package/dist/testing/data-explorer.js +237 -265
- package/dist/testing/dev-test-routes.d.ts +2 -2
- package/dist/testing/dev-test-routes.d.ts.map +1 -1
- package/dist/testing/dev-test-routes.js +258 -249
- package/dist/testing/dev-vitest-manager.d.ts +1 -1
- package/dist/testing/dev-vitest-manager.d.ts.map +1 -1
- package/dist/testing/dev-vitest-manager.js +514 -539
- package/dist/testing/faker-mappings.js +422 -420
- package/dist/testing/fixture-generator.d.ts +3 -3
- package/dist/testing/fixture-generator.d.ts.map +1 -1
- package/dist/testing/fixture-generator.js +1216 -1346
- package/dist/testing/fixture-loader.js +26 -25
- package/dist/testing/fixture-manager.d.ts +3 -3
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +706 -776
- package/dist/testing/global-setup.js +53 -49
- package/dist/testing/index.js +19 -11
- package/dist/testing/naite-vitest-reporter.js +18 -13
- package/dist/testing/parallel-db-manager.d.ts +1 -1
- package/dist/testing/parallel-db-manager.d.ts.map +1 -1
- package/dist/testing/parallel-db-manager.js +63 -78
- package/dist/testing/vitest-helpers.d.ts +1 -1
- package/dist/testing/vitest-helpers.d.ts.map +1 -1
- package/dist/testing/vitest-helpers.js +37 -33
- package/dist/types/types.d.ts +28 -28
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +764 -890
- package/dist/ui/ai-api.d.ts +1 -1
- package/dist/ui/ai-api.d.ts.map +1 -1
- package/dist/ui/ai-api.js +52 -42
- package/dist/ui/ai-client.d.ts +1 -2
- package/dist/ui/ai-client.d.ts.map +1 -1
- package/dist/ui/ai-client.js +353 -388
- package/dist/ui/api.d.ts +1 -1
- package/dist/ui/api.d.ts.map +1 -1
- package/dist/ui/api.js +903 -1145
- package/dist/ui/cdd-service.d.ts +1 -1
- package/dist/ui/cdd-service.d.ts.map +1 -1
- package/dist/ui/cdd-service.js +406 -407
- package/dist/ui/cdd-types.js +1 -3
- package/dist/ui-web/assets/index-C-Zz-wYg.css +1 -0
- package/dist/ui-web/assets/index-DejDON8K.js +238 -0
- package/dist/ui-web/index.html +3 -3
- package/dist/utils/async-utils.js +57 -45
- package/dist/utils/console-util.d.ts.map +1 -1
- package/dist/utils/console-util.js +104 -87
- package/dist/utils/controller.js +26 -19
- package/dist/utils/esm-utils.js +49 -38
- package/dist/utils/formatter.d.ts +1 -2
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +89 -115
- package/dist/utils/fs-utils.d.ts.map +1 -1
- package/dist/utils/fs-utils.js +68 -65
- package/dist/utils/lodash-able.js +11 -4
- package/dist/utils/model.d.ts +1 -1
- package/dist/utils/model.d.ts.map +1 -1
- package/dist/utils/model.js +21 -19
- package/dist/utils/object-utils.js +148 -186
- package/dist/utils/path-utils.js +67 -57
- package/dist/utils/process-utils.d.ts.map +1 -1
- package/dist/utils/process-utils.js +37 -31
- package/dist/utils/sql-parser.d.ts +1 -1
- package/dist/utils/sql-parser.d.ts.map +1 -1
- package/dist/utils/sql-parser.js +40 -40
- package/dist/utils/type-utils.js +44 -43
- package/dist/utils/utils.d.ts +2 -3
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +81 -93
- 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 +24 -17
- package/dist/vector/chunking.d.ts +1 -1
- package/dist/vector/chunking.d.ts.map +1 -1
- package/dist/vector/chunking.js +100 -94
- package/dist/vector/config.d.ts +1 -1
- package/dist/vector/config.d.ts.map +1 -1
- package/dist/vector/config.js +76 -78
- package/dist/vector/embedding.d.ts +1 -1
- package/dist/vector/embedding.d.ts.map +1 -1
- package/dist/vector/embedding.js +128 -125
- package/dist/vector/index.js +5 -5
- package/dist/vector/types.js +1 -5
- package/package.json +31 -36
- package/src/ai/agents/agent.ts +12 -5
- package/src/ai/agents/types.ts +5 -5
- package/src/ai/providers/rtzr/model.ts +8 -10
- package/src/ai/providers/rtzr/options.ts +2 -1
- package/src/ai/providers/rtzr/provider.ts +5 -3
- package/src/ai/providers/rtzr/utils.ts +2 -7
- package/src/api/__tests__/config.test.ts +15 -8
- package/src/api/base-frame.ts +5 -3
- package/src/api/caster.ts +7 -6
- package/src/api/code-converters.ts +23 -26
- package/src/api/config.ts +23 -17
- package/src/api/context.ts +18 -11
- package/src/api/decorators.ts +17 -18
- package/src/api/sonamu.ts +44 -49
- package/src/auth/auth-generator.ts +4 -6
- package/src/auth/better-auth-entities.ts +3 -2
- package/src/auth/knex-adapter.ts +6 -5
- package/src/auth/plugins/entity-definitions/admin.ts +1 -1
- package/src/auth/plugins/entity-definitions/anonymous.ts +1 -1
- package/src/auth/plugins/entity-definitions/api-key.ts +1 -1
- package/src/auth/plugins/entity-definitions/index.ts +1 -1
- package/src/auth/plugins/entity-definitions/jwt.ts +1 -1
- package/src/auth/plugins/entity-definitions/organization.ts +1 -1
- package/src/auth/plugins/entity-definitions/passkey.ts +1 -1
- package/src/auth/plugins/entity-definitions/phone-number.ts +1 -1
- package/src/auth/plugins/entity-definitions/sso.ts +1 -1
- package/src/auth/plugins/entity-definitions/two-factor.ts +1 -1
- package/src/auth/plugins/entity-definitions/types.ts +1 -1
- package/src/auth/plugins/entity-definitions/username.ts +1 -1
- package/src/auth/plugins/wrappers/admin.ts +3 -1
- package/src/auth/plugins/wrappers/anonymous.ts +3 -1
- package/src/auth/plugins/wrappers/api-key.ts +3 -1
- package/src/auth/plugins/wrappers/jwt.ts +3 -1
- package/src/auth/plugins/wrappers/organization.ts +3 -1
- package/src/auth/plugins/wrappers/passkey.ts +3 -1
- package/src/auth/plugins/wrappers/phone-number.ts +3 -1
- package/src/auth/plugins/wrappers/sso.ts +2 -1
- package/src/auth/plugins/wrappers/two-factor.ts +3 -1
- package/src/auth/plugins/wrappers/username.ts +3 -1
- package/src/bin/__tests__/ts-loader-register.test.ts +7 -12
- package/src/bin/build-config.ts +3 -3
- package/src/bin/cli.ts +27 -25
- package/src/bin/fixture.ts +4 -2
- package/src/bin/hmr-hook-register.ts +1 -0
- package/src/bin/test-command.ts +4 -2
- package/src/bin/ts-loader-registration.ts +6 -22
- package/src/cache/cache-manager.ts +2 -1
- package/src/cache/decorator.ts +2 -2
- package/src/cache/types.ts +3 -3
- package/src/cache-control/cache-control.ts +3 -2
- package/src/cache-control/types.ts +2 -2
- package/src/compress/compress.ts +1 -1
- package/src/cone/cone-generator.ts +5 -3
- package/src/database/_batch_update.ts +1 -1
- package/src/database/base-model.ts +20 -14
- package/src/database/base-model.types.ts +12 -11
- package/src/database/db.ts +56 -21
- package/src/database/knex.ts +2 -2
- package/src/database/puri-subset.test-d.ts +33 -32
- package/src/database/puri-subset.types.ts +6 -7
- package/src/database/puri-wrapper.ts +29 -26
- package/src/database/puri.ts +36 -34
- package/src/database/puri.types.test-d.ts +6 -5
- package/src/database/puri.types.ts +9 -12
- package/src/database/transaction-context.ts +2 -2
- package/src/database/upsert-builder.ts +17 -10
- package/src/dict/sd.ts +17 -4
- package/src/dict/sonamu-dictionary.ts +23 -17
- package/src/entity/entity-manager.ts +9 -7
- package/src/entity/entity-template-cone.ts +10 -3
- package/src/entity/entity.ts +20 -16
- package/src/exceptions/error-handler.ts +2 -1
- package/src/exceptions/so-exceptions.ts +1 -1
- package/src/filter/utils.ts +3 -2
- package/src/logger/category.ts +1 -0
- package/src/logger/configure.ts +5 -5
- package/src/migration/__tests__/code-generation.search-text.test.ts +2 -3
- package/src/migration/code-generation.ts +26 -25
- package/src/migration/migration-set.ts +16 -18
- package/src/migration/migrator.ts +38 -33
- package/src/migration/postgresql-schema-reader.ts +12 -12
- package/src/migration/slack-confirm.ts +5 -4
- package/src/migration/types.ts +2 -2
- package/src/naite/messaging-types.ts +1 -1
- package/src/naite/naite-reporter.ts +5 -3
- package/src/naite/naite.ts +12 -7
- package/src/shared/app.shared.ts.txt +2 -2
- package/src/shared/web.shared.ts.txt +2 -2
- package/src/skills/AGENTS.md +19 -18
- package/src/skills/commands/sonamu-skills.md +9 -9
- package/src/skills/sonamu/SKILL.md +111 -104
- package/src/skills/sonamu/ai-agents.md +27 -26
- package/src/skills/sonamu/api.md +81 -69
- package/src/skills/sonamu/auth-migration.md +13 -27
- package/src/skills/sonamu/auth-plugins.md +41 -31
- package/src/skills/sonamu/auth.md +30 -24
- package/src/skills/sonamu/cdd.md +26 -17
- package/src/skills/sonamu/cone.md +50 -50
- package/src/skills/sonamu/config.md +74 -51
- package/src/skills/sonamu/create-sonamu.md +31 -19
- package/src/skills/sonamu/database.md +43 -26
- package/src/skills/sonamu/entity-basic.md +61 -61
- package/src/skills/sonamu/entity-relations.md +84 -80
- package/src/skills/sonamu/entity-validation-checklist.md +19 -15
- package/src/skills/sonamu/fixture-cli.md +52 -30
- package/src/skills/sonamu/framework-change.md +9 -7
- package/src/skills/sonamu/frontend.md +64 -82
- package/src/skills/sonamu/i18n.md +45 -37
- package/src/skills/sonamu/migration.md +54 -31
- package/src/skills/sonamu/model.md +98 -66
- package/src/skills/sonamu/naite.md +34 -32
- package/src/skills/sonamu/project-init.md +28 -8
- package/src/skills/sonamu/puri.md +82 -91
- package/src/skills/sonamu/scaffolding.md +44 -32
- package/src/skills/sonamu/skill-contribution.md +50 -45
- package/src/skills/sonamu/subset.md +13 -13
- package/src/skills/sonamu/tasks.md +73 -58
- package/src/skills/sonamu/testing-devrunner.md +56 -36
- package/src/skills/sonamu/testing.md +23 -58
- package/src/skills/sonamu/upsert.md +32 -31
- package/src/skills/sonamu/vector.md +37 -36
- package/src/ssr/index.ts +2 -12
- package/src/ssr/registry.ts +1 -1
- package/src/ssr/renderer.ts +7 -5
- package/src/ssr/types.ts +2 -2
- package/src/storage/buffered-file.ts +4 -2
- package/src/storage/drivers.ts +3 -2
- package/src/storage/s3-driver.ts +7 -4
- package/src/storage/storage-manager.ts +3 -2
- package/src/storage/types.ts +3 -2
- package/src/storage/uploaded-file.ts +1 -1
- package/src/stream/sse.ts +2 -2
- package/src/syncer/api-parser.ts +8 -5
- package/src/syncer/checksum.ts +9 -5
- package/src/syncer/code-generator.ts +16 -8
- package/src/syncer/entity-operations.ts +5 -3
- package/src/syncer/file-patterns.ts +2 -1
- package/src/syncer/module-loader.ts +9 -6
- package/src/syncer/syncer-actions.ts +5 -3
- package/src/syncer/syncer.ts +18 -24
- package/src/tasks/decorator.ts +10 -8
- package/src/tasks/step-wrapper.ts +1 -1
- package/src/tasks/workflow-manager.ts +18 -15
- package/src/template/__tests__/generated.template.search-text.test.ts +1 -0
- package/src/template/entity-converter.ts +4 -2
- package/src/template/generated.template.test-d.ts +2 -1
- package/src/template/helpers.ts +5 -2
- package/src/template/implementations/entity.template.ts +9 -8
- package/src/template/implementations/entry-server.template.ts +1 -1
- package/src/template/implementations/generated.template.ts +21 -29
- package/src/template/implementations/generated_http.template.ts +9 -6
- package/src/template/implementations/generated_sso.template.ts +6 -4
- package/src/template/implementations/init_types.template.ts +3 -2
- package/src/template/implementations/model.template.ts +4 -2
- package/src/template/implementations/model_test.template.ts +3 -2
- package/src/template/implementations/queries.template.ts +6 -14
- package/src/template/implementations/sd.template.ts +4 -2
- package/src/template/implementations/services.template.ts +7 -11
- package/src/template/implementations/view_form.template.ts +5 -3
- package/src/template/implementations/view_id_all_select.template.ts +3 -2
- package/src/template/implementations/view_list.template.ts +7 -5
- package/src/template/implementations/view_search_input.template.ts +3 -2
- package/src/template/template-manager.ts +4 -3
- package/src/template/template.ts +4 -3
- package/src/template/zod-converter.ts +10 -7
- package/src/testing/__tests__/dev-test-routes.test.ts +3 -2
- package/src/testing/__tests__/dev-vitest-manager.test.ts +1 -0
- package/src/testing/_relation-graph.ts +2 -2
- package/src/testing/bootstrap.ts +55 -27
- package/src/testing/data-explorer.ts +5 -4
- package/src/testing/dev-test-routes.ts +8 -5
- package/src/testing/dev-vitest-manager.ts +13 -12
- package/src/testing/fixture-generator.ts +11 -17
- package/src/testing/fixture-manager.ts +21 -17
- package/src/testing/parallel-db-manager.ts +2 -1
- package/src/testing/vitest-helpers.ts +2 -1
- package/src/types/__tests__/entity-json-schema-search-text.test.ts +1 -0
- package/src/types/types.ts +8 -8
- package/src/typings/knex.d.ts +4 -4
- package/src/ui/ai-api.ts +5 -3
- package/src/ui/ai-client.ts +6 -5
- package/src/ui/api.ts +25 -23
- package/src/ui/cdd-service.ts +12 -11
- package/src/utils/console-util.ts +3 -1
- package/src/utils/formatter.ts +94 -102
- package/src/utils/fs-utils.ts +2 -1
- package/src/utils/model.ts +2 -2
- package/src/utils/object-utils.ts +3 -3
- package/src/utils/process-utils.ts +2 -1
- package/src/utils/sql-parser.ts +10 -1
- package/src/utils/type-utils.ts +3 -3
- package/src/utils/utils.ts +9 -7
- package/src/utils/zod-error.ts +1 -1
- package/src/vector/chunking.ts +1 -1
- package/src/vector/config.ts +1 -1
- package/src/vector/embedding.ts +11 -9
- package/tsdown.api.config.ts +50 -0
- package/.swcrc.project-default +0 -18
- package/dist/api/__tests__/config.test.js +0 -189
- package/dist/bin/__tests__/test-command.test.js +0 -112
- package/dist/bin/__tests__/ts-loader-register.test.js +0 -45
- package/dist/database/puri-subset.test-d.js +0 -89
- package/dist/database/puri.types.test-d.js +0 -129
- package/dist/migration/__tests__/code-generation.search-text.test.js +0 -435
- package/dist/template/__tests__/generated.template.search-text.test.js +0 -99
- package/dist/template/generated.template.test-d.js +0 -24
- package/dist/testing/__tests__/dev-test-routes.test.js +0 -144
- package/dist/testing/__tests__/dev-vitest-manager.test.js +0 -152
- package/dist/types/__tests__/entity-json-schema-search-text.test.js +0 -256
- package/dist/typings/knex.d.js +0 -3
- package/dist/ui-web/assets/index-CKo0Z2Iu.css +0 -1
- package/dist/ui-web/assets/index-DK-2aacv.js +0 -257
|
@@ -6,6 +6,7 @@ description: Reference for defining Sonamu Entity relationships. BelongsToOne, H
|
|
|
6
6
|
# Entity Relationship Definitions
|
|
7
7
|
|
|
8
8
|
**Reference for working code:**
|
|
9
|
+
|
|
9
10
|
- `sonamu/examples/miomock/api/src/application/project/` - full ManyToMany relationship example
|
|
10
11
|
- `sonamu/examples/miomock/api/src/application/employee/` - BelongsToOne relationship example
|
|
11
12
|
- `sonamu/examples/miomock/api/src/application/company/` - HasMany relationship example
|
|
@@ -14,13 +15,14 @@ description: Reference for defining Sonamu Entity relationships. BelongsToOne, H
|
|
|
14
15
|
|
|
15
16
|
### 1:N vs N:M Decision Criteria
|
|
16
17
|
|
|
17
|
-
| Question
|
|
18
|
-
|
|
19
|
-
| Can one A belong to multiple Bs?
|
|
20
|
-
| Does the relationship need additional information? | No
|
|
21
|
-
| Can it be expressed as "A belongs to B"?
|
|
18
|
+
| Question | 1:N (BelongsToOne) | N:M (ManyToMany or intermediate entity) |
|
|
19
|
+
| -------------------------------------------------- | ------------------ | --------------------------------------- |
|
|
20
|
+
| Can one A belong to multiple Bs? | No | Yes |
|
|
21
|
+
| Does the relationship need additional information? | No | Yes → intermediate entity |
|
|
22
|
+
| Can it be expressed as "A belongs to B"? | Yes | No |
|
|
22
23
|
|
|
23
24
|
**Examples:**
|
|
25
|
+
|
|
24
26
|
- Post → Author: 1:N (a post has one author)
|
|
25
27
|
- Post ↔ Tag: N:M (multiple posts have multiple tags)
|
|
26
28
|
- Researcher ↔ Task: N:M + intermediate entity (participation rate, role, and other additional info)
|
|
@@ -29,15 +31,16 @@ description: Reference for defining Sonamu Entity relationships. BelongsToOne, H
|
|
|
29
31
|
|
|
30
32
|
If an N:M relationship has **additional information**, use an **intermediate entity** instead of ManyToMany.
|
|
31
33
|
|
|
32
|
-
| Situation
|
|
33
|
-
|
|
34
|
-
| Only a simple connection is needed
|
|
35
|
-
| Relationship needs a date/period
|
|
36
|
-
| Relationship needs a role/status
|
|
37
|
-
| Relationship needs a quantity/ratio
|
|
38
|
-
| Relationship history management needed |
|
|
34
|
+
| Situation | ManyToMany | Intermediate entity |
|
|
35
|
+
| -------------------------------------- | ---------- | ------------------- |
|
|
36
|
+
| Only a simple connection is needed | ✓ | |
|
|
37
|
+
| Relationship needs a date/period | | ✓ |
|
|
38
|
+
| Relationship needs a role/status | | ✓ |
|
|
39
|
+
| Relationship needs a quantity/ratio | | ✓ |
|
|
40
|
+
| Relationship history management needed | | ✓ |
|
|
39
41
|
|
|
40
42
|
**Intermediate entity example:**
|
|
43
|
+
|
|
41
44
|
```
|
|
42
45
|
Researcher ↔ Task
|
|
43
46
|
└─ ProjectResearcher (intermediate entity)
|
|
@@ -179,12 +182,12 @@ Task
|
|
|
179
182
|
|
|
180
183
|
## Which Relationship to Use?
|
|
181
184
|
|
|
182
|
-
| Situation
|
|
183
|
-
|
|
184
|
-
| "A belongs to B" (N:1)
|
|
185
|
-
| "A has many Bs" (1:N)
|
|
186
|
-
| "A and B are 1:1"
|
|
187
|
-
| "A and B are many-to-many" | `ManyToMany`
|
|
185
|
+
| Situation | Relationship type | Example |
|
|
186
|
+
| -------------------------- | ----------------- | -------------------- |
|
|
187
|
+
| "A belongs to B" (N:1) | `BelongsToOne` | Post → User (author) |
|
|
188
|
+
| "A has many Bs" (1:N) | `HasMany` | User → Posts |
|
|
189
|
+
| "A and B are 1:1" | `OneToOne` | User ↔ Employee |
|
|
190
|
+
| "A and B are many-to-many" | `ManyToMany` | Post ↔ Tag |
|
|
188
191
|
|
|
189
192
|
## BelongsToOne (N:1) - Most Common
|
|
190
193
|
|
|
@@ -208,6 +211,7 @@ Task
|
|
|
208
211
|
**Note**: Do not define `author_id` directly in props (it is auto-generated)
|
|
209
212
|
|
|
210
213
|
**Optional options:**
|
|
214
|
+
|
|
211
215
|
- `customJoinClause`: custom JOIN condition SQL (specify JOIN condition directly instead of FK)
|
|
212
216
|
- `useConstraint`: whether to create FK constraint (default: `true`). If `false`, the FK column is created but no DB constraint is generated
|
|
213
217
|
|
|
@@ -216,6 +220,7 @@ Task
|
|
|
216
220
|
Since a BelongsToOne relationship automatically creates a `{name}_id` column, use the correct field name when working with it directly in Model, FixtureGenerator, etc.
|
|
217
221
|
|
|
218
222
|
**Correct pattern:**
|
|
223
|
+
|
|
219
224
|
```typescript
|
|
220
225
|
// Entity definition
|
|
221
226
|
{
|
|
@@ -235,25 +240,26 @@ await puri.ubRegister("departments", department);
|
|
|
235
240
|
```
|
|
236
241
|
|
|
237
242
|
**Wrong pattern (common mistake):**
|
|
243
|
+
|
|
238
244
|
```typescript
|
|
239
245
|
// ✗ WRONG: using relation name directly
|
|
240
246
|
const department = {
|
|
241
247
|
name: "Engineering",
|
|
242
|
-
company: 1
|
|
248
|
+
company: 1, // FK is not set! company_id is saved as NULL
|
|
243
249
|
};
|
|
244
250
|
|
|
245
251
|
// ✗ WRONG: passing as object
|
|
246
252
|
const department = {
|
|
247
253
|
name: "Engineering",
|
|
248
|
-
company: { id: 1 }
|
|
254
|
+
company: { id: 1 }, // FK is not set!
|
|
249
255
|
};
|
|
250
256
|
```
|
|
251
257
|
|
|
252
258
|
**FixtureGenerator example:**
|
|
259
|
+
|
|
253
260
|
```typescript
|
|
254
261
|
// inside fixture-generator.ts
|
|
255
|
-
if (isBelongsToOneRelationProp(prop) ||
|
|
256
|
-
(isOneToOneRelationProp(prop) && prop.hasJoinColumn)) {
|
|
262
|
+
if (isBelongsToOneRelationProp(prop) || (isOneToOneRelationProp(prop) && prop.hasJoinColumn)) {
|
|
257
263
|
const relationValue = await this.generateRelationValue(entity, prop, context);
|
|
258
264
|
|
|
259
265
|
// ✓ CORRECT: set FK as {prop.name}_id
|
|
@@ -264,6 +270,7 @@ if (isBelongsToOneRelationProp(prop) ||
|
|
|
264
270
|
```
|
|
265
271
|
|
|
266
272
|
**Key points:**
|
|
273
|
+
|
|
267
274
|
- Entity JSON: `"name": "company"` (relation name)
|
|
268
275
|
- DB column: `company_id` (auto-generated)
|
|
269
276
|
- TypeScript code: use `company_id` (setting FK)
|
|
@@ -293,12 +300,14 @@ if (isBelongsToOneRelationProp(prop) ||
|
|
|
293
300
|
**No DB column is created** (virtual)
|
|
294
301
|
|
|
295
302
|
**When is it needed?**
|
|
303
|
+
|
|
296
304
|
- When reverse lookup like `user.posts.title` is needed in a Subset
|
|
297
305
|
- Can be omitted if not needed
|
|
298
306
|
|
|
299
307
|
### HasMany Performance Optimization
|
|
300
308
|
|
|
301
309
|
HasMany relationships are automatically optimized using the **DataLoader pattern**:
|
|
310
|
+
|
|
302
311
|
- Parent record IDs are collected in batches
|
|
303
312
|
- All child records are queried in a single `whereIn` query
|
|
304
313
|
- **No N+1 query problem**
|
|
@@ -312,6 +321,7 @@ This optimization is applied automatically and requires no additional configurat
|
|
|
312
321
|
**Situation**: When User and Employee are 1:1
|
|
313
322
|
|
|
314
323
|
**The side holding the FK** (Employee):
|
|
324
|
+
|
|
315
325
|
```json
|
|
316
326
|
{
|
|
317
327
|
"type": "relation",
|
|
@@ -326,6 +336,7 @@ This optimization is applied automatically and requires no additional configurat
|
|
|
326
336
|
```
|
|
327
337
|
|
|
328
338
|
**The side without the FK** (User):
|
|
339
|
+
|
|
329
340
|
```json
|
|
330
341
|
{
|
|
331
342
|
"type": "relation",
|
|
@@ -340,6 +351,7 @@ This optimization is applied automatically and requires no additional configurat
|
|
|
340
351
|
**Key point**: FK is only created on the side with `hasJoinColumn: true` (omitting it means no FK; it is an optional option)
|
|
341
352
|
|
|
342
353
|
**Optional options (when `hasJoinColumn: true`):**
|
|
354
|
+
|
|
343
355
|
- `customJoinClause`: custom JOIN condition SQL
|
|
344
356
|
- `useConstraint`: whether to create FK constraint (default: `true`)
|
|
345
357
|
|
|
@@ -365,12 +377,14 @@ This optimization is applied automatically and requires no additional configurat
|
|
|
365
377
|
### ManyToMany Naming Conventions
|
|
366
378
|
|
|
367
379
|
**joinTable (join table name)**: use **double** underscore
|
|
380
|
+
|
|
368
381
|
```
|
|
369
382
|
User ↔ Role → user__roles
|
|
370
383
|
Post ↔ Tag → posts__tags (alphabetical order recommended)
|
|
371
384
|
```
|
|
372
385
|
|
|
373
386
|
**joinColumn (join table column name)**: use **single** underscore
|
|
387
|
+
|
|
374
388
|
```
|
|
375
389
|
user__roles table:
|
|
376
390
|
- user_id (single underscore)
|
|
@@ -378,6 +392,7 @@ user__roles table:
|
|
|
378
392
|
```
|
|
379
393
|
|
|
380
394
|
**Example**:
|
|
395
|
+
|
|
381
396
|
```typescript
|
|
382
397
|
// Entity: User
|
|
383
398
|
{
|
|
@@ -427,18 +442,18 @@ Error: '{child_table}.{parent_fk}' is not assignable to type 'AvailableColumns'
|
|
|
427
442
|
|
|
428
443
|
### Solution: Choose One of the Two
|
|
429
444
|
|
|
430
|
-
| Requirement
|
|
431
|
-
|
|
432
|
-
| Query child list together in parent detail view | Independent entity | ✗ not used | ✓ possible
|
|
433
|
-
| Child is CRUD'd only through parent
|
|
445
|
+
| Requirement | Choice | parentId | HasMany in parent subset |
|
|
446
|
+
| ----------------------------------------------- | ------------------ | ---------- | ------------------------ |
|
|
447
|
+
| Query child list together in parent detail view | Independent entity | ✗ not used | ✓ possible |
|
|
448
|
+
| Child is CRUD'd only through parent | Use parentId | ✓ used | ✗ not possible |
|
|
434
449
|
|
|
435
450
|
### Decision Criteria
|
|
436
451
|
|
|
437
|
-
| Question
|
|
438
|
-
|
|
439
|
-
| Will the child ever be queried/modified standalone?
|
|
440
|
-
| Does the admin screen need a separate child list page?
|
|
441
|
-
| Is the child list queried as a subset in the parent detail? | ✓
|
|
452
|
+
| Question | Yes → Independent entity | No → parentId |
|
|
453
|
+
| ----------------------------------------------------------- | ------------------------ | ------------- |
|
|
454
|
+
| Will the child ever be queried/modified standalone? | ✓ | |
|
|
455
|
+
| Does the admin screen need a separate child list page? | ✓ | |
|
|
456
|
+
| Is the child list queried as a subset in the parent detail? | ✓ | |
|
|
442
457
|
|
|
443
458
|
### Example
|
|
444
459
|
|
|
@@ -464,23 +479,21 @@ When a BelongsToOne relationship is defined, a `{name}_id` column is automatical
|
|
|
464
479
|
|
|
465
480
|
### Where It Applies
|
|
466
481
|
|
|
467
|
-
| Location | Format
|
|
468
|
-
|
|
469
|
-
| subsets
|
|
470
|
-
| indexes
|
|
471
|
-
| unique
|
|
472
|
-
| search
|
|
482
|
+
| Location | Format | Example |
|
|
483
|
+
| -------- | ---------------------------- | --------------------- |
|
|
484
|
+
| subsets | FieldExpr (`relation.field`) | `"user.id"` |
|
|
485
|
+
| indexes | actual DB column name | `"user_id"` |
|
|
486
|
+
| unique | actual DB column name | `["user_id", "date"]` |
|
|
487
|
+
| search | FieldExpr (`relation.field`) | `"user.id"` |
|
|
473
488
|
|
|
474
489
|
### Example
|
|
475
490
|
|
|
476
491
|
```json
|
|
477
492
|
{
|
|
478
493
|
"id": "ApiLog",
|
|
479
|
-
"props": [
|
|
480
|
-
{ "type": "relation", "name": "user", "with": "User", "relationType": "BelongsToOne" }
|
|
481
|
-
],
|
|
494
|
+
"props": [{ "type": "relation", "name": "user", "with": "User", "relationType": "BelongsToOne" }],
|
|
482
495
|
"subsets": {
|
|
483
|
-
"A": ["id", "user.id", "api_path"]
|
|
496
|
+
"A": ["id", "user.id", "api_path"] // use FieldExpr
|
|
484
497
|
},
|
|
485
498
|
"indexes": [
|
|
486
499
|
{
|
|
@@ -506,29 +519,25 @@ If you see this error in subsets, change `user_id` → `user.id`. In indexes, `u
|
|
|
506
519
|
|
|
507
520
|
## Common Mistakes
|
|
508
521
|
|
|
509
|
-
| Mistake
|
|
510
|
-
|
|
511
|
-
| Using a separate `"relations": [...]` section | Define with `"type": "relation"` inside `props`
|
|
512
|
-
| Directly defining `{name}_id` in BelongsToOne | Delete it (auto-generated)
|
|
513
|
-
| Using `user_id` directly in Subset
|
|
514
|
-
| Mismatch of FK intent in OneToOne
|
|
515
|
-
| Missing `joinColumn` in HasMany
|
|
516
|
-
| Missing `onUpdate/onDelete` in ManyToMany
|
|
517
|
-
| Inconsistent joinTable name
|
|
518
|
-
| `nullable: false` in self-reference
|
|
522
|
+
| Mistake | Fix |
|
|
523
|
+
| --------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
524
|
+
| Using a separate `"relations": [...]` section | Define with `"type": "relation"` inside `props` |
|
|
525
|
+
| Directly defining `{name}_id` in BelongsToOne | Delete it (auto-generated) |
|
|
526
|
+
| Using `user_id` directly in Subset | Change to `user.id` form |
|
|
527
|
+
| Mismatch of FK intent in OneToOne | Explicitly set `hasJoinColumn: true` on the side holding the FK (optional, no FK if omitted) |
|
|
528
|
+
| Missing `joinColumn` in HasMany | Specify the FK column name in the related table |
|
|
529
|
+
| Missing `onUpdate/onDelete` in ManyToMany | Add as required |
|
|
530
|
+
| Inconsistent joinTable name | Consistent naming recommended (alphabetical order) |
|
|
531
|
+
| `nullable: false` in self-reference | Change to `nullable: true` |
|
|
519
532
|
|
|
520
533
|
## Using Relationships in Subsets
|
|
534
|
+
|
|
521
535
|
- See `subset.md`
|
|
536
|
+
|
|
522
537
|
```json
|
|
523
538
|
{
|
|
524
539
|
"subsets": {
|
|
525
|
-
"A": [
|
|
526
|
-
"id",
|
|
527
|
-
"title",
|
|
528
|
-
"author.id",
|
|
529
|
-
"author.username",
|
|
530
|
-
"author.department.name"
|
|
531
|
-
]
|
|
540
|
+
"A": ["id", "title", "author.id", "author.username", "author.department.name"]
|
|
532
541
|
}
|
|
533
542
|
}
|
|
534
543
|
```
|
|
@@ -553,24 +562,24 @@ Reference: sonamu/examples/miomock/api/src/application/project
|
|
|
553
562
|
import { z } from "zod";
|
|
554
563
|
import { ProjectBaseSchema } from "../sonamu.generated";
|
|
555
564
|
|
|
556
|
-
export const ProjectSaveParams = ProjectBaseSchema
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
})
|
|
565
|
+
export const ProjectSaveParams = ProjectBaseSchema.partial({
|
|
566
|
+
id: true,
|
|
567
|
+
created_at: true,
|
|
568
|
+
})
|
|
561
569
|
.extend({
|
|
562
|
-
employee_ids: z.array(z.number().int().positive()),
|
|
563
|
-
tag_ids: z.array(z.number().int().positive()),
|
|
570
|
+
employee_ids: z.array(z.number().int().positive()), // ManyToMany: employee
|
|
571
|
+
tag_ids: z.array(z.number().int().positive()), // ManyToMany: tags
|
|
564
572
|
})
|
|
565
573
|
.omit({
|
|
566
|
-
virtual_test: true,
|
|
574
|
+
virtual_test: true, // remove virtual fields
|
|
567
575
|
virtual_query_test: true,
|
|
568
|
-
textsearchable_index_col: true,
|
|
576
|
+
textsearchable_index_col: true, // remove generated fields
|
|
569
577
|
});
|
|
570
578
|
export type ProjectSaveParams = z.infer<typeof ProjectSaveParams>;
|
|
571
579
|
```
|
|
572
580
|
|
|
573
581
|
**Important:**
|
|
582
|
+
|
|
574
583
|
- Since BaseSchema does not have ManyToMany relation fields, add them with `.extend()`
|
|
575
584
|
- Field name should be in the `{relation_name}_ids` form (e.g. employee → employee_ids, tags → tag_ids)
|
|
576
585
|
- Type validation: `z.array(z.number().int().positive())` - only positive integers allowed
|
|
@@ -676,16 +685,12 @@ When re-saving data queried in an update test, ManyToMany relationship fields mu
|
|
|
676
685
|
```typescript
|
|
677
686
|
// WRONG - saving without category_ids will delete all relationships
|
|
678
687
|
const { categories, ...collectionData } = collection;
|
|
679
|
-
await QuestionCollectionModel.save([
|
|
680
|
-
{ ...collectionData, title: "Updated Title" }
|
|
681
|
-
]);
|
|
688
|
+
await QuestionCollectionModel.save([{ ...collectionData, title: "Updated Title" }]);
|
|
682
689
|
|
|
683
690
|
// CORRECT - extract ids from categories and pass them
|
|
684
691
|
const { categories, ...collectionData } = collection;
|
|
685
|
-
const category_ids = categories?.map(c => c.id) ?? [];
|
|
686
|
-
await QuestionCollectionModel.save([
|
|
687
|
-
{ ...collectionData, category_ids, title: "Updated Title" }
|
|
688
|
-
]);
|
|
692
|
+
const category_ids = categories?.map((c) => c.id) ?? [];
|
|
693
|
+
await QuestionCollectionModel.save([{ ...collectionData, category_ids, title: "Updated Title" }]);
|
|
689
694
|
```
|
|
690
695
|
|
|
691
696
|
### Managing Bidirectional ManyToMany
|
|
@@ -697,18 +702,17 @@ await QuestionCollectionModel.save([
|
|
|
697
702
|
// Employee Entity: projs (ManyToMany, same join table)
|
|
698
703
|
|
|
699
704
|
// project.types.ts - manages employee_ids
|
|
700
|
-
export const ProjectSaveParams = ProjectBaseSchema
|
|
701
|
-
.
|
|
702
|
-
|
|
703
|
-
});
|
|
705
|
+
export const ProjectSaveParams = ProjectBaseSchema.extend({
|
|
706
|
+
employee_ids: z.array(z.number().int().positive()),
|
|
707
|
+
});
|
|
704
708
|
|
|
705
709
|
// employee.types.ts - does not manage proj_ids
|
|
706
|
-
export const EmployeeSaveParams = EmployeeBaseSchema
|
|
707
|
-
.partial({ id: true, created_at: true });
|
|
710
|
+
export const EmployeeSaveParams = EmployeeBaseSchema.partial({ id: true, created_at: true });
|
|
708
711
|
// proj_ids is not added
|
|
709
712
|
```
|
|
710
713
|
|
|
711
714
|
**Reason:**
|
|
715
|
+
|
|
712
716
|
- Managing from both sides causes synchronization issues
|
|
713
717
|
- Managing from the primary Entity (Project) only is clearer
|
|
714
718
|
- When querying Employee, projs are automatically joined and returned
|
|
@@ -41,6 +41,7 @@ Immediately after writing your entity.json file, validate the following **before
|
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
**How to validate:**
|
|
44
|
+
|
|
44
45
|
```bash
|
|
45
46
|
# Find indexes without type in all entity.json files
|
|
46
47
|
grep -r '"indexes"' packages/api/src/application/*/\*.entity.json | \
|
|
@@ -64,17 +65,20 @@ grep -r '"indexes"' packages/api/src/application/*/\*.entity.json | \
|
|
|
64
65
|
```
|
|
65
66
|
|
|
66
67
|
**Rules:**
|
|
68
|
+
|
|
67
69
|
- `{relation_name}_id` → `{relation_name}.id`
|
|
68
70
|
- If a BelongsToOne relation exists, always use `relation.id` format
|
|
69
71
|
- Sonamu optimizes by reading the FK column directly and skipping JOINs when only `.id` is referenced
|
|
70
72
|
|
|
71
73
|
**How to validate:**
|
|
74
|
+
|
|
72
75
|
```bash
|
|
73
76
|
# Find subset fields ending in _id in entity.json
|
|
74
77
|
grep -A 20 '"subsets"' your-entity.entity.json | grep '_id"'
|
|
75
78
|
```
|
|
76
79
|
|
|
77
80
|
**Reference working code:**
|
|
81
|
+
|
|
78
82
|
- `sonamu/examples/miomock/api/src/application/project/project.entity.json`
|
|
79
83
|
- `sonamu/examples/miomock/api/src/application/employee/employee.entity.json`
|
|
80
84
|
|
|
@@ -92,18 +96,13 @@ grep -A 20 '"subsets"' your-entity.entity.json | grep '_id"'
|
|
|
92
96
|
{ "type": "relation", "name": "user" }
|
|
93
97
|
],
|
|
94
98
|
"subsets": {
|
|
95
|
-
"A": [
|
|
96
|
-
"id",
|
|
97
|
-
"created_at",
|
|
98
|
-
"title",
|
|
99
|
-
"user.id",
|
|
100
|
-
"user.name"
|
|
101
|
-
]
|
|
99
|
+
"A": ["id", "created_at", "title", "user.id", "user.name"]
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
102
|
```
|
|
105
103
|
|
|
106
104
|
**Validation checklist:**
|
|
105
|
+
|
|
107
106
|
- [ ] All regular fields included
|
|
108
107
|
- [ ] All relations include at least `.id`
|
|
109
108
|
- [ ] Non-nullable relations also include required fields
|
|
@@ -140,6 +139,7 @@ grep -A 20 '"subsets"' your-entity.entity.json | grep '_id"'
|
|
|
140
139
|
```
|
|
141
140
|
|
|
142
141
|
**How to validate:**
|
|
142
|
+
|
|
143
143
|
```bash
|
|
144
144
|
# Check if a BelongsToOne relation also has an _id field
|
|
145
145
|
grep -A 5 '"relationType": "BelongsToOne"' your-entity.entity.json
|
|
@@ -209,6 +209,7 @@ ls packages/api/src/application/your-entity/your-entity.model.ts
|
|
|
209
209
|
**If missing, manual creation is required** (refer to another entity's model.ts)
|
|
210
210
|
|
|
211
211
|
Required methods:
|
|
212
|
+
|
|
212
213
|
- `findById`
|
|
213
214
|
- `findOne`
|
|
214
215
|
- `findMany`
|
|
@@ -225,12 +226,10 @@ ls packages/api/src/application/your-entity/your-entity.types.ts
|
|
|
225
226
|
```
|
|
226
227
|
|
|
227
228
|
**Required content:**
|
|
229
|
+
|
|
228
230
|
```typescript
|
|
229
231
|
import { z } from "zod";
|
|
230
|
-
import {
|
|
231
|
-
YourEntityBaseListParams,
|
|
232
|
-
YourEntityBaseSchema,
|
|
233
|
-
} from "../sonamu.generated";
|
|
232
|
+
import { YourEntityBaseListParams, YourEntityBaseSchema } from "../sonamu.generated";
|
|
234
233
|
|
|
235
234
|
export const YourEntityListParams = YourEntityBaseListParams;
|
|
236
235
|
export type YourEntityListParams = z.infer<typeof YourEntityListParams>;
|
|
@@ -244,19 +243,20 @@ export type YourEntitySaveParams = z.infer<typeof YourEntitySaveParams>;
|
|
|
244
243
|
```
|
|
245
244
|
|
|
246
245
|
**If a ManyToMany relation exists:**
|
|
246
|
+
|
|
247
247
|
```typescript
|
|
248
248
|
// ManyToMany relation: add {relation_name}_ids array
|
|
249
249
|
export const YourEntitySaveParams = YourEntityBaseSchema.partial({
|
|
250
250
|
id: true,
|
|
251
251
|
created_at: true,
|
|
252
|
-
})
|
|
253
|
-
.
|
|
254
|
-
|
|
255
|
-
});
|
|
252
|
+
}).extend({
|
|
253
|
+
relation_name_ids: z.array(z.number().int().positive()),
|
|
254
|
+
});
|
|
256
255
|
export type YourEntitySaveParams = z.infer<typeof YourEntitySaveParams>;
|
|
257
256
|
```
|
|
258
257
|
|
|
259
258
|
**Reference working code:**
|
|
259
|
+
|
|
260
260
|
- `sonamu/examples/miomock/api/src/application/project/project.types.ts` - ManyToMany example
|
|
261
261
|
- `sonamu/examples/miomock/api/src/application/employee/employee.types.ts` - basic pattern
|
|
262
262
|
|
|
@@ -279,6 +279,7 @@ grep "your-entity" packages/api/sonamu.lock
|
|
|
279
279
|
```
|
|
280
280
|
|
|
281
281
|
**Expected result:**
|
|
282
|
+
|
|
282
283
|
```json
|
|
283
284
|
[
|
|
284
285
|
{
|
|
@@ -338,6 +339,7 @@ ls packages/api/src/migrations/*_create__your_entities.ts
|
|
|
338
339
|
```
|
|
339
340
|
|
|
340
341
|
**Validation checklist:**
|
|
342
|
+
|
|
341
343
|
- [ ] Is the table name correct? (plural, snake_case)
|
|
342
344
|
- [ ] Are all columns defined?
|
|
343
345
|
- [ ] Are foreign key constraints present?
|
|
@@ -353,6 +355,7 @@ pnpm sonamu migration:latest --dry-run
|
|
|
353
355
|
```
|
|
354
356
|
|
|
355
357
|
**Check for:**
|
|
358
|
+
|
|
356
359
|
- No SQL syntax errors
|
|
357
360
|
- No duplicate column definitions
|
|
358
361
|
- No Boolean default type errors
|
|
@@ -443,6 +446,7 @@ echo "[COMPLETE] Entity validation complete!"
|
|
|
443
446
|
```
|
|
444
447
|
|
|
445
448
|
**Usage:**
|
|
449
|
+
|
|
446
450
|
```bash
|
|
447
451
|
chmod +x packages/api/scripts/validate-entity.sh
|
|
448
452
|
./packages/api/scripts/validate-entity.sh your-entity
|