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
package/src/skills/sonamu/api.md
CHANGED
|
@@ -15,29 +15,29 @@ async findById(id: number): Promise<User> { }
|
|
|
15
15
|
|
|
16
16
|
## Options
|
|
17
17
|
|
|
18
|
-
| Option
|
|
19
|
-
|
|
20
|
-
| `httpMethod`
|
|
21
|
-
| `clients`
|
|
22
|
-
| `resourceName` | queryKey for TanStack Query
|
|
23
|
-
| `guards`
|
|
24
|
-
| `path`
|
|
25
|
-
| `description`
|
|
26
|
-
| `timeout`
|
|
27
|
-
| `contentType`
|
|
28
|
-
| `cacheControl` | Cache-Control header setting
|
|
29
|
-
| `compress`
|
|
18
|
+
| Option | Description | Default |
|
|
19
|
+
| -------------- | ------------------------------------------------------- | ------------------- |
|
|
20
|
+
| `httpMethod` | GET, POST, PUT, DELETE, PATCH | GET |
|
|
21
|
+
| `clients` | Client types to generate | `["axios"]` |
|
|
22
|
+
| `resourceName` | queryKey for TanStack Query | - |
|
|
23
|
+
| `guards` | Authentication/authorization guards | - |
|
|
24
|
+
| `path` | Custom path | `/{model}/{method}` |
|
|
25
|
+
| `description` | API description (for documentation) | - |
|
|
26
|
+
| `timeout` | Request timeout (ms) | - |
|
|
27
|
+
| `contentType` | Response Content-Type | `application/json` |
|
|
28
|
+
| `cacheControl` | Cache-Control header setting | - |
|
|
29
|
+
| `compress` | Response compression setting (can disable with `false`) | - |
|
|
30
30
|
|
|
31
31
|
## clients Options
|
|
32
32
|
|
|
33
|
-
| Client
|
|
34
|
-
|
|
35
|
-
| `axios`
|
|
36
|
-
| `axios-multipart`
|
|
37
|
-
| `tanstack-query`
|
|
38
|
-
| `tanstack-mutation`
|
|
39
|
-
| `tanstack-mutation-multipart` | File upload Mutation
|
|
40
|
-
| `window-fetch`
|
|
33
|
+
| Client | Purpose |
|
|
34
|
+
| ----------------------------- | ------------------------ |
|
|
35
|
+
| `axios` | General API calls |
|
|
36
|
+
| `axios-multipart` | File upload (axios) |
|
|
37
|
+
| `tanstack-query` | Query hook for reads |
|
|
38
|
+
| `tanstack-mutation` | Mutation hook for writes |
|
|
39
|
+
| `tanstack-mutation-multipart` | File upload Mutation |
|
|
40
|
+
| `window-fetch` | Browser fetch API |
|
|
41
41
|
|
|
42
42
|
## Pattern Examples
|
|
43
43
|
|
|
@@ -81,16 +81,16 @@ async me(): Promise<User | null> {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
| Context Property | Description
|
|
85
|
-
|
|
86
|
-
| `user`
|
|
87
|
-
| `session`
|
|
88
|
-
| `request`
|
|
89
|
-
| `reply`
|
|
90
|
-
| `headers`
|
|
91
|
-
| `bufferedFiles`
|
|
92
|
-
| `uploadedFiles`
|
|
93
|
-
| `locale`
|
|
84
|
+
| Context Property | Description |
|
|
85
|
+
| ---------------- | ------------------------------------------------------------------- |
|
|
86
|
+
| `user` | Authenticated user (better-auth User, null if unauthenticated) |
|
|
87
|
+
| `session` | Current session info (better-auth Session, null if unauthenticated) |
|
|
88
|
+
| `request` | FastifyRequest |
|
|
89
|
+
| `reply` | FastifyReply |
|
|
90
|
+
| `headers` | HTTP request headers |
|
|
91
|
+
| `bufferedFiles` | Buffer mode uploaded files |
|
|
92
|
+
| `uploadedFiles` | Stream mode uploaded files |
|
|
93
|
+
| `locale` | Request locale |
|
|
94
94
|
|
|
95
95
|
## File Upload (@upload)
|
|
96
96
|
|
|
@@ -111,13 +111,13 @@ async upload(...): Promise<number[]> { }
|
|
|
111
111
|
|
|
112
112
|
**`@upload` supported options** (`httpMethod`, `clients` are not supported — set automatically)
|
|
113
113
|
|
|
114
|
-
| Option
|
|
115
|
-
|
|
116
|
-
| `guards`
|
|
117
|
-
| `limits`
|
|
118
|
-
| `consume`
|
|
119
|
-
| `description`
|
|
120
|
-
| `destination`
|
|
114
|
+
| Option | Description |
|
|
115
|
+
| -------------- | --------------------------------------------------- |
|
|
116
|
+
| `guards` | Authentication/authorization guards |
|
|
117
|
+
| `limits` | File count/size limits (`{ files: N }`) |
|
|
118
|
+
| `consume` | `"buffer"` (default) or `"stream"` |
|
|
119
|
+
| `description` | API documentation description |
|
|
120
|
+
| `destination` | Stream mode only: storage driver key |
|
|
121
121
|
| `keyGenerator` | Stream mode only: function to generate storage path |
|
|
122
122
|
|
|
123
123
|
### Parameter Rule: Must Wrap in a Single Object
|
|
@@ -135,11 +135,12 @@ async upload(params: { entity_type: string; entity_id: number; file_type: string
|
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
Call site pattern:
|
|
138
|
+
|
|
138
139
|
```typescript
|
|
139
140
|
uploadMutation.mutate({
|
|
140
141
|
params: { entity_type, entity_id, file_type },
|
|
141
142
|
files,
|
|
142
|
-
})
|
|
143
|
+
});
|
|
143
144
|
```
|
|
144
145
|
|
|
145
146
|
> For detailed root cause analysis, see the `@upload multiple parameters` section in `framework-change.md`.
|
|
@@ -187,7 +188,7 @@ async changeStatus(
|
|
|
187
188
|
memo?: string
|
|
188
189
|
): Promise<Consultation> {
|
|
189
190
|
const wdb = this.getPuri("w");
|
|
190
|
-
|
|
191
|
+
|
|
191
192
|
return wdb.transaction(async (trx) => {
|
|
192
193
|
// 1. Update consultation
|
|
193
194
|
await trx.ubRegister("consultations", {
|
|
@@ -196,7 +197,7 @@ async changeStatus(
|
|
|
196
197
|
updated_at: new Date()
|
|
197
198
|
});
|
|
198
199
|
await trx.ubUpsert("consultations");
|
|
199
|
-
|
|
200
|
+
|
|
200
201
|
// 2. Record status change history
|
|
201
202
|
await trx.ubRegister("consultation_histories", {
|
|
202
203
|
consultation_id: id,
|
|
@@ -205,7 +206,7 @@ async changeStatus(
|
|
|
205
206
|
created_at: new Date(),
|
|
206
207
|
});
|
|
207
208
|
await trx.ubUpsert("consultation_histories");
|
|
208
|
-
|
|
209
|
+
|
|
209
210
|
// 3. Return result
|
|
210
211
|
return this.findById("A", id);
|
|
211
212
|
});
|
|
@@ -213,6 +214,7 @@ async changeStatus(
|
|
|
213
214
|
```
|
|
214
215
|
|
|
215
216
|
**Key points:**
|
|
217
|
+
|
|
216
218
|
- Atomicity guaranteed by transaction
|
|
217
219
|
- ubRegister + ubUpsert pattern
|
|
218
220
|
- Return latest data after change
|
|
@@ -232,19 +234,19 @@ async enroll(
|
|
|
232
234
|
course_id: courseId,
|
|
233
235
|
user_id: userId,
|
|
234
236
|
});
|
|
235
|
-
|
|
237
|
+
|
|
236
238
|
if (existing) {
|
|
237
239
|
throw new Error("Already enrolled in this course");
|
|
238
240
|
}
|
|
239
|
-
|
|
241
|
+
|
|
240
242
|
// 2. Check capacity
|
|
241
243
|
const course = await CourseModel.findById("A", courseId);
|
|
242
244
|
const { total } = await this.findMany({ course_id: courseId });
|
|
243
|
-
|
|
245
|
+
|
|
244
246
|
if (total >= course.max_students) {
|
|
245
247
|
throw new Error("Course is at capacity");
|
|
246
248
|
}
|
|
247
|
-
|
|
249
|
+
|
|
248
250
|
// 3. Enroll
|
|
249
251
|
const [id] = await this.save([{ course_id: courseId, user_id: userId }]);
|
|
250
252
|
return this.findById("A", id);
|
|
@@ -252,6 +254,7 @@ async enroll(
|
|
|
252
254
|
```
|
|
253
255
|
|
|
254
256
|
**Key points:**
|
|
257
|
+
|
|
255
258
|
- Step-by-step validation (duplicate → capacity)
|
|
256
259
|
- Clear error messages
|
|
257
260
|
- Save after validation passes
|
|
@@ -286,34 +289,34 @@ Validating custom APIs in Business Logic tests:
|
|
|
286
289
|
describe("E. Business Logic", () => {
|
|
287
290
|
test("Status change API", async () => {
|
|
288
291
|
const { consultationId } = await createTestConsultationWithDeps();
|
|
289
|
-
|
|
292
|
+
|
|
290
293
|
// Call custom API
|
|
291
294
|
const updated = await ConsultationModel.changeStatus(
|
|
292
295
|
consultationId,
|
|
293
296
|
"completed",
|
|
294
|
-
"Consultation complete"
|
|
297
|
+
"Consultation complete",
|
|
295
298
|
);
|
|
296
|
-
|
|
299
|
+
|
|
297
300
|
expect(updated.status).toBe("completed");
|
|
298
|
-
|
|
301
|
+
|
|
299
302
|
// Verify history was recorded
|
|
300
303
|
const histories = await ConsultationHistoryModel.findMany({
|
|
301
304
|
consultation_id: consultationId,
|
|
302
305
|
});
|
|
303
306
|
expect(histories.rows).toHaveLength(1);
|
|
304
307
|
});
|
|
305
|
-
|
|
308
|
+
|
|
306
309
|
test("Enrollment validation", async () => {
|
|
307
310
|
const courseId = 1;
|
|
308
311
|
const userId = 1;
|
|
309
|
-
|
|
312
|
+
|
|
310
313
|
// First enrollment succeeds
|
|
311
314
|
await EnrollmentModel.enroll(courseId, userId);
|
|
312
|
-
|
|
315
|
+
|
|
313
316
|
// Duplicate enrollment fails
|
|
314
|
-
await expect(
|
|
315
|
-
|
|
316
|
-
)
|
|
317
|
+
await expect(EnrollmentModel.enroll(courseId, userId)).rejects.toThrow(
|
|
318
|
+
"Already enrolled in this course",
|
|
319
|
+
);
|
|
317
320
|
});
|
|
318
321
|
});
|
|
319
322
|
```
|
|
@@ -327,6 +330,7 @@ describe("E. Business Logic", () => {
|
|
|
327
330
|
Use `this.modelName` and the `SD()` function for consistent error messages.
|
|
328
331
|
|
|
329
332
|
**BAD: Hardcoded model name**
|
|
333
|
+
|
|
330
334
|
```typescript
|
|
331
335
|
// findById
|
|
332
336
|
if (!rows[0]) {
|
|
@@ -338,6 +342,7 @@ throw new BadRequestException(SD("error.unknownSearchField")(params.search));
|
|
|
338
342
|
```
|
|
339
343
|
|
|
340
344
|
**GOOD: Using this.modelName**
|
|
345
|
+
|
|
341
346
|
```typescript
|
|
342
347
|
// findById - auto-detects model name
|
|
343
348
|
if (!rows[0]) {
|
|
@@ -349,6 +354,7 @@ throw new BadRequestException(SD("search.invalidField")(params.search));
|
|
|
349
354
|
```
|
|
350
355
|
|
|
351
356
|
**Benefits:**
|
|
357
|
+
|
|
352
358
|
- DRY principle: model name managed in one place
|
|
353
359
|
- Refactoring safe: error messages auto-reflect model name changes
|
|
354
360
|
- Short i18n keys: `notFound`, `search.invalidField` are more concise
|
|
@@ -358,6 +364,7 @@ throw new BadRequestException(SD("search.invalidField")(params.search));
|
|
|
358
364
|
Use TypeScript's satisfies keyword to preserve type inference while checking types.
|
|
359
365
|
|
|
360
366
|
**BAD: Loss of type inference**
|
|
367
|
+
|
|
361
368
|
```typescript
|
|
362
369
|
const params: RoleListParams = {
|
|
363
370
|
num: 24,
|
|
@@ -369,6 +376,7 @@ const params: RoleListParams = {
|
|
|
369
376
|
```
|
|
370
377
|
|
|
371
378
|
**GOOD: Type check + preserved inference with satisfies**
|
|
379
|
+
|
|
372
380
|
```typescript
|
|
373
381
|
const params = {
|
|
374
382
|
num: 24,
|
|
@@ -380,6 +388,7 @@ const params = {
|
|
|
380
388
|
```
|
|
381
389
|
|
|
382
390
|
**Benefits:**
|
|
391
|
+
|
|
383
392
|
- Compile-time verification: checks that params satisfies the RoleListParams type
|
|
384
393
|
- Preserved type inference: params keeps its narrowed type
|
|
385
394
|
- Better IDE support: more accurate autocomplete and type checking
|
|
@@ -389,17 +398,19 @@ const params = {
|
|
|
389
398
|
The debug option in executeSubsetQuery defaults to false, so it does not need to be specified explicitly.
|
|
390
399
|
|
|
391
400
|
**BAD: Unnecessary debug: false**
|
|
401
|
+
|
|
392
402
|
```typescript
|
|
393
403
|
return this.executeSubsetQuery({
|
|
394
404
|
subset,
|
|
395
405
|
qb,
|
|
396
406
|
params,
|
|
397
407
|
enhancers,
|
|
398
|
-
debug: false,
|
|
408
|
+
debug: false, // unnecessary — it's the default
|
|
399
409
|
});
|
|
400
410
|
```
|
|
401
411
|
|
|
402
412
|
**GOOD: Use the default**
|
|
413
|
+
|
|
403
414
|
```typescript
|
|
404
415
|
return this.executeSubsetQuery({
|
|
405
416
|
subset,
|
|
@@ -410,13 +421,14 @@ return this.executeSubsetQuery({
|
|
|
410
421
|
```
|
|
411
422
|
|
|
412
423
|
**When to use debug: true:**
|
|
424
|
+
|
|
413
425
|
```typescript
|
|
414
426
|
// Only specify when debugging
|
|
415
427
|
return this.executeSubsetQuery({
|
|
416
428
|
subset,
|
|
417
429
|
qb,
|
|
418
430
|
params,
|
|
419
|
-
debug: true,
|
|
431
|
+
debug: true, // Print SQL query log
|
|
420
432
|
});
|
|
421
433
|
```
|
|
422
434
|
|
|
@@ -439,13 +451,13 @@ import { z } from "zod";
|
|
|
439
451
|
async processStream() { ... }
|
|
440
452
|
```
|
|
441
453
|
|
|
442
|
-
| Option
|
|
443
|
-
|
|
444
|
-
| `type`
|
|
445
|
-
| `events`
|
|
446
|
-
| `path`
|
|
447
|
-
| `resourceName` | Resource name
|
|
448
|
-
| `guards`
|
|
454
|
+
| Option | Description | Required |
|
|
455
|
+
| -------------- | ---------------------------------------------- | -------- |
|
|
456
|
+
| `type` | `"sse"` (only SSE currently supported) | Yes |
|
|
457
|
+
| `events` | Define event keys and payloads with Zod schema | Yes |
|
|
458
|
+
| `path` | Custom path | - |
|
|
459
|
+
| `resourceName` | Resource name | - |
|
|
460
|
+
| `guards` | Authentication/authorization guards | - |
|
|
449
461
|
|
|
450
462
|
## @transactional Decorator
|
|
451
463
|
|
|
@@ -460,8 +472,8 @@ async transferFunds(fromId: number, toId: number, amount: number) {
|
|
|
460
472
|
}
|
|
461
473
|
```
|
|
462
474
|
|
|
463
|
-
| Option
|
|
464
|
-
|
|
465
|
-
| `isolation` | Transaction isolation level (read uncommitted/read committed/repeatable read/serializable) | -
|
|
466
|
-
| `readOnly`
|
|
467
|
-
| `dbPreset`
|
|
475
|
+
| Option | Description | Default |
|
|
476
|
+
| ----------- | ------------------------------------------------------------------------------------------ | ------- |
|
|
477
|
+
| `isolation` | Transaction isolation level (read uncommitted/read committed/repeatable read/serializable) | - |
|
|
478
|
+
| `readOnly` | Read-only transaction | `false` |
|
|
479
|
+
| `dbPreset` | DB preset | `"w"` |
|
|
@@ -60,35 +60,23 @@ Correct order:
|
|
|
60
60
|
```typescript
|
|
61
61
|
export async function up(knex: Knex): Promise<void> {
|
|
62
62
|
// Step 1: Remove all FK constraints
|
|
63
|
-
await knex.raw(
|
|
64
|
-
|
|
65
|
-
);
|
|
66
|
-
await knex.raw(
|
|
67
|
-
'ALTER TABLE "sessions" DROP CONSTRAINT "sessions_user_id_foreign"',
|
|
68
|
-
);
|
|
63
|
+
await knex.raw('ALTER TABLE "accounts" DROP CONSTRAINT "accounts_user_id_foreign"');
|
|
64
|
+
await knex.raw('ALTER TABLE "sessions" DROP CONSTRAINT "sessions_user_id_foreign"');
|
|
69
65
|
await knex.raw(
|
|
70
66
|
'ALTER TABLE "evaluation_committees" DROP CONSTRAINT "evaluation_committees_evaluator_id_foreign"',
|
|
71
67
|
);
|
|
72
68
|
await knex.raw(
|
|
73
69
|
'ALTER TABLE "project_participants" DROP CONSTRAINT "project_participants_user_id_foreign"',
|
|
74
70
|
);
|
|
75
|
-
await knex.raw(
|
|
76
|
-
'ALTER TABLE "reports" DROP CONSTRAINT "reports_submitted_by_id_foreign"',
|
|
77
|
-
);
|
|
71
|
+
await knex.raw('ALTER TABLE "reports" DROP CONSTRAINT "reports_submitted_by_id_foreign"');
|
|
78
72
|
|
|
79
73
|
// Step 2: Remove PK constraint
|
|
80
74
|
await knex.raw('ALTER TABLE "users" DROP CONSTRAINT "users_pkey"');
|
|
81
75
|
|
|
82
76
|
// Step 3: Change all column types (parent PK + child FKs)
|
|
83
|
-
await knex.raw(
|
|
84
|
-
|
|
85
|
-
);
|
|
86
|
-
await knex.raw(
|
|
87
|
-
'ALTER TABLE "accounts" ALTER COLUMN "user_id" TYPE text USING "user_id"::text',
|
|
88
|
-
);
|
|
89
|
-
await knex.raw(
|
|
90
|
-
'ALTER TABLE "sessions" ALTER COLUMN "user_id" TYPE text USING "user_id"::text',
|
|
91
|
-
);
|
|
77
|
+
await knex.raw('ALTER TABLE "users" ALTER COLUMN "id" TYPE text USING "id"::text');
|
|
78
|
+
await knex.raw('ALTER TABLE "accounts" ALTER COLUMN "user_id" TYPE text USING "user_id"::text');
|
|
79
|
+
await knex.raw('ALTER TABLE "sessions" ALTER COLUMN "user_id" TYPE text USING "user_id"::text');
|
|
92
80
|
await knex.raw(
|
|
93
81
|
'ALTER TABLE "evaluation_committees" ALTER COLUMN "evaluator_id" TYPE text USING "evaluator_id"::text',
|
|
94
82
|
);
|
|
@@ -100,9 +88,7 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
100
88
|
);
|
|
101
89
|
|
|
102
90
|
// Step 4: Restore PK constraint
|
|
103
|
-
await knex.raw(
|
|
104
|
-
'ALTER TABLE "users" ADD CONSTRAINT "users_pkey" PRIMARY KEY ("id")',
|
|
105
|
-
);
|
|
91
|
+
await knex.raw('ALTER TABLE "users" ADD CONSTRAINT "users_pkey" PRIMARY KEY ("id")');
|
|
106
92
|
|
|
107
93
|
// Step 5: Restore FK constraints
|
|
108
94
|
await knex.raw(
|
|
@@ -382,12 +368,12 @@ In Sonamu Entity, use the DB column name (snake_case) as-is:
|
|
|
382
368
|
|
|
383
369
|
#### Plugin Categories
|
|
384
370
|
|
|
385
|
-
| Category
|
|
386
|
-
|
|
|
387
|
-
| Basic auth
|
|
388
|
-
| User extension | username, phone number, admin, anonymous
|
|
389
|
-
| Security
|
|
390
|
-
| Enterprise
|
|
371
|
+
| Category | Plugins | Impact |
|
|
372
|
+
| -------------- | ----------------------------------------------------------- | ---------------------------------------------- |
|
|
373
|
+
| Basic auth | email/password, OAuth, magic link, email OTP, multi-session | User/Session/Account/Verification tables |
|
|
374
|
+
| User extension | username, phone number, admin, anonymous | Adds fields to User table |
|
|
375
|
+
| Security | two-factor, passkey | New tables needed (TwoFactor, Passkey) |
|
|
376
|
+
| Enterprise | organization, API key, SSO, JWT | New tables needed (Organization, Member, etc.) |
|
|
391
377
|
|
|
392
378
|
#### Classification by Schema Requirements
|
|
393
379
|
|
|
@@ -9,6 +9,7 @@ Sonamu wraps better-auth plugins with snake_case schema mapping.
|
|
|
9
9
|
Use the `auth generate --plugins` command to auto-generate plugin entities.
|
|
10
10
|
|
|
11
11
|
**Source code:**
|
|
12
|
+
|
|
12
13
|
- Wrappers: `modules/sonamu/src/auth/plugins/wrappers/`
|
|
13
14
|
- Entity definitions: `modules/sonamu/src/auth/plugins/entity-definitions/`
|
|
14
15
|
- Generator: `modules/sonamu/src/auth/auth-generator.ts`
|
|
@@ -17,18 +18,18 @@ Use the `auth generate --plugins` command to auto-generate plugin entities.
|
|
|
17
18
|
|
|
18
19
|
## Supported Plugins
|
|
19
20
|
|
|
20
|
-
| Plugin ID
|
|
21
|
-
|
|
22
|
-
| `admin`
|
|
23
|
-
| `organization` | `organization()` | `better-auth/plugins`
|
|
24
|
-
| `2fa`
|
|
25
|
-
| `username`
|
|
26
|
-
| `phone-number` | `phoneNumber()`
|
|
27
|
-
| `api-key`
|
|
28
|
-
| `jwt`
|
|
29
|
-
| `passkey`
|
|
30
|
-
| `sso`
|
|
31
|
-
| `anonymous`
|
|
21
|
+
| Plugin ID | Wrapper function | Package | Purpose |
|
|
22
|
+
| -------------- | ---------------- | ---------------------- | ----------------------------------------------------- |
|
|
23
|
+
| `admin` | `admin()` | `better-auth/plugins` | Admin features, user ban/unban, session impersonation |
|
|
24
|
+
| `organization` | `organization()` | `better-auth/plugins` | Organization, team, member, and invitation management |
|
|
25
|
+
| `2fa` | `twoFactor()` | `better-auth/plugins` | TOTP-based two-factor authentication |
|
|
26
|
+
| `username` | `username()` | `better-auth/plugins` | Username-based authentication |
|
|
27
|
+
| `phone-number` | `phoneNumber()` | `better-auth/plugins` | Phone number authentication |
|
|
28
|
+
| `api-key` | `apiKey()` | `better-auth/plugins` | API key issuance/management, rate limiting |
|
|
29
|
+
| `jwt` | `jwt()` | `better-auth/plugins` | JWT tokens + JWKS key management |
|
|
30
|
+
| `passkey` | `passkey()` | `@better-auth/passkey` | WebAuthn/Passkey authentication |
|
|
31
|
+
| `sso` | `sso()` | `@better-auth/sso` | OIDC/SAML SSO integration |
|
|
32
|
+
| `anonymous` | `anonymous()` | `better-auth/plugins` | Anonymous user support |
|
|
32
33
|
|
|
33
34
|
---
|
|
34
35
|
|
|
@@ -68,12 +69,7 @@ export default defineConfig({
|
|
|
68
69
|
server: {
|
|
69
70
|
auth: {
|
|
70
71
|
emailAndPassword: { enabled: true },
|
|
71
|
-
plugins: [
|
|
72
|
-
admin(),
|
|
73
|
-
organization(),
|
|
74
|
-
twoFactor(),
|
|
75
|
-
username(),
|
|
76
|
-
],
|
|
72
|
+
plugins: [admin(), organization(), twoFactor(), username()],
|
|
77
73
|
},
|
|
78
74
|
},
|
|
79
75
|
});
|
|
@@ -103,13 +99,14 @@ import { admin } from "sonamu/auth/plugins";
|
|
|
103
99
|
import { admin } from "sonamu/auth/plugins";
|
|
104
100
|
|
|
105
101
|
// Basic usage
|
|
106
|
-
admin()
|
|
102
|
+
admin();
|
|
107
103
|
|
|
108
104
|
// Customize options (schema mapping is automatically merged)
|
|
109
|
-
admin({ defaultRole: "user" })
|
|
105
|
+
admin({ defaultRole: "user" });
|
|
110
106
|
```
|
|
111
107
|
|
|
112
108
|
Schema mapping:
|
|
109
|
+
|
|
113
110
|
- `banReason` → `ban_reason`
|
|
114
111
|
- `banExpires` → `ban_expires`
|
|
115
112
|
- `impersonatedBy` → `impersonated_by`
|
|
@@ -122,10 +119,11 @@ Schema mapping:
|
|
|
122
119
|
```typescript
|
|
123
120
|
import { organization } from "sonamu/auth/plugins";
|
|
124
121
|
|
|
125
|
-
organization()
|
|
122
|
+
organization();
|
|
126
123
|
```
|
|
127
124
|
|
|
128
125
|
Schema mapping:
|
|
126
|
+
|
|
129
127
|
- All tables: `createdAt` → `created_at`
|
|
130
128
|
- Member: `userId` → `user_id`, `organizationId` → `organization_id`
|
|
131
129
|
- Invitation: `inviterId` → `inviter_id`, `organizationId` → `organization_id`, `teamId` → `team_id`, `expiresAt` → `expires_at`
|
|
@@ -141,10 +139,11 @@ Schema mapping:
|
|
|
141
139
|
```typescript
|
|
142
140
|
import { twoFactor } from "sonamu/auth/plugins";
|
|
143
141
|
|
|
144
|
-
twoFactor()
|
|
142
|
+
twoFactor();
|
|
145
143
|
```
|
|
146
144
|
|
|
147
145
|
Schema mapping:
|
|
146
|
+
|
|
148
147
|
- User: `twoFactorEnabled` → `two_factor_enabled`
|
|
149
148
|
- TwoFactor: `userId` → `user_id`, `backupCodes` → `backup_codes`
|
|
150
149
|
|
|
@@ -155,10 +154,11 @@ Schema mapping:
|
|
|
155
154
|
```typescript
|
|
156
155
|
import { username } from "sonamu/auth/plugins";
|
|
157
156
|
|
|
158
|
-
username()
|
|
157
|
+
username();
|
|
159
158
|
```
|
|
160
159
|
|
|
161
160
|
Schema mapping:
|
|
161
|
+
|
|
162
162
|
- `displayUsername` → `display_username`
|
|
163
163
|
|
|
164
164
|
### phone-number
|
|
@@ -168,10 +168,15 @@ Schema mapping:
|
|
|
168
168
|
```typescript
|
|
169
169
|
import { phoneNumber } from "sonamu/auth/plugins";
|
|
170
170
|
|
|
171
|
-
phoneNumber({
|
|
171
|
+
phoneNumber({
|
|
172
|
+
sendOTP: async ({ phoneNumber, otp }) => {
|
|
173
|
+
/* send SMS */
|
|
174
|
+
},
|
|
175
|
+
});
|
|
172
176
|
```
|
|
173
177
|
|
|
174
178
|
Schema mapping:
|
|
179
|
+
|
|
175
180
|
- `phoneNumber` → `phone_number`
|
|
176
181
|
- `phoneNumberVerified` → `phone_number_verified`
|
|
177
182
|
|
|
@@ -182,10 +187,11 @@ Schema mapping:
|
|
|
182
187
|
```typescript
|
|
183
188
|
import { apiKey } from "sonamu/auth/plugins";
|
|
184
189
|
|
|
185
|
-
apiKey()
|
|
190
|
+
apiKey();
|
|
186
191
|
```
|
|
187
192
|
|
|
188
193
|
Schema mapping:
|
|
194
|
+
|
|
189
195
|
- `userId` → `user_id`, `lastRequest` → `last_request`, `requestCount` → `request_count`
|
|
190
196
|
- `rateLimitEnabled` → `rate_limit_enabled`, `rateLimitTimeWindow` → `rate_limit_time_window`
|
|
191
197
|
- `rateLimitMax` → `rate_limit_max`, `refillInterval` → `refill_interval`
|
|
@@ -199,10 +205,11 @@ Schema mapping:
|
|
|
199
205
|
```typescript
|
|
200
206
|
import { jwt } from "sonamu/auth/plugins";
|
|
201
207
|
|
|
202
|
-
jwt()
|
|
208
|
+
jwt();
|
|
203
209
|
```
|
|
204
210
|
|
|
205
211
|
Schema mapping:
|
|
212
|
+
|
|
206
213
|
- `publicKey` → `public_key`, `privateKey` → `private_key`
|
|
207
214
|
- `createdAt` → `created_at`, `expiresAt` → `expires_at`
|
|
208
215
|
|
|
@@ -218,10 +225,11 @@ pnpm add @better-auth/passkey
|
|
|
218
225
|
```typescript
|
|
219
226
|
import { passkey } from "sonamu/auth/plugins";
|
|
220
227
|
|
|
221
|
-
passkey({ rpID: "localhost", rpName: "My App" })
|
|
228
|
+
passkey({ rpID: "localhost", rpName: "My App" });
|
|
222
229
|
```
|
|
223
230
|
|
|
224
231
|
Schema mapping:
|
|
232
|
+
|
|
225
233
|
- `publicKey` → `public_key`, `userId` → `user_id`, `credentialID` → `credential_id`
|
|
226
234
|
- `deviceType` → `device_type`, `backedUp` → `backed_up`, `createdAt` → `created_at`
|
|
227
235
|
|
|
@@ -236,11 +244,12 @@ pnpm add @better-auth/sso
|
|
|
236
244
|
```typescript
|
|
237
245
|
import { sso } from "sonamu/auth/plugins";
|
|
238
246
|
|
|
239
|
-
sso()
|
|
247
|
+
sso();
|
|
240
248
|
```
|
|
241
249
|
|
|
242
250
|
Table: `sso_providers`
|
|
243
251
|
Schema mapping:
|
|
252
|
+
|
|
244
253
|
- `oidcConfig` → `oidc_config`, `samlConfig` → `saml_config`
|
|
245
254
|
- `userId` → `user_id`, `providerId` → `provider_id`, `organizationId` → `organization_id`
|
|
246
255
|
|
|
@@ -251,10 +260,11 @@ Schema mapping:
|
|
|
251
260
|
```typescript
|
|
252
261
|
import { anonymous } from "sonamu/auth/plugins";
|
|
253
262
|
|
|
254
|
-
anonymous()
|
|
263
|
+
anonymous();
|
|
255
264
|
```
|
|
256
265
|
|
|
257
266
|
Schema mapping:
|
|
267
|
+
|
|
258
268
|
- `isAnonymous` → `is_anonymous`
|
|
259
269
|
|
|
260
270
|
---
|
|
@@ -269,11 +279,11 @@ admin({
|
|
|
269
279
|
schema: {
|
|
270
280
|
user: {
|
|
271
281
|
fields: {
|
|
272
|
-
customField: "custom_field",
|
|
282
|
+
customField: "custom_field", // additional mapping
|
|
273
283
|
},
|
|
274
284
|
},
|
|
275
285
|
},
|
|
276
|
-
})
|
|
286
|
+
});
|
|
277
287
|
```
|
|
278
288
|
|
|
279
289
|
Internally, `merge(ADMIN_SCHEMA, options.schema)` is executed to preserve the Sonamu mapping.
|