Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fixing merge conflict in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-rodgers committed Nov 8, 2016
2 parents 308b5ad + 9641b1c commit 6c492c3
Show file tree
Hide file tree
Showing 24 changed files with 952 additions and 253 deletions.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@
"sourceMaps": false,
"outDir": null
},
{
"name": "Gulp",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
"stopOnEntry": false,
"args": ["test"],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# JavaScript Core Component

[![npm version](https://badge.fury.io/js/sp-pnp-js.svg)](https://badge.fury.io/js/sp-pnp-js) [![Join the chat at https://gitter.im/OfficeDev/PnP-JS-Core](https://badges.gitter.im/OfficeDev/PnP-JS-Core.svg)](https://gitter.im/OfficeDev/PnP-JS-Core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Downloads](https://img.shields.io/npm/dm/sp-pnp-js.svg)](https://www.npmjs.com/package/sp-pnp-js) [![bitHound Overall Score](https://www.bithound.io/github/OfficeDev/PnP-JS-Core/badges/score.svg)](https://www.bithound.io/github/OfficeDev/PnP-JS-Core)
[![npm version](https://badge.fury.io/js/sp-pnp-js.svg)](https://badge.fury.io/js/sp-pnp-js) [![Join the chat at https://gitter.im/OfficeDev/PnP-JS-Core](https://badges.gitter.im/OfficeDev/PnP-JS-Core.svg)](https://gitter.im/OfficeDev/PnP-JS-Core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Downloads](https://img.shields.io/npm/dm/sp-pnp-js.svg)](https://www.npmjs.com/package/sp-pnp-js) [![bitHound Overall Score](https://www.bithound.io/github/SharePoint/PnP-JS-Core/badges/score.svg)](https://www.bithound.io/github/SharePoint/PnP-JS-Core)

The Patterns and Practices JavaScript Core Library was created to help developers by simplifying common operations within SharePoint and the SharePoint Framework. Currently it contains a fluent API for working with the full SharePoint REST API as well as utility and helper functions. This takes the guess work out of creating REST requests, letting developers focus on the what and less on the how.

Expand All @@ -26,7 +26,7 @@ Add the package from bower

### Wiki

Please see [the wiki](https://github.com/OfficeDev/PnP-JS-Core/wiki) for detailed guides on getting started both using and contributing to the library.
Please see [the wiki](https://github.com/SharePoint/PnP-JS-Core/wiki) for detailed guides on getting started both using and contributing to the library.

### API Documentation

Expand Down
8 changes: 5 additions & 3 deletions buildtasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
var gulp = require("gulp"),
mocha = require("gulp-mocha"),
istanbul = require("gulp-istanbul"),
tsc = require("gulp-typescript");
tsc = require("gulp-typescript"),
yargs = require('yargs').argv;

//******************************************************************************
//* TEST
Expand All @@ -29,7 +30,8 @@ gulp.task("build-tests", ["clean"], function() {
});

gulp.task("test", ["build", "build-tests", "istanbul:hook"], function() {
return gulp.src(global.TSCompiledOutput.JSTestFiles)
let path = './build/tests/{path}.test.js';
return gulp.src(yargs.single ? path.replace('{path}', yargs.single) : global.TSCompiledOutput.JSTestFiles)
.pipe(mocha({ ui: 'bdd', reporter: 'dot', timeout: 10000 }))
.pipe(istanbul.writeReports());
});
});
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@
"typescript": "^2.0.3",
"typings": "^1.4.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
"vinyl-source-stream": "^1.1.0",
"yargs": "^6.0.0"
},
"scripts": {
"test": "gulp test"
},
"repository": {
"type": "git",
"url": "git://github.com/OfficeDev/PnP-JS-Core"
"url": "git://github.com/SharePoint/PnP-JS-Core"
},
"author": {
"name": "Microsoft and other contributors"
Expand All @@ -60,12 +61,14 @@
"keywords": [
"sharepoint",
"office365",
"tools"
"tools",
"spfx",
"sharepoint framework"
],
"bugs": {
"url": "https://github.com/OfficeDev/PnP-JS-Core/issues"
"url": "https://github.com/SharePoint/PnP-JS-Core/issues"
},
"homepage": "https://github.com/OfficeDev/PnP-JS-Core",
"homepage": "https://github.com/SharePoint/PnP-JS-Core",
"browser": {
"./build/src/net/nodefetchclient.js": "./build/src/net/nodefetchclientbrowser.js",
"./lib/net/nodefetchclient.js": "./lib/net/nodefetchclientbrowser.js"
Expand Down
83 changes: 59 additions & 24 deletions server-root/scratchpad.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ require(["pnp"], function (pnp) {
// pnp.sp.web.lists.getByTitle("Config3").items.orderBy("Title").top(1).getPaged().then(d => {
// show(d);
// d.getNext().then(d => show(d));
// });
// });
// pnp.sp.web.siteGroups.get().then(show);
// pnp.sp.web.siteGroups.add({ "Title": "Test Group 1" }).then(show);
// pnp.sp.web.siteGroups.getById(11).get().then(show);
// pnp.sp.web.siteGroups.removeById(13).get().then(show);
// pnp.sp.web.siteGroups.removeByLoginName("Delete My By Name").then(show);
// pnp.sp.web.siteGroups.removeByLoginName("Delete My By Name").then(show);
// pnp.sp.web.siteGroups.getByName("Test Group 1").get().then(show);
// pnp.sp.web.siteGroups.getById(11).users.get().then(show);
// pnp.sp.web.siteGroups.getByName("Test Group 1").update({ Title: "Test Group 1-2" }).then((r) => {
// r.group.users.get().then(show);
// pnp.sp.web.siteGroups.getByName("Test Group 1").update({ Title: "Test Group 1-2" }).then((r) => {
// r.group.users.get().then(show);
// });
//pnp.sp.web.roleDefinitions.add("Test1", "Description", 180, { High: '176', Low: '138612801' }).then(show);
//pnp.sp.web.roleDefinitions.getByName("Test1").update({ BasePermissions: { High: '0', Low: '138612801' }, Name: "Fred" }).then(show);
Expand All @@ -66,11 +66,11 @@ require(["pnp"], function (pnp) {
// pnp.sp.web.lists.getByTitle("Documents").items.get().then(show);
// pnp.sp.web.roleAssignments.get().then(show);
// pnp.sp.web.lists.getByTitle("Documents").views.get().then(show);
// pnp.sp.site.rootWeb.folders.get().then(show);
// pnp.sp.site.rootWeb.folders.getByName("Shared Documents").select("Title").get().then(show);
// pnp.sp.site.rootWeb.folders.get().then(show);
// pnp.sp.site.rootWeb.folders.getByName("Shared Documents").select("Title").get().then(show);
// pnp.sp.site.rootWeb.getFolderByServerRelativeUrl("sites/dev/Style Library/test").select("Name").get().then(show);
// pnp.sp.site.rootWeb.getFolderByServerRelativeUrl("/sites/dev/Style Library/test").parentFolder.select("Name").get().then(show);
// pnp.sp.site.rootWeb.getFolderByServerRelativeUrl("/sites/dev/Style Library").folders.get().then(show);
// pnp.sp.site.rootWeb.getFolderByServerRelativeUrl("/sites/dev/Style Library").folders.get().then(show);
// pnp.sp.site.rootWeb.getFolderByServerRelativeUrl("/sites/dev/Style Library").name.get().then(show);
// pnp.sp.site.rootWeb.getFolderByServerRelativeUrl("/sites/dev/Style Library").properties.select("vti_x005f_dirlateststamp").get().then(show);
// pnp.sp.site.rootWeb.getFolderByServerRelativeUrl("/sites/dev/Style Library/test").files.get().then(show);
Expand All @@ -82,40 +82,40 @@ require(["pnp"], function (pnp) {
// pnp.sp.web.lists.getByTitle("Documents").eventReceivers.get().then(show);
// pnp.sp.web.lists.getByTitle("Documents").eventReceivers.select("ReceiverName").filter("SequenceNumber ne 10000").get().then(show);
// pnp.sp.web.lists.getByTitle("Documents").getUserEffectivePermissions("i:0h.f|membership|[email protected]").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).attachmentFiles.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).attachmentFiles.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).attachmentFiles.select("ServerRelativeUrl").filter("FileName eq 'SP Customizations.pptx'").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).contentType.select("Id", "Name").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).effectiveBasePermissions.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).effectiveBasePermissionsForUI.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).fieldValuesAsHTML.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).fieldValuesAsHTML.select("GUID", "Title").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).fieldValuesAsHTML.select("GUID", "Title").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).fieldValuesAsText.select("GUID", "Title").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).fieldValuesForEdit.select("GUID", "Title").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).firstUniqueAncestorSecurableObject.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(1).firstUniqueAncestorSecurableObject.select("odata.type").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(2).folder.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(3).getUserEffectivePermissions("i:0h.f|membership|[email protected]").get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(3).roleAssignments.get().then(show);
// pnp.sp.web.lists.getByTitle("Test List").items.getById(3).roleAssignments.select("PrincipalId").filter("PrincipalId eq 8").get().then(show)
// pnp.sp.web.lists.getByTitle("Test List").items.getById(3).roleAssignments.select("PrincipalId").filter("PrincipalId eq 8").get().then(show)
// pnp.sp.web.lists.add("My first list").then(function(result) {
// result.list.update({ Title: "New Title!!" }).then(function(result) {
// show(result.data);
// });
// });
// });
// pnp.sp.web.lists.getByTitle("New Title!!").delete().then(show);
// pnp.sp.web.lists.add("My first list").then(function(result) {
// result.list.update({ Title: "New Title!!" }).then(function(result2) {
// result.list.update({ Title: "New Title!!" }).then(function(result2) {
// result2.list.breakRoleInheritance().then(show);
// });
// });
// });
// pnp.sp.web.lists.getByTitle("New Title!!").resetRoleInheritance().then(show);
// pnp.sp.web.lists.getByTitle("New Title!!").roleAssignments.get().then(show);
// pnp.sp.web.lists.getByTitle("New Title!!").roleAssignments.get().then(show);
// let provider = new pnp.configuration.Providers.SPListConfigurationProvider("https://318studios.sharepoint.com/sites/dev");
// provider.getConfiguration().then(show);
// provider.getConfiguration().then(show);
// pnp.sp.web.lists.getByTitle("Config").items.add({
// Title: "Title 2",
// Value: "Value 2"
// }).then(show);
// }).then(show);
// pnp.sp.web.lists.getByTitle("Config").items.getById(4).update({
// Value: "Different"
// }).then(show);
Expand All @@ -132,11 +132,11 @@ require(["pnp"], function (pnp) {
// });
// pnp.sp.web.lists.ensureSitePagesLibrary().then(function(list) {
// list.items.get().then(show);
// });
// });
//pnp.sp.web.lists.ensureSitePagesLibrary().then(show);
//pnp.sp.web.lists.getByTitle("Config").items.getById(5).validateUpdateListItem([{ FieldName: "Title", FieldValue: "So different, much woot."}]).then(show);
//pnp.sp.web.lists.getByTitle("Config").views.getById("66e251c3-1362-4e86-90f2-1a8dacd655a5").renderAsHtml().then(showRaw);
//pnp.sp.web.lists.getByTitle("Config").views.add("My New View").then(show);
//pnp.sp.web.lists.getByTitle("Config").views.add("My New View").then(show);
// pnp.sp.web.lists.getByTitle("Config").views.add("My New View 3").then(function(result) {
// result.view.fields.getSchemaXml().then(show);
// });
Expand All @@ -147,7 +147,7 @@ require(["pnp"], function (pnp) {
// result.view.fields.add("Modified").then(function () {
// result.view.fields.move("Modified", 0).then(show);
// });
// });
// });
//pnp.sp.web.lists.getByTitle("Config").fields.addText("MyNewField3").then(show);
//pnp.sp.web.lists.getByTitle("Config").fields.addCalculated("calc", "=[Title]", 1, 2).then(show);
//pnp.sp.web.lists.getByTitle("Config").fields.addDateTime("datetimefield").then(show);
Expand All @@ -165,7 +165,7 @@ require(["pnp"], function (pnp) {
//pnp.sp.site.getDocumentLibraries("https://318studios.sharepoint.com/sites/dev/").then(show);
//pnp.sp.web.applyTheme("/sites/dev/_catalogs/theme/15/palette011.spcolor", "/sites/dev/_catalogs/theme/15/fontscheme007.spfont", "/sites/dev/Style%20Library/DSC_0024.JPG", false).then(show);
//pnp.sp.site.getWebUrlFromPageUrl("https://318studios.sharepoint.com/sites/dev/SitePages/DevHome.aspx").then(show);
//pnp.sp.web.mapToIcon("blah.xlsx").then(show);
//pnp.sp.web.mapToIcon("blah.xlsx").then(show);
// pnp.sp.profiles.editProfileLink.then(show);
// pnp.sp.profiles.isMyPeopleListPublic.then(show);
// pnp.sp.profiles.amIFollowedBy("i:0#.w|ylo001\_spocrawler_18_3996").then(show);
Expand All @@ -182,25 +182,60 @@ require(["pnp"], function (pnp) {
//pnp.sp.profiles.ownerUserProfile.then(show);
//pnp.sp.profiles.userProfile.then(show);
// test profile image upload
// $(function() {
// $("#testingshow").append("<div id='profiletest'><input type='file' /><button>Upload</button></div>");
// $(function() {
// $("#testingshow").append("<div id='profiletest'><input type='file' /><button>Upload</button></div>");
// var div = $("#testingshow").find("#profiletest");
// var btn = div.find("button");

// btn.on('click', function(e) {
// e.preventDefault();
// e.preventDefault();
// var file = $(this).closest("div").find("input")[0].files[0];
// pnp.sp.profiles.setMyProfilePic(file).then(show);
// });
// });

// var caml = { ViewXml: "<View><ViewFields><FieldRef Name='Title' /><FieldRef Name='RoleAssignments' /></ViewFields><RowLimit>10</RowLimit></View>" };

// pnp.sp.web.lists.getByTitle("Config3").getItemsByCAMLQuery(caml, "RoleAssignments").then(show);
// pnp.sp.web.lists.getByTitle("Config3").getItemsByCAMLQuery(caml, "RoleAssignments").then(show);

//pnp.sp.search("Title").then(show);


/* Webhook subscription creation */
// var notificationUrl = "{ notification url }";
// var today = new Date();
// var expirationDate = new Date(today.setDate(today.getDate() + 90)).toISOString();
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.create(notificationUrl, expirationDate, 'custom').then(function (data) {
// // Show new subscription information
// show(data);
// // Check all subscriptions of the current list
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.get().then(show);
// });

/* Show webhook subscriptions of a list/library */
//pnp.sp.web.lists.getByTitle("Documents").subscriptions.get().then(show);

/* Show webhook subscription by ID */
// var subscriptionId = "820965d1-f02b-483e-8b82-c3628aa459c0";
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.getById(subscriptionId).then(show);

/* Update a webhook subscription from a list or library */
// var subscriptionId = "820965d1-f02b-483e-8b82-c3628aa459c0";
// var today = new Date();
// var expirationDate = new Date(today.setDate(today.getDate() + 90)).toISOString();
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.getById(subscriptionId).then(show);
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.update(subscriptionId, expirationDate).then(function () {
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.getById(subscriptionId).then(show);
// });

/* Delete a webhook subscription */
// var subscriptionId = "820965d1-f02b-483e-8b82-c3628aa459c0";
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.get().then(show);
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.remove(subscriptionId).then(function () {
// pnp.sp.web.lists.getByTitle("Documents").subscriptions.get().then(show);
// });


function syntaxHighlight(json) {
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
Expand Down
1 change: 1 addition & 0 deletions settings.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var settings = {
clientSecret: "{ client secret }",
enableWebTests: true,
siteUrl: "{ site collection url }",
notificationUrl: "{ notification url }",
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/net/httpclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class HttpClient {
}

if (!headers.has("X-ClientService-ClientTag")) {
headers.append("X-ClientService-ClientTag", "PnPCoreJS:1.0.5");
headers.append("X-ClientService-ClientTag", "PnPCoreJS:1.0.6");
}

opts = Util.extend(opts, { headers: headers });
Expand Down Expand Up @@ -131,6 +131,16 @@ export class HttpClient {
return this.fetch(url, opts);
}

public patch(url: string, options: FetchOptions = {}): Promise<Response> {
let opts = Util.extend(options, { method: "PATCH" });
return this.fetch(url, opts);
}

public delete(url: string, options: FetchOptions = {}): Promise<Response> {
let opts = Util.extend(options, { method: "DELETE" });
return this.fetch(url, opts);
}

protected getFetchImpl(): HttpClientImpl {
if (RuntimeConfig.useSPRequestExecutor) {
return new SPRequestExecutorClient();
Expand Down
Loading

0 comments on commit 6c492c3

Please sign in to comment.