Extension

Extension

Source:
Extensions let you create custom fields and custom widgets that lets you customize Contentstack's default UI and behavior. Read more about Extensions.

Methods

(static) update() → {Promise.<Extension.Extension>}

Source:
The Update Extension call lets you update an existing Extension.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).extension('extension_uid').fetch()
.then((extension) => {
 extension.title = 'My Extension Type'
 return extension.update()
})
.then((extension) => console.log(extension))
Returns:
Promise for Extension instance.
Type
Promise.<Extension.Extension>

(static) delete() → {Object}

Source:
The Delete Extension call is used to delete an existing Extension permanently from your Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).extension('extension_uid').delete()
.then((response) => console.log(response.notice))
Returns:
Response Object.
Type
Object

(static) fetch() → {Promise.<Extension.Extension>}

Source:
The fetch Extension call fetches Extension details.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).extension('extension_uid').fetch()
.then((extension) => console.log(extension))
Returns:
Promise for Extension instance
Type
Promise.<Extension.Extension>

(static) upload() → {Promise.<Extension.Extension>}

Source:
The Upload is used to upload a new custom widget, custom field, dashboard Widget to a stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

const extension = {
 upload: 'path/to/file',
 title: 'Title',
 tags: [
   'tag1',
   'tag2'
 ],
 data_type: 'text',
 title: 'Old Extension',
 multiple: false,
 config: {},
 type: 'Type of extenstion you want to create widget/dashboard/field'
}

client.stack({ api_key: 'api_key'}).extension().upload(extension)
.then((extension) => console.log(extension))
Returns:
Promise for Extension instance
Type
Promise.<Extension.Extension>

(static) create() → {Promise.<Extension.Extension>}

Source:
The Create a extension call creates a new extension in a particular stack of your Contentstack account.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const extension = {
 tags: [
   'tag1',
   'tag2'
 ],
 data_type: 'text',
 title: 'Old Extension',
 src: "Enter either the source code (use 'srcdoc') or the external hosting link of the extension depending on the hosting method you selected.",
 multiple: false,
 config: {},
 type: 'field'
}

client.stack().extension().create({ extension })
.then((extension) => console.log(extension))
Returns:
Promise for Extension instance
Type
Promise.<Extension.Extension>

(static) query(include_count) → {Array.<Extension>}

Source:
The Query on Content Type will allow to fetch details of all or specific Content Type
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack().extension().query({ query={"type":"field"}})
.then((extensions) => console.log(extensions))
Parameters:
Name Type Description
include_count Boolean Set this to 'true' to include in response the total count of content types available in your stack.
Returns:
Array of ContentTyoe.
Type
Array.<Extension>