UNPKG

3.4 kBTypeScriptView Raw
1import type { Except } from 'type-fest';
2import type { BasicMetaSysProps, DefaultElements, MakeRequest, SysLink } from '../common-types';
3import type { ParameterDefinition } from './widget-parameters';
4type AppActionSys = Except<BasicMetaSysProps, 'version'> & {
5 appDefinition: SysLink;
6 organization: SysLink;
7};
8export type AppActionParameterDefinition = Omit<ParameterDefinition, 'labels'>;
9export type AppActionCategoryProps = {
10 sys: {
11 id: AppActionCategoryType;
12 type: 'AppActionCategory';
13 version: string;
14 };
15 name: string;
16 description: string;
17 parameters?: AppActionParameterDefinition[];
18};
19type BuiltInCategoriesProps = {
20 /**
21 * Category identifying the shape of the action.
22 */
23 category: 'Entries.v1.0' | 'Notification.v1.0';
24};
25type CustomAppActionProps = {
26 /**
27 * "Custom" category requires "parameters"
28 */
29 category: 'Custom';
30 parameters: AppActionParameterDefinition[];
31};
32type AppActionCategory = BuiltInCategoriesProps | CustomAppActionProps;
33export type AppActionCategoryType = AppActionCategory['category'];
34export type AppActionType = 'endpoint' | 'function' | 'function-invocation';
35export type CreateAppActionProps = AppActionCategory & {
36 url: string;
37 name: string;
38 description?: string;
39 type?: AppActionType;
40};
41export type AppActionProps = AppActionCategory & {
42 /**
43 * System metadata
44 */
45 sys: AppActionSys;
46 /**
47 * Url that will be called when the action is invoked
48 */
49 url: string;
50 /**
51 * Human readable name for the action
52 */
53 name: string;
54 /**
55 * Human readable description of the action
56 */
57 description?: string;
58 /**
59 * Type of the action, defaults to endpoint if not provided
60 * endpoint: action is sent to specified URL
61 * function: deprecated, use function-invocation instead
62 * function-invocation: action invokes a contentful function
63 */
64 type?: AppActionType;
65};
66export type AppAction = AppActionProps & DefaultElements<AppActionProps> & {
67 /**
68 * Deletes this object on the server.
69 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
70 * @example ```javascript
71 * const contentful = require('contentful-management')
72 *
73 * const client = contentful.createClient({
74 * accessToken: '<content_management_api_key>'
75 * })
76 *
77 * client.getOrganization('<org_id>')
78 * .then((org) => org.getAppDefinition('<app_def_id>'))
79 * .then((appDefinition) => appDefinition.getAppAction('<app-action-id>'))
80 * .then((appAction) => appAction.delete())
81 * .catch(console.error)
82 * ```
83 */
84 delete(): Promise<void>;
85};
86/**
87 * @private
88 * @param makeRequest - function to make requests via an adapter
89 * @param data - Raw App Bundle data
90 * @return Wrapped App Bundle data
91 */
92export declare function wrapAppAction(makeRequest: MakeRequest, data: AppActionProps): AppAction;
93/**
94 * @private
95 * @param makeRequest - function to make requests via an adapter
96 * @param data - Raw App Bundle collection data
97 * @return Wrapped App Bundle collection data
98 */
99export declare const wrapAppActionCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<AppActionProps>) => import("../common-types").Collection<AppAction, AppActionProps>;
100export {};