joist-codegen 2.3.0-next.13 → 2.3.0-next.14
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/build/config.d.ts +1 -0
- package/build/config.js +2 -0
- package/build/config.js.map +1 -1
- package/build/index.js +4 -0
- package/build/index.js.map +1 -1
- package/build/installSkills.d.ts +8 -0
- package/build/installSkills.js +37 -0
- package/build/installSkills.js.map +1 -0
- package/package.json +4 -3
- package/skills/joist-em-basics/SKILL.md +114 -0
- package/skills/joist-partial-updates/SKILL.md +352 -0
- package/skills/joist-reactive-hints/SKILL.md +150 -0
- package/skills/joist-test-factories/SKILL.md +397 -0
- package/skills/joist-upsert/SKILL.md +95 -0
package/build/config.d.ts
CHANGED
|
@@ -127,6 +127,7 @@ export declare const config: z.ZodObject<{
|
|
|
127
127
|
esm: z.ZodOptional<z.ZodBoolean>;
|
|
128
128
|
paginationStyle: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"cursor">, z.ZodLiteral<"limit">]>>>;
|
|
129
129
|
docs: z.ZodOptional<z.ZodBoolean>;
|
|
130
|
+
skills: z.ZodOptional<z.ZodBoolean>;
|
|
130
131
|
outputDocs: z.ZodOptional<z.ZodBoolean>;
|
|
131
132
|
allowImportingTsExtensions: z.ZodOptional<z.ZodBoolean>;
|
|
132
133
|
codemodVersion: z.ZodDefault<z.ZodNumber>;
|
package/build/config.js
CHANGED
|
@@ -158,6 +158,8 @@ exports.config = zod_1.z
|
|
|
158
158
|
paginationStyle: zod_1.z.optional(zod_1.z.union([zod_1.z.literal("cursor"), zod_1.z.literal("limit")])).default("cursor"),
|
|
159
159
|
/** Enables documentation syncing between .md files and JSDocs. */
|
|
160
160
|
docs: zod_1.z.optional(zod_1.z.boolean()),
|
|
161
|
+
/** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */
|
|
162
|
+
skills: zod_1.z.optional(zod_1.z.boolean()),
|
|
161
163
|
/** Output a metadata-docs.ts file with entity/field documentation available at runtime. */
|
|
162
164
|
outputDocs: zod_1.z.optional(zod_1.z.boolean()),
|
|
163
165
|
/** Auto-set by probing the project's `tsconfig.json` file. */
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AA8KA,4DAyFC;AAED,sCAEC;AAED,0CAEC;AAED,kDAEC;AAGD,oDAEC;AAED,kCAEC;AAED,kCAEC;AAED,8CAEC;AAED,0CAEC;AAED,0CAEC;AAED,8CAEC;AAGD,8CAEC;AAED,wCAcC;AAED,8CAIC;AAID,gCAmBC;AAQD,kCAUC;AAED,oDASC;AAGD,gDAsBC;AAxZD,iDAAqD;AACrD,uCAAuC;AAEvC,2BAAkD;AAClD,6CAAsC;AACtC,4DAA4B;AAC5B,6BAAwB;AACxB,yCAAqD;AACrD,+CAA+C;AAC/C,qCAAkC;AAClC,mCAAyD;AAEzD,MAAM,aAAa,GAAG,IAAA,4BAAgB,EAAC,IAAA,iBAAY,EAAC,IAAA,cAAO,GAAE,CAAC,CAAC,CAAC;AAEhE,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,+BAA+B;IAC/B,OAAO,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrE,SAAS,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;IAClC,MAAM,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;IAC/B,WAAW,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IACnC,SAAS,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,C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OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,GAAG,oBAAE,CAAC,cAAc,CAAC,UAAU,EAAE,oBAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAClE,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,0BAA0B,KAAK,IAAI,CAAC;AACjF,CAAC;AAED,2EAA2E;AAC3E,SAAS,uBAAuB,CAAC,QAAwC;IACvE,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;QAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAY;IACzC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,GAAG,CAAC;IACb,CAAC;IACD,yEAAyE;IACzE,MAAM,MAAM,GAAG,EAAE,GAAI,GAA+B,EAAE,CAAC;IACvD,OAAO,MAAM,CAAC,OAAO,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const config_1 = require("./config");
|
|
|
21
21
|
const foreignKeyOrdering_1 = require("./foreignKeyOrdering");
|
|
22
22
|
const generate_1 = require("./generate");
|
|
23
23
|
const generateFlushFunction_1 = require("./generateFlushFunction");
|
|
24
|
+
const installSkills_1 = require("./installSkills");
|
|
24
25
|
const inheritance_1 = require("./inheritance");
|
|
25
26
|
const loadMetadata_1 = require("./loadMetadata");
|
|
26
27
|
const logger_1 = require("./logger");
|
|
@@ -66,6 +67,9 @@ async function joistCodegen() {
|
|
|
66
67
|
(0, config_1.warnInvalidConfigEntries)(config, dbMetadata);
|
|
67
68
|
// Finally actually generate the files (even if we found a fatal error)
|
|
68
69
|
await generateAndSaveFiles(config, dbMetadata);
|
|
70
|
+
// Install our bundled Agent Skills so coding agents can find them, unless explicitly disabled
|
|
71
|
+
if (config.skills !== false)
|
|
72
|
+
await (0, installSkills_1.installSkills)();
|
|
69
73
|
(0, config_1.stripStiPlaceholders)(config, entities);
|
|
70
74
|
await (0, config_1.writeConfig)(config);
|
|
71
75
|
}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAoCA,oCAyDC;AAGD,oDASC;AAiDD,4CAUC;AAlKD,6CAAsE;AACtE,gEAAmC;AACnC,2BAA4B;AAC5B,gEAAuC;AACvC,qCAAoC;AACpC,yDAAqH;AA2BpG,iGA3BI,mCAAgB,OA2BJ;AA1BjC,6CAA0C;AAC1C,yCAAgD;AAChD,qCAA2G;AAC3G,6DAAkE;AAClE,yCAA2C;AAC3C,mEAA8D;AAC9D,mDAAgD;AAChD,+CAAwD;AACxD,iDAAsE;AACtE,qCAAgE;AAChE,uDAAoD;AACpD,mCAAmG;AAehE,gHAfe,uCAA+B,OAef;AAblE,uDAW4B;AAR1B,8GAAA,UAAU,OAAA;AAYL,KAAK,UAAU,YAAY;IAChC,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAU,GAAE,CAAC;IAElC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,CAAC,sBAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,sBAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC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AAC,QAAQ,CAAC,UAAU,CAAC,IAAI,iCAAwB,IAAI,mBAAU,CAAC,IAAI,CAAC;YACjF,8BAA8B;YAC9B,iCAAwB,IAAI,mBAAU,CAAC,KAAK,CAAC,EAC/C,CAAC;QACD,sBAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,YAAY,EAAE;SACX,IAAI,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;SAC9B,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,sBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies Joist's bundled Agent Skills into the project so coding agents can
|
|
3
|
+
* discover them.
|
|
4
|
+
*
|
|
5
|
+
* The skills are framework-owned and rewritten on every codegen run, so users
|
|
6
|
+
* should not hand-edit them (re-run codegen to pick up new Joist versions).
|
|
7
|
+
*/
|
|
8
|
+
export declare function installSkills(rootDir?: string): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installSkills = installSkills;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/** The bundled skills live at the package root, alongside `build`/`src`. */
|
|
7
|
+
const bundledSkillsDir = (0, path_1.resolve)(__dirname, "../skills");
|
|
8
|
+
/**
|
|
9
|
+
* Targets that each get a full copy of every skill directory.
|
|
10
|
+
*
|
|
11
|
+
* `.claude/skills` is read by Claude Code (and opencode); `.agents/skills` is read
|
|
12
|
+
* by Codex (and opencode), so writing both gives native coverage across all three.
|
|
13
|
+
*/
|
|
14
|
+
const skillTargets = [".claude/skills", ".agents/skills"];
|
|
15
|
+
/**
|
|
16
|
+
* Copies Joist's bundled Agent Skills into the project so coding agents can
|
|
17
|
+
* discover them.
|
|
18
|
+
*
|
|
19
|
+
* The skills are framework-owned and rewritten on every codegen run, so users
|
|
20
|
+
* should not hand-edit them (re-run codegen to pick up new Joist versions).
|
|
21
|
+
*/
|
|
22
|
+
async function installSkills(rootDir = ".") {
|
|
23
|
+
let skillNames;
|
|
24
|
+
try {
|
|
25
|
+
const entries = await fs_1.promises.readdir(bundledSkillsDir, { withFileTypes: true });
|
|
26
|
+
skillNames = entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// The bundled skills are missing (e.g. running against an unbuilt package); nothing to do.
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (skillNames.length === 0)
|
|
33
|
+
return;
|
|
34
|
+
await Promise.all(skillTargets.flatMap((target) => skillNames.map((name) => fs_1.promises.cp((0, path_1.join)(bundledSkillsDir, name), (0, path_1.join)(rootDir, target, name), { recursive: true, force: true }))));
|
|
35
|
+
console.log(`Installed ${skillNames.length} Joist skill(s) into ${skillTargets.join(" and ")}`);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=installSkills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installSkills.js","sourceRoot":"","sources":["../src/installSkills.ts"],"names":[],"mappings":";;AAqBA,sCAoBC;AAzCD,2BAAoC;AACpC,+BAAqC;AAErC,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;AAE1D;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CAAC,UAAkB,GAAG;IACvD,IAAI,UAAoB,CAAC;IACzB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,aAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,2FAA2F;QAC3F,OAAO;IACT,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEpC,MAAM,OAAO,CAAC,GAAG,CACf,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAC9B,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACtB,aAAE,CAAC,EAAE,CAAC,IAAA,WAAI,EAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE,IAAA,WAAI,EAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CACnG,CACF,CACF,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,aAAa,UAAU,CAAC,MAAM,wBAAwB,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAClG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joist-codegen",
|
|
3
|
-
"version": "2.3.0-next.
|
|
3
|
+
"version": "2.3.0-next.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
"format": "prettier --ignore-path ../../.prettierignore --write '{schema,migrations,src}/**/*.{ts,js,tsx,jsx,graphql}'"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"build"
|
|
17
|
+
"build",
|
|
18
|
+
"skills"
|
|
18
19
|
],
|
|
19
20
|
"peerDependencies": {
|
|
20
|
-
"joist-utils": "2.3.0-next.
|
|
21
|
+
"joist-utils": "2.3.0-next.14",
|
|
21
22
|
"knex": "^3.1.0",
|
|
22
23
|
"pg": "^8.22.0"
|
|
23
24
|
},
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: joist-em-basics
|
|
3
|
+
description: Create, load, find, mutate, and save entities with Joist's EntityManager. Use when writing data-access or business logic in a Joist project — anything using em.create, em.load, em.find, em.flush, or walking the entity graph.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- Managed by joist-codegen. Do not edit by hand; re-run codegen to update. -->
|
|
7
|
+
|
|
8
|
+
# Joist EntityManager basics
|
|
9
|
+
|
|
10
|
+
The `EntityManager` (`em`) is how entities are loaded from and saved to the
|
|
11
|
+
database. It is a Unit of Work: each request gets its own `em`, which tracks
|
|
12
|
+
the entities it has loaded/created and writes them all out on `em.flush()`.
|
|
13
|
+
|
|
14
|
+
Entities are always loaded/created _through_ the `em`, never via static methods
|
|
15
|
+
on the class (Joist is not ActiveRecord). IDs are tagged strings like `"a:1"`.
|
|
16
|
+
|
|
17
|
+
## Creating
|
|
18
|
+
|
|
19
|
+
`em.create` is synchronous and returns the new entity immediately:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const author = em.create(Author, { firstName: "a1" });
|
|
23
|
+
// Nested/related entities can be created inline
|
|
24
|
+
const author = em.create(Author, { firstName: "a1", address: { street: "123 Main" } });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Loading by id
|
|
28
|
+
|
|
29
|
+
Use tagged ids. These throw if the id does not exist (except the `IfExists`
|
|
30
|
+
variants):
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const a = await em.load(Author, "a:1");
|
|
34
|
+
const as = await em.loadAll(Author, ["a:1", "a:2"]);
|
|
35
|
+
const as = await em.loadAllIfExists(Author, ["a:1", "a:2"]); // skips missing ids
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
To eagerly load relations, pass a populate hint as the 3rd argument; the
|
|
39
|
+
returned entity is typed as "loaded" so the relations can be read synchronously:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const a = await em.load(Author, "a:1", { books: "reviews" });
|
|
43
|
+
a.books.get.flatMap((b) => b.reviews.get);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Walking the graph
|
|
47
|
+
|
|
48
|
+
~90% of reads are just navigating relations from an entity you already have.
|
|
49
|
+
These are guaranteed N+1-safe, even in a loop:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const author = await book.author.load(); // load a single relation
|
|
53
|
+
const reviews = await publisher.load((p) => p.books.reviews); // lens
|
|
54
|
+
const loaded = await author.populate({ books: "reviews" }); // populate + .get
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Finding (filtered queries)
|
|
58
|
+
|
|
59
|
+
`em.find` issues a `SELECT` with a "join literal" of nested relations plus
|
|
60
|
+
inline `WHERE` conditions. It is batch/N+1-safe.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const books = await em.find(Book, { author: { firstName: "a1" } });
|
|
64
|
+
const recent = await em.find(Book, { publishedAt: { gte: jan1 } });
|
|
65
|
+
const some = await em.find(Author, { firstName: { in: ["a1", "a2"] } });
|
|
66
|
+
|
|
67
|
+
const one = await em.findOne(Book, { title: "b1" }); // undefined if none
|
|
68
|
+
const one = await em.findOneOrFail(Book, { title: "b1" }); // throws if none
|
|
69
|
+
const one = await em.findOrCreate(Author, { email: "a@b.com" });
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`undefined` values are pruned (the condition and any now-unused join are
|
|
73
|
+
dropped), so filters compose cleanly. To filter for null, pass `null`
|
|
74
|
+
explicitly, e.g. `{ firstName: null }`. For `OR` / nested boolean logic, use
|
|
75
|
+
`alias`/`aliases` with a `conditions` argument. For aggregates or group-bys,
|
|
76
|
+
drop down to Knex/Kysely — Joist's `find` only returns whole entities.
|
|
77
|
+
|
|
78
|
+
## Mutating
|
|
79
|
+
|
|
80
|
+
Assign fields directly, or use `.set` for a batch of changes:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
author.firstName = "a2";
|
|
84
|
+
author.set({ firstName: "a2", lastName: "b2" });
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For partial/RPC-style updates (treating `null` as "unset"), and for
|
|
88
|
+
incrementally updating children, see the `joist-upsert` skill.
|
|
89
|
+
|
|
90
|
+
## Deleting
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
const a = await em.load(Author, "a:1");
|
|
94
|
+
em.delete(a);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Saving with `em.flush()`
|
|
98
|
+
|
|
99
|
+
`em.flush()` is where everything happens. It is async and:
|
|
100
|
+
|
|
101
|
+
1. Runs lifecycle hooks and validation rules,
|
|
102
|
+
2. Opens a transaction,
|
|
103
|
+
3. Issues batched `INSERT`/`UPDATE`/`DELETE` (one batch per entity type),
|
|
104
|
+
4. Commits.
|
|
105
|
+
|
|
106
|
+
You don't write individual SQL statements — let Joist batch them. `flush` can
|
|
107
|
+
be called multiple times as you do more work:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const author = em.create(Author, { firstName: "a1" });
|
|
111
|
+
await em.flush();
|
|
112
|
+
author.firstName = "a2";
|
|
113
|
+
await em.flush();
|
|
114
|
+
```
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: joist-partial-updates
|
|
3
|
+
description: Joist ORM partial updates, em.upsert, setPartial, nested collection op semantics, and GraphQL/REST/gRPC save inputs. Use when designing, implementing, reviewing, or debugging Joist partial-update or save-input APIs, especially parent-child graphs, id-less nested rows, required-parent validation errors, or accidental collection removal.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Joist Partial Update APIs
|
|
7
|
+
|
|
8
|
+
Use Joist's native partial-update contract from the transport through to `EntityManager.upsert` or `Entity.setPartial`. Do not load an existing graph and write custom reconciliation code when IDs and Joist collection operations can express the update.
|
|
9
|
+
|
|
10
|
+
Authoritative documentation: <https://joist-orm.io/features/partial-update-apis/>
|
|
11
|
+
|
|
12
|
+
## Non-Negotiable Rules
|
|
13
|
+
|
|
14
|
+
1. Preserve entity IDs across read, edit, and write boundaries.
|
|
15
|
+
2. Decide whether every supplied collection is exhaustive or incremental before writing the payload.
|
|
16
|
+
3. Omit a field to leave it unchanged. Do not replace omission with `null`, `[]`, or a generated default.
|
|
17
|
+
4. A collection array is exhaustive by default. Omitted existing children are removed from the relation.
|
|
18
|
+
5. A collection becomes incremental when its child objects use `op`.
|
|
19
|
+
6. If any child has `op`, every child in that collection must have `op`, including newly created children.
|
|
20
|
+
7. An empty array is always exhaustive and clears the collection. It never means "no changes."
|
|
21
|
+
8. Use `{ op: "incremental" }` only as a no-op sentinel when the collection key must be present. Prefer omitting the collection key.
|
|
22
|
+
9. Use `include`, `delete`, and `remove` according to their actual relationship semantics.
|
|
23
|
+
10. Test updates against an already-persisted graph and flush the unit of work. Mapper-only tests cannot catch detached required children.
|
|
24
|
+
11. Authorize every supplied ID and operation. Joist enforces persistence rules, not API permissions or tenant boundaries.
|
|
25
|
+
|
|
26
|
+
## Partial Field Semantics
|
|
27
|
+
|
|
28
|
+
Joist distinguishes omission, `undefined`, and `null`:
|
|
29
|
+
|
|
30
|
+
| Input | Scalar or relation behavior | Collection behavior |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| Omitted | Leave unchanged | Leave unchanged |
|
|
33
|
+
| `undefined` | Leave unchanged | Leave unchanged |
|
|
34
|
+
| `null` | Unset optional value; required value fails validation | Clear the collection |
|
|
35
|
+
| Value or array | Set/update | Exhaustively replace unless `op` enables incremental behavior |
|
|
36
|
+
|
|
37
|
+
Do not globally normalize `null` to `undefined`. That destroys the caller's ability to explicitly unset an optional field. Adapt only fields whose transport representation differs from the entity graph.
|
|
38
|
+
|
|
39
|
+
Transport-specific presence rules:
|
|
40
|
+
|
|
41
|
+
- GraphQL: preserve the difference between an omitted input field and an explicit `null`. Codegen commonly produces `T | null | undefined`; this is what `DeepPartialOrNull` and the partial APIs are designed to accept.
|
|
42
|
+
- REST/JSON: omission means no change; JSON has no `undefined`, so do not synthesize absent keys while decoding or mapping.
|
|
43
|
+
- gRPC/Protobuf: scalar presence can use `optional`, wrappers, or `oneof`, but ordinary repeated fields do not distinguish omitted from empty. Wrap repeated fields in a present message, use a `oneof`, or use a field mask so "unchanged" cannot decode to `[]`.
|
|
44
|
+
|
|
45
|
+
## Choose the Collection Contract
|
|
46
|
+
|
|
47
|
+
### Exhaustive Replacement
|
|
48
|
+
|
|
49
|
+
Use an exhaustive collection only when the caller intentionally sends the complete desired membership:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
await em.upsert(Author, {
|
|
53
|
+
id: "a:1",
|
|
54
|
+
books: [
|
|
55
|
+
{ id: "b:1", title: "Retained and updated" },
|
|
56
|
+
{ title: "New book" },
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This removes every omitted existing book from `author.books`. It does not imply hard deletion. If the inverse relation is required, detaching an omitted child can produce validation errors such as `Book author is required`.
|
|
62
|
+
|
|
63
|
+
Do not use exhaustive replacement when:
|
|
64
|
+
|
|
65
|
+
- The client does not know every existing child.
|
|
66
|
+
- The UI discarded child IDs.
|
|
67
|
+
- Omitted children should remain untouched.
|
|
68
|
+
- Removed children must be hard-deleted rather than merely detached.
|
|
69
|
+
|
|
70
|
+
### Incremental Update
|
|
71
|
+
|
|
72
|
+
Use incremental operations when the request describes additions, updates, removals, or deletions without replacing the whole collection:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
await em.upsert(Author, {
|
|
76
|
+
id: "a:1",
|
|
77
|
+
books: [
|
|
78
|
+
{ id: "b:1", op: "include", title: "Updated title" },
|
|
79
|
+
{ op: "include", title: "New book" },
|
|
80
|
+
{ id: "b:2", op: "delete" },
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Operation meanings:
|
|
86
|
+
|
|
87
|
+
| Operation | Behavior |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `include` | Create or update the child, and ensure it belongs to the collection |
|
|
90
|
+
| `delete` | Remove the child from the collection and call `EntityManager.delete` |
|
|
91
|
+
| `remove` | Detach the child without deleting it |
|
|
92
|
+
| `incremental` | No-op sentinel that enables incremental semantics for an otherwise empty list |
|
|
93
|
+
|
|
94
|
+
Use `remove` only when the child can validly exist without this parent or is being reparented in the same unit of work. For a required parent relation, `remove` alone usually creates an invalid entity. Use `delete` when the child should cease to exist.
|
|
95
|
+
|
|
96
|
+
An actual empty array still clears:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
await em.upsert(Author, { id: "a:1", books: [] });
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For an incremental no-op, prefer:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
await em.upsert(Author, { id: "a:1" });
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
If a generic payload builder must emit `books`, use:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
await em.upsert(Author, {
|
|
112
|
+
id: "a:1",
|
|
113
|
+
books: [{ op: "incremental" }],
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Stable Identity End to End
|
|
118
|
+
|
|
119
|
+
IDs are the reliable identity contract for active nested updates. A nested object without an ID is normally a request to create a new entity.
|
|
120
|
+
|
|
121
|
+
For an editable parent-child graph:
|
|
122
|
+
|
|
123
|
+
1. Query IDs for the parent and every editable nested entity.
|
|
124
|
+
2. Include those IDs in API response types.
|
|
125
|
+
3. Store IDs in form or draft state.
|
|
126
|
+
4. Send retained rows as `{ id, op: "include", ...changes }`.
|
|
127
|
+
5. Mark deleted persisted rows in place by switching their `op` to `delete` (or `remove`); keep them in the same array rather than moving their IDs to a separate deletion list.
|
|
128
|
+
6. Send new rows without an ID but with `op: "include"`.
|
|
129
|
+
7. Keep the same discipline recursively for grandchildren.
|
|
130
|
+
|
|
131
|
+
A robust UI row model carries `op` on the row itself, so a deleted book flips to `op: "delete"`/`"remove"` in place instead of moving to a separate collection:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
interface EditableBook {
|
|
135
|
+
id?: string;
|
|
136
|
+
op?: "include" | "remove" | "delete";
|
|
137
|
+
title: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
interface AuthorDraft {
|
|
141
|
+
books: EditableBook[];
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Because each row already mirrors `SaveBookInput` (`id`, `op`, scalars), the draft state can go directly onto the wire as the GraphQL input, with no separate deletion list to reconcile back in. Keep the collection incremental (every row has `op`) once any row does.
|
|
146
|
+
|
|
147
|
+
Do not key editable rows only by array index. Reordering or deleting an earlier row can assign an existing ID to the wrong logical row. Prefer structured row state with stable IDs. If a textarea represents multiple database rows, either maintain line identity explicitly or document why positional identity is safe for that domain.
|
|
148
|
+
|
|
149
|
+
Do not infer identity from `sortOrder`, names, unique constraints, or array position. Joist may use configured uniqueness for specific upsert cases such as soft-deleted rows, but do not assume `uniqueBy` will match active id-less children. Send the ID unless the current Joist behavior is intentionally relied on and covered by an integration test.
|
|
150
|
+
|
|
151
|
+
## GraphQL Shape
|
|
152
|
+
|
|
153
|
+
Make GraphQL inputs mirror Joist's native graph shape:
|
|
154
|
+
|
|
155
|
+
```graphql
|
|
156
|
+
enum UpsertOp {
|
|
157
|
+
include
|
|
158
|
+
remove
|
|
159
|
+
delete
|
|
160
|
+
incremental
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
input SaveAuthorInput {
|
|
164
|
+
id: ID
|
|
165
|
+
firstName: String
|
|
166
|
+
books: [SaveBookInput!]
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
input SaveBookInput {
|
|
170
|
+
id: ID
|
|
171
|
+
op: UpsertOp
|
|
172
|
+
title: String
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The corresponding output query must expose nested IDs:
|
|
177
|
+
|
|
178
|
+
```graphql
|
|
179
|
+
query EditAuthor($id: ID!) {
|
|
180
|
+
author(id: $id) {
|
|
181
|
+
id
|
|
182
|
+
firstName
|
|
183
|
+
books {
|
|
184
|
+
id
|
|
185
|
+
title
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Keep the resolver thin when the schema already matches the entity graph:
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
import { type DeepPartialOrNull } from "joist-orm";
|
|
195
|
+
|
|
196
|
+
async function saveAuthor(input: SaveAuthorInput, em: EntityManager): Promise<Author> {
|
|
197
|
+
return em.upsert(Author, input as DeepPartialOrNull<Author>);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The cast is appropriate only after checking that relation names, IDs, scalar fields, and nested collection operations align with Joist's expected graph. A cast does not make an incompatible payload safe.
|
|
202
|
+
|
|
203
|
+
Thin does not mean unchecked. Before calling `upsert`, authorize the parent and every nested ID for the caller's tenant/scope, and validate that each requested attach, reparent, remove, or delete operation is allowed. This security validation is separate from persistence reconciliation.
|
|
204
|
+
|
|
205
|
+
If the API also accepts convenience fields, such as a textarea that expands into child rows, use a small boundary mapper:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
type SaveAuthorConvenienceInput = SaveAuthorInput & { booksText?: string | null };
|
|
209
|
+
|
|
210
|
+
function toAuthorUpsertInput(input: SaveAuthorConvenienceInput): DeepPartialOrNull<Author> {
|
|
211
|
+
return {
|
|
212
|
+
id: input.id,
|
|
213
|
+
firstName: input.firstName,
|
|
214
|
+
books: mapBooks(input),
|
|
215
|
+
} as DeepPartialOrNull<Author>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function mapBooks(input: SaveAuthorConvenienceInput) {
|
|
219
|
+
if (input.books !== undefined) return input.books;
|
|
220
|
+
if (input.booksText === undefined) return undefined;
|
|
221
|
+
return parseLegacyBooks(input.booksText ?? "");
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The mapper should transform representation, not reconcile persistence. It must preserve `books: null` as an explicit clear and preserve omission as `undefined`; do not use `??` when `null` and omission have different meanings.
|
|
226
|
+
|
|
227
|
+
## REST and gRPC Shapes
|
|
228
|
+
|
|
229
|
+
Use the same graph contract regardless of transport. For example, a REST PATCH body can be:
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"id": "a:1",
|
|
234
|
+
"books": [
|
|
235
|
+
{ "id": "b:1", "op": "include", "title": "Updated title" },
|
|
236
|
+
{ "id": "b:2", "op": "delete" }
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
A gRPC message should model the same operations with an enum and explicit collection presence. A plain `repeated SaveBookInput books` field is unsafe for a partial update because its decoded empty list cannot distinguish "omitted" from "clear." Use a wrapper message inside a `oneof`, or an equivalent field-mask convention:
|
|
242
|
+
|
|
243
|
+
```proto
|
|
244
|
+
message BookChanges {
|
|
245
|
+
repeated SaveBookInput values = 1;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
message SaveAuthorRequest {
|
|
249
|
+
optional string id = 1;
|
|
250
|
+
oneof books_update {
|
|
251
|
+
BookChanges books = 2;
|
|
252
|
+
bool clear_books = 3;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
An unset `books_update` means unchanged; a present `books` wrapper carries incremental or exhaustive values; `clear_books: true` explicitly clears. Convert generated enum values to Joist's lowercase strings at the boundary if necessary.
|
|
258
|
+
|
|
259
|
+
Do not invent transport-specific reconciliation semantics. GraphQL, REST, and gRPC should all produce the same `DeepPartialOrNull<Entity>` graph before calling Joist.
|
|
260
|
+
|
|
261
|
+
## Implementation Workflow
|
|
262
|
+
|
|
263
|
+
1. Read the entity metadata and identify required inverse relations and delete behavior.
|
|
264
|
+
2. Trace the complete read-edit-write path, not only the resolver.
|
|
265
|
+
3. Verify every editable output type and query includes stable nested IDs.
|
|
266
|
+
4. Verify client state retains those IDs after parsing, normalization, and form edits.
|
|
267
|
+
5. Choose exhaustive or incremental semantics independently for every nested collection.
|
|
268
|
+
6. Make transport inputs match Joist's graph and expose `op` where incremental updates are needed.
|
|
269
|
+
7. Add only the smallest representation mapper required by the transport.
|
|
270
|
+
8. Call `em.upsert`, `entity.setPartial`, or a thin shared helper that delegates to them.
|
|
271
|
+
9. Flush in an integration test and assert identity, membership, deletion, and untouched fields.
|
|
272
|
+
|
|
273
|
+
## Failure Signatures
|
|
274
|
+
|
|
275
|
+
### `<Child> <parent> is required` after updating a parent
|
|
276
|
+
|
|
277
|
+
Likely cause: an id-less or incomplete child array was interpreted as exhaustive replacement. Joist created new children and detached omitted persisted children, whose required parent relation then failed validation.
|
|
278
|
+
|
|
279
|
+
Fix: preserve child IDs and either send the complete exhaustive graph or use `op: "include"`/`"delete"` incrementally.
|
|
280
|
+
|
|
281
|
+
### Duplicate children after each save
|
|
282
|
+
|
|
283
|
+
Likely cause: existing child IDs are missing from the write payload, so each row is treated as new.
|
|
284
|
+
|
|
285
|
+
Fix: query, retain, and resend IDs. Do not match by sort order or content on the server.
|
|
286
|
+
|
|
287
|
+
### All children disappear on a no-change save
|
|
288
|
+
|
|
289
|
+
Likely cause: a payload builder emitted `children: []`, which is an exhaustive clear.
|
|
290
|
+
|
|
291
|
+
Fix: omit `children`, or emit `[{ op: "incremental" }]` only if the key is mandatory.
|
|
292
|
+
|
|
293
|
+
### Incremental update is rejected or behaves exhaustively
|
|
294
|
+
|
|
295
|
+
Likely cause: only some children have `op`.
|
|
296
|
+
|
|
297
|
+
Fix: give every child in that collection an operation, including new children.
|
|
298
|
+
|
|
299
|
+
### GraphQL input does not type-check against Joist
|
|
300
|
+
|
|
301
|
+
Likely cause: generated nullable input types do not directly match strict entity setters, or the API has convenience fields not present on the entity.
|
|
302
|
+
|
|
303
|
+
Fix: target `DeepPartialOrNull<Entity>` and use a narrow boundary mapper. Do not weaken unrelated types or write a persistence reconciliation layer.
|
|
304
|
+
|
|
305
|
+
## Anti-Patterns
|
|
306
|
+
|
|
307
|
+
Never solve a partial-update mismatch by defaulting to these approaches:
|
|
308
|
+
|
|
309
|
+
- Loading all existing children in the resolver to assign IDs by array position.
|
|
310
|
+
- Diffing old and new child arrays manually.
|
|
311
|
+
- Appending custom delete markers after comparing database state.
|
|
312
|
+
- Matching active children by `sortOrder`, name, or another mutable field.
|
|
313
|
+
- Assuming a database unique constraint supplies identity to an id-less upsert.
|
|
314
|
+
- Dropping nested IDs from API output, DTOs, parsers, or form state.
|
|
315
|
+
- Mapping an omitted collection to `[]`.
|
|
316
|
+
- Mixing children with and without `op` in one collection.
|
|
317
|
+
- Using `remove` for a child whose parent relation is required.
|
|
318
|
+
- Treating an empty array as an incremental no-op.
|
|
319
|
+
- Converting every GraphQL `null` to `undefined`.
|
|
320
|
+
- Adding backward-compatibility reconciliation without a concrete shipped caller that requires it.
|
|
321
|
+
|
|
322
|
+
Custom reconciliation is justified only when the API contract fundamentally cannot carry stable identity or Joist operations, and changing that contract is impossible. Document that constraint before adding such code.
|
|
323
|
+
|
|
324
|
+
## Regression Tests
|
|
325
|
+
|
|
326
|
+
For a nested update bug, build a persisted graph before invoking the real API boundary:
|
|
327
|
+
|
|
328
|
+
1. Create a parent with at least three children.
|
|
329
|
+
2. Give one child at least two grandchildren.
|
|
330
|
+
3. Update retained entities using their IDs and `op: "include"`.
|
|
331
|
+
4. Add one new id-less entity with `op: "include"`.
|
|
332
|
+
5. Delete one persisted entity with `op: "delete"`.
|
|
333
|
+
6. Omit another relation and prove it remains unchanged.
|
|
334
|
+
7. Flush and reload.
|
|
335
|
+
8. Assert retained IDs are unchanged, new IDs were created, deleted entities are gone, and no duplicates exist.
|
|
336
|
+
|
|
337
|
+
Do not re-test `em.upsert`'s own collection semantics (omitted vs `[]` vs `[{ op: "incremental" }]`, `remove` vs `delete`, mixed-`op` rejection) — Joist owns and tests those. Test what is yours: that nested IDs and operations survive the transport boundary and reach the resolver. Do not stop at payload snapshots; the original class of failure often appears only during validation or flush.
|
|
338
|
+
|
|
339
|
+
## Review Checklist
|
|
340
|
+
|
|
341
|
+
- Are IDs selected for every editable nested entity?
|
|
342
|
+
- Are IDs retained in client or caller state?
|
|
343
|
+
- Does each supplied collection intentionally use exhaustive or incremental semantics?
|
|
344
|
+
- If incremental, does every child have `op`?
|
|
345
|
+
- Are new children marked `include`?
|
|
346
|
+
- Are deleted persisted IDs sent as `delete`?
|
|
347
|
+
- Is `remove` valid for the inverse relation's nullability?
|
|
348
|
+
- Can any no-change path emit `[]` accidentally?
|
|
349
|
+
- Are omitted fields preserved as omitted or `undefined`?
|
|
350
|
+
- Are explicit `null` values preserved where they mean unset?
|
|
351
|
+
- Is the resolver a thin `upsert`/`setPartial` boundary instead of a reconciliation engine?
|
|
352
|
+
- Does an integration test update a persisted graph and verify stable IDs after flush?
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: joist-reactive-hint
|
|
3
|
+
description: Explains how Joist reactive hints work and what they cost to run — a hint is both a reverse-reactivity trigger (which roots re-run when a hinted field changes) and a forward load hint (what gets populated before the lambda runs), so a rule can pull an entire child collection into memory even when its lambda only reads a parent field. Covers followReverseHint, the two rule shapes (child-rooted reacting up to a parent vs parent-rooted reacting down into a child collection), and how to avoid surprise O(children) loads. Use when reasoning about the performance of a reactive rule/field/property (addRule, hasReactiveField, hasReactiveProperty, hasReactiveReference), when a validation rule seems to load far more rows than expected, when deciding whether to put a field in a reactive hint vs load it on-demand, or when a hot-path mutation (e.g. a bulk job) triggers surprise N×M loads. Keywords: reactive hint, load hint, reverse reactivity, followReverseHint, reverseSubHint, m2o vs o2m reactivity, over-invalidation, populate, "a parent rule that hints a child collection loads the whole collection".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Joist reactive hints
|
|
7
|
+
|
|
8
|
+
Reactive hints declare the fields a rule, `ReactiveField`, `ReactiveProperty`, or `ReactiveReference`
|
|
9
|
+
depends on. A hint does **double duty**: Joist walks it in **reverse** to find *which* roots to re-run
|
|
10
|
+
when a hinted field changes, then uses it **forward as a load hint** to populate that data on each root
|
|
11
|
+
before the lambda runs. Most hints are cheap — but either direction can pull an entire child collection
|
|
12
|
+
into memory, and the *forward* load is the surprising one, so both are the focus below.
|
|
13
|
+
|
|
14
|
+
## TL;DR
|
|
15
|
+
|
|
16
|
+
A reactive rule/field is declared on a **root entity** with a hint. There are two shapes, and they
|
|
17
|
+
cost very differently.
|
|
18
|
+
|
|
19
|
+
**Shape #1 — rule on the child, hint reaches *up* to the parent** (e.g. a rule on `Book` with
|
|
20
|
+
`{ author: ["currentDraftBook"] }`). When `Author.currentDraftBook` changes, Joist walks the hint in
|
|
21
|
+
reverse (`followReverseHint`), reversing the `Book.author` m2o into the `Author.books` o2m and
|
|
22
|
+
**loading the whole collection** to enumerate the child roots, then re-runs each book's rule.
|
|
23
|
+
`O(children)` per parent-field change. This is **intuitive**: "change the author, and all of its books
|
|
24
|
+
re-check."
|
|
25
|
+
|
|
26
|
+
**Shape #2 — rule on the parent, hint reaches *down* into a child collection** (e.g. a rule on `Author`
|
|
27
|
+
with `{ books: ["title"] }`). When a single `Book.title` changes, the reverse walk is **cheap** — one
|
|
28
|
+
`book.author` m2o hop to the one author. But the reactive hint is **also a load hint**: before running
|
|
29
|
+
the author's lambda, Joist populates `author.books`, pulling the **entire** collection into memory —
|
|
30
|
+
*even if the lambda only reads `author.status` and never touches the books*.
|
|
31
|
+
|
|
32
|
+
> The surprising one is **Shape #2**. `{ books: ["title"] }` reads like "react to book titles," but it
|
|
33
|
+
> *also* means "load all of this author's books every time this rule fires." A lambda whose body is just
|
|
34
|
+
> `return a.status === "active" ? undefined : "…"` still pays to load `author.books`, because the
|
|
35
|
+
> **hint, not the lambda body, decides what gets loaded**.
|
|
36
|
+
|
|
37
|
+
Neither shows up in tests (behavior is correct; only throughput/memory suffer). Both bite bulk/hot-path
|
|
38
|
+
jobs at scale — Shape #2 especially, because it looks cheap from the reverse-reactivity side.
|
|
39
|
+
|
|
40
|
+
## Why: reverse reactivity *and* load hints
|
|
41
|
+
|
|
42
|
+
A hinted-field change triggers two steps, both in `joist-core/build/reactiveHints.js`:
|
|
43
|
+
|
|
44
|
+
**Step 1 — find the roots (reverse walk).** `followReverseHint` starts at the changed entity and walks
|
|
45
|
+
the hint in reverse, reversing each *traversed relation* (via `reverseSubHint`):
|
|
46
|
+
|
|
47
|
+
- Reverse of an **m2o** (`Book.author`) is the **o2m** (`Author.books`) — so a **child-rooted** rule
|
|
48
|
+
reacting to a parent field loads the whole sibling collection just to list the roots (Shape #1).
|
|
49
|
+
- Reverse of an **o2m** (`Author.books`) is the **m2o** (`Book.author`) — so a **parent-rooted** rule
|
|
50
|
+
reacting to a child field finds exactly one root per changed child (Shape #2's reverse is cheap).
|
|
51
|
+
- A **leaf field** (primitive / enum / m2o read as a value, e.g. `["title"]`, `["currentDraftBook"]`) is
|
|
52
|
+
only a "react to this field changing" trigger; it is **not** traversed into.
|
|
53
|
+
|
|
54
|
+
**Step 2 — load the hint (forward populate).** Before running each root's lambda, Joist populates the
|
|
55
|
+
reactive hint *as a load hint* on that root so the lambda can read it synchronously. For a parent-rooted
|
|
56
|
+
rule with `{ books: [...] }`, that is effectively `author.populate("books")` — the **full collection** —
|
|
57
|
+
**regardless of what the lambda actually reads**. This is why Shape #2 is expensive even though its
|
|
58
|
+
reverse walk touched only one author: the cost is in the forward load, not the reverse walk.
|
|
59
|
+
|
|
60
|
+
So `{ author: ["currentDraftBook"] }` on `Book` compiles to a reactive target
|
|
61
|
+
`{ entity: Author, fields: ["currentDraftBook"], path: ["books"] }` — "when `Author.currentDraftBook`
|
|
62
|
+
changes, load `Author.books` and re-validate each" — while `{ books: ["title"] }` on `Author` loads
|
|
63
|
+
`author.books` on every fire so the rule can run at all. Either way Joist over-invalidates for
|
|
64
|
+
correctness: every sibling is re-checked/loaded even when only one could change the outcome.
|
|
65
|
+
|
|
66
|
+
## The old/new-value shortcut — and when it does NOT apply
|
|
67
|
+
|
|
68
|
+
`followReverseHint` has a reference-history optimization (`getInstanceData(c).getReferenceHistory`)
|
|
69
|
+
that pulls in **old + new** values — but only when the **step being walked is itself an m2o/poly**
|
|
70
|
+
(the "`Book.author` moved to a new `Author`" reparent case). It exists so a reparent re-validates
|
|
71
|
+
both the old and new parent.
|
|
72
|
+
|
|
73
|
+
It does **not** turn a child→`parent.field` reaction into a cheap old/new lookup: there, the walked
|
|
74
|
+
step is the `books` **o2m**, so Joist takes the `relation.load()` (full-collection) branch. The
|
|
75
|
+
`currentDraftBook` field's own m2o-ness is irrelevant — it's reacted to *as a field*, not *traversed*.
|
|
76
|
+
|
|
77
|
+
Rule of thumb for the cost of one changed field:
|
|
78
|
+
- reverse step is an **o2m/o2o** (you're on the child, parent-field changed) → **loads the full
|
|
79
|
+
sibling collection**.
|
|
80
|
+
- reverse step is an **m2o/poly** being reparented → loads a couple entities (current + history).
|
|
81
|
+
|
|
82
|
+
## How to spot / avoid it
|
|
83
|
+
|
|
84
|
+
- **The hint decides the load, not the lambda body.** A parent rule with `{ books: [...] }` loads
|
|
85
|
+
*every* book on *every* fire, even if the lambda only reads the parent's own fields. If the rule does
|
|
86
|
+
not actually need the collection, do not hint it; if it does, know you are paying `O(children)` memory
|
|
87
|
+
per fire.
|
|
88
|
+
- **For SQL-derived fields, split the hint with `hasAsyncReactiveField`.** It takes two hints — a
|
|
89
|
+
`loadHint`, whose data is populated into memory and passed to the lambda, and a `reactiveHint`, whose
|
|
90
|
+
data only *triggers* recalculation but is **not** loaded into memory (the lambda recomputes from SQL
|
|
91
|
+
instead). Put the large child collections you merely need to react to in the `reactiveHint` so a
|
|
92
|
+
child-field change still recomputes the value without pulling every sibling into memory.
|
|
93
|
+
- **Root the rule where the frequently-changing field lives.** A rule on `Book` reacting to
|
|
94
|
+
`author.currentDraftBook` reloads all siblings; the same check rooted on `Author` reacting to its
|
|
95
|
+
own `["currentDraftBook"]` needs no reverse collection-load (but then detecting anything about the
|
|
96
|
+
*children* forces you to scan them anyway — so this only helps if the check is about the parent).
|
|
97
|
+
- **Only react to fields that change rarely.** Put a field in the reactive hint only if you truly
|
|
98
|
+
need to re-run when it changes. If you just need to *read* a value, `await rel.load()` it on
|
|
99
|
+
demand inside the rule and leave it out of the hint. Reserve the hint for the rare-change trigger
|
|
100
|
+
that actually needs to fire the rule.
|
|
101
|
+
- **Watch bulk/hot-path mutations.** If a job sets some `parent.fk` once per child (e.g. a bulk
|
|
102
|
+
copy job setting `author.currentDraftBook` per book), any child-rooted rule reacting to that fk
|
|
103
|
+
reloads every child's siblings — the same `O(children × siblings)` you'd get from an explicit
|
|
104
|
+
`parent.children.load()` in the loop.
|
|
105
|
+
|
|
106
|
+
## Worked examples
|
|
107
|
+
|
|
108
|
+
### Shape #2 — the surprising one: a parent rule hinting into a child collection
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// ❌ Rooted on Author. The hint `{ books: ["title"] }` reads like "react to book titles" — but it is
|
|
112
|
+
// ALSO a load hint, so every time ANY book's title changes, Joist loads the author's ENTIRE `books`
|
|
113
|
+
// collection into memory to run this rule, even though the lambda only looks at the author's status.
|
|
114
|
+
authorConfig.addRule(["status", { books: ["title"] }], (a) => {
|
|
115
|
+
return a.status === "active" ? undefined : "inactive authors need review";
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// ✅ The rule only depends on the author's own status, so hint only that — no books are loaded.
|
|
119
|
+
authorConfig.addRule("status", (a) => {
|
|
120
|
+
return a.status === "active" ? undefined : "inactive authors need review";
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
If the rule genuinely must react to a child field, keep the hint — but know each fire loads the whole
|
|
125
|
+
collection, so reserve it for collections the lambda actually reads and for child fields that change
|
|
126
|
+
rarely.
|
|
127
|
+
|
|
128
|
+
### Shape #1 — intuitive but still O(children): a child rule reacting to a parent field
|
|
129
|
+
|
|
130
|
+
Invariant wanted: "an unpublished book must be one of its author's tracked books — its `favoriteBook` or
|
|
131
|
+
`currentDraftBook`."
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
// ❌ Simple but O(books × siblings) on the bulk copy-job hot path:
|
|
135
|
+
// the job sets author.currentDraftBook per book -> reverse-loads author.books each time.
|
|
136
|
+
bookConfig.addRule(
|
|
137
|
+
["publishedAt", { author: ["favoriteBook", "currentDraftBook"] }],
|
|
138
|
+
(b) => { ... },
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// ✅ React only to favoriteBook (which changes rarely — on publish, not per draft edit);
|
|
142
|
+
// read currentDraftBook on-demand so it's not a reactive dependency.
|
|
143
|
+
bookConfig.addRule(["publishedAt", { author: ["favoriteBook"] }], async (b) => {
|
|
144
|
+
if (b.publishedAt) return;
|
|
145
|
+
const author = b.author.get;
|
|
146
|
+
const favorite = author.favoriteBook.get;
|
|
147
|
+
const draft = await author.currentDraftBook.load(); // read, don't react
|
|
148
|
+
if (b !== favorite && b !== draft) return `${b} is unpublished but neither the favorite nor current draft`;
|
|
149
|
+
});
|
|
150
|
+
```
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: joist-test-factories
|
|
3
|
+
description: Use when writing or refactoring Joist ORM tests with newTestInstance factories, DeepNew, run or makeRun, toMatchEntity, and nested Given graphs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Joist Test Factories
|
|
7
|
+
|
|
8
|
+
Write isolated, succinct tests that use Joist's factories for setup, retain
|
|
9
|
+
typed entity references through the action, and assert those same entities
|
|
10
|
+
with `toMatchEntity`.
|
|
11
|
+
|
|
12
|
+
Authoritative references:
|
|
13
|
+
|
|
14
|
+
- <https://joist-orm.io/testing/test-factories/>
|
|
15
|
+
- <https://joist-orm.io/testing/entity-matcher/>
|
|
16
|
+
- <https://joist-orm.io/testing/test-utils/>
|
|
17
|
+
- <https://joist-orm.io/goals/great-tests/>
|
|
18
|
+
|
|
19
|
+
## Non-Negotiable Rules
|
|
20
|
+
|
|
21
|
+
1. Create initial Given state with test factories. Never use the same function
|
|
22
|
+
or API operation under test to arrange its own preconditions.
|
|
23
|
+
2. Set only fields and relationships that define the boundary case. Let the
|
|
24
|
+
factories supply unrelated required values and dependencies.
|
|
25
|
+
3. Keep direct `const` references to entities that participate in the action or
|
|
26
|
+
assertions.
|
|
27
|
+
4. Keep using the factory-created `DeepNew` graph after same-`EntityManager`
|
|
28
|
+
actions or actions run through Joist's test `run` helper. Do not reload the
|
|
29
|
+
same rows merely to assert against them.
|
|
30
|
+
5. Use `run` or the project's `makeRun` wrapper when production code needs an
|
|
31
|
+
isolated `EntityManager`; it flushes Given state and mirrors the callback's
|
|
32
|
+
flushed Joist writes into the original test graph.
|
|
33
|
+
6. Assert entity state and relationships with `toMatchEntity`.
|
|
34
|
+
7. Prefer focused tests for one behavior over a single scenario that exercises
|
|
35
|
+
unrelated updates at several graph levels.
|
|
36
|
+
|
|
37
|
+
## Given, When, Then
|
|
38
|
+
|
|
39
|
+
Structure every test as "Given the state of the world is X, When action Y
|
|
40
|
+
happens, Then the state of the world is Z": the factory-created graph is the
|
|
41
|
+
Given, the code under test is the When, and `toMatchEntity` proves the Then.
|
|
42
|
+
Mark the three phases with `// Given`, `// When`, `// Then` comments:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
it.withCtx("updates a book", async (ctx) => {
|
|
46
|
+
// Given an author with one book
|
|
47
|
+
const author = newAuthor(ctx.em, {
|
|
48
|
+
books: [{ title: "Before" }],
|
|
49
|
+
});
|
|
50
|
+
const [book] = author.books.get;
|
|
51
|
+
|
|
52
|
+
// When we update the book's title (updateBook owns and flushes its production unit of work)
|
|
53
|
+
await run(ctx, (ctx) => updateBook(ctx, { id: book.id, title: "After" }));
|
|
54
|
+
|
|
55
|
+
// Then the book's title is changed
|
|
56
|
+
expect(author).toMatchEntity({ books: [{ title: "After" }] });
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The factory owns the Given defaults. `run` provides production isolation and
|
|
61
|
+
mirrors flushed writes. The callback still owns its production unit of work.
|
|
62
|
+
`toMatchEntity` owns the Then's entity-aware assertions.
|
|
63
|
+
|
|
64
|
+
## Factories Own Given State
|
|
65
|
+
|
|
66
|
+
Do not call the same code under test to arrange its own preconditions:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
// Wrong: saveAuthor is both setup and the behavior under test.
|
|
70
|
+
const created = await saveAuthor(ctx, {
|
|
71
|
+
firstName: "a1",
|
|
72
|
+
books: [{ title: "Before" }],
|
|
73
|
+
});
|
|
74
|
+
const author = await created.author;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This couples setup to the behavior under test, can reproduce the same bug in
|
|
78
|
+
both phases, and loses the ergonomic `DeepNew` type.
|
|
79
|
+
|
|
80
|
+
Use a factory instead:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const author = newAuthor(ctx.em, {
|
|
84
|
+
books: [{ title: "Before" }],
|
|
85
|
+
});
|
|
86
|
+
const [book] = author.books.get;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Factories are test-only tools. Never call them from production code.
|
|
90
|
+
Using another production API for Given state can be valid in an integration
|
|
91
|
+
test when that API's authorization, hooks, defaults, or events are part of the
|
|
92
|
+
scenario. This should be intentional, not the default way to create rows.
|
|
93
|
+
|
|
94
|
+
## Keep Given State Minimal
|
|
95
|
+
|
|
96
|
+
Every explicit factory option should answer: "Why does this test need this
|
|
97
|
+
value?"
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// Wrong: most values are unrelated to changing one title.
|
|
101
|
+
const author = newAuthor(ctx.em, {
|
|
102
|
+
firstName: "Ann",
|
|
103
|
+
lastName: "Smith",
|
|
104
|
+
age: 40,
|
|
105
|
+
books: [
|
|
106
|
+
{
|
|
107
|
+
title: "Before",
|
|
108
|
+
order: 1,
|
|
109
|
+
published: false,
|
|
110
|
+
reviews: [],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
// Right: only the value being changed is specified.
|
|
118
|
+
const author = newAuthor(ctx.em, {
|
|
119
|
+
books: [{ title: "Before" }],
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Specify additional values only when they establish the scenario. Examples:
|
|
124
|
+
|
|
125
|
+
- Two `{}` children establish collection cardinality.
|
|
126
|
+
- Distinct sort orders may be necessary for a parent/sort-order unique key.
|
|
127
|
+
- An initial value is necessary when the assertion proves that it changed.
|
|
128
|
+
- A relation override is necessary when the identity of that relation matters.
|
|
129
|
+
|
|
130
|
+
Do not copy production payloads into factory opts. Factory opts describe the
|
|
131
|
+
minimum database state before the action, not every field the action accepts.
|
|
132
|
+
|
|
133
|
+
## Build Graphs in One Factory Call
|
|
134
|
+
|
|
135
|
+
Prefer a top-level factory with nested opts when it clearly describes the
|
|
136
|
+
scenario:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
const author = newAuthor(ctx.em, {
|
|
140
|
+
books: [{ title: "First", reviews: [{ rating: 5 }] }, { title: "Second" }],
|
|
141
|
+
});
|
|
142
|
+
const [firstBook, secondBook] = author.books.get;
|
|
143
|
+
const [review] = firstBook.reviews.get;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This is usually clearer than creating each row separately and wiring every
|
|
147
|
+
required relation by hand. Separate factory calls are appropriate when the
|
|
148
|
+
test's behavior is specifically about how independently created entities
|
|
149
|
+
relate.
|
|
150
|
+
|
|
151
|
+
Factories recursively fill required primitives and relations. They also reuse
|
|
152
|
+
an obvious existing entity when exactly one candidate exists. Use factory
|
|
153
|
+
controls intentionally:
|
|
154
|
+
|
|
155
|
+
- Pass an entity directly to force a specific relation.
|
|
156
|
+
- Pass `{ use: entity }` to nominate an existing entity throughout a factory
|
|
157
|
+
scope.
|
|
158
|
+
- Pass `{}` for a relation when a new related entity is required.
|
|
159
|
+
- Use `useFactoryDefaults: false` sparingly; frequent use means the factory
|
|
160
|
+
defaults may be too opinionated.
|
|
161
|
+
- Use `useFactoryDefaults: "none"` only for tests explicitly exercising invalid
|
|
162
|
+
or incomplete state.
|
|
163
|
+
|
|
164
|
+
## Retain Entity References
|
|
165
|
+
|
|
166
|
+
Immediately name entities used by the action or assertions:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const author = newAuthor(ctx.em, {
|
|
170
|
+
books: [{}, {}],
|
|
171
|
+
});
|
|
172
|
+
const [updatedBook, deletedBook] = author.books.get;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Do not unnecessarily rediscover Given entities later by index, query, ID, or
|
|
176
|
+
mutation result. Newly created entities can come from the action result, and a
|
|
177
|
+
query result is appropriate when querying is the behavior under test.
|
|
178
|
+
|
|
179
|
+
For complicated cross-references in one factory graph, use factory IDs:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
const author = newAuthor(ctx.em, {
|
|
183
|
+
books: [
|
|
184
|
+
{ is: "b#1", title: "First" },
|
|
185
|
+
{ is: "b#2", prequel: "b#1", title: "Second" },
|
|
186
|
+
],
|
|
187
|
+
});
|
|
188
|
+
const [firstBook, secondBook] = author.books.get;
|
|
189
|
+
|
|
190
|
+
expect(secondBook).toMatchEntity({ prequel: firstBook });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The `factories` proxy is also available when direct relation destructuring is
|
|
194
|
+
awkward:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
newAuthor(ctx.em, { books: [{}, {}] });
|
|
198
|
+
const { a1, b1, b2 } = factories;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The proxy resolves against the most recently used `EntityManager`, so avoid it
|
|
202
|
+
in tests with multiple active test entity managers.
|
|
203
|
+
|
|
204
|
+
Prefer ordinary named constants when the graph is small; they make the test's
|
|
205
|
+
roles clearer than numeric factory IDs.
|
|
206
|
+
|
|
207
|
+
## DeepNew Means Async-Free Graph Access
|
|
208
|
+
|
|
209
|
+
Follow the signature generated by the project's Joist version. Factories that
|
|
210
|
+
return `DeepNew<Entity>` provide the loaded graph ergonomics used here:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
export function newAuthor(em: EntityManager, opts: FactoryOpts<Author> = {}): DeepNew<Author> {
|
|
214
|
+
return newTestInstance(em, Author, opts, {});
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`DeepNew` is a loadedness type for the factory-created graph, so setup and
|
|
219
|
+
assertions can use `.get` without `await`:
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
const author = newAuthor(ctx.em, { books: [{}] });
|
|
223
|
+
const [book] = author.books.get;
|
|
224
|
+
|
|
225
|
+
expect(author).toMatchEntity({ books: [book] });
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Avoid this boilerplate:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
const books = await author.books.load();
|
|
232
|
+
const reloadedAuthor = await ctx.em.load(Author, author.id);
|
|
233
|
+
const reloadedBooks = await reloadedAuthor.books.load();
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`DeepNew` does not synchronize writes from another `EntityManager`. If a
|
|
237
|
+
relation was not part of the factory-created graph, use an intentional
|
|
238
|
+
populate, or use Joist's `run` helper when testing a separate production unit
|
|
239
|
+
of work. Do not silence a legitimate unloaded-relation boundary with arbitrary
|
|
240
|
+
test-only loads.
|
|
241
|
+
|
|
242
|
+
## Use run for Production Isolation
|
|
243
|
+
|
|
244
|
+
Joist's `run(ctx, fn)` executes `fn` with a fresh production-style context and
|
|
245
|
+
`EntityManager`. Before the callback, it flushes the test factory graph. As the
|
|
246
|
+
callback flushes Joist writes, `RunPlugin` mirrors those writes into the
|
|
247
|
+
original test `EntityManager`. It does not call `EntityManager.refresh`. The
|
|
248
|
+
callback result is also mapped back to entities from the original test
|
|
249
|
+
`EntityManager`.
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
const author = newAuthor(ctx.em, { books: [{ title: "Before" }] });
|
|
253
|
+
const [book] = author.books.get;
|
|
254
|
+
|
|
255
|
+
// updateBook must own and flush its production unit of work.
|
|
256
|
+
await run(ctx, (ctx) => updateBook(ctx, { id: book.id, title: "After" }));
|
|
257
|
+
|
|
258
|
+
expect(book).toMatchEntity({ title: "After" });
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Many applications expose a project-specific helper created with `makeRun`,
|
|
262
|
+
such as `runMutation` or `runService`. Use that helper instead of manually
|
|
263
|
+
constructing a second `EntityManager`.
|
|
264
|
+
|
|
265
|
+
`run` deliberately does not flush the callback's `EntityManager`; production
|
|
266
|
+
code under test must own its normal unit-of-work boundary. Unflushed changes,
|
|
267
|
+
direct SQL, and writes outside Joist are not guaranteed to be mirrored into the
|
|
268
|
+
test graph.
|
|
269
|
+
|
|
270
|
+
Do not write:
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
const result = await runMutation(ctx, () => updateBookInput(book.id));
|
|
274
|
+
const savedBook = await result.book;
|
|
275
|
+
const books = await savedBook.author.load().then((author) => author.books.load());
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Keep using `author` and `book`. They are the stable test references.
|
|
279
|
+
|
|
280
|
+
Call `em.flush()` directly only when the test intentionally needs a persistence
|
|
281
|
+
boundary and its helper does not provide one. Pure entity tests should usually
|
|
282
|
+
avoid unnecessary flushes.
|
|
283
|
+
|
|
284
|
+
## Register toMatchEntity
|
|
285
|
+
|
|
286
|
+
Examples assume `toMatchEntity` is imported from the `joist-orm/tests`
|
|
287
|
+
entry point and registered in the project's test setup:
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
import { toMatchEntity } from "joist-orm/tests";
|
|
291
|
+
|
|
292
|
+
expect.extend({ toMatchEntity });
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Use the runner-specific setup and types from the installed Joist version.
|
|
296
|
+
|
|
297
|
+
## Assert with toMatchEntity
|
|
298
|
+
|
|
299
|
+
`toMatchEntity` provides `toMatchObject`-style subset assertions while
|
|
300
|
+
understanding Joist references, collections, properties, reactive fields, and
|
|
301
|
+
entity identity. It also produces concise entity IDs in diffs.
|
|
302
|
+
|
|
303
|
+
`toMatchEntity` synchronously unwraps loaded relations through `.get`; it does
|
|
304
|
+
not query or asynchronously load missing relations. Ensure the asserted graph
|
|
305
|
+
is loaded by the factory, an intentional populate, or `RunPlugin`.
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
expect(author).toMatchEntity({
|
|
309
|
+
firstName: "Ann",
|
|
310
|
+
books: [book],
|
|
311
|
+
});
|
|
312
|
+
expect(book).toMatchEntity({ title: "After" });
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Pass retained entity constants directly for relationship identity. Use nested
|
|
316
|
+
object literals when the nested values themselves are the assertion:
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
expect(author).toMatchEntity({
|
|
320
|
+
books: [{ title: "First" }, { title: "Second" }],
|
|
321
|
+
});
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
For a hard delete, assert both the surviving collection and deletion state
|
|
325
|
+
when deletion semantics matter:
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
expect(author).toMatchEntity({ books: [updatedBook] });
|
|
329
|
+
expect(deletedBook).toMatchEntity({ isDeletedEntity: true });
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Do not map entity graphs into temporary POJOs just to use `toEqual`:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
// Wrong.
|
|
336
|
+
expect((await author.books.load()).map((book) => ({ id: book.id, title: book.title }))).toEqual([
|
|
337
|
+
{ id: updatedBook.id, title: "After" },
|
|
338
|
+
]);
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Keep Tests Focused
|
|
342
|
+
|
|
343
|
+
One test should describe one coherent boundary. Split a large graph mutation
|
|
344
|
+
into separate tests when failures would otherwise have several unrelated
|
|
345
|
+
causes:
|
|
346
|
+
|
|
347
|
+
- Updating/deleting members of a parent collection.
|
|
348
|
+
- Updating/deleting grandchildren.
|
|
349
|
+
- Creating a new nested entity.
|
|
350
|
+
- Clearing a collection.
|
|
351
|
+
- Preserving an omitted relation.
|
|
352
|
+
|
|
353
|
+
Combining an update and delete can be appropriate when they jointly exercise
|
|
354
|
+
one incremental-collection contract. Avoid a kitchen-sink test that performs
|
|
355
|
+
step updates, ingredient updates, note updates, and several unrelated scalar
|
|
356
|
+
changes in one action.
|
|
357
|
+
|
|
358
|
+
Focused tests produce smaller Given graphs, clearer constants, and useful
|
|
359
|
+
failure messages.
|
|
360
|
+
|
|
361
|
+
## Factory Defaults
|
|
362
|
+
|
|
363
|
+
Customize a generated factory only for defaults that make entities valid by
|
|
364
|
+
default across the suite:
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
export function newAuthor(em: EntityManager, opts: FactoryOpts<Author> = {}): DeepNew<Author> {
|
|
368
|
+
return newTestInstance(em, Author, opts, {
|
|
369
|
+
age: 40,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Use `testIndex` for deterministic unique values when a database unique
|
|
375
|
+
constraint requires them. Add collection defaults only for genuine suite-wide
|
|
376
|
+
validity rules, such as every valid author requiring at least one book.
|
|
377
|
+
|
|
378
|
+
Custom options such as `withSignedContract` can package a commonly repeated
|
|
379
|
+
graph, but use them sparingly. A reader should not need to inspect a factory to
|
|
380
|
+
understand the values directly asserted by the test.
|
|
381
|
+
|
|
382
|
+
If factory behavior is surprising, enable `useLogging: true` for that call or
|
|
383
|
+
temporarily enable global factory logging. Diagnose the factory scope and
|
|
384
|
+
reuse decisions instead of replacing factories with manual setup.
|
|
385
|
+
|
|
386
|
+
## Review Checklist
|
|
387
|
+
|
|
388
|
+
- Test reads as Given, When, Then, with the code under test isolated as a single
|
|
389
|
+
When.
|
|
390
|
+
- Given state uses minimal factory opts and does not invoke the behavior under
|
|
391
|
+
test.
|
|
392
|
+
- Important entities have direct, role-based `const` names.
|
|
393
|
+
- Separate production units of work use `run`/`makeRun` and flush normally.
|
|
394
|
+
- Assertions reuse loaded factory entities with `toMatchEntity`.
|
|
395
|
+
- No unnecessary reloads, `load()` calls, assertion awaits, or direct flushes
|
|
396
|
+
remain.
|
|
397
|
+
- Each test covers one coherent boundary.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: joist-upsert
|
|
3
|
+
description: Implement partial-update / RPC / GraphQL save endpoints with Joist using setPartial, createPartial, em.upsert, and incremental collection ops. Use when a create/update accepts a subset of fields, treats null as "unset", or saves a parent plus a mix of new and existing children.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- Managed by joist-codegen. Do not edit by hand; re-run codegen to update. -->
|
|
7
|
+
|
|
8
|
+
# Joist partial updates & upsert
|
|
9
|
+
|
|
10
|
+
These APIs exist for "partial update" endpoints (REST/GraphQL/gRPC) where the
|
|
11
|
+
input is loosely typed (`string | null | undefined`) and follows the
|
|
12
|
+
conventions:
|
|
13
|
+
|
|
14
|
+
- A subset of fields may be sent; omitted fields are left as-is.
|
|
15
|
+
- `null` means "unset this field".
|
|
16
|
+
- Children collections can be updated incrementally.
|
|
17
|
+
|
|
18
|
+
Joist's normal `em.create` / `Entity.set` are intentionally strict and won't
|
|
19
|
+
accept `string | null | undefined`. The partial variants opt into the looser
|
|
20
|
+
semantics.
|
|
21
|
+
|
|
22
|
+
## `setPartial`
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// firstName is typed `string | null | undefined` (e.g. from a GraphQL input)
|
|
26
|
+
const author = await em.load(Author, "a:1");
|
|
27
|
+
author.setPartial({ firstName }); // compiles; `set` would not
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Semantics, per field:
|
|
31
|
+
|
|
32
|
+
- Required field (`firstName`): value updates it; `undefined` does nothing;
|
|
33
|
+
`null` is a **validation error** (required field can't be unset).
|
|
34
|
+
- Optional field (`lastName`): value updates it; `undefined` does nothing;
|
|
35
|
+
`null` unsets it (sets to `undefined`).
|
|
36
|
+
- Collection (`books`): `[b1]` sets it to exactly `[b1]`; `null` sets it to
|
|
37
|
+
`[]`; `undefined` does nothing.
|
|
38
|
+
|
|
39
|
+
`em.createPartial(Author, ...)` and `em.upsert(Author, ...)` share these
|
|
40
|
+
semantics.
|
|
41
|
+
|
|
42
|
+
## `em.upsert` — parent plus children
|
|
43
|
+
|
|
44
|
+
`em.upsert` saves a parent and a mix of new/existing children in one call. It is
|
|
45
|
+
**async** (unlike `em.create`) because it may issue `SELECT`s to resolve
|
|
46
|
+
existing child ids.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
await em.upsert(Author, {
|
|
50
|
+
id: "a:1", // update author 1
|
|
51
|
+
books: [
|
|
52
|
+
{ title: "new book" }, // no id -> create
|
|
53
|
+
{ id: "b:1" }, // existing, unchanged
|
|
54
|
+
{ id: "b:2", title: "updated" }, // existing, updated
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
By default a collection is set **exhaustively** — any existing child not listed
|
|
60
|
+
is removed.
|
|
61
|
+
|
|
62
|
+
## Incremental collections (`op`)
|
|
63
|
+
|
|
64
|
+
To change only some children without sending the whole collection, add an `op`
|
|
65
|
+
hint to each child:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
author.setPartial({
|
|
69
|
+
books: [{ op: "include", title: "b3" }], // adds b3, leaves existing books
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- `{ op: "include", id }` — add if needed, or update an existing child
|
|
74
|
+
- `{ op: "remove", id }` — remove from the collection (no delete)
|
|
75
|
+
- `{ op: "delete", id }` — remove and `em.delete` the child
|
|
76
|
+
|
|
77
|
+
Rules and gotchas:
|
|
78
|
+
|
|
79
|
+
- If **any** child has an `op`, **all** children must have one.
|
|
80
|
+
- `op` is not a real entity field — it's only a hint on the input type.
|
|
81
|
+
- An **empty** list always clears the collection (it looks like an exhaustive
|
|
82
|
+
set), so to send "no changes" omit the collection key entirely. Alternatively
|
|
83
|
+
include a single `{ op: "incremental" }` sentinel child to force incremental
|
|
84
|
+
semantics without adding/removing anything.
|
|
85
|
+
|
|
86
|
+
## Legacy keys (soft-deprecated)
|
|
87
|
+
|
|
88
|
+
Older code used `delete: true` / `remove: true` instead of `op`; still
|
|
89
|
+
supported, but prefer `op` for new code:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
author.setPartial({
|
|
93
|
+
books: [{ id: "b:1", delete: true }, { id: "b:2", remove: true }, { id: "b:4" }],
|
|
94
|
+
});
|
|
95
|
+
```
|