UNPKG

2.93 kBTypeScriptView Raw
1import type { DefaultElements, BasicMetaSysProps, SysLink, MakeRequest } from '../common-types';
2import type { Except } from 'type-fest';
3import type { FreeFormParameters } from './widget-parameters';
4export type AppInstallationProps = {
5 sys: Omit<BasicMetaSysProps, 'id'> & {
6 appDefinition: SysLink;
7 environment: SysLink;
8 space: SysLink;
9 organization: SysLink;
10 };
11 /**
12 * Free-form installation parameters (API limits stringified length to 32KB)
13 */
14 parameters?: FreeFormParameters;
15};
16export type CreateAppInstallationProps = Except<AppInstallationProps, 'sys'>;
17export interface AppInstallation extends AppInstallationProps, DefaultElements<AppInstallationProps> {
18 /**
19 * Sends an update to the server with any changes made to the object's properties
20 * @return Object returned from the server with updated changes.
21 * @example ```javascript
22 * const contentful = require('contentful-management')
23 *
24 * const client = contentful.createClient({
25 * accessToken: '<content_management_api_key>'
26 * })
27 *
28 * client.getSpace('<space_id>')
29 * .then((space) => space.getEnvironment('<environment_id>'))
30 * .then((environment) => environment.getAppInstallation('<app_definition_id>'))
31 * .then((appInstallation) => {
32 * appInstallation.parameters.someParameter = 'New Value'
33 * return appInstallation.update()
34 * })
35 * .then((appInstallation) => console.log(`App installation ${appInstallation.sys.id} was updated`))
36 * .catch(console.error)
37 * ```
38 */
39 update(): Promise<AppInstallation>;
40 /**
41 * Deletes this object on the server.
42 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
43 * @example ```javascript
44 * const contentful = require('contentful-management')
45 *
46 * const client = contentful.createClient({
47 * accessToken: '<content_management_api_key>'
48 * })
49 *
50 * client.getSpace('<space_id>')
51 * .then((space) => space.getEnvironment('<environment_id>'))
52 * .then((environment) => environment.getAppInstallation('<app_definition_id>'))
53 * .then((appInstallation) => appInstallation.delete())
54 * .then(() => console.log(`App installation deleted.`))
55 * .catch(console.error)
56 * ```
57 */
58 delete(): Promise<void>;
59}
60/**
61 * @private
62 * @param makeRequest - function to make requests via an adapter
63 * @param data - Raw App Installation data
64 * @return Wrapped App installation data
65 */
66export declare function wrapAppInstallation(makeRequest: MakeRequest, data: AppInstallationProps): AppInstallation;
67/**
68 * @private
69 */
70export declare const wrapAppInstallationCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<AppInstallationProps>) => import("../common-types").Collection<AppInstallation, AppInstallationProps>;