@warlock.js/cascade 4.0.48 → 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,178 @@
|
|
|
1
|
+
'use strict';var modelSyncOperation=require('./model-sync-operation.js');/**
|
|
2
|
+
* ModelSync facade for registering sync operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides a clean API for defining sync relationships between models
|
|
5
|
+
* with automatic cleanup support for HMR (Hot Module Replacement).
|
|
6
|
+
*
|
|
7
|
+
* @module cascade-next/sync/model-sync
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* ModelSync facade implementation.
|
|
11
|
+
*
|
|
12
|
+
* Manages sync operation registration with scoped cleanup support.
|
|
13
|
+
* Uses a registration stack to track operations created during
|
|
14
|
+
* a `register()` callback for proper HMR cleanup.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // In events file
|
|
19
|
+
* export const cleanup = modelSync.register(() => {
|
|
20
|
+
* Category.sync(Product, "category");
|
|
21
|
+
* Tag.syncMany(Post, "tags").identifyBy("id");
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
class ModelSyncFacade {
|
|
26
|
+
/**
|
|
27
|
+
* All active sync operations.
|
|
28
|
+
*/
|
|
29
|
+
operations = [];
|
|
30
|
+
/**
|
|
31
|
+
* Stack for tracking operations during register() callbacks.
|
|
32
|
+
* Each element is an array of operations created in that scope.
|
|
33
|
+
*/
|
|
34
|
+
registrationStack = [];
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// PUBLIC API
|
|
37
|
+
// ============================================================================
|
|
38
|
+
/**
|
|
39
|
+
* Create a sync operation for a single embedded document.
|
|
40
|
+
*
|
|
41
|
+
* When the source model is updated, the target model's field
|
|
42
|
+
* will be updated with the embedded data.
|
|
43
|
+
*
|
|
44
|
+
* @param source - Source model class that triggers sync
|
|
45
|
+
* @param target - Target model class that receives data
|
|
46
|
+
* @param field - Field path in target model
|
|
47
|
+
* @returns Sync operation for chaining configuration
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // When Category updates, update Product.category
|
|
52
|
+
* modelSync.sync(Category, Product, "category");
|
|
53
|
+
*
|
|
54
|
+
* // With configuration
|
|
55
|
+
* modelSync.sync(Category, Product, "category")
|
|
56
|
+
* .embed("embedMinimal")
|
|
57
|
+
* .watchFields(["name", "slug"]);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
sync(source, target, field) {
|
|
61
|
+
const operation = new modelSyncOperation.ModelSyncOperation(source, target, field, false);
|
|
62
|
+
this.trackOperation(operation);
|
|
63
|
+
return operation;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a sync operation for an array of embedded documents.
|
|
67
|
+
*
|
|
68
|
+
* When the source model is updated, the corresponding element
|
|
69
|
+
* in the target model's array field will be updated.
|
|
70
|
+
*
|
|
71
|
+
* @param source - Source model class that triggers sync
|
|
72
|
+
* @param target - Target model class that receives data
|
|
73
|
+
* @param field - Array field path in target model
|
|
74
|
+
* @returns Sync operation for chaining configuration
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // When Tag updates, update Post.tags[i] where tags[i].id matches
|
|
79
|
+
* modelSync.syncMany(Tag, Post, "tags").identifyBy("id");
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
syncMany(source, target, field) {
|
|
83
|
+
const operation = new modelSyncOperation.ModelSyncOperation(source, target, field, true);
|
|
84
|
+
this.trackOperation(operation);
|
|
85
|
+
return operation;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Register sync operations with automatic cleanup.
|
|
89
|
+
*
|
|
90
|
+
* Executes the callback function which should contain sync registrations.
|
|
91
|
+
* Returns a cleanup function that unsubscribes all operations created
|
|
92
|
+
* during the callback - perfect for HMR module cleanup.
|
|
93
|
+
*
|
|
94
|
+
* @param callback - Function that registers sync operations
|
|
95
|
+
* @returns Cleanup function that unsubscribes all registered operations
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // In src/app/blog/events/sync.ts
|
|
100
|
+
* export const cleanup = modelSync.register(() => {
|
|
101
|
+
* Category.sync(Product, "category");
|
|
102
|
+
* Tag.syncMany(Post, "tags").identifyBy("id");
|
|
103
|
+
* Author.sync(Article, "author").unsetOnDelete();
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
register(callback) {
|
|
108
|
+
// Create a new scope for tracking operations
|
|
109
|
+
const scopedOperations = [];
|
|
110
|
+
this.registrationStack.push(scopedOperations);
|
|
111
|
+
try {
|
|
112
|
+
// Execute callback - operations are tracked via trackOperation()
|
|
113
|
+
callback();
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
// Remove the scope from stack
|
|
117
|
+
this.registrationStack.pop();
|
|
118
|
+
}
|
|
119
|
+
// Return cleanup function for just these scoped operations
|
|
120
|
+
return () => {
|
|
121
|
+
for (const operation of scopedOperations) {
|
|
122
|
+
operation.unsubscribe();
|
|
123
|
+
// Remove from global operations array
|
|
124
|
+
const index = this.operations.indexOf(operation);
|
|
125
|
+
if (index !== -1) {
|
|
126
|
+
this.operations.splice(index, 1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Clear all registered sync operations.
|
|
133
|
+
* Useful for testing or complete reset.
|
|
134
|
+
*/
|
|
135
|
+
clear() {
|
|
136
|
+
for (const operation of this.operations) {
|
|
137
|
+
operation.unsubscribe();
|
|
138
|
+
}
|
|
139
|
+
this.operations.length = 0;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get count of active sync operations.
|
|
143
|
+
* Useful for debugging and testing.
|
|
144
|
+
*/
|
|
145
|
+
get count() {
|
|
146
|
+
return this.operations.length;
|
|
147
|
+
}
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// PRIVATE HELPERS
|
|
150
|
+
// ============================================================================
|
|
151
|
+
/**
|
|
152
|
+
* Track a new operation in global list and current registration scope.
|
|
153
|
+
*/
|
|
154
|
+
trackOperation(operation) {
|
|
155
|
+
// Always add to global operations
|
|
156
|
+
this.operations.push(operation);
|
|
157
|
+
// If inside a register() callback, also track in the current scope
|
|
158
|
+
const currentScope = this.registrationStack[this.registrationStack.length - 1];
|
|
159
|
+
if (currentScope) {
|
|
160
|
+
currentScope.push(operation);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Global modelSync facade instance.
|
|
166
|
+
*
|
|
167
|
+
* Use this to register sync operations between models.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* import { modelSync } from "@warlock.js/cascade";
|
|
172
|
+
*
|
|
173
|
+
* export const cleanup = modelSync.register(() => {
|
|
174
|
+
* Category.sync(Product, "category");
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
const modelSync = new ModelSyncFacade();exports.modelSync=modelSync;//# sourceMappingURL=model-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-sync.js","sources":["../../src/sync/model-sync.ts"],"sourcesContent":[null],"names":["ModelSyncOperation"],"mappings":"yEAAA;;;;;;;AAOG;AAMH;;;;;;;;;;;;;;;AAeG;AACH,MAAM,eAAe,CAAA;AACnB;;AAEG;IACc,UAAU,GAAyB,EAAE,CAAC;AAEvD;;;AAGG;IACc,iBAAiB,GAA2B,EAAE,CAAC;;;;AAMhE;;;;;;;;;;;;;;;;;;;;;AAqBG;AACI,IAAA,IAAI,CACT,MAAyB,EACzB,MAAyB,EACzB,KAAa,EAAA;AAEb,QAAA,MAAM,SAAS,GAAG,IAAIA,qCAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACvE,QAAA,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AAC/B,QAAA,OAAO,SAAS,CAAC;KAClB;AAED;;;;;;;;;;;;;;;;AAgBG;AACI,IAAA,QAAQ,CACb,MAAyB,EACzB,MAAyB,EACzB,KAAa,EAAA;AAEb,QAAA,MAAM,SAAS,GAAG,IAAIA,qCAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AACtE,QAAA,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AAC/B,QAAA,OAAO,SAAS,CAAC;KAClB;AAED;;;;;;;;;;;;;;;;;;;AAmBG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YAAA,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9B,SAAA;KACF;AACF,CAAA;AAED;;;;;;;;;;;;;AAaG;AACU,MAAA,SAAS,GAAG,IAAI,eAAe"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync context management and validation.
|
|
3
|
+
*
|
|
4
|
+
* @module cascade-next/sync/sync-context
|
|
5
|
+
*/
|
|
6
|
+
import type { SyncContext, SyncInstruction } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Default maximum sync depth.
|
|
9
|
+
* Prevents infinite sync chains.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_MAX_SYNC_DEPTH = 3;
|
|
12
|
+
/**
|
|
13
|
+
* Manages sync context and provides validation utilities.
|
|
14
|
+
*/
|
|
15
|
+
export declare class SyncContextManager {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new sync context from a sync instruction.
|
|
18
|
+
*
|
|
19
|
+
* @param instruction - The sync instruction to create context from
|
|
20
|
+
* @param affectedCount - Number of documents affected
|
|
21
|
+
* @returns A new sync context
|
|
22
|
+
*/
|
|
23
|
+
static createContext(instruction: SyncInstruction, affectedCount: number): SyncContext;
|
|
24
|
+
/**
|
|
25
|
+
* Validates if a sync operation can proceed based on depth and cycle detection.
|
|
26
|
+
*
|
|
27
|
+
* @param depth - Current sync depth
|
|
28
|
+
* @param chain - Current sync chain
|
|
29
|
+
* @param targetModel - Target model name
|
|
30
|
+
* @param maxDepth - Maximum allowed depth
|
|
31
|
+
* @param preventCircular - Whether to prevent circular references
|
|
32
|
+
* @returns Validation result with success flag and optional error message
|
|
33
|
+
*/
|
|
34
|
+
static validate(depth: number, chain: string[], targetModel: string, maxDepth: number, preventCircular: boolean): {
|
|
35
|
+
valid: boolean;
|
|
36
|
+
error?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Checks if adding a target model would create a cycle in the sync chain.
|
|
40
|
+
*
|
|
41
|
+
* @param chain - Current sync chain
|
|
42
|
+
* @param targetModel - Model to be added to the chain
|
|
43
|
+
* @returns True if adding the model would create a cycle
|
|
44
|
+
*/
|
|
45
|
+
static hasCycle(chain: string[], targetModel: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new sync chain by appending a model name.
|
|
48
|
+
*
|
|
49
|
+
* @param chain - Current sync chain
|
|
50
|
+
* @param modelName - Model name to append
|
|
51
|
+
* @returns New sync chain array
|
|
52
|
+
*/
|
|
53
|
+
static extendChain(chain: string[], modelName: string): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Formats a sync chain for display.
|
|
56
|
+
*
|
|
57
|
+
* @param chain - Sync chain to format
|
|
58
|
+
* @returns Formatted string (e.g., "Category → Product → Module")
|
|
59
|
+
*/
|
|
60
|
+
static formatChain(chain: string[]): string;
|
|
61
|
+
/**
|
|
62
|
+
* Checks if the current depth allows for further syncing.
|
|
63
|
+
*
|
|
64
|
+
* @param currentDepth - Current depth in the chain
|
|
65
|
+
* @param maxDepth - Maximum allowed depth
|
|
66
|
+
* @returns True if more syncing is allowed
|
|
67
|
+
*/
|
|
68
|
+
static canSyncDeeper(currentDepth: number, maxDepth: number): boolean;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=sync-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-context.d.ts","sourceRoot":"","sources":["../../src/sync/sync-context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;GAEG;AACH,qBAAa,kBAAkB;IAC7B;;;;;;OAMG;WACW,aAAa,CACzB,WAAW,EAAE,eAAe,EAC5B,aAAa,EAAE,MAAM,GACpB,WAAW;IAcd;;;;;;;;;OASG;WACW,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EAAE,EACf,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,OAAO,GACvB;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAoBrC;;;;;;OAMG;WACW,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAIrE;;;;;;OAMG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAIvE;;;;;OAKG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IAIlD;;;;;;OAMG;WACW,aAAa,CACzB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,OAAO;CAGX"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';/**
|
|
2
|
+
* Sync context management and validation.
|
|
3
|
+
*
|
|
4
|
+
* @module cascade-next/sync/sync-context
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default maximum sync depth.
|
|
8
|
+
* Prevents infinite sync chains.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_MAX_SYNC_DEPTH = 3;
|
|
11
|
+
/**
|
|
12
|
+
* Manages sync context and provides validation utilities.
|
|
13
|
+
*/
|
|
14
|
+
class SyncContextManager {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new sync context from a sync instruction.
|
|
17
|
+
*
|
|
18
|
+
* @param instruction - The sync instruction to create context from
|
|
19
|
+
* @param affectedCount - Number of documents affected
|
|
20
|
+
* @returns A new sync context
|
|
21
|
+
*/
|
|
22
|
+
static createContext(instruction, affectedCount) {
|
|
23
|
+
return {
|
|
24
|
+
sourceModel: instruction.sourceModel,
|
|
25
|
+
sourceId: instruction.sourceId,
|
|
26
|
+
currentDepth: instruction.depth,
|
|
27
|
+
syncChain: [...instruction.chain],
|
|
28
|
+
targetModel: instruction.targetModel,
|
|
29
|
+
filter: { ...instruction.filter },
|
|
30
|
+
update: { ...instruction.update },
|
|
31
|
+
affectedCount,
|
|
32
|
+
timestamp: new Date(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates if a sync operation can proceed based on depth and cycle detection.
|
|
37
|
+
*
|
|
38
|
+
* @param depth - Current sync depth
|
|
39
|
+
* @param chain - Current sync chain
|
|
40
|
+
* @param targetModel - Target model name
|
|
41
|
+
* @param maxDepth - Maximum allowed depth
|
|
42
|
+
* @param preventCircular - Whether to prevent circular references
|
|
43
|
+
* @returns Validation result with success flag and optional error message
|
|
44
|
+
*/
|
|
45
|
+
static validate(depth, chain, targetModel, maxDepth, preventCircular) {
|
|
46
|
+
// Check depth limit
|
|
47
|
+
if (depth > maxDepth) {
|
|
48
|
+
return {
|
|
49
|
+
valid: false,
|
|
50
|
+
error: `Sync depth limit exceeded: ${depth} > ${maxDepth}. Chain: ${chain.join(" → ")}`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Check for circular references
|
|
54
|
+
if (preventCircular && this.hasCycle(chain, targetModel)) {
|
|
55
|
+
return {
|
|
56
|
+
valid: false,
|
|
57
|
+
error: `Circular sync detected: ${targetModel} already exists in chain [${chain.join(" → ")}]`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return { valid: true };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Checks if adding a target model would create a cycle in the sync chain.
|
|
64
|
+
*
|
|
65
|
+
* @param chain - Current sync chain
|
|
66
|
+
* @param targetModel - Model to be added to the chain
|
|
67
|
+
* @returns True if adding the model would create a cycle
|
|
68
|
+
*/
|
|
69
|
+
static hasCycle(chain, targetModel) {
|
|
70
|
+
return chain.includes(targetModel);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new sync chain by appending a model name.
|
|
74
|
+
*
|
|
75
|
+
* @param chain - Current sync chain
|
|
76
|
+
* @param modelName - Model name to append
|
|
77
|
+
* @returns New sync chain array
|
|
78
|
+
*/
|
|
79
|
+
static extendChain(chain, modelName) {
|
|
80
|
+
return [...chain, modelName];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Formats a sync chain for display.
|
|
84
|
+
*
|
|
85
|
+
* @param chain - Sync chain to format
|
|
86
|
+
* @returns Formatted string (e.g., "Category → Product → Module")
|
|
87
|
+
*/
|
|
88
|
+
static formatChain(chain) {
|
|
89
|
+
return chain.join(" → ");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Checks if the current depth allows for further syncing.
|
|
93
|
+
*
|
|
94
|
+
* @param currentDepth - Current depth in the chain
|
|
95
|
+
* @param maxDepth - Maximum allowed depth
|
|
96
|
+
* @returns True if more syncing is allowed
|
|
97
|
+
*/
|
|
98
|
+
static canSyncDeeper(currentDepth, maxDepth) {
|
|
99
|
+
return currentDepth < maxDepth;
|
|
100
|
+
}
|
|
101
|
+
}exports.DEFAULT_MAX_SYNC_DEPTH=DEFAULT_MAX_SYNC_DEPTH;exports.SyncContextManager=SyncContextManager;//# sourceMappingURL=sync-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-context.js","sources":["../../src/sync/sync-context.ts"],"sourcesContent":[null],"names":[],"mappings":"aAAA;;;;AAIG;AAIH;;;AAGG;AACI,MAAM,sBAAsB,GAAG,EAAE;AAExC;;AAEG;MACU,kBAAkB,CAAA;AAC7B;;;;;;AAMG;AACI,IAAA,OAAO,aAAa,CACzB,WAA4B,EAC5B,aAAqB,EAAA;QAErB,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,YAAY,EAAE,WAAW,CAAC,KAAK;AAC/B,YAAA,SAAS,EAAE,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;YACjC,WAAW,EAAE,WAAW,CAAC,WAAW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AC,KAAK,CAAC,CAAC;KAC1B;AAED;;;;;;AAMG;AACI,IAAA,OAAO,aAAa,CACzB,YAAoB,EACpB,QAAgB,EAAA;QAEhB,OAAO,YAAY,GAAG,QAAQ,CAAC;KAChC;AACF"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync manager service for handling multi-level sync operations.
|
|
3
|
+
*
|
|
4
|
+
* @module cascade-next/sync/sync-manager
|
|
5
|
+
*/
|
|
6
|
+
import type { DriverContract } from "../contracts/database-driver.contract";
|
|
7
|
+
import { ChildModel, Model } from "../model/model";
|
|
8
|
+
import type { SyncConfig, SyncResult } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Manages sync operations across models with multi-level support.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SyncManager {
|
|
13
|
+
private readonly sourceModel;
|
|
14
|
+
private readonly driver;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new sync manager.
|
|
17
|
+
*
|
|
18
|
+
* @param sourceModel - The source model class
|
|
19
|
+
* @param driver - The database driver
|
|
20
|
+
*/
|
|
21
|
+
constructor(sourceModel: ChildModel<Model>, driver: DriverContract);
|
|
22
|
+
/**
|
|
23
|
+
* Executes sync operations for a model update.
|
|
24
|
+
*
|
|
25
|
+
* @param sourceId - The source model ID
|
|
26
|
+
* @param updatedData - The updated data to sync (Model instance or plain data)
|
|
27
|
+
* @param changedFields - Fields that were changed (for filtering)
|
|
28
|
+
* @returns Sync result with success status and details
|
|
29
|
+
*/
|
|
30
|
+
syncUpdate(sourceId: string | number, updatedData: Record<string, unknown> | Model, changedFields: string[]): Promise<SyncResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Executes sync operations for a model update with a specific config.
|
|
33
|
+
* Used by ModelSyncOperation for event-based sync.
|
|
34
|
+
*
|
|
35
|
+
* @param sourceId - The source model ID
|
|
36
|
+
* @param updatedData - The updated data to sync
|
|
37
|
+
* @param changedFields - Fields that were changed
|
|
38
|
+
* @param config - The sync configuration to use
|
|
39
|
+
* @returns Sync result with success status and details
|
|
40
|
+
*/
|
|
41
|
+
syncUpdateWithConfig(sourceId: string | number, updatedData: Record<string, unknown> | Model, changedFields: string[], config: SyncConfig): Promise<SyncResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Executes sync delete operations with a specific config.
|
|
44
|
+
* Used by ModelSyncOperation for event-based sync.
|
|
45
|
+
*
|
|
46
|
+
* @param sourceId - The source model ID
|
|
47
|
+
* @param config - The sync configuration to use
|
|
48
|
+
* @returns Sync result with success status and details
|
|
49
|
+
*/
|
|
50
|
+
syncDeleteWithConfig(sourceId: string | number, config: SyncConfig): Promise<SyncResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Executes sync operations for a model deletion.
|
|
53
|
+
*
|
|
54
|
+
* @param sourceId - The source model ID
|
|
55
|
+
* @returns Sync result with success status and details
|
|
56
|
+
*/
|
|
57
|
+
syncDelete(sourceId: string | number): Promise<SyncResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Collects sync instructions recursively with depth limiting.
|
|
60
|
+
*
|
|
61
|
+
* @param payload - Data payload
|
|
62
|
+
* @returns Array of sync instructions
|
|
63
|
+
*/
|
|
64
|
+
private collectInstructions;
|
|
65
|
+
/**
|
|
66
|
+
* Collects delete sync instructions.
|
|
67
|
+
*
|
|
68
|
+
* @param sourceId - Source model ID
|
|
69
|
+
* @param syncConfigs - Sync configurations
|
|
70
|
+
* @param options - Instruction options
|
|
71
|
+
* @returns Array of sync instructions
|
|
72
|
+
*/
|
|
73
|
+
private collectDeleteInstructions;
|
|
74
|
+
/**
|
|
75
|
+
* Collects instructions for the next level in the sync chain.
|
|
76
|
+
*
|
|
77
|
+
* @param parentInstruction - The parent instruction
|
|
78
|
+
* @param embedData - Embedded data from parent
|
|
79
|
+
* @param changedFields - Changed fields
|
|
80
|
+
* @param parentConfig - Parent sync config
|
|
81
|
+
* @param parentOptions - Parent instruction options
|
|
82
|
+
* @returns Array of next-level sync instructions
|
|
83
|
+
*/
|
|
84
|
+
private collectNextLevelInstructions;
|
|
85
|
+
/**
|
|
86
|
+
* Builds an update sync instruction.
|
|
87
|
+
*
|
|
88
|
+
* @param sourceId - Source model ID
|
|
89
|
+
* @param config - Sync configuration
|
|
90
|
+
* @param embedData - Embedded data to sync
|
|
91
|
+
* @param options - Instruction options
|
|
92
|
+
* @returns Sync instruction
|
|
93
|
+
*/
|
|
94
|
+
private buildUpdateInstruction;
|
|
95
|
+
/**
|
|
96
|
+
* Builds a delete sync instruction.
|
|
97
|
+
*
|
|
98
|
+
* @param sourceId - Source model ID
|
|
99
|
+
* @param config - Sync configuration
|
|
100
|
+
* @param options - Instruction options
|
|
101
|
+
* @returns Sync instruction
|
|
102
|
+
*/
|
|
103
|
+
private buildDeleteInstruction;
|
|
104
|
+
/**
|
|
105
|
+
* Builds a filter for identifying target documents.
|
|
106
|
+
*
|
|
107
|
+
* @param sourceId - Source model ID
|
|
108
|
+
* @param config - Sync configuration
|
|
109
|
+
* @returns Filter object
|
|
110
|
+
*/
|
|
111
|
+
private buildFilter;
|
|
112
|
+
/**
|
|
113
|
+
* Builds an update operation for syncing data.
|
|
114
|
+
*
|
|
115
|
+
* @param embedData - Embedded data to sync
|
|
116
|
+
* @param config - Sync configuration
|
|
117
|
+
* @returns Update operation object
|
|
118
|
+
*/
|
|
119
|
+
private buildUpdate;
|
|
120
|
+
/**
|
|
121
|
+
* Executes sync instructions with batch optimization.
|
|
122
|
+
* Groups by depth and target table for optimal batching.
|
|
123
|
+
*
|
|
124
|
+
* @param instructions - Array of sync instructions
|
|
125
|
+
* @returns Sync result
|
|
126
|
+
*/
|
|
127
|
+
private executeInstructions;
|
|
128
|
+
/**
|
|
129
|
+
* Executes instructions in batch.
|
|
130
|
+
*
|
|
131
|
+
* @param instructions - Instructions to execute
|
|
132
|
+
* @param result - Result object to update
|
|
133
|
+
*/
|
|
134
|
+
private executeBatch;
|
|
135
|
+
/**
|
|
136
|
+
* Executes instructions individually (fallback).
|
|
137
|
+
* Provides detailed error reporting for each failed instruction.
|
|
138
|
+
*
|
|
139
|
+
* @param instructions - Instructions to execute
|
|
140
|
+
* @param result - Result object to update
|
|
141
|
+
*/
|
|
142
|
+
private executeIndividual;
|
|
143
|
+
/**
|
|
144
|
+
* Formats a sync error with detailed context.
|
|
145
|
+
*
|
|
146
|
+
* @param instruction - The failed instruction
|
|
147
|
+
* @param error - The error that occurred
|
|
148
|
+
* @returns Formatted error message
|
|
149
|
+
*/
|
|
150
|
+
private formatSyncError;
|
|
151
|
+
/**
|
|
152
|
+
* Groups instructions by depth for batch processing.
|
|
153
|
+
*
|
|
154
|
+
* @param instructions - Instructions to group
|
|
155
|
+
* @returns Map of depth to instructions (sorted ascending)
|
|
156
|
+
*/
|
|
157
|
+
private groupByDepth;
|
|
158
|
+
/**
|
|
159
|
+
* Groups instructions by target table for batch optimization.
|
|
160
|
+
*
|
|
161
|
+
* @param instructions - Instructions to group
|
|
162
|
+
* @returns Map of table name to instructions
|
|
163
|
+
*/
|
|
164
|
+
private groupByTable;
|
|
165
|
+
/**
|
|
166
|
+
* Checks if sync should proceed based on watched fields.
|
|
167
|
+
*
|
|
168
|
+
* @param config - Sync configuration
|
|
169
|
+
* @param changedFields - Fields that changed
|
|
170
|
+
* @returns True if sync should proceed
|
|
171
|
+
*/
|
|
172
|
+
private shouldSync;
|
|
173
|
+
/**
|
|
174
|
+
* Gets embedded data from the source model.
|
|
175
|
+
*
|
|
176
|
+
* @param data - Source model data or Model instance
|
|
177
|
+
* @param config - Sync configuration
|
|
178
|
+
* @returns Embedded data
|
|
179
|
+
*/
|
|
180
|
+
private getEmbedData;
|
|
181
|
+
/**
|
|
182
|
+
* Gets sync configurations from the source model.
|
|
183
|
+
*
|
|
184
|
+
* @returns Array of sync configurations
|
|
185
|
+
*/
|
|
186
|
+
private getSyncConfigs;
|
|
187
|
+
/**
|
|
188
|
+
* Gets sync configurations for a specific model.
|
|
189
|
+
*
|
|
190
|
+
* @param modelClass - The model class
|
|
191
|
+
* @returns Array of sync configurations
|
|
192
|
+
*/
|
|
193
|
+
private getSyncConfigsForModel;
|
|
194
|
+
/**
|
|
195
|
+
* Emits a syncing event.
|
|
196
|
+
*
|
|
197
|
+
* @param instruction - The sync instruction
|
|
198
|
+
*/
|
|
199
|
+
private emitSyncingEvent;
|
|
200
|
+
/**
|
|
201
|
+
* Emits a synced event.
|
|
202
|
+
*
|
|
203
|
+
* @param context - The sync context
|
|
204
|
+
*/
|
|
205
|
+
private emitSyncedEvent;
|
|
206
|
+
/**
|
|
207
|
+
* Creates an empty sync result.
|
|
208
|
+
*
|
|
209
|
+
* @returns Empty sync result
|
|
210
|
+
*/
|
|
211
|
+
private createEmptyResult;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=sync-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-manager.d.ts","sourceRoot":"","sources":["../../src/sync/sync-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAEV,UAAU,EAIV,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IAExC;;;;;OAKG;gBACgB,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,cAAc;IAKzE;;;;;;;OAOG;IACU,UAAU,CACrB,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,EAC5C,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,UAAU,CAAC;IAsDtB;;;;;;;;;OASG;IACU,oBAAoB,CAC/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