# @contentful/app-action-utils

> Utilities for intearcting with Hosted App Actions

Latest version **1.4.1** (published 2024-07-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @contentful/app-action-utils
pnpm add @contentful/app-action-utils
yarn add @contentful/app-action-utils
bun add @contentful/app-action-utils
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2024-07-30 |
| First published | 2023-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.13 |
| Dependencies | 0 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Contentful |
| Maintainers | stephenlloyd-cf, michaelpearce, it-internal, whydah-gally, contentful-ecosystem |

## Links

- npm: https://www.npmjs.com/package/@contentful/app-action-utils
- Repository: https://github.com/contentful/app-action-utils
- Homepage: https://github.com/contentful/app-action-utils#readme
- Issues: https://github.com/contentful/app-action-utils/issues
- npm.io page: https://npm.io/package/@contentful/app-action-utils

## Recent versions

- 1.4.1 (latest) — 2024-07-30
- 1.4.0 — 2023-10-31
- 1.3.0 — 2023-05-05
- 1.2.3 — 2023-04-19
- 1.2.2 — 2023-03-14
- 1.2.1 — 2023-03-02
- 1.2.0 — 2023-02-21
- 1.1.0 — 2023-02-21
- 1.0.0 — 2023-02-20

## README

# Utils package for App Actions

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

## Installation
 
```shell
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

```ts
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

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

---
_Source: https://npm.io/package/@contentful/app-action-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
