11import cloneDeep from 'lodash/cloneDeep'
22import error from '../core/contentstackError'
33import { create , deleteEntity , fetch , fetchAll , update } from '../entity'
4+ import { Hosting } from './hosting'
45import { Installation } from './installation'
6+
57export function App ( http , data ) {
68 http . defaults . versioningStrategy = undefined
7- this . urlPath = '/apps '
9+ this . urlPath = '/manifests '
810 this . params = { }
911 if ( data ) {
1012 if ( data . organization_uid ) {
@@ -19,10 +21,10 @@ export function App (http, data) {
1921 organization_uid : this . organization_uid
2022 }
2123 }
22- this . urlPath = `/apps /${ this . uid } `
24+ this . urlPath = `/manifests /${ this . uid } `
2325
2426 /**
25- * @description The update an app call is used to update the app details such as name, description, icon, and so on.
27+ * @description The update manifest call is used to update the app details such as name, description, icon, and so on.
2628 * @memberof App
2729 * @func update
2830 * @returns {Promise<App> }
@@ -35,7 +37,7 @@ export function App (http, data) {
3537 * description: 'APP_DESCRIPTION',
3638 * target_type: 'stack'/'organization',
3739 * }
38- * const app = client.organization('organization_uid').app('app_uid ')
40+ * const app = client.organization('organization_uid').app('manifest_uid ')
3941 * app = Object.assign(app, updateApp)
4042 * app.update()
4143 * .then((app) => console.log(app))
@@ -44,7 +46,7 @@ export function App (http, data) {
4446 this . update = update ( http , undefined , this . params )
4547
4648 /**
47- * @description The get app details call is used to fetch details of a particular app with its ID.
49+ * @description The get manifest call is used to fetch details of a particular app with its ID.
4850 * @memberof App
4951 * @func fetch
5052 * @returns {Promise<App> }
@@ -53,14 +55,14 @@ export function App (http, data) {
5355 * import * as contentstack from '@contentstack/management'
5456 * const client = contentstack.client({ authtoken: 'TOKEN'})
5557 *
56- * client.organization('organization_uid').app('app_uid ').fetch()
58+ * client.organization('organization_uid').app('manifest_uid ').fetch()
5759 * .then((app) => console.log(app))
5860 *
5961 */
6062 this . fetch = fetch ( http , 'data' , this . params )
6163
6264 /**
63- * @description The delete an app call is used to delete the app.
65+ * @description The delete manifest call is used to delete the app.
6466 * @memberof App
6567 * @func delete
6668 * @returns {Promise<Response> }
@@ -69,7 +71,7 @@ export function App (http, data) {
6971 * import * as contentstack from '@contentstack/management'
7072 * const client = contentstack.client({ authtoken: 'TOKEN'})
7173 *
72- * client.organization('organization_uid').app('app_uid ').delete()
74+ * client.organization('organization_uid').app('manifest_uid ').delete()
7375 * .then((response) => console.log(response))
7476 */
7577 this . delete = deleteEntity ( http , false , this . params )
@@ -84,7 +86,7 @@ export function App (http, data) {
8486 * import * as contentstack from '@contentstack/management'
8587 * const client = contentstack.client({ authtoken: 'TOKEN'})
8688 *
87- * client.organization('organization_uid').app('app_uid ').fetchOAuth()
89+ * client.organization('organization_uid').app('manifest_uid ').fetchOAuth()
8890 * .then((oAuthConfig) => console.log(oAuthConfig))
8991 */
9092 this . fetchOAuth = async ( param = { } ) => {
@@ -127,7 +129,7 @@ export function App (http, data) {
127129 * scopes: ['scope1', 'scope2']
128130 * }
129131 * }
130- * client.organization('organization_uid').app('app_uid ').updateOAuth({ config })
132+ * client.organization('organization_uid').app('manifest_uid ').updateOAuth({ config })
131133 * .then((oAuthConfig) => console.log(oAuthConfig))
132134 */
133135 this . updateOAuth = async ( { config, param = { } } ) => {
@@ -150,6 +152,22 @@ export function App (http, data) {
150152 }
151153 }
152154
155+ /**
156+ * @description The hosting will allow you get, update, deploy manifest.
157+ * @memberof App
158+ * @func updateOAuth
159+ * @returns {Promise<AppOAuth> }
160+ * @returns {Hosting }
161+ *
162+ * @example
163+ * import * as contentstack from '@contentstack/management'
164+ * const client = contentstack.client({ authtoken: 'TOKEN'})
165+ * client.organization('organization_uid').app('manifest_uid').hosting()
166+ */
167+ this . hosting = ( ) => {
168+ return new Hosting ( http , { app_uid : this . uid } , this . params )
169+ }
170+
153171 /**
154172 * @description The install call is used to initiate the installation of the app
155173 * @memberof App
@@ -161,7 +179,7 @@ export function App (http, data) {
161179 * @example
162180 * import * as contentstack from '@contentstack/management'
163181 * const client = contentstack.client({ authtoken: 'TOKEN'})
164- * client.organization('organization_uid').app('app_uid ').install({ targetUid: 'STACK_API_KEY', targetType: 'stack' })
182+ * client.organization('organization_uid').app('manifest_uid ').install({ targetUid: 'STACK_API_KEY', targetType: 'stack' })
165183 * .then((installation) => console.log(installation))
166184 */
167185 this . install = async ( { targetUid, targetType } ) => {
@@ -191,21 +209,21 @@ export function App (http, data) {
191209 * @example
192210 * import * as contentstack from '@contentstack/management'
193211 * const client = contentstack.client({ authtoken: 'TOKEN'})
194- * client.organization('organization_uid').app('app_uid ').installation().findAll()
212+ * client.organization('organization_uid').app('manifest_uid ').installation().findAll()
195213 * .then((installations) => console.log(installations))
196214 *
197215 * @example
198216 * import * as contentstack from '@contentstack/management'
199217 * const client = contentstack.client({ authtoken: 'TOKEN'})
200- * client.organization('organization_uid').app('app_uid ').installation('installation_uid').fetch()
218+ * client.organization('organization_uid').app('manifest_uid ').installation('installation_uid').fetch()
201219 * .then((installation) => console.log(installation))
202220 */
203221 this . installation = ( uid = null ) => {
204222 return new Installation ( http , uid ? { data : { uid } } : { app_uid : this . uid } , this . params )
205223 }
206224 } else {
207225 /**
208- * @description The create an app call is used for creating a new app in your Contentstack organization.
226+ * @description The create manifest call is used for creating a new app/manifest in your Contentstack organization.
209227 * @memberof App
210228 * @func create
211229 * @returns {Promise<App> }
@@ -236,7 +254,7 @@ export function App (http, data) {
236254 this . create = create ( { http, params : this . params } )
237255
238256 /**
239- * @description The get all apps call is used to fetch all the apps in your Contentstack organization.
257+ * @description The get all manifest call is used to fetch all the apps in your Contentstack organization.
240258 * @memberof App
241259 * @func findAll
242260 * @returns {Promise<ContentstackCollection<App>> }
0 commit comments