sonamu 0.10.11 → 0.10.13
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/dist/ai/agents/agent.d.ts +1 -1
- package/dist/ai/agents/agent.d.ts.map +1 -1
- package/dist/ai/agents/agent.js +5 -6
- package/dist/ai/agents/types.d.ts +1 -1
- package/dist/ai/agents/types.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/api.js +18 -18
- package/dist/ai/providers/rtzr/error.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/error.js +17 -15
- package/dist/ai/providers/rtzr/model.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/model.js +3 -2
- package/dist/ai/providers/rtzr/options.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/options.js +16 -16
- package/dist/ai/providers/rtzr/provider.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/provider.js +9 -9
- package/dist/ai/providers/rtzr/utils.d.ts.map +1 -1
- package/dist/ai/providers/rtzr/utils.js +1 -1
- package/dist/api/caster.d.ts.map +1 -1
- package/dist/api/caster.js +17 -17
- package/dist/api/code-converters.d.ts +4 -2
- package/dist/api/code-converters.d.ts.map +1 -1
- package/dist/api/code-converters.js +100 -19
- package/dist/api/config.d.ts +16 -1
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +28 -21
- package/dist/api/context.d.ts +2 -2
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +1 -1
- package/dist/api/decorators.d.ts.map +1 -1
- package/dist/api/decorators.js +18 -11
- package/dist/api/http-validator.d.ts +36 -0
- package/dist/api/http-validator.d.ts.map +1 -0
- package/dist/api/http-validator.js +72 -0
- package/dist/api/index.js +6 -4
- package/dist/api/sonamu.d.ts +59 -20
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +250 -106
- package/dist/api/websocket-helpers.d.ts +7 -5
- package/dist/api/websocket-helpers.d.ts.map +1 -1
- package/dist/api/websocket-helpers.js +6 -6
- package/dist/auth/audit-log/builders.d.ts.map +1 -1
- package/dist/auth/audit-log/builders.js +1 -1
- package/dist/auth/audit-log/client-ip.d.ts +1 -1
- package/dist/auth/audit-log/client-ip.d.ts.map +1 -1
- package/dist/auth/audit-log/client-ip.js +4 -2
- package/dist/auth/audit-log/events.d.ts +5 -1
- package/dist/auth/audit-log/events.d.ts.map +1 -1
- package/dist/auth/audit-log/events.js +1 -1
- package/dist/auth/audit-log/plugin.d.ts +0 -8
- package/dist/auth/audit-log/plugin.d.ts.map +1 -1
- package/dist/auth/audit-log/plugin.js +48 -52
- package/dist/auth/audit-log-ingestor.d.ts.map +1 -1
- package/dist/auth/audit-log-ingestor.js +16 -12
- package/dist/auth/auth-generator.d.ts.map +1 -1
- package/dist/auth/auth-generator.js +1 -1
- package/dist/auth/better-auth-request.d.ts.map +1 -1
- package/dist/auth/better-auth-request.js +6 -5
- package/dist/auth/knex-adapter.js +1 -1
- package/dist/auth/plugins/entity-definitions/index.d.ts +13 -1
- package/dist/auth/plugins/entity-definitions/index.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/index.js +1 -1
- package/dist/auth/plugins/wrappers/admin.d.ts +1 -1
- package/dist/bin/build-config.d.ts +25 -0
- package/dist/bin/build-config.d.ts.map +1 -1
- package/dist/bin/build-config.js +105 -2
- package/dist/bin/cli.js +133 -29
- package/dist/bin/compiler-policy.d.ts +3 -0
- package/dist/bin/compiler-policy.d.ts.map +1 -0
- package/dist/bin/compiler-policy.js +24 -0
- package/dist/bin/fixture.d.ts.map +1 -1
- package/dist/bin/fixture.js +5 -3
- package/dist/bin/test-command.d.ts +22 -1
- package/dist/bin/test-command.d.ts.map +1 -1
- package/dist/bin/test-command.js +18 -10
- package/dist/bin/ts-loader-registration.d.ts +7 -1
- package/dist/bin/ts-loader-registration.d.ts.map +1 -1
- package/dist/bin/ts-loader-registration.js +13 -4
- package/dist/cache/decorator.d.ts.map +1 -1
- package/dist/cache/decorator.js +11 -4
- package/dist/compress/compress.d.ts.map +1 -1
- package/dist/compress/compress.js +1 -1
- package/dist/cone/cone-generator.d.ts +14 -1
- package/dist/cone/cone-generator.d.ts.map +1 -1
- package/dist/cone/cone-generator.js +13 -9
- package/dist/database/_batch_update.js +1 -1
- package/dist/database/base-model.d.ts +22 -10
- package/dist/database/base-model.d.ts.map +1 -1
- package/dist/database/base-model.js +26 -16
- package/dist/database/base-model.types.d.ts +15 -3
- package/dist/database/base-model.types.d.ts.map +1 -1
- package/dist/database/db.d.ts +12 -2
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +10 -7
- package/dist/database/knex.d.ts.map +1 -1
- package/dist/database/knex.js +17 -14
- package/dist/database/puri.d.ts +11 -9
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +93 -79
- package/dist/database/puri.types.d.ts +21 -21
- package/dist/database/puri.types.d.ts.map +1 -1
- package/dist/database/puri.types.js +1 -1
- package/dist/database/upsert-builder.d.ts +12 -10
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +20 -12
- package/dist/dict/sd.d.ts.map +1 -1
- package/dist/dict/sd.js +1 -1
- package/dist/dict/sonamu-dictionary.d.ts.map +1 -1
- package/dist/dict/sonamu-dictionary.js +1 -1
- package/dist/dict/utils.d.ts.map +1 -1
- package/dist/dict/utils.js +7 -2
- package/dist/entity/entity-manager.d.ts +13 -4
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +19 -11
- package/dist/entity/entity-template-cone.d.ts +73 -5
- package/dist/entity/entity-template-cone.d.ts.map +1 -1
- package/dist/entity/entity-template-cone.js +4 -2
- package/dist/entity/entity.d.ts +6 -2
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +30 -28
- package/dist/env.d.ts +3 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +1 -1
- package/dist/exceptions/error-handler.d.ts.map +1 -1
- package/dist/exceptions/error-handler.js +7 -2
- package/dist/exceptions/so-exceptions.d.ts +24 -20
- package/dist/exceptions/so-exceptions.d.ts.map +1 -1
- package/dist/exceptions/so-exceptions.js +4 -2
- package/dist/filter/utils.d.ts +7 -2
- package/dist/filter/utils.d.ts.map +1 -1
- package/dist/filter/utils.js +8 -6
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -7
- package/dist/logger/configure.d.ts.map +1 -1
- package/dist/logger/configure.js +10 -10
- package/dist/migration/code-generation.d.ts.map +1 -1
- package/dist/migration/code-generation.js +50 -46
- package/dist/migration/index-where-predicate.d.ts.map +1 -1
- package/dist/migration/index-where-predicate.js +22 -8
- package/dist/migration/migration-set.d.ts.map +1 -1
- package/dist/migration/migration-set.js +1 -1
- package/dist/migration/migrator.d.ts +61 -36
- package/dist/migration/migrator.d.ts.map +1 -1
- package/dist/migration/migrator.js +276 -167
- package/dist/migration/postgresql-schema-reader.d.ts.map +1 -1
- package/dist/migration/postgresql-schema-reader.js +51 -36
- package/dist/migration/slack-confirm.d.ts.map +1 -1
- package/dist/migration/slack-confirm.js +1 -1
- package/dist/migration/types.d.ts +54 -0
- package/dist/migration/types.d.ts.map +1 -1
- package/dist/naite/naite-reporter.js +2 -2
- package/dist/naite/naite.d.ts +74 -15
- package/dist/naite/naite.d.ts.map +1 -1
- package/dist/naite/naite.js +5 -19
- package/dist/runtime-type.d.ts +6 -0
- package/dist/runtime-type.d.ts.map +1 -0
- package/dist/runtime-type.js +26 -0
- package/dist/ssr/hmr-opt-out.d.ts +26 -0
- package/dist/ssr/hmr-opt-out.d.ts.map +1 -0
- package/dist/ssr/hmr-opt-out.js +59 -0
- package/dist/ssr/renderer.d.ts.map +1 -1
- package/dist/ssr/renderer.js +4 -1
- package/dist/storage/base-file.js +14 -14
- 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 +12 -12
- package/dist/storage/s3-driver.d.ts.map +1 -1
- package/dist/storage/s3-driver.js +1 -1
- package/dist/storage/uploaded-file.d.ts +2 -2
- package/dist/storage/uploaded-file.d.ts.map +1 -1
- package/dist/storage/uploaded-file.js +8 -8
- package/dist/stream/sse.js +11 -11
- package/dist/stream/ws-core.d.ts +1 -1
- package/dist/stream/ws-core.d.ts.map +1 -1
- package/dist/stream/ws-delivery.d.ts +1 -1
- package/dist/stream/ws-delivery.d.ts.map +1 -1
- package/dist/stream/ws-delivery.js +6 -4
- package/dist/stream/ws-local-connection-store.d.ts.map +1 -1
- package/dist/stream/ws-local-connection-store.js +4 -2
- package/dist/stream/ws-presence-store.js +1 -1
- package/dist/stream/ws-registry.d.ts +4 -4
- package/dist/stream/ws-registry.d.ts.map +1 -1
- package/dist/stream/ws-registry.js +4 -2
- package/dist/stream/ws-telemetry.d.ts +16 -12
- package/dist/stream/ws-telemetry.d.ts.map +1 -1
- package/dist/stream/ws-telemetry.js +22 -18
- package/dist/stream/ws.d.ts +18 -12
- package/dist/stream/ws.d.ts.map +1 -1
- package/dist/stream/ws.js +26 -22
- package/dist/syncer/api-parser.js +1 -1
- package/dist/syncer/checksum.d.ts.map +1 -1
- package/dist/syncer/checksum.js +7 -8
- package/dist/syncer/code-generator.d.ts.map +1 -1
- package/dist/syncer/code-generator.js +13 -14
- package/dist/syncer/entity-operations.d.ts.map +1 -1
- package/dist/syncer/entity-operations.js +5 -6
- package/dist/syncer/file-copy.d.ts +5 -0
- package/dist/syncer/file-copy.d.ts.map +1 -0
- package/dist/syncer/file-copy.js +36 -0
- package/dist/syncer/file-patterns.d.ts +1 -0
- package/dist/syncer/file-patterns.d.ts.map +1 -1
- package/dist/syncer/file-patterns.js +5 -2
- package/dist/syncer/file-tracking.d.ts.map +1 -1
- package/dist/syncer/file-tracking.js +5 -4
- package/dist/syncer/filesystem-dependencies.d.ts +15 -0
- package/dist/syncer/filesystem-dependencies.d.ts.map +1 -0
- package/dist/syncer/filesystem-dependencies.js +53 -0
- package/dist/syncer/module-loader.d.ts +1 -1
- package/dist/syncer/module-loader.d.ts.map +1 -1
- package/dist/syncer/module-loader.js +6 -4
- package/dist/syncer/syncer-actions.d.ts +4 -0
- package/dist/syncer/syncer-actions.d.ts.map +1 -1
- package/dist/syncer/syncer-actions.js +34 -17
- package/dist/syncer/syncer.d.ts +17 -6
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +71 -29
- package/dist/syncer/watcher.d.ts.map +1 -1
- package/dist/syncer/watcher.js +3 -3
- package/dist/tasks/decorator.d.ts +6 -6
- package/dist/tasks/decorator.d.ts.map +1 -1
- package/dist/tasks/decorator.js +4 -4
- package/dist/tasks/step-wrapper.d.ts +6 -4
- package/dist/tasks/step-wrapper.d.ts.map +1 -1
- package/dist/tasks/step-wrapper.js +5 -5
- package/dist/tasks/workflow-manager.d.ts.map +1 -1
- package/dist/tasks/workflow-manager.js +13 -7
- 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 +2 -2
- package/dist/template/helpers.d.ts +8 -6
- package/dist/template/helpers.d.ts.map +1 -1
- package/dist/template/helpers.js +1 -1
- package/dist/template/implementations/generated.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.js +4 -4
- package/dist/template/implementations/generated_http.template.d.ts +7 -4
- package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_http.template.js +21 -21
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_sso.template.js +6 -3
- package/dist/template/implementations/http_validators.template.d.ts +18 -0
- package/dist/template/implementations/http_validators.template.d.ts.map +1 -0
- package/dist/template/implementations/http_validators.template.js +127 -0
- package/dist/template/implementations/model.template.d.ts.map +1 -1
- package/dist/template/implementations/model.template.js +1 -1
- package/dist/template/implementations/queries.template.js +1 -1
- package/dist/template/implementations/sd.template.d.ts.map +1 -1
- package/dist/template/implementations/sd.template.js +79 -39
- package/dist/template/implementations/services.template.d.ts.map +1 -1
- package/dist/template/implementations/services.template.js +6 -4
- package/dist/template/implementations/view_form.template.d.ts +6 -1
- package/dist/template/implementations/view_form.template.d.ts.map +1 -1
- package/dist/template/implementations/view_form.template.js +23 -15
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +11 -6
- package/dist/template/template-manager.d.ts.map +1 -1
- package/dist/template/template-manager.js +9 -7
- package/dist/template/template-types.d.ts +12 -5
- package/dist/template/template-types.d.ts.map +1 -1
- package/dist/template/template-types.js +1 -1
- package/dist/template/template.d.ts +2 -2
- package/dist/template/template.d.ts.map +1 -1
- package/dist/template/template.js +6 -4
- package/dist/template/zod-converter.d.ts +0 -19
- package/dist/template/zod-converter.d.ts.map +1 -1
- package/dist/template/zod-converter.js +100 -84
- package/dist/testing/_relation-graph.d.ts.map +1 -1
- package/dist/testing/_relation-graph.js +2 -1
- package/dist/testing/bootstrap.d.ts.map +1 -1
- package/dist/testing/bootstrap.js +9 -6
- package/dist/testing/data-explorer.d.ts +32 -7
- package/dist/testing/data-explorer.d.ts.map +1 -1
- package/dist/testing/data-explorer.js +77 -31
- package/dist/testing/dev-test-routes.d.ts +8 -1
- package/dist/testing/dev-test-routes.d.ts.map +1 -1
- package/dist/testing/dev-test-routes.js +125 -108
- package/dist/testing/dev-vitest-manager.d.ts +54 -8
- package/dist/testing/dev-vitest-manager.d.ts.map +1 -1
- package/dist/testing/dev-vitest-manager.js +24 -9
- package/dist/testing/faker-mappings.d.ts +412 -1
- package/dist/testing/faker-mappings.d.ts.map +1 -1
- package/dist/testing/faker-mappings.js +1 -1
- package/dist/testing/filesystem.d.ts +2 -0
- package/dist/testing/filesystem.d.ts.map +1 -0
- package/dist/testing/filesystem.js +7 -0
- package/dist/testing/fixture-generator.d.ts +25 -8
- package/dist/testing/fixture-generator.d.ts.map +1 -1
- package/dist/testing/fixture-generator.js +132 -73
- package/dist/testing/fixture-loader.d.ts +3 -1
- package/dist/testing/fixture-loader.d.ts.map +1 -1
- package/dist/testing/fixture-loader.js +1 -20
- package/dist/testing/fixture-manager.d.ts +8 -7
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +91 -59
- package/dist/testing/global-setup.d.ts.map +1 -1
- package/dist/testing/global-setup.js +5 -2
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +6 -3
- package/dist/types/types.d.ts +101 -99
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +234 -225
- package/dist/ui/ai-api.d.ts.map +1 -1
- package/dist/ui/ai-api.js +1 -1
- package/dist/ui/ai-client.d.ts.map +1 -1
- package/dist/ui/ai-client.js +28 -18
- package/dist/ui/api.d.ts.map +1 -1
- package/dist/ui/api.js +146 -210
- package/dist/ui/async-route.d.ts +3 -0
- package/dist/ui/async-route.d.ts.map +1 -0
- package/dist/ui/async-route.js +12 -0
- package/dist/ui/cdd-service.d.ts +9 -7
- package/dist/ui/cdd-service.d.ts.map +1 -1
- package/dist/ui/cdd-service.js +7 -5
- package/dist/ui/migrations-api.d.ts +3 -0
- package/dist/ui/migrations-api.d.ts.map +1 -0
- package/dist/ui/migrations-api.js +215 -0
- package/dist/ui-web/assets/index-D3QNH-Dv.css +1 -0
- package/dist/ui-web/assets/index-DV1AAq6W.js +178 -0
- package/dist/ui-web/index.html +2 -2
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +7 -5
- package/dist/utils/fs-utils.d.ts +3 -3
- package/dist/utils/fs-utils.d.ts.map +1 -1
- package/dist/utils/fs-utils.js +6 -6
- package/dist/utils/model.d.ts +3 -5
- package/dist/utils/model.d.ts.map +1 -1
- package/dist/utils/model.js +1 -1
- package/dist/utils/object-utils.d.ts +1 -1
- package/dist/utils/object-utils.d.ts.map +1 -1
- package/dist/utils/object-utils.js +17 -16
- package/dist/utils/process-utils.d.ts.map +1 -1
- package/dist/utils/process-utils.js +4 -2
- package/dist/utils/runtime-value.d.ts +13 -0
- package/dist/utils/runtime-value.d.ts.map +1 -0
- package/dist/utils/runtime-value.js +40 -0
- package/dist/utils/sql-parser.d.ts +8 -1
- package/dist/utils/sql-parser.d.ts.map +1 -1
- package/dist/utils/sql-parser.js +6 -3
- package/dist/utils/type-utils.d.ts.map +1 -1
- package/dist/utils/type-utils.js +10 -8
- package/dist/utils/utils.d.ts +2 -2
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +11 -8
- package/dist/utils/zod-error.d.ts.map +1 -1
- package/dist/utils/zod-error.js +7 -4
- package/dist/vector/chunking.d.ts.map +1 -1
- package/dist/vector/chunking.js +1 -1
- package/dist/vector/embedding.d.ts.map +1 -1
- package/dist/vector/embedding.js +1 -1
- package/dist/vector/types.d.ts +3 -2
- package/dist/vector/types.d.ts.map +1 -1
- package/package.json +11 -7
- package/src/ai/agents/agent.ts +5 -5
- package/src/ai/agents/types.ts +1 -1
- package/src/ai/providers/rtzr/__tests__/model.test.ts +2 -2
- package/src/ai/providers/rtzr/error.ts +5 -3
- package/src/ai/providers/rtzr/model.ts +3 -2
- package/src/ai/providers/rtzr/options.ts +10 -5
- package/src/ai/providers/rtzr/provider.ts +10 -10
- package/src/ai/providers/rtzr/utils.ts +3 -1
- package/src/api/__tests__/config.test.ts +11 -21
- package/src/api/__tests__/sonamu.http-validator.test.ts +512 -0
- package/src/api/__tests__/sonamu.websocket.test.ts +51 -41
- package/src/api/__tests__/zod-compiler-policy.test.ts +95 -0
- package/src/api/caster.ts +6 -8
- package/src/api/code-converters.ts +136 -36
- package/src/api/config.ts +62 -4
- package/src/api/context.ts +3 -3
- package/src/api/decorators.ts +28 -17
- package/src/api/http-validator.ts +149 -0
- package/src/api/sonamu.ts +459 -152
- package/src/api/websocket-helpers.ts +24 -17
- package/src/auth/audit-log/builders.ts +3 -2
- package/src/auth/audit-log/client-ip.ts +4 -2
- package/src/auth/audit-log/events.ts +15 -1
- package/src/auth/audit-log/plugin.ts +129 -200
- package/src/auth/audit-log-ingestor.ts +19 -15
- package/src/auth/auth-generator.ts +10 -5
- package/src/auth/better-auth-request.ts +4 -3
- package/src/auth/knex-adapter.ts +8 -2
- package/src/auth/plugins/entity-definitions/index.ts +6 -5
- package/src/bin/__tests__/http-validator-benchmark.test.ts +94 -0
- package/src/bin/__tests__/test-command.test.ts +9 -15
- package/src/bin/__tests__/ts-loader-register.test.ts +15 -17
- package/src/bin/__tests__/zod-compiler-build.test.ts +307 -0
- package/src/bin/build-config.ts +167 -0
- package/src/bin/cli.ts +155 -38
- package/src/bin/compiler-policy.ts +35 -0
- package/src/bin/fixture.ts +14 -3
- package/src/bin/test-command.ts +74 -29
- package/src/bin/ts-loader-registration.ts +22 -4
- package/src/cache/decorator.ts +10 -3
- package/src/compress/compress.ts +17 -4
- package/src/cone/cone-generator.ts +34 -6
- package/src/database/__tests__/db.test.ts +1 -0
- package/src/database/__tests__/puri.test.ts +16 -15
- package/src/database/__tests__/transaction-scope.test.ts +5 -0
- package/src/database/_batch_update.ts +1 -0
- package/src/database/base-model.ts +81 -50
- package/src/database/base-model.types.ts +6 -6
- package/src/database/db.ts +29 -19
- package/src/database/knex.ts +30 -17
- package/src/database/puri-subset.test-d.ts +17 -0
- package/src/database/puri.ts +181 -143
- package/src/database/puri.types.test-d.ts +31 -1
- package/src/database/puri.types.ts +23 -21
- package/src/database/upsert-builder.ts +75 -53
- package/src/dict/sd.ts +15 -5
- package/src/dict/sonamu-dictionary.ts +6 -6
- package/src/dict/utils.ts +9 -1
- package/src/entity/entity-manager.ts +26 -9
- package/src/entity/entity-template-cone.ts +5 -10
- package/src/entity/entity.ts +50 -34
- package/src/env.ts +7 -3
- package/src/exceptions/error-handler.ts +17 -2
- package/src/exceptions/so-exceptions.ts +26 -20
- package/src/filter/utils.ts +21 -11
- package/src/index.ts +3 -0
- package/src/logger/configure.ts +26 -18
- package/src/migration/__tests__/migrator.test.ts +50 -57
- package/src/migration/code-generation.ts +132 -104
- package/src/migration/index-where-predicate.ts +51 -24
- package/src/migration/migration-set.ts +11 -5
- package/src/migration/migrator.ts +392 -244
- package/src/migration/postgresql-schema-reader.ts +52 -47
- package/src/migration/slack-confirm.ts +17 -15
- package/src/migration/types.ts +57 -0
- package/src/naite/naite-reporter.ts +1 -1
- package/src/naite/naite.ts +97 -24
- package/src/runtime-type.ts +34 -0
- package/src/ssr/hmr-opt-out.ts +78 -0
- package/src/ssr/renderer.ts +6 -0
- package/src/storage/base-file.ts +13 -13
- package/src/storage/buffered-file.ts +11 -11
- package/src/storage/s3-driver.ts +4 -1
- package/src/storage/uploaded-file.ts +8 -8
- package/src/stream/__tests__/ws-contracts.test.ts +4 -2
- package/src/stream/__tests__/ws-telemetry.test.ts +1 -1
- package/src/stream/__tests__/ws.test.ts +30 -6
- package/src/stream/sse.ts +12 -11
- package/src/stream/ws-core.ts +1 -1
- package/src/stream/ws-delivery.ts +16 -7
- package/src/stream/ws-local-connection-store.ts +2 -3
- package/src/stream/ws-presence-store.ts +6 -1
- package/src/stream/ws-registry.ts +16 -7
- package/src/stream/ws-telemetry.ts +66 -43
- package/src/stream/ws.ts +73 -39
- package/src/syncer/__tests__/api-parser.websocket-type-ref.test.ts +3 -2
- package/src/syncer/__tests__/http-validator-registry.test.ts +137 -0
- package/src/syncer/api-parser.ts +67 -27
- package/src/syncer/checksum.ts +17 -11
- package/src/syncer/code-generator.ts +25 -17
- package/src/syncer/entity-operations.ts +3 -5
- package/src/syncer/file-copy.ts +46 -0
- package/src/syncer/file-patterns.ts +11 -8
- package/src/syncer/file-tracking.ts +3 -4
- package/src/syncer/filesystem-dependencies.ts +73 -0
- package/src/syncer/module-loader.ts +8 -4
- package/src/syncer/syncer-actions.ts +56 -18
- package/src/syncer/syncer.ts +116 -43
- package/src/syncer/watcher.ts +8 -4
- package/src/tasks/decorator.ts +20 -12
- package/src/tasks/step-wrapper.ts +19 -9
- package/src/tasks/workflow-manager.ts +15 -9
- package/src/template/__tests__/http_validators.template.test.ts +160 -0
- package/src/template/__tests__/services.template.mutation.test.ts +24 -23
- package/src/template/__tests__/services.template.websocket.test.ts +21 -25
- package/src/template/entity-converter.ts +5 -2
- package/src/template/helpers.ts +8 -9
- package/src/template/implementations/generated.template.ts +5 -4
- package/src/template/implementations/generated_http.template.ts +61 -15
- package/src/template/implementations/generated_sso.template.ts +15 -4
- package/src/template/implementations/http_validators.template.ts +175 -0
- package/src/template/implementations/model.template.ts +3 -1
- package/src/template/implementations/sd.template.ts +81 -41
- package/src/template/implementations/services.template.ts +2 -2
- package/src/template/implementations/view_form.template.ts +56 -39
- package/src/template/implementations/view_list.template.ts +31 -23
- package/src/template/template-manager.ts +15 -13
- package/src/template/template-types.ts +13 -5
- package/src/template/template.ts +4 -3
- package/src/template/zod-converter.ts +206 -91
- package/src/testing/__tests__/dev-test-routes.test.ts +85 -25
- package/src/testing/__tests__/dev-vitest-manager.test.ts +15 -15
- package/src/testing/_relation-graph.ts +4 -1
- package/src/testing/bootstrap.ts +12 -5
- package/src/testing/data-explorer.ts +102 -53
- package/src/testing/dev-test-routes.ts +87 -50
- package/src/testing/dev-vitest-manager.ts +88 -32
- package/src/testing/faker-mappings.ts +2 -2
- package/src/testing/filesystem.ts +1 -0
- package/src/testing/fixture-generator.ts +191 -131
- package/src/testing/fixture-loader.ts +5 -1
- package/src/testing/fixture-manager.ts +129 -90
- package/src/testing/global-setup.ts +7 -3
- package/src/testing/index.ts +5 -0
- package/src/types/__tests__/entity-json-schema-search-text.test.ts +9 -3
- package/src/types/types.ts +184 -158
- package/src/ui/ai-api.ts +9 -7
- package/src/ui/ai-client.ts +61 -56
- package/src/ui/api.ts +726 -770
- package/src/ui/async-route.ts +4 -0
- package/src/ui/cdd-service.ts +35 -12
- package/src/ui/migrations-api.ts +381 -0
- package/src/utils/formatter.ts +7 -3
- package/src/utils/fs-utils.ts +5 -5
- package/src/utils/model.ts +4 -5
- package/src/utils/object-utils.ts +32 -22
- package/src/utils/process-utils.ts +4 -1
- package/src/utils/runtime-value.ts +43 -0
- package/src/utils/sql-parser.ts +13 -6
- package/src/utils/type-utils.ts +9 -7
- package/src/utils/utils.ts +19 -21
- package/src/utils/zod-error.ts +4 -2
- package/src/vector/chunking.ts +6 -1
- package/src/vector/embedding.ts +2 -1
- package/src/vector/types.ts +4 -2
- package/tsdown.api.config.ts +5 -2
- package/dist/ui-web/assets/index-CJf8uJYf.js +0 -176
- package/dist/ui-web/assets/index-GMMIVGja.css +0 -1
package/src/tasks/decorator.ts
CHANGED
|
@@ -13,18 +13,18 @@ import { type Executable } from "../types/types";
|
|
|
13
13
|
import { type WorkflowFunction } from "./workflow-manager";
|
|
14
14
|
|
|
15
15
|
// 워크플로우의 메타데이터 객체
|
|
16
|
-
export interface WorkflowMetadata {
|
|
16
|
+
export interface WorkflowMetadata<RawInput = unknown, Input = unknown, Output = unknown> {
|
|
17
17
|
type: "workflow";
|
|
18
18
|
id: string;
|
|
19
19
|
name: string;
|
|
20
20
|
version: string | null;
|
|
21
|
-
schema: StandardSchemaV1<
|
|
21
|
+
schema: StandardSchemaV1<RawInput, Input> | undefined;
|
|
22
22
|
schedules: {
|
|
23
23
|
name: string;
|
|
24
24
|
expression: string;
|
|
25
|
-
input: Executable<
|
|
25
|
+
input: Executable<RawInput | undefined>;
|
|
26
26
|
}[];
|
|
27
|
-
fn: WorkflowFunction<
|
|
27
|
+
fn: WorkflowFunction<Input, Output>;
|
|
28
28
|
retryPolicy?: RetryPolicy;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -50,22 +50,30 @@ export type DefineWorkflowOptions<
|
|
|
50
50
|
// 이것들은 syncer에서 한번에 load한 다음, WorkflowManager에서 synchronize를 통해 등록됨.
|
|
51
51
|
export function workflow<Input, Output, TSchema extends StandardSchemaV1 | undefined = undefined>(
|
|
52
52
|
options: DefineWorkflowOptions<Input, Output, TSchema>,
|
|
53
|
-
): (
|
|
53
|
+
): (
|
|
54
|
+
fn: WorkflowFunction<SchemaOutput<TSchema, Input>, Output>,
|
|
55
|
+
) => WorkflowMetadata<SchemaInput<TSchema, Input>, SchemaOutput<TSchema, Input>, Output>;
|
|
54
56
|
export function workflow<Input, Output, TSchema extends StandardSchemaV1 | undefined = undefined>(
|
|
55
57
|
options: DefineWorkflowOptions<Input, Output, TSchema>,
|
|
56
58
|
fn: WorkflowFunction<SchemaOutput<TSchema, Input>, Output>,
|
|
57
|
-
): WorkflowMetadata
|
|
59
|
+
): WorkflowMetadata<SchemaInput<TSchema, Input>, SchemaOutput<TSchema, Input>, Output>;
|
|
58
60
|
export function workflow<Input, Output, TSchema extends StandardSchemaV1 | undefined = undefined>(
|
|
59
61
|
options: DefineWorkflowOptions<Input, Output, TSchema>,
|
|
60
62
|
fn?: WorkflowFunction<SchemaOutput<TSchema, Input>, Output>,
|
|
61
63
|
):
|
|
62
|
-
| WorkflowMetadata
|
|
63
|
-
| ((
|
|
64
|
-
|
|
64
|
+
| WorkflowMetadata<SchemaInput<TSchema, Input>, SchemaOutput<TSchema, Input>, Output>
|
|
65
|
+
| ((
|
|
66
|
+
fn: WorkflowFunction<SchemaOutput<TSchema, Input>, Output>,
|
|
67
|
+
) => WorkflowMetadata<SchemaInput<TSchema, Input>, SchemaOutput<TSchema, Input>, Output>) {
|
|
68
|
+
const decorated = (workflowFunction: WorkflowFunction<SchemaOutput<TSchema, Input>, Output>) => {
|
|
65
69
|
const id = randomUUID();
|
|
66
|
-
const workflowName = options.name ?? inflection.underscore(
|
|
70
|
+
const workflowName = options.name ?? inflection.underscore(workflowFunction.name);
|
|
67
71
|
|
|
68
|
-
const metadata: WorkflowMetadata
|
|
72
|
+
const metadata: WorkflowMetadata<
|
|
73
|
+
SchemaInput<TSchema, Input>,
|
|
74
|
+
SchemaOutput<TSchema, Input>,
|
|
75
|
+
Output
|
|
76
|
+
> = {
|
|
69
77
|
type: "workflow" as const,
|
|
70
78
|
id,
|
|
71
79
|
name: workflowName,
|
|
@@ -78,7 +86,7 @@ export function workflow<Input, Output, TSchema extends StandardSchemaV1 | undef
|
|
|
78
86
|
input: schedule.input,
|
|
79
87
|
};
|
|
80
88
|
}),
|
|
81
|
-
fn:
|
|
89
|
+
fn: workflowFunction,
|
|
82
90
|
retryPolicy: options.retryPolicy,
|
|
83
91
|
};
|
|
84
92
|
|
|
@@ -6,6 +6,10 @@ export type RunnableStep<TArgs extends unknown[], TResult> = {
|
|
|
6
6
|
run: StepFunction<TArgs, Promise<TResult>>;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
interface StepConfig {
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
export type MethodNames<T, TKey extends keyof T> = T[TKey] extends (
|
|
10
14
|
...args: infer _TArgs
|
|
11
15
|
) => infer _TResult
|
|
@@ -14,7 +18,7 @@ export type MethodNames<T, TKey extends keyof T> = T[TKey] extends (
|
|
|
14
18
|
|
|
15
19
|
export type MethodArguments<T, TKey extends keyof T> = T[TKey] extends (
|
|
16
20
|
...args: infer TArgs
|
|
17
|
-
) =>
|
|
21
|
+
) => infer _TResult
|
|
18
22
|
? TArgs
|
|
19
23
|
: never;
|
|
20
24
|
|
|
@@ -37,7 +41,7 @@ export class StepWrapper {
|
|
|
37
41
|
TKey extends keyof T,
|
|
38
42
|
TArgs extends MethodArguments<T, TKey>,
|
|
39
43
|
TResult extends MethodReturnType<T, TKey>,
|
|
40
|
-
>(config:
|
|
44
|
+
>(config: StepConfig, object: T, name: MethodNames<T, TKey>): RunnableStep<TArgs, TResult>;
|
|
41
45
|
get<
|
|
42
46
|
T,
|
|
43
47
|
TKey extends keyof T,
|
|
@@ -50,20 +54,26 @@ export class StepWrapper {
|
|
|
50
54
|
TArgs extends MethodArguments<T, TKey>,
|
|
51
55
|
TResult extends MethodReturnType<T, TKey>,
|
|
52
56
|
>(
|
|
53
|
-
...
|
|
57
|
+
...definitionArgs: [StepConfig, T, MethodNames<T, TKey>] | [T, MethodNames<T, TKey>]
|
|
54
58
|
): RunnableStep<TArgs, TResult> {
|
|
55
|
-
let config:
|
|
59
|
+
let config: StepConfig;
|
|
56
60
|
let fn: StepFunction<TArgs, Exclude<TResult, never>>;
|
|
57
61
|
|
|
58
|
-
if (
|
|
59
|
-
const [rawObject, methodName] =
|
|
60
|
-
const method =
|
|
62
|
+
if (definitionArgs.length === 2) {
|
|
63
|
+
const [rawObject, methodName] = definitionArgs;
|
|
64
|
+
const method =
|
|
65
|
+
/* SAFETY: 작업 데코레이터와 워크플로 정의가 이 값의 타입을 보장한다. */ rawObject[
|
|
66
|
+
methodName
|
|
67
|
+
] as CallableFunction;
|
|
61
68
|
config = { name: inflection.underscore(methodName.toString()) };
|
|
62
69
|
|
|
63
70
|
fn = (...args: TArgs) => method.bind(rawObject)(...args);
|
|
64
71
|
} else {
|
|
65
|
-
const [rawConfig, rawObject, name] =
|
|
66
|
-
const method =
|
|
72
|
+
const [rawConfig, rawObject, name] = definitionArgs;
|
|
73
|
+
const method =
|
|
74
|
+
/* SAFETY: 작업 데코레이터와 워크플로 정의가 이 값의 타입을 보장한다. */ rawObject[
|
|
75
|
+
name
|
|
76
|
+
] as CallableFunction;
|
|
67
77
|
|
|
68
78
|
config = { name: rawConfig.name ?? inflection.underscore(name.toString()) };
|
|
69
79
|
fn = (...args: TArgs) => method.bind(rawObject)(...args);
|
|
@@ -25,6 +25,7 @@ import { convertDomainToCategory } from "../logger/category";
|
|
|
25
25
|
import { Naite } from "../naite/naite";
|
|
26
26
|
import { createMockSSEFactory } from "../stream/sse";
|
|
27
27
|
import { type Executable } from "../types/types";
|
|
28
|
+
import { isFunctionValue } from "../utils/runtime-value";
|
|
28
29
|
import { type WorkflowMetadata } from "./decorator";
|
|
29
30
|
import { StepWrapper } from "./step-wrapper";
|
|
30
31
|
|
|
@@ -126,7 +127,7 @@ export class WorkflowManager {
|
|
|
126
127
|
await Promise.allSettled(
|
|
127
128
|
Array.from(this.#workflowsMap.entries())
|
|
128
129
|
.filter(([key]) => !workflowMap.has(key))
|
|
129
|
-
.flatMap(([
|
|
130
|
+
.flatMap(([, workflows]) =>
|
|
130
131
|
workflows.map((workflow) => {
|
|
131
132
|
return Promise.allSettled([
|
|
132
133
|
...workflow.schedules.map((schedule) => this.unscheduleTask(schedule.name)),
|
|
@@ -140,7 +141,7 @@ export class WorkflowManager {
|
|
|
140
141
|
await Promise.allSettled(
|
|
141
142
|
Array.from(workflowMap.entries())
|
|
142
143
|
.filter(([key]) => !this.#workflowsMap.has(key))
|
|
143
|
-
.flatMap(([
|
|
144
|
+
.flatMap(([, workflows]) =>
|
|
144
145
|
workflows.map((workflow) => {
|
|
145
146
|
this.registerWorkflow({
|
|
146
147
|
id: workflow.id,
|
|
@@ -167,7 +168,7 @@ export class WorkflowManager {
|
|
|
167
168
|
assert(previousWorkflows, "previous workflows not found");
|
|
168
169
|
return [key, [previousWorkflows, newWorkflows]];
|
|
169
170
|
})
|
|
170
|
-
.map(async ([
|
|
171
|
+
.map(async ([, [previousWorkflows, newWorkflows]]) => {
|
|
171
172
|
// 기존 것들을 삭제부터 해야함.
|
|
172
173
|
await Promise.allSettled(
|
|
173
174
|
previousWorkflows
|
|
@@ -237,7 +238,7 @@ export class WorkflowManager {
|
|
|
237
238
|
{ name, version }: Pick<WorkflowMetadata, "name" | "version">,
|
|
238
239
|
{ input }: WorkflowMetadata["schedules"][number],
|
|
239
240
|
) => {
|
|
240
|
-
const inputData = await (
|
|
241
|
+
const inputData = await (isFunctionValue(input)
|
|
241
242
|
? Promise.resolve(input())
|
|
242
243
|
: Promise.resolve(input));
|
|
243
244
|
|
|
@@ -287,17 +288,22 @@ export class WorkflowManager {
|
|
|
287
288
|
version: string | null;
|
|
288
289
|
}>,
|
|
289
290
|
) => {
|
|
290
|
-
const baseContext = {
|
|
291
|
+
const baseContext: Context = {
|
|
291
292
|
transport: "http" as const,
|
|
292
|
-
|
|
293
|
-
|
|
293
|
+
// 워크플로우에는 HTTP 요청이 없으므로 잘못된 접근을 즉시 드러냅니다.
|
|
294
|
+
get request(): Context["request"] {
|
|
295
|
+
throw new Error("HTTP request is unavailable in workflow context");
|
|
296
|
+
},
|
|
297
|
+
get reply(): Context["reply"] {
|
|
298
|
+
throw new Error("HTTP reply is unavailable in workflow context");
|
|
299
|
+
},
|
|
294
300
|
headers: {},
|
|
295
|
-
createSSE: (schema:
|
|
301
|
+
createSSE: <T extends ZodObject>(schema: T) => createMockSSEFactory(schema),
|
|
296
302
|
naiteStore: Naite.createStore(),
|
|
297
303
|
locale: "",
|
|
298
304
|
user: null,
|
|
299
305
|
session: null,
|
|
300
|
-
}
|
|
306
|
+
};
|
|
301
307
|
|
|
302
308
|
const contextProvider = Sonamu.config.tasks?.contextProvider;
|
|
303
309
|
const context: Context = contextProvider
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { type SonamuConfig } from "../../api/config";
|
|
9
|
+
import { type ExtendedApi } from "../../api/decorators";
|
|
10
|
+
import { Sonamu } from "../../api/sonamu";
|
|
11
|
+
import { Syncer } from "../../syncer/syncer";
|
|
12
|
+
import { Template__http_validators } from "../implementations/http_validators.template";
|
|
13
|
+
|
|
14
|
+
function createApi(overrides: {
|
|
15
|
+
httpMethod: "GET" | "POST";
|
|
16
|
+
modelName: string;
|
|
17
|
+
path: string;
|
|
18
|
+
parameterType?: "number" | "string";
|
|
19
|
+
}): ExtendedApi {
|
|
20
|
+
return {
|
|
21
|
+
modelName: overrides.modelName,
|
|
22
|
+
methodName: "find",
|
|
23
|
+
path: overrides.path,
|
|
24
|
+
options: {
|
|
25
|
+
httpMethod: overrides.httpMethod,
|
|
26
|
+
},
|
|
27
|
+
typeParameters: [],
|
|
28
|
+
parameters: [
|
|
29
|
+
{
|
|
30
|
+
name: "filter",
|
|
31
|
+
optional: false,
|
|
32
|
+
type: {
|
|
33
|
+
t: "object",
|
|
34
|
+
props: [
|
|
35
|
+
{
|
|
36
|
+
name: "page",
|
|
37
|
+
optional: false,
|
|
38
|
+
type: overrides.parameterType ?? "number",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
returnType: "unknown",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function readFingerprint(body: string): string {
|
|
49
|
+
const match = body.match(/fingerprint\w*\s*[:=]\s*["']([^"']+)["']/i);
|
|
50
|
+
if (match?.[1] === undefined) {
|
|
51
|
+
throw new Error("generated validator registry에 fingerprint가 없습니다");
|
|
52
|
+
}
|
|
53
|
+
return match[1];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const testConfig = {
|
|
57
|
+
api: { dir: ".", route: { prefix: "/api" } },
|
|
58
|
+
i18n: { defaultLocale: "ko", supportedLocales: ["ko"] },
|
|
59
|
+
sync: { targets: [] },
|
|
60
|
+
validation: { zodCompiler: { api: "aot" } },
|
|
61
|
+
database: {},
|
|
62
|
+
server: {
|
|
63
|
+
apiConfig: {
|
|
64
|
+
contextProvider: (defaultContext) => defaultContext,
|
|
65
|
+
guardHandler: () => undefined,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
} satisfies SonamuConfig;
|
|
69
|
+
|
|
70
|
+
function setSyncerState(apis: ExtendedApi[]) {
|
|
71
|
+
const syncer = new Syncer();
|
|
72
|
+
syncer.apis = apis;
|
|
73
|
+
syncer.types = {};
|
|
74
|
+
Sonamu.syncer = syncer;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
describe("Template__http_validators 생성 계약", () => {
|
|
78
|
+
const tempRoots: string[] = [];
|
|
79
|
+
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
Sonamu.config = testConfig;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
afterEach(async () => {
|
|
85
|
+
await Promise.all(
|
|
86
|
+
tempRoots.splice(0).map((rootPath) => rm(rootPath, { recursive: true, force: true })),
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("충돌 없는 route key와 fingerprint로 최종 caster의 explicit compile registry를 결정적으로 만든다", () => {
|
|
91
|
+
const apis = [
|
|
92
|
+
createApi({ httpMethod: "GET", modelName: "ReportModel", path: "/report/find" }),
|
|
93
|
+
createApi({ httpMethod: "GET", modelName: "AuditModel", path: "/audit/find" }),
|
|
94
|
+
createApi({ httpMethod: "POST", modelName: "ReportModel", path: "/report/find" }),
|
|
95
|
+
createApi({ httpMethod: "GET", modelName: "ReportModel", path: "/report/find-alternate" }),
|
|
96
|
+
];
|
|
97
|
+
const template = new Template__http_validators();
|
|
98
|
+
|
|
99
|
+
setSyncerState(apis);
|
|
100
|
+
const first = template.render();
|
|
101
|
+
setSyncerState(apis.toReversed());
|
|
102
|
+
const reordered = template.render();
|
|
103
|
+
|
|
104
|
+
expect(first.body).toBe(reordered.body);
|
|
105
|
+
expect(first.body.match(/\bcompile\(/g)).toHaveLength(4);
|
|
106
|
+
expect(first.body).toMatch(/compile\(\s*fastifyCaster\(/);
|
|
107
|
+
expect(readFingerprint(first.body)).toBe(readFingerprint(reordered.body));
|
|
108
|
+
|
|
109
|
+
const changedApis = [
|
|
110
|
+
...apis.slice(0, -1),
|
|
111
|
+
createApi({
|
|
112
|
+
httpMethod: "GET",
|
|
113
|
+
modelName: "ReportModel",
|
|
114
|
+
parameterType: "string",
|
|
115
|
+
path: "/report/find-alternate",
|
|
116
|
+
}),
|
|
117
|
+
];
|
|
118
|
+
setSyncerState(changedApis);
|
|
119
|
+
const changed = template.render();
|
|
120
|
+
|
|
121
|
+
expect(readFingerprint(changed.body)).not.toBe(readFingerprint(first.body));
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("동일한 canonical route key가 중복되면 registry 생성을 거부한다", () => {
|
|
125
|
+
const duplicatedApi = createApi({
|
|
126
|
+
httpMethod: "GET",
|
|
127
|
+
modelName: "ReportModel",
|
|
128
|
+
path: "/report/find",
|
|
129
|
+
});
|
|
130
|
+
setSyncerState([duplicatedApi, { ...duplicatedApi }]);
|
|
131
|
+
|
|
132
|
+
const template = new Template__http_validators();
|
|
133
|
+
|
|
134
|
+
expect(() => template.render()).toThrow();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("REST API가 0개인 AOT registry는 compiler import 없이 내보내며 독립적으로 로드된다", async () => {
|
|
138
|
+
setSyncerState([]);
|
|
139
|
+
|
|
140
|
+
const rendered = new Template__http_validators().render();
|
|
141
|
+
const source = [...(rendered.customHeaders ?? []), rendered.body].join("\n");
|
|
142
|
+
|
|
143
|
+
expect(rendered.body).toMatch(/export const validators = new Map\(\[\s*\]\);/);
|
|
144
|
+
expect(rendered.body).toContain("export const routeIds = {}");
|
|
145
|
+
expect(source).not.toContain('from "zod-compiler"');
|
|
146
|
+
expect(source).not.toContain('from "sonamu"');
|
|
147
|
+
expect(source).not.toMatch(/\bcompile\(/);
|
|
148
|
+
expect(readFingerprint(rendered.body)).toHaveLength(64);
|
|
149
|
+
|
|
150
|
+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "sonamu-zero-registry-load-test-"));
|
|
151
|
+
tempRoots.push(tempRoot);
|
|
152
|
+
const modulePath = path.join(tempRoot, "sonamu.validators.generated.mjs");
|
|
153
|
+
await writeFile(modulePath, source);
|
|
154
|
+
|
|
155
|
+
await expect(import(`${pathToFileURL(modulePath).href}?test=zero`)).resolves.toMatchObject({
|
|
156
|
+
routeIds: {},
|
|
157
|
+
validators: expect.any(Map),
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
3
|
import { Sonamu } from "../../api";
|
|
4
|
+
import { type SonamuConfig } from "../../api/config";
|
|
4
5
|
import { type ExtendedApi } from "../../api/decorators";
|
|
6
|
+
import { Syncer } from "../../syncer/syncer";
|
|
5
7
|
import { Template__services } from "../implementations/services.template";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const testConfig = {
|
|
10
|
+
api: { dir: ".", route: { prefix: "/api" } },
|
|
11
|
+
i18n: { defaultLocale: "ko", supportedLocales: ["ko"] },
|
|
12
|
+
sync: { targets: [] },
|
|
13
|
+
database: {},
|
|
14
|
+
server: {
|
|
15
|
+
apiConfig: {
|
|
16
|
+
contextProvider: (defaultContext) => defaultContext,
|
|
17
|
+
guardHandler: () => undefined,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
} satisfies SonamuConfig;
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
prefix: "/api",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
+
function renderServices(apis: ExtendedApi[]) {
|
|
23
|
+
const syncer = new Syncer();
|
|
24
|
+
syncer.apis = apis;
|
|
25
|
+
Sonamu.syncer = syncer;
|
|
26
|
+
return new Template__services().render({}).body;
|
|
27
|
+
}
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
describe("Template__services mutation hooks", () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
Sonamu.config = testConfig;
|
|
26
32
|
});
|
|
27
33
|
|
|
28
|
-
const renderServices = (apis: ExtendedApi[]) => {
|
|
29
|
-
Reflect.set(Sonamu, "_syncer", { apis });
|
|
30
|
-
return new Template__services().render({}).body;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
34
|
it("파라미터가 있는 일반 mutation에서 namespace와 인자 순서를 유지한다", () => {
|
|
34
35
|
const body = renderServices([
|
|
35
36
|
{
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
import { Sonamu } from "../../api";
|
|
5
|
+
import { type SonamuConfig } from "../../api/config";
|
|
5
6
|
import { type ExtendedApi } from "../../api/decorators";
|
|
6
7
|
import { EntityManager } from "../../entity/entity-manager";
|
|
8
|
+
import { Syncer } from "../../syncer/syncer";
|
|
7
9
|
import { Template__services } from "../implementations/services.template";
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
11
|
+
const testConfig = {
|
|
12
|
+
api: { dir: ".", route: { prefix: "/api" } },
|
|
13
|
+
i18n: { defaultLocale: "ko", supportedLocales: ["ko"] },
|
|
14
|
+
sync: { targets: [] },
|
|
15
|
+
database: {},
|
|
16
|
+
server: {
|
|
17
|
+
apiConfig: {
|
|
18
|
+
contextProvider: (defaultContext) => defaultContext,
|
|
19
|
+
guardHandler: () => undefined,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
} satisfies SonamuConfig;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
route: {
|
|
27
|
-
prefix: "/api",
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
24
|
+
describe("Template__services websocket event refs", () => {
|
|
25
|
+
it("가져올 수 있는 websocket 이벤트 타입 이름을 재사용한다", () => {
|
|
26
|
+
Sonamu.config = testConfig;
|
|
31
27
|
|
|
32
28
|
const apis: ExtendedApi[] = [
|
|
33
29
|
{
|
|
@@ -62,9 +58,9 @@ describe("Template__services websocket event refs", () => {
|
|
|
62
58
|
returnType: "void",
|
|
63
59
|
},
|
|
64
60
|
];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
const syncer = new Syncer();
|
|
62
|
+
syncer.apis = apis;
|
|
63
|
+
Sonamu.syncer = syncer;
|
|
68
64
|
|
|
69
65
|
EntityManager.setModulePath("ChatOutEvents", "chat/chat.types");
|
|
70
66
|
EntityManager.setModulePath("ChatInEvents", "chat/chat.types");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
|
|
3
|
-
import z from "zod";
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
import { SD } from "../dict/sd";
|
|
6
6
|
import { EntityManager } from "../entity/entity-manager";
|
|
@@ -26,7 +26,10 @@ export async function getColumnsNode(entityId: string, subsetKey: string): Promi
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
// oxlint-disable-next-line @typescript-eslint/no-explicit-any -- zod 스키마를 로드할 때 사용하는 타입
|
|
29
|
-
const columnsZodType =
|
|
29
|
+
const columnsZodType =
|
|
30
|
+
/* SAFETY: 선행 Zod 종류 분기와 템플릿 입력 계약이 이 값의 타입을 보장한다. */ (await propNodeToZodType(
|
|
31
|
+
rootPropNode,
|
|
32
|
+
)) as z.ZodObject<any>;
|
|
30
33
|
|
|
31
34
|
const columnsNode = zodTypeToRenderingNode(columnsZodType);
|
|
32
35
|
assert(columnsNode.children !== undefined, "columnsNode.children is undefined");
|
package/src/template/helpers.ts
CHANGED
|
@@ -5,6 +5,13 @@ import { type EntityNamesRecord } from "../entity/entity-manager";
|
|
|
5
5
|
import { isEnumProp, isRelationProp } from "../types/types";
|
|
6
6
|
import { type RelationProp } from "../types/types";
|
|
7
7
|
|
|
8
|
+
interface EnumColumnInfo {
|
|
9
|
+
id: string;
|
|
10
|
+
targetEntityNames: EntityNamesRecord;
|
|
11
|
+
targetEntityId: string;
|
|
12
|
+
title: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
/**
|
|
9
16
|
* Enum의 표시용 라벨을 가져옵니다.
|
|
10
17
|
* OrderBy, SearchField 등 특수한 경우와 일반 Enum을 구분하여 처리합니다.
|
|
@@ -29,15 +36,7 @@ export function getLabel(entityId: string, enumId: string): string {
|
|
|
29
36
|
* 컬럼 이름으로부터 Enum 정보를 추출합니다.
|
|
30
37
|
* Entity의 prop 중 enum 타입인 것을 찾아 관련 정보를 반환합니다.
|
|
31
38
|
*/
|
|
32
|
-
export function getEnumInfoFromColName(
|
|
33
|
-
entityId: string,
|
|
34
|
-
colName: string,
|
|
35
|
-
): {
|
|
36
|
-
id: string;
|
|
37
|
-
targetEntityNames: EntityNamesRecord;
|
|
38
|
-
targetEntityId: string;
|
|
39
|
-
title: string;
|
|
40
|
-
} {
|
|
39
|
+
export function getEnumInfoFromColName(entityId: string, colName: string): EnumColumnInfo {
|
|
41
40
|
const baseEntity = EntityManager.get(entityId);
|
|
42
41
|
const prop = baseEntity.props.find((p) => p.name === colName);
|
|
43
42
|
if (prop && isEnumProp(prop)) {
|
|
@@ -70,7 +70,7 @@ export class Template__generated extends Template {
|
|
|
70
70
|
importKeys: unique([...result.importKeys, ...ts.importKeys].toSorted()),
|
|
71
71
|
};
|
|
72
72
|
},
|
|
73
|
-
{
|
|
73
|
+
/* SAFETY: reduce 누산기는 label을 제외한 SourceCode의 두 배열로 초기화된다. */ {
|
|
74
74
|
lines: [],
|
|
75
75
|
importKeys: [],
|
|
76
76
|
} as Omit<SourceCode, "label">,
|
|
@@ -83,7 +83,7 @@ export class Template__generated extends Template {
|
|
|
83
83
|
);
|
|
84
84
|
if (cdImportKeys.length > 0) {
|
|
85
85
|
const customScalarLines = cdImportKeys.flatMap((importKey) => {
|
|
86
|
-
const entity = entities.find((
|
|
86
|
+
const entity = entities.find((candidateEntity) => candidateEntity.types[importKey]);
|
|
87
87
|
if (!entity) {
|
|
88
88
|
throw new Error(`ZodType not found ${importKey}`);
|
|
89
89
|
}
|
|
@@ -109,7 +109,8 @@ export class Template__generated extends Template {
|
|
|
109
109
|
// import
|
|
110
110
|
// sourceCode.importKeys에 내장 타입의 스키마가 있으면 sonamu import에 추가
|
|
111
111
|
const builtInSchemaNames = Object.values(BUILT_IN_TYPES).map(
|
|
112
|
-
(info) =>
|
|
112
|
+
(info) =>
|
|
113
|
+
/* SAFETY: BUILT_IN_TYPES의 모든 항목은 생성 코드에 쓸 schemaName을 가진다. */ info.schemaName as string,
|
|
113
114
|
);
|
|
114
115
|
const builtInSchemas = sourceCode.importKeys.filter((key) => builtInSchemaNames.includes(key));
|
|
115
116
|
const sonamuImports = [
|
|
@@ -146,7 +147,7 @@ export class Template__generated extends Template {
|
|
|
146
147
|
return {
|
|
147
148
|
label: `Enums: ${entity.id}`,
|
|
148
149
|
lines: Object.entries(entity.enumLabels)
|
|
149
|
-
.filter(([
|
|
150
|
+
.filter(([, enumLabel]) => Object.keys(enumLabel).length > 0)
|
|
150
151
|
.flatMap(([enumId, enumLabel]) => [
|
|
151
152
|
`export const ${enumId} = z.enum([${Object.keys(enumLabel).map(
|
|
152
153
|
(el) => `"${el}"`,
|