Skip to content

feat(sync): pull models/blocks from CMS#30

Draft
Androlax2 wants to merge 109 commits into
betafrom
feat/dato-sync
Draft

feat(sync): pull models/blocks from CMS#30
Androlax2 wants to merge 109 commits into
betafrom
feat/dato-sync

Conversation

@Androlax2

@Androlax2 Androlax2 commented Jul 13, 2025

Copy link
Copy Markdown
Owner

Do some more tests with a lot of fields to see if all the options are correctly retrieved + everything is retrieved correctly

  • Make the CodeFormatter better, it's pretty bad looking now (the file being formatted)
  • Update the ImportGenerator so it put the correct import for a project that use dato-builder (should import from dato-builder)
  • The FileGenerator should call some sub Generator class for each fields, would be easier to work with
  • For all the fields that have options or things that come from the CMS (like .addSelect() etc..), the sync should create file and also a const with all possible values and a type from that const, and the options should use the const array so it can be changed, and the type will be updated too
  • Refactor all the FieldGenerators when everything is stable
  • Make the sync command be able to run in concurrent (We need only I/O to write file and content, so maybe we can calculate the number of concurrent in an auto mode and also provide a --concurrent, the auto mode can calculate based on the CPUs core but also as it's a I/O task, maybe we can spawn multiple processes)
  • Refactor the FieldGenerators to make it easier to use, check that all tests test the good things
  • Integration Tests
  • Unit tests
  • Update documentation

Androlax2 added 15 commits July 12, 2025 01:22
* feat(cli): introduce initial CLI structure with parsing and logging

- Add `CLI` class to bootstrap and execute commands with configuration loading.
- Implement `ConfigParser` for loading and validating configuration files.
- Include `ConsoleLogger` for customizable logging with multiple log levels.
- Enable robust config management with validation and error handling.

* refactor(api): use Client type directly in DatoApi class

- Replaced `ReturnType<typeof getDatoClient>` with `Client` type for better clarity and maintainability.
- Simplifies the constructor type definition without changing functionality.

* refactor(config): remove DatoCMS configuration and loader utilities

- Deleted `getDatoClient` and `loadDatoBuilderConfig` utilities along with supporting types and validation logic.
- Removed redundant client initialization and configuration loading for simplicity.
- Streamlines the codebase by eliminating unused DatoCMS-related code.

BREAKING CHANGE:
Removed `getDatoClient` and `loadDatoBuilderConfig`. Any code importing or calling those functions, or relying on their types/validation, will need to be updated or replaced.

* refactor(builder): simplify constructors and streamline configuration handling

- Unified constructor arguments into options objects (`BlockBuilderOptions`, `ModelBuilderOptions`, and `ItemTypeBuilderOptions`) for better readability and maintainability.
- Removed redundant `mergeConfig` method in favor of static default configuration merging.
- Replaced `client` usage with `api.client` in `ItemTypeBuilder` methods to improve clarity.
- Removed debug logging statements to reduce noise and emphasize essential information.
- Added `getContentHash` method as a replacement for `computeHash`.

BREAKING CHANGE:
Constructor signatures for `BlockBuilder`, `ModelBuilder`, and `ItemTypeBuilder` have changed to use object-based options. This may require updates to instantiations of these classes. Additionally, the `mergeConfig` method has been removed, and any client initialization outside `api.client` is outdated.

* refactor(builder): replace ItemTypeBuilderConfig with DatoBuilderConfig

- Removed `ItemTypeBuilderConfig` and consolidated configurations into `DatoBuilderConfig` for consistency.
- Updated `BlockBuilder`, `ModelBuilder`, and `ItemTypeBuilder` to use `DatoBuilderConfig` with `Required` for stricter type enforcement.
- Simplified configuration merging by removing static defaults in `ItemTypeBuilder`.

BREAKING CHANGE:
`ItemTypeBuilderConfig` has been removed and replaced with `DatoBuilderConfig`. Constructors for builders and methods using configuration now require updates to conform to the new type. Static defaults for configuration merging are no longer applied.

* refactor(config): streamline config loading with static defaults

- Moved static defaults to a `DEFAULTS` constant for improved clarity and maintainability.
- Consolidated `loadBaseConfig` and `loadConfig` into a single `loadConfig` method while integrating default values with user-provided configurations.
- Updated `DatoBuilderConfig` types to allow `null` values for `modelApiKeySuffix` and `blockApiKeySuffix`.
- Enhanced configuration validity checks to minimize redundant logic.

* refactor(cli,config): streamline config handling and CLI initialization

- Updated `CLI` class to accept a fully-loaded `Required<DatoBuilderConfig>` instead of relying on `ConfigParser` internally.
- Modified `ConfigParser` to return a `Required<DatoBuilderConfig>` type, enforcing stricter type safety.
- Consolidated CLI initialization logic with an async IIFE for more concise and maintainable setup.
- Improved error handling by adding a process exit on unhandled exceptions during CLI execution.
- Simplified `validateConfig` method by removing redundant async behavior and improving type usage for better clarity.

* refactor(cli): replace CLI class with RunCommand execution

- Removed the `CLI` class and replaced it with a more streamlined `RunCommand` implementation for better modularity and maintainability.
- Updated the CLI initialization to configure and execute `RunCommand` with necessary paths and logger.
- Adjusted the `WARN` log format in `ConsoleLogger` for cleaner output.
- Minor adjustments to `package-lock.json` due to dependency changes.

* refactor(commands): optimize discoverAllFiles with concurrent glob calls

- Replaced individual `glob` calls with `Promise.all` for concurrent file discovery, improving performance and clarity.
- Maintains existing functionality while enhancing the efficiency of file scanning.

* refactor(commands): remove unused code and improve type safety

- Removed unused `console.log` and commented-out code for better clarity and maintainability.
- Improved type safety by refining return type annotations and adding `ItemTypeBuilder` casts.
- Added `getBlockFiles` and `getModelFiles` utility methods to simplify file filtering.
- Optimized caching logic in `getOrCreateBlock` and `getOrCreateModel` to enhance readability and reduce redundancy.
- No functional changes; focuses strictly on code quality improvements.

* refactor(builder,commands): remove unused code and enhance clarity

- Removed unused `GenericDatoError`, redundant logging, and commented-out code to streamline `ItemTypeBuilder` methods.
- Refactored error handling in cache-related methods to replace log warnings with direct `Error` throwing for consistency.
- Simplified `acquireLock` and `releaseLock` by removing nested `try-catch` blocks.
- Replaced inline `DatoApiKey` type definitions with a new unified `DatoApiKeyOptions` interface for improved reusability.
- Migrated `DatoBuilderConfig` and `BuilderContext` to dedicated files under `src/types` for better organization.
- Updated `RunCommand` to use a centralized `getContext` method to construct the `BuilderContext` dynamically, reducing redundancy.

BREAKING CHANGE:
Improved type usage and configuration structure may require updates:
- `GenericDatoError` is no longer available.
- `DatoBuilderConfig` type was moved to `src/types/DatoBuilderConfig.ts`.
- Any direct usage of `config` fields now requires access through the `BuilderContext`.

* refactor(logger,validators,config): add log level handling and async item type resolution

- Introduced `getLogLevel` utility to map configuration log levels to `LogLevel` constants for consistent logger initialization.
- Enhanced `ConsoleLogger` usage across builders and commands by dynamically setting log levels.
- Updated `ItemItemTypeValidator` and `RichTextBlocksValidator` to support async resolution of `item_types`, enabling both static strings and promises.
- Improved `syncFields` in `ItemTypeBuilder` with detailed debug logs for creating, updating, and deleting fields.
- Added `logLevel` option to `DatoBuilderConfig` with default `info` level for better configurability.
- Adjusted `ConfigParser` to include `logLevel` in its default configuration.

* refactor(logger,itemTypeBuilder): enhance context-aware logging and field sync debug messages

- Added `LogContext` to `ConsoleLogger` for richer, context-aware log messages, including support for dynamic context propagation through `child` loggers.
- Introduced detailed debug logs in `ItemTypeBuilder` to improve tracking of field creation, updates, and deletions during the `syncFields` process.
- Added `debugJson` and `debugJsonCompact` methods to `ConsoleLogger` for formatted JSON debugging.
- Updated `getLogLevel` utility to support optional and null log levels.

* refactor(validators): add support for async validator results

- Updated `build` method to handle both synchronous and asynchronous validator results.
- Ensure `Promise`-based results are resolved and properly set in the final object.
- Improved type checks to account for undefined and asynchronous values.

* refactor(commands, itemTypeBuilder): add dependency analysis and topological sort

- Implemented `analyzeDependencies` to determine dependencies between blocks and models during build.
- Added `topologicalSort` to resolve dependencies and ensure correct build order.
- Enhanced `RunCommand` to handle dependency-aware builds with detailed logging.
- Updated `ItemTypeBuilder` to include cache clearing functionality for improved consistency.

* refactor(validators): simplify item_types handling and remove async resolution

- Updated `ItemItemTypeValidator` and `RichTextBlocksValidator` to directly accept `string[]` for `item_types`, removing support for `Promise` resolution.
- Simplified `build` methods in both validators by removing asynchronous processing logic.
- Adjusted `Validator` interface to reflect changes, making `build` exclusively synchronous.
- Streamlined `Validators` aggregation logic by ensuring all `build` results are direct objects without Promises, enhancing predictability and reducing complexity.

* refactor(config): update TypeScript target to es2015 in tsconfig.json

- Changed `target` in `tsconfig.json` from `es5` to `es2015` to enable modern JavaScript features.
- This update improves compatibility with newer tools and runtime environments.
* refactor(itemTypeBuilder): remove caching and lockfile logic

- Eliminated cache functionality, including methods for loading, saving, and clearing cache as well as lockfile-related operations.
- Simplified `create` and `update` methods by removing cache dependency and hash validation.
- Removed unused helper methods like `computeHash` and `getCache`.

BREAKING CHANGE:
The `ItemTypeBuilder` no longer supports caching or lockfile mechanisms. Any code relying on these features will need to be updated.

* refactor(itemTypeBuilder): remove pending operation logic

- Removed `pendingOperations` and associated methods (`cleanPendingOperations`, `waitForPendingOperation`, `handlePendingOperation`) due to redundancy and complexity.
- Simplified `create` and `update` methods by directly handling item type creation and updates without pending operation tracking.
- Eliminated `PendingOperation` interface and related constants for timeout handling.

BREAKING CHANGE:
`ItemTypeBuilder` no longer supports pending operation tracking. Any dependent workflows must adapt to the updated logic where operations are executed directly without in-flight tracking.

* feat(commands,cache): integrate ItemTypeCacheManager for block and model caching

- Added `ItemTypeCacheManager` to enable caching for blocks and models during build processes.
- Updated `RunCommand` to utilize `ItemTypeCacheManager` for efficient cache handling of block and model IDs.
- Refactored `getHash` method to replace `getContentHash` in `ItemTypeBuilder`.
- Adjusted CLI to initialize and pass the cache manager to `RunCommand`.
- Introduced `.dato-builder-cache` folder to store cache data.

BREAKING CHANGE:
Replaced in-memory caching logic in `RunCommand` with `ItemTypeCacheManager`. Any workflows or extensions relying on the previous cache implementation must adapt to the new cache model that utilizes persistent storage.

* feat(commands,cache): improve cache validation and logging in RunCommand

- Added logic to validate cache entries by comparing hashes during block and model builds.
- Ensured cached items with matching hashes are reused, reducing redundant builds.
- Introduced `builtFromCache` tracking to differentiate between cached and newly built items.
- Added detailed execution summary logs including success/failure counts, cache usage, and actual builds.
- Updated `ConfigParser` to use debug logging instead of info for configuration file loading.
- Enhanced logging for block/model cache usage to include hash comparison details, improving debugging clarity.

* refactor(cache): update import syntax to use `node:` prefix

- Replaced "fs" and "path" imports with "node:fs" and "node:path" for consistency with newer Node.js module resolution standards.
- Ensures clarity and modern compliance when referencing built-in Node.js modules.

* refactor(commands): split RunCommand into modular components

- Extracted `FileDiscoverer`, `DependencyAnalyzer`, `ItemBuilder`, and other logic into standalone classes to enhance separation of concerns.
- Improved code readability, reuse, and testability by modularizing functionality.
- Updated `RunCommand` to orchestrate these components for a more structured execution flow.
- Refactored dependency management and build execution to work with the new modular design.

* refactor(commands): enhance cache management and error handling in ItemBuilder

- Introduced `ItemBuildError` for consistent error reporting with additional context such as item type, name, and cause.
- Added caching mechanisms for loaded modules and computed hashes (`moduleCache` and `hashCache`) to reduce redundant computations and imports.
- Enhanced `tryUseCache` and `computeHash` methods to utilize the new caching logic and improve efficiency.
- Refactored `buildFromSource` to consolidate and validate builder loading, avoiding redundant hash calculations.
- Added new methods `loadModule`, `validateBuilderType`, and `clearCaches` for better modularity and maintainability.
- Improved logging around cache usage and cache invalidation, ensuring better debugging and clarity.

* feat(runCommand): add custom error type and suggestions for missing items

- Introduced `ItemNotFoundError` for more detailed error reporting, including item type, name, and available alternatives.
- Added `getAvailableItems` method to provide a list of valid items by type, combining cache and file map data.
- Implemented `findSimilarItems` and `buildItemNotFoundMessage` to suggest potential matches for misspelled item names and improve user feedback.
- Enhanced debugging with methods for cache clearing and retrieving debug info.
- Improves usability and diagnostics for missing block or model issues.

* feat(cli): add ListCommand to support listing blocks and models

- Introduced `ListCommand` to list blocks and models with format options (`table`, `json`, `simple`).
- Added filtering by type (`blocks`, `models`, `all`) and support for showing cached and stale items.
- Enhanced summary display with detailed counts of items, cached status, and stale items.
- Updated CLI to integrate `ListCommand` alongside build, debug, and clear cache functionalities.
- Improved code maintainability by modularizing CLI command logic.
* refactor(logger): extend functionality for richer logging options

- Added support for TRACE level and configurable options like colors, timestamps, context ordering, and JSON prettification.
- Updated `ConsoleLogger` methods to enhance format consistency, support customizable contexts, and improve debugging flexibility.
- Introduced new methods such as `trace`, `progress`, `banner`, `table`, `group`, and `time` for advanced logging capabilities.
- Improved `json` logging with structured formatting and level-specific color coding.
- Refactored CLI success and error messages to remove emojis for better log clarity.
- Enhanced caching functionality with additional hooks and initialization logic in `ItemBuilder`.

* feat(logger): enhance bold style for specific log levels

- Introduced `boldLevels` set to define log levels such as ERROR, WARN, INFO, and SUCCESS that require bold formatting.
- Updated `formatMessage` method to apply bold styling conditionally based on the log level.

* feat(config, logger): enhance log level handling and CLI options

- Introduced `logLevel` as a `LogLevel` enum in `DatoBuilderConfig`, improving type safety and ensuring consistency across logging configurations.
- Replaced string-based log levels in `ConsoleLogger` with enum-based validation for better runtime reliability.
- Removed redundant `getLogLevel` utility and migrated its functionality directly into the CLI setup logic.
- Updated CLI to allow log level overrides (`debug`, `verbose`, `quiet`) via command-line options for flexible runtime configurations.
- Added default paths (`blocksPath`, `modelsPath`) and enhanced configuration handling in `ConfigParser`.
- Streamlined `RunCommand`, `ListCommand`, and `BuildCommand` by passing the updated configuration directly, improving modularity and maintainability.

* feat(logger,utils,cli): integrate enhanced logging for traceability

- Added `ConsoleLogger` with `LogLevel` support in `errors`, `Validators`, and CLI commands (`build`, `list`, `debug`, `clearCache`) to improve logging and context handling.
- Replaced `console.log` and `console.error` with structured logging (`info`, `error`, `trace`) for better consistency and debugging clarity.
- Improved error messaging by appending technical details, resource definitions, and operation context in error handling logic.
- Integrated trace logs for critical operations like validator initialization, command executions, and CLI processes to enhance debugging.

* feat(logger,cache,commands): add detailed trace logging and refactor cache manager

- Integrated `traceJson` and additional structured logging across multiple components (e.g., `ExecutionSummary`, `BuildExecutor`, `DependencyAnalyzer`, `ItemBuilder`, etc.) to enhance traceability and debugging.
- Refactored `ItemTypeCacheManager` to `CacheManager` with streamlined methods and improved type consistency.
- Updated commands (`RunCommand`, `ListCommand`) to utilize enhanced logging methods for summaries, cache operations, and executions.
- Improved module, hash, and dependency caching logic with detailed validation logs.
- Enhanced logging in error handling contexts for cache misses, build failures, and validation issues.
- Simplified validation, execution, and build flow with modularized and instrumented components for improved maintainability.

* feat(logger,itemTypeBuilder): enhance trace logging and synchronization flow

- Added `traceJson` logging throughout `ItemTypeBuilder` to improve debugging and traceability during initialization, field management, and API operations.
- Integrated detailed context-aware logs for field creation, updates, deletions, and synchronization processes, including relevant metadata.
- Improved error handling with structured JSON logs for informative failure diagnostics.
- Removed unused `UniquenessError` import for cleaner code.

* feat(cli): add "clear-cache" command to manage cache operations

- Introduced `clear-cache` command in CLI to allow users to clear all caches programmatically.
- Integrated detailed logging to provide feedback during the cache clearing process.
- Enhanced error handling to capture and log issues during cache clearing, ensuring process reliability and user clarity.

* refactor(runCommand): remove ExecutionSummary and debug logic

- Deleted the `ExecutionSummary` class and associated logging methods to simplify and streamline the `RunCommand` implementation.
- Removed redundant debug-related functionality, including methods for gathering and logging debug information, in the `RunCommand` and CLI.
- Introduced a progress-enhanced `buildExecutorWithProgress` method for improved build tracking and user feedback.
- Updated `BuildResult` type definition to support flexible error typing, replacing `ExecutionSummary` JSON-based summary with inline progress reporting.
- Improved modularity by eliminating unused imports and dependencies in `RunCommand`.

BREAKING CHANGE:
All debug-related methods and the `ExecutionSummary` logic have been removed. This may impact workflows relying on detailed execution summaries or debug gathering functionalities.

* feat(config): set defaults for API key suffixes in ConfigParser

- Added default values for `modelApiKeySuffix` ("model") and `blockApiKeySuffix` ("block") in `ConfigParser` for improved consistency.
- Updated `DatoBuilderConfig` type with `@default` annotations for clarity and documentation purposes.

* refactor(run): enhance error handling and logging in build process

- Updated `RunCommand` to clear progress bar upon encountering errors, improving feedback clarity.
- Added `hasErrors` flag to track and manage error state during builds.
- Refined logging by replacing `errorJson` with `traceJson` in `ItemBuilder` to align with improved traceability standards.
- Suppressed progress output after the first error to prevent misleading visuals.
- Improved separation of progress updates and error handling logic for better maintainability.
- Introduced `skipReads` option to `CacheManager` to allow disabling cache reads.
- Updated `initialize`, `get`, `set`, and other cache methods to respect the `skipReads` flag, effectively bypassing cache operations when enabled.
- Enhanced CLI with `--no-cache` flag to control cache behavior during execution.
- Improved logging in `BuildExecutor` and `cli` to reflect cache usage-related options and behavior.
- Removed `ListCommand` and its integration within the CLI.
- Deleted associated logging, file discovery, and item filtering logic.
- Simplified CLI by removing unused `list` command handlers and redundant code in `RunCommand`.
- Enhanced `buildExecutor` in `RunCommand` to replace progress logic with concise logging for better consistency.
- Updated related types and dependencies to reflect the removal of `ListCommand`.
- Streamlined `CLI` initialization by removing the `list` command setup.

BREAKING CHANGE:
`ListCommand` has been fully removed, along with its options and summaries. Any workflows or CLI scripts relying on the `list` command need to be updated or replaced.
- Deleted a redundant and outdated TODO comment regarding cache persistence in `ItemBuilder`.
- Simplifies code readability with no functional changes.
- Removed `tsconfig-paths` and replaced it with `tsx` for improved TypeScript execution and compatibility.
- Added `get-tsconfig`, `resolve-pkg-maps`, and `esbuild` dependencies to the project.
- Integrated platform-specific optional dependencies under `esbuild` for better build flexibility and compatibility.
- Updated `package-lock.json` to reflect the addition and removal of dependencies.
… resolution

- Added support for resolving existing item types by name when no ID is provided.
- Enabled passing an optional `existingId` to the `update` method for direct item type updates.
- Improved error handling with detailed logs for missing item types by name.
- Introduced additional logging for update body preparation and API calls for enhanced traceability.
- Removed unused `NotFoundError` import for cleaner code.
…able concurrency levels

- Introduced `--concurrent`, `--concurrency`, and `--auto-concurrency` CLI options to manage build concurrency.
- Added logic to determine concurrency levels automatically based on CPU cores (`--auto-concurrency`).
- Updated `RunCommand` to execute builds sequentially or concurrently based on the concurrency options.
- Implemented a new `buildConcurrently` method to handle concurrent builds with dependency resolution.
- Improved logging to reflect progress, concurrency levels, and potential deadlock detection.
…detection

- Updated `buildConcurrently` to process all completed builds instead of waiting on the first one.
- Improved handling of rejected promises with detailed error logging.
- Enhanced safety checks to detect and log circular or missing dependencies more effectively.
- Refactored deadlock detection to include missing dependency details for better debugging.
- Streamlined progress logging and cleared `inProgress` map after processing builds.
- Introduced a new `DatoCmsSync` class to support syncing blocks and models from DatoCMS to local files.
- Added `sync` and `syncModelsPath`/`syncBlocksPath` configurations to `DatoBuilderConfig` for custom file generation paths.
- Enhanced CLI with `sync` command, supporting `--dry-run` and `--force` options for flexibility during sync operations.
- Updated `CLI` processing to integrate `DatoCmsSync` and handle confirmation prompts for destructive operations.
- Expanded README with detailed instructions for `sync` usage, including dry-run and force examples.
- Added `@inquirer/prompts` dependency for interactive prompts in the CLI.
@Androlax2 Androlax2 changed the base branch from main to refactor/dato-builder July 13, 2025 01:47
@Androlax2 Androlax2 changed the title feat/dato-sync feat(sync): pull models/blocks from CMS Jul 13, 2025
Androlax2 and others added 12 commits July 15, 2025 14:27
…rvice, BlockReferenceAnalyzer, BuilderConfigGenerator, and CodeFormatter
Updates test expectations to align with refactored FileGeneration architecture:
- FileGenerationService now uses single FieldGeneratorFactory instance
- FileGenerator function names changed from "Pascal..." to "buildPascal..." format
- Fixed mock configurations for consistent boolean parameter handling
- Updated constructor dependency expectations

All 699 tests now pass successfully.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add LinkFieldGenerator and LinksFieldGenerator for DatoCMS link fields
- Support both single links (addLink) and multiple links (addLinks) with proper appearance mapping
- Implement async function call generation (getModel/getBlock) for item type references
- Add itemTypeReferences pipeline through FieldGenerator, FieldMethodGenerator, and FileGenerator
- Enhance BlockReferenceAnalyzer with getUsedFunctions for granular async detection
- Update FunctionGenerator to accept UsedFunctions parameter for optimized BuilderContext
- Add comprehensive test coverage for all new components and updated signatures
- Ensure PascalCase conversion for item type names in generated calls
- Support complex validator handling with proper type safety

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add JsonFieldGenerator for plain JSON fields
- Add StringMultiSelectFieldGenerator for multi-select with options
- Add StringCheckboxGroupFieldGenerator for checkbox groups with options
- Update FieldGeneratorFactory with JSON field routing logic based on appearance.editor
- Add comprehensive test coverage for all three generators (22 tests)
- Update FieldGeneratorFactory tests with JSON field type mappings (46 tests total)
- Follow established NEW FIELD GENERATOR WORKFLOW from CLAUDE.md
- All generators handle validators, hints, default values, and options extraction
- Successfully verified with DatoCMS sync generating correct method calls

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…text field generators

- Add RichTextFieldGenerator for modular content fields
- Add SingleBlockFieldGenerator for single block selection
- Add StructuredTextFieldGenerator for rich content with blocks/links
- Update FieldGeneratorFactory with complete field type mappings
- Fix BlockReferenceAnalyzer validator key (single_block → single_block_blocks)
- Add comprehensive test coverage for all new generators

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix type casting in SingleBlockFieldGenerator
- Add missing fieldsets property to BlockReferenceAnalyzer test
- Add missing editor and addons properties to appearance objects in tests
- Add fieldsets to project-words.txt for spellcheck

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
… text tests

- Remove required validator tests from RichTextFieldGenerator (not supported)
- Replace required validator with length validator in TestStructuredText
- Fix test expectations to match actual field validator constraints

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ator

- Inline blocks validator passes item_types as-is without conversion
- Update StructuredTextFieldGenerator to handle inline blocks correctly
- Fix test expectations to match actual behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…validator

- Direct assignment instead of spread to preserve all required properties
- Ensure TypeScript type checking passes for inline blocks validator

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ment

- Add 'as any' cast to resolve TypeScript strictness issues
- Ensure proper type handling for inline blocks validator

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Androlax2 Androlax2 added the enhancement New feature or request label Jul 16, 2025
Androlax2 and others added 14 commits July 16, 2025 10:12
- Add logger parameter to DatoApi constructor and pass from all instantiation sites
- Log API call start/end with operation names and timing (DEBUG level)
- Log request data for create/update operations with full payload visibility
- Log response data with smart truncation for large arrays (shows count + sample)
- Log detailed error information including DatoCMS error structures
- Log retry attempts for transient errors
- Use existing ConsoleLogger from logger.ts instead of creating duplicate
- Integrate with CLI debug flag for conditional API logging visibility

This provides comprehensive API monitoring for debugging, performance analysis,
and understanding data flow between the application and DatoCMS API.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix FormatValidator to use .source property for regex pattern serialization
- Remove trailing commas from error messages for consistency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Deleted unused `ExhaustiveFieldConfigurationTesting` block generation code
- Simplifies the codebase by removing redundant logic
- No impact on functionality as the block was not in use
- Refactored multiple FieldGenerators to use common methods (`processLengthValidator`, `processFormatValidator`) for validator processing
- Replaced boolean `sanitized_html` with a structured object containing `sanitize_before_validation`
- Updated `custom_pattern` fields to use `RegExp` type instead of `string`
- Updated related test cases to reflect changes
- Upgraded TypeScript to `5.9.0-beta` in `package.json` and `package-lock.json`

This improves code maintainability by consolidating validation logic and updating types for better accuracy and clarity.
- Updated `jest.config.js`:
  - Added `testEnvironment: "node"` for consistency with Node.js testing
  - Configured `collectCoverageFrom` to exclude irrelevant files and directories
  - Enabled coverage reporting with `text`, `lcov`, and `html` formats
  - Adjusted test matching patterns for broader test detection
  - Included `clearMocks` and `restoreMocks` for better test isolation
  - Limited test workers to 50% for optimized performance on CI/CD
- Refined `.npmignore`:
  - Added additional patterns for excluding development, configuration, and build artifacts
  - Excluded coverage reports, build artifacts, IDE, and CI files

These changes streamline the development process, improve test configuration, and ensure unnecessary files are omitted from package publishing.
- Removed `nodemon` as a development dependency and replaced it with `tsc`'s watch mode in the `dev` and `build:watch` scripts
- Updated TypeScript version from `5.9.0-beta` to `5.6.3` for stability
- Removed unused or redundant packages (`chokidar`, `nodemon` dependencies, etc.) from `package-lock.json`
- Enhanced npm scripts:
  - Added `ci` and `clean` commands for streamlined CI process and cleanup tasks
  - Updated `lint` and `format` commands to use explicit `npx` calls for `@biomejs/biome`
  - Improved `test` commands with the `--passWithNoTests` flag for flexibility

These changes simplify the developer experience, reduce unneeded dependencies, and optimize the build/test workflow.
- Upgraded `target` to `es2020` and `lib` to `es2020` for modern JavaScript compatibility
- Added stricter compiler options:
  - `noImplicitReturns`, `noUnusedLocals`, `noUnusedParameters`, `exactOptionalPropertyTypes`, and more
  - Enhanced TypeScript incremental build settings with `incremental` and `tsBuildInfoFile`
- Enabled `removeComments` for cleaner output and disabled `sourceMap` generation

These changes improve type safety, alignment with modern standards, and build efficiency.
…andards

- Upgraded `target` to `es2020` and `lib` to include `es2020` for broader JavaScript support
- Added stricter compiler options like `noImplicitReturns`, `noUnusedLocals`, `exactOptionalPropertyTypes`, and more
- Enabled incremental compilation with `skipLibCheck`, `forceConsistentCasingInFileNames`, and `tsBuildInfoFile`
- Simplified `include` paths by removing unnecessary directories

Enhances developer experience with improved type safety and build performance.
- Updated `tsconfig.json` and `tsconfig.build.json`:
  - Disabled `exactOptionalPropertyTypes` and added new options: `noFallthroughCasesInSwitch`, `isolatedModules`, and `moduleResolution: "node"`
  - Expanded `include` paths to cover generated files
- Modified `ModelBuilder.ts` to explicitly use `override` keyword for class member override
- Refined `CodeFormatter.ts` to handle optional chaining in ESLint linting output

These changes improve type safety, ensure better configuration alignment, and enhance overall code readability.
…eScript settings

- Updated `tsconfig.json`:
  - Disabled `noPropertyAccessFromIndexSignature` for flexibility with index signatures.
  - Enhanced compatibility with isolated modules.
- Introduced `NumberFieldGenerator` as an abstract base class for `IntegerFieldGenerator` and future numeric generators, consolidating shared logic.
- Simplified `EmailFieldGenerator` and `BooleanFieldGenerator` by utilizing base class template methods for default configuration generation.
- Added caching logic to `FieldGeneratorFactory` for optimized generator retrieval, improving performance.
- Standardized and enhanced validator handling across fields by introducing more reusable methods (`processValidators` improvements).
- Modified tests to reflect changes in validation (`sanitized_html` now uses structured configuration).
- Added `FieldGeneratorError` for better error handling in field generation processes.

These changes improve code maintainability, extend base class reuse for field generators, and streamline TypeScript configuration.
- Changed `lefthook.yml` to set the `--diagnostic-level` flag to `error` for Biome checks, ensuring stricter code validation during pre-commit hooks.
…ndling

- Replaced `any` types with `Record<string, unknown>` for better type safety across FieldGenerators.
- Standardized usage of `this.addOptionalProperty` for optional property assignments.
- Added stricter type checks for validators, including `rich_text_blocks`, `structured_text_blocks`, `item_item_type`, and others.
- Improved handling of array-based properties like `item_types` using `Array.isArray` to ensure type safety.
- Refactored `extractAppearanceParameters` to include stricter definitions for nested fields.
- Updated related field-specific methods to support improved type safety and readability.

These changes improve the maintainability and overall type safety of the codebase without altering functionality.
Base automatically changed from refactor/dato-builder to beta July 22, 2025 00:20
Base automatically changed from beta to main July 24, 2025 21:04
@Androlax2 Androlax2 changed the base branch from main to beta July 24, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant