Skip to content

Allow to define the type of asset's meta_data #216

@angelikatyborska

Description

@angelikatyborska

This is a feature request 🙂

Currently, we're using the type generation with the option additionalProperties set to false so that our component types do not include any unknown properties. This has the consequence that the meta_data field on the Storyblok Asset type has this definition:

meta_data?: {};

It's an object without any known fields. With our strict TS config, trying to use any property on the meta_data field (e.g. blok.image.meta_data?.our_field) causes a type error.

However, Storyblok allows adding arbitrary custom fields to asset metadata. For example, in our project, we use the MAPI to set a boolean field above_the_fold: true on some assets. We would like to somehow be able to define that the meta_data field on assets in our project has the type:

meta_data?: {
  above_the_fold?: boolean
};

Additionally, there are default metadata fields that the CMS supports out of the box and allow setting via the UI (see screenshot below).

It would be nice if users of the CLI could specify the exact type of their asset meta_data when generating types.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature[Issue] New feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions