@warlock.js/cascade 5.34.0 → 5.34.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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.34.2 - 2026-10-19
8
+
9
+ ### Fixed
10
+
11
+ - Remove the redundant loose skill catalog and include package orientation in generated LLM projections.
12
+
7
13
  ## 5.34.0 - 2026-10-19
8
14
 
9
15
  ### Removed
package/llms-full.txt CHANGED
@@ -4,6 +4,36 @@
4
4
 
5
5
  > Generated artifact. Concatenates every SKILL.md and reference file under `@warlock.js/cascade/skills/`. Re-run `node scripts/generate-llms.mjs` after any change.
6
6
 
7
+ ## Package orientation
8
+
9
+ ---
10
+ description: "Model-first ORM for MongoDB and Postgres. Exports `Model`, `RegisterModel`, `Migration`, `defineModel`, `BelongsTo`, `HasMany`, `transaction`, `DataSource`, `dataSourceRegistry`, `connectToDatabase`, `runMigrations`. Use for: define a model, add a column or collection, write or alter a migration, query or filter records, paginate, aggregate or group, add a relation, run a transaction, soft delete, track changes, react to save or delete events, vector search. Not this package: request validation and schemas → @warlock.js/seal; routes, controllers, repositories → @warlock.js/core."
11
+ ---
12
+
13
+ # @warlock.js/cascade
14
+
15
+ Cascade is the data layer. The model is the query entry point (`User.find(id)`, `User.paginate(...)`); one seal schema gives the TypeScript type, the save-time validation, and the shape migrations write against. MongoDB and Postgres drivers ship with the same query API. Server-only.
16
+
17
+ ## The 80% path
18
+
19
+ 1. Read `cascade-basics.md` first: it is the map and the ten foundations.
20
+ 2. Define the model and register it (`define-model.md`), then relations (`define-relations.md`).
21
+ 3. Write the migration; models never create tables or collections on their own (`write-migration.md`, `alter-migration.md`, run with `run-cascade-cli.md`).
22
+ 4. Query, paginate, aggregate (`query-data.md`, `paginate-results.md`, `aggregate-data.md`, `perform-atomic-ops.md`).
23
+ 5. Wrap multi-step writes in a transaction (`manage-transactions.md`); pick a delete strategy (`configure-delete-strategy.md`).
24
+ 6. Connect and manage drivers (`manage-data-sources.md`); hook lifecycle and diffs (`subscribe-to-model-events.md`, `track-changes.md`); embeddings via `search-by-vector.md`.
25
+
26
+ ## Conventions and pitfalls
27
+
28
+ - `pg` and `mongodb` are optional peers; install only the driver you use.
29
+ - `.create()` validates against the schema, applies defaults, and throws on failure.
30
+ - Pick an update idiom by shape: `.set(k, v).save()` for one or two fields, `.merge(data).save()` for payloads.
31
+ - `.destroy()` follows the configured strategy (permanent, soft, or trash), not always a hard delete.
32
+ - Relations refer to models by registered name, so `@RegisterModel()` must run first.
33
+ - Run code needing a live connection through `onceConnected`, not at import time.
34
+ - Undefined `where` values and unsafe filters throw on purpose; sanitize user-supplied filters.
35
+
36
+
7
37
  ## aggregate-data `@warlock.js/cascade/aggregate-data/SKILL.md`
8
38
 
9
39
  ---
package/llms.txt CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  ## Skills
8
8
 
9
+ - [Package orientation](@warlock.js/cascade/skills/index.md): Model-first ORM for MongoDB and Postgres. Exports `Model`, `RegisterModel`, `Migration`, `defineModel`, `BelongsTo`, `HasMany`, `transaction`, `DataSource`, `dataSourceRegistry`, `connectToDatabase`, `runMigrations`. Use for: define a model, add a column or collection, write or alter a migration, query or filter records, paginate, aggregate or group, add a relation, run a transaction, soft delete, track changes, react to save or delete events, vector search. Not this package: request validation and schemas → @warlock.js/seal; routes, controllers, repositories → @warlock.js/core.
9
10
  - [aggregate-data](@warlock.js/cascade/aggregate-data/SKILL.md): Compute aggregates over a query — scalar `.count()` / `.sum(field)` / `.avg` / `.min` / `.max`, plus grouped rollups via the two-arg `.groupBy(fields, { alias: $agg.* })`, portable date-bucketing via `.groupByDate(col, unit, aggregates?)`, the `$agg` helpers (including expression-aware `$agg.sum($expr.mul("price","quantity"))` / `$agg.sumRaw`), and `.having(alias, op, value)` on computed aggregates, plus MongoDB pipeline stages `.unwind(field, options?)` / `.addFields(fields)` / pipeline-form `join()` (`UnsupportedQueryOperationError` on Postgres). Triggers: `.unwind`, `.addFields`, `.joinRaw`, `.raw`, `$unwind`, `$lookup`, `.count`, `.sum`, `.avg`, `.min`, `.max`, `.groupBy`, `.groupByDate`, `.having`, `$agg`, `$agg.sum`, `$agg.sumRaw`, `$agg.count`, `$expr`, `$expr.mul`, `$expr.col`, `$expr.lit`; "monthly revenue report", "revenue per month", "X per category", "group by status", "sum price times quantity", "dashboard rollup"; typical import `import { Model, $agg, $expr } from "@warlock.js/cascade"`. Skip: row queries — the `query-data` topic; cached aggregates — the `use-cached-hof` topic of the `warlock-js-cache` skill; competing tools raw SQL `GROUP BY`, `mongoose aggregate`, `prisma` `groupBy`.
10
11
  - [alter-migration](@warlock.js/cascade/alter-migration/SKILL.md): Evolve an existing table with `Migration.alter(Model, schema, options?)` — add/drop/rename/modify columns; add/drop regular, unique, expression, full-text, geo, vector, and TTL indexes; add/drop foreign keys and CHECK constraints; write rollbacks with class-form methods in `down()`. Triggers: "alter a table", "add a column to existing table", "drop a column", "rename a column", "add an index", "drop a unique constraint", "change a column type", `Migration.alter`, `dropUnique`, `addIndex`, `addForeign`. Skip: creating a brand-new table — the `write-migration` topic.
11
12
  - [cascade-basics](@warlock.js/cascade/cascade-basics/SKILL.md): Start here for @warlock.js/cascade models, data sources, migrations, and query workflows.
package/package.json CHANGED
@@ -13,10 +13,10 @@
13
13
  "@mongez/events": "^2.2.8",
14
14
  "@mongez/reinforcements": "^4.0.2",
15
15
  "@mongez/supportive-is": "^3.0.0",
16
- "@warlock.js/context": "5.34.0",
17
- "@warlock.js/logger": "5.34.0",
18
- "@warlock.js/scheduler": "5.34.0",
19
- "@warlock.js/seal": "5.34.0",
16
+ "@warlock.js/context": "5.34.2",
17
+ "@warlock.js/logger": "5.34.2",
18
+ "@warlock.js/scheduler": "5.34.2",
19
+ "@warlock.js/seal": "5.34.2",
20
20
  "citty": "^0.2.2",
21
21
  "fast-glob": "^3.3.3"
22
22
  },
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "author": "hassanzohdy",
55
55
  "license": "MIT",
56
- "version": "5.34.0",
56
+ "version": "5.34.2",
57
57
  "main": "./cjs/index.cjs",
58
58
  "module": "./esm/index.mjs",
59
59
  "types": "./esm/index.d.mts",
package/skills/README.md DELETED
@@ -1,69 +0,0 @@
1
- # `@warlock.js/cascade` — skills index
2
-
3
- Per-task skills. Cross-references name the topic, for example "the `define-model` topic"; the other package's topics are named with the `warlock-js-<pkg>` skill that holds them.
4
-
5
- ## Skills
6
-
7
- ### `alter-migration.md`
8
-
9
- Evolve an existing table with `Migration.alter(Model, schema, options?)` — add/drop/rename/modify columns; add/drop regular, unique, expression, full-text, geo, vector, and TTL indexes; add/drop foreign keys and CHECK constraints; write rollbacks with class-form methods in `down()`. Load when changing an existing table — adding columns, swapping unique→index, wiring new foreign keys, or any DDL that's not creating a brand-new table.
10
-
11
- ### `aggregate-data.md`
12
-
13
- Compute aggregates over a query — `.count()`, `.sum(field)`, `.avg`, `.min`, `.max`, the two-arg `.groupBy(fields, { alias: $agg.* })` + `.having`, portable date-bucketing via `.groupByDate(col, unit, aggregates?)`, and expression-aware `$agg.sum(mul("price","quantity"))` / `$agg.sumRaw` for group-level rollups. Load when building reports, dashboards, 'X per category' rollups, time-series ('revenue per month'), or any query returning numbers rather than rows.
14
-
15
- ### `cascade-basics.md`
16
-
17
- Start with @warlock.js/cascade ORM — model-first for MongoDB and Postgres, one schema (seal) does triple duty (type / validator / DB shape), model is the query entry point. Load when importing @warlock.js/cascade, wiring connectToDatabase, defining the first model, or choosing which cascade skill to load.
18
-
19
- ### `configure-delete-strategy.md`
20
-
21
- Pick the delete behavior — `permanent` (hard delete), `soft` (set deletedAt, keep the row), `trash` (move to a separate table). Configure per-model via `static deleteStrategy` or pass `.destroy({ strategy })` per call; restore via static `Model.restore(id)` / `Model.restoreAll()`. Soft-deleted rows are NOT auto-hidden — add a `notDeleted` global scope yourself. Load when records should be reversibly deletable or implementing GDPR hard delete.
22
-
23
- ### `define-model.md`
24
-
25
- Define a Cascade model — @RegisterModel() decorator, class extends Model<TSchema>, static table, static schema, three update idioms (.set / .merge / .save), .unset, .destroy, static toJsonColumns / resource / static hidden for output shaping. Covers why merge() on a persisted model can't retarget a write via a spoofed id, and why static hidden — not toJsonColumns/resource alone — is the field that's guaranteed to never serialize. Load when creating a model file, adding accessors, shaping serialized output, or hiding a password/token from responses.
26
-
27
- ### `define-relations.md`
28
-
29
- Define and query relations — @BelongsTo('Model') / @HasMany('Model') / @BelongsToMany('Model', { pivot, localKey, foreignKey }), .with('relation') eager loading, .whereHas(relation, cb) filter-by-related, setRelation on save, .joinWith for SQL joins, .load(relation) for lazy loading. Load when two models reference each other, avoiding N+1, or filtering parents by child conditions.
30
-
31
- ### `manage-data-sources.md`
32
-
33
- Configure multiple databases — register each via `connectToDatabase({ name, driver, database, isDefault })`, assign a model with `static dataSource = 'name'`, pin a migration with `public dataSource`, inspect via `dataSourceRegistry.get(name)` / `getAllDataSources()`. Load when the app talks to more than one database (reporting replica, analytics DB, per-tenant DBs).
34
-
35
- ### `manage-transactions.md`
36
-
37
- Wrap multi-statement work in transaction(async () => {...}) — rollback on throw or `ctx.rollback()`, commit on resolve, `isolationLevel` option (Postgres). Postgres native, MongoDB requires replica set; nested calls flat-join the outer transaction. Also covers row locking (`lockForUpdate({ skipLocked })` → `FOR UPDATE SKIP LOCKED`, Postgres-only — the concurrent queue-claim shape), transaction-aware raw SQL (`Model.raw` / `DataSource.raw` → `RawQueryResult`) and the Postgres `nativeArrayColumns` connection option. Load when two or more writes must succeed or fail together (creating parent + children, transferring balances, multi-step state machines), locking rows against concurrent workers, or when running raw SQL.
38
-
39
- ### `paginate-results.md`
40
-
41
- Paginate query results — `.paginate({ page, limit })` for offset (returns `data` + `pagination`), `.cursorPaginate({ limit, cursor })` for very large datasets (cursor fields under `pagination`), `.chunk(size, callback)` for streaming. Load when listing records for a UI, fetching a slice for an API, or processing a large table in batches.
42
-
43
- ### `perform-atomic-ops.md`
44
-
45
- Avoid races on concurrent writes — Model.increase(filter, field, n) / Model.decrease for atomic counters, Model.atomic(filter, ops) for arbitrary atomic mutations, Model.createMany(rows, { bulk, batchSize }) / Model.findAndUpdate / Model.delete for bulk. atomic() / findAndUpdate() / findOneAndUpdate() / findAndReplace() / findOneAndDelete() sanitize their filter argument the same way where() does. Load when incrementing counters under concurrency, fast bulk inserts (native multi-row insertMany), bulk ops without N+1, or single-document atomic mutations without a full transaction.
46
-
47
- ### `query-data.md`
48
-
49
- Query records via the model — .where(field, value) / .where(field, op, value), .find(id) / .first(filter?) / .all(filter?), .count / .exists, plus the broader query-builder vocabulary (.orderBy / .whereIn / .whereBetween / .whereLike / .whereRaw / .pluck / .firstOrFail / scopes) via .query() or chained off .where(). Covers filter safety (where() rejects $-prefixed keys, whereRaw() string mode rejects $where, whereLike/whereSearch match strings literally). Load when filtering, fetching by ID, getting a single match, ordering, or checking whether a filter/search built from request data is safe.
50
-
51
- ### `run-cascade-cli.md`
52
-
53
- Cascade's standalone CLI binary + programmatic Operations API — cascade migrate / migrate:list / migrate:rollback / migrate:export-sql, plus runMigrations / rollbackMigrations / freshMigrate / exportMigrationsSQL / listExecutedMigrations / migrationRunner functions. Load when applying migrations during deploy, resetting DB for test setup, or programmatic migration ops from a custom script.
54
-
55
- ### `search-by-vector.md`
56
-
57
- Vector similarity search via `.similarTo(column, embedding, alias?)` — adds a `score` column, orders by distance for index usage, cap with `.limit()`. Postgres uses pgvector (IVFFlat index via `this.vectorIndex`); MongoDB uses Atlas. Load when building semantic search, RAG retrieval against documents, hybrid (vector + full-text) search, or 'find records most similar to this vector'.
58
-
59
- ### `subscribe-to-model-events.md`
60
-
61
- Hook into model lifecycle events — `saving` / `saved`, `creating` / `created`, `updating` / `updated`, `validating` / `validated`, `deleting` / `deleted`, `restoring` / `restored`, `fetching` / `fetched`. The gerund form is the "before" hook (no `beforeSave` alias). Per-model `Model.on` or global. Load when wiring an audit log, sending notifications on changes, or denormalizing into a search index.
62
-
63
- ### `track-changes.md`
64
-
65
- Inspect a model's pending changes — `hasChanges()`, `isDirty(column)`, `getDirtyColumns()` (changed field names), `getDirtyColumnsWithValues()` (old + new per field), `getRemovedColumns()`. Load when implementing audit logs, conditionally running expensive logic only if a field changed, or building a change diff.
66
-
67
- ### `write-migration.md`
68
-
69
- Write a Cascade migration — a class `extends Migration` with `public table`, `up()` / `down()`, and fluent schema builders on `this` (`createTable`, `id`, `string`, `timestamps`, `references`, `index`). Run with `cascade migrate`. Load when creating or altering a table, indexing a column, dropping data, or wiring a new model.