Skip to content

Conversation

@dipankarmaikap
Copy link
Collaborator

@dipankarmaikap dipankarmaikap commented Nov 7, 2025

This PR adds datasource type generation via the CLI.

  • If the user has already pulled datasources and any component fields are linked to a datasource, the CLI will now use the correct datasource type automatically.

  • If the user has no datasources pulled yet, the CLI will fall back to a string or number union for those fields.

  • It also introduces a general export type:

    // Example
    export type ContentType = Author | MyUniversalComponent | Page | Post

    This type represents a union of all universal and content type blocks, allowing users to access all possible content types without maintaining them manually.

Closes #190


Note

Adds datasource-based typing and a ContentType union to the CLI types generator, with optional datasource loading and component field mapping.

  • Types Generation (packages/cli/src/commands/types/generate):
    • Map internal datasource-backed fields to specific datasource types (arrays for options), using datasource_slug.
    • Generate type schemas for each datasource from entries and include them in compiled output.
    • Add ContentType union type of all root components.
    • Introduce getDatasourceTypeTitle helper and collect content type blocks during schema build.
  • CLI Command (index.ts):
    • Optionally load datasources via readDatasourcesFiles; merge with components before generating types.
  • Schema Types (packages/cli/src/types/schemas.ts):
    • Extend ComponentPropertySchema with datasource_slug.

Written by Cursor Bugbot for commit 296b4f1. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on December 1

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

title: 'ContentType',
type: 'string',
tsType: `${Array.from(contentTypeBloks).join(' | ')}`,
};
Copy link

Choose a reason for hiding this comment

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

Bug: Async race: empty ContentType from unawaited promises

The contentTypeSchema is created using contentTypeBloks before the async component mapping functions have executed. Since componentsSchema is an array of unawaited promises, the contentTypeBloks.add(type) calls at line 334 haven't run yet when contentTypeSchema reads from the set at line 395. This results in ContentType always being an empty string instead of a union of all content type components.

Fix in Cursor Fix in Web

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.

🐛 [Bug]: Storyblok CLI v4 does not support option --resolve-datasources anymore

1 participant