@warlock.js/cascade 4.0.174 → 4.1.2
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/README.md +6 -5
- package/bin/cascadejs +3 -0
- package/esm/cli/commands/migrate-export-sql.mjs +48 -0
- package/esm/cli/commands/migrate-export-sql.mjs.map +1 -0
- package/esm/cli/commands/migrate-list.mjs +26 -0
- package/esm/cli/commands/migrate-list.mjs.map +1 -0
- package/esm/cli/commands/migrate-rollback.mjs +50 -0
- package/esm/cli/commands/migrate-rollback.mjs.map +1 -0
- package/esm/cli/commands/migrate.mjs +65 -0
- package/esm/cli/commands/migrate.mjs.map +1 -0
- package/esm/cli/connection-from-env.mjs +181 -0
- package/esm/cli/connection-from-env.mjs.map +1 -0
- package/esm/cli/index.mjs +31 -0
- package/esm/cli/index.mjs.map +1 -0
- package/esm/cli/load-migrations.mjs +78 -0
- package/esm/cli/load-migrations.mjs.map +1 -0
- package/esm/cli/printers.mjs +57 -0
- package/esm/cli/printers.mjs.map +1 -0
- package/esm/cli/setup-logger.mjs +30 -0
- package/esm/cli/setup-logger.mjs.map +1 -0
- package/esm/cli/with-cli-connection.mjs +39 -0
- package/esm/cli/with-cli-connection.mjs.map +1 -0
- package/esm/cli.d.mts +1 -0
- package/esm/cli.mjs +26 -0
- package/esm/cli.mjs.map +1 -0
- package/esm/context/database-data-source-context.d.mts +32 -0
- package/esm/context/database-data-source-context.d.mts.map +1 -0
- package/esm/context/database-data-source-context.mjs +35 -0
- package/esm/context/database-data-source-context.mjs.map +1 -0
- package/esm/context/database-transaction-context.d.mts +38 -0
- package/esm/context/database-transaction-context.d.mts.map +1 -0
- package/esm/context/database-transaction-context.mjs +47 -0
- package/esm/context/database-transaction-context.mjs.map +1 -0
- package/esm/contracts/database-driver.contract.d.mts +443 -0
- package/esm/contracts/database-driver.contract.d.mts.map +1 -0
- package/esm/contracts/database-id-generator.contract.d.mts +109 -0
- package/esm/contracts/database-id-generator.contract.d.mts.map +1 -0
- package/esm/contracts/database-remover.contract.d.mts +108 -0
- package/esm/contracts/database-remover.contract.d.mts.map +1 -0
- package/esm/contracts/database-restorer.contract.d.mts +145 -0
- package/esm/contracts/database-restorer.contract.d.mts.map +1 -0
- package/esm/contracts/database-writer.contract.d.mts +123 -0
- package/esm/contracts/database-writer.contract.d.mts.map +1 -0
- package/esm/contracts/driver-blueprint.contract.d.mts +52 -0
- package/esm/contracts/driver-blueprint.contract.d.mts.map +1 -0
- package/esm/contracts/index.d.mts +9 -0
- package/esm/contracts/migration-driver.contract.d.mts +476 -0
- package/esm/contracts/migration-driver.contract.d.mts.map +1 -0
- package/esm/contracts/query-builder.contract.d.mts +1663 -0
- package/esm/contracts/query-builder.contract.d.mts.map +1 -0
- package/esm/contracts/sync-adapter.contract.d.mts +49 -0
- package/esm/contracts/sync-adapter.contract.d.mts.map +1 -0
- package/esm/data-source/data-source-registry.d.mts +111 -0
- package/esm/data-source/data-source-registry.d.mts.map +1 -0
- package/esm/data-source/data-source-registry.mjs +142 -0
- package/esm/data-source/data-source-registry.mjs.map +1 -0
- package/esm/data-source/data-source.d.mts +160 -0
- package/esm/data-source/data-source.d.mts.map +1 -0
- package/esm/data-source/data-source.mjs +87 -0
- package/esm/data-source/data-source.mjs.map +1 -0
- package/esm/database-dirty-tracker.d.mts +254 -0
- package/esm/database-dirty-tracker.d.mts.map +1 -0
- package/esm/database-dirty-tracker.mjs +356 -0
- package/esm/database-dirty-tracker.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-blueprint.mjs +54 -0
- package/esm/drivers/mongodb/mongodb-blueprint.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-driver.d.mts +334 -0
- package/esm/drivers/mongodb/mongodb-driver.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-driver.mjs +716 -0
- package/esm/drivers/mongodb/mongodb-driver.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts +120 -0
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-id-generator.mjs +141 -0
- package/esm/drivers/mongodb/mongodb-id-generator.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts +322 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.mjs +531 -0
- package/esm/drivers/mongodb/mongodb-migration-driver.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts +1117 -0
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-builder.mjs +1828 -0
- package/esm/drivers/mongodb/mongodb-query-builder.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts +230 -0
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-operations.mjs +275 -0
- package/esm/drivers/mongodb/mongodb-query-operations.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts +263 -0
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-query-parser.mjs +965 -0
- package/esm/drivers/mongodb/mongodb-query-parser.mjs.map +1 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts +78 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts.map +1 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.mjs +118 -0
- package/esm/drivers/mongodb/mongodb-sync-adapter.mjs.map +1 -0
- package/esm/drivers/mongodb/types.d.mts +43 -0
- package/esm/drivers/mongodb/types.d.mts.map +1 -0
- package/esm/drivers/postgres/index.d.mts +8 -0
- package/esm/drivers/postgres/index.mjs +9 -0
- package/esm/drivers/postgres/postgres-blueprint.d.mts +60 -0
- package/esm/drivers/postgres/postgres-blueprint.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-blueprint.mjs +105 -0
- package/esm/drivers/postgres/postgres-blueprint.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-dialect.d.mts +144 -0
- package/esm/drivers/postgres/postgres-dialect.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-dialect.mjs +227 -0
- package/esm/drivers/postgres/postgres-dialect.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-driver.d.mts +424 -0
- package/esm/drivers/postgres/postgres-driver.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-driver.mjs +845 -0
- package/esm/drivers/postgres/postgres-driver.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-migration-driver.d.mts +393 -0
- package/esm/drivers/postgres/postgres-migration-driver.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-migration-driver.mjs +760 -0
- package/esm/drivers/postgres/postgres-migration-driver.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-query-builder.d.mts +399 -0
- package/esm/drivers/postgres/postgres-query-builder.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-query-builder.mjs +1105 -0
- package/esm/drivers/postgres/postgres-query-builder.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-query-parser.d.mts +351 -0
- package/esm/drivers/postgres/postgres-query-parser.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-query-parser.mjs +796 -0
- package/esm/drivers/postgres/postgres-query-parser.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-sql-serializer.mjs +260 -0
- package/esm/drivers/postgres/postgres-sql-serializer.mjs.map +1 -0
- package/esm/drivers/postgres/postgres-sync-adapter.d.mts +79 -0
- package/esm/drivers/postgres/postgres-sync-adapter.d.mts.map +1 -0
- package/esm/drivers/postgres/postgres-sync-adapter.mjs +162 -0
- package/esm/drivers/postgres/postgres-sync-adapter.mjs.map +1 -0
- package/esm/drivers/postgres/types.d.mts +105 -0
- package/esm/drivers/postgres/types.d.mts.map +1 -0
- package/esm/drivers/sql/sql-dialect.contract.d.mts +221 -0
- package/esm/drivers/sql/sql-dialect.contract.d.mts.map +1 -0
- package/esm/drivers/sql/sql-types.d.mts +150 -0
- package/esm/drivers/sql/sql-types.d.mts.map +1 -0
- package/esm/errors/missing-data-source.error.d.mts +25 -0
- package/esm/errors/missing-data-source.error.d.mts.map +1 -0
- package/esm/errors/missing-data-source.error.mjs +31 -0
- package/esm/errors/missing-data-source.error.mjs.map +1 -0
- package/esm/errors/transaction-rollback.error.d.mts +23 -0
- package/esm/errors/transaction-rollback.error.d.mts.map +1 -0
- package/esm/errors/transaction-rollback.error.mjs +29 -0
- package/esm/errors/transaction-rollback.error.mjs.map +1 -0
- package/esm/events/model-events.d.mts +234 -0
- package/esm/events/model-events.d.mts.map +1 -0
- package/esm/events/model-events.mjs +254 -0
- package/esm/events/model-events.mjs.map +1 -0
- package/esm/expressions/aggregate-expressions.d.mts +224 -0
- package/esm/expressions/aggregate-expressions.d.mts.map +1 -0
- package/esm/expressions/aggregate-expressions.mjs +232 -0
- package/esm/expressions/aggregate-expressions.mjs.map +1 -0
- package/esm/index.d.mts +67 -0
- package/esm/index.mjs +53 -0
- package/esm/migration/column-builder.d.mts +420 -0
- package/esm/migration/column-builder.d.mts.map +1 -0
- package/esm/migration/column-builder.mjs +532 -0
- package/esm/migration/column-builder.mjs.map +1 -0
- package/esm/migration/column-helpers.d.mts +280 -0
- package/esm/migration/column-helpers.d.mts.map +1 -0
- package/esm/migration/column-helpers.mjs +376 -0
- package/esm/migration/column-helpers.mjs.map +1 -0
- package/esm/migration/foreign-key-builder.d.mts +106 -0
- package/esm/migration/foreign-key-builder.d.mts.map +1 -0
- package/esm/migration/foreign-key-builder.mjs +126 -0
- package/esm/migration/foreign-key-builder.mjs.map +1 -0
- package/esm/migration/index.d.mts +6 -0
- package/esm/migration/index.mjs +7 -0
- package/esm/migration/migration-runner.d.mts +279 -0
- package/esm/migration/migration-runner.d.mts.map +1 -0
- package/esm/migration/migration-runner.mjs +662 -0
- package/esm/migration/migration-runner.mjs.map +1 -0
- package/esm/migration/migration.d.mts +2035 -0
- package/esm/migration/migration.d.mts.map +1 -0
- package/esm/migration/migration.mjs +2083 -0
- package/esm/migration/migration.mjs.map +1 -0
- package/esm/migration/sql-grammar.mjs +115 -0
- package/esm/migration/sql-grammar.mjs.map +1 -0
- package/esm/migration/sql-serializer.d.mts +26 -0
- package/esm/migration/sql-serializer.d.mts.map +1 -0
- package/esm/migration/sql-serializer.mjs +26 -0
- package/esm/migration/sql-serializer.mjs.map +1 -0
- package/esm/migration/types.d.mts +136 -0
- package/esm/migration/types.d.mts.map +1 -0
- package/esm/model/methods/accessor-methods.mjs +54 -0
- package/esm/model/methods/accessor-methods.mjs.map +1 -0
- package/esm/model/methods/delete-methods.mjs +16 -0
- package/esm/model/methods/delete-methods.mjs.map +1 -0
- package/esm/model/methods/dirty-methods.mjs +20 -0
- package/esm/model/methods/dirty-methods.mjs.map +1 -0
- package/esm/model/methods/hydration-methods.mjs +51 -0
- package/esm/model/methods/hydration-methods.mjs.map +1 -0
- package/esm/model/methods/instance-event-methods.mjs +22 -0
- package/esm/model/methods/instance-event-methods.mjs.map +1 -0
- package/esm/model/methods/meta-methods.mjs +36 -0
- package/esm/model/methods/meta-methods.mjs.map +1 -0
- package/esm/model/methods/pivot-methods.mjs +48 -0
- package/esm/model/methods/pivot-methods.mjs.map +1 -0
- package/esm/model/methods/query-methods.mjs +121 -0
- package/esm/model/methods/query-methods.mjs.map +1 -0
- package/esm/model/methods/restore-methods.mjs +16 -0
- package/esm/model/methods/restore-methods.mjs.map +1 -0
- package/esm/model/methods/scope-methods.mjs +20 -0
- package/esm/model/methods/scope-methods.mjs.map +1 -0
- package/esm/model/methods/serialization-methods.mjs +20 -0
- package/esm/model/methods/serialization-methods.mjs.map +1 -0
- package/esm/model/methods/static-event-methods.mjs +37 -0
- package/esm/model/methods/static-event-methods.mjs.map +1 -0
- package/esm/model/methods/write-methods.mjs +69 -0
- package/esm/model/methods/write-methods.mjs.map +1 -0
- package/esm/model/model.d.mts +1778 -0
- package/esm/model/model.d.mts.map +1 -0
- package/esm/model/model.mjs +1762 -0
- package/esm/model/model.mjs.map +1 -0
- package/esm/model/model.types.d.mts +47 -0
- package/esm/model/model.types.d.mts.map +1 -0
- package/esm/model/register-model.d.mts +140 -0
- package/esm/model/register-model.d.mts.map +1 -0
- package/esm/model/register-model.mjs +175 -0
- package/esm/model/register-model.mjs.map +1 -0
- package/esm/model/relation-decorators.d.mts +88 -0
- package/esm/model/relation-decorators.d.mts.map +1 -0
- package/esm/model/relation-decorators.mjs +191 -0
- package/esm/model/relation-decorators.mjs.map +1 -0
- package/esm/operations/database.d.mts +46 -0
- package/esm/operations/database.d.mts.map +1 -0
- package/esm/operations/database.mjs +40 -0
- package/esm/operations/database.mjs.map +1 -0
- package/esm/operations/index.d.mts +2 -0
- package/esm/operations/index.mjs +4 -0
- package/esm/operations/migrations.d.mts +71 -0
- package/esm/operations/migrations.d.mts.map +1 -0
- package/esm/operations/migrations.mjs +70 -0
- package/esm/operations/migrations.mjs.map +1 -0
- package/esm/query-builder/query-builder.d.mts +564 -0
- package/esm/query-builder/query-builder.d.mts.map +1 -0
- package/esm/query-builder/query-builder.mjs +1097 -0
- package/esm/query-builder/query-builder.mjs.map +1 -0
- package/esm/relations/index.d.mts +4 -0
- package/esm/relations/index.mjs +5 -0
- package/esm/relations/key-conventions.mjs +119 -0
- package/esm/relations/key-conventions.mjs.map +1 -0
- package/esm/relations/pivot-operations.d.mts +155 -0
- package/esm/relations/pivot-operations.d.mts.map +1 -0
- package/esm/relations/pivot-operations.mjs +232 -0
- package/esm/relations/pivot-operations.mjs.map +1 -0
- package/esm/relations/relation-hydrator.d.mts +55 -0
- package/esm/relations/relation-hydrator.d.mts.map +1 -0
- package/esm/relations/relation-hydrator.mjs +52 -0
- package/esm/relations/relation-hydrator.mjs.map +1 -0
- package/esm/relations/relation-loader.d.mts +190 -0
- package/esm/relations/relation-loader.d.mts.map +1 -0
- package/esm/relations/relation-loader.mjs +416 -0
- package/esm/relations/relation-loader.mjs.map +1 -0
- package/esm/relations/types.d.mts +317 -0
- package/esm/relations/types.d.mts.map +1 -0
- package/esm/remover/database-remover.d.mts +104 -0
- package/esm/remover/database-remover.d.mts.map +1 -0
- package/esm/remover/database-remover.mjs +174 -0
- package/esm/remover/database-remover.mjs.map +1 -0
- package/esm/restorer/database-restorer.d.mts +135 -0
- package/esm/restorer/database-restorer.d.mts.map +1 -0
- package/esm/restorer/database-restorer.mjs +316 -0
- package/esm/restorer/database-restorer.mjs.map +1 -0
- package/esm/sql-database-dirty-tracker.d.mts +17 -0
- package/esm/sql-database-dirty-tracker.d.mts.map +1 -0
- package/esm/sql-database-dirty-tracker.mjs +20 -0
- package/esm/sql-database-dirty-tracker.mjs.map +1 -0
- package/esm/sync/model-events.mjs +46 -0
- package/esm/sync/model-events.mjs.map +1 -0
- package/esm/sync/model-sync-operation.d.mts +159 -0
- package/esm/sync/model-sync-operation.d.mts.map +1 -0
- package/esm/sync/model-sync-operation.mjs +257 -0
- package/esm/sync/model-sync-operation.mjs.map +1 -0
- package/esm/sync/model-sync.d.mts +126 -0
- package/esm/sync/model-sync.d.mts.map +1 -0
- package/esm/sync/model-sync.mjs +157 -0
- package/esm/sync/model-sync.mjs.map +1 -0
- package/esm/sync/sync-context.d.mts +69 -0
- package/esm/sync/sync-context.d.mts.map +1 -0
- package/esm/sync/sync-context.mjs +95 -0
- package/esm/sync/sync-context.mjs.map +1 -0
- package/esm/sync/sync-manager.d.mts +213 -0
- package/esm/sync/sync-manager.d.mts.map +1 -0
- package/esm/sync/sync-manager.mjs +597 -0
- package/esm/sync/sync-manager.mjs.map +1 -0
- package/esm/sync/types.d.mts +215 -0
- package/esm/sync/types.d.mts.map +1 -0
- package/esm/types.d.mts +423 -0
- package/esm/types.d.mts.map +1 -0
- package/esm/utils/connect-to-database.d.mts +328 -0
- package/esm/utils/connect-to-database.d.mts.map +1 -0
- package/esm/utils/connect-to-database.mjs +130 -0
- package/esm/utils/connect-to-database.mjs.map +1 -0
- package/esm/utils/database-writer.utils.d.mts +18 -0
- package/esm/utils/database-writer.utils.d.mts.map +1 -0
- package/esm/utils/database-writer.utils.mjs +25 -0
- package/esm/utils/database-writer.utils.mjs.map +1 -0
- package/esm/utils/define-model.d.mts +185 -0
- package/esm/utils/define-model.d.mts.map +1 -0
- package/esm/utils/define-model.mjs +105 -0
- package/esm/utils/define-model.mjs.map +1 -0
- package/esm/utils/is-valid-date-value.mjs +22 -0
- package/esm/utils/is-valid-date-value.mjs.map +1 -0
- package/esm/utils/once-connected.d.mts +150 -0
- package/esm/utils/once-connected.d.mts.map +1 -0
- package/esm/utils/once-connected.mjs +203 -0
- package/esm/utils/once-connected.mjs.map +1 -0
- package/esm/validation/database-seal-plugins.d.mts +1 -0
- package/esm/validation/database-seal-plugins.mjs +11 -0
- package/esm/validation/database-seal-plugins.mjs.map +1 -0
- package/esm/validation/database-writer-validation-error.d.mts +101 -0
- package/esm/validation/database-writer-validation-error.d.mts.map +1 -0
- package/esm/validation/database-writer-validation-error.mjs +153 -0
- package/esm/validation/database-writer-validation-error.mjs.map +1 -0
- package/esm/validation/index.d.mts +2 -0
- package/esm/validation/index.mjs +4 -0
- package/esm/validation/mutators/embed-mutator.mjs +26 -0
- package/esm/validation/mutators/embed-mutator.mjs.map +1 -0
- package/esm/validation/plugins/database-rules-plugin.d.mts +28 -0
- package/esm/validation/plugins/database-rules-plugin.d.mts.map +1 -0
- package/esm/validation/plugins/database-rules-plugin.mjs +43 -0
- package/esm/validation/plugins/database-rules-plugin.mjs.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.d.mts +17 -0
- package/esm/validation/plugins/embed-validator-plugin.d.mts.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.mjs +20 -0
- package/esm/validation/plugins/embed-validator-plugin.mjs.map +1 -0
- package/esm/validation/rules/database-model-rule.mjs +32 -0
- package/esm/validation/rules/database-model-rule.mjs.map +1 -0
- package/esm/validation/rules/exists-rule.mjs +29 -0
- package/esm/validation/rules/exists-rule.mjs.map +1 -0
- package/esm/validation/rules/unique-rule.mjs +43 -0
- package/esm/validation/rules/unique-rule.mjs.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.mjs +17 -0
- package/esm/validation/transformers/embed-model-transformer.mjs.map +1 -0
- package/esm/validation/types.d.mts +43 -0
- package/esm/validation/types.d.mts.map +1 -0
- package/esm/validation/validators/embed-validator.d.mts +25 -0
- package/esm/validation/validators/embed-validator.d.mts.map +1 -0
- package/esm/validation/validators/embed-validator.mjs +42 -0
- package/esm/validation/validators/embed-validator.mjs.map +1 -0
- package/esm/writer/database-writer.d.mts +178 -0
- package/esm/writer/database-writer.d.mts.map +1 -0
- package/esm/writer/database-writer.mjs +317 -0
- package/esm/writer/database-writer.mjs.map +1 -0
- package/llms-full.txt +2027 -0
- package/llms.txt +23 -0
- package/package.json +60 -51
- package/skills/README.md +65 -0
- package/skills/aggregate-data/SKILL.md +102 -0
- package/skills/cascade-basics/SKILL.md +93 -0
- package/skills/configure-delete-strategy/SKILL.md +126 -0
- package/skills/define-model/SKILL.md +170 -0
- package/skills/define-relations/SKILL.md +171 -0
- package/skills/manage-data-sources/SKILL.md +140 -0
- package/skills/manage-transactions/SKILL.md +118 -0
- package/skills/paginate-results/SKILL.md +122 -0
- package/skills/perform-atomic-ops/SKILL.md +98 -0
- package/skills/query-data/SKILL.md +168 -0
- package/skills/run-cascade-cli/SKILL.md +125 -0
- package/skills/search-by-vector/SKILL.md +127 -0
- package/skills/subscribe-to-model-events/SKILL.md +148 -0
- package/skills/track-changes/SKILL.md +109 -0
- package/skills/write-migration/SKILL.md +144 -0
- package/cjs/context/database-data-source-context.d.ts +0 -29
- package/cjs/context/database-data-source-context.d.ts.map +0 -1
- package/cjs/context/database-data-source-context.js +0 -28
- package/cjs/context/database-data-source-context.js.map +0 -1
- package/cjs/context/database-transaction-context.d.ts +0 -35
- package/cjs/context/database-transaction-context.d.ts.map +0 -1
- package/cjs/context/database-transaction-context.js +0 -40
- package/cjs/context/database-transaction-context.js.map +0 -1
- package/cjs/contracts/database-driver.contract.d.ts +0 -450
- package/cjs/contracts/database-driver.contract.d.ts.map +0 -1
- package/cjs/contracts/database-id-generator.contract.d.ts +0 -109
- package/cjs/contracts/database-id-generator.contract.d.ts.map +0 -1
- package/cjs/contracts/database-remover.contract.d.ts +0 -104
- package/cjs/contracts/database-remover.contract.d.ts.map +0 -1
- package/cjs/contracts/database-restorer.contract.d.ts +0 -143
- package/cjs/contracts/database-restorer.contract.d.ts.map +0 -1
- package/cjs/contracts/database-writer.contract.d.ts +0 -119
- package/cjs/contracts/database-writer.contract.d.ts.map +0 -1
- package/cjs/contracts/driver-blueprint.contract.d.ts +0 -49
- package/cjs/contracts/driver-blueprint.contract.d.ts.map +0 -1
- package/cjs/contracts/index.d.ts +0 -10
- package/cjs/contracts/index.d.ts.map +0 -1
- package/cjs/contracts/migration-driver.contract.d.ts +0 -522
- package/cjs/contracts/migration-driver.contract.d.ts.map +0 -1
- package/cjs/contracts/query-builder.contract.d.ts +0 -1609
- package/cjs/contracts/query-builder.contract.d.ts.map +0 -1
- package/cjs/contracts/sync-adapter.contract.d.ts +0 -58
- package/cjs/contracts/sync-adapter.contract.d.ts.map +0 -1
- package/cjs/data-source/data-source-registry.d.ts +0 -108
- package/cjs/data-source/data-source-registry.d.ts.map +0 -1
- package/cjs/data-source/data-source-registry.js +0 -145
- package/cjs/data-source/data-source-registry.js.map +0 -1
- package/cjs/data-source/data-source.d.ts +0 -147
- package/cjs/data-source/data-source.d.ts.map +0 -1
- package/cjs/data-source/data-source.js +0 -83
- package/cjs/data-source/data-source.js.map +0 -1
- package/cjs/database-dirty-tracker.d.ts +0 -252
- package/cjs/database-dirty-tracker.d.ts.map +0 -1
- package/cjs/database-dirty-tracker.js +0 -386
- package/cjs/database-dirty-tracker.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
- package/cjs/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-blueprint.js +0 -51
- package/cjs/drivers/mongodb/mongodb-blueprint.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-driver.d.ts +0 -325
- package/cjs/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-driver.js +0 -845
- package/cjs/drivers/mongodb/mongodb-driver.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
- package/cjs/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-id-generator.js +0 -149
- package/cjs/drivers/mongodb/mongodb-id-generator.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
- package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-migration-driver.js +0 -666
- package/cjs/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
- package/cjs/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-builder.js +0 -1988
- package/cjs/drivers/mongodb/mongodb-query-builder.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
- package/cjs/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-operations.js +0 -270
- package/cjs/drivers/mongodb/mongodb-query-operations.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
- package/cjs/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-query-parser.js +0 -1351
- package/cjs/drivers/mongodb/mongodb-query-parser.js.map +0 -1
- package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
- package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-sync-adapter.js +0 -146
- package/cjs/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
- package/cjs/drivers/mongodb/types.d.ts +0 -43
- package/cjs/drivers/mongodb/types.d.ts.map +0 -1
- package/cjs/drivers/postgres/index.d.ts +0 -16
- package/cjs/drivers/postgres/index.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-blueprint.d.ts +0 -64
- package/cjs/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-blueprint.js +0 -121
- package/cjs/drivers/postgres/postgres-blueprint.js.map +0 -1
- package/cjs/drivers/postgres/postgres-dialect.d.ts +0 -136
- package/cjs/drivers/postgres/postgres-dialect.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-dialect.js +0 -268
- package/cjs/drivers/postgres/postgres-dialect.js.map +0 -1
- package/cjs/drivers/postgres/postgres-driver.d.ts +0 -432
- package/cjs/drivers/postgres/postgres-driver.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-driver.js +0 -1008
- package/cjs/drivers/postgres/postgres-driver.js.map +0 -1
- package/cjs/drivers/postgres/postgres-migration-driver.d.ts +0 -397
- package/cjs/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-migration-driver.js +0 -900
- package/cjs/drivers/postgres/postgres-migration-driver.js.map +0 -1
- package/cjs/drivers/postgres/postgres-query-builder.d.ts +0 -254
- package/cjs/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-query-builder.js +0 -933
- package/cjs/drivers/postgres/postgres-query-builder.js.map +0 -1
- package/cjs/drivers/postgres/postgres-query-parser.d.ts +0 -328
- package/cjs/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-query-parser.js +0 -868
- package/cjs/drivers/postgres/postgres-query-parser.js.map +0 -1
- package/cjs/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
- package/cjs/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-sql-serializer.js +0 -400
- package/cjs/drivers/postgres/postgres-sql-serializer.js.map +0 -1
- package/cjs/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
- package/cjs/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
- package/cjs/drivers/postgres/postgres-sync-adapter.js +0 -204
- package/cjs/drivers/postgres/postgres-sync-adapter.js.map +0 -1
- package/cjs/drivers/postgres/types.d.ts +0 -144
- package/cjs/drivers/postgres/types.d.ts.map +0 -1
- package/cjs/drivers/sql/index.d.ts +0 -10
- package/cjs/drivers/sql/index.d.ts.map +0 -1
- package/cjs/drivers/sql/sql-dialect.contract.d.ts +0 -204
- package/cjs/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
- package/cjs/drivers/sql/sql-types.d.ts +0 -202
- package/cjs/drivers/sql/sql-types.d.ts.map +0 -1
- package/cjs/errors/missing-data-source.error.d.ts +0 -22
- package/cjs/errors/missing-data-source.error.d.ts.map +0 -1
- package/cjs/errors/missing-data-source.error.js +0 -29
- package/cjs/errors/missing-data-source.error.js.map +0 -1
- package/cjs/errors/transaction-rollback.error.d.ts +0 -20
- package/cjs/errors/transaction-rollback.error.d.ts.map +0 -1
- package/cjs/errors/transaction-rollback.error.js +0 -27
- package/cjs/errors/transaction-rollback.error.js.map +0 -1
- package/cjs/events/model-events.d.ts +0 -231
- package/cjs/events/model-events.d.ts.map +0 -1
- package/cjs/events/model-events.js +0 -259
- package/cjs/events/model-events.js.map +0 -1
- package/cjs/expressions/aggregate-expressions.d.ts +0 -215
- package/cjs/expressions/aggregate-expressions.d.ts.map +0 -1
- package/cjs/expressions/aggregate-expressions.js +0 -221
- package/cjs/expressions/aggregate-expressions.js.map +0 -1
- package/cjs/expressions/index.d.ts +0 -2
- package/cjs/expressions/index.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -45
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/migration/column-builder.d.ts +0 -417
- package/cjs/migration/column-builder.d.ts.map +0 -1
- package/cjs/migration/column-builder.js +0 -586
- package/cjs/migration/column-builder.js.map +0 -1
- package/cjs/migration/column-helpers.d.ts +0 -275
- package/cjs/migration/column-helpers.d.ts.map +0 -1
- package/cjs/migration/column-helpers.js +0 -389
- package/cjs/migration/column-helpers.js.map +0 -1
- package/cjs/migration/foreign-key-builder.d.ts +0 -103
- package/cjs/migration/foreign-key-builder.d.ts.map +0 -1
- package/cjs/migration/foreign-key-builder.js +0 -121
- package/cjs/migration/foreign-key-builder.js.map +0 -1
- package/cjs/migration/index.d.ts +0 -7
- package/cjs/migration/index.d.ts.map +0 -1
- package/cjs/migration/migration-runner.d.ts +0 -278
- package/cjs/migration/migration-runner.d.ts.map +0 -1
- package/cjs/migration/migration-runner.js +0 -815
- package/cjs/migration/migration-runner.js.map +0 -1
- package/cjs/migration/migration.d.ts +0 -1988
- package/cjs/migration/migration.d.ts.map +0 -1
- package/cjs/migration/migration.js +0 -2162
- package/cjs/migration/migration.js.map +0 -1
- package/cjs/migration/sql-grammar.d.ts +0 -61
- package/cjs/migration/sql-grammar.d.ts.map +0 -1
- package/cjs/migration/sql-grammar.js +0 -164
- package/cjs/migration/sql-grammar.js.map +0 -1
- package/cjs/migration/sql-serializer.d.ts +0 -22
- package/cjs/migration/sql-serializer.d.ts.map +0 -1
- package/cjs/migration/sql-serializer.js +0 -26
- package/cjs/migration/sql-serializer.js.map +0 -1
- package/cjs/migration/types.d.ts +0 -155
- package/cjs/migration/types.d.ts.map +0 -1
- package/cjs/model/methods/accessor-methods.d.ts +0 -13
- package/cjs/model/methods/accessor-methods.d.ts.map +0 -1
- package/cjs/model/methods/accessor-methods.js +0 -51
- package/cjs/model/methods/accessor-methods.js.map +0 -1
- package/cjs/model/methods/delete-methods.d.ts +0 -10
- package/cjs/model/methods/delete-methods.d.ts.map +0 -1
- package/cjs/model/methods/delete-methods.js +0 -10
- package/cjs/model/methods/delete-methods.js.map +0 -1
- package/cjs/model/methods/dirty-methods.d.ts +0 -10
- package/cjs/model/methods/dirty-methods.d.ts.map +0 -1
- package/cjs/model/methods/dirty-methods.js +0 -15
- package/cjs/model/methods/dirty-methods.js.map +0 -1
- package/cjs/model/methods/hydration-methods.d.ts +0 -10
- package/cjs/model/methods/hydration-methods.d.ts.map +0 -1
- package/cjs/model/methods/hydration-methods.js +0 -57
- package/cjs/model/methods/hydration-methods.js.map +0 -1
- package/cjs/model/methods/instance-event-methods.d.ts +0 -7
- package/cjs/model/methods/instance-event-methods.d.ts.map +0 -1
- package/cjs/model/methods/instance-event-methods.js +0 -15
- package/cjs/model/methods/instance-event-methods.js.map +0 -1
- package/cjs/model/methods/meta-methods.d.ts +0 -7
- package/cjs/model/methods/meta-methods.d.ts.map +0 -1
- package/cjs/model/methods/meta-methods.js +0 -78
- package/cjs/model/methods/meta-methods.js.map +0 -1
- package/cjs/model/methods/query-methods.d.ts +0 -24
- package/cjs/model/methods/query-methods.d.ts.map +0 -1
- package/cjs/model/methods/query-methods.js +0 -164
- package/cjs/model/methods/query-methods.js.map +0 -1
- package/cjs/model/methods/restore-methods.d.ts +0 -10
- package/cjs/model/methods/restore-methods.d.ts.map +0 -1
- package/cjs/model/methods/restore-methods.js +0 -13
- package/cjs/model/methods/restore-methods.js.map +0 -1
- package/cjs/model/methods/scope-methods.d.ts +0 -7
- package/cjs/model/methods/scope-methods.d.ts.map +0 -1
- package/cjs/model/methods/scope-methods.js +0 -15
- package/cjs/model/methods/scope-methods.js.map +0 -1
- package/cjs/model/methods/serialization-methods.d.ts +0 -3
- package/cjs/model/methods/serialization-methods.d.ts.map +0 -1
- package/cjs/model/methods/serialization-methods.js +0 -27
- package/cjs/model/methods/serialization-methods.js.map +0 -1
- package/cjs/model/methods/static-event-methods.d.ts +0 -9
- package/cjs/model/methods/static-event-methods.d.ts.map +0 -1
- package/cjs/model/methods/static-event-methods.js +0 -29
- package/cjs/model/methods/static-event-methods.js.map +0 -1
- package/cjs/model/methods/write-methods.d.ts +0 -10
- package/cjs/model/methods/write-methods.d.ts.map +0 -1
- package/cjs/model/methods/write-methods.js +0 -52
- package/cjs/model/methods/write-methods.js.map +0 -1
- package/cjs/model/model.d.ts +0 -1647
- package/cjs/model/model.d.ts.map +0 -1
- package/cjs/model/model.js +0 -1657
- package/cjs/model/model.js.map +0 -1
- package/cjs/model/model.types.d.ts +0 -44
- package/cjs/model/model.types.d.ts.map +0 -1
- package/cjs/model/register-model.d.ts +0 -81
- package/cjs/model/register-model.d.ts.map +0 -1
- package/cjs/model/register-model.js +0 -94
- package/cjs/model/register-model.js.map +0 -1
- package/cjs/query-builder/query-builder.d.ts +0 -556
- package/cjs/query-builder/query-builder.d.ts.map +0 -1
- package/cjs/query-builder/query-builder.js +0 -1070
- package/cjs/query-builder/query-builder.js.map +0 -1
- package/cjs/relations/helpers.d.ts +0 -156
- package/cjs/relations/helpers.d.ts.map +0 -1
- package/cjs/relations/helpers.js +0 -202
- package/cjs/relations/helpers.js.map +0 -1
- package/cjs/relations/index.d.ts +0 -35
- package/cjs/relations/index.d.ts.map +0 -1
- package/cjs/relations/pivot-operations.d.ts +0 -160
- package/cjs/relations/pivot-operations.d.ts.map +0 -1
- package/cjs/relations/pivot-operations.js +0 -293
- package/cjs/relations/pivot-operations.js.map +0 -1
- package/cjs/relations/relation-hydrator.d.ts +0 -68
- package/cjs/relations/relation-hydrator.d.ts.map +0 -1
- package/cjs/relations/relation-hydrator.js +0 -81
- package/cjs/relations/relation-hydrator.js.map +0 -1
- package/cjs/relations/relation-loader.d.ts +0 -194
- package/cjs/relations/relation-loader.d.ts.map +0 -1
- package/cjs/relations/relation-loader.js +0 -466
- package/cjs/relations/relation-loader.js.map +0 -1
- package/cjs/relations/types.d.ts +0 -306
- package/cjs/relations/types.d.ts.map +0 -1
- package/cjs/remover/database-remover.d.ts +0 -100
- package/cjs/remover/database-remover.d.ts.map +0 -1
- package/cjs/remover/database-remover.js +0 -214
- package/cjs/remover/database-remover.js.map +0 -1
- package/cjs/restorer/database-restorer.d.ts +0 -131
- package/cjs/restorer/database-restorer.d.ts.map +0 -1
- package/cjs/restorer/database-restorer.js +0 -434
- package/cjs/restorer/database-restorer.js.map +0 -1
- package/cjs/sql-database-dirty-tracker.d.ts +0 -13
- package/cjs/sql-database-dirty-tracker.d.ts.map +0 -1
- package/cjs/sql-database-dirty-tracker.js +0 -14
- package/cjs/sql-database-dirty-tracker.js.map +0 -1
- package/cjs/sync/index.d.ts +0 -12
- package/cjs/sync/index.d.ts.map +0 -1
- package/cjs/sync/model-events.d.ts +0 -62
- package/cjs/sync/model-events.d.ts.map +0 -1
- package/cjs/sync/model-events.js +0 -49
- package/cjs/sync/model-events.js.map +0 -1
- package/cjs/sync/model-sync-operation.d.ts +0 -163
- package/cjs/sync/model-sync-operation.d.ts.map +0 -1
- package/cjs/sync/model-sync-operation.js +0 -292
- package/cjs/sync/model-sync-operation.js.map +0 -1
- package/cjs/sync/model-sync.d.ts +0 -130
- package/cjs/sync/model-sync.d.ts.map +0 -1
- package/cjs/sync/model-sync.js +0 -178
- package/cjs/sync/model-sync.js.map +0 -1
- package/cjs/sync/sync-context.d.ts +0 -70
- package/cjs/sync/sync-context.d.ts.map +0 -1
- package/cjs/sync/sync-context.js +0 -101
- package/cjs/sync/sync-context.js.map +0 -1
- package/cjs/sync/sync-manager.d.ts +0 -213
- package/cjs/sync/sync-manager.d.ts.map +0 -1
- package/cjs/sync/sync-manager.js +0 -689
- package/cjs/sync/sync-manager.js.map +0 -1
- package/cjs/sync/types.d.ts +0 -289
- package/cjs/sync/types.d.ts.map +0 -1
- package/cjs/test-migrations/test-enhanced-features.migration.d.ts +0 -15
- package/cjs/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
- package/cjs/types.d.ts +0 -371
- package/cjs/types.d.ts.map +0 -1
- package/cjs/utils/connect-to-database.d.ts +0 -307
- package/cjs/utils/connect-to-database.d.ts.map +0 -1
- package/cjs/utils/connect-to-database.js +0 -130
- package/cjs/utils/connect-to-database.js.map +0 -1
- package/cjs/utils/database-writer.utils.d.ts +0 -15
- package/cjs/utils/database-writer.utils.d.ts.map +0 -1
- package/cjs/utils/database-writer.utils.js +0 -14
- package/cjs/utils/database-writer.utils.js.map +0 -1
- package/cjs/utils/define-model.js +0 -100
- package/cjs/utils/define-model.js.map +0 -1
- package/cjs/utils/is-valid-date-value.d.ts +0 -5
- package/cjs/utils/is-valid-date-value.d.ts.map +0 -1
- package/cjs/utils/is-valid-date-value.js +0 -25
- package/cjs/utils/is-valid-date-value.js.map +0 -1
- package/cjs/utils/once-connected.d.ts +0 -146
- package/cjs/utils/once-connected.d.ts.map +0 -1
- package/cjs/utils/once-connected.js +0 -251
- package/cjs/utils/once-connected.js.map +0 -1
- package/cjs/validation/database-seal-plugins.d.ts +0 -12
- package/cjs/validation/database-seal-plugins.d.ts.map +0 -1
- package/cjs/validation/database-seal-plugins.js +0 -1
- package/cjs/validation/database-seal-plugins.js.map +0 -1
- package/cjs/validation/database-writer-validation-error.d.ts +0 -97
- package/cjs/validation/database-writer-validation-error.d.ts.map +0 -1
- package/cjs/validation/database-writer-validation-error.js +0 -160
- package/cjs/validation/database-writer-validation-error.js.map +0 -1
- package/cjs/validation/index.d.ts +0 -3
- package/cjs/validation/index.d.ts.map +0 -1
- package/cjs/validation/mutators/embed-mutator.d.ts +0 -9
- package/cjs/validation/mutators/embed-mutator.d.ts.map +0 -1
- package/cjs/validation/mutators/embed-mutator.js +0 -33
- package/cjs/validation/mutators/embed-mutator.js.map +0 -1
- package/cjs/validation/plugins/embed-validator-plugin.d.ts +0 -24
- package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
- package/cjs/validation/plugins/embed-validator-plugin.js +0 -18
- package/cjs/validation/plugins/embed-validator-plugin.js.map +0 -1
- package/cjs/validation/rules/database-model-rule.d.ts +0 -7
- package/cjs/validation/rules/database-model-rule.d.ts.map +0 -1
- package/cjs/validation/rules/database-model-rule.js +0 -27
- package/cjs/validation/rules/database-model-rule.js.map +0 -1
- package/cjs/validation/transformers/embed-model-transformer.d.ts +0 -3
- package/cjs/validation/transformers/embed-model-transformer.d.ts.map +0 -1
- package/cjs/validation/transformers/embed-model-transformer.js +0 -18
- package/cjs/validation/transformers/embed-model-transformer.js.map +0 -1
- package/cjs/validation/validators/embed-validator.d.ts +0 -21
- package/cjs/validation/validators/embed-validator.d.ts.map +0 -1
- package/cjs/validation/validators/embed-validator.js +0 -43
- package/cjs/validation/validators/embed-validator.js.map +0 -1
- package/cjs/writer/database-writer.d.ts +0 -174
- package/cjs/writer/database-writer.d.ts.map +0 -1
- package/cjs/writer/database-writer.js +0 -400
- package/cjs/writer/database-writer.js.map +0 -1
- package/esm/context/database-data-source-context.d.ts +0 -29
- package/esm/context/database-data-source-context.d.ts.map +0 -1
- package/esm/context/database-data-source-context.js +0 -28
- package/esm/context/database-data-source-context.js.map +0 -1
- package/esm/context/database-transaction-context.d.ts +0 -35
- package/esm/context/database-transaction-context.d.ts.map +0 -1
- package/esm/context/database-transaction-context.js +0 -40
- package/esm/context/database-transaction-context.js.map +0 -1
- package/esm/contracts/database-driver.contract.d.ts +0 -450
- package/esm/contracts/database-driver.contract.d.ts.map +0 -1
- package/esm/contracts/database-id-generator.contract.d.ts +0 -109
- package/esm/contracts/database-id-generator.contract.d.ts.map +0 -1
- package/esm/contracts/database-remover.contract.d.ts +0 -104
- package/esm/contracts/database-remover.contract.d.ts.map +0 -1
- package/esm/contracts/database-restorer.contract.d.ts +0 -143
- package/esm/contracts/database-restorer.contract.d.ts.map +0 -1
- package/esm/contracts/database-writer.contract.d.ts +0 -119
- package/esm/contracts/database-writer.contract.d.ts.map +0 -1
- package/esm/contracts/driver-blueprint.contract.d.ts +0 -49
- package/esm/contracts/driver-blueprint.contract.d.ts.map +0 -1
- package/esm/contracts/index.d.ts +0 -10
- package/esm/contracts/index.d.ts.map +0 -1
- package/esm/contracts/migration-driver.contract.d.ts +0 -522
- package/esm/contracts/migration-driver.contract.d.ts.map +0 -1
- package/esm/contracts/query-builder.contract.d.ts +0 -1609
- package/esm/contracts/query-builder.contract.d.ts.map +0 -1
- package/esm/contracts/sync-adapter.contract.d.ts +0 -58
- package/esm/contracts/sync-adapter.contract.d.ts.map +0 -1
- package/esm/data-source/data-source-registry.d.ts +0 -108
- package/esm/data-source/data-source-registry.d.ts.map +0 -1
- package/esm/data-source/data-source-registry.js +0 -145
- package/esm/data-source/data-source-registry.js.map +0 -1
- package/esm/data-source/data-source.d.ts +0 -147
- package/esm/data-source/data-source.d.ts.map +0 -1
- package/esm/data-source/data-source.js +0 -83
- package/esm/data-source/data-source.js.map +0 -1
- package/esm/database-dirty-tracker.d.ts +0 -252
- package/esm/database-dirty-tracker.d.ts.map +0 -1
- package/esm/database-dirty-tracker.js +0 -386
- package/esm/database-dirty-tracker.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
- package/esm/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-blueprint.js +0 -51
- package/esm/drivers/mongodb/mongodb-blueprint.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-driver.d.ts +0 -325
- package/esm/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-driver.js +0 -845
- package/esm/drivers/mongodb/mongodb-driver.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
- package/esm/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-id-generator.js +0 -149
- package/esm/drivers/mongodb/mongodb-id-generator.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
- package/esm/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.js +0 -666
- package/esm/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
- package/esm/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-builder.js +0 -1988
- package/esm/drivers/mongodb/mongodb-query-builder.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
- package/esm/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-operations.js +0 -270
- package/esm/drivers/mongodb/mongodb-query-operations.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
- package/esm/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-query-parser.js +0 -1351
- package/esm/drivers/mongodb/mongodb-query-parser.js.map +0 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.js +0 -146
- package/esm/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
- package/esm/drivers/mongodb/types.d.ts +0 -43
- package/esm/drivers/mongodb/types.d.ts.map +0 -1
- package/esm/drivers/postgres/index.d.ts +0 -16
- package/esm/drivers/postgres/index.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-blueprint.d.ts +0 -64
- package/esm/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-blueprint.js +0 -121
- package/esm/drivers/postgres/postgres-blueprint.js.map +0 -1
- package/esm/drivers/postgres/postgres-dialect.d.ts +0 -136
- package/esm/drivers/postgres/postgres-dialect.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-dialect.js +0 -268
- package/esm/drivers/postgres/postgres-dialect.js.map +0 -1
- package/esm/drivers/postgres/postgres-driver.d.ts +0 -432
- package/esm/drivers/postgres/postgres-driver.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-driver.js +0 -1008
- package/esm/drivers/postgres/postgres-driver.js.map +0 -1
- package/esm/drivers/postgres/postgres-migration-driver.d.ts +0 -397
- package/esm/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-migration-driver.js +0 -900
- package/esm/drivers/postgres/postgres-migration-driver.js.map +0 -1
- package/esm/drivers/postgres/postgres-query-builder.d.ts +0 -254
- package/esm/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-query-builder.js +0 -933
- package/esm/drivers/postgres/postgres-query-builder.js.map +0 -1
- package/esm/drivers/postgres/postgres-query-parser.d.ts +0 -328
- package/esm/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-query-parser.js +0 -868
- package/esm/drivers/postgres/postgres-query-parser.js.map +0 -1
- package/esm/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
- package/esm/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-sql-serializer.js +0 -400
- package/esm/drivers/postgres/postgres-sql-serializer.js.map +0 -1
- package/esm/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
- package/esm/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
- package/esm/drivers/postgres/postgres-sync-adapter.js +0 -204
- package/esm/drivers/postgres/postgres-sync-adapter.js.map +0 -1
- package/esm/drivers/postgres/types.d.ts +0 -144
- package/esm/drivers/postgres/types.d.ts.map +0 -1
- package/esm/drivers/sql/index.d.ts +0 -10
- package/esm/drivers/sql/index.d.ts.map +0 -1
- package/esm/drivers/sql/sql-dialect.contract.d.ts +0 -204
- package/esm/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
- package/esm/drivers/sql/sql-types.d.ts +0 -202
- package/esm/drivers/sql/sql-types.d.ts.map +0 -1
- package/esm/errors/missing-data-source.error.d.ts +0 -22
- package/esm/errors/missing-data-source.error.d.ts.map +0 -1
- package/esm/errors/missing-data-source.error.js +0 -29
- package/esm/errors/missing-data-source.error.js.map +0 -1
- package/esm/errors/transaction-rollback.error.d.ts +0 -20
- package/esm/errors/transaction-rollback.error.d.ts.map +0 -1
- package/esm/errors/transaction-rollback.error.js +0 -27
- package/esm/errors/transaction-rollback.error.js.map +0 -1
- package/esm/events/model-events.d.ts +0 -231
- package/esm/events/model-events.d.ts.map +0 -1
- package/esm/events/model-events.js +0 -259
- package/esm/events/model-events.js.map +0 -1
- package/esm/expressions/aggregate-expressions.d.ts +0 -215
- package/esm/expressions/aggregate-expressions.d.ts.map +0 -1
- package/esm/expressions/aggregate-expressions.js +0 -221
- package/esm/expressions/aggregate-expressions.js.map +0 -1
- package/esm/expressions/index.d.ts +0 -2
- package/esm/expressions/index.d.ts.map +0 -1
- package/esm/index.d.ts +0 -45
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +0 -1
- package/esm/migration/column-builder.d.ts +0 -417
- package/esm/migration/column-builder.d.ts.map +0 -1
- package/esm/migration/column-builder.js +0 -586
- package/esm/migration/column-builder.js.map +0 -1
- package/esm/migration/column-helpers.d.ts +0 -275
- package/esm/migration/column-helpers.d.ts.map +0 -1
- package/esm/migration/column-helpers.js +0 -389
- package/esm/migration/column-helpers.js.map +0 -1
- package/esm/migration/foreign-key-builder.d.ts +0 -103
- package/esm/migration/foreign-key-builder.d.ts.map +0 -1
- package/esm/migration/foreign-key-builder.js +0 -121
- package/esm/migration/foreign-key-builder.js.map +0 -1
- package/esm/migration/index.d.ts +0 -7
- package/esm/migration/index.d.ts.map +0 -1
- package/esm/migration/migration-runner.d.ts +0 -278
- package/esm/migration/migration-runner.d.ts.map +0 -1
- package/esm/migration/migration-runner.js +0 -815
- package/esm/migration/migration-runner.js.map +0 -1
- package/esm/migration/migration.d.ts +0 -1988
- package/esm/migration/migration.d.ts.map +0 -1
- package/esm/migration/migration.js +0 -2162
- package/esm/migration/migration.js.map +0 -1
- package/esm/migration/sql-grammar.d.ts +0 -61
- package/esm/migration/sql-grammar.d.ts.map +0 -1
- package/esm/migration/sql-grammar.js +0 -164
- package/esm/migration/sql-grammar.js.map +0 -1
- package/esm/migration/sql-serializer.d.ts +0 -22
- package/esm/migration/sql-serializer.d.ts.map +0 -1
- package/esm/migration/sql-serializer.js +0 -26
- package/esm/migration/sql-serializer.js.map +0 -1
- package/esm/migration/types.d.ts +0 -155
- package/esm/migration/types.d.ts.map +0 -1
- package/esm/model/methods/accessor-methods.d.ts +0 -13
- package/esm/model/methods/accessor-methods.d.ts.map +0 -1
- package/esm/model/methods/accessor-methods.js +0 -51
- package/esm/model/methods/accessor-methods.js.map +0 -1
- package/esm/model/methods/delete-methods.d.ts +0 -10
- package/esm/model/methods/delete-methods.d.ts.map +0 -1
- package/esm/model/methods/delete-methods.js +0 -10
- package/esm/model/methods/delete-methods.js.map +0 -1
- package/esm/model/methods/dirty-methods.d.ts +0 -10
- package/esm/model/methods/dirty-methods.d.ts.map +0 -1
- package/esm/model/methods/dirty-methods.js +0 -15
- package/esm/model/methods/dirty-methods.js.map +0 -1
- package/esm/model/methods/hydration-methods.d.ts +0 -10
- package/esm/model/methods/hydration-methods.d.ts.map +0 -1
- package/esm/model/methods/hydration-methods.js +0 -57
- package/esm/model/methods/hydration-methods.js.map +0 -1
- package/esm/model/methods/instance-event-methods.d.ts +0 -7
- package/esm/model/methods/instance-event-methods.d.ts.map +0 -1
- package/esm/model/methods/instance-event-methods.js +0 -15
- package/esm/model/methods/instance-event-methods.js.map +0 -1
- package/esm/model/methods/meta-methods.d.ts +0 -7
- package/esm/model/methods/meta-methods.d.ts.map +0 -1
- package/esm/model/methods/meta-methods.js +0 -78
- package/esm/model/methods/meta-methods.js.map +0 -1
- package/esm/model/methods/query-methods.d.ts +0 -24
- package/esm/model/methods/query-methods.d.ts.map +0 -1
- package/esm/model/methods/query-methods.js +0 -164
- package/esm/model/methods/query-methods.js.map +0 -1
- package/esm/model/methods/restore-methods.d.ts +0 -10
- package/esm/model/methods/restore-methods.d.ts.map +0 -1
- package/esm/model/methods/restore-methods.js +0 -13
- package/esm/model/methods/restore-methods.js.map +0 -1
- package/esm/model/methods/scope-methods.d.ts +0 -7
- package/esm/model/methods/scope-methods.d.ts.map +0 -1
- package/esm/model/methods/scope-methods.js +0 -15
- package/esm/model/methods/scope-methods.js.map +0 -1
- package/esm/model/methods/serialization-methods.d.ts +0 -3
- package/esm/model/methods/serialization-methods.d.ts.map +0 -1
- package/esm/model/methods/serialization-methods.js +0 -27
- package/esm/model/methods/serialization-methods.js.map +0 -1
- package/esm/model/methods/static-event-methods.d.ts +0 -9
- package/esm/model/methods/static-event-methods.d.ts.map +0 -1
- package/esm/model/methods/static-event-methods.js +0 -29
- package/esm/model/methods/static-event-methods.js.map +0 -1
- package/esm/model/methods/write-methods.d.ts +0 -10
- package/esm/model/methods/write-methods.d.ts.map +0 -1
- package/esm/model/methods/write-methods.js +0 -52
- package/esm/model/methods/write-methods.js.map +0 -1
- package/esm/model/model.d.ts +0 -1647
- package/esm/model/model.d.ts.map +0 -1
- package/esm/model/model.js +0 -1657
- package/esm/model/model.js.map +0 -1
- package/esm/model/model.types.d.ts +0 -44
- package/esm/model/model.types.d.ts.map +0 -1
- package/esm/model/register-model.d.ts +0 -81
- package/esm/model/register-model.d.ts.map +0 -1
- package/esm/model/register-model.js +0 -94
- package/esm/model/register-model.js.map +0 -1
- package/esm/query-builder/query-builder.d.ts +0 -556
- package/esm/query-builder/query-builder.d.ts.map +0 -1
- package/esm/query-builder/query-builder.js +0 -1070
- package/esm/query-builder/query-builder.js.map +0 -1
- package/esm/relations/helpers.d.ts +0 -156
- package/esm/relations/helpers.d.ts.map +0 -1
- package/esm/relations/helpers.js +0 -202
- package/esm/relations/helpers.js.map +0 -1
- package/esm/relations/index.d.ts +0 -35
- package/esm/relations/index.d.ts.map +0 -1
- package/esm/relations/pivot-operations.d.ts +0 -160
- package/esm/relations/pivot-operations.d.ts.map +0 -1
- package/esm/relations/pivot-operations.js +0 -293
- package/esm/relations/pivot-operations.js.map +0 -1
- package/esm/relations/relation-hydrator.d.ts +0 -68
- package/esm/relations/relation-hydrator.d.ts.map +0 -1
- package/esm/relations/relation-hydrator.js +0 -81
- package/esm/relations/relation-hydrator.js.map +0 -1
- package/esm/relations/relation-loader.d.ts +0 -194
- package/esm/relations/relation-loader.d.ts.map +0 -1
- package/esm/relations/relation-loader.js +0 -466
- package/esm/relations/relation-loader.js.map +0 -1
- package/esm/relations/types.d.ts +0 -306
- package/esm/relations/types.d.ts.map +0 -1
- package/esm/remover/database-remover.d.ts +0 -100
- package/esm/remover/database-remover.d.ts.map +0 -1
- package/esm/remover/database-remover.js +0 -214
- package/esm/remover/database-remover.js.map +0 -1
- package/esm/restorer/database-restorer.d.ts +0 -131
- package/esm/restorer/database-restorer.d.ts.map +0 -1
- package/esm/restorer/database-restorer.js +0 -434
- package/esm/restorer/database-restorer.js.map +0 -1
- package/esm/sql-database-dirty-tracker.d.ts +0 -13
- package/esm/sql-database-dirty-tracker.d.ts.map +0 -1
- package/esm/sql-database-dirty-tracker.js +0 -14
- package/esm/sql-database-dirty-tracker.js.map +0 -1
- package/esm/sync/index.d.ts +0 -12
- package/esm/sync/index.d.ts.map +0 -1
- package/esm/sync/model-events.d.ts +0 -62
- package/esm/sync/model-events.d.ts.map +0 -1
- package/esm/sync/model-events.js +0 -49
- package/esm/sync/model-events.js.map +0 -1
- package/esm/sync/model-sync-operation.d.ts +0 -163
- package/esm/sync/model-sync-operation.d.ts.map +0 -1
- package/esm/sync/model-sync-operation.js +0 -292
- package/esm/sync/model-sync-operation.js.map +0 -1
- package/esm/sync/model-sync.d.ts +0 -130
- package/esm/sync/model-sync.d.ts.map +0 -1
- package/esm/sync/model-sync.js +0 -178
- package/esm/sync/model-sync.js.map +0 -1
- package/esm/sync/sync-context.d.ts +0 -70
- package/esm/sync/sync-context.d.ts.map +0 -1
- package/esm/sync/sync-context.js +0 -101
- package/esm/sync/sync-context.js.map +0 -1
- package/esm/sync/sync-manager.d.ts +0 -213
- package/esm/sync/sync-manager.d.ts.map +0 -1
- package/esm/sync/sync-manager.js +0 -689
- package/esm/sync/sync-manager.js.map +0 -1
- package/esm/sync/types.d.ts +0 -289
- package/esm/sync/types.d.ts.map +0 -1
- package/esm/test-migrations/test-enhanced-features.migration.d.ts +0 -15
- package/esm/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
- package/esm/types.d.ts +0 -371
- package/esm/types.d.ts.map +0 -1
- package/esm/utils/connect-to-database.d.ts +0 -307
- package/esm/utils/connect-to-database.d.ts.map +0 -1
- package/esm/utils/connect-to-database.js +0 -130
- package/esm/utils/connect-to-database.js.map +0 -1
- package/esm/utils/database-writer.utils.d.ts +0 -15
- package/esm/utils/database-writer.utils.d.ts.map +0 -1
- package/esm/utils/database-writer.utils.js +0 -14
- package/esm/utils/database-writer.utils.js.map +0 -1
- package/esm/utils/define-model.js +0 -100
- package/esm/utils/define-model.js.map +0 -1
- package/esm/utils/is-valid-date-value.d.ts +0 -5
- package/esm/utils/is-valid-date-value.d.ts.map +0 -1
- package/esm/utils/is-valid-date-value.js +0 -25
- package/esm/utils/is-valid-date-value.js.map +0 -1
- package/esm/utils/once-connected.d.ts +0 -146
- package/esm/utils/once-connected.d.ts.map +0 -1
- package/esm/utils/once-connected.js +0 -251
- package/esm/utils/once-connected.js.map +0 -1
- package/esm/validation/database-seal-plugins.d.ts +0 -12
- package/esm/validation/database-seal-plugins.d.ts.map +0 -1
- package/esm/validation/database-seal-plugins.js +0 -1
- package/esm/validation/database-seal-plugins.js.map +0 -1
- package/esm/validation/database-writer-validation-error.d.ts +0 -97
- package/esm/validation/database-writer-validation-error.d.ts.map +0 -1
- package/esm/validation/database-writer-validation-error.js +0 -160
- package/esm/validation/database-writer-validation-error.js.map +0 -1
- package/esm/validation/index.d.ts +0 -3
- package/esm/validation/index.d.ts.map +0 -1
- package/esm/validation/mutators/embed-mutator.d.ts +0 -9
- package/esm/validation/mutators/embed-mutator.d.ts.map +0 -1
- package/esm/validation/mutators/embed-mutator.js +0 -33
- package/esm/validation/mutators/embed-mutator.js.map +0 -1
- package/esm/validation/plugins/embed-validator-plugin.d.ts +0 -24
- package/esm/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
- package/esm/validation/plugins/embed-validator-plugin.js +0 -18
- package/esm/validation/plugins/embed-validator-plugin.js.map +0 -1
- package/esm/validation/rules/database-model-rule.d.ts +0 -7
- package/esm/validation/rules/database-model-rule.d.ts.map +0 -1
- package/esm/validation/rules/database-model-rule.js +0 -27
- package/esm/validation/rules/database-model-rule.js.map +0 -1
- package/esm/validation/transformers/embed-model-transformer.d.ts +0 -3
- package/esm/validation/transformers/embed-model-transformer.d.ts.map +0 -1
- package/esm/validation/transformers/embed-model-transformer.js +0 -18
- package/esm/validation/transformers/embed-model-transformer.js.map +0 -1
- package/esm/validation/validators/embed-validator.d.ts +0 -21
- package/esm/validation/validators/embed-validator.d.ts.map +0 -1
- package/esm/validation/validators/embed-validator.js +0 -43
- package/esm/validation/validators/embed-validator.js.map +0 -1
- package/esm/writer/database-writer.d.ts +0 -174
- package/esm/writer/database-writer.d.ts.map +0 -1
- package/esm/writer/database-writer.js +0 -400
- package/esm/writer/database-writer.js.map +0 -1
|
@@ -1,868 +0,0 @@
|
|
|
1
|
-
'use strict';var postgresDialect=require('./postgres-dialect.js');/**
|
|
2
|
-
* PostgreSQL Query Parser
|
|
3
|
-
*
|
|
4
|
-
* Translates Cascade query operations into PostgreSQL SQL queries.
|
|
5
|
-
* Mirrors the MongoQueryParser pattern but generates SQL instead
|
|
6
|
-
* of MongoDB aggregation pipelines.
|
|
7
|
-
*
|
|
8
|
-
* @module cascade/drivers/postgres
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* PostgreSQL Query Parser.
|
|
12
|
-
*
|
|
13
|
-
* Converts a list of query operations into a SQL query string with parameters.
|
|
14
|
-
* Handles SELECT, WHERE, JOIN, ORDER BY, GROUP BY, LIMIT/OFFSET clauses.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const parser = new PostgresQueryParser({
|
|
19
|
-
* table: 'users',
|
|
20
|
-
* operations: [
|
|
21
|
-
* { type: 'where', data: { field: 'name', operator: '=', value: 'Alice' } },
|
|
22
|
-
* { type: 'orderBy', data: { field: 'createdAt', direction: 'desc' } },
|
|
23
|
-
* { type: 'limit', data: { value: 10 } }
|
|
24
|
-
* ]
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* const { sql, params } = parser.parse();
|
|
28
|
-
* // sql: 'SELECT * FROM "users" WHERE "name" = $1 ORDER BY "createdAt" DESC LIMIT 10'
|
|
29
|
-
* // params: ['Alice']
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
class PostgresQueryParser {
|
|
33
|
-
/**
|
|
34
|
-
* Target table name.
|
|
35
|
-
*/
|
|
36
|
-
table;
|
|
37
|
-
/**
|
|
38
|
-
* Table alias.
|
|
39
|
-
*/
|
|
40
|
-
alias;
|
|
41
|
-
/**
|
|
42
|
-
* Operations to process.
|
|
43
|
-
*/
|
|
44
|
-
operations;
|
|
45
|
-
/**
|
|
46
|
-
* SQL dialect for syntax.
|
|
47
|
-
*/
|
|
48
|
-
dialect;
|
|
49
|
-
/**
|
|
50
|
-
* Current parameter index (1-based for PostgreSQL).
|
|
51
|
-
*/
|
|
52
|
-
paramIndex = 1;
|
|
53
|
-
/**
|
|
54
|
-
* Collected parameters.
|
|
55
|
-
*/
|
|
56
|
-
params = [];
|
|
57
|
-
/**
|
|
58
|
-
* SELECT columns.
|
|
59
|
-
*/
|
|
60
|
-
selectColumns = [];
|
|
61
|
-
/**
|
|
62
|
-
* Deselected (excluded) columns.
|
|
63
|
-
*/
|
|
64
|
-
deselectColumns = [];
|
|
65
|
-
/**
|
|
66
|
-
* Raw SELECT expressions.
|
|
67
|
-
*/
|
|
68
|
-
selectRaw = [];
|
|
69
|
-
/**
|
|
70
|
-
* WHERE clauses.
|
|
71
|
-
*/
|
|
72
|
-
whereClauses = [];
|
|
73
|
-
/**
|
|
74
|
-
* JOIN clauses.
|
|
75
|
-
*/
|
|
76
|
-
joinClauses = [];
|
|
77
|
-
/**
|
|
78
|
-
* ORDER BY clauses.
|
|
79
|
-
*/
|
|
80
|
-
orderClauses = [];
|
|
81
|
-
/**
|
|
82
|
-
* GROUP BY columns.
|
|
83
|
-
*/
|
|
84
|
-
groupColumns = [];
|
|
85
|
-
/**
|
|
86
|
-
* HAVING clauses.
|
|
87
|
-
*/
|
|
88
|
-
havingClauses = [];
|
|
89
|
-
/**
|
|
90
|
-
* LIMIT value.
|
|
91
|
-
*/
|
|
92
|
-
limitValue;
|
|
93
|
-
/**
|
|
94
|
-
* OFFSET value.
|
|
95
|
-
*/
|
|
96
|
-
offsetValue;
|
|
97
|
-
/**
|
|
98
|
-
* DISTINCT flag.
|
|
99
|
-
*/
|
|
100
|
-
isDistinct = false;
|
|
101
|
-
/**
|
|
102
|
-
* Whether the query has any JOIN operations (pre-scanned before processing).
|
|
103
|
-
* Used by qualifyColumn() to decide whether to prefix columns with the main table.
|
|
104
|
-
*/
|
|
105
|
-
hasJoins = false;
|
|
106
|
-
/**
|
|
107
|
-
* Tracked joined tables (for table reference detection).
|
|
108
|
-
*/
|
|
109
|
-
joinedTables = new Set();
|
|
110
|
-
/**
|
|
111
|
-
* Create a new query parser.
|
|
112
|
-
*
|
|
113
|
-
* @param options - Parser configuration
|
|
114
|
-
*/
|
|
115
|
-
constructor(options) {
|
|
116
|
-
this.table = options.table;
|
|
117
|
-
this.alias = options.alias;
|
|
118
|
-
this.operations = options.operations;
|
|
119
|
-
this.dialect = options.dialect ?? new postgresDialect.PostgresDialect();
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Parse all operations and build the SQL query.
|
|
123
|
-
*
|
|
124
|
-
* @returns DriverQuery with `query` (SQL string) and `bindings` (parameter values)
|
|
125
|
-
*/
|
|
126
|
-
parse() {
|
|
127
|
-
// Pre-scan for any join operations so qualifyColumn() can prefix columns
|
|
128
|
-
// correctly even when WHERE clauses appear before JOINs in the operations list.
|
|
129
|
-
const JOIN_TYPES = new Set([
|
|
130
|
-
"join",
|
|
131
|
-
"leftJoin",
|
|
132
|
-
"rightJoin",
|
|
133
|
-
"innerJoin",
|
|
134
|
-
"fullJoin",
|
|
135
|
-
"crossJoin",
|
|
136
|
-
"joinRaw",
|
|
137
|
-
]);
|
|
138
|
-
this.hasJoins = false;
|
|
139
|
-
// First pass: locate all joins and populate joinedTables for accurate JSON path detection
|
|
140
|
-
for (const operation of this.operations) {
|
|
141
|
-
if (JOIN_TYPES.has(operation.type)) {
|
|
142
|
-
this.hasJoins = true;
|
|
143
|
-
const data = operation.data;
|
|
144
|
-
const joinTable = data.table;
|
|
145
|
-
const alias = data.alias;
|
|
146
|
-
if (joinTable)
|
|
147
|
-
this.joinedTables.add(joinTable);
|
|
148
|
-
if (alias)
|
|
149
|
-
this.joinedTables.add(alias);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// Process each operation
|
|
153
|
-
for (const operation of this.operations) {
|
|
154
|
-
this.processOperation(operation);
|
|
155
|
-
}
|
|
156
|
-
// Build the final SQL query
|
|
157
|
-
const query = this.buildSql();
|
|
158
|
-
return { query, bindings: this.params };
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Get a formatted string representation of the query.
|
|
162
|
-
*
|
|
163
|
-
* @returns Formatted SQL with bindings
|
|
164
|
-
*/
|
|
165
|
-
toPrettyString() {
|
|
166
|
-
const { query = "", bindings } = this.parse();
|
|
167
|
-
return `${query}\n-- Bindings: ${JSON.stringify(bindings ?? [])}`;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Process a single operation.
|
|
171
|
-
*
|
|
172
|
-
* @param operation - The operation to process
|
|
173
|
-
*/
|
|
174
|
-
processOperation(operation) {
|
|
175
|
-
const { type, data } = operation;
|
|
176
|
-
switch (type) {
|
|
177
|
-
// WHERE operations
|
|
178
|
-
case "where":
|
|
179
|
-
this.processWhere(data, "AND");
|
|
180
|
-
break;
|
|
181
|
-
case "orWhere":
|
|
182
|
-
this.processWhere(data, "OR");
|
|
183
|
-
break;
|
|
184
|
-
case "whereRaw":
|
|
185
|
-
this.processWhereRaw(data, "AND");
|
|
186
|
-
break;
|
|
187
|
-
case "orWhereRaw":
|
|
188
|
-
this.processWhereRaw(data, "OR");
|
|
189
|
-
break;
|
|
190
|
-
case "whereIn":
|
|
191
|
-
this.processWhereIn(data, false);
|
|
192
|
-
break;
|
|
193
|
-
case "whereNotIn":
|
|
194
|
-
this.processWhereIn(data, true);
|
|
195
|
-
break;
|
|
196
|
-
case "whereNull":
|
|
197
|
-
this.processWhereNull(data, false);
|
|
198
|
-
break;
|
|
199
|
-
case "whereNotNull":
|
|
200
|
-
this.processWhereNull(data, true);
|
|
201
|
-
break;
|
|
202
|
-
case "whereBetween":
|
|
203
|
-
this.processWhereBetween(data, false);
|
|
204
|
-
break;
|
|
205
|
-
case "whereNotBetween":
|
|
206
|
-
this.processWhereBetween(data, true);
|
|
207
|
-
break;
|
|
208
|
-
case "whereLike":
|
|
209
|
-
this.processWhereLike(data, false);
|
|
210
|
-
break;
|
|
211
|
-
case "whereNotLike":
|
|
212
|
-
this.processWhereLike(data, true);
|
|
213
|
-
break;
|
|
214
|
-
case "whereColumn":
|
|
215
|
-
this.processWhereColumn(data, "AND");
|
|
216
|
-
break;
|
|
217
|
-
case "orWhereColumn":
|
|
218
|
-
this.processWhereColumn(data, "OR");
|
|
219
|
-
break;
|
|
220
|
-
case "whereJsonContains":
|
|
221
|
-
this.processWhereJsonContains(data, false);
|
|
222
|
-
break;
|
|
223
|
-
case "whereJsonDoesntContain":
|
|
224
|
-
this.processWhereJsonContains(data, true);
|
|
225
|
-
break;
|
|
226
|
-
case "whereFullText":
|
|
227
|
-
this.processWhereFullText(data);
|
|
228
|
-
break;
|
|
229
|
-
// SELECT operations
|
|
230
|
-
case "select":
|
|
231
|
-
this.processSelect(data);
|
|
232
|
-
break;
|
|
233
|
-
case "selectRaw":
|
|
234
|
-
this.processSelectRaw(data);
|
|
235
|
-
break;
|
|
236
|
-
case "deselect":
|
|
237
|
-
this.processDeselect(data);
|
|
238
|
-
break;
|
|
239
|
-
// JOIN operations
|
|
240
|
-
case "join":
|
|
241
|
-
case "innerJoin":
|
|
242
|
-
this.processJoin(data, "INNER");
|
|
243
|
-
break;
|
|
244
|
-
case "leftJoin":
|
|
245
|
-
this.processJoin(data, "LEFT");
|
|
246
|
-
break;
|
|
247
|
-
case "rightJoin":
|
|
248
|
-
this.processJoin(data, "RIGHT");
|
|
249
|
-
break;
|
|
250
|
-
case "fullJoin":
|
|
251
|
-
this.processJoin(data, "FULL OUTER");
|
|
252
|
-
break;
|
|
253
|
-
case "crossJoin":
|
|
254
|
-
this.processCrossJoin(data);
|
|
255
|
-
break;
|
|
256
|
-
case "joinRaw":
|
|
257
|
-
this.processJoinRaw(data);
|
|
258
|
-
break;
|
|
259
|
-
// ORDER operations
|
|
260
|
-
case "orderBy":
|
|
261
|
-
this.processOrderBy(data);
|
|
262
|
-
break;
|
|
263
|
-
case "orderByRaw":
|
|
264
|
-
this.processOrderByRaw(data);
|
|
265
|
-
break;
|
|
266
|
-
// GROUP operations
|
|
267
|
-
case "groupBy":
|
|
268
|
-
this.processGroupBy(data);
|
|
269
|
-
break;
|
|
270
|
-
case "having":
|
|
271
|
-
this.processHaving(data);
|
|
272
|
-
break;
|
|
273
|
-
case "havingRaw":
|
|
274
|
-
this.processHavingRaw(data);
|
|
275
|
-
break;
|
|
276
|
-
// LIMIT operations
|
|
277
|
-
case "limit":
|
|
278
|
-
this.limitValue = data.value;
|
|
279
|
-
break;
|
|
280
|
-
case "offset":
|
|
281
|
-
this.offsetValue = data.value;
|
|
282
|
-
break;
|
|
283
|
-
// Other
|
|
284
|
-
case "distinct":
|
|
285
|
-
this.isDistinct = true;
|
|
286
|
-
break;
|
|
287
|
-
// joinWith select related columns
|
|
288
|
-
case "selectRelatedColumns":
|
|
289
|
-
this.processSelectRelatedColumns(data);
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Build the final SQL query from collected clauses.
|
|
295
|
-
*
|
|
296
|
-
* @returns Complete SQL query string
|
|
297
|
-
*/
|
|
298
|
-
buildSql() {
|
|
299
|
-
const parts = [];
|
|
300
|
-
// SELECT clause
|
|
301
|
-
parts.push(this.buildSelectClause());
|
|
302
|
-
// FROM clause
|
|
303
|
-
const quotedTable = this.dialect.quoteIdentifier(this.table);
|
|
304
|
-
const fromClause = this.alias
|
|
305
|
-
? `FROM ${quotedTable} AS ${this.dialect.quoteIdentifier(this.alias)}`
|
|
306
|
-
: `FROM ${quotedTable}`;
|
|
307
|
-
parts.push(fromClause);
|
|
308
|
-
// JOIN clauses
|
|
309
|
-
if (this.joinClauses.length > 0) {
|
|
310
|
-
parts.push(this.joinClauses.join(" "));
|
|
311
|
-
}
|
|
312
|
-
// WHERE clause
|
|
313
|
-
if (this.whereClauses.length > 0) {
|
|
314
|
-
parts.push(`WHERE ${this.whereClauses.join(" ")}`);
|
|
315
|
-
}
|
|
316
|
-
// GROUP BY clause
|
|
317
|
-
if (this.groupColumns.length > 0) {
|
|
318
|
-
const quotedCols = this.groupColumns.map((c) => this.dialect.quoteIdentifier(c));
|
|
319
|
-
parts.push(`GROUP BY ${quotedCols.join(", ")}`);
|
|
320
|
-
}
|
|
321
|
-
// HAVING clause
|
|
322
|
-
if (this.havingClauses.length > 0) {
|
|
323
|
-
parts.push(`HAVING ${this.havingClauses.join(" AND ")}`);
|
|
324
|
-
}
|
|
325
|
-
// ORDER BY clause
|
|
326
|
-
if (this.orderClauses.length > 0) {
|
|
327
|
-
parts.push(`ORDER BY ${this.orderClauses.join(", ")}`);
|
|
328
|
-
}
|
|
329
|
-
// LIMIT/OFFSET
|
|
330
|
-
const limitOffset = this.dialect.limitOffset(this.limitValue, this.offsetValue);
|
|
331
|
-
if (limitOffset) {
|
|
332
|
-
parts.push(limitOffset);
|
|
333
|
-
}
|
|
334
|
-
return parts.join(" ");
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Build the SELECT clause.
|
|
338
|
-
*
|
|
339
|
-
* @returns SELECT clause string
|
|
340
|
-
*/
|
|
341
|
-
buildSelectClause() {
|
|
342
|
-
const distinct = this.isDistinct ? "DISTINCT " : "";
|
|
343
|
-
// If no specific columns, select all — qualify with main table when joins present
|
|
344
|
-
if (this.selectColumns.length === 0 && this.selectRaw.length === 0) {
|
|
345
|
-
return this.hasJoins
|
|
346
|
-
? `SELECT ${distinct}${this.dialect.quoteIdentifier(this.table)}.*`
|
|
347
|
-
: `SELECT ${distinct}*`;
|
|
348
|
-
}
|
|
349
|
-
const columns = [];
|
|
350
|
-
// Add selected columns — prefix with main table when joins present to avoid ambiguity
|
|
351
|
-
for (const col of this.selectColumns) {
|
|
352
|
-
if (!this.deselectColumns.includes(col)) {
|
|
353
|
-
columns.push(this.parseColumnIdentifier(col, this.table, this.alias));
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
// Add raw expressions
|
|
357
|
-
columns.push(...this.selectRaw);
|
|
358
|
-
return `SELECT ${distinct}${columns.join(", ")}`;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Add a placeholder and parameter.
|
|
362
|
-
*
|
|
363
|
-
* @param value - Parameter value
|
|
364
|
-
* @returns Placeholder string ($1, $2, etc.)
|
|
365
|
-
*/
|
|
366
|
-
addParam(value) {
|
|
367
|
-
this.params.push(value);
|
|
368
|
-
return this.dialect.placeholder(this.paramIndex++);
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Process a basic WHERE operation.
|
|
372
|
-
*
|
|
373
|
-
* Delegates to specialised processors for operators that require more than a
|
|
374
|
-
* single placeholder (between, in, like-variants, exists, etc.).
|
|
375
|
-
*/
|
|
376
|
-
processWhere(data, boolean) {
|
|
377
|
-
const field = data.field;
|
|
378
|
-
const operator = data.operator ?? "=";
|
|
379
|
-
const value = data.value;
|
|
380
|
-
// Delegate to specialised processors for operators that need it
|
|
381
|
-
switch (operator) {
|
|
382
|
-
case "between":
|
|
383
|
-
return this.processWhereBetween({ field, range: value }, false);
|
|
384
|
-
case "notBetween":
|
|
385
|
-
return this.processWhereBetween({ field, range: value }, true);
|
|
386
|
-
case "in":
|
|
387
|
-
return this.processWhereIn({ field, values: value }, false);
|
|
388
|
-
case "notIn":
|
|
389
|
-
return this.processWhereIn({ field, values: value }, true);
|
|
390
|
-
case "like":
|
|
391
|
-
case "ilike":
|
|
392
|
-
case "startsWith":
|
|
393
|
-
case "endsWith":
|
|
394
|
-
return this.processWhereLike({ field, pattern: value }, false);
|
|
395
|
-
case "notLike":
|
|
396
|
-
case "notStartsWith":
|
|
397
|
-
case "notEndsWith":
|
|
398
|
-
return this.processWhereLike({ field, pattern: value }, true);
|
|
399
|
-
case "exists":
|
|
400
|
-
// EXISTS expects value to be a raw sub-query string
|
|
401
|
-
return this.addWhereClause(`EXISTS (${value})`, boolean);
|
|
402
|
-
}
|
|
403
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
404
|
-
if (value === null) {
|
|
405
|
-
const nullOperator = operator === "!=" ? "IS NOT NULL" : "IS NULL";
|
|
406
|
-
return this.addWhereClause(`${quotedField} ${nullOperator}`, boolean);
|
|
407
|
-
}
|
|
408
|
-
// Simple single-value operator — fall through to generic path
|
|
409
|
-
const placeholder = this.addParam(value);
|
|
410
|
-
this.addWhereClause(`${quotedField} ${this.mapOperator(operator)} ${placeholder}`, boolean);
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Process a raw WHERE operation.
|
|
414
|
-
*/
|
|
415
|
-
processWhereRaw(data, boolean) {
|
|
416
|
-
const expression = data.expression;
|
|
417
|
-
const bindings = data.bindings ?? [];
|
|
418
|
-
// Replace ? placeholders with $n
|
|
419
|
-
let processed = expression;
|
|
420
|
-
for (const binding of bindings) {
|
|
421
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
422
|
-
}
|
|
423
|
-
this.addWhereClause(processed, boolean);
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Process WHERE IN / NOT IN.
|
|
427
|
-
*/
|
|
428
|
-
processWhereIn(data, negate) {
|
|
429
|
-
const field = data.field;
|
|
430
|
-
const values = data.values;
|
|
431
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
432
|
-
const operator = negate ? "!= ALL" : "= ANY";
|
|
433
|
-
const placeholder = this.addParam(values);
|
|
434
|
-
this.addWhereClause(`${quotedField} ${operator}(${placeholder})`, "AND");
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Process WHERE NULL / NOT NULL.
|
|
438
|
-
*/
|
|
439
|
-
processWhereNull(data, negate) {
|
|
440
|
-
const field = data.field;
|
|
441
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
442
|
-
const clause = negate ? `${quotedField} IS NOT NULL` : `${quotedField} IS NULL`;
|
|
443
|
-
this.addWhereClause(clause, "AND");
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Process WHERE BETWEEN / NOT BETWEEN.
|
|
447
|
-
*/
|
|
448
|
-
processWhereBetween(data, negate) {
|
|
449
|
-
const field = data.field;
|
|
450
|
-
const range = data.range;
|
|
451
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
452
|
-
const placeholder1 = this.addParam(range[0]);
|
|
453
|
-
const placeholder2 = this.addParam(range[1]);
|
|
454
|
-
const keyword = negate ? "NOT BETWEEN" : "BETWEEN";
|
|
455
|
-
this.addWhereClause(`${quotedField} ${keyword} ${placeholder1} AND ${placeholder2}`, "AND");
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Process WHERE LIKE / NOT LIKE.
|
|
459
|
-
*/
|
|
460
|
-
processWhereLike(data, negate) {
|
|
461
|
-
const field = data.field;
|
|
462
|
-
const pattern = data.pattern;
|
|
463
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
464
|
-
const { operator } = this.dialect.likePattern(pattern, true);
|
|
465
|
-
const placeholder = this.addParam(pattern);
|
|
466
|
-
const keyword = negate ? `NOT ${operator}` : operator;
|
|
467
|
-
this.addWhereClause(`${quotedField} ${keyword} ${placeholder}`, "AND");
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* Process WHERE column comparison.
|
|
471
|
-
*/
|
|
472
|
-
processWhereColumn(data, boolean) {
|
|
473
|
-
const first = data.first;
|
|
474
|
-
const operator = data.operator ?? "=";
|
|
475
|
-
const second = data.second;
|
|
476
|
-
// Both sides may need qualification if unambiguous table is unclear
|
|
477
|
-
const quotedFirst = this.parseColumnIdentifier(first, this.table, this.alias);
|
|
478
|
-
const quotedSecond = this.parseColumnIdentifier(second, this.table, this.alias);
|
|
479
|
-
this.addWhereClause(`${quotedFirst} ${operator} ${quotedSecond}`, boolean);
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Process WHERE JSON contains.
|
|
483
|
-
*/
|
|
484
|
-
processWhereJsonContains(data, negate) {
|
|
485
|
-
const path = data.path;
|
|
486
|
-
const value = data.value;
|
|
487
|
-
const quotedPath = this.parseColumnIdentifier(path, this.table, this.alias);
|
|
488
|
-
const jsonValue = JSON.stringify(value);
|
|
489
|
-
const operator = negate ? "NOT @>" : "@>";
|
|
490
|
-
this.addWhereClause(`${quotedPath} ${operator} '${jsonValue}'::jsonb`, "AND");
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Process full-text search WHERE.
|
|
494
|
-
*/
|
|
495
|
-
processWhereFullText(data) {
|
|
496
|
-
const fields = data.fields;
|
|
497
|
-
const query = data.query;
|
|
498
|
-
// Build tsvector from fields
|
|
499
|
-
const tsVectors = fields
|
|
500
|
-
.map((f) => `to_tsvector('english', ${this.dialect.quoteIdentifier(f)})`)
|
|
501
|
-
.join(" || ");
|
|
502
|
-
const placeholder = this.addParam(query);
|
|
503
|
-
this.addWhereClause(`(${tsVectors}) @@ plainto_tsquery('english', ${placeholder})`, "AND");
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Process SELECT operation.
|
|
507
|
-
*/
|
|
508
|
-
processSelect(data) {
|
|
509
|
-
const fields = data.fields;
|
|
510
|
-
if (Array.isArray(fields)) {
|
|
511
|
-
this.selectColumns.push(...fields);
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
// Handle aliases: { field: 'alias' }
|
|
515
|
-
for (const [field, alias] of Object.entries(fields)) {
|
|
516
|
-
const quotedField = this.dialect.quoteIdentifier(field);
|
|
517
|
-
const quotedAlias = this.dialect.quoteIdentifier(alias);
|
|
518
|
-
this.selectRaw.push(`${quotedField} AS ${quotedAlias}`);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Process raw SELECT expression.
|
|
524
|
-
*/
|
|
525
|
-
processSelectRaw(data) {
|
|
526
|
-
const expression = data.expression;
|
|
527
|
-
const bindings = data.bindings ?? [];
|
|
528
|
-
if (typeof expression === "string") {
|
|
529
|
-
// Replace ? placeholders with $n positional params (same as processWhereRaw)
|
|
530
|
-
let processed = expression;
|
|
531
|
-
for (const binding of bindings) {
|
|
532
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
533
|
-
}
|
|
534
|
-
this.selectRaw.push(processed);
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
// Handle object expressions (for compatibility)
|
|
538
|
-
for (const [alias, expr] of Object.entries(expression)) {
|
|
539
|
-
this.selectRaw.push(`${expr} AS ${this.dialect.quoteIdentifier(alias)}`);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Process DESELECT operation.
|
|
545
|
-
*/
|
|
546
|
-
processDeselect(data) {
|
|
547
|
-
const fields = data.fields;
|
|
548
|
-
this.deselectColumns.push(...fields);
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* Process SELECT for related columns (joinWith).
|
|
552
|
-
*
|
|
553
|
-
* - hasOne / belongsTo → LEFT JOIN + row_to_json (single object)
|
|
554
|
-
* - hasMany → correlated subquery with json_agg (array, no row explosion)
|
|
555
|
-
*
|
|
556
|
-
* @example hasMany correlated subquery:
|
|
557
|
-
* (SELECT json_agg(row_to_json(a.*))
|
|
558
|
-
* FROM "chat_message_actions" a
|
|
559
|
-
* WHERE a."chat_message_id" = "chat_messages"."id") AS "actions"
|
|
560
|
-
*
|
|
561
|
-
* @example hasOne/belongsTo row_to_json:
|
|
562
|
-
* row_to_json("organizationAiModel".*) AS "organizationAiModel"
|
|
563
|
-
*/
|
|
564
|
-
processSelectRelatedColumns(data) {
|
|
565
|
-
const alias = data.alias;
|
|
566
|
-
const select = data.select;
|
|
567
|
-
const relationType = data.type;
|
|
568
|
-
const constraintOps = data.constraintOps;
|
|
569
|
-
const quotedAlias = this.dialect.quoteIdentifier(alias);
|
|
570
|
-
const quotedTable = this.dialect.quoteIdentifier(this.table);
|
|
571
|
-
const hasExplicitSelect = this.selectColumns.length > 0;
|
|
572
|
-
if (!hasExplicitSelect && !this.selectRaw.includes(`${quotedTable}.*`)) {
|
|
573
|
-
this.selectRaw.unshift(`${quotedTable}.*`);
|
|
574
|
-
}
|
|
575
|
-
if (relationType === "hasMany") {
|
|
576
|
-
// Correlated subquery — no JOIN, no row explosion, returns a JSON array.
|
|
577
|
-
const relatedTable = data.table;
|
|
578
|
-
const foreignKey = data.foreignKey;
|
|
579
|
-
const localKey = data.localKey;
|
|
580
|
-
const quotedRelatedTable = this.dialect.quoteIdentifier(relatedTable);
|
|
581
|
-
const quotedForeignKey = this.dialect.quoteIdentifier(foreignKey);
|
|
582
|
-
const quotedLocalKey = this.dialect.quoteIdentifier(localKey);
|
|
583
|
-
const quotedMainTable = this.dialect.quoteIdentifier(this.table);
|
|
584
|
-
let innerSelect;
|
|
585
|
-
if (select && select.length > 0) {
|
|
586
|
-
// Pick specific columns: json_agg(json_build_object('id', a."id", ...))
|
|
587
|
-
const fields = select
|
|
588
|
-
.map((col) => `'${col}', a.${this.dialect.quoteIdentifier(col)}`)
|
|
589
|
-
.join(", ");
|
|
590
|
-
innerSelect = `json_agg(json_build_object(${fields}))`;
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
innerSelect = `json_agg(row_to_json(a.*))`;
|
|
594
|
-
}
|
|
595
|
-
// Build the base FK condition
|
|
596
|
-
const fkCondition = `a.${quotedForeignKey} = ${quotedMainTable}.${quotedLocalKey}`;
|
|
597
|
-
// Merge constraint ops (where / order / limit) from a sub-parser
|
|
598
|
-
let extraWhere = "";
|
|
599
|
-
let orderBy = "";
|
|
600
|
-
let limitClause = "";
|
|
601
|
-
if (constraintOps && constraintOps.length > 0) {
|
|
602
|
-
const subParser = new PostgresQueryParser({
|
|
603
|
-
table: relatedTable,
|
|
604
|
-
alias: "a",
|
|
605
|
-
operations: constraintOps,
|
|
606
|
-
});
|
|
607
|
-
subParser.parse();
|
|
608
|
-
if (subParser.whereClauses.length > 0) {
|
|
609
|
-
extraWhere = ` AND ${subParser.whereClauses.join(" ")}`;
|
|
610
|
-
}
|
|
611
|
-
if (subParser.orderClauses.length > 0) {
|
|
612
|
-
orderBy = ` ORDER BY ${subParser.orderClauses.join(", ")}`;
|
|
613
|
-
}
|
|
614
|
-
if (subParser.limitValue !== undefined) {
|
|
615
|
-
limitClause = ` LIMIT ${subParser.limitValue}`;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
// Wrap with ORDER/LIMIT only when constraints are present (json_agg ignores ORDER)
|
|
619
|
-
orderBy || limitClause
|
|
620
|
-
? `SELECT row_to_json(sub.*) FROM (SELECT * FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}${orderBy}${limitClause}) sub`
|
|
621
|
-
: `SELECT ${innerSelect.replace("json_agg(", "").replace(/\)$/, "")} FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}`;
|
|
622
|
-
const aggregated = orderBy || limitClause
|
|
623
|
-
? `(SELECT json_agg(row_to_json(sub.*)) FROM (SELECT * FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}${orderBy}${limitClause}) sub) AS ${quotedAlias}`
|
|
624
|
-
: `(SELECT ${innerSelect} FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}) AS ${quotedAlias}`;
|
|
625
|
-
this.selectRaw.push(aggregated);
|
|
626
|
-
}
|
|
627
|
-
else {
|
|
628
|
-
// hasOne / belongsTo — single object via LEFT JOIN + row_to_json.
|
|
629
|
-
// If constraint provides an explicit select list, prefer it over data.select
|
|
630
|
-
let effectiveSelect = select;
|
|
631
|
-
if (constraintOps && constraintOps.length > 0) {
|
|
632
|
-
const subParser = new PostgresQueryParser({
|
|
633
|
-
table: data.table ?? alias,
|
|
634
|
-
alias,
|
|
635
|
-
operations: constraintOps,
|
|
636
|
-
});
|
|
637
|
-
subParser.parse();
|
|
638
|
-
if (subParser.selectColumns.length > 0) {
|
|
639
|
-
effectiveSelect = subParser.selectColumns;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (effectiveSelect && effectiveSelect.length > 0) {
|
|
643
|
-
const selectedColumns = effectiveSelect
|
|
644
|
-
.map((col) => `${quotedAlias}.${this.dialect.quoteIdentifier(col)}`)
|
|
645
|
-
.join(", ");
|
|
646
|
-
this.selectRaw.push(`row_to_json((SELECT d FROM (SELECT ${selectedColumns}) d)) AS ${quotedAlias}`);
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
this.selectRaw.push(`row_to_json(${quotedAlias}.*) AS ${quotedAlias}`);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Process JOIN operation with smart field detection.
|
|
655
|
-
*
|
|
656
|
-
* Handles both regular columns and JSONB nested paths:
|
|
657
|
-
* - "id" → "table"."id" (auto-prefixed)
|
|
658
|
-
* - "users.id" → "users"."id" (explicit table)
|
|
659
|
-
* - "createdBy.id" → "table"."createdBy"->>'id' (JSONB path)
|
|
660
|
-
* - "posts.createdBy.id" → "posts"."createdBy"->>'id' (JSONB with table)
|
|
661
|
-
*/
|
|
662
|
-
processJoin(data, type) {
|
|
663
|
-
const options = data;
|
|
664
|
-
const joinTable = "table" in options ? options.table : "";
|
|
665
|
-
const localField = "localField" in options ? options.localField : "";
|
|
666
|
-
const foreignField = "foreignField" in options ? options.foreignField : "";
|
|
667
|
-
const alias = "alias" in options ? options.alias : undefined;
|
|
668
|
-
const quotedTable = this.dialect.quoteIdentifier(joinTable);
|
|
669
|
-
const tableRef = alias
|
|
670
|
-
? `${quotedTable} AS ${this.dialect.quoteIdentifier(alias)}`
|
|
671
|
-
: quotedTable;
|
|
672
|
-
const tableAlias = alias ?? joinTable;
|
|
673
|
-
// Track the joined table for reference detection
|
|
674
|
-
this.joinedTables.add(joinTable);
|
|
675
|
-
if (alias) {
|
|
676
|
-
this.joinedTables.add(alias);
|
|
677
|
-
}
|
|
678
|
-
// Parse local field (belongs to main table)
|
|
679
|
-
const quotedLocal = this.parseColumnIdentifier(localField, this.table, this.alias);
|
|
680
|
-
// Parse foreign field (belongs to join table)
|
|
681
|
-
const quotedForeign = this.parseColumnIdentifier(foreignField, joinTable, tableAlias);
|
|
682
|
-
this.joinClauses.push(`${type} JOIN ${tableRef} ON ${quotedLocal} = ${quotedForeign}`);
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Parse a column identifier with smart detection for table prefixes and JSONB paths.
|
|
686
|
-
*
|
|
687
|
-
* @param field - The field string (e.g., "id", "users.id", "createdBy.id")
|
|
688
|
-
* @param defaultTable - Default table to use if no prefix
|
|
689
|
-
* @param tableAlias - Table alias to use if provided
|
|
690
|
-
* @returns Properly quoted SQL expression
|
|
691
|
-
*/
|
|
692
|
-
parseColumnIdentifier(field, defaultTable, tableAlias) {
|
|
693
|
-
if (!field)
|
|
694
|
-
return "";
|
|
695
|
-
const effectiveTable = tableAlias ?? defaultTable;
|
|
696
|
-
const parts = field.split(".");
|
|
697
|
-
// Single part: just a column name, prefix with default table
|
|
698
|
-
if (parts.length === 1) {
|
|
699
|
-
return `${this.dialect.quoteIdentifier(effectiveTable)}.${this.dialect.quoteIdentifier(field)}`;
|
|
700
|
-
}
|
|
701
|
-
// Two parts: could be "table.column" or "jsonbColumn.key"
|
|
702
|
-
if (parts.length === 2) {
|
|
703
|
-
const [first, second] = parts;
|
|
704
|
-
// Check if first part is a known table (main table, join table, or alias)
|
|
705
|
-
if (this.isTableReference(first)) {
|
|
706
|
-
// It's table.column - regular column reference
|
|
707
|
-
return `${this.dialect.quoteIdentifier(first)}.${this.dialect.quoteIdentifier(second)}`;
|
|
708
|
-
}
|
|
709
|
-
// It's jsonbColumn.key - JSONB path
|
|
710
|
-
return this.buildJsonbPath(effectiveTable, first, [second]);
|
|
711
|
-
}
|
|
712
|
-
// Three or more parts: "table.jsonbColumn.key..." or "jsonbColumn.key1.key2..."
|
|
713
|
-
const [first, second, ...rest] = parts;
|
|
714
|
-
if (this.isTableReference(first)) {
|
|
715
|
-
// First part is table: "posts.createdBy.id" → table is "posts", JSONB is "createdBy.id"
|
|
716
|
-
return this.buildJsonbPath(first, second, rest);
|
|
717
|
-
}
|
|
718
|
-
// No table prefix: "createdBy.address.city" → use default table
|
|
719
|
-
return this.buildJsonbPath(effectiveTable, first, [second, ...rest]);
|
|
720
|
-
}
|
|
721
|
-
/**
|
|
722
|
-
* Check if a string is a table reference (main table or join table).
|
|
723
|
-
*/
|
|
724
|
-
isTableReference(name) {
|
|
725
|
-
if (name === this.table || name === this.alias) {
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
if (this.joinedTables.has(name)) {
|
|
729
|
-
return true;
|
|
730
|
-
}
|
|
731
|
-
return false;
|
|
732
|
-
}
|
|
733
|
-
/**
|
|
734
|
-
* Build a JSONB path expression.
|
|
735
|
-
*
|
|
736
|
-
* @param table - Table name
|
|
737
|
-
* @param column - JSONB column name
|
|
738
|
-
* @param path - Array of nested keys
|
|
739
|
-
* @returns PostgreSQL JSONB path expression
|
|
740
|
-
*
|
|
741
|
-
* @example
|
|
742
|
-
* buildJsonbPath("posts", "createdBy", ["id"])
|
|
743
|
-
* // Returns: ("posts"."createdBy"->>'id')::integer
|
|
744
|
-
*
|
|
745
|
-
* buildJsonbPath("posts", "createdBy", ["address", "city"])
|
|
746
|
-
* // Returns: "posts"."createdBy"->'address'->>'city'
|
|
747
|
-
*/
|
|
748
|
-
buildJsonbPath(table, column, path) {
|
|
749
|
-
const quotedTable = this.dialect.quoteIdentifier(table);
|
|
750
|
-
const quotedColumn = this.dialect.quoteIdentifier(column);
|
|
751
|
-
if (path.length === 0) {
|
|
752
|
-
return `${quotedTable}.${quotedColumn}`;
|
|
753
|
-
}
|
|
754
|
-
// Build JSONB path: use -> for intermediate keys, ->> for final key (returns text)
|
|
755
|
-
let expression = `${quotedTable}.${quotedColumn}`;
|
|
756
|
-
for (let i = 0; i < path.length; i++) {
|
|
757
|
-
const isLast = i === path.length - 1;
|
|
758
|
-
const operator = isLast ? "->>" : "->";
|
|
759
|
-
expression += `${operator}'${path[i]}'`;
|
|
760
|
-
}
|
|
761
|
-
// Cast to integer if the path ends with 'id' (common pattern for foreign keys)
|
|
762
|
-
const lastKey = path[path.length - 1].toLowerCase();
|
|
763
|
-
if (lastKey === "id" || lastKey.endsWith("id")) {
|
|
764
|
-
expression = `(${expression})::integer`;
|
|
765
|
-
}
|
|
766
|
-
return expression;
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Process CROSS JOIN operation.
|
|
770
|
-
*/
|
|
771
|
-
processCrossJoin(data) {
|
|
772
|
-
const table = data.table;
|
|
773
|
-
const quotedTable = this.dialect.quoteIdentifier(table);
|
|
774
|
-
this.joinClauses.push(`CROSS JOIN ${quotedTable}`);
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* Process raw JOIN expression.
|
|
778
|
-
*/
|
|
779
|
-
processJoinRaw(data) {
|
|
780
|
-
const expression = data.expression;
|
|
781
|
-
const bindings = data.bindings ?? [];
|
|
782
|
-
let processed = expression;
|
|
783
|
-
for (const binding of bindings) {
|
|
784
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
785
|
-
}
|
|
786
|
-
this.joinClauses.push(processed);
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* Process ORDER BY operation.
|
|
790
|
-
*/
|
|
791
|
-
processOrderBy(data) {
|
|
792
|
-
const field = data.field;
|
|
793
|
-
const direction = (data.direction ?? "asc").toUpperCase();
|
|
794
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
795
|
-
this.orderClauses.push(`${quotedField} ${direction}`);
|
|
796
|
-
}
|
|
797
|
-
/**
|
|
798
|
-
* Process raw ORDER BY expression.
|
|
799
|
-
*/
|
|
800
|
-
processOrderByRaw(data) {
|
|
801
|
-
const expression = data.expression;
|
|
802
|
-
const bindings = data.bindings ?? [];
|
|
803
|
-
// Replace ? placeholders with $n positional params (same as processWhereRaw)
|
|
804
|
-
let processed = expression;
|
|
805
|
-
for (const binding of bindings) {
|
|
806
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
807
|
-
}
|
|
808
|
-
this.orderClauses.push(processed);
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* Process GROUP BY operation.
|
|
812
|
-
*/
|
|
813
|
-
processGroupBy(data) {
|
|
814
|
-
const fields = data.fields;
|
|
815
|
-
const columns = Array.isArray(fields) ? fields : [fields];
|
|
816
|
-
this.groupColumns.push(...columns);
|
|
817
|
-
}
|
|
818
|
-
/**
|
|
819
|
-
* Process HAVING operation.
|
|
820
|
-
*/
|
|
821
|
-
processHaving(data) {
|
|
822
|
-
const field = data.field;
|
|
823
|
-
const operator = data.operator ?? "=";
|
|
824
|
-
const value = data.value;
|
|
825
|
-
const quotedField = this.dialect.quoteIdentifier(field);
|
|
826
|
-
const placeholder = this.addParam(value);
|
|
827
|
-
this.havingClauses.push(`${quotedField} ${operator} ${placeholder}`);
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* Process raw HAVING expression.
|
|
831
|
-
*/
|
|
832
|
-
processHavingRaw(data) {
|
|
833
|
-
const expression = data.expression;
|
|
834
|
-
this.havingClauses.push(expression);
|
|
835
|
-
}
|
|
836
|
-
/**
|
|
837
|
-
* Add a WHERE clause with boolean operator.
|
|
838
|
-
*/
|
|
839
|
-
addWhereClause(clause, boolean) {
|
|
840
|
-
if (this.whereClauses.length === 0) {
|
|
841
|
-
this.whereClauses.push(clause);
|
|
842
|
-
}
|
|
843
|
-
else {
|
|
844
|
-
this.whereClauses.push(`${boolean} ${clause}`);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* Map simple Cascade operators to their SQL equivalents.
|
|
849
|
-
*
|
|
850
|
-
* Complex operators (between, in, like-variants, exists) are handled by
|
|
851
|
-
* dedicated processors and should never reach this method.
|
|
852
|
-
*/
|
|
853
|
-
mapOperator(operator) {
|
|
854
|
-
const mapping = {
|
|
855
|
-
"=": "=",
|
|
856
|
-
"!=": "!=",
|
|
857
|
-
"<>": "<>",
|
|
858
|
-
">": ">",
|
|
859
|
-
">=": ">=",
|
|
860
|
-
"<": "<",
|
|
861
|
-
"<=": "<=",
|
|
862
|
-
like: "LIKE",
|
|
863
|
-
notlike: "NOT LIKE",
|
|
864
|
-
ilike: "ILIKE",
|
|
865
|
-
};
|
|
866
|
-
return mapping[operator.toLowerCase()] ?? operator;
|
|
867
|
-
}
|
|
868
|
-
}exports.PostgresQueryParser=PostgresQueryParser;//# sourceMappingURL=postgres-query-parser.js.map
|