App 动作的 Utils 软件包
此 repo 是越来越多的用于与 App Action 交互的 utils 集合
安装
npm install --save @contentful/app-action-utils
# or
yarn add @contentful/app-action-utils
可用特性
现在它只支持调用应用操作 并收回结果。 这包括:
- 调用应用程序动作
- 获取应用程序动作结果
- 投票、重试和详细分析
所需资源
当通过从 contentful-management它必须 org, (中文(简体) ), space 财务报告和审定财务报表 environment 设置为默认值。 狦ぃ筁 spaceId 财务报告和审定财务报表 environmentId 每一个方法.
使用量
要求应用动作并获得结果
呼叫应用程序动作并获得结果 callAppAction 可以像这样使用
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,
})
获取上次通话的结果
const appActionResult = await callAppActionResult({
api,
appActionId: '<appActionId>',
callId: '<callId>',
spaceId: '<spaceId>',
environmentId: '<environmentId>'
})