@warlock.js/cascade 4.0.47 → 4.0.58
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/cjs/context/database-data-source-context.d.ts +29 -0
- package/cjs/context/database-data-source-context.d.ts.map +1 -0
- package/cjs/context/database-data-source-context.js +28 -0
- package/cjs/context/database-data-source-context.js.map +1 -0
- package/cjs/context/database-transaction-context.d.ts +31 -0
- package/cjs/context/database-transaction-context.d.ts.map +1 -0
- package/cjs/context/database-transaction-context.js +34 -0
- package/cjs/context/database-transaction-context.js.map +1 -0
- package/cjs/contracts/database-driver.contract.d.ts +143 -0
- package/cjs/contracts/database-driver.contract.d.ts.map +1 -0
- package/cjs/contracts/database-id-generator.contract.d.ts +109 -0
- package/cjs/contracts/database-id-generator.contract.d.ts.map +1 -0
- package/cjs/contracts/database-remover.contract.d.ts +104 -0
- package/cjs/contracts/database-remover.contract.d.ts.map +1 -0
- package/cjs/contracts/database-restorer.contract.d.ts +143 -0
- package/cjs/contracts/database-restorer.contract.d.ts.map +1 -0
- package/cjs/contracts/database-writer.contract.d.ts +119 -0
- package/cjs/contracts/database-writer.contract.d.ts.map +1 -0
- package/cjs/contracts/driver-blueprint.contract.d.ts +45 -0
- package/cjs/contracts/driver-blueprint.contract.d.ts.map +1 -0
- package/cjs/contracts/index.d.ts +10 -0
- package/cjs/contracts/index.d.ts.map +1 -0
- package/cjs/contracts/migration-driver.contract.d.ts +365 -0
- package/cjs/contracts/migration-driver.contract.d.ts.map +1 -0
- package/cjs/contracts/query-builder.contract.d.ts +1128 -0
- package/cjs/contracts/query-builder.contract.d.ts.map +1 -0
- package/cjs/contracts/sync-adapter.contract.d.ts +58 -0
- package/cjs/contracts/sync-adapter.contract.d.ts.map +1 -0
- package/cjs/data-source/data-source-registry.d.ts +104 -0
- package/cjs/data-source/data-source-registry.d.ts.map +1 -0
- package/cjs/data-source/data-source-registry.js +138 -0
- package/cjs/data-source/data-source-registry.js.map +1 -0
- package/cjs/data-source/data-source.d.ts +106 -0
- package/cjs/data-source/data-source.d.ts.map +1 -0
- package/cjs/data-source/data-source.js +77 -0
- package/cjs/data-source/data-source.js.map +1 -0
- package/cjs/database-dirty-tracker.d.ts +253 -0
- package/cjs/database-dirty-tracker.d.ts.map +1 -0
- package/cjs/database-dirty-tracker.js +389 -0
- package/cjs/database-dirty-tracker.js.map +1 -0
- package/cjs/drivers/mongo/mongo-id-generator.d.ts +116 -0
- package/cjs/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-id-generator.js +149 -0
- package/cjs/drivers/mongo/mongo-id-generator.js.map +1 -0
- package/cjs/drivers/mongo/mongo-migration-driver.d.ts +228 -0
- package/cjs/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-migration-driver.js +524 -0
- package/cjs/drivers/mongo/mongo-migration-driver.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-builder.d.ts +922 -0
- package/cjs/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-builder.js +1740 -0
- package/cjs/drivers/mongo/mongo-query-builder.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-operations.d.ts +226 -0
- package/cjs/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-operations.js +270 -0
- package/cjs/drivers/mongo/mongo-query-operations.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-parser.d.ts +262 -0
- package/cjs/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-parser.js +1351 -0
- package/cjs/drivers/mongo/mongo-query-parser.js.map +1 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.js +146 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.js.map +1 -0
- package/cjs/drivers/mongo/mongodb-blueprint.d.ts +30 -0
- package/cjs/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongodb-blueprint.js +51 -0
- package/cjs/drivers/mongo/mongodb-blueprint.js.map +1 -0
- package/cjs/drivers/mongo/mongodb-driver.d.ts +188 -0
- package/cjs/drivers/mongo/mongodb-driver.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongodb-driver.js +411 -0
- package/cjs/drivers/mongo/mongodb-driver.js.map +1 -0
- package/cjs/drivers/mongo/types.d.ts +43 -0
- package/cjs/drivers/mongo/types.d.ts.map +1 -0
- package/cjs/errors/missing-data-source.error.d.ts +22 -0
- package/cjs/errors/missing-data-source.error.d.ts.map +1 -0
- package/cjs/errors/missing-data-source.error.js +29 -0
- package/cjs/errors/missing-data-source.error.js.map +1 -0
- package/cjs/events/model-events.d.ts +231 -0
- package/cjs/events/model-events.d.ts.map +1 -0
- package/cjs/events/model-events.js +259 -0
- package/cjs/events/model-events.js.map +1 -0
- package/cjs/expressions/aggregate-expressions.d.ts +215 -0
- package/cjs/expressions/aggregate-expressions.d.ts.map +1 -0
- package/cjs/expressions/aggregate-expressions.js +221 -0
- package/cjs/expressions/aggregate-expressions.js.map +1 -0
- package/cjs/expressions/index.d.ts +2 -0
- package/cjs/expressions/index.d.ts.map +1 -0
- package/cjs/index.d.ts +41 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +1 -267
- package/cjs/index.js.map +1 -1
- package/cjs/migration/column-builder.d.ts +167 -0
- package/cjs/migration/column-builder.d.ts.map +1 -0
- package/cjs/migration/column-builder.js +217 -0
- package/cjs/migration/column-builder.js.map +1 -0
- package/cjs/migration/foreign-key-builder.d.ts +110 -0
- package/cjs/migration/foreign-key-builder.d.ts.map +1 -0
- package/cjs/migration/foreign-key-builder.js +129 -0
- package/cjs/migration/foreign-key-builder.js.map +1 -0
- package/cjs/migration/index.d.ts +6 -0
- package/cjs/migration/index.d.ts.map +1 -0
- package/cjs/migration/migration-runner.d.ts +231 -0
- package/cjs/migration/migration-runner.d.ts.map +1 -0
- package/cjs/migration/migration-runner.js +443 -0
- package/cjs/migration/migration-runner.js.map +1 -0
- package/cjs/migration/migration.js +1346 -0
- package/cjs/migration/migration.js.map +1 -0
- package/cjs/migration/types.d.ts +132 -0
- package/cjs/migration/types.d.ts.map +1 -0
- package/cjs/model/model.d.ts +1267 -0
- package/cjs/model/model.d.ts.map +1 -0
- package/cjs/model/model.js +1463 -0
- package/cjs/model/model.js.map +1 -0
- package/cjs/model/register-model.d.ts +80 -0
- package/cjs/model/register-model.d.ts.map +1 -0
- package/cjs/model/register-model.js +91 -0
- package/cjs/model/register-model.js.map +1 -0
- package/cjs/remover/database-remover.d.ts +100 -0
- package/cjs/remover/database-remover.d.ts.map +1 -0
- package/cjs/remover/database-remover.js +209 -0
- package/cjs/remover/database-remover.js.map +1 -0
- package/cjs/restorer/database-restorer.d.ts +131 -0
- package/cjs/restorer/database-restorer.d.ts.map +1 -0
- package/cjs/restorer/database-restorer.js +425 -0
- package/cjs/restorer/database-restorer.js.map +1 -0
- package/cjs/sync/index.d.ts +12 -0
- package/cjs/sync/index.d.ts.map +1 -0
- package/cjs/sync/model-events.d.ts +62 -0
- package/cjs/sync/model-events.d.ts.map +1 -0
- package/cjs/sync/model-events.js +49 -0
- package/cjs/sync/model-events.js.map +1 -0
- package/cjs/sync/model-sync-operation.d.ts +163 -0
- package/cjs/sync/model-sync-operation.d.ts.map +1 -0
- package/cjs/sync/model-sync-operation.js +292 -0
- package/cjs/sync/model-sync-operation.js.map +1 -0
- package/cjs/sync/model-sync.d.ts +130 -0
- package/cjs/sync/model-sync.d.ts.map +1 -0
- package/cjs/sync/model-sync.js +178 -0
- package/cjs/sync/model-sync.js.map +1 -0
- package/cjs/sync/sync-context.d.ts +70 -0
- package/cjs/sync/sync-context.d.ts.map +1 -0
- package/cjs/sync/sync-context.js +101 -0
- package/cjs/sync/sync-context.js.map +1 -0
- package/cjs/sync/sync-manager.d.ts +213 -0
- package/cjs/sync/sync-manager.d.ts.map +1 -0
- package/cjs/sync/sync-manager.js +689 -0
- package/cjs/sync/sync-manager.js.map +1 -0
- package/cjs/sync/types.d.ts +289 -0
- package/cjs/sync/types.d.ts.map +1 -0
- package/cjs/types.d.ts +45 -0
- package/cjs/types.d.ts.map +1 -0
- package/cjs/utils/connect-to-database.d.ts +246 -0
- package/cjs/utils/connect-to-database.d.ts.map +1 -0
- package/cjs/utils/connect-to-database.js +92 -0
- package/cjs/utils/connect-to-database.js.map +1 -0
- package/cjs/utils/database-writer.utils.d.ts +15 -0
- package/cjs/utils/database-writer.utils.d.ts.map +1 -0
- package/cjs/utils/database-writer.utils.js +14 -0
- package/cjs/utils/database-writer.utils.js.map +1 -0
- package/cjs/utils/define-model.js +100 -0
- package/cjs/utils/define-model.js.map +1 -0
- package/cjs/utils/once-connected.d.ts +146 -0
- package/cjs/utils/once-connected.d.ts.map +1 -0
- package/cjs/utils/once-connected.js +252 -0
- package/cjs/utils/once-connected.js.map +1 -0
- package/cjs/validation/database-seal-plugins.d.ts +2 -0
- package/cjs/validation/database-seal-plugins.d.ts.map +1 -0
- package/cjs/validation/database-seal-plugins.js +4 -0
- package/cjs/validation/database-seal-plugins.js.map +1 -0
- package/cjs/validation/database-writer-validation-error.d.ts +97 -0
- package/cjs/validation/database-writer-validation-error.d.ts.map +1 -0
- package/cjs/validation/database-writer-validation-error.js +160 -0
- package/cjs/validation/database-writer-validation-error.js.map +1 -0
- package/cjs/validation/index.d.ts +3 -0
- package/cjs/validation/index.d.ts.map +1 -0
- package/cjs/validation/mutators/embed-mutator.d.ts +9 -0
- package/cjs/validation/mutators/embed-mutator.d.ts.map +1 -0
- package/cjs/validation/mutators/embed-mutator.js +33 -0
- package/cjs/validation/mutators/embed-mutator.js.map +1 -0
- package/cjs/validation/plugins/embed-validator-plugin.d.ts +24 -0
- package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
- package/cjs/validation/plugins/embed-validator-plugin.js +18 -0
- package/cjs/validation/plugins/embed-validator-plugin.js.map +1 -0
- package/cjs/validation/rules/database-model-rule.d.ts +7 -0
- package/cjs/validation/rules/database-model-rule.d.ts.map +1 -0
- package/cjs/validation/rules/database-model-rule.js +27 -0
- package/cjs/validation/rules/database-model-rule.js.map +1 -0
- package/cjs/validation/transformers/embed-model-transformer.d.ts +3 -0
- package/cjs/validation/transformers/embed-model-transformer.d.ts.map +1 -0
- package/cjs/validation/transformers/embed-model-transformer.js +18 -0
- package/cjs/validation/transformers/embed-model-transformer.js.map +1 -0
- package/cjs/validation/validators/embed-validator.d.ts +21 -0
- package/cjs/validation/validators/embed-validator.d.ts.map +1 -0
- package/cjs/validation/validators/embed-validator.js +42 -0
- package/cjs/validation/validators/embed-validator.js.map +1 -0
- package/cjs/writer/database-writer.d.ts +181 -0
- package/cjs/writer/database-writer.d.ts.map +1 -0
- package/cjs/writer/database-writer.js +402 -0
- package/cjs/writer/database-writer.js.map +1 -0
- package/esm/context/database-data-source-context.d.ts +29 -0
- package/esm/context/database-data-source-context.d.ts.map +1 -0
- package/esm/context/database-data-source-context.js +28 -0
- package/esm/context/database-data-source-context.js.map +1 -0
- package/esm/context/database-transaction-context.d.ts +31 -0
- package/esm/context/database-transaction-context.d.ts.map +1 -0
- package/esm/context/database-transaction-context.js +34 -0
- package/esm/context/database-transaction-context.js.map +1 -0
- package/esm/contracts/database-driver.contract.d.ts +143 -0
- package/esm/contracts/database-driver.contract.d.ts.map +1 -0
- package/esm/contracts/database-id-generator.contract.d.ts +109 -0
- package/esm/contracts/database-id-generator.contract.d.ts.map +1 -0
- package/esm/contracts/database-remover.contract.d.ts +104 -0
- package/esm/contracts/database-remover.contract.d.ts.map +1 -0
- package/esm/contracts/database-restorer.contract.d.ts +143 -0
- package/esm/contracts/database-restorer.contract.d.ts.map +1 -0
- package/esm/contracts/database-writer.contract.d.ts +119 -0
- package/esm/contracts/database-writer.contract.d.ts.map +1 -0
- package/esm/contracts/driver-blueprint.contract.d.ts +45 -0
- package/esm/contracts/driver-blueprint.contract.d.ts.map +1 -0
- package/esm/contracts/index.d.ts +10 -0
- package/esm/contracts/index.d.ts.map +1 -0
- package/esm/contracts/migration-driver.contract.d.ts +365 -0
- package/esm/contracts/migration-driver.contract.d.ts.map +1 -0
- package/esm/contracts/query-builder.contract.d.ts +1128 -0
- package/esm/contracts/query-builder.contract.d.ts.map +1 -0
- package/esm/contracts/sync-adapter.contract.d.ts +58 -0
- package/esm/contracts/sync-adapter.contract.d.ts.map +1 -0
- package/esm/data-source/data-source-registry.d.ts +104 -0
- package/esm/data-source/data-source-registry.d.ts.map +1 -0
- package/esm/data-source/data-source-registry.js +138 -0
- package/esm/data-source/data-source-registry.js.map +1 -0
- package/esm/data-source/data-source.d.ts +106 -0
- package/esm/data-source/data-source.d.ts.map +1 -0
- package/esm/data-source/data-source.js +77 -0
- package/esm/data-source/data-source.js.map +1 -0
- package/esm/database-dirty-tracker.d.ts +253 -0
- package/esm/database-dirty-tracker.d.ts.map +1 -0
- package/esm/database-dirty-tracker.js +389 -0
- package/esm/database-dirty-tracker.js.map +1 -0
- package/esm/drivers/mongo/mongo-id-generator.d.ts +116 -0
- package/esm/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-id-generator.js +149 -0
- package/esm/drivers/mongo/mongo-id-generator.js.map +1 -0
- package/esm/drivers/mongo/mongo-migration-driver.d.ts +228 -0
- package/esm/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-migration-driver.js +524 -0
- package/esm/drivers/mongo/mongo-migration-driver.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-builder.d.ts +922 -0
- package/esm/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-builder.js +1740 -0
- package/esm/drivers/mongo/mongo-query-builder.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-operations.d.ts +226 -0
- package/esm/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-operations.js +270 -0
- package/esm/drivers/mongo/mongo-query-operations.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-parser.d.ts +262 -0
- package/esm/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-parser.js +1351 -0
- package/esm/drivers/mongo/mongo-query-parser.js.map +1 -0
- package/esm/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
- package/esm/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-sync-adapter.js +146 -0
- package/esm/drivers/mongo/mongo-sync-adapter.js.map +1 -0
- package/esm/drivers/mongo/mongodb-blueprint.d.ts +30 -0
- package/esm/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
- package/esm/drivers/mongo/mongodb-blueprint.js +51 -0
- package/esm/drivers/mongo/mongodb-blueprint.js.map +1 -0
- package/esm/drivers/mongo/mongodb-driver.d.ts +188 -0
- package/esm/drivers/mongo/mongodb-driver.d.ts.map +1 -0
- package/esm/drivers/mongo/mongodb-driver.js +411 -0
- package/esm/drivers/mongo/mongodb-driver.js.map +1 -0
- package/esm/drivers/mongo/types.d.ts +43 -0
- package/esm/drivers/mongo/types.d.ts.map +1 -0
- package/esm/errors/missing-data-source.error.d.ts +22 -0
- package/esm/errors/missing-data-source.error.d.ts.map +1 -0
- package/esm/errors/missing-data-source.error.js +29 -0
- package/esm/errors/missing-data-source.error.js.map +1 -0
- package/esm/events/model-events.d.ts +231 -0
- package/esm/events/model-events.d.ts.map +1 -0
- package/esm/events/model-events.js +259 -0
- package/esm/events/model-events.js.map +1 -0
- package/esm/expressions/aggregate-expressions.d.ts +215 -0
- package/esm/expressions/aggregate-expressions.d.ts.map +1 -0
- package/esm/expressions/aggregate-expressions.js +221 -0
- package/esm/expressions/aggregate-expressions.js.map +1 -0
- package/esm/expressions/index.d.ts +2 -0
- package/esm/expressions/index.d.ts.map +1 -0
- package/esm/index.d.ts +41 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +1 -40
- package/esm/index.js.map +1 -1
- package/esm/migration/column-builder.d.ts +167 -0
- package/esm/migration/column-builder.d.ts.map +1 -0
- package/esm/migration/column-builder.js +217 -0
- package/esm/migration/column-builder.js.map +1 -0
- package/esm/migration/foreign-key-builder.d.ts +110 -0
- package/esm/migration/foreign-key-builder.d.ts.map +1 -0
- package/esm/migration/foreign-key-builder.js +129 -0
- package/esm/migration/foreign-key-builder.js.map +1 -0
- package/esm/migration/index.d.ts +6 -0
- package/esm/migration/index.d.ts.map +1 -0
- package/esm/migration/migration-runner.d.ts +231 -0
- package/esm/migration/migration-runner.d.ts.map +1 -0
- package/esm/migration/migration-runner.js +443 -0
- package/esm/migration/migration-runner.js.map +1 -0
- package/esm/migration/migration.js +1346 -0
- package/esm/migration/migration.js.map +1 -0
- package/esm/migration/types.d.ts +132 -0
- package/esm/migration/types.d.ts.map +1 -0
- package/esm/model/model.d.ts +1267 -0
- package/esm/model/model.d.ts.map +1 -0
- package/esm/model/model.js +1463 -0
- package/esm/model/model.js.map +1 -0
- package/esm/model/register-model.d.ts +80 -0
- package/esm/model/register-model.d.ts.map +1 -0
- package/esm/model/register-model.js +91 -0
- package/esm/model/register-model.js.map +1 -0
- package/esm/remover/database-remover.d.ts +100 -0
- package/esm/remover/database-remover.d.ts.map +1 -0
- package/esm/remover/database-remover.js +209 -0
- package/esm/remover/database-remover.js.map +1 -0
- package/esm/restorer/database-restorer.d.ts +131 -0
- package/esm/restorer/database-restorer.d.ts.map +1 -0
- package/esm/restorer/database-restorer.js +425 -0
- package/esm/restorer/database-restorer.js.map +1 -0
- package/esm/sync/index.d.ts +12 -0
- package/esm/sync/index.d.ts.map +1 -0
- package/esm/sync/model-events.d.ts +62 -0
- package/esm/sync/model-events.d.ts.map +1 -0
- package/esm/sync/model-events.js +49 -0
- package/esm/sync/model-events.js.map +1 -0
- package/esm/sync/model-sync-operation.d.ts +163 -0
- package/esm/sync/model-sync-operation.d.ts.map +1 -0
- package/esm/sync/model-sync-operation.js +292 -0
- package/esm/sync/model-sync-operation.js.map +1 -0
- package/esm/sync/model-sync.d.ts +130 -0
- package/esm/sync/model-sync.d.ts.map +1 -0
- package/esm/sync/model-sync.js +178 -0
- package/esm/sync/model-sync.js.map +1 -0
- package/esm/sync/sync-context.d.ts +70 -0
- package/esm/sync/sync-context.d.ts.map +1 -0
- package/esm/sync/sync-context.js +101 -0
- package/esm/sync/sync-context.js.map +1 -0
- package/esm/sync/sync-manager.d.ts +213 -0
- package/esm/sync/sync-manager.d.ts.map +1 -0
- package/esm/sync/sync-manager.js +689 -0
- package/esm/sync/sync-manager.js.map +1 -0
- package/esm/sync/types.d.ts +289 -0
- package/esm/sync/types.d.ts.map +1 -0
- package/esm/types.d.ts +45 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/utils/connect-to-database.d.ts +246 -0
- package/esm/utils/connect-to-database.d.ts.map +1 -0
- package/esm/utils/connect-to-database.js +92 -0
- package/esm/utils/connect-to-database.js.map +1 -0
- package/esm/utils/database-writer.utils.d.ts +15 -0
- package/esm/utils/database-writer.utils.d.ts.map +1 -0
- package/esm/utils/database-writer.utils.js +14 -0
- package/esm/utils/database-writer.utils.js.map +1 -0
- package/esm/utils/define-model.js +100 -0
- package/esm/utils/define-model.js.map +1 -0
- package/esm/utils/once-connected.d.ts +146 -0
- package/esm/utils/once-connected.d.ts.map +1 -0
- package/esm/utils/once-connected.js +252 -0
- package/esm/utils/once-connected.js.map +1 -0
- package/esm/validation/database-seal-plugins.d.ts +2 -0
- package/esm/validation/database-seal-plugins.d.ts.map +1 -0
- package/esm/validation/database-seal-plugins.js +4 -0
- package/esm/validation/database-seal-plugins.js.map +1 -0
- package/esm/validation/database-writer-validation-error.d.ts +97 -0
- package/esm/validation/database-writer-validation-error.d.ts.map +1 -0
- package/esm/validation/database-writer-validation-error.js +160 -0
- package/esm/validation/database-writer-validation-error.js.map +1 -0
- package/esm/validation/index.d.ts +3 -0
- package/esm/validation/index.d.ts.map +1 -0
- package/esm/validation/mutators/embed-mutator.d.ts +9 -0
- package/esm/validation/mutators/embed-mutator.d.ts.map +1 -0
- package/esm/validation/mutators/embed-mutator.js +33 -0
- package/esm/validation/mutators/embed-mutator.js.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.d.ts +24 -0
- package/esm/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.js +18 -0
- package/esm/validation/plugins/embed-validator-plugin.js.map +1 -0
- package/esm/validation/rules/database-model-rule.d.ts +7 -0
- package/esm/validation/rules/database-model-rule.d.ts.map +1 -0
- package/esm/validation/rules/database-model-rule.js +27 -0
- package/esm/validation/rules/database-model-rule.js.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.d.ts +3 -0
- package/esm/validation/transformers/embed-model-transformer.d.ts.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.js +18 -0
- package/esm/validation/transformers/embed-model-transformer.js.map +1 -0
- package/esm/validation/validators/embed-validator.d.ts +21 -0
- package/esm/validation/validators/embed-validator.d.ts.map +1 -0
- package/esm/validation/validators/embed-validator.js +42 -0
- package/esm/validation/validators/embed-validator.js.map +1 -0
- package/esm/writer/database-writer.d.ts +181 -0
- package/esm/writer/database-writer.d.ts.map +1 -0
- package/esm/writer/database-writer.js +402 -0
- package/esm/writer/database-writer.js.map +1 -0
- package/package.json +61 -52
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Context } from "@warlock.js/context";
|
|
2
|
+
import type { DataSource } from "../data-source/data-source";
|
|
3
|
+
type DataSourceContextValue = string | DataSource;
|
|
4
|
+
type DataSourceContextStore = {
|
|
5
|
+
dataSource?: DataSourceContextValue;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Database DataSource Context
|
|
9
|
+
*
|
|
10
|
+
* Manages the active database connection/data source using AsyncLocalStorage.
|
|
11
|
+
* Extends the base Context class for consistent API.
|
|
12
|
+
*/
|
|
13
|
+
declare class DatabaseDataSourceContext extends Context<DataSourceContextStore> {
|
|
14
|
+
/**
|
|
15
|
+
* Get the current data source
|
|
16
|
+
*/
|
|
17
|
+
getDataSource(): DataSourceContextValue | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Set the data source in context
|
|
20
|
+
*/
|
|
21
|
+
setDataSource(dataSource: DataSourceContextValue): void;
|
|
22
|
+
/**
|
|
23
|
+
* Build the initial data source store with defaults
|
|
24
|
+
*/
|
|
25
|
+
buildStore(): DataSourceContextStore;
|
|
26
|
+
}
|
|
27
|
+
export declare const databaseDataSourceContext: DatabaseDataSourceContext;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=database-data-source-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-data-source-context.d.ts","sourceRoot":"","sources":["../../src/context/database-data-source-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,KAAK,sBAAsB,GAAG,MAAM,GAAG,UAAU,CAAC;AAElD,KAAK,sBAAsB,GAAG;IAC5B,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,cAAM,yBAA0B,SAAQ,OAAO,CAAC,sBAAsB,CAAC;IACrE;;OAEG;IACI,aAAa,IAAI,sBAAsB,GAAG,SAAS;IAI1D;;OAEG;IACI,aAAa,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI;IAI9D;;OAEG;IACI,UAAU,IAAI,sBAAsB;CAG5C;AAED,eAAO,MAAM,yBAAyB,2BAAkC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';var context=require('@warlock.js/context');/**
|
|
2
|
+
* Database DataSource Context
|
|
3
|
+
*
|
|
4
|
+
* Manages the active database connection/data source using AsyncLocalStorage.
|
|
5
|
+
* Extends the base Context class for consistent API.
|
|
6
|
+
*/
|
|
7
|
+
class DatabaseDataSourceContext extends context.Context {
|
|
8
|
+
/**
|
|
9
|
+
* Get the current data source
|
|
10
|
+
*/
|
|
11
|
+
getDataSource() {
|
|
12
|
+
return this.get("dataSource");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Set the data source in context
|
|
16
|
+
*/
|
|
17
|
+
setDataSource(dataSource) {
|
|
18
|
+
this.set("dataSource", dataSource);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build the initial data source store with defaults
|
|
22
|
+
*/
|
|
23
|
+
buildStore() {
|
|
24
|
+
return { dataSource: undefined };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const databaseDataSourceContext = new DatabaseDataSourceContext();
|
|
28
|
+
context.contextManager.register("db.datasource", databaseDataSourceContext);exports.databaseDataSourceContext=databaseDataSourceContext;//# sourceMappingURL=database-data-source-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-data-source-context.js","sources":["../../src/context/database-data-source-context.ts"],"sourcesContent":[null],"names":["Context","contextManager"],"mappings":"wDASA;;;;;AAKG;AACH,MAAM,yBAA0B,SAAQA,eAA+B,CAAA;AACrE;;AAEG;IACI,aAAa,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;KAC/B;AAED;;AAEG;AACI,IAAA,aAAa,CAAC,UAAkC,EAAA;AACrD,QAAA,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;KACpC;AAED;;AAEG;IACI,UAAU,GAAA;AACf,QAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;KAClC;AACF,CAAA;AAEY,MAAA,yBAAyB,GAAG,IAAI,yBAAyB,GAAG;AAEzEC,sBAAc,CAAC,QAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Context } from "@warlock.js/context";
|
|
2
|
+
interface TransactionContextStore {
|
|
3
|
+
session?: unknown;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Database Transaction Context
|
|
7
|
+
*
|
|
8
|
+
* Manages database transaction sessions using AsyncLocalStorage.
|
|
9
|
+
* Extends the base Context class for consistent API.
|
|
10
|
+
*/
|
|
11
|
+
declare class DatabaseTransactionContext extends Context<TransactionContextStore> {
|
|
12
|
+
/**
|
|
13
|
+
* Get the current transaction session
|
|
14
|
+
*/
|
|
15
|
+
getSession<TSession = unknown>(): TSession | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Set the transaction session in context
|
|
18
|
+
*/
|
|
19
|
+
setSession(session: unknown): void;
|
|
20
|
+
/**
|
|
21
|
+
* Exit the transaction context
|
|
22
|
+
*/
|
|
23
|
+
exit(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Build the initial transaction store with defaults
|
|
26
|
+
*/
|
|
27
|
+
buildStore(): TransactionContextStore;
|
|
28
|
+
}
|
|
29
|
+
export declare const databaseTransactionContext: DatabaseTransactionContext;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=database-transaction-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-transaction-context.d.ts","sourceRoot":"","sources":["../../src/context/database-transaction-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAC;AAE9D,UAAU,uBAAuB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,cAAM,0BAA2B,SAAQ,OAAO,CAAC,uBAAuB,CAAC;IACvE;;OAEG;IACI,UAAU,CAAC,QAAQ,GAAG,OAAO,KAAK,QAAQ,GAAG,SAAS;IAI7D;;OAEG;IACI,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIzC;;OAEG;IACI,IAAI,IAAI,IAAI;IAInB;;OAEG;IACI,UAAU,IAAI,uBAAuB;CAG7C;AAED,eAAO,MAAM,0BAA0B,4BAAmC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';var context=require('@warlock.js/context');/**
|
|
2
|
+
* Database Transaction Context
|
|
3
|
+
*
|
|
4
|
+
* Manages database transaction sessions using AsyncLocalStorage.
|
|
5
|
+
* Extends the base Context class for consistent API.
|
|
6
|
+
*/
|
|
7
|
+
class DatabaseTransactionContext extends context.Context {
|
|
8
|
+
/**
|
|
9
|
+
* Get the current transaction session
|
|
10
|
+
*/
|
|
11
|
+
getSession() {
|
|
12
|
+
return this.get("session");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Set the transaction session in context
|
|
16
|
+
*/
|
|
17
|
+
setSession(session) {
|
|
18
|
+
this.set("session", session);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Exit the transaction context
|
|
22
|
+
*/
|
|
23
|
+
exit() {
|
|
24
|
+
this.clear();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build the initial transaction store with defaults
|
|
28
|
+
*/
|
|
29
|
+
buildStore() {
|
|
30
|
+
return { session: undefined };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const databaseTransactionContext = new DatabaseTransactionContext();
|
|
34
|
+
context.contextManager.register("db.transaction", databaseTransactionContext);exports.databaseTransactionContext=databaseTransactionContext;//# sourceMappingURL=database-transaction-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-transaction-context.js","sources":["../../src/context/database-transaction-context.ts"],"sourcesContent":[null],"names":["Context","contextManager"],"mappings":"wDAMA;;;;;AAKG;AACH,MAAM,0BAA2B,SAAQA,eAAgC,CAAA;AACvE;;AAEG;IACI,UAAU,GAAA;AACf,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAyB,CAAC;KACpD;AAED;;AAEG;AACI,IAAA,UAAU,CAAC,OAAgB,EAAA;AAChC,QAAA,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;KAC9B;AAED;;AAEG;IACI,IAAI,GAAA;QACT,IAAI,CAAC,KAAK,EAAE,CAAC;KACd;AAED;;AAEG;IACI,UAAU,GAAA;AACf,QAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;KAC/B;AACF,CAAA;AAEY,MAAA,0BAA0B,GAAG,IAAI,0BAA0B,GAAG;AAE3EC,sBAAc,CAAC,QAAQ,CAAC,gBAAgB,EAAE,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { DriverBlueprintContract } from "./driver-blueprint.contract";
|
|
2
|
+
import type { MigrationDriverContract } from "./migration-driver.contract";
|
|
3
|
+
import type { QueryBuilderContract } from "./query-builder.contract";
|
|
4
|
+
import type { SyncAdapterContract } from "./sync-adapter.contract";
|
|
5
|
+
/** Supported driver lifecycle events. */
|
|
6
|
+
export type DriverEvent = "connected" | "disconnected" | string;
|
|
7
|
+
/** Listener signature for driver lifecycle events. */
|
|
8
|
+
export type DriverEventListener = (...args: unknown[]) => void;
|
|
9
|
+
/** Representation of an opened transaction. */
|
|
10
|
+
export interface DriverTransactionContract<TContext = unknown> {
|
|
11
|
+
/** Driver-specific transaction context (session, connection, ...). */
|
|
12
|
+
context: TContext;
|
|
13
|
+
/** Commit the transaction. */
|
|
14
|
+
commit(): Promise<void>;
|
|
15
|
+
/** Rollback the transaction. */
|
|
16
|
+
rollback(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/** Result returned after insert operations. */
|
|
19
|
+
export type InsertResult<TDocument = unknown> = {
|
|
20
|
+
document: TDocument;
|
|
21
|
+
};
|
|
22
|
+
/** Result returned after update operations. */
|
|
23
|
+
export type UpdateResult = {
|
|
24
|
+
modifiedCount: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Database-agnostic update operations.
|
|
28
|
+
*
|
|
29
|
+
* Drivers translate these to their native syntax:
|
|
30
|
+
* - MongoDB: Used as-is (e.g., `{ $set: { age: 31 } }`)
|
|
31
|
+
* - SQL: Translated to SET/NULL statements (e.g., `SET age = 31`)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Set fields
|
|
36
|
+
* { $set: { age: 31, name: "Alice" } }
|
|
37
|
+
*
|
|
38
|
+
* // Remove fields (MongoDB: delete, SQL: SET NULL)
|
|
39
|
+
* { $unset: { tempField: 1 } }
|
|
40
|
+
*
|
|
41
|
+
* // Increment numeric fields
|
|
42
|
+
* { $inc: { views: 1, likes: 5 } }
|
|
43
|
+
*
|
|
44
|
+
* // Combined operations
|
|
45
|
+
* {
|
|
46
|
+
* $set: { status: "active" },
|
|
47
|
+
* $unset: { tempData: 1 },
|
|
48
|
+
* $inc: { loginCount: 1 }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export type UpdateOperations = {
|
|
53
|
+
/** Set field values */
|
|
54
|
+
$set?: Record<string, unknown>;
|
|
55
|
+
/** Remove/unset fields (MongoDB: delete field, SQL: SET NULL) */
|
|
56
|
+
$unset?: Record<string, 1 | true>;
|
|
57
|
+
/** Increment numeric fields */
|
|
58
|
+
$inc?: Record<string, number>;
|
|
59
|
+
/** Decrement numeric fields */
|
|
60
|
+
$dec?: Record<string, number>;
|
|
61
|
+
/** Push to arrays (NoSQL only, SQL drivers may ignore) */
|
|
62
|
+
$push?: Record<string, unknown>;
|
|
63
|
+
/** Pull from arrays (NoSQL only, SQL drivers may ignore) */
|
|
64
|
+
$pull?: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Unified driver contract used by the model layer.
|
|
68
|
+
*/
|
|
69
|
+
export interface DriverContract {
|
|
70
|
+
/**
|
|
71
|
+
* The name of the driver.
|
|
72
|
+
*
|
|
73
|
+
* Used for identification, logging, and debugging.
|
|
74
|
+
*
|
|
75
|
+
* @example "mongodb", "postgres", "mysql"
|
|
76
|
+
*/
|
|
77
|
+
readonly name: string;
|
|
78
|
+
/**
|
|
79
|
+
* Database blueprint (Information Schema)
|
|
80
|
+
*/
|
|
81
|
+
readonly blueprint: DriverBlueprintContract;
|
|
82
|
+
/** Whether the underlying connection is currently established. */
|
|
83
|
+
readonly isConnected: boolean;
|
|
84
|
+
/** Establish the underlying database connection/pool. */
|
|
85
|
+
connect(): Promise<void>;
|
|
86
|
+
/** Close the underlying database connection/pool. */
|
|
87
|
+
disconnect(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Serialize the given data
|
|
90
|
+
*/
|
|
91
|
+
serialize(data: Record<string, unknown>): Record<string, unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* Deserialize the given data
|
|
94
|
+
*/
|
|
95
|
+
deserialize(data: Record<string, unknown>): Record<string, unknown>;
|
|
96
|
+
/** Register event listeners (connected/disconnected/custom). */
|
|
97
|
+
on(event: DriverEvent, listener: DriverEventListener): void;
|
|
98
|
+
/** Insert a single document/row into the given table. */
|
|
99
|
+
insert(table: string, document: Record<string, unknown>, options?: Record<string, unknown>): Promise<InsertResult>;
|
|
100
|
+
/** Insert multiple documents/rows into the given table. */
|
|
101
|
+
insertMany(table: string, documents: Record<string, unknown>[], options?: Record<string, unknown>): Promise<InsertResult[]>;
|
|
102
|
+
/** Update documents/rows matching the filter. */
|
|
103
|
+
update(table: string, filter: Record<string, unknown>, update: UpdateOperations, options?: Record<string, unknown>): Promise<UpdateResult>;
|
|
104
|
+
/** Update many documents/rows matching the filter. */
|
|
105
|
+
updateMany(table: string, filter: Record<string, unknown>, update: UpdateOperations, options?: Record<string, unknown>): Promise<UpdateResult>;
|
|
106
|
+
/** Replace a single document that matches the provided filter. */
|
|
107
|
+
replace<T = unknown>(table: string, filter: Record<string, unknown>, document: Record<string, unknown>, options?: Record<string, unknown>): Promise<T | null>;
|
|
108
|
+
/** Delete a single document that matches the provided filter. */
|
|
109
|
+
delete(table: string, filter?: Record<string, unknown>, options?: Record<string, unknown>): Promise<number>;
|
|
110
|
+
/** Delete documents/rows matching the filter. */
|
|
111
|
+
deleteMany(table: string, filter?: Record<string, unknown>, options?: Record<string, unknown>): Promise<number>;
|
|
112
|
+
/**
|
|
113
|
+
* Remove all records from a table/collection.
|
|
114
|
+
*
|
|
115
|
+
* This is a destructive operation that deletes all documents/rows.
|
|
116
|
+
* Use with caution, especially in production environments.
|
|
117
|
+
*
|
|
118
|
+
* @param table - Table/collection name to truncate
|
|
119
|
+
* @param options - Driver-specific options
|
|
120
|
+
* @returns Number of records deleted
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // Clear all users
|
|
125
|
+
* await driver.truncateTable("users");
|
|
126
|
+
*
|
|
127
|
+
* // Use in seeders for test data cleanup
|
|
128
|
+
* await driver.truncateTable("test_data");
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
truncateTable(table: string, options?: Record<string, unknown>): Promise<number>;
|
|
132
|
+
/** Obtain a query builder for custom querying. */
|
|
133
|
+
queryBuilder<T = unknown>(table: string): QueryBuilderContract<T>;
|
|
134
|
+
/** Start a new transaction scope. */
|
|
135
|
+
beginTransaction(): Promise<DriverTransactionContract>;
|
|
136
|
+
/** Perform atomic updates matching the filter. */
|
|
137
|
+
atomic(table: string, filter: Record<string, unknown>, operations: UpdateOperations, options?: Record<string, unknown>): Promise<UpdateResult>;
|
|
138
|
+
/** Access the sync adapter used for bulk denormalized updates. */
|
|
139
|
+
syncAdapter(): SyncAdapterContract;
|
|
140
|
+
/** Access the migration driver for schema operations. */
|
|
141
|
+
migrationDriver(): MigrationDriverContract;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=database-driver.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-driver.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/database-driver.contract.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for generating the next ID.
|
|
3
|
+
*/
|
|
4
|
+
export type GenerateIdOptions = {
|
|
5
|
+
/** The table/collection name */
|
|
6
|
+
table: string;
|
|
7
|
+
/** Initial ID value for the first record (default: 1) */
|
|
8
|
+
initialId?: number;
|
|
9
|
+
/** Amount to increment by for each new record (default: 1) */
|
|
10
|
+
incrementIdBy?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* ID generator contract for auto-incrementing IDs in NoSQL databases.
|
|
14
|
+
*
|
|
15
|
+
* This service generates sequential integer IDs for NoSQL databases (like MongoDB)
|
|
16
|
+
* that don't have native auto-increment support. It maintains a separate collection
|
|
17
|
+
* that tracks the last generated ID for each table.
|
|
18
|
+
*
|
|
19
|
+
* **Note:** SQL databases (PostgreSQL, MySQL) use native AUTO_INCREMENT/SERIAL
|
|
20
|
+
* and don't need this service.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // For MongoDB
|
|
25
|
+
* const mongoDriver = new MongoDbDriver({ ...config, autoGenerateId: true });
|
|
26
|
+
* const idGenerator = mongoDriver.getIdGenerator();
|
|
27
|
+
*
|
|
28
|
+
* // Generate next ID
|
|
29
|
+
* const id = await idGenerator.generateNextId({
|
|
30
|
+
* table: "users",
|
|
31
|
+
* initialId: 1000,
|
|
32
|
+
* incrementIdBy: 1
|
|
33
|
+
* });
|
|
34
|
+
* console.log(id); // 1000 (first time), 1001 (second time), etc.
|
|
35
|
+
*
|
|
36
|
+
* // Get last ID for a table
|
|
37
|
+
* const lastId = await idGenerator.getLastId("users"); // Returns 1001
|
|
38
|
+
*
|
|
39
|
+
* // Manually set last ID (useful for migrations)
|
|
40
|
+
* await idGenerator.setLastId("users", 5000);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export interface IdGeneratorContract {
|
|
44
|
+
/**
|
|
45
|
+
* Generate the next ID for a table.
|
|
46
|
+
*
|
|
47
|
+
* This method:
|
|
48
|
+
* 1. Atomically increments the counter in the tracking collection
|
|
49
|
+
* 2. Returns the new ID
|
|
50
|
+
* 3. Creates the counter document if it doesn't exist (using initialId)
|
|
51
|
+
*
|
|
52
|
+
* The operation is atomic to ensure uniqueness even in concurrent scenarios.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Configuration for ID generation
|
|
55
|
+
* @returns The generated ID
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const id = await idGenerator.generateNextId({
|
|
60
|
+
* table: "users",
|
|
61
|
+
* initialId: 1000,
|
|
62
|
+
* incrementIdBy: 5
|
|
63
|
+
* });
|
|
64
|
+
* console.log(id); // 1000, 1005, 1010, etc.
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
generateNextId(options: GenerateIdOptions): Promise<number>;
|
|
68
|
+
/**
|
|
69
|
+
* Get the last generated ID for a table.
|
|
70
|
+
*
|
|
71
|
+
* Returns 0 if no IDs have been generated yet for this table.
|
|
72
|
+
*
|
|
73
|
+
* @param table - The table/collection name
|
|
74
|
+
* @returns The last generated ID, or 0 if none exists
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const lastId = await idGenerator.getLastId("users");
|
|
79
|
+
* console.log(lastId); // 42
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
getLastId(table: string): Promise<number>;
|
|
83
|
+
/**
|
|
84
|
+
* Set the last ID for a table.
|
|
85
|
+
*
|
|
86
|
+
* Useful for:
|
|
87
|
+
* - Migrations: Setting a starting point for IDs
|
|
88
|
+
* - Manual ID management: Adjusting counters after bulk operations
|
|
89
|
+
* - Testing: Resetting ID sequences
|
|
90
|
+
*
|
|
91
|
+
* @param table - The table/collection name
|
|
92
|
+
* @param id - The ID to set as the last generated ID
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // Start IDs from 1000
|
|
97
|
+
* await idGenerator.setLastId("users", 1000);
|
|
98
|
+
*
|
|
99
|
+
* // Next generated ID will be 1001
|
|
100
|
+
* const nextId = await idGenerator.generateNextId({
|
|
101
|
+
* table: "users",
|
|
102
|
+
* incrementIdBy: 1
|
|
103
|
+
* });
|
|
104
|
+
* console.log(nextId); // 1001
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
setLastId(table: string, id: number): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=database-id-generator.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-id-generator.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/database-id-generator.contract.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5D;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { DeleteStrategy } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Remover service contract for deleting models from the database.
|
|
4
|
+
*
|
|
5
|
+
* The remover orchestrates the complete deletion pipeline:
|
|
6
|
+
* 1. Strategy resolution (options → model static → data source default)
|
|
7
|
+
* 2. Validation (check if model is new, has primary key)
|
|
8
|
+
* 3. Event emission (deleting, deleted)
|
|
9
|
+
* 4. Driver execution (based on strategy: trash, permanent, or soft)
|
|
10
|
+
* 5. Post-deletion cleanup (mark as new, reset state)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const user = await User.find(1);
|
|
15
|
+
* const remover = new DatabaseRemover(user);
|
|
16
|
+
* const result = await remover.destroy();
|
|
17
|
+
*
|
|
18
|
+
* console.log(result.success); // true
|
|
19
|
+
* console.log(result.strategy); // "trash" | "permanent" | "soft"
|
|
20
|
+
* console.log(result.deletedCount); // 1
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export interface RemoverContract {
|
|
24
|
+
/**
|
|
25
|
+
* Destroy (delete) the model instance from the database.
|
|
26
|
+
*
|
|
27
|
+
* Performs deletion based on the resolved strategy:
|
|
28
|
+
* - `trash`: Moves to trash collection, then deletes
|
|
29
|
+
* - `permanent`: Direct deletion
|
|
30
|
+
* - `soft`: Sets deletedAt timestamp
|
|
31
|
+
*
|
|
32
|
+
* Automatically emits lifecycle events and handles cleanup.
|
|
33
|
+
*
|
|
34
|
+
* @param options - Remover options
|
|
35
|
+
* @returns Result containing success status, strategy used, and metadata
|
|
36
|
+
*
|
|
37
|
+
* @throws {Error} If model is new (not saved) or if deletion fails
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* // Use default strategy
|
|
42
|
+
* const result = await remover.destroy();
|
|
43
|
+
*
|
|
44
|
+
* // Override strategy
|
|
45
|
+
* await remover.destroy({ strategy: "permanent" });
|
|
46
|
+
*
|
|
47
|
+
* // Skip events (silent delete)
|
|
48
|
+
* await remover.destroy({ skipEvents: true });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
destroy(options?: RemoverOptions): Promise<RemoverResult>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for controlling the destroy operation.
|
|
55
|
+
*/
|
|
56
|
+
export type RemoverOptions = {
|
|
57
|
+
/**
|
|
58
|
+
* Override the delete strategy for this operation.
|
|
59
|
+
* Takes precedence over model static property and data source default.
|
|
60
|
+
*
|
|
61
|
+
* @default undefined (uses model static or data source default)
|
|
62
|
+
*/
|
|
63
|
+
strategy?: DeleteStrategy;
|
|
64
|
+
/**
|
|
65
|
+
* Skip lifecycle event emission.
|
|
66
|
+
* Equivalent to "silent delete" in legacy Cascade.
|
|
67
|
+
*
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
skipEvents?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Skip sync operations after delete.
|
|
73
|
+
* Useful when you want to delete without triggering sync updates.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
skipSync?: boolean;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Result returned after a successful destroy operation.
|
|
81
|
+
*/
|
|
82
|
+
export type RemoverResult = {
|
|
83
|
+
/**
|
|
84
|
+
* Whether the destroy operation succeeded.
|
|
85
|
+
*/
|
|
86
|
+
success: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Number of records deleted.
|
|
89
|
+
* - `1` for permanent and trash strategies
|
|
90
|
+
* - `1` for soft delete (one record updated)
|
|
91
|
+
* - `0` if deletion failed
|
|
92
|
+
*/
|
|
93
|
+
deletedCount: number;
|
|
94
|
+
/**
|
|
95
|
+
* The delete strategy that was used.
|
|
96
|
+
*/
|
|
97
|
+
strategy: DeleteStrategy;
|
|
98
|
+
/**
|
|
99
|
+
* The trash record (if strategy was "trash").
|
|
100
|
+
* Contains the original record data that was moved to trash.
|
|
101
|
+
*/
|
|
102
|
+
trashRecord?: Record<string, unknown>;
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=database-remover.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-remover.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/database-remover.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Model } from "../model/model";
|
|
2
|
+
/**
|
|
3
|
+
* Restorer service contract for restoring deleted models from the database.
|
|
4
|
+
*
|
|
5
|
+
* The restorer orchestrates the complete restoration pipeline:
|
|
6
|
+
* 1. Strategy detection (trash vs soft delete)
|
|
7
|
+
* 2. Record retrieval from trash table or soft-deleted records
|
|
8
|
+
* 3. ID conflict resolution
|
|
9
|
+
* 4. Event emission (restoring, restored)
|
|
10
|
+
* 5. Driver execution (insert back to original table, remove from trash/clear deletedAt)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const restorer = new DatabaseRestorer(User);
|
|
15
|
+
* const result = await restorer.restore(123);
|
|
16
|
+
*
|
|
17
|
+
* console.log(result.success); // true
|
|
18
|
+
* console.log(result.strategy); // "trash" | "soft"
|
|
19
|
+
* console.log(result.restoredCount); // 1
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export interface RestorerContract {
|
|
23
|
+
/**
|
|
24
|
+
* Restore a single deleted record by its ID.
|
|
25
|
+
*
|
|
26
|
+
* Resolves the delete strategy from options → model static → data source default.
|
|
27
|
+
* Handles ID conflicts based on options.
|
|
28
|
+
*
|
|
29
|
+
* @param id - The primary key value of the record to restore
|
|
30
|
+
* @param options - Restorer options
|
|
31
|
+
* @returns Result containing success status, strategy used, and restored record
|
|
32
|
+
*
|
|
33
|
+
* @throws {Error} If strategy is "permanent" (cannot restore permanently deleted records)
|
|
34
|
+
* @throws {Error} If record not found in trash or soft-deleted records
|
|
35
|
+
* @throws {Error} If ID conflict and onIdConflict is "fail"
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Restore with default options (assign new ID if conflict)
|
|
40
|
+
* const result = await restorer.restore(123);
|
|
41
|
+
*
|
|
42
|
+
* // Restore with explicit strategy
|
|
43
|
+
* await restorer.restore(123, { strategy: "trash" });
|
|
44
|
+
*
|
|
45
|
+
* // Restore and fail if ID conflict
|
|
46
|
+
* await restorer.restore(123, { onIdConflict: "fail" });
|
|
47
|
+
*
|
|
48
|
+
* // Silent restore (skip events)
|
|
49
|
+
* await restorer.restore(123, { skipEvents: true });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
restore(id: string | number, options?: RestorerOptions): Promise<RestorerResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Restore all deleted records for the model's table.
|
|
55
|
+
*
|
|
56
|
+
* Restores all records from the trash table (if using trash strategy)
|
|
57
|
+
* or all soft-deleted records (if using soft strategy).
|
|
58
|
+
*
|
|
59
|
+
* @param options - Restorer options
|
|
60
|
+
* @returns Result containing success status, strategy used, and aggregate counts
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // Restore all with default options
|
|
65
|
+
* const result = await restorer.restoreAll();
|
|
66
|
+
*
|
|
67
|
+
* // Restore all and fail on any ID conflict
|
|
68
|
+
* await restorer.restoreAll({ onIdConflict: "fail" });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
restoreAll(options?: RestorerOptions): Promise<RestorerResult>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Options for controlling the restore operation.
|
|
75
|
+
*/
|
|
76
|
+
export type RestorerOptions = {
|
|
77
|
+
/**
|
|
78
|
+
* Override the delete strategy for this operation.
|
|
79
|
+
* Takes precedence over model static property and data source default.
|
|
80
|
+
*
|
|
81
|
+
* Must be "trash" or "soft" (cannot restore permanently deleted records).
|
|
82
|
+
*
|
|
83
|
+
* @default undefined (uses model static or data source default)
|
|
84
|
+
*/
|
|
85
|
+
strategy?: "trash" | "soft";
|
|
86
|
+
/**
|
|
87
|
+
* Behavior when the original ID already exists in the target table.
|
|
88
|
+
*
|
|
89
|
+
* - `"assignNew"`: Automatically assign a new ID (default)
|
|
90
|
+
* - `"fail"`: Throw an error if ID conflict occurs
|
|
91
|
+
*
|
|
92
|
+
* @default "assignNew"
|
|
93
|
+
*/
|
|
94
|
+
onIdConflict?: "fail" | "assignNew";
|
|
95
|
+
/**
|
|
96
|
+
* Skip lifecycle event emission.
|
|
97
|
+
* Equivalent to "silent restore".
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
skipEvents?: boolean;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Result returned after a successful restore operation.
|
|
105
|
+
*/
|
|
106
|
+
export type RestorerResult = {
|
|
107
|
+
/**
|
|
108
|
+
* Whether the restore operation succeeded.
|
|
109
|
+
*/
|
|
110
|
+
success: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Number of records restored.
|
|
113
|
+
* - `1` for single restore
|
|
114
|
+
* - `N` for restoreAll (number of records restored)
|
|
115
|
+
*/
|
|
116
|
+
restoredCount: number;
|
|
117
|
+
/**
|
|
118
|
+
* The delete strategy that was used for restoration.
|
|
119
|
+
* - `"trash"`: Record was restored from trash table
|
|
120
|
+
* - `"soft"`: Record was restored by clearing deletedAt timestamp
|
|
121
|
+
*/
|
|
122
|
+
strategy: "trash" | "soft";
|
|
123
|
+
/**
|
|
124
|
+
* The restored record data (for single restore only).
|
|
125
|
+
* Contains the record that was restored, with potentially new ID if conflict occurred.
|
|
126
|
+
*/
|
|
127
|
+
restoredRecord?: Model;
|
|
128
|
+
/**
|
|
129
|
+
* The restored records list
|
|
130
|
+
*/
|
|
131
|
+
restoredRecords?: Model[];
|
|
132
|
+
/**
|
|
133
|
+
* List of ID conflicts that occurred during restoreAll.
|
|
134
|
+
* Only populated if onIdConflict is "assignNew" and conflicts occurred.
|
|
135
|
+
*/
|
|
136
|
+
conflicts?: Array<{
|
|
137
|
+
/** The original ID that conflicted */
|
|
138
|
+
id: string | number;
|
|
139
|
+
/** Reason for the conflict */
|
|
140
|
+
reason: string;
|
|
141
|
+
}>;
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=database-restorer.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-restorer.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/database-restorer.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CACL,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAChE;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE5B;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAEpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IAE3B;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC;IAEvB;;OAEG;IACH,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC;IAE1B;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,sCAAsC;QACtC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,8BAA8B;QAC9B,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ,CAAC"}
|