@warlock.js/cascade 5.11.0 → 5.13.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/cjs/index.cjs +685 -128
  3. package/cjs/index.cjs.map +1 -1
  4. package/esm/contracts/database-driver.contract.d.mts +44 -7
  5. package/esm/contracts/database-driver.contract.d.mts.map +1 -1
  6. package/esm/contracts/index.d.mts +2 -2
  7. package/esm/contracts/query-builder.contract.d.mts +61 -1
  8. package/esm/contracts/query-builder.contract.d.mts.map +1 -1
  9. package/esm/drivers/mongodb/mongodb-driver.d.mts +8 -4
  10. package/esm/drivers/mongodb/mongodb-driver.d.mts.map +1 -1
  11. package/esm/drivers/mongodb/mongodb-driver.mjs +16 -6
  12. package/esm/drivers/mongodb/mongodb-driver.mjs.map +1 -1
  13. package/esm/drivers/mongodb/mongodb-query-builder.d.mts +32 -7
  14. package/esm/drivers/mongodb/mongodb-query-builder.d.mts.map +1 -1
  15. package/esm/drivers/mongodb/mongodb-query-builder.mjs +56 -8
  16. package/esm/drivers/mongodb/mongodb-query-builder.mjs.map +1 -1
  17. package/esm/drivers/mongodb/mongodb-query-parser.d.mts +39 -12
  18. package/esm/drivers/mongodb/mongodb-query-parser.d.mts.map +1 -1
  19. package/esm/drivers/mongodb/mongodb-query-parser.mjs +143 -55
  20. package/esm/drivers/mongodb/mongodb-query-parser.mjs.map +1 -1
  21. package/esm/drivers/mongodb/mongodb-update-translator.mjs +25 -0
  22. package/esm/drivers/mongodb/mongodb-update-translator.mjs.map +1 -0
  23. package/esm/drivers/mongodb/pipeline-stage-object.mjs +24 -0
  24. package/esm/drivers/mongodb/pipeline-stage-object.mjs.map +1 -0
  25. package/esm/drivers/mongodb/types.d.mts +7 -1
  26. package/esm/drivers/mongodb/types.d.mts.map +1 -1
  27. package/esm/drivers/postgres/postgres-driver.d.mts +52 -9
  28. package/esm/drivers/postgres/postgres-driver.d.mts.map +1 -1
  29. package/esm/drivers/postgres/postgres-driver.mjs +170 -38
  30. package/esm/drivers/postgres/postgres-driver.mjs.map +1 -1
  31. package/esm/drivers/postgres/postgres-query-builder.d.mts +17 -1
  32. package/esm/drivers/postgres/postgres-query-builder.d.mts.map +1 -1
  33. package/esm/drivers/postgres/postgres-query-builder.mjs +31 -0
  34. package/esm/drivers/postgres/postgres-query-builder.mjs.map +1 -1
  35. package/esm/drivers/postgres/postgres-update-validator.mjs +36 -0
  36. package/esm/drivers/postgres/postgres-update-validator.mjs.map +1 -0
  37. package/esm/errors/unsupported-lean-operation.error.d.mts +25 -0
  38. package/esm/errors/unsupported-lean-operation.error.d.mts.map +1 -0
  39. package/esm/errors/unsupported-lean-operation.error.mjs +31 -0
  40. package/esm/errors/unsupported-lean-operation.error.mjs.map +1 -0
  41. package/esm/errors/unsupported-query-operation.error.d.mts +30 -0
  42. package/esm/errors/unsupported-query-operation.error.d.mts.map +1 -0
  43. package/esm/errors/unsupported-query-operation.error.mjs +37 -0
  44. package/esm/errors/unsupported-query-operation.error.mjs.map +1 -0
  45. package/esm/errors/unsupported-update-operation.error.d.mts +30 -0
  46. package/esm/errors/unsupported-update-operation.error.d.mts.map +1 -0
  47. package/esm/errors/unsupported-update-operation.error.mjs +37 -0
  48. package/esm/errors/unsupported-update-operation.error.mjs.map +1 -0
  49. package/esm/index.d.mts +6 -3
  50. package/esm/index.mjs +4 -1
  51. package/esm/model/methods/query-methods.mjs +22 -6
  52. package/esm/model/methods/query-methods.mjs.map +1 -1
  53. package/esm/model/model.d.mts +28 -11
  54. package/esm/model/model.d.mts.map +1 -1
  55. package/esm/model/model.mjs +30 -13
  56. package/esm/model/model.mjs.map +1 -1
  57. package/esm/query-builder/lean-records.mjs +34 -0
  58. package/esm/query-builder/lean-records.mjs.map +1 -0
  59. package/esm/query-builder/query-builder.d.mts +13 -1
  60. package/esm/query-builder/query-builder.d.mts.map +1 -1
  61. package/esm/query-builder/query-builder.mjs +16 -0
  62. package/esm/query-builder/query-builder.mjs.map +1 -1
  63. package/llms-full.txt +72 -5
  64. package/llms.txt +3 -3
  65. package/package.json +4 -4
  66. package/skills/aggregate-data/SKILL.md +24 -1
  67. package/skills/perform-atomic-ops/SKILL.md +38 -3
  68. package/skills/query-data/SKILL.md +10 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,37 @@ All notable changes to `@warlock.js/cascade` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.13.0 - 2026-09-17
8
+
9
+ ### Upgrading
10
+
11
+ - On Postgres, `$push` / `$pull` / `$addToSet`, pipeline updates, `arrayFilters` and unknown update operators now throw `UnsupportedUpdateOperationError` instead of being silently ignored. If any code path relied on such an operator being a no-op on Postgres, update it to an operation Postgres supports (or branch by driver) before upgrading.
12
+
13
+ ### Added
14
+
15
+ - `Model.atomic`, `Model.findOneAndUpdate` and `Model.findAndUpdate` take options: `upsert`, `arrayFilters` (MongoDB), and on `findOneAndUpdate` `returnDocument: "before" | "after"` (default stays `"after"`). A counter or quota can now be filter + `$inc`/`$setOnInsert` + upsert, returning the new document, in one call.
16
+ - Update operators `$setOnInsert` and `$addToSet`, and pipeline (array-form) updates such as `[{ $set: { score: { $add: ["$likes", "$shares"] } } }]` (MongoDB).
17
+ - `trustedFilter: true` lets a code-authored conditional filter (`{ used: { $lt: 10 } }`) through the operator-injection check on these statics. Filters are still checked by default.
18
+ - Postgres upsert runs as `INSERT … ON CONFLICT … DO UPDATE … RETURNING *`. The conflict target is the primary key or a unique index whose columns are all equality keys of the filter.
19
+ - `UnsupportedUpdateOperationError` (`operation`, `driver`): what a driver throws when it cannot run part of an update.
20
+ - `.lean()` on the query builder: `get` / `first` / `paginate` / `chunk` return plain objects typed as the model schema (`LeanDocument<T>`), with no Model hydration, no driver casting and no `fetched` event. `static hidden` fields are still removed. With `with()` / `joinWith()` it throws `UnsupportedLeanOperationError`. About 1.9x faster than a hydrated read for 10k MongoDB documents.
21
+ - `.unwind(field, { preserveNullAndEmptyArrays?, includeArrayIndex? })` and `.addFields(fields)` on the query builder (MongoDB). Both run in call order, so a `where()` after `unwind()` filters the elements. `join({ table, alias, pipeline })` now sends a pipeline `$lookup`.
22
+ - `UnsupportedQueryOperationError` (`operation`, `driver`): the Postgres builder throws it for `unwind()` and `addFields()`, so these stages are never dropped without an error.
23
+
24
+ ### Changed
25
+
26
+ - **BREAKING:** The Postgres driver now throws `UnsupportedUpdateOperationError` for `$push` / `$pull` / `$addToSet`, pipeline updates, `arrayFilters` and unknown operators. It used to ignore `$push` / `$pull` without saying so.
27
+ - `Model.atomic` returns modified + upserted count.
28
+ - Postgres `findOneAndUpdate` picks its row with `SELECT … LIMIT 1 FOR UPDATE`, matches it by primary key and checks the filter again, so concurrent callers never go past a conditional filter.
29
+
30
+ ### Fixed
31
+
32
+ - `$dec` on the MongoDB driver was sent to the server as-is and rejected ("Unknown modifier"). It is now converted to a negative `$inc`.
33
+ - The MongoDB pipeline parser dropped `$vectorSearch` and `$addFields` stages, so `similarTo()` ran with no vector search and no `score`. It now emits both.
34
+ - On MongoDB, a `join()` with a `pipeline` sent a `$lookup` with no pipeline and no join fields.
35
+ - On MongoDB, `joinRaw()` and `raw()` were silently dropped from the pipeline. `joinRaw(stage | stages)` now emits the stages verbatim in call order; `raw(pipeline => …)` receives the pipeline built so far and may return a replacement. A SQL string, a non-stage object or a non-array callback result throws `UnsupportedQueryOperationError`.
36
+ - On MongoDB, `select([...]).orderBy(field)` did not sort when `field` was not selected, because `$project` ran before `$sort` (hydrated, lean, `first()` and `paginate()` reads). The sort now runs before the projection; sorting by a computed `selectRaw` alias still works, also mixed with unselected fields.
37
+
7
38
  ## 5.11.0 - 2026-09-14
8
39
 
9
40
  ### Fixed