Issues discovered while testing against dealbrain project.
Current: Generator uses OpportunityEntity as the type name
Expected: Opportunity (no Entity suffix)
Location: templates/entity/new/frontend/entity/types.ejs.t
Details:
- Dealbrain's
@repo/db/schema/clientexportsOpportunity, notOpportunityEntity - Generator assumes
{ClassName}Entityconvention - Need config option:
typeNaming: 'entity' | 'plain'(default: 'entity')
Current: Always generates import { userCollection } from './user' when entity has belongs_to relation
Expected: Skip FK resolution when target collection doesn't exist
Location: templates/entity/new/frontend/entity/collection.ejs.t lines 30-31, 40-47
Details:
existingBelongsTofilter checks if domain entity file exists, not if frontend collection exists- For frontend, should check if
generated/collections/{target}.tsexists - Or add config option to disable FK resolution entirely:
generate.fkResolution: false
Current: url: \${API_BASE_URL}/opportunities`**Expected:**url: new URL(`${API_BASE_URL}/opportunities`, window.location.origin).toString()`
Location: templates/entity/new/frontend/entity/collection.ejs.t line 54
Details:
- The
wrapInUrlConstructorconfig only applies whenuseTableParam: true(lines 40-46) - The
useTableParam: falsebranch (line 54) doesn't wrap the URL - Should apply URL wrapping regardless of
useTableParamwhenwrapInUrlConstructor: true
Current: opportunityCollection (singular entity name)
Expected: opportunitiesCollection (plural)
Location: templates/entity/new/frontend/entity/collection.ejs.t line 35
Details:
- Generator uses
<%= camelName %>Collectionwhich is singular - Should use
<%= plural %>Collectionfor consistency with collection ID - Or add config option:
collectionNaming: 'singular' | 'plural'
Current: generated/collections/opportunity.ts
Expected: generated/collections/opportunities.ts
Location: templates/entity/new/frontend/entity/collection.ejs.t line 2
Details:
- Uses
${name}(singular) in path - Should use
${plural}for consistency - Or add config option:
fileNaming: 'singular' | 'plural'
Current: return { data: ..., isLoading }
Expected: return { opportunities: ..., isLoading } (entity-specific key)
Location: templates/entity/new/frontend/entity/hooks.ejs.t lines 15-18
Details:
- Generic
datakey works but entity-specific key (opportunities) is more ergonomic - Could be config option:
hookReturnStyle: 'generic' | 'named'
- High: Issue 2 (FK resolution) - causes TypeScript errors
- High: Issue 1 (type naming) - causes TypeScript errors
- Medium: Issue 3 (URL wrap) - functional difference
- Low: Issues 4, 5, 6 - naming conventions, non-breaking
generate:
# Type naming: 'entity' = OpportunityEntity, 'plain' = Opportunity
typeNaming: "plain"
# Skip FK resolution (useful when related collections don't exist)
fkResolution: false
# Collection variable naming: 'singular' = opportunityCollection, 'plural' = opportunitiesCollection
collectionNaming: "plural"
# File naming: 'singular' = opportunity.ts, 'plural' = opportunities.ts
fileNaming: "plural"
# Hook return key: 'generic' = { data }, 'named' = { opportunities }
hookReturnStyle: "named"