diff --git a/packages/gatsby-source-contentful/package.json b/packages/gatsby-source-contentful/package.json index 1104e1a07758c..07fa956ff22e1 100644 --- a/packages/gatsby-source-contentful/package.json +++ b/packages/gatsby-source-contentful/package.json @@ -16,7 +16,6 @@ "chalk": "^2.4.2", "contentful": "^7.14.6", "contentful-resolve-response": "^1.1.4", - "deep-map": "^1.5.0", "fs-extra": "^8.1.0", "gatsby-core-utils": "^1.3.14", "gatsby-plugin-sharp": "^2.6.24", diff --git a/packages/gatsby-source-contentful/src/__fixtures__/starter-blog-data.js b/packages/gatsby-source-contentful/src/__fixtures__/starter-blog-data.js index 805597d44cd1f..d094eaa401c73 100644 --- a/packages/gatsby-source-contentful/src/__fixtures__/starter-blog-data.js +++ b/packages/gatsby-source-contentful/src/__fixtures__/starter-blog-data.js @@ -1,72 +1,434 @@ -exports.initialSync = { - currentSyncData: { - entries: [ - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, +exports.initialSync = () => { + return { + currentSyncData: { + entries: [ + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c31TNnjHlfaGUoMOwU0M2og`, + type: `Entry`, + createdAt: `2020-06-03T14:17:32.667Z`, + updatedAt: `2020-06-03T14:17:32.667Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentType: { + sys: { + type: `Link`, + linkType: `ContentType`, + id: `blogPost`, + contentful_id: `blogPost`, + }, + }, + contentful_id: `31TNnjHlfaGUoMOwU0M2og`, + }, + fields: { + title: { "en-US": `Automate with webhooks` }, + slug: { "en-US": `automate-with-webhooks` }, + heroImage: { + "en-US": { + sys: { + type: `Link`, + linkType: `Asset`, + id: `c4shwYI3POEGkw0Eg6kcyaQ`, + contentful_id: `4shwYI3POEGkw0Eg6kcyaQ`, + }, + }, + }, + description: { + "en-US": `Webhooks notify you, another person or system when resources have changed by calling a given HTTP endpoint.`, }, + body: { + "en-US": `## What are webhooks?\n\nThe webhooks are used to notify you when content has been changed. Specify a URL, configure your webhook, and we will send an HTTP POST request whenever something happens to your content.\n\n## How do I configure a webhook?\n\nGo to Settings → Webhooks from the navigation bar at the top. From there, hit Add webhook, and you will be directed to your new webhook. Then choose a name, put in the information of your HTTP endpoint (URL and authentication), specify any custom headers and select the types of events that should trigger the webhook.\n\n## Why do I get an old version in the CDA?\n\nAs the delivery API is powered by a CDN network consisting of hundreds of servers distributed across continents, it takes some time (up to a few minutes) to reflect the changes to the published content. This must be taken into consideration when reacting to webhooks. In normal conditions, there could be a reasonable delay of 2 to 5 minutes.\n\nExtracted from the [Webhooks FAQ](https://www.contentful.com/faq/webhooks/ "Webhooks FAQ").`, + }, + author: { + "en-US": { + sys: { + type: `Link`, + linkType: `Entry`, + id: `c15jwOBqpxqSAOy2eOO4S0m`, + contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + }, + }, + }, + publishDate: { "en-US": `2017-05-12T00:00+02:00` }, + tags: { "en-US": [`javascript`] }, }, - id: `c31TNnjHlfaGUoMOwU0M2og`, - type: `Entry`, - createdAt: `2020-06-03T14:17:32.667Z`, - updatedAt: `2020-06-03T14:17:32.667Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, + }, + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c3K9b0esdy0q0yGqgW2g6Ke`, + type: `Entry`, + createdAt: `2020-06-03T14:17:32.289Z`, + updatedAt: `2020-06-03T14:17:32.289Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentType: { + sys: { + type: `Link`, + linkType: `ContentType`, + id: `blogPost`, + contentful_id: `blogPost`, + }, + }, + contentful_id: `3K9b0esdy0q0yGqgW2g6Ke`, + }, + fields: { + title: { "en-US": `Hello world` }, + slug: { "en-US": `hello-world` }, + heroImage: { + "en-US": { + sys: { + type: `Link`, + linkType: `Asset`, + id: `c6Od9v3wzLOysiMum0Wkmme`, + contentful_id: `6Od9v3wzLOysiMum0Wkmme`, + }, + }, + }, + description: { + "en-US": `Your very first content with Contentful, pulled in JSON format using the Content Delivery API.`, + }, + body: { + "en-US": `These is your very first content with Contentful, pulled in JSON format using the [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API"). Content and presentation are now decoupled, allowing you to focus your efforts in building the perfect app.\n\n## Your first steps\n\nBuilding with Contentful is easy. First take a moment to get [the basics of content modelling](https://www.contentful.com/r/knowledgebase/content-modelling-basics/ "the basics of content modelling"), which you can set up in the [Contentful Web app](https://app.contentful.com/ "Contentful Web app"). Once you get that, feel free to drop by the [Documentation](https://www.contentful.com/developers/docs/ "Documentation") to learn a bit more about how to build your app with Contentful, in particular the [API basics](https://www.contentful.com/developers/docs/concepts/apis/ "API basics") and each one of our four APIs, as shown below.\n\n### Content Delivery API\n\nThe [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API") (CDA), available at \`cdn.contentful.com\`, is a read-only API for delivering content from Contentful to apps, websites and other media. Content is delivered as JSON data, and images, videos and other media as files.\nThe API is available via a globally distributed content delivery network. The server closest to the user serves all content, both JSON and binary. This minimizes latency, which especially benefits mobile apps. Hosting content in multiple global data centers also greatly improves the availability of content.\n\n### Content Management API\n\nThe [Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/ "Content Management API") (CMA), available at \`api.contentful.com\`, is a read-write API for managing content. Unlike the Content Delivery API, the management API requires you to authenticate as a Contentful user. You could use the CMA for several use cases, such as:\n* Automatic imports from different CMSes like WordPress or Drupal.\n* Integration with other backend systems, such as an e-commerce shop.\n* Building custom editing experiences. We built the [Contentful Web app](https://app.contentful.com/ "Contentful Web app") on top of this API.\n\n### Preview API\n\nThe [Content Preview API](https://www.contentful.com/developers/docs/concepts/apis/#content-preview-api "Content Preview API"), available at \`preview.contentful.com\`, is a variant of the CDA for previewing your content before delivering it to your customers. You use the Content Preview API in combination with a "preview" deployment of your website (or a "preview" build of your mobile app) that allows content managers and authors to view their work in-context, as if it were published, using a "preview" access token as though it were delivered by the CDA.\n\n### Images API\n\nThe [Images API](https://www.contentful.com/developers/docs/concepts/apis/#images-api "Images API"), available at \`images.contentful.com\`, allows you to resize and crop images, change their background color and convert them to different formats. Using our API for these transformations lets you upload high-quality assets, deliver exactly what your app needs, and still get all the benefits of our caching CDN.`, + }, + author: { + "en-US": { + sys: { + type: `Link`, + linkType: `Entry`, + id: `c15jwOBqpxqSAOy2eOO4S0m`, + contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + }, + }, }, + publishDate: { "en-US": `2017-05-15T00:00+02:00` }, + tags: { "en-US": [`general`] }, }, - revision: 1, - contentType: { - sys: { - type: `Link`, - linkType: `ContentType`, - id: `blogPost`, - contentful_id: `blogPost`, + }, + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c2PtC9h1YqIA6kaUaIsWEQ0`, + type: `Entry`, + createdAt: `2020-06-03T14:17:31.852Z`, + updatedAt: `2020-06-03T14:17:31.852Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentType: { + sys: { + type: `Link`, + linkType: `ContentType`, + id: `blogPost`, + contentful_id: `blogPost`, + }, + }, + contentful_id: `2PtC9h1YqIA6kaUaIsWEQ0`, + }, + fields: { + title: { "en-US": `Static sites are great` }, + slug: { "en-US": `static-sites-are-great` }, + heroImage: { + "en-US": { + sys: { + type: `Link`, + linkType: `Asset`, + id: `c4NzwDSDlGECGIiokKomsyI`, + contentful_id: `4NzwDSDlGECGIiokKomsyI`, + }, + }, }, + description: { + "en-US": `Worry less about security, caching, and talking to the server. Static sites are the new thing.`, + }, + body: { + "en-US": `## The case for the static site generator\n\nMore and more developers are jumping on the "go static train", and rightfully so. Static pages are fast, lightweight, they scale well. They are more secure, and simple to maintain and they allow you to focus all your time and effort on the user interface. Often times, this dedication really shows.\n\nIt just so happens that static site generators are mostly loved by developers, but not by the average Joe. They do not offer WYSIWYG, previewing on demo sites may take an update cycle, they are often based on markdown text files, and they require some knowledge of modern day repositories.\n\nMoreover, when teams are collaborating, it can get complicated quickly. Has this article already been proof-read or reviewed? Is this input valid? Are user permissions available, e.g. for administering adding and removing team members? Can this article be published at a future date? How can a large repository of content be categorized, organized, and searched? All these requirements have previously been more or less solved within the admin area of your CMS. But of course with all the baggage that made you leave the appserver-app-database-in-one-big-blob stack in the first place.\n\n## Content APIs to the rescue\n\nAn alternative is decoupling the content management aspect from the system. And then replacing the maintenance prone server with a cloud based web service offering. Effectively, instead of your CMS of old, you move to a [Content Management as a Service (CMaaS)](https://www.contentful.com/r/knowledgebase/content-as-a-service/ "Content Management as a Service (CMaaS)") world, with a content API to deliver all your content. That way, you get the all the [benefits of content management features](http://www.digett.com/blog/01/16/2014/pairing-static-websites-cms "benefits of content management features") while still being able to embrace the static site generator mantra.\n\nIt so happens that Contentful is offering just that kind of content API. A service that\n\n* from the ground up has been designed to be fast, scalable, secure, and offer high uptime, so that you don’t have to worry about maintenance ever again.\n* offers a powerful editor and lots of flexibility in creating templates for your documents that your editors can reuse and combine, so that no developers resources are required in everyday writing and updating tasks.\n* separates content from presentation, so you can reuse your content repository for any device platform your heart desires. That way, you can COPE ("create once, publish everywhere").\n* offers webhooks that you can use to rebuild your static site in a fully automated fashion every time your content is modified.\n\nExtracted from the article [CMS-functionality for static site generators](https://www.contentful.com/r/knowledgebase/contentful-api-cms-static-site-generators/ "CMS-functionality for static site generators"). Read more about the [static site generators supported by Contentful](https://www.contentful.com/developers/docs/tools/staticsitegenerators/ "static site generators supported by Contentful").`, + }, + author: { + "en-US": { + sys: { + type: `Link`, + linkType: `Entry`, + id: `c15jwOBqpxqSAOy2eOO4S0m`, + contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + }, + }, + }, + publishDate: { "en-US": `2017-05-16T00:00+02:00` }, + tags: { "en-US": [`javascript`, `static-sites`] }, }, - contentful_id: `31TNnjHlfaGUoMOwU0M2og`, }, - fields: { - title: { "en-US": `Automate with webhooks` }, - slug: { "en-US": `automate-with-webhooks` }, - heroImage: { - "en-US": { + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c15jwOBqpxqSAOy2eOO4S0m`, + type: `Entry`, + createdAt: `2020-06-03T14:17:31.246Z`, + updatedAt: `2020-06-03T14:17:31.246Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentType: { sys: { type: `Link`, - linkType: `Asset`, - id: `c4shwYI3POEGkw0Eg6kcyaQ`, - contentful_id: `4shwYI3POEGkw0Eg6kcyaQ`, + linkType: `ContentType`, + id: `person`, + contentful_id: `person`, + }, + }, + contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + }, + fields: { + name: { "en-US": `John Doe` }, + title: { "en-US": `Web Developer` }, + company: { "en-US": `ACME` }, + shortBio: { + "en-US": `Research and recommendations for modern stack websites.`, + }, + email: { "en-US": `john@doe.com` }, + phone: { "en-US": `0176 / 1234567` }, + facebook: { "en-US": `johndoe` }, + twitter: { "en-US": `johndoe` }, + github: { "en-US": `johndoe` }, + image: { + "en-US": { + sys: { + type: `Link`, + linkType: `Asset`, + id: `c7orLdboQQowIUs22KAW4U`, + contentful_id: `7orLdboQQowIUs22KAW4U`, + }, }, }, }, - description: { - "en-US": `Webhooks notify you, another person or system when resources have changed by calling a given HTTP endpoint.`, + }, + ], + assets: [ + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c6Od9v3wzLOysiMum0Wkmme`, + type: `Asset`, + createdAt: `2020-06-03T14:17:27.525Z`, + updatedAt: `2020-06-03T14:17:27.525Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentful_id: `6Od9v3wzLOysiMum0Wkmme`, + }, + fields: { + title: { "en-US": `Woman with black hat` }, + description: { "en-US": `Woman wearing a black hat` }, + file: { + "en-US": { + url: `//images.ctfassets.net/uzfinxahlog0/6Od9v3wzLOysiMum0Wkmme/d261929fcaffdd2e676d450fc519decf/cameron-kirby-88711.jpg`, + details: { + size: 7316629, + image: { width: 3000, height: 2000 }, + }, + fileName: `cameron-kirby-88711.jpg`, + contentType: `image/jpeg`, + }, + }, }, - body: { - "en-US": `## What are webhooks?\n\nThe webhooks are used to notify you when content has been changed. Specify a URL, configure your webhook, and we will send an HTTP POST request whenever something happens to your content.\n\n## How do I configure a webhook?\n\nGo to Settings → Webhooks from the navigation bar at the top. From there, hit Add webhook, and you will be directed to your new webhook. Then choose a name, put in the information of your HTTP endpoint (URL and authentication), specify any custom headers and select the types of events that should trigger the webhook.\n\n## Why do I get an old version in the CDA?\n\nAs the delivery API is powered by a CDN network consisting of hundreds of servers distributed across continents, it takes some time (up to a few minutes) to reflect the changes to the published content. This must be taken into consideration when reacting to webhooks. In normal conditions, there could be a reasonable delay of 2 to 5 minutes.\n\nExtracted from the [Webhooks FAQ](https://www.contentful.com/faq/webhooks/ "Webhooks FAQ").`, + }, + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c4NzwDSDlGECGIiokKomsyI`, + type: `Asset`, + createdAt: `2020-06-03T14:17:27.247Z`, + updatedAt: `2020-06-03T14:17:27.247Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentful_id: `4NzwDSDlGECGIiokKomsyI`, + }, + fields: { + title: { "en-US": `City` }, + description: { "en-US": `City pictured from the sky` }, + file: { + "en-US": { + url: `//images.ctfassets.net/uzfinxahlog0/4NzwDSDlGECGIiokKomsyI/f763654f90472d84e928b653a6741c05/denys-nevozhai-100695.jpg`, + details: { + size: 15736986, + image: { width: 3992, height: 2992 }, + }, + fileName: `denys-nevozhai-100695.jpg`, + contentType: `image/jpeg`, + }, + }, }, - author: { - "en-US": { + }, + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c4shwYI3POEGkw0Eg6kcyaQ`, + type: `Asset`, + createdAt: `2020-06-03T14:17:26.971Z`, + updatedAt: `2020-06-03T14:17:26.971Z`, + environment: { sys: { + id: `master`, type: `Link`, - linkType: `Entry`, - id: `c15jwOBqpxqSAOy2eOO4S0m`, - contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentful_id: `4shwYI3POEGkw0Eg6kcyaQ`, + }, + fields: { + title: { "en-US": `Man in the fields` }, + description: { "en-US": `Tattooed man walking in a field` }, + file: { + "en-US": { + url: `//images.ctfassets.net/uzfinxahlog0/4shwYI3POEGkw0Eg6kcyaQ/48c44bb6ebb52013dd14addd25725a76/felix-russell-saw-112140.jpg`, + details: { + size: 4539181, + image: { width: 2500, height: 1667 }, + }, + fileName: `felix-russell-saw-112140.jpg`, + contentType: `image/jpeg`, }, }, }, - publishDate: { "en-US": `2017-05-12T00:00+02:00` }, - tags: { "en-US": [`javascript`] }, }, - }, + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c7orLdboQQowIUs22KAW4U`, + type: `Asset`, + createdAt: `2020-06-03T14:17:26.685Z`, + updatedAt: `2020-06-03T14:17:26.685Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentful_id: `7orLdboQQowIUs22KAW4U`, + }, + fields: { + title: { "en-US": `Sparkler` }, + description: { "en-US": `John with Sparkler` }, + file: { + "en-US": { + url: `//images.ctfassets.net/uzfinxahlog0/7orLdboQQowIUs22KAW4U/c0f07c92d9eb36b73c883681e639441c/matt-palmer-254999.jpg`, + details: { + size: 2293094, + image: { width: 3000, height: 2000 }, + }, + fileName: `matt-palmer-254999.jpg`, + contentType: `image/jpeg`, + }, + }, + }, + }, + ], + deletedEntries: [], + deletedAssets: [], + nextSyncToken: `FEnChMOBwr1Yw 4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw3CswoUY34WECLCh152KsOLQcKwH8Kfw4kOQcOlw6TCr8OmEcKiwrhBZ8KhwrLCrcOsA8KYAMOFwo1kBMOZwrHDgCbDllcXVA`, + }, + contentTypeItems: [ { sys: { space: { @@ -77,10 +439,10 @@ exports.initialSync = { contentful_id: `uzfinxahlog0`, }, }, - id: `c3K9b0esdy0q0yGqgW2g6Ke`, - type: `Entry`, - createdAt: `2020-06-03T14:17:32.289Z`, - updatedAt: `2020-06-03T14:17:32.289Z`, + id: `person`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:18.696Z`, + updatedAt: `2020-06-03T14:17:18.696Z`, environment: { sys: { id: `master`, @@ -90,48 +452,104 @@ exports.initialSync = { }, }, revision: 1, - contentType: { - sys: { - type: `Link`, - linkType: `ContentType`, - id: `blogPost`, - contentful_id: `blogPost`, - }, - }, - contentful_id: `3K9b0esdy0q0yGqgW2g6Ke`, - }, - fields: { - title: { "en-US": `Hello world` }, - slug: { "en-US": `hello-world` }, - heroImage: { - "en-US": { - sys: { - type: `Link`, - linkType: `Asset`, - id: `c6Od9v3wzLOysiMum0Wkmme`, - contentful_id: `6Od9v3wzLOysiMum0Wkmme`, - }, - }, - }, - description: { - "en-US": `Your very first content with Contentful, pulled in JSON format using the Content Delivery API.`, - }, - body: { - "en-US": `These is your very first content with Contentful, pulled in JSON format using the [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API"). Content and presentation are now decoupled, allowing you to focus your efforts in building the perfect app.\n\n## Your first steps\n\nBuilding with Contentful is easy. First take a moment to get [the basics of content modelling](https://www.contentful.com/r/knowledgebase/content-modelling-basics/ "the basics of content modelling"), which you can set up in the [Contentful Web app](https://app.contentful.com/ "Contentful Web app"). Once you get that, feel free to drop by the [Documentation](https://www.contentful.com/developers/docs/ "Documentation") to learn a bit more about how to build your app with Contentful, in particular the [API basics](https://www.contentful.com/developers/docs/concepts/apis/ "API basics") and each one of our four APIs, as shown below.\n\n### Content Delivery API\n\nThe [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API") (CDA), available at \`cdn.contentful.com\`, is a read-only API for delivering content from Contentful to apps, websites and other media. Content is delivered as JSON data, and images, videos and other media as files.\nThe API is available via a globally distributed content delivery network. The server closest to the user serves all content, both JSON and binary. This minimizes latency, which especially benefits mobile apps. Hosting content in multiple global data centers also greatly improves the availability of content.\n\n### Content Management API\n\nThe [Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/ "Content Management API") (CMA), available at \`api.contentful.com\`, is a read-write API for managing content. Unlike the Content Delivery API, the management API requires you to authenticate as a Contentful user. You could use the CMA for several use cases, such as:\n* Automatic imports from different CMSes like WordPress or Drupal.\n* Integration with other backend systems, such as an e-commerce shop.\n* Building custom editing experiences. We built the [Contentful Web app](https://app.contentful.com/ "Contentful Web app") on top of this API.\n\n### Preview API\n\nThe [Content Preview API](https://www.contentful.com/developers/docs/concepts/apis/#content-preview-api "Content Preview API"), available at \`preview.contentful.com\`, is a variant of the CDA for previewing your content before delivering it to your customers. You use the Content Preview API in combination with a "preview" deployment of your website (or a "preview" build of your mobile app) that allows content managers and authors to view their work in-context, as if it were published, using a "preview" access token as though it were delivered by the CDA.\n\n### Images API\n\nThe [Images API](https://www.contentful.com/developers/docs/concepts/apis/#images-api "Images API"), available at \`images.contentful.com\`, allows you to resize and crop images, change their background color and convert them to different formats. Using our API for these transformations lets you upload high-quality assets, deliver exactly what your app needs, and still get all the benefits of our caching CDN.`, - }, - author: { - "en-US": { - sys: { - type: `Link`, - linkType: `Entry`, - id: `c15jwOBqpxqSAOy2eOO4S0m`, - contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, - }, - }, + contentful_id: `person`, + }, + displayField: `name`, + name: `Person`, + description: ``, + fields: [ + { + id: `name`, + name: `Name`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `company`, + name: `Company`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `shortBio`, + name: `Short Bio`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `email`, + name: `Email`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `phone`, + name: `Phone`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `facebook`, + name: `Facebook`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `twitter`, + name: `Twitter`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `github`, + name: `Github`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `image`, + name: `Image`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Asset`, }, - publishDate: { "en-US": `2017-05-15T00:00+02:00` }, - tags: { "en-US": [`general`] }, - }, + ], }, { sys: { @@ -143,10 +561,10 @@ exports.initialSync = { contentful_id: `uzfinxahlog0`, }, }, - id: `c2PtC9h1YqIA6kaUaIsWEQ0`, - type: `Entry`, - createdAt: `2020-06-03T14:17:31.852Z`, - updatedAt: `2020-06-03T14:17:31.852Z`, + id: `blogPost`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:19.068Z`, + updatedAt: `2020-06-03T14:17:19.068Z`, environment: { sys: { id: `master`, @@ -156,49 +574,254 @@ exports.initialSync = { }, }, revision: 1, - contentType: { - sys: { - type: `Link`, - linkType: `ContentType`, - id: `blogPost`, - contentful_id: `blogPost`, + contentful_id: `blogPost`, + }, + displayField: `title`, + name: `Blog Post`, + description: ``, + fields: [ + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `slug`, + name: `Slug`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `heroImage`, + name: `Hero Image`, + type: `Link`, + localized: false, + required: true, + disabled: false, + omitted: false, + linkType: `Asset`, + }, + { + id: `description`, + name: `Description`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `body`, + name: `Body`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `author`, + name: `Author`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Entry`, + }, + { + id: `publishDate`, + name: `Publish Date`, + type: `Date`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `tags`, + name: `Tags`, + type: `Array`, + localized: false, + required: false, + disabled: false, + omitted: false, + items: { + type: `Symbol`, + validations: [{ in: [`general`, `javascript`, `static-sites`] }], }, }, - contentful_id: `2PtC9h1YqIA6kaUaIsWEQ0`, + ], + }, + ], + defaultLocale: `en-US`, + locales: [ + { + code: `en-US`, + name: `English (United States)`, + default: true, + fallbackCode: null, + sys: { + id: `1uSElBQA68GRKF30tpTxxT`, + type: `Locale`, + version: 1, + }, + }, + { + code: `nl`, + name: `Dutch`, + default: false, + fallbackCode: `en-US`, + sys: { + id: `2T7M2OzIrvE8cOCOF1HMuY`, + type: `Locale`, + version: 1, + }, + }, + ], + space: { + sys: { type: `Space`, id: `uzfinxahlog0` }, + name: `Starter Gatsby Blog`, + locales: [ + { + code: `en-US`, + default: true, + name: `English (United States)`, + fallbackCode: null, + }, + { + code: `nl`, + default: false, + name: `Dutch`, + fallbackCode: `en-US`, }, - fields: { - title: { "en-US": `Static sites are great` }, - slug: { "en-US": `static-sites-are-great` }, - heroImage: { - "en-US": { + ], + }, + } +} + +exports.createBlogPost = () => { + return { + currentSyncData: { + entries: [ + { + sys: { + space: { sys: { type: `Link`, - linkType: `Asset`, - id: `c4NzwDSDlGECGIiokKomsyI`, - contentful_id: `4NzwDSDlGECGIiokKomsyI`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, }, }, + id: `c1dHS3UzOqupJZY7AyeDc6s`, + type: `Entry`, + createdAt: `2020-06-03T14:22:37.720Z`, + updatedAt: `2020-06-03T14:22:37.720Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentType: { + sys: { + type: `Link`, + linkType: `ContentType`, + id: `blogPost`, + contentful_id: `blogPost`, + }, + }, + contentful_id: `1dHS3UzOqupJZY7AyeDc6s`, + }, + fields: { + title: { "en-US": `Integration tests` }, + slug: { "en-US": `integration-tests` }, + heroImage: { + "en-US": { + sys: { + type: `Link`, + linkType: `Asset`, + id: `c1aaRo2sQbdfWnG8iNvnkH3`, + contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, + }, + }, + }, + description: { + "en-US": `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris et nisl eget dolor consequat vulputate. Duis a turpis sit amet turpis tincidunt imperdiet eget ac magna. Vestibulum aliquam id nisi nec consequat. Maecenas imperdiet sem ut pharetra vehicula. Fusce tristique luctus ex a porttitor. Duis blandit rutrum dui eu finibus. Etiam consequat nec tellus ut lacinia. Morbi a tempor purus. Donec sit amet consequat augue, nec interdum nulla. Vivamus urna sapien, luctus eget lectus non, malesuada dapibus purus. Nulla cursus commodo nunc. Mauris sapien est, pharetra vel fermentum in, pulvinar ut magna. Nunc sapien justo, sollicitudin ac tortor vel, tristique dictum quam.`, + }, + body: { + "en-US": `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris et nisl eget dolor consequat vulputate. Duis a turpis sit amet turpis tincidunt imperdiet eget ac magna. Vestibulum aliquam id nisi nec consequat. Maecenas imperdiet sem ut pharetra vehicula. Fusce tristique luctus ex a porttitor. Duis blandit rutrum dui eu finibus. Etiam consequat nec tellus ut lacinia. Morbi a tempor purus. Donec sit amet consequat augue, nec interdum nulla. Vivamus urna sapien, luctus eget lectus non, malesuada dapibus purus. Nulla cursus commodo nunc. Mauris sapien est, pharetra vel fermentum in, pulvinar ut magna. Nunc sapien justo, sollicitudin ac tortor vel, tristique dictum quam.\n\nEtiam a imperdiet massa, sit amet sodales arcu. In risus ex, venenatis vitae vestibulum at, cursus sed urna. Phasellus cursus finibus suscipit. Fusce scelerisque felis commodo nulla vehicula faucibus. Nullam magna mi, fermentum sed mauris at, condimentum sagittis risus. Maecenas rutrum condimentum nisl. Pellentesque ut tortor tortor. In venenatis congue justo, id condimentum leo. Maecenas sed accumsan magna, ac condimentum dui. Aliquam a dapibus turpis. Etiam laoreet vel dui eget ultricies. Proin nec elit odio.`, + }, + author: { + "en-US": { + sys: { + type: `Link`, + linkType: `Entry`, + id: `c15jwOBqpxqSAOy2eOO4S0m`, + contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + }, + }, + }, + publishDate: { "en-US": `2020-04-01T00:00+02:00` }, }, - description: { - "en-US": `Worry less about security, caching, and talking to the server. Static sites are the new thing.`, - }, - body: { - "en-US": `## The case for the static site generator\n\nMore and more developers are jumping on the "go static train", and rightfully so. Static pages are fast, lightweight, they scale well. They are more secure, and simple to maintain and they allow you to focus all your time and effort on the user interface. Often times, this dedication really shows.\n\nIt just so happens that static site generators are mostly loved by developers, but not by the average Joe. They do not offer WYSIWYG, previewing on demo sites may take an update cycle, they are often based on markdown text files, and they require some knowledge of modern day repositories.\n\nMoreover, when teams are collaborating, it can get complicated quickly. Has this article already been proof-read or reviewed? Is this input valid? Are user permissions available, e.g. for administering adding and removing team members? Can this article be published at a future date? How can a large repository of content be categorized, organized, and searched? All these requirements have previously been more or less solved within the admin area of your CMS. But of course with all the baggage that made you leave the appserver-app-database-in-one-big-blob stack in the first place.\n\n## Content APIs to the rescue\n\nAn alternative is decoupling the content management aspect from the system. And then replacing the maintenance prone server with a cloud based web service offering. Effectively, instead of your CMS of old, you move to a [Content Management as a Service (CMaaS)](https://www.contentful.com/r/knowledgebase/content-as-a-service/ "Content Management as a Service (CMaaS)") world, with a content API to deliver all your content. That way, you get the all the [benefits of content management features](http://www.digett.com/blog/01/16/2014/pairing-static-websites-cms "benefits of content management features") while still being able to embrace the static site generator mantra.\n\nIt so happens that Contentful is offering just that kind of content API. A service that\n\n* from the ground up has been designed to be fast, scalable, secure, and offer high uptime, so that you don’t have to worry about maintenance ever again.\n* offers a powerful editor and lots of flexibility in creating templates for your documents that your editors can reuse and combine, so that no developers resources are required in everyday writing and updating tasks.\n* separates content from presentation, so you can reuse your content repository for any device platform your heart desires. That way, you can COPE ("create once, publish everywhere").\n* offers webhooks that you can use to rebuild your static site in a fully automated fashion every time your content is modified.\n\nExtracted from the article [CMS-functionality for static site generators](https://www.contentful.com/r/knowledgebase/contentful-api-cms-static-site-generators/ "CMS-functionality for static site generators"). Read more about the [static site generators supported by Contentful](https://www.contentful.com/developers/docs/tools/staticsitegenerators/ "static site generators supported by Contentful").`, - }, - author: { - "en-US": { + }, + ], + assets: [ + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + id: `c1aaRo2sQbdfWnG8iNvnkH3`, + type: `Asset`, + createdAt: `2020-06-03T14:22:35.102Z`, + updatedAt: `2020-06-03T14:22:35.102Z`, + environment: { sys: { + id: `master`, type: `Link`, - linkType: `Entry`, - id: `c15jwOBqpxqSAOy2eOO4S0m`, - contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 1, + contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, + }, + fields: { + title: { "en-US": `Dummy image` }, + description: { "en-US": `Just a dummy image` }, + file: { + "en-US": { + url: `//images.ctfassets.net/uzfinxahlog0/1aaRo2sQbdfWnG8iNvnkH3/4b70303a3989c92bdc09870a00d294a8/Gatsby_Monogram.png`, + details: { size: 77907, image: { width: 2000, height: 2000 } }, + fileName: `Gatsby_Monogram.png`, + contentType: `image/png`, }, }, }, - publishDate: { "en-US": `2017-05-16T00:00+02:00` }, - tags: { "en-US": [`javascript`, `static-sites`] }, }, - }, + ], + deletedEntries: [], + deletedAssets: [], + nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw0YQMOfwrtZBsOQw41ww7xhJj8Ew4TChcOow6ZPPVVZaMOfOlFEwp7CpcOxwpd_YcKBw5jCkznDgMO6w4lsw73CrcOmwpILwqTClg`, + }, + contentTypeItems: [ { sys: { space: { @@ -209,10 +832,10 @@ exports.initialSync = { contentful_id: `uzfinxahlog0`, }, }, - id: `c15jwOBqpxqSAOy2eOO4S0m`, - type: `Entry`, - createdAt: `2020-06-03T14:17:31.246Z`, - updatedAt: `2020-06-03T14:17:31.246Z`, + id: `person`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:18.696Z`, + updatedAt: `2020-06-03T14:17:18.696Z`, environment: { sys: { id: `master`, @@ -222,42 +845,105 @@ exports.initialSync = { }, }, revision: 1, - contentType: { - sys: { - type: `Link`, - linkType: `ContentType`, - id: `person`, - contentful_id: `person`, - }, - }, - contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, - }, - fields: { - name: { "en-US": `John Doe` }, - title: { "en-US": `Web Developer` }, - company: { "en-US": `ACME` }, - shortBio: { - "en-US": `Research and recommendations for modern stack websites.`, - }, - email: { "en-US": `john@doe.com` }, - phone: { "en-US": `0176 / 1234567` }, - facebook: { "en-US": `johndoe` }, - twitter: { "en-US": `johndoe` }, - github: { "en-US": `johndoe` }, - image: { - "en-US": { - sys: { - type: `Link`, - linkType: `Asset`, - id: `c7orLdboQQowIUs22KAW4U`, - contentful_id: `7orLdboQQowIUs22KAW4U`, - }, - }, + contentful_id: `person`, + }, + displayField: `name`, + name: `Person`, + description: ``, + fields: [ + { + id: `name`, + name: `Name`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `company`, + name: `Company`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `shortBio`, + name: `Short Bio`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `email`, + name: `Email`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `phone`, + name: `Phone`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `facebook`, + name: `Facebook`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `twitter`, + name: `Twitter`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `github`, + name: `Github`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `image`, + name: `Image`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Asset`, }, - }, + ], }, - ], - assets: [ { sys: { space: { @@ -268,10 +954,10 @@ exports.initialSync = { contentful_id: `uzfinxahlog0`, }, }, - id: `c6Od9v3wzLOysiMum0Wkmme`, - type: `Asset`, - createdAt: `2020-06-03T14:17:27.525Z`, - updatedAt: `2020-06-03T14:17:27.525Z`, + id: `blogPost`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:19.068Z`, + updatedAt: `2020-06-03T14:17:19.068Z`, environment: { sys: { id: `master`, @@ -281,59 +967,215 @@ exports.initialSync = { }, }, revision: 1, - contentful_id: `6Od9v3wzLOysiMum0Wkmme`, - }, - fields: { - title: { "en-US": `Woman with black hat` }, - description: { "en-US": `Woman wearing a black hat` }, - file: { - "en-US": { - url: `//images.ctfassets.net/uzfinxahlog0/6Od9v3wzLOysiMum0Wkmme/d261929fcaffdd2e676d450fc519decf/cameron-kirby-88711.jpg`, - details: { size: 7316629, image: { width: 3000, height: 2000 } }, - fileName: `cameron-kirby-88711.jpg`, - contentType: `image/jpeg`, - }, - }, - }, + contentful_id: `blogPost`, + }, + displayField: `title`, + name: `Blog Post`, + description: ``, + fields: [ + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `slug`, + name: `Slug`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `heroImage`, + name: `Hero Image`, + type: `Link`, + localized: false, + required: true, + disabled: false, + omitted: false, + linkType: `Asset`, + }, + { + id: `description`, + name: `Description`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `body`, + name: `Body`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `author`, + name: `Author`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Entry`, + }, + { + id: `publishDate`, + name: `Publish Date`, + type: `Date`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `tags`, + name: `Tags`, + type: `Array`, + localized: false, + required: false, + disabled: false, + omitted: false, + items: { + type: `Symbol`, + validations: [{ in: [`general`, `javascript`, `static-sites`] }], + }, + }, + ], }, + ], + defaultLocale: `en-US`, + locales: [ { + code: `en-US`, + name: `English (United States)`, + default: true, + fallbackCode: null, sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, + id: `1uSElBQA68GRKF30tpTxxT`, + type: `Locale`, + version: 1, + }, + }, + { + code: `nl`, + name: `Dutch`, + default: false, + fallbackCode: `en-US`, + sys: { + id: `2T7M2OzIrvE8cOCOF1HMuY`, + type: `Locale`, + version: 1, + }, + }, + ], + space: { + sys: { type: `Space`, id: `uzfinxahlog0` }, + name: `Starter Gatsby Blog`, + locales: [ + { + code: `en-US`, + default: true, + name: `English (United States)`, + fallbackCode: null, + }, + { + code: `nl`, + default: false, + name: `Dutch`, + fallbackCode: `en-US`, + }, + ], + }, + } +} + +exports.updateBlogPost = () => { + return { + currentSyncData: { + entries: [ + { + sys: { + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, }, - }, - id: `c4NzwDSDlGECGIiokKomsyI`, - type: `Asset`, - createdAt: `2020-06-03T14:17:27.247Z`, - updatedAt: `2020-06-03T14:17:27.247Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, + id: `c1dHS3UzOqupJZY7AyeDc6s`, + type: `Entry`, + createdAt: `2020-06-03T14:22:37.720Z`, + updatedAt: `2020-06-03T14:27:24.359Z`, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, }, - }, - revision: 1, - contentful_id: `4NzwDSDlGECGIiokKomsyI`, - }, - fields: { - title: { "en-US": `City` }, - description: { "en-US": `City pictured from the sky` }, - file: { - "en-US": { - url: `//images.ctfassets.net/uzfinxahlog0/4NzwDSDlGECGIiokKomsyI/f763654f90472d84e928b653a6741c05/denys-nevozhai-100695.jpg`, - details: { size: 15736986, image: { width: 3992, height: 2992 } }, - fileName: `denys-nevozhai-100695.jpg`, - contentType: `image/jpeg`, + revision: 2, + contentType: { + sys: { + type: `Link`, + linkType: `ContentType`, + id: `blogPost`, + contentful_id: `blogPost`, + }, + }, + contentful_id: `1dHS3UzOqupJZY7AyeDc6s`, + }, + fields: { + title: { "en-US": `Hello world 1234` }, + slug: { "en-US": `hello-world-1234` }, + heroImage: { + "en-US": { + sys: { + type: `Link`, + linkType: `Asset`, + id: `c1aaRo2sQbdfWnG8iNvnkH3`, + contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, + }, + }, + }, + description: { + "en-US": `Your very first content with Contentful, pulled in JSON format using the Content Delivery API.`, + }, + body: { + "en-US": `These is your very first content with Contentful, pulled in JSON format using the [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API"). Content and presentation are now decoupled, allowing you to focus your efforts in building the perfect app.\n\n## Your first steps\n\nBuilding with Contentful is easy. First take a moment to get [the basics of content modelling](https://www.contentful.com/r/knowledgebase/content-modelling-basics/ "the basics of content modelling"), which you can set up in the [Contentful Web app](https://app.contentful.com/ "Contentful Web app"). Once you get that, feel free to drop by the [Documentation](https://www.contentful.com/developers/docs/ "Documentation") to learn a bit more about how to build your app with Contentful, in particular the [API basics](https://www.contentful.com/developers/docs/concepts/apis/ "API basics") and each one of our four APIs, as shown below.\n\n### Content Delivery API\n\nThe [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API") (CDA), available at \\\`cdn.contentful.com\\\`, is a read-only API for delivering content from Contentful to apps, websites and other media. Content is delivered as JSON data, and images, videos and other media as files.\nThe API is available via a globally distributed content delivery network. The server closest to the user serves all content, both JSON and binary. This minimizes latency, which especially benefits mobile apps. Hosting content in multiple global data centers also greatly improves the availability of content.\n\n### Content Management API\n\nThe [Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/ "Content Management API") (CMA), available at \\\`api.contentful.com\\\`, is a read-write API for managing content. Unlike the Content Delivery API, the management API requires you to authenticate as a Contentful user. You could use the CMA for several use cases, such as:\n* Automatic imports from different CMSes like WordPress or Drupal.\n* Integration with other backend systems, such as an e-commerce shop.\n* Building custom editing experiences. We built the [Contentful Web app](https://app.contentful.com/ "Contentful Web app") on top of this API.\n\n### Preview API\n\nThe [Content Preview API](https://www.contentful.com/developers/docs/concepts/apis/#content-preview-api "Content Preview API"), available at \\\`preview.contentful.com\\\`, is a variant of the CDA for previewing your content before delivering it to your customers. You use the Content Preview API in combination with a "preview" deployment of your website (or a "preview" build of your mobile app) that allows content managers and authors to view their work in-context, as if it were published, using a "preview" access token as though it were delivered by the CDA.\n\n### Images API\n\nThe [Images API](https://www.contentful.com/developers/docs/concepts/apis/#images-api "Images API"), available at \\\`images.contentful.com\\\`, allows you to resize and crop images, change their background color and convert them to different formats. Using our API for these transformations lets you upload high-quality assets, deliver exactly what your app needs, and still get all the benefits of our caching CDN.`, + }, + author: { + "en-US": { + sys: { + type: `Link`, + linkType: `Entry`, + id: `c15jwOBqpxqSAOy2eOO4S0m`, + contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + }, + }, }, + publishDate: { "en-US": `2020-05-15T00:00+02:00` }, }, }, - }, + ], + assets: [], + deletedEntries: [], + deletedAssets: [], + nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw0OwpjDkMOywrZewqlOAMK_wp_DmcOzLRXDmlJ3wp5VextfJMKtw43CngvCrw7Cn07CgnNJw4XDscOsw5zCuXbDrMKnw7rCsTPCpxE`, + }, + contentTypeItems: [ { sys: { space: { @@ -344,10 +1186,10 @@ exports.initialSync = { contentful_id: `uzfinxahlog0`, }, }, - id: `c4shwYI3POEGkw0Eg6kcyaQ`, - type: `Asset`, - createdAt: `2020-06-03T14:17:26.971Z`, - updatedAt: `2020-06-03T14:17:26.971Z`, + id: `person`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:18.696Z`, + updatedAt: `2020-06-03T14:17:18.696Z`, environment: { sys: { id: `master`, @@ -357,20 +1199,104 @@ exports.initialSync = { }, }, revision: 1, - contentful_id: `4shwYI3POEGkw0Eg6kcyaQ`, - }, - fields: { - title: { "en-US": `Man in the fields` }, - description: { "en-US": `Tattooed man walking in a field` }, - file: { - "en-US": { - url: `//images.ctfassets.net/uzfinxahlog0/4shwYI3POEGkw0Eg6kcyaQ/48c44bb6ebb52013dd14addd25725a76/felix-russell-saw-112140.jpg`, - details: { size: 4539181, image: { width: 2500, height: 1667 } }, - fileName: `felix-russell-saw-112140.jpg`, - contentType: `image/jpeg`, - }, + contentful_id: `person`, + }, + displayField: `name`, + name: `Person`, + description: ``, + fields: [ + { + id: `name`, + name: `Name`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `company`, + name: `Company`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `shortBio`, + name: `Short Bio`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `email`, + name: `Email`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `phone`, + name: `Phone`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `facebook`, + name: `Facebook`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `twitter`, + name: `Twitter`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `github`, + name: `Github`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `image`, + name: `Image`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Asset`, }, - }, + ], }, { sys: { @@ -382,10 +1308,10 @@ exports.initialSync = { contentful_id: `uzfinxahlog0`, }, }, - id: `c7orLdboQQowIUs22KAW4U`, - type: `Asset`, - createdAt: `2020-06-03T14:17:26.685Z`, - updatedAt: `2020-06-03T14:17:26.685Z`, + id: `blogPost`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:19.068Z`, + updatedAt: `2020-06-03T14:17:19.068Z`, environment: { sys: { id: `master`, @@ -395,307 +1321,177 @@ exports.initialSync = { }, }, revision: 1, - contentful_id: `7orLdboQQowIUs22KAW4U`, - }, - fields: { - title: { "en-US": `Sparkler` }, - description: { "en-US": `John with Sparkler` }, - file: { - "en-US": { - url: `//images.ctfassets.net/uzfinxahlog0/7orLdboQQowIUs22KAW4U/c0f07c92d9eb36b73c883681e639441c/matt-palmer-254999.jpg`, - details: { size: 2293094, image: { width: 3000, height: 2000 } }, - fileName: `matt-palmer-254999.jpg`, - contentType: `image/jpeg`, - }, - }, - }, - }, - ], - deletedEntries: [], - deletedAssets: [], - nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw3CswoUY34WECLCh152KsOLQcKwH8Kfw4kOQcOlw6TCr8OmEcKiwrhBZ8KhwrLCrcOsA8KYAMOFwo1kBMOZwrHDgCbDllcXVA`, - }, - contentTypeItems: [ - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `person`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:18.696Z`, - updatedAt: `2020-06-03T14:17:18.696Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `person`, - }, - displayField: `name`, - name: `Person`, - description: ``, - fields: [ - { - id: `name`, - name: `Name`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `company`, - name: `Company`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `shortBio`, - name: `Short Bio`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `email`, - name: `Email`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `phone`, - name: `Phone`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `facebook`, - name: `Facebook`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `twitter`, - name: `Twitter`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `github`, - name: `Github`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `image`, - name: `Image`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - ], - }, - { - sys: { - space: { - sys: { + contentful_id: `blogPost`, + }, + displayField: `title`, + name: `Blog Post`, + description: ``, + fields: [ + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `slug`, + name: `Slug`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `heroImage`, + name: `Hero Image`, type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `blogPost`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:19.068Z`, - updatedAt: `2020-06-03T14:17:19.068Z`, - environment: { - sys: { - id: `master`, + localized: false, + required: true, + disabled: false, + omitted: false, + linkType: `Asset`, + }, + { + id: `description`, + name: `Description`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `body`, + name: `Body`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `author`, + name: `Author`, type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `blogPost`, - }, - displayField: `title`, - name: `Blog Post`, - description: ``, - fields: [ - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `slug`, - name: `Slug`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `heroImage`, - name: `Hero Image`, - type: `Link`, - localized: false, - required: true, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - { - id: `description`, - name: `Description`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `body`, - name: `Body`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `author`, - name: `Author`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Entry`, - }, - { - id: `publishDate`, - name: `Publish Date`, - type: `Date`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `tags`, - name: `Tags`, - type: `Array`, - localized: false, - required: false, - disabled: false, - omitted: false, - items: { - type: `Symbol`, - validations: [{ in: [`general`, `javascript`, `static-sites`] }], + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Entry`, + }, + { + id: `publishDate`, + name: `Publish Date`, + type: `Date`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `tags`, + name: `Tags`, + type: `Array`, + localized: false, + required: false, + disabled: false, + omitted: false, + items: { + type: `Symbol`, + validations: [{ in: [`general`, `javascript`, `static-sites`] }], + }, }, - }, - ], - }, - ], - defaultLocale: `en-US`, - locales: [ - { - code: `en-US`, - name: `English (United States)`, - default: true, - fallbackCode: null, - sys: { - id: `1uSElBQA68GRKF30tpTxxT`, - type: `Locale`, - version: 1, - }, - }, - { - code: `nl`, - name: `Dutch`, - default: false, - fallbackCode: `en-US`, - sys: { - id: `2T7M2OzIrvE8cOCOF1HMuY`, - type: `Locale`, - version: 1, + ], }, - }, - ], - space: { - sys: { type: `Space`, id: `uzfinxahlog0` }, - name: `Starter Gatsby Blog`, + ], + defaultLocale: `en-US`, locales: [ { code: `en-US`, - default: true, name: `English (United States)`, + default: true, fallbackCode: null, + sys: { + id: `1uSElBQA68GRKF30tpTxxT`, + type: `Locale`, + version: 1, + }, }, { code: `nl`, - default: false, name: `Dutch`, + default: false, fallbackCode: `en-US`, + sys: { + id: `2T7M2OzIrvE8cOCOF1HMuY`, + type: `Locale`, + version: 1, + }, }, ], - }, + space: { + sys: { type: `Space`, id: `uzfinxahlog0` }, + name: `Starter Gatsby Blog`, + locales: [ + { + code: `en-US`, + default: true, + name: `English (United States)`, + fallbackCode: null, + }, + { + code: `nl`, + default: false, + name: `Dutch`, + fallbackCode: `en-US`, + }, + ], + }, + } } -exports.createBlogPost = { - currentSyncData: { - entries: [ +exports.removeBlogPost = () => { + return { + currentSyncData: { + entries: [], + assets: [], + deletedEntries: [ + { + sys: { + type: `DeletedEntry`, + id: `c1dHS3UzOqupJZY7AyeDc6s`, + space: { + sys: { + type: `Link`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, + }, + }, + environment: { + sys: { + id: `master`, + type: `Link`, + linkType: `Environment`, + contentful_id: `master`, + }, + }, + revision: 2, + createdAt: `2020-06-03T14:28:24.828Z`, + updatedAt: `2020-06-03T14:28:24.828Z`, + deletedAt: `2020-06-03T14:28:24.828Z`, + contentful_id: `1dHS3UzOqupJZY7AyeDc6s`, + }, + }, + ], + deletedAssets: [], + nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw13woJkDMK6fDpuN014SMKXw4MowpNDLcKVGQlXJiNSw53DlcKow4Fjw5HDqjthfQQrwo5MBlfDr3UfZjjCiMKi`, + }, + contentTypeItems: [ { sys: { space: { @@ -706,10 +1502,10 @@ exports.createBlogPost = { contentful_id: `uzfinxahlog0`, }, }, - id: `c1dHS3UzOqupJZY7AyeDc6s`, - type: `Entry`, - createdAt: `2020-06-03T14:22:37.720Z`, - updatedAt: `2020-06-03T14:22:37.720Z`, + id: `person`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:18.696Z`, + updatedAt: `2020-06-03T14:17:18.696Z`, environment: { sys: { id: `master`, @@ -719,50 +1515,105 @@ exports.createBlogPost = { }, }, revision: 1, - contentType: { - sys: { - type: `Link`, - linkType: `ContentType`, - id: `blogPost`, - contentful_id: `blogPost`, - }, - }, - contentful_id: `1dHS3UzOqupJZY7AyeDc6s`, - }, - fields: { - title: { "en-US": `Integration tests` }, - slug: { "en-US": `integration-tests` }, - heroImage: { - "en-US": { - sys: { - type: `Link`, - linkType: `Asset`, - id: `c1aaRo2sQbdfWnG8iNvnkH3`, - contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, - }, - }, - }, - description: { - "en-US": `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris et nisl eget dolor consequat vulputate. Duis a turpis sit amet turpis tincidunt imperdiet eget ac magna. Vestibulum aliquam id nisi nec consequat. Maecenas imperdiet sem ut pharetra vehicula. Fusce tristique luctus ex a porttitor. Duis blandit rutrum dui eu finibus. Etiam consequat nec tellus ut lacinia. Morbi a tempor purus. Donec sit amet consequat augue, nec interdum nulla. Vivamus urna sapien, luctus eget lectus non, malesuada dapibus purus. Nulla cursus commodo nunc. Mauris sapien est, pharetra vel fermentum in, pulvinar ut magna. Nunc sapien justo, sollicitudin ac tortor vel, tristique dictum quam.`, - }, - body: { - "en-US": `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris et nisl eget dolor consequat vulputate. Duis a turpis sit amet turpis tincidunt imperdiet eget ac magna. Vestibulum aliquam id nisi nec consequat. Maecenas imperdiet sem ut pharetra vehicula. Fusce tristique luctus ex a porttitor. Duis blandit rutrum dui eu finibus. Etiam consequat nec tellus ut lacinia. Morbi a tempor purus. Donec sit amet consequat augue, nec interdum nulla. Vivamus urna sapien, luctus eget lectus non, malesuada dapibus purus. Nulla cursus commodo nunc. Mauris sapien est, pharetra vel fermentum in, pulvinar ut magna. Nunc sapien justo, sollicitudin ac tortor vel, tristique dictum quam.\n\nEtiam a imperdiet massa, sit amet sodales arcu. In risus ex, venenatis vitae vestibulum at, cursus sed urna. Phasellus cursus finibus suscipit. Fusce scelerisque felis commodo nulla vehicula faucibus. Nullam magna mi, fermentum sed mauris at, condimentum sagittis risus. Maecenas rutrum condimentum nisl. Pellentesque ut tortor tortor. In venenatis congue justo, id condimentum leo. Maecenas sed accumsan magna, ac condimentum dui. Aliquam a dapibus turpis. Etiam laoreet vel dui eget ultricies. Proin nec elit odio.`, - }, - author: { - "en-US": { - sys: { - type: `Link`, - linkType: `Entry`, - id: `c15jwOBqpxqSAOy2eOO4S0m`, - contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, - }, - }, + contentful_id: `person`, + }, + displayField: `name`, + name: `Person`, + description: ``, + fields: [ + { + id: `name`, + name: `Name`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `company`, + name: `Company`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `shortBio`, + name: `Short Bio`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `email`, + name: `Email`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `phone`, + name: `Phone`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `facebook`, + name: `Facebook`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `twitter`, + name: `Twitter`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `github`, + name: `Github`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `image`, + name: `Image`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Asset`, }, - publishDate: { "en-US": `2020-04-01T00:00+02:00` }, - }, + ], }, - ], - assets: [ { sys: { space: { @@ -773,10 +1624,10 @@ exports.createBlogPost = { contentful_id: `uzfinxahlog0`, }, }, - id: `c1aaRo2sQbdfWnG8iNvnkH3`, - type: `Asset`, - createdAt: `2020-06-03T14:22:35.102Z`, - updatedAt: `2020-06-03T14:22:35.102Z`, + id: `blogPost`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:19.068Z`, + updatedAt: `2020-06-03T14:17:19.068Z`, environment: { sys: { id: `master`, @@ -786,665 +1637,179 @@ exports.createBlogPost = { }, }, revision: 1, - contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, - }, - fields: { - title: { "en-US": `Dummy image` }, - description: { "en-US": `Just a dummy image` }, - file: { - "en-US": { - url: `//images.ctfassets.net/uzfinxahlog0/1aaRo2sQbdfWnG8iNvnkH3/4b70303a3989c92bdc09870a00d294a8/Gatsby_Monogram.png`, - details: { size: 77907, image: { width: 2000, height: 2000 } }, - fileName: `Gatsby_Monogram.png`, - contentType: `image/png`, + contentful_id: `blogPost`, + }, + displayField: `title`, + name: `Blog Post`, + description: ``, + fields: [ + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `slug`, + name: `Slug`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `heroImage`, + name: `Hero Image`, + type: `Link`, + localized: false, + required: true, + disabled: false, + omitted: false, + linkType: `Asset`, + }, + { + id: `description`, + name: `Description`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `body`, + name: `Body`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `author`, + name: `Author`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Entry`, + }, + { + id: `publishDate`, + name: `Publish Date`, + type: `Date`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `tags`, + name: `Tags`, + type: `Array`, + localized: false, + required: false, + disabled: false, + omitted: false, + items: { + type: `Symbol`, + validations: [{ in: [`general`, `javascript`, `static-sites`] }], }, }, - }, + ], }, ], - deletedEntries: [], - deletedAssets: [], - nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw0YQMOfwrtZBsOQw41ww7xhJj8Ew4TChcOow6ZPPVVZaMOfOlFEwp7CpcOxwpd_YcKBw5jCkznDgMO6w4lsw73CrcOmwpILwqTClg`, - }, - contentTypeItems: [ - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `person`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:18.696Z`, - updatedAt: `2020-06-03T14:17:18.696Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, + defaultLocale: `en-US`, + locales: [ + { + code: `en-US`, + name: `English (United States)`, + default: true, + fallbackCode: null, + sys: { + id: `1uSElBQA68GRKF30tpTxxT`, + type: `Locale`, + version: 1, }, - revision: 1, - contentful_id: `person`, }, - displayField: `name`, - name: `Person`, - description: ``, - fields: [ - { - id: `name`, - name: `Name`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `company`, - name: `Company`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `shortBio`, - name: `Short Bio`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `email`, - name: `Email`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `phone`, - name: `Phone`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `facebook`, - name: `Facebook`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `twitter`, - name: `Twitter`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, + { + code: `nl`, + name: `Dutch`, + default: false, + fallbackCode: `en-US`, + sys: { + id: `2T7M2OzIrvE8cOCOF1HMuY`, + type: `Locale`, + version: 1, }, + }, + ], + space: { + sys: { type: `Space`, id: `uzfinxahlog0` }, + name: `Starter Gatsby Blog`, + locales: [ { - id: `github`, - name: `Github`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, + code: `en-US`, + default: true, + name: `English (United States)`, + fallbackCode: null, }, { - id: `image`, - name: `Image`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Asset`, + code: `nl`, + default: false, + name: `Dutch`, + fallbackCode: `en-US`, }, ], }, - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `blogPost`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:19.068Z`, - updatedAt: `2020-06-03T14:17:19.068Z`, - environment: { + } +} + +exports.removeAsset = () => { + return { + currentSyncData: { + entries: [], + assets: [], + deletedEntries: [], + deletedAssets: [ + { sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `blogPost`, - }, - displayField: `title`, - name: `Blog Post`, - description: ``, - fields: [ - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `slug`, - name: `Slug`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `heroImage`, - name: `Hero Image`, - type: `Link`, - localized: false, - required: true, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - { - id: `description`, - name: `Description`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `body`, - name: `Body`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `author`, - name: `Author`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Entry`, - }, - { - id: `publishDate`, - name: `Publish Date`, - type: `Date`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `tags`, - name: `Tags`, - type: `Array`, - localized: false, - required: false, - disabled: false, - omitted: false, - items: { - type: `Symbol`, - validations: [{ in: [`general`, `javascript`, `static-sites`] }], - }, - }, - ], - }, - ], - defaultLocale: `en-US`, - locales: [ - { - code: `en-US`, - name: `English (United States)`, - default: true, - fallbackCode: null, - sys: { - id: `1uSElBQA68GRKF30tpTxxT`, - type: `Locale`, - version: 1, - }, - }, - { - code: `nl`, - name: `Dutch`, - default: false, - fallbackCode: `en-US`, - sys: { - id: `2T7M2OzIrvE8cOCOF1HMuY`, - type: `Locale`, - version: 1, - }, - }, - ], - space: { - sys: { type: `Space`, id: `uzfinxahlog0` }, - name: `Starter Gatsby Blog`, - locales: [ - { - code: `en-US`, - default: true, - name: `English (United States)`, - fallbackCode: null, - }, - { - code: `nl`, - default: false, - name: `Dutch`, - fallbackCode: `en-US`, - }, - ], - }, -} - -exports.updateBlogPost = { - currentSyncData: { - entries: [ - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `c1dHS3UzOqupJZY7AyeDc6s`, - type: `Entry`, - createdAt: `2020-06-03T14:22:37.720Z`, - updatedAt: `2020-06-03T14:27:24.359Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 2, - contentType: { - sys: { - type: `Link`, - linkType: `ContentType`, - id: `blogPost`, - contentful_id: `blogPost`, - }, - }, - contentful_id: `1dHS3UzOqupJZY7AyeDc6s`, - }, - fields: { - title: { "en-US": `Hello world 1234` }, - slug: { "en-US": `hello-world-1234` }, - heroImage: { - "en-US": { + type: `DeletedAsset`, + id: `c1aaRo2sQbdfWnG8iNvnkH3`, + space: { sys: { type: `Link`, - linkType: `Asset`, - id: `c1aaRo2sQbdfWnG8iNvnkH3`, - contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, + linkType: `Space`, + id: `uzfinxahlog0`, + contentful_id: `uzfinxahlog0`, }, }, - }, - description: { - "en-US": `Your very first content with Contentful, pulled in JSON format using the Content Delivery API.`, - }, - body: { - "en-US": `These is your very first content with Contentful, pulled in JSON format using the [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API"). Content and presentation are now decoupled, allowing you to focus your efforts in building the perfect app.\n\n## Your first steps\n\nBuilding with Contentful is easy. First take a moment to get [the basics of content modelling](https://www.contentful.com/r/knowledgebase/content-modelling-basics/ "the basics of content modelling"), which you can set up in the [Contentful Web app](https://app.contentful.com/ "Contentful Web app"). Once you get that, feel free to drop by the [Documentation](https://www.contentful.com/developers/docs/ "Documentation") to learn a bit more about how to build your app with Contentful, in particular the [API basics](https://www.contentful.com/developers/docs/concepts/apis/ "API basics") and each one of our four APIs, as shown below.\n\n### Content Delivery API\n\nThe [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/ "Content Delivery API") (CDA), available at \\\`cdn.contentful.com\\\`, is a read-only API for delivering content from Contentful to apps, websites and other media. Content is delivered as JSON data, and images, videos and other media as files.\nThe API is available via a globally distributed content delivery network. The server closest to the user serves all content, both JSON and binary. This minimizes latency, which especially benefits mobile apps. Hosting content in multiple global data centers also greatly improves the availability of content.\n\n### Content Management API\n\nThe [Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/ "Content Management API") (CMA), available at \\\`api.contentful.com\\\`, is a read-write API for managing content. Unlike the Content Delivery API, the management API requires you to authenticate as a Contentful user. You could use the CMA for several use cases, such as:\n* Automatic imports from different CMSes like WordPress or Drupal.\n* Integration with other backend systems, such as an e-commerce shop.\n* Building custom editing experiences. We built the [Contentful Web app](https://app.contentful.com/ "Contentful Web app") on top of this API.\n\n### Preview API\n\nThe [Content Preview API](https://www.contentful.com/developers/docs/concepts/apis/#content-preview-api "Content Preview API"), available at \\\`preview.contentful.com\\\`, is a variant of the CDA for previewing your content before delivering it to your customers. You use the Content Preview API in combination with a "preview" deployment of your website (or a "preview" build of your mobile app) that allows content managers and authors to view their work in-context, as if it were published, using a "preview" access token as though it were delivered by the CDA.\n\n### Images API\n\nThe [Images API](https://www.contentful.com/developers/docs/concepts/apis/#images-api "Images API"), available at \\\`images.contentful.com\\\`, allows you to resize and crop images, change their background color and convert them to different formats. Using our API for these transformations lets you upload high-quality assets, deliver exactly what your app needs, and still get all the benefits of our caching CDN.`, - }, - author: { - "en-US": { + environment: { sys: { + id: `master`, type: `Link`, - linkType: `Entry`, - id: `c15jwOBqpxqSAOy2eOO4S0m`, - contentful_id: `15jwOBqpxqSAOy2eOO4S0m`, + linkType: `Environment`, + contentful_id: `master`, }, }, - }, - publishDate: { "en-US": `2020-05-15T00:00+02:00` }, - }, - }, - ], - assets: [], - deletedEntries: [], - deletedAssets: [], - nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw0OwpjDkMOywrZewqlOAMK_wp_DmcOzLRXDmlJ3wp5VextfJMKtw43CngvCrw7Cn07CgnNJw4XDscOsw5zCuXbDrMKnw7rCsTPCpxE`, - }, - contentTypeItems: [ - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `person`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:18.696Z`, - updatedAt: `2020-06-03T14:17:18.696Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, + revision: 1, + createdAt: `2020-06-03T14:28:57.237Z`, + updatedAt: `2020-06-03T14:28:57.237Z`, + deletedAt: `2020-06-03T14:28:57.237Z`, + contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, }, }, - revision: 1, - contentful_id: `person`, - }, - displayField: `name`, - name: `Person`, - description: ``, - fields: [ - { - id: `name`, - name: `Name`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `company`, - name: `Company`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `shortBio`, - name: `Short Bio`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `email`, - name: `Email`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `phone`, - name: `Phone`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `facebook`, - name: `Facebook`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `twitter`, - name: `Twitter`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `github`, - name: `Github`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `image`, - name: `Image`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Asset`, - }, ], + nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw0LNMOLwow1KMKwAW_Ci8OIwoPDgcK-Hn5Rw5XDvwXCsMK7wpPDk2jDtywiw6lyU8KEwprCojzDscOMwollMCbCicK_XTUEw7wZ`, }, - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `blogPost`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:19.068Z`, - updatedAt: `2020-06-03T14:17:19.068Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `blogPost`, - }, - displayField: `title`, - name: `Blog Post`, - description: ``, - fields: [ - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `slug`, - name: `Slug`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `heroImage`, - name: `Hero Image`, - type: `Link`, - localized: false, - required: true, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - { - id: `description`, - name: `Description`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `body`, - name: `Body`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `author`, - name: `Author`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Entry`, - }, - { - id: `publishDate`, - name: `Publish Date`, - type: `Date`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `tags`, - name: `Tags`, - type: `Array`, - localized: false, - required: false, - disabled: false, - omitted: false, - items: { - type: `Symbol`, - validations: [{ in: [`general`, `javascript`, `static-sites`] }], - }, - }, - ], - }, - ], - defaultLocale: `en-US`, - locales: [ - { - code: `en-US`, - name: `English (United States)`, - default: true, - fallbackCode: null, - sys: { - id: `1uSElBQA68GRKF30tpTxxT`, - type: `Locale`, - version: 1, - }, - }, - { - code: `nl`, - name: `Dutch`, - default: false, - fallbackCode: `en-US`, - sys: { - id: `2T7M2OzIrvE8cOCOF1HMuY`, - type: `Locale`, - version: 1, - }, - }, - ], - space: { - sys: { type: `Space`, id: `uzfinxahlog0` }, - name: `Starter Gatsby Blog`, - locales: [ - { - code: `en-US`, - default: true, - name: `English (United States)`, - fallbackCode: null, - }, - { - code: `nl`, - default: false, - name: `Dutch`, - fallbackCode: `en-US`, - }, - ], - }, -} - -exports.removeBlogPost = { - currentSyncData: { - entries: [], - assets: [], - deletedEntries: [ + contentTypeItems: [ { sys: { - type: `DeletedEntry`, - id: `c1dHS3UzOqupJZY7AyeDc6s`, space: { sys: { type: `Link`, @@ -1453,6 +1818,10 @@ exports.removeBlogPost = { contentful_id: `uzfinxahlog0`, }, }, + id: `person`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:18.696Z`, + updatedAt: `2020-06-03T14:17:18.696Z`, environment: { sys: { id: `master`, @@ -1461,305 +1830,108 @@ exports.removeBlogPost = { contentful_id: `master`, }, }, - revision: 2, - createdAt: `2020-06-03T14:28:24.828Z`, - updatedAt: `2020-06-03T14:28:24.828Z`, - deletedAt: `2020-06-03T14:28:24.828Z`, - contentful_id: `1dHS3UzOqupJZY7AyeDc6s`, - }, - }, - ], - deletedAssets: [], - nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw13woJkDMK6fDpuN014SMKXw4MowpNDLcKVGQlXJiNSw53DlcKow4Fjw5HDqjthfQQrwo5MBlfDr3UfZjjCiMKi`, - }, - contentTypeItems: [ - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `person`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:18.696Z`, - updatedAt: `2020-06-03T14:17:18.696Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `person`, - }, - displayField: `name`, - name: `Person`, - description: ``, - fields: [ - { - id: `name`, - name: `Name`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `company`, - name: `Company`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `shortBio`, - name: `Short Bio`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `email`, - name: `Email`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `phone`, - name: `Phone`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `facebook`, - name: `Facebook`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `twitter`, - name: `Twitter`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `github`, - name: `Github`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `image`, - name: `Image`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - ], - }, - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `blogPost`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:19.068Z`, - updatedAt: `2020-06-03T14:17:19.068Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `blogPost`, - }, - displayField: `title`, - name: `Blog Post`, - description: ``, - fields: [ - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `slug`, - name: `Slug`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `heroImage`, - name: `Hero Image`, - type: `Link`, - localized: false, - required: true, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - { - id: `description`, - name: `Description`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `body`, - name: `Body`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `author`, - name: `Author`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Entry`, - }, - { - id: `publishDate`, - name: `Publish Date`, - type: `Date`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `tags`, - name: `Tags`, - type: `Array`, - localized: false, - required: false, - disabled: false, - omitted: false, - items: { + revision: 1, + contentful_id: `person`, + }, + displayField: `name`, + name: `Person`, + description: ``, + fields: [ + { + id: `name`, + name: `Name`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `company`, + name: `Company`, type: `Symbol`, - validations: [{ in: [`general`, `javascript`, `static-sites`] }], + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `shortBio`, + name: `Short Bio`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `email`, + name: `Email`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `phone`, + name: `Phone`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `facebook`, + name: `Facebook`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `twitter`, + name: `Twitter`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `github`, + name: `Github`, + type: `Symbol`, + localized: false, + required: false, + disabled: false, + omitted: false, + }, + { + id: `image`, + name: `Image`, + type: `Link`, + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Asset`, }, - }, - ], - }, - ], - defaultLocale: `en-US`, - locales: [ - { - code: `en-US`, - name: `English (United States)`, - default: true, - fallbackCode: null, - sys: { - id: `1uSElBQA68GRKF30tpTxxT`, - type: `Locale`, - version: 1, - }, - }, - { - code: `nl`, - name: `Dutch`, - default: false, - fallbackCode: `en-US`, - sys: { - id: `2T7M2OzIrvE8cOCOF1HMuY`, - type: `Locale`, - version: 1, - }, - }, - ], - space: { - sys: { type: `Space`, id: `uzfinxahlog0` }, - name: `Starter Gatsby Blog`, - locales: [ - { - code: `en-US`, - default: true, - name: `English (United States)`, - fallbackCode: null, - }, - { - code: `nl`, - default: false, - name: `Dutch`, - fallbackCode: `en-US`, + ], }, - ], - }, -} - -exports.removeAsset = { - currentSyncData: { - entries: [], - assets: [], - deletedEntries: [], - deletedAssets: [ { sys: { - type: `DeletedAsset`, - id: `c1aaRo2sQbdfWnG8iNvnkH3`, space: { sys: { type: `Link`, @@ -1768,6 +1940,10 @@ exports.removeAsset = { contentful_id: `uzfinxahlog0`, }, }, + id: `blogPost`, + type: `ContentType`, + createdAt: `2020-06-03T14:17:19.068Z`, + updatedAt: `2020-06-03T14:17:19.068Z`, environment: { sys: { id: `master`, @@ -1777,289 +1953,135 @@ exports.removeAsset = { }, }, revision: 1, - createdAt: `2020-06-03T14:28:57.237Z`, - updatedAt: `2020-06-03T14:28:57.237Z`, - deletedAt: `2020-06-03T14:28:57.237Z`, - contentful_id: `1aaRo2sQbdfWnG8iNvnkH3`, - }, - }, - ], - nextSyncToken: `FEnChMOBwr1Yw4TCqsK2LcKpCH3CjsORIyLDrGbDtgozw6xreMKCwpjCtlxATw0LNMOLwow1KMKwAW_Ci8OIwoPDgcK-Hn5Rw5XDvwXCsMK7wpPDk2jDtywiw6lyU8KEwprCojzDscOMwollMCbCicK_XTUEw7wZ`, - }, - contentTypeItems: [ - { - sys: { - space: { - sys: { - type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `person`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:18.696Z`, - updatedAt: `2020-06-03T14:17:18.696Z`, - environment: { - sys: { - id: `master`, - type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `person`, - }, - displayField: `name`, - name: `Person`, - description: ``, - fields: [ - { - id: `name`, - name: `Name`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `company`, - name: `Company`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `shortBio`, - name: `Short Bio`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `email`, - name: `Email`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `phone`, - name: `Phone`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `facebook`, - name: `Facebook`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `twitter`, - name: `Twitter`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `github`, - name: `Github`, - type: `Symbol`, - localized: false, - required: false, - disabled: false, - omitted: false, - }, - { - id: `image`, - name: `Image`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - ], - }, - { - sys: { - space: { - sys: { + contentful_id: `blogPost`, + }, + displayField: `title`, + name: `Blog Post`, + description: ``, + fields: [ + { + id: `title`, + name: `Title`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `slug`, + name: `Slug`, + type: `Symbol`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `heroImage`, + name: `Hero Image`, type: `Link`, - linkType: `Space`, - id: `uzfinxahlog0`, - contentful_id: `uzfinxahlog0`, - }, - }, - id: `blogPost`, - type: `ContentType`, - createdAt: `2020-06-03T14:17:19.068Z`, - updatedAt: `2020-06-03T14:17:19.068Z`, - environment: { - sys: { - id: `master`, + localized: false, + required: true, + disabled: false, + omitted: false, + linkType: `Asset`, + }, + { + id: `description`, + name: `Description`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `body`, + name: `Body`, + type: `Text`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `author`, + name: `Author`, type: `Link`, - linkType: `Environment`, - contentful_id: `master`, - }, - }, - revision: 1, - contentful_id: `blogPost`, - }, - displayField: `title`, - name: `Blog Post`, - description: ``, - fields: [ - { - id: `title`, - name: `Title`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `slug`, - name: `Slug`, - type: `Symbol`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `heroImage`, - name: `Hero Image`, - type: `Link`, - localized: false, - required: true, - disabled: false, - omitted: false, - linkType: `Asset`, - }, - { - id: `description`, - name: `Description`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `body`, - name: `Body`, - type: `Text`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `author`, - name: `Author`, - type: `Link`, - localized: false, - required: false, - disabled: false, - omitted: false, - linkType: `Entry`, - }, - { - id: `publishDate`, - name: `Publish Date`, - type: `Date`, - localized: false, - required: true, - disabled: false, - omitted: false, - }, - { - id: `tags`, - name: `Tags`, - type: `Array`, - localized: false, - required: false, - disabled: false, - omitted: false, - items: { - type: `Symbol`, - validations: [{ in: [`general`, `javascript`, `static-sites`] }], + localized: false, + required: false, + disabled: false, + omitted: false, + linkType: `Entry`, + }, + { + id: `publishDate`, + name: `Publish Date`, + type: `Date`, + localized: false, + required: true, + disabled: false, + omitted: false, + }, + { + id: `tags`, + name: `Tags`, + type: `Array`, + localized: false, + required: false, + disabled: false, + omitted: false, + items: { + type: `Symbol`, + validations: [{ in: [`general`, `javascript`, `static-sites`] }], + }, }, - }, - ], - }, - ], - defaultLocale: `en-US`, - locales: [ - { - code: `en-US`, - name: `English (United States)`, - default: true, - fallbackCode: null, - sys: { - id: `1uSElBQA68GRKF30tpTxxT`, - type: `Locale`, - version: 1, - }, - }, - { - code: `nl`, - name: `Dutch`, - default: false, - fallbackCode: `en-US`, - sys: { - id: `2T7M2OzIrvE8cOCOF1HMuY`, - type: `Locale`, - version: 1, + ], }, - }, - ], - space: { - sys: { type: `Space`, id: `uzfinxahlog0` }, - name: `Starter Gatsby Blog`, + ], + defaultLocale: `en-US`, locales: [ { code: `en-US`, - default: true, name: `English (United States)`, + default: true, fallbackCode: null, + sys: { + id: `1uSElBQA68GRKF30tpTxxT`, + type: `Locale`, + version: 1, + }, }, { code: `nl`, - default: false, name: `Dutch`, + default: false, fallbackCode: `en-US`, + sys: { + id: `2T7M2OzIrvE8cOCOF1HMuY`, + type: `Locale`, + version: 1, + }, }, ], - }, + space: { + sys: { type: `Space`, id: `uzfinxahlog0` }, + name: `Starter Gatsby Blog`, + locales: [ + { + code: `en-US`, + default: true, + name: `English (United States)`, + fallbackCode: null, + }, + { + code: `nl`, + default: false, + name: `Dutch`, + fallbackCode: `en-US`, + }, + ], + }, + } } diff --git a/packages/gatsby-source-contentful/src/__tests__/fetch.js b/packages/gatsby-source-contentful/src/__tests__/fetch.js index 105dfcb2b26fb..205f7781e8de1 100644 --- a/packages/gatsby-source-contentful/src/__tests__/fetch.js +++ b/packages/gatsby-source-contentful/src/__tests__/fetch.js @@ -85,7 +85,11 @@ beforeAll(() => { const reporter = { info: jest.fn(), + verbose: jest.fn(), panic: jest.fn(), + activityTimer: () => { + return { start: jest.fn(), end: jest.fn() } + }, } beforeEach(() => { diff --git a/packages/gatsby-source-contentful/src/__tests__/gatsby-node.js b/packages/gatsby-source-contentful/src/__tests__/gatsby-node.js index dece9e6015be4..46abf8b6c5a99 100644 --- a/packages/gatsby-source-contentful/src/__tests__/gatsby-node.js +++ b/packages/gatsby-source-contentful/src/__tests__/gatsby-node.js @@ -7,7 +7,6 @@ jest.mock(`gatsby-core-utils`, () => { } }) -const _ = require(`lodash`) const gatsbyNode = require(`../gatsby-node`) const fetch = require(`../fetch`) const normalize = require(`../normalize`) @@ -30,6 +29,10 @@ describe(`gatsby-node`, () => { const getCache = jest.fn() const reporter = { info: jest.fn(), + verbose: jest.fn(), + activityTimer: () => { + return { start: jest.fn(), end: jest.fn() } + }, } const createNodeId = jest.fn(value => value) let currentNodeMap @@ -265,9 +268,7 @@ describe(`gatsby-node`, () => { it(`should create nodes from initial payload`, async () => { cache.get.mockClear() cache.set.mockClear() - fetch.mockImplementationOnce(() => - _.cloneDeep(startersBlogFixture.initialSync) - ) + fetch.mockImplementationOnce(startersBlogFixture.initialSync) const locales = [`en-US`, `nl`] await gatsbyNode.sourceNodes({ @@ -282,14 +283,14 @@ describe(`gatsby-node`, () => { schema, }) - testIfContentTypesExists(startersBlogFixture.initialSync.contentTypeItems) + testIfContentTypesExists(startersBlogFixture.initialSync().contentTypeItems) testIfEntriesExists( - startersBlogFixture.initialSync.currentSyncData.entries, - startersBlogFixture.initialSync.contentTypeItems, + startersBlogFixture.initialSync().currentSyncData.entries, + startersBlogFixture.initialSync().contentTypeItems, locales ) testIfAssetsExistsAndMatch( - startersBlogFixture.initialSync.currentSyncData.assets, + startersBlogFixture.initialSync().currentSyncData.assets, locales ) @@ -301,11 +302,11 @@ describe(`gatsby-node`, () => { // Stores sync token and raw/unparsed data to the cache expect(cache.set).toHaveBeenCalledWith( `syncToken`, - startersBlogFixture.initialSync.currentSyncData.nextSyncToken + startersBlogFixture.initialSync().currentSyncData.nextSyncToken ) expect(cache.set).toHaveBeenCalledWith( `previousSyncData`, - startersBlogFixture.initialSync.currentSyncData + startersBlogFixture.initialSync().currentSyncData ) expect(cache.set.mock.calls.length).toBe(2) }) @@ -314,11 +315,11 @@ describe(`gatsby-node`, () => { const locales = [`en-US`, `nl`] fetch - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.initialSync)) - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.createBlogPost)) + .mockImplementationOnce(startersBlogFixture.initialSync) + .mockImplementationOnce(startersBlogFixture.createBlogPost) - const createdBlogEntry = - startersBlogFixture.createBlogPost.currentSyncData.entries[0] + const createdBlogEntry = startersBlogFixture.createBlogPost() + .currentSyncData.entries[0] const createdBlogEntryIds = locales.map(locale => normalize.makeId({ spaceId: createdBlogEntry.sys.space.sys.id, @@ -360,15 +361,15 @@ describe(`gatsby-node`, () => { schema, }) testIfContentTypesExists( - startersBlogFixture.createBlogPost.contentTypeItems + startersBlogFixture.createBlogPost().contentTypeItems ) testIfEntriesExists( - startersBlogFixture.createBlogPost.currentSyncData.entries, - startersBlogFixture.createBlogPost.contentTypeItems, + startersBlogFixture.createBlogPost().currentSyncData.entries, + startersBlogFixture.createBlogPost().contentTypeItems, locales ) testIfAssetsExistsAndMatch( - startersBlogFixture.createBlogPost.currentSyncData.assets, + startersBlogFixture.createBlogPost().currentSyncData.assets, locales ) @@ -382,12 +383,12 @@ describe(`gatsby-node`, () => { it(`should update a blogpost`, async () => { const locales = [`en-US`, `nl`] fetch - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.initialSync)) - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.createBlogPost)) - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.updateBlogPost)) + .mockImplementationOnce(startersBlogFixture.initialSync) + .mockImplementationOnce(startersBlogFixture.createBlogPost) + .mockImplementationOnce(startersBlogFixture.updateBlogPost) - const updatedBlogEntry = - startersBlogFixture.updateBlogPost.currentSyncData.entries[0] + const updatedBlogEntry = startersBlogFixture.updateBlogPost() + .currentSyncData.entries[0] const updatedBlogEntryIds = locales.map(locale => normalize.makeId({ spaceId: updatedBlogEntry.sys.space.sys.id, @@ -442,15 +443,15 @@ describe(`gatsby-node`, () => { }) testIfContentTypesExists( - startersBlogFixture.updateBlogPost.contentTypeItems + startersBlogFixture.updateBlogPost().contentTypeItems ) testIfEntriesExists( - startersBlogFixture.updateBlogPost.currentSyncData.entries, - startersBlogFixture.updateBlogPost.contentTypeItems, + startersBlogFixture.updateBlogPost().currentSyncData.entries, + startersBlogFixture.updateBlogPost().contentTypeItems, locales ) testIfAssetsExistsAndMatch( - startersBlogFixture.updateBlogPost.currentSyncData.assets, + startersBlogFixture.updateBlogPost().currentSyncData.assets, locales ) @@ -465,12 +466,12 @@ describe(`gatsby-node`, () => { it(`should remove a blogpost and update linkedNodes`, async () => { const locales = [`en-US`, `nl`] fetch - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.initialSync)) - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.createBlogPost)) - .mockReturnValueOnce(_.cloneDeep(startersBlogFixture.removeBlogPost)) + .mockImplementationOnce(startersBlogFixture.initialSync) + .mockImplementationOnce(startersBlogFixture.createBlogPost) + .mockImplementationOnce(startersBlogFixture.removeBlogPost) - const removedBlogEntry = - startersBlogFixture.removeBlogPost.currentSyncData.deletedEntries[0] + const removedBlogEntry = startersBlogFixture.removeBlogPost() + .currentSyncData.deletedEntries[0] const normalizedType = removedBlogEntry.sys.type.startsWith(`Deleted`) ? removedBlogEntry.sys.type.substring(`Deleted`.length) : removedBlogEntry.sys.type @@ -532,10 +533,10 @@ describe(`gatsby-node`, () => { }) testIfContentTypesExists( - startersBlogFixture.removeBlogPost.contentTypeItems + startersBlogFixture.removeBlogPost().contentTypeItems ) testIfEntriesDeleted( - startersBlogFixture.removeBlogPost.currentSyncData.assets, + startersBlogFixture.removeBlogPost().currentSyncData.assets, locales ) @@ -549,12 +550,12 @@ describe(`gatsby-node`, () => { const locales = [`en-US`, `nl`] fetch - .mockReturnValueOnce(startersBlogFixture.initialSync) - .mockReturnValueOnce(startersBlogFixture.createBlogPost) - .mockReturnValueOnce(startersBlogFixture.removeAsset) + .mockImplementationOnce(startersBlogFixture.initialSync) + .mockImplementationOnce(startersBlogFixture.createBlogPost) + .mockImplementationOnce(startersBlogFixture.removeAsset) - const removedAssetEntry = - startersBlogFixture.createBlogPost.currentSyncData.entries[0] + const removedAssetEntry = startersBlogFixture.createBlogPost() + .currentSyncData.entries[0] const removedAssetEntryIds = locales.map(locale => normalize.makeId({ spaceId: removedAssetEntry.sys.space.sys.id, @@ -598,7 +599,7 @@ describe(`gatsby-node`, () => { // check if assets exists testIfAssetsExists( - startersBlogFixture.removeAsset.currentSyncData.deletedAssets, + startersBlogFixture.removeAsset().currentSyncData.deletedAssets, locales ) @@ -615,14 +616,14 @@ describe(`gatsby-node`, () => { schema, }) - testIfContentTypesExists(startersBlogFixture.removeAsset.contentTypeItems) + testIfContentTypesExists(startersBlogFixture.removeAsset().contentTypeItems) testIfEntriesExists( - startersBlogFixture.removeAsset.currentSyncData.entries, - startersBlogFixture.removeAsset.contentTypeItems, + startersBlogFixture.removeAsset().currentSyncData.entries, + startersBlogFixture.removeAsset().contentTypeItems, locales ) testIfAssetsDeleted( - startersBlogFixture.removeAsset.currentSyncData.deletedAssets, + startersBlogFixture.removeAsset().currentSyncData.deletedAssets, locales ) }) diff --git a/packages/gatsby-source-contentful/src/fetch.js b/packages/gatsby-source-contentful/src/fetch.js index ab2af70bb854b..49829faebd645 100644 --- a/packages/gatsby-source-contentful/src/fetch.js +++ b/packages/gatsby-source-contentful/src/fetch.js @@ -8,11 +8,17 @@ module.exports = async function contentfulFetch({ syncToken, reporter, pluginConfig, + parentSpan, }) { - // Fetch articles. - console.time(`Fetch Contentful data`) + const fetchActivity = reporter.activityTimer( + `fetching data from Contentful`, + { + parentSpan, + } + ) + fetchActivity.start() - console.log(`Starting to fetch data from Contentful`) + // Fetch articles. const pageLimit = pluginConfig.get(`pageLimit`) const contentfulClientOptions = { @@ -33,7 +39,7 @@ module.exports = async function contentfulFetch({ let locales let defaultLocale = `en-US` try { - reporter.info(`Fetching default locale`) + reporter.verbose(`Fetching default locale`) space = await client.getSpace() let contentfulLocales = await client .getLocales() @@ -48,7 +54,7 @@ module.exports = async function contentfulFetch({ )}' were found but were filtered down to none.` ) } - reporter.info(`Default locale is: ${defaultLocale}`) + reporter.verbose(`Default locale is: ${defaultLocale}`) } catch (e) { let details let errors @@ -110,7 +116,7 @@ ${formatPluginOptionsForCLI(pluginConfig.getOriginalPluginOptions(), errors)}`) } catch (e) { reporter.panic(`Error fetching content types`, e) } - reporter.info(`Content types fetched ${contentTypes.items.length}`) + reporter.verbose(`Content types fetched ${contentTypes.items.length}`) let contentTypeItems = contentTypes.items @@ -138,7 +144,7 @@ ${formatPluginOptionsForCLI(pluginConfig.getOriginalPluginOptions(), errors)}`) space, } - console.timeEnd(`Fetch Contentful data`) + fetchActivity.end() return result } diff --git a/packages/gatsby-source-contentful/src/gatsby-node.js b/packages/gatsby-source-contentful/src/gatsby-node.js index bcf1aab9abc3f..1eb5ec1132a3b 100644 --- a/packages/gatsby-source-contentful/src/gatsby-node.js +++ b/packages/gatsby-source-contentful/src/gatsby-node.js @@ -2,11 +2,13 @@ const path = require(`path`) const isOnline = require(`is-online`) const _ = require(`lodash`) const fs = require(`fs-extra`) +const { createClient } = require(`contentful`) + const normalize = require(`./normalize`) const fetchData = require(`./fetch`) const { createPluginConfig, validateOptions } = require(`./plugin-options`) const { downloadContentfulAssets } = require(`./download-contentful-assets`) -const { createClient } = require(`contentful`) + const conflictFieldPrefix = `contentful` const CACHE_SYNC_KEY = `previousSyncData` @@ -48,14 +50,11 @@ exports.sourceNodes = async ( getCache, reporter, schema, + parentSpan, }, pluginOptions ) => { const { createNode, deleteNode, touchNode, createTypes } = actions - const client = createClient({ - space: `none`, - accessToken: `fake-access-token`, - }) const online = await isOnline() // If the user knows they are offline, serve them cached result @@ -117,6 +116,7 @@ exports.sourceNodes = async ( syncToken, reporter, pluginConfig, + parentSpan, }) createTypes(` @@ -156,7 +156,10 @@ exports.sourceNodes = async ( ) createTypes(gqlTypes) - console.time(`Process Contentful data`) + const processingActivity = reporter.activityTimer(`process Contentful data`, { + parentSpan, + }) + processingActivity.start() // Remove deleted entries and assets from cached sync data set previousSyncData.entries = previousSyncData.entries.filter( @@ -191,7 +194,10 @@ exports.sourceNodes = async ( const currentSyncDataRaw = _.cloneDeep(currentSyncData) // Use the JS-SDK to resolve the entries and assets - const res = client.parseEntries({ + const res = createClient({ + space: `none`, + accessToken: `fake-access-token`, + }).parseEntries({ items: currentSyncData.entries, includes: { assets: currentSyncData.assets, @@ -285,7 +291,7 @@ exports.sourceNodes = async ( cache.set(CACHE_SYNC_TOKEN, nextSyncToken), ]) - reporter.info(`Building Contentful reference map`) + reporter.verbose(`Building Contentful reference map`) // Create map of resolvable ids so we can check links against them while creating // links. @@ -309,7 +315,7 @@ exports.sourceNodes = async ( useNameForId: pluginConfig.get(`useNameForId`), }) - reporter.info(`Resolving Contentful references`) + reporter.verbose(`Resolving Contentful references`) const newOrUpdatedEntries = [] entryList.forEach(entries => { @@ -341,8 +347,12 @@ exports.sourceNodes = async ( } }) - console.timeEnd(`Process Contentful data`) - console.time(`Create Contentful nodes`) + processingActivity.end() + + const creationActivity = reporter.activityTimer(`create Contentful nodes`, { + parentSpan, + }) + creationActivity.start() for (let i = 0; i < contentTypeItems.length; i++) { const contentTypeItem = contentTypeItems[i] @@ -393,7 +403,7 @@ exports.sourceNodes = async ( ) } - console.timeEnd(`Create Contentful nodes`) + creationActivity.end() if (pluginConfig.get(`downloadLocal`)) { reporter.info(`Download Contentful asset files`) diff --git a/packages/gatsby-source-contentful/src/normalize.js b/packages/gatsby-source-contentful/src/normalize.js index 1e59f35d305d1..58184995e841b 100644 --- a/packages/gatsby-source-contentful/src/normalize.js +++ b/packages/gatsby-source-contentful/src/normalize.js @@ -210,9 +210,7 @@ exports.buildForeignReferenceMap = ({ }) } } else if ( - entryItemFieldValue && - entryItemFieldValue.sys && - entryItemFieldValue.sys.type && + entryItemFieldValue?.sys?.type && entryItemFieldValue.sys.id ) { const key = `${entryItemFieldValue.sys.id}___${ diff --git a/packages/gatsby-source-contentful/src/rich-text.js b/packages/gatsby-source-contentful/src/rich-text.js index af2f563198b41..a274b08622dc2 100644 --- a/packages/gatsby-source-contentful/src/rich-text.js +++ b/packages/gatsby-source-contentful/src/rich-text.js @@ -7,12 +7,7 @@ import resolveResponse from "contentful-resolve-response" const prepareIdsForResolving = obj => { for (let k in obj) { const value = obj[k] - if ( - value && - value.sys && - value.sys.type === `Link` && - value.sys.contentful_id - ) { + if (value?.sys?.type === `Link` && value.sys.contentful_id) { value.sys.id = value.sys.contentful_id delete value.sys.contentful_id } else if (value && typeof value === `object`) { @@ -31,7 +26,8 @@ function renderRichText({ raw, references }, options = {}) { prepareIdsForResolving(richText) - // Create dummy response so we can use official libraries for resolving the entries + // Reconstruct the Contentful API response pattern to use the official + // contentful-resolve-response module to resolve references const dummyResponse = { items: [ {