@signal24/dk-server-foundation 26.213.615
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/.gitattributes +2 -0
- package/.gitlab-ci.yml +49 -0
- package/.oxlintrc.json +40 -0
- package/.prettierignore +3 -0
- package/.prettierrc.json +15 -0
- package/.serena/project.yml +111 -0
- package/.vscode/launch.json +15 -0
- package/.vscode/settings.json +12 -0
- package/.yarnrc.yml +5 -0
- package/CLAUDE.md +279 -0
- package/LICENSE +21 -0
- package/README.md +439 -0
- package/TEST_MIGRATION_GUIDE.md +348 -0
- package/dist/resources/proto/generated/test/test.d.ts +224 -0
- package/dist/resources/proto/generated/test/test.d.ts.map +1 -0
- package/dist/resources/proto/generated/test/test.js +2376 -0
- package/dist/resources/proto/generated/test/test.js.map +1 -0
- package/dist/src/app/base.d.ts +37 -0
- package/dist/src/app/base.d.ts.map +1 -0
- package/dist/src/app/base.js +244 -0
- package/dist/src/app/base.js.map +1 -0
- package/dist/src/app/config.d.ts +91 -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 +6 -0
- package/dist/src/app/dev.d.ts.map +1 -0
- package/dist/src/app/dev.js +78 -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 +359 -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 +91 -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 +11 -0
- package/dist/src/database/migration/MigrationResetCommand.d.ts.map +1 -0
- package/dist/src/database/migration/MigrationResetCommand.js +149 -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 +104 -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 +408 -0
- package/dist/src/database/migration/create/entity-reader.js.map +1 -0
- package/dist/src/database/migration/create/file-generator.d.ts +2 -0
- package/dist/src/database/migration/create/file-generator.d.ts.map +1 -0
- package/dist/src/database/migration/create/file-generator.js +55 -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 +2 -0
- package/dist/src/database/migration/helpers.d.ts.map +1 -0
- package/dist/src/database/migration/helpers.js +8 -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/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 +8 -0
- package/dist/src/health/healthcheck.service.d.ts.map +1 -0
- package/dist/src/health/healthcheck.service.js +20 -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 +12 -0
- package/dist/src/helpers/redis/broadcast.d.ts.map +1 -0
- package/dist/src/helpers/redis/broadcast.js +99 -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.d.ts +5 -0
- package/dist/src/services/cli/repl.d.ts.map +1 -0
- package/dist/src/services/cli/repl.js +71 -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 +70 -0
- package/dist/src/services/worker/bootstrap.js.map +1 -0
- package/dist/src/services/worker/cli.d.ts +23 -0
- package/dist/src/services/worker/cli.d.ts.map +1 -0
- package/dist/src/services/worker/cli.js +81 -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/observer.d.ts +18 -0
- package/dist/src/services/worker/observer.d.ts.map +1 -0
- package/dist/src/services/worker/observer.js +172 -0
- package/dist/src/services/worker/observer.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 +31 -0
- package/dist/src/services/worker/queue.js.map +1 -0
- package/dist/src/services/worker/runner.d.ts +17 -0
- package/dist/src/services/worker/runner.d.ts.map +1 -0
- package/dist/src/services/worker/runner.js +131 -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 +54 -0
- package/dist/src/srpc/SrpcServer.d.ts.map +1 -0
- package/dist/src/srpc/SrpcServer.js +456 -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 +129 -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/testapp/bootstrap.d.ts +1 -0
- package/dist/src/testapp/bootstrap.d.ts.map +1 -0
- package/dist/src/testapp/bootstrap.js +18 -0
- package/dist/src/testapp/bootstrap.js.map +1 -0
- package/dist/src/testapp/sample.d.ts +6 -0
- package/dist/src/testapp/sample.d.ts.map +1 -0
- package/dist/src/testapp/sample.js +228 -0
- package/dist/src/testapp/sample.js.map +1 -0
- package/dist/src/testapp/srpc-test.d.ts +27 -0
- package/dist/src/testapp/srpc-test.d.ts.map +1 -0
- package/dist/src/testapp/srpc-test.js +570 -0
- package/dist/src/testapp/srpc-test.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/dist/tsconfig.tsbuildinfo +1 -0
- package/docs/README.md +38 -0
- package/docs/authentication.md +215 -0
- package/docs/cli.md +302 -0
- package/docs/configuration.md +176 -0
- package/docs/database.md +422 -0
- package/docs/getting-started.md +154 -0
- package/docs/health.md +53 -0
- package/docs/helpers.md +436 -0
- package/docs/http.md +253 -0
- package/docs/leader-service.md +98 -0
- package/docs/logging.md +150 -0
- package/docs/mail.md +161 -0
- package/docs/mesh-service.md +204 -0
- package/docs/srpc.md +261 -0
- package/docs/telemetry.md +166 -0
- package/docs/testing.md +222 -0
- package/docs/types.md +215 -0
- package/docs/worker.md +174 -0
- package/lefthook.yml +12 -0
- package/openapi.yaml +109 -0
- package/package.json +133 -0
- package/patches/@deepkit+type+1.0.19.patch +38 -0
- package/resources/proto/generated/test/test.ts +2721 -0
- package/resources/proto/sample.proto +85 -0
- package/resources/proto/test.proto +178 -0
- package/src/app/base.ts +257 -0
- package/src/app/config.loader.ts +66 -0
- package/src/app/config.ts +120 -0
- package/src/app/const.ts +4 -0
- package/src/app/dev.ts +70 -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 +363 -0
- package/src/cli/dksf-gen-proto.ts +176 -0
- package/src/cli/dksf-install.ts +11 -0
- package/src/cli/dksf-test.ts +95 -0
- package/src/cli/dksf-update.ts +101 -0
- package/src/database/CLAUDE.md +390 -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 +152 -0
- package/src/database/migration/MigrationRunCommand.ts +118 -0
- package/src/database/migration/characters.ts +53 -0
- package/src/database/migration/create/MigrationCreateCommand.ts +94 -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 +462 -0
- package/src/database/migration/create/file-generator.ts +52 -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 +3 -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/health/health.module.ts +30 -0
- package/src/health/healthcheck.controller.ts +17 -0
- package/src/health/healthcheck.service.ts +15 -0
- package/src/health/index.ts +2 -0
- package/src/helpers/CLAUDE.md +71 -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 +94 -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.ts +67 -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/CLAUDE.md +77 -0
- package/src/services/worker/bootstrap.ts +58 -0
- package/src/services/worker/cli.ts +63 -0
- package/src/services/worker/entity.ts +22 -0
- package/src/services/worker/index.ts +30 -0
- package/src/services/worker/observer.ts +180 -0
- package/src/services/worker/queue.ts +34 -0
- package/src/services/worker/runner.ts +146 -0
- package/src/services/worker/types.ts +32 -0
- package/src/srpc/CLAUDE.md +194 -0
- package/src/srpc/SRPC_MIGRATION_GUIDE.md +348 -0
- package/src/srpc/SrpcByteStream.ts +382 -0
- package/src/srpc/SrpcClient.ts +512 -0
- package/src/srpc/SrpcServer.ts +575 -0
- package/src/srpc/index.ts +15 -0
- package/src/srpc/types.ts +144 -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/testapp/bootstrap.ts +17 -0
- package/src/testapp/sample.ts +220 -0
- package/src/testapp/srpc-test.ts +684 -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/tests/app/app.spec.ts +53 -0
- package/tests/app/type.spec.ts +22 -0
- package/tests/auth/jwt.spec.ts +90 -0
- package/tests/database/entity.spec.ts +382 -0
- package/tests/database/locks.spec.ts +142 -0
- package/tests/database/migration-create-integration.spec.ts +234 -0
- package/tests/database/migration-create-unit.spec.ts +3896 -0
- package/tests/helpers/array.spec.ts +80 -0
- package/tests/helpers/cache.spec.ts +202 -0
- package/tests/helpers/crypto.spec.ts +236 -0
- package/tests/helpers/date.spec.ts +94 -0
- package/tests/helpers/error.spec.ts +233 -0
- package/tests/helpers/mutex.spec.ts +354 -0
- package/tests/helpers/objects.spec.ts +212 -0
- package/tests/helpers/package.spec.ts +90 -0
- package/tests/helpers/promise.spec.ts +119 -0
- package/tests/helpers/redis.spec.ts +50 -0
- package/tests/helpers/serialization.spec.ts +150 -0
- package/tests/helpers/stream.spec.ts +225 -0
- package/tests/helpers/validation.spec.ts +133 -0
- package/tests/services/leader.spec.ts +257 -0
- package/tests/services/logger.spec.ts +269 -0
- package/tests/services/mesh.spec.ts +814 -0
- package/tests/shared/db.ts +105 -0
- package/tests/shared/globalSetup.ts +48 -0
- package/tests/shared/helpers.ts +40 -0
- package/tests/srpc/SrpcByteStream.spec.ts +542 -0
- package/tests/tsconfig.json +4 -0
- package/tests/types/index.spec.ts +60 -0
- package/tests/types/phone.spec.ts +140 -0
- package/tsconfig.json +106 -0
- package/tsconfig.test.json +8 -0
- package/types.d.ts +6 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { cli, Flag } from '@deepkit/app';
|
|
2
|
+
import { SQLDatabaseAdapter } from '@deepkit/sql';
|
|
3
|
+
|
|
4
|
+
import { DBProvider } from '../../../app/state';
|
|
5
|
+
import { getAppConfig } from '../../../app/resolver';
|
|
6
|
+
import { createLogger } from '../../../services';
|
|
7
|
+
import { getDialect } from '../../dialect';
|
|
8
|
+
import { readEntitiesSchema } from './entity-reader';
|
|
9
|
+
import { readAllTableNames, readDatabaseSchema } from './db-reader';
|
|
10
|
+
import { compareSchemas } from './comparator';
|
|
11
|
+
import { generateDDL } from './ddl-generator';
|
|
12
|
+
import { generateMigrationFile } from './file-generator';
|
|
13
|
+
import { promptMigrationDescription, setNonInteractive } from './prompt';
|
|
14
|
+
import { INTERNAL_TABLES } from './schema-model';
|
|
15
|
+
|
|
16
|
+
@cli.controller('migration:create')
|
|
17
|
+
export class MigrationCreateCommand {
|
|
18
|
+
private logger = createLogger('MigrationCreate');
|
|
19
|
+
|
|
20
|
+
constructor(private dbProvider: DBProvider) {}
|
|
21
|
+
|
|
22
|
+
async execute(nonInteractive: boolean & Flag<{ description: 'Skip interactive prompts' }> = false) {
|
|
23
|
+
if (nonInteractive) {
|
|
24
|
+
setNonInteractive(true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const db = this.dbProvider.db;
|
|
29
|
+
const dialect = getDialect(db.adapter as SQLDatabaseAdapter);
|
|
30
|
+
const pgSchema = dialect === 'postgres' ? (getAppConfig().PG_SCHEMA ?? 'public') : 'public';
|
|
31
|
+
|
|
32
|
+
this.logger.info(`Dialect: ${dialect}`);
|
|
33
|
+
|
|
34
|
+
// Step 1: Read entity schema
|
|
35
|
+
this.logger.info('Reading entity definitions...');
|
|
36
|
+
const entitySchema = readEntitiesSchema(db, dialect);
|
|
37
|
+
const entityTableNames = Array.from(entitySchema.keys());
|
|
38
|
+
this.logger.info(`Found ${entityTableNames.length} entity table(s): ${entityTableNames.join(', ')}`);
|
|
39
|
+
|
|
40
|
+
// Step 2: Discover all DB tables and union with entity table names
|
|
41
|
+
const allDbTableNames = await readAllTableNames(db, dialect, pgSchema);
|
|
42
|
+
const dbOnlyTables = allDbTableNames.filter(n => !entitySchema.has(n) && !INTERNAL_TABLES.has(n));
|
|
43
|
+
const tableNames = [...entityTableNames, ...dbOnlyTables];
|
|
44
|
+
|
|
45
|
+
// Step 3: Read database schema
|
|
46
|
+
this.logger.info('Reading database schema...');
|
|
47
|
+
const dbSchema = await readDatabaseSchema(db, dialect, tableNames, pgSchema);
|
|
48
|
+
|
|
49
|
+
// Step 4: Compare schemas
|
|
50
|
+
this.logger.info('Comparing schemas...');
|
|
51
|
+
const diff = await compareSchemas(entitySchema, dbSchema, dialect, !nonInteractive, pgSchema);
|
|
52
|
+
|
|
53
|
+
// Step 5: Generate DDL
|
|
54
|
+
const statements = generateDDL(diff);
|
|
55
|
+
|
|
56
|
+
if (statements.length === 0) {
|
|
57
|
+
this.logger.info('No schema changes detected.');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Step 6: Show summary
|
|
62
|
+
this.logger.info(`\nChanges detected:`);
|
|
63
|
+
if (diff.addedTables.length > 0) {
|
|
64
|
+
this.logger.info(` Added tables: ${diff.addedTables.map(t => t.name).join(', ')}`);
|
|
65
|
+
}
|
|
66
|
+
if (diff.removedTables.length > 0) {
|
|
67
|
+
this.logger.info(` Removed tables: ${diff.removedTables.map(t => t.name).join(', ')}`);
|
|
68
|
+
}
|
|
69
|
+
for (const table of diff.modifiedTables) {
|
|
70
|
+
const changes: string[] = [];
|
|
71
|
+
if (table.addedColumns.length > 0) changes.push(`+${table.addedColumns.length} cols`);
|
|
72
|
+
if (table.removedColumns.length > 0) changes.push(`-${table.removedColumns.length} cols`);
|
|
73
|
+
if (table.modifiedColumns.length > 0) changes.push(`~${table.modifiedColumns.length} cols`);
|
|
74
|
+
if (table.renamedColumns.length > 0) changes.push(`${table.renamedColumns.length} renamed`);
|
|
75
|
+
if (table.addedIndexes.length > 0) changes.push(`+${table.addedIndexes.length} idx`);
|
|
76
|
+
if (table.removedIndexes.length > 0) changes.push(`-${table.removedIndexes.length} idx`);
|
|
77
|
+
if (table.primaryKeyChanged) changes.push('PK changed');
|
|
78
|
+
this.logger.info(` ${table.tableName}: ${changes.join(', ')}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.logger.info(`\nDDL statements (${statements.length}):`);
|
|
82
|
+
for (const stmt of statements) {
|
|
83
|
+
this.logger.info(` ${stmt}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Step 7: Prompt for description and generate file
|
|
87
|
+
const description = await promptMigrationDescription();
|
|
88
|
+
const filePath = generateMigrationFile(statements, description);
|
|
89
|
+
this.logger.info(`\nMigration file created: ${filePath}`);
|
|
90
|
+
} finally {
|
|
91
|
+
setNonInteractive(false);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColumnModification,
|
|
3
|
+
ColumnSchema,
|
|
4
|
+
DatabaseSchema,
|
|
5
|
+
Dialect,
|
|
6
|
+
ForeignKeySchema,
|
|
7
|
+
IndexSchema,
|
|
8
|
+
SchemaDiff,
|
|
9
|
+
TableDiff,
|
|
10
|
+
TableSchema
|
|
11
|
+
} from './schema-model';
|
|
12
|
+
import { promptRename } from './prompt';
|
|
13
|
+
|
|
14
|
+
export async function compareSchemas(
|
|
15
|
+
entitySchema: DatabaseSchema,
|
|
16
|
+
dbSchema: DatabaseSchema,
|
|
17
|
+
dialect: Dialect,
|
|
18
|
+
interactive: boolean,
|
|
19
|
+
pgSchema?: string
|
|
20
|
+
): Promise<SchemaDiff> {
|
|
21
|
+
const addedTables: TableSchema[] = [];
|
|
22
|
+
const removedTables: TableSchema[] = [];
|
|
23
|
+
const modifiedTables: TableDiff[] = [];
|
|
24
|
+
|
|
25
|
+
// Find added tables (in entities but not in DB)
|
|
26
|
+
for (const [name, table] of entitySchema) {
|
|
27
|
+
if (!dbSchema.has(name)) {
|
|
28
|
+
addedTables.push(table);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Find removed tables (in DB but not in entities)
|
|
33
|
+
for (const [name, table] of dbSchema) {
|
|
34
|
+
if (!entitySchema.has(name)) {
|
|
35
|
+
removedTables.push(table);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Compare matching tables
|
|
40
|
+
for (const [name, entityTable] of entitySchema) {
|
|
41
|
+
const dbTable = dbSchema.get(name);
|
|
42
|
+
if (!dbTable) continue;
|
|
43
|
+
|
|
44
|
+
const diff = await compareTable(entityTable, dbTable, dialect, interactive);
|
|
45
|
+
if (diff) {
|
|
46
|
+
modifiedTables.push(diff);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Collect all enum type names from entity tables (for safe PG DROP TYPE filtering)
|
|
51
|
+
let entityEnumTypes: Set<string> | undefined;
|
|
52
|
+
if (dialect === 'postgres') {
|
|
53
|
+
entityEnumTypes = new Set<string>();
|
|
54
|
+
for (const table of entitySchema.values()) {
|
|
55
|
+
for (const col of table.columns) {
|
|
56
|
+
if (col.type === 'enum' && col.enumTypeName) {
|
|
57
|
+
entityEnumTypes.add(col.enumTypeName);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { dialect, pgSchema, addedTables, removedTables, modifiedTables, entityEnumTypes };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function compareTable(entityTable: TableSchema, dbTable: TableSchema, dialect: Dialect, interactive: boolean): Promise<TableDiff | null> {
|
|
67
|
+
const diff: TableDiff = {
|
|
68
|
+
tableName: entityTable.name,
|
|
69
|
+
addedColumns: [],
|
|
70
|
+
removedColumns: [],
|
|
71
|
+
modifiedColumns: [],
|
|
72
|
+
renamedColumns: [],
|
|
73
|
+
reorderedColumns: [],
|
|
74
|
+
addedIndexes: [],
|
|
75
|
+
removedIndexes: [],
|
|
76
|
+
addedForeignKeys: [],
|
|
77
|
+
removedForeignKeys: [],
|
|
78
|
+
primaryKeyChanged: false,
|
|
79
|
+
addedEnumTypes: [],
|
|
80
|
+
removedEnumTypes: [],
|
|
81
|
+
modifiedEnumTypes: [],
|
|
82
|
+
entityColumns: entityTable.columns
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// --- Columns ---
|
|
86
|
+
const entityColMap = new Map(entityTable.columns.map(c => [c.name, c]));
|
|
87
|
+
const dbColMap = new Map(dbTable.columns.map(c => [c.name, c]));
|
|
88
|
+
|
|
89
|
+
let candidateAdds = entityTable.columns.filter(c => !dbColMap.has(c.name));
|
|
90
|
+
let candidateDrops = dbTable.columns.filter(c => !entityColMap.has(c.name) && !entityTable.skippedColumns?.has(c.name));
|
|
91
|
+
|
|
92
|
+
// Rename detection
|
|
93
|
+
if (candidateAdds.length > 0 && candidateDrops.length > 0) {
|
|
94
|
+
if (interactive) {
|
|
95
|
+
const renames = await detectRenames(entityTable.name, candidateAdds, candidateDrops);
|
|
96
|
+
for (const rename of renames) {
|
|
97
|
+
diff.renamedColumns.push(rename);
|
|
98
|
+
candidateAdds = candidateAdds.filter(c => c.name !== rename.to);
|
|
99
|
+
candidateDrops = candidateDrops.filter(c => c.name !== rename.from);
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
console.warn(
|
|
103
|
+
`Warning: Table \`${entityTable.name}\` has columns added (${candidateAdds.map(c => c.name).join(', ')}) ` +
|
|
104
|
+
`and removed (${candidateDrops.map(c => c.name).join(', ')}). ` +
|
|
105
|
+
`In non-interactive mode, these are treated as separate DROP/ADD operations (potential data loss). ` +
|
|
106
|
+
`Run without --non-interactive to detect renames.`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
diff.addedColumns = candidateAdds;
|
|
112
|
+
diff.removedColumns = candidateDrops;
|
|
113
|
+
|
|
114
|
+
// Modified columns (present in both by same name)
|
|
115
|
+
for (const [name, entityCol] of entityColMap) {
|
|
116
|
+
const dbCol = dbColMap.get(name);
|
|
117
|
+
if (!dbCol) continue;
|
|
118
|
+
|
|
119
|
+
const mod = compareColumn(entityCol, dbCol);
|
|
120
|
+
if (mod) diff.modifiedColumns.push(mod);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Renamed columns may also have property changes (type, nullable, default, etc.)
|
|
124
|
+
// For MySQL, CHANGE COLUMN already includes the full new definition so these are handled.
|
|
125
|
+
// For PG, RENAME COLUMN only renames — separate ALTER COLUMN statements are needed.
|
|
126
|
+
for (const rename of diff.renamedColumns) {
|
|
127
|
+
const dbCol = dbColMap.get(rename.from);
|
|
128
|
+
if (!dbCol) continue;
|
|
129
|
+
|
|
130
|
+
const mod = compareColumn(rename.column, dbCol);
|
|
131
|
+
if (mod) diff.modifiedColumns.push(mod);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Column reordering (MySQL only)
|
|
135
|
+
if (dialect === 'mysql') {
|
|
136
|
+
diff.reorderedColumns = detectReorderingMySQL(entityTable, dbTable, diff);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// --- Primary Key ---
|
|
140
|
+
const entityPK = entityTable.columns.filter(c => c.isPrimaryKey).map(c => c.name);
|
|
141
|
+
const rawDbPK = dbTable.columns.filter(c => c.isPrimaryKey).map(c => c.name);
|
|
142
|
+
// Apply rename mappings to DB PK names so that pure PK column renames
|
|
143
|
+
// are not falsely detected as PK changes
|
|
144
|
+
const renamedFromToMap = new Map(diff.renamedColumns.map(r => [r.from, r.to]));
|
|
145
|
+
const dbPK = rawDbPK.map(name => renamedFromToMap.get(name) ?? name);
|
|
146
|
+
if (!arraysEqual(entityPK, dbPK)) {
|
|
147
|
+
diff.primaryKeyChanged = true;
|
|
148
|
+
diff.newPrimaryKey = entityPK;
|
|
149
|
+
// Store the raw DB column names (before rename mapping) so that DDL generation
|
|
150
|
+
// can reference columns by their current DB names when stripping AUTO_INCREMENT
|
|
151
|
+
// before DROP PRIMARY KEY (which happens before CHANGE COLUMN renames).
|
|
152
|
+
diff.oldPrimaryKey = rawDbPK;
|
|
153
|
+
diff.oldPrimaryKeyConstraintName = dbTable.primaryKeyConstraintName;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// --- Indexes ---
|
|
157
|
+
const { added: addedIdx, removed: removedIdx } = compareIndexes(entityTable.indexes, dbTable.indexes);
|
|
158
|
+
diff.addedIndexes = addedIdx;
|
|
159
|
+
diff.removedIndexes = removedIdx;
|
|
160
|
+
|
|
161
|
+
// --- Foreign Keys ---
|
|
162
|
+
const { added: addedFK, removed: removedFK } = compareForeignKeys(entityTable.foreignKeys, dbTable.foreignKeys);
|
|
163
|
+
diff.addedForeignKeys = addedFK;
|
|
164
|
+
diff.removedForeignKeys = removedFK;
|
|
165
|
+
|
|
166
|
+
// --- Enum types (PG only) ---
|
|
167
|
+
if (dialect === 'postgres') {
|
|
168
|
+
detectEnumChanges(diff, entityTable, dbTable);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Check if there are any actual changes
|
|
172
|
+
if (
|
|
173
|
+
diff.addedColumns.length === 0 &&
|
|
174
|
+
diff.removedColumns.length === 0 &&
|
|
175
|
+
diff.modifiedColumns.length === 0 &&
|
|
176
|
+
diff.renamedColumns.length === 0 &&
|
|
177
|
+
diff.reorderedColumns.length === 0 &&
|
|
178
|
+
diff.addedIndexes.length === 0 &&
|
|
179
|
+
diff.removedIndexes.length === 0 &&
|
|
180
|
+
diff.addedForeignKeys.length === 0 &&
|
|
181
|
+
diff.removedForeignKeys.length === 0 &&
|
|
182
|
+
!diff.primaryKeyChanged &&
|
|
183
|
+
diff.addedEnumTypes.length === 0 &&
|
|
184
|
+
diff.removedEnumTypes.length === 0 &&
|
|
185
|
+
diff.modifiedEnumTypes.length === 0
|
|
186
|
+
) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return diff;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function compareColumn(entityCol: ColumnSchema, dbCol: ColumnSchema): ColumnModification | null {
|
|
194
|
+
const typeChanged = !typesMatch(entityCol, dbCol);
|
|
195
|
+
const nullableChanged = entityCol.nullable !== dbCol.nullable;
|
|
196
|
+
const defaultChanged = !defaultsMatch(entityCol, dbCol);
|
|
197
|
+
const autoIncrementChanged = entityCol.autoIncrement !== dbCol.autoIncrement;
|
|
198
|
+
// ON UPDATE expression (MySQL only). If entity side has no onUpdateExpression, treat as "remove it".
|
|
199
|
+
const onUpdateChanged = (entityCol.onUpdateExpression || '') !== (dbCol.onUpdateExpression || '');
|
|
200
|
+
|
|
201
|
+
if (!typeChanged && !nullableChanged && !defaultChanged && !autoIncrementChanged && !onUpdateChanged) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
name: entityCol.name,
|
|
207
|
+
oldColumn: dbCol,
|
|
208
|
+
newColumn: entityCol,
|
|
209
|
+
typeChanged,
|
|
210
|
+
nullableChanged,
|
|
211
|
+
defaultChanged,
|
|
212
|
+
autoIncrementChanged,
|
|
213
|
+
onUpdateChanged
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function normalizeTypeAlias(type: string): string {
|
|
218
|
+
switch (type) {
|
|
219
|
+
case 'integer':
|
|
220
|
+
return 'int';
|
|
221
|
+
case 'numeric':
|
|
222
|
+
return 'decimal';
|
|
223
|
+
default:
|
|
224
|
+
return type;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function typesMatch(a: ColumnSchema, b: ColumnSchema): boolean {
|
|
229
|
+
if (normalizeTypeAlias(a.type) !== normalizeTypeAlias(b.type)) return false;
|
|
230
|
+
|
|
231
|
+
// Compare size when relevant
|
|
232
|
+
if (a.size !== undefined || b.size !== undefined) {
|
|
233
|
+
if (a.size !== b.size) return false;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Compare scale
|
|
237
|
+
if (a.scale !== undefined || b.scale !== undefined) {
|
|
238
|
+
if (a.scale !== b.scale) return false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Compare unsigned
|
|
242
|
+
if (a.unsigned !== b.unsigned) return false;
|
|
243
|
+
|
|
244
|
+
// Compare enum type name (PG)
|
|
245
|
+
if (a.enumTypeName || b.enumTypeName) {
|
|
246
|
+
if (a.enumTypeName !== b.enumTypeName) return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Compare enum values (sorted to ignore order-only differences)
|
|
250
|
+
if (a.enumValues || b.enumValues) {
|
|
251
|
+
const aVals = [...(a.enumValues || [])].sort();
|
|
252
|
+
const bVals = [...(b.enumValues || [])].sort();
|
|
253
|
+
if (!arraysEqual(aVals, bVals)) return false;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function normalizeDefaultExpression(expr: string): string {
|
|
260
|
+
let s = expr.toUpperCase().trim();
|
|
261
|
+
// Normalize now() and CURRENT_TIMESTAMP() variants to CURRENT_TIMESTAMP (no parens)
|
|
262
|
+
s = s.replace(/\bNOW\s*\(\)/g, 'CURRENT_TIMESTAMP');
|
|
263
|
+
s = s.replace(/\bCURRENT_TIMESTAMP\s*\(\)/g, 'CURRENT_TIMESTAMP');
|
|
264
|
+
return s;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function defaultsMatch(a: ColumnSchema, b: ColumnSchema): boolean {
|
|
268
|
+
// Skip default comparison for auto-increment columns
|
|
269
|
+
if (a.autoIncrement || b.autoIncrement) return true;
|
|
270
|
+
|
|
271
|
+
// If entity side has no default info at all, treat as "unspecified" and skip comparison.
|
|
272
|
+
// The entity reader does not populate default values from Deepkit metadata.
|
|
273
|
+
if (a.defaultValue === undefined && a.defaultExpression === undefined) return true;
|
|
274
|
+
|
|
275
|
+
// Both have expression defaults
|
|
276
|
+
if (a.defaultExpression && b.defaultExpression) {
|
|
277
|
+
return normalizeDefaultExpression(a.defaultExpression) === normalizeDefaultExpression(b.defaultExpression);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// One has expression, other doesn't
|
|
281
|
+
if (a.defaultExpression !== b.defaultExpression) {
|
|
282
|
+
if ((a.defaultExpression && !b.defaultExpression) || (!a.defaultExpression && b.defaultExpression)) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Compare values
|
|
288
|
+
if (a.defaultValue === undefined && b.defaultValue === undefined) return true;
|
|
289
|
+
if (a.defaultValue === undefined || b.defaultValue === undefined) return false;
|
|
290
|
+
|
|
291
|
+
return String(a.defaultValue) === String(b.defaultValue);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
async function detectRenames(
|
|
295
|
+
tableName: string,
|
|
296
|
+
candidateAdds: ColumnSchema[],
|
|
297
|
+
candidateDrops: ColumnSchema[]
|
|
298
|
+
): Promise<{ from: string; to: string; column: ColumnSchema }[]> {
|
|
299
|
+
const renames: { from: string; to: string; column: ColumnSchema }[] = [];
|
|
300
|
+
let remainingDrops = [...candidateDrops];
|
|
301
|
+
|
|
302
|
+
for (const added of candidateAdds) {
|
|
303
|
+
// Prefer exact type matches
|
|
304
|
+
let compatibleDrops = remainingDrops.filter(d => typesMatch(added, d));
|
|
305
|
+
|
|
306
|
+
// Fall back to all remaining drops (type differs — prompt will warn)
|
|
307
|
+
if (compatibleDrops.length === 0 && remainingDrops.length > 0) {
|
|
308
|
+
compatibleDrops = remainingDrops;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (compatibleDrops.length === 0) continue;
|
|
312
|
+
|
|
313
|
+
const result = await promptRename(
|
|
314
|
+
tableName,
|
|
315
|
+
added.name,
|
|
316
|
+
compatibleDrops.map(d => d.name)
|
|
317
|
+
);
|
|
318
|
+
if (result) {
|
|
319
|
+
renames.push({ from: result, to: added.name, column: added });
|
|
320
|
+
remainingDrops = remainingDrops.filter(d => d.name !== result);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return renames;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function detectReorderingMySQL(entityTable: TableSchema, dbTable: TableSchema, diff: TableDiff): { name: string; after: string | null }[] {
|
|
328
|
+
// Build the expected column order from the entity
|
|
329
|
+
const entityOrder = entityTable.columns.map(c => c.name);
|
|
330
|
+
|
|
331
|
+
// Build the current DB order, accounting for adds/drops/renames
|
|
332
|
+
const renamedFrom = new Map(diff.renamedColumns.map(r => [r.from, r.to]));
|
|
333
|
+
const removedNames = new Set(diff.removedColumns.map(c => c.name));
|
|
334
|
+
const addedNames = new Set(diff.addedColumns.map(c => c.name));
|
|
335
|
+
|
|
336
|
+
// Current DB order with renames applied and removals excluded
|
|
337
|
+
const dbOrder = dbTable.columns.map(c => renamedFrom.get(c.name) || c.name).filter(name => !removedNames.has(name));
|
|
338
|
+
|
|
339
|
+
// Entity order without new additions (the columns that should be in DB order)
|
|
340
|
+
const existingEntityOrder = entityOrder.filter(name => !addedNames.has(name));
|
|
341
|
+
|
|
342
|
+
// Check if the existing columns are in the same relative order
|
|
343
|
+
if (arraysEqual(existingEntityOrder, dbOrder)) {
|
|
344
|
+
return [];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Compute which columns need MODIFY with AFTER
|
|
348
|
+
const reorders: { name: string; after: string | null }[] = [];
|
|
349
|
+
for (let i = 0; i < existingEntityOrder.length; i++) {
|
|
350
|
+
if (existingEntityOrder[i] !== dbOrder[i]) {
|
|
351
|
+
const after = i === 0 ? null : existingEntityOrder[i - 1];
|
|
352
|
+
reorders.push({ name: existingEntityOrder[i], after });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return reorders;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function compareIndexes(entityIndexes: IndexSchema[], dbIndexes: IndexSchema[]): { added: IndexSchema[]; removed: IndexSchema[] } {
|
|
360
|
+
// Match by column set + uniqueness + spatial, not by name
|
|
361
|
+
const indexKey = (idx: IndexSchema) => `${idx.columns.join(',')}:${idx.unique}:${idx.spatial}`;
|
|
362
|
+
|
|
363
|
+
const entityKeys = new Map(entityIndexes.map(i => [indexKey(i), i]));
|
|
364
|
+
const dbKeys = new Map(dbIndexes.map(i => [indexKey(i), i]));
|
|
365
|
+
|
|
366
|
+
const added = entityIndexes.filter(i => !dbKeys.has(indexKey(i)));
|
|
367
|
+
const removed = dbIndexes.filter(i => !entityKeys.has(indexKey(i)));
|
|
368
|
+
|
|
369
|
+
return { added, removed };
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function normalizeFkAction(action: string): string {
|
|
373
|
+
const upper = action.toUpperCase();
|
|
374
|
+
// NO ACTION and RESTRICT are semantically equivalent for comparison
|
|
375
|
+
return upper === 'NO ACTION' ? 'RESTRICT' : upper;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function compareForeignKeys(entityFKs: ForeignKeySchema[], dbFKs: ForeignKeySchema[]): { added: ForeignKeySchema[]; removed: ForeignKeySchema[] } {
|
|
379
|
+
// Match by structure including actions, not by name
|
|
380
|
+
// NO ACTION and RESTRICT are treated as equivalent to avoid diff churn
|
|
381
|
+
const fkKey = (fk: ForeignKeySchema) =>
|
|
382
|
+
`${fk.columns.join(',')}→${fk.referencedTable}(${fk.referencedColumns.join(',')})/${normalizeFkAction(fk.onDelete)}/${normalizeFkAction(fk.onUpdate)}`;
|
|
383
|
+
|
|
384
|
+
const entityKeys = new Map(entityFKs.map(fk => [fkKey(fk), fk]));
|
|
385
|
+
const dbKeys = new Map(dbFKs.map(fk => [fkKey(fk), fk]));
|
|
386
|
+
|
|
387
|
+
const added = entityFKs.filter(fk => !dbKeys.has(fkKey(fk)));
|
|
388
|
+
const removed = dbFKs.filter(fk => !entityKeys.has(fkKey(fk)));
|
|
389
|
+
|
|
390
|
+
return { added, removed };
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function detectEnumChanges(diff: TableDiff, entityTable: TableSchema, dbTable: TableSchema): void {
|
|
394
|
+
const dbColMap = new Map(dbTable.columns.map(c => [c.name, c]));
|
|
395
|
+
|
|
396
|
+
for (const col of entityTable.columns) {
|
|
397
|
+
if (col.type !== 'enum' || !col.enumValues || !col.enumTypeName) continue;
|
|
398
|
+
|
|
399
|
+
const dbCol = dbColMap.get(col.name);
|
|
400
|
+
|
|
401
|
+
// New enum type for new columns
|
|
402
|
+
if (!dbCol) {
|
|
403
|
+
diff.addedEnumTypes.push({
|
|
404
|
+
typeName: col.enumTypeName,
|
|
405
|
+
values: col.enumValues
|
|
406
|
+
});
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Existing column: non-enum → enum requires CREATE TYPE
|
|
411
|
+
if (dbCol.type !== 'enum') {
|
|
412
|
+
diff.addedEnumTypes.push({
|
|
413
|
+
typeName: col.enumTypeName,
|
|
414
|
+
values: col.enumValues
|
|
415
|
+
});
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Enum type name changed — need to create the new type and drop the old one
|
|
420
|
+
if (dbCol.enumTypeName && dbCol.enumTypeName !== col.enumTypeName) {
|
|
421
|
+
diff.addedEnumTypes.push({
|
|
422
|
+
typeName: col.enumTypeName,
|
|
423
|
+
values: col.enumValues
|
|
424
|
+
});
|
|
425
|
+
diff.removedEnumTypes.push(dbCol.enumTypeName);
|
|
426
|
+
// The type change will be picked up by compareColumn() → typesMatch() → enumTypeName comparison
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Existing column with enum value changes (same type name)
|
|
431
|
+
if (dbCol.enumValues) {
|
|
432
|
+
const added = col.enumValues.filter(v => !dbCol.enumValues!.includes(v));
|
|
433
|
+
const removed = dbCol.enumValues.filter(v => !col.enumValues!.includes(v));
|
|
434
|
+
if (added.length > 0 || removed.length > 0) {
|
|
435
|
+
diff.modifiedEnumTypes.push({
|
|
436
|
+
typeName: col.enumTypeName,
|
|
437
|
+
added,
|
|
438
|
+
removed,
|
|
439
|
+
newValues: col.enumValues,
|
|
440
|
+
tableName: diff.tableName,
|
|
441
|
+
columnName: col.name
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Detect orphaned enum types from removed columns or enum→non-enum changes
|
|
448
|
+
const entityColMap = new Map(entityTable.columns.map(c => [c.name, c]));
|
|
449
|
+
for (const dbCol of dbTable.columns) {
|
|
450
|
+
if (dbCol.type !== 'enum' || !dbCol.enumTypeName) continue;
|
|
451
|
+
|
|
452
|
+
const entityCol = entityColMap.get(dbCol.name);
|
|
453
|
+
// Column removed entirely — its enum type may be orphaned
|
|
454
|
+
// Column changed from enum to non-enum — old type may be orphaned
|
|
455
|
+
if (!entityCol || entityCol.type !== 'enum' || entityCol.enumTypeName !== dbCol.enumTypeName) {
|
|
456
|
+
// Only schedule drop if not already handled above (type-name change already pushes to removedEnumTypes)
|
|
457
|
+
if (!diff.removedEnumTypes.includes(dbCol.enumTypeName)) {
|
|
458
|
+
diff.removedEnumTypes.push(dbCol.enumTypeName);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function arraysEqual<T>(a: T[], b: T[]): boolean {
|
|
465
|
+
if (a.length !== b.length) return false;
|
|
466
|
+
return a.every((v, i) => v === b[i]);
|
|
467
|
+
}
|