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
|
@@ -45,6 +45,7 @@ export default defineConfig({
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Configuration type (`SonamuDevRunnerConfig`):
|
|
48
|
+
|
|
48
49
|
- `enabled: boolean` — Whether to enable DevRunner (default: false)
|
|
49
50
|
- `routePrefix?: string` — Test endpoint path prefix (default: `/__test__`)
|
|
50
51
|
- `vitestConfigPath?: string` — vitest.config.ts path (relative to api-root)
|
|
@@ -82,6 +83,7 @@ sonamu test user.model -p "findMany" -t
|
|
|
82
83
|
```
|
|
83
84
|
|
|
84
85
|
Argument processing rules:
|
|
86
|
+
|
|
85
87
|
- `--pattern` / `-p`: test name string filter (`setGlobalTestNamePattern` → `resetGlobalTestNamePattern` after execution)
|
|
86
88
|
- `--traces` / `-t`: boolean flag, enables Naite trace output
|
|
87
89
|
- Arguments not starting with `-`: treated as file list
|
|
@@ -115,6 +117,7 @@ For trace data details: see `naite.md`
|
|
|
115
117
|
### HMR Integration — Automatic Vitest Module Graph Invalidation on Source Changes
|
|
116
118
|
|
|
117
119
|
When a source file is modified, `syncFromWatcher` in the syncer triggers both of the following simultaneously:
|
|
120
|
+
|
|
118
121
|
1. Server HMR cache invalidation (`hot.invalidateFile`)
|
|
119
122
|
2. Vitest module graph invalidation (`Sonamu.devVitestManager.invalidateFiles([filePath])`)
|
|
120
123
|
|
|
@@ -127,6 +130,7 @@ sonamu test user.model ← runs with latest code
|
|
|
127
130
|
Because Vite's `moduleGraph.invalidateModule()` recursively cascades in the importer direction, invalidating a single source file automatically invalidates any test files that import it. No restart is needed.
|
|
128
131
|
|
|
129
132
|
**Transitive dependency example:**
|
|
133
|
+
|
|
130
134
|
- Change `utils.ts` → `user.model.ts` (imports utils) → `user.model.test.ts` all automatically invalidated
|
|
131
135
|
|
|
132
136
|
### Direct HTTP API Calls
|
|
@@ -144,24 +148,36 @@ curl http://localhost:3000/__test__/status
|
|
|
144
148
|
```
|
|
145
149
|
|
|
146
150
|
**POST `/__test__/run`** request:
|
|
151
|
+
|
|
147
152
|
```json
|
|
148
153
|
{ "files": ["src/user/user.model.test.ts"], "pattern": "should create user" }
|
|
149
154
|
```
|
|
150
155
|
|
|
151
156
|
Response (success):
|
|
157
|
+
|
|
152
158
|
```json
|
|
153
159
|
{
|
|
154
160
|
"ok": true,
|
|
155
161
|
"summary": { "total": 12, "passed": 11, "failed": 1, "skipped": 0, "durationMs": 842 },
|
|
156
162
|
"failed": [
|
|
157
|
-
{
|
|
163
|
+
{
|
|
164
|
+
"file": "src/user/user.model.test.ts",
|
|
165
|
+
"name": "UserModel > should create user",
|
|
166
|
+
"error": "Expected ..."
|
|
167
|
+
}
|
|
158
168
|
],
|
|
159
169
|
"traces": [
|
|
160
170
|
{
|
|
161
171
|
"testName": "UserModel > should create user",
|
|
162
172
|
"file": "src/user/user.model.test.ts",
|
|
163
173
|
"traces": [
|
|
164
|
-
{
|
|
174
|
+
{
|
|
175
|
+
"key": "esq-query",
|
|
176
|
+
"value": "select ...",
|
|
177
|
+
"filePath": "user.model.ts",
|
|
178
|
+
"lineNumber": 113,
|
|
179
|
+
"at": "2026-02-23T14:51:35+09:00"
|
|
180
|
+
}
|
|
165
181
|
]
|
|
166
182
|
}
|
|
167
183
|
]
|
|
@@ -169,6 +185,7 @@ Response (success):
|
|
|
169
185
|
```
|
|
170
186
|
|
|
171
187
|
**GET `/__test__/status`** response:
|
|
188
|
+
|
|
172
189
|
```json
|
|
173
190
|
{ "ready": true, "running": false, "lastRunAt": "2026-02-13T12:34:56.000Z" }
|
|
174
191
|
```
|
|
@@ -176,6 +193,7 @@ Response (success):
|
|
|
176
193
|
### Internal Architecture
|
|
177
194
|
|
|
178
195
|
**DevVitestManager** (`testing/dev-vitest-manager.ts`):
|
|
196
|
+
|
|
179
197
|
- Creates a resident instance with `createVitest('test', cliOptions, viteOverrides)`
|
|
180
198
|
- Configured with `watch: true, standalone: true`, but blocks automatic re-runs:
|
|
181
199
|
- `forceRerunTriggers: []`
|
|
@@ -187,11 +205,13 @@ Response (success):
|
|
|
187
205
|
- Keeps loading the project's `vitest.config.ts` (reuses existing sequencer/reporter/globalSetup)
|
|
188
206
|
|
|
189
207
|
**Fastify integration** (`testing/dev-test-routes.ts`):
|
|
208
|
+
|
|
190
209
|
- Registers routes with `registerDevTestRoutes(server, config)`
|
|
191
210
|
- Stores manager instance in `Sonamu.devVitestManager`
|
|
192
211
|
- Ensures `shutdown()` is called in `server.addHook('onClose')`
|
|
193
212
|
|
|
194
213
|
**CLI** (`bin/test-command.ts`):
|
|
214
|
+
|
|
195
215
|
- Calls `testCommand()` directly before `tsicli` matching (to handle variadic arguments)
|
|
196
216
|
- Included in `bootstrap()`'s `notToInit` list (no need for `Sonamu.init` since it only makes HTTP calls)
|
|
197
217
|
- Server port/host read from `server.listen` in `sonamu.config.ts`
|
|
@@ -200,30 +220,30 @@ Response (success):
|
|
|
200
220
|
|
|
201
221
|
Single file (`user.model.test.ts`):
|
|
202
222
|
|
|
203
|
-
| Item
|
|
204
|
-
|
|
205
|
-
| Test execution time
|
|
206
|
-
| Total elapsed time (wall clock) | 4,118ms
|
|
223
|
+
| Item | `vitest run` | `sonamu test` | Difference |
|
|
224
|
+
| ------------------------------- | ------------ | ------------- | ----------- |
|
|
225
|
+
| Test execution time | 2,610ms | 823ms | 3.2x faster |
|
|
226
|
+
| Total elapsed time (wall clock) | 4,118ms | 1,907ms | 2.2x faster |
|
|
207
227
|
|
|
208
228
|
Multiple files (puri tests, 4 files 147 tests):
|
|
209
229
|
|
|
210
|
-
| Item
|
|
211
|
-
|
|
212
|
-
| Test execution time
|
|
213
|
-
| Total elapsed time (wall clock) | 7,035ms
|
|
230
|
+
| Item | `vitest run` | `sonamu test` | Difference |
|
|
231
|
+
| ------------------------------- | ------------ | ------------- | ----------- |
|
|
232
|
+
| Test execution time | 5,740ms | 1,774ms | 3.2x faster |
|
|
233
|
+
| Total elapsed time (wall clock) | 7,035ms | 2,673ms | 2.6x faster |
|
|
214
234
|
|
|
215
235
|
Speed difference reason: `vitest run` requires process boot (~1.5s) + module transform (~400ms) on every execution, whereas `sonamu test` reuses an already-initialized instance and avoids this overhead.
|
|
216
236
|
|
|
217
237
|
### `pnpm sonamu test` vs `pnpm test` Comparison
|
|
218
238
|
|
|
219
|
-
|
|
|
220
|
-
|
|
221
|
-
| Execution method
|
|
222
|
-
| Initialization cost | None (already initialized)
|
|
223
|
-
| HMR integration
|
|
224
|
-
| Naite trace
|
|
225
|
-
| Use case
|
|
226
|
-
| Prerequisite
|
|
239
|
+
| | `pnpm sonamu test` (default) | `pnpm test` (CI/fallback) |
|
|
240
|
+
| ------------------- | --------------------------------------------- | --------------------------- |
|
|
241
|
+
| Execution method | Resident instance inside dev server | Independent Vitest process |
|
|
242
|
+
| Initialization cost | None (already initialized) | Initialization on every run |
|
|
243
|
+
| HMR integration | Source changes reflected immediately | Not applicable |
|
|
244
|
+
| Naite trace | CLI output via `--traces` flag | Available through reporter |
|
|
245
|
+
| Use case | **Default test execution during development** | CI environments |
|
|
246
|
+
| Prerequisite | `sonamu dev` running (assumed always running) | None |
|
|
227
247
|
|
|
228
248
|
### Troubleshooting
|
|
229
249
|
|
|
@@ -275,8 +295,8 @@ Both `pnpm sonamu test` and `pnpm test` share the parallel configuration. Only c
|
|
|
275
295
|
```typescript
|
|
276
296
|
export default defineConfig({
|
|
277
297
|
test: {
|
|
278
|
-
parallel: true,
|
|
279
|
-
maxWorkers: 4,
|
|
298
|
+
parallel: true, // Separate DB execution per worker
|
|
299
|
+
maxWorkers: 4, // Number of workers (default: 4)
|
|
280
300
|
},
|
|
281
301
|
});
|
|
282
302
|
```
|
|
@@ -291,14 +311,14 @@ To use `pnpm sonamu test`, DevRunner must be enabled. Just add `test.devRunner.e
|
|
|
291
311
|
export default defineConfig({
|
|
292
312
|
server: {
|
|
293
313
|
listen: {
|
|
294
|
-
port: 3000,
|
|
295
|
-
host: "localhost",
|
|
314
|
+
port: 3000, // CLI sends HTTP requests to this port
|
|
315
|
+
host: "localhost", // CLI connects to this host (default: localhost)
|
|
296
316
|
},
|
|
297
317
|
},
|
|
298
318
|
|
|
299
319
|
test: {
|
|
300
320
|
devRunner: {
|
|
301
|
-
enabled: true,
|
|
321
|
+
enabled: true, // Required: enable DevRunner
|
|
302
322
|
// routePrefix: "/__test__", // Optional: endpoint path (default value)
|
|
303
323
|
// vitestConfigPath: undefined, // Optional: vitest.config.ts path (default: vitest.config.ts in api-root)
|
|
304
324
|
},
|
|
@@ -310,16 +330,16 @@ export default defineConfig({
|
|
|
310
330
|
|
|
311
331
|
### Source Code Reference Locations per Setting
|
|
312
332
|
|
|
313
|
-
| Setting path
|
|
314
|
-
|
|
315
|
-
| `test.devRunner.enabled`
|
|
316
|
-
| `test.devRunner.routePrefix`
|
|
317
|
-
| `test.devRunner.vitestConfigPath` | `undefined`
|
|
318
|
-
| `test.parallel`
|
|
319
|
-
| `test.maxWorkers`
|
|
320
|
-
| `server.listen.port`
|
|
321
|
-
| `server.listen.host`
|
|
322
|
-
| `database.name`
|
|
333
|
+
| Setting path | Default | Reference location | Purpose |
|
|
334
|
+
| --------------------------------- | ------------- | ----------------------------------------------- | -------------------------------------------------- |
|
|
335
|
+
| `test.devRunner.enabled` | `false` | `sonamu.ts` L394, `test-command.ts` | DevRunner activation condition |
|
|
336
|
+
| `test.devRunner.routePrefix` | `"/__test__"` | `dev-test-routes.ts`, `test-command.ts` | HTTP endpoint path |
|
|
337
|
+
| `test.devRunner.vitestConfigPath` | `undefined` | `dev-vitest-manager.ts` `start()` | Vitest config file location |
|
|
338
|
+
| `test.parallel` | `false` | `vitest-helpers.ts` `getSonamuTestConfig()` | `pool: "forks"` + `SONAMU_WORKER_DB` env injection |
|
|
339
|
+
| `test.maxWorkers` | `4` | `vitest-helpers.ts`, `global-setup.ts` | Vitest maxWorkers + number of worker DBs |
|
|
340
|
+
| `server.listen.port` | `3000` | `test-command.ts` | CLI → dev server HTTP connection port |
|
|
341
|
+
| `server.listen.host` | `"localhost"` | `test-command.ts` | CLI → dev server HTTP connection host |
|
|
342
|
+
| `database.name` | — | `db.ts` `generateDBConfig()`, `global-setup.ts` | Test DB name (`{name}_test`) |
|
|
323
343
|
|
|
324
344
|
### Activation Conditions
|
|
325
345
|
|
|
@@ -372,10 +392,10 @@ export { setup } from "sonamu/test";
|
|
|
372
392
|
```typescript
|
|
373
393
|
export default defineConfig({
|
|
374
394
|
test: {
|
|
375
|
-
parallel: true,
|
|
376
|
-
maxWorkers: 4,
|
|
395
|
+
parallel: true, // Enable parallel testing
|
|
396
|
+
maxWorkers: 4, // Number of workers (default: 4)
|
|
377
397
|
devRunner: {
|
|
378
|
-
enabled: true,
|
|
398
|
+
enabled: true, // Enable DevRunner
|
|
379
399
|
},
|
|
380
400
|
},
|
|
381
401
|
});
|
|
@@ -35,9 +35,7 @@ import PostModel from "../post/post.model";
|
|
|
35
35
|
import CommentModel from "../comment/comment.model";
|
|
36
36
|
|
|
37
37
|
// User helper
|
|
38
|
-
export async function createTestUser(
|
|
39
|
-
params?: Partial<UserSaveParams>,
|
|
40
|
-
): Promise<number> {
|
|
38
|
+
export async function createTestUser(params?: Partial<UserSaveParams>): Promise<number> {
|
|
41
39
|
const user: UserSaveParams = {
|
|
42
40
|
email: `test-${Date.now()}@example.com`,
|
|
43
41
|
name: "Test User",
|
|
@@ -598,11 +596,7 @@ export async function createTestConsultationWithDeps() {
|
|
|
598
596
|
role: "counselor",
|
|
599
597
|
});
|
|
600
598
|
const damageTypeId = await createTestDamageType(null);
|
|
601
|
-
const consultationId = await createTestConsultation(
|
|
602
|
-
applicantId,
|
|
603
|
-
counselorId,
|
|
604
|
-
damageTypeId,
|
|
605
|
-
);
|
|
599
|
+
const consultationId = await createTestConsultation(applicantId, counselorId, damageTypeId);
|
|
606
600
|
return { applicantId, counselorId, damageTypeId, consultationId };
|
|
607
601
|
}
|
|
608
602
|
```
|
|
@@ -625,8 +619,7 @@ This is what differentiates it from simple CRUD tests, and it's **the core that
|
|
|
625
619
|
describe("E. Business Logic", () => {
|
|
626
620
|
test("full process from consultation submission to completion", async () => {
|
|
627
621
|
// 1. submit consultation + create dependencies
|
|
628
|
-
const { consultationId, counselorId } =
|
|
629
|
-
await createTestConsultationWithDeps();
|
|
622
|
+
const { consultationId, counselorId } = await createTestConsultationWithDeps();
|
|
630
623
|
// 2. record channel logs (online submission, phone consultation)
|
|
631
624
|
await createTestConsultationChannelLog(consultationId, {
|
|
632
625
|
channel: "online",
|
|
@@ -785,12 +778,12 @@ const [id] = await FAQModel.save([
|
|
|
785
778
|
|
|
786
779
|
#### Application Criteria
|
|
787
780
|
|
|
788
|
-
| Field type
|
|
781
|
+
| Field type | Handling |
|
|
789
782
|
| -------------------------------- | ------------------------------- |
|
|
790
783
|
| `id`, `created_at`, `updated_at` | Always partial (auto-generated) |
|
|
791
|
-
| Fields with `dbDefault`
|
|
792
|
-
| Fields with `nullable: true`
|
|
793
|
-
| Required fields
|
|
784
|
+
| Fields with `dbDefault` | `.optional().default(value)` |
|
|
785
|
+
| Fields with `nullable: true` | partial + extend + `.nullish()` |
|
|
786
|
+
| Required fields | Excluded from partial |
|
|
794
787
|
|
|
795
788
|
#### Checklist
|
|
796
789
|
|
|
@@ -872,12 +865,12 @@ expect(item?.field).toBe(expectedValue); // find() can return undefined
|
|
|
872
865
|
|
|
873
866
|
Sonamu Model provides the following methods by default. Tests are written targeting these methods:
|
|
874
867
|
|
|
875
|
-
| Method
|
|
876
|
-
| -------------------------- |
|
|
877
|
-
| `findById(subset, id)`
|
|
878
|
-
| `findMany(subset, params)` | Fetch list
|
|
879
|
-
| `save(rows)`
|
|
880
|
-
| `del(ids)`
|
|
868
|
+
| Method | Purpose | Returns |
|
|
869
|
+
| -------------------------- | ---------------------- | -------------------------------- |
|
|
870
|
+
| `findById(subset, id)` | Fetch single record | `Promise<Subset>` |
|
|
871
|
+
| `findMany(subset, params)` | Fetch list | `Promise<ListResult<Subset>>` |
|
|
872
|
+
| `save(rows)` | Create/update (upsert) | `Promise<number[]>` (ids) |
|
|
873
|
+
| `del(ids)` | Delete | `Promise<number>` (delete count) |
|
|
881
874
|
|
|
882
875
|
**Note:** It's `del`, not `delete`. This avoids JavaScript reserved words.
|
|
883
876
|
|
|
@@ -1231,9 +1224,7 @@ test("validate select query", async () => {
|
|
|
1231
1224
|
|
|
1232
1225
|
expectQuery(query, "type").toBe("select");
|
|
1233
1226
|
expectQuery(query, "table").toBe("users");
|
|
1234
|
-
expectQuery(query, "columns").toMatchInlineSnapshot(
|
|
1235
|
-
`""users"."id" AS \`id\`"`,
|
|
1236
|
-
);
|
|
1227
|
+
expectQuery(query, "columns").toMatchInlineSnapshot(`""users"."id" AS \`id\`"`);
|
|
1237
1228
|
});
|
|
1238
1229
|
|
|
1239
1230
|
test("validate where condition", async () => {
|
|
@@ -1246,9 +1237,7 @@ test("validate where condition", async () => {
|
|
|
1246
1237
|
|
|
1247
1238
|
test("validate join", async () => {
|
|
1248
1239
|
const db = UserModel.getPuri("r");
|
|
1249
|
-
await db
|
|
1250
|
-
.table("employees")
|
|
1251
|
-
.leftJoin("departments", "employees.department_id", "departments.id");
|
|
1240
|
+
await db.table("employees").leftJoin("departments", "employees.department_id", "departments.id");
|
|
1252
1241
|
const query = Naite.get("puri:executed-query").first();
|
|
1253
1242
|
|
|
1254
1243
|
expectQuery(query, "join").toMatchInlineSnapshot(
|
|
@@ -1427,9 +1416,7 @@ test("unresolved reference error", async () => {
|
|
|
1427
1416
|
ub.register("departments", { company_id: companyRef, name: "Dept" });
|
|
1428
1417
|
|
|
1429
1418
|
// attempt upsert in wrong order
|
|
1430
|
-
await expect(ub.upsert(wdb, "departments")).rejects.toThrow(
|
|
1431
|
-
/unresolved reference/,
|
|
1432
|
-
);
|
|
1419
|
+
await expect(ub.upsert(wdb, "departments")).rejects.toThrow(/unresolved reference/);
|
|
1433
1420
|
});
|
|
1434
1421
|
```
|
|
1435
1422
|
|
|
@@ -1572,10 +1559,7 @@ SaveParams types are exported from each entity's types.ts, not from sonamu.gener
|
|
|
1572
1559
|
|
|
1573
1560
|
```typescript
|
|
1574
1561
|
// test-helpers.ts
|
|
1575
|
-
import type {
|
|
1576
|
-
UserSaveParams,
|
|
1577
|
-
TaskSaveParams,
|
|
1578
|
-
} from "../application/sonamu.generated"; // WRONG
|
|
1562
|
+
import type { UserSaveParams, TaskSaveParams } from "../application/sonamu.generated"; // WRONG
|
|
1579
1563
|
```
|
|
1580
1564
|
|
|
1581
1565
|
**Correct:**
|
|
@@ -1870,9 +1854,7 @@ function uniqueId(prefix: string) {
|
|
|
1870
1854
|
return `${prefix}_${Date.now()}_${++counter}`;
|
|
1871
1855
|
}
|
|
1872
1856
|
|
|
1873
|
-
export async function createTestInstitution(
|
|
1874
|
-
override?: Partial<InstitutionSaveParams>,
|
|
1875
|
-
) {
|
|
1857
|
+
export async function createTestInstitution(override?: Partial<InstitutionSaveParams>) {
|
|
1876
1858
|
const [id] = await InstitutionModel.save([
|
|
1877
1859
|
{
|
|
1878
1860
|
name: "Test Institution",
|
|
@@ -1903,10 +1885,7 @@ export async function createTestDepartment(
|
|
|
1903
1885
|
return id;
|
|
1904
1886
|
}
|
|
1905
1887
|
|
|
1906
|
-
export async function createTestUser(
|
|
1907
|
-
institutionId: number,
|
|
1908
|
-
override?: Partial<UserSaveParams>,
|
|
1909
|
-
) {
|
|
1888
|
+
export async function createTestUser(institutionId: number, override?: Partial<UserSaveParams>) {
|
|
1910
1889
|
const [id] = await UserModel.save([
|
|
1911
1890
|
{
|
|
1912
1891
|
employee_no: uniqueId("EMP"),
|
|
@@ -1940,18 +1919,14 @@ export async function createTestTask(
|
|
|
1940
1919
|
}
|
|
1941
1920
|
|
|
1942
1921
|
// create the entire dependency chain at once
|
|
1943
|
-
export async function createTestTaskWithDeps(
|
|
1944
|
-
taskOverride?: Partial<TaskSaveParams>,
|
|
1945
|
-
) {
|
|
1922
|
+
export async function createTestTaskWithDeps(taskOverride?: Partial<TaskSaveParams>) {
|
|
1946
1923
|
const institutionId = await createTestInstitution();
|
|
1947
1924
|
const userId = await createTestUser(institutionId);
|
|
1948
1925
|
const taskId = await createTestTask(userId, taskOverride);
|
|
1949
1926
|
return { institutionId, userId, taskId };
|
|
1950
1927
|
}
|
|
1951
1928
|
|
|
1952
|
-
export async function createTestUserWithDeps(
|
|
1953
|
-
userOverride?: Partial<UserSaveParams>,
|
|
1954
|
-
) {
|
|
1929
|
+
export async function createTestUserWithDeps(userOverride?: Partial<UserSaveParams>) {
|
|
1955
1930
|
const institutionId = await createTestInstitution();
|
|
1956
1931
|
const userId = await createTestUser(institutionId, userOverride);
|
|
1957
1932
|
return { institutionId, userId };
|
|
@@ -2005,14 +1980,7 @@ When modifying findById results and saving again, relations must be converted to
|
|
|
2005
1980
|
|
|
2006
1981
|
// Task Subset A → SaveParams conversion
|
|
2007
1982
|
export function taskToSaveParams(task: TaskSubsetA): TaskSaveParams {
|
|
2008
|
-
const {
|
|
2009
|
-
program,
|
|
2010
|
-
project,
|
|
2011
|
-
principal_investigator,
|
|
2012
|
-
department,
|
|
2013
|
-
prev_task,
|
|
2014
|
-
...rest
|
|
2015
|
-
} = task;
|
|
1983
|
+
const { program, project, principal_investigator, department, prev_task, ...rest } = task;
|
|
2016
1984
|
|
|
2017
1985
|
return {
|
|
2018
1986
|
...rest,
|
|
@@ -2047,10 +2015,7 @@ export function relationToFk<T extends Record<string, any>>(
|
|
|
2047
2015
|
### Simplifying Update Tests
|
|
2048
2016
|
|
|
2049
2017
|
```typescript
|
|
2050
|
-
import {
|
|
2051
|
-
createTestTaskWithDeps,
|
|
2052
|
-
taskToSaveParams,
|
|
2053
|
-
} from "../../testing/test-helpers";
|
|
2018
|
+
import { createTestTaskWithDeps, taskToSaveParams } from "../../testing/test-helpers";
|
|
2054
2019
|
|
|
2055
2020
|
test("Update - update task info", async () => {
|
|
2056
2021
|
const { taskId } = await createTestTaskWithDeps();
|
|
@@ -11,9 +11,9 @@ The reference object returned by `ubRegister()`:
|
|
|
11
11
|
|
|
12
12
|
```typescript
|
|
13
13
|
type UBRef = {
|
|
14
|
-
uuid: string;
|
|
15
|
-
of: string;
|
|
16
|
-
use?: string;
|
|
14
|
+
uuid: string; // unique identifier
|
|
15
|
+
of: string; // table name
|
|
16
|
+
use?: string; // field to reference (default: "id")
|
|
17
17
|
};
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -30,8 +30,8 @@ wdb.ubRegister("employees", { user_id: userRef, department_id: deptId });
|
|
|
30
30
|
|
|
31
31
|
// Save in order inside a transaction
|
|
32
32
|
return wdb.transaction(async (trx) => {
|
|
33
|
-
await trx.ubUpsert("users");
|
|
34
|
-
return trx.ubUpsert("employees");
|
|
33
|
+
await trx.ubUpsert("users"); // Save first (referenced by FK)
|
|
34
|
+
return trx.ubUpsert("employees"); // Save after (uses FK)
|
|
35
35
|
});
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -54,12 +54,13 @@ wdb.ubRegister("posts", {
|
|
|
54
54
|
wdb.ubRegister("posts", {
|
|
55
55
|
id: 1,
|
|
56
56
|
title: "Updated Title",
|
|
57
|
-
content: "Updated Content",
|
|
58
|
-
author_id: 1,
|
|
57
|
+
content: "Updated Content", // required field included!
|
|
58
|
+
author_id: 1, // FK also included if required!
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
**How to identify required fields**:
|
|
63
|
+
|
|
63
64
|
1. Check props in entity.json
|
|
64
65
|
2. Fields without `nullable: true` = required fields
|
|
65
66
|
3. `id`, `created_at`, fields with `dbDefault` can be omitted
|
|
@@ -68,11 +69,11 @@ wdb.ubRegister("posts", {
|
|
|
68
69
|
// entity.json example
|
|
69
70
|
{
|
|
70
71
|
"props": [
|
|
71
|
-
{ "name": "id", "type": "integer" },
|
|
72
|
-
{ "name": "title", "type": "string" },
|
|
73
|
-
{ "name": "content", "type": "string" },
|
|
74
|
-
{ "name": "category", "type": "string", "nullable": true },
|
|
75
|
-
{ "name": "created_at", "type": "date", "dbDefault": "CURRENT_TIMESTAMP" }
|
|
72
|
+
{ "name": "id", "type": "integer" }, // can be omitted
|
|
73
|
+
{ "name": "title", "type": "string" }, // required! (no nullable)
|
|
74
|
+
{ "name": "content", "type": "string" }, // required! (no nullable)
|
|
75
|
+
{ "name": "category", "type": "string", "nullable": true }, // optional
|
|
76
|
+
{ "name": "created_at", "type": "date", "dbDefault": "CURRENT_TIMESTAMP" } // can be omitted
|
|
76
77
|
]
|
|
77
78
|
}
|
|
78
79
|
```
|
|
@@ -82,10 +83,10 @@ wdb.ubRegister("posts", {
|
|
|
82
83
|
Save the table referenced by FK first:
|
|
83
84
|
|
|
84
85
|
```typescript
|
|
85
|
-
await trx.ubUpsert("companies");
|
|
86
|
+
await trx.ubUpsert("companies"); // 1. No dependencies
|
|
86
87
|
await trx.ubUpsert("departments"); // 2. Needs company_id
|
|
87
|
-
await trx.ubUpsert("users");
|
|
88
|
-
await trx.ubUpsert("employees");
|
|
88
|
+
await trx.ubUpsert("users"); // 3. No dependencies
|
|
89
|
+
await trx.ubUpsert("employees"); // 4. Needs user_id, department_id
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
## Model save Pattern
|
|
@@ -165,10 +166,10 @@ In hierarchical structures (e.g. categories, org charts), self-referential relat
|
|
|
165
166
|
await wdb.transaction(async (trx) => {
|
|
166
167
|
// Root category
|
|
167
168
|
const rootRef = trx.ubRegister("categories", { name: "Root", parent_id: null });
|
|
168
|
-
|
|
169
|
+
|
|
169
170
|
// Child category (references rootRef)
|
|
170
171
|
const childRef = trx.ubRegister("categories", { name: "Child", parent_id: rootRef });
|
|
171
|
-
|
|
172
|
+
|
|
172
173
|
// Grandchild category (references childRef)
|
|
173
174
|
trx.ubRegister("categories", { name: "Grandchild", parent_id: childRef });
|
|
174
175
|
|
|
@@ -197,8 +198,8 @@ wdb.ubRegister("users", { id: 3, status: "inactive" });
|
|
|
197
198
|
|
|
198
199
|
await wdb.transaction(async (trx) => {
|
|
199
200
|
await trx.updateBatch("users", {
|
|
200
|
-
chunkSize: 500,
|
|
201
|
-
where: "id",
|
|
201
|
+
chunkSize: 500, // batch size (default: 500)
|
|
202
|
+
where: "id", // WHERE condition column (default: "id")
|
|
202
203
|
});
|
|
203
204
|
});
|
|
204
205
|
|
|
@@ -214,9 +215,9 @@ Options for `ubUpsert()`:
|
|
|
214
215
|
|
|
215
216
|
```typescript
|
|
216
217
|
type UpsertOptions = {
|
|
217
|
-
chunkSize?: number;
|
|
218
|
-
cleanOrphans?: string | string[];
|
|
219
|
-
inherit?: string[];
|
|
218
|
+
chunkSize?: number; // batch size
|
|
219
|
+
cleanOrphans?: string | string[]; // FK column(s) to use as basis for deleting orphan records
|
|
220
|
+
inherit?: string[]; // columns to preserve existing values on UPDATE
|
|
220
221
|
};
|
|
221
222
|
```
|
|
222
223
|
|
|
@@ -235,7 +236,7 @@ Automatically delete orphan records based on FK:
|
|
|
235
236
|
```typescript
|
|
236
237
|
// Single FK
|
|
237
238
|
await trx.ubUpsert("order_items", {
|
|
238
|
-
cleanOrphans: "order_id",
|
|
239
|
+
cleanOrphans: "order_id", // delete records with the same order_id that were not upserted this time
|
|
239
240
|
});
|
|
240
241
|
|
|
241
242
|
// Composite FK
|
|
@@ -250,7 +251,7 @@ Preserve existing values for specific columns on UPDATE:
|
|
|
250
251
|
|
|
251
252
|
```typescript
|
|
252
253
|
await trx.ubUpsert("users", {
|
|
253
|
-
inherit: ["created_at", "password"],
|
|
254
|
+
inherit: ["created_at", "password"], // these columns are excluded from UPDATE
|
|
254
255
|
});
|
|
255
256
|
```
|
|
256
257
|
|
|
@@ -259,16 +260,16 @@ await trx.ubUpsert("users", {
|
|
|
259
260
|
Select upsert or insert mode at runtime.
|
|
260
261
|
|
|
261
262
|
```typescript
|
|
262
|
-
await trx.ubUpsertOrInsert("logs", "insert");
|
|
263
|
-
await trx.ubUpsertOrInsert("users", "upsert");
|
|
263
|
+
await trx.ubUpsertOrInsert("logs", "insert"); // INSERT only
|
|
264
|
+
await trx.ubUpsertOrInsert("users", "upsert"); // UPSERT (default)
|
|
264
265
|
await trx.ubUpsertOrInsert("users", "upsert", { cleanOrphans: "team_id" });
|
|
265
266
|
```
|
|
266
267
|
|
|
267
|
-
| Parameter
|
|
268
|
-
|
|
269
|
-
| `tableName` | string
|
|
270
|
-
| `mode`
|
|
271
|
-
| `options`
|
|
268
|
+
| Parameter | Type | Description |
|
|
269
|
+
| ----------- | ------------------------ | --------------------------------------------------- |
|
|
270
|
+
| `tableName` | string | table name |
|
|
271
|
+
| `mode` | `"upsert"` \| `"insert"` | operation mode |
|
|
272
|
+
| `options` | `UpsertOptions` | chunkSize, cleanOrphans, inherit (same as ubUpsert) |
|
|
272
273
|
|
|
273
274
|
When `mode: "insert"`, unlike `insertOnly`, `UpsertOptions` (cleanOrphans, inherit) can be used.
|
|
274
275
|
|