Skip to content

Commit

Permalink
Merge pull request #310 from gunjandatta/gdatta
Browse files Browse the repository at this point in the history
Updated API to Sept 2024
  • Loading branch information
gunjandatta authored Sep 28, 2024
2 parents e3b26a3 + 37366fb commit b75f06d
Show file tree
Hide file tree
Showing 28 changed files with 1,321 additions and 446 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- uses: actions/checkout@v2

Expand All @@ -23,7 +23,7 @@ jobs:
npm run test --if-present
- name: Build Artifacts
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
3 changes: 3 additions & 0 deletions @types/helper/listForm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export interface IListForm {
*/
refreshItem(info: IListFormResult): PromiseLike<IListFormResult>;

/** Method to refresh the request digest value. */
refreshRequestDigest(info: IListFormResult): PromiseLike<void>;

/**
* Method to remove attachment from an item.
*/
Expand Down
2 changes: 1 addition & 1 deletion @types/helper/methods/loadSPCore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/
export const loadSPCore: IloadSPCore;
export interface IloadSPCore {
(): PromiseLike<void>;
(additionalLibs?: string[]): PromiseLike<void>;
}
26 changes: 26 additions & 0 deletions @types/helper/spCfg.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export interface IFieldInfo {
/** True for hidden fields. */
hidden?: boolean;

/** The guid of the field. */
id?: string;

/** True to index the field. */
indexed?: boolean;

Expand Down Expand Up @@ -285,6 +288,11 @@ export interface IFieldInfoUser extends IFieldInfo {
* SharePoint Configuration - Content Type Information
*/
export interface ISPCfgContentTypeInfo extends ContentTypeCreationInformation {
/**
* The client form custom formatter.
*/
ClientFormCustomFormatter?: string;

/**
* The content type. (This value is set internally.)
*/
Expand Down Expand Up @@ -408,15 +416,30 @@ export interface ISPCfgListInfo {
* SharePoint Configuration - View Information
*/
export interface ISPCfgViewInfo {
/** Custom formatter */
CustomFormatter?: string;

/** Flag to set the view as the default view. */
Default?: boolean;

/** The JSLink property. */
JSLink?: string;

/** Flag to set the view as hidden. */
Hidden?: boolean;

/** Flag to set the default mobile view. */
MobileDefaultView?: boolean;

/** Flag to set the view for mobile. */
MobileView?: boolean;

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

/** Flag to enable the tabular view option. */
Tabular?: boolean;

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

Expand Down Expand Up @@ -504,6 +527,9 @@ export interface ISPConfigProps {
/** The list configuration. */
ListCfg?: Array<ISPCfgListInfo>;

/** Event for the logging of the configuration. */
onLogMessage?: (msg: string, isError?: boolean) => void;

/** The web part configuration. */
WebPartCfg?: Array<ISPCfgWebPartInfo>;
}
Expand Down
2 changes: 1 addition & 1 deletion @types/lib/search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ export interface ISearch {
* Method to execute a post query
* @param
*/
postQuery(props: ISearchPostQuery): PromiseLike<SearchResult>;
postQuery<T = any>(props: ISearchPostQuery): PromiseLike<SearchResult<T>>;
}
3 changes: 3 additions & 0 deletions @types/utils/helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ export interface IBaseHelper {

/** Updates the metdata uri. */
updateMetadataUri(base: IBase, metadata, targetInfo: ITargetInfoProps);

/** Updates the search results. */
updateSearchResults(base: IBase);
}
36 changes: 34 additions & 2 deletions dist/gd-sprest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ declare module 'gd-sprest/lib/search' {
* Method to execute a post query
* @param
*/
postQuery(props: ISearchPostQuery): PromiseLike<SearchResult>;
postQuery<T = any>(props: ISearchPostQuery): PromiseLike<SearchResult<T>>;
}
}

Expand Down Expand Up @@ -2401,6 +2401,9 @@ declare module 'gd-sprest/helper/listForm' {
*/
refreshItem(info: IListFormResult): PromiseLike<IListFormResult>;

/** Method to refresh the request digest value. */
refreshRequestDigest(info: IListFormResult): PromiseLike<void>;

/**
* Method to remove attachment from an item.
*/
Expand Down Expand Up @@ -3537,6 +3540,9 @@ declare module 'gd-sprest/helper/spCfg' {
/** True for hidden fields. */
hidden?: boolean;

/** The guid of the field. */
id?: string;

/** True to index the field. */
indexed?: boolean;

Expand Down Expand Up @@ -3762,6 +3768,11 @@ declare module 'gd-sprest/helper/spCfg' {
* SharePoint Configuration - Content Type Information
*/
export interface ISPCfgContentTypeInfo extends ContentTypeCreationInformation {
/**
* The client form custom formatter.
*/
ClientFormCustomFormatter?: string;

/**
* The content type. (This value is set internally.)
*/
Expand Down Expand Up @@ -3885,15 +3896,30 @@ declare module 'gd-sprest/helper/spCfg' {
* SharePoint Configuration - View Information
*/
export interface ISPCfgViewInfo {
/** Custom formatter */
CustomFormatter?: string;

/** Flag to set the view as the default view. */
Default?: boolean;

/** The JSLink property. */
JSLink?: string;

/** Flag to set the view as hidden. */
Hidden?: boolean;

/** Flag to set the default mobile view. */
MobileDefaultView?: boolean;

/** Flag to set the view for mobile. */
MobileView?: boolean;

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

/** Flag to enable the tabular view option. */
Tabular?: boolean;

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

Expand Down Expand Up @@ -3981,6 +4007,9 @@ declare module 'gd-sprest/helper/spCfg' {
/** The list configuration. */
ListCfg?: Array<ISPCfgListInfo>;

/** Event for the logging of the configuration. */
onLogMessage?: (msg: string, isError?: boolean) => void;

/** The web part configuration. */
WebPartCfg?: Array<ISPCfgWebPartInfo>;
}
Expand Down Expand Up @@ -6888,7 +6917,7 @@ declare module 'gd-sprest/helper/methods/loadSPCore' {
*/
export const loadSPCore: IloadSPCore;
export interface IloadSPCore {
(): PromiseLike<void>;
(additionalLibs?: string[]): PromiseLike<void>;
}
}

Expand Down Expand Up @@ -7103,6 +7132,9 @@ declare module 'gd-sprest/utils/helper' {

/** Updates the metdata uri. */
updateMetadataUri(base: IBase, metadata, targetInfo: ITargetInfoProps);

/** Updates the search results. */
updateSearchResults(base: IBase);
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/gd-sprest.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gd-sprest.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gd-sprest",
"version": "7.8.9",
"version": "8.2.4",
"description": "An easy way to develop against the SharePoint REST API.",
"author": "Gunjan Datta <[email protected]> (https://gunjandatta.github.io)",
"license": "MIT",
Expand All @@ -24,7 +24,7 @@
},
"homepage": "https://dattabase.com",
"dependencies": {
"gd-sprest-def": "^1.4.6"
"gd-sprest-def": "^1.4.9"
},
"devDependencies": {
"@babel/core": "^7.18.10",
Expand Down
9 changes: 7 additions & 2 deletions src/helper/fieldSchemaXML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SPCfgFieldType } from "./spCfg";
*/
export const FieldSchemaXML = (fieldInfo: IFieldInfo, targetWebUrl?: string): PromiseLike<string> => {
let _resolve = null;
let _reject = null;

// Returns the schema xml for a boolean field.
let createBoolean = (fieldInfo: IFieldInfo, props: object) => {
Expand Down Expand Up @@ -249,6 +250,9 @@ export const FieldSchemaXML = (fieldInfo: IFieldInfo, targetWebUrl?: string): Pr

// Resolve the request
_resolve("<Field " + toString(props) + " />");
}, () => {
// Error getting the lookup list
_reject("Error getting the lookup list.");
});
} else {
// Set the list id
Expand Down Expand Up @@ -417,8 +421,9 @@ export const FieldSchemaXML = (fieldInfo: IFieldInfo, targetWebUrl?: string): Pr

// Return a promise
return new Promise((resolve, reject) => {
// Set the resolve method
// Set the resolve/reject methods
_resolve = resolve;
_reject = reject;

// See if the schema xml has been defined
if (fieldInfo.schemaXml) {
Expand All @@ -427,7 +432,7 @@ export const FieldSchemaXML = (fieldInfo: IFieldInfo, targetWebUrl?: string): Pr
} else {
// Set the base properties
let props = {};
props["ID"] = "{" + ContextInfo.generateGUID() + "}";
props["ID"] = fieldInfo.id || "{" + ContextInfo.generateGUID() + "}";
props["Name"] = fieldInfo.name;
props["StaticName"] = fieldInfo.name;
props["DisplayName"] = fieldInfo.title || fieldInfo.name;
Expand Down
22 changes: 19 additions & 3 deletions src/helper/listForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
IListFormResult, IListFormProps
} from "../../@types/helper";
import { IODataQuery, SP } from "gd-sprest-def";
import { SPTypes, Web } from "..";
import { ContextInfo, SPTypes, Web } from "..";
import { Types } from "../../@types";

/**
Expand Down Expand Up @@ -496,6 +496,22 @@ export const ListForm: IListForm = {
});
},

// Method to refresh the request digest value
refreshRequestDigest: (info: IListFormResult): PromiseLike<void> => {
// Return a promise
return new Promise((resolve, reject) => {
// Get the context info
ContextInfo.getWeb(info.webUrl).execute(context => {
// Update the request digest value
info.item.updateRequestDigest(context.GetContextWebInformation.FormDigestValue);
info.list.updateRequestDigest(context.GetContextWebInformation.FormDigestValue);

// Resolve the request
resolve();
}, reject);
});
},

// Method to remove attachments from an item
removeAttachment: (info: IListFormResult, fileName: string): PromiseLike<IListFormResult> => {
// Return a promise
Expand Down Expand Up @@ -581,7 +597,7 @@ export const ListForm: IListForm = {
// Resolve the promise
resolve(info);
}, reject);
});
}, reject);
} else {
// Set the metadata type
formValues["__metadata"] = { type: info.list.ListItemEntityTypeFullName };
Expand All @@ -597,7 +613,7 @@ export const ListForm: IListForm = {
ListForm.refreshItem(info).then(info => {
// Resolve the promise
resolve(info);
});
}, reject);
}, reject);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/helper/methods/createContentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const createContentType: IcreateContentType = (ctInfo: ContentTypeCreatio
// Success
() => {
// Set the content type collection
let cts = (listName ? Web().Lists(listName) : Web()).ContentTypes();
let cts = (listName ? Web(webUrl).Lists(listName) : Web(webUrl)).ContentTypes();

// Find the content type
cts.query({ Filter: "Name eq '" + ctInfo.Name + "'" }).execute(cts => {
Expand Down
Loading

0 comments on commit b75f06d

Please sign in to comment.