@warlock.js/cascade 5.30.0 → 5.32.0
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/CHANGELOG.md +17 -0
- package/README.md +1 -5
- package/cjs/index.cjs +104 -86
- package/cjs/index.cjs.map +1 -1
- package/esm/context/database-data-source-context.d.mts +2 -3
- package/esm/context/database-data-source-context.d.mts.map +1 -1
- package/esm/context/database-transaction-context.d.mts +2 -3
- package/esm/context/database-transaction-context.d.mts.map +1 -1
- package/esm/contracts/database-driver.contract.d.mts +56 -36
- package/esm/contracts/database-driver.contract.d.mts.map +1 -1
- package/esm/contracts/database-id-generator.contract.d.mts +7 -5
- package/esm/contracts/database-id-generator.contract.d.mts.map +1 -1
- package/esm/contracts/database-remover.contract.d.mts +3 -5
- package/esm/contracts/database-remover.contract.d.mts.map +1 -1
- package/esm/contracts/database-restorer.contract.d.mts +6 -6
- package/esm/contracts/database-restorer.contract.d.mts.map +1 -1
- package/esm/contracts/database-writer.contract.d.mts +4 -6
- package/esm/contracts/database-writer.contract.d.mts.map +1 -1
- package/esm/contracts/driver-blueprint.contract.d.mts +2 -3
- package/esm/contracts/driver-blueprint.contract.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/migration-driver.contract.d.mts +101 -53
- package/esm/contracts/migration-driver.contract.d.mts.map +1 -1
- package/esm/contracts/query-builder.contract.d.mts +51 -33
- package/esm/contracts/query-builder.contract.d.mts.map +1 -1
- package/esm/contracts/sync-adapter.contract.d.mts +25 -14
- package/esm/contracts/sync-adapter.contract.d.mts.map +1 -1
- package/esm/data-source/data-source-registry.d.mts +4 -5
- package/esm/data-source/data-source-registry.d.mts.map +1 -1
- package/esm/data-source/data-source-registry.mjs.map +1 -1
- package/esm/data-source/data-source.d.mts +8 -5
- package/esm/data-source/data-source.d.mts.map +1 -1
- package/esm/database-dirty-tracker.d.mts +2 -2
- package/esm/database-dirty-tracker.d.mts.map +1 -1
- package/esm/database-dirty-tracker.mjs +3 -2
- package/esm/database-dirty-tracker.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-driver.d.mts +3 -4
- package/esm/drivers/mongodb/mongodb-driver.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-driver.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts +2 -3
- package/esm/drivers/mongodb/mongodb-id-generator.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-id-generator.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts +1 -3
- package/esm/drivers/mongodb/mongodb-migration-driver.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts +2 -3
- package/esm/drivers/mongodb/mongodb-query-builder.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-builder.mjs +8 -5
- package/esm/drivers/mongodb/mongodb-query-builder.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts +1 -3
- package/esm/drivers/mongodb/mongodb-query-operations.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-operations.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts +7 -6
- package/esm/drivers/mongodb/mongodb-query-parser.d.mts.map +1 -1
- package/esm/drivers/mongodb/mongodb-query-parser.mjs +2 -6
- package/esm/drivers/mongodb/mongodb-query-parser.mjs.map +1 -1
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts +1 -3
- package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts.map +1 -1
- package/esm/drivers/mongodb/types.d.mts +11 -9
- package/esm/drivers/mongodb/types.d.mts.map +1 -1
- package/esm/drivers/postgres/index.d.mts +2 -1
- package/esm/drivers/postgres/index.mjs +1 -1
- package/esm/drivers/postgres/naming.mjs +1 -1
- package/esm/drivers/postgres/naming.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-blueprint.d.mts +1 -3
- package/esm/drivers/postgres/postgres-blueprint.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-dialect.d.mts +4 -6
- package/esm/drivers/postgres/postgres-dialect.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-dialect.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-driver.d.mts +4 -5
- package/esm/drivers/postgres/postgres-driver.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-driver.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-migration-driver.d.mts +1 -3
- package/esm/drivers/postgres/postgres-migration-driver.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-migration-driver.mjs +13 -10
- package/esm/drivers/postgres/postgres-migration-driver.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-query-builder.d.mts +4 -4
- package/esm/drivers/postgres/postgres-query-builder.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-query-builder.mjs +14 -10
- package/esm/drivers/postgres/postgres-query-builder.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-query-parser.d.mts +16 -11
- package/esm/drivers/postgres/postgres-query-parser.d.mts.map +1 -1
- package/esm/drivers/postgres/postgres-query-parser.mjs +1 -2
- package/esm/drivers/postgres/postgres-query-parser.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-sql-serializer.mjs +13 -10
- package/esm/drivers/postgres/postgres-sql-serializer.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-ttl-purge.mjs +1 -1
- package/esm/drivers/postgres/postgres-ttl-purge.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-type-converters.mjs +2 -2
- package/esm/drivers/postgres/postgres-type-converters.mjs.map +1 -1
- package/esm/drivers/postgres/postgres-update-validator.mjs +1 -1
- package/esm/drivers/postgres/postgres-update-validator.mjs.map +1 -1
- package/esm/drivers/postgres/types.d.mts +87 -45
- package/esm/drivers/postgres/types.d.mts.map +1 -1
- package/esm/drivers/sql/sql-dialect.contract.d.mts +1 -3
- package/esm/drivers/sql/sql-dialect.contract.d.mts.map +1 -1
- package/esm/drivers/sql/sql-types.d.mts +113 -59
- package/esm/drivers/sql/sql-types.d.mts.map +1 -1
- package/esm/errors/missing-data-source.error.d.mts +1 -2
- package/esm/errors/missing-data-source.error.d.mts.map +1 -1
- package/esm/errors/transaction-rollback.error.d.mts +1 -2
- package/esm/errors/transaction-rollback.error.d.mts.map +1 -1
- package/esm/errors/undefined-where-value.error.d.mts +1 -2
- package/esm/errors/undefined-where-value.error.d.mts.map +1 -1
- package/esm/errors/unsafe-filter.error.d.mts +1 -2
- package/esm/errors/unsafe-filter.error.d.mts.map +1 -1
- package/esm/errors/unsafe-raw-expression.error.d.mts +1 -2
- package/esm/errors/unsafe-raw-expression.error.d.mts.map +1 -1
- package/esm/errors/unsupported-lean-operation.error.d.mts +1 -2
- package/esm/errors/unsupported-lean-operation.error.d.mts.map +1 -1
- package/esm/errors/unsupported-lock-for-update.error.d.mts +1 -2
- package/esm/errors/unsupported-lock-for-update.error.d.mts.map +1 -1
- package/esm/errors/unsupported-query-operation.error.d.mts +1 -2
- package/esm/errors/unsupported-query-operation.error.d.mts.map +1 -1
- package/esm/errors/unsupported-query-operation.error.mjs.map +1 -1
- package/esm/errors/unsupported-update-operation.error.d.mts +1 -2
- package/esm/errors/unsupported-update-operation.error.d.mts.map +1 -1
- package/esm/events/model-events.d.mts +8 -6
- package/esm/events/model-events.d.mts.map +1 -1
- package/esm/expressions/aggregate-expressions.d.mts +7 -7
- package/esm/expressions/aggregate-expressions.d.mts.map +1 -1
- package/esm/expressions/column-expressions.d.mts +11 -11
- package/esm/expressions/column-expressions.d.mts.map +1 -1
- package/esm/expressions/column-expressions.mjs.map +1 -1
- package/esm/index.d.mts +7 -2
- package/esm/index.mjs +1 -1
- package/esm/migration/column-builder.d.mts +2 -3
- package/esm/migration/column-builder.d.mts.map +1 -1
- package/esm/migration/column-helpers.d.mts +49 -50
- package/esm/migration/column-helpers.d.mts.map +1 -1
- package/esm/migration/column-helpers.mjs +1 -1
- package/esm/migration/foreign-key-builder.d.mts +2 -3
- package/esm/migration/foreign-key-builder.d.mts.map +1 -1
- package/esm/migration/foreign-key-builder.mjs.map +1 -1
- package/esm/migration/index.d.mts +3 -2
- package/esm/migration/index.mjs +2 -2
- package/esm/migration/migration-runner.d.mts +7 -6
- package/esm/migration/migration-runner.d.mts.map +1 -1
- package/esm/migration/migration-runner.mjs +15 -11
- package/esm/migration/migration-runner.mjs.map +1 -1
- package/esm/migration/migration.d.mts +50 -32
- package/esm/migration/migration.d.mts.map +1 -1
- package/esm/migration/migration.mjs +1 -3
- package/esm/migration/migration.mjs.map +1 -1
- package/esm/migration/parse-created-at.mjs.map +1 -1
- package/esm/migration/sql-grammar.mjs.map +1 -1
- package/esm/migration/sql-serializer.d.mts +1 -3
- package/esm/migration/sql-serializer.d.mts.map +1 -1
- package/esm/migration/types.d.mts +7 -7
- package/esm/migration/types.d.mts.map +1 -1
- package/esm/model/generate-model-id.mjs.map +1 -1
- package/esm/model/methods/accessor-methods.mjs +1 -1
- package/esm/model/methods/accessor-methods.mjs.map +1 -1
- package/esm/model/methods/dirty-methods.mjs.map +1 -1
- package/esm/model/methods/hydration-methods.mjs.map +1 -1
- package/esm/model/methods/meta-methods.mjs +4 -2
- package/esm/model/methods/meta-methods.mjs.map +1 -1
- package/esm/model/methods/query-methods.mjs +1 -1
- package/esm/model/methods/query-methods.mjs.map +1 -1
- package/esm/model/methods/scope-methods.mjs.map +1 -1
- package/esm/model/methods/static-event-methods.mjs.map +1 -1
- package/esm/model/methods/write-methods.d.mts +3 -2
- package/esm/model/methods/write-methods.d.mts.map +1 -1
- package/esm/model/methods/write-methods.mjs +5 -2
- package/esm/model/methods/write-methods.mjs.map +1 -1
- package/esm/model/model.d.mts +9 -9
- package/esm/model/model.d.mts.map +1 -1
- package/esm/model/model.mjs.map +1 -1
- package/esm/model/model.types.d.mts +7 -7
- package/esm/model/model.types.d.mts.map +1 -1
- package/esm/model/register-model.d.mts +13 -15
- package/esm/model/register-model.d.mts.map +1 -1
- package/esm/model/register-model.mjs.map +1 -1
- package/esm/model/relation-decorators.d.mts +6 -8
- package/esm/model/relation-decorators.d.mts.map +1 -1
- package/esm/operations/database.d.mts +13 -8
- package/esm/operations/database.d.mts.map +1 -1
- package/esm/operations/index.d.mts +2 -1
- package/esm/operations/index.mjs +1 -1
- package/esm/operations/migrations.d.mts +18 -14
- package/esm/operations/migrations.d.mts.map +1 -1
- package/esm/operations/migrations.mjs.map +1 -1
- package/esm/query-builder/query-builder.d.mts +2 -4
- package/esm/query-builder/query-builder.d.mts.map +1 -1
- package/esm/query-builder/query-builder.mjs +12 -11
- package/esm/query-builder/query-builder.mjs.map +1 -1
- package/esm/relations/index.d.mts +2 -1
- package/esm/relations/index.mjs +1 -1
- package/esm/relations/key-conventions.mjs +2 -1
- package/esm/relations/key-conventions.mjs.map +1 -1
- package/esm/relations/pivot-operations.d.mts +3 -5
- package/esm/relations/pivot-operations.d.mts.map +1 -1
- package/esm/relations/pivot-operations.mjs.map +1 -1
- package/esm/relations/relation-hydrator.d.mts +3 -5
- package/esm/relations/relation-hydrator.d.mts.map +1 -1
- package/esm/relations/relation-loader.d.mts +2 -4
- package/esm/relations/relation-loader.d.mts.map +1 -1
- package/esm/relations/relation-loader.mjs +4 -5
- package/esm/relations/relation-loader.mjs.map +1 -1
- package/esm/relations/types.d.mts +14 -15
- package/esm/relations/types.d.mts.map +1 -1
- package/esm/remover/database-remover.d.mts +1 -3
- package/esm/remover/database-remover.d.mts.map +1 -1
- package/esm/remover/database-remover.mjs.map +1 -1
- package/esm/restorer/database-restorer.d.mts +1 -3
- package/esm/restorer/database-restorer.d.mts.map +1 -1
- package/esm/restorer/database-restorer.mjs +2 -1
- package/esm/restorer/database-restorer.mjs.map +1 -1
- package/esm/sql-database-dirty-tracker.d.mts +1 -3
- package/esm/sql-database-dirty-tracker.d.mts.map +1 -1
- package/esm/sync/model-events.mjs +1 -1
- package/esm/sync/model-sync-operation.d.mts +2 -4
- package/esm/sync/model-sync-operation.d.mts.map +1 -1
- package/esm/sync/model-sync.d.mts +3 -4
- package/esm/sync/model-sync.d.mts.map +1 -1
- package/esm/sync/sync-context.d.mts +2 -4
- package/esm/sync/sync-context.d.mts.map +1 -1
- package/esm/sync/sync-context.mjs.map +1 -1
- package/esm/sync/sync-fanout.mjs +1 -1
- package/esm/sync/sync-fanout.mjs.map +1 -1
- package/esm/sync/sync-manager.d.mts +2 -4
- package/esm/sync/sync-manager.d.mts.map +1 -1
- package/esm/sync/sync-manager.mjs.map +1 -1
- package/esm/sync/types.d.mts +121 -64
- package/esm/sync/types.d.mts.map +1 -1
- package/esm/transactions/after-commit.d.mts +2 -2
- package/esm/transactions/after-commit.d.mts.map +1 -1
- package/esm/types.d.mts +7 -8
- package/esm/types.d.mts.map +1 -1
- package/esm/utils/connect-to-database.d.mts +7 -8
- package/esm/utils/connect-to-database.d.mts.map +1 -1
- package/esm/utils/database-writer.utils.d.mts +3 -4
- package/esm/utils/database-writer.utils.d.mts.map +1 -1
- package/esm/utils/database-writer.utils.mjs.map +1 -1
- package/esm/utils/define-model.d.mts +3 -5
- package/esm/utils/define-model.d.mts.map +1 -1
- package/esm/utils/escape-regex.d.mts +3 -4
- package/esm/utils/escape-regex.d.mts.map +1 -1
- package/esm/utils/is-valid-date-value.mjs.map +1 -1
- package/esm/utils/once-connected.d.mts +2 -4
- package/esm/utils/once-connected.d.mts.map +1 -1
- package/esm/utils/sanitize-filter.d.mts +3 -4
- package/esm/utils/sanitize-filter.d.mts.map +1 -1
- package/esm/validation/database-seal-plugins.d.mts +2 -1
- package/esm/validation/database-writer-validation-error.d.mts +1 -3
- package/esm/validation/database-writer-validation-error.d.mts.map +1 -1
- package/esm/validation/index.d.mts +3 -1
- package/esm/validation/index.mjs +1 -1
- package/esm/validation/plugins/database-rules-plugin.d.mts +2 -3
- package/esm/validation/plugins/database-rules-plugin.d.mts.map +1 -1
- package/esm/validation/plugins/embed-validator-plugin.d.mts +4 -3
- package/esm/validation/plugins/embed-validator-plugin.d.mts.map +1 -1
- package/esm/validation/types.d.mts +14 -10
- package/esm/validation/types.d.mts.map +1 -1
- package/esm/validation/validators/embed-validator.d.mts +2 -3
- package/esm/validation/validators/embed-validator.d.mts.map +1 -1
- package/esm/writer/database-writer.d.mts +1 -3
- package/esm/writer/database-writer.d.mts.map +1 -1
- package/esm/writer/database-writer.mjs +1 -1
- package/esm/writer/database-writer.mjs.map +1 -1
- package/llms-full.txt +541 -434
- package/package.json +5 -5
- package/skills/aggregate-data/SKILL.md +28 -17
- package/skills/alter-migration/SKILL.md +325 -233
- package/skills/cascade-basics/SKILL.md +19 -19
- package/skills/configure-delete-strategy/SKILL.md +11 -11
- package/skills/define-model/SKILL.md +19 -17
- package/skills/define-relations/SKILL.md +13 -18
- package/skills/index.md +3 -0
- package/skills/manage-transactions/SKILL.md +18 -12
- package/skills/paginate-results/SKILL.md +6 -8
- package/skills/perform-atomic-ops/SKILL.md +26 -21
- package/skills/query-data/SKILL.md +27 -33
- package/skills/run-cascade-cli/SKILL.md +11 -10
- package/skills/search-by-vector/SKILL.md +8 -5
- package/skills/subscribe-to-model-events/SKILL.md +17 -17
- package/skills/track-changes/SKILL.md +9 -9
- package/skills/write-migration/SKILL.md +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-query-operations.d.mts","names":[],"sources":["../../../../../../../../../packages/cascade/src/drivers/mongodb/mongodb-query-operations.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mongodb-query-operations.d.mts","names":[],"sources":["../../../../../../../../../packages/cascade/src/drivers/mongodb/mongodb-query-operations.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqCa;UAiBgB;;;;;;;;;;;;;;;;;EAA3B,YAA2B,YAAY;EAEhC,cAAc,YAAY;;;;;;;;;;;;;;;;;;;;;;;;EA2B1B,kBAAkB,cAAc,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;EAkC/D,oBAAoB,cAAc,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCjE,iBAAiB,cAAc,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;EAkC9D,kBAAkB,cAAc,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwC/D,mBAAmB,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0CvC,aACL,OAAO,eACP,cACA,MAAM,yBACN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-query-operations.mjs","names":[],"sources":["../../../../../../../../../packages/cascade/src/drivers/mongodb/mongodb-query-operations.ts"],"sourcesContent":["import type { Operation, PipelineStage } from \"./types\";\n\n/**\n * Helper class for constructing MongoDB aggregation pipeline operations.\n *\n * This class encapsulates the logic for creating operation objects that will be\n * converted to MongoDB aggregation stages by the query parser. It provides a\n * clean abstraction over the low-level operation structure, making the query\n * builder code more maintainable and testable.\n *\n * Each operation consists of:\n * - **stage**: The MongoDB aggregation stage name (e.g., \"$match\", \"$project\")\n * - **type**: An internal identifier for the operation type\n * - **data**: The data associated with the operation\n * - **mergeable**: Whether this operation can be merged with adjacent similar operations\n *\n * @internal This class is for internal use within the MongoDB driver\n *\n * @example\n * ```typescript\n * const operations: Operation[] = [];\n * const helper = new MongoQueryOperations(operations);\n *\n * // Add a match operation\n * helper.addMatchOperation(\"whereIn\", { field: \"status\", values: [\"active\", \"pending\"] });\n *\n * // Add a project operation\n * helper.addProjectOperation(\"select\", { fields: [\"name\", \"email\"] });\n *\n * // Operations array is now populated\n * console.log(operations);\n * // [\n * // { stage: \"$match\", mergeable: true, type: \"whereIn\", data: {...} },\n * // { stage: \"$project\", mergeable: true, type: \"select\", data: {...} }\n * // ]\n * ```\n */\nexport class MongoQueryOperations {\n /**\n * Creates a new operations helper.\n *\n * The helper maintains a reference to the operations array and populates it\n * as methods are called. This allows the query builder to maintain a single\n * ordered list of operations that will be converted to a MongoDB aggregation\n * pipeline.\n *\n * @param operations - Reference to the operations array to populate\n *\n * @example\n * ```typescript\n * const operations: Operation[] = [];\n * const helper = new MongoQueryOperations(operations);\n * ```\n */\n public constructor(private operations: Operation[]) {}\n\n public setOperations(operations: Operation[]): void {\n this.operations = operations;\n }\n\n /**\n * Adds a $match stage operation to the pipeline.\n *\n * Match operations filter documents in the aggregation pipeline, similar to\n * the WHERE clause in SQL. Multiple match operations can be merged together\n * by the parser for optimization.\n *\n * @param type - The operation type identifier (e.g., \"where\", \"whereIn\", \"whereLike\")\n * @param data - The operation data data containing filter criteria\n * @param mergeable - Whether this operation can be merged with adjacent match operations (default: true)\n *\n * @example\n * ```typescript\n * // Simple where operation\n * helper.addMatchOperation(\"where\", { field: \"age\", operator: \">\", value: 18 });\n *\n * // WhereIn operation\n * helper.addMatchOperation(\"whereIn\", { field: \"status\", values: [\"active\", \"pending\"] });\n *\n * // Non-mergeable match (e.g., after a group stage)\n * helper.addMatchOperation(\"having\", { field: \"count\", operator: \">\", value: 5 }, false);\n * ```\n */\n public addMatchOperation(type: string, data: Record<string, unknown>, mergeable = true): void {\n this.operations.push({\n stage: \"$match\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $project stage operation to the pipeline.\n *\n * Project operations control which fields are included or excluded in the\n * output documents, similar to the SELECT clause in SQL. They can also be\n * used to compute new fields or reshape documents.\n *\n * @param type - The operation type identifier (e.g., \"select\", \"deselect\", \"selectRaw\")\n * @param data - The operation data data containing projection specifications\n * @param mergeable - Whether this operation can be merged with adjacent project operations (default: true)\n *\n * @example\n * ```typescript\n * // Select specific fields\n * helper.addProjectOperation(\"select\", { fields: [\"name\", \"email\", \"age\"] });\n *\n * // Deselect fields\n * helper.addProjectOperation(\"deselect\", { fields: [\"password\", \"secret\"] });\n *\n * // Computed field\n * helper.addProjectOperation(\"selectRaw\", {\n * expression: { fullName: { $concat: [\"$firstName\", \" \", \"$lastName\"] } }\n * });\n * ```\n */\n public addProjectOperation(\n type: string,\n data: Record<string, unknown>,\n mergeable = true,\n ): void {\n this.operations.push({\n stage: \"$project\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $sort stage operation to the pipeline.\n *\n * Sort operations order the documents in the pipeline, similar to the ORDER BY\n * clause in SQL. Multiple sort operations can be merged to create compound\n * sorting.\n *\n * @param type - The operation type identifier (e.g., \"orderBy\", \"orderByRandom\")\n * @param data - The operation data data containing sort specifications\n * @param mergeable - Whether this operation can be merged with adjacent sort operations (default: true)\n *\n * @example\n * ```typescript\n * // Order by a single field\n * helper.addSortOperation(\"orderBy\", { field: \"createdAt\", direction: \"desc\" });\n *\n * // Random ordering (not mergeable)\n * helper.addSortOperation(\"orderByRandom\", {limit: 1000}, false);\n *\n * // Order by raw expression\n * helper.addSortOperation(\"orderByRaw\", {\n * expression: { score: -1, name: 1 }\n * });\n * ```\n */\n public addSortOperation(type: string, data: Record<string, unknown>, mergeable = true): void {\n this.operations.push({\n stage: \"$sort\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $group stage operation to the pipeline.\n *\n * Group operations aggregate documents by specified fields and compute\n * aggregate values, similar to the GROUP BY clause in SQL. Group operations\n * are typically not mergeable as they represent distinct aggregation boundaries.\n *\n * @param type - The operation type identifier (e.g., \"groupBy\", \"distinct\")\n * @param data - The operation data data containing grouping specifications\n * @param mergeable - Whether this operation can be merged with adjacent group operations (default: false)\n *\n * @example\n * ```typescript\n * // Group by a single field\n * helper.addGroupOperation(\"groupBy\", { fields: \"category\" });\n *\n * // Group by multiple fields\n * helper.addGroupOperation(\"groupBy\", {\n * fields: { category: \"$category\", status: \"$status\" }\n * });\n *\n * // Distinct operation (special case of grouping)\n * helper.addGroupOperation(\"distinct\", { fields: [\"email\"] });\n * ```\n */\n public addGroupOperation(\n type: string,\n data: Record<string, unknown>,\n mergeable = false,\n ): void {\n this.operations.push({\n stage: \"$group\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $lookup stage operation to the pipeline.\n *\n * Lookup operations perform left outer joins with other collections, similar\n * to JOIN in SQL. Lookup operations are never mergeable as each represents a\n * distinct join operation.\n *\n * @param type - The operation type identifier (typically \"join\")\n * @param data - The operation data data containing join specifications\n *\n * @example\n * ```typescript\n * // Simple lookup\n * helper.addLookupOperation(\"join\", {\n * table: \"orders\",\n * localField: \"id\",\n * foreignField: \"userId\",\n * alias: \"userOrders\"\n * });\n *\n * // Lookup with pipeline\n * helper.addLookupOperation(\"join\", {\n * table: \"products\",\n * pipeline: [\n * { $match: { inStock: true } },\n * { $sort: { price: 1 } }\n * ],\n * alias: \"availableProducts\"\n * });\n * ```\n */\n public addLookupOperation(type: string, data: Record<string, unknown>): void {\n this.operations.push({\n stage: \"$lookup\",\n mergeable: false,\n type,\n data,\n });\n }\n\n /**\n * Adds a generic stage operation to the pipeline.\n *\n * This method provides flexibility to add any MongoDB aggregation stage,\n * including less common stages like $facet, $bucket, $setWindowFields, etc.\n * Use this for operations that don't fit into the standard categories.\n *\n * @param stage - The MongoDB aggregation stage name (e.g., \"$limit\", \"$skip\", \"$unwind\")\n * @param type - The operation type identifier\n * @param data - The operation data data\n * @param mergeable - Whether this operation can be merged with adjacent operations (default: false)\n *\n * @example\n * ```typescript\n * // Add a limit operation\n * helper.addOperation(\"$limit\", \"limit\", { value: 10 });\n *\n * // Add a skip operation\n * helper.addOperation(\"$skip\", \"skip\", { value: 20 });\n *\n * // Add an unwind operation\n * helper.addOperation(\"$unwind\", \"unwind\", { path: \"$tags\" });\n *\n * // Add a window function\n * helper.addOperation(\"$setWindowFields\", \"selectWindow\", {\n * spec: {\n * partitionBy: \"$category\",\n * sortBy: { price: 1 },\n * output: { rank: { $rank: {} } }\n * }\n * });\n * ```\n */\n public addOperation(\n stage: PipelineStage,\n type: string,\n data: Record<string, unknown>,\n mergeable = false,\n ): void {\n this.operations.push({\n stage,\n mergeable,\n type,\n data,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,uBAAb,MAAkC;CAiBL;;;;;;;;;;;;;;;;;CAA3B,AAAO,YAAY,AAAQ,YAAyB;EAAzB;CAA0B;CAErD,AAAO,cAAc,YAA+B;EAClD,KAAK,aAAa;CACpB;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,AAAO,kBAAkB,MAAc,MAA+B,YAAY,MAAY;EAC5F,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,oBACL,MACA,MACA,YAAY,MACN;EACN,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,iBAAiB,MAAc,MAA+B,YAAY,MAAY;EAC3F,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,kBACL,MACA,MACA,YAAY,OACN;EACN,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCA,AAAO,mBAAmB,MAAc,MAAqC;EAC3E,KAAK,WAAW,KAAK;GACnB,OAAO;GACP,WAAW;GACX;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCA,AAAO,aACL,OACA,MACA,MACA,YAAY,OACN;EACN,KAAK,WAAW,KAAK;GACnB;GACA;GACA;GACA;EACF,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"mongodb-query-operations.mjs","names":[],"sources":["../../../../../../../../../packages/cascade/src/drivers/mongodb/mongodb-query-operations.ts"],"sourcesContent":["import type { Operation, PipelineStage } from \"./types\";\n\n/**\n * Helper class for constructing MongoDB aggregation pipeline operations.\n *\n * This class encapsulates the logic for creating operation objects that will be\n * converted to MongoDB aggregation stages by the query parser. It provides a\n * clean abstraction over the low-level operation structure, making the query\n * builder code more maintainable and testable.\n *\n * Each operation consists of:\n * - **stage**: The MongoDB aggregation stage name (e.g., \"$match\", \"$project\")\n * - **type**: An internal identifier for the operation type\n * - **data**: The data associated with the operation\n * - **mergeable**: Whether this operation can be merged with adjacent similar operations\n *\n * @internal This class is for internal use within the MongoDB driver\n *\n * @example\n * ```typescript\n * const operations: Operation[] = [];\n * const helper = new MongoQueryOperations(operations);\n *\n * // Add a match operation\n * helper.addMatchOperation(\"whereIn\", { field: \"status\", values: [\"active\", \"pending\"] });\n *\n * // Add a project operation\n * helper.addProjectOperation(\"select\", { fields: [\"name\", \"email\"] });\n *\n * // Operations array is now populated\n * console.log(operations);\n * // [\n * // { stage: \"$match\", mergeable: true, type: \"whereIn\", data: {...} },\n * // { stage: \"$project\", mergeable: true, type: \"select\", data: {...} }\n * // ]\n * ```\n */\nexport class MongoQueryOperations {\n /**\n * Creates a new operations helper.\n *\n * The helper maintains a reference to the operations array and populates it\n * as methods are called. This allows the query builder to maintain a single\n * ordered list of operations that will be converted to a MongoDB aggregation\n * pipeline.\n *\n * @param operations - Reference to the operations array to populate\n *\n * @example\n * ```typescript\n * const operations: Operation[] = [];\n * const helper = new MongoQueryOperations(operations);\n * ```\n */\n public constructor(private operations: Operation[]) {}\n\n public setOperations(operations: Operation[]): void {\n this.operations = operations;\n }\n\n /**\n * Adds a $match stage operation to the pipeline.\n *\n * Match operations filter documents in the aggregation pipeline, similar to\n * the WHERE clause in SQL. Multiple match operations can be merged together\n * by the parser for optimization.\n *\n * @param type - The operation type identifier (e.g., \"where\", \"whereIn\", \"whereLike\")\n * @param data - The operation data data containing filter criteria\n * @param mergeable - Whether this operation can be merged with adjacent match operations (default: true)\n *\n * @example\n * ```typescript\n * // Simple where operation\n * helper.addMatchOperation(\"where\", { field: \"age\", operator: \">\", value: 18 });\n *\n * // WhereIn operation\n * helper.addMatchOperation(\"whereIn\", { field: \"status\", values: [\"active\", \"pending\"] });\n *\n * // Non-mergeable match (e.g., after a group stage)\n * helper.addMatchOperation(\"having\", { field: \"count\", operator: \">\", value: 5 }, false);\n * ```\n */\n public addMatchOperation(type: string, data: Record<string, unknown>, mergeable = true): void {\n this.operations.push({\n stage: \"$match\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $project stage operation to the pipeline.\n *\n * Project operations control which fields are included or excluded in the\n * output documents, similar to the SELECT clause in SQL. They can also be\n * used to compute new fields or reshape documents.\n *\n * @param type - The operation type identifier (e.g., \"select\", \"deselect\", \"selectRaw\")\n * @param data - The operation data data containing projection specifications\n * @param mergeable - Whether this operation can be merged with adjacent project operations (default: true)\n *\n * @example\n * ```typescript\n * // Select specific fields\n * helper.addProjectOperation(\"select\", { fields: [\"name\", \"email\", \"age\"] });\n *\n * // Deselect fields\n * helper.addProjectOperation(\"deselect\", { fields: [\"password\", \"secret\"] });\n *\n * // Computed field\n * helper.addProjectOperation(\"selectRaw\", {\n * expression: { fullName: { $concat: [\"$firstName\", \" \", \"$lastName\"] } }\n * });\n * ```\n */\n public addProjectOperation(type: string, data: Record<string, unknown>, mergeable = true): void {\n this.operations.push({\n stage: \"$project\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $sort stage operation to the pipeline.\n *\n * Sort operations order the documents in the pipeline, similar to the ORDER BY\n * clause in SQL. Multiple sort operations can be merged to create compound\n * sorting.\n *\n * @param type - The operation type identifier (e.g., \"orderBy\", \"orderByRandom\")\n * @param data - The operation data data containing sort specifications\n * @param mergeable - Whether this operation can be merged with adjacent sort operations (default: true)\n *\n * @example\n * ```typescript\n * // Order by a single field\n * helper.addSortOperation(\"orderBy\", { field: \"createdAt\", direction: \"desc\" });\n *\n * // Random ordering (not mergeable)\n * helper.addSortOperation(\"orderByRandom\", {limit: 1000}, false);\n *\n * // Order by raw expression\n * helper.addSortOperation(\"orderByRaw\", {\n * expression: { score: -1, name: 1 }\n * });\n * ```\n */\n public addSortOperation(type: string, data: Record<string, unknown>, mergeable = true): void {\n this.operations.push({\n stage: \"$sort\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $group stage operation to the pipeline.\n *\n * Group operations aggregate documents by specified fields and compute\n * aggregate values, similar to the GROUP BY clause in SQL. Group operations\n * are typically not mergeable as they represent distinct aggregation boundaries.\n *\n * @param type - The operation type identifier (e.g., \"groupBy\", \"distinct\")\n * @param data - The operation data data containing grouping specifications\n * @param mergeable - Whether this operation can be merged with adjacent group operations (default: false)\n *\n * @example\n * ```typescript\n * // Group by a single field\n * helper.addGroupOperation(\"groupBy\", { fields: \"category\" });\n *\n * // Group by multiple fields\n * helper.addGroupOperation(\"groupBy\", {\n * fields: { category: \"$category\", status: \"$status\" }\n * });\n *\n * // Distinct operation (special case of grouping)\n * helper.addGroupOperation(\"distinct\", { fields: [\"email\"] });\n * ```\n */\n public addGroupOperation(type: string, data: Record<string, unknown>, mergeable = false): void {\n this.operations.push({\n stage: \"$group\",\n mergeable,\n type,\n data,\n });\n }\n\n /**\n * Adds a $lookup stage operation to the pipeline.\n *\n * Lookup operations perform left outer joins with other collections, similar\n * to JOIN in SQL. Lookup operations are never mergeable as each represents a\n * distinct join operation.\n *\n * @param type - The operation type identifier (typically \"join\")\n * @param data - The operation data data containing join specifications\n *\n * @example\n * ```typescript\n * // Simple lookup\n * helper.addLookupOperation(\"join\", {\n * table: \"orders\",\n * localField: \"id\",\n * foreignField: \"userId\",\n * alias: \"userOrders\"\n * });\n *\n * // Lookup with pipeline\n * helper.addLookupOperation(\"join\", {\n * table: \"products\",\n * pipeline: [\n * { $match: { inStock: true } },\n * { $sort: { price: 1 } }\n * ],\n * alias: \"availableProducts\"\n * });\n * ```\n */\n public addLookupOperation(type: string, data: Record<string, unknown>): void {\n this.operations.push({\n stage: \"$lookup\",\n mergeable: false,\n type,\n data,\n });\n }\n\n /**\n * Adds a generic stage operation to the pipeline.\n *\n * This method provides flexibility to add any MongoDB aggregation stage,\n * including less common stages like $facet, $bucket, $setWindowFields, etc.\n * Use this for operations that don't fit into the standard categories.\n *\n * @param stage - The MongoDB aggregation stage name (e.g., \"$limit\", \"$skip\", \"$unwind\")\n * @param type - The operation type identifier\n * @param data - The operation data data\n * @param mergeable - Whether this operation can be merged with adjacent operations (default: false)\n *\n * @example\n * ```typescript\n * // Add a limit operation\n * helper.addOperation(\"$limit\", \"limit\", { value: 10 });\n *\n * // Add a skip operation\n * helper.addOperation(\"$skip\", \"skip\", { value: 20 });\n *\n * // Add an unwind operation\n * helper.addOperation(\"$unwind\", \"unwind\", { path: \"$tags\" });\n *\n * // Add a window function\n * helper.addOperation(\"$setWindowFields\", \"selectWindow\", {\n * spec: {\n * partitionBy: \"$category\",\n * sortBy: { price: 1 },\n * output: { rank: { $rank: {} } }\n * }\n * });\n * ```\n */\n public addOperation(\n stage: PipelineStage,\n type: string,\n data: Record<string, unknown>,\n mergeable = false,\n ): void {\n this.operations.push({\n stage,\n mergeable,\n type,\n data,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,uBAAb,MAAkC;CAiBL;;;;;;;;;;;;;;;;;CAA3B,AAAO,YAAY,AAAQ,YAAyB;EAAzB;CAA0B;CAErD,AAAO,cAAc,YAA+B;EAClD,KAAK,aAAa;CACpB;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,AAAO,kBAAkB,MAAc,MAA+B,YAAY,MAAY;EAC5F,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,oBAAoB,MAAc,MAA+B,YAAY,MAAY;EAC9F,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,iBAAiB,MAAc,MAA+B,YAAY,MAAY;EAC3F,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,kBAAkB,MAAc,MAA+B,YAAY,OAAa;EAC7F,KAAK,WAAW,KAAK;GACnB,OAAO;GACP;GACA;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCA,AAAO,mBAAmB,MAAc,MAAqC;EAC3E,KAAK,WAAW,KAAK;GACnB,OAAO;GACP,WAAW;GACX;GACA;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCA,AAAO,aACL,OACA,MACA,MACA,YAAY,OACN;EACN,KAAK,WAAW,KAAK;GACnB;GACA;GACA;GACA;EACF,CAAC;CACH;AACF"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Operation } from "./types.mjs";
|
|
2
2
|
import { MongoQueryBuilder } from "./mongodb-query-builder.mjs";
|
|
3
3
|
import { Collection } from "mongodb";
|
|
4
|
-
|
|
5
4
|
//#region ../../packages/cascade/src/drivers/mongodb/mongodb-query-parser.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Options for configuring the MongoDB query parser.
|
|
8
7
|
*/
|
|
9
|
-
type MongoQueryParserOptions = {
|
|
10
|
-
/** The MongoDB collection being queried */
|
|
11
|
-
|
|
8
|
+
export type MongoQueryParserOptions = {
|
|
9
|
+
/** The MongoDB collection being queried */
|
|
10
|
+
collection: Collection;
|
|
11
|
+
/** The ordered list of operations to parse */
|
|
12
|
+
operations: Operation[];
|
|
13
|
+
/** Factory method for creating sub-builders (used for callbacks) */
|
|
12
14
|
createSubBuilder: () => MongoQueryBuilder;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
@@ -19,7 +21,7 @@ type MongoQueryParserOptions = {
|
|
|
19
21
|
* intelligent grouping of mergeable operations (like multiple where clauses)
|
|
20
22
|
* into single pipeline stages for optimal performance.
|
|
21
23
|
*/
|
|
22
|
-
declare class MongoQueryParser {
|
|
24
|
+
export declare class MongoQueryParser {
|
|
23
25
|
/**
|
|
24
26
|
* The MongoDB collection being queried.
|
|
25
27
|
*/
|
|
@@ -365,5 +367,4 @@ declare class MongoQueryParser {
|
|
|
365
367
|
private buildLookupStage;
|
|
366
368
|
}
|
|
367
369
|
//#endregion
|
|
368
|
-
export { MongoQueryParser };
|
|
369
370
|
//# sourceMappingURL=mongodb-query-parser.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-query-parser.d.mts","names":[],"sources":["../../../../../../../../../packages/cascade/src/drivers/mongodb/mongodb-query-parser.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"mongodb-query-parser.d.mts","names":[],"sources":["../../../../../../../../../packages/cascade/src/drivers/mongodb/mongodb-query-parser.ts"],"mappings":";;;;;;;YAyDY;;EAEV,YAAY;;EAEZ,YAAY;;EAEZ,wBAAwB;;;;;;;;;;qBAuBb;;;;mBAIM;;;;mBAKA;;;;mBAKA;;;;;mBAMA;;;;;;;mBAQA;;;;;;EAOjB,YAAmB,SAAS;;;;;;;;;;;;;;;;;;;;;EA0BrB;;;;;UAyFC;;;;;;;;;;;UA+CA;;;;;;;;;;;;;;UAmCA;;;;;;;;;;;;;;;;;;UAuDA;;;;UAkCA;;;;;;UAkCA;;;;;;;;;;UAyBA;;;;;;;;;;;;;;;;;;;;;;;;EA4DD;;;;;;;;UAmCC;;;;;;;;UAoDA;;;;;;;;;;;UAyEA;UAqKA;;;;;;;;;UAkBA;;;;;;;UAkFA;;;;;;;;;;;;;UAyNA;;;;;;;;;UAgBA;UAoDA;;;;;;;UAcA;UAYA;;;;;;;;UA2BA;UAsBA;UAYA;UASA;UAWA;UAIA;UAOA;UAKA;UAKA;UAgBA;UAiBA;UAQA;UAMA;UAMA;UASA;UAQA;UASA;UAWA;UAMA;UAMA;UAIA;;;;;;UAeA;UAmCA;UAeA;UA0BA;UAoBA;UAwBA;UAMA;UAMA;UAgBA;;;;;UAkBA;UAaA;UAYA;UAMA;;;;;;;UAsBA;;;;;;;UAgHA;;;;;;;UA4BA;UA6DA;;;;;;;;UAgBA;;;;;;;;;;UAoCA;;;;;;;UA0BA;;;;;;;UA4BA;;;;;;;;;;;;;UAuFA;UAoCA;;;;;;;UAgDA"}
|
|
@@ -1066,10 +1066,7 @@ var MongoQueryParser = class {
|
|
|
1066
1066
|
case "selectConcat":
|
|
1067
1067
|
projection[op.data.alias] = this.buildConcatExpression(op.data.fields);
|
|
1068
1068
|
break;
|
|
1069
|
-
case "selectCoalesce":
|
|
1070
|
-
projection[op.data.alias] = this.buildCoalesceExpression(op.data.fields);
|
|
1071
|
-
break;
|
|
1072
|
-
default: break;
|
|
1069
|
+
case "selectCoalesce": projection[op.data.alias] = this.buildCoalesceExpression(op.data.fields);
|
|
1073
1070
|
}
|
|
1074
1071
|
for (const callback of driverCallbacks) callback(projection);
|
|
1075
1072
|
return Object.keys(projection).length > 0 ? { $project: projection } : null;
|
|
@@ -1127,7 +1124,6 @@ var MongoQueryParser = class {
|
|
|
1127
1124
|
if (stage) return stage;
|
|
1128
1125
|
break;
|
|
1129
1126
|
}
|
|
1130
|
-
default: break;
|
|
1131
1127
|
}
|
|
1132
1128
|
return null;
|
|
1133
1129
|
}
|
|
@@ -1305,5 +1301,5 @@ var MongoQueryParser = class {
|
|
|
1305
1301
|
};
|
|
1306
1302
|
|
|
1307
1303
|
//#endregion
|
|
1308
|
-
export { MongoQueryParser };
|
|
1304
|
+
export { MongoQueryParser, resolveMongoLikePattern };
|
|
1309
1305
|
//# sourceMappingURL=mongodb-query-parser.mjs.map
|