@zyno-io/dk-server-foundation 26.216.430
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/LICENSE +21 -0
- package/README.md +458 -0
- package/dist/devconsole/assets/index-CKF3C3kv.css +1 -0
- package/dist/devconsole/assets/index-CsHdomhM.js +27 -0
- package/dist/devconsole/index.html +13 -0
- package/dist/resources/proto/generated/devconsole/devconsole.d.ts +320 -0
- package/dist/resources/proto/generated/devconsole/devconsole.d.ts.map +1 -0
- package/dist/resources/proto/generated/devconsole/devconsole.js +3751 -0
- package/dist/resources/proto/generated/devconsole/devconsole.js.map +1 -0
- package/dist/src/app/base.d.ts +36 -0
- package/dist/src/app/base.d.ts.map +1 -0
- package/dist/src/app/base.js +240 -0
- package/dist/src/app/base.js.map +1 -0
- package/dist/src/app/config.d.ts +90 -0
- package/dist/src/app/config.d.ts.map +1 -0
- package/dist/src/app/config.js +33 -0
- package/dist/src/app/config.js.map +1 -0
- package/dist/src/app/config.loader.d.ts +14 -0
- package/dist/src/app/config.loader.d.ts.map +1 -0
- package/dist/src/app/config.loader.js +67 -0
- package/dist/src/app/config.loader.js.map +1 -0
- package/dist/src/app/const.d.ts +3 -0
- package/dist/src/app/const.d.ts.map +1 -0
- package/dist/src/app/const.js +6 -0
- package/dist/src/app/const.js.map +1 -0
- package/dist/src/app/dev.d.ts +7 -0
- package/dist/src/app/dev.d.ts.map +1 -0
- package/dist/src/app/dev.js +105 -0
- package/dist/src/app/dev.js.map +1 -0
- package/dist/src/app/index.d.ts +7 -0
- package/dist/src/app/index.d.ts.map +1 -0
- package/dist/src/app/index.js +12 -0
- package/dist/src/app/index.js.map +1 -0
- package/dist/src/app/openapi.d.ts +4 -0
- package/dist/src/app/openapi.d.ts.map +1 -0
- package/dist/src/app/openapi.js +6 -0
- package/dist/src/app/openapi.js.map +1 -0
- package/dist/src/app/resolver.d.ts +11 -0
- package/dist/src/app/resolver.d.ts.map +1 -0
- package/dist/src/app/resolver.js +60 -0
- package/dist/src/app/resolver.js.map +1 -0
- package/dist/src/app/shutdown.d.ts +12 -0
- package/dist/src/app/shutdown.d.ts.map +1 -0
- package/dist/src/app/shutdown.js +63 -0
- package/dist/src/app/shutdown.js.map +1 -0
- package/dist/src/app/state.d.ts +16 -0
- package/dist/src/app/state.d.ts.map +1 -0
- package/dist/src/app/state.js +12 -0
- package/dist/src/app/state.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 +6 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/jwt.d.ts +76 -0
- package/dist/src/auth/jwt.d.ts.map +1 -0
- package/dist/src/auth/jwt.js +218 -0
- package/dist/src/auth/jwt.js.map +1 -0
- package/dist/src/auth/provider.d.ts +15 -0
- package/dist/src/auth/provider.d.ts.map +1 -0
- package/dist/src/auth/provider.js +50 -0
- package/dist/src/auth/provider.js.map +1 -0
- package/dist/src/cli/dksf-dev.d.ts +3 -0
- package/dist/src/cli/dksf-dev.d.ts.map +1 -0
- package/dist/src/cli/dksf-dev.js +408 -0
- package/dist/src/cli/dksf-dev.js.map +1 -0
- package/dist/src/cli/dksf-gen-proto.d.ts +3 -0
- package/dist/src/cli/dksf-gen-proto.d.ts.map +1 -0
- package/dist/src/cli/dksf-gen-proto.js +164 -0
- package/dist/src/cli/dksf-gen-proto.js.map +1 -0
- package/dist/src/cli/dksf-install.d.ts +3 -0
- package/dist/src/cli/dksf-install.d.ts.map +1 -0
- package/dist/src/cli/dksf-install.js +10 -0
- package/dist/src/cli/dksf-install.js.map +1 -0
- package/dist/src/cli/dksf-test.d.ts +3 -0
- package/dist/src/cli/dksf-test.d.ts.map +1 -0
- package/dist/src/cli/dksf-test.js +78 -0
- package/dist/src/cli/dksf-test.js.map +1 -0
- package/dist/src/cli/dksf-update.d.ts +3 -0
- package/dist/src/cli/dksf-update.d.ts.map +1 -0
- package/dist/src/cli/dksf-update.js +86 -0
- package/dist/src/cli/dksf-update.js.map +1 -0
- package/dist/src/database/common.d.ts +84 -0
- package/dist/src/database/common.d.ts.map +1 -0
- package/dist/src/database/common.js +380 -0
- package/dist/src/database/common.js.map +1 -0
- package/dist/src/database/dialect.d.ts +10 -0
- package/dist/src/database/dialect.d.ts.map +1 -0
- package/dist/src/database/dialect.js +56 -0
- package/dist/src/database/dialect.js.map +1 -0
- package/dist/src/database/entity.d.ts +62 -0
- package/dist/src/database/entity.d.ts.map +1 -0
- package/dist/src/database/entity.js +198 -0
- package/dist/src/database/entity.js.map +1 -0
- package/dist/src/database/index.d.ts +8 -0
- package/dist/src/database/index.d.ts.map +1 -0
- package/dist/src/database/index.js +15 -0
- package/dist/src/database/index.js.map +1 -0
- package/dist/src/database/migration/MigrationResetCommand.d.ts +9 -0
- package/dist/src/database/migration/MigrationResetCommand.d.ts.map +1 -0
- package/dist/src/database/migration/MigrationResetCommand.js +75 -0
- package/dist/src/database/migration/MigrationResetCommand.js.map +1 -0
- package/dist/src/database/migration/MigrationRunCommand.d.ts +11 -0
- package/dist/src/database/migration/MigrationRunCommand.d.ts.map +1 -0
- package/dist/src/database/migration/MigrationRunCommand.js +118 -0
- package/dist/src/database/migration/MigrationRunCommand.js.map +1 -0
- package/dist/src/database/migration/characters.d.ts +14 -0
- package/dist/src/database/migration/characters.d.ts.map +1 -0
- package/dist/src/database/migration/characters.js +56 -0
- package/dist/src/database/migration/characters.js.map +1 -0
- package/dist/src/database/migration/create/MigrationCreateCommand.d.ts +11 -0
- package/dist/src/database/migration/create/MigrationCreateCommand.d.ts.map +1 -0
- package/dist/src/database/migration/create/MigrationCreateCommand.js +106 -0
- package/dist/src/database/migration/create/MigrationCreateCommand.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 +408 -0
- package/dist/src/database/migration/create/comparator.js.map +1 -0
- package/dist/src/database/migration/create/db-reader.d.ts +5 -0
- package/dist/src/database/migration/create/db-reader.d.ts.map +1 -0
- package/dist/src/database/migration/create/db-reader.js +473 -0
- package/dist/src/database/migration/create/db-reader.js.map +1 -0
- package/dist/src/database/migration/create/ddl-generator.d.ts +3 -0
- package/dist/src/database/migration/create/ddl-generator.d.ts.map +1 -0
- package/dist/src/database/migration/create/ddl-generator.js +725 -0
- package/dist/src/database/migration/create/ddl-generator.js.map +1 -0
- package/dist/src/database/migration/create/entity-reader.d.ts +4 -0
- package/dist/src/database/migration/create/entity-reader.d.ts.map +1 -0
- package/dist/src/database/migration/create/entity-reader.js +417 -0
- package/dist/src/database/migration/create/entity-reader.js.map +1 -0
- package/dist/src/database/migration/create/file-generator.d.ts +3 -0
- package/dist/src/database/migration/create/file-generator.d.ts.map +1 -0
- package/dist/src/database/migration/create/file-generator.js +62 -0
- package/dist/src/database/migration/create/file-generator.js.map +1 -0
- package/dist/src/database/migration/create/prompt.d.ts +4 -0
- package/dist/src/database/migration/create/prompt.d.ts.map +1 -0
- package/dist/src/database/migration/create/prompt.js +55 -0
- package/dist/src/database/migration/create/prompt.js.map +1 -0
- package/dist/src/database/migration/create/schema-model.d.ts +109 -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/helpers.d.ts +3 -0
- package/dist/src/database/migration/helpers.d.ts.map +1 -0
- package/dist/src/database/migration/helpers.js +13 -0
- package/dist/src/database/migration/helpers.js.map +1 -0
- package/dist/src/database/migration/index.d.ts +9 -0
- package/dist/src/database/migration/index.d.ts.map +1 -0
- package/dist/src/database/migration/index.js +43 -0
- package/dist/src/database/migration/index.js.map +1 -0
- package/dist/src/database/migration/migration.entity.d.ts +8 -0
- package/dist/src/database/migration/migration.entity.d.ts.map +1 -0
- package/dist/src/database/migration/migration.entity.js +16 -0
- package/dist/src/database/migration/migration.entity.js.map +1 -0
- package/dist/src/database/mysql.d.ts +16 -0
- package/dist/src/database/mysql.d.ts.map +1 -0
- package/dist/src/database/mysql.js +140 -0
- package/dist/src/database/mysql.js.map +1 -0
- package/dist/src/database/postgres.d.ts +16 -0
- package/dist/src/database/postgres.d.ts.map +1 -0
- package/dist/src/database/postgres.js +91 -0
- package/dist/src/database/postgres.js.map +1 -0
- package/dist/src/database/types.d.ts +21 -0
- package/dist/src/database/types.d.ts.map +1 -0
- package/dist/src/database/types.js +27 -0
- package/dist/src/database/types.js.map +1 -0
- package/dist/src/devconsole/devconsole.controller.d.ts +7 -0
- package/dist/src/devconsole/devconsole.controller.d.ts.map +1 -0
- package/dist/src/devconsole/devconsole.controller.js +82 -0
- package/dist/src/devconsole/devconsole.controller.js.map +1 -0
- package/dist/src/devconsole/devconsole.middleware.d.ts +12 -0
- package/dist/src/devconsole/devconsole.middleware.d.ts.map +1 -0
- package/dist/src/devconsole/devconsole.middleware.js +28 -0
- package/dist/src/devconsole/devconsole.middleware.js.map +1 -0
- package/dist/src/devconsole/devconsole.srpc.d.ts +14 -0
- package/dist/src/devconsole/devconsole.srpc.d.ts.map +1 -0
- package/dist/src/devconsole/devconsole.srpc.js +94 -0
- package/dist/src/devconsole/devconsole.srpc.js.map +1 -0
- package/dist/src/devconsole/devconsole.store.d.ts +101 -0
- package/dist/src/devconsole/devconsole.store.d.ts.map +1 -0
- package/dist/src/devconsole/devconsole.store.js +125 -0
- package/dist/src/devconsole/devconsole.store.js.map +1 -0
- package/dist/src/devconsole/devconsole.ws.d.ts +18 -0
- package/dist/src/devconsole/devconsole.ws.d.ts.map +1 -0
- package/dist/src/devconsole/devconsole.ws.js +470 -0
- package/dist/src/devconsole/devconsole.ws.js.map +1 -0
- package/dist/src/devconsole/index.d.ts +2 -0
- package/dist/src/devconsole/index.d.ts.map +1 -0
- package/dist/src/devconsole/index.js +6 -0
- package/dist/src/devconsole/index.js.map +1 -0
- package/dist/src/devconsole/patches.d.ts +6 -0
- package/dist/src/devconsole/patches.d.ts.map +1 -0
- package/dist/src/devconsole/patches.js +397 -0
- package/dist/src/devconsole/patches.js.map +1 -0
- package/dist/src/health/health.module.d.ts +6 -0
- package/dist/src/health/health.module.d.ts.map +1 -0
- package/dist/src/health/health.module.js +32 -0
- package/dist/src/health/health.module.js.map +1 -0
- package/dist/src/health/healthcheck.controller.d.ts +10 -0
- package/dist/src/health/healthcheck.controller.d.ts.map +1 -0
- package/dist/src/health/healthcheck.controller.js +30 -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 +33 -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 +6 -0
- package/dist/src/health/index.js.map +1 -0
- package/dist/src/helpers/async/context.d.ts +11 -0
- package/dist/src/helpers/async/context.d.ts.map +1 -0
- package/dist/src/helpers/async/context.js +75 -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 +44 -0
- package/dist/src/helpers/async/process.js.map +1 -0
- package/dist/src/helpers/async/promise.d.ts +5 -0
- package/dist/src/helpers/async/promise.d.ts.map +1 -0
- package/dist/src/helpers/async/promise.js +27 -0
- package/dist/src/helpers/async/promise.js.map +1 -0
- package/dist/src/helpers/data/array.d.ts +3 -0
- package/dist/src/helpers/data/array.d.ts.map +1 -0
- package/dist/src/helpers/data/array.js +17 -0
- package/dist/src/helpers/data/array.js.map +1 -0
- package/dist/src/helpers/data/objects.d.ts +12 -0
- package/dist/src/helpers/data/objects.d.ts.map +1 -0
- package/dist/src/helpers/data/objects.js +75 -0
- package/dist/src/helpers/data/objects.js.map +1 -0
- package/dist/src/helpers/data/serialization.d.ts +4 -0
- package/dist/src/helpers/data/serialization.d.ts.map +1 -0
- package/dist/src/helpers/data/serialization.js +15 -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 +55 -0
- package/dist/src/helpers/data/transformer.js.map +1 -0
- package/dist/src/helpers/framework/decorators.d.ts +5 -0
- package/dist/src/helpers/framework/decorators.d.ts.map +1 -0
- package/dist/src/helpers/framework/decorators.js +39 -0
- package/dist/src/helpers/framework/decorators.js.map +1 -0
- package/dist/src/helpers/framework/event.d.ts +3 -0
- package/dist/src/helpers/framework/event.d.ts.map +1 -0
- package/dist/src/helpers/framework/event.js +20 -0
- package/dist/src/helpers/framework/event.js.map +1 -0
- package/dist/src/helpers/framework/injection.d.ts +7 -0
- package/dist/src/helpers/framework/injection.d.ts.map +1 -0
- package/dist/src/helpers/framework/injection.js +52 -0
- package/dist/src/helpers/framework/injection.js.map +1 -0
- package/dist/src/helpers/index.d.ts +22 -0
- package/dist/src/helpers/index.d.ts.map +1 -0
- package/dist/src/helpers/index.js +32 -0
- package/dist/src/helpers/index.js.map +1 -0
- package/dist/src/helpers/io/package.d.ts +5 -0
- package/dist/src/helpers/io/package.d.ts.map +1 -0
- package/dist/src/helpers/io/package.js +31 -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 +91 -0
- package/dist/src/helpers/io/stream.js.map +1 -0
- package/dist/src/helpers/redis/broadcast.d.ts +13 -0
- package/dist/src/helpers/redis/broadcast.d.ts.map +1 -0
- package/dist/src/helpers/redis/broadcast.js +100 -0
- package/dist/src/helpers/redis/broadcast.js.map +1 -0
- package/dist/src/helpers/redis/cache.d.ts +7 -0
- package/dist/src/helpers/redis/cache.d.ts.map +1 -0
- package/dist/src/helpers/redis/cache.js +28 -0
- package/dist/src/helpers/redis/cache.js.map +1 -0
- package/dist/src/helpers/redis/mutex.d.ts +24 -0
- package/dist/src/helpers/redis/mutex.d.ts.map +1 -0
- package/dist/src/helpers/redis/mutex.js +240 -0
- package/dist/src/helpers/redis/mutex.js.map +1 -0
- package/dist/src/helpers/redis/redis.d.ts +11 -0
- package/dist/src/helpers/redis/redis.d.ts.map +1 -0
- package/dist/src/helpers/redis/redis.js +59 -0
- package/dist/src/helpers/redis/redis.js.map +1 -0
- package/dist/src/helpers/security/crypto.d.ts +26 -0
- package/dist/src/helpers/security/crypto.d.ts.map +1 -0
- package/dist/src/helpers/security/crypto.js +121 -0
- package/dist/src/helpers/security/crypto.js.map +1 -0
- package/dist/src/helpers/security/validation.d.ts +4 -0
- package/dist/src/helpers/security/validation.d.ts.map +1 -0
- package/dist/src/helpers/security/validation.js +25 -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 +23 -0
- package/dist/src/helpers/utils/date.js.map +1 -0
- package/dist/src/helpers/utils/error.d.ts +24 -0
- package/dist/src/helpers/utils/error.d.ts.map +1 -0
- package/dist/src/helpers/utils/error.js +168 -0
- package/dist/src/helpers/utils/error.js.map +1 -0
- package/dist/src/helpers/utils/jsx.d.ts +3 -0
- package/dist/src/helpers/utils/jsx.d.ts.map +1 -0
- package/dist/src/helpers/utils/jsx.js +13 -0
- package/dist/src/helpers/utils/jsx.js.map +1 -0
- package/dist/src/helpers/utils/uuid.d.ts +3 -0
- package/dist/src/helpers/utils/uuid.d.ts.map +1 -0
- package/dist/src/helpers/utils/uuid.js +14 -0
- package/dist/src/helpers/utils/uuid.js.map +1 -0
- package/dist/src/http/auth.d.ts +46 -0
- package/dist/src/http/auth.d.ts.map +1 -0
- package/dist/src/http/auth.js +162 -0
- package/dist/src/http/auth.js.map +1 -0
- package/dist/src/http/context.d.ts +5 -0
- package/dist/src/http/context.d.ts.map +1 -0
- package/dist/src/http/context.js +22 -0
- package/dist/src/http/context.js.map +1 -0
- package/dist/src/http/cors.d.ts +36 -0
- package/dist/src/http/cors.d.ts.map +1 -0
- package/dist/src/http/cors.js +171 -0
- package/dist/src/http/cors.js.map +1 -0
- package/dist/src/http/errors.d.ts +3 -0
- package/dist/src/http/errors.d.ts.map +1 -0
- package/dist/src/http/errors.js +10 -0
- package/dist/src/http/errors.js.map +1 -0
- package/dist/src/http/index.d.ts +24 -0
- package/dist/src/http/index.d.ts.map +1 -0
- package/dist/src/http/index.js +25 -0
- package/dist/src/http/index.js.map +1 -0
- package/dist/src/http/kernel.d.ts +17 -0
- package/dist/src/http/kernel.d.ts.map +1 -0
- package/dist/src/http/kernel.js +133 -0
- package/dist/src/http/kernel.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 +61 -0
- package/dist/src/http/middleware.js.map +1 -0
- package/dist/src/http/overrides.d.ts +2 -0
- package/dist/src/http/overrides.d.ts.map +1 -0
- package/dist/src/http/overrides.js +19 -0
- package/dist/src/http/overrides.js.map +1 -0
- package/dist/src/http/store.d.ts +33 -0
- package/dist/src/http/store.d.ts.map +1 -0
- package/dist/src/http/store.js +102 -0
- package/dist/src/http/store.js.map +1 -0
- package/dist/src/http/uploads.d.ts +7 -0
- package/dist/src/http/uploads.d.ts.map +1 -0
- package/dist/src/http/uploads.js +8 -0
- package/dist/src/http/uploads.js.map +1 -0
- package/dist/src/http/workflow.d.ts +18 -0
- package/dist/src/http/workflow.d.ts.map +1 -0
- package/dist/src/http/workflow.js +181 -0
- package/dist/src/http/workflow.js.map +1 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/services/cli/invoke.d.ts +5 -0
- package/dist/src/services/cli/invoke.d.ts.map +1 -0
- package/dist/src/services/cli/invoke.js +45 -0
- package/dist/src/services/cli/invoke.js.map +1 -0
- package/dist/src/services/cli/repl-context.d.ts +13 -0
- package/dist/src/services/cli/repl-context.d.ts.map +1 -0
- package/dist/src/services/cli/repl-context.js +60 -0
- package/dist/src/services/cli/repl-context.js.map +1 -0
- package/dist/src/services/cli/repl.d.ts +5 -0
- package/dist/src/services/cli/repl.d.ts.map +1 -0
- package/dist/src/services/cli/repl.js +32 -0
- package/dist/src/services/cli/repl.js.map +1 -0
- package/dist/src/services/cli.d.ts +12 -0
- package/dist/src/services/cli.d.ts.map +1 -0
- package/dist/src/services/cli.js +76 -0
- package/dist/src/services/cli.js.map +1 -0
- package/dist/src/services/index.d.ts +7 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +10 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/leader.d.ts +32 -0
- package/dist/src/services/leader.d.ts.map +1 -0
- package/dist/src/services/leader.js +174 -0
- package/dist/src/services/leader.js.map +1 -0
- package/dist/src/services/logger.d.ts +35 -0
- package/dist/src/services/logger.d.ts.map +1 -0
- package/dist/src/services/logger.js +245 -0
- package/dist/src/services/logger.js.map +1 -0
- package/dist/src/services/mail/index.d.ts +61 -0
- package/dist/src/services/mail/index.d.ts.map +1 -0
- package/dist/src/services/mail/index.js +90 -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 +42 -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 +61 -0
- package/dist/src/services/mail/smtp.js.map +1 -0
- package/dist/src/services/mesh.d.ts +65 -0
- package/dist/src/services/mesh.d.ts.map +1 -0
- package/dist/src/services/mesh.js +422 -0
- package/dist/src/services/mesh.js.map +1 -0
- package/dist/src/services/worker/bootstrap.d.ts +3 -0
- package/dist/src/services/worker/bootstrap.d.ts.map +1 -0
- package/dist/src/services/worker/bootstrap.js +64 -0
- package/dist/src/services/worker/bootstrap.js.map +1 -0
- package/dist/src/services/worker/cli.d.ts +11 -0
- package/dist/src/services/worker/cli.d.ts.map +1 -0
- package/dist/src/services/worker/cli.js +43 -0
- package/dist/src/services/worker/cli.js.map +1 -0
- package/dist/src/services/worker/entity.d.ts +18 -0
- package/dist/src/services/worker/entity.d.ts.map +1 -0
- package/dist/src/services/worker/entity.js +16 -0
- package/dist/src/services/worker/entity.js.map +1 -0
- package/dist/src/services/worker/index.d.ts +9 -0
- package/dist/src/services/worker/index.d.ts.map +1 -0
- package/dist/src/services/worker/index.js +40 -0
- package/dist/src/services/worker/index.js.map +1 -0
- package/dist/src/services/worker/queue.d.ts +8 -0
- package/dist/src/services/worker/queue.d.ts.map +1 -0
- package/dist/src/services/worker/queue.js +32 -0
- package/dist/src/services/worker/queue.js.map +1 -0
- package/dist/src/services/worker/recorder.d.ts +16 -0
- package/dist/src/services/worker/recorder.d.ts.map +1 -0
- package/dist/src/services/worker/recorder.js +168 -0
- package/dist/src/services/worker/recorder.js.map +1 -0
- package/dist/src/services/worker/runner.d.ts +21 -0
- package/dist/src/services/worker/runner.d.ts.map +1 -0
- package/dist/src/services/worker/runner.js +156 -0
- package/dist/src/services/worker/runner.js.map +1 -0
- package/dist/src/services/worker/types.d.ts +26 -0
- package/dist/src/services/worker/types.d.ts.map +1 -0
- package/dist/src/services/worker/types.js +29 -0
- package/dist/src/services/worker/types.js.map +1 -0
- package/dist/src/srpc/SrpcByteStream.d.ts +67 -0
- package/dist/src/srpc/SrpcByteStream.d.ts.map +1 -0
- package/dist/src/srpc/SrpcByteStream.js +319 -0
- package/dist/src/srpc/SrpcByteStream.js.map +1 -0
- package/dist/src/srpc/SrpcClient.d.ts +75 -0
- package/dist/src/srpc/SrpcClient.d.ts.map +1 -0
- package/dist/src/srpc/SrpcClient.js +445 -0
- package/dist/src/srpc/SrpcClient.js.map +1 -0
- package/dist/src/srpc/SrpcServer.d.ts +80 -0
- package/dist/src/srpc/SrpcServer.d.ts.map +1 -0
- package/dist/src/srpc/SrpcServer.js +561 -0
- package/dist/src/srpc/SrpcServer.js.map +1 -0
- package/dist/src/srpc/index.d.ts +7 -0
- package/dist/src/srpc/index.d.ts.map +1 -0
- package/dist/src/srpc/index.js +12 -0
- package/dist/src/srpc/index.js.map +1 -0
- package/dist/src/srpc/types.d.ts +131 -0
- package/dist/src/srpc/types.d.ts.map +1 -0
- package/dist/src/srpc/types.js +65 -0
- package/dist/src/srpc/types.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +2 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/index.js +5 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/otel/MariaDBInstrumentation.d.ts +22 -0
- package/dist/src/telemetry/otel/MariaDBInstrumentation.d.ts.map +1 -0
- package/dist/src/telemetry/otel/MariaDBInstrumentation.js +248 -0
- package/dist/src/telemetry/otel/MariaDBInstrumentation.js.map +1 -0
- package/dist/src/telemetry/otel/helpers.d.ts +27 -0
- package/dist/src/telemetry/otel/helpers.d.ts.map +1 -0
- package/dist/src/telemetry/otel/helpers.js +126 -0
- package/dist/src/telemetry/otel/helpers.js.map +1 -0
- package/dist/src/telemetry/otel/index.d.ts +14 -0
- package/dist/src/telemetry/otel/index.d.ts.map +1 -0
- package/dist/src/telemetry/otel/index.js +132 -0
- package/dist/src/telemetry/otel/index.js.map +1 -0
- package/dist/src/telemetry/otel/metrics.controller.d.ts +6 -0
- package/dist/src/telemetry/otel/metrics.controller.d.ts.map +1 -0
- package/dist/src/telemetry/otel/metrics.controller.js +63 -0
- package/dist/src/telemetry/otel/metrics.controller.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 +62 -0
- package/dist/src/telemetry/sentry.js.map +1 -0
- package/dist/src/testing/expect.d.ts +25 -0
- package/dist/src/testing/expect.d.ts.map +1 -0
- package/dist/src/testing/expect.js +151 -0
- package/dist/src/testing/expect.js.map +1 -0
- package/dist/src/testing/fixtures.d.ts +19 -0
- package/dist/src/testing/fixtures.d.ts.map +1 -0
- package/dist/src/testing/fixtures.js +69 -0
- package/dist/src/testing/fixtures.js.map +1 -0
- package/dist/src/testing/index.d.ts +260 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +345 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/requests.d.ts +10 -0
- package/dist/src/testing/requests.d.ts.map +1 -0
- package/dist/src/testing/requests.js +56 -0
- package/dist/src/testing/requests.js.map +1 -0
- package/dist/src/testing/sql.d.ts +11 -0
- package/dist/src/testing/sql.d.ts.map +1 -0
- package/dist/src/testing/sql.js +55 -0
- package/dist/src/testing/sql.js.map +1 -0
- package/dist/src/types/index.d.ts +57 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +73 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/phone.d.ts +11 -0
- package/dist/src/types/phone.d.ts.map +1 -0
- package/dist/src/types/phone.js +73 -0
- package/dist/src/types/phone.js.map +1 -0
- package/docs/.vitepress/config.mts +79 -0
- package/docs/.yarnrc.yml +1 -0
- package/docs/content/CONTRIBUTING.md +140 -0
- package/docs/content/README-DEV.md +142 -0
- package/docs/content/README.md +39 -0
- package/docs/content/authentication.md +215 -0
- package/docs/content/cli.md +335 -0
- package/docs/content/configuration.md +175 -0
- package/docs/content/database.md +422 -0
- package/docs/content/devconsole.md +123 -0
- package/docs/content/getting-started.md +154 -0
- package/docs/content/guides/test-migration-guide.md +351 -0
- package/docs/content/health.md +54 -0
- package/docs/content/helpers.md +322 -0
- package/docs/content/http.md +253 -0
- package/docs/content/index.md +147 -0
- package/docs/content/leader-service.md +98 -0
- package/docs/content/logging.md +150 -0
- package/docs/content/mail.md +161 -0
- package/docs/content/mesh-service.md +204 -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/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/redis.md +168 -0
- package/docs/content/srpc.md +261 -0
- package/docs/content/telemetry.md +166 -0
- package/docs/content/testing.md +222 -0
- package/docs/content/types.md +215 -0
- package/docs/content/worker.md +177 -0
- package/docs/package.json +16 -0
- package/docs/scripts/README-SCREENSHOTS.md +145 -0
- package/docs/scripts/capture-devconsole-screenshots.js +184 -0
- package/docs/yarn.lock +2408 -0
- package/package.json +144 -0
- package/patches/@deepkit+type+1.0.19.patch +38 -0
- package/patches/deepkit-openapi-core+0.0.9.patch +62 -0
- package/src/app/base.ts +253 -0
- package/src/app/config.loader.ts +66 -0
- package/src/app/config.ts +119 -0
- package/src/app/const.ts +4 -0
- package/src/app/dev.ts +92 -0
- package/src/app/index.ts +6 -0
- package/src/app/openapi.ts +3 -0
- package/src/app/resolver.ts +49 -0
- package/src/app/shutdown.ts +55 -0
- package/src/app/state.ts +19 -0
- package/src/auth/index.ts +2 -0
- package/src/auth/jwt.ts +275 -0
- package/src/auth/provider.ts +57 -0
- package/src/cli/dksf-dev.ts +416 -0
- package/src/cli/dksf-gen-proto.ts +176 -0
- package/src/cli/dksf-install.ts +11 -0
- package/src/cli/dksf-test.ts +84 -0
- package/src/cli/dksf-update.ts +101 -0
- package/src/database/common.ts +385 -0
- package/src/database/dialect.ts +43 -0
- package/src/database/entity.ts +285 -0
- package/src/database/index.ts +7 -0
- package/src/database/migration/MigrationResetCommand.ts +72 -0
- package/src/database/migration/MigrationRunCommand.ts +118 -0
- package/src/database/migration/characters.ts +53 -0
- package/src/database/migration/create/MigrationCreateCommand.ts +96 -0
- package/src/database/migration/create/comparator.ts +467 -0
- package/src/database/migration/create/db-reader.ts +510 -0
- package/src/database/migration/create/ddl-generator.ts +755 -0
- package/src/database/migration/create/entity-reader.ts +471 -0
- package/src/database/migration/create/file-generator.ts +57 -0
- package/src/database/migration/create/prompt.ts +49 -0
- package/src/database/migration/create/schema-model.ts +102 -0
- package/src/database/migration/helpers.ts +7 -0
- package/src/database/migration/index.ts +35 -0
- package/src/database/migration/migration.entity.ts +10 -0
- package/src/database/mysql.ts +140 -0
- package/src/database/postgres.ts +97 -0
- package/src/database/types.ts +18 -0
- package/src/devconsole/devconsole.controller.ts +59 -0
- package/src/devconsole/devconsole.middleware.ts +23 -0
- package/src/devconsole/devconsole.srpc.ts +94 -0
- package/src/devconsole/devconsole.store.ts +190 -0
- package/src/devconsole/devconsole.ws.ts +491 -0
- package/src/devconsole/index.ts +1 -0
- package/src/devconsole/patches.ts +428 -0
- package/src/health/health.module.ts +30 -0
- package/src/health/healthcheck.controller.ts +17 -0
- package/src/health/healthcheck.service.ts +28 -0
- package/src/health/index.ts +2 -0
- package/src/helpers/async/context.ts +67 -0
- package/src/helpers/async/process.ts +49 -0
- package/src/helpers/async/promise.ts +16 -0
- package/src/helpers/data/array.ts +11 -0
- package/src/helpers/data/objects.ts +64 -0
- package/src/helpers/data/serialization.ts +11 -0
- package/src/helpers/data/transformer.ts +54 -0
- package/src/helpers/framework/decorators.ts +27 -0
- package/src/helpers/framework/event.ts +11 -0
- package/src/helpers/framework/injection.ts +47 -0
- package/src/helpers/index.ts +34 -0
- package/src/helpers/io/package.ts +26 -0
- package/src/helpers/io/stream.ts +79 -0
- package/src/helpers/redis/broadcast.ts +96 -0
- package/src/helpers/redis/cache.ts +28 -0
- package/src/helpers/redis/mutex.ts +260 -0
- package/src/helpers/redis/redis.ts +60 -0
- package/src/helpers/security/crypto.ts +133 -0
- package/src/helpers/security/validation.ts +16 -0
- package/src/helpers/utils/date.ts +13 -0
- package/src/helpers/utils/error.ts +155 -0
- package/src/helpers/utils/jsx.ts +8 -0
- package/src/helpers/utils/uuid.ts +8 -0
- package/src/http/auth.ts +156 -0
- package/src/http/context.ts +15 -0
- package/src/http/cors.ts +159 -0
- package/src/http/errors.ts +9 -0
- package/src/http/index.ts +19 -0
- package/src/http/kernel.ts +138 -0
- package/src/http/middleware.ts +59 -0
- package/src/http/overrides.ts +20 -0
- package/src/http/store.ts +86 -0
- package/src/http/uploads.ts +6 -0
- package/src/http/workflow.ts +167 -0
- package/src/index.ts +19 -0
- package/src/services/cli/invoke.ts +39 -0
- package/src/services/cli/repl-context.ts +63 -0
- package/src/services/cli/repl.ts +22 -0
- package/src/services/cli.ts +74 -0
- package/src/services/index.ts +6 -0
- package/src/services/leader.ts +201 -0
- package/src/services/logger.ts +258 -0
- package/src/services/mail/index.ts +117 -0
- package/src/services/mail/postmark.ts +37 -0
- package/src/services/mail/smtp.ts +46 -0
- package/src/services/mesh.ts +508 -0
- package/src/services/worker/bootstrap.ts +53 -0
- package/src/services/worker/cli.ts +32 -0
- package/src/services/worker/entity.ts +22 -0
- package/src/services/worker/index.ts +30 -0
- package/src/services/worker/queue.ts +35 -0
- package/src/services/worker/recorder.ts +172 -0
- package/src/services/worker/runner.ts +179 -0
- package/src/services/worker/types.ts +32 -0
- package/src/srpc/SrpcByteStream.ts +382 -0
- package/src/srpc/SrpcClient.ts +512 -0
- package/src/srpc/SrpcServer.ts +681 -0
- package/src/srpc/index.ts +15 -0
- package/src/srpc/types.ts +146 -0
- package/src/telemetry/index.ts +1 -0
- package/src/telemetry/otel/MariaDBInstrumentation.ts +297 -0
- package/src/telemetry/otel/helpers.ts +117 -0
- package/src/telemetry/otel/index.ts +150 -0
- package/src/telemetry/otel/metrics.controller.ts +50 -0
- package/src/telemetry/sentry.ts +58 -0
- package/src/testing/expect.ts +148 -0
- package/src/testing/fixtures.ts +62 -0
- package/src/testing/index.ts +355 -0
- package/src/testing/requests.ts +68 -0
- package/src/testing/sql.ts +50 -0
- package/src/types/index.ts +64 -0
- package/src/types/phone.ts +64 -0
- package/types.d.ts +20 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Authentication
|
|
2
|
+
|
|
3
|
+
JWT (HS256/EdDSA) and HTTP Basic Auth with request-scoped caching and entity resolution.
|
|
4
|
+
|
|
5
|
+
## JWT
|
|
6
|
+
|
|
7
|
+
### Configuration
|
|
8
|
+
|
|
9
|
+
Configure via environment variables (see [Configuration](./configuration.md)):
|
|
10
|
+
|
|
11
|
+
- `AUTH_JWT_SECRET` -- Plain string HMAC key (HS256)
|
|
12
|
+
- `AUTH_JWT_SECRET_B64` -- Base64-encoded HMAC key (HS256)
|
|
13
|
+
- `AUTH_JWT_ED_SECRET` -- EdDSA private key (PEM format, base64-encoded)
|
|
14
|
+
- `AUTH_JWT_ISSUER` -- Issuer claim
|
|
15
|
+
- `AUTH_JWT_EXPIRATION_MINS` -- Token expiration in minutes
|
|
16
|
+
- `AUTH_JWT_COOKIE_NAME` -- Cookie name for JWT storage
|
|
17
|
+
- `AUTH_JWT_ENABLE_VERIFY` -- Enable signature verification (default: `true`)
|
|
18
|
+
|
|
19
|
+
### Generating Tokens
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { JWT } from '@zyno-io/dk-server-foundation';
|
|
23
|
+
|
|
24
|
+
// Generate a JWT
|
|
25
|
+
const token = await JWT.generate({
|
|
26
|
+
subject: user.id.toString(),
|
|
27
|
+
payload: { role: user.role }
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Generate and set as HttpOnly cookie
|
|
31
|
+
await JWT.generateCookie({ subject: user.id.toString(), payload: { role: user.role } }, response);
|
|
32
|
+
|
|
33
|
+
// Clear the JWT cookie
|
|
34
|
+
JWT.clearCookie(response);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Verifying Tokens
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { JWT } from '@zyno-io/dk-server-foundation';
|
|
41
|
+
|
|
42
|
+
// Verify signature and claims
|
|
43
|
+
const result = await JWT.verify<{ role: string }>(token);
|
|
44
|
+
if (result.isValid) {
|
|
45
|
+
console.log(result.subject); // User ID
|
|
46
|
+
console.log(result.payload.role); // Typed payload
|
|
47
|
+
} else {
|
|
48
|
+
// Granular failure inspection
|
|
49
|
+
console.log(result.isDecodable); // Could the token be decoded?
|
|
50
|
+
console.log(result.isSignatureValid); // Was the signature valid?
|
|
51
|
+
console.log(result.isPayloadValid); // Were the claims valid?
|
|
52
|
+
console.log(result.isNotExpired); // Is the token not expired?
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Decode without verification
|
|
56
|
+
const decoded = await JWT.decode<{ role: string }>(token);
|
|
57
|
+
|
|
58
|
+
// Process (verify or decode based on AUTH_JWT_ENABLE_VERIFY)
|
|
59
|
+
const processed = await JWT.process(token);
|
|
60
|
+
|
|
61
|
+
// Extract from request (Bearer token or cookie)
|
|
62
|
+
const fromReq = await JWT.processWithRequest(request);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Custom Verifiers
|
|
66
|
+
|
|
67
|
+
Create verifiers with different keys or options:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const verifier = JWT.createVerifier({
|
|
71
|
+
key: 'custom-secret',
|
|
72
|
+
algorithm: 'HS256'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// verifier is an async function: (token) => Promise<JwtValidationResult>
|
|
76
|
+
const result = await verifier(token);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### JWT Result Types
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Valid JWT (class with isValid = true)
|
|
83
|
+
class ParsedJwt<T> {
|
|
84
|
+
readonly isValid = true;
|
|
85
|
+
id?: string;
|
|
86
|
+
issuer!: string;
|
|
87
|
+
audience?: string;
|
|
88
|
+
subject!: string;
|
|
89
|
+
issuedAtMs!: number;
|
|
90
|
+
get issuedAt(): Date; // Derived from issuedAtMs
|
|
91
|
+
expiresAtMs!: number;
|
|
92
|
+
get expiresAt(): Date; // Derived from expiresAtMs
|
|
93
|
+
payload!: T;
|
|
94
|
+
rawPayload!: Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Invalid JWT
|
|
98
|
+
interface InvalidJwtValidationResult {
|
|
99
|
+
isValid: false;
|
|
100
|
+
isDecodable: boolean;
|
|
101
|
+
isSignatureValid?: boolean;
|
|
102
|
+
isPayloadValid?: boolean;
|
|
103
|
+
isNotExpired?: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type JwtValidationResult<T> = ParsedJwt<T> | InvalidJwtValidationResult;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Entity Authentication Middleware
|
|
110
|
+
|
|
111
|
+
`createAuthMiddleware()` returns a middleware class that validates the JWT and caches the entity ID. Extend it to add entity validation:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { createAuthMiddleware, getEntityFromRequestJwt } from '@zyno-io/dk-server-foundation';
|
|
115
|
+
|
|
116
|
+
// Basic auth middleware - validates JWT has a subject
|
|
117
|
+
const AuthMiddleware = createAuthMiddleware(User);
|
|
118
|
+
|
|
119
|
+
// With custom entity validation (extend the returned class)
|
|
120
|
+
class StrictAuthMiddleware extends createAuthMiddleware(User) {
|
|
121
|
+
async validateEntity(request: HttpRequest, entity: User) {
|
|
122
|
+
if (entity.isSuspended) {
|
|
123
|
+
throw new HttpAccessDeniedError();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Use in controllers
|
|
129
|
+
@http.controller('/api')
|
|
130
|
+
class UserController {
|
|
131
|
+
@(http.GET('/me').use(AuthMiddleware))
|
|
132
|
+
async getMe(request: HttpRequest) {
|
|
133
|
+
const user = await getEntityFromRequestJwt(request, User);
|
|
134
|
+
return user;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### How It Works
|
|
140
|
+
|
|
141
|
+
1. JWT extracted from `Authorization: Bearer <token>` header or cookie
|
|
142
|
+
2. JWT verified (or decoded if `AUTH_JWT_ENABLE_VERIFY=false`)
|
|
143
|
+
3. Entity ID extracted from JWT subject and cached per-request
|
|
144
|
+
4. If the subclass defines `validateEntity()`, the entity is loaded and validated
|
|
145
|
+
5. Entity ID and entity are cached per-request (subsequent accesses don't hit the database)
|
|
146
|
+
|
|
147
|
+
### Lower-Level Functions
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { getJwtFromRequest, getEntityFromRequestJwt, getEntityIdFromRequestJwt } from '@zyno-io/dk-server-foundation';
|
|
151
|
+
|
|
152
|
+
// Get parsed JWT from request (cached)
|
|
153
|
+
const jwt = await getJwtFromRequest(request);
|
|
154
|
+
|
|
155
|
+
// Get entity from JWT subject
|
|
156
|
+
const user = await getEntityFromRequestJwt(request, User);
|
|
157
|
+
|
|
158
|
+
// Get just the entity ID from JWT subject
|
|
159
|
+
const userId = await getEntityIdFromRequestJwt(request);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## HTTP Basic Auth
|
|
163
|
+
|
|
164
|
+
Create middleware for HTTP Basic Authentication using the `AUTH_BASIC_SECRET` config value:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { createBasicAuthMiddleware } from '@zyno-io/dk-server-foundation';
|
|
168
|
+
|
|
169
|
+
// Any username, password must match AUTH_BASIC_SECRET
|
|
170
|
+
const basicAuth = createBasicAuthMiddleware();
|
|
171
|
+
|
|
172
|
+
// Specific username required
|
|
173
|
+
const basicAuth = createBasicAuthMiddleware('admin');
|
|
174
|
+
|
|
175
|
+
@http.GET('/admin/stats').use(basicAuth)
|
|
176
|
+
async getStats() {
|
|
177
|
+
return { users: 100 };
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Password Hashing
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { Auth } from '@zyno-io/dk-server-foundation';
|
|
185
|
+
|
|
186
|
+
// Hash a password (bcrypt, default 10 rounds)
|
|
187
|
+
const hash = await Auth.hashPassword('my-password');
|
|
188
|
+
const hash = await Auth.hashPassword('my-password', 12); // custom rounds
|
|
189
|
+
|
|
190
|
+
// Verify a password
|
|
191
|
+
const isValid = await Auth.verifyHash('my-password', hash);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Reset Tokens
|
|
195
|
+
|
|
196
|
+
Generate secure tokens for password resets, email verification, etc.:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { Auth } from '@zyno-io/dk-server-foundation';
|
|
200
|
+
|
|
201
|
+
// Generate a reset token with embedded data
|
|
202
|
+
const { token, verifier, generatedAt } = await Auth.generateResetToken({
|
|
203
|
+
userId: 123,
|
|
204
|
+
email: 'user@example.com'
|
|
205
|
+
});
|
|
206
|
+
// token: base64-encoded string containing timestamp + verifier + data
|
|
207
|
+
|
|
208
|
+
// Decode the token
|
|
209
|
+
const decoded = await Auth.decodeResetToken<{ userId: number; email: string }>(token);
|
|
210
|
+
console.log(decoded.data.userId); // 123
|
|
211
|
+
console.log(decoded.generatedAt); // Date
|
|
212
|
+
console.log(decoded.verifier); // Buffer (16 bytes)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The token embeds a 4-byte timestamp, 16-byte random verifier, and JSON-serialized data, all base64-encoded. The `verifier` field is a base64-encoded string (not a Buffer), and `generationTime` is a Unix timestamp in milliseconds.
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# CLI Tools
|
|
2
|
+
|
|
3
|
+
Built-in CLI commands and standalone tools for development, debugging, and database management.
|
|
4
|
+
|
|
5
|
+
## Application CLI Commands
|
|
6
|
+
|
|
7
|
+
These commands are available when running your app:
|
|
8
|
+
|
|
9
|
+
### REPL
|
|
10
|
+
|
|
11
|
+
Interactive Node.js REPL with access to all providers and entities:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
node app.js repl
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Inside the REPL:
|
|
18
|
+
|
|
19
|
+
- `$` -- Object containing all registered class types (for use with `r()`)
|
|
20
|
+
- `$$` -- Object containing resolved instances of all providers
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
> $$.UserService.findById(1)
|
|
24
|
+
> r($.MyDatabase).query($.User).find()
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Provider Invoke
|
|
28
|
+
|
|
29
|
+
Invoke any provider method from the command line:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
node app.js provider:invoke UserService findById '[1]'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Arguments:
|
|
36
|
+
|
|
37
|
+
| Argument | Description |
|
|
38
|
+
| -------------- | ---------------------------------- |
|
|
39
|
+
| `providerName` | Class name of the provider |
|
|
40
|
+
| `methodName` | Method to call |
|
|
41
|
+
| `argsJson` | JSON array of arguments (optional) |
|
|
42
|
+
|
|
43
|
+
### Migration Commands
|
|
44
|
+
|
|
45
|
+
#### `migration:run`
|
|
46
|
+
|
|
47
|
+
Run all pending migrations:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
node app.js migration:run
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Behavior:
|
|
54
|
+
|
|
55
|
+
1. Scans the migrations directory for `.ts`/`.js` files
|
|
56
|
+
2. Creates `_migrations` table if it doesn't exist
|
|
57
|
+
3. Runs unexecuted migrations in alphabetical order
|
|
58
|
+
4. Records execution time in `_migrations` table
|
|
59
|
+
5. Clears repeatable worker jobs (if workers enabled)
|
|
60
|
+
|
|
61
|
+
#### `migration:create`
|
|
62
|
+
|
|
63
|
+
Generate a migration by comparing entity definitions against the live database schema:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Interactive mode (prompts for column renames)
|
|
67
|
+
node app.js migration:create
|
|
68
|
+
|
|
69
|
+
# Non-interactive (CI-safe)
|
|
70
|
+
node app.js migration:create --non-interactive
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Behavior:
|
|
74
|
+
|
|
75
|
+
1. Reads entity metadata via Deepkit reflection
|
|
76
|
+
2. Introspects the live database schema via `information_schema`
|
|
77
|
+
3. Compares the two and detects added/removed/modified tables, columns, indexes, foreign keys, primary key changes, and PostgreSQL enum types
|
|
78
|
+
4. In interactive mode, prompts to detect column renames (avoiding data loss from drop+add)
|
|
79
|
+
5. Generates dialect-specific DDL (MySQL or PostgreSQL)
|
|
80
|
+
6. Writes a timestamped migration file using `createMigration()` format
|
|
81
|
+
|
|
82
|
+
**Non-interactive mode**: Column renames cannot be detected without user input. Ambiguous changes (columns simultaneously added and removed on the same table) are treated as separate DROP/ADD operations, which may cause data loss. A warning is printed when this occurs.
|
|
83
|
+
|
|
84
|
+
#### `migration:reset`
|
|
85
|
+
|
|
86
|
+
Generate a single base migration from entity definitions:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
node app.js migration:reset
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Behavior:
|
|
93
|
+
|
|
94
|
+
1. Creates the `src/migrations/` directory if missing
|
|
95
|
+
2. Removes all existing `.ts` migration files
|
|
96
|
+
3. Reads entity schema from code definitions (using the same entity-reader as `migration:create`)
|
|
97
|
+
4. Generates DDL by treating all entity tables as new (using the same DDL generator as `migration:create`)
|
|
98
|
+
5. Writes `00000000_000000_base.ts` with all CREATE statements
|
|
99
|
+
6. Skips internal tables (prefixed with `_`)
|
|
100
|
+
|
|
101
|
+
#### `migration:characters`
|
|
102
|
+
|
|
103
|
+
Standardize database character set and collation:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
node app.js migration:characters [charset] [collation]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Defaults to `utf8mb4` / `utf8mb4_0900_ai_ci`.
|
|
110
|
+
|
|
111
|
+
### Worker Commands
|
|
112
|
+
|
|
113
|
+
#### `worker:start`
|
|
114
|
+
|
|
115
|
+
Start the BullMQ job runner. One runner automatically self-elects as the job recorder via leader election:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
node app.js worker:start
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### `worker:queue`
|
|
122
|
+
|
|
123
|
+
Queue a job by name from the command line:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
node app.js worker:queue SendEmailJob '{"to":"user@example.com","subject":"Hello"}'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Standalone CLI Tools
|
|
130
|
+
|
|
131
|
+
These are installed as bin scripts by the package:
|
|
132
|
+
|
|
133
|
+
### `dksf-dev`
|
|
134
|
+
|
|
135
|
+
All-in-one development workflow tool. Subcommands for cleaning, building, running dev servers, migrations, tests, and REPL.
|
|
136
|
+
|
|
137
|
+
Sets `APP_ENV=development` by default if not already set in the environment.
|
|
138
|
+
|
|
139
|
+
#### Common Options
|
|
140
|
+
|
|
141
|
+
All subcommands (except `clean`) accept:
|
|
142
|
+
|
|
143
|
+
| Option | Description |
|
|
144
|
+
| ----------------------- | ------------------------------------------------------------------------------------- |
|
|
145
|
+
| `-p, --tsconfig <file>` | TypeScript config file (default: `tsconfig.json`, or `tsconfig.test.json` for `test`) |
|
|
146
|
+
|
|
147
|
+
#### `dksf-dev clean`
|
|
148
|
+
|
|
149
|
+
Removes the `dist/` directory.
|
|
150
|
+
|
|
151
|
+
#### `dksf-dev build`
|
|
152
|
+
|
|
153
|
+
Cleans, then compiles with TypeScript:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# One-shot build
|
|
157
|
+
dksf-dev build
|
|
158
|
+
|
|
159
|
+
# Watch mode
|
|
160
|
+
dksf-dev build --watch
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Without `--watch`, runs `tsc -p tsconfig.json` and exits. With `--watch`, runs `tsc -w --preserveWatchOutput -p tsconfig.json` (use Ctrl+C to stop).
|
|
164
|
+
|
|
165
|
+
#### `dksf-dev run`
|
|
166
|
+
|
|
167
|
+
Cleans, starts `tsc --watch`, and once the initial compilation completes, starts the application with `node --watch`. The first `run` process owns the `tsc --watch` for continuous recompilation:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Default: node --watch --inspect . server:start
|
|
171
|
+
dksf-dev run
|
|
172
|
+
|
|
173
|
+
# Run a different command
|
|
174
|
+
dksf-dev run -- nats:process
|
|
175
|
+
|
|
176
|
+
# Custom script entrypoint
|
|
177
|
+
dksf-dev run ./src/other.js
|
|
178
|
+
|
|
179
|
+
# Debug mode (--inspect-brk instead of --inspect)
|
|
180
|
+
dksf-dev run --debug
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
| Option | Description |
|
|
184
|
+
| ----------- | --------------------------------------------------------------------- |
|
|
185
|
+
| `--debug` | Use `--inspect-brk` instead of `--inspect` |
|
|
186
|
+
| `<script>` | Entrypoint to run (default: `.`, resolves via `main` in package.json) |
|
|
187
|
+
| `-- <args>` | Arguments passed to the child process (default: `server:start`) |
|
|
188
|
+
|
|
189
|
+
**Inspect port**: Always includes `--inspect` (or `--inspect-brk` with `--debug`). If `PORT` is set, the inspect port is `PORT + 1000`. Otherwise the default Node.js inspect port (9229) is used.
|
|
190
|
+
|
|
191
|
+
**Multi-process coordination**: Multiple `dksf-dev run` processes in the same project coordinate via a temp file (keyed by a hash of the project path). The first process performs the clean+build; any others started concurrently wait for it to finish. This allows running multiple dev processes without redundant builds:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Terminal 1
|
|
195
|
+
dksf-dev run
|
|
196
|
+
|
|
197
|
+
# Terminal 2 (waits for Terminal 1's build, then starts)
|
|
198
|
+
dksf-dev run -- nats:process
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### `dksf-dev migrate`
|
|
202
|
+
|
|
203
|
+
Runs database migrations:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
dksf-dev migrate
|
|
207
|
+
dksf-dev migrate --debug
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
If a `dksf-dev run` process is already running (detected via the coordination state file), the clean+build step is skipped. Otherwise, a full clean+build is performed first.
|
|
211
|
+
|
|
212
|
+
Runs: `node --inspect=9226 . migration:run` (or `--inspect-brk=9226` with `--debug`).
|
|
213
|
+
|
|
214
|
+
#### `dksf-dev migrate:create`
|
|
215
|
+
|
|
216
|
+
Generates a migration by comparing entity definitions against the live database:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
dksf-dev migrate:create
|
|
220
|
+
dksf-dev migrate:create --debug
|
|
221
|
+
dksf-dev migrate:create --non-interactive
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Builds (if needed), then runs `node --inspect=9226 . migration:create`. Extra arguments (e.g., `--non-interactive`) are passed through.
|
|
225
|
+
|
|
226
|
+
#### `dksf-dev migrate:reset`
|
|
227
|
+
|
|
228
|
+
Removes all existing migrations and generates a single base migration from entity definitions:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
dksf-dev migrate:reset
|
|
232
|
+
dksf-dev migrate:reset --debug
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Builds (if needed), then runs `node --inspect=9226 . migration:reset`.
|
|
236
|
+
|
|
237
|
+
#### `dksf-dev test`
|
|
238
|
+
|
|
239
|
+
Cleans, compiles tests, and runs the test suite:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Run all tests
|
|
243
|
+
dksf-dev test
|
|
244
|
+
|
|
245
|
+
# Run specific test file(s)
|
|
246
|
+
dksf-dev test tests/helpers/array.spec.ts
|
|
247
|
+
|
|
248
|
+
# Run all tests in a directory
|
|
249
|
+
dksf-dev test tests/integration/
|
|
250
|
+
|
|
251
|
+
# Debug mode
|
|
252
|
+
dksf-dev test --debug
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Runs: `tsc -p tsconfig.test.json`, then `dksf-test` with `--inspect=9268` (or `--inspect-brk=9268` with `--debug`). Extra arguments are passed through to `dksf-test`.
|
|
256
|
+
|
|
257
|
+
#### `dksf-dev repl`
|
|
258
|
+
|
|
259
|
+
Builds (if no `dksf-dev run` process is active) and starts an interactive REPL:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Start REPL
|
|
263
|
+
dksf-dev repl
|
|
264
|
+
|
|
265
|
+
# Debug mode
|
|
266
|
+
dksf-dev repl --debug
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Runs: `node --inspect=9227 . repl` (or `--inspect-brk=9227` with `--debug`). See [REPL](#repl) above for usage inside the REPL.
|
|
270
|
+
|
|
271
|
+
### `dksf-gen-proto`
|
|
272
|
+
|
|
273
|
+
Generate TypeScript types from Protocol Buffer `.proto` files using ts-proto:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
dksf-gen-proto <input.proto> <output-dir> [options]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
| Option | Description |
|
|
280
|
+
| ---------------- | ---------------------------------- |
|
|
281
|
+
| `--use-date` | Use `Date` instead of `Timestamp` |
|
|
282
|
+
| `--use-map-type` | Use `Map` instead of plain objects |
|
|
283
|
+
| `--only-types` | Generate only type definitions |
|
|
284
|
+
|
|
285
|
+
Example:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
dksf-gen-proto src/proto/messages.proto src/generated/proto/messages
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### `dksf-install`
|
|
292
|
+
|
|
293
|
+
Postinstall script that runs:
|
|
294
|
+
|
|
295
|
+
1. `patch-package` -- Apply any patches
|
|
296
|
+
2. `deepkit-type-install` -- Install Deepkit type reflection
|
|
297
|
+
|
|
298
|
+
This runs automatically after `npm install` / `yarn install`.
|
|
299
|
+
|
|
300
|
+
### `dksf-update`
|
|
301
|
+
|
|
302
|
+
Update utility for the library.
|
|
303
|
+
|
|
304
|
+
## Creating Migrations
|
|
305
|
+
|
|
306
|
+
Migrations are TypeScript files in the `src/migrations/` directory (or `dist/src/migrations/` for compiled code):
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// src/migrations/20240101_120000_add_users.ts
|
|
310
|
+
import { createMigration } from '@zyno-io/dk-server-foundation';
|
|
311
|
+
|
|
312
|
+
export default createMigration(async db => {
|
|
313
|
+
await db.rawExecute(sql`
|
|
314
|
+
CREATE TABLE users (
|
|
315
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
316
|
+
email VARCHAR(255) NOT NULL UNIQUE,
|
|
317
|
+
name VARCHAR(255) NOT NULL,
|
|
318
|
+
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
319
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
|
320
|
+
`);
|
|
321
|
+
});
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Run programmatically:
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import { runMigrations } from '@zyno-io/dk-server-foundation';
|
|
328
|
+
await runMigrations();
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Migration File Resolution
|
|
332
|
+
|
|
333
|
+
- Running `.ts` files: looks in `src/migrations/`
|
|
334
|
+
- Running `.js` files: looks in `dist/src/migrations/`
|
|
335
|
+
- Override with `DKSF_FORCE_DIST_MIGRATIONS=true` to always use `dist/`
|