{"id":15101403,"url":"https://github.com/sbezludny/content-type-to-typescript","last_synced_at":"2025-10-08T08:32:27.666Z","repository":{"id":57114979,"uuid":"114863584","full_name":"sbezludny/content-type-to-typescript","owner":"sbezludny","description":"Converts Contentful Models to Typescript Definitions","archived":true,"fork":false,"pushed_at":"2018-01-31T11:12:45.000Z","size":90,"stargazers_count":7,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T03:23:47.350Z","etag":null,"topics":["cli","contentful","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbezludny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-20T08:40:01.000Z","updated_at":"2023-03-08T03:45:56.000Z","dependencies_parsed_at":"2022-08-22T04:31:26.674Z","dependency_job_id":null,"html_url":"https://github.com/sbezludny/content-type-to-typescript","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbezludny%2Fcontent-type-to-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbezludny%2Fcontent-type-to-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbezludny%2Fcontent-type-to-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbezludny%2Fcontent-type-to-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbezludny","download_url":"https://codeload.github.com/sbezludny/content-type-to-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235700110,"owners_count":19031668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","contentful","typescript"],"created_at":"2024-09-25T18:22:18.325Z","updated_at":"2025-10-08T08:32:22.355Z","avatar_url":"https://github.com/sbezludny.png","language":"TypeScript","funding_links":[],"categories":["typescript"],"sub_categories":[],"readme":"# Content-type-to-typescript\n\nThis is a tool to convert Contentful Models (Content Types) to the TS Definitions.\nProvides a way to automate TS Definitions generation. Could be used as a library or cli tool.\n\n[Try-it-out](https://content-type-to-typescript.netlify.com/)\n\n## Installation\n\n```\n$ npm install content-type-to-typescript --save\n```\n\n## Usage\n\n1. As CLI \n\n```\n$ ./node_modules/.bin/content-type-to-typescript --access-token \u003ctoken\u003e --space \u003cspace\u003e --output \u003cfilepath\u003e\n```\n\nThis command will generate TS Definition file. Could also be used as a npm script.\n\npackage.json:\n```json\n\"scripts\": {\n  \"sync-contentful-types\": \"content-type-to-typescript --access-token \u003ctoken\u003e --space \u003cspace\u003e --output \u003cfilepath\u003e\"\n}\n```\nUsage:\n\n```\nnpm run sync-contentful-types\n```\n\n2. As a library using JSON preview from Web App\n\nCopy JSON Preview from [Contentful Web App](https://app.contentful.com/)\n\n```js\nimport { compileFromContentTypes } from 'content-type-to-typescript';\n\nconst category = {\n    name: 'Category',\n    description: null,\n    fields: [\n      {\n        id: 'title',\n        name: 'Title',\n        type: 'Text',\n        required: true,\n        omitted: false,\n      },\n    ],\n  }\n\nconst typings = await compileFromContentTypes([category]);\n\nconsole.log(typings);\n```\n\n```ts\ncompileFromContentTypes(\n  contentTypes: Array\u003cPartial\u003cContentType\u003e\u003e,\n  options?: Partial\u003cOptions\u003e\n): Promise\u003cstring\u003e\n```\n\n### ContentType\n\nThe structure of the Content Type is described here [Contentful data model](https://www.contentful.com/developers/docs/concepts/data-model/).\n\n### Options\n\n| Property      | Type   | Required? | Description                          |\n| :------------ | :----- | :-------: | :----------------------------------- |\n| bannerComment | String |           | A comment at the top of the response |\n\n\n\n## Example\n\nInput:\n\n```json\n{\n  \"name\": \"Category\",\n  \"fields\": [\n    {\n      \"id\": \"title\",\n      \"name\": \"Title\",\n      \"type\": \"Text\",\n      \"required\": true,\n      \"omitted\": false\n    },\n    {\n      \"id\": \"icon\",\n      \"name\": \"Icon\",\n      \"type\": \"Link\",\n      \"required\": false,\n      \"omitted\": false,\n      \"linkType\": \"Asset\"\n    },\n    {\n      \"id\": \"categoryDescription\",\n      \"name\": \"Description\",\n      \"type\": \"Text\",\n      \"required\": false,\n      \"omitted\": false\n    },\n    {\n      \"id\": \"simpleTextField\",\n      \"name\": \"Simple text field\",\n      \"type\": \"Symbol\",\n      \"required\": false,\n      \"validations\": [],\n      \"disabled\": false,\n      \"omitted\": false\n    }\n  ]\n}\n```\n\nOutput:\n\n```ts\nexport interface Category {\n  title: string;\n  icon?: AssetLink;\n  categoryDescription?: string;\n  simpleTextField?: string;\n}\n\nexport interface AssetLink {\n  type: string;\n  linkType: string;\n  id: string;\n}\n```\n## Built with\n\n* [json-schema-to-typescript](https://github.com/bcherny/json-schema-to-typescript/)\n* [typescript-library-starter](https://github.com/alexjoverm/typescript-library-starter)\n\n## License\n\nMIT License - fork, modify and use however you want.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbezludny%2Fcontent-type-to-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbezludny%2Fcontent-type-to-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbezludny%2Fcontent-type-to-typescript/lists"}