Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Added support for ALM APIs #640

Merged
merged 5 commits into from
Nov 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 75 additions & 0 deletions src/sharepoint/webs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ import { Features } from "./features";
import { SharePointQueryableShareableWeb } from "./sharepointqueryableshareable";
import { RelatedItemManger, RelatedItemManagerImpl } from "./relateditems";

export enum AppOperation {
/**
* 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",
}

/**
* Describes a collection of webs
*
Expand Down Expand Up @@ -467,6 +494,54 @@ export class Web extends SharePointQueryableShareableWeb {
public getStorageEntity(key: string): Promise<string> {
return this.clone(Web, `getStorageEntity('${key}')`).get();
}

/**
* Get all available apps from app catalog
*/

public getAvailableApps(): Promise<string> {
return this.clone(Web, `tenantappcatalog/AvailableApps`).get();
}

/**
* Get details of specific app from the app catalog
* @param id - Specify the guid of the app
*/

public getAppById(id: string): Promise<string> {
return this.clone(Web, `tenantappcatalog/AvailableApps/GetById('${id}')`).get();
}

/**
* 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.
* The Deploy, Retract and Remove operations will work in the context of tenant app catalog site only
*/

public appOperation(id: string, operation: AppOperation): Promise<string> {
return this.clone(Web, `tenantappcatalog/AvailableApps/GetById('${id}')/${operation}`).postCore();
}

/**
* Uploads an app package. Not supported for batching
*
* @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<any> {
return this.clone(Web, `tenantappcatalog/add(overwrite=${shouldOverWrite},url='${url}')`)
.postCore({
body: content,
}).then((response) => {
return {
data: response,
};
});
}
}

/**
Expand Down