@warlock.js/cascade 4.0.156 → 4.0.158
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/package.json +4 -4
- 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 -324
- package/cjs/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
- package/cjs/drivers/mongodb/mongodb-driver.js +0 -799
- 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 -965
- 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 -864
- 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 -197
- package/cjs/drivers/postgres/postgres-sync-adapter.js.map +0 -1
- package/cjs/drivers/postgres/types.d.ts +0 -142
- 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 -1992
- 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 -161
- 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 -1650
- 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 -201
- 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 -300
- package/cjs/utils/connect-to-database.d.ts.map +0 -1
- package/cjs/utils/connect-to-database.js +0 -128
- 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 -181
- package/cjs/writer/database-writer.d.ts.map +0 -1
- package/cjs/writer/database-writer.js +0 -407
- 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 -324
- package/esm/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
- package/esm/drivers/mongodb/mongodb-driver.js +0 -799
- 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 -965
- 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 -864
- 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 -197
- package/esm/drivers/postgres/postgres-sync-adapter.js.map +0 -1
- package/esm/drivers/postgres/types.d.ts +0 -142
- 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 -1992
- 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 -161
- 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 -1650
- 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 -201
- 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 -300
- package/esm/utils/connect-to-database.d.ts.map +0 -1
- package/esm/utils/connect-to-database.js +0 -128
- 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 -181
- package/esm/writer/database-writer.d.ts.map +0 -1
- package/esm/writer/database-writer.js +0 -407
- package/esm/writer/database-writer.js.map +0 -1
|
@@ -1,864 +0,0 @@
|
|
|
1
|
-
import {PostgresDialect}from'./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();
|
|
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
|
-
// Simple single-value operator — fall through to generic path
|
|
404
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
405
|
-
const placeholder = this.addParam(value);
|
|
406
|
-
this.addWhereClause(`${quotedField} ${this.mapOperator(operator)} ${placeholder}`, boolean);
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Process a raw WHERE operation.
|
|
410
|
-
*/
|
|
411
|
-
processWhereRaw(data, boolean) {
|
|
412
|
-
const expression = data.expression;
|
|
413
|
-
const bindings = data.bindings ?? [];
|
|
414
|
-
// Replace ? placeholders with $n
|
|
415
|
-
let processed = expression;
|
|
416
|
-
for (const binding of bindings) {
|
|
417
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
418
|
-
}
|
|
419
|
-
this.addWhereClause(processed, boolean);
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Process WHERE IN / NOT IN.
|
|
423
|
-
*/
|
|
424
|
-
processWhereIn(data, negate) {
|
|
425
|
-
const field = data.field;
|
|
426
|
-
const values = data.values;
|
|
427
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
428
|
-
const operator = negate ? "!= ALL" : "= ANY";
|
|
429
|
-
const placeholder = this.addParam(values);
|
|
430
|
-
this.addWhereClause(`${quotedField} ${operator}(${placeholder})`, "AND");
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Process WHERE NULL / NOT NULL.
|
|
434
|
-
*/
|
|
435
|
-
processWhereNull(data, negate) {
|
|
436
|
-
const field = data.field;
|
|
437
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
438
|
-
const clause = negate ? `${quotedField} IS NOT NULL` : `${quotedField} IS NULL`;
|
|
439
|
-
this.addWhereClause(clause, "AND");
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Process WHERE BETWEEN / NOT BETWEEN.
|
|
443
|
-
*/
|
|
444
|
-
processWhereBetween(data, negate) {
|
|
445
|
-
const field = data.field;
|
|
446
|
-
const range = data.range;
|
|
447
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
448
|
-
const placeholder1 = this.addParam(range[0]);
|
|
449
|
-
const placeholder2 = this.addParam(range[1]);
|
|
450
|
-
const keyword = negate ? "NOT BETWEEN" : "BETWEEN";
|
|
451
|
-
this.addWhereClause(`${quotedField} ${keyword} ${placeholder1} AND ${placeholder2}`, "AND");
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Process WHERE LIKE / NOT LIKE.
|
|
455
|
-
*/
|
|
456
|
-
processWhereLike(data, negate) {
|
|
457
|
-
const field = data.field;
|
|
458
|
-
const pattern = data.pattern;
|
|
459
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
460
|
-
const { operator } = this.dialect.likePattern(pattern, true);
|
|
461
|
-
const placeholder = this.addParam(pattern);
|
|
462
|
-
const keyword = negate ? `NOT ${operator}` : operator;
|
|
463
|
-
this.addWhereClause(`${quotedField} ${keyword} ${placeholder}`, "AND");
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Process WHERE column comparison.
|
|
467
|
-
*/
|
|
468
|
-
processWhereColumn(data, boolean) {
|
|
469
|
-
const first = data.first;
|
|
470
|
-
const operator = data.operator ?? "=";
|
|
471
|
-
const second = data.second;
|
|
472
|
-
// Both sides may need qualification if unambiguous table is unclear
|
|
473
|
-
const quotedFirst = this.parseColumnIdentifier(first, this.table, this.alias);
|
|
474
|
-
const quotedSecond = this.parseColumnIdentifier(second, this.table, this.alias);
|
|
475
|
-
this.addWhereClause(`${quotedFirst} ${operator} ${quotedSecond}`, boolean);
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Process WHERE JSON contains.
|
|
479
|
-
*/
|
|
480
|
-
processWhereJsonContains(data, negate) {
|
|
481
|
-
const path = data.path;
|
|
482
|
-
const value = data.value;
|
|
483
|
-
const quotedPath = this.parseColumnIdentifier(path, this.table, this.alias);
|
|
484
|
-
const jsonValue = JSON.stringify(value);
|
|
485
|
-
const operator = negate ? "NOT @>" : "@>";
|
|
486
|
-
this.addWhereClause(`${quotedPath} ${operator} '${jsonValue}'::jsonb`, "AND");
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Process full-text search WHERE.
|
|
490
|
-
*/
|
|
491
|
-
processWhereFullText(data) {
|
|
492
|
-
const fields = data.fields;
|
|
493
|
-
const query = data.query;
|
|
494
|
-
// Build tsvector from fields
|
|
495
|
-
const tsVectors = fields
|
|
496
|
-
.map((f) => `to_tsvector('english', ${this.dialect.quoteIdentifier(f)})`)
|
|
497
|
-
.join(" || ");
|
|
498
|
-
const placeholder = this.addParam(query);
|
|
499
|
-
this.addWhereClause(`(${tsVectors}) @@ plainto_tsquery('english', ${placeholder})`, "AND");
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Process SELECT operation.
|
|
503
|
-
*/
|
|
504
|
-
processSelect(data) {
|
|
505
|
-
const fields = data.fields;
|
|
506
|
-
if (Array.isArray(fields)) {
|
|
507
|
-
this.selectColumns.push(...fields);
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
// Handle aliases: { field: 'alias' }
|
|
511
|
-
for (const [field, alias] of Object.entries(fields)) {
|
|
512
|
-
const quotedField = this.dialect.quoteIdentifier(field);
|
|
513
|
-
const quotedAlias = this.dialect.quoteIdentifier(alias);
|
|
514
|
-
this.selectRaw.push(`${quotedField} AS ${quotedAlias}`);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* Process raw SELECT expression.
|
|
520
|
-
*/
|
|
521
|
-
processSelectRaw(data) {
|
|
522
|
-
const expression = data.expression;
|
|
523
|
-
const bindings = data.bindings ?? [];
|
|
524
|
-
if (typeof expression === "string") {
|
|
525
|
-
// Replace ? placeholders with $n positional params (same as processWhereRaw)
|
|
526
|
-
let processed = expression;
|
|
527
|
-
for (const binding of bindings) {
|
|
528
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
529
|
-
}
|
|
530
|
-
this.selectRaw.push(processed);
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
// Handle object expressions (for compatibility)
|
|
534
|
-
for (const [alias, expr] of Object.entries(expression)) {
|
|
535
|
-
this.selectRaw.push(`${expr} AS ${this.dialect.quoteIdentifier(alias)}`);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Process DESELECT operation.
|
|
541
|
-
*/
|
|
542
|
-
processDeselect(data) {
|
|
543
|
-
const fields = data.fields;
|
|
544
|
-
this.deselectColumns.push(...fields);
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Process SELECT for related columns (joinWith).
|
|
548
|
-
*
|
|
549
|
-
* - hasOne / belongsTo → LEFT JOIN + row_to_json (single object)
|
|
550
|
-
* - hasMany → correlated subquery with json_agg (array, no row explosion)
|
|
551
|
-
*
|
|
552
|
-
* @example hasMany correlated subquery:
|
|
553
|
-
* (SELECT json_agg(row_to_json(a.*))
|
|
554
|
-
* FROM "chat_message_actions" a
|
|
555
|
-
* WHERE a."chat_message_id" = "chat_messages"."id") AS "actions"
|
|
556
|
-
*
|
|
557
|
-
* @example hasOne/belongsTo row_to_json:
|
|
558
|
-
* row_to_json("organizationAiModel".*) AS "organizationAiModel"
|
|
559
|
-
*/
|
|
560
|
-
processSelectRelatedColumns(data) {
|
|
561
|
-
const alias = data.alias;
|
|
562
|
-
const select = data.select;
|
|
563
|
-
const relationType = data.type;
|
|
564
|
-
const constraintOps = data.constraintOps;
|
|
565
|
-
const quotedAlias = this.dialect.quoteIdentifier(alias);
|
|
566
|
-
const quotedTable = this.dialect.quoteIdentifier(this.table);
|
|
567
|
-
if (relationType === "hasMany") {
|
|
568
|
-
// Correlated subquery — no JOIN, no row explosion, returns a JSON array.
|
|
569
|
-
const relatedTable = data.table;
|
|
570
|
-
const foreignKey = data.foreignKey;
|
|
571
|
-
const localKey = data.localKey;
|
|
572
|
-
const quotedRelatedTable = this.dialect.quoteIdentifier(relatedTable);
|
|
573
|
-
const quotedForeignKey = this.dialect.quoteIdentifier(foreignKey);
|
|
574
|
-
const quotedLocalKey = this.dialect.quoteIdentifier(localKey);
|
|
575
|
-
const quotedMainTable = this.dialect.quoteIdentifier(this.table);
|
|
576
|
-
let innerSelect;
|
|
577
|
-
if (select && select.length > 0) {
|
|
578
|
-
// Pick specific columns: json_agg(json_build_object('id', a."id", ...))
|
|
579
|
-
const fields = select
|
|
580
|
-
.map((col) => `'${col}', a.${this.dialect.quoteIdentifier(col)}`)
|
|
581
|
-
.join(", ");
|
|
582
|
-
innerSelect = `json_agg(json_build_object(${fields}))`;
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
innerSelect = `json_agg(row_to_json(a.*))`;
|
|
586
|
-
}
|
|
587
|
-
// Build the base FK condition
|
|
588
|
-
const fkCondition = `a.${quotedForeignKey} = ${quotedMainTable}.${quotedLocalKey}`;
|
|
589
|
-
// Merge constraint ops (where / order / limit) from a sub-parser
|
|
590
|
-
let extraWhere = "";
|
|
591
|
-
let orderBy = "";
|
|
592
|
-
let limitClause = "";
|
|
593
|
-
if (constraintOps && constraintOps.length > 0) {
|
|
594
|
-
const subParser = new PostgresQueryParser({
|
|
595
|
-
table: relatedTable,
|
|
596
|
-
alias: "a",
|
|
597
|
-
operations: constraintOps,
|
|
598
|
-
});
|
|
599
|
-
subParser.parse();
|
|
600
|
-
if (subParser.whereClauses.length > 0) {
|
|
601
|
-
extraWhere = ` AND ${subParser.whereClauses.join(" ")}`;
|
|
602
|
-
}
|
|
603
|
-
if (subParser.orderClauses.length > 0) {
|
|
604
|
-
orderBy = ` ORDER BY ${subParser.orderClauses.join(", ")}`;
|
|
605
|
-
}
|
|
606
|
-
if (subParser.limitValue !== undefined) {
|
|
607
|
-
limitClause = ` LIMIT ${subParser.limitValue}`;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
// Wrap with ORDER/LIMIT only when constraints are present (json_agg ignores ORDER)
|
|
611
|
-
orderBy || limitClause
|
|
612
|
-
? `SELECT row_to_json(sub.*) FROM (SELECT * FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}${orderBy}${limitClause}) sub`
|
|
613
|
-
: `SELECT ${innerSelect.replace("json_agg(", "").replace(/\)$/, "")} FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}`;
|
|
614
|
-
const aggregated = orderBy || limitClause
|
|
615
|
-
? `(SELECT json_agg(row_to_json(sub.*)) FROM (SELECT * FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}${orderBy}${limitClause}) sub) AS ${quotedAlias}`
|
|
616
|
-
: `(SELECT ${innerSelect} FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}) AS ${quotedAlias}`;
|
|
617
|
-
this.selectRaw.push(aggregated);
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
// hasOne / belongsTo — single object via LEFT JOIN + row_to_json.
|
|
621
|
-
const hasExplicitSelect = this.selectColumns.length > 0;
|
|
622
|
-
if (!hasExplicitSelect && !this.selectRaw.includes(`${quotedTable}.*`)) {
|
|
623
|
-
this.selectRaw.unshift(`${quotedTable}.*`);
|
|
624
|
-
}
|
|
625
|
-
// If constraint provides an explicit select list, prefer it over data.select
|
|
626
|
-
let effectiveSelect = select;
|
|
627
|
-
if (constraintOps && constraintOps.length > 0) {
|
|
628
|
-
const subParser = new PostgresQueryParser({
|
|
629
|
-
table: data.table ?? alias,
|
|
630
|
-
alias,
|
|
631
|
-
operations: constraintOps,
|
|
632
|
-
});
|
|
633
|
-
subParser.parse();
|
|
634
|
-
if (subParser.selectColumns.length > 0) {
|
|
635
|
-
effectiveSelect = subParser.selectColumns;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
if (effectiveSelect && effectiveSelect.length > 0) {
|
|
639
|
-
const selectedColumns = effectiveSelect
|
|
640
|
-
.map((col) => `${quotedAlias}.${this.dialect.quoteIdentifier(col)}`)
|
|
641
|
-
.join(", ");
|
|
642
|
-
this.selectRaw.push(`row_to_json((SELECT d FROM (SELECT ${selectedColumns}) d)) AS ${quotedAlias}`);
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
this.selectRaw.push(`row_to_json(${quotedAlias}.*) AS ${quotedAlias}`);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Process JOIN operation with smart field detection.
|
|
651
|
-
*
|
|
652
|
-
* Handles both regular columns and JSONB nested paths:
|
|
653
|
-
* - "id" → "table"."id" (auto-prefixed)
|
|
654
|
-
* - "users.id" → "users"."id" (explicit table)
|
|
655
|
-
* - "createdBy.id" → "table"."createdBy"->>'id' (JSONB path)
|
|
656
|
-
* - "posts.createdBy.id" → "posts"."createdBy"->>'id' (JSONB with table)
|
|
657
|
-
*/
|
|
658
|
-
processJoin(data, type) {
|
|
659
|
-
const options = data;
|
|
660
|
-
const joinTable = "table" in options ? options.table : "";
|
|
661
|
-
const localField = "localField" in options ? options.localField : "";
|
|
662
|
-
const foreignField = "foreignField" in options ? options.foreignField : "";
|
|
663
|
-
const alias = "alias" in options ? options.alias : undefined;
|
|
664
|
-
const quotedTable = this.dialect.quoteIdentifier(joinTable);
|
|
665
|
-
const tableRef = alias
|
|
666
|
-
? `${quotedTable} AS ${this.dialect.quoteIdentifier(alias)}`
|
|
667
|
-
: quotedTable;
|
|
668
|
-
const tableAlias = alias ?? joinTable;
|
|
669
|
-
// Track the joined table for reference detection
|
|
670
|
-
this.joinedTables.add(joinTable);
|
|
671
|
-
if (alias) {
|
|
672
|
-
this.joinedTables.add(alias);
|
|
673
|
-
}
|
|
674
|
-
// Parse local field (belongs to main table)
|
|
675
|
-
const quotedLocal = this.parseColumnIdentifier(localField, this.table, this.alias);
|
|
676
|
-
// Parse foreign field (belongs to join table)
|
|
677
|
-
const quotedForeign = this.parseColumnIdentifier(foreignField, joinTable, tableAlias);
|
|
678
|
-
this.joinClauses.push(`${type} JOIN ${tableRef} ON ${quotedLocal} = ${quotedForeign}`);
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Parse a column identifier with smart detection for table prefixes and JSONB paths.
|
|
682
|
-
*
|
|
683
|
-
* @param field - The field string (e.g., "id", "users.id", "createdBy.id")
|
|
684
|
-
* @param defaultTable - Default table to use if no prefix
|
|
685
|
-
* @param tableAlias - Table alias to use if provided
|
|
686
|
-
* @returns Properly quoted SQL expression
|
|
687
|
-
*/
|
|
688
|
-
parseColumnIdentifier(field, defaultTable, tableAlias) {
|
|
689
|
-
if (!field)
|
|
690
|
-
return "";
|
|
691
|
-
const effectiveTable = tableAlias ?? defaultTable;
|
|
692
|
-
const parts = field.split(".");
|
|
693
|
-
// Single part: just a column name, prefix with default table
|
|
694
|
-
if (parts.length === 1) {
|
|
695
|
-
return `${this.dialect.quoteIdentifier(effectiveTable)}.${this.dialect.quoteIdentifier(field)}`;
|
|
696
|
-
}
|
|
697
|
-
// Two parts: could be "table.column" or "jsonbColumn.key"
|
|
698
|
-
if (parts.length === 2) {
|
|
699
|
-
const [first, second] = parts;
|
|
700
|
-
// Check if first part is a known table (main table, join table, or alias)
|
|
701
|
-
if (this.isTableReference(first)) {
|
|
702
|
-
// It's table.column - regular column reference
|
|
703
|
-
return `${this.dialect.quoteIdentifier(first)}.${this.dialect.quoteIdentifier(second)}`;
|
|
704
|
-
}
|
|
705
|
-
// It's jsonbColumn.key - JSONB path
|
|
706
|
-
return this.buildJsonbPath(effectiveTable, first, [second]);
|
|
707
|
-
}
|
|
708
|
-
// Three or more parts: "table.jsonbColumn.key..." or "jsonbColumn.key1.key2..."
|
|
709
|
-
const [first, second, ...rest] = parts;
|
|
710
|
-
if (this.isTableReference(first)) {
|
|
711
|
-
// First part is table: "posts.createdBy.id" → table is "posts", JSONB is "createdBy.id"
|
|
712
|
-
return this.buildJsonbPath(first, second, rest);
|
|
713
|
-
}
|
|
714
|
-
// No table prefix: "createdBy.address.city" → use default table
|
|
715
|
-
return this.buildJsonbPath(effectiveTable, first, [second, ...rest]);
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* Check if a string is a table reference (main table or join table).
|
|
719
|
-
*/
|
|
720
|
-
isTableReference(name) {
|
|
721
|
-
if (name === this.table || name === this.alias) {
|
|
722
|
-
return true;
|
|
723
|
-
}
|
|
724
|
-
if (this.joinedTables.has(name)) {
|
|
725
|
-
return true;
|
|
726
|
-
}
|
|
727
|
-
return false;
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Build a JSONB path expression.
|
|
731
|
-
*
|
|
732
|
-
* @param table - Table name
|
|
733
|
-
* @param column - JSONB column name
|
|
734
|
-
* @param path - Array of nested keys
|
|
735
|
-
* @returns PostgreSQL JSONB path expression
|
|
736
|
-
*
|
|
737
|
-
* @example
|
|
738
|
-
* buildJsonbPath("posts", "createdBy", ["id"])
|
|
739
|
-
* // Returns: ("posts"."createdBy"->>'id')::integer
|
|
740
|
-
*
|
|
741
|
-
* buildJsonbPath("posts", "createdBy", ["address", "city"])
|
|
742
|
-
* // Returns: "posts"."createdBy"->'address'->>'city'
|
|
743
|
-
*/
|
|
744
|
-
buildJsonbPath(table, column, path) {
|
|
745
|
-
const quotedTable = this.dialect.quoteIdentifier(table);
|
|
746
|
-
const quotedColumn = this.dialect.quoteIdentifier(column);
|
|
747
|
-
if (path.length === 0) {
|
|
748
|
-
return `${quotedTable}.${quotedColumn}`;
|
|
749
|
-
}
|
|
750
|
-
// Build JSONB path: use -> for intermediate keys, ->> for final key (returns text)
|
|
751
|
-
let expression = `${quotedTable}.${quotedColumn}`;
|
|
752
|
-
for (let i = 0; i < path.length; i++) {
|
|
753
|
-
const isLast = i === path.length - 1;
|
|
754
|
-
const operator = isLast ? "->>" : "->";
|
|
755
|
-
expression += `${operator}'${path[i]}'`;
|
|
756
|
-
}
|
|
757
|
-
// Cast to integer if the path ends with 'id' (common pattern for foreign keys)
|
|
758
|
-
const lastKey = path[path.length - 1].toLowerCase();
|
|
759
|
-
if (lastKey === "id" || lastKey.endsWith("id")) {
|
|
760
|
-
expression = `(${expression})::integer`;
|
|
761
|
-
}
|
|
762
|
-
return expression;
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Process CROSS JOIN operation.
|
|
766
|
-
*/
|
|
767
|
-
processCrossJoin(data) {
|
|
768
|
-
const table = data.table;
|
|
769
|
-
const quotedTable = this.dialect.quoteIdentifier(table);
|
|
770
|
-
this.joinClauses.push(`CROSS JOIN ${quotedTable}`);
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Process raw JOIN expression.
|
|
774
|
-
*/
|
|
775
|
-
processJoinRaw(data) {
|
|
776
|
-
const expression = data.expression;
|
|
777
|
-
const bindings = data.bindings ?? [];
|
|
778
|
-
let processed = expression;
|
|
779
|
-
for (const binding of bindings) {
|
|
780
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
781
|
-
}
|
|
782
|
-
this.joinClauses.push(processed);
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Process ORDER BY operation.
|
|
786
|
-
*/
|
|
787
|
-
processOrderBy(data) {
|
|
788
|
-
const field = data.field;
|
|
789
|
-
const direction = (data.direction ?? "asc").toUpperCase();
|
|
790
|
-
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
791
|
-
this.orderClauses.push(`${quotedField} ${direction}`);
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Process raw ORDER BY expression.
|
|
795
|
-
*/
|
|
796
|
-
processOrderByRaw(data) {
|
|
797
|
-
const expression = data.expression;
|
|
798
|
-
const bindings = data.bindings ?? [];
|
|
799
|
-
// Replace ? placeholders with $n positional params (same as processWhereRaw)
|
|
800
|
-
let processed = expression;
|
|
801
|
-
for (const binding of bindings) {
|
|
802
|
-
processed = processed.replace("?", this.addParam(binding));
|
|
803
|
-
}
|
|
804
|
-
this.orderClauses.push(processed);
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Process GROUP BY operation.
|
|
808
|
-
*/
|
|
809
|
-
processGroupBy(data) {
|
|
810
|
-
const fields = data.fields;
|
|
811
|
-
const columns = Array.isArray(fields) ? fields : [fields];
|
|
812
|
-
this.groupColumns.push(...columns);
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Process HAVING operation.
|
|
816
|
-
*/
|
|
817
|
-
processHaving(data) {
|
|
818
|
-
const field = data.field;
|
|
819
|
-
const operator = data.operator ?? "=";
|
|
820
|
-
const value = data.value;
|
|
821
|
-
const quotedField = this.dialect.quoteIdentifier(field);
|
|
822
|
-
const placeholder = this.addParam(value);
|
|
823
|
-
this.havingClauses.push(`${quotedField} ${operator} ${placeholder}`);
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Process raw HAVING expression.
|
|
827
|
-
*/
|
|
828
|
-
processHavingRaw(data) {
|
|
829
|
-
const expression = data.expression;
|
|
830
|
-
this.havingClauses.push(expression);
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* Add a WHERE clause with boolean operator.
|
|
834
|
-
*/
|
|
835
|
-
addWhereClause(clause, boolean) {
|
|
836
|
-
if (this.whereClauses.length === 0) {
|
|
837
|
-
this.whereClauses.push(clause);
|
|
838
|
-
}
|
|
839
|
-
else {
|
|
840
|
-
this.whereClauses.push(`${boolean} ${clause}`);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
/**
|
|
844
|
-
* Map simple Cascade operators to their SQL equivalents.
|
|
845
|
-
*
|
|
846
|
-
* Complex operators (between, in, like-variants, exists) are handled by
|
|
847
|
-
* dedicated processors and should never reach this method.
|
|
848
|
-
*/
|
|
849
|
-
mapOperator(operator) {
|
|
850
|
-
const mapping = {
|
|
851
|
-
"=": "=",
|
|
852
|
-
"!=": "!=",
|
|
853
|
-
"<>": "<>",
|
|
854
|
-
">": ">",
|
|
855
|
-
">=": ">=",
|
|
856
|
-
"<": "<",
|
|
857
|
-
"<=": "<=",
|
|
858
|
-
like: "LIKE",
|
|
859
|
-
notlike: "NOT LIKE",
|
|
860
|
-
ilike: "ILIKE",
|
|
861
|
-
};
|
|
862
|
-
return mapping[operator.toLowerCase()] ?? operator;
|
|
863
|
-
}
|
|
864
|
-
}export{PostgresQueryParser};//# sourceMappingURL=postgres-query-parser.js.map
|