• Stars
    star
    320
  • Rank 130,600 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🚚 Migration tooling for contentful

header

Join Contentful Community Slack Β  Join Contentful Community Forum

contentful-migration - content model migration tool

Describe and execute changes to your content model and transform entry content.

This repository is actively maintained Β  MIT License Β  Build Status

NPM Β  NPM downloads Β 

What is Contentful?

Contentful provides content infrastructure for digital teams to power websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship their products faster.

Table of contents

Core Features

  • Content type
    • Edit Content type
    • Create a Content type
  • Entries
    • Transform Entries for a Given Content type
    • Derives a new entry and sets up a reference to it on the source entry
    • Updates tags on entries for a given Content Type
  • Fields
    • Create a field
    • Edit a field
    • Delete a field
    • Rename a field
    • Change a field's control
    • Reset a field's control
    • Copy a field's control
    • Move field
  • Tags
    • Create a Tag
    • Rename a Tag
    • Delete a Tag

Pre-requisites && Installation

Pre-requisites

  • Node LTS

Installation

npm install contentful-migration

Usage

❗ Usage as CLI

We moved the CLI version of this tool into our Contentful CLI. This allows our users to use and install only one single CLI tool to get the full Contentful experience.

Please have a look at the Contentful CLI migration command documentation to learn more about how to use this as command line tool.

Usage as a library

const { runMigration } = require('contentful-migration')
const options = {
  filePath: '<migration-file-path>',
  spaceId: '<space-id>',
  accessToken: '<access-token>'
}
runMigration(options)
  .then(() => console.log('Migration Done!'))
  .catch((e) => console.error(e))

In your migration description file, export a function that accepts the migration object as its argument. For example:

module.exports = function (migration, context) {
  const dog = migration.createContentType('dog')
  const name = dog.createField('name')
  name.type('Symbol').required(true)
}

You can also pass the function directly. For example:

const { runMigration } = require('contentful-migration')

function migrationFunction(migration, context) {
  const dog = migration.createContentType('dog')
  const name = dog.createField('name')
  name.type('Symbol').required(true)
}

const options = {
  migrationFunction,
  spaceId: '<space-id>',
  accessToken: '<access-token>'
}

runMigration(options)
  .then(() => console.log('Migration Done!'))
  .catch((e) => console.error(e))

Documentation & References

Configuration

Name Default Type Description Required
filePath string The path to the migration file if migrationFunction is not supplied
migrationFunction function Specify the migration function directly. See the expected signature. if filePath is not supplied
spaceId string ID of the space to run the migration script on true
environmentId 'master' string ID of the environment within the space to run the false
accessToken string The access token to use true
yes false boolean Skips any confirmation before applying the migration,script false
retryLimit 5 number Number of retries before failure (every subsequent retry will increase the timeout to the previous retry by about 1.5 seconds) false
requestBatchSize 100 number Limit for every single request false
headers object Additional headers to attach to the requests false

Chaining vs Object notation

All methods described below can be used in two flavors:

  1. The chained approach:

    const author = migration
      .createContentType('author')
      .name('Author')
      .description('Author of blog posts or pages')
  2. The object approach:

    const author = migration.createContentType('author', {
      name: 'Author',
      description: 'Author of blog posts or pages'
    })

    While both approaches work, it is recommended to use the chained approach since validation errors will display context information whenever an error is detected, along with a line number. The object notation will lead the validation error to only show the line where the object is described, whereas the chained notation will show precisely where the error is located.

migration

The main interface for creating and editing content types and tags.

createContentType(id[, opts]) : ContentType

Creates a content type with provided id and returns a reference to the newly created content type.

id : string – The ID of the content type.

opts : Object – Content type definition, with the following options:

  • name : string – Name of the content type.
  • description : string – Description of the content type.
  • displayField : string – ID of the field to use as the display field for the content type. This is referred to as the "Entry title" in the web application.

editContentType(id[, opts]) : ContentType

Edits an existing content type of provided id and returns a reference to the content type. Uses the same options as createContentType.

deleteContentType(id)

Deletes the content type with the provided id and returns undefined. Note that the content type must not have any entries.

transformEntries(config)

For the given content type, transforms all its entries according to the user-provided transformEntryForLocale function. For each entry, the CLI will call this function once per locale in the space, passing in the from fields and the locale as arguments. The transform function is expected to return an object with the desired target fields. If it returns undefined, this entry locale will be left untouched.

config : Object – Content transformation definition, with the following properties:

  • contentType : string (required) – Content type ID
  • from : array (required) – Array of the source field IDs
  • to : array (required) – Array of the target field IDs
  • transformEntryForLocale : function (fields, locale, {id}): object (required) – Transformation function to be applied.
    • fields is an object containing each of the from fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}})
    • locale one of the locales in the space being transformed
    • id id of the current entry in scope
      The return value must be an object with the same keys as specified in to. Their values will be written to the respective entry fields for the current locale (i.e. {nameField: 'myNewValue'}). If it returns undefined, this the values for this locale on the entry will be left untouched.
  • shouldPublish : bool | 'preserve' (optional) – Flag that specifies publishing of target entries, preserve will keep current states of the source entries (default 'preserve')
transformEntries Example
migration.transformEntries({
  contentType: 'newsArticle',
  from: ['author', 'authorCity'],
  to: ['byline'],
  transformEntryForLocale: function (fromFields, currentLocale, { id }) {
    if (currentLocale === 'de-DE') {
      return
    }
    const newByline = `${fromFields.author[currentLocale]} ${fromFields.authorCity[currentLocale]}`
    return { byline: newByline }
  }
})

For the complete version, please refer to this example.

deriveLinkedEntries(config)

For each entry of the given content type (source entry), derives a new entry and sets up a reference to it on the source entry. The content of the new entry is generated by the user-provided deriveEntryForLocale function. For each source entry, this function will be called as many times as there are locales in the space. Each time, it will be called with the from fields and one of the locales as arguments. The derive function is expected to return an object with the desired target fields. If it returns undefined, the new entry will have no values for the current locale.

config : Object – Entry derivation definition, with the following properties:

  • contentType : string (required) – Source content type ID

  • derivedContentType : string (required) – Target content type ID

  • from : array (required) – Array of the source field IDs

  • toReferenceField : string (required) – ID of the field on the source content type in which to insert the reference

  • derivedFields : array (required) – Array of the field IDs on the target content type

  • identityKey: function (fields): string (required) - Called once per source entry. Returns the ID used for the derived entry, which is also used for de-duplication so that multiple source entries can link to the same derived entry.

    • fields is an object containing each of the from fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}})
  • deriveEntryForLocale : function (fields, locale, {id}): object (required) – Function that generates the field values for the derived entry.

    • fields is an object containing each of the from fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}})
    • locale one of the locales in the space being transformed
    • id id of the current entry in scope

    The return value must be an object with the same keys as specified in derivedFields. Their values will be written to the respective new entry fields for the current locale (i.e. {nameField: 'myNewValue'})

  • shouldPublish : bool|'preserve' (optional) – If true, both the source and the derived entries will be published. If false, both will remain in draft state. If preserve, will keep current states of the source entries (default true)

deriveLinkedEntries(config) Example
migration.deriveLinkedEntries({
  contentType: 'dog',
  derivedContentType: 'owner',
  from: ['owner'],
  toReferenceField: 'ownerRef',
  derivedFields: ['firstName', 'lastName'],
  identityKey: async (fromFields) => {
    return fromFields.owner['en-US'].toLowerCase().replace(' ', '-')
  },
  shouldPublish: true,
  deriveEntryForLocale: async (inputFields, locale, { id }) => {
    if (locale !== 'en-US') {
      return
    }
    const [firstName, lastName] = inputFields.owner[locale].split(' ')
    return {
      firstName,
      lastName
    }
  }
})

For the complete version of this migration, please refer to this example.

transformEntriesToType(config)

For the given (source) content type, transforms all its entries according to the user-provided transformEntryForLocale function into a new entry of a specific different (target) content type. For each entry, the CLI will call the function transformEntryForLocale once per locale in the space, passing in the from fields and the locale as arguments. The transform function is expected to return an object with the desired target fields. If it returns undefined, this entry locale will be left untouched.

config : Object – Content transformation definition, with the following properties:

  • sourceContentType : string (required) – Content type ID of source entries

  • targetContentType : string (required) – Targeted Content type ID

  • from : array (optional) – Array of the source field IDs, returns complete list of fields if not configured

  • identityKey: function (fields): string (required) - Function to create a new entry ID for the target entry

  • shouldPublish : bool | 'preserve' (optional) – Flag that specifies publishing of target entries, preserve will keep current states of the source entries (default false)

  • updateReferences : bool (optional) – Flag that specifies if linking entries should be updated with target entries (default false). Note that this flag does not support Rich Text Fields references.

  • removeOldEntries : bool (optional) – Flag that specifies if source entries should be deleted (default false)

  • transformEntryForLocale : function (fields, locale, {id}): object (required) – Transformation function to be applied.

    • fields is an object containing each of the from fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}})
    • locale one of the locales in the space being transformed
    • id id of the current entry in scope

    The return value must be an object with the same keys as specified in the targetContentType. Their values will be written to the respective entry fields for the current locale (i.e. {nameField: 'myNewValue'}). If it returns undefined, this the values for this locale on the entry will be left untouched.

transformEntriesToType Example
const MurmurHash3 = require('imurmurhash')

migration.transformEntriesToType({
  sourceContentType: 'dog',
  targetContentType: 'copycat',
  from: ['woofs'],
  shouldPublish: false,
  updateReferences: false,
  removeOldEntries: false,
  identityKey: function (fields) {
    const value = fields.woofs['en-US'].toString()
    return MurmurHash3(value).result().toString()
  },
  transformEntryForLocale: function (fromFields, currentLocale, { id }) {
    return {
      woofs: `copy - ${fromFields.woofs[currentLocale]}`
    }
  }
})

For the complete version of this migration, please refer to this example.

createTag(id[, opts, visibility])

Creates a tag with provided id and returns a reference to the newly created tag.

  • id : string – The ID of the tag.

  • opts : Object – Tag definition, with the following options:

    • name : string – Name of the tag.
  • visibility : 'private' | 'public' Tag visibility - defaults to private.

editTag(id[, opts])

Edits an existing tag of provided id and returns a reference to the tag. Uses the same options as createTag.

deleteTag(id)

Deletes the tag with the provided id and returns undefined. Note that this deletes the tag even if it is still attached to entries or assets.

setTagsForEntries(config)

For the given content type, updates the tags that are attached to its entries according to the user-provided setTagsForEntry function. For each entry, the CLI will call this function once, passing in the from fields, link objects of all tags that already are attached to the entry and link objects of all tags available in the environment. The setTagsForEntry function is expected to return an array with link objects for all tags that are to be added to the entry. If it returns undefined, the entry will be left untouched.

config : Object – Content transformation definition, with the following properties:

  • contentType : string (required) – Content type ID
  • from : array (required) – Array of the source field IDs
  • setTagsForEntry : function (entryFields, entryTags, apiTags): array (required) – Transformation function to be applied. - entryFields is an object containing each of the from fields. - entryTags is an array containing link objects of all tags already attached to the entry. - apiTags is an array containing link objects of all tags available in the environment.
setTagsForEntries Example
migration.createTag('department-sf').name('Department: San Francisco')
migration.createTag('department-ldn').name('Department: London')

const departmentMapping = {
  'san-francisco': 'department-sf',
  london: 'department-ldn'
}

migration.setTagsForEntries({
  contentType: 'news-article',
  from: ['department'],
  setTagsForEntry: (entryFields, entryTags, apiTags) => {
    const departmentField = entryFields.department['en-US']
    const newTag = apiTags.find((tag) => tag.sys.id === departmentMapping[departmentField])

    return [...entryTags, newTag]
  }
})

context

There may be cases where you want to use Contentful API features that are not supported by the migration object. For these cases you have access to the internal configuration of the running migration in a context object.

module.exports = async function (migration, { makeRequest, spaceId, accessToken }) {
  const contentType = await makeRequest({
    method: 'GET',
    url: `/content_types?sys.id[in]=foo`
  })

  const anyOtherTool = new AnyOtherTool({ spaceId, accessToken })
}

makeRequest(config)

The function used by the migration object to talk to the Contentful Management API. This can be useful if you want to use API features that may not be supported by the migration object.

config : Object - Configuration for the request based on the Contentful management SDK

  • method : string – HTTP method
  • url : string - HTTP endpoint
module.exports = async function (migration, { makeRequest }) {
  const contentType = await makeRequest({
    method: 'GET',
    url: `/content_types?sys.id[in]=foo`
  })
}

spaceId : string

The space ID that was set for the current migration.

accessToken : string

The access token that was set for the current migration.

Content type

For a comprehensive guide to content modelling, please refer to this guide.

createField(id[, opts]) : Field

Creates a field with provided id.

id : string – The ID of the field.

opts : Object – Field definition, with the following options:

  • name : string (required) – Field name.

  • type : string (required) – Field type, amongst the following values:

    • Symbol (Short text)
    • Text (Long text)
    • Integer
    • Number
    • Date
    • Boolean
    • Object
    • Location
    • RichText
    • Array (requires items)
    • Link (requires linkType)
    • ResourceLink (requires allowedResources)
  • items : Object (required for type 'Array') – Defines the items of an Array field. Example:

    items: {
      type: 'Link',
      linkType: 'Entry',
      validations: [
        { linkContentType: [ 'my-content-type' ] }
      ]
    }
  • linkType : string (required for type 'Link') – Type of the referenced entry. Can take the same values as the ones listed for type above.

  • allowedResources (required for type 'ResourceLink') - Defines which resources can be linked through the field.

  • required : boolean – Sets the field as required.

  • validations : Array – Validations for the field. Example:

    validations: [{ in: ['Web', 'iOS', 'Android'] }]

    See The CMA documentation for the list of available validations.

  • localized : boolean – Sets the field as localized.

  • disabled : boolean – Sets the field as disabled, hence not editable by authors.

  • omitted : boolean – Sets the field as omitted, hence not sent in response.

  • deleted : boolean – Sets the field as deleted. Requires to have been omitted first. You may prefer using the deleteField method.

  • defaultValue : Object – Sets the default value for the field. Example:

    defaultValue: {
      "en-US": false,
      "de-DE": true
    }

editField(id[, opts]) : Field

Edits the field of provided id.

id : string – The ID of the field to edit.

opts : Object – Same as createField listed above.

deleteField(id) : void

Shorthand method to omit a field, publish its content type, and then delete the field. This implies that associated content for the field will be lost.

id : string – The ID of the field to delete.

changeFieldId (currentId, newId) : void

Changes the field's ID.

currentId : string – The current ID of the field.

newId : string – The new ID for the field.

moveField (id) : MovableField

Move the field (position of the field in the web editor)

id: string - The ID of the field to move

.moveField(id) returns a movable field type which must be called with a direction function:

  • .toTheTop()
  • .toTheBottom()
  • .beforeField(fieldId)
  • .afterField(fieldId)

Example:

module.exports = function (migration) {
  const food = migration.editContentType('food')

  food.createField('calories').type('Number').name('How many calories does it have?')

  food.createField('sugar').type('Number').name('Amount of sugar')

  food.createField('vegan').type('Boolean').name('Vegan friendly')

  food.createField('producer').type('Symbol').name('Food producer')

  food.createField('gmo').type('Boolean').name('Genetically modified food')

  food.moveField('calories').toTheTop()
  food.moveField('sugar').toTheBottom()
  food.moveField('producer').beforeField('vegan')
  food.moveField('gmo').afterField('vegan')
}

changeFieldControl (fieldId, widgetNamespace, widgetId[, settings]) : void

Changes control interface of given field's ID.

fieldId : string – The ID of the field.

widgetNamespace : string – The namespace of the widget, one of the following values:

  • builtin (Standard widget)
  • app (Custom App)
  • extension (Custom UI extension)
  • app (Custom app widget)

widgetId : string – The new widget ID for the field. See the editor interface documentation for a list of available widgets.

settings : Object – Widget settings and extension instance parameters. Key-value pairs of type (string, number | boolean | string). For builtin widgets, the the following options are available:

  • helpText : string – This help text will show up below the field.
  • trueLabel : string (only for fields of type boolean) – Shows this text next to the radio button that sets this value to true. Defaults to β€œYes”.
  • falseLabel : string (only for fields of type boolean) – Shows this text next to the radio button that sets this value to false. Defaults to β€œNo”.
  • stars : number (only for fields of type rating) – Number of stars to select from. Defaults to 5.
  • format : string (only for fields of type datePicker) – One of β€œdateonly”, β€œtime”, β€œtimeZ” (default). Specifies whether to show the clock and/or timezone inputs.
  • ampm : string (only for fields of type datePicker) – Specifies which type of clock to use. Must be one of the strings β€œ12” or β€œ24” (default).
  • bulkEditing : boolean (only for fields of type Array) – Specifies whether bulk editing of linked entries is possible.
  • trackingFieldId : string (only for fields of type slugEditor) – Specifies the ID of the field that will be used to generate the slug value.
  • showCreateEntityAction : boolean (only for fields of type Link) - specifies whether creation of new entries from the field is enabled.
  • showLinkEntityAction : boolean (only for fields of type Link) - specifies whether linking to existing entries from the field is enabled.

resetFieldControl (fieldId) : void

fieldId : string – The ID of the field.

copyFieldControl (sourceFieldId, destinationFieldId) : void

sourceFieldId : string – The ID of the field to copy the control setting from. destinationFieldId : string – The ID of the field to apply the copied control setting to.

addSidebarWidget (widgetNamespace, widgetId[, settings, insertBeforeWidgetId]) : void

Adds a builtin or custom widget to the sidebar of the content type.

widgetNamespace: string – The namespace of the widget, one of the following values:

  • sidebar-builtin (Standard widget, default)
  • extension (Custom UI extension)

widgetId : string – The ID of the builtin or extension widget to add.

settings : Object – Instance settings for the widget. Key-value pairs of type (string, number | boolean | string)

insertBeforeWidgetId : Object – Insert widget above this widget in the sidebar. If null, the widget will be added to the end.

updateSidebarWidget (widgetNamespace, widgetId, settings) : void

Updates the configuration of a widget in the sidebar of the content type.

widgetNamespace: string – The namespace of the widget, one of the following values:

  • sidebar-builtin (Standard widget, default)
  • extension (Custom UI extension)

widgetId : string – The ID of the builtin or extension widget to add.

settings : Object – Instance settings for the widget. Key-value pairs of type (string, number | boolean | string)

removeSidebarWidget (widgetNamespace, widgetId) : void

Removes a widget from the sidebar of the content type.

widgetNamespace: string – The namespace of the widget, one of the following values:

  • sidebar-builtin (Standard widget, default)
  • extension (Custom UI extension)

widgetId : string – The ID of the builtin or extension widget to remove.

resetSidebarToDefault () : void

Resets the sidebar of the content type to default.

configureEntryEditor (widgetNamespace, widgetId[, settings]) : void

Sets the entry editor to specified widget.

widgetNamespace: string – The namespace of the widget. widgetId : string – The ID of the builtin or extension widget to add. settings : Object – Instance settings for the widget. Key-value pairs of type (string, number | boolean | string). Optional.

configureEntryEditors (EntryEditor[]) : void

As opposed to configureEntryEditor which only sets one editor, this sets a list of editors to the current editor interface of a content-type.

Each EntryEditor has the following properties:

  • widgetNamespace: string – The namespace of the widget (i.e: app, extension or builtin-editor).
  • widgetId : string – The ID of the builtin, extension or app widget to add.
  • settings : Object – Instance settings for the widget. Key-value pairs of type (string, number | boolean | string). Optional.

resetEntryEditorToDefault () : void

Resets the entry editor of the content type to default.

createEditorLayout () : EditorLayout

Creates an empty editor layout for this content type.

editEditorLayout () : EditorLayout

Edits the editor layout for this content type.

deleteEditorLayout () : void

Deletes the editor layout for this content type.

setAnnotations(AnnotationId[])

Configure the annotations assigned to this content type. See annotations documentation for more details on valid AnnotationId.

clearAnnotations()

Remove all assigned annotations from this content type

Field

The field object has the same methods as the properties listed in the ContentType.createField method.

In addition the following methods allow to manage field annotations.

setAnnotations(AnnotationId[])

Configure the annotations assigned to this field. See annotations documentation for more details on valid AnnotationId.

clearAnnotations()

Remove all assigned annotations from this field.

Editor Layout

moveField(id) : MovableEditorLayoutItem

Moves the field with the provided id.

moveField(id) returns a movable editor layout item type which must be called with a direction function:

  • .toTheTopOfFieldGroup(groupId)
      • if no groupId is provided, the field will be moved within its group
  • .toTheBottomOfFieldGroup(groupId)
      • if no groupId is provided, the field will be moved within its group
  • .beforeFieldGroup(groupId)
  • .afterFieldGroup(groupId)
  • .beforeField(fieldId)
  • .afterField(fieldId)

createFieldGroup(id[, opts]) : EditorLayoutFieldGroup

Creates a tab with the provided id.

id : string – The ID of the group.

opts : Object – Group settings, with the following options:

  • name : string (required) – Group name.

deleteFieldGroup (id) : void

Deletes the group with the provided id from the editor layout, moving its contents to the parent if the group to delete is a field set or to the default tab if it’s a tab.

changeFieldGroupId (currentId, newId)

Changes the group’s ID.

currentId : string – The current ID of the group.

newId : string – The new ID for the group.

editFieldGroup (id[, opts]) : EditorLayoutFieldGroup

Editor Layout Field Group

createFieldGroup (id[, opts]) : EditorLayoutFieldGroup

Creates a field set with the provided id.

id : string – The ID of the group.

opts : Object – Group settings, with the following options:

  • name : string (required) – Group name.

changeFieldGroupControl (id, widgetNamespace, widgetId[, settings]) : void

Sets the group control for a field group.

widgetNamespace : string – The namespace for the group control. Currently allowed: builtin. widgetId : string - The widget ID for the group control. Allowed values: fieldset, topLevelTab. settings : Object – Field set settings, with the following properties:

  • helpText : string – Help text for the field set. Displayed when editing.
  • collapsible : boolean – Whether the field set can be collapsed when editing.
  • collapsedByDefault : string – Whether the field set is collapsed when opening the editor.

Validation errors

You can learn more from the possible validation errors here.

Example migrations

You can check out the examples to learn more about the migrations DSL. Each example file is prefixed with a sequence number, specifying the order in which you're supposed to run the migrations, as follows:

const runMigration = require('contentful-migration/built/bin/cli').runMigration

const options = {
  spaceId: '<space-id>',
  accessToken: '<access-token>',
  yes: true
}

const migrations = async () => {
  await runMigration({ ...options, ...{ filePath: '01-angry-dog.js' } })
  await runMigration({ ...options, ...{ filePath: '02-friendly-dog.js' } })
  await runMigration({ ...options, ...{ filePath: '03-long-example.js' } })
  await runMigration({ ...options, ...{ filePath: '04-steps-errors.js' } })
  await runMigration({ ...options, ...{ filePath: '05-plan-errors.js' } })
  await runMigration({ ...options, ...{ filePath: '06-delete-field.js' } })
  await runMigration({ ...options, ...{ filePath: '07-display-field.js' } })
}

migrations()

Writing Migrations in Typescript

You can use Typescript to write your migration files using ts-node! First npm install --save ts-node typescript, then run your migration with ts-node:

node_modules/.bin/ts-node node_modules/.bin/contentful-migration -s $CONTENTFUL_SPACE_ID -a $CONTENTFUL_MANAGEMENT_TOKEN my_migration.ts

An example Typescript migration:

import { MigrationFunction } from 'contentful-migration'

// typecast to 'MigrationFunction' to ensure you get type hints in your editor
export = function (migration, { makeRequest, spaceId, accessToken }) {
  const dog = migration.createContentType('dog', {
    name: 'Dog'
  })

  const name = dog.createField('name')
  name.name('Name').type('Symbol').required(true)
} as MigrationFunction

Here's how it looks inside VS Code:

typescript migration in vscode

Troubleshooting

  • Unable to connect to Contentful through your Proxy? Try to set the rawProxy option to true.
runMigration({
  proxy: 'https://cat:[email protected]:1234',
  rawProxy: true,
  ...
})

Updating Integration tests fixtures

  • To add new/update integration tests, you need to set environment variable NOCK_RECORD=1 which should automatically update fixtures

Reach out to us

You have questions about how to use this library?

  • Reach out to our community forum: Contentful Community Forum
  • Jump into our community slack channel: Contentful Community Slack

You found a bug or want to propose a feature?

  • File an issue here on GitHub: File an issue. Make sure to remove any credential from your code before sharing it.

You need to share confidential information or have other questions?

  • File a support ticket at our Contentful Customer Support: File support ticket

Get involved

PRs Welcome

We appreciate any help on our repositories. For more details about how to contribute see our CONTRIBUTING.md document.

License

This repository is published under the MIT license.

Code of Conduct

We want to provide a safe, inclusive, welcoming, and harassment-free space and experience for all participants, regardless of gender identity and expression, sexual orientation, disability, physical appearance, socioeconomic status, body size, ethnicity, nationality, level of experience, age, religion (or lack thereof), or other identity markers.

More Repositories

1

contentful.js

JavaScript library for Contentful's Delivery API (node & browser)
TypeScript
1,174
star
2

rich-text

Libraries for handling and rendering Rich Text πŸ“„
TypeScript
529
star
3

the-example-app.nodejs

Example app for Contentful in node.js
JavaScript
431
star
4

forma-36

A design system by Contentful
TypeScript
329
star
5

contentful-cli

The official Contentful command line interface. Use Contentful features straight from the command line!
JavaScript
322
star
6

contentful-management.js

JavaScript library for Contentful's Management API (node & browser)
TypeScript
264
star
7

extensions

Repository providing samples using the UI Extensions SDK
JavaScript
201
star
8

contentful.swift

A delightful Swift interface to Contentful's content delivery API.
Swift
195
star
9

starter-gatsby-blog

Gatsby starter for a Contentful project from the community.
JavaScript
194
star
10

cf-graphql

Generate a GraphQL schema out of your Contentful space
JavaScript
185
star
11

blog-in-5-minutes

Vue
170
star
12

contentful-export

This tool allows you to export a Contentful space to a JSON dump
JavaScript
160
star
13

field-editors

React components and extensions for building Contentful entry editor
TypeScript
148
star
14

contentful_middleman

Contentful Middleman is an extension to use the Middleman static site generator (Ruby) together with the API-driven Contentful CMS.
Ruby
145
star
15

Stargate

A communication channel from your Mac to your watch.
Swift
135
star
16

contentful.rb

Ruby client for the Contentful Content Delivery API
Ruby
135
star
17

apps

Apps on the Contentful Marketplace and resources to build them
TypeScript
132
star
18

ui-extensions-sdk

A JavaScript library to develop custom apps for Contentful
TypeScript
120
star
19

discovery-app-react

A React.js based version of the Contentful Discovery app
JavaScript
111
star
20

contentful.php

Official PHP Library for the Content Delivery API
PHP
111
star
21

contentful-import

Node module that uses the data provided by contentful-export to import it to contentful space
TypeScript
99
star
22

jekyll-contentful-data-import

Contentful Plugin for the Jekyll Static Site Generator
Ruby
99
star
23

create-contentful-app

Bootstrap a Contentful App
TypeScript
98
star
24

gallery-app-react

A React application example for the gallery space template.
JavaScript
97
star
25

contentful.net

.NET Library for Contentful's Content Delivery and Management API
C#
95
star
26

template-blog-webapp-nextjs

Next.js blog starter template
TypeScript
89
star
27

contentful-metalsmith

A plugin for Metalsmith that pulls content from the Contentful API
JavaScript
86
star
28

vault

Easy persistence of Contentful data for Android over SQLite.
Java
84
star
29

template-marketing-webapp-nextjs

Next.js marketing website starter template
TypeScript
80
star
30

contentful.java

Java SDK for Contentful's Content Delivery API
Java
74
star
31

create-contentful-extension

Create Contentful Extension is a CLI tool for developing in-app extensions without the hassle of managing build configurations.
JavaScript
71
star
32

ContentfulWatchKitExample

Example for a WatchKit app using the Contentful SDK
Swift
71
star
33

gallery-app-android

Android application example for the gallery space template.
Java
68
star
34

template-ecommerce-webapp-nextjs

Next.js ecommerce website starter template
TypeScript
63
star
35

compose-starter-helpcenter-nextjs

A sample website frontend for Compose with Next.js
TypeScript
59
star
36

live-preview

Preview SDK for both the field tagging connection + live content updates
TypeScript
56
star
37

contentful_rails

A ruby gem to help you quickly integrate Contentful into your Rails site
Ruby
52
star
38

contentful.objc

Objective-C SDK for Contentful's Content Delivery API and Content Management API.
Objective-C
50
star
39

contentful-resolve-response

Resolve items & includes of a Contentful API response into a proper object graph
JavaScript
46
star
40

contentful.py

Python client for the Contentful Content Delivery API https://www.contentful.com/developers/documentation/content-delivery-api/
Python
45
star
41

contentful-laravel

Laravel integration for the Contentful SDK.
PHP
44
star
42

contentful_model

A lightweight wrapper around the Contentful api gem, to make it behave more like ActiveRecord
Ruby
44
star
43

contentful-space-sync

Synchronize Contentful spaces
JavaScript
42
star
44

the-example-app.swift

Example app for Contentful in Swift
Swift
42
star
45

covid-19-site-template

#project-covid19
JavaScript
40
star
46

11ty-contentful-starter

Contentful 11ty starter project.
CSS
39
star
47

contentful-management.py

Python client for the Contentful Content Management API https://www.contentful.com/developers/documentation/content-management-api/
Python
36
star
48

product-catalogue-js

Product catalogue in JavaScript
JavaScript
36
star
49

contentful-management.rb

Ruby client for the Contentful Content Management API
Ruby
33
star
50

ContentfulBundle

Symfony Bundle for the Contentful SDK.
PHP
32
star
51

contribution-program

Contribute to the Contentful blog with pieces on "better ways to build websites". Get rewarded for each post you publish.
30
star
52

contentful_express_tutorial

A Simple Express js application Built on top of Contentful
JavaScript
30
star
53

rich-text-renderer.swift

Render Contentful Rich Text fields to native strings and views
Swift
29
star
54

contentful_jekyll_examples

Examples for Contentful and Jekyll Integration
29
star
55

11ty-contentful-gallery

Photo Gallery made using Contentful and 11ty.
Liquid
28
star
56

guide-app-sw

A generic guide app for shop guides
JavaScript
27
star
57

ls-postman-rest-api

26
star
58

gallery-app-ios

An iOS application example for the gallery space template.
Swift
26
star
59

contentful-management.java

Java library for using the Contentful Content Management API
Java
26
star
60

contentful-bootstrap.rb

Contentful CLI tool for getting started with Contentful
Ruby
24
star
61

contentful-graphql-playground-app

Contentful App to integrate GraphQL Playground
TypeScript
23
star
62

wordpress-exporter.rb

Adapter to extract data from Wordpress
Ruby
23
star
63

contentful-database-importer.rb

Adapter to extract data from SQL Databases https://www.contentful.com
Ruby
23
star
64

blog-app-android

Android application example for the blog space template.
Java
22
star
65

contentful-sdk-core

Core modules for the Contentful JS SDKs
TypeScript
22
star
66

contentful-persistence.swift

Simplified persistence for the Contentful Swift Library.
Swift
21
star
67

content-models

A set of example content models build with and for Contentful
19
star
68

product-catalogue-android

Android application example for the product catalogue space template.
Java
19
star
69

the-example-app.graphql.js

Example app for Contentful with GraphQL with React
JavaScript
19
star
70

boilerplate-javascript

Boilerplate project for getting started using javascript with Contentful
JavaScript
19
star
71

the-example-app.php

Example app for Contentful in PHP
PHP
18
star
72

ng-contentful

Contentful module for AngularJS, providing access to the content delivery API
JavaScript
17
star
73

contentful_middleman_examples

A useful collection of examples using the `contentful_middleman` gem
Ruby
17
star
74

the-example-app.py

Example app for Contentful in Python
Python
17
star
75

The-Learning-Demo

Working repo for the new Learning Demo being developed by Learning Services
CSS
17
star
76

contentful-core.php

Foundation library for Contentful PHP SDKs
PHP
16
star
77

guide-app-ios

A generic iOS app for shop guides, styled as a guide to Coffee places.
Objective-C
16
star
78

starter-hydrogen-store

Example store starter template built with Contentful and Hydrogen framework from Shopify
JavaScript
16
star
79

contentful_django_tutorial

A Simple Django Application using Contentful
CSS
16
star
80

contentful-action

JavaScript
15
star
81

contentful-merge

CLI to merge entries between environments
TypeScript
15
star
82

contentful-batch-libs

Library modules used by contentful batch utility CLI tools.
JavaScript
15
star
83

sveltekit-starter

Starter repo to get started with Sveltekit and Contentful
Svelte
15
star
84

contentful-scheduler.rb

Scheduling Server for Contentful entries
Ruby
15
star
85

blog-app-ios

An iOS application example for the blog space template.
Swift
15
star
86

the-example-app.kotlin

The example Android app. See how to connect to a sample space and use kotlin and Contentful unisono.
Kotlin
15
star
87

contentful-social.rb

Contentful Social Publishing Gem
Ruby
14
star
88

discovery-app-android

Contentful Discovery App for Android
Java
14
star
89

discovery-app

iOS app for previewing the content of Contentful Spaces
Objective-C
14
star
90

ls-content-as-code

Example content migration API scripts
JavaScript
13
star
91

blog-app-laravel

Example app using Contentful with Laravel.
PHP
13
star
92

slash-developers

THIS REPOSITORY IS DEPRECATED. Please do not open new PRs or issues.
HTML
13
star
93

node-apps-toolkit

A collection of helpers and utilities for creating NodeJS Contentful Apps
TypeScript
12
star
94

rich-text.php

Utilities for the Contentful Rich Text
PHP
12
star
95

the-example-app.csharp

Example app for Contentful in C#
C#
12
star
96

the-example-app.graphql.swift

The Example App and Contentful GraphQL Endpoint, using Apollo iOS, Contentful/ImageOptions
Swift
12
star
97

contentful-link-cleaner

Cleans up unresolved Entry links in Contentful spaces
JavaScript
11
star
98

tvful

Example for using the Contentful SDK for tvOS apps.
Swift
11
star
99

contentful-sdk-jsdoc

JSDoc template and config for the Contentful JS SDKs
JavaScript
10
star
100

generator.java

Code generator for Contentful models
Shell
10
star