From 6c6c23b96e992607a3b242de2edfb0fd00ef6cc6 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Thu, 16 Nov 2017 22:37:17 +0530 Subject: [PATCH 1/5] Added support for ALM APIs --- src/sharepoint/webs.ts | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/sharepoint/webs.ts b/src/sharepoint/webs.ts index 15e49989..04241a26 100644 --- a/src/sharepoint/webs.ts +++ b/src/sharepoint/webs.ts @@ -19,6 +19,33 @@ import { Features } from "./features"; import { SharePointQueryableShareableWeb } from "./sharepointqueryableshareable"; import { RelatedItemManger, RelatedItemManagerImpl } from "./relateditems"; +export enum AppOperation { + /** + * Install addin + */ + Install = 0, + /** + * Deploy the add-in + */ + Deploy = 1, + /** + * Upgrade addin + */ + Upgrade = 2, + /** + * Retract addin + */ + Retract = 3, + /** + * UnInstall addin + */ + Uninstall = 4, + /** + * Remove addin + */ + Remove = 5, +} + /** * Describes a collection of webs * @@ -467,6 +494,33 @@ export class Web extends SharePointQueryableShareableWeb { public getStorageEntity(key: string): Promise { return this.clone(Web, `getStorageEntity('${key}')`).get(); } + + /** + * Get available apps from appcatalog + */ + + public getAvailableApps(): Promise { + return this.clone(Web, `tenantappcatalog/AvailableApps`).get(); + } + + /** + * Get specific app from appcatalog + * @param id - Specify the guid of the app + */ + + public getAppById(id: string): Promise { + return this.clone(Web, `tenantappcatalog/AvailableApps/GetById('${id}')`).get(); + } + + /** + * Perform app operation on the app from appcatalog + * @param id - Specify the guid of the app + * @param appEvent - Specify the type of event you want to perform + */ + + public appOperation(id: string, appEvent: AppOperation): Promise { + return this.clone(Web, `tenantappcatalog/AvailableApps/GetById('${id}')/${appEvent}`).postCore(); + } } /** From 55322fbbfcaa71b505369e6625a344e3bf34b339 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Sun, 19 Nov 2017 18:59:39 +0530 Subject: [PATCH 2/5] Enum members initialized by string, changed variable name to operation --- src/sharepoint/webs.ts | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/sharepoint/webs.ts b/src/sharepoint/webs.ts index 04241a26..f84bbda8 100644 --- a/src/sharepoint/webs.ts +++ b/src/sharepoint/webs.ts @@ -21,29 +21,29 @@ import { RelatedItemManger, RelatedItemManagerImpl } from "./relateditems"; export enum AppOperation { /** - * Install addin - */ - Install = 0, - /** - * Deploy the add-in - */ - Deploy = 1, - /** - * Upgrade addin - */ - Upgrade = 2, - /** - * Retract addin - */ - Retract = 3, - /** - * UnInstall addin - */ - Uninstall = 4, - /** - * Remove addin - */ - Remove = 5, + * Install addin + */ + Install = "Install", + /** + * Deploy the add-in + */ + Deploy = "Deploy", + /** + * Upgrade addin + */ + Upgrade = "Upgrade", + /** + * Retract addin + */ + Retract = "Retract", + /** + * UnInstall addin + */ + Uninstall = "Uninstall", + /** + * Remove addin + */ + Remove = "Remove", } /** @@ -515,11 +515,11 @@ export class Web extends SharePointQueryableShareableWeb { /** * Perform app operation on the app from appcatalog * @param id - Specify the guid of the app - * @param appEvent - Specify the type of event you want to perform + * @param operation - Specify the type of operation you want to perform */ - public appOperation(id: string, appEvent: AppOperation): Promise { - return this.clone(Web, `tenantappcatalog/AvailableApps/GetById('${id}')/${appEvent}`).postCore(); + public appOperation(id: string, operation: AppOperation): Promise { + return this.clone(Web, `tenantappcatalog/AvailableApps/GetById('${id}')/${operation}`).postCore(); } } From a85f36a0d47724fc3b4ebc326eb47bb27d45978c Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Tue, 21 Nov 2017 22:12:01 +0530 Subject: [PATCH 3/5] Added support for uploading app package --- src/sharepoint/webs.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/sharepoint/webs.ts b/src/sharepoint/webs.ts index f84bbda8..43390ad5 100644 --- a/src/sharepoint/webs.ts +++ b/src/sharepoint/webs.ts @@ -521,6 +521,25 @@ export class Web extends SharePointQueryableShareableWeb { public appOperation(id: string, operation: AppOperation): Promise { return this.clone(Web, `tenantappcatalog/AvailableApps/GetById('${id}')/${operation}`).postCore(); } + + /** + * Uploads an app package. Not supported for batching + * + * @param url The url of the app. + * @param content The app package (eg: the .app or .sppkg file). + * @param shouldOverWrite Should an app with the same name in the same location be overwritten? (default: true) + * @returns The response. + */ + public addApp(url: string, content: ArrayBuffer | Blob, shouldOverWrite = true): Promise { + return this.clone(Web, `tenantappcatalog/add(overwrite=${shouldOverWrite},url='${url}')`) + .postCore({ + body: content, + }).then((response) => { + return { + data: response, + }; + }); + } } /** From 2aba7f1e03d636a69cf5c64914b53b4c3ad52c26 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Tue, 21 Nov 2017 22:20:54 +0530 Subject: [PATCH 4/5] Updated documentation related to ALM api changes --- src/sharepoint/webs.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sharepoint/webs.ts b/src/sharepoint/webs.ts index 43390ad5..89642934 100644 --- a/src/sharepoint/webs.ts +++ b/src/sharepoint/webs.ts @@ -496,7 +496,7 @@ export class Web extends SharePointQueryableShareableWeb { } /** - * Get available apps from appcatalog + * Get all available apps from app catalog */ public getAvailableApps(): Promise { @@ -504,7 +504,7 @@ export class Web extends SharePointQueryableShareableWeb { } /** - * Get specific app from appcatalog + * Get details of specific app from the app catalog * @param id - Specify the guid of the app */ @@ -513,9 +513,10 @@ export class Web extends SharePointQueryableShareableWeb { } /** - * Perform app operation on the app from appcatalog + * Perform app operation on the app from app catalog * @param id - Specify the guid of the app - * @param operation - Specify the type of operation you want to perform + * @param operation - Specify the type of operation you want to perform. + * The Deploy, Retract and Remove operations will work in the context of tenant app catalog site only */ public appOperation(id: string, operation: AppOperation): Promise { @@ -525,11 +526,12 @@ export class Web extends SharePointQueryableShareableWeb { /** * Uploads an app package. Not supported for batching * - * @param url The url of the app. + * @param url The name of the app. * @param content The app package (eg: the .app or .sppkg file). * @param shouldOverWrite Should an app with the same name in the same location be overwritten? (default: true) * @returns The response. */ + public addApp(url: string, content: ArrayBuffer | Blob, shouldOverWrite = true): Promise { return this.clone(Web, `tenantappcatalog/add(overwrite=${shouldOverWrite},url='${url}')`) .postCore({ From 40030714be184b13e7c929b63d7f3695c6ad6b3c Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Tue, 21 Nov 2017 22:47:55 +0530 Subject: [PATCH 5/5] lint fixes --- src/sharepoint/webs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sharepoint/webs.ts b/src/sharepoint/webs.ts index 89642934..ad4b6db7 100644 --- a/src/sharepoint/webs.ts +++ b/src/sharepoint/webs.ts @@ -531,7 +531,7 @@ export class Web extends SharePointQueryableShareableWeb { * @param shouldOverWrite Should an app with the same name in the same location be overwritten? (default: true) * @returns The response. */ - + public addApp(url: string, content: ArrayBuffer | Blob, shouldOverWrite = true): Promise { return this.clone(Web, `tenantappcatalog/add(overwrite=${shouldOverWrite},url='${url}')`) .postCore({