UNPKG

6.94 kBTypeScriptView Raw
1import type { MakeRequest, QueryOptions, SpaceQueryOptions } from './common-types';
2import type { CreateAppBundleProps } from './entities/app-bundle';
3import type { UpsertResourceProviderProps } from './entities/resource-provider';
4/**
5 * @private
6 */
7export type ContentfulAppDefinitionAPI = ReturnType<typeof createAppDefinitionApi>;
8/**
9 * @private
10 */
11export default function createAppDefinitionApi(makeRequest: MakeRequest): {
12 /**
13 * Sends an update to the server with any changes made to the object's properties
14 * @return Object returned from the server with updated changes.
15 * @example ```javascript
16 * const contentful = require('contentful-management')
17 *
18 * const client = contentful.createClient({
19 * accessToken: '<content_management_api_key>'
20 * })
21 *
22 * client.getOrganization('<org_id>')
23 * .then((org) => org.getAppDefinition('<app_def_id>'))
24 * .then((appDefinition) => {
25 * appDefinition.name = 'New App Definition name'
26 * return appDefinition.update()
27 * })
28 * .then((appDefinition) => console.log(`App Definition ${appDefinition.sys.id} updated.`))
29 * .catch(console.error)
30 * ```
31 */
32 update: () => Promise<import("./entities/app-definition").AppDefinition>;
33 /**
34 * Deletes this object on the server.
35 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
36 * @example ```javascript
37 * const contentful = require('contentful-management')
38 *
39 * const client = contentful.createClient({
40 * accessToken: '<content_management_api_key>'
41 * })
42 *
43 * client.getOrganization('<org_id>')
44 * .then((org) => org.getAppDefinition('<app_def_id>'))
45 * .then((appDefinition) => appDefinition.delete())
46 * .then(() => console.log(`App Definition deleted.`))
47 * .catch(console.error)
48 * ```
49 */
50 delete: () => Promise<any>;
51 /**
52 * Gets an app bundle
53 * @param id - AppBundle ID
54 * @return Promise for an AppBundle
55 * @example ```javascript
56 * const contentful = require('contentful-management')
57 * const client = contentful.createClient({
58 * accessToken: '<content_management_api_key>'
59 * })
60 *
61 * client.getOrganization('<org_id>')
62 * .then((org) => org.getAppDefinition('<app_def_id>'))
63 * .then((appDefinition) => appDefinition.getAppBundle('<app_upload_id>'))
64 * .then((appBundle) => console.log(appBundle))
65 * .catch(console.error)
66 * ```
67 */
68 getAppBundle(id: string): Promise<import("./entities/app-bundle").AppBundle>;
69 /**
70 * Gets a collection of AppBundles
71 * @return Promise for a collection of AppBundles
72 * @example ```javascript
73 * const contentful = require('contentful-management')
74 * const client = contentful.createClient({
75 * accessToken: '<content_management_api_key>'
76 * })
77 *
78 * client.getOrganization('<org_id>')
79 * .then((org) => org.getAppDefinition('<app_def_id>'))
80 * .then((appDefinition) => appDefinition.getAppBundles())
81 * .then((response) => console.log(response.items))
82 * .catch(console.error)
83 * ```
84 */
85 getAppBundles(query?: QueryOptions): Promise<import("./common-types").Collection<import("./entities/app-bundle").AppBundle, import("./entities/app-bundle").AppBundleProps>>;
86 /**
87 * Creates an app bundle
88 * @param Object representation of the App Bundle to be created
89 * @return Promise for the newly created AppBundle
90 * @example ```javascript
91 * const contentful = require('contentful-management')
92 * const client = contentful.createClient({
93 * accessToken: '<content_management_api_key>'
94 * })
95 * client.getOrganization('<org_id>')
96 * .then((org) => org.getAppDefinition('<app_def_id>'))
97 * .then((appDefinition) => appDefinition.createAppBundle('<app_upload_id>'))
98 * .then((appBundle) => console.log(appBundle))
99 * .catch(console.error)
100 * ```
101 */
102 createAppBundle(data: CreateAppBundleProps): Promise<import("./entities/app-bundle").AppBundle>;
103 /**
104 * Gets a list of App Installations across an org for given organization and App Definition
105 * If a spaceId is provided in the query object, it will return the App Installations for that specific space.
106 * @return Promise for the newly created AppBundle
107 * @example ```javascript
108 * const contentful = require('contentful-management')
109 * const client = contentful.createClient({
110 * accessToken: '<content_management_api_key>'
111 * })
112 * client.getAppDefinition('<organization_id>', '<app_definition_id>')
113 * .then((appDefinition) => appDefinition.getInstallationsForOrg(
114 * { spaceId: '<space_id>' } // optional
115 * ))
116 * .then((appInstallationsForOrg) => console.log(appInstallationsForOrg.items))
117 * .catch(console.error)
118 * ```
119 */
120 getInstallationsForOrg(query?: SpaceQueryOptions): Promise<import("./entities/app-definition").AppInstallationsForOrganizationProps>;
121 /**
122 * Creates or updates a resource provider
123 * @param data representation of the ResourceProvider
124 * @return Promise for the newly created or updated ResourceProvider
125 * @example ```javascript
126 * const contentful = require('contentful-management')
127 * const client = contentful.createClient({
128 * accessToken: '<content_management_api_key>'
129 * })
130 *
131 * // You need a valid AppDefinition with an activated AppBundle that has a contentful function configured
132 * client.getOrganization('<org_id>')
133 * .then((org) => org.getAppDefinition('<app_def_id>'))
134 * .then((appDefinition) => appDefinition.upsertResourceProvider({
135 * sys: {
136 * id: '<resource_provider_id>'
137 * },
138 * type: 'function',
139 * function: {
140 * sys: {
141 * id: '<contentful_function_id>',
142 * type: 'Link'
143 * linkType: 'Function'
144 * }
145 * }
146 * }))
147 * .then((resourceProvider) => console.log(resourceProvider))
148 * .catch(console.error)
149 * ```
150 */
151 upsertResourceProvider(data: UpsertResourceProviderProps): Promise<import("./entities/resource-provider").ResourceProvider>;
152 /**
153 * Gets a Resource Provider
154 * @return Promise for a Resource Provider
155 * @example ```javascript
156 * const contentful = require('contentful-management')
157 * const client = contentful.createClient({
158 * accessToken: '<content_management_api_key>'
159 * })
160 *
161 * client.getOrganization('<org_id>')
162 * .then((org) => org.getAppDefinition('<app_def_id>'))
163 * .then((appDefinition) => appDefinition.getResourceProvider())
164 * .then((resourceProvider) => console.log(resourceProvider))
165 * .catch(console.error)
166 * ```
167 */
168 getResourceProvider(): Promise<import("./entities/resource-provider").ResourceProvider>;
169};