@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,286 @@
|
|
|
1
|
+
# Types
|
|
2
|
+
|
|
3
|
+
Custom type annotations integrate with reflected type metadata, validation, deserialization, OpenAPI, and the migration generator.
|
|
4
|
+
|
|
5
|
+
Import them from the package root:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
DateString,
|
|
10
|
+
EmailAddress,
|
|
11
|
+
GreaterThan,
|
|
12
|
+
Length,
|
|
13
|
+
OptionalNulls,
|
|
14
|
+
PhoneNumber,
|
|
15
|
+
TrimmedString,
|
|
16
|
+
UUID,
|
|
17
|
+
UuidString
|
|
18
|
+
} from '@zyno-io/ts-server-foundation';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The important distinction is that not every type affects every layer. Some types only validate input, some only change generated database schema, and some do both.
|
|
22
|
+
|
|
23
|
+
In the table below, runtime validation/deserialization means the explicit reflection helpers and automatic HTTP input pipeline. Entity creation and database saves do not automatically run these validators or deserialization transforms; database-specific runtime conversion is documented in [Database](./database.md#runtime-value-conversion-and-validation).
|
|
24
|
+
|
|
25
|
+
## Type Utility Helpers
|
|
26
|
+
|
|
27
|
+
### `OptionalNulls<T>`
|
|
28
|
+
|
|
29
|
+
`OptionalNulls<T>` makes properties optional when their type includes `null`, while leaving non-nullable properties required.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
class DbEntity extends BaseEntity {
|
|
33
|
+
name!: string;
|
|
34
|
+
color!: string | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type ControllerDto = OptionalNulls<Pick<DbEntity, 'name' | 'color'>>;
|
|
38
|
+
// { name: string; color?: string | null }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Storage And Schema Effects
|
|
42
|
+
|
|
43
|
+
| Type | Runtime validation/deserialization | Migration column | OpenAPI schema |
|
|
44
|
+
| ------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------- |
|
|
45
|
+
| `DateString` | Validates `YYYY-MM-DD`. | `date` on MySQL and PostgreSQL. | `string`, `format: date`. |
|
|
46
|
+
| `UuidString` | Validates UUID-formatted strings. | MySQL `char(36)`, PostgreSQL `uuid`. | `string`, `format: uuid`. |
|
|
47
|
+
| `UUID` | Validates UUID-formatted strings. | MySQL `binary(16)`, PostgreSQL `uuid`. | `string`, `format: uuid`. |
|
|
48
|
+
| `PhoneNumber` | Normalizes to E.164 and rejects invalid phones. | `varchar(20)`. | `string`. |
|
|
49
|
+
| `PhoneNumberNANP` | Normalizes to NANP digits without `+1` and rejects invalid phones. | `varchar(20)`. | `string`. |
|
|
50
|
+
| `Length<N>` | `MinLength<N>` and `MaxLength<N>`. | `char(N)`. | `string` with `minLength: N`, `maxLength: N`. |
|
|
51
|
+
| `string & MaxLength<N>` | `maxLength` validation. | `varchar(N)`. | `string` with `maxLength: N`. |
|
|
52
|
+
| `TrimmedString` | Trims during deserialization. | Normal string mapping unless combined with another annotation. | Normal string schema. |
|
|
53
|
+
| `NonEmptyTrimmedString` | Trims and applies `MinLength<1>`. | Normal string mapping unless combined with another annotation. | `string` with `minLength: 1`. |
|
|
54
|
+
| `EmailAddress` | Regex validation. | Normal string mapping unless combined with another annotation. | `string` with the email regex pattern. |
|
|
55
|
+
| `number & GreaterThan<N>` | Rejects values `<= N`. | MySQL numeric columns are unsigned when the lower bound is `>= 0`. | `number` with `exclusiveMinimum: N`. |
|
|
56
|
+
| `number & LessThan<N>` | Rejects values `>= N`. | Does not choose a column type. | `number` with `exclusiveMaximum: N`. |
|
|
57
|
+
| `ValidDate` | Rejects `Invalid Date` values. | Normal `Date` mapping: MySQL `datetime`, PostgreSQL `timestamp`. | `string`, `format: date-time`. |
|
|
58
|
+
| `UnsignedNumber` | `Minimum<0>` validation. | MySQL numeric columns are unsigned when the minimum is `>= 0`. | `number` with `minimum: 0`. |
|
|
59
|
+
| `MySQLCoordinate` | `Coordinate` object shape. | MySQL `point`. | Normal object schema. |
|
|
60
|
+
| `NullableMySQLCoordinate` | `Coordinate \| null` object shape. | MySQL `point`, nullable. | Normal nullable object schema. |
|
|
61
|
+
| `HasDefault` | Marks undefined values as omittable for entity creation/insert helpers. | Does not choose a column type. | No OpenAPI effect. |
|
|
62
|
+
| `OnUpdate<T>` | No runtime validation. | Adds the column `ON UPDATE` expression where supported. | No OpenAPI effect. |
|
|
63
|
+
|
|
64
|
+
For fixed-width storage, use `Length<N>`. For variable-width storage, use `string & MaxLength<N>`.
|
|
65
|
+
|
|
66
|
+
## Strings
|
|
67
|
+
|
|
68
|
+
### `TrimmedString` and `NonEmptyTrimmedString`
|
|
69
|
+
|
|
70
|
+
`TrimmedString` trims incoming string values during reflected deserialization. `NonEmptyTrimmedString` also applies `MinLength<1>`.
|
|
71
|
+
|
|
72
|
+
These types do not change the database column type by themselves. In an entity, they still use the normal string mapping unless combined with `Length<N>`, `MaxLength<N>`, or a database annotation.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { NonEmptyTrimmedString, TrimmedString } from '@zyno-io/ts-server-foundation';
|
|
76
|
+
|
|
77
|
+
class UserInput {
|
|
78
|
+
name!: NonEmptyTrimmedString;
|
|
79
|
+
notes!: TrimmedString;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### `EmailAddress`
|
|
84
|
+
|
|
85
|
+
`EmailAddress` validates against the project email regex and emits that pattern into OpenAPI.
|
|
86
|
+
|
|
87
|
+
It does not imply a database-specific email column type. In an entity it maps like a normal string, so add `MaxLength<N>` when the column size matters.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { EmailAddress } from '@zyno-io/ts-server-foundation';
|
|
91
|
+
import { MaxLength } from '@zyno-io/ts-server-foundation';
|
|
92
|
+
|
|
93
|
+
class User {
|
|
94
|
+
email!: EmailAddress & MaxLength<255>;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### `Length<N>`
|
|
99
|
+
|
|
100
|
+
`Length<N>` is a fixed-length string type. It is implemented as `MinLength<N> & MaxLength<N>` plus a TSF marker annotation, so validation, OpenAPI, and the migration type mapper can all read it.
|
|
101
|
+
|
|
102
|
+
In generated migrations, `Length<6>` becomes `char(6)`. If you want `varchar(6)`, use `string & MaxLength<6>` instead.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { Length } from '@zyno-io/ts-server-foundation';
|
|
106
|
+
|
|
107
|
+
class VerificationCode {
|
|
108
|
+
code!: Length<6>; // char(6)
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Dates
|
|
113
|
+
|
|
114
|
+
### `DateString`
|
|
115
|
+
|
|
116
|
+
`DateString` validates `YYYY-MM-DD`, maps to a database `date` column, and appears in OpenAPI as a date string.
|
|
117
|
+
|
|
118
|
+
Use this for calendar dates without a time. Use `Date` or `ValidDate` for timestamps.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { DateString } from '@zyno-io/ts-server-foundation';
|
|
122
|
+
|
|
123
|
+
class Event {
|
|
124
|
+
date!: DateString; // date
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `ValidDate`
|
|
129
|
+
|
|
130
|
+
`ValidDate` rejects `Invalid Date` values during validation.
|
|
131
|
+
|
|
132
|
+
It keeps normal `Date` storage semantics: MySQL `datetime`, PostgreSQL `timestamp`, and OpenAPI `string` with `format: date-time`.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { ValidDate } from '@zyno-io/ts-server-foundation';
|
|
136
|
+
|
|
137
|
+
class ScheduledTask {
|
|
138
|
+
startsAt!: ValidDate;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Phone Numbers
|
|
143
|
+
|
|
144
|
+
Phone types use `google-libphonenumber` during deserialization and validation. In generated migrations, both phone types map to `varchar(20)`.
|
|
145
|
+
|
|
146
|
+
### `PhoneNumber`
|
|
147
|
+
|
|
148
|
+
International E.164 format with `+` prefix:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { PhoneNumber } from '@zyno-io/ts-server-foundation';
|
|
152
|
+
|
|
153
|
+
class Contact {
|
|
154
|
+
phone!: PhoneNumber; // '+12025550125'
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### `PhoneNumberNANP`
|
|
159
|
+
|
|
160
|
+
North American Numbering Plan format without the `+1` prefix:
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
import { PhoneNumberNANP } from '@zyno-io/ts-server-foundation';
|
|
164
|
+
|
|
165
|
+
class Contact {
|
|
166
|
+
phone!: PhoneNumberNANP; // '2025550125'
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Utilities
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
import { cleanPhone, formatPhoneFriendly } from '@zyno-io/ts-server-foundation';
|
|
174
|
+
|
|
175
|
+
cleanPhone('(202) 555-0125'); // '+12025550125'
|
|
176
|
+
cleanPhone('invalid'); // null
|
|
177
|
+
formatPhoneFriendly('+12025550125', 'US'); // '(202) 555-0125'
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Database Annotations
|
|
181
|
+
|
|
182
|
+
### `UuidString` and `UUID`
|
|
183
|
+
|
|
184
|
+
Both aliases validate UUID-formatted strings and emit OpenAPI `string` schemas with `format: uuid`. Their MySQL storage differs:
|
|
185
|
+
|
|
186
|
+
- `UuidString` uses `char(36)` and remains a string in database bindings and hydrated entities.
|
|
187
|
+
- `UUID` uses `binary(16)` and converts between the application string and compact MySQL storage.
|
|
188
|
+
- PostgreSQL uses its native `uuid` type for both aliases.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { UUID, UuidString } from '@zyno-io/ts-server-foundation';
|
|
192
|
+
|
|
193
|
+
class Resource {
|
|
194
|
+
id!: UUID;
|
|
195
|
+
externalId!: UuidString;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### `HasDefault`
|
|
200
|
+
|
|
201
|
+
Marks a field as having an application/database default so entity creation and insert helpers can treat `undefined` as "omit this column".
|
|
202
|
+
|
|
203
|
+
`HasDefault` does not pick a database column type. It only changes optional/default handling.
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
import { HasDefault } from '@zyno-io/ts-server-foundation';
|
|
207
|
+
|
|
208
|
+
class User {
|
|
209
|
+
role!: string & HasDefault;
|
|
210
|
+
isAdmin: boolean & HasDefault = false;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Fields with TypeScript initializers are also read by the migration generator and can produce SQL defaults. For example, `count: number = 0` produces `DEFAULT '0'`, and `createdAt: Date = new Date()` produces `DEFAULT CURRENT_TIMESTAMP`.
|
|
215
|
+
|
|
216
|
+
### `OnUpdate<T>`
|
|
217
|
+
|
|
218
|
+
Column `ON UPDATE` expression annotation:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import { OnUpdate } from '@zyno-io/ts-server-foundation';
|
|
222
|
+
|
|
223
|
+
class User {
|
|
224
|
+
updatedAt!: Date & OnUpdate<'CURRENT_TIMESTAMP'>;
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This is primarily useful for MySQL timestamp columns. PostgreSQL does not have a direct column-level `ON UPDATE` equivalent.
|
|
229
|
+
|
|
230
|
+
### `UnsignedNumber`
|
|
231
|
+
|
|
232
|
+
Number with a minimum value of `0`. In MySQL migrations, any numeric field with a minimum value greater than or equal to zero is emitted as unsigned.
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { UnsignedNumber } from '@zyno-io/ts-server-foundation';
|
|
236
|
+
|
|
237
|
+
class Counter {
|
|
238
|
+
value!: UnsignedNumber;
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### `MySQLCoordinate` and `NullableMySQLCoordinate`
|
|
243
|
+
|
|
244
|
+
MySQL `POINT` geometry type. These are MySQL-specific types; do not use them in PostgreSQL entities unless you provide a custom mapping.
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { MySQLCoordinate, NullableMySQLCoordinate } from '@zyno-io/ts-server-foundation';
|
|
248
|
+
|
|
249
|
+
class Location {
|
|
250
|
+
coords!: MySQLCoordinate;
|
|
251
|
+
optionalCoords!: NullableMySQLCoordinate;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const coords = { x: -73.9857, y: 40.7484 };
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Utility Types
|
|
258
|
+
|
|
259
|
+
The package also exports common utility types:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
type ConcretePrimitive = string | number | boolean;
|
|
263
|
+
type DefinedPrimitive = ConcretePrimitive | null;
|
|
264
|
+
type Primitive = DefinedPrimitive | undefined;
|
|
265
|
+
type StrictBool = true | false;
|
|
266
|
+
type KVObject<T = any> = Record<string, T>;
|
|
267
|
+
type NestedKVObject<T = any> = KVObject<T | T[] | KVObject<T>>;
|
|
268
|
+
type Serializable<T = ConcretePrimitive> = T | T[] | NestedKVObject<T> | NestedKVObject<T>[];
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Field and method helpers:
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
type RequireFields<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
275
|
+
type ObjectKeysMatching<O, V> = {
|
|
276
|
+
[K in keyof O]: O[K] extends V ? K : V extends O[K] ? K : never;
|
|
277
|
+
}[keyof O];
|
|
278
|
+
type MethodsOf<T> = { [K in keyof T as T[K] extends (...args: any[]) => any ? K : never]: T[K] };
|
|
279
|
+
type MethodKeys<T> = keyof MethodsOf<T>;
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Class helpers:
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
import { getClassName, isClass } from '@zyno-io/ts-server-foundation';
|
|
286
|
+
```
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Uploads
|
|
2
|
+
|
|
3
|
+
Multipart upload parsing is integrated with the HTTP parameter resolver. File parts are accepted only when a route explicitly declares matching `FileUpload` fields through a `FileUpload` parameter or a `FileUpload` property in `HttpBody<T>`.
|
|
4
|
+
|
|
5
|
+
## File Parameters
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { FileUpload, http, HttpBody } from '@zyno-io/ts-server-foundation';
|
|
9
|
+
|
|
10
|
+
interface UploadBody {
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@http.controller('/files')
|
|
15
|
+
class FilesController {
|
|
16
|
+
@http.POST()
|
|
17
|
+
async upload(body: HttpBody<UploadBody>, file: FileUpload<{ maxSize: '40MB'; allowedTypes: 'image/*' }>) {
|
|
18
|
+
return {
|
|
19
|
+
description: body.description,
|
|
20
|
+
name: file.originalName,
|
|
21
|
+
path: file.path,
|
|
22
|
+
size: file.size,
|
|
23
|
+
type: file.type,
|
|
24
|
+
detectedType: file.detectedType
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
A standalone `FileUpload` parameter is required unless the controller parameter is optional. If the named file is absent, a required parameter returns HTTP `400`; an optional parameter receives `undefined`. This applies to non-multipart requests and multipart requests containing only text fields. A multipart file under an undeclared field name is rejected with HTTP `400`, even when the declared upload parameter is optional.
|
|
31
|
+
|
|
32
|
+
`FileUpload<Options>` supports:
|
|
33
|
+
|
|
34
|
+
| Option | Description |
|
|
35
|
+
| -------------- | ------------------------------------------------------------------------- |
|
|
36
|
+
| `maxSize` | Per-file byte limit as a number or string such as `'40MB'`. |
|
|
37
|
+
| `allowedTypes` | MIME type or list of MIME types. Exact matches, `type/*`, and `*/*` work. |
|
|
38
|
+
|
|
39
|
+
The multipart part `Content-Type` must match `allowedTypes` before the file is written. When `allowedTypes` is set, the framework also buffers a signature sample, asks `file-type` to detect the format, and requires the detected MIME type to match. Both checks honor wildcards. Detection is still mandatory for `*/*`: an empty, text-only, truncated, or otherwise undetectable signature is rejected. Use allowed types that `file-type` can recognize, and do not treat detection as malware scanning or complete content validation.
|
|
40
|
+
|
|
41
|
+
`FileUpload` fields:
|
|
42
|
+
|
|
43
|
+
| Field | Description |
|
|
44
|
+
| ------------------- | -------------------------------------------------------------------- |
|
|
45
|
+
| `path` | Temporary file path on disk. |
|
|
46
|
+
| `size` | Uploaded byte count. |
|
|
47
|
+
| `type` | MIME type from the multipart part, or `application/octet-stream`. |
|
|
48
|
+
| `declaredType` | Same declared MIME type from the multipart part. |
|
|
49
|
+
| `detectedType` | MIME type detected by `file-type` when `allowedTypes` is set. |
|
|
50
|
+
| `detectedExtension` | Extension detected by `file-type` when `allowedTypes` is set. |
|
|
51
|
+
| `originalName` | Original client filename. A sanitized copy is used in the temp path. |
|
|
52
|
+
| `name` | Alias for `originalName`. |
|
|
53
|
+
|
|
54
|
+
## Multipart Body Fields
|
|
55
|
+
|
|
56
|
+
Regular multipart fields are merged into the parsed body. A field named `_payload` is parsed as JSON and merged into the body object.
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
_payload={"description":"Profile photo"}
|
|
60
|
+
file=<binary>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If multiple text fields use the same name, the parsed body stores them in order as an array; declare the corresponding DTO property as an array. Duplicate files are arrays in `request.uploadedFiles` and the raw parsed body. A standalone `FileUpload` parameter selects the first file under its name. If its named field is absent, it falls back only when exactly one file exists across the route's other declared upload fields.
|
|
64
|
+
|
|
65
|
+
Typed multi-file body properties are not supported: `file: FileUpload` expects one file and rejects the duplicate-file array. Use `HttpRequest.uploadedFiles` when an endpoint intentionally accepts repeated files, and apply application-level checks to the array.
|
|
66
|
+
|
|
67
|
+
A body DTO can declare file fields directly:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
class AttachmentBody {
|
|
71
|
+
title!: string;
|
|
72
|
+
attachment?: FileUpload<{ maxSize: '2MB'; allowedTypes: 'application/pdf' }>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@http.controller('/attachments')
|
|
76
|
+
class AttachmentController {
|
|
77
|
+
@http.POST()
|
|
78
|
+
upload(body: HttpBody<AttachmentBody>) {
|
|
79
|
+
return { title: body.title, fileName: body.attachment?.originalName };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For OpenAPI, a required body file makes the request multipart-only. When all body files are optional or nullable, the operation advertises both JSON (for requests without files) and multipart content.
|
|
85
|
+
|
|
86
|
+
Keep runtime upload properties at the top level of the body DTO. Multipart file parts are assigned by their flat field name; a nested `nested.file: FileUpload` schema cannot be populated automatically from a file part.
|
|
87
|
+
|
|
88
|
+
## Cleanup
|
|
89
|
+
|
|
90
|
+
Uploaded files are written to a temporary directory created with the `tsf-upload-` prefix. The `onResponse` workflow runs while uploaded files still exist. Immediately afterward, the HTTP router removes every upload directory in a cleanup `finally`, including JSON/multipart parse failures, MIME and size rejections, controller errors, and failures thrown by `onResponse` listeners.
|
|
91
|
+
|
|
92
|
+
`FileUpload.path` is request-scoped. Do not store it for later background work without copying the file before the controller returns. By the time `app.http.request()` resolves—or rejects because the final response workflow failed—the temporary path has been removed.
|
|
93
|
+
|
|
94
|
+
## Raw Streaming
|
|
95
|
+
|
|
96
|
+
Use `HttpRequestStream` for endpoints that intentionally accept a raw body stream and bypass body guards.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { http, HttpRequestStream } from '@zyno-io/ts-server-foundation';
|
|
100
|
+
|
|
101
|
+
@http.controller('/raw')
|
|
102
|
+
class RawController {
|
|
103
|
+
@http.POST()
|
|
104
|
+
async upload(request: HttpRequestStream) {
|
|
105
|
+
for await (const chunk of request) {
|
|
106
|
+
await writeChunk(chunk);
|
|
107
|
+
}
|
|
108
|
+
return { ok: true };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Do not combine `HttpRequestStream` with `HttpBody<T>` or `FileUpload` on the same route; route registration rejects that combination. Raw streaming also bypasses MIME policies, multipart declaration checks, content decoding, `content-length` checks, and request byte limits, so the handler must enforce every appropriate limit itself.
|
|
114
|
+
|
|
115
|
+
## Cached Body Reads
|
|
116
|
+
|
|
117
|
+
`HttpRequest.readBodyBuffer()`, `readBodyText()`, and `readBody()` read the request body and cache the buffer on `request.body`.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
const first = await request.readBodyBuffer();
|
|
121
|
+
const second = await request.readBodyBuffer();
|
|
122
|
+
|
|
123
|
+
first === second; // true
|
|
124
|
+
request.body === first; // true
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Cached reads are reusable. If the request stream is already being consumed through `request.stream`, body-buffer reads throw because the stream cannot be consumed twice.
|
|
128
|
+
|
|
129
|
+
## Testing Multipart Requests
|
|
130
|
+
|
|
131
|
+
`HttpRequest` can build multipart bodies for tests.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const request = HttpRequest.POST('/files').multiPart([
|
|
135
|
+
{ name: '_payload', value: JSON.stringify({ description: 'Avatar' }) },
|
|
136
|
+
{
|
|
137
|
+
name: 'file',
|
|
138
|
+
file: Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', 'base64'),
|
|
139
|
+
fileName: 'avatar.png',
|
|
140
|
+
contentType: 'image/png'
|
|
141
|
+
}
|
|
142
|
+
]);
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This uses the same parser path as a real multipart request.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Workers
|
|
2
|
+
|
|
3
|
+
The worker layer uses BullMQ with Redis outside test mode. In `APP_ENV=test`, it uses an in-process queue so tests do not require Redis unless a test explicitly starts an app with a non-test config.
|
|
4
|
+
|
|
5
|
+
Enable worker services with `createApp({ enableWorker: true })`. This registers `WorkerService`, `WorkerRunnerService`, the queue registry, and the recorder.
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
const app = createApp({
|
|
9
|
+
enableWorker: true,
|
|
10
|
+
providers: [SendEmailJob]
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Normal server processes can enqueue jobs. Runner ownership is controlled by `ENABLE_JOB_RUNNER`:
|
|
15
|
+
|
|
16
|
+
| Environment | Default runner behavior |
|
|
17
|
+
| --------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| `production` | runner off unless `ENABLE_JOB_RUNNER=true` |
|
|
19
|
+
| non-production | runner on unless `ENABLE_JOB_RUNNER=false` |
|
|
20
|
+
| `node . worker:start` | runner forced on; the HTTP listener also starts, including `/healthz` unless health checks were disabled |
|
|
21
|
+
|
|
22
|
+
Production deployments should run API/server pods with `node . server:start` and `ENABLE_JOB_RUNNER` unset or false, and separate worker pods with `node . worker:start`.
|
|
23
|
+
|
|
24
|
+
## Defining Jobs
|
|
25
|
+
|
|
26
|
+
Jobs extend `BaseJob<I, O>` and are registered with `@WorkerJob()`.
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { BaseJob, WorkerJob } from '@zyno-io/ts-server-foundation';
|
|
30
|
+
|
|
31
|
+
interface SendEmailInput {
|
|
32
|
+
to: string;
|
|
33
|
+
subject: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@WorkerJob({ queueName: 'mail' })
|
|
37
|
+
class SendEmailJob extends BaseJob<SendEmailInput, { sent: boolean }> {
|
|
38
|
+
async handle(data: SendEmailInput) {
|
|
39
|
+
return { sent: true };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The job class must also be registered as a provider so the runner can resolve it through DI.
|
|
45
|
+
|
|
46
|
+
`BaseJob<I, O>` contains one required method, `handle(data: I): O | Promise<O>`. `@WorkerJob()` sets the job class's queue and cron metadata and adds it to the process registry; it does not add the class to the app's DI container. The decorator accepts `queueName` (`queue` is an alias) and `cronSchedule` (`cron` is an alias).
|
|
47
|
+
|
|
48
|
+
The equivalent static metadata remains available for jobs that cannot use decorator arguments:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
@WorkerJob()
|
|
52
|
+
class DailyCleanupJob extends BaseJob<void, void> {
|
|
53
|
+
static QUEUE_NAME = 'maintenance';
|
|
54
|
+
static CRON_SCHEDULE = '0 2 * * *';
|
|
55
|
+
|
|
56
|
+
async handle() {
|
|
57
|
+
await cleanup();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Decorator values override the inherited `QUEUE_NAME = 'default'` and `CRON_SCHEDULE = null` defaults on that job class.
|
|
63
|
+
|
|
64
|
+
## Queueing Jobs
|
|
65
|
+
|
|
66
|
+
Use `WorkerService.queueJob()` for normal queueing and `WorkerService.runJob()` for immediate execution.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const worker = app.get(WorkerService);
|
|
70
|
+
|
|
71
|
+
await worker.queueJob(SendEmailJob, {
|
|
72
|
+
to: 'user@example.com',
|
|
73
|
+
subject: 'Welcome'
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const execution = await worker.runJob(SendEmailJob, {
|
|
77
|
+
to: 'user@example.com',
|
|
78
|
+
subject: 'Welcome'
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`runJob()` always creates an in-process queue record and executes it immediately through `WorkerRunnerService`; it does not enqueue a BullMQ job. `queueJob(..., { runImmediately: true })` uses the same inline path. Without `runImmediately`, test mode uses the in-memory queue while non-test environments enqueue through BullMQ.
|
|
83
|
+
|
|
84
|
+
In `APP_ENV=test`, `queueJob()` returns `undefined` unless `runInTest: true` is passed. This keeps tests from accidentally scheduling background work.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
await worker.queueJob(SendEmailJob, data, {
|
|
88
|
+
runInTest: true,
|
|
89
|
+
runImmediately: true
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Job Options
|
|
94
|
+
|
|
95
|
+
| Option | Description |
|
|
96
|
+
| ------------------ | ------------------------------------------------------ |
|
|
97
|
+
| `delay` | Delay in milliseconds before the job is ready. |
|
|
98
|
+
| `queueName` | Override the queue for this job instance. |
|
|
99
|
+
| `runInTest` | Allow queueing in `APP_ENV=test`. |
|
|
100
|
+
| `runImmediately` | Bypass BullMQ and execute inline through the runner. |
|
|
101
|
+
| `recordToDatabase` | Insert a `_jobs` record when a database is configured. |
|
|
102
|
+
| `repeatKey` | Internal repeat key used for cron scheduling. |
|
|
103
|
+
|
|
104
|
+
The default queue comes from `BaseAppConfig.BULL_QUEUE`. If unset, it is `default`.
|
|
105
|
+
|
|
106
|
+
Outside `APP_ENV=test`, BullMQ requires a `BULL_REDIS_HOST`/`BULL_REDIS_SENTINEL_HOST` connection or the corresponding generic `REDIS_HOST`/`REDIS_SENTINEL_HOST` fallback.
|
|
107
|
+
|
|
108
|
+
## Cron Jobs
|
|
109
|
+
|
|
110
|
+
Use `cronSchedule` or `cron` on `@WorkerJob()`.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
@WorkerJob({ queueName: 'daily', cronSchedule: '0 2 * * *' })
|
|
114
|
+
class DailyCleanupJob extends BaseJob<void, void> {
|
|
115
|
+
async handle() {
|
|
116
|
+
await cleanup();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
When the runner starts, it registers BullMQ job schedulers for registered cron jobs. In test-mode in-process queues, the runner schedules one pending repeat job per registered job class and repeat key.
|
|
122
|
+
|
|
123
|
+
## Queue Registry
|
|
124
|
+
|
|
125
|
+
`WorkerQueueRegistry` is primarily an internal queue abstraction. In test mode it stores queued jobs in memory and exposes:
|
|
126
|
+
|
|
127
|
+
- `add(jobClass, data, options)`
|
|
128
|
+
- `getQueuedJobs(queue?)`
|
|
129
|
+
- `getAllQueuedJobs()`
|
|
130
|
+
- `markCompleted(job, result)`
|
|
131
|
+
- `markFailed(job, result)`
|
|
132
|
+
- `remove(job)`
|
|
133
|
+
- `clear(queue?)`
|
|
134
|
+
- `WorkerQueueRegistry.closeQueues()`
|
|
135
|
+
|
|
136
|
+
Outside test mode, `WorkerService.queueJob()` writes to BullMQ. Workers deserialize jobs by class name and resolve the matching registered provider through DI.
|
|
137
|
+
|
|
138
|
+
## Recorder
|
|
139
|
+
|
|
140
|
+
`WorkerRecorderService` keeps in-memory execution records for the lifetime of the process and can optionally write completed/failed records into a `_jobs` table when a `BaseDatabase` provider is configured and the job option `recordToDatabase` is true. The application must provision that table through its own migration; registering worker services does not add it to the database entity registry or create it automatically. `getRecords()` returns shallow copies. The recorder itself is unbounded; DevConsole intentionally displays only the latest 200 records.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
await worker.queueJob(SendEmailJob, data, {
|
|
144
|
+
runImmediately: true,
|
|
145
|
+
recordToDatabase: true
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const records = app.get(WorkerRecorderService).getRecords();
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The database record contains queue, queue id, attempt, job name, input data, status, result, and timestamps.
|
|
152
|
+
|
|
153
|
+
## Request Context
|
|
154
|
+
|
|
155
|
+
Jobs execute inside helper context data containing the current job metadata:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { getContextProp } from '@zyno-io/ts-server-foundation';
|
|
159
|
+
|
|
160
|
+
const job = getContextProp<{ queue: string; id: string; name: string }>('job');
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Observers
|
|
164
|
+
|
|
165
|
+
`registerWorkerObserver()` receives process-wide queue/execution events and returns an unsubscribe function.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { registerWorkerObserver } from '@zyno-io/ts-server-foundation';
|
|
169
|
+
|
|
170
|
+
const unsubscribe = registerWorkerObserver(entry => {
|
|
171
|
+
console.log(entry.type, entry.job.name, entry.job.id);
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Entries are `added`, `delayed`, `active`, `completed`, or `failed`; completed/failed entries also include the execution record. Observer exceptions are isolated from queueing and job execution. DevConsole uses the same observation surface, so observers are process-wide rather than scoped to one app.
|
|
176
|
+
|
|
177
|
+
## Current Limits
|
|
178
|
+
|
|
179
|
+
- Queue names are discovered from `BULL_QUEUE` and registered `@WorkerJob({ queueName })` classes. Avoid arbitrary per-call `queueName` overrides unless worker processes also register a job class on that queue.
|
|
180
|
+
- Retry/backoff policy is application-defined; the current worker options do not expose BullMQ retry options.
|
|
181
|
+
- Recorder/database failures currently propagate through job execution and can turn an otherwise successful handler into a failed job; choose `recordToDatabase` only when that failure coupling is intended.
|
|
182
|
+
- Runner shutdown waits for active handlers without a timeout or cancellation signal.
|
package/docs/openapi.md
ADDED