refactor: Refactor all remaining generators to use new TS system#521
Conversation
|
WalkthroughThis set of changes implements a broad migration from an older imperative, string-based TypeScript code generation system to a newer, fragment-based, declarative approach using Changes
Sequence Diagram(s)sequenceDiagram
participant Generator
participant ImportProvider
participant TemplateRenderer
participant OutputBuilder
Generator->>ImportProvider: Request import declarations (e.g., for components)
Generator->>TemplateRenderer: Render template file with variables, import maps, and metadata options
TemplateRenderer->>OutputBuilder: Write file with rendered content and metadata (if allowed)
OutputBuilder-->>Generator: File written to output directory
sequenceDiagram
participant CRUDCompiler
participant Generator
participant InputContainer
CRUDCompiler->>Generator: compileInput(definition, { order, ... })
Generator->>InputContainer: addInput({ ..., order })
InputContainer-->>Generator: Input registered with order
Generator-->>CRUDCompiler: Generated bundle with ordered inputs
sequenceDiagram
participant TemplateRenderer
participant MetadataCallback
TemplateRenderer->>MetadataCallback: shouldGenerateMetadata({ fileId, filePath, ... })
MetadataCallback-->>TemplateRenderer: true/false
TemplateRenderer->>OutputBuilder: Write file with or without metadata
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 12
🔭 Outside diff range comments (2)
plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts (1)
48-52:⚠️ Potential issueMissing import for
zin validation fragmentThe validation fragment references the global
zidentifier but does not declare an import.
If the file where the fragment lands has no existingimport { z } from 'zod', compilation will fail.Option 1 – provide the import here:
expression: tsCodeFragment( `z.object({ id: z.string(), name: z.string().nullish() })${ isOptional ? '.nullish()' : '' }`, + { ...uploadComponentsImports.zod?.declaration?.() ?? [ + { moduleSpecifier: 'zod', namedImports: ['z'] }, + ] }, ),Option 2 – document/guarantee that the host file always imports
z.packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
229-251: 🛠️ Refactor suggestionPotential infinite loop when lazy templates mutually reference each other
Thewhile (lazyTemplates.size > 0)loop only removes templates whose destination is already referenced. If two lazy templates import each other but nothing outside references either file,usedProjectRelativePathsnever receives their paths and the loop will spin forever.Mitigation ideas:
- Keep a loop counter and break after N iterations with a descriptive error.
- Detect cycles by marking visited templates and abort with guidance.
- Fall back to rendering everything once when no progress is made.
🧹 Nitpick comments (15)
plugins/baseplate-plugin-storage/src/storage/admin-crud/node.ts (1)
21-21: Added order parameter needs type annotationThe addition of the
orderparameter is consistent with changes in other admin CRUD input compilers and supports ordering of input fields. However, consider adding a type annotation for theorderparameter (likelynumber) to improve type safety and documentation.- compileInput(definition, { order, definitionContainer, model }) { + compileInput(definition, { order, definitionContainer, model }: { order: number; definitionContainer: any; model: any }) {Also applies to: 55-55
packages/react-generators/src/generators/admin/admin-home/admin-home.generator.ts (1)
32-33: Preferpath.posix.joinand omit the file-extension to avoid brittle import pathsInterpolating strings to build
pagePathhard-codes the separator and keeps the “.tsx” extension in the public import path, which TypeScript/Bundlers typically resolve without. Usingpath.posix.join:
- Guarantees forward-slash separators across OSes.
- Produces the correct import specifier (
/Home/index) that plays nicely withtsImportBuilder.+import path from 'node:path'; ... -const pagePath = `${reactRoutes.getDirectoryBase()}/Home/index.tsx`; +const pagePath = path.posix.join( + reactRoutes.getDirectoryBase(), + 'Home', + 'index', +);packages/react-generators/src/generators/admin/admin-crud-embedded-input/admin-crud-embedded-input.generator.ts (2)
69-84:TsCodeUtils.formatFragmentcan accept an array of imports – consider groupingPassing each import as a separate argument works but becomes noisy when the call grows.
formatFragmentalso accepts animportsarray, which keeps the signature stable if more imports are added later:- adminComponentsImports.EmbeddedObjectInput.declaration(), + [ + adminComponentsImports.EmbeddedObjectInput.declaration(), + ],Same observation applies to the list-input branch below.
This is purely about readability/maintenance; the current code is functionally correct.
115-117: Tiny readability nit – extract the “nullish” suffixInline template logic is fine, but extracting the suffix makes the intent explicit:
-expression: tsTemplate`${validationExpression}${isRequired ? '' : '.nullish()'}`, +expression: isRequired + ? validationExpression + : tsTemplate`${validationExpression}.nullish()`,This avoids embedding raw strings in a tagged template and keeps each branch a valid
TsCodeFragment.plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts (1)
8-14: Validate the neworderfield more strictly
orderis currently any number, which meansNaN, negative, or fractional values can sneak through and break input ordering at runtime.
Consider tightening the schema – e.g. positive integer – to fail fast during compilation.- order: z.number(), + order: z.number().int().nonnegative(),packages/react-generators/src/generators/admin/admin-components/admin-components.generator.ts (1)
92-99: Minor: unusedreactComponentstemplate paths can be delegated to the template groupSince you already hand the
reactComponentsImportsprovider torenderTemplateGroup, consider letting the template resolveEmbedded*component paths itself rather than hard-coding them here. This keeps path logic in one place and reduces drift.packages/sync/src/output/generator-task-output.ts (1)
118-138: Enhanced context for metadata generation decisionsThe new
shouldGenerateMetadatamethod now accepts a detailed context object, providing much more information for making metadata generation decisions.Consider adding JSDoc descriptions for the
hasManualIdparameter to clarify how it should influence metadata generation decisions:/** * Whether the file has a manual ID provided by the generator * * This usually means that the file may be generated by multiple instances of the generator * and we only want to generate metadata for one instance of the file. + * + * For example, if a generator creates multiple files with the same template, + * we typically only want to track the template origin in one of those files. */packages/react-generators/src/generators/admin/admin-layout/admin-layout.generator.ts (2)
38-46: Regex may mis-categorize somereact-iconspackages
The prefix extraction regex^[A-Z][a-z]*ignores digits and any subsequent capital letters. Icons such asMd3DRotationorHi2Outlinewill be resolved toreact-icons/md/react-icons/hi, which works, but other edge-cases likeSiC++(contains+) or future icon sets with numeral namespaces could break.
Consider hard-coding the known react-icons prefixes or extending the pattern to^[A-Z][A-Za-z0-9]*and validating against an allow-list to guard against invalid imports.
80-82: Usepath.posix.jointo build project-relative paths
Interpolating paths via template strings can introduce duplicate slashes and makes Windows support brittle. ConstructlayoutPathwith the already importedpath.posix.join(available elsewhere in the repo) for consistency:-const layoutPath = `${reactComponents.getComponentsFolder()}/AdminLayout/index.tsx`; +const layoutPath = path.posix.join( + reactComponents.getComponentsFolder(), + 'AdminLayout', + 'index.tsx', +);packages/react-generators/src/generators/admin/admin-crud-edit/admin-crud-edit.generator.ts (1)
79-83: Path construction is OS-dependent
As with the AdminLayout generator, concatenating with/${...}risks backslash issues on Windows. Since this generator already importspath.posix.join(line 1-7), prefer it here as well to stay consistent and platform-safe.-const editSchemaPath = `${reactRoutes.getDirectoryBase()}/edit/${lowerCaseFirst( - dasherize(underscore(modelName)), -)}-schema.ts`; +const editSchemaPath = path.posix.join( + reactRoutes.getDirectoryBase(), + 'edit', + `${lowerCaseFirst(dasherize(underscore(modelName)))}-schema.ts`, +);packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
254-263: Import-sort grouping omits ‘type-only’ group
importSortOptions.groupsmisses the"type"group that many internal generators emit whenes2022target is used withimportsNotUsedAsValues: "error". Omitting it can reorder or collapse type-only imports.-groups: [ +groups: [ 'builtin', 'external', 'internal', ['parent', 'sibling'], + 'type', 'index', ] as const,packages/react-generators/src/generators/admin/admin-bull-board/admin-bull-board.generator.ts (1)
29-31: Strengthen validation ofbullBoardUrl
bullBoardUrlis expected to be a URL. Replacingz.string().min(1)withz.string().url()gives earlier feedback to users supplying an invalid value.-const descriptorSchema = z.object({ - bullBoardUrl: z.string().min(1), -}); +const descriptorSchema = z.object({ + bullBoardUrl: z.string().url(), +});packages/react-generators/src/generators/admin/admin-crud-list/admin-crud-list.generator.ts (1)
31-35: Add minimal length check to newmodelIdfield
For consistency with other identifiers, enforcemin(1)to avoid empty strings slipping through.- modelId: z.string(), + modelId: z.string().min(1),packages/react-generators/src/generators/admin/admin-crud-embedded-form/admin-crud-embedded-form.generator.ts (2)
333-370: EmptyTPL_EXTRA_PROP_SPREADyields a dangling commaWhen
tableDataDependenciesis empty the generated parameter list becomes
{ items, edit, remove, }, which is legal but easy to mis-read and triggers several linters (comma-dangle,no-trailing-comma, etc.).Replace the join logic to conditionally prepend the comma:
- TPL_EXTRA_PROP_SPREAD + ${tableDataDependencies.length + ? `${tableDataDependencies + .map((d) => d.propName) + .join(',\n')},` + : ''}This keeps the emitted code linter-clean in both scenarios.
390-391:orderproperty may beundefined– provide a stable fallbackSorting by a possibly-undefined numeric field can yield non-deterministic order across Node versions. Consider supplying a default (
Infinity) to keep original declaration order whenorderis not set:-const sortedInputFields = sortBy(inputFields, [(f) => f.order]); +const sortedInputFields = sortBy(inputFields, [(f) => f.order ?? Infinity]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite
⛔ Files ignored due to path filters (16)
-
packages/fastify-generators/src/generators/auth/password-hasher-service/generated/ts-import-maps.tsis excluded by!**/generated/** -
packages/fastify-generators/src/generators/auth/password-hasher-service/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-bull-board/generated/text-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-bull-board/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-components/generated/ts-import-maps.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-components/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-crud-edit/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-crud-embedded-form/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-crud-list/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-home/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/admin/admin-layout/generated/ts-templates.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/core/react-components/generated/ts-import-maps.tsis excluded by!**/generated/** -
packages/react-generators/src/generators/core/react-components/generated/ts-templates.tsis excluded by!**/generated/** -
plugins/baseplate-plugin-storage/src/generators/react/upload-components/generated/text-templates.tsis excluded by!**/generated/** -
plugins/baseplate-plugin-storage/src/generators/react/upload-components/generated/ts-import-maps.tsis excluded by!**/generated/** -
plugins/baseplate-plugin-storage/src/generators/react/upload-components/generated/ts-templates.tsis excluded by!**/generated/**
📒 Files selected for processing (83)
-
.cursor/rules/ts-code-migration.mdc(0 hunks) -
packages/core-generators/src/generators/node/ts-utils/ts-utils.generator.ts(3 hunks) -
packages/core-generators/src/generators/node/typescript/typescript.generator.ts(5 hunks) -
packages/core-generators/src/generators/node/typescript/typescript.generator.unit.test.ts(1 hunks) -
packages/core-generators/src/renderers/typescript/actions/render-ts-template-file-action.ts(3 hunks) -
packages/core-generators/src/renderers/typescript/actions/render-ts-template-file-action.unit.test.ts(1 hunks) -
packages/core-generators/src/renderers/typescript/extractor/ts-template-file-extractor.unit.test.ts(1 hunks) -
packages/core-generators/src/renderers/typescript/extractor/write-ts-project-exports.ts(1 hunks) -
packages/core-generators/src/renderers/typescript/extractor/write-ts-project-exports.unit.test.ts(1 hunks) -
packages/core-generators/src/renderers/typescript/imports/ts-path-maps.ts(2 hunks) -
packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts(3 hunks) -
packages/fastify-generators/src/generators/auth/password-hasher-service/password-hasher-service.generator.ts(3 hunks) -
packages/fastify-generators/src/generators/auth/password-hasher-service/templates/password-hasher.service.ts(1 hunks) -
packages/fastify-generators/src/generators/auth/prisma-password-transformer/prisma-password-transformer.generator.ts(3 hunks) -
packages/fastify-generators/src/generators/core/app-module/app-module.generator.ts(0 hunks) -
packages/fastify-generators/src/generators/core/fastify-scripts/fastify-scripts.generator.ts(0 hunks) -
packages/fastify-generators/src/generators/core/service-file/service-file.generator.ts(2 hunks) -
packages/fastify-generators/src/generators/prisma/prisma-utils/prisma-utils.generator.ts(2 hunks) -
packages/project-builder-lib/src/compiler/admin-crud-input-spec.ts(1 hunks) -
packages/project-builder-lib/src/schema/template-extractor/index.ts(1 hunks) -
packages/project-builder-server/src/compiler/admin/crud/index.ts(5 hunks) -
packages/project-builder-server/src/compiler/admin/crud/inputs.ts(12 hunks) -
packages/project-builder-server/src/sync/build-project.ts(1 hunks) -
packages/project-builder-server/src/sync/generate-for-directory.test.ts(1 hunks) -
packages/project-builder-server/src/sync/generate-for-directory.ts(5 hunks) -
packages/project-builder-web/src/pages/settings/template-extractor.tsx(2 hunks) -
packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts(2 hunks) -
packages/react-generators/src/generators/admin/_providers/admin-loader.ts(2 hunks) -
packages/react-generators/src/generators/admin/_utils/data-display.ts(1 hunks) -
packages/react-generators/src/generators/admin/_utils/data-loaders.ts(2 hunks) -
packages/react-generators/src/generators/admin/_utils/foreign-data-dependency.ts(3 hunks) -
packages/react-generators/src/generators/admin/admin-bull-board/admin-bull-board.generator.ts(2 hunks) -
packages/react-generators/src/generators/admin/admin-bull-board/templates/bull-board.page.tsx(1 hunks) -
packages/react-generators/src/generators/admin/admin-components/admin-components.generator.ts(4 hunks) -
packages/react-generators/src/generators/admin/admin-components/templates/DescriptionList/index.tsx(1 hunks) -
packages/react-generators/src/generators/admin/admin-components/templates/EmbeddedListInput/index.tsx(1 hunks) -
packages/react-generators/src/generators/admin/admin-components/templates/EmbeddedObjectInput/index.tsx(1 hunks) -
packages/react-generators/src/generators/admin/admin-components/ts-extractor.json(1 hunks) -
packages/react-generators/src/generators/admin/admin-crud-edit/admin-crud-edit.generator.ts(7 hunks) -
packages/react-generators/src/generators/admin/admin-crud-edit/templates/EditForm.tsx(3 hunks) -
packages/react-generators/src/generators/admin/admin-crud-edit/templates/create.page.tsx(1 hunks) -
packages/react-generators/src/generators/admin/admin-crud-edit/templates/edit.page.tsx(2 hunks) -
packages/react-generators/src/generators/admin/admin-crud-edit/templates/schema.ts(1 hunks) -
packages/react-generators/src/generators/admin/admin-crud-embedded-form/admin-crud-embedded-form.generator.ts(12 hunks) -
packages/react-generators/src/generators/admin/admin-crud-embedded-form/templates/EmbeddedForm.tsx(2 hunks) -
packages/react-generators/src/generators/admin/admin-crud-embedded-input/admin-crud-embedded-input.generator.ts(6 hunks) -
packages/react-generators/src/generators/admin/admin-crud-enum-input/admin-crud-enum-input.generator.ts(4 hunks) -
packages/react-generators/src/generators/admin/admin-crud-foreign-display/admin-crud-foreign-display.generator.ts(2 hunks) -
packages/react-generators/src/generators/admin/admin-crud-foreign-input/admin-crud-foreign-input.generator.ts(4 hunks) -
packages/react-generators/src/generators/admin/admin-crud-list/admin-crud-list.generator.ts(5 hunks) -
packages/react-generators/src/generators/admin/admin-crud-list/templates/Table.tsx(3 hunks) -
packages/react-generators/src/generators/admin/admin-crud-list/templates/index.page.tsx(1 hunks) -
packages/react-generators/src/generators/admin/admin-crud-password-input/admin-crud-password-input.generator.ts(1 hunks) -
packages/react-generators/src/generators/admin/admin-crud-queries/admin-crud-queries.generator.ts(6 hunks) -
packages/react-generators/src/generators/admin/admin-crud-section/admin-crud-section.generator.ts(1 hunks) -
packages/react-generators/src/generators/admin/admin-crud-text-display/admin-crud-text-display.generator.ts(2 hunks) -
packages/react-generators/src/generators/admin/admin-crud-text-input/admin-crud-text-input.generator.ts(2 hunks) -
packages/react-generators/src/generators/admin/admin-home/admin-home.generator.ts(2 hunks) -
packages/react-generators/src/generators/admin/admin-home/templates/Home.page.tsx(1 hunks) -
packages/react-generators/src/generators/admin/admin-layout/admin-layout.generator.ts(2 hunks) -
packages/react-generators/src/generators/admin/admin-layout/templates/AdminLayout.tsx(2 hunks) -
packages/react-generators/src/generators/core/react-components/react-components.generator.ts(2 hunks) -
packages/react-generators/src/generators/core/react-components/ts-extractor.json(1 hunks) -
packages/react-generators/src/generators/core/react-routes/react-routes.generator.ts(0 hunks) -
packages/react-generators/src/generators/core/react-utils/react-utils.generator.ts(2 hunks) -
packages/sync/src/output/generator-task-output.ts(3 hunks) -
packages/sync/src/templates/extractor/index.ts(0 hunks) -
packages/sync/src/templates/extractor/read-template-metadata-paths.ts(0 hunks) -
packages/sync/src/templates/extractor/read-template-metadata-paths.unit.test.ts(0 hunks) -
packages/sync/src/templates/raw-template/render-raw-template-action.ts(2 hunks) -
packages/sync/src/templates/raw-template/render-raw-template-action.unit.test.ts(1 hunks) -
packages/sync/src/templates/text-template/render-text-template-file-action.ts(8 hunks) -
packages/sync/src/templates/text-template/render-text-template-file-action.unit.test.ts(2 hunks) -
packages/sync/src/templates/text-template/text-template-file-extractor.ts(3 hunks) -
packages/sync/src/templates/text-template/types.ts(2 hunks) -
packages/sync/src/templates/text-template/utils.ts(2 hunks) -
plugins/baseplate-plugin-storage/src/generators/fastify/storage-module/storage-module.generator.ts(1 hunks) -
plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts(3 hunks) -
plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/components/FileInput/index.tsx(2 hunks) -
plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/components/FileInput/upload.gql(1 hunks) -
plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/hooks/useUpload.ts(1 hunks) -
plugins/baseplate-plugin-storage/src/generators/react/upload-components/upload-components.generator.ts(3 hunks) -
plugins/baseplate-plugin-storage/src/storage/admin-crud/node.ts(2 hunks)
💤 Files with no reviewable changes (7)
- packages/fastify-generators/src/generators/core/app-module/app-module.generator.ts
- packages/sync/src/templates/extractor/index.ts
- packages/fastify-generators/src/generators/core/fastify-scripts/fastify-scripts.generator.ts
- packages/react-generators/src/generators/core/react-routes/react-routes.generator.ts
- packages/sync/src/templates/extractor/read-template-metadata-paths.unit.test.ts
- packages/sync/src/templates/extractor/read-template-metadata-paths.ts
- .cursor/rules/ts-code-migration.mdc
🧰 Additional context used
🧬 Code Graph Analysis (29)
packages/react-generators/src/generators/admin/admin-crud-text-display/admin-crud-text-display.generator.ts (1)
packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)
packages/react-generators/src/generators/admin/_utils/data-loaders.ts (1)
packages/core-generators/src/renderers/typescript/fragments/types.ts (1)
TsCodeFragment(45-62)
packages/react-generators/src/generators/admin/_utils/foreign-data-dependency.ts (2)
packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)packages/core-generators/src/renderers/typescript/imports/builder.ts (1)
tsImportBuilder(69-77)
packages/sync/src/templates/text-template/utils.ts (1)
packages/sync/src/templates/text-template/types.ts (1)
TextTemplateFileVariable(42-52)
packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts (3)
packages/core-generators/src/renderers/typescript/fragments/types.ts (1)
TsCodeFragment(45-62)packages/react-generators/src/writers/graphql/index.ts (1)
GraphQLField(34-34)packages/react-generators/src/generators/admin/_utils/data-loaders.ts (1)
AdminCrudDataDependency(12-19)
packages/react-generators/src/generators/admin/_utils/data-display.ts (3)
packages/core-generators/src/renderers/typescript/fragments/types.ts (1)
TsCodeFragment(45-62)packages/react-generators/src/writers/graphql/index.ts (1)
GraphQLField(34-34)packages/react-generators/src/generators/admin/_utils/data-loaders.ts (1)
AdminCrudDataDependency(12-19)
packages/react-generators/src/generators/admin/admin-crud-edit/templates/edit.page.tsx (1)
packages/react-generators/src/generators/admin/admin-crud-edit/templates/schema.ts (1)
TPL_FORM_DATA_NAME(7-7)
plugins/baseplate-plugin-storage/src/generators/fastify/storage-module/storage-module.generator.ts (1)
packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)
packages/fastify-generators/src/generators/auth/prisma-password-transformer/prisma-password-transformer.generator.ts (3)
packages/fastify-generators/src/generators/auth/password-hasher-service/generated/ts-import-maps.ts (1)
passwordHasherServiceImportsProvider(19-22)packages/fastify-generators/src/generators/auth/password-hasher-service/password-hasher-service.generator.ts (1)
passwordHasherServiceImportsProvider(68-68)packages/fastify-generators/src/generators/prisma/prisma-crud-service/prisma-crud-service.generator.ts (1)
prismaCrudServiceSetupProvider(22-25)
packages/react-generators/src/generators/admin/admin-crud-edit/templates/create.page.tsx (1)
packages/react-generators/src/generators/admin/admin-crud-edit/templates/schema.ts (1)
TPL_FORM_DATA_NAME(7-7)
packages/react-generators/src/generators/admin/admin-crud-foreign-display/admin-crud-foreign-display.generator.ts (1)
packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)
packages/core-generators/src/generators/node/ts-utils/ts-utils.generator.ts (1)
packages/core-generators/src/generators/node/ts-utils/generated/ts-templates.ts (1)
NODE_TS_UTILS_TS_TEMPLATES(31-36)
packages/react-generators/src/generators/admin/admin-crud-edit/templates/EditForm.tsx (3)
packages/react-generators/src/generators/admin/admin-crud-edit/templates/schema.ts (1)
TPL_FORM_DATA_NAME(7-7)packages/react-generators/src/generators/admin/admin-crud-embedded-form/templates/EmbeddedForm.tsx (1)
TPL_COMPONENT_NAME(10-36)packages/react-generators/src/generators/core/react-components/templates/hooks/useStatus.ts (1)
useStatus(23-36)
packages/react-generators/src/generators/admin/admin-home/admin-home.generator.ts (6)
packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
reactComponentsImportsProvider(231-231)packages/react-generators/src/generators/auth/_providers/auth-hooks.ts (1)
authHooksImportsProvider(25-26)packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
typescriptFileProvider(132-133)packages/react-generators/src/providers/routes.ts (1)
reactRoutesProvider(26-27)packages/react-generators/src/utils/routes.ts (1)
createRouteElement(5-13)packages/react-generators/src/generators/admin/admin-home/generated/ts-templates.ts (1)
ADMIN_ADMIN_HOME_TS_TEMPLATES(17-17)
packages/react-generators/src/generators/admin/admin-components/admin-components.generator.ts (5)
packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
reactComponentsImportsProvider(231-231)packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
typescriptFileProvider(132-133)packages/core-generators/src/providers/scopes.ts (1)
projectScope(3-6)packages/react-generators/src/generators/admin/admin-components/generated/ts-import-maps.ts (2)
adminComponentsImportsProvider(23-26)createAdminComponentsImports(28-46)packages/react-generators/src/generators/admin/admin-components/generated/ts-templates.ts (1)
ADMIN_ADMIN_COMPONENTS_TS_TEMPLATES(62-62)
packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts (4)
packages/core-generators/src/renderers/typescript/imports/types.ts (1)
TsImportDeclaration(22-43)packages/core-generators/src/renderers/typescript/imports/builder.ts (1)
tsImportBuilder(69-77)packages/core-generators/src/renderers/typescript/fragments/types.ts (1)
TsCodeFragment(45-62)packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)
packages/react-generators/src/generators/admin/admin-crud-password-input/admin-crud-password-input.generator.ts (6)
packages/sync/src/utils/create-generator.ts (1)
createGenerator(96-123)packages/sync/src/generators/generators.ts (1)
createGeneratorTask(196-204)packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts (1)
adminCrudInputContainerProvider(29-30)packages/react-generators/src/generators/core/react-components/generated/ts-import-maps.ts (1)
reactComponentsImportsProvider(49-52)packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
reactComponentsImportsProvider(231-231)packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)
packages/project-builder-server/src/sync/generate-for-directory.ts (1)
packages/sync/src/output/generator-task-output.ts (1)
TemplateMetadataOptions(110-139)
packages/fastify-generators/src/generators/auth/password-hasher-service/password-hasher-service.generator.ts (4)
packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
typescriptFileProvider(132-133)packages/fastify-generators/src/generators/auth/password-hasher-service/generated/ts-import-maps.ts (2)
passwordHasherServiceImportsProvider(19-22)createPasswordHasherServiceImports(24-35)packages/core-generators/src/providers/scopes.ts (1)
projectScope(3-6)packages/fastify-generators/src/generators/auth/password-hasher-service/generated/ts-templates.ts (1)
AUTH_PASSWORD_HASHER_SERVICE_TS_TEMPLATES(10-12)
packages/react-generators/src/generators/admin/admin-crud-embedded-form/templates/EmbeddedForm.tsx (1)
packages/react-generators/src/generators/core/react-components/templates/hooks/useStatus.ts (1)
useStatus(23-36)
packages/project-builder-server/src/sync/build-project.ts (1)
packages/project-builder-server/src/sync/generate-for-directory.ts (1)
generateForDirectory(121-256)
packages/react-generators/src/generators/admin/_providers/admin-loader.ts (5)
packages/core-generators/src/renderers/typescript/fragments/types.ts (1)
TsCodeFragment(45-62)packages/react-generators/src/generators/core/react-components/generated/ts-import-maps.ts (1)
ReactComponentsImportsProvider(45-47)packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
ReactComponentsImportsProvider(232-232)packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts (1)
TsCodeUtils(85-539)
packages/react-generators/src/generators/admin/admin-crud-enum-input/admin-crud-enum-input.generator.ts (5)
packages/sync/src/generators/generators.ts (1)
createGeneratorTask(196-204)packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts (1)
adminCrudInputContainerProvider(29-30)packages/react-generators/src/generators/core/react-components/generated/ts-import-maps.ts (1)
reactComponentsImportsProvider(49-52)packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
reactComponentsImportsProvider(231-231)packages/core-generators/src/renderers/typescript/fragments/creators.ts (2)
tsCodeFragment(39-49)tsHoistedFragment(15-26)
packages/react-generators/src/generators/admin/admin-crud-embedded-input/admin-crud-embedded-input.generator.ts (6)
packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts (1)
adminCrudInputContainerProvider(29-30)packages/react-generators/src/generators/admin/admin-components/generated/ts-import-maps.ts (1)
adminComponentsImportsProvider(23-26)packages/react-generators/src/generators/admin/admin-components/admin-components.generator.ts (1)
adminComponentsImportsProvider(108-108)packages/react-generators/src/generators/admin/admin-crud-embedded-form/admin-crud-embedded-form.generator.ts (1)
adminCrudEmbeddedFormProvider(81-85)packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts (2)
TsCodeUtils(85-539)tsTemplate(542-542)packages/react-generators/src/writers/graphql/index.ts (1)
mergeGraphQLFields(225-247)
packages/react-generators/src/generators/admin/admin-bull-board/admin-bull-board.generator.ts (8)
packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
typescriptFileProvider(132-133)packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
reactComponentsImportsProvider(231-231)packages/react-generators/src/generators/core/react-config/react-config.generator.ts (1)
reactConfigImportsProvider(161-161)packages/react-generators/src/generators/core/react-error/react-error.generator.ts (1)
reactErrorImportsProvider(126-126)packages/react-generators/src/generators/apollo/react-apollo/react-apollo.generator.ts (2)
reactApolloProvider(172-173)generatedGraphqlImportsProvider(678-678)packages/react-generators/src/generators/admin/admin-bull-board/generated/ts-templates.ts (1)
ADMIN_ADMIN_BULL_BOARD_TS_TEMPLATES(21-21)packages/sync/src/templates/text-template/render-text-template-file-action.ts (1)
renderTextTemplateFileAction(34-175)packages/react-generators/src/generators/admin/admin-bull-board/generated/text-templates.ts (1)
ADMIN_ADMIN_BULL_BOARD_TEXT_TEMPLATES(9-11)
plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts (4)
packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts (1)
adminCrudInputContainerProvider(29-30)plugins/baseplate-plugin-storage/src/generators/react/upload-components/generated/ts-import-maps.ts (1)
uploadComponentsImportsProvider(19-22)plugins/baseplate-plugin-storage/src/generators/react/upload-components/upload-components.generator.ts (1)
uploadComponentsImportsProvider(120-120)packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)
packages/project-builder-server/src/compiler/admin/crud/index.ts (1)
packages/project-builder-server/src/compiler/admin/crud/inputs.ts (1)
compileAdminCrudInput(223-242)
packages/react-generators/src/generators/admin/admin-crud-list/admin-crud-list.generator.ts (10)
packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
typescriptFileProvider(132-133)packages/react-generators/src/providers/routes.ts (1)
reactRoutesProvider(26-27)packages/react-generators/src/generators/admin/admin-crud-queries/admin-crud-queries.generator.ts (1)
adminCrudQueriesProvider(64-65)packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
reactComponentsImportsProvider(231-231)packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts (2)
tsTemplate(542-542)TsCodeUtils(85-539)packages/react-generators/src/generators/admin/_providers/admin-loader.ts (1)
printDataLoaders(13-52)packages/react-generators/src/generators/admin/admin-crud-list/generated/ts-templates.ts (1)
ADMIN_ADMIN_CRUD_LIST_TS_TEMPLATES(47-47)packages/project-builder-server/src/utils/case.ts (1)
titleizeCamel(21-23)packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
tsCodeFragment(39-49)packages/react-generators/src/utils/routes.ts (1)
createRouteElement(5-13)
packages/react-generators/src/generators/admin/admin-crud-embedded-form/admin-crud-embedded-form.generator.ts (8)
packages/core-generators/src/renderers/typescript/fragments/types.ts (1)
TsCodeFragment(45-62)packages/react-generators/src/generators/admin/_utils/data-loaders.ts (1)
AdminCrudDataDependency(12-19)packages/react-generators/src/generators/admin/admin-components/admin-components.generator.ts (2)
AdminComponentsImportsProvider(107-107)adminComponentsImportsProvider(108-108)packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts (2)
tsTemplate(542-542)TsCodeUtils(85-539)packages/core-generators/src/renderers/typescript/fragments/creators.ts (2)
tsCodeFragment(39-49)tsHoistedFragment(15-26)packages/react-generators/src/generators/core/react-components/react-components.generator.ts (1)
reactComponentsImportsProvider(231-231)packages/core-generators/src/generators/node/typescript/typescript.generator.ts (1)
typescriptFileProvider(132-133)packages/react-generators/src/generators/admin/admin-crud-embedded-form/generated/ts-templates.ts (1)
ADMIN_ADMIN_CRUD_EMBEDDED_FORM_TS_TEMPLATES(26-26)
🔇 Additional comments (148)
plugins/baseplate-plugin-storage/src/generators/fastify/storage-module/storage-module.generator.ts (2)
139-139: Correct environment variable name used for AWS access key configuration.The
seedValuenow properly matches the standard AWS environment variable name, ensuring consistency with AWS SDK conventions.
144-144: Correct environment variable name used for AWS secret key configuration.The
seedValuenow properly matches the standard AWS environment variable name, ensuring consistency with AWS SDK conventions.packages/core-generators/src/generators/node/ts-utils/ts-utils.generator.ts (2)
44-46: Simplified build process with direct template iteration.The build function has been simplified to directly iterate over all template keys without conditional logic, which aligns with the more declarative approach being adopted across the codebase.
61-61: Added type export for improved type safety.Exporting the type definition for
TsUtilsImportsProviderallows consumers to properly type-check their usage of the provider, improving type safety across the codebase.packages/fastify-generators/src/generators/prisma/prisma-utils/prisma-utils.generator.ts (1)
70-70: Added type export for improved type safety.Exporting the type definition for
PrismaUtilsImportsProviderallows consumers to properly type-check their usage of the provider, improving type safety across the codebase.packages/fastify-generators/src/generators/auth/password-hasher-service/templates/password-hasher.service.ts (1)
3-3: Reordered imports for consistency.The import statement has been reordered to list the imported entities in alphabetical order (
Algorithm, hash, Options, verify), which improves consistency across the codebase without changing functionality.packages/core-generators/src/renderers/typescript/actions/render-ts-template-file-action.unit.test.ts (1)
52-52: Updated metadata generation control to use callback pattern.The addition of
shouldGenerateMetadatacallback aligns with the new template metadata generation control pattern being implemented across the codebase. This ensures the test properly exercises the updated metadata generation logic that uses a context-aware callback instead of a simple boolean flag.packages/core-generators/src/renderers/typescript/extractor/write-ts-project-exports.unit.test.ts (1)
90-90: Updated property name to match implementation changes.The test expectation has been updated to check for
"name":"default"instead of"exportName":"default"in the import map schema for default exports. This change correctly aligns with corresponding implementation changes in the codebase.packages/react-generators/src/generators/admin/admin-crud-text-display/admin-crud-text-display.generator.ts (2)
1-1: Updated import to use fragment-based TypeScript code generation.Changed from importing
TypescriptCodeUtilsto importing the more specifictsCodeFragmentutility, aligning with the broader migration to fragment-based, declarative TypeScript code generation.
23-23: Refactored to use fragment-based TypeScript code generation.Replaced
TypescriptCodeUtils.createExpressionwithtsCodeFragmentto generate display content. This change is part of the broader migration to a newer, more consistent TypeScript code generation system usingTsCodeFragmentutilities.packages/sync/src/templates/raw-template/render-raw-template-action.unit.test.ts (1)
40-40: Updated metadata generation control to use callback pattern.The addition of
shouldGenerateMetadatacallback aligns with the new template metadata generation control pattern being implemented across the codebase, replacing the simple boolean flag approach with a more flexible context-aware callback mechanism.packages/react-generators/src/generators/core/react-components/ts-extractor.json (1)
1-7: Configuration added to support new import map providersThis configuration file establishes export provider settings for the react-components generator. Setting
exportProviderType: trueindicates that this module should expose its provider type, which aligns with the broader refactoring to transition from older provider abstractions to the new import map provider system.packages/core-generators/src/renderers/typescript/extractor/write-ts-project-exports.ts (1)
207-207: Property key renamed to align with schema standardsThe property key has been renamed from
exportNametonamein the import map schema. This change aligns with the updated schema expectations in corresponding test files and provides more intuitive naming for default exports.packages/react-generators/src/generators/admin/admin-components/templates/EmbeddedObjectInput/index.tsx (2)
3-3: Consolidated UI component importsUI component imports have been consolidated to use the centralized
%reactComponentsImportsprovider instead of individual imports. This aligns with the broader refactoring effort to standardize import handling across React generators.
8-8: Reordered import for better groupingThe
DefaultValuesimport has been reordered to group it with other imports from the react-hook-form package, improving code organization and readability.packages/react-generators/src/generators/admin/admin-home/templates/Home.page.tsx (1)
3-4: Updated imports to use centralized import providersImports for
useCurrentUserandErrorableLoadernow use module aliases (%authHooksImportsand%reactComponentsImports) instead of direct imports. This supports the transition to a more maintainable and consistent import system using fragment-based TypeScript code generation.packages/react-generators/src/generators/admin/admin-components/ts-extractor.json (1)
1-7: Configuration looks good!This JSON file properly configures the TypeScript extractor for admin components, setting
exportProviderTypetotruefor the default export group. This aligns with the broader refactoring approach to use fragment-based TypeScript code generation.packages/react-generators/src/generators/admin/admin-components/templates/EmbeddedListInput/index.tsx (2)
3-9: Import consolidation looks good!Centralizing UI component imports through the new import map provider (
%reactComponentsImports) improves maintainability and aligns with the pattern established across other templates in this PR.
14-20: Nice organization of react-hook-form imports!Moving
DefaultValuesup to be grouped with other imports from the same package improves code organization and readability.plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/hooks/useUpload.ts (1)
81-87: Good fix to prevent duplicate Content-Type headers!This change correctly checks if 'Content-Type' is already present in the upload parameters before appending it to the FormData. This prevents potential issues with duplicate headers that could cause problems during file uploads.
packages/core-generators/src/renderers/typescript/extractor/ts-template-file-extractor.unit.test.ts (1)
233-233: Property name update aligns with schema changes.Changing
exportNametonamefor default exports aligns the test with the corresponding changes in the implementation, ensuring consistency in the import map schema structure.packages/react-generators/src/generators/admin/admin-crud-foreign-display/admin-crud-foreign-display.generator.ts (1)
1-1: Clean migration to new TS fragment systemThe change from
TypescriptCodeUtils.createExpressiontotsCodeFragmentsuccessfully implements the new fragment-based TypeScript code generation system. This approach provides better support for imports and hoisted fragments while maintaining the same functionality.Also applies to: 65-65
packages/core-generators/src/renderers/typescript/imports/ts-path-maps.ts (1)
1-1: Good use of external utility for regex escapingReplacing the locally defined
escapeRegexfunction with the importedescapeRegExpfromes-toolkitimproves maintainability and consistency. This change aligns with best practices by reducing duplicate code and leveraging established libraries for common utilities.Also applies to: 41-41, 43-43
packages/react-generators/src/generators/admin/_utils/data-loaders.ts (1)
1-1: Updated type definition aligns with new TS fragment systemChanging the import and type from
TypescriptCodeExpressiontoTsCodeFragmentis consistent with the broader migration to the new TypeScript code fragment system. TheTsCodeFragmentinterface provides more structured support for code contents, imports, and hoisted fragments, which enables more declarative code generation.Also applies to: 14-14
plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/components/FileInput/upload.gql (1)
1-1: Fragment type updated to use template placeholderThe fragment type has been changed from
FILE_SCHEMAtoTPL_FILE_TYPE, correctly implementing the new templating convention where type names are replaced at generation time.packages/react-generators/src/generators/admin/admin-bull-board/templates/bull-board.page.tsx (1)
3-6: Imports refactored to use centralized import providersImport statements have been updated to use the new import map provider pattern with
%prefixed aliases, aligning with the broader refactoring to use a centralized import system.packages/react-generators/src/generators/admin/admin-components/templates/DescriptionList/index.tsx (1)
33-33: Improved className formattingMinor formatting improvement to the className string, making the code cleaner and more consistent.
packages/core-generators/src/generators/node/typescript/typescript.generator.unit.test.ts (1)
83-86: Enhanced template metadata configuration in testsAdded structured
templateMetadataOptionswith a context-aware callback for metadata generation, implementing the new standardized approach to template metadata handling.packages/react-generators/src/generators/admin/admin-layout/templates/AdminLayout.tsx (3)
3-4: Import paths updated to use module aliases.The changes to use
%authHooksImportsand%reactComponentsImportsalign with the broader refactoring to use import map providers instead of direct imports, making the code more maintainable and consistent across the project.
7-7: Import order rearranged.The
react-router-domimport has been moved lower in the import list, which helps maintain a consistent import ordering pattern (aliased imports first, then regular imports).
23-23: Placeholder component updated to use new template syntax.Replacing
<SIDEBAR_NAV />with<TPL_SIDEBAR_LINKS />follows the new convention for template placeholders, using theTPL_prefix for better identification and consistency in generated code.packages/sync/src/templates/text-template/types.ts (2)
23-29: AddedisIdentifiersupport to text template variables.The new property will improve template variable handling by distinguishing identifiers from other variable types, ensuring proper boundary checking and preventing partial word replacements.
47-51: Added interface documentation forisIdentifierproperty.The documentation clearly explains the purpose of the new property, matching the schema implementation and providing guidance for developers using this interface.
packages/sync/src/templates/text-template/render-text-template-file-action.unit.test.ts (3)
47-50: Updated test configuration to use the new metadata callback.The test now uses the
shouldGenerateMetadatacallback function instead of a simple boolean flag, aligning with the architectural changes in the metadata generation system.
187-190: Consistently implemented metadata options in error test case.This test case now correctly includes the same metadata options structure, ensuring consistent behavior across all test scenarios and preventing potential false negatives.
193-193: Updated error message to match new validation logic.The error message has been updated to reflect the refined validation logic that now checks for variable values in the template content.
packages/project-builder-lib/src/schema/template-extractor/index.ts (1)
10-17: Added file ID whitelist configuration for template extraction.This new
fileIdRegexWhitelistproperty enhances template extraction by allowing fine-grained control over which file IDs should be included in the metadata. The documentation clearly explains its purpose and format.This addition enables more selective metadata generation for files with manually assigned IDs, which is particularly useful for generators producing multiple instances of templates.
plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/components/FileInput/index.tsx (2)
3-5: Import centralization looks goodThe imports have been successfully refactored to use the new import map providers (
%generatedGraphqlImports,%reactComponentsImports, and%reactErrorImports), which aligns with the PR objective of migrating to a fragment-based, declarative TS system.
21-21: Path update is correctThe import path for
useUploadhas been correctly updated to use a relative path, maintaining the component's functionality while aligning with the new import system.packages/react-generators/src/generators/core/react-components/react-components.generator.ts (2)
158-158: Path alignment improvementThe change to use
@/src/componentsinstead ofsrc/componentsaligns thegetComponentsFoldermethod with the import path used ingetComponentsImportand the import map, ensuring consistency across the codebase.
230-233: Enhanced type exportsThe expanded export statement properly includes both the provider and its type definition, which improves type safety and integration with other generators and providers that consume these imports.
packages/sync/src/templates/raw-template/render-raw-template-action.ts (2)
30-37: Improved metadata generation controlThe addition of a context-aware conditional check for metadata generation is a significant improvement. This approach provides fine-grained control over when template metadata should be included in generated files.
57-57: Conditional metadata applicationThe conditional passing of
templateMetadatato thewriteFilemethod properly implements the metadata generation control logic, ensuring metadata is only included when appropriate.packages/react-generators/src/generators/admin/_utils/data-display.ts (2)
1-1: Type import consolidationThe import statements have been consolidated to use the unified
TsCodeFragmenttype, which aligns with the broader migration to standardize TypeScript code fragment handling.
8-8: Interface type standardizationThe
AdminCrudDisplayinterface has been updated to useTsCodeFragmentfor bothcontentandheaderproperties, replacing the olderTypescriptCodeExpressionandTypescriptCodeBlocktypes. This standardization improves consistency and integrates with the new TypeScript fragment system.Also applies to: 11-11
packages/project-builder-server/src/sync/generate-for-directory.test.ts (1)
112-115: Good refactoring of template metadata handling.The change from the simple boolean flag
shouldWriteTemplateMetadata: trueto a structured object withincludeTemplateMetadataandshouldGenerateMetadatacallback aligns with the new metadata generation framework. This provides more granular control while maintaining the same behavior in the test case.packages/project-builder-web/src/pages/settings/template-extractor.tsx (2)
10-15: Well-structured imports update.The import statement has been properly updated to include the new
TextareaFieldcomponent needed for the form enhancement.
79-84: Good addition of the file ID regex whitelist input.This new form field enables users to specify which file IDs should include template metadata, particularly useful for generators with manually assigned file IDs. The implementation follows the existing form pattern and includes a helpful descriptive text explaining the field's purpose and format.
packages/fastify-generators/src/generators/core/service-file/service-file.generator.ts (2)
120-121: Good separation of template type and instance identification.Changing to a fixed template name improves consistency and aligns with the new fragment-based template approach.
130-133: Well-implemented template instance identification.Adding a separate
idproperty with the former dynamic naming logic preserves the unique identification of each template instance while standardizing the template type naming.packages/react-generators/src/generators/admin/_utils/foreign-data-dependency.ts (3)
1-1: Good migration to granular import approach.Replacing the general
TypescriptCodeUtilsimport with specific utilities for fragments and imports improves code clarity and follows the new TypeScript generation system.
42-47: Well-implemented fragment-based code generation.Converting to use
tsCodeFragmentwithtsImportBuilderimproves code readability and maintainability while preserving the same functionality. The declarative approach makes the code intention clearer.
77-82: Consistent implementation of the new fragment pattern.The loader code fragment is properly updated to use the new system, maintaining consistency throughout the codebase.
packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts (3)
1-1: Good update to use unifiedTsCodeFragmenttypeThis change is part of the broader refactoring to use the new TypeScript fragment-based system, replacing separate imports for code blocks and expressions with a unified
TsCodeFragmenttype.
9-12: Updated interface to useTsCodeFragmentGood adjustment to the
AdminCrudInputValidationinterface to utilize the newTsCodeFragmenttype for theexpressionproperty, which will provide better composition and import handling than the previous type.
14-21: Addedorderproperty and updated to useTsCodeFragmentThe addition of the
orderproperty to theAdminCrudInputinterface is a good enhancement that will allow for controlled ordering of input fields. The update to useTsCodeFragmentfor bothcontentandheaderproperties aligns with the fragment-based approach.packages/fastify-generators/src/generators/auth/prisma-password-transformer/prisma-password-transformer.generator.ts (3)
1-1: Simplified imports with the new systemGood refactoring to remove the
tsImportBuilderand use onlytsCodeFragment, along with switching to the dedicated import provider. This aligns with the fragment-based approach and reduces manual import handling.Also applies to: 7-7
19-24: Updated dependency injection to use import providerThe change from
passwordHasherServiceProvidertopasswordHasherServiceImportsProviderin the dependencies and the corresponding update to the function parameter improves the code by using the dedicated imports provider.
41-44: Improved import declaration for transformerUsing the import provider's declaration method (
passwordHasherServiceImports.createPasswordHash.declaration()) instead of manually constructing imports is cleaner and less error-prone.packages/sync/src/templates/text-template/utils.ts (2)
1-4: Added necessary imports for new functionGood addition of imports for
escapeRegExpandTextTemplateFileVariableto support the new regex generation function.
35-47: Added useful regex generation function for template variablesThis new function
getTextTemplateVariableRegExpenhances template variable handling by creating appropriate regular expressions based on whether the variable is an identifier or not. The use of word boundary assertions for identifiers is a smart approach to prevent partial matches.The function handles two cases well:
- For identifiers, it uses negative lookbehind and lookahead assertions to ensure whole word matches
- For non-identifiers, it simply escapes the value for regex usage
packages/react-generators/src/generators/admin/admin-crud-edit/templates/edit.page.tsx (5)
3-3: Improved import handling with import map providerGood update to use the import alias
%reactComponentsImportswhich simplifies import management through the import map provider system rather than separate imports.
6-12: Standardized template placeholder namingThe consistent use of the
TPL_prefix for component names, data loaders, and mutations improves the clarity and maintainability of the template.
17-23: Updated mutation handling with consistent namingThe form submission logic is properly updated to use the standardized
TPL_prefixed placeholders, maintaining the functionality while aligning with the new naming convention.
25-33: Improved template text with dynamic model nameUsing
<TPL_MODEL_NAME />instead of a hardcoded reference improves the template by allowing for dynamic model name rendering, and the update to useTPL_EDIT_FORMmaintains consistency with other template changes.
36-36: Updated default export with consistent namingGood update to the default export to use the
TPL_COMPONENT_NAMEplaceholder, maintaining consistency with the component declaration.packages/project-builder-lib/src/compiler/admin-crud-input-spec.ts (1)
17-23: Improved parameter structure with ordering supportThe refactoring of the
compileInputmethod to use a single options object with anorderproperty is a good architectural improvement. This change enables explicit ordering of CRUD input fields and provides a more extensible parameter structure for future additions.packages/sync/src/templates/text-template/text-template-file-extractor.ts (3)
15-18: LGTM! Enhanced imports for template variable handlingThe addition of
getTextTemplateVariableRegExpimport aligns with the broader effort to improve template variable handling.
43-57: Robust variable replacement with improved error detectionThe replacement of simple string replacement with regex-based replacement using
getTextTemplateVariableRegExpis a significant improvement. The added error handling ensures that problems with variable replacements are caught early with meaningful error messages.
73-74: Added identifier metadata supportIncluding the
isIdentifierproperty in the variable metadata enhances the variable schema, providing better characterization of variables and supporting the new regex matching behavior.packages/project-builder-server/src/sync/build-project.ts (1)
146-170: Enhanced template metadata generation with context-aware controlsThe replacement of a simple boolean flag with a detailed options object and a context-aware
shouldGenerateMetadatacallback is a well-designed improvement. This approach provides fine-grained control over metadata generation based on file ID patterns, making the system more flexible and maintainable.The implementation properly handles both non-manual IDs (always generating metadata) and selective generation for manual IDs based on regex patterns from the whitelist.
packages/react-generators/src/generators/admin/admin-crud-section/admin-crud-section.generator.ts (1)
23-23: Simplified exports aligned with new fragment-based architectureThe removal of the typed provider export aligns with the migration from imperative, string-based code generation to a more declarative, fragment-based approach. This change is part of a broader pattern in this PR where explicit provider types created via
createProviderTypeare removed in favor of simplified structures.packages/react-generators/src/generators/admin/admin-crud-edit/templates/schema.ts (1)
5-7: Consistent template placeholder naming convention applied.The code has been updated to follow the new template naming convention by prefixing template placeholders with
TPL_. This is part of the broader refactoring to use the fragment-based TypeScript code generation system.packages/project-builder-server/src/sync/generate-for-directory.ts (4)
8-8: Updated imports to include TemplateMetadataOptions type.The imported types now include
TemplateMetadataOptionsfrom the sync package, used for the updated metadata options pattern.
43-43: Enhanced template metadata control with richer options object.Replaced the simple boolean flag
shouldWriteTemplateMetadatawith a more flexiblewriteTemplateMetadataOptionsobject that supports granular control over template metadata generation.
125-125: Updated function parameters to use the new metadata options pattern.The function signature and internal call now use the more structured
writeTemplateMetadataOptionsobject instead of a boolean flag, passing it directly toexecuteGeneratorEntryastemplateMetadataOptions.Also applies to: 139-140
180-182: Updated metadata generation condition to use the new options structure.The condition for writing metadata now checks
writeTemplateMetadataOptions?.includeTemplateMetadata, which is more explicit than the previous boolean check and aligns with the new metadata options pattern.packages/react-generators/src/generators/admin/admin-crud-edit/templates/create.page.tsx (8)
3-3: Consolidated import statement using import alias.Imports for
BackButtonanduseToastnow use a single alias%reactComponentsImports, which will be replaced during code generation with the appropriate import paths.
6-8: Renamed component to follow template naming convention.The component function has been renamed from
COMPONENT_NAMEtoTPL_COMPONENT_NAMEand the data loader reference updated to use theTPL_prefix, making it clear these are template placeholders.
9-14: Updated mutation hook with explicit refetchQueries array format.The mutation hook now uses the
TPL_prefix and has an expandedrefetchQueriesoption in a more explicit array format, which is more maintainable and consistent with Apollo Client best practices.
20-22: Updated type references in the submitData function.The function parameter type is now
TPL_FORM_DATA_NAME(consistent with the updated schema.ts file) and the mutation hook reference uses theTPL_prefix.
28-28: Updated data gate reference with template prefix.The data gate reference now uses the
TPL_prefix, following the new naming convention.
34-37: Dynamic model name rendering in JSX.Updated the JSX to render the model name dynamically via
<TPL_MODEL_NAME />component instead of using a static string, which allows for more flexible code generation.
38-38: Updated form component reference.The form component reference now uses the
TPL_prefix, maintaining consistency with the naming convention.
43-43: Updated default export to use the new component name.The default export now correctly references the renamed
TPL_COMPONENT_NAMEcomponent.packages/react-generators/src/generators/core/react-utils/react-utils.generator.ts (2)
7-7: Updated imports to remove unused providers.Simplified imports by removing unused provider imports, which aligns with the removal of the usage tracking logic.
45-47: Simplified build function to use synchronous template addition.The build function has been simplified to directly add all templates in a synchronous loop without usage tracking. This change removes complexity and aligns with the broader shift away from usage-based template rendering.
packages/react-generators/src/generators/admin/admin-crud-list/templates/index.page.tsx (2)
3-3: Import‐alias consistency – verify that%reactComponentsImportsresolves correctlyThe template now uses the
%reactComponentsImportsalias. Please confirm that:
- The corresponding import-map provider exposes this alias.
- Other templates that still reference the old
%react-componentsalias have been updated.Missing or mismatched aliases will explode at render time and are notoriously hard to trace.
29-33: Logic appears inverted – loader shown when data existsCurrently:
{TPL_DATA_PARTS ? <ErrorableLoader … /> : TPL_TABLE_COMPONENT}Typical UX is “show loader or error when data is missing”.
UnlessTPL_DATA_PARTSactually represents a loading or error flag, this condition seems flipped. Please double-check the variable semantics across all generated list pages.-{TPL_DATA_PARTS ? ( - <ErrorableLoader error={TPL_ERROR_PARTS} /> -) : ( - TPL_TABLE_COMPONENT -)} +{TPL_ERROR_PARTS ? ( + <ErrorableLoader error={TPL_ERROR_PARTS} /> +) : ( + TPL_TABLE_COMPONENT +)}packages/react-generators/src/generators/admin/admin-crud-password-input/admin-crud-password-input.generator.ts (1)
37-44: Great use oftsCodeFragmentfor cohesive import managementWrapping the validation expression and component markup in
tsCodeFragmentkeeps imports declarative and localised—much easier to reason about than raw strings.packages/core-generators/src/renderers/typescript/actions/render-ts-template-file-action.ts (1)
101-107: Helpful error message improvement – nice!Enumerating both missing and extra template keys will drastically reduce debugging time for template consumers.
packages/react-generators/src/generators/admin/admin-crud-text-input/admin-crud-text-input.generator.ts (5)
1-1: Import refactoring looks goodThe migration from string-based to fragment-based code generation is properly implemented by importing
tsCodeFragmentand replacing the previous provider with the typed import map provider.Also applies to: 5-7
13-13: Required order field added correctlyAdding the required numeric order field to the schema aligns with the broader migration pattern of supporting ordered inputs across CRUD generators.
21-29: Type refinement improves type safetyThe type annotation refinement ensures that
INPUT_TYPE_MAPmapsTextInputTypekeys to valid component keys inReactComponentsImportsProvider, improving type safety and preventing potential import errors.
36-41: Order parameter correctly propagatedThe order parameter is properly destructured from the input and passed to the dependencies, ensuring consistent ordering behavior throughout the generation process.
42-64: Fragment-based code generation implemented correctlyThe migration from string-based code generation to fragment-based approach is properly implemented:
- Order field is passed to addInput
- Content uses tsCodeFragment with proper import declarations
- Validation expression is wrapped with tsCodeFragment
This approach provides better type safety and more consistent import handling.
packages/react-generators/src/generators/admin/admin-crud-embedded-form/templates/EmbeddedForm.tsx (5)
3-4: Import consolidation improves template maintenanceGrouping imports from template variables
%reactComponentsImportsand%reactErrorImportssimplifies dependency management and aligns with the new fragment-based approach.
8-15: Template placeholders correctly implementedThe use of
TPL_prefixed placeholders (TPL_TABLE_COMPONENT,TPL_COMPONENT_NAME, etc.) aligns with the template rendering overhaul, making the template more flexible and reusable.
19-19: Header placeholder properly integratedThe
TPL_HEADERplaceholder allows for customizable header content insertion.
23-28: Improved form submission handlerThe form submission handler now:
- Explicitly stops event propagation
- Uses
logAndFormatErrorto format errors before setting form errorsThis enhances error handling and provides better error messages to users.
32-32: Inputs placeholder correctly implementedThe
TPL_INPUTSplaceholder allows for dynamic injection of form inputs during template rendering.packages/project-builder-server/src/compiler/admin/crud/index.ts (5)
66-74: Order parameter added to list form fieldsAdding the index parameter to the
compileAdminCrudInputcall ensures that embedded list form fields are properly ordered. This aligns with the broader update to support input ordering across the codebase.
82-90: Order parameter added to regular form fieldsSimilar to the list form, adding the index parameter to the
compileAdminCrudInputcall for regular form fields ensures consistent ordering behavior.
113-116: Model ID added to edit generatorAdding the
modelIdproperty to theadminCrudEditGeneratorcall explicitly associates the model reference ID with the edit generator, improving traceability and model association.
132-135: Model ID added to list generatorAdding the
modelIdproperty to theadminCrudListGeneratorcall maintains consistency with the edit generator and ensures proper model association.
153-156: Model ID added to queries generatorAdding the
modelIdproperty to theadminCrudQueriesGeneratorcall completes the model association pattern across all generators in the CRUD section.packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts (4)
106-114: New utility function for default importsThe
defaultImportfunction provides a convenient way to create default import declarations without having to chain builder methods, simplifying import creation in generators.
124-135: New utility function for default import fragmentsThe
defaultImportFragmentfunction extends the import utilities by creating a fragment with a default import, providing a consistent pattern for default imports that matches the named import pattern.
145-153: Enhanced fragment merge functionThe
mergeFragmentsfunction now accepts bothMapand plain object (Record) inputs, increasing flexibility in fragment merging. The input is properly normalized to aMapbefore sorting and merging.
261-263:✅ Verification successful
JavaScript compatibility consideration
The
toSortedmethod was introduced in ECMAScript 2023. Ensure your target environments support this method or consider using a polyfill if you need to support older JavaScript environments.
🌐 Web query:
When was the JavaScript toSorted array method introduced and what browsers support it?💡 Result:
Introduction of
Array.prototype.toSorted()The
toSorted()array method was introduced as part of the ECMAScript 2023 (ES2023) specification. This method provides a non-mutating way to sort arrays, returning a new sorted array while leaving the original array unchanged[1][9]. Its addition addresses a long-standing issue where the traditionalsort()method would modify the original array, which could lead to unintended side effects in code[3][4][5][7][9].Browser Support
The
toSorted()method is supported in all major modern browsers starting with versions released around early to mid-2023, closely following the ES2023 standardization. Here's a summary of browser support[1][6]:
Browser Supported From Version Chrome 110 Edge 110 Firefox 115 Safari 16.0 Opera 96 Android Browser 135 Chrome for Android 135 Firefox for Android 137 Samsung Internet 21 Safari on iOS 16.0
- Not supported in Internet Explorer.
- Opera Mini and some other niche browsers may lack support or have unknown status[6].
Details
- As of July 2023, the method is widely available across the latest versions of popular browsers and devices[1][6].
- Older browsers or devices are unlikely to support
toSorted()[6].Summary
- JavaScript
Array.prototype.toSorted()was introduced in ES2023 (finalized in 2023).- Supported in all major modern browsers from mid-2023 versions onward. For best compatibility, target Chrome 110+, Edge 110+, Firefox 115+, and Safari 16.0+ for this feature[1][6].
If you need to support older browsers, you will need to use the traditional
sort()method (which mutates the original array) or implement a polyfill fortoSorted().Citations:
- 1: https://www.w3schools.com/jsref/jsref_array_tosorted.asp
- 2: https://www.w3schools.com/js/js_array_sort.asp
- 3: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
- 4: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
- 5: https://dev.to/manthanank/sorting-arrays-in-javascript-tosorted-and-sort-4pf6
- 6: https://caniuse.com/mdn-javascript_builtins_array_tosorted
- 7: https://daily.dev/blog/javascript-latest-version-an-overview
- 8: https://www.codecademy.com/resources/docs/javascript/arrays/toSorted
- 9: https://blog.greenroots.info/exploring-advanced-javascript-features-ecmascript-2023
- 10: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toSorted
ECMAScript 2023 Array.prototype.toSorted() Compatibility
The call tokeys.toSorted()requires ES2023 support (Node 20+/Chrome 110+/Edge 110+/Firefox 115+/Safari 16+). If your build or target runtimes include older environments (e.g. Node 18 LTS or IE/older browsers), please either:
- Bump the minimum supported Node/browser version to one that implements ES2023,
- Polyfill
Array.prototype.toSorted(), or- Replace with a non-mutating sort using a copy, for example:
const sortedKeys = disableSort ? keys : caseSensitive ? [...keys].sort() : [...keys].sort((a, b) => a.localeCompare(b));packages/fastify-generators/src/generators/auth/password-hasher-service/password-hasher-service.generator.ts (1)
49-51: Double-check thatmoduleFolderalways starts with@/
createPasswordHasherServiceImports()throws if the argument does not start with@/.
WhileappModule.getModuleFolder()is expected to satisfy this, any future change to that contract will break the generator at runtime.Please confirm (or add an invariant test) that
getModuleFolder()always returns a path beginning with@/, or normalise the value before passing it:const importBase = moduleFolder.startsWith('@/') ? moduleFolder : `@/${moduleFolder}`; passwordHasherServiceImports: createPasswordHasherServiceImports( path.posix.join(importBase, 'services'), ),plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts (1)
24-28: ConfirmaddInputaccepts the neworderprop
adminCrudInputContainer.addInput({...})is now called withorder.
If the underlying API hasn’t been updated, this argument will be silently ignored or throw.
Please verify and add a unit test for ordered rendering.packages/react-generators/src/generators/admin/admin-crud-edit/templates/EditForm.tsx (1)
35-45: Looks good – template logic matches the new fragment systemThe refactor cleanly converts hard-coded elements into template placeholders, and the
max-w-mdclass improves layout consistency. No functional issues spotted here.packages/react-generators/src/generators/admin/admin-components/admin-components.generator.ts (1)
68-76: Path for%admin-componentsmay be inconsistentYou point
%admin-componentstoreactComponentsImports.Button.moduleSpecifier, yet the allowed exports areEmbeddedListInputandEmbeddedObjectInput– notButton.
IfButtonlives in a different barrel file, consumers will import from an unexpected path and TypeScript will error.Verify that
reactComponentsImports.Button.moduleSpecifierreally re-exports the embedded inputs, or swap in the correct module specifier.packages/project-builder-server/src/compiler/admin/crud/inputs.ts (1)
34-35: Consistent addition of order parameter to CRUD input compilersThe
orderparameter has been systematically added to all admin CRUD input compiler methods and passed to their respective generator functions. This enhancement enables positional control of inputs in the generated UI.Also applies to: 56-57, 71-72, 91-92, 127-128, 140-141, 159-160, 164-165, 177-178, 193-194, 207-210, 228-229, 237-238
packages/sync/src/templates/text-template/render-text-template-file-action.ts (4)
1-1: LGTM: Import improvements for better code organizationUsing
escapeRegExpfrom 'es-toolkit' instead of a local implementation improves code maintainability by leveraging standard library functions.Also applies to: 15-18
57-64: Good refactoring: Centralized metadata generation logicCreating a dedicated
shouldWriteMetadataboolean centralizes the decision logic for including template metadata, making the code more maintainable.
125-145: LGTM: Improved template variable replacementThe use of
replaceAllwith a regex for template variable replacement is a more robust approach.
251-258: LGTM: Conditional metadata inclusionThe updated logic for conditionally including template metadata is consistent with the new interface design.
packages/sync/src/output/generator-task-output.ts (1)
196-197: LGTM: Default implementation for shouldGenerateMetadataProviding a default implementation that returns
falseensures there's always a reasonable fallback.packages/react-generators/src/generators/admin/admin-crud-queries/admin-crud-queries.generator.ts (4)
1-1: LGTM: Migration to new TypeScript fragment systemSuccessfully migrated from
TypescriptCodeExpressiontoTsCodeFragmentandTypescriptCodeUtilstoTsCodeUtils, aligning with the broader refactoring effort.Also applies to: 3-3, 45-46, 52-54, 59-60
106-111: LGTM: Improved import generation with TsCodeUtilsUsing
TsCodeUtils.importFragmentprovides a more structured and type-safe way to generate imports.
32-33:✅ Verification successful
Added modelId to descriptor schema and buildTasks function
The addition of
modelIdto the descriptor schema and buildTasks function provides better identification of models.Verify that all consumers of this generator have been updated to provide both
modelIdandmodelName:Also applies to: 72-73
🏁 Script executed:
#!/bin/bash # Search for usage of admin-crud-queries generator to ensure modelId is provided rg -A 5 "admin/admin-crud-queries" --type tsLength of output: 859
No external consumers detected for
admin-crud-queriesgeneratorA search for
admin/admin-crud-queriesin all.tsfiles only returned the generator’s own definition—no other call sites were found. No further updates are needed to supplymodelIdormodelNameelsewhere.
319-320:❓ Verification inconclusive
File ID format changed
The file ID for the output file has been changed from using
admin-crud-queries>${modelName}to${modelId}-crud-queries.This change in ID format could potentially affect systems that depend on the old format. Verify that this change is compatible with any code that references these IDs:
🏁 Script executed:
#!/bin/bash # Search for references to the old ID format rg "admin-crud-queries>" --type tsLength of output: 36
Verify no legacy ID references remain
Ran
rg "admin-crud-queries>" --type tsagainst the.tsfiles and found no occurrences of the oldadmin-crud-queries>${modelName}format. Please manually check any other file types (e.g..tsx,.js, templates or config files) to ensure no code or templates still reference the old ID before approving this change.packages/react-generators/src/generators/admin/admin-crud-enum-input/admin-crud-enum-input.generator.ts (4)
1-4: Great job migrating to granular imports and providers!The refactoring from
TypescriptCodeUtilsto specific fragment-based imports (tsCodeFragment,tsHoistedFragment) and updating toreactComponentsImportsProvideraligns well with the PR objective of migrating to the new TS system. These changes make the code more modular and easier to maintain.Also applies to: 9-9
15-15: Proper implementation of the order propertyAdding the
orderproperty to the schema and passing it through toaddInputis a good improvement. This will allow for consistent ordering of CRUD input fields across the UI, enhancing the user experience.Also applies to: 31-31, 39-39
40-67: Well-structured conversion to fragment-based code generationThe switch from string-based code generation to fragment-based approach (
tsCodeFragment,tsHoistedFragment) is well implemented. This declarative approach will make the code more maintainable and easier to reason about, while properly handling imports and hoisted code sections.
72-76: Clean implementation of validation expressionThe validation expression has been correctly migrated to use
tsCodeFragment, maintaining the same functionality while integrating with the new TS system.packages/react-generators/src/generators/admin/admin-crud-list/templates/Table.tsx (3)
3-10: Well-implemented module alias importsThe consolidation of imports using module aliases (
%reactComponentsImports,%reactErrorImports) is a good approach for template-based code generation. This will make import management more flexible during code generation.
14-17: Effective templating with placeholdersThe conversion to a template using
TPL_prefixed placeholders enables dynamic code generation. This approach allows the same template to be reused across different models with varying properties and requirements.Also applies to: 19-19, 22-22, 48-48, 55-55, 70-70
57-57: Enhanced UI with Show functionalityAdding the "Show" link alongside the existing "Edit" and "Delete" actions improves the UI by providing a view-only option. This is a good UX improvement that allows users to view details without entering edit mode.
packages/react-generators/src/generators/admin/admin-crud-foreign-input/admin-crud-foreign-input.generator.ts (4)
1-5: Good migration to specific fragment APIsSimilar to the enum input generator, the switch from
TypescriptCodeUtilsto more granular imports (tsCodeFragment,TsCodeUtils,tsTemplate) and updating the provider toreactComponentsImportsProvideraligns with the PR objective and improves code modularity.Also applies to: 11-11
18-18: Consistent implementation of order propertyThe addition of the
orderproperty follows the same pattern seen in the enum input generator, ensuring consistency across different input types and enabling proper ordering of form fields.Also applies to: 44-44, 74-74
64-72: Well-implemented fragment-based code generationThe conversion from string-based expressions to
tsCodeFragmentis consistent and well-implemented, making the code more maintainable and structured.Also applies to: 75-84, 89-91
95-106: Improved template composition with tsTemplateUsing
TsCodeUtils.formatFragmentwithtsTemplatefor generating the header options list is an elegant approach. This method provides better composition of code fragments and improves readability compared to manual string manipulation.packages/react-generators/src/generators/admin/_providers/admin-loader.ts (4)
1-1: Consistent type updates to TsCodeFragmentThe type references have been properly updated from
TypescriptCodeBlocktoTsCodeFragmentthroughout the file, ensuring consistency with the new TS system.Also applies to: 3-3, 8-8, 17-18
15-15: Updated provider type for importsChanging the parameter type from
ReactComponentsProvidertoReactComponentsImportsProvideraligns with the broader migration to dedicated import map providers, improving type safety and making the code more explicit.
42-44: Improved fragment merging with MapUsing
TsCodeUtils.mergeFragmentswith aMapis a good approach as it ensures deterministic ordering of merged fragments based on their keys. This is more reliable than merging an array of blocks where order might not be preserved.
46-50: Clean implementation of template literalsThe use of
TsCodeUtils.templateWithImportswith template literals for the gate code generation is more declarative and readable than the previous string-based approach. It properly handles both the code content and the required imports in a single expression.packages/react-generators/src/generators/admin/admin-crud-edit/admin-crud-edit.generator.ts (1)
173-174: 🛠️ Refactor suggestionUndefined
orderproduces unstable ordering
sortBy(inputFields, [(i) => i.order])will push inputs withorder === undefinedto the front (becauseundefinedis treated asNaN). Explicitly default the order or filter:-const sortedInputs = sortBy(inputFields, [(i) => i.order]); +const sortedInputs = sortBy(inputFields, [(i) => i.order ?? Number.MAX_SAFE_INTEGER]);This guarantees a deterministic render order when some inputs omit
order.Likely an incorrect or invalid review comment.
plugins/baseplate-plugin-storage/src/generators/react/upload-components/upload-components.generator.ts (1)
84-100: Nit: template variables naming contract is respected – good job
All variables follow theTPL_prefix convention; this prevents accidental collisions with ordinary identifiers in the template.packages/react-generators/src/generators/admin/admin-bull-board/admin-bull-board.generator.ts (1)
84-88: Emptyvariablesobject can be omitted
renderTemplateFiletreats the argument as optional. Omitting it slightly declutters the call site, but feel free to keep it if explicitness is preferred.packages/react-generators/src/generators/admin/admin-crud-list/admin-crud-list.generator.ts (2)
175-183: UnusedErrorableLoaderimport inside create button
The fragment includesErrorableLoader.declaration()but the JSX does not render the component.
Either render the loader or drop the import to avoid an “unused import” linter warning.
196-205: Great use ofmergeFragmentsAsInterfaceContent
Merging extra props into an interface via utilities keeps the output deterministic and readable. Nicely done.packages/react-generators/src/generators/admin/admin-crud-embedded-form/admin-crud-embedded-form.generator.ts (4)
115-139: Potential duplicate hoisted-fragment keys
tsHoistedFragmentusespropsName('FormProps'/'TableProps') as its key.
WhengetComponentPropsis invoked twice inside the same file (once for the form, once for the table) you will have two hoisted fragments with identical keys ifcomponentTyperepeats, which may silently overwrite one interface (depending on the merge strategy).Safest options:
- Prefix the key with
inputTypeas well (\${inputType}${propsName}``).- Or generate all props interfaces in a single fragment to remove duplication risk.
Please verify the merge behaviour or adjust the key before this lands.
252-275:zsymbol may be left unimported in the generated fileThe hoisted schema block references
z.object/z.inferbut does not attach azodimport to the fragment. If the template does not already containimport { z } from 'zod', the generated file will fail to compile.const embeddedBlock = tsHoistedFragment( TsCodeUtils.formatFragment( @@ `, { @@ }, -), +), +// Ensure `z` is imported once. +tsCodeFragment('', { module: 'zod', namedImports: ['z'] }),Double-check that the template reliably supplies the import; otherwise include it explicitly as shown above.
433-437: Missing import-map provider for admin components
getComponentPropsproduces fragments that import fromadminComponentsImportsProvider, yet that provider is not passed torenderTemplateFile’simportMapProviders. If any of the generated fragments rely on the provider’s alias resolution (rather than an absolute path), imports may be missing or mis-resolved.Please add it unless you are certain all admin-component fragments embed fully-qualified paths:
importMapProviders: { reactComponentsImports, reactErrorImports, + adminComponentsImports, },
102-106: 🛠️ Refactor suggestionAvoid relying on a runtime guard for an impossible state – make it a compile-time error instead
EmbeddedObjectTablePropsis ruled out through a runtimethrow, yet the only way it can appear is via theinputType/componentTypetuple passed togetComponentProps. This means the invalid combination can already be ruled out at the type-level, keeping the generator free from dead branches and surprise throws during build time.- // actually not sure why it's not supported here but it doesn't exist - if (defaultProps === 'EmbeddedObjectTableProps') { - throw new Error('EmbeddedObjectTableProps is not supported'); - } + // Disallow unsupported variant at the *type* level. + type UnsupportedCombination = + inputType extends 'Object' + ? (componentType extends 'Table' ? true : false) + : false; + // @ts-expect-error — “Object × Table” is intentionally unsupported. + const _compileTimeCheck: UnsupportedCombination = false;This removes the runtime path while still failing the build if a caller ever requests the unsupported pair.
Likely an incorrect or invalid review comment.
| const handleDeleteItem = async ( | ||
| item: TPL_ROW_FRAGMENT_NAME, | ||
| ): Promise<void> => { | ||
| await TPL_DELETE_FUNCTION({ | ||
| variables: { input: { id: item.id } }, | ||
| }); | ||
| }; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add error handling around the delete mutation
handleDeleteItem awaits TPL_DELETE_FUNCTION but swallows network / GraphQL errors. A failed delete will silently do nothing in the UI.
const handleDeleteItem = async (
item: TPL_ROW_FRAGMENT_NAME,
): Promise<void> => {
- await TPL_DELETE_FUNCTION({
- variables: { input: { id: item.id } },
- });
+ try {
+ await TPL_DELETE_FUNCTION({
+ variables: { input: { id: item.id } },
+ });
+ } catch (err) {
+ // TODO: surface the error (toast / banner / logger)
+ console.error(err);
+ }
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const handleDeleteItem = async ( | |
| item: TPL_ROW_FRAGMENT_NAME, | |
| ): Promise<void> => { | |
| await TPL_DELETE_FUNCTION({ | |
| variables: { input: { id: item.id } }, | |
| }); | |
| }; | |
| const handleDeleteItem = async ( | |
| item: TPL_ROW_FRAGMENT_NAME, | |
| ): Promise<void> => { | |
| try { | |
| await TPL_DELETE_FUNCTION({ | |
| variables: { input: { id: item.id } }, | |
| }); | |
| } catch (err) { | |
| // TODO: surface the error (toast / banner / logger) | |
| console.error(err); | |
| } | |
| }; |
| order: z.number(), | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Tighten validation for the new order field
order controls input ordering, so negative or fractional values would break sort stability.
-order: z.number(),
+order: z.number().int().nonnegative(),This small tweak prevents subtle ordering bugs and eliminates the need for downstream clamping.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| order: z.number(), | |
| }); | |
| order: z.number().int().nonnegative(), | |
| }); |
| const shouldIncludeMetadata = | ||
| builder.metadataOptions.includeTemplateMetadata && | ||
| (!includeMetadataOnDemand || | ||
| builder.metadataOptions.hasTemplateMetadata?.( | ||
| normalizePathToProjectPath(destination), | ||
| )); | ||
| builder.metadataOptions.shouldGenerateMetadata({ | ||
| fileId: id ?? template.name, | ||
| filePath: normalizePathToProjectPath(destination), | ||
| generatorName: generatorInfo.name, | ||
| hasManualId: !!id, | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Guard against absent shouldGenerateMetadata callback
builder.metadataOptions.includeTemplateMetadata && builder.metadataOptions.shouldGenerateMetadata(...)
If a custom builder forgets to supply shouldGenerateMetadata, the RHS will throw. Consider defensive access:
-const shouldIncludeMetadata =
- builder.metadataOptions.includeTemplateMetadata &&
- builder.metadataOptions.shouldGenerateMetadata({ … });
+const shouldIncludeMetadata =
+ builder.metadataOptions.includeTemplateMetadata &&
+ builder.metadataOptions.shouldGenerateMetadata?.({
+ fileId: id ?? template.name,
+ filePath: normalizePathToProjectPath(destination),
+ generatorName: generatorInfo.name,
+ hasManualId: !!id,
+ });This keeps the API backward-compatible while still embracing the richer metadata predicate.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const shouldIncludeMetadata = | |
| builder.metadataOptions.includeTemplateMetadata && | |
| (!includeMetadataOnDemand || | |
| builder.metadataOptions.hasTemplateMetadata?.( | |
| normalizePathToProjectPath(destination), | |
| )); | |
| builder.metadataOptions.shouldGenerateMetadata({ | |
| fileId: id ?? template.name, | |
| filePath: normalizePathToProjectPath(destination), | |
| generatorName: generatorInfo.name, | |
| hasManualId: !!id, | |
| }); | |
| const shouldIncludeMetadata = | |
| builder.metadataOptions.includeTemplateMetadata && | |
| builder.metadataOptions.shouldGenerateMetadata?.({ | |
| fileId: id ?? template.name, | |
| filePath: normalizePathToProjectPath(destination), | |
| generatorName: generatorInfo.name, | |
| hasManualId: !!id, | |
| }); |
There was a problem hiding this comment.
I'm relying on Typescript to guard against missing shouldGenerateMetadata since it's a required field.
There was a problem hiding this comment.
@kingston That makes sense! Since you're using TypeScript's static type checking to ensure shouldGenerateMetadata is required in the type definition, additional runtime checks would be redundant. Your approach is clean and type-safe.
| if (missingVariableValue && shouldWriteMetadata) { | ||
| throw new Error( | ||
| `Template variable is empty: ${missingVariableValue}. All template variables must have a value when metadata is included.`, | ||
| ); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Consider validating empty variables regardless of metadata setting
Similar to the previous comment, validation for empty variable values only throws errors when shouldWriteMetadata is true.
- if (missingVariableValue && shouldWriteMetadata) {
+ if (missingVariableValue) {Empty variables could cause issues in the template rendering even when metadata is not being generated.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (missingVariableValue && shouldWriteMetadata) { | |
| throw new Error( | |
| `Template variable is empty: ${missingVariableValue}. All template variables must have a value when metadata is included.`, | |
| ); | |
| } | |
| if (missingVariableValue) { | |
| throw new Error( | |
| `Template variable is empty: ${missingVariableValue}. All template variables must have a value when metadata is included.`, | |
| ); | |
| } |
There was a problem hiding this comment.
Same - normal generation can have empty variable values without issue. Only if we're generating with the intention of extracting the template (i.e. in development) does empty variable values make it impossible to infer the value.
There was a problem hiding this comment.
@kingston I understand now - you're right. Empty variable values are only problematic when extracting templates (when shouldWriteMetadata is true) because they make it impossible to infer the original variable. For normal generation without template extraction, empty values are acceptable and shouldn't trigger an error.
Thanks for the clarification!
🧠 Learnings used
Learnt from: kingston
PR: halfdomelabs/baseplate#521
File: packages/sync/src/templates/text-template/render-text-template-file-action.ts:97-106
Timestamp: 2025-05-05T06:35:57.504Z
Learning: In the text template renderer, validation of template variable values against template content is only necessary when preparing for future template extraction (when shouldWriteMetadata is true). This validation prevents extraction errors by ensuring variable values don't already exist in the template content.
| const formDataExpression = TsCodeUtils.importFragment( | ||
| formDataName, | ||
| `import { ${formDataName} } from '${editSchemaImport}';`, | ||
| editSchemaPath, | ||
| ); | ||
|
|
There was a problem hiding this comment.
Import specifier still contains “.ts” extension
TsCodeUtils.importFragment will keep the supplied string verbatim. Passing editSchemaPath that ends with .ts results in import ... from './foo-schema.ts', which is invalid under the Node16/ES2022 module resolver used elsewhere (extensions must be omitted). Strip the extension before handing it to importFragment, or rely on typescriptFile.resolveModuleSpecifier.
There was a problem hiding this comment.
Import paths can include .ts and the resolveModuleSpecifier will figure it out approrpiately
There was a problem hiding this comment.
@kingston Thank you for clarifying. I'll make note of this for future reviews - that import paths can include .ts extensions in your codebase and that resolveModuleSpecifier will handle it appropriately.
✏️ Learnings added
Learnt from: kingston
PR: halfdomelabs/baseplate#521
File: packages/react-generators/src/generators/admin/admin-crud-edit/admin-crud-edit.generator.ts:90-94
Timestamp: 2025-05-05T06:36:50.659Z
Learning: In this codebase, import paths can include `.ts` extensions, and the `resolveModuleSpecifier` function will handle them appropriately. There's no need to strip file extensions before passing paths to functions like `TsCodeUtils.importFragment`.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
| providers: { | ||
| uploadComponents: { | ||
| getImportMap() { | ||
| return importMap; | ||
| }, | ||
| }, | ||
| uploadComponentsImports: createUploadComponentsImports('@/src'), | ||
| }, |
There was a problem hiding this comment.
Possible invalid path alias @/src
createUploadComponentsImports('@/src') uses an alias that is inconsistent with the rest of the code-base (everywhere else we use @src/…).
If the resolver is not configured for @/, generated imports will break at compile-time.
- uploadComponentsImports: createUploadComponentsImports('@/src'),
+ uploadComponentsImports: createUploadComponentsImports('@src'),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| providers: { | |
| uploadComponents: { | |
| getImportMap() { | |
| return importMap; | |
| }, | |
| }, | |
| uploadComponentsImports: createUploadComponentsImports('@/src'), | |
| }, | |
| providers: { | |
| - uploadComponentsImports: createUploadComponentsImports('@/src'), | |
| + uploadComponentsImports: createUploadComponentsImports('@src'), | |
| }, |
There was a problem hiding this comment.
@/src is the correct format for create*imports. @src only occurs in the generated codebase
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
| typescriptFile.renderTemplateFile({ | ||
| template: REACT_UPLOAD_COMPONENTS_TS_TEMPLATES.hooksUseUpload, | ||
| destination: hookPath, | ||
| }), | ||
| ); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Missing importMapProviders for the hook template
hooksUseUpload likely imports the same component/error/GraphQL symbols rendered into the FileInput component.
Providing the same import-map ensures consistent aliasing and prevents undeclared-identifier errors inside the generated hook.
- await builder.apply(
- typescriptFile.renderTemplateFile({
+ await builder.apply(
+ typescriptFile.renderTemplateFile({
template: REACT_UPLOAD_COMPONENTS_TS_TEMPLATES.hooksUseUpload,
destination: hookPath,
+ importMapProviders: {
+ reactErrorImports,
+ reactComponentsImports,
+ generatedGraphqlImports,
+ },
}),
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| typescriptFile.renderTemplateFile({ | |
| template: REACT_UPLOAD_COMPONENTS_TS_TEMPLATES.hooksUseUpload, | |
| destination: hookPath, | |
| }), | |
| ); | |
| await builder.apply( | |
| typescriptFile.renderTemplateFile({ | |
| template: REACT_UPLOAD_COMPONENTS_TS_TEMPLATES.hooksUseUpload, | |
| destination: hookPath, | |
| importMapProviders: { | |
| reactErrorImports, | |
| reactComponentsImports, | |
| generatedGraphqlImports, | |
| }, | |
| }), | |
| ); |
There was a problem hiding this comment.
The importMapProviders is not necessary for certain templates (these are inferred from the template extractor which will automatically determine the necessary import map providers)
There was a problem hiding this comment.
@kingston Thank you for the clarification. I understand now that the template extractor automatically determines the necessary import map providers for certain templates, making explicit specification unnecessary in these cases.
✏️ Learnings added
Learnt from: kingston
PR: halfdomelabs/baseplate#521
File: plugins/baseplate-plugin-storage/src/generators/react/upload-components/upload-components.generator.ts:108-112
Timestamp: 2025-05-05T06:37:43.048Z
Learning: The template extractor in the baseplate codebase can automatically infer and determine the necessary import map providers for certain templates, making explicit specification of importMapProviders unnecessary in those cases.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
| importMapProviders: { | ||
| reactComponentsImports, | ||
| }, | ||
| }), |
There was a problem hiding this comment.
reactErrorImports missing from importMapProviders
The list page embeds an ErrorableLoader import through loaderOutput / TPL_CREATE_BUTTON.
Without adding reactErrorImports, the generated file will contain a bare identifier without a corresponding import statement.
importMapProviders: {
reactComponentsImports,
+ reactErrorImports,
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| importMapProviders: { | |
| reactComponentsImports, | |
| }, | |
| }), | |
| importMapProviders: { | |
| reactComponentsImports, | |
| reactErrorImports, | |
| }, | |
| }), |
There was a problem hiding this comment.
The importMapProviders is not necessary for certain templates (these are inferred from the template extractor which will automatically determine the necessary import map providers)
There was a problem hiding this comment.
@kingston I understand now - thanks for the clarification about how the template extractor works. The system automatically infers the necessary import map providers from the templates, making the explicit specification unnecessary in certain cases.
✏️ Learnings added
Learnt from: kingston
PR: halfdomelabs/baseplate#521
File: packages/react-generators/src/generators/admin/admin-crud-list/admin-crud-list.generator.ts:163-166
Timestamp: 2025-05-05T06:37:50.980Z
Learning: For certain templates in the codebase, the `importMapProviders` property is not explicitly required as the template extractor will automatically determine and infer the necessary import map providers.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/sync/src/templates/text-template/utils.unit.test.ts (1)
1-48: Suggestion: Add tests for edge cases to improve robustness.While the current tests are good, consider adding tests for:
- Empty string values
- Values with regex special characters (e.g.,
+,*,(,))- Unicode characters and emojis
- Very long identifiers
These additional tests would help ensure the regex generator handles all possible input scenarios correctly.
+ it('should handle regex special characters in values', () => { + const regex = getTextTemplateVariableRegExp({ isIdentifier: true }, 'test+*()'); + expect('test+*()').toMatch(regex); + expect('prefix test+*() suffix').toMatch(regex); + expect('test+*()123').not.toMatch(regex); + }); + + it('should handle empty values', () => { + const regex = getTextTemplateVariableRegExp({ isIdentifier: true }, ''); + expect('').toMatch(regex); + // Add appropriate assertions based on expected behavior for empty values + }); + + it('should handle unicode characters and emojis', () => { + const regex = getTextTemplateVariableRegExp({ isIdentifier: true }, 'test🚀'); + expect('test🚀').toMatch(regex); + expect('prefix test🚀 suffix').toMatch(regex); + expect('test🚀123').not.toMatch(regex); + });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite
📒 Files selected for processing (9)
packages/core-generators/src/renderers/typescript/templates/types.ts(1 hunks)packages/react-generators/src/generators/admin/admin-crud-password-input/admin-crud-password-input.generator.ts(1 hunks)packages/sync/src/templates/text-template/render-text-template-file-action.ts(8 hunks)packages/sync/src/templates/text-template/text-template-file-extractor.ts(4 hunks)packages/sync/src/templates/text-template/text-template-file-extractor.unit.test.ts(4 hunks)packages/sync/src/templates/text-template/types.ts(3 hunks)packages/sync/src/templates/text-template/utils.ts(2 hunks)packages/sync/src/templates/text-template/utils.unit.test.ts(1 hunks)plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/core-generators/src/renderers/typescript/templates/types.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- packages/sync/src/templates/text-template/text-template-file-extractor.ts
- packages/sync/src/templates/text-template/utils.ts
- packages/sync/src/templates/text-template/types.ts
- packages/react-generators/src/generators/admin/admin-crud-password-input/admin-crud-password-input.generator.ts
- plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts
- packages/sync/src/templates/text-template/render-text-template-file-action.ts
🔇 Additional comments (7)
packages/sync/src/templates/text-template/text-template-file-extractor.unit.test.ts (4)
23-24: Test case updated to include identifier-based template variable.The test fixture has been enhanced to include text with an identifier that will be templated, which is a good addition to test the new identifier functionality.
40-44: Good implementation of the identifier template variable.The addition of
TPL_IDENTIFIERwith theisIdentifier: trueflag demonstrates the new feature for handling word boundaries in template variables. This properly tests the ability to distinguish between regular string replacement and identifier-aware replacement.
54-56: Correctly updated expected output with templated identifier.The expected output now includes the identifier replacement with
{{TPL_IDENTIFIER}}, which aligns with the implementation of identifier-aware template variables.
65-68: Proper representation of template variables in generated code.The generated TypeScript template file correctly includes the
isIdentifierflag for theTPL_IDENTIFIERvariable while omitting thevalueproperty. This is consistent with the metadata handling requirements where template variable runtime values aren't needed in the generated code.packages/sync/src/templates/text-template/utils.unit.test.ts (3)
1-6: Well-structured imports and setup for utility tests.The imports are properly organized, separating types from implementation and using the correct import syntax with file extensions.
7-26: Thorough test cases for identifier-aware variables.These tests comprehensively verify the behavior of
getTextTemplateVariableRegExpwhen the variable is an identifier. The test cases correctly check:
- Matching standalone words
- Not matching substrings within longer words
- Not matching identifiers with underscores
- Proper handling of special characters
This is critical to ensure template variables marked as identifiers only replace whole words in templates.
28-46: Comprehensive tests for non-identifier variables.The tests for regular (non-identifier) variables verify that the function generates expressions that match substrings anywhere within the text. These cases are important to maintain backward compatibility with the existing template variable behavior while supporting the new identifier-aware functionality.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Removals
Documentation
Tests