import type { MakeRequest, QueryOptions, SpaceQueryOptions } from './common-types'; import type { CreateAppBundleProps } from './entities/app-bundle'; import type { UpsertResourceProviderProps } from './entities/resource-provider'; /** * @private */ export type ContentfulAppDefinitionAPI = ReturnType; /** * @private */ export default function createAppDefinitionApi(makeRequest: MakeRequest): { /** * Sends an update to the server with any changes made to the object's properties * @return Object returned from the server with updated changes. * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => { * appDefinition.name = 'New App Definition name' * return appDefinition.update() * }) * .then((appDefinition) => console.log(`App Definition ${appDefinition.sys.id} updated.`)) * .catch(console.error) * ``` */ update: () => Promise; /** * Deletes this object on the server. * @return Promise for the deletion. It contains no data, but the Promise error case should be handled. * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => appDefinition.delete()) * .then(() => console.log(`App Definition deleted.`)) * .catch(console.error) * ``` */ delete: () => Promise; /** * Gets an app bundle * @param id - AppBundle ID * @return Promise for an AppBundle * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => appDefinition.getAppBundle('')) * .then((appBundle) => console.log(appBundle)) * .catch(console.error) * ``` */ getAppBundle(id: string): Promise; /** * Gets a collection of AppBundles * @return Promise for a collection of AppBundles * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => appDefinition.getAppBundles()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getAppBundles(query?: QueryOptions): Promise>; /** * Creates an app bundle * @param Object representation of the App Bundle to be created * @return Promise for the newly created AppBundle * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => appDefinition.createAppBundle('')) * .then((appBundle) => console.log(appBundle)) * .catch(console.error) * ``` */ createAppBundle(data: CreateAppBundleProps): Promise; /** * Gets a list of App Installations across an org for given organization and App Definition * If a spaceId is provided in the query object, it will return the App Installations for that specific space. * @return Promise for the newly created AppBundle * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * client.getAppDefinition('', '') * .then((appDefinition) => appDefinition.getInstallationsForOrg( * { spaceId: '' } // optional * )) * .then((appInstallationsForOrg) => console.log(appInstallationsForOrg.items)) * .catch(console.error) * ``` */ getInstallationsForOrg(query?: SpaceQueryOptions): Promise; /** * Creates or updates a resource provider * @param data representation of the ResourceProvider * @return Promise for the newly created or updated ResourceProvider * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * // You need a valid AppDefinition with an activated AppBundle that has a contentful function configured * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => appDefinition.upsertResourceProvider({ * sys: { * id: '' * }, * type: 'function', * function: { * sys: { * id: '', * type: 'Link' * linkType: 'Function' * } * } * })) * .then((resourceProvider) => console.log(resourceProvider)) * .catch(console.error) * ``` */ upsertResourceProvider(data: UpsertResourceProviderProps): Promise; /** * Gets a Resource Provider * @return Promise for a Resource Provider * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => appDefinition.getResourceProvider()) * .then((resourceProvider) => console.log(resourceProvider)) * .catch(console.error) * ``` */ getResourceProvider(): Promise; };