Repository navigation
fix(generator): honor resource capabilities and form defaults - #49
Conversation
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR teaches the generator to build composite person titles from first/last name pairs, both at the meta-IR level and in the Next.js emitter, with matching runtime handling in
Reviewed commit: e0088fd |
There was a problem hiding this comment.
Adds composite-title support (synthetic fullName) to the ORM source and Next.js resource generator, tightens junction-link detection, and gates 'now' defaults for required date fields.
Key findings
- 🟡 Optional name pair shadows required title, yields empty titles — meta-ir.ts:648
| ir.compositeTitle = namedTitle ? undefined : namePair; | ||
| const title = | ||
| named(required(informative), TITLE_NAMES) ?? | ||
| namedTitle ?? | ||
| namedField(informative, ['email']) ?? | ||
| required(informative).find((field) => field.input === 'text') ?? | ||
| required(informative)[0] ?? | ||
| required(longText)[0] ?? | ||
| // No text to name a row: resource-kit titles it by the related record instead. | ||
| required(belongsTo)[0] ?? | ||
| named(informative, TITLE_NAMES) ?? | ||
| named(informative, TITLE_FALLBACK_NAMES) ?? | ||
| namedField(informative, TITLE_FALLBACK_NAMES) ?? | ||
| informative[0] ?? | ||
| belongsTo[0] ?? | ||
| longText[0] ?? | ||
| required(textual)[0] ?? | ||
| textual[0] ?? | ||
| visible.find((field) => !field.readOnly && field.selectable); | ||
| ir.titleField = title?.name ?? ir.primaryKey; | ||
| ir.titleField = ir.compositeTitle?.name ?? title?.name ?? ir.primaryKey; |
There was a problem hiding this comment.
🟡 bug · medium
Optional name pair shadows required title, yields empty titles
personTitle accepts any visible text firstName/lastName pair without checking that either field is required, and finishLayout assigns it as compositeTitle whenever no TITLE_NAMES field exists (shared/gen/meta-ir.ts:648), so the synthetic fullName outranks the entire fallback chain — email, required text, required longText — at shared/gen/meta-ir.ts:664. fromWire joins the two parts with .filter(Boolean), so a row whose name fields are both empty gets row.fullName === ''. Rows with blank optional names render with an empty title where the previous ordering would have titled them by a required field; the same empty label feeds relation pickers.
📋 Prompt for AI Agents
In shared/gen/meta-ir.ts, finishLayout (around lines 633-664): gate the person-title promotion on requiredness. Look up the given/family FieldIR entries matched by personTitle (lines 619-627) in ir.fields, and at line 648 assign ir.compositeTitle = namedTitle ? undefined : namePair only when at least one of those fields has required === true; otherwise assign undefined so the existing chain (email at line 651, required text at 652-653, etc.) picks a title that is never empty. Update the 'picks a title field' and person-title tests in shared/gen/tests/meta-ir.test.ts with an optional-name-parts fixture asserting the required field or email wins.
…ities The generator now emits resource operations and create-only date defaults, which the resource kit gained in blocks da1ff834 (blocks#60). The composed-app check built the registry at an older commit and failed on the new fields.
|
Dependency limit exceeded — report not shown. This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report. Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard. Socket is always free for open source. If this is a non-commercial open source project, contact us to request a free Team account. |
da1ff834, the merge of the Resource Kit capability change that these configs need.