@zyno-io/ts-server-foundation 26.712.36
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/README.md +31 -0
- package/dist/devconsole/assets/index-BlWLbczn.css +1 -0
- package/dist/devconsole/assets/index-lSF6DUY3.js +3 -0
- package/dist/devconsole/index.html +13 -0
- package/dist/src/app/base.d.ts +66 -0
- package/dist/src/app/base.d.ts.map +1 -0
- package/dist/src/app/base.js +577 -0
- package/dist/src/app/base.js.map +1 -0
- package/dist/src/app/commands.d.ts +20 -0
- package/dist/src/app/commands.d.ts.map +1 -0
- package/dist/src/app/commands.js +17 -0
- package/dist/src/app/commands.js.map +1 -0
- package/dist/src/app/config-loader.d.ts +9 -0
- package/dist/src/app/config-loader.d.ts.map +1 -0
- package/dist/src/app/config-loader.js +91 -0
- package/dist/src/app/config-loader.js.map +1 -0
- package/dist/src/app/config.d.ts +96 -0
- package/dist/src/app/config.d.ts.map +1 -0
- package/dist/src/app/config.js +114 -0
- package/dist/src/app/config.js.map +1 -0
- package/dist/src/app/const.d.ts +5 -0
- package/dist/src/app/const.d.ts.map +1 -0
- package/dist/src/app/const.js +17 -0
- package/dist/src/app/const.js.map +1 -0
- package/dist/src/app/current.d.ts +5 -0
- package/dist/src/app/current.d.ts.map +1 -0
- package/dist/src/app/current.js +14 -0
- package/dist/src/app/current.js.map +1 -0
- package/dist/src/app/index.d.ts +8 -0
- package/dist/src/app/index.d.ts.map +1 -0
- package/dist/src/app/index.js +13 -0
- package/dist/src/app/index.js.map +1 -0
- package/dist/src/app/lifecycle.d.ts +9 -0
- package/dist/src/app/lifecycle.d.ts.map +1 -0
- package/dist/src/app/lifecycle.js +21 -0
- package/dist/src/app/lifecycle.js.map +1 -0
- package/dist/src/app/migrations-entrypoint.d.ts +3 -0
- package/dist/src/app/migrations-entrypoint.d.ts.map +1 -0
- package/dist/src/app/migrations-entrypoint.js +35 -0
- package/dist/src/app/migrations-entrypoint.js.map +1 -0
- package/dist/src/app/resolver.d.ts +6 -0
- package/dist/src/app/resolver.d.ts.map +1 -0
- package/dist/src/app/resolver.js +15 -0
- package/dist/src/app/resolver.js.map +1 -0
- package/dist/src/auth/index.d.ts +3 -0
- package/dist/src/auth/index.d.ts.map +1 -0
- package/dist/src/auth/index.js +15 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/jwt.d.ts +61 -0
- package/dist/src/auth/jwt.d.ts.map +1 -0
- package/dist/src/auth/jwt.js +379 -0
- package/dist/src/auth/jwt.js.map +1 -0
- package/dist/src/auth/provider.d.ts +21 -0
- package/dist/src/auth/provider.d.ts.map +1 -0
- package/dist/src/auth/provider.js +148 -0
- package/dist/src/auth/provider.js.map +1 -0
- package/dist/src/cli/common.d.ts +13 -0
- package/dist/src/cli/common.d.ts.map +1 -0
- package/dist/src/cli/common.js +99 -0
- package/dist/src/cli/common.js.map +1 -0
- package/dist/src/cli/tsf-create-app.d.ts +3 -0
- package/dist/src/cli/tsf-create-app.d.ts.map +1 -0
- package/dist/src/cli/tsf-create-app.js +89 -0
- package/dist/src/cli/tsf-create-app.js.map +1 -0
- package/dist/src/cli/tsf-dev.d.ts +3 -0
- package/dist/src/cli/tsf-dev.d.ts.map +1 -0
- package/dist/src/cli/tsf-dev.js +753 -0
- package/dist/src/cli/tsf-dev.js.map +1 -0
- package/dist/src/cli/tsf-gen-proto.d.ts +3 -0
- package/dist/src/cli/tsf-gen-proto.d.ts.map +1 -0
- package/dist/src/cli/tsf-gen-proto.js +134 -0
- package/dist/src/cli/tsf-gen-proto.js.map +1 -0
- package/dist/src/cli/tsf-install.d.ts +8 -0
- package/dist/src/cli/tsf-install.d.ts.map +1 -0
- package/dist/src/cli/tsf-install.js +424 -0
- package/dist/src/cli/tsf-install.js.map +1 -0
- package/dist/src/cli/tsf-migrate.d.ts +3 -0
- package/dist/src/cli/tsf-migrate.d.ts.map +1 -0
- package/dist/src/cli/tsf-migrate.js +271 -0
- package/dist/src/cli/tsf-migrate.js.map +1 -0
- package/dist/src/cli/tsf-test.d.ts +4 -0
- package/dist/src/cli/tsf-test.d.ts.map +1 -0
- package/dist/src/cli/tsf-test.js +350 -0
- package/dist/src/cli/tsf-test.js.map +1 -0
- package/dist/src/cli/tsf-update.d.ts +3 -0
- package/dist/src/cli/tsf-update.d.ts.map +1 -0
- package/dist/src/cli/tsf-update.js +12 -0
- package/dist/src/cli/tsf-update.js.map +1 -0
- package/dist/src/cli/tsf.d.ts +3 -0
- package/dist/src/cli/tsf.d.ts.map +1 -0
- package/dist/src/cli/tsf.js +29 -0
- package/dist/src/cli/tsf.js.map +1 -0
- package/dist/src/database/database.d.ts +54 -0
- package/dist/src/database/database.d.ts.map +1 -0
- package/dist/src/database/database.js +695 -0
- package/dist/src/database/database.js.map +1 -0
- package/dist/src/database/driver.d.ts +28 -0
- package/dist/src/database/driver.d.ts.map +1 -0
- package/dist/src/database/driver.js +5 -0
- package/dist/src/database/driver.js.map +1 -0
- package/dist/src/database/drivers/index.d.ts +4 -0
- package/dist/src/database/drivers/index.d.ts.map +1 -0
- package/dist/src/database/drivers/index.js +9 -0
- package/dist/src/database/drivers/index.js.map +1 -0
- package/dist/src/database/drivers/mysql-session-rpc.d.ts +40 -0
- package/dist/src/database/drivers/mysql-session-rpc.d.ts.map +1 -0
- package/dist/src/database/drivers/mysql-session-rpc.js +180 -0
- package/dist/src/database/drivers/mysql-session-rpc.js.map +1 -0
- package/dist/src/database/drivers/mysql-session.d.ts +25 -0
- package/dist/src/database/drivers/mysql-session.d.ts.map +1 -0
- package/dist/src/database/drivers/mysql-session.js +124 -0
- package/dist/src/database/drivers/mysql-session.js.map +1 -0
- package/dist/src/database/drivers/mysql.d.ts +20 -0
- package/dist/src/database/drivers/mysql.d.ts.map +1 -0
- package/dist/src/database/drivers/mysql.js +84 -0
- package/dist/src/database/drivers/mysql.js.map +1 -0
- package/dist/src/database/drivers/postgres.d.ts +22 -0
- package/dist/src/database/drivers/postgres.d.ts.map +1 -0
- package/dist/src/database/drivers/postgres.js +80 -0
- package/dist/src/database/drivers/postgres.js.map +1 -0
- package/dist/src/database/entity.d.ts +112 -0
- package/dist/src/database/entity.d.ts.map +1 -0
- package/dist/src/database/entity.js +333 -0
- package/dist/src/database/entity.js.map +1 -0
- package/dist/src/database/errors.d.ts +7 -0
- package/dist/src/database/errors.d.ts.map +1 -0
- package/dist/src/database/errors.js +34 -0
- package/dist/src/database/errors.js.map +1 -0
- package/dist/src/database/factory.d.ts +48 -0
- package/dist/src/database/factory.d.ts.map +1 -0
- package/dist/src/database/factory.js +139 -0
- package/dist/src/database/factory.js.map +1 -0
- package/dist/src/database/identifiers.d.ts +8 -0
- package/dist/src/database/identifiers.d.ts.map +1 -0
- package/dist/src/database/identifiers.js +46 -0
- package/dist/src/database/identifiers.js.map +1 -0
- package/dist/src/database/index.d.ts +14 -0
- package/dist/src/database/index.d.ts.map +1 -0
- package/dist/src/database/index.js +33 -0
- package/dist/src/database/index.js.map +1 -0
- package/dist/src/database/metadata.d.ts +27 -0
- package/dist/src/database/metadata.d.ts.map +1 -0
- package/dist/src/database/metadata.js +70 -0
- package/dist/src/database/metadata.js.map +1 -0
- package/dist/src/database/migration/create/comparator.d.ts +3 -0
- package/dist/src/database/migration/create/comparator.d.ts.map +1 -0
- package/dist/src/database/migration/create/comparator.js +302 -0
- package/dist/src/database/migration/create/comparator.js.map +1 -0
- package/dist/src/database/migration/create/db-reader.d.ts +9 -0
- package/dist/src/database/migration/create/db-reader.d.ts.map +1 -0
- package/dist/src/database/migration/create/db-reader.js +478 -0
- package/dist/src/database/migration/create/db-reader.js.map +1 -0
- package/dist/src/database/migration/create/ddl-generator.d.ts +4 -0
- package/dist/src/database/migration/create/ddl-generator.d.ts.map +1 -0
- package/dist/src/database/migration/create/ddl-generator.js +431 -0
- package/dist/src/database/migration/create/ddl-generator.js.map +1 -0
- package/dist/src/database/migration/create/entity-reader.d.ts +7 -0
- package/dist/src/database/migration/create/entity-reader.d.ts.map +1 -0
- package/dist/src/database/migration/create/entity-reader.js +169 -0
- package/dist/src/database/migration/create/entity-reader.js.map +1 -0
- package/dist/src/database/migration/create/file-generator.d.ts +7 -0
- package/dist/src/database/migration/create/file-generator.d.ts.map +1 -0
- package/dist/src/database/migration/create/file-generator.js +60 -0
- package/dist/src/database/migration/create/file-generator.js.map +1 -0
- package/dist/src/database/migration/create/index.d.ts +19 -0
- package/dist/src/database/migration/create/index.d.ts.map +1 -0
- package/dist/src/database/migration/create/index.js +102 -0
- package/dist/src/database/migration/create/index.js.map +1 -0
- package/dist/src/database/migration/create/schema-model.d.ts +99 -0
- package/dist/src/database/migration/create/schema-model.d.ts.map +1 -0
- package/dist/src/database/migration/create/schema-model.js +24 -0
- package/dist/src/database/migration/create/schema-model.js.map +1 -0
- package/dist/src/database/migration/create/type-mapper.d.ts +13 -0
- package/dist/src/database/migration/create/type-mapper.d.ts.map +1 -0
- package/dist/src/database/migration/create/type-mapper.js +293 -0
- package/dist/src/database/migration/create/type-mapper.js.map +1 -0
- package/dist/src/database/migration/index.d.ts +33 -0
- package/dist/src/database/migration/index.d.ts.map +1 -0
- package/dist/src/database/migration/index.js +165 -0
- package/dist/src/database/migration/index.js.map +1 -0
- package/dist/src/database/migration/maintenance.d.ts +26 -0
- package/dist/src/database/migration/maintenance.d.ts.map +1 -0
- package/dist/src/database/migration/maintenance.js +65 -0
- package/dist/src/database/migration/maintenance.js.map +1 -0
- package/dist/src/database/query.d.ts +79 -0
- package/dist/src/database/query.d.ts.map +1 -0
- package/dist/src/database/query.js +435 -0
- package/dist/src/database/query.js.map +1 -0
- package/dist/src/database/schema.d.ts +147 -0
- package/dist/src/database/schema.d.ts.map +1 -0
- package/dist/src/database/schema.js +709 -0
- package/dist/src/database/schema.js.map +1 -0
- package/dist/src/database/session.d.ts +63 -0
- package/dist/src/database/session.d.ts.map +1 -0
- package/dist/src/database/session.js +226 -0
- package/dist/src/database/session.js.map +1 -0
- package/dist/src/database/sql.d.ts +37 -0
- package/dist/src/database/sql.d.ts.map +1 -0
- package/dist/src/database/sql.js +143 -0
- package/dist/src/database/sql.js.map +1 -0
- package/dist/src/database/values.d.ts +6 -0
- package/dist/src/database/values.d.ts.map +1 -0
- package/dist/src/database/values.js +237 -0
- package/dist/src/database/values.js.map +1 -0
- package/dist/src/devconsole/controller.d.ts +11 -0
- package/dist/src/devconsole/controller.d.ts.map +1 -0
- package/dist/src/devconsole/controller.js +78 -0
- package/dist/src/devconsole/controller.js.map +1 -0
- package/dist/src/devconsole/generated/devconsole.d.ts +306 -0
- package/dist/src/devconsole/generated/devconsole.d.ts.map +1 -0
- package/dist/src/devconsole/generated/devconsole.js +4029 -0
- package/dist/src/devconsole/generated/devconsole.js.map +1 -0
- package/dist/src/devconsole/index.d.ts +10 -0
- package/dist/src/devconsole/index.d.ts.map +1 -0
- package/dist/src/devconsole/index.js +26 -0
- package/dist/src/devconsole/index.js.map +1 -0
- package/dist/src/devconsole/observers.d.ts +4 -0
- package/dist/src/devconsole/observers.d.ts.map +1 -0
- package/dist/src/devconsole/observers.js +170 -0
- package/dist/src/devconsole/observers.js.map +1 -0
- package/dist/src/devconsole/runtime.d.ts +16 -0
- package/dist/src/devconsole/runtime.d.ts.map +1 -0
- package/dist/src/devconsole/runtime.js +48 -0
- package/dist/src/devconsole/runtime.js.map +1 -0
- package/dist/src/devconsole/security.d.ts +8 -0
- package/dist/src/devconsole/security.d.ts.map +1 -0
- package/dist/src/devconsole/security.js +33 -0
- package/dist/src/devconsole/security.js.map +1 -0
- package/dist/src/devconsole/server.d.ts +25 -0
- package/dist/src/devconsole/server.d.ts.map +1 -0
- package/dist/src/devconsole/server.js +452 -0
- package/dist/src/devconsole/server.js.map +1 -0
- package/dist/src/devconsole/store.d.ts +111 -0
- package/dist/src/devconsole/store.d.ts.map +1 -0
- package/dist/src/devconsole/store.js +177 -0
- package/dist/src/devconsole/store.js.map +1 -0
- package/dist/src/di/container.d.ts +38 -0
- package/dist/src/di/container.d.ts.map +1 -0
- package/dist/src/di/container.js +252 -0
- package/dist/src/di/container.js.map +1 -0
- package/dist/src/di/errors.d.ts +18 -0
- package/dist/src/di/errors.d.ts.map +1 -0
- package/dist/src/di/errors.js +71 -0
- package/dist/src/di/errors.js.map +1 -0
- package/dist/src/di/index.d.ts +5 -0
- package/dist/src/di/index.d.ts.map +1 -0
- package/dist/src/di/index.js +10 -0
- package/dist/src/di/index.js.map +1 -0
- package/dist/src/di/module.d.ts +29 -0
- package/dist/src/di/module.d.ts.map +1 -0
- package/dist/src/di/module.js +42 -0
- package/dist/src/di/module.js.map +1 -0
- package/dist/src/di/provider.d.ts +34 -0
- package/dist/src/di/provider.d.ts.map +1 -0
- package/dist/src/di/provider.js +24 -0
- package/dist/src/di/provider.js.map +1 -0
- package/dist/src/env.d.ts +122 -0
- package/dist/src/env.d.ts.map +1 -0
- package/dist/src/env.js +61 -0
- package/dist/src/env.js.map +1 -0
- package/dist/src/events/event-bus.d.ts +26 -0
- package/dist/src/events/event-bus.d.ts.map +1 -0
- package/dist/src/events/event-bus.js +67 -0
- package/dist/src/events/event-bus.js.map +1 -0
- package/dist/src/events/index.d.ts +2 -0
- package/dist/src/events/index.d.ts.map +1 -0
- package/dist/src/events/index.js +7 -0
- package/dist/src/events/index.js.map +1 -0
- package/dist/src/health/healthcheck.controller.d.ts +9 -0
- package/dist/src/health/healthcheck.controller.d.ts.map +1 -0
- package/dist/src/health/healthcheck.controller.js +33 -0
- package/dist/src/health/healthcheck.controller.js.map +1 -0
- package/dist/src/health/healthcheck.service.d.ts +13 -0
- package/dist/src/health/healthcheck.service.d.ts.map +1 -0
- package/dist/src/health/healthcheck.service.js +37 -0
- package/dist/src/health/healthcheck.service.js.map +1 -0
- package/dist/src/health/index.d.ts +3 -0
- package/dist/src/health/index.d.ts.map +1 -0
- package/dist/src/health/index.js +8 -0
- package/dist/src/health/index.js.map +1 -0
- package/dist/src/helpers/async/context.d.ts +10 -0
- package/dist/src/helpers/async/context.d.ts.map +1 -0
- package/dist/src/helpers/async/context.js +52 -0
- package/dist/src/helpers/async/context.js.map +1 -0
- package/dist/src/helpers/async/process.d.ts +16 -0
- package/dist/src/helpers/async/process.d.ts.map +1 -0
- package/dist/src/helpers/async/process.js +62 -0
- package/dist/src/helpers/async/process.js.map +1 -0
- package/dist/src/helpers/async/promise.d.ts +11 -0
- package/dist/src/helpers/async/promise.d.ts.map +1 -0
- package/dist/src/helpers/async/promise.js +32 -0
- package/dist/src/helpers/async/promise.js.map +1 -0
- package/dist/src/helpers/data/array.d.ts +5 -0
- package/dist/src/helpers/data/array.d.ts.map +1 -0
- package/dist/src/helpers/data/array.js +27 -0
- package/dist/src/helpers/data/array.js.map +1 -0
- package/dist/src/helpers/data/objects.d.ts +13 -0
- package/dist/src/helpers/data/objects.d.ts.map +1 -0
- package/dist/src/helpers/data/objects.js +55 -0
- package/dist/src/helpers/data/objects.js.map +1 -0
- package/dist/src/helpers/data/serialization.d.ts +5 -0
- package/dist/src/helpers/data/serialization.d.ts.map +1 -0
- package/dist/src/helpers/data/serialization.js +25 -0
- package/dist/src/helpers/data/serialization.js.map +1 -0
- package/dist/src/helpers/data/transformer.d.ts +13 -0
- package/dist/src/helpers/data/transformer.d.ts.map +1 -0
- package/dist/src/helpers/data/transformer.js +50 -0
- package/dist/src/helpers/data/transformer.js.map +1 -0
- package/dist/src/helpers/index.d.ts +19 -0
- package/dist/src/helpers/index.d.ts.map +1 -0
- package/dist/src/helpers/index.js +30 -0
- package/dist/src/helpers/index.js.map +1 -0
- package/dist/src/helpers/io/package.d.ts +10 -0
- package/dist/src/helpers/io/package.d.ts.map +1 -0
- package/dist/src/helpers/io/package.js +35 -0
- package/dist/src/helpers/io/package.js.map +1 -0
- package/dist/src/helpers/io/stream.d.ts +18 -0
- package/dist/src/helpers/io/stream.d.ts.map +1 -0
- package/dist/src/helpers/io/stream.js +131 -0
- package/dist/src/helpers/io/stream.js.map +1 -0
- package/dist/src/helpers/redis/broadcast.d.ts +15 -0
- package/dist/src/helpers/redis/broadcast.d.ts.map +1 -0
- package/dist/src/helpers/redis/broadcast.js +93 -0
- package/dist/src/helpers/redis/broadcast.js.map +1 -0
- package/dist/src/helpers/redis/cache.d.ts +20 -0
- package/dist/src/helpers/redis/cache.d.ts.map +1 -0
- package/dist/src/helpers/redis/cache.js +57 -0
- package/dist/src/helpers/redis/cache.js.map +1 -0
- package/dist/src/helpers/redis/mutex.d.ts +45 -0
- package/dist/src/helpers/redis/mutex.d.ts.map +1 -0
- package/dist/src/helpers/redis/mutex.js +446 -0
- package/dist/src/helpers/redis/mutex.js.map +1 -0
- package/dist/src/helpers/redis/redis.d.ts +12 -0
- package/dist/src/helpers/redis/redis.d.ts.map +1 -0
- package/dist/src/helpers/redis/redis.js +62 -0
- package/dist/src/helpers/redis/redis.js.map +1 -0
- package/dist/src/helpers/security/crypto.d.ts +31 -0
- package/dist/src/helpers/security/crypto.d.ts.map +1 -0
- package/dist/src/helpers/security/crypto.js +108 -0
- package/dist/src/helpers/security/crypto.js.map +1 -0
- package/dist/src/helpers/security/validation.d.ts +3 -0
- package/dist/src/helpers/security/validation.d.ts.map +1 -0
- package/dist/src/helpers/security/validation.js +14 -0
- package/dist/src/helpers/security/validation.js.map +1 -0
- package/dist/src/helpers/utils/date.d.ts +4 -0
- package/dist/src/helpers/utils/date.d.ts.map +1 -0
- package/dist/src/helpers/utils/date.js +16 -0
- package/dist/src/helpers/utils/date.js.map +1 -0
- package/dist/src/helpers/utils/error.d.ts +20 -0
- package/dist/src/helpers/utils/error.d.ts.map +1 -0
- package/dist/src/helpers/utils/error.js +164 -0
- package/dist/src/helpers/utils/error.js.map +1 -0
- package/dist/src/helpers/utils/uuid.d.ts +5 -0
- package/dist/src/helpers/utils/uuid.d.ts.map +1 -0
- package/dist/src/helpers/utils/uuid.js +13 -0
- package/dist/src/helpers/utils/uuid.js.map +1 -0
- package/dist/src/http/auth.d.ts +20 -0
- package/dist/src/http/auth.d.ts.map +1 -0
- package/dist/src/http/auth.js +68 -0
- package/dist/src/http/auth.js.map +1 -0
- package/dist/src/http/base.d.ts +57 -0
- package/dist/src/http/base.d.ts.map +1 -0
- package/dist/src/http/base.js +331 -0
- package/dist/src/http/base.js.map +1 -0
- package/dist/src/http/context.d.ts +6 -0
- package/dist/src/http/context.d.ts.map +1 -0
- package/dist/src/http/context.js +26 -0
- package/dist/src/http/context.js.map +1 -0
- package/dist/src/http/cors.d.ts +25 -0
- package/dist/src/http/cors.d.ts.map +1 -0
- package/dist/src/http/cors.js +124 -0
- package/dist/src/http/cors.js.map +1 -0
- package/dist/src/http/decorators.d.ts +64 -0
- package/dist/src/http/decorators.d.ts.map +1 -0
- package/dist/src/http/decorators.js +102 -0
- package/dist/src/http/decorators.js.map +1 -0
- package/dist/src/http/errors.d.ts +50 -0
- package/dist/src/http/errors.d.ts.map +1 -0
- package/dist/src/http/errors.js +158 -0
- package/dist/src/http/errors.js.map +1 -0
- package/dist/src/http/index.d.ts +31 -0
- package/dist/src/http/index.d.ts.map +1 -0
- package/dist/src/http/index.js +33 -0
- package/dist/src/http/index.js.map +1 -0
- package/dist/src/http/middleware.d.ts +12 -0
- package/dist/src/http/middleware.d.ts.map +1 -0
- package/dist/src/http/middleware.js +31 -0
- package/dist/src/http/middleware.js.map +1 -0
- package/dist/src/http/parameter-resolvers.d.ts +3 -0
- package/dist/src/http/parameter-resolvers.d.ts.map +1 -0
- package/dist/src/http/parameter-resolvers.js +8 -0
- package/dist/src/http/parameter-resolvers.js.map +1 -0
- package/dist/src/http/request-logging.d.ts +34 -0
- package/dist/src/http/request-logging.d.ts.map +1 -0
- package/dist/src/http/request-logging.js +130 -0
- package/dist/src/http/request-logging.js.map +1 -0
- package/dist/src/http/request.d.ts +69 -0
- package/dist/src/http/request.d.ts.map +1 -0
- package/dist/src/http/request.js +366 -0
- package/dist/src/http/request.js.map +1 -0
- package/dist/src/http/response.d.ts +98 -0
- package/dist/src/http/response.d.ts.map +1 -0
- package/dist/src/http/response.js +292 -0
- package/dist/src/http/response.js.map +1 -0
- package/dist/src/http/router.d.ts +100 -0
- package/dist/src/http/router.d.ts.map +1 -0
- package/dist/src/http/router.js +1085 -0
- package/dist/src/http/router.js.map +1 -0
- package/dist/src/http/startup-logging.d.ts +8 -0
- package/dist/src/http/startup-logging.d.ts.map +1 -0
- package/dist/src/http/startup-logging.js +55 -0
- package/dist/src/http/startup-logging.js.map +1 -0
- package/dist/src/http/static-files.d.ts +15 -0
- package/dist/src/http/static-files.d.ts.map +1 -0
- package/dist/src/http/static-files.js +110 -0
- package/dist/src/http/static-files.js.map +1 -0
- package/dist/src/http/store.d.ts +8 -0
- package/dist/src/http/store.d.ts.map +1 -0
- package/dist/src/http/store.js +47 -0
- package/dist/src/http/store.js.map +1 -0
- package/dist/src/http/types.d.ts +23 -0
- package/dist/src/http/types.d.ts.map +1 -0
- package/dist/src/http/types.js +3 -0
- package/dist/src/http/types.js.map +1 -0
- package/dist/src/http/upgrade.d.ts +22 -0
- package/dist/src/http/upgrade.d.ts.map +1 -0
- package/dist/src/http/upgrade.js +164 -0
- package/dist/src/http/upgrade.js.map +1 -0
- package/dist/src/http/uploads.d.ts +36 -0
- package/dist/src/http/uploads.d.ts.map +1 -0
- package/dist/src/http/uploads.js +287 -0
- package/dist/src/http/uploads.js.map +1 -0
- package/dist/src/http/workflow.d.ts +34 -0
- package/dist/src/http/workflow.d.ts.map +1 -0
- package/dist/src/http/workflow.js +40 -0
- package/dist/src/http/workflow.js.map +1 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +88 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/openapi/controller.d.ts +9 -0
- package/dist/src/openapi/controller.d.ts.map +1 -0
- package/dist/src/openapi/controller.js +45 -0
- package/dist/src/openapi/controller.js.map +1 -0
- package/dist/src/openapi/index.d.ts +5 -0
- package/dist/src/openapi/index.d.ts.map +1 -0
- package/dist/src/openapi/index.js +21 -0
- package/dist/src/openapi/index.js.map +1 -0
- package/dist/src/openapi/schema.d.ts +26 -0
- package/dist/src/openapi/schema.d.ts.map +1 -0
- package/dist/src/openapi/schema.js +1128 -0
- package/dist/src/openapi/schema.js.map +1 -0
- package/dist/src/openapi/serializer.d.ts +16 -0
- package/dist/src/openapi/serializer.d.ts.map +1 -0
- package/dist/src/openapi/serializer.js +506 -0
- package/dist/src/openapi/serializer.js.map +1 -0
- package/dist/src/openapi/types.d.ts +84 -0
- package/dist/src/openapi/types.d.ts.map +1 -0
- package/dist/src/openapi/types.js +5 -0
- package/dist/src/openapi/types.js.map +1 -0
- package/dist/src/reflection/annotations.d.ts +15 -0
- package/dist/src/reflection/annotations.d.ts.map +1 -0
- package/dist/src/reflection/annotations.js +228 -0
- package/dist/src/reflection/annotations.js.map +1 -0
- package/dist/src/reflection/conversion.d.ts +15 -0
- package/dist/src/reflection/conversion.d.ts.map +1 -0
- package/dist/src/reflection/conversion.js +360 -0
- package/dist/src/reflection/conversion.js.map +1 -0
- package/dist/src/reflection/deserializer.d.ts +15 -0
- package/dist/src/reflection/deserializer.d.ts.map +1 -0
- package/dist/src/reflection/deserializer.js +42 -0
- package/dist/src/reflection/deserializer.js.map +1 -0
- package/dist/src/reflection/entity.d.ts +9 -0
- package/dist/src/reflection/entity.d.ts.map +1 -0
- package/dist/src/reflection/entity.js +74 -0
- package/dist/src/reflection/entity.js.map +1 -0
- package/dist/src/reflection/errors.d.ts +8 -0
- package/dist/src/reflection/errors.d.ts.map +1 -0
- package/dist/src/reflection/errors.js +21 -0
- package/dist/src/reflection/errors.js.map +1 -0
- package/dist/src/reflection/index.d.ts +8 -0
- package/dist/src/reflection/index.d.ts.map +1 -0
- package/dist/src/reflection/index.js +13 -0
- package/dist/src/reflection/index.js.map +1 -0
- package/dist/src/reflection/metadata-store.d.ts +14 -0
- package/dist/src/reflection/metadata-store.d.ts.map +1 -0
- package/dist/src/reflection/metadata-store.js +18 -0
- package/dist/src/reflection/metadata-store.js.map +1 -0
- package/dist/src/reflection/model.d.ts +271 -0
- package/dist/src/reflection/model.d.ts.map +1 -0
- package/dist/src/reflection/model.js +36 -0
- package/dist/src/reflection/model.js.map +1 -0
- package/dist/src/reflection/reflection-class.d.ts +60 -0
- package/dist/src/reflection/reflection-class.d.ts.map +1 -0
- package/dist/src/reflection/reflection-class.js +263 -0
- package/dist/src/reflection/reflection-class.js.map +1 -0
- package/dist/src/reflection/type-utils.d.ts +34 -0
- package/dist/src/reflection/type-utils.d.ts.map +1 -0
- package/dist/src/reflection/type-utils.js +485 -0
- package/dist/src/reflection/type-utils.js.map +1 -0
- package/dist/src/reflection.d.ts +2 -0
- package/dist/src/reflection.d.ts.map +1 -0
- package/dist/src/reflection.js +5 -0
- package/dist/src/reflection.js.map +1 -0
- package/dist/src/services/cli.d.ts +9 -0
- package/dist/src/services/cli.d.ts.map +1 -0
- package/dist/src/services/cli.js +47 -0
- package/dist/src/services/cli.js.map +1 -0
- package/dist/src/services/index.d.ts +8 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +13 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/leader.d.ts +31 -0
- package/dist/src/services/leader.d.ts.map +1 -0
- package/dist/src/services/leader.js +176 -0
- package/dist/src/services/leader.js.map +1 -0
- package/dist/src/services/logger.d.ts +60 -0
- package/dist/src/services/logger.d.ts.map +1 -0
- package/dist/src/services/logger.js +349 -0
- package/dist/src/services/logger.js.map +1 -0
- package/dist/src/services/mail/index.d.ts +57 -0
- package/dist/src/services/mail/index.d.ts.map +1 -0
- package/dist/src/services/mail/index.js +89 -0
- package/dist/src/services/mail/index.js.map +1 -0
- package/dist/src/services/mail/postmark.d.ts +11 -0
- package/dist/src/services/mail/postmark.d.ts.map +1 -0
- package/dist/src/services/mail/postmark.js +41 -0
- package/dist/src/services/mail/postmark.js.map +1 -0
- package/dist/src/services/mail/smtp.d.ts +11 -0
- package/dist/src/services/mail/smtp.d.ts.map +1 -0
- package/dist/src/services/mail/smtp.js +50 -0
- package/dist/src/services/mail/smtp.js.map +1 -0
- package/dist/src/services/mesh-client/index.d.ts +9 -0
- package/dist/src/services/mesh-client/index.d.ts.map +1 -0
- package/dist/src/services/mesh-client/index.js +18 -0
- package/dist/src/services/mesh-client/index.js.map +1 -0
- package/dist/src/services/mesh-client/mesh-client-redis-registry.d.ts +23 -0
- package/dist/src/services/mesh-client/mesh-client-redis-registry.d.ts.map +1 -0
- package/dist/src/services/mesh-client/mesh-client-redis-registry.js +360 -0
- package/dist/src/services/mesh-client/mesh-client-redis-registry.js.map +1 -0
- package/dist/src/services/mesh-client/mesh-client-registry.d.ts +16 -0
- package/dist/src/services/mesh-client/mesh-client-registry.d.ts.map +1 -0
- package/dist/src/services/mesh-client/mesh-client-registry.js +44 -0
- package/dist/src/services/mesh-client/mesh-client-registry.js.map +1 -0
- package/dist/src/services/mesh-client/mesh-client-service.d.ts +88 -0
- package/dist/src/services/mesh-client/mesh-client-service.d.ts.map +1 -0
- package/dist/src/services/mesh-client/mesh-client-service.js +222 -0
- package/dist/src/services/mesh-client/mesh-client-service.js.map +1 -0
- package/dist/src/services/mesh-client/mesh-srpc-server.d.ts +95 -0
- package/dist/src/services/mesh-client/mesh-srpc-server.d.ts.map +1 -0
- package/dist/src/services/mesh-client/mesh-srpc-server.js +475 -0
- package/dist/src/services/mesh-client/mesh-srpc-server.js.map +1 -0
- package/dist/src/services/mesh-client/types.d.ts +36 -0
- package/dist/src/services/mesh-client/types.d.ts.map +1 -0
- package/dist/src/services/mesh-client/types.js +38 -0
- package/dist/src/services/mesh-client/types.js.map +1 -0
- package/dist/src/services/mesh.d.ts +73 -0
- package/dist/src/services/mesh.d.ts.map +1 -0
- package/dist/src/services/mesh.js +511 -0
- package/dist/src/services/mesh.js.map +1 -0
- package/dist/src/services/worker/entity.d.ts +26 -0
- package/dist/src/services/worker/entity.d.ts.map +1 -0
- package/dist/src/services/worker/entity.js +30 -0
- package/dist/src/services/worker/entity.js.map +1 -0
- package/dist/src/services/worker/index.d.ts +25 -0
- package/dist/src/services/worker/index.d.ts.map +1 -0
- package/dist/src/services/worker/index.js +52 -0
- package/dist/src/services/worker/index.js.map +1 -0
- package/dist/src/services/worker/observer.d.ts +13 -0
- package/dist/src/services/worker/observer.d.ts.map +1 -0
- package/dist/src/services/worker/observer.js +22 -0
- package/dist/src/services/worker/observer.js.map +1 -0
- package/dist/src/services/worker/queue.d.ts +38 -0
- package/dist/src/services/worker/queue.d.ts.map +1 -0
- package/dist/src/services/worker/queue.js +227 -0
- package/dist/src/services/worker/queue.js.map +1 -0
- package/dist/src/services/worker/recorder.d.ts +17 -0
- package/dist/src/services/worker/recorder.d.ts.map +1 -0
- package/dist/src/services/worker/recorder.js +88 -0
- package/dist/src/services/worker/recorder.js.map +1 -0
- package/dist/src/services/worker/runner.d.ts +37 -0
- package/dist/src/services/worker/runner.d.ts.map +1 -0
- package/dist/src/services/worker/runner.js +319 -0
- package/dist/src/services/worker/runner.js.map +1 -0
- package/dist/src/services/worker/types.d.ts +63 -0
- package/dist/src/services/worker/types.d.ts.map +1 -0
- package/dist/src/services/worker/types.js +38 -0
- package/dist/src/services/worker/types.js.map +1 -0
- package/dist/src/srpc/SrpcByteStream.d.ts +60 -0
- package/dist/src/srpc/SrpcByteStream.d.ts.map +1 -0
- package/dist/src/srpc/SrpcByteStream.js +237 -0
- package/dist/src/srpc/SrpcByteStream.js.map +1 -0
- package/dist/src/srpc/SrpcClient.d.ts +67 -0
- package/dist/src/srpc/SrpcClient.d.ts.map +1 -0
- package/dist/src/srpc/SrpcClient.js +406 -0
- package/dist/src/srpc/SrpcClient.js.map +1 -0
- package/dist/src/srpc/SrpcServer.d.ts +56 -0
- package/dist/src/srpc/SrpcServer.d.ts.map +1 -0
- package/dist/src/srpc/SrpcServer.js +519 -0
- package/dist/src/srpc/SrpcServer.js.map +1 -0
- package/dist/src/srpc/index.d.ts +9 -0
- package/dist/src/srpc/index.d.ts.map +1 -0
- package/dist/src/srpc/index.js +17 -0
- package/dist/src/srpc/index.js.map +1 -0
- package/dist/src/srpc/observer.d.ts +21 -0
- package/dist/src/srpc/observer.d.ts.map +1 -0
- package/dist/src/srpc/observer.js +22 -0
- package/dist/src/srpc/observer.js.map +1 -0
- package/dist/src/srpc/types.d.ts +92 -0
- package/dist/src/srpc/types.d.ts.map +1 -0
- package/dist/src/srpc/types.js +28 -0
- package/dist/src/srpc/types.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +3 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/index.js +22 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/otel/helpers.d.ts +45 -0
- package/dist/src/telemetry/otel/helpers.d.ts.map +1 -0
- package/dist/src/telemetry/otel/helpers.js +142 -0
- package/dist/src/telemetry/otel/helpers.js.map +1 -0
- package/dist/src/telemetry/otel/index.d.ts +22 -0
- package/dist/src/telemetry/otel/index.d.ts.map +1 -0
- package/dist/src/telemetry/otel/index.js +268 -0
- package/dist/src/telemetry/otel/index.js.map +1 -0
- package/dist/src/telemetry/otel/metrics.controller.d.ts +5 -0
- package/dist/src/telemetry/otel/metrics.controller.d.ts.map +1 -0
- package/dist/src/telemetry/otel/metrics.controller.js +82 -0
- package/dist/src/telemetry/otel/metrics.controller.js.map +1 -0
- package/dist/src/telemetry/otel/metrics.d.ts +2 -0
- package/dist/src/telemetry/otel/metrics.d.ts.map +1 -0
- package/dist/src/telemetry/otel/metrics.js +16 -0
- package/dist/src/telemetry/otel/metrics.js.map +1 -0
- package/dist/src/telemetry/sentry.d.ts +9 -0
- package/dist/src/telemetry/sentry.d.ts.map +1 -0
- package/dist/src/telemetry/sentry.js +63 -0
- package/dist/src/telemetry/sentry.js.map +1 -0
- package/dist/src/testing/database-readiness.d.ts +11 -0
- package/dist/src/testing/database-readiness.d.ts.map +1 -0
- package/dist/src/testing/database-readiness.js +102 -0
- package/dist/src/testing/database-readiness.js.map +1 -0
- package/dist/src/testing/expect.d.ts +21 -0
- package/dist/src/testing/expect.d.ts.map +1 -0
- package/dist/src/testing/expect.js +110 -0
- package/dist/src/testing/expect.js.map +1 -0
- package/dist/src/testing/fixtures.d.ts +18 -0
- package/dist/src/testing/fixtures.d.ts.map +1 -0
- package/dist/src/testing/fixtures.js +46 -0
- package/dist/src/testing/fixtures.js.map +1 -0
- package/dist/src/testing/index.d.ts +143 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +993 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/mysql-session-manager-process.d.ts +3 -0
- package/dist/src/testing/mysql-session-manager-process.d.ts.map +1 -0
- package/dist/src/testing/mysql-session-manager-process.js +77 -0
- package/dist/src/testing/mysql-session-manager-process.js.map +1 -0
- package/dist/src/testing/mysql-session-manager.d.ts +59 -0
- package/dist/src/testing/mysql-session-manager.d.ts.map +1 -0
- package/dist/src/testing/mysql-session-manager.js +910 -0
- package/dist/src/testing/mysql-session-manager.js.map +1 -0
- package/dist/src/testing/sql.d.ts +47 -0
- package/dist/src/testing/sql.d.ts.map +1 -0
- package/dist/src/testing/sql.js +313 -0
- package/dist/src/testing/sql.js.map +1 -0
- package/dist/src/type-compiler/go/ast_expression.go +161 -0
- package/dist/src/type-compiler/go/ast_metadata.go +355 -0
- package/dist/src/type-compiler/go/collect.go +806 -0
- package/dist/src/type-compiler/go/emission_plan.go +205 -0
- package/dist/src/type-compiler/go/emit_ast.go +406 -0
- package/dist/src/type-compiler/go/emit_ast_test.go +248 -0
- package/dist/src/type-compiler/go/go.mod +10 -0
- package/dist/src/type-compiler/go/plugin.go +308 -0
- package/dist/src/type-compiler/go/plugin_test.go +752 -0
- package/dist/src/type-compiler/go/precompute.go +86 -0
- package/dist/src/type-compiler/go/receive_type.go +837 -0
- package/dist/src/type-compiler/go/resolve.go +265 -0
- package/dist/src/type-compiler/go/source_scan.go +51 -0
- package/dist/src/type-compiler/go/text_parse.go +671 -0
- package/dist/src/type-compiler/go/type_expr.go +1227 -0
- package/dist/src/type-compiler/go/typia_expr.go +2119 -0
- package/dist/src/type-compiler/index.cjs +6 -0
- package/dist/src/types/index.d.ts +7 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +14 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/phone.d.ts +6 -0
- package/dist/src/types/phone.d.ts.map +1 -0
- package/dist/src/types/phone.js +64 -0
- package/dist/src/types/phone.js.map +1 -0
- package/dist/src/types/primitives.d.ts +33 -0
- package/dist/src/types/primitives.d.ts.map +1 -0
- package/dist/src/types/primitives.js +5 -0
- package/dist/src/types/primitives.js.map +1 -0
- package/dist/src/types/runtime.d.ts +5 -0
- package/dist/src/types/runtime.d.ts.map +1 -0
- package/dist/src/types/runtime.js +20 -0
- package/dist/src/types/runtime.js.map +1 -0
- package/dist/src/types/type-annotations.d.ts +28 -0
- package/dist/src/types/type-annotations.d.ts.map +1 -0
- package/dist/src/types/type-annotations.js +33 -0
- package/dist/src/types/type-annotations.js.map +1 -0
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +7 -0
- package/dist/src/types.js.map +1 -0
- package/docs/.vitepress/config.mts +85 -0
- package/docs/content/CONTRIBUTING.md +53 -0
- package/docs/content/README-DEV.md +59 -0
- package/docs/content/README.md +52 -0
- package/docs/content/authentication.md +213 -0
- package/docs/content/cli.md +214 -0
- package/docs/content/configuration.md +191 -0
- package/docs/content/database.md +476 -0
- package/docs/content/devconsole.md +148 -0
- package/docs/content/di.md +212 -0
- package/docs/content/documentation-plan.md +182 -0
- package/docs/content/env.md +120 -0
- package/docs/content/getting-started.md +324 -0
- package/docs/content/health.md +64 -0
- package/docs/content/helpers.md +294 -0
- package/docs/content/http.md +402 -0
- package/docs/content/index.md +109 -0
- package/docs/content/leader-service.md +98 -0
- package/docs/content/logging.md +225 -0
- package/docs/content/mail.md +171 -0
- package/docs/content/mesh-client.md +333 -0
- package/docs/content/mesh-service.md +255 -0
- package/docs/content/migrations.md +190 -0
- package/docs/content/openapi.md +134 -0
- package/docs/content/overview.md +98 -0
- package/docs/content/public/images/devconsole/01-dashboard.png +0 -0
- package/docs/content/public/images/devconsole/02-routes.png +0 -0
- package/docs/content/public/images/devconsole/03-openapi.png +0 -0
- package/docs/content/public/images/devconsole/04-requests.png +0 -0
- package/docs/content/public/images/devconsole/05-srpc.png +0 -0
- package/docs/content/public/images/devconsole/06-database.png +0 -0
- package/docs/content/public/images/devconsole/06b-database-log.png +0 -0
- package/docs/content/public/images/devconsole/07-health.png +0 -0
- package/docs/content/public/images/devconsole/08-mutex.png +0 -0
- package/docs/content/public/images/devconsole/09-repl.png +0 -0
- package/docs/content/public/images/devconsole/10-workers.png +0 -0
- package/docs/content/public-api.md +84 -0
- package/docs/content/redis.md +174 -0
- package/docs/content/reflection.md +180 -0
- package/docs/content/release.md +100 -0
- package/docs/content/sql.md +121 -0
- package/docs/content/srpc.md +292 -0
- package/docs/content/telemetry.md +173 -0
- package/docs/content/testing.md +327 -0
- package/docs/content/type-reflection-architecture.md +149 -0
- package/docs/content/types.md +286 -0
- package/docs/content/uploads.md +145 -0
- package/docs/content/worker.md +182 -0
- package/docs/openapi.md +3 -0
- package/package.json +124 -0
- package/resources/proto/devconsole.proto +286 -0
- package/template-app/.env.development +10 -0
- package/template-app/gitignore.tmpl +11 -0
- package/template-app/package.json.tmpl +25 -0
- package/template-app/src/app.ts +13 -0
- package/template-app/src/config.ts +5 -0
- package/template-app/src/controllers/Example.controller.ts +19 -0
- package/template-app/src/database.ts +5 -0
- package/template-app/src/entities/Example.entity.ts +9 -0
- package/template-app/src/index.ts +7 -0
- package/template-app/src/migrations/.gitkeep +2 -0
- package/template-app/src/services/Example.service.ts +20 -0
- package/template-app/tests/app.spec.ts +8 -0
- package/template-app/tsconfig.json +26 -0
- package/template-app/tsconfig.test.json +5 -0
- package/types.d.ts +4 -0
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
# Database
|
|
2
|
+
|
|
3
|
+
TSF provides a small database layer over `mysql2` and `pg`. It includes database factories, entity metadata, active-record helpers, sessions, transactions, raw SQL with bindings, a query builder, session locks, and schema migration tooling.
|
|
4
|
+
|
|
5
|
+
## Database Classes
|
|
6
|
+
|
|
7
|
+
Register entities with a database class and pass that class to `createApp()`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { BaseAppConfig, createApp, createDatabase } from '@zyno-io/ts-server-foundation';
|
|
11
|
+
import { User } from './entities/User';
|
|
12
|
+
|
|
13
|
+
class AppConfig extends BaseAppConfig {}
|
|
14
|
+
|
|
15
|
+
class AppDatabase extends createDatabase('postgres', {}, [User]) {}
|
|
16
|
+
|
|
17
|
+
export const app = createApp({
|
|
18
|
+
config: AppConfig,
|
|
19
|
+
db: AppDatabase
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Available factories:
|
|
24
|
+
|
|
25
|
+
| Factory | Description |
|
|
26
|
+
| ------------------------------------------------------- | ------------------------------------------------ |
|
|
27
|
+
| `createDatabase(config, entities)` | Selects `mysql` or `postgres` from `DB_ADAPTER`. |
|
|
28
|
+
| `createDatabase('mysql', config, entities)` | Creates a MySQL/MariaDB database class. |
|
|
29
|
+
| `createDatabase('postgres', config, entities)` | Creates a PostgreSQL database class. |
|
|
30
|
+
| `createMySQLDatabase(config, entities)` | MySQL/MariaDB-specific factory. |
|
|
31
|
+
| `createPostgresDatabase(config, entities)` | PostgreSQL-specific factory. |
|
|
32
|
+
| `createDatabaseClass(driverFactory, entities, options)` | Wraps a custom `DatabaseDriver`. |
|
|
33
|
+
|
|
34
|
+
Factory config accepts the native driver pool config plus TSF options:
|
|
35
|
+
|
|
36
|
+
| Option | Description |
|
|
37
|
+
| ------------------ | --------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `enableLocksTable` | Enables MySQL session locks through a lock table. PostgreSQL uses advisory transaction locks. |
|
|
39
|
+
| `lockTableName` | MySQL lock table name. Defaults to `_locks`. |
|
|
40
|
+
|
|
41
|
+
When pool options are omitted, connection settings are read from config/environment keys such as `MYSQL_HOST`, `MYSQL_DATABASE`, `PG_HOST`, and `PG_DATABASE`.
|
|
42
|
+
|
|
43
|
+
## Entities
|
|
44
|
+
|
|
45
|
+
Registered database entity classes must extend `BaseEntity`; database construction rejects other classes. `BaseEntity` supplies the active-record helpers and lets the database bind each entity class to its owning database.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { AutoIncrement, BaseEntity, entity, MaxLength, PrimaryKey, UuidString } from '@zyno-io/ts-server-foundation';
|
|
49
|
+
|
|
50
|
+
@entity.name('users')
|
|
51
|
+
export class User extends BaseEntity {
|
|
52
|
+
id!: number & PrimaryKey & AutoIncrement;
|
|
53
|
+
publicId!: UuidString;
|
|
54
|
+
email!: string & MaxLength<255>;
|
|
55
|
+
name!: string & MaxLength<120>;
|
|
56
|
+
createdAt: Date = new Date();
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The migration generator reads entity metadata to infer table names, column names, indexes, primary keys, defaults, nullability, enums, foreign keys, and custom TSF types. See [Types](./types.md) for the database effects of `UuidString`, `DateString`, `Length<N>`, and related annotations.
|
|
61
|
+
|
|
62
|
+
## Runtime Value Conversion And Validation
|
|
63
|
+
|
|
64
|
+
Database I/O does not run the reflected HTTP-input deserializer or validator over whole entities. TSF instead performs a small set of column-aware storage conversions and otherwise relies on the database driver and database engine.
|
|
65
|
+
|
|
66
|
+
| Path | Outbound conversion | Inbound conversion | Reflected validation |
|
|
67
|
+
| ---------------------------------------------- | ------------------------------------------------------------- | ---------------------------------------------------------------- | -------------------- |
|
|
68
|
+
| Entity `save()` / `saveEntity()` | Column-aware | N/A | No |
|
|
69
|
+
| Query-builder filters and patches | Column-aware | N/A | No |
|
|
70
|
+
| Query-builder entity hydration | N/A | Column-aware | No |
|
|
71
|
+
| `createEntity()` and related constructors | None; assigns application values and fills framework defaults | N/A | No |
|
|
72
|
+
| `rawFind<T>()` / `rawFindOne<T>()` | Generic SQL binding normalization only | Driver values returned unchanged | No |
|
|
73
|
+
| `rawFindUnsafe<T>()` / `rawFindOneUnsafe<T>()` | Generic SQL binding normalization only | Reflected `deserialize<T>()` when compiler metadata is available | No |
|
|
74
|
+
|
|
75
|
+
Column-aware writes perform these conversions:
|
|
76
|
+
|
|
77
|
+
- `UUID` values become 16-byte MySQL values and normalized PostgreSQL UUID strings.
|
|
78
|
+
- Database `date` columns receive a UTC `YYYY-MM-DD` value.
|
|
79
|
+
- `Date` values bound to other columns become UTC SQL date-time strings.
|
|
80
|
+
- `Buffer`, `Uint8Array`, and `ArrayBuffer` values are normalized for binary columns.
|
|
81
|
+
- JSON columns are encoded with `JSON.stringify`.
|
|
82
|
+
- MySQL point columns accept `Coordinate`/GeoJSON-like values and are written with `ST_GeomFromText`.
|
|
83
|
+
- JavaScript `bigint` SQL bindings become decimal strings.
|
|
84
|
+
|
|
85
|
+
Query-builder hydration creates an entity instance and reverses the applicable storage conversions. It normalizes UUIDs, date-only strings, binary values, JSON strings, and MySQL points, then coerces reflected boolean columns, bigint columns, and finite numeric strings. Other values retain the form supplied by `mysql2` or `pg`; for example, timestamp object behavior can depend on the driver configuration.
|
|
86
|
+
|
|
87
|
+
These converters are not validators. They do not apply `TrimmedString`, phone normalization, email/pattern checks, length checks, numeric bounds, `ValidDate`, or custom reflected validators. A conversion that does not recognize a value generally leaves it unchanged. Database column types and constraints then determine whether the value is accepted. Nullability, uniqueness, foreign keys, enum/column types, widths, and other generated schema constraints are enforced by the database engine; reflected rules that are not represented in the schema are not enforced during persistence.
|
|
88
|
+
|
|
89
|
+
If application code needs runtime validation before persistence, call the compiler-backed `validate<T>()` or `validatedDeserialize<T>()` at the application boundary. HTTP DTO parameters already do this automatically before controller invocation.
|
|
90
|
+
|
|
91
|
+
## Active Record Helpers
|
|
92
|
+
|
|
93
|
+
Entities registered with a database can query and persist themselves.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const users = await User.query().filter({ email: 'a@example.com' }).find();
|
|
97
|
+
|
|
98
|
+
const user = User.reference(1);
|
|
99
|
+
user.name = 'Alice';
|
|
100
|
+
await user.save();
|
|
101
|
+
await user.delete();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`reference(value)` creates a clean entity reference with the primary key populated. It is useful when an API expects an entity instance but no database read is needed.
|
|
105
|
+
|
|
106
|
+
## Entity Creation
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { createEntity, createPersistedEntity, createQueuedEntity, persistEntity } from '@zyno-io/ts-server-foundation';
|
|
110
|
+
|
|
111
|
+
const user = createEntity(User, { email: 'a@example.com', name: 'Alice' });
|
|
112
|
+
|
|
113
|
+
await db.transaction(async session => {
|
|
114
|
+
const queued = createQueuedEntity(User, { email: 'b@example.com', name: 'Bob' }, session);
|
|
115
|
+
queued.name = 'Bobby';
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const persisted = await createPersistedEntity(User, { email: 'c@example.com', name: 'Carol' });
|
|
119
|
+
await persistEntity(user);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`createEntity()` fills omitted auto-increment fields with `0` and nullable fields with `null`. Fields annotated with `HasDefault` can be omitted from inserts when their value is `undefined`.
|
|
123
|
+
|
|
124
|
+
Related helpers:
|
|
125
|
+
|
|
126
|
+
| Helper | Description |
|
|
127
|
+
| --------------------------------------------------- | -------------------------------------------------- |
|
|
128
|
+
| `createEntities(Entity, data[])` | Creates multiple unsaved entities. |
|
|
129
|
+
| `createQueuedEntities(Entity, data[], session)` | Creates and queues multiple entities in a session. |
|
|
130
|
+
| `createPersistedEntities(Entity, data[], session?)` | Creates and persists multiple entities. |
|
|
131
|
+
| `persistEntities(entities, session?)` | Persists multiple existing entities. |
|
|
132
|
+
|
|
133
|
+
## Retrieval Helpers
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { entityExists, getEntity, getEntityOr404, getEntityOrUndefined } from '@zyno-io/ts-server-foundation';
|
|
137
|
+
|
|
138
|
+
const user = await getEntity(User, 1);
|
|
139
|
+
const maybeUser = await getEntityOrUndefined(User, { email: 'a@example.com' });
|
|
140
|
+
const requiredUser = await getEntityOr404(User, 1);
|
|
141
|
+
const exists = await entityExists(User, { email: 'a@example.com' });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
`getEntity()` throws `ItemNotFound`. `getEntityOr404()` throws `HttpNotFoundError`.
|
|
145
|
+
|
|
146
|
+
## Batched Lookups And Relations
|
|
147
|
+
|
|
148
|
+
The batched lookup helpers issue one `$in` query, deduplicate input IDs, and return hydrated entities:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { getEntitiesById, getKeyedEntities, getKeyedGroupedEntities } from '@zyno-io/ts-server-foundation';
|
|
152
|
+
|
|
153
|
+
const users = await getEntitiesById({ schema: User, ids: [3, 1, 3] });
|
|
154
|
+
const usersById = await getKeyedEntities({ schema: User, ids: [1, 2, 3] });
|
|
155
|
+
const postsByAuthorId = await getKeyedGroupedEntities({
|
|
156
|
+
schema: Post,
|
|
157
|
+
ids: [1, 2, 3],
|
|
158
|
+
keyField: 'authorId'
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Options shared by these helpers:
|
|
163
|
+
|
|
164
|
+
| Option | Meaning |
|
|
165
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
166
|
+
| `schema` | Registered `BaseEntity` class to query. |
|
|
167
|
+
| `ids` | Values for the primary key or `keyField`. Duplicate and empty falsey values are ignored; number or bigint ID `0` is retained. |
|
|
168
|
+
| `keyField` | Field used for the `$in` query and returned object keys. Defaults to the entity primary key. |
|
|
169
|
+
| `fields` | Optional projected fields. Include the key field when requesting a keyed result. |
|
|
170
|
+
| `filter` | Additional query-builder filters. |
|
|
171
|
+
| `txn` | Optional `DatabaseSession` used for the query. |
|
|
172
|
+
|
|
173
|
+
`getKeyedEntities()` returns one entity per stringified key. If multiple rows share a key, the last row wins. `getKeyedGroupedEntities()` preserves all rows in an array per stringified key. Present keys such as `__proto__`, `constructor`, and `toString` are stored as own data properties. Use `Object.hasOwn(result, key)` before reading an arbitrary key. `getEntitiesByIdWithKeyName()` exposes the resolved key-field name together with the entity array for integrations that need both.
|
|
174
|
+
|
|
175
|
+
Relation resolvers attach lookup results to existing source objects:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { resolveRelated, resolveRelatedByPivot } from '@zyno-io/ts-server-foundation';
|
|
179
|
+
|
|
180
|
+
await resolveRelated({
|
|
181
|
+
src: posts,
|
|
182
|
+
srcIdField: 'authorId',
|
|
183
|
+
targetField: 'author',
|
|
184
|
+
targetSchema: User
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
await resolveRelatedByPivot({
|
|
188
|
+
src: users,
|
|
189
|
+
pivotSchema: UserRole,
|
|
190
|
+
pivotIdKey: 'userId',
|
|
191
|
+
pivotRelatedKey: 'roleId',
|
|
192
|
+
targetField: 'roles',
|
|
193
|
+
targetSchema: Role
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`resolveRelated()` assigns one related entity, or `undefined` when no matching row exists. `resolveRelatedByPivot()` assigns an array; every related result also has its pivot entity under `pivot`. It defaults the source ID field to the source entity primary key. `resolveRelatedByPivotForOne()` is the single-source convenience form. All resolver forms mutate and return the supplied source objects. When using `targetFields`, include the target primary key so results can be keyed.
|
|
198
|
+
|
|
199
|
+
## Query Builder
|
|
200
|
+
|
|
201
|
+
`db.query(Entity)` and `Entity.query()` return a `QueryBuilder`.
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
const users = await db
|
|
205
|
+
.query(User)
|
|
206
|
+
.filter({ active: true, age: { $gte: 18 } })
|
|
207
|
+
.sort({ name: 'asc', id: -1 })
|
|
208
|
+
.limit(50)
|
|
209
|
+
.offset(100)
|
|
210
|
+
.find();
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Supported filter operators:
|
|
214
|
+
|
|
215
|
+
| Operator | SQL behavior |
|
|
216
|
+
| ---------------------------- | ------------------------------------------------------------------------------ |
|
|
217
|
+
| `{ field: value }` | Equality, with `null` mapped to `IS NULL`. |
|
|
218
|
+
| `$ne` | Not equal, with `null` mapped to `IS NOT NULL`. |
|
|
219
|
+
| `$gt`, `$gte`, `$lt`, `$lte` | Comparison operators. |
|
|
220
|
+
| `$in`, `$nin` | Inclusion/exclusion lists. Empty `$in` is false; `$nin` always excludes nulls. |
|
|
221
|
+
| `$like`, `$notLike` | SQL `LIKE` and `NOT LIKE` pattern matching. |
|
|
222
|
+
| `$and`, `$or` | Top-level arrays of nested filter records. Empty `$or` is always false. |
|
|
223
|
+
|
|
224
|
+
Because `$nin` excludes `null`/`undefined` values as well as listed values, an empty `$nin` renders as `IS NOT NULL`.
|
|
225
|
+
|
|
226
|
+
Query methods:
|
|
227
|
+
|
|
228
|
+
| Method | Description |
|
|
229
|
+
| ---------------------------------------------- | -------------------------------------------------------------------- |
|
|
230
|
+
| `filter()` / `filterField()` | Adds equality or operator filters. |
|
|
231
|
+
| `select(...fields)` | Limits hydrated results to selected entity fields. |
|
|
232
|
+
| `orderBy()` / `sort()` | Adds ordering; `sort()` also accepts a field-direction object. |
|
|
233
|
+
| `limit()` / `offset()` / `skip()` | Applies result paging. |
|
|
234
|
+
| `find()` | Returns hydrated entities. |
|
|
235
|
+
| `findOne()` / `findOneOrUndefined()` | Returns one entity, throwing or returning `undefined` when absent. |
|
|
236
|
+
| `findField(field)` | Returns a single field from each row. |
|
|
237
|
+
| `findOneField()` / `findOneFieldOrUndefined()` | Returns one selected scalar field. |
|
|
238
|
+
| `withMax(field)` | Selects `MAX(field)`; read it with `findField(field)`. |
|
|
239
|
+
| `has()` | Returns whether at least one row exists. |
|
|
240
|
+
| `count()` | Returns a numeric count. |
|
|
241
|
+
| `patchMany(patch)` | Updates rows matched by the query and returns affected primary keys. |
|
|
242
|
+
| `patchOne(patch)` | Directly updates the row identified by an exact primary-key filter. |
|
|
243
|
+
| `deleteMany()` | Deletes rows matched by the query and returns affected primary keys. |
|
|
244
|
+
| `deleteOne()` | Directly deletes the row identified by an exact primary-key filter. |
|
|
245
|
+
| `toSelectSql()` / `toCountSql()` | Returns a SQL fragment for inspection or composition. |
|
|
246
|
+
|
|
247
|
+
`patchOne()` and `deleteOne()` require top-level exact equality filters for every primary-key component. Additional filters can be used for conditional mutations, such as transitioning a row only when it has an expected status.
|
|
248
|
+
|
|
249
|
+
Patch operations accept direct assignments and a top-level `$inc` object:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
const result = await User.query()
|
|
253
|
+
.filter({ tenantId, active: true })
|
|
254
|
+
.patchMany({ lastSeenAt: new Date(), $inc: { loginCount: 1 } });
|
|
255
|
+
|
|
256
|
+
result.affectedRows;
|
|
257
|
+
result.primaryKeys; // [{ id: ... }, ...]
|
|
258
|
+
result.modified; // compatibility alias for affectedRows
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
All mutation methods return `QueryMutationResult`. Its enumerable fields are `affectedRows` and `primaryKeys`; `modified` is a non-enumerable compatibility alias.
|
|
262
|
+
|
|
263
|
+
## Sessions And Transactions
|
|
264
|
+
|
|
265
|
+
`db.transaction()` opens a connection, starts a transaction, waits for tracked query mutations, flushes queued/managed entities before commit, and rolls back on error. Use it for all connection-scoped work, including raw SQL sequences.
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
await db.transaction(async session => {
|
|
269
|
+
const user = createQueuedEntity(User, { email: 'a@example.com', name: 'Alice' }, session);
|
|
270
|
+
session.addPreCommitHook(async () => {
|
|
271
|
+
await session.rawExecute(sql`INSERT INTO audit_log (message) VALUES (${'created user'})`);
|
|
272
|
+
});
|
|
273
|
+
session.addPostCommitHook(async () => {
|
|
274
|
+
await notifyUserCreated(user.id);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Unprojected entities loaded through `session.query(Entity)` become managed. A managed entity is dirty-checked and saved again at the next flush or commit. Projected queries (`select(...)`) are not managed. Session query reads do not flush queued writes first; session raw methods do.
|
|
280
|
+
|
|
281
|
+
Session methods:
|
|
282
|
+
|
|
283
|
+
| Method | Description |
|
|
284
|
+
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
285
|
+
| `add(...entities)` | Queues new or existing entities for persistence. |
|
|
286
|
+
| `manage(...entities)` | Adds clean existing entities to dirty tracking for later flushes. |
|
|
287
|
+
| `remove(...entities)` | Cancels an unflushed new insert, or queues a managed/snapshotted entity for deletion. |
|
|
288
|
+
| `removeQueued(...entities)` | Removes only the queued-persistence state. |
|
|
289
|
+
| `unmanage(...entities)` | Clears queued, managed, and removal state for the entities. |
|
|
290
|
+
| `flush()` | Inserts queued entities, saves dirty managed entities, then performs queued deletions. |
|
|
291
|
+
| `query(Entity)` | Creates a query builder bound to the session connection. |
|
|
292
|
+
| `rawQuery()`, `rawFind()`, `rawFindOne()`, `rawExecute()` | Flushes, then executes SQL through the session connection. |
|
|
293
|
+
| `raw(input)` | Returns an object with `execute()`, `find()`, and `findOne()` for one SQL input. |
|
|
294
|
+
| `rawFindUnsafe()`, `rawFindOneUnsafe()`, `rawExecuteUnsafe()` | Flushes, then executes string SQL with manual bindings. |
|
|
295
|
+
| `trackOperation(fn)` / `waitForPendingOperations()` | Tracks query mutations so transaction commit waits for them and propagates rejection. |
|
|
296
|
+
| `withoutAutoFlush(fn)` | Temporarily suppresses database-method auto-flush behavior for internal/composed reads. |
|
|
297
|
+
| `savepoint(name)` | Flushes and creates a transaction savepoint. |
|
|
298
|
+
| `rollbackToSavepoint(name)` | Rolls back to a savepoint. |
|
|
299
|
+
| `withSavepoint(name, fn)` | Runs a block and restores queued/managed/removal and hook state if the block throws. |
|
|
300
|
+
| `addPreCommitHook(fn)` | Runs serially before commit, after normal flushes; failure rolls back the transaction. |
|
|
301
|
+
| `addPostCommitHook(fn)` | Runs serially after successful commit; it is skipped on rollback. |
|
|
302
|
+
| `acquireSessionLock(key)` | Acquires a transaction-scoped database lock. |
|
|
303
|
+
|
|
304
|
+
Use `db.withTransaction(existingSession, fn)` when helper functions should reuse a caller-provided session if one exists, or open a transaction otherwise.
|
|
305
|
+
|
|
306
|
+
`db.withConnection(fn)` scopes one acquired connection to all raw operations for that database inside the callback. Nested calls reuse the same connection, and the outer call releases it when the callback settles. It does not start a transaction; use `transaction()` when atomicity is required.
|
|
307
|
+
|
|
308
|
+
## Session Locks
|
|
309
|
+
|
|
310
|
+
Locks are transaction-scoped.
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
await db.transaction(async session => {
|
|
314
|
+
await session.acquireSessionLock(['billing-account', accountId]);
|
|
315
|
+
await recalculateBalance(accountId, session);
|
|
316
|
+
});
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
PostgreSQL uses `pg_advisory_xact_lock()`. MySQL/MariaDB uses a `_locks` table. Set `enableLocksTable: true` to let TSF create and prune that table automatically, or provision the DKSF-compatible table yourself.
|
|
320
|
+
|
|
321
|
+
## Raw SQL
|
|
322
|
+
|
|
323
|
+
Use the `sql` tag for values and identifiers.
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
import { sql } from '@zyno-io/ts-server-foundation';
|
|
327
|
+
|
|
328
|
+
const rows = await db.rawFind<{ id: number; email: string }>(
|
|
329
|
+
sql`SELECT ${sql.identifier('id')}, ${sql.identifier('email')}
|
|
330
|
+
FROM ${sql.identifier('users')}
|
|
331
|
+
WHERE ${sql.identifier('active')} = ${true}`
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
await db.rawExecute(
|
|
335
|
+
sql`UPDATE ${sql.identifier('users')}
|
|
336
|
+
SET ${sql.identifier('lastLoginAt')} = ${new Date()}
|
|
337
|
+
WHERE ${sql.identifier('id')} = ${userId}`
|
|
338
|
+
);
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
`rawQuery<T>()` is the base row-returning method, and `rawFind<T>()` is its alias. `rawFindOne()` returns the first row or `undefined`. `rawExecute()` returns `{ affectedRows, rowCount?, insertId?, warningStatus? }`.
|
|
342
|
+
|
|
343
|
+
The generic type on `rawFind<T>()` is a TypeScript-only assertion: returned rows keep the values produced by the database driver. The unsafe string methods have an additional compiler-injected reflected type slot, so `rawFindUnsafe<T>()` and `rawFindOneUnsafe<T>()` pass rows through `deserialize<T>()` when that metadata is available. That operation can coerce nested values or construct reflected classes, but it does not validate the rows. Prefer the query builder when entity column-aware hydration is required.
|
|
344
|
+
|
|
345
|
+
The unsafe variants accept a SQL string and bindings:
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
await db.rawFindUnsafe('SELECT * FROM users WHERE email = ?', ['a@example.com']);
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
See [SQL](./sql.md) for fragment composition and rendering details.
|
|
352
|
+
|
|
353
|
+
## Database Errors
|
|
354
|
+
|
|
355
|
+
MySQL duplicate-entry errors (`ER_DUP_ENTRY`/errno `1062`) and PostgreSQL unique violations (`23505`) are normalized to `UniqueConstraintError` at query, execute, and transaction boundaries. The normalized error retains the driver error as `cause`.
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
import { isUniqueConstraintError } from '@zyno-io/ts-server-foundation';
|
|
359
|
+
|
|
360
|
+
try {
|
|
361
|
+
await user.save();
|
|
362
|
+
} catch (error) {
|
|
363
|
+
if (!isUniqueConstraintError(error)) throw error;
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Other driver errors pass through unchanged. `normalizeDatabaseError()` is exported for integrations that need the same normalization outside `BaseDatabase`.
|
|
368
|
+
|
|
369
|
+
## Dirty Tracking
|
|
370
|
+
|
|
371
|
+
Hydrated entities are marked clean. `save()` or `saveEntity()` updates only changed non-primary-key fields.
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
import { getDirtyDetails, getDirtyFields, getFieldOriginal, isEntityDirty, isFieldDirty, revertDirtyEntity } from '@zyno-io/ts-server-foundation';
|
|
375
|
+
|
|
376
|
+
user.name = 'Alice Updated';
|
|
377
|
+
|
|
378
|
+
isEntityDirty(user); // true
|
|
379
|
+
getDirtyFields(user); // ['name']
|
|
380
|
+
isFieldDirty(user, 'name'); // true
|
|
381
|
+
getFieldOriginal(user, 'name'); // previous value
|
|
382
|
+
getDirtyDetails(user); // { name: { original, current } }
|
|
383
|
+
|
|
384
|
+
revertDirtyEntity(user);
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Schema Builder
|
|
388
|
+
|
|
389
|
+
`db.schema.create()` creates tables from an imperative builder. It is useful for hand-written migrations.
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
await db.schema.create('api_tokens', table => {
|
|
393
|
+
table.uuidString('id').primary();
|
|
394
|
+
table.string('name', 120);
|
|
395
|
+
table.string('tokenHash', 255).unique();
|
|
396
|
+
table.time('expiresAfterLocalTime').nullable();
|
|
397
|
+
table.dateTime('createdAt').defaultRaw('CURRENT_TIMESTAMP');
|
|
398
|
+
table.index(['name']);
|
|
399
|
+
});
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Database-level methods:
|
|
403
|
+
|
|
404
|
+
| Method | Behavior |
|
|
405
|
+
| ---------------------------- | ---------------------------------------------------------------------- |
|
|
406
|
+
| `create(name, callback)` | Creates a table, its indexes, and its foreign keys. |
|
|
407
|
+
| `alter(name, callback)` | Applies ordered drop, rename, add, and modify operations. |
|
|
408
|
+
| `drop()` / `dropIfExists()` | Drops a table, with optional existence guard. |
|
|
409
|
+
| `rename(from, to)` | Renames a table with dialect-specific SQL. |
|
|
410
|
+
| `enumType(name, values)` | Creates a PostgreSQL enum type and text cast; it is a no-op for MySQL. |
|
|
411
|
+
| `raw(statement)` | Executes a raw schema statement. |
|
|
412
|
+
| `onlyOn(dialect, callback)` | Runs an async schema callback only for the active dialect. |
|
|
413
|
+
| `hasTable()` / `hasColumn()` | Checks the active database's schema catalog. |
|
|
414
|
+
| `hasIndex()` | Checks the active database's index catalog. |
|
|
415
|
+
| `flush()` | Clears the in-memory PostgreSQL enum-type deduplication registry. |
|
|
416
|
+
|
|
417
|
+
Column methods:
|
|
418
|
+
|
|
419
|
+
| Family | Methods |
|
|
420
|
+
| --------------- | -------------------------------------------------------------------- |
|
|
421
|
+
| Identifiers | `id`, `uuidString`, `uuid` |
|
|
422
|
+
| Strings | `string`, `char`, `text`, `tinyText`, `mediumText`, `longText` |
|
|
423
|
+
| Integers | `integer`, `tinyint`, `smallint`, `bigint`, `bigInteger` |
|
|
424
|
+
| Numeric | `float`, `double`, `decimal` |
|
|
425
|
+
| Boolean | `boolean` |
|
|
426
|
+
| Date/time | `dateTime`, `timestamp`, `timestamptz`, `time`, `date`, `timestamps` |
|
|
427
|
+
| Structured/data | `json`, `jsonb`, `binary`, `blob`, `enum`, `point` |
|
|
428
|
+
|
|
429
|
+
`point()` is MySQL-only. `jsonb()` and binary/blob types choose the nearest supported representation for the active dialect. `timestamps()` adds `createdAt` and `updatedAt` defaults and a MySQL `ON UPDATE` expression.
|
|
430
|
+
|
|
431
|
+
MySQL booleans are emitted as `tinyint(1) unsigned`; PostgreSQL booleans are emitted as `boolean`. Generated schema and entity index/foreign-key names are shortened with a stable hash when they exceed the active dialect identifier limit.
|
|
432
|
+
|
|
433
|
+
Column modifiers:
|
|
434
|
+
|
|
435
|
+
`primary`, `nullable(value?)`, `notNull`, `unsigned(value?)`, `autoIncrement(value?)`, `default(value)`, `defaultRaw(expression)`, `onUpdate(expression)`, `index(name?)`, `unique(name?)`, `references(column)`, `change`, `after(column)`, and `first`.
|
|
436
|
+
|
|
437
|
+
`change()` marks a column declared inside `alter()` as a modification instead of an addition. `after()` and `first()` affect MySQL column placement; PostgreSQL does not emit a placement clause.
|
|
438
|
+
|
|
439
|
+
Table constraint methods:
|
|
440
|
+
|
|
441
|
+
- `primary(columns)` creates a composite/table primary key.
|
|
442
|
+
- `index(columns, name?)`, `unique(columns, name?)`, and `spatialIndex(columns, name?)` add indexes.
|
|
443
|
+
- `foreign(columns, name?)` returns a builder supporting `references()`, `referencesAll()`, `on()`, `onDelete()`, `onUpdate()`, and `name()`.
|
|
444
|
+
|
|
445
|
+
Alter-only removals and renames are `dropColumn`, `renameColumn`, `dropIndex`, `dropUnique`, `renameIndex`, `dropForeign`, and `dropPrimary`. Alter operations execute in dependency-aware groups: foreign keys and indexes are dropped before structural column changes, while new indexes and foreign keys are added afterward.
|
|
446
|
+
|
|
447
|
+
## Migrations
|
|
448
|
+
|
|
449
|
+
Migration files export a function or a `Migration` object.
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
import { createMigration, sql } from '@zyno-io/ts-server-foundation';
|
|
453
|
+
import type { BaseDatabase } from '@zyno-io/ts-server-foundation';
|
|
454
|
+
|
|
455
|
+
export default createMigration(async (db: BaseDatabase) => {
|
|
456
|
+
await db.rawExecute(sql`ALTER TABLE ${sql.identifier('users')} ADD ${sql.identifier('archivedAt')} datetime NULL`);
|
|
457
|
+
});
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Run compiled migrations with `tsf-migrate run`. Generate entity/database diffs with `tsf-migrate create`. See [Migrations](./migrations.md) for the full command reference.
|
|
461
|
+
|
|
462
|
+
The migration runner logs count summaries and per-migration lifecycle messages with the `Migrator` scope: migrations found, migrations previously executed, migrations to run, `Running migration: <name>`, and `Completed migration: <name>`.
|
|
463
|
+
|
|
464
|
+
## Query Observation
|
|
465
|
+
|
|
466
|
+
Database queries can be observed by DevConsole and tests.
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
import { registerDatabaseQueryObserver } from '@zyno-io/ts-server-foundation';
|
|
470
|
+
|
|
471
|
+
const stop = registerDatabaseQueryObserver(entry => {
|
|
472
|
+
if (entry.phase === 'finish') console.log(entry.sql, entry.durationMs, entry.error);
|
|
473
|
+
});
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
Observers receive start/finish events with SQL, bindings, dialect, operation, timing, and errors.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# DevConsole
|
|
2
|
+
|
|
3
|
+
A built-in web dashboard for development-time monitoring and debugging. It is automatically enabled when `APP_ENV=development`; other environments require `DEVCONSOLE_ENABLED=true`. It is accessible at `http://localhost:{PORT}/_devconsole/`.
|
|
4
|
+
|
|
5
|
+
DevConsole is zero-config, localhost-only, and requires no additional setup beyond running your app in development mode.
|
|
6
|
+
|
|
7
|
+
## Screenshots
|
|
8
|
+
|
|
9
|
+
### Dashboard
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
### Routes
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
### OpenAPI Schema
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
### HTTP Requests
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
### SRPC
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
### Database Entities
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
### Database Log
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
### Health Checks
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
### Mutex Monitor
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
### Interactive REPL
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
### Workers
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
## Views
|
|
54
|
+
|
|
55
|
+
### Dashboard
|
|
56
|
+
|
|
57
|
+
App overview showing name, version, environment, uptime, and real-time statistics (HTTP request count, SRPC connections/messages). Also displays process info: PID, Node version, platform, CPU usage, and memory consumption.
|
|
58
|
+
|
|
59
|
+
### Routes
|
|
60
|
+
|
|
61
|
+
Lists all registered HTTP routes with their methods, paths, controller class, and handler method. Internal `/_devconsole` routes are excluded.
|
|
62
|
+
|
|
63
|
+
### OpenAPI
|
|
64
|
+
|
|
65
|
+
Displays the OpenAPI schema generated from your HTTP routes. The schema is loaded from the app-level `/openapi.json` endpoint.
|
|
66
|
+
|
|
67
|
+
### Requests
|
|
68
|
+
|
|
69
|
+
HTTP request inspector capturing the last 500 requests. Shows timestamp, method, URL, status code, duration, and remote address. Expanding a request reveals full request/response headers and body previews (up to 64 KiB), plus error details with stack traces for failed requests. New requests appear in real time.
|
|
70
|
+
|
|
71
|
+
A search input filters the table by URL substring (case-insensitive). The **Clear** button removes all captured entries — this is synced across connected DevConsole clients via a server broadcast.
|
|
72
|
+
|
|
73
|
+
### SRPC
|
|
74
|
+
|
|
75
|
+
SRPC connection monitor showing active connections (client ID, stream ID, app version, address, uptime, ping, message count) and recent disconnections. Includes a message-level inspector (last 500 messages) showing type, direction, request ID, reply status, and errors. Messages can be filtered by stream ID.
|
|
76
|
+
|
|
77
|
+
A search input filters the per-connection message list by message type (case-insensitive). The **Clear** button removes all captured messages and recent disconnections — synced across clients.
|
|
78
|
+
|
|
79
|
+
### Database Entities
|
|
80
|
+
|
|
81
|
+
Entity browser listing all registered ORM entities with table names and columns. Includes a SQL query editor — `SELECT` queries return result rows, while `INSERT`/`UPDATE`/`DELETE` return affected row counts. Execute with Ctrl+Enter.
|
|
82
|
+
|
|
83
|
+
### Database Log
|
|
84
|
+
|
|
85
|
+
Live query log capturing SQL emitted through TSF's process-global database observer. Queries appear immediately with a **running** status and update on completion with duration and error info (last 500 entries). In a process containing multiple apps, the log can include queries from their database layers as described under [How It Works](#how-it-works).
|
|
86
|
+
|
|
87
|
+
The table shows timestamp, SQL (truncated), parameter count, duration, and status. Clicking a row opens a detail panel with:
|
|
88
|
+
|
|
89
|
+
- **Composite SQL** — the prepared SQL with binding placeholders replaced by their values inline, formatted for readability (dates as `'YYYY-MM-DD HH:mm:ss'` in UTC, strings escaped, numbers bare, booleans as `TRUE`/`FALSE`, JSON objects as quoted strings, nulls as `NULL`)
|
|
90
|
+
- **Prepared SQL** — the raw parameterized SQL
|
|
91
|
+
- **Bindings** — the parameter values as JSON
|
|
92
|
+
- **Error** — error message (if the query failed)
|
|
93
|
+
|
|
94
|
+
A search input filters by SQL substring. The **Clear** button removes all captured queries — synced across clients.
|
|
95
|
+
|
|
96
|
+
Query capture uses `registerDatabaseQueryObserver()`, which receives start and finish events from `BaseDatabase.rawFind()`, `BaseDatabase.rawExecute()`, sessions, and query builders.
|
|
97
|
+
|
|
98
|
+
### Health
|
|
99
|
+
|
|
100
|
+
Displays results from all registered health checks with status (ok/error) and error messages.
|
|
101
|
+
|
|
102
|
+
### Mutex
|
|
103
|
+
|
|
104
|
+
Redis mutex monitor showing active mutexes (key, status, timing) and a history of the last 200 completed/failed acquisitions with wait and hold duration metrics.
|
|
105
|
+
|
|
106
|
+
### REPL
|
|
107
|
+
|
|
108
|
+
Interactive JavaScript REPL running in the server's context. Resolve DI tokens with `resolve(token)`, `r(token)`, or `$(token)`. Supports Tab-completion, command history (arrow keys), and multiline input (Shift+Enter). Console output (`log`, `warn`, `error`) is captured and displayed.
|
|
109
|
+
|
|
110
|
+
The context also exposes `app`, `container`, `config`, an optional `db`, `process`, `Buffer`, and `inspect`. REPL code executes inside the server process with application privileges; the localhost restriction is the security boundary, so do not expose or proxy DevConsole to untrusted networks.
|
|
111
|
+
|
|
112
|
+
### Environment
|
|
113
|
+
|
|
114
|
+
Displays application configuration from the config class. Keys containing `SECRET`, `PASSWORD`, `DSN`, `TOKEN`, or `KEY` are masked.
|
|
115
|
+
|
|
116
|
+
### Workers
|
|
117
|
+
|
|
118
|
+
BullMQ job inspector showing queue statistics (active, waiting, delayed, completed, failed counts), live jobs, and the latest 200 in-memory entries from `WorkerRecorderService`.
|
|
119
|
+
|
|
120
|
+
## Architecture
|
|
121
|
+
|
|
122
|
+
### Transport
|
|
123
|
+
|
|
124
|
+
DevConsole uses SRPC over WebSocket (`/_devconsole/ws`) for bidirectional communication. The protocol is defined in `resources/proto/devconsole.proto` and uses Protocol Buffers for encoding.
|
|
125
|
+
|
|
126
|
+
Real-time events (new HTTP requests, SRPC messages, database queries, mutex state changes, worker jobs) are pushed from server to client without polling.
|
|
127
|
+
|
|
128
|
+
### Security
|
|
129
|
+
|
|
130
|
+
Access is restricted to localhost connections only. The `DevConsoleLocalhostMiddleware` checks that the request originates from `127.0.0.1` or `::1` using the socket's `remoteAddress` (not proxy headers). SRPC authentication is bypassed for DevConsole connections.
|
|
131
|
+
|
|
132
|
+
### How It Works
|
|
133
|
+
|
|
134
|
+
DevConsole is wired by `DevConsoleRuntime` when the app listens. Its HTTP observer belongs to that app. Database, SRPC, worker, and mutex observers are currently process-global and are not ownership-filtered, so multiple apps in one process can appear in the same console:
|
|
135
|
+
|
|
136
|
+
- **HTTP Runtime** — `app.http.registerObserver()` captures completed request/response data and controller errors.
|
|
137
|
+
- **SRPC** — `registerSrpcObserver()` observes messages and connection lifecycle.
|
|
138
|
+
- **Database** — `registerDatabaseQueryObserver()` captures query start/finish events with timing and errors.
|
|
139
|
+
- **Worker Recorder** — `registerWorkerObserver()` listens to BullMQ job lifecycle events.
|
|
140
|
+
- **Mutex (`withMutex`)** — `registerMutexObserver()` tracks mutex acquisitions and releases.
|
|
141
|
+
|
|
142
|
+
Visible HTTP, SRPC, database-query, and mutex histories are stored in ring buffers (`DevConsoleStore`). `WorkerRecorderService` history remains unbounded even though the UI returns only its latest 200 records, so long-running processes should account for that separate history.
|
|
143
|
+
|
|
144
|
+
### Frontend
|
|
145
|
+
|
|
146
|
+
The frontend is a Vue 3 SPA built with Vite. Source lives in `devconsole/` and builds to `dist/devconsole/`. The built assets are served by `DevConsoleController` at `/_devconsole/`.
|
|
147
|
+
|
|
148
|
+
In development, the frontend can be run standalone with `cd devconsole && npm run dev`, which proxies API and WebSocket requests to `localhost:3000`.
|