Skip to content

refactor: Refactor all remaining generators to use new TS system#521

Merged
kingston merged 22 commits into
mainfrom
kingston/eng-676-convert-admin-generators-to-use-new-ts-system
May 5, 2025
Merged

refactor: Refactor all remaining generators to use new TS system#521
kingston merged 22 commits into
mainfrom
kingston/eng-676-convert-admin-generators-to-use-new-ts-system

Conversation

@kingston

@kingston kingston commented May 4, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added support for ordering of admin CRUD input fields across multiple generators and input types.
    • Introduced a file ID regex whitelist field in template extractor settings for finer metadata control.
    • Added new utility functions for default TypeScript imports and merging code fragments.
  • Improvements

    • Migrated to a new fragment-based system for TypeScript code generation, enhancing modularity and import handling.
    • Refactored generators to use template-based rendering and structured import providers.
    • Enhanced template metadata generation with more flexible, context-aware options and improved validation.
    • Consolidated and standardized import statements across React and Fastify generators for better maintainability.
    • Improved error messaging and validation for template variable extraction and replacement.
    • Simplified generator build steps by removing usage tracking and rendering all templates unconditionally.
    • Streamlined route registration and file path handling in multiple generators.
    • Updated React component imports and code fragment handling to use new import providers and utilities.
  • Bug Fixes

    • Corrected AWS configuration seed values in the storage module generator.
    • Fixed logic to prevent duplicate 'Content-Type' fields during file uploads.
  • Removals

    • Removed legacy code, providers, and documentation related to deprecated TypeScript code generation approaches.
    • Deleted obsolete migration guides and internal helper utilities.
  • Documentation

    • Updated and removed outdated migration guides and internal documentation files.
  • Tests

    • Updated tests to align with new metadata options and refactored code structures.

@linear

linear Bot commented May 4, 2025

Copy link
Copy Markdown

@changeset-bot

changeset-bot Bot commented May 4, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f1fcba3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented May 4, 2025

Copy link
Copy Markdown

Walkthrough

This 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 TsCodeFragment and related utilities. Numerous generators across core, React, and plugin packages have been refactored to utilize new fragment APIs, template rendering mechanisms, and structured import map providers. The migration also introduces improved handling for template metadata, with a new context-aware callback for metadata inclusion, and extends support for ordering of CRUD input fields. Several internal provider abstractions and manual import mappers have been removed in favor of generated import providers and more consistent template-based workflows. Additional improvements include enhanced test coverage, configuration schema extensions, and corrections in configuration values.

Changes

Files / Groups Change Summary
.cursor/rules/ts-code-migration.mdc Deleted migration guide for transitioning TypeScript code generation to a fragment-based system.
packages/core-generators/src/generators/node/ts-utils/ts-utils.generator.ts, packages/core-generators/src/generators/core/react-utils/react-utils.generator.ts, packages/core-generators/src/generators/node/typescript/typescript.generator.ts, packages/core-generators/src/generators/node/typescript/typescript.generator.unit.test.ts Removed or refactored providers, exports, and usage tracking for template utilities; simplified build logic to use lazy template files and updated export names.
packages/core-generators/src/renderers/typescript/actions/render-ts-template-file-action.ts, packages/core-generators/src/renderers/typescript/actions/render-ts-template-file-action.unit.test.ts, packages/core-generators/src/renderers/typescript/extractor/ts-template-file-extractor.unit.test.ts, packages/core-generators/src/renderers/typescript/extractor/write-ts-project-exports.ts, packages/core-generators/src/renderers/typescript/extractor/write-ts-project-exports.unit.test.ts, packages/core-generators/src/renderers/typescript/imports/ts-path-maps.ts, packages/core-generators/src/renderers/typescript/utils/ts-code-utils.ts Improved validation, error reporting, and utility APIs for code fragments and imports; added new utility methods and extended input types for merging fragments.
packages/fastify-generators/src/generators/auth/password-hasher-service/password-hasher-service.generator.ts, packages/fastify-generators/src/generators/auth/prisma-password-transformer/prisma-password-transformer.generator.ts, packages/fastify-generators/src/generators/core/app-module/app-module.generator.ts, packages/fastify-generators/src/generators/core/fastify-scripts/fastify-scripts.generator.ts, packages/fastify-generators/src/generators/core/service-file/service-file.generator.ts, packages/fastify-generators/src/generators/prisma/prisma-utils/prisma-utils.generator.ts Refactored generators to use new import providers, removed manual import mappers, updated template rendering logic, and simplified configuration schemas.
packages/project-builder-lib/src/compiler/admin-crud-input-spec.ts, packages/project-builder-server/src/compiler/admin/crud/index.ts, packages/project-builder-server/src/compiler/admin/crud/inputs.ts, packages/project-builder-server/src/sync/build-project.ts, packages/project-builder-server/src/sync/generate-for-directory.test.ts, packages/project-builder-server/src/sync/generate-for-directory.ts, packages/project-builder-lib/src/schema/template-extractor/index.ts Extended admin CRUD input compilation with order parameter, improved template metadata writing options with regex whitelists, and updated schema definitions.
packages/project-builder-web/src/pages/settings/template-extractor.tsx Added UI for configuring file ID regex whitelist for template extractor metadata.
packages/react-generators/src/generators/admin/_providers/admin-crud-input-container.ts, packages/react-generators/src/generators/admin/_providers/admin-loader.ts, packages/react-generators/src/generators/admin/_utils/data-display.ts, packages/react-generators/src/generators/admin/_utils/data-loaders.ts, packages/react-generators/src/generators/admin/_utils/foreign-data-dependency.ts, packages/react-generators/src/generators/admin/admin-bull-board/admin-bull-board.generator.ts, packages/react-generators/src/generators/admin/admin-bull-board/templates/bull-board.page.tsx, packages/react-generators/src/generators/admin/admin-components/admin-components.generator.ts, packages/react-generators/src/generators/admin/admin-components/templates/DescriptionList/index.tsx, packages/react-generators/src/generators/admin/admin-components/templates/EmbeddedListInput/index.tsx, packages/react-generators/src/generators/admin/admin-components/templates/EmbeddedObjectInput/index.tsx, packages/react-generators/src/generators/admin/admin-components/ts-extractor.json, packages/react-generators/src/generators/admin/admin-crud-edit/admin-crud-edit.generator.ts, packages/react-generators/src/generators/admin/admin-crud-edit/templates/EditForm.tsx, packages/react-generators/src/generators/admin/admin-crud-edit/templates/create.page.tsx, packages/react-generators/src/generators/admin/admin-crud-edit/templates/edit.page.tsx, packages/react-generators/src/generators/admin/admin-crud-edit/templates/schema.ts, packages/react-generators/src/generators/admin/admin-crud-embedded-form/admin-crud-embedded-form.generator.ts, packages/react-generators/src/generators/admin/admin-crud-embedded-form/templates/EmbeddedForm.tsx, packages/react-generators/src/generators/admin/admin-crud-embedded-input/admin-crud-embedded-input.generator.ts, packages/react-generators/src/generators/admin/admin-crud-enum-input/admin-crud-enum-input.generator.ts, packages/react-generators/src/generators/admin/admin-crud-foreign-display/admin-crud-foreign-display.generator.ts, packages/react-generators/src/generators/admin/admin-crud-foreign-input/admin-crud-foreign-input.generator.ts, packages/react-generators/src/generators/admin/admin-crud-list/admin-crud-list.generator.ts, packages/react-generators/src/generators/admin/admin-crud-list/templates/Table.tsx, packages/react-generators/src/generators/admin/admin-crud-list/templates/index.page.tsx, packages/react-generators/src/generators/admin/admin-crud-password-input/admin-crud-password-input.generator.ts, packages/react-generators/src/generators/admin/admin-crud-queries/admin-crud-queries.generator.ts, packages/react-generators/src/generators/admin/admin-crud-section/admin-crud-section.generator.ts, packages/react-generators/src/generators/admin/admin-crud-text-display/admin-crud-text-display.generator.ts, packages/react-generators/src/generators/admin/admin-crud-text-input/admin-crud-text-input.generator.ts, packages/react-generators/src/generators/admin/admin-home/admin-home.generator.ts, packages/react-generators/src/generators/admin/admin-home/templates/Home.page.ts, packages/react-generators/src/generators/admin/admin-layout/admin-layout.generator.ts, packages/react-generators/src/generators/admin/admin-layout/templates/AdminLayout.tsx, packages/react-generators/src/generators/core/react-components/react-components.generator.ts, packages/react-generators/src/generators/core/react-components/ts-extractor.json, packages/react-generators/src/generators/core/react-routes/react-routes.generator.ts Migrated React and admin generators to new fragment-based code generation, updated import handling, added input ordering, replaced manual template logic with template rendering, and updated configuration and provider usage.
packages/sync/src/output/generator-task-output.ts, packages/sync/src/templates/raw-template/render-raw-template-action.ts, packages/sync/src/templates/raw-template/render-raw-template-action.unit.test.ts, packages/sync/src/templates/text-template/render-text-template-file-action.ts, packages/sync/src/templates/text-template/render-text-template-file-action.unit.test.ts, packages/sync/src/templates/text-template/text-template-file-extractor.ts, packages/sync/src/templates/text-template/types.ts, packages/sync/src/templates/text-template/utils.ts Refactored template metadata handling to use context-aware callbacks, improved validation and regex handling for template variables, and added identifier support for variables.
packages/sync/src/templates/extractor/index.ts, packages/sync/src/templates/extractor/read-template-metadata-paths.ts, packages/sync/src/templates/extractor/read-template-metadata-paths.unit.test.ts Removed unused code for reading template metadata paths and associated tests.
plugins/baseplate-plugin-storage/src/generators/fastify/storage-module/storage-module.generator.ts Fixed seed values for AWS config fields to correct environment variable names.
plugins/baseplate-plugin-storage/src/generators/react/admin-crud-file-input/admin-crud-file-input.generator.ts, plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/components/FileInput/index.tsx, plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/components/FileInput/upload.gql, plugins/baseplate-plugin-storage/src/generators/react/upload-components/templates/hooks/useUpload.ts, plugins/baseplate-plugin-storage/src/generators/react/upload-components/upload-components.generator.ts, plugins/baseplate-plugin-storage/src/storage/admin-crud/node.ts Updated plugin generators and components to use new import providers, template rendering, improved file input logic, and corrected GraphQL fragment type names.

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
Loading
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
Loading
sequenceDiagram
    participant TemplateRenderer
    participant MetadataCallback

    TemplateRenderer->>MetadataCallback: shouldGenerateMetadata({ fileId, filePath, ... })
    MetadataCallback-->>TemplateRenderer: true/false
    TemplateRenderer->>OutputBuilder: Write file with or without metadata
Loading

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 issue

Missing import for z in validation fragment

The validation fragment references the global z identifier but does not declare an import.
If the file where the fragment lands has no existing import { 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 suggestion

Potential infinite loop when lazy templates mutually reference each other
The while (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, usedProjectRelativePaths never receives their paths and the loop will spin forever.

Mitigation ideas:

  1. Keep a loop counter and break after N iterations with a descriptive error.
  2. Detect cycles by marking visited templates and abort with guidance.
  3. 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 annotation

The addition of the order parameter is consistent with changes in other admin CRUD input compilers and supports ordering of input fields. However, consider adding a type annotation for the order parameter (likely number) 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: Prefer path.posix.join and omit the file-extension to avoid brittle import paths

Interpolating strings to build pagePath hard-codes the separator and keeps the “.tsx” extension in the public import path, which TypeScript/Bundlers typically resolve without. Using path.posix.join:

  1. Guarantees forward-slash separators across OSes.
  2. Produces the correct import specifier (/Home/index) that plays nicely with tsImportBuilder.
+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.formatFragment can accept an array of imports – consider grouping

Passing each import as a separate argument works but becomes noisy when the call grows.
formatFragment also accepts an imports array, 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” suffix

Inline 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 new order field more strictly

order is currently any number, which means NaN, 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: unused reactComponents template paths can be delegated to the template group

Since you already hand the reactComponentsImports provider to renderTemplateGroup, consider letting the template resolve Embedded* 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 decisions

The new shouldGenerateMetadata method now accepts a detailed context object, providing much more information for making metadata generation decisions.

Consider adding JSDoc descriptions for the hasManualId parameter 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 some react-icons packages
The prefix extraction regex ^[A-Z][a-z]* ignores digits and any subsequent capital letters. Icons such as Md3DRotation or Hi2Outline will be resolved to react-icons/md / react-icons/hi, which works, but other edge-cases like SiC++ (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: Use path.posix.join to build project-relative paths
Interpolating paths via template strings can introduce duplicate slashes and makes Windows support brittle. Construct layoutPath with the already imported path.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 imports path.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.groups misses the "type" group that many internal generators emit when es2022 target is used with importsNotUsedAsValues: "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 of bullBoardUrl
bullBoardUrl is expected to be a URL. Replacing z.string().min(1) with z.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 new modelId field
For consistency with other identifiers, enforce min(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: Empty TPL_EXTRA_PROP_SPREAD yields a dangling comma

When tableDataDependencies is 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: order property may be undefined – provide a stable fallback

Sorting by a possibly-undefined numeric field can yield non-deterministic order across Node versions. Consider supplying a default (Infinity) to keep original declaration order when order is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4e691a0 and 0565133.

⛔ Files ignored due to path filters (16)
  • packages/fastify-generators/src/generators/auth/password-hasher-service/generated/ts-import-maps.ts is excluded by !**/generated/**
  • packages/fastify-generators/src/generators/auth/password-hasher-service/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-bull-board/generated/text-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-bull-board/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-components/generated/ts-import-maps.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-components/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-crud-edit/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-crud-embedded-form/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-crud-list/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-home/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/admin/admin-layout/generated/ts-templates.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/core/react-components/generated/ts-import-maps.ts is excluded by !**/generated/**
  • packages/react-generators/src/generators/core/react-components/generated/ts-templates.ts is excluded by !**/generated/**
  • plugins/baseplate-plugin-storage/src/generators/react/upload-components/generated/text-templates.ts is excluded by !**/generated/**
  • plugins/baseplate-plugin-storage/src/generators/react/upload-components/generated/ts-import-maps.ts is excluded by !**/generated/**
  • plugins/baseplate-plugin-storage/src/generators/react/upload-components/generated/ts-templates.ts is 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 seedValue now 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 seedValue now 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 TsUtilsImportsProvider allows 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 PrismaUtilsImportsProvider allows 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 shouldGenerateMetadata callback 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 TypescriptCodeUtils to importing the more specific tsCodeFragment utility, aligning with the broader migration to fragment-based, declarative TypeScript code generation.


23-23: Refactored to use fragment-based TypeScript code generation.

Replaced TypescriptCodeUtils.createExpression with tsCodeFragment to generate display content. This change is part of the broader migration to a newer, more consistent TypeScript code generation system using TsCodeFragment utilities.

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 shouldGenerateMetadata callback 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 providers

This configuration file establishes export provider settings for the react-components generator. Setting exportProviderType: true indicates 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 standards

The property key has been renamed from exportName to name in 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 imports

UI component imports have been consolidated to use the centralized %reactComponentsImports provider instead of individual imports. This aligns with the broader refactoring effort to standardize import handling across React generators.


8-8: Reordered import for better grouping

The DefaultValues import 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 providers

Imports for useCurrentUser and ErrorableLoader now use module aliases (%authHooksImports and %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 exportProviderType to true for 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 DefaultValues up 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 exportName to name for 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 system

The change from TypescriptCodeUtils.createExpression to tsCodeFragment successfully 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 escaping

Replacing the locally defined escapeRegex function with the imported escapeRegExp from es-toolkit improves 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 system

Changing the import and type from TypescriptCodeExpression to TsCodeFragment is consistent with the broader migration to the new TypeScript code fragment system. The TsCodeFragment interface 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 placeholder

The fragment type has been changed from FILE_SCHEMA to TPL_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 providers

Import 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 formatting

Minor 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 tests

Added structured templateMetadataOptions with 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 %authHooksImports and %reactComponentsImports align 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-dom import 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 the TPL_ prefix for better identification and consistency in generated code.

packages/sync/src/templates/text-template/types.ts (2)

23-29: Added isIdentifier support 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 for isIdentifier property.

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 shouldGenerateMetadata callback 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 fileIdRegexWhitelist property 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 good

The 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 correct

The import path for useUpload has 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 improvement

The change to use @/src/components instead of src/components aligns the getComponentsFolder method with the import path used in getComponentsImport and the import map, ensuring consistency across the codebase.


230-233: Enhanced type exports

The 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 control

The 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 application

The conditional passing of templateMetadata to the writeFile method 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 consolidation

The import statements have been consolidated to use the unified TsCodeFragment type, which aligns with the broader migration to standardize TypeScript code fragment handling.


8-8: Interface type standardization

The AdminCrudDisplay interface has been updated to use TsCodeFragment for both content and header properties, replacing the older TypescriptCodeExpression and TypescriptCodeBlock types. 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: true to a structured object with includeTemplateMetadata and shouldGenerateMetadata callback 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 TextareaField component 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 id property 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 TypescriptCodeUtils import 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 tsCodeFragment with tsImportBuilder improves 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 unified TsCodeFragment type

This 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 TsCodeFragment type.


9-12: Updated interface to use TsCodeFragment

Good adjustment to the AdminCrudInputValidation interface to utilize the new TsCodeFragment type for the expression property, which will provide better composition and import handling than the previous type.


14-21: Added order property and updated to use TsCodeFragment

The addition of the order property to the AdminCrudInput interface is a good enhancement that will allow for controlled ordering of input fields. The update to use TsCodeFragment for both content and header properties 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 system

Good refactoring to remove the tsImportBuilder and use only tsCodeFragment, 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 provider

The change from passwordHasherServiceProvider to passwordHasherServiceImportsProvider in 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 transformer

Using 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 function

Good addition of imports for escapeRegExp and TextTemplateFileVariable to support the new regex generation function.


35-47: Added useful regex generation function for template variables

This new function getTextTemplateVariableRegExp enhances 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:

  1. For identifiers, it uses negative lookbehind and lookahead assertions to ensure whole word matches
  2. 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 provider

Good update to use the import alias %reactComponentsImports which simplifies import management through the import map provider system rather than separate imports.


6-12: Standardized template placeholder naming

The 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 naming

The 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 name

Using <TPL_MODEL_NAME /> instead of a hardcoded reference improves the template by allowing for dynamic model name rendering, and the update to use TPL_EDIT_FORM maintains consistency with other template changes.


36-36: Updated default export with consistent naming

Good update to the default export to use the TPL_COMPONENT_NAME placeholder, 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 support

The refactoring of the compileInput method to use a single options object with an order property 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 handling

The addition of getTextTemplateVariableRegExp import aligns with the broader effort to improve template variable handling.


43-57: Robust variable replacement with improved error detection

The replacement of simple string replacement with regex-based replacement using getTextTemplateVariableRegExp is 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 support

Including the isIdentifier property 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 controls

The replacement of a simple boolean flag with a detailed options object and a context-aware shouldGenerateMetadata callback 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 architecture

The 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 createProviderType are 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 TemplateMetadataOptions from 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 shouldWriteTemplateMetadata with a more flexible writeTemplateMetadataOptions object 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 writeTemplateMetadataOptions object instead of a boolean flag, passing it directly to executeGeneratorEntry as templateMetadataOptions.

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 BackButton and useToast now 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_NAME to TPL_COMPONENT_NAME and the data loader reference updated to use the TPL_ 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 expanded refetchQueries option 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 the TPL_ 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_NAME component.

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 %reactComponentsImports resolves correctly

The template now uses the %reactComponentsImports alias. Please confirm that:

  1. The corresponding import-map provider exposes this alias.
  2. Other templates that still reference the old %react-components alias 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 exists

Currently:

{TPL_DATA_PARTS ? <ErrorableLoader  /> : TPL_TABLE_COMPONENT}

Typical UX is “show loader or error when data is missing.
Unless TPL_DATA_PARTS actually 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 of tsCodeFragment for cohesive import management

Wrapping the validation expression and component markup in tsCodeFragment keeps 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 good

The migration from string-based to fragment-based code generation is properly implemented by importing tsCodeFragment and replacing the previous provider with the typed import map provider.

Also applies to: 5-7


13-13: Required order field added correctly

Adding 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 safety

The type annotation refinement ensures that INPUT_TYPE_MAP maps TextInputType keys to valid component keys in ReactComponentsImportsProvider, improving type safety and preventing potential import errors.


36-41: Order parameter correctly propagated

The 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 correctly

The 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 maintenance

Grouping imports from template variables %reactComponentsImports and %reactErrorImports simplifies dependency management and aligns with the new fragment-based approach.


8-15: Template placeholders correctly implemented

The 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 integrated

The TPL_HEADER placeholder allows for customizable header content insertion.


23-28: Improved form submission handler

The form submission handler now:

  1. Explicitly stops event propagation
  2. Uses logAndFormatError to format errors before setting form errors

This enhances error handling and provides better error messages to users.


32-32: Inputs placeholder correctly implemented

The TPL_INPUTS placeholder 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 fields

Adding the index parameter to the compileAdminCrudInput call 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 fields

Similar to the list form, adding the index parameter to the compileAdminCrudInput call for regular form fields ensures consistent ordering behavior.


113-116: Model ID added to edit generator

Adding the modelId property to the adminCrudEditGenerator call explicitly associates the model reference ID with the edit generator, improving traceability and model association.


132-135: Model ID added to list generator

Adding the modelId property to the adminCrudListGenerator call maintains consistency with the edit generator and ensures proper model association.


153-156: Model ID added to queries generator

Adding the modelId property to the adminCrudQueriesGenerator call 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 imports

The defaultImport function 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 fragments

The defaultImportFragment function 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 function

The mergeFragments function now accepts both Map and plain object (Record) inputs, increasing flexibility in fragment merging. The input is properly normalized to a Map before sorting and merging.


261-263:

✅ Verification successful

JavaScript compatibility consideration

The toSorted method 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 traditional sort() 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 for toSorted().

Citations:


ECMAScript 2023 Array.prototype.toSorted() Compatibility
The call to keys.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 that moduleFolder always starts with @/

createPasswordHasherServiceImports() throws if the argument does not start with @/.
While appModule.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: Confirm addInput accepts the new order prop

adminCrudInputContainer.addInput({...}) is now called with order.
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 system

The refactor cleanly converts hard-coded elements into template placeholders, and the max-w-md class 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-components may be inconsistent

You point %admin-components to reactComponentsImports.Button.moduleSpecifier, yet the allowed exports are EmbeddedListInput and EmbeddedObjectInput – not Button.
If Button lives in a different barrel file, consumers will import from an unexpected path and TypeScript will error.

Verify that reactComponentsImports.Button.moduleSpecifier really 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 compilers

The order parameter 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 organization

Using escapeRegExp from '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 logic

Creating a dedicated shouldWriteMetadata boolean centralizes the decision logic for including template metadata, making the code more maintainable.


125-145: LGTM: Improved template variable replacement

The use of replaceAll with a regex for template variable replacement is a more robust approach.


251-258: LGTM: Conditional metadata inclusion

The 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 shouldGenerateMetadata

Providing a default implementation that returns false ensures 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 system

Successfully migrated from TypescriptCodeExpression to TsCodeFragment and TypescriptCodeUtils to TsCodeUtils, aligning with the broader refactoring effort.

Also applies to: 3-3, 45-46, 52-54, 59-60


106-111: LGTM: Improved import generation with TsCodeUtils

Using TsCodeUtils.importFragment provides 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 modelId to the descriptor schema and buildTasks function provides better identification of models.

Verify that all consumers of this generator have been updated to provide both modelId and modelName:

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 ts

Length of output: 859


No external consumers detected for admin-crud-queries generator

A search for admin/admin-crud-queries in all .ts files only returned the generator’s own definition—no other call sites were found. No further updates are needed to supply modelId or modelName elsewhere.


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 ts

Length of output: 36


Verify no legacy ID references remain

Ran rg "admin-crud-queries>" --type ts against the .ts files and found no occurrences of the old admin-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 TypescriptCodeUtils to specific fragment-based imports (tsCodeFragment, tsHoistedFragment) and updating to reactComponentsImportsProvider aligns 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 property

Adding the order property to the schema and passing it through to addInput is 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 generation

The 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 expression

The 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 imports

The 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 placeholders

The 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 functionality

Adding 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 APIs

Similar to the enum input generator, the switch from TypescriptCodeUtils to more granular imports (tsCodeFragment, TsCodeUtils, tsTemplate) and updating the provider to reactComponentsImportsProvider aligns with the PR objective and improves code modularity.

Also applies to: 11-11


18-18: Consistent implementation of order property

The addition of the order property 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 generation

The conversion from string-based expressions to tsCodeFragment is consistent and well-implemented, making the code more maintainable and structured.

Also applies to: 75-84, 89-91


95-106: Improved template composition with tsTemplate

Using TsCodeUtils.formatFragment with tsTemplate for 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 TsCodeFragment

The type references have been properly updated from TypescriptCodeBlock to TsCodeFragment throughout the file, ensuring consistency with the new TS system.

Also applies to: 3-3, 8-8, 17-18


15-15: Updated provider type for imports

Changing the parameter type from ReactComponentsProvider to ReactComponentsImportsProvider aligns with the broader migration to dedicated import map providers, improving type safety and making the code more explicit.


42-44: Improved fragment merging with Map

Using TsCodeUtils.mergeFragments with a Map is 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 literals

The use of TsCodeUtils.templateWithImports with 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 suggestion

Undefined order produces unstable ordering
sortBy(inputFields, [(i) => i.order]) will push inputs with order === undefined to the front (because undefined is treated as NaN). 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 the TPL_ 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: Empty variables object can be omitted
renderTemplateFile treats 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: Unused ErrorableLoader import inside create button
The fragment includes ErrorableLoader.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 of mergeFragmentsAsInterfaceContent
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

tsHoistedFragment uses propsName ('FormProps' / 'TableProps') as its key.
When getComponentProps is invoked twice inside the same file (once for the form, once for the table) you will have two hoisted fragments with identical keys if componentType repeats, which may silently overwrite one interface (depending on the merge strategy).

Safest options:

  1. Prefix the key with inputType as well (\${inputType}${propsName}``).
  2. 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: z symbol may be left unimported in the generated file

The hoisted schema block references z.object / z.infer but does not attach a zod import to the fragment. If the template does not already contain import { 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

getComponentProps produces fragments that import from adminComponentsImportsProvider, yet that provider is not passed to renderTemplateFile’s importMapProviders. 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 suggestion

Avoid relying on a runtime guard for an impossible state – make it a compile-time error instead

EmbeddedObjectTableProps is ruled out through a runtime throw, yet the only way it can appear is via the inputType/componentType tuple passed to getComponentProps. 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.

Comment on lines +15 to 21
const handleDeleteItem = async (
item: TPL_ROW_FRAGMENT_NAME,
): Promise<void> => {
await TPL_DELETE_FUNCTION({
variables: { input: { id: item.id } },
});
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ 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.

Suggested change
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);
}
};

Comment on lines +12 to 13
order: z.number(),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ 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.

Suggested change
order: z.number(),
});
order: z.number().int().nonnegative(),
});

Comment on lines 131 to +138
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,
});

@coderabbitai coderabbitai Bot May 4, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ 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.

Suggested change
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,
});

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm relying on Typescript to guard against missing shouldGenerateMetadata since it's a required field.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

Comment on lines +119 to 123
if (missingVariableValue && shouldWriteMetadata) {
throw new Error(
`Template variable is empty: ${missingVariableValue}. All template variables must have a value when metadata is included.`,
);
}

@coderabbitai coderabbitai Bot May 4, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ 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.

Suggested change
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.`,
);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

Comment on lines +90 to 94
const formDataExpression = TsCodeUtils.importFragment(
formDataName,
`import { ${formDataName} } from '${editSchemaImport}';`,
editSchemaPath,
);

@coderabbitai coderabbitai Bot May 4, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Import paths can include .ts and the resolveModuleSpecifier will figure it out approrpiately

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

Comment on lines 79 to 81
providers: {
uploadComponents: {
getImportMap() {
return importMap;
},
},
uploadComponentsImports: createUploadComponentsImports('@/src'),
},

@coderabbitai coderabbitai Bot May 4, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
providers: {
uploadComponents: {
getImportMap() {
return importMap;
},
},
uploadComponentsImports: createUploadComponentsImports('@/src'),
},
providers: {
- uploadComponentsImports: createUploadComponentsImports('@/src'),
+ uploadComponentsImports: createUploadComponentsImports('@src'),
},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@/src is the correct format for create*imports. @src only occurs in the generated codebase

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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!

Comment on lines +108 to 112
typescriptFile.renderTemplateFile({
template: REACT_UPLOAD_COMPONENTS_TS_TEMPLATES.hooksUseUpload,
destination: hookPath,
}),
);

@coderabbitai coderabbitai Bot May 4, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ 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.

Suggested change
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,
},
}),
);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The importMapProviders is not necessary for certain templates (these are inferred from the template extractor which will automatically determine the necessary import map providers)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

Comment on lines +163 to +166
importMapProviders: {
reactComponentsImports,
},
}),

@coderabbitai coderabbitai Bot May 4, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
importMapProviders: {
reactComponentsImports,
},
}),
importMapProviders: {
reactComponentsImports,
reactErrorImports,
},
}),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The importMapProviders is not necessary for certain templates (these are inferred from the template extractor which will automatically determine the necessary import map providers)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0565133 and f1fcba3.

📒 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_IDENTIFIER with the isIdentifier: true flag 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 isIdentifier flag for the TPL_IDENTIFIER variable while omitting the value property. 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 getTextTemplateVariableRegExp when 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.

@kingston kingston merged commit fb88548 into main May 5, 2025
@kingston kingston deleted the kingston/eng-676-convert-admin-generators-to-use-new-ts-system branch May 5, 2025 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant