{"_id":"@aceandtate/contentful-ts-type-generator","_rev":"1-9bb8344e39ef11babbfaa7e6d7529bc0","name":"@aceandtate/contentful-ts-type-generator","dist-tags":{"latest":"0.6.0"},"versions":{"0.6.0":{"name":"@aceandtate/contentful-ts-type-generator","version":"0.6.0","private":false,"description":"Typescript type declaration file generator from Contentful models","main":"generateContentfulTypes.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/aceandtate/contentful-ts-type-generator.git"},"keywords":["contentful","typescript","definition"],"author":{"name":"Artur Rimkevitch"},"license":"MIT","bugs":{"url":"https://github.com/aceandtate/contentful-ts-type-generator/issues"},"homepage":"https://github.com/aceandtate/contentful-ts-type-generator#readme","dependencies":{"commander":"^2.20.3","contentful":"^7.14.0","rx":"^4.1.0"},"bin":{"generateContentfulTypes":"generateContentfulTypes.js"},"gitHead":"bd060911e3f568e8778fffb4fc368ea2605744a6","_id":"@aceandtate/contentful-ts-type-generator@0.6.0","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-ADeMSpFK4Fgiz4jYxCO4qfG2mBA9wxc9Q7aNuN3oNUtZnVPtZH4KTgYs51HcoarCBoBoPFw5Joe5iJbesdleyg==","shasum":"a183f8eb2c9beffc3de89f4b28c012f1274f9cdc","tarball":"https://registry.npmjs.org/@aceandtate/contentful-ts-type-generator/-/contentful-ts-type-generator-0.6.0.tgz","fileCount":4,"unpackedSize":9133,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8w03CRA9TVsSAnZWagAA420P/0oCv7NqkobzWGWnEo7k\ns+9NgoLl7xetX5zzTFvNi2Etu07UKeZPP1K7JtU1iGHQmAM7qirZdM4oXHkv\nIVnLWAQQ3iqWkxYz6Xq7gV2yO3sPKYtc7DVEeQNpcpmoNOrfzE2Z/sZKMMKA\nh1Zd82H4qDOiEES1k9PQWg8pPgNPLFzXh7eAXNQBjVPiWRFUdYuCialZRtkw\nzoGoVsG0bM9ck0z+Ew6Fg0ppMMxOXxgD+UEFaoFTXzxvVPFuHKhiYRvsV+Bi\nVVndbjOQPzT+2KvHUTtMcUngg77MNMOuCErQNrmqBytzPuPKwx+eurghwC6E\nWpFjJrxfCxJPJO5FRMRyANwVF90Gz8jYsT978IyaO8GDqcntMX+F98Nn8hM2\nqnJcJX+RxBnro5ur198d0MPFItqbm2xuRRCjkMJRM9PqPTgRo4/iYKFINQ5N\nEZOX411kh2w62tc55I+L0LMEX8EWQkuw/R7t/YRoYMOPEl0DJWXhZ3Yxx9ZQ\n4R8pMmNFstCsbC0UHfdPbbySYG7uq5qjyCewRt23fTVr98whHzxzjJyjTERs\n4hiH66gBrMgt7W/DOCYqfvwVcUgtdcPmsdlAgHkjzIgehG80IDGG7lv8FT4l\nFkLyw8YNAUfwNCfu1P5xebkACxBHsH+0Gx71Ey9kLV47SSP/PjC0qhw6xK57\nGBqZ\r\n=2sSZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICHs6QZHBFja3hNXYDkdAKL69nHxy3OIiAVDIarYKcUGAiBseodYwTh14lOzuocHjVwa0hQFENk+OazON6AWnv8eLA=="}]},"_npmUser":{"name":"reaktivo","email":"m@reaktivo.com"},"directories":{},"maintainers":[{"name":"sofie.andersen","email":"a.sofie.andersen@gmail.com"},{"name":"alexdudar","email":"alexandr.dudar@gmail.com"},{"name":"aceandtatedev","email":"development@aceandtate.com"},{"name":"reaktivo","email":"m@reaktivo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/contentful-ts-type-generator_0.6.0_1609764151294_0.5566975909285508"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-04T12:42:31.144Z","0.6.0":"2021-01-04T12:42:31.512Z","modified":"2022-04-04T11:10:22.361Z"},"maintainers":[{"name":"sofie.andersen","email":"a.sofie.andersen@gmail.com"},{"name":"alexdudar","email":"alexandr.dudar@gmail.com"},{"name":"aceandtatedev","email":"development@aceandtate.com"},{"name":"reaktivo","email":"m@reaktivo.com"}],"description":"Typescript type declaration file generator from Contentful models","homepage":"https://github.com/aceandtate/contentful-ts-type-generator#readme","keywords":["contentful","typescript","definition"],"repository":{"type":"git","url":"git+https://github.com/aceandtate/contentful-ts-type-generator.git"},"author":{"name":"Artur Rimkevitch"},"bugs":{"url":"https://github.com/aceandtate/contentful-ts-type-generator/issues"},"license":"MIT","readme":"## contentful-ts-type-generator\n\nNote: This is a fork of github.com/arimkevi/contentful-ts-type-generator\n\n## Usage\n\n1. Get preview api token and spaceId from Contentful. \n\n2. Install this repository into your node project\n\n```\nnpm install @aceandtate/contentful-ts-type-generator\n```\n\n3. Run the script to get help options\n```\nnpx generateContentfulTypes\n```\n\n4. Base usage\n\n```\nnpx generateContentfulTypes <SPACE_ID> <PREVIEW_API_TOKEN>\n```\n\nThis will generate contentfulTypes.d.ts file that will contain all of the space model as interfaces and inheritance. Export contains also model sys.id.\n\nIf you use the `generateContentfulTypes` command in your package.json scripts, you can leave out the `npx` in front of it.\n\n5. Options\n\n```\n  -o, --output <file>, Output file path. Default: './contentfulTypes.d.ts'\n  -e, --environment [value], Contentful environment id to use. Default: 'master'\n  -p, --prefix <value>, Name prefix for generated interfaces. Default: ''\n  -h, --host [value], Default: 'api.contentful.com'\n  -i, --ignore [value], Ignored field(s): a single field id or comma separated list of field ids. Default: ''\n```\n\n6. Once the types are generated you can use contentful.js calling the following function:\n\n```ts\n\nconst client = contentful.createClient({\n  host: 'contentfulHost',\n  accessToken: 'accessToken',\n  space: 'spaceId',\n  resolveLinks: true,\n})\n\nexport function getContent<T>(\n  contentfulLocale: string, contentType: string\n): Promise<contentful.Entry<T>> {\n  return client\n    .getEntries({ content_type: contentType, locale: contentfulLocale })\n    .then((response: contentful.EntryCollection<T>) => response.items[0])\n}\n\ngetContent<T>(locale, YourContentfulType)\n\n```\n","readmeFilename":"README.md"}