Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing imports with --v10 and --out #249

Closed
jrr opened this issue Apr 26, 2023 · 1 comment · Fixed by #251
Closed

Missing imports with --v10 and --out #249

jrr opened this issue Apr 26, 2023 · 1 comment · Fixed by #251

Comments

@jrr
Copy link

jrr commented Apr 26, 2023

Thanks for your work to support v10!

When using --v10 and generating multiple output files, the files don't seem to be importing from each other.

Using a command line like cf-content-types-generator --v10 contentful-export.json --out generated-output will produce output like this:

import type { ChainModifiers, Entry, EntryFieldTypes, EntrySkeletonType, LocaleCode } from "contentful";

export interface TypeArticleGroupFields {
    title?: EntryFieldTypes.Symbol;
    articles?: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<TypeArticleSkeleton>>;
}

(with a squiggle on the TypeArticleSkeleton type)

Here's a minimized contentful-export.json that reproduces the issue:

{
  "contentTypes": [
    {
      "sys": {
        "id": "article",
        "type": "ContentType"
      },
      "displayField": "title",
      "name": "Article",
      "description": "",
      "fields": [
        {
          "id": "title",
          "name": "Title",
          "type": "Symbol",
          "localized": true,
          "required": true,
          "validations": [
            {
              "unique": true
            }
          ],
          "disabled": false,
          "omitted": false
        },
        {
          "id": "introduction",
          "name": "Introduction",
          "type": "Text",
          "localized": true,
          "required": false,
          "validations": [],
          "disabled": false,
          "omitted": false
        }
      ]
    },
    {
      "sys": {
        "id": "articleGroup",
        "type": "ContentType"
      },
      "displayField": "title",
      "name": "ArticleGroup",
      "description": "",
      "fields": [
        {
          "id": "title",
          "name": "Title",
          "type": "Symbol",
          "localized": true,
          "required": false,
          "validations": [],
          "disabled": false,
          "omitted": false
        },
        {
          "id": "articles",
          "name": "Articles",
          "type": "Array",
          "localized": false,
          "required": false,
          "validations": [],
          "disabled": false,
          "omitted": false,
          "items": {
            "type": "Link",
            "validations": [
              {
                "linkContentType": ["article"]
              }
            ],
            "linkType": "Entry"
          }
        }
      ]
    }
  ],
  "locales": [
    {
      "name": "English",
      "code": "en",
      "fallbackCode": null,
      "default": true,
      "contentManagementApi": true,
      "contentDeliveryApi": true,
      "optional": false
    },
    {
      "name": "Spanish",
      "code": "es",
      "fallbackCode": null,
      "default": false,
      "contentManagementApi": true,
      "contentDeliveryApi": true,
      "optional": true
    }
  ]
}

A workaround for now is to avoid --out, and produce only a single file with e.g. cf-content-types-generator --v10 contentful-export.json >generated-output/contentful-types.ts.

@jrr
Copy link
Author

jrr commented Apr 26, 2023

Wow, that was fast! Thanks.

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 a pull request may close this issue.

1 participant