
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
@sysdoc/sharepoint-utils
Advanced tools
This package contains all of Sysdoc's core Sharepoint utiltiies.
Version | @pnp/sp Support | Branch |
---|---|---|
0.x.x | 1.3.8 | pnp/v1 |
1.x.x | ^2.0.0 | Master |
TODO - complete this section.
Largest update here has been the inclusion of a callback function to allow custom processing of search results.
When instantiating a new SPSearchProvider you can now pass a resultsTransformer function in to transform your results - this gets passed via callback into the SPSearchResultPageModel and supercedes the makeSPSearchResultEntry function.
import { ISearchResult, ISearchResultEntry } from "@sysdoc/sharepoint-utils";
const resultsTransformer = (
result: ISearchResult
): ISearchResultEntry<ISearchResult> => {
try {
return {
href: result.Path,
payload: result,
foo: "Some custom result"
};
} catch (err) {
console.error(err);
return null;
}
};
const searchProvider = new SPSearchProvider({
resultsTransformer: resultsTransformer
});
import { SPBasicRestProvider } from "@sysdoc/sp-rest-provider";
const provider = new SPBasicRestProvider({
contentTypeId: "<A string value of a Sharepoint ContentTypeId>",
listTitle: "<A string value of a Sharepoint list title>",
webUrl: "<The string value of the Sharepoint WebURL you want to use>" // NB: You can use _spPageContextInfo.siteAbsoluteUrl here
});
Once a provider has been instantiated you have the following fields available on the provider:
provider.fields;
This returns an array of field names as strings.
provider.schema;
This returns an object which contains all field names for the list used to instantiate the REST provider. Each field name has an object associated with it which contains various metadata fields i.e:
{
schema: {
title: {
odata.type: "SP.FieldText",
odata.id: "https://sysdoc.sharepoint.com/sites/sys-registers-dev/_api/Web/Lists(guid'4c90fdea-b467-4d80-a9b4-9133de1d8586')/Fields(guid'fa564e0f-0c70-4ab9-b863-0177e6ddd247')",
odata.editLink: "Web/Lists(guid'4c90fdea-b467-4d80-a9b4-9133de1d8586')/Fields(guid'fa564e0f-0c70-4ab9-b863-0177e6ddd247')",
EnforceUniqueValues: false,
Group: "Custom Columns",
Hidden: false,
Id: "fa564e0f-0c70-4ab9-b863-0177e6ddd247",
Indexed: false,
InternalName: "Title",
Required: true,
TypeAsString: "Text"
}
}
}
TODO: Write explanation of method
getSchema is called by the constructor when SPBasicRestProvider is instantiated - it uses the listTitle passed in when the SPBasicRestProvider is instantiated to programatically generate a schema of that lists fields. It then makes this available via the schema prop i.e. - taking our example above the schema would be available:
const provider = new SPBasicRestProvider({
contentTypeId: "<A string value of a Sharepoint ContentTypeId>",
listTitle: "<A string value of a Sharepoint list title>",
webUrl: "<The string value of the Sharepoint WebURL you want to use>" // NB: You can use _spPageContextInfo.siteAbsoluteUrl here
});
const schema = provider.schema;
Internal method called by getSchema - generally you do not need to use this by itself.
Internal method called by whenReady - generally you do not need to use this by itself.
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
TODO: Write explanation of method
If you want to extend the REST provider you can do so using the following pattern:
import { SPBasicRestProvider } from "@sysdoc/sp-rest-provider";
export interface ISPFooProvider {
getBar(userId?: number, limit?: number): Promise<any>;
}
export class SPFooProvider extends SPBasicRestProvider
implements ISPFooProvider {
constructor(cfg: ISPBasicRestProviderConfig) {
super(cfg);
}
async getBar(userId?: number, limit?: number): Promise<any> {
return this.getByQuery(
`FooBarUser eq ${userId || _spPageContextInfo.userId}`,
{
limit: limit || null,
orderBy: {
field: "FooBarDate",
sortAsc: false
}
}
);
}
}
const provider = new SPFooProvider({
contentTypeId: "<A string value of a Sharepoint ContentTypeId>",
listTitle: "<A string value of a Sharepoint list title>",
webUrl: "<The string value of the Sharepoint WebURL you want to use>" // NB: You can use _spPageContextInfo.siteAbsoluteUrl here
});
const baz = provider.getBar();
This strategy allows you to access all the available methods from basic use - but also allows you to add additional methods
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.