joist-codegen 2.3.0-next.83 → 2.3.0-next.84

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joist-codegen",
3
- "version": "2.3.0-next.83",
3
+ "version": "2.3.0-next.84",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "skills"
39
39
  ],
40
40
  "peerDependencies": {
41
- "joist-utils": "2.3.0-next.83",
41
+ "joist-utils": "2.3.0-next.84",
42
42
  "knex": "^3.1.0",
43
43
  "pg": "^8.23.0"
44
44
  },
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: entity-docs
3
- description: Read and write the `src/entities/<Entity>.md` business-docs that sit next to each Joist entity. Use when working on ANY entity in `src/entities/` (its `.ts`, resolvers, jobs, or tests) read the sibling `.md` first for the business rationale, worked scenarios, and gotchas the code can't show, and record any non-obvious domain knowledge you learn back into it. Also covers the codegen doc-sync: how `## Overview` and `## Fields`/`### fieldName` sections become entity JSDocs via `yarn joist-codegen`, and what belongs in field docs vs. free-form narrative.
3
+ description: Read the `src/entities/<Entity>.md` business-docs when working on an entity, its resolvers, jobs, or tests. Add only durable, non-obvious domain knowledge that helps readers understand a business rule or avoid a likely mistake; prioritize succinctness, clarity, and discretion. Also covers how `## Overview` and `## Fields`/`### fieldName` sections sync to JSDocs via `yarn joist-codegen`.
4
4
  ---
5
5
 
6
6
  # Entity docs (`src/entities/<Entity>.md`)
@@ -10,10 +10,11 @@ Many Joist entities have a sibling Markdown doc — `src/entities/Author.ts` ↔
10
10
  **"why"** that code can't: business rationale, worked scenarios, gotchas, domain vocabulary, and
11
11
  cross-entity workflows. They are written for **both humans and agents** — you are a primary audience.
12
12
 
13
- Two jobs, and you should do both as a matter of course:
13
+ Read routinely; write selectively:
14
14
 
15
15
  1. **Read** the sibling `.md` before/while you work on an entity, to get domain context.
16
- 2. **Write** back to it whenever you learn something useful, weird, or non-obvious.
16
+ 2. **Write** only when a concise addition would give future readers important context they cannot
17
+ readily get from the code or existing docs. Leaving the docs unchanged is often the right outcome.
17
18
 
18
19
  ## 1. Read it first
19
20
 
@@ -27,9 +28,8 @@ have to reverse-engineer or would get subtly wrong:
27
28
  - **Gotchas & edge cases** — footguns, "this looks stale but isn't", exemptions
28
29
  - **Domain vocabulary** — statuses, flags, and other "esoteric unless you know it" domain concepts
29
30
 
30
- Follow the cross-links (`[Book](Book.md)`, sometimes with anchors like
31
- `Book.md#Definitions`) into related docs. If the doc is missing or thin, that's your cue to add
32
- to it once you've figured things out (job #2).
31
+ Follow relevant cross-links (`[Book](Book.md)`, sometimes with anchors like
32
+ `Book.md#Definitions`) into related docs. A missing or thin doc is not by itself a reason to add content.
33
33
 
34
34
  ## 2. How the file maps to code (the codegen doc-sync)
35
35
 
@@ -67,10 +67,10 @@ in the `.ts` gets stomped on the next codegen.
67
67
  entries together under the one `## Fields` section (conventionally at the bottom of the file).
68
68
  - **Methods don't sync** — only fields/getters/properties/relations get their JSDoc updated.
69
69
 
70
- ## 3. Write back what you learn
70
+ ## 3. Choose what is worth documenting
71
71
 
72
- When you discover something useful/weird/non-obvious while working record it. This is the point of the
73
- files. Good triggers to write:
72
+ Add a note only when the knowledge is durable, non-obvious, and useful for a future domain decision or
73
+ for avoiding a likely mistake. Possible candidates, not a checklist to fill:
74
74
 
75
75
  - You just figured out **why** an entity or field exists, or what it really models.
76
76
  - A **non-obvious business rule**, invariant, or "this only applies to X clients" exemption.
@@ -78,28 +78,35 @@ files. Good triggers to write:
78
78
  type.
79
79
  - A **cross-entity interaction** or workflow that isn't visible from one file.
80
80
  - **Domain vocabulary** a newcomer (human or agent) wouldn't know.
81
- - A **worked scenario** that makes an abstract entity concrete.
81
+ - A **worked scenario** needed to resolve an ambiguity that a short explanation cannot.
82
82
 
83
- **Don't** document what the code already says plainly (restating a type, signature, or an obvious
84
- one-liner), or transient implementation detail that will rot.
83
+ **Omit** what the code already says plainly, transient implementation details, exhaustive edge-case
84
+ lists, and a recap of the work just completed. Do not repeat knowledge already documented elsewhere;
85
+ link to it when readers need it. Correct outdated guidance rather than appending a competing explanation.
85
86
 
86
87
  **Where to put it:**
87
88
 
88
89
  - Something specific to one field → a `### <fieldName>` block under `## Fields`. It syncs to that
89
90
  member's JSDoc, so it shows on hover/`@generated` in the `.ts`.
90
- - Broad rationale, scenarios, diagrams, cross-entity workflows, DB constraints, glossary a free-form
91
- `##` section (`## Overview` for the headline, or a custom section like `## Employee Onboarding Flow`).
91
+ - The entity's purpose a short `## Overview`, which syncs to the class JSDoc.
92
+ - Necessary longer explanations or cross-entity workflows a free-form `##` section, linked from the
93
+ field doc if needed. Keep synced JSDocs small enough to read comfortably on hover.
92
94
 
93
- **Style** (match the existing docs):
95
+ **Style** (prioritize succinctness and clarity):
94
96
 
95
- - Lead with business meaning and *why*, not mechanics.
96
- - Use `I.e. ...` worked examples with concrete values.
97
+ - Lead with business meaning and *why*. Use plain language and state each fact once.
98
+ - Default to one sentence for a field and one short paragraph for an overview. Add detail only when
99
+ shortening it would hide an important rule or make the meaning ambiguous.
100
+ - Use a single brief `I.e. ...` example with concrete values only when it clarifies a difficult rule.
101
+ Do not add examples, diagrams, or sections merely to make the doc look complete.
97
102
  - Cross-link related entities with relative links: `[Book](Book.md)`.
98
103
  - Reference field/entity names in backticks.
104
+ - Before finishing, remove any sentence that does not add necessary meaning. Match existing terminology,
105
+ but do not copy existing verbosity.
99
106
 
100
107
  ## 4. Workflow to add or update a doc
101
108
 
102
- 1. Edit `src/entities/<Entity>.md` (create it if missing — basename must equal the entity, e.g.
109
+ 1. If an addition meets the criteria above, edit `src/entities/<Entity>.md` (create it only if needed — basename must equal the entity, e.g.
103
110
  `Author.md`). For field docs, use the exact member name as a `### ` heading under `## Fields`.
104
111
  2. Sync into the JSDocs:
105
112
  ```bash
@@ -114,6 +121,8 @@ touch files under `src/entities/codegen/` (see the repo's generated-files rules)
114
121
 
115
122
  ## Skeleton for a new doc
116
123
 
124
+ Include only the sections and fields that need explanation; this is a structure, not a checklist.
125
+
117
126
  ```markdown
118
127
  # <Entity>
119
128
 
@@ -123,11 +132,11 @@ touch files under `src/entities/codegen/` (see the repo's generated-files rules)
123
132
 
124
133
  ## <Some Business Concept> <!-- free-form: rationale, scenarios, gotchas, diagrams; NOT synced -->
125
134
 
126
- <Prose, `I.e.` examples, mermaid, cross-links to [OtherEntity](OtherEntity.md).>
135
+ <Only if needed: a concise explanation of a non-obvious business concept.>
127
136
 
128
137
  ## Fields <!-- each ### below syncs into that member's JSDoc -->
129
138
 
130
139
  ### someField
131
140
 
132
- <Why it exists / the non-obvious rule or gotcha. Exact field name, single word.>
141
+ <Usually one sentence: why it exists or the important non-obvious rule.>
133
142
  ```