Skip to content

fix(generator): honor resource capabilities and form defaults - #49

Merged
yyyyaaa merged 5 commits into
mainfrom
fix/gen-readonly-models
Nov 6, 2026
Merged

yyyyaaa merged 5 commits into
mainfrom
fix/gen-readonly-models

Conversation

@yyyyaaa

@yyyyaaa yyyyaaa commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor
  • Generate list and detail pages for models with restricted writes. The Resource Kit shows only the actions exposed by the schema.
  • Use both name parts in person pickers and related records. Keep explicit AppSpec row titles.
  • Prefill required date and time controls on create when neither the database nor AppSpec supplies a default.
  • Build the composed-app check against blocks da1ff834, the merge of the Resource Kit capability change that these configs need.
Mock CRM fixture Before After
Insert-only interactions Row menu includes Edit and Delete Row menu offers Open only
New interaction Identical first names and an empty When field Distinct full names and a prefilled When field

@yyyyaaa
yyyyaaa marked this pull request as ready for review November 6, 2026 16:30
@luxor-code-review

luxor-code-review Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)

  • 🟡 Optional name pair shadows required title, yields empty titles — meta-ir.ts:648

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 orm-source.ts (ordering by the composite parts and synthesizing the label on read). It also restricts junction-table detection to link tables with both create and delete mutations, and adds a 'now' creation default for required writable date-only fields, with updated tests across both packages.

Files Change
shared/gen/meta-ir.ts Adds composite-title derivation (personTitle), 'now' default gating, and junction detection requiring create+delete mutations to the meta-IR.
shared/gen/emitters/nextjs.ts Emits the synthetic fullName field config, adjusted detail/column layouts, and relation label wiring for composite titles.
shared/app/lib/resources/orm-source.ts Adds runtime support: orders by composite title parts, maps wire rows to a synthesized label, and guards write methods when the ORM lacks them.
shared/gen/__tests__/meta-ir.test.ts, shared/gen/__tests__/emitter.test.ts Updates IR and emitter snapshots/tests for composite titles, 'now' defaults, and junction rules.
shared/app/lib/resources/__tests__/orm-source.test.ts Tests composite-title ordering, label synthesis, and optional write-method guards.
README.md Documentation touch.

Reviewed commit: e0088fd

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread shared/gen/meta-ir.ts
Comment on lines +648 to +664
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.
@socket-security

Copy link
Copy Markdown

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.

@yyyyaaa
yyyyaaa merged commit aebcf9d into main Nov 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant