sonamu 0.10.12 → 0.11.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/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/base-frame.d.ts.map +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 +252 -107
- package/dist/api/validator.d.ts.map +1 -1
- 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/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -3
- package/dist/auth/knex-adapter.d.ts.map +1 -1
- 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 +4 -4
- package/dist/auth/plugins/wrappers/admin.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/anonymous.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/api-key.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/jwt.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/organization.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/passkey.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/phone-number.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/sso.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/two-factor.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/username.d.ts.map +1 -1
- package/dist/bin/build-config.d.ts +35 -0
- package/dist/bin/build-config.d.ts.map +1 -1
- package/dist/bin/build-config.js +232 -5
- 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 +7 -4
- package/dist/bin/fixture.d.ts.map +1 -1
- package/dist/bin/fixture.js +165 -15
- package/dist/bin/test-command.d.ts +29 -1
- package/dist/bin/test-command.d.ts.map +1 -1
- package/dist/bin/test-command.js +33 -11
- 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/bin/typecheck-web.d.ts +2 -0
- package/dist/bin/typecheck-web.d.ts.map +1 -0
- package/dist/bin/typecheck-web.js +36 -0
- package/dist/cache/decorator.d.ts.map +1 -1
- package/dist/cache/decorator.js +11 -4
- package/dist/cache/drivers.d.ts.map +1 -1
- package/dist/cache-control/cache-control.d.ts.map +1 -1
- 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 +14 -10
- 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 -4
- 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-subset.types.d.ts +0 -1
- package/dist/database/puri-subset.types.d.ts.map +1 -1
- package/dist/database/puri-wrapper.d.ts +0 -1
- package/dist/database/puri-wrapper.d.ts.map +1 -1
- package/dist/database/puri.d.ts +11 -10
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +93 -79
- package/dist/database/puri.types.d.ts +21 -22
- package/dist/database/puri.types.d.ts.map +1 -1
- package/dist/database/puri.types.js +1 -1
- package/dist/database/transaction-context.d.ts.map +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/en.d.ts +58 -58
- package/dist/dict/en.d.ts.map +1 -1
- package/dist/dict/ko.d.ts +58 -58
- package/dist/dict/ko.d.ts.map +1 -1
- package/dist/dict/rc-keys.d.ts.map +1 -1
- 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 +2 -2
- package/dist/dict/utils.d.ts.map +1 -1
- package/dist/dict/utils.js +7 -2
- package/dist/entity/entity-manager.d.ts +126 -115
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +42 -28
- 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 +12 -3
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +37 -30
- 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/types.d.ts.map +1 -1
- 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 +17 -11
- package/dist/logger/configure.d.ts +10 -1
- package/dist/logger/configure.d.ts.map +1 -1
- package/dist/logger/configure.js +39 -14
- 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 +15 -3
- package/dist/migration/migrator.d.ts.map +1 -1
- package/dist/migration/migrator.js +102 -49
- 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/naite/messaging-types.d.ts +0 -1
- package/dist/naite/messaging-types.d.ts.map +1 -1
- package/dist/naite/naite-reporter.d.ts +0 -1
- package/dist/naite/naite-reporter.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.d.ts.map +1 -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/drivers.d.ts.map +1 -1
- package/dist/storage/s3-driver.d.ts.map +1 -1
- package/dist/storage/s3-driver.js +1 -1
- package/dist/storage/storage-manager.d.ts.map +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-audience-resolver.d.ts.map +1 -1
- package/dist/stream/ws-audience.d.ts.map +1 -1
- package/dist/stream/ws-cluster-bus.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- 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-memory.d.ts.map +1 -1
- 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 +2 -2
- 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 +17 -16
- 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/entity.template.d.ts +2 -2
- package/dist/template/implementations/entity.template.d.ts.map +1 -1
- package/dist/template/implementations/entry-server.template.d.ts +2 -2
- package/dist/template/implementations/entry-server.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.d.ts +2 -2
- 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 +9 -6
- 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 +2 -2
- 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/init_types.template.d.ts +2 -2
- package/dist/template/implementations/init_types.template.d.ts.map +1 -1
- package/dist/template/implementations/model.template.d.ts +2 -2
- package/dist/template/implementations/model.template.d.ts.map +1 -1
- package/dist/template/implementations/model.template.js +1 -1
- package/dist/template/implementations/model_test.template.d.ts +2 -2
- package/dist/template/implementations/model_test.template.d.ts.map +1 -1
- package/dist/template/implementations/queries.template.d.ts +2 -2
- package/dist/template/implementations/queries.template.d.ts.map +1 -1
- package/dist/template/implementations/queries.template.js +1 -1
- package/dist/template/implementations/sd.template.d.ts +2 -2
- package/dist/template/implementations/sd.template.d.ts.map +1 -1
- package/dist/template/implementations/sd.template.js +80 -40
- package/dist/template/implementations/services.template.d.ts +2 -2
- 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 +9 -4
- 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_id_all_select.template.d.ts +2 -2
- package/dist/template/implementations/view_id_all_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.d.ts +2 -2
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +11 -6
- package/dist/template/implementations/view_search_input.template.d.ts +2 -2
- package/dist/template/implementations/view_search_input.template.d.ts.map +1 -1
- package/dist/template/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 +133 -74
- 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 +12 -7
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +179 -73
- 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/testing/naite-vitest-reporter.d.ts.map +1 -1
- package/dist/testing/parallel-db-manager.d.ts.map +1 -1
- package/dist/tooling/__tests__/helpers/sonamu-test-root.d.ts +10 -0
- package/dist/tooling/__tests__/helpers/sonamu-test-root.d.ts.map +1 -0
- package/dist/tooling/__tests__/helpers/sonamu-test-root.js +42 -0
- package/dist/tooling/cdd-service.d.ts +87 -0
- package/dist/tooling/cdd-service.d.ts.map +1 -0
- package/dist/tooling/cdd-service.js +215 -0
- package/dist/tooling/cli-tooling.d.ts +11 -0
- package/dist/tooling/cli-tooling.d.ts.map +1 -0
- package/dist/tooling/cli-tooling.js +901 -0
- package/dist/tooling/fixture-service.d.ts +29 -0
- package/dist/tooling/fixture-service.d.ts.map +1 -0
- package/dist/tooling/fixture-service.js +53 -0
- package/dist/tooling/index.d.ts +2 -0
- package/dist/tooling/index.d.ts.map +1 -0
- package/dist/tooling/index.js +2 -0
- package/dist/tooling/test-run-client.d.ts +27 -0
- package/dist/tooling/test-run-client.d.ts.map +1 -0
- package/dist/tooling/test-run-client.js +120 -0
- package/dist/tsdown.api.config.js +48 -0
- package/dist/types/types.d.ts +620 -618
- 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 +135 -128
- 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.map +1 -1
- package/dist/ui/migrations-api.js +17 -15
- package/dist/ui-web/assets/index-DV1AAq6W.js +178 -0
- package/dist/ui-web/index.html +1 -1
- package/dist/utils/formatter.d.ts +6 -0
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +46 -13
- 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 +4 -6
- 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 +17 -14
- 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 +461 -153
- 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/index.ts +1 -1
- 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 +374 -0
- package/src/bin/build-config.ts +317 -4
- package/src/bin/compiler-policy.ts +35 -0
- package/src/bin/fixture.ts +218 -24
- package/src/bin/test-command.ts +100 -32
- package/src/bin/ts-loader-registration.ts +22 -4
- package/src/bin/typecheck-web.ts +56 -0
- 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 +7 -7
- package/src/dict/utils.ts +9 -1
- package/src/entity/__tests__/entity-manager-autoload.contract.test.ts +55 -0
- package/src/entity/__tests__/entity-manager-explicit-root-registration.contract.test.ts +107 -0
- package/src/entity/entity-manager.ts +56 -27
- package/src/entity/entity-template-cone.ts +5 -10
- package/src/entity/entity.ts +57 -36
- 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/__tests__/configure.test.ts +33 -0
- package/src/logger/configure.ts +69 -19
- package/src/migration/__tests__/migrator.test.ts +101 -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 +166 -70
- package/src/migration/postgresql-schema-reader.ts +52 -47
- package/src/migration/slack-confirm.ts +17 -15
- 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 +68 -28
- 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 +237 -106
- package/src/testing/global-setup.ts +7 -3
- package/src/testing/index.ts +5 -0
- package/src/tooling/__tests__/cdd-rule-bootstrap.contract.test.ts +118 -0
- package/src/tooling/__tests__/cli-tooling-auth.contract.test.ts +72 -0
- package/src/tooling/__tests__/cli-tooling-cone-locale.contract.test.ts +150 -0
- package/src/tooling/__tests__/cli-tooling-entity-patch.contract.test.ts +131 -0
- package/src/tooling/__tests__/cli-tooling-fixture-transfer.contract.test.ts +255 -0
- package/src/tooling/__tests__/cli-tooling-i18n-update.contract.test.ts +104 -0
- package/src/tooling/__tests__/cli-tooling-scaffold.contract.test.ts +86 -0
- package/src/tooling/__tests__/cli-tooling-stub-practice.contract.test.ts +147 -0
- package/src/tooling/__tests__/default-cdd-adapter.contract.test.ts +73 -0
- package/src/tooling/__tests__/helpers/sonamu-test-root.ts +42 -0
- package/src/tooling/__tests__/test-run-client-config.contract.test.ts +154 -0
- package/src/tooling/cdd-service.ts +256 -0
- package/src/tooling/cli-tooling.ts +937 -0
- package/src/tooling/fixture-service.ts +72 -0
- package/src/tooling/index.ts +1 -0
- package/src/tooling/test-run-client.ts +196 -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 +727 -616
- package/src/ui/async-route.ts +4 -0
- package/src/ui/cdd-service.ts +35 -12
- package/src/ui/migrations-api.ts +63 -51
- package/src/utils/__tests__/formatter-bin.test.ts +99 -0
- package/src/utils/formatter.ts +80 -12
- 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 +12 -11
- package/bin/cli.js +0 -75
- package/dist/bin/cli.d.ts +0 -2
- package/dist/bin/cli.d.ts.map +0 -1
- package/dist/bin/cli.js +0 -852
- package/dist/ui-web/assets/index-C0m1pk6K.js +0 -177
- package/src/bin/cli.ts +0 -1049
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { Sonamu, type SonamuTestingSnapshot } from "../../../api/sonamu";
|
|
6
|
+
import { type AbsolutePath } from "../../../utils/path-utils";
|
|
7
|
+
|
|
8
|
+
const createdWorkspaces: string[] = [];
|
|
9
|
+
let capturedSnapshot: SonamuTestingSnapshot | null = null;
|
|
10
|
+
let capturedInitialized = false;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 임시 api root를 만들어 Sonamu singleton의 공개 setter로 주입합니다.
|
|
14
|
+
*
|
|
15
|
+
* tooling 연산은 `Sonamu.isInitialized`가 참이면 초기화를 건너뛰므로,
|
|
16
|
+
* 실제 DB/설정 없이 파일 경로 기반 동작만 검증할 수 있습니다.
|
|
17
|
+
*/
|
|
18
|
+
export async function attachSonamuTestRoot(): Promise<string> {
|
|
19
|
+
const workspace = await mkdtemp(path.join(os.tmpdir(), "sonamu-tooling-"));
|
|
20
|
+
createdWorkspaces.push(workspace);
|
|
21
|
+
const apiRootPath = path.join(workspace, "api");
|
|
22
|
+
await mkdir(path.join(apiRootPath, "src", "application"), { recursive: true });
|
|
23
|
+
|
|
24
|
+
capturedSnapshot ??= Sonamu.captureTestingSnapshot();
|
|
25
|
+
capturedInitialized = Sonamu.isInitialized;
|
|
26
|
+
// SAFETY: mkdtemp가 반환한 절대 경로만 주입합니다.
|
|
27
|
+
Sonamu.apiRootPath = apiRootPath as AbsolutePath;
|
|
28
|
+
Sonamu.isInitialized = true;
|
|
29
|
+
return apiRootPath;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 주입한 Sonamu 상태를 되돌리고 임시 디렉터리를 정리합니다. */
|
|
33
|
+
export async function detachSonamuTestRoot(): Promise<void> {
|
|
34
|
+
if (capturedSnapshot !== null) {
|
|
35
|
+
Sonamu.restoreTestingSnapshot(capturedSnapshot);
|
|
36
|
+
capturedSnapshot = null;
|
|
37
|
+
}
|
|
38
|
+
Sonamu.isInitialized = capturedInitialized;
|
|
39
|
+
await Promise.all(
|
|
40
|
+
createdWorkspaces.splice(0).map((workspace) => rm(workspace, { recursive: true, force: true })),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { createServer, type Server } from "node:http";
|
|
3
|
+
import { type AddressInfo } from "node:net";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
|
|
7
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
8
|
+
|
|
9
|
+
import { createDefaultTestRunClient } from "../test-run-client";
|
|
10
|
+
|
|
11
|
+
const STATUS_PAYLOAD = { running: false };
|
|
12
|
+
const RUN_RESULT = {
|
|
13
|
+
ok: true,
|
|
14
|
+
summary: { total: 1, passed: 1, failed: 0, skipped: 0, durationMs: 12 },
|
|
15
|
+
results: [],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const originalVitest = process.env.VITEST;
|
|
19
|
+
const originalHot = process.env.HOT;
|
|
20
|
+
const temporaryRoots: string[] = [];
|
|
21
|
+
const startedServers: Server[] = [];
|
|
22
|
+
|
|
23
|
+
/** DevRunner 응답을 대신하는 실제 로컬 HTTP 서버를 띄웁니다. */
|
|
24
|
+
async function startDevRunnerServer(): Promise<number> {
|
|
25
|
+
const server = createServer((request, response) => {
|
|
26
|
+
response.setHeader("content-type", "application/json");
|
|
27
|
+
if (request.url === "/__test__/status") {
|
|
28
|
+
response.end(JSON.stringify(STATUS_PAYLOAD));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (request.url === "/__test__/run") {
|
|
32
|
+
response.end(JSON.stringify(RUN_RESULT));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
response.statusCode = 404;
|
|
36
|
+
response.end("{}");
|
|
37
|
+
});
|
|
38
|
+
startedServers.push(server);
|
|
39
|
+
await new Promise<void>((resolve) => {
|
|
40
|
+
server.listen(0, "127.0.0.1", resolve);
|
|
41
|
+
});
|
|
42
|
+
// SAFETY: TCP listen 이후의 주소는 항상 AddressInfo 입니다.
|
|
43
|
+
const address = server.address() as AddressInfo;
|
|
44
|
+
return address.port;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** dist 빌드 없이 src/sonamu.config.ts만 가진 일반 개발 프로젝트를 만듭니다. */
|
|
48
|
+
async function createSourceOnlyProject(port: number | null): Promise<string> {
|
|
49
|
+
const projectRoot = await mkdtemp(path.join(os.tmpdir(), "sonamu-test-run-client-"));
|
|
50
|
+
temporaryRoots.push(projectRoot);
|
|
51
|
+
await mkdir(path.join(projectRoot, "src"), { recursive: true });
|
|
52
|
+
await writeFile(path.join(projectRoot, ".env"), "SONAMU_TEST_RUN_CLIENT=1\n");
|
|
53
|
+
if (port === null) return projectRoot;
|
|
54
|
+
|
|
55
|
+
await writeFile(
|
|
56
|
+
path.join(projectRoot, "src", "sonamu.config.ts"),
|
|
57
|
+
`
|
|
58
|
+
export default {
|
|
59
|
+
server: { listen: { host: "127.0.0.1", port: ${port} } },
|
|
60
|
+
test: { devRunner: { enabled: true, routePrefix: "/__test__" } },
|
|
61
|
+
};
|
|
62
|
+
`,
|
|
63
|
+
);
|
|
64
|
+
return projectRoot;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function enterPlainDevShell(): void {
|
|
68
|
+
// dist 설정을 고르는 환경변수가 없는 일반 개발 셸을 재현합니다.
|
|
69
|
+
delete process.env.VITEST;
|
|
70
|
+
delete process.env.HOT;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
afterEach(async () => {
|
|
74
|
+
if (originalVitest === undefined) delete process.env.VITEST;
|
|
75
|
+
else process.env.VITEST = originalVitest;
|
|
76
|
+
if (originalHot === undefined) delete process.env.HOT;
|
|
77
|
+
else process.env.HOT = originalHot;
|
|
78
|
+
|
|
79
|
+
await Promise.all(
|
|
80
|
+
startedServers.splice(0).map(
|
|
81
|
+
(server) =>
|
|
82
|
+
new Promise<void>((resolve) => {
|
|
83
|
+
server.close(() => resolve());
|
|
84
|
+
}),
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
await Promise.all(
|
|
88
|
+
temporaryRoots.splice(0).map((root) => rm(root, { recursive: true, force: true })),
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("test-run-client의 sonamu.config 로딩", () => {
|
|
93
|
+
it("dist 빌드가 없어도 status가 src/sonamu.config.ts를 읽는다", async () => {
|
|
94
|
+
const port = await startDevRunnerServer();
|
|
95
|
+
const projectRoot = await createSourceOnlyProject(port);
|
|
96
|
+
enterPlainDevShell();
|
|
97
|
+
|
|
98
|
+
await expect(createDefaultTestRunClient(projectRoot).status()).resolves.toEqual(STATUS_PAYLOAD);
|
|
99
|
+
expect(process.env.VITEST).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("dist 빌드가 없어도 run이 src/sonamu.config.ts를 읽는다", async () => {
|
|
103
|
+
const port = await startDevRunnerServer();
|
|
104
|
+
const projectRoot = await createSourceOnlyProject(port);
|
|
105
|
+
enterPlainDevShell();
|
|
106
|
+
|
|
107
|
+
await expect(
|
|
108
|
+
createDefaultTestRunClient(projectRoot).run({ files: ["a.test.ts"] }),
|
|
109
|
+
).resolves.toMatchObject({ ok: true });
|
|
110
|
+
expect(process.env.VITEST).toBeUndefined();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("기존 VITEST 값은 설정 로딩 후 원래 값으로 되돌린다", async () => {
|
|
114
|
+
const port = await startDevRunnerServer();
|
|
115
|
+
const projectRoot = await createSourceOnlyProject(port);
|
|
116
|
+
enterPlainDevShell();
|
|
117
|
+
process.env.VITEST = "false";
|
|
118
|
+
|
|
119
|
+
await expect(createDefaultTestRunClient(projectRoot).status()).resolves.toEqual(STATUS_PAYLOAD);
|
|
120
|
+
expect(process.env.VITEST).toBe("false");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("설정 파일이 없으면 TEST_RUN_CONFIG_ERROR로 실패하고 환경변수를 복원한다", async () => {
|
|
124
|
+
const projectRoot = await createSourceOnlyProject(null);
|
|
125
|
+
enterPlainDevShell();
|
|
126
|
+
|
|
127
|
+
await expect(createDefaultTestRunClient(projectRoot).status()).rejects.toMatchObject({
|
|
128
|
+
code: "TEST_RUN_CONFIG_ERROR",
|
|
129
|
+
});
|
|
130
|
+
expect(process.env.VITEST).toBeUndefined();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("devRunner가 비활성화되어 있으면 설정 오류로 실패한다", async () => {
|
|
134
|
+
const projectRoot = await mkdtemp(path.join(os.tmpdir(), "sonamu-test-run-client-off-"));
|
|
135
|
+
temporaryRoots.push(projectRoot);
|
|
136
|
+
await mkdir(path.join(projectRoot, "src"), { recursive: true });
|
|
137
|
+
await writeFile(path.join(projectRoot, ".env"), "SONAMU_TEST_RUN_CLIENT=1\n");
|
|
138
|
+
await writeFile(
|
|
139
|
+
path.join(projectRoot, "src", "sonamu.config.ts"),
|
|
140
|
+
`
|
|
141
|
+
export default {
|
|
142
|
+
server: { listen: { host: "127.0.0.1", port: 3000 } },
|
|
143
|
+
test: { devRunner: { enabled: false } },
|
|
144
|
+
};
|
|
145
|
+
`,
|
|
146
|
+
);
|
|
147
|
+
enterPlainDevShell();
|
|
148
|
+
|
|
149
|
+
await expect(createDefaultTestRunClient(projectRoot).status()).rejects.toMatchObject({
|
|
150
|
+
code: "TEST_RUN_CONFIG_ERROR",
|
|
151
|
+
});
|
|
152
|
+
expect(process.env.VITEST).toBeUndefined();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import * as defaultFs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
type CddFileSystem = Pick<typeof defaultFs, "lstat" | "mkdir" | "open" | "opendir" | "realpath">;
|
|
6
|
+
|
|
7
|
+
function invalidCddPath(relativePath: string, cause?: unknown): Error {
|
|
8
|
+
return Object.assign(new Error(`CDD 경로가 contract 밖을 참조합니다: ${relativePath}`), {
|
|
9
|
+
code: "INVALID_CDD_PATH",
|
|
10
|
+
cause,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isWithin(root: string, target: string): boolean {
|
|
15
|
+
const relative = path.relative(root, target);
|
|
16
|
+
return relative === "" || (!relative.startsWith(`..${path.sep}`) && relative !== "..");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function nearestExistingPath(fs: CddFileSystem, target: string): Promise<string> {
|
|
20
|
+
let candidate = target;
|
|
21
|
+
while (true) {
|
|
22
|
+
try {
|
|
23
|
+
await fs.lstat(candidate);
|
|
24
|
+
return candidate;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
// SAFETY: node:fs lstat 실패의 code만 읽어 경로 부재를 구분합니다.
|
|
27
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
28
|
+
const parent = path.dirname(candidate);
|
|
29
|
+
if (parent === candidate) throw error;
|
|
30
|
+
candidate = parent;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createCddFileOperation({
|
|
36
|
+
contractRoot,
|
|
37
|
+
fs = defaultFs,
|
|
38
|
+
}: {
|
|
39
|
+
contractRoot: string;
|
|
40
|
+
fs?: CddFileSystem;
|
|
41
|
+
}) {
|
|
42
|
+
async function resolveBoundary(relativePath: string) {
|
|
43
|
+
const [canonicalRoot, configuredRoot] = await Promise.all([
|
|
44
|
+
fs.realpath(contractRoot),
|
|
45
|
+
Promise.resolve(path.resolve(contractRoot)),
|
|
46
|
+
]);
|
|
47
|
+
const target = path.resolve(configuredRoot, relativePath);
|
|
48
|
+
if (!isWithin(configuredRoot, target)) throw invalidCddPath(relativePath);
|
|
49
|
+
return { canonicalRoot, target };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function assertCanonicalPath(
|
|
53
|
+
canonicalRoot: string,
|
|
54
|
+
target: string,
|
|
55
|
+
relativePath: string,
|
|
56
|
+
): Promise<string> {
|
|
57
|
+
const canonicalTarget = await fs.realpath(target);
|
|
58
|
+
if (!isWithin(canonicalRoot, canonicalTarget)) throw invalidCddPath(relativePath);
|
|
59
|
+
return canonicalTarget;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
async readDirectory(relativePath: string) {
|
|
64
|
+
const { canonicalRoot, target } = await resolveBoundary(relativePath);
|
|
65
|
+
const canonicalTarget = await assertCanonicalPath(canonicalRoot, target, relativePath);
|
|
66
|
+
let directory;
|
|
67
|
+
try {
|
|
68
|
+
directory = await fs.opendir(target);
|
|
69
|
+
const recheckedTarget = await assertCanonicalPath(canonicalRoot, target, relativePath);
|
|
70
|
+
if (recheckedTarget !== canonicalTarget) throw invalidCddPath(relativePath);
|
|
71
|
+
const entries = [];
|
|
72
|
+
while (true) {
|
|
73
|
+
const entry = await directory.read();
|
|
74
|
+
if (entry === null) return entries;
|
|
75
|
+
entries.push(entry);
|
|
76
|
+
}
|
|
77
|
+
} finally {
|
|
78
|
+
await directory?.close();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async read(relativePath: string): Promise<string> {
|
|
82
|
+
const { canonicalRoot, target } = await resolveBoundary(relativePath);
|
|
83
|
+
const canonicalTarget = await assertCanonicalPath(canonicalRoot, target, relativePath);
|
|
84
|
+
let handle;
|
|
85
|
+
try {
|
|
86
|
+
// 최종 symlink를 따라가지 않은 descriptor를 연 뒤 실제 경로를 다시 확인합니다.
|
|
87
|
+
handle = await fs.open(target, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
88
|
+
const recheckedTarget = await assertCanonicalPath(canonicalRoot, target, relativePath);
|
|
89
|
+
if (recheckedTarget !== canonicalTarget) throw invalidCddPath(relativePath);
|
|
90
|
+
return await handle.readFile("utf8");
|
|
91
|
+
} catch (error) {
|
|
92
|
+
// SAFETY: node:fs open 실패의 code만 읽어 symlink 거부를 정규화합니다.
|
|
93
|
+
if ((error as NodeJS.ErrnoException).code === "ELOOP") {
|
|
94
|
+
throw invalidCddPath(relativePath, error);
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
} finally {
|
|
98
|
+
await handle?.close();
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
async write(relativePath: string, contents: string): Promise<void> {
|
|
103
|
+
const { canonicalRoot, target } = await resolveBoundary(relativePath);
|
|
104
|
+
const existing = await nearestExistingPath(fs, target);
|
|
105
|
+
const canonicalExisting = await assertCanonicalPath(canonicalRoot, existing, relativePath);
|
|
106
|
+
const targetExists = existing === target;
|
|
107
|
+
|
|
108
|
+
if (!targetExists) {
|
|
109
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
110
|
+
await assertCanonicalPath(canonicalRoot, path.dirname(target), relativePath);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let handle;
|
|
114
|
+
try {
|
|
115
|
+
// 검증 전 truncate를 피하고 새 파일은 배타적으로 생성합니다.
|
|
116
|
+
const flags = targetExists
|
|
117
|
+
? constants.O_WRONLY | constants.O_NOFOLLOW
|
|
118
|
+
: constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW;
|
|
119
|
+
handle = await fs.open(target, flags, 0o666);
|
|
120
|
+
const canonicalTarget = await assertCanonicalPath(canonicalRoot, target, relativePath);
|
|
121
|
+
if (
|
|
122
|
+
!isWithin(canonicalRoot, canonicalTarget) ||
|
|
123
|
+
(targetExists && canonicalTarget !== canonicalExisting)
|
|
124
|
+
) {
|
|
125
|
+
throw invalidCddPath(relativePath);
|
|
126
|
+
}
|
|
127
|
+
await handle.truncate(0);
|
|
128
|
+
await handle.writeFile(contents, "utf8");
|
|
129
|
+
} catch (error) {
|
|
130
|
+
// SAFETY: node:fs open 실패의 code만 읽어 symlink 거부를 정규화합니다.
|
|
131
|
+
if ((error as NodeJS.ErrnoException).code === "ELOOP") {
|
|
132
|
+
throw invalidCddPath(relativePath, error);
|
|
133
|
+
}
|
|
134
|
+
throw error;
|
|
135
|
+
} finally {
|
|
136
|
+
await handle?.close();
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
type CddRuleDocument = {
|
|
143
|
+
description?: string;
|
|
144
|
+
rules?: Array<{ id: string; when: string; instruction: string; examples?: string[] }>;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
function parseCddRules(contents: string): CddRuleDocument {
|
|
148
|
+
try {
|
|
149
|
+
// SAFETY: CDD 규칙 소비 지점은 선택 필드만 읽고 배열 부재를 기본값으로 처리합니다.
|
|
150
|
+
return JSON.parse(contents) as CddRuleDocument;
|
|
151
|
+
} catch (cause) {
|
|
152
|
+
throw Object.assign(new Error("CDD rules JSON is malformed"), {
|
|
153
|
+
code: "INVALID_CDD_RULES",
|
|
154
|
+
exitCode: 2,
|
|
155
|
+
cause,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 규칙 문서를 읽되, 아직 파일이 없으면 빈 문서로 취급합니다.
|
|
162
|
+
*
|
|
163
|
+
* 첫 규칙 등록 시 rules 디렉터리와 파일이 없는 상태를 부트스트랩하기 위한 처리이며,
|
|
164
|
+
* 깨진 JSON은 그대로 INVALID_CDD_RULES로 실패시켜 덮어쓰기를 막습니다.
|
|
165
|
+
*/
|
|
166
|
+
async function readCddRuleDocument(
|
|
167
|
+
files: { read(relativePath: string): Promise<string> },
|
|
168
|
+
relativePath: string,
|
|
169
|
+
): Promise<CddRuleDocument> {
|
|
170
|
+
try {
|
|
171
|
+
return parseCddRules(await files.read(relativePath));
|
|
172
|
+
} catch (error) {
|
|
173
|
+
// SAFETY: node:fs 읽기 실패의 code만 읽어 규칙 문서 부재를 구분합니다.
|
|
174
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return {};
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function createDefaultCddToolingAdapter({
|
|
180
|
+
contractRoot,
|
|
181
|
+
fs = defaultFs,
|
|
182
|
+
}: {
|
|
183
|
+
contractRoot: string;
|
|
184
|
+
fs?: CddFileSystem;
|
|
185
|
+
}) {
|
|
186
|
+
const files = createCddFileOperation({ contractRoot, fs });
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
async read(input: { path: string }) {
|
|
190
|
+
return { content: await files.read(input.path), fileType: "contract" as const };
|
|
191
|
+
},
|
|
192
|
+
async rules() {
|
|
193
|
+
let entries;
|
|
194
|
+
try {
|
|
195
|
+
entries = await files.readDirectory("rules");
|
|
196
|
+
} catch (error) {
|
|
197
|
+
// SAFETY: node:fs 디렉터리 조회 실패의 code만 읽어 규칙 디렉터리 부재를 구분합니다.
|
|
198
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return { rules: [] };
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const rules = [];
|
|
203
|
+
for (const entry of entries) {
|
|
204
|
+
if (!entry.isFile() || !entry.name.endsWith(".rules.json")) continue;
|
|
205
|
+
const key = entry.name.replace(/\.rules\.json$/, "");
|
|
206
|
+
const relativePath = `rules/${entry.name}`;
|
|
207
|
+
const document = parseCddRules(await files.read(relativePath));
|
|
208
|
+
rules.push({
|
|
209
|
+
key,
|
|
210
|
+
path: relativePath,
|
|
211
|
+
description: document.description ?? "",
|
|
212
|
+
ruleCount: document.rules?.length ?? 0,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return { rules };
|
|
216
|
+
},
|
|
217
|
+
async showRule(input: { ruleId: string }) {
|
|
218
|
+
const relativePath = `rules/${input.ruleId}.rules.json`;
|
|
219
|
+
return {
|
|
220
|
+
key: input.ruleId,
|
|
221
|
+
path: relativePath,
|
|
222
|
+
...parseCddRules(await files.read(relativePath)),
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
async addRule(input: {
|
|
226
|
+
ruleKey: string;
|
|
227
|
+
id: string;
|
|
228
|
+
when: string;
|
|
229
|
+
text: string;
|
|
230
|
+
examples?: string[];
|
|
231
|
+
dryRun: boolean;
|
|
232
|
+
}) {
|
|
233
|
+
const rule = { ruleKey: input.ruleKey, id: input.id, when: input.when, text: input.text };
|
|
234
|
+
if (input.dryRun) return { dryRun: true as const, rule };
|
|
235
|
+
|
|
236
|
+
const relativePath = `rules/${input.ruleKey}.rules.json`;
|
|
237
|
+
const document = await readCddRuleDocument(files, relativePath);
|
|
238
|
+
document.rules ??= [];
|
|
239
|
+
document.rules.push({
|
|
240
|
+
id: input.id,
|
|
241
|
+
when: input.when,
|
|
242
|
+
instruction: input.text,
|
|
243
|
+
examples: input.examples ?? [],
|
|
244
|
+
});
|
|
245
|
+
await files.write(relativePath, `${JSON.stringify(document, null, 2)}\n`);
|
|
246
|
+
return { key: input.ruleKey, path: relativePath, ...document };
|
|
247
|
+
},
|
|
248
|
+
async addAcceptanceCriterion(input: { document: string; text: string; dryRun: boolean }) {
|
|
249
|
+
if (input.dryRun)
|
|
250
|
+
return { operation: "addAcceptanceCriterion" as const, input, dryRun: true };
|
|
251
|
+
const contents = await files.read(input.document);
|
|
252
|
+
await files.write(input.document, `${contents}\n- ${input.text}\n`);
|
|
253
|
+
return { document: input.document, text: input.text, applied: true as const };
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
}
|