@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,324 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
Scaffold a project:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx @zyno-io/ts-server-foundation create-app @myorg/my-api
|
|
9
|
+
cd my-api
|
|
10
|
+
corepack yarn install
|
|
11
|
+
corepack yarn dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Manual installation:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
corepack yarn add @zyno-io/ts-server-foundation
|
|
18
|
+
corepack yarn tsf-install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`tsf-install` adds the supported TypeScript/`ttsc` compiler dependencies and configures TSF's metadata transform. Scaffolded applications run it from `postinstall`.
|
|
22
|
+
|
|
23
|
+
## Scaffold Anatomy
|
|
24
|
+
|
|
25
|
+
The generated project is intentionally small:
|
|
26
|
+
|
|
27
|
+
| Path | Purpose |
|
|
28
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| `src/index.ts` | Executable entrypoint. Initializes `@zyno-io/ts-server-foundation/otel` before loading the application, then calls `app.run()`. |
|
|
30
|
+
| `src/app.ts` | Creates and exports the application, database, controllers, and providers. Tests should import this module rather than the executable entrypoint. |
|
|
31
|
+
| `src/config.ts` | Application config class extending `BaseAppConfig`. |
|
|
32
|
+
| `src/database.ts` | MySQL database class and entity registry used by the example. |
|
|
33
|
+
| `src/controllers/`, `src/services/`, `src/entities/` | Example HTTP, service, and database layers. |
|
|
34
|
+
| `src/migrations/` | Source migration files; their compiled output under `dist/src/migrations/` is used by migration commands. |
|
|
35
|
+
| `tests/` | Node test-runner tests compiled with `tsconfig.test.json`. |
|
|
36
|
+
| `.env.development` | Local port, MySQL connection, database adapter, and Redis key prefix. Do not commit real secrets. |
|
|
37
|
+
| `package.json` | Sets `main` to `./dist/src/index.js`, allowing `node . <command>` to dispatch through the compiled entrypoint. |
|
|
38
|
+
|
|
39
|
+
The generated scripts map to the development wrapper:
|
|
40
|
+
|
|
41
|
+
| Script | Command |
|
|
42
|
+
| --------------------- | ----------------------------- |
|
|
43
|
+
| `yarn build` | `tsf-dev build` |
|
|
44
|
+
| `yarn dev` | `tsf-dev run -- server:start` |
|
|
45
|
+
| `yarn test` | `tsf-dev test` |
|
|
46
|
+
| `yarn test:debug` | `tsf-dev test --debug` |
|
|
47
|
+
| `yarn migrate` | `tsf-dev migrate` |
|
|
48
|
+
| `yarn migrate:create` | `tsf-dev migrate:create` |
|
|
49
|
+
| `postinstall` | `tsf-install` |
|
|
50
|
+
|
|
51
|
+
The OTel-first entrypoint matters: instrumentation must load before HTTP, database, Redis, and other modules it patches. Keep application construction in `app.ts` so tests can import it without running command dispatch.
|
|
52
|
+
|
|
53
|
+
## TypeScript Configuration
|
|
54
|
+
|
|
55
|
+
Reflected type metadata is required for constructor injection, route parameter metadata, OpenAPI schemas, config loading, entity metadata, and custom type annotations.
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"compilerOptions": {
|
|
60
|
+
"target": "ES2022",
|
|
61
|
+
"lib": ["ES2022"],
|
|
62
|
+
"module": "commonjs",
|
|
63
|
+
"rootDir": ".",
|
|
64
|
+
"outDir": "dist",
|
|
65
|
+
"sourceMap": true,
|
|
66
|
+
"strict": true,
|
|
67
|
+
"esModuleInterop": true,
|
|
68
|
+
"forceConsistentCasingInFileNames": true,
|
|
69
|
+
"skipLibCheck": true,
|
|
70
|
+
"experimentalDecorators": true,
|
|
71
|
+
"emitDecoratorMetadata": true,
|
|
72
|
+
"importHelpers": true,
|
|
73
|
+
"types": ["node"],
|
|
74
|
+
"plugins": [
|
|
75
|
+
{
|
|
76
|
+
"transform": "./node_modules/@zyno-io/ts-server-foundation/dist/src/type-compiler/index.cjs"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"include": ["src/**/*.ts"],
|
|
81
|
+
"reflection": true
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Build with `ttsc`, as the scaffold and `tsf-dev` commands do. `tsf-install` installs the supported compiler and adds the transform plus top-level `reflection` setting; the full scaffold configuration above is the recommended baseline for a new application. The TSF compiler emits the reflected metadata used by these runtime systems. See [Type Reflection Architecture](./type-reflection-architecture.md) for the compiler and runtime metadata policy.
|
|
86
|
+
|
|
87
|
+
For tests, extend the main config and include both source and tests:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"extends": "./tsconfig.json",
|
|
92
|
+
"include": ["src/**/*.ts", "tests/**/*.ts"],
|
|
93
|
+
"reflection": true
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Create an App
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { BaseAppConfig, createApp, createDatabase, http } from '@zyno-io/ts-server-foundation';
|
|
101
|
+
|
|
102
|
+
class AppConfig extends BaseAppConfig {
|
|
103
|
+
APP_ENV = 'development';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@http.controller('/health-example')
|
|
107
|
+
class ExampleController {
|
|
108
|
+
@http.GET()
|
|
109
|
+
get() {
|
|
110
|
+
return { ok: true };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class AppDatabase extends createDatabase('mysql', {}, []) {}
|
|
115
|
+
|
|
116
|
+
export const app = createApp({
|
|
117
|
+
config: AppConfig,
|
|
118
|
+
db: AppDatabase,
|
|
119
|
+
controllers: [ExampleController]
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (require.main === module) {
|
|
123
|
+
void app.run();
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Run the server entrypoint with an explicit command:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
node . server:start
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`app.run()` handles command dispatch for `server:start`, `worker:start`, `migrate:run`, `openapi:generate`, and commands registered on the app. Direct HTTP server APIs live under `app.http`; for tests, demos, or embedded usage call `app.http.listen()`:
|
|
134
|
+
|
|
135
|
+
Running `node .` without a command, or with an unknown command, prints usage and sets a failing exit code. Production process definitions should always include the intended command.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
const server = await app.http.listen(0, '127.0.0.1');
|
|
139
|
+
await app.stop();
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Register app commands with `@cli.controller()` and the `commands` option:
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { cli, createApp, ScopedLogger } from '@zyno-io/ts-server-foundation';
|
|
146
|
+
|
|
147
|
+
@cli.controller('receipts:requeue', { description: 'Requeue queued receipts' })
|
|
148
|
+
class ReceiptsRequeueCommand {
|
|
149
|
+
constructor(private logger: ScopedLogger) {}
|
|
150
|
+
|
|
151
|
+
async execute(args: string[]) {
|
|
152
|
+
this.logger.info('Running receipts:requeue', { args });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export const app = createApp({
|
|
157
|
+
commands: [ReceiptsRequeueCommand]
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Run custom commands through the same compiled entrypoint:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
node . receipts:requeue
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## `createApp()` Options
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
interface CreateAppOptions<C extends BaseAppConfig = BaseAppConfig> extends ModuleDefinition<C> {
|
|
171
|
+
config?: ClassType<C>;
|
|
172
|
+
defaultConfig?: Partial<C>;
|
|
173
|
+
db?: ClassType;
|
|
174
|
+
frameworkConfig?: Record<string, unknown>;
|
|
175
|
+
serverConfig?: Record<string, unknown>;
|
|
176
|
+
cors?: HttpCorsConfig<C>;
|
|
177
|
+
staticFiles?: boolean | StaticFilesOptions;
|
|
178
|
+
httpResolvers?: RouteParameterResolverRegistry;
|
|
179
|
+
enableHealthcheck?: boolean;
|
|
180
|
+
enableWorker?: boolean;
|
|
181
|
+
enableDkRpc?: boolean;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Common fields:
|
|
186
|
+
|
|
187
|
+
| Option | Description |
|
|
188
|
+
| ------------------- | --------------------------------------------------------------------------------------------- |
|
|
189
|
+
| `config` | Config class. Defaults to `BaseAppConfig`. |
|
|
190
|
+
| `defaultConfig` | Default values applied before env files and `Env`. |
|
|
191
|
+
| `db` | Database class from `createDatabase`, `createMySQLDatabase`, or `createPostgresDatabase`. |
|
|
192
|
+
| `controllers` | HTTP controllers registered with the owned router. |
|
|
193
|
+
| `providers` | DI providers. Classes, `useValue`, `useClass`, `useExisting`, and `useFactory` are supported. |
|
|
194
|
+
| `imports` | Imported modules. Exported providers from imported modules become globally injectable. |
|
|
195
|
+
| `exports` | Providers exported by this module for global injection. |
|
|
196
|
+
| `listeners` | Lifecycle/event listener classes. |
|
|
197
|
+
| `commands` | Classes decorated with `@cli.command()` or `@cli.controller()`. |
|
|
198
|
+
| `frameworkConfig` | HTTP runtime options; `port` overrides `config.PORT`. |
|
|
199
|
+
| `serverConfig` | Secondary HTTP runtime options; `frameworkConfig` takes precedence for `port`. |
|
|
200
|
+
| `cors` | Static CORS options or a config-driven factory. |
|
|
201
|
+
| `staticFiles` | Static-file options, or `true` for the default `static/` directory with SPA fallback. |
|
|
202
|
+
| `httpResolvers` | App-wide custom HTTP parameter resolvers keyed by reflected class name. |
|
|
203
|
+
| `enableHealthcheck` | Set to `false` to skip the default `/healthz` endpoint. |
|
|
204
|
+
| `enableWorker` | Registers worker services and job runners. |
|
|
205
|
+
| `enableDkRpc` | Legacy compatibility flag; the current runtime does not act on it. |
|
|
206
|
+
|
|
207
|
+
## Application And HTTP Runtime
|
|
208
|
+
|
|
209
|
+
`App` owns lifecycle, DI, config, command entrypoints, and module wiring. HTTP server behavior is exposed through `app.http`:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
const app = createApp({ controllers: [ExampleController] });
|
|
213
|
+
|
|
214
|
+
await app.start(); // optional; app.http.listen() starts it automatically
|
|
215
|
+
const server = await app.http.listen(3000, '0.0.0.0');
|
|
216
|
+
|
|
217
|
+
app.http.registerUpgradeHandler((request, socket, head) => {
|
|
218
|
+
// WebSocket or other upgrade handling
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
app.http.registerObserver(entry => {
|
|
222
|
+
// completed HTTP request observation
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
await app.stop();
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Transport APIs live under `app.http` so the base application class stays focused on application lifecycle.
|
|
229
|
+
|
|
230
|
+
## Dependency Injection
|
|
231
|
+
|
|
232
|
+
Constructor dependencies are read from reflected type metadata:
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
class UserService {
|
|
236
|
+
constructor(private db: BaseDatabase) {}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Resolve app-level providers outside constructor injection with `resolve()` or `r()`:
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import { BaseAppConfig, r, resolve } from '@zyno-io/ts-server-foundation';
|
|
244
|
+
|
|
245
|
+
const config = resolve(BaseAppConfig);
|
|
246
|
+
const sameConfig = r(BaseAppConfig);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Exported providers from imported modules are globally injectable. You do not need to explicitly import a module at the injection site when a provider is exported by a module in the app graph.
|
|
250
|
+
|
|
251
|
+
## AutoConstruct
|
|
252
|
+
|
|
253
|
+
`@AutoConstruct()` instantiates a registered provider during app startup. The decorator does not register the class by itself:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
import { AutoConstruct, createApp } from '@zyno-io/ts-server-foundation';
|
|
257
|
+
|
|
258
|
+
@AutoConstruct()
|
|
259
|
+
class StartupProbe {
|
|
260
|
+
constructor() {
|
|
261
|
+
// Runs when app.start() creates AutoConstruct providers.
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const app = createApp({ providers: [StartupProbe] });
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Environment
|
|
269
|
+
|
|
270
|
+
`APP_ENV` is required only when `NODE_ENV=production`. Tests infer `APP_ENV=test` from the Node test runner; other non-production processes default to `development`.
|
|
271
|
+
|
|
272
|
+
Configuration is loaded from env files and `Env`. Values consumed by reflected config properties remain in `process.env`, so later code and child processes inherit the same environment.
|
|
273
|
+
|
|
274
|
+
## Development, Test, And Production Setup
|
|
275
|
+
|
|
276
|
+
For the generated MySQL example, create the database named by `MYSQL_DATABASE` and make the `.env.development` credentials usable before running migrations or calling the example endpoints. The scaffold unit test only constructs the app and does not require a live database. Redis is not required by the base scaffold; configure it when enabling BullMQ workers, mutexes, leader election, mesh services, caches, or broadcasts.
|
|
277
|
+
|
|
278
|
+
Local development:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
corepack enable
|
|
282
|
+
corepack yarn install
|
|
283
|
+
corepack yarn migrate
|
|
284
|
+
corepack yarn dev
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Tests compile source and tests with the reflection transform before invoking Node's test runner:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
corepack yarn test
|
|
291
|
+
corepack yarn test:debug
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
For production, provide environment variables through the deployment secret/config system, build once, and execute the compiled package entrypoint explicitly:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
corepack yarn build
|
|
298
|
+
APP_ENV=production node . server:start
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Run migrations as a separate release step with `node . migrate:run`. If workers are enabled, use a separate `node . worker:start` process; see [Workers](./worker.md). A production database is required when the app registers one. Redis remains feature-dependent rather than an unconditional server prerequisite.
|
|
302
|
+
|
|
303
|
+
## CLI
|
|
304
|
+
|
|
305
|
+
Primary commands:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
tsf create-app <package-name> [path]
|
|
309
|
+
tsf test [node-test-options] [test-files-or-dirs...]
|
|
310
|
+
tsf gen-proto <proto-file-or-dir> <output-dir> [options]
|
|
311
|
+
|
|
312
|
+
tsf-dev build
|
|
313
|
+
tsf-dev run -- server:start
|
|
314
|
+
tsf-dev test
|
|
315
|
+
tsf-dev migrate
|
|
316
|
+
tsf-dev migrate:create
|
|
317
|
+
tsf-dev migrate:reset
|
|
318
|
+
tsf-dev migrate:charset
|
|
319
|
+
tsf-dev openapi:generate
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
See [CLI Tools](./cli.md) for the detailed command reference.
|
|
323
|
+
|
|
324
|
+
See [Public API](./public-api.md) for package export rules and import guidance.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Health Checks
|
|
2
|
+
|
|
3
|
+
TSF includes a health service and a default HTTP endpoint at `/healthz`.
|
|
4
|
+
|
|
5
|
+
## Endpoint
|
|
6
|
+
|
|
7
|
+
```http
|
|
8
|
+
GET /healthz
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Successful response:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{ "version": "0.0.0-dev" }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The version comes from the cached `package.json` in the process working directory and falls back to `unknown` when that metadata is unavailable. If a registered health check throws, the endpoint returns a normalized HTTP error response.
|
|
18
|
+
|
|
19
|
+
Disable the default endpoint with `createApp({ enableHealthcheck: false })`.
|
|
20
|
+
|
|
21
|
+
## Registering Checks
|
|
22
|
+
|
|
23
|
+
Inject `HealthcheckService` and register named checks.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { HealthcheckService, sql } from '@zyno-io/ts-server-foundation';
|
|
27
|
+
|
|
28
|
+
class DatabaseHealth {
|
|
29
|
+
constructor(health: HealthcheckService, db: AppDatabase) {
|
|
30
|
+
health.register('database', async () => {
|
|
31
|
+
await db.rawFind(sql`SELECT ${1}`);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Checks return `void` or `Promise<void>`. Throw to mark the check unhealthy.
|
|
38
|
+
|
|
39
|
+
## Service API
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { HealthcheckService } from '@zyno-io/ts-server-foundation';
|
|
43
|
+
|
|
44
|
+
health.register('cache', async () => {
|
|
45
|
+
await cache.ping();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
await health.check();
|
|
49
|
+
const results = await health.checkIndividual();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| Method | Description |
|
|
53
|
+
| -------------------- | --------------------------------------------------------- |
|
|
54
|
+
| `register(name, fn)` | Adds a named check. |
|
|
55
|
+
| `check()` | Runs all checks and throws on the first failure. |
|
|
56
|
+
| `checkIndividual()` | Runs all checks and returns `{ name, status, error? }[]`. |
|
|
57
|
+
|
|
58
|
+
## Request Logging
|
|
59
|
+
|
|
60
|
+
Health check request logging is controlled separately from other HTTP routes.
|
|
61
|
+
|
|
62
|
+
| Config key | Description |
|
|
63
|
+
| -------------------------------- | ----------------------------------------------------------------- |
|
|
64
|
+
| `HEALTHZ_ENABLE_REQUEST_LOGGING` | Enables request logs for `/healthz` when true. Defaults to false. |
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# Helpers
|
|
2
|
+
|
|
3
|
+
TSF exports small utility helpers from the package root. They are grouped by async context, data manipulation, streams, Redis, security, dates, errors, and package metadata.
|
|
4
|
+
|
|
5
|
+
## Async Context
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { getContext, getContextProp, removeContextProp, setContextProp, withContext, withContextData } from '@zyno-io/ts-server-foundation';
|
|
9
|
+
|
|
10
|
+
await withContext(async () => {
|
|
11
|
+
setContextProp('reqId', 'abc');
|
|
12
|
+
getContextProp<string>('reqId'); // 'abc'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
await withContextData({ userId: '123' }, async () => {
|
|
16
|
+
getContext(); // { userId: '123' }
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`withContextData()` restores overwritten values when the callback completes.
|
|
21
|
+
|
|
22
|
+
## Promises And Processes
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createSemaphore, deferred, execProcess } from '@zyno-io/ts-server-foundation';
|
|
26
|
+
|
|
27
|
+
const semaphore = createSemaphore();
|
|
28
|
+
semaphore.release();
|
|
29
|
+
await semaphore.promise;
|
|
30
|
+
|
|
31
|
+
const pending = deferred<string>();
|
|
32
|
+
pending.resolve('done');
|
|
33
|
+
await pending.promise;
|
|
34
|
+
|
|
35
|
+
const result = await execProcess('git', ['status'], { cwd: process.cwd() });
|
|
36
|
+
result.stdout.toString();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`execProcess()` throws on non-zero exit codes unless `errorOnNonZero: false` is passed.
|
|
40
|
+
|
|
41
|
+
`ExecProcessOptions` also accepts `cwd`, `env`, `stdio`, `shell`, and `onSpawn`. Captured `stdout` and `stderr` are `Buffer` values; they are empty when the selected `stdio` mode does not expose child pipes. `onSpawn` receives the `ChildProcess` after spawn, and throwing from it kills the child and rejects the operation. Spawn and exit failures are wrapped with the command in the outer error message and the original failure as `cause`.
|
|
42
|
+
|
|
43
|
+
## Arrays
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { asyncMap, chunk, toArray, unique } from '@zyno-io/ts-server-foundation';
|
|
47
|
+
|
|
48
|
+
toArray('one'); // ['one']
|
|
49
|
+
unique([1, 1, 2]); // [1, 2]
|
|
50
|
+
chunk([1, 2, 3, 4], 2); // [[1, 2], [3, 4]]
|
|
51
|
+
await asyncMap(items, async item => processItem(item));
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`asyncMap()` runs sequentially.
|
|
55
|
+
|
|
56
|
+
`chunk()` throws when its size is zero or negative. `unique()` uses JavaScript `Set` equality and preserves first-seen order.
|
|
57
|
+
|
|
58
|
+
## Objects
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { extractKV, extractUpdates, extractValues, objectAssign, objectEntries, objectKeys, patchObject } from '@zyno-io/ts-server-foundation';
|
|
62
|
+
|
|
63
|
+
const keys = objectKeys(user);
|
|
64
|
+
const entries = objectEntries(user);
|
|
65
|
+
const subset = extractValues(user, ['id', 'email'] as const);
|
|
66
|
+
const updates = extractUpdates(current, next);
|
|
67
|
+
patchObject(current, { name: 'Alice' });
|
|
68
|
+
const namesById = extractKV(users, 'id', 'name');
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`extractUpdates()` supports `equals` and `matches` comparison modes. `matches` recursively compares plain-object subsets.
|
|
72
|
+
|
|
73
|
+
## Transformer
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { Transformer } from '@zyno-io/ts-server-foundation';
|
|
77
|
+
|
|
78
|
+
const rows = await Transformer.create(users)
|
|
79
|
+
.apply(items => items.filter(item => item.active))
|
|
80
|
+
.applyEach(item => ({ ...item, label: item.name.toUpperCase() }))
|
|
81
|
+
.narrow('id', 'label')
|
|
82
|
+
.get();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Methods:
|
|
86
|
+
|
|
87
|
+
| Method | Description |
|
|
88
|
+
| ---------------------------------- | --------------------------------------------------- |
|
|
89
|
+
| `apply(fn, shouldApply?)` | Transforms the whole array. |
|
|
90
|
+
| `applyEach(fn, shouldApply?)` | Maps each item synchronously. |
|
|
91
|
+
| `applyEachAsync(fn, shouldApply?)` | Maps each item sequentially with an async function. |
|
|
92
|
+
| `narrow(...keys)` | Keeps selected keys. |
|
|
93
|
+
| `get()` | Resolves the transformed array. |
|
|
94
|
+
|
|
95
|
+
## JSON
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { fromJson, safeJsonStringify, toJson } from '@zyno-io/ts-server-foundation';
|
|
99
|
+
|
|
100
|
+
const text = toJson({ ok: true });
|
|
101
|
+
const value = fromJson<{ ok: boolean }>(text);
|
|
102
|
+
safeJsonStringify(circularObject);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`safeJsonStringify()` replaces circular references with `"[Circular]"`.
|
|
106
|
+
|
|
107
|
+
## Streams
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { safePipe, PipeError } from '@zyno-io/ts-server-foundation';
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
await safePipe(input, output);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (error instanceof PipeError) {
|
|
116
|
+
error.side; // 'input' | 'output'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`safePipe()` destroys the opposite stream when one side fails.
|
|
122
|
+
|
|
123
|
+
## Resource Cleanup
|
|
124
|
+
|
|
125
|
+
`withResourceCleanup()` owns temporary files and streams for the duration of an async operation:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { createReadStream } from 'node:fs';
|
|
129
|
+
import { withResourceCleanup } from '@zyno-io/ts-server-foundation';
|
|
130
|
+
|
|
131
|
+
const result = await withResourceCleanup(async tracker => {
|
|
132
|
+
tracker.addFile('/tmp/generated-report');
|
|
133
|
+
tracker.addStream(createReadStream('/tmp/generated-report'));
|
|
134
|
+
return processReport();
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The callback receives a `ResourceTracker`:
|
|
139
|
+
|
|
140
|
+
| Method | Behavior |
|
|
141
|
+
| --------------- | ----------------------------------------------------------------------------------------------- |
|
|
142
|
+
| `addFile(path)` | Records a file to unlink during cleanup. Missing/unlink-failed files are ignored. |
|
|
143
|
+
| `addStream(s)` | Records a readable or writable stream, captures its first emitted error, and destroys it later. |
|
|
144
|
+
| `getFailure()` | Returns the first recorded stream error, if any. |
|
|
145
|
+
| `cleanup()` | Unlinks tracked files and destroys tracked streams that are not already destroyed. |
|
|
146
|
+
|
|
147
|
+
Cleanup runs in `finally` after success or failure. If the callback finishes but a tracked stream has already emitted an error, `withResourceCleanup()` rejects with that error. Its optional `onError` callback observes callback/recorded failures before cleanup; it does not suppress them.
|
|
148
|
+
|
|
149
|
+
## Package Metadata
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { getPackageJson, getPackageName, getPackageVersion, resetPackageJsonCache } from '@zyno-io/ts-server-foundation';
|
|
153
|
+
|
|
154
|
+
getPackageName();
|
|
155
|
+
getPackageVersion();
|
|
156
|
+
resetPackageJsonCache();
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Package metadata is read from `process.cwd()/package.json` and cached.
|
|
160
|
+
|
|
161
|
+
## Security
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import {
|
|
165
|
+
AlphanumericCharacters,
|
|
166
|
+
Crypto,
|
|
167
|
+
NumericCharacters,
|
|
168
|
+
PrintableCharacters,
|
|
169
|
+
UpperCaseAlphanumericCharacters,
|
|
170
|
+
randomBytes,
|
|
171
|
+
randomBytesSync,
|
|
172
|
+
randomString,
|
|
173
|
+
randomStringSync
|
|
174
|
+
} from '@zyno-io/ts-server-foundation';
|
|
175
|
+
|
|
176
|
+
const token = await randomString(32, AlphanumericCharacters);
|
|
177
|
+
const pin = randomStringSync(6, NumericCharacters);
|
|
178
|
+
const recoveryCode = randomStringSync(12, UpperCaseAlphanumericCharacters);
|
|
179
|
+
const printable = randomStringSync(24, PrintableCharacters);
|
|
180
|
+
const bytes = await randomBytes(32);
|
|
181
|
+
const hex = randomBytesSync(16, true);
|
|
182
|
+
|
|
183
|
+
const encrypted = Crypto.encrypt('secret');
|
|
184
|
+
const decrypted = Crypto.decrypt(encrypted);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`Crypto` uses AES-256-GCM. `CRYPTO_SECRET` must be 32 bytes or 64 hex characters. `CRYPTO_IV_LENGTH` defaults to 12.
|
|
188
|
+
|
|
189
|
+
The four exported character sources are `PrintableCharacters` (ASCII 32 through 126), `AlphanumericCharacters`, `UpperCaseAlphanumericCharacters`, and `NumericCharacters`. `randomString()` and `randomStringSync()` default to `AlphanumericCharacters` and reject an empty source. Character selection uses random bytes modulo the source length.
|
|
190
|
+
|
|
191
|
+
`randomBytes(length, true)` and `randomBytesSync(length, true)` return hex strings; without `true` they return `Buffer` values. String encryption returns base64 and string decryption returns UTF-8. Buffer input produces Buffer output. Invalid/truncated payloads or authentication-tag failures throw. Use `new Crypto({ secret })` for app-independent settings with the default 12-byte IV, or also pass `ivLength` to override it. When `secret` is omitted, construction reads application configuration. The static methods share a lazily created instance, and `Crypto.reset()` clears that instance so changed application configuration is read on the next static call.
|
|
192
|
+
|
|
193
|
+
`assertInput()` and `isValidEmail()` provide lightweight boundary checks independent of reflection:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { assertInput, isValidEmail } from '@zyno-io/ts-server-foundation';
|
|
197
|
+
|
|
198
|
+
assertInput(value, 'email');
|
|
199
|
+
if (!isValidEmail(value)) throw new Error('Invalid email');
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`assertInput()` rejects `undefined`, `null`, and `''`; it does not reject other falsey values such as `0` or `false`. `isValidEmail()` is a simple whitespace/`@`/dot shape check, not mailbox verification.
|
|
203
|
+
|
|
204
|
+
## Reflected Deserialization And Validation
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
import { assertInput, deserialize, validate, validatedDeserialize } from '@zyno-io/ts-server-foundation';
|
|
208
|
+
|
|
209
|
+
const deserialized = deserialize<MyInput>(payload);
|
|
210
|
+
const errors = validate<MyInput>(payload);
|
|
211
|
+
const input = validatedDeserialize<MyInput>(payload);
|
|
212
|
+
assertInput(payload.name, 'name');
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The generic `deserialize<T>()`, `validate<T>()`, and `validatedDeserialize<T>()` calls require TSF's metadata compiler transform when the reflected type is supplied only through `T`.
|
|
216
|
+
|
|
217
|
+
| Helper | Deserializes | Validates | Failure behavior |
|
|
218
|
+
| --------------------------- | ------------ | --------- | ------------------------------------------------ |
|
|
219
|
+
| `deserialize<T>()` | Yes | No | Returns the transformed value. |
|
|
220
|
+
| `validate<T>()` | No | Yes | Returns every reflected `ValidatorError`. |
|
|
221
|
+
| `validatedDeserialize<T>()` | Yes | Yes | Deserializes first, then throws the first error. |
|
|
222
|
+
|
|
223
|
+
The compatibility exports `cast<T>()`, `assert<T>()`, and `is<T>()` receive generic metadata when they are imported directly from `@zyno-io/ts-server-foundation`. The compiler checks import identity so application helpers with the same short names are not transformed. Uncompiled calls and calls without a generic type require an explicit reflected `Type` argument and throw when it is absent.
|
|
224
|
+
|
|
225
|
+
Deserialization recursively coerces supported primitives, arrays, tuples, objects, unions, intersections, and reflected classes. It also applies registered transforms such as `TrimmedString` trimming and phone normalization. Reflected object DTOs are reconstructed from their declared properties, so undeclared input properties are generally dropped rather than rejected. Union deserialization uses validation internally to select the first matching branch, but `deserialize<T>()` does not perform a final whole-value validation pass.
|
|
226
|
+
|
|
227
|
+
Validation checks required/null handling, primitive and structured shapes, literals, enums, unions, and reflected constraints such as patterns, lengths, numeric bounds, and custom validators. `NaN` is not a valid reflected `number`; positive and negative infinity remain valid JavaScript numbers unless a narrower constraint rejects them.
|
|
228
|
+
|
|
229
|
+
Use `validatedDeserialize<T>()` for untrusted input whenever a type has transforms. Calling `validate<T>()` directly does not trim or normalize first. The exported `deserializer` is the global transform registry used by library-provided and custom reflected types; there is intentionally no reflected outbound serializer registry.
|
|
230
|
+
|
|
231
|
+
`assertInput()` is separate from reflected validation. It throws `HttpBadRequestError` when a value is `undefined`, `null`, or an empty string.
|
|
232
|
+
|
|
233
|
+
## Dates And UUIDs
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import { extractDate, sleepMs, sleepSecs, uuid4, uuid7, uuid7FromDate } from '@zyno-io/ts-server-foundation';
|
|
237
|
+
|
|
238
|
+
await sleepMs(100);
|
|
239
|
+
await sleepSecs(2);
|
|
240
|
+
const day = extractDate(new Date());
|
|
241
|
+
const id = uuid7();
|
|
242
|
+
const randomId = uuid4();
|
|
243
|
+
const historicalId = uuid7FromDate(new Date('2026-01-01T00:00:00Z'));
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
`extractDate()` accepts a `Date`, timestamp, or date string and returns the UTC `YYYY-MM-DD` portion of its ISO representation. Invalid date input throws when converted to ISO.
|
|
247
|
+
|
|
248
|
+
`uuid7()` creates time-ordered UUID v7 strings. `uuid7FromDate()` creates a v7 value using the supplied date's timestamp; it is not a deterministic hash of the date. `uuid4()` creates random UUID v4 strings.
|
|
249
|
+
|
|
250
|
+
## Error Helpers And Reporting
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
import { getErrorMessage, isError, reportError, setGlobalErrorReporter, toError, tryOrError, tryOrErrorSync } from '@zyno-io/ts-server-foundation';
|
|
254
|
+
|
|
255
|
+
const error = toError('failed to process input', unknownError);
|
|
256
|
+
const parsed = tryOrErrorSync(() => JSON.parse(text));
|
|
257
|
+
const fetched = await tryOrError(() => fetchData());
|
|
258
|
+
|
|
259
|
+
setGlobalErrorReporter((level, reported, context) => {
|
|
260
|
+
auditError(level, reported, context);
|
|
261
|
+
});
|
|
262
|
+
reportError(3, error, { scope: 'ImportJob', data: { fileId } });
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
`isError()` recognizes ordinary and native errors. `getErrorMessage()` returns an error's message or `String(value)`. `toError()` preserves an existing `Error`, converts other values with `String`, and attaches a recursively normalized `cause` when supplied. `tryOrErrorSync()` and `tryOrError()` return caught failures as `Error` values instead of throwing, so callers must distinguish the result with `isError()`.
|
|
266
|
+
|
|
267
|
+
`reportError()` synchronously calls the registered global reporter, sends the exception to Sentry when installed, and starts a Slack webhook notification only for level `1`. A throwing global reporter is isolated and logged so it does not prevent Sentry or Slack handling. Level `1` maps to Sentry `fatal`, level `3` to `warning`, and other levels to `error`. Populate `SentryLiftKeysToTagsFromLoggerContext` with primitive logger-context keys that should be lifted to Sentry tags; the remaining logger context stays in the event details. Slack delivery is asynchronous and delivery errors are logged rather than thrown to the caller.
|
|
268
|
+
|
|
269
|
+
See [Logging](./logging.md#error-handling) for logger integration and alert configuration.
|
|
270
|
+
|
|
271
|
+
## Redis Helpers
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
import { Cache, createBroadcastChannel, createRedis, createRedisOptions, disconnectAllRedis, withMutex } from '@zyno-io/ts-server-foundation';
|
|
275
|
+
|
|
276
|
+
const { client, prefix } = createRedis('CACHE');
|
|
277
|
+
await Cache.setObj('settings', { enabled: true }, 60);
|
|
278
|
+
|
|
279
|
+
const channel = createBroadcastChannel<{ id: string }>('item.changed');
|
|
280
|
+
channel.subscribe(message => console.log(message.id));
|
|
281
|
+
channel.publish({ id: '123' });
|
|
282
|
+
|
|
283
|
+
await withMutex({
|
|
284
|
+
key: ['job', 'daily'],
|
|
285
|
+
fn: async didWait => runJob(didWait),
|
|
286
|
+
mode: 'redis'
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
await disconnectAllRedis();
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Redis config prefixes map keys like `CACHE_REDIS_HOST` to the base Redis option names for that connection.
|
|
293
|
+
|
|
294
|
+
See [Redis](./redis.md) for cache, mutex, broadcast, and distributed-method details.
|