Skip to content

Commit

Permalink
Merge pull request #309 from gunjandatta/gdatta
Browse files Browse the repository at this point in the history
New Enhancements and V2 API
  • Loading branch information
gunjandatta authored Apr 26, 2024
2 parents c4f0e2b + 49517ff commit e3b26a3
Show file tree
Hide file tree
Showing 42 changed files with 3,094 additions and 217 deletions.
2 changes: 1 addition & 1 deletion @types/helper/executor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export const Executor: IExecutor;
* Executor
*/
export interface IExecutor {
<T = any>(methodParams: Array<T>, method: (param: T) => PromiseLike<any> | void, onExecuted?: (...args) => PromiseLike<any> | void): PromiseLike<any>;
<T = any>(methodParams: Array<T>, method: (param: T) => PromiseLike<any | undefined> | void, onExecuted?: (...args) => PromiseLike<any | undefined> | void): PromiseLike<any | undefined>;
}
6 changes: 6 additions & 0 deletions @types/helper/listForm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export interface IListFormProps {
/** OData query used when loading an item */
query?: IODataQuery;

/** The request digest value to use w/ the requests */
requestDigest?: string;

/** The relative web url containing the list */
webUrl?: string;
}
Expand Down Expand Up @@ -198,6 +201,9 @@ export interface IListFormResult {
/** The list. */
list: List;

/** The request digest value to use w/ the requests */
requestDigest?: string;

/** The relative web url containing the list. */
webUrl?: string;
}
6 changes: 6 additions & 0 deletions @types/helper/spCfg.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ export interface ISPCfgViewInfo {
/** The JSLink property. */
JSLink?: string;

/** The row limit property. */
RowLimit?: number;

/** The view fields. */
ViewFields?: Array<string>;

Expand Down Expand Up @@ -465,6 +468,9 @@ export interface ISPConfig {
/** The configuration. */
_configuration: ISPConfigProps;

/** Gets the web url for the solution assets. */
getWebUrl(): string;

/**
* Method to install the configuration
*/
Expand Down
6 changes: 6 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export { Helper }
import * as Lib from "./lib";
export { Lib }

/**
* V2 Library Components
*/
import * as v2 from "./v2";
export { v2 }

/**
* $REST Global Variable
*/
Expand Down
27 changes: 27 additions & 0 deletions @types/lib/list.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export interface IList {
* @param parameters - The optional list data parameters.
*/
getDataAsStream(listFullUrl: string, parameters?: RenderListDataParameters): IBaseExecution<IListDataStream>;

/**
* Runs a flow against a list item.
*/
runFlow(props: IRunFlow): PromiseLike<IRunFlowResult>;
}

/**
Expand Down Expand Up @@ -91,4 +96,26 @@ export interface IListEntityProps {

/** The relative url of the web containing the list. */
url?: string;
}

/**
* Properties for running a flow
*/
export interface IRunFlow {
cloudEnv?: string;
data: object;
id?: string;
list: string;
token?: string;
webUrl?: string;
}

/**
* Flow execution result
*/
export interface IRunFlowResult {
errorDetails?: object;
errorMessage?: string;
executed: boolean;
flowToken?: string;
}
21 changes: 19 additions & 2 deletions @types/lib/search.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IBaseExecution } from "gd-sprest-def/lib/base";
import { SearchRequest } from "gd-sprest-def/lib/Microsoft/Office/Server/Search/REST/complextypes";
import { SearchRequest, SearchResult } from "gd-sprest-def/lib/Microsoft/Office/Server/Search/REST";
import { ISearchService } from "gd-sprest-def/lib/Microsoft/Office/Server/Search/REST/entitytypes";
import { ITargetInfoProps } from "../utils";

Expand All @@ -9,6 +9,17 @@ import { ITargetInfoProps } from "../utils";
*/
export const Search: ISearch;

/**
* Search Post Query
*/
export interface ISearchPostQuery {
onQueryCompleted?: (results: SearchResult) => void;
query: SearchRequest
targetInfo?: ITargetInfoProps;
url?: string;
useBatch?: boolean;
}

/**
* Search
* @category Search
Expand All @@ -31,11 +42,17 @@ export interface ISearch {
* Method to get the query from the search parameters.
* @param parameters - The search parameters.
*/
getQuery: (parameters: SearchRequest /* | Microsoft.Office.Server.Search.REST.SearchSuggestion*/) => Array<string>;
getQuery(parameters: SearchRequest): Array<string>;

/**
* Method to get the url of a site, by its id.
* @param id - The site id.
*/
getUrlById(id: string): IBaseExecution<{ GetUrlById: string }>;

/**
* Method to execute a post query
* @param
*/
postQuery(props: ISearchPostQuery): PromiseLike<SearchResult>;
}
4 changes: 2 additions & 2 deletions @types/lib/site.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ITargetInfoProps } from "../utils";
* #### REST API
* _api/site
*
* #### Get list from the current site collection
* #### Get the current site collection
*
* ```typescript
* import { Site } from "gd-sprest";
Expand All @@ -17,7 +17,7 @@ import { ITargetInfoProps } from "../utils";
* ```
*
*
* #### Query a list to include various collections
* #### Query a site collection to include various collections
*
* ```typescript
* import { Site } from "gd-sprest";
Expand Down
8 changes: 8 additions & 0 deletions @types/lib/sitePages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export interface ISitePages {
*/
(url?: string, targetInfo?: ITargetInfoProps): ISitePageService;

/**
* Converts the modern page layout type.
* @param pageUrl - The url of the page.
* @param layout - The page layout type.
* @param webUrl - The url containing the page, if it's not within the same web.
*/
convertPage(pageUrl: string, layout: string, webUrl?: string): PromiseLike<void>;

/**
* Creates a modern page.
* @param fileName - The name of the file to create, including the .aspx extension.
Expand Down
16 changes: 16 additions & 0 deletions @types/rest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IList, RemoteWeb } from "gd-sprest-def/lib/SP/entitytypes";
import { IHelper } from "./helper";
import { ISPTypes } from "./sptypes";
import * as LibTypes from "./lib";
import * as LibV2Types from "./v2";

/**
* SharePoint REST Library
Expand Down Expand Up @@ -39,6 +40,16 @@ export interface IREST {
*/
DefaultRequestToHostFl: boolean;

/**
* The default library for a site.
*/
drive: LibV2Types.Idrive;

/**
* The libraries for a site.
*/
drives: LibV2Types.Idrives;

/**
* Use this api to get the web url from a page url.
*/
Expand Down Expand Up @@ -154,6 +165,11 @@ export interface IREST {
*/
SiteExists: (url: string) => IBaseExecution<LibTypes.ISiteExists>;

/**
* The graph sites endpoint.
*/
sites: LibV2Types.Isites;

/**
* Use this api to get the url of a site, by its id.
* @param id - The site id.
Expand Down
5 changes: 4 additions & 1 deletion @types/sptypes/sptypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ export type IClientTemplateUtility = {
*/
export type IClientSidePageLayout = {
Article: string;
HeaderlessSearchResults: string;
Home: string;
SingleWebPartAppPage: string;
RepostPage: string;
SingleWebPartAppPage: string;
Spaces: string;
Topic: string;
}

/**
Expand Down
33 changes: 33 additions & 0 deletions @types/v2/drive.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { IBaseExecution } from "gd-sprest-def/lib/base";
import { drive } from "gd-sprest-def/lib/Microsoft/Graph/entityTypes";
import { ITargetInfoProps } from "../utils";

/**
* #### REST API
* _api/v2.0/drive
*
* #### Get the default library for a site.
*
* ```typescript
* import { Drives } from "gd-sprest";
*
* Drives().execute(drives => {
* drives.forEach(...);
* });
* ```
*/
export const drive: Idrive;

/**
* Drive
* The v2.0 REST endpoint.
* @category Drive
*/
export interface Idrive {
/**
* Get the default library for a site.
* @param id - (Optional) The site id to target, current by default.
* @param targetInfo - (Optional) The target information.
*/
(id?: string, targetInfo?: ITargetInfoProps): IBaseExecution<drive>;
}
33 changes: 33 additions & 0 deletions @types/v2/drives.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { IBaseExecution } from "gd-sprest-def/lib/base";
import { driveCollection } from "gd-sprest-def/lib/Microsoft/Graph/entityTypes";
import { ITargetInfoProps } from "../utils";

/**
* #### REST API
* _api/v2.0/drives
*
* #### Get the libraries for a site.
*
* ```typescript
* import { Drives } from "gd-sprest";
*
* Drives().execute(drives => {
* drives.forEach(...);
* });
* ```
*/
export const drives: Idrives;

/**
* Drives
* The v2.0 REST endpoint.
* @category Drives
*/
export interface Idrives {
/**
* Get the libraries for a site.
* @param id - (Optional) The site id to target, current by default.
* @param targetInfo - (Optional) The target information.
*/
(id?: string, targetInfo?: ITargetInfoProps): IBaseExecution<driveCollection>;
}
3 changes: 3 additions & 0 deletions @types/v2/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./drive";
export * from "./drives";
export * from "./sites";
40 changes: 40 additions & 0 deletions @types/v2/sites.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { IBaseExecution } from "gd-sprest-def/lib/base";
import { sites } from "gd-sprest-def/lib/Microsoft/Graph/api";
import { list, listMethods, siteMethods } from "gd-sprest-def/lib/Microsoft/Graph/entityTypes";
import { ITargetInfoProps } from "../utils";

/**
* #### REST API
* _api/v2.0/sites
*
* #### Get the current site
*
* ```typescript
* import { Sites } from "gd-sprest";
*
* Sites().execute(site => {
* let siteTitle = site.title;
* });
* ```
*/
export const sites: Isites;

/**
* Sites
* The v2.0 REST endpoint.
* @category Sites
*/
export interface Isites {
/**
* Creates an instance of the site library.
* @param id - (Optional) The site id to target, current by default.
* @param targetInfo - (Optional) The target information.
*/
(id?: string, targetInfo?: ITargetInfoProps): siteMethods & sites;

/** Returns the current web. */
static getCurrentWeb(): IBaseExecution<sites> & siteMethods;

/** Returns a list from the current web. */
static getList(title: string): IBaseExecution<list> & listMethods;
}
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

The SharePoint REST Framework was designed for SharePoint 2013, but works in both SharePoint 2013/Online (Classic/Modern) pages. This framework is designed to remove the overhead required for SharePoint development, allowing the developer to focus on the client requirements.

<center><img alt="intellisense" src="https://dattabase.com/assets/images/intellisense.gif" style="max-height: 500px;" /></center>
<center><img alt="intellisense" src="assets/images/intellisense.gif" style="max-height: 500px;" /></center>

### References

- [gd-sprest](api) - An easy way to execute requests against the SharePoint 2013/Online REST api
- [gd-sprest-bs](extras/bs) - Extends the [Bootstrap Framework](https://getbootstrap.com) with components designed for SharePoint 2013/Online.
- [gd-sprest-bs-vue](extras/bs) - Extends the [gd-sprest-bs](extras/bs) library for use with vue projects.
- [gd-sprest](api) - An easy way to execute requests against the SharePoint 2013/Online REST API
- [gd-sprest-def](https://github.com/gunjandatta/sprest-def) - Generates TypeScript definition files from the $metadata SharePoint REST endpoint, for this library.
- [gd-sprest-react](extras/react) - Extends the [Office Fluent-UI React Framework](https://developer.microsoft.com/en-us/fluentui) with components designed for SharePoint 2013/Online.
- [gd-sprest-bs](bs) - Extends the [Bootstrap Framework](https://getbootstrap.com) with components designed for SharePoint 2013/Online.

### Core Library

Expand All @@ -26,6 +24,7 @@ The gd-sprest library is similar to the pnp-js, with the main difference being t
- Ability to create reusable scripts/solutions
- Intellisense is available for JavaScript/TypeScript
- Ability to execute live requests from the browser console, helps to debug issues in production
- Ability to use pure JavaScript if NodeJS is not available to be installed for TypeScript/WebPack/Babel

### Bugs/Issues/Missing Functionality

Expand All @@ -47,4 +46,4 @@ Follow the [documentation](https://gunjandatta.github.io/dev/spfx) for steps on

### Security

The REST api execute requests based on the user's permissions. There is no way to elevate privileges requests against the SharePoint REST.
The REST api execute requests based on the user's permissions. There is no way to elevate privileges requests against the SharePoint REST.
Loading

0 comments on commit e3b26a3

Please sign in to comment.