@warlock.js/cascade 4.0.174 → 4.1.1
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
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
import { PostgresDialect } from "./postgres-dialect.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/cascade/src/drivers/postgres/postgres-query-parser.ts
|
|
4
|
+
/**
|
|
5
|
+
* PostgreSQL Query Parser.
|
|
6
|
+
*
|
|
7
|
+
* Converts a list of query operations into a SQL query string with parameters.
|
|
8
|
+
* Handles SELECT, WHERE, JOIN, ORDER BY, GROUP BY, LIMIT/OFFSET clauses.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const parser = new PostgresQueryParser({
|
|
13
|
+
* table: 'users',
|
|
14
|
+
* operations: [
|
|
15
|
+
* { type: 'where', data: { field: 'name', operator: '=', value: 'Alice' } },
|
|
16
|
+
* { type: 'orderBy', data: { field: 'createdAt', direction: 'desc' } },
|
|
17
|
+
* { type: 'limit', data: { value: 10 } }
|
|
18
|
+
* ]
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* const { sql, params } = parser.parse();
|
|
22
|
+
* // sql: 'SELECT * FROM "users" WHERE "name" = $1 ORDER BY "createdAt" DESC LIMIT 10'
|
|
23
|
+
* // params: ['Alice']
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
var PostgresQueryParser = class PostgresQueryParser {
|
|
27
|
+
/**
|
|
28
|
+
* Target table name.
|
|
29
|
+
*/
|
|
30
|
+
table;
|
|
31
|
+
/**
|
|
32
|
+
* Table alias.
|
|
33
|
+
*/
|
|
34
|
+
alias;
|
|
35
|
+
/**
|
|
36
|
+
* Operations to process.
|
|
37
|
+
*/
|
|
38
|
+
operations;
|
|
39
|
+
/**
|
|
40
|
+
* SQL dialect for syntax.
|
|
41
|
+
*/
|
|
42
|
+
dialect;
|
|
43
|
+
/**
|
|
44
|
+
* Current parameter index (1-based for PostgreSQL).
|
|
45
|
+
*/
|
|
46
|
+
paramIndex = 1;
|
|
47
|
+
/**
|
|
48
|
+
* Collected parameters.
|
|
49
|
+
*/
|
|
50
|
+
params = [];
|
|
51
|
+
/**
|
|
52
|
+
* SELECT columns.
|
|
53
|
+
*/
|
|
54
|
+
selectColumns = [];
|
|
55
|
+
/**
|
|
56
|
+
* Deselected (excluded) columns.
|
|
57
|
+
*/
|
|
58
|
+
deselectColumns = [];
|
|
59
|
+
/**
|
|
60
|
+
* Raw SELECT expressions.
|
|
61
|
+
*/
|
|
62
|
+
selectRaw = [];
|
|
63
|
+
/**
|
|
64
|
+
* WHERE clauses.
|
|
65
|
+
*/
|
|
66
|
+
whereClauses = [];
|
|
67
|
+
/**
|
|
68
|
+
* JOIN clauses.
|
|
69
|
+
*/
|
|
70
|
+
joinClauses = [];
|
|
71
|
+
/**
|
|
72
|
+
* ORDER BY clauses.
|
|
73
|
+
*/
|
|
74
|
+
orderClauses = [];
|
|
75
|
+
/**
|
|
76
|
+
* GROUP BY columns.
|
|
77
|
+
*/
|
|
78
|
+
groupColumns = [];
|
|
79
|
+
/**
|
|
80
|
+
* HAVING clauses.
|
|
81
|
+
*/
|
|
82
|
+
havingClauses = [];
|
|
83
|
+
/**
|
|
84
|
+
* LIMIT value.
|
|
85
|
+
*/
|
|
86
|
+
limitValue;
|
|
87
|
+
/**
|
|
88
|
+
* OFFSET value.
|
|
89
|
+
*/
|
|
90
|
+
offsetValue;
|
|
91
|
+
/**
|
|
92
|
+
* DISTINCT flag.
|
|
93
|
+
*/
|
|
94
|
+
isDistinct = false;
|
|
95
|
+
/**
|
|
96
|
+
* Whether the query has any JOIN operations (pre-scanned before processing).
|
|
97
|
+
* Used by qualifyColumn() to decide whether to prefix columns with the main table.
|
|
98
|
+
*/
|
|
99
|
+
hasJoins = false;
|
|
100
|
+
/**
|
|
101
|
+
* Tracked joined tables (for table reference detection).
|
|
102
|
+
*/
|
|
103
|
+
joinedTables = /* @__PURE__ */ new Set();
|
|
104
|
+
/**
|
|
105
|
+
* Create a new query parser.
|
|
106
|
+
*
|
|
107
|
+
* @param options - Parser configuration
|
|
108
|
+
*/
|
|
109
|
+
constructor(options) {
|
|
110
|
+
this.table = options.table;
|
|
111
|
+
this.alias = options.alias;
|
|
112
|
+
this.operations = options.operations;
|
|
113
|
+
this.dialect = options.dialect ?? new PostgresDialect();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Parse all operations and build the SQL query.
|
|
117
|
+
*
|
|
118
|
+
* @returns DriverQuery with `query` (SQL string) and `bindings` (parameter values)
|
|
119
|
+
*/
|
|
120
|
+
parse() {
|
|
121
|
+
const JOIN_TYPES = new Set([
|
|
122
|
+
"join",
|
|
123
|
+
"leftJoin",
|
|
124
|
+
"rightJoin",
|
|
125
|
+
"innerJoin",
|
|
126
|
+
"fullJoin",
|
|
127
|
+
"crossJoin",
|
|
128
|
+
"joinRaw"
|
|
129
|
+
]);
|
|
130
|
+
this.hasJoins = false;
|
|
131
|
+
for (const operation of this.operations) if (JOIN_TYPES.has(operation.type)) {
|
|
132
|
+
this.hasJoins = true;
|
|
133
|
+
const data = operation.data;
|
|
134
|
+
const joinTable = data.table;
|
|
135
|
+
const alias = data.alias;
|
|
136
|
+
if (joinTable) this.joinedTables.add(joinTable);
|
|
137
|
+
if (alias) this.joinedTables.add(alias);
|
|
138
|
+
}
|
|
139
|
+
for (const operation of this.operations) this.processOperation(operation);
|
|
140
|
+
return {
|
|
141
|
+
query: this.buildSql(),
|
|
142
|
+
bindings: this.params
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get a formatted string representation of the query.
|
|
147
|
+
*
|
|
148
|
+
* @returns Formatted SQL with bindings
|
|
149
|
+
*/
|
|
150
|
+
toPrettyString() {
|
|
151
|
+
const { query = "", bindings } = this.parse();
|
|
152
|
+
return `${query}\n-- Bindings: ${JSON.stringify(bindings ?? [])}`;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Process a single operation.
|
|
156
|
+
*
|
|
157
|
+
* @param operation - The operation to process
|
|
158
|
+
*/
|
|
159
|
+
processOperation(operation) {
|
|
160
|
+
const { type, data } = operation;
|
|
161
|
+
switch (type) {
|
|
162
|
+
case "where":
|
|
163
|
+
this.processWhere(data, "AND");
|
|
164
|
+
break;
|
|
165
|
+
case "orWhere":
|
|
166
|
+
this.processWhere(data, "OR");
|
|
167
|
+
break;
|
|
168
|
+
case "whereRaw":
|
|
169
|
+
this.processWhereRaw(data, "AND");
|
|
170
|
+
break;
|
|
171
|
+
case "orWhereRaw":
|
|
172
|
+
this.processWhereRaw(data, "OR");
|
|
173
|
+
break;
|
|
174
|
+
case "whereIn":
|
|
175
|
+
this.processWhereIn(data, false);
|
|
176
|
+
break;
|
|
177
|
+
case "whereNotIn":
|
|
178
|
+
this.processWhereIn(data, true);
|
|
179
|
+
break;
|
|
180
|
+
case "whereNull":
|
|
181
|
+
this.processWhereNull(data, false);
|
|
182
|
+
break;
|
|
183
|
+
case "whereNotNull":
|
|
184
|
+
this.processWhereNull(data, true);
|
|
185
|
+
break;
|
|
186
|
+
case "whereBetween":
|
|
187
|
+
this.processWhereBetween(data, false);
|
|
188
|
+
break;
|
|
189
|
+
case "whereNotBetween":
|
|
190
|
+
this.processWhereBetween(data, true);
|
|
191
|
+
break;
|
|
192
|
+
case "whereLike":
|
|
193
|
+
this.processWhereLike(data, false);
|
|
194
|
+
break;
|
|
195
|
+
case "whereNotLike":
|
|
196
|
+
this.processWhereLike(data, true);
|
|
197
|
+
break;
|
|
198
|
+
case "whereColumn":
|
|
199
|
+
this.processWhereColumn(data, "AND");
|
|
200
|
+
break;
|
|
201
|
+
case "orWhereColumn":
|
|
202
|
+
this.processWhereColumn(data, "OR");
|
|
203
|
+
break;
|
|
204
|
+
case "whereJsonContains":
|
|
205
|
+
this.processWhereJsonContains(data, false);
|
|
206
|
+
break;
|
|
207
|
+
case "whereJsonDoesntContain":
|
|
208
|
+
this.processWhereJsonContains(data, true);
|
|
209
|
+
break;
|
|
210
|
+
case "whereFullText":
|
|
211
|
+
this.processWhereFullText(data);
|
|
212
|
+
break;
|
|
213
|
+
case "select":
|
|
214
|
+
this.processSelect(data);
|
|
215
|
+
break;
|
|
216
|
+
case "selectRaw":
|
|
217
|
+
this.processSelectRaw(data);
|
|
218
|
+
break;
|
|
219
|
+
case "deselect":
|
|
220
|
+
this.processDeselect(data);
|
|
221
|
+
break;
|
|
222
|
+
case "join":
|
|
223
|
+
case "innerJoin":
|
|
224
|
+
this.processJoin(data, "INNER");
|
|
225
|
+
break;
|
|
226
|
+
case "leftJoin":
|
|
227
|
+
this.processJoin(data, "LEFT");
|
|
228
|
+
break;
|
|
229
|
+
case "rightJoin":
|
|
230
|
+
this.processJoin(data, "RIGHT");
|
|
231
|
+
break;
|
|
232
|
+
case "fullJoin":
|
|
233
|
+
this.processJoin(data, "FULL OUTER");
|
|
234
|
+
break;
|
|
235
|
+
case "crossJoin":
|
|
236
|
+
this.processCrossJoin(data);
|
|
237
|
+
break;
|
|
238
|
+
case "joinRaw":
|
|
239
|
+
this.processJoinRaw(data);
|
|
240
|
+
break;
|
|
241
|
+
case "orderBy":
|
|
242
|
+
this.processOrderBy(data);
|
|
243
|
+
break;
|
|
244
|
+
case "orderByRaw":
|
|
245
|
+
this.processOrderByRaw(data);
|
|
246
|
+
break;
|
|
247
|
+
case "groupBy":
|
|
248
|
+
this.processGroupBy(data);
|
|
249
|
+
break;
|
|
250
|
+
case "having":
|
|
251
|
+
this.processHaving(data);
|
|
252
|
+
break;
|
|
253
|
+
case "havingRaw":
|
|
254
|
+
this.processHavingRaw(data);
|
|
255
|
+
break;
|
|
256
|
+
case "limit":
|
|
257
|
+
this.limitValue = data.value;
|
|
258
|
+
break;
|
|
259
|
+
case "offset":
|
|
260
|
+
this.offsetValue = data.value;
|
|
261
|
+
break;
|
|
262
|
+
case "distinct":
|
|
263
|
+
this.isDistinct = true;
|
|
264
|
+
break;
|
|
265
|
+
case "selectRelatedColumns":
|
|
266
|
+
this.processSelectRelatedColumns(data);
|
|
267
|
+
break;
|
|
268
|
+
default: break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Build the final SQL query from collected clauses.
|
|
273
|
+
*
|
|
274
|
+
* @returns Complete SQL query string
|
|
275
|
+
*/
|
|
276
|
+
buildSql() {
|
|
277
|
+
const parts = [];
|
|
278
|
+
parts.push(this.buildSelectClause());
|
|
279
|
+
const quotedTable = this.dialect.quoteIdentifier(this.table);
|
|
280
|
+
const fromClause = this.alias ? `FROM ${quotedTable} AS ${this.dialect.quoteIdentifier(this.alias)}` : `FROM ${quotedTable}`;
|
|
281
|
+
parts.push(fromClause);
|
|
282
|
+
if (this.joinClauses.length > 0) parts.push(this.joinClauses.join(" "));
|
|
283
|
+
if (this.whereClauses.length > 0) parts.push(`WHERE ${this.whereClauses.join(" ")}`);
|
|
284
|
+
if (this.groupColumns.length > 0) {
|
|
285
|
+
const quotedCols = this.groupColumns.map((c) => this.dialect.quoteIdentifier(c));
|
|
286
|
+
parts.push(`GROUP BY ${quotedCols.join(", ")}`);
|
|
287
|
+
}
|
|
288
|
+
if (this.havingClauses.length > 0) parts.push(`HAVING ${this.havingClauses.join(" AND ")}`);
|
|
289
|
+
if (this.orderClauses.length > 0) parts.push(`ORDER BY ${this.orderClauses.join(", ")}`);
|
|
290
|
+
const limitOffset = this.dialect.limitOffset(this.limitValue, this.offsetValue);
|
|
291
|
+
if (limitOffset) parts.push(limitOffset);
|
|
292
|
+
return parts.join(" ");
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Build the SELECT clause.
|
|
296
|
+
*
|
|
297
|
+
* @returns SELECT clause string
|
|
298
|
+
*/
|
|
299
|
+
buildSelectClause() {
|
|
300
|
+
const distinct = this.isDistinct ? "DISTINCT " : "";
|
|
301
|
+
if (this.selectColumns.length === 0 && this.selectRaw.length === 0) return this.hasJoins ? `SELECT ${distinct}${this.dialect.quoteIdentifier(this.table)}.*` : `SELECT ${distinct}*`;
|
|
302
|
+
const columns = [];
|
|
303
|
+
for (const col of this.selectColumns) if (!this.deselectColumns.includes(col)) columns.push(this.parseColumnIdentifier(col, this.table, this.alias));
|
|
304
|
+
columns.push(...this.selectRaw);
|
|
305
|
+
return `SELECT ${distinct}${columns.join(", ")}`;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Add a placeholder and parameter.
|
|
309
|
+
*
|
|
310
|
+
* @param value - Parameter value
|
|
311
|
+
* @returns Placeholder string ($1, $2, etc.)
|
|
312
|
+
*/
|
|
313
|
+
addParam(value) {
|
|
314
|
+
this.params.push(value);
|
|
315
|
+
return this.dialect.placeholder(this.paramIndex++);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Absorb a sub-parser's params into this parser, returning a rewriter
|
|
319
|
+
* function that translates the sub-parser's `$N` placeholders into freshly
|
|
320
|
+
* numbered placeholders in this parser's namespace.
|
|
321
|
+
*
|
|
322
|
+
* Required whenever sub-parser SQL fragments (e.g. WHERE clauses produced
|
|
323
|
+
* for a `joinWith` constraint) are spliced into the outer query — without
|
|
324
|
+
* the rewrite the embedded `$N` references point at parameters this
|
|
325
|
+
* parser has no knowledge of, leaving them dangling in the final SQL.
|
|
326
|
+
*
|
|
327
|
+
* The sub-parser's `params[i]` corresponds to its `$(i+1)` placeholder
|
|
328
|
+
* (its `paramIndex` always starts at 1), so we map sequentially.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* const renumber = this.absorbSubParserParams(subParser);
|
|
332
|
+
* const fragment = renumber(subParser.whereClauses.join(" "));
|
|
333
|
+
*/
|
|
334
|
+
absorbSubParserParams(subParser) {
|
|
335
|
+
if (subParser.params.length === 0) return (sql) => sql;
|
|
336
|
+
const oldToNew = /* @__PURE__ */ new Map();
|
|
337
|
+
for (let index = 0; index < subParser.params.length; index++) {
|
|
338
|
+
const newPlaceholder = this.addParam(subParser.params[index]);
|
|
339
|
+
oldToNew.set(`$${index + 1}`, newPlaceholder);
|
|
340
|
+
}
|
|
341
|
+
return (sql) => sql.replace(/\$\d+/g, (match) => oldToNew.get(match) ?? match);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Process a basic WHERE operation.
|
|
345
|
+
*
|
|
346
|
+
* Delegates to specialised processors for operators that require more than a
|
|
347
|
+
* single placeholder (between, in, like-variants, exists, etc.).
|
|
348
|
+
*/
|
|
349
|
+
processWhere(data, boolean) {
|
|
350
|
+
const field = data.field;
|
|
351
|
+
const operator = data.operator ?? "=";
|
|
352
|
+
const value = data.value;
|
|
353
|
+
switch (operator) {
|
|
354
|
+
case "between": return this.processWhereBetween({
|
|
355
|
+
field,
|
|
356
|
+
range: value
|
|
357
|
+
}, false);
|
|
358
|
+
case "notBetween": return this.processWhereBetween({
|
|
359
|
+
field,
|
|
360
|
+
range: value
|
|
361
|
+
}, true);
|
|
362
|
+
case "in": return this.processWhereIn({
|
|
363
|
+
field,
|
|
364
|
+
values: value
|
|
365
|
+
}, false);
|
|
366
|
+
case "notIn": return this.processWhereIn({
|
|
367
|
+
field,
|
|
368
|
+
values: value
|
|
369
|
+
}, true);
|
|
370
|
+
case "like":
|
|
371
|
+
case "ilike":
|
|
372
|
+
case "startsWith":
|
|
373
|
+
case "endsWith": return this.processWhereLike({
|
|
374
|
+
field,
|
|
375
|
+
pattern: value
|
|
376
|
+
}, false);
|
|
377
|
+
case "notLike":
|
|
378
|
+
case "notStartsWith":
|
|
379
|
+
case "notEndsWith": return this.processWhereLike({
|
|
380
|
+
field,
|
|
381
|
+
pattern: value
|
|
382
|
+
}, true);
|
|
383
|
+
case "exists": return this.addWhereClause(`EXISTS (${value})`, boolean);
|
|
384
|
+
}
|
|
385
|
+
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
386
|
+
if (value === null) {
|
|
387
|
+
const nullOperator = operator === "!=" ? "IS NOT NULL" : "IS NULL";
|
|
388
|
+
return this.addWhereClause(`${quotedField} ${nullOperator}`, boolean);
|
|
389
|
+
}
|
|
390
|
+
const placeholder = this.addParam(value);
|
|
391
|
+
this.addWhereClause(`${quotedField} ${this.mapOperator(operator)} ${placeholder}`, boolean);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Process a raw WHERE operation.
|
|
395
|
+
*/
|
|
396
|
+
processWhereRaw(data, boolean) {
|
|
397
|
+
const expression = data.expression;
|
|
398
|
+
const bindings = data.bindings ?? [];
|
|
399
|
+
let processed = expression;
|
|
400
|
+
for (const binding of bindings) processed = processed.replace("?", this.addParam(binding));
|
|
401
|
+
this.addWhereClause(processed, boolean);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Process WHERE IN / NOT IN.
|
|
405
|
+
*/
|
|
406
|
+
processWhereIn(data, negate) {
|
|
407
|
+
const field = data.field;
|
|
408
|
+
const values = data.values;
|
|
409
|
+
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
410
|
+
const operator = negate ? "!= ALL" : "= ANY";
|
|
411
|
+
const placeholder = this.addParam(values);
|
|
412
|
+
this.addWhereClause(`${quotedField} ${operator}(${placeholder})`, "AND");
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Process WHERE NULL / NOT NULL.
|
|
416
|
+
*/
|
|
417
|
+
processWhereNull(data, negate) {
|
|
418
|
+
const field = data.field;
|
|
419
|
+
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
420
|
+
const clause = negate ? `${quotedField} IS NOT NULL` : `${quotedField} IS NULL`;
|
|
421
|
+
this.addWhereClause(clause, "AND");
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Process WHERE BETWEEN / NOT BETWEEN.
|
|
425
|
+
*/
|
|
426
|
+
processWhereBetween(data, negate) {
|
|
427
|
+
const field = data.field;
|
|
428
|
+
const range = data.range;
|
|
429
|
+
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
430
|
+
const placeholder1 = this.addParam(range[0]);
|
|
431
|
+
const placeholder2 = this.addParam(range[1]);
|
|
432
|
+
const keyword = negate ? "NOT BETWEEN" : "BETWEEN";
|
|
433
|
+
this.addWhereClause(`${quotedField} ${keyword} ${placeholder1} AND ${placeholder2}`, "AND");
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Process WHERE LIKE / NOT LIKE.
|
|
437
|
+
*/
|
|
438
|
+
processWhereLike(data, negate) {
|
|
439
|
+
const field = data.field;
|
|
440
|
+
const pattern = data.pattern;
|
|
441
|
+
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
442
|
+
const { operator } = this.dialect.likePattern(pattern, true);
|
|
443
|
+
const placeholder = this.addParam(pattern);
|
|
444
|
+
const keyword = negate ? `NOT ${operator}` : operator;
|
|
445
|
+
this.addWhereClause(`${quotedField} ${keyword} ${placeholder}`, "AND");
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Process WHERE column comparison.
|
|
449
|
+
*/
|
|
450
|
+
processWhereColumn(data, boolean) {
|
|
451
|
+
const first = data.first;
|
|
452
|
+
const operator = data.operator ?? "=";
|
|
453
|
+
const second = data.second;
|
|
454
|
+
const quotedFirst = this.parseColumnIdentifier(first, this.table, this.alias);
|
|
455
|
+
const quotedSecond = this.parseColumnIdentifier(second, this.table, this.alias);
|
|
456
|
+
this.addWhereClause(`${quotedFirst} ${operator} ${quotedSecond}`, boolean);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Process WHERE JSON contains.
|
|
460
|
+
*/
|
|
461
|
+
processWhereJsonContains(data, negate) {
|
|
462
|
+
const path = data.path;
|
|
463
|
+
const value = data.value;
|
|
464
|
+
const quotedPath = this.parseColumnIdentifier(path, this.table, this.alias);
|
|
465
|
+
const jsonValue = JSON.stringify(value);
|
|
466
|
+
const operator = negate ? "NOT @>" : "@>";
|
|
467
|
+
this.addWhereClause(`${quotedPath} ${operator} '${jsonValue}'::jsonb`, "AND");
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Process full-text search WHERE.
|
|
471
|
+
*/
|
|
472
|
+
processWhereFullText(data) {
|
|
473
|
+
const fields = data.fields;
|
|
474
|
+
const query = data.query;
|
|
475
|
+
const tsVectors = fields.map((f) => `to_tsvector('english', ${this.dialect.quoteIdentifier(f)})`).join(" || ");
|
|
476
|
+
const placeholder = this.addParam(query);
|
|
477
|
+
this.addWhereClause(`(${tsVectors}) @@ plainto_tsquery('english', ${placeholder})`, "AND");
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Process SELECT operation.
|
|
481
|
+
*/
|
|
482
|
+
processSelect(data) {
|
|
483
|
+
const fields = data.fields;
|
|
484
|
+
if (Array.isArray(fields)) this.selectColumns.push(...fields);
|
|
485
|
+
else for (const [field, alias] of Object.entries(fields)) {
|
|
486
|
+
const quotedField = this.dialect.quoteIdentifier(field);
|
|
487
|
+
const quotedAlias = this.dialect.quoteIdentifier(alias);
|
|
488
|
+
this.selectRaw.push(`${quotedField} AS ${quotedAlias}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Process raw SELECT expression.
|
|
493
|
+
*/
|
|
494
|
+
processSelectRaw(data) {
|
|
495
|
+
const expression = data.expression;
|
|
496
|
+
const bindings = data.bindings ?? [];
|
|
497
|
+
if (typeof expression === "string") {
|
|
498
|
+
let processed = expression;
|
|
499
|
+
for (const binding of bindings) processed = processed.replace("?", this.addParam(binding));
|
|
500
|
+
this.selectRaw.push(processed);
|
|
501
|
+
} else for (const [alias, expr] of Object.entries(expression)) this.selectRaw.push(`${expr} AS ${this.dialect.quoteIdentifier(alias)}`);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Process DESELECT operation.
|
|
505
|
+
*/
|
|
506
|
+
processDeselect(data) {
|
|
507
|
+
const fields = data.fields;
|
|
508
|
+
this.deselectColumns.push(...fields);
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Process SELECT for related columns (joinWith).
|
|
512
|
+
*
|
|
513
|
+
* - hasOne / belongsTo → LEFT JOIN + row_to_json (single object)
|
|
514
|
+
* - hasMany → correlated subquery with json_agg (array, no row explosion)
|
|
515
|
+
*
|
|
516
|
+
* @example hasMany correlated subquery:
|
|
517
|
+
* (SELECT json_agg(row_to_json(a.*))
|
|
518
|
+
* FROM "chat_message_actions" a
|
|
519
|
+
* WHERE a."chat_message_id" = "chat_messages"."id") AS "actions"
|
|
520
|
+
*
|
|
521
|
+
* @example hasOne/belongsTo row_to_json:
|
|
522
|
+
* row_to_json("organizationAiModel".*) AS "organizationAiModel"
|
|
523
|
+
*/
|
|
524
|
+
processSelectRelatedColumns(data) {
|
|
525
|
+
const alias = data.alias;
|
|
526
|
+
const select = data.select;
|
|
527
|
+
const relationType = data.type;
|
|
528
|
+
const constraintOps = data.constraintOps;
|
|
529
|
+
const quotedAlias = this.dialect.quoteIdentifier(alias);
|
|
530
|
+
const quotedTable = this.dialect.quoteIdentifier(this.table);
|
|
531
|
+
if (!(this.selectColumns.length > 0) && !this.selectRaw.includes(`${quotedTable}.*`)) this.selectRaw.unshift(`${quotedTable}.*`);
|
|
532
|
+
if (relationType === "hasMany") {
|
|
533
|
+
const relatedTable = data.table;
|
|
534
|
+
const foreignKey = data.foreignKey;
|
|
535
|
+
const localKey = data.localKey;
|
|
536
|
+
const quotedRelatedTable = this.dialect.quoteIdentifier(relatedTable);
|
|
537
|
+
const quotedForeignKey = this.dialect.quoteIdentifier(foreignKey);
|
|
538
|
+
const quotedLocalKey = this.dialect.quoteIdentifier(localKey);
|
|
539
|
+
const quotedMainTable = this.dialect.quoteIdentifier(this.table);
|
|
540
|
+
let innerSelect;
|
|
541
|
+
if (select && select.length > 0) innerSelect = `json_agg(json_build_object(${select.map((col) => `'${col}', a.${this.dialect.quoteIdentifier(col)}`).join(", ")}))`;
|
|
542
|
+
else innerSelect = `json_agg(row_to_json(a.*))`;
|
|
543
|
+
const fkCondition = `a.${quotedForeignKey} = ${quotedMainTable}.${quotedLocalKey}`;
|
|
544
|
+
let extraWhere = "";
|
|
545
|
+
let orderBy = "";
|
|
546
|
+
let limitClause = "";
|
|
547
|
+
if (constraintOps && constraintOps.length > 0) {
|
|
548
|
+
const subParser = new PostgresQueryParser({
|
|
549
|
+
table: relatedTable,
|
|
550
|
+
alias: "a",
|
|
551
|
+
operations: constraintOps
|
|
552
|
+
});
|
|
553
|
+
subParser.parse();
|
|
554
|
+
const renumber = this.absorbSubParserParams(subParser);
|
|
555
|
+
if (subParser.whereClauses.length > 0) extraWhere = ` AND ${renumber(subParser.whereClauses.join(" "))}`;
|
|
556
|
+
if (subParser.orderClauses.length > 0) orderBy = ` ORDER BY ${renumber(subParser.orderClauses.join(", "))}`;
|
|
557
|
+
if (subParser.limitValue !== void 0) limitClause = ` LIMIT ${subParser.limitValue}`;
|
|
558
|
+
}
|
|
559
|
+
orderBy || limitClause ? `${quotedRelatedTable}${fkCondition}${extraWhere}${orderBy}${limitClause}` : `${innerSelect.replace("json_agg(", "").replace(/\)$/, "")}${quotedRelatedTable}${fkCondition}${extraWhere}`;
|
|
560
|
+
const aggregated = orderBy || limitClause ? `(SELECT json_agg(row_to_json(sub.*)) FROM (SELECT * FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}${orderBy}${limitClause}) sub) AS ${quotedAlias}` : `(SELECT ${innerSelect} FROM ${quotedRelatedTable} a WHERE ${fkCondition}${extraWhere}) AS ${quotedAlias}`;
|
|
561
|
+
this.selectRaw.push(aggregated);
|
|
562
|
+
} else {
|
|
563
|
+
let effectiveSelect = select;
|
|
564
|
+
if (constraintOps && constraintOps.length > 0) {
|
|
565
|
+
const subParser = new PostgresQueryParser({
|
|
566
|
+
table: data.table ?? alias,
|
|
567
|
+
alias,
|
|
568
|
+
operations: constraintOps
|
|
569
|
+
});
|
|
570
|
+
subParser.parse();
|
|
571
|
+
if (subParser.selectColumns.length > 0) effectiveSelect = subParser.selectColumns;
|
|
572
|
+
}
|
|
573
|
+
if (effectiveSelect && effectiveSelect.length > 0) {
|
|
574
|
+
const selectedColumns = effectiveSelect.map((col) => `${quotedAlias}.${this.dialect.quoteIdentifier(col)}`).join(", ");
|
|
575
|
+
this.selectRaw.push(`row_to_json((SELECT d FROM (SELECT ${selectedColumns}) d)) AS ${quotedAlias}`);
|
|
576
|
+
} else this.selectRaw.push(`row_to_json(${quotedAlias}.*) AS ${quotedAlias}`);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Process JOIN operation with smart field detection.
|
|
581
|
+
*
|
|
582
|
+
* Handles both regular columns and JSONB nested paths:
|
|
583
|
+
* - "id" → "table"."id" (auto-prefixed)
|
|
584
|
+
* - "users.id" → "users"."id" (explicit table)
|
|
585
|
+
* - "createdBy.id" → "table"."createdBy"->>'id' (JSONB path)
|
|
586
|
+
* - "posts.createdBy.id" → "posts"."createdBy"->>'id' (JSONB with table)
|
|
587
|
+
*/
|
|
588
|
+
processJoin(data, type) {
|
|
589
|
+
const options = data;
|
|
590
|
+
const joinTable = "table" in options ? options.table : "";
|
|
591
|
+
const localField = "localField" in options ? options.localField : "";
|
|
592
|
+
const foreignField = "foreignField" in options ? options.foreignField : "";
|
|
593
|
+
const alias = "alias" in options ? options.alias : void 0;
|
|
594
|
+
const constraintOps = data.constraintOps ?? [];
|
|
595
|
+
const quotedTable = this.dialect.quoteIdentifier(joinTable);
|
|
596
|
+
const tableRef = alias ? `${quotedTable} AS ${this.dialect.quoteIdentifier(alias)}` : quotedTable;
|
|
597
|
+
const tableAlias = alias ?? joinTable;
|
|
598
|
+
this.joinedTables.add(joinTable);
|
|
599
|
+
if (alias) this.joinedTables.add(alias);
|
|
600
|
+
let onClause = `${this.parseColumnIdentifier(localField, this.table, this.alias)} = ${this.parseColumnIdentifier(foreignField, joinTable, tableAlias)}`;
|
|
601
|
+
if (constraintOps.length > 0) {
|
|
602
|
+
const whereOps = constraintOps.filter((op) => op.type.startsWith("where") || op.type.startsWith("orWhere"));
|
|
603
|
+
if (whereOps.length > 0) {
|
|
604
|
+
const subParser = new PostgresQueryParser({
|
|
605
|
+
table: joinTable,
|
|
606
|
+
alias: tableAlias,
|
|
607
|
+
operations: whereOps
|
|
608
|
+
});
|
|
609
|
+
subParser.parse();
|
|
610
|
+
if (subParser.whereClauses.length > 0) {
|
|
611
|
+
const renumber = this.absorbSubParserParams(subParser);
|
|
612
|
+
onClause = `${onClause} AND ${renumber(subParser.whereClauses.join(" "))}`;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
this.joinClauses.push(`${type} JOIN ${tableRef} ON ${onClause}`);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Parse a column identifier with smart detection for table prefixes and JSONB paths.
|
|
620
|
+
*
|
|
621
|
+
* Supports an optional explicit cast suffix using PostgreSQL's `::type` syntax,
|
|
622
|
+
* which is the only way to coerce a JSONB-extracted value (always returned as
|
|
623
|
+
* `text`) into another type. The parser does NOT infer casts from key names —
|
|
624
|
+
* coercion is always opt-in by the caller.
|
|
625
|
+
*
|
|
626
|
+
* @param field - The field string. Examples:
|
|
627
|
+
* - "id" → `"table"."id"`
|
|
628
|
+
* - "users.id" → `"users"."id"`
|
|
629
|
+
* - "createdBy.id" → `"table"."createdBy"->>'id'`
|
|
630
|
+
* - "createdBy.id::int" → `("table"."createdBy"->>'id')::int`
|
|
631
|
+
* - "meta.score::numeric" → `("table"."meta"->>'score')::numeric`
|
|
632
|
+
* - "posts.createdBy.id::uuid" → `("posts"."createdBy"->>'id')::uuid`
|
|
633
|
+
* @param defaultTable - Default table to use if no prefix
|
|
634
|
+
* @param tableAlias - Table alias to use if provided
|
|
635
|
+
* @returns Properly quoted SQL expression
|
|
636
|
+
*/
|
|
637
|
+
parseColumnIdentifier(field, defaultTable, tableAlias) {
|
|
638
|
+
if (!field) return "";
|
|
639
|
+
let cast;
|
|
640
|
+
const castIndex = field.indexOf("::");
|
|
641
|
+
if (castIndex !== -1) {
|
|
642
|
+
cast = field.slice(castIndex + 2).trim();
|
|
643
|
+
field = field.slice(0, castIndex);
|
|
644
|
+
}
|
|
645
|
+
const effectiveTable = tableAlias ?? defaultTable;
|
|
646
|
+
const parts = field.split(".");
|
|
647
|
+
let expression;
|
|
648
|
+
if (parts.length === 1) expression = `${this.dialect.quoteIdentifier(effectiveTable)}.${this.dialect.quoteIdentifier(field)}`;
|
|
649
|
+
else if (parts.length === 2) {
|
|
650
|
+
const [first, second] = parts;
|
|
651
|
+
if (this.isTableReference(first)) expression = `${this.dialect.quoteIdentifier(first)}.${this.dialect.quoteIdentifier(second)}`;
|
|
652
|
+
else expression = this.buildJsonbPath(effectiveTable, first, [second]);
|
|
653
|
+
} else {
|
|
654
|
+
const [first, second, ...rest] = parts;
|
|
655
|
+
if (this.isTableReference(first)) expression = this.buildJsonbPath(first, second, rest);
|
|
656
|
+
else expression = this.buildJsonbPath(effectiveTable, first, [second, ...rest]);
|
|
657
|
+
}
|
|
658
|
+
return cast ? `(${expression})::${cast}` : expression;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Check if a string is a table reference (main table or join table).
|
|
662
|
+
*/
|
|
663
|
+
isTableReference(name) {
|
|
664
|
+
if (name === this.table || name === this.alias) return true;
|
|
665
|
+
if (this.joinedTables.has(name)) return true;
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Build a JSONB path expression.
|
|
670
|
+
*
|
|
671
|
+
* @param table - Table name
|
|
672
|
+
* @param column - JSONB column name
|
|
673
|
+
* @param path - Array of nested keys
|
|
674
|
+
* @returns PostgreSQL JSONB path expression
|
|
675
|
+
*
|
|
676
|
+
* Returns the raw JSONB path expression — extracted values are always `text`
|
|
677
|
+
* (`->>` returns text). Callers that need a different type must request an
|
|
678
|
+
* explicit cast via the `::type` suffix in `parseColumnIdentifier`.
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* buildJsonbPath("posts", "createdBy", ["id"])
|
|
682
|
+
* // Returns: "posts"."createdBy"->>'id'
|
|
683
|
+
*
|
|
684
|
+
* buildJsonbPath("posts", "createdBy", ["address", "city"])
|
|
685
|
+
* // Returns: "posts"."createdBy"->'address'->>'city'
|
|
686
|
+
*/
|
|
687
|
+
buildJsonbPath(table, column, path) {
|
|
688
|
+
const quotedTable = this.dialect.quoteIdentifier(table);
|
|
689
|
+
const quotedColumn = this.dialect.quoteIdentifier(column);
|
|
690
|
+
if (path.length === 0) return `${quotedTable}.${quotedColumn}`;
|
|
691
|
+
let expression = `${quotedTable}.${quotedColumn}`;
|
|
692
|
+
for (let i = 0; i < path.length; i++) {
|
|
693
|
+
const operator = i === path.length - 1 ? "->>" : "->";
|
|
694
|
+
expression += `${operator}'${path[i]}'`;
|
|
695
|
+
}
|
|
696
|
+
return expression;
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Process CROSS JOIN operation.
|
|
700
|
+
*/
|
|
701
|
+
processCrossJoin(data) {
|
|
702
|
+
const table = data.table;
|
|
703
|
+
const quotedTable = this.dialect.quoteIdentifier(table);
|
|
704
|
+
this.joinClauses.push(`CROSS JOIN ${quotedTable}`);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Process raw JOIN expression.
|
|
708
|
+
*/
|
|
709
|
+
processJoinRaw(data) {
|
|
710
|
+
const expression = data.expression;
|
|
711
|
+
const bindings = data.bindings ?? [];
|
|
712
|
+
let processed = expression;
|
|
713
|
+
for (const binding of bindings) processed = processed.replace("?", this.addParam(binding));
|
|
714
|
+
this.joinClauses.push(processed);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Process ORDER BY operation.
|
|
718
|
+
*/
|
|
719
|
+
processOrderBy(data) {
|
|
720
|
+
const field = data.field;
|
|
721
|
+
const direction = (data.direction ?? "asc").toUpperCase();
|
|
722
|
+
const quotedField = this.parseColumnIdentifier(field, this.table, this.alias);
|
|
723
|
+
this.orderClauses.push(`${quotedField} ${direction}`);
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Process raw ORDER BY expression.
|
|
727
|
+
*/
|
|
728
|
+
processOrderByRaw(data) {
|
|
729
|
+
const expression = data.expression;
|
|
730
|
+
const bindings = data.bindings ?? [];
|
|
731
|
+
let processed = expression;
|
|
732
|
+
for (const binding of bindings) processed = processed.replace("?", this.addParam(binding));
|
|
733
|
+
this.orderClauses.push(processed);
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Process GROUP BY operation.
|
|
737
|
+
*/
|
|
738
|
+
processGroupBy(data) {
|
|
739
|
+
const fields = data.fields;
|
|
740
|
+
const columns = Array.isArray(fields) ? fields : [fields];
|
|
741
|
+
this.groupColumns.push(...columns);
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Process HAVING operation.
|
|
745
|
+
*/
|
|
746
|
+
processHaving(data) {
|
|
747
|
+
const field = data.field;
|
|
748
|
+
const operator = data.operator ?? "=";
|
|
749
|
+
const value = data.value;
|
|
750
|
+
const quotedField = this.dialect.quoteIdentifier(field);
|
|
751
|
+
const placeholder = this.addParam(value);
|
|
752
|
+
this.havingClauses.push(`${quotedField} ${operator} ${placeholder}`);
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Process a raw HAVING expression, threading `?` placeholders into
|
|
756
|
+
* positional params the same way `processWhereRaw` / `processSelectRaw` do.
|
|
757
|
+
* Without this, bindings on a `havingRaw` op are silently dropped.
|
|
758
|
+
*/
|
|
759
|
+
processHavingRaw(data) {
|
|
760
|
+
let expression = data.expression;
|
|
761
|
+
const bindings = data.bindings ?? [];
|
|
762
|
+
for (const binding of bindings) expression = expression.replace("?", this.addParam(binding));
|
|
763
|
+
this.havingClauses.push(expression);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Add a WHERE clause with boolean operator.
|
|
767
|
+
*/
|
|
768
|
+
addWhereClause(clause, boolean) {
|
|
769
|
+
if (this.whereClauses.length === 0) this.whereClauses.push(clause);
|
|
770
|
+
else this.whereClauses.push(`${boolean} ${clause}`);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Map simple Cascade operators to their SQL equivalents.
|
|
774
|
+
*
|
|
775
|
+
* Complex operators (between, in, like-variants, exists) are handled by
|
|
776
|
+
* dedicated processors and should never reach this method.
|
|
777
|
+
*/
|
|
778
|
+
mapOperator(operator) {
|
|
779
|
+
return {
|
|
780
|
+
"=": "=",
|
|
781
|
+
"!=": "!=",
|
|
782
|
+
"<>": "<>",
|
|
783
|
+
">": ">",
|
|
784
|
+
">=": ">=",
|
|
785
|
+
"<": "<",
|
|
786
|
+
"<=": "<=",
|
|
787
|
+
like: "LIKE",
|
|
788
|
+
notlike: "NOT LIKE",
|
|
789
|
+
ilike: "ILIKE"
|
|
790
|
+
}[operator.toLowerCase()] ?? operator;
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
//#endregion
|
|
795
|
+
export { PostgresQueryParser };
|
|
796
|
+
//# sourceMappingURL=postgres-query-parser.mjs.map
|