@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,471 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReflectionClass,
|
|
3
|
+
ReflectionKind,
|
|
4
|
+
ReflectionProperty,
|
|
5
|
+
Type,
|
|
6
|
+
TypeClass,
|
|
7
|
+
TypeEnum,
|
|
8
|
+
TypeIntersection,
|
|
9
|
+
TypeLiteral,
|
|
10
|
+
typeAnnotation,
|
|
11
|
+
databaseAnnotation,
|
|
12
|
+
validationAnnotation
|
|
13
|
+
} from '@deepkit/type';
|
|
14
|
+
|
|
15
|
+
import { BaseDatabase } from '../../common';
|
|
16
|
+
import { ColumnSchema, DatabaseSchema, Dialect, IndexSchema, ForeignKeySchema, INTERNAL_TABLES, TableSchema } from './schema-model';
|
|
17
|
+
|
|
18
|
+
export function readEntitiesSchema(db: BaseDatabase, dialect: Dialect): DatabaseSchema {
|
|
19
|
+
const schema: DatabaseSchema = new Map();
|
|
20
|
+
const entities = db.entityRegistry.all();
|
|
21
|
+
|
|
22
|
+
for (const entity of entities) {
|
|
23
|
+
const reflection = ReflectionClass.from(entity);
|
|
24
|
+
const tableName = reflection.getCollectionName() || reflection.name || '';
|
|
25
|
+
if (!tableName) continue;
|
|
26
|
+
|
|
27
|
+
if (INTERNAL_TABLES.has(tableName)) continue;
|
|
28
|
+
|
|
29
|
+
const table = readTableSchema(reflection, tableName, dialect, db);
|
|
30
|
+
schema.set(tableName, table);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return schema;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function readTableSchema(reflection: ReflectionClass<unknown>, tableName: string, dialect: Dialect, db: BaseDatabase): TableSchema {
|
|
37
|
+
const columns: ColumnSchema[] = [];
|
|
38
|
+
const indexes: IndexSchema[] = [];
|
|
39
|
+
const foreignKeys: ForeignKeySchema[] = [];
|
|
40
|
+
const pkColumns: string[] = [];
|
|
41
|
+
const skippedColumns = new Set<string>();
|
|
42
|
+
|
|
43
|
+
const properties = reflection.getProperties();
|
|
44
|
+
let ordinal = 0;
|
|
45
|
+
|
|
46
|
+
for (const prop of properties) {
|
|
47
|
+
if (prop.isBackReference()) continue;
|
|
48
|
+
|
|
49
|
+
// For references, we handle the FK column, not the object
|
|
50
|
+
if (prop.isReference()) {
|
|
51
|
+
const col = readReferenceColumn(prop, ++ordinal, dialect, db, tableName);
|
|
52
|
+
if (col) {
|
|
53
|
+
columns.push(col);
|
|
54
|
+
if (col.isPrimaryKey) pkColumns.push(col.name);
|
|
55
|
+
|
|
56
|
+
// Create FK
|
|
57
|
+
const fk = readForeignKey(prop, tableName, dialect, db);
|
|
58
|
+
if (fk) foreignKeys.push(fk);
|
|
59
|
+
} else {
|
|
60
|
+
skippedColumns.add(prop.name);
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const col = readColumn(prop, ++ordinal, dialect, tableName);
|
|
66
|
+
if (col) {
|
|
67
|
+
columns.push(col);
|
|
68
|
+
if (col.isPrimaryKey) pkColumns.push(col.name);
|
|
69
|
+
|
|
70
|
+
// Single-column index from property
|
|
71
|
+
const indexInfo = prop.getIndex();
|
|
72
|
+
if (indexInfo) {
|
|
73
|
+
indexes.push({
|
|
74
|
+
name: indexInfo.name || `idx_${tableName}_${col.name}`,
|
|
75
|
+
columns: [col.name],
|
|
76
|
+
unique: indexInfo.unique || false,
|
|
77
|
+
spatial: false
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
skippedColumns.add(prop.name);
|
|
82
|
+
console.warn(`migration:create: Skipping column '${prop.name}' in '${tableName}' — unsupported type`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Multi-column indexes from entity-level indexes
|
|
87
|
+
if (reflection.indexes) {
|
|
88
|
+
for (const idx of reflection.indexes) {
|
|
89
|
+
indexes.push({
|
|
90
|
+
name: idx.options.name || `idx_${tableName}_${idx.names.join('_')}`,
|
|
91
|
+
columns: idx.names,
|
|
92
|
+
unique: idx.options.unique || false,
|
|
93
|
+
spatial: dialect === 'mysql' ? idx.options.spatial || false : false
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Deduplicate indexes by name (Deepkit stores property-level indexes
|
|
99
|
+
// both on the property and in reflection.indexes)
|
|
100
|
+
const seen = new Set<string>();
|
|
101
|
+
const dedupedIndexes = indexes.filter(idx => {
|
|
102
|
+
if (seen.has(idx.name)) return false;
|
|
103
|
+
seen.add(idx.name);
|
|
104
|
+
return true;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return { name: tableName, columns, indexes: dedupedIndexes, foreignKeys, skippedColumns };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function readColumn(prop: ReflectionProperty, ordinal: number, dialect: Dialect, tableName?: string): ColumnSchema | null {
|
|
111
|
+
const type = prop.type;
|
|
112
|
+
const resolved = resolveColumnType(type, prop.name, dialect, tableName);
|
|
113
|
+
if (!resolved) return null;
|
|
114
|
+
|
|
115
|
+
const col: ColumnSchema = {
|
|
116
|
+
name: prop.name,
|
|
117
|
+
type: resolved.type,
|
|
118
|
+
size: resolved.size,
|
|
119
|
+
scale: resolved.scale,
|
|
120
|
+
unsigned: resolved.unsigned || false,
|
|
121
|
+
nullable: prop.isOptional() || prop.isNullable(),
|
|
122
|
+
autoIncrement: prop.isAutoIncrement(),
|
|
123
|
+
isPrimaryKey: prop.isPrimaryKey(),
|
|
124
|
+
defaultValue: resolved.defaultValue,
|
|
125
|
+
defaultExpression: resolved.defaultExpression,
|
|
126
|
+
enumValues: resolved.enumValues,
|
|
127
|
+
enumTypeName: resolved.enumTypeName,
|
|
128
|
+
ordinalPosition: ordinal
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// ON UPDATE expression (MySQL only)
|
|
132
|
+
if (dialect === 'mysql') {
|
|
133
|
+
const onUpdateAnnotation = typeAnnotation.getType(type, 'dksf:onUpdate');
|
|
134
|
+
if (onUpdateAnnotation?.kind === ReflectionKind.literal && typeof onUpdateAnnotation.literal === 'string') {
|
|
135
|
+
col.onUpdateExpression = (onUpdateAnnotation.literal as string).toUpperCase();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return col;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function readReferenceColumn(
|
|
143
|
+
prop: ReflectionProperty,
|
|
144
|
+
ordinal: number,
|
|
145
|
+
dialect: Dialect,
|
|
146
|
+
_db: BaseDatabase,
|
|
147
|
+
tableName?: string
|
|
148
|
+
): ColumnSchema | null {
|
|
149
|
+
// A reference property stores the PK of the referenced entity
|
|
150
|
+
const refClass = prop.getResolvedReflectionClass();
|
|
151
|
+
|
|
152
|
+
// Guard: only single-column PKs are supported for references
|
|
153
|
+
const refPkProps = refClass.getProperties().filter(p => p.isPrimaryKey());
|
|
154
|
+
if (refPkProps.length !== 1) {
|
|
155
|
+
console.warn(
|
|
156
|
+
`migration:create: Skipping reference '${prop.name}' in '${tableName ?? '?'}' — ` +
|
|
157
|
+
`referenced entity '${refClass.name}' has ${refPkProps.length === 0 ? 'no' : 'composite'} primary key (unsupported)`
|
|
158
|
+
);
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const refPk = refClass.getPrimary();
|
|
163
|
+
if (!refPk) return null;
|
|
164
|
+
|
|
165
|
+
// Resolve the PK column type of the referenced entity
|
|
166
|
+
const resolved = resolveColumnType(refPk.type, prop.name, dialect, tableName);
|
|
167
|
+
if (!resolved) return null;
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
name: prop.name,
|
|
171
|
+
type: resolved.type,
|
|
172
|
+
size: resolved.size,
|
|
173
|
+
scale: resolved.scale,
|
|
174
|
+
unsigned: resolved.unsigned || false,
|
|
175
|
+
nullable: prop.isOptional() || prop.isNullable(),
|
|
176
|
+
autoIncrement: false,
|
|
177
|
+
isPrimaryKey: prop.isPrimaryKey(),
|
|
178
|
+
ordinalPosition: ordinal
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function readForeignKey(prop: ReflectionProperty, tableName: string, _dialect: Dialect, _db: BaseDatabase): ForeignKeySchema | null {
|
|
183
|
+
const refClass = prop.getResolvedReflectionClass();
|
|
184
|
+
const refTableName = refClass.getCollectionName() || refClass.name || '';
|
|
185
|
+
|
|
186
|
+
// Guard: only single-column PKs are supported for FK generation
|
|
187
|
+
const refPkProps = refClass.getProperties().filter(p => p.isPrimaryKey());
|
|
188
|
+
if (refPkProps.length !== 1) {
|
|
189
|
+
// Warning already emitted by readReferenceColumn
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const refPk = refClass.getPrimary();
|
|
194
|
+
if (!refPk || !refTableName) return null;
|
|
195
|
+
|
|
196
|
+
const ref = prop.getReference();
|
|
197
|
+
const onDelete: string = ref?.onDelete ?? 'CASCADE';
|
|
198
|
+
// Deepkit's ReferenceOptions does not expose onUpdate; future-proof with dynamic check.
|
|
199
|
+
// Default is CASCADE to match Deepkit's internal FK default (see @deepkit/sql ForeignKey class).
|
|
200
|
+
const onUpdate: string = (ref as Record<string, unknown>)?.onUpdate ? String((ref as Record<string, unknown>).onUpdate) : 'CASCADE';
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
name: `fk_${tableName}_${prop.name}`,
|
|
204
|
+
columns: [prop.name],
|
|
205
|
+
referencedTable: refTableName,
|
|
206
|
+
referencedColumns: [refPk.name],
|
|
207
|
+
onDelete: onDelete.toUpperCase(),
|
|
208
|
+
onUpdate: onUpdate.toUpperCase()
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface ResolvedType {
|
|
213
|
+
type: string;
|
|
214
|
+
size?: number;
|
|
215
|
+
scale?: number;
|
|
216
|
+
unsigned?: boolean;
|
|
217
|
+
defaultValue?: unknown;
|
|
218
|
+
defaultExpression?: string;
|
|
219
|
+
enumValues?: string[];
|
|
220
|
+
enumTypeName?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function resolveColumnType(type: Type, columnName: string, dialect: Dialect, parentTableName?: string): ResolvedType | null {
|
|
224
|
+
// Unwrap unions: filter out undefined/null (they only affect nullable)
|
|
225
|
+
if (type.kind === ReflectionKind.union) {
|
|
226
|
+
const nonNull = type.types.filter(
|
|
227
|
+
t => t.kind !== ReflectionKind.undefined && t.kind !== ReflectionKind.null && !(t.kind === ReflectionKind.literal && t.literal === null)
|
|
228
|
+
);
|
|
229
|
+
if (nonNull.length === 1) {
|
|
230
|
+
return resolveColumnType(nonNull[0], columnName, dialect, parentTableName);
|
|
231
|
+
}
|
|
232
|
+
// Multiple non-null union members -- treat as the first (lossy; warn)
|
|
233
|
+
if (nonNull.length > 0) {
|
|
234
|
+
console.warn(
|
|
235
|
+
`migration:create: Column '${columnName}'${parentTableName ? ` in '${parentTableName}'` : ''} ` +
|
|
236
|
+
`has a union type with ${nonNull.length} non-null members — using the first member only`
|
|
237
|
+
);
|
|
238
|
+
return resolveColumnType(nonNull[0], columnName, dialect, parentTableName);
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Unwrap intersections: look for base type + annotations
|
|
244
|
+
if (type.kind === ReflectionKind.intersection) {
|
|
245
|
+
return resolveIntersectionType(type, columnName, dialect, parentTableName);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Check dksf:type annotation
|
|
249
|
+
const dksfType = typeAnnotation.getType(type, 'dksf:type');
|
|
250
|
+
if (dksfType?.kind === ReflectionKind.literal) {
|
|
251
|
+
const result = resolveDksfType(dksfType.literal as string, type, dialect);
|
|
252
|
+
if (result) return result;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Check dialect-specific database annotation
|
|
256
|
+
const dbAnnotation = databaseAnnotation.getDatabase<{ type?: string }>(type, dialect);
|
|
257
|
+
if (dbAnnotation?.type) {
|
|
258
|
+
return { type: dbAnnotation.type.toLowerCase() };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Check generic database annotation
|
|
262
|
+
const genericDbAnnotation = databaseAnnotation.getDatabase<{ type?: string }>(type, '*');
|
|
263
|
+
if (genericDbAnnotation?.type) {
|
|
264
|
+
return { type: genericDbAnnotation.type.toLowerCase() };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Check dksf:length annotation
|
|
268
|
+
const lengthAnnotation = typeAnnotation.getType(type, 'dksf:length');
|
|
269
|
+
if (lengthAnnotation?.kind === ReflectionKind.literal && typeof lengthAnnotation.literal === 'number') {
|
|
270
|
+
return { type: 'char', size: lengthAnnotation.literal };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Check validation annotations for MaxLength
|
|
274
|
+
const maxLength = getMaxLength(type);
|
|
275
|
+
if (maxLength !== undefined) {
|
|
276
|
+
return { type: 'varchar', size: maxLength };
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Enum types
|
|
280
|
+
if (type.kind === ReflectionKind.enum) {
|
|
281
|
+
return resolveEnumType(type, columnName, dialect, parentTableName);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Primitive type map
|
|
285
|
+
return resolvePrimitiveType(type, dialect);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function resolveIntersectionType(type: TypeIntersection, columnName: string, dialect: Dialect, parentTableName?: string): ResolvedType | null {
|
|
289
|
+
// Priority 1: Check for dialect-specific database annotation on the intersection
|
|
290
|
+
const dbAnnotation = databaseAnnotation.getDatabase<{ type?: string }>(type, dialect);
|
|
291
|
+
if (dbAnnotation?.type) {
|
|
292
|
+
return { type: dbAnnotation.type.toLowerCase() };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Priority 2: Check for generic database annotation
|
|
296
|
+
const genericDbAnnotation = databaseAnnotation.getDatabase<{ type?: string }>(type, '*');
|
|
297
|
+
if (genericDbAnnotation?.type) {
|
|
298
|
+
return { type: genericDbAnnotation.type.toLowerCase() };
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Priority 3: dksf:type annotation
|
|
302
|
+
const dksfType = typeAnnotation.getType(type, 'dksf:type');
|
|
303
|
+
if (dksfType?.kind === ReflectionKind.literal) {
|
|
304
|
+
const result = resolveDksfType(dksfType.literal as string, type, dialect);
|
|
305
|
+
if (result) return result;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Priority 4: dksf:length annotation
|
|
309
|
+
const lengthAnnotation = typeAnnotation.getType(type, 'dksf:length');
|
|
310
|
+
if (lengthAnnotation?.kind === ReflectionKind.literal && typeof lengthAnnotation.literal === 'number') {
|
|
311
|
+
return { type: 'char', size: lengthAnnotation.literal };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Priority 5: MaxLength validation
|
|
315
|
+
const maxLength = getMaxLength(type);
|
|
316
|
+
if (maxLength !== undefined) {
|
|
317
|
+
return { type: 'varchar', size: maxLength };
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Priority 6: Find the base type in the intersection members
|
|
321
|
+
for (const member of type.types) {
|
|
322
|
+
// Skip annotation-only types (PrimaryKey, AutoIncrement, Index, etc.)
|
|
323
|
+
if (
|
|
324
|
+
member.kind === ReflectionKind.class ||
|
|
325
|
+
member.kind === ReflectionKind.string ||
|
|
326
|
+
member.kind === ReflectionKind.number ||
|
|
327
|
+
member.kind === ReflectionKind.boolean ||
|
|
328
|
+
member.kind === ReflectionKind.bigint ||
|
|
329
|
+
member.kind === ReflectionKind.enum
|
|
330
|
+
) {
|
|
331
|
+
const result = resolveColumnType(member, columnName, dialect, parentTableName);
|
|
332
|
+
if (result) return result;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function resolveDksfType(dksfType: string, _type: Type, _dialect: Dialect): ResolvedType | null {
|
|
340
|
+
switch (dksfType) {
|
|
341
|
+
case 'uuid':
|
|
342
|
+
return { type: 'char', size: 36 };
|
|
343
|
+
case 'date':
|
|
344
|
+
return { type: 'date' };
|
|
345
|
+
case 'phone':
|
|
346
|
+
case 'phoneNanp':
|
|
347
|
+
return { type: 'varchar', size: 20 };
|
|
348
|
+
default:
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function resolveEnumType(type: TypeEnum, columnName: string, dialect: Dialect, parentTableName?: string): ResolvedType | null {
|
|
354
|
+
const values = type.values.filter(v => v != null);
|
|
355
|
+
|
|
356
|
+
if (values.length === 0) return null;
|
|
357
|
+
|
|
358
|
+
// String enum
|
|
359
|
+
if (typeof values[0] === 'string') {
|
|
360
|
+
const stringValues = values.filter((v): v is string => typeof v === 'string');
|
|
361
|
+
if (dialect === 'postgres') {
|
|
362
|
+
const typeName = parentTableName ? `${parentTableName}_${columnName}` : columnName;
|
|
363
|
+
return {
|
|
364
|
+
type: 'enum',
|
|
365
|
+
enumValues: stringValues,
|
|
366
|
+
enumTypeName: typeName
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
type: 'enum',
|
|
371
|
+
enumValues: stringValues
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Numeric enum
|
|
376
|
+
const numValues = values.filter((v): v is number => typeof v === 'number');
|
|
377
|
+
const minVal = Math.min(...numValues);
|
|
378
|
+
const maxVal = Math.max(...numValues);
|
|
379
|
+
if (dialect === 'mysql') {
|
|
380
|
+
if (minVal >= 0 && maxVal <= 255) return { type: 'tinyint', unsigned: true };
|
|
381
|
+
if (minVal >= -128 && maxVal <= 127) return { type: 'tinyint' };
|
|
382
|
+
if (minVal >= 0 && maxVal <= 65535) return { type: 'smallint', unsigned: true };
|
|
383
|
+
return { type: 'int' };
|
|
384
|
+
}
|
|
385
|
+
if (minVal >= -32768 && maxVal <= 32767) return { type: 'smallint' };
|
|
386
|
+
return { type: 'int' };
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function getMaxLength(type: Type): number | undefined {
|
|
390
|
+
// Check for Deepkit's MaxLength validation annotation
|
|
391
|
+
try {
|
|
392
|
+
const annotations = validationAnnotation.getAnnotations(type);
|
|
393
|
+
if (annotations) {
|
|
394
|
+
for (const annotation of annotations) {
|
|
395
|
+
if (annotation.name === 'maxLength') {
|
|
396
|
+
const arg = annotation.args?.[0];
|
|
397
|
+
if (arg && arg.kind === ReflectionKind.literal && typeof arg.literal === 'number') {
|
|
398
|
+
return arg.literal;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
} catch {
|
|
404
|
+
// validationAnnotation might not be available
|
|
405
|
+
}
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function resolvePrimitiveType(type: Type, dialect: Dialect): ResolvedType | null {
|
|
410
|
+
switch (type.kind) {
|
|
411
|
+
case ReflectionKind.string:
|
|
412
|
+
return { type: 'varchar', size: 255 };
|
|
413
|
+
|
|
414
|
+
case ReflectionKind.number:
|
|
415
|
+
return dialect === 'mysql' ? { type: 'double' } : { type: 'double precision' };
|
|
416
|
+
|
|
417
|
+
case ReflectionKind.boolean:
|
|
418
|
+
return dialect === 'mysql' ? { type: 'tinyint', size: 1 } : { type: 'boolean' };
|
|
419
|
+
|
|
420
|
+
case ReflectionKind.bigint:
|
|
421
|
+
return { type: 'bigint' };
|
|
422
|
+
|
|
423
|
+
case ReflectionKind.class:
|
|
424
|
+
return resolveClassType(type, dialect);
|
|
425
|
+
|
|
426
|
+
case ReflectionKind.objectLiteral:
|
|
427
|
+
case ReflectionKind.array:
|
|
428
|
+
return dialect === 'mysql' ? { type: 'json' } : { type: 'jsonb' };
|
|
429
|
+
|
|
430
|
+
case ReflectionKind.any:
|
|
431
|
+
return dialect === 'mysql' ? { type: 'json' } : { type: 'jsonb' };
|
|
432
|
+
|
|
433
|
+
case ReflectionKind.literal: {
|
|
434
|
+
// literal string → varchar, literal number → int, etc.
|
|
435
|
+
const literal = (type as TypeLiteral).literal;
|
|
436
|
+
if (typeof literal === 'string') return { type: 'varchar', size: 255 };
|
|
437
|
+
if (typeof literal === 'number') return { type: 'int' };
|
|
438
|
+
if (typeof literal === 'boolean') {
|
|
439
|
+
return dialect === 'mysql' ? { type: 'tinyint', size: 1 } : { type: 'boolean' };
|
|
440
|
+
}
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
default:
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function resolveClassType(type: TypeClass, dialect: Dialect): ResolvedType | null {
|
|
450
|
+
const className = type.classType?.name;
|
|
451
|
+
|
|
452
|
+
switch (className) {
|
|
453
|
+
case 'Date':
|
|
454
|
+
return dialect === 'mysql' ? { type: 'datetime' } : { type: 'timestamp' };
|
|
455
|
+
|
|
456
|
+
case 'Coordinate':
|
|
457
|
+
if (dialect === 'mysql') {
|
|
458
|
+
return { type: 'point' };
|
|
459
|
+
}
|
|
460
|
+
// PG doesn't support POINT in this framework
|
|
461
|
+
return null;
|
|
462
|
+
|
|
463
|
+
case 'ArrayBuffer':
|
|
464
|
+
case 'Uint8Array':
|
|
465
|
+
return dialect === 'mysql' ? { type: 'blob' } : { type: 'bytea' };
|
|
466
|
+
|
|
467
|
+
default:
|
|
468
|
+
// Unknown class → JSON
|
|
469
|
+
return dialect === 'mysql' ? { type: 'json' } : { type: 'jsonb' };
|
|
470
|
+
}
|
|
471
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import { getSourceMigrationsDir } from '../helpers';
|
|
5
|
+
|
|
6
|
+
export function generateMigrationFile(statements: string[], description: string): string {
|
|
7
|
+
const migrationsDir = getSourceMigrationsDir();
|
|
8
|
+
|
|
9
|
+
if (!existsSync(migrationsDir)) {
|
|
10
|
+
mkdirSync(migrationsDir, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const timestamp = formatTimestamp(new Date());
|
|
14
|
+
const slug = slugify(description);
|
|
15
|
+
const filename = `${timestamp}_${slug}.ts`;
|
|
16
|
+
const filePath = path.join(migrationsDir, filename);
|
|
17
|
+
|
|
18
|
+
const content = buildFileContent(statements);
|
|
19
|
+
writeFileSync(filePath, content, 'utf8');
|
|
20
|
+
|
|
21
|
+
return filePath;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function buildFileContent(statements: string[]): string {
|
|
25
|
+
const execLines = statements.map(formatStatement).join('\n');
|
|
26
|
+
return `import { createMigration } from '@zyno-io/dk-server-foundation';\n\nexport default createMigration(async db => {\n${execLines}\n});\n`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function formatStatement(stmt: string): string {
|
|
30
|
+
const escaped = stmt.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
31
|
+
if (!escaped.includes('\n')) {
|
|
32
|
+
return ` await db.rawExecute(\`${escaped}\`);`;
|
|
33
|
+
}
|
|
34
|
+
const indented = escaped
|
|
35
|
+
.split('\n')
|
|
36
|
+
.map(line => ` ${line}`)
|
|
37
|
+
.join('\n');
|
|
38
|
+
return ` await db.rawExecute(\`\n${indented}\n \`);`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function formatTimestamp(date: Date): string {
|
|
42
|
+
const y = date.getUTCFullYear();
|
|
43
|
+
const m = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
44
|
+
const d = String(date.getUTCDate()).padStart(2, '0');
|
|
45
|
+
const h = String(date.getUTCHours()).padStart(2, '0');
|
|
46
|
+
const min = String(date.getUTCMinutes()).padStart(2, '0');
|
|
47
|
+
const s = String(date.getUTCSeconds()).padStart(2, '0');
|
|
48
|
+
return `${y}${m}${d}_${h}${min}${s}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function slugify(text: string): string {
|
|
52
|
+
return text
|
|
53
|
+
.toLowerCase()
|
|
54
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
55
|
+
.replace(/^_|_$/g, '')
|
|
56
|
+
.substring(0, 50);
|
|
57
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createInterface } from 'readline';
|
|
2
|
+
|
|
3
|
+
let nonInteractive = false;
|
|
4
|
+
|
|
5
|
+
export function setNonInteractive(value: boolean): void {
|
|
6
|
+
nonInteractive = value;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function promptRename(tableName: string, newName: string, oldCandidates: string[]): Promise<string | null> {
|
|
10
|
+
if (nonInteractive) return null;
|
|
11
|
+
|
|
12
|
+
if (oldCandidates.length === 1) {
|
|
13
|
+
const oldName = oldCandidates[0];
|
|
14
|
+
const answer = await ask(
|
|
15
|
+
`Table \`${tableName}\`: Column \`${oldName}\` was removed and \`${newName}\` was added.\n` +
|
|
16
|
+
`Was \`${oldName}\` renamed to \`${newName}\`? [y/N] `
|
|
17
|
+
);
|
|
18
|
+
return answer.toLowerCase() === 'y' ? oldName : null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Multiple candidates
|
|
22
|
+
console.log(`\nTable \`${tableName}\`: Column \`${newName}\` was added and these columns were removed:`);
|
|
23
|
+
for (let i = 0; i < oldCandidates.length; i++) {
|
|
24
|
+
console.log(` ${i + 1}. ${oldCandidates[i]}`);
|
|
25
|
+
}
|
|
26
|
+
console.log(` 0. None (treat as new column)`);
|
|
27
|
+
|
|
28
|
+
const answer = await ask(`Was \`${newName}\` renamed from one of these? [0-${oldCandidates.length}] `);
|
|
29
|
+
const choice = parseInt(answer, 10);
|
|
30
|
+
if (isNaN(choice) || choice === 0 || choice > oldCandidates.length) return null;
|
|
31
|
+
return oldCandidates[choice - 1];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function promptMigrationDescription(): Promise<string> {
|
|
35
|
+
if (nonInteractive) return 'auto';
|
|
36
|
+
|
|
37
|
+
const answer = await ask('Enter a short description for this migration: ');
|
|
38
|
+
return answer.trim() || 'migration';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function ask(question: string): Promise<string> {
|
|
42
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
43
|
+
return new Promise(resolve => {
|
|
44
|
+
rl.question(question, answer => {
|
|
45
|
+
rl.close();
|
|
46
|
+
resolve(answer);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Dialect } from '../../dialect';
|
|
2
|
+
|
|
3
|
+
export { Dialect };
|
|
4
|
+
|
|
5
|
+
/** Tables managed internally by the framework — excluded from migration diff. */
|
|
6
|
+
export const INTERNAL_TABLES = new Set(['_migrations', '_locks', '_jobs']);
|
|
7
|
+
|
|
8
|
+
export interface ColumnSchema {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string; // canonical lowercase: 'varchar', 'int', 'enum', 'point', 'date', 'text', 'boolean', 'timestamp', etc.
|
|
11
|
+
size?: number; // e.g. 255 for varchar(255)
|
|
12
|
+
scale?: number; // e.g. 2 for decimal(10,2)
|
|
13
|
+
unsigned: boolean; // MySQL only; always false for PG
|
|
14
|
+
nullable: boolean;
|
|
15
|
+
autoIncrement: boolean;
|
|
16
|
+
isPrimaryKey: boolean;
|
|
17
|
+
defaultValue?: unknown;
|
|
18
|
+
defaultExpression?: string; // e.g. 'CURRENT_TIMESTAMP', 'NOW()'
|
|
19
|
+
onUpdateExpression?: string; // MySQL only; e.g. 'CURRENT_TIMESTAMP'
|
|
20
|
+
enumValues?: string[]; // ordered values for ENUM type
|
|
21
|
+
enumTypeName?: string; // PG only: name of the enum type
|
|
22
|
+
isIdentity?: boolean; // PG only: true if GENERATED ... AS IDENTITY (vs sequence-backed serial)
|
|
23
|
+
sequenceName?: string; // PG only: actual sequence name from pg_get_serial_sequence()
|
|
24
|
+
ordinalPosition: number; // 1-based column order
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface IndexSchema {
|
|
28
|
+
name: string;
|
|
29
|
+
columns: string[]; // ordered
|
|
30
|
+
unique: boolean;
|
|
31
|
+
spatial: boolean; // MySQL only
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ForeignKeySchema {
|
|
35
|
+
name: string;
|
|
36
|
+
columns: string[];
|
|
37
|
+
referencedTable: string;
|
|
38
|
+
referencedColumns: string[];
|
|
39
|
+
onDelete: string;
|
|
40
|
+
onUpdate: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TableSchema {
|
|
44
|
+
name: string;
|
|
45
|
+
columns: ColumnSchema[]; // in ordinal order
|
|
46
|
+
indexes: IndexSchema[];
|
|
47
|
+
foreignKeys: ForeignKeySchema[];
|
|
48
|
+
primaryKeyConstraintName?: string; // PG only: actual constraint name from DB
|
|
49
|
+
skippedColumns?: Set<string>; // columns the entity-reader couldn't resolve (should not be diffed)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type DatabaseSchema = Map<string, TableSchema>;
|
|
53
|
+
|
|
54
|
+
// --- Diff types ---
|
|
55
|
+
|
|
56
|
+
export interface SchemaDiff {
|
|
57
|
+
dialect: Dialect;
|
|
58
|
+
pgSchema?: string; // PG only: schema name for qualified DDL
|
|
59
|
+
addedTables: TableSchema[];
|
|
60
|
+
removedTables: TableSchema[];
|
|
61
|
+
modifiedTables: TableDiff[];
|
|
62
|
+
entityEnumTypes?: Set<string>; // PG only: all enum type names across all entity tables (for safe DROP filtering)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface TableDiff {
|
|
66
|
+
tableName: string;
|
|
67
|
+
addedColumns: ColumnSchema[];
|
|
68
|
+
removedColumns: ColumnSchema[];
|
|
69
|
+
modifiedColumns: ColumnModification[];
|
|
70
|
+
renamedColumns: { from: string; to: string; column: ColumnSchema }[];
|
|
71
|
+
reorderedColumns: { name: string; after: string | null }[]; // MySQL only; null = FIRST
|
|
72
|
+
addedIndexes: IndexSchema[];
|
|
73
|
+
removedIndexes: IndexSchema[];
|
|
74
|
+
addedForeignKeys: ForeignKeySchema[];
|
|
75
|
+
removedForeignKeys: ForeignKeySchema[];
|
|
76
|
+
primaryKeyChanged: boolean;
|
|
77
|
+
newPrimaryKey?: string[];
|
|
78
|
+
oldPrimaryKey?: string[]; // DB's current PK columns (empty = no existing PK)
|
|
79
|
+
oldPrimaryKeyConstraintName?: string; // PG only: constraint name from DB for DROP
|
|
80
|
+
addedEnumTypes: { typeName: string; values: string[] }[]; // PG only
|
|
81
|
+
removedEnumTypes: string[]; // PG only: old enum type names to DROP
|
|
82
|
+
modifiedEnumTypes: {
|
|
83
|
+
typeName: string;
|
|
84
|
+
added: string[];
|
|
85
|
+
removed: string[];
|
|
86
|
+
newValues: string[];
|
|
87
|
+
tableName: string;
|
|
88
|
+
columnName: string;
|
|
89
|
+
}[]; // PG only
|
|
90
|
+
entityColumns?: ColumnSchema[]; // full entity column list for MySQL reorder DDL
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ColumnModification {
|
|
94
|
+
name: string;
|
|
95
|
+
oldColumn: ColumnSchema;
|
|
96
|
+
newColumn: ColumnSchema;
|
|
97
|
+
typeChanged: boolean;
|
|
98
|
+
nullableChanged: boolean;
|
|
99
|
+
defaultChanged: boolean;
|
|
100
|
+
autoIncrementChanged: boolean;
|
|
101
|
+
onUpdateChanged: boolean;
|
|
102
|
+
}
|