1.4.0 • Published 6 months ago

@contentful/app-action-utils v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Utils package for App Actions

This repo is a growing collection of utils for interacting with App Actions

Installation

npm install --save @contentful/app-action-utils
# or
yarn add @contentful/app-action-utils

Available features

Right now it only supports calling the app action and retrieving the result. This consist of:

  • Calling app actions
  • Getting an app action result
  • Polling, retrying and parsing of the details call

Requirements

When passing the plain client generated from contentful-management, it has to have org, space and environment set as defaults. If not you can pass in the spaceId and environmentId to each of the methods.

Usage

Calling an app action and getting the result

To call an app action and get the result callAppAction can be used like this

import { createClient } from 'contentful-management'


const api = createClient({
    accessToken: '<token>'
}, {
    type: 'plain'
})

const parameters: AppActionCategoryParams<'<appActionCategory>'> = {} // The parameters the app action expects, when the generic is correct it will be fully typed
const abortController = new AbortController()
const additionalParameters = {
    spaceId: '<spaceId>',
    environmentId: '<environmentId>'
}

const appActionResult = await callAppAction({
    api,
    appActionId: '<appActionId>',
    appDefinitionId: '<appDefinitionId>',
    parameters, 
})

Getting the result of a previous call

const appActionResult = await callAppActionResult({
    api,
    appActionId: '<appActionId>',
    callId: '<callId>',
    spaceId: '<spaceId>',
    environmentId: '<environmentId>'
})
1.4.0

6 months ago

1.2.3

1 year ago

1.3.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago