Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contentful/app-action-utils

Package Overview
Dependencies
Maintainers
156
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentful/app-action-utils - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

70

dist/index.d.ts

@@ -29,3 +29,3 @@ import { PlainClientAPI } from 'contentful-management';

type AppActionResponseError = {
error: string;
errorMessage: string;
};

@@ -41,2 +41,10 @@ type AppActionResponseSuccess<Result> = {

/**
* @typedef {Object} GetAppActionCallDetailsProps
* @property {PlainClientAPI} api - Contentful Management API
* @property {string} appActionId - App Action ID
* @property {string} callId - Call ID
* @property {string} [spaceId=] - Space ID
* @property {string} [environmentId=] - Environment ID
*/
type GetAppActionCallDetailsProps = {

@@ -62,5 +70,15 @@ api: PlainClientAPI;

type GeneratedDetailsCall = () => Promise<DetailsResult>;
/**
* Get the details of an App Action call
* @param {GetAppActionCallDetailsProps} props - Object containing the parameters
* @return {GeneratedDetailsCall} - Function that returns the details of the App Action call
*/
declare function getAppActionCallDetails({ api, appActionId, callId, spaceId, environmentId, }: GetAppActionCallDetailsProps): GeneratedDetailsCall;
type BaseParameters = Record<string, string>;
/**
* @typedef {Object} AdditionalParameters
* @property {string} spaceId - Space ID
* @property {string} environmentId - Environment ID
*/
type AdditionalParameters = {

@@ -70,2 +88,13 @@ spaceId: string;

};
/**
* @typedef {Object} CallAppActionProps
* @property {PlainClientAPI} api - Contentful Management API
* @property {string} appActionId - App Action ID
* @property {string} appDefinitionId - App Definition ID
* @property {Parameters} parameters - App Action parameters, can be fully typed with AppActionCategoryParams<'<appActionCategory>'>
* @property {AbortSignal} [abortSignal=] - Abort signal
* @property {number} [timeout=10000] - Max timeout for the call and retrieving the result
* @property {number} [retryInterval=1000] - Interval between retries
* @property {AdditionalParameters} [additionalParameters=] - Additional parameters in case they are not set in the client
*/
type CallAppActionProps<Parameters extends BaseParameters = BaseParameters> = {

@@ -81,4 +110,26 @@ api: PlainClientAPI;

};
/**
* Call an App Action and get the result
*
* @typedef {Object} ActionCallResult
* @property {ActionCallResponse<TMessage>} result - Result of the App Action
* @property {string} callId - Call ID
*
* @param {CallAppActionProps} props - Object containing the parameters
* @return {Promise<ActionCallResult>} - Result of the App Action of type TMessage
*
* @template TMessage - Type of the message returned by the App Action
*/
declare function callAppAction<Parameters extends BaseParameters, TMessage = unknown>({ api, appActionId, appDefinitionId, parameters, timeout, retryInterval, abortSignal, additionalParameters, }: CallAppActionProps<Parameters>): Promise<ActionCallResponse<TMessage>>;
/**
* @typedef {Object} CallAppActionResultProps
* @property {PlainClientAPI} api - Contentful Management API
* @property {string} appActionId - App Action ID
* @property {string} callId - Call ID
* @property {Parameters} parameters - App Action parameters, can be fully typed with AppActionCategoryParams<'<appActionCategory>'>
* @property {AbortSignal} [abortSignal=] - Abort signal
* @property {number} [timeout=10000] - Max timeout for the call and retrieving the result
* @property {number} [retryInterval=1000] - Interval between retries
*/
type CallAppActionResultProps = {

@@ -94,2 +145,14 @@ api: PlainClientAPI;

};
/**
* Call an App Action and get the result
*
* @typedef {Object} ActionCallResult
* @property {ActionCallResponse<Result>} result - Result of the App Action
* @property {string} callId - Call ID
*
* @param {CallAppActionResultProps} props - Object containing the parameters
* @return {Promise<ActionCallResult>} - Result of the App Action of type TMessage
*
* @template Result - Type of the message returned by the App Action
*/
declare function callAppActionResult<Result = any>({ api, appActionId, spaceId, environmentId, callId, timeout, retryInterval, abortSignal, }: CallAppActionResultProps): Promise<AppActionResponse<Result>>;

@@ -108,2 +171,5 @@

export { ActionCallResponse, AppActionCallError, AppActionCategoryParams, AppActionResponse, AppActionResponseError, AppActionResponseSuccess, CallAppActionParams, ContentfulError, DetailsResult, NotFoundError, ParsingError, PolledDetailsResult, ResponseStatus, callAppAction, callAppActionResult, getAppActionCallDetails };
declare function safeParse(body: string): any;
declare function isResultWithError<T>(result: AppActionResponse<T>): result is AppActionResponseError;
export { ActionCallResponse, AppActionCallError, AppActionCategoryParams, AppActionResponse, AppActionResponseError, AppActionResponseSuccess, CallAppActionParams, ContentfulError, DetailsResult, NotFoundError, ParsingError, PolledDetailsResult, ResponseStatus, callAppAction, callAppActionResult, getAppActionCallDetails, isResultWithError, safeParse };

19

dist/index.js

@@ -30,3 +30,5 @@ "use strict";

callAppActionResult: () => callAppActionResult,
getAppActionCallDetails: () => getAppActionCallDetails
getAppActionCallDetails: () => getAppActionCallDetails,
isResultWithError: () => isResultWithError,
safeParse: () => safeParse
});

@@ -108,2 +110,5 @@ module.exports = __toCommonJS(src_exports);

}
function isResultWithError(result) {
return result.hasOwnProperty("errorMessage");
}

@@ -150,5 +155,7 @@ // src/callAppAction/callAppActionResult.ts

}
return safeParse(
safeParse(pollResult.result.response.body)
);
let parsedResult = safeParse(pollResult.result.response.body);
if (typeof parsedResult === "string") {
parsedResult = safeParse(parsedResult);
}
return parsedResult;
}

@@ -211,3 +218,5 @@ async function poll(fn, fnCondition, abortSignal, interval = 1e3, timeout = 1e3 * 100) {

callAppActionResult,
getAppActionCallDetails
getAppActionCallDetails,
isResultWithError,
safeParse
});
{
"name": "@contentful/app-action-utils",
"description": "Utilities for intearcting with Hosted App Actions",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "author": "Contentful <opensource@contentful.com>",

@@ -1,9 +0,5 @@

# Utils package for Hosted App Actions
# Utils package for App Actions
This repo is a growing collection of utils for interacting with App Actions
## Compatibiltiy
Requires an [Node.js LTS version](https://github.com/nodejs/Release), at least 16.13. Odd-numbered and not-yet LTS major versions are not supported.
## Installation

@@ -44,3 +40,3 @@

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

@@ -56,6 +52,3 @@ const additionalParameters = {

appDefinitionId: '<appDefinitionId>',
timeout: 10000, // Not required and 10000 is the default
abortSignal: abortController.signal // Not required
retryInterval: 1000 // Not required, 1000 is the default,
additionalParameters // Not required if the client has the defaults set
parameters,
})

@@ -71,7 +64,4 @@ ```

callId: '<callId>',
spaceId: '<spaceId>', // Not required if the client has set it as a default
environmentId: '<environmentId>', // Not required if the client has set it as a default
timeout: 10000, // Not required and 10000 is the default
abortSignal: abortController.signal // Not required
retryInterval: 1000 // Not required, 1000 is the default,
spaceId: '<spaceId>',
environmentId: '<environmentId>'
})

@@ -78,0 +68,0 @@ ```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc