Skip to content

Commit

Permalink
Merge branch 'version-3'
Browse files Browse the repository at this point in the history
  • Loading branch information
juliemturner committed Jan 17, 2024
2 parents 02261db + 5a1d220 commit b436704
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 105 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/v4-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: v4 Nightly Builds

on:
schedule:
- cron: "0 2 * * 1-5"

workflow_dispatch:

jobs:
publish-v4-nightly:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
ref: version-4
# setup nodejs
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: package-lock.json

# Run the npm install
- run: npm ci

# Runs a set of commands using the runners shell
- name: Test - not setup
run: echo this would be the tests

# Runs a single command using the runners shell
- name: Run a one-line script
run: npm run pnp-publish-v4nightly
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ debug/serve/*

# project settings
settings.js
settingsv3.js
settingsv4.js

# don't save the locally produced .js of the buildsystem config
buildsystem-config.js
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 3.22.0 - 2024-Jan-15

- sp
- fromAbsolutePath methods reference undefined this.
- Update request-digest.ts to still make call when injected headers include odata=verbose

- queryable
- Addressing #2890 - Node Clone - Fix

## 3.21.0 - 2023-Dec-11

- graph
Expand Down
169 changes: 78 additions & 91 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@pnp/monorepo",
"private": true,
"type": "module",
"version": "3.21.0",
"version": "3.22.0",
"description": "A JavaScript library for SharePoint & Graph development.",
"devDependencies": {
"@azure/identity": "3.4.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"postinstall": "node ./post-install.cjs"
},
"dependencies": {
"@microsoft/microsoft-graph-types": "2.35.0",
"tslib": "2.6.0",
"@microsoft/microsoft-graph-types": "2.40.0",
"tslib": "2.6.2",
"@pnp/core": "0.0.0-PLACEHOLDER",
"@pnp/queryable": "0.0.0-PLACEHOLDER"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/queryable/behaviors/caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function Caching(props?: ICachingProps): TimelinePipe<Queryable> {
if (cached === null) {

// if we don't have a cached result we need to get it after the request is sent. Get the raw value (un-parsed) to store into cache
this.on.rawData(noInherit(async function (response) {
instance.on.rawData(noInherit(async function (response) {
setCachedValue(response);
}));

Expand Down
9 changes: 7 additions & 2 deletions packages/queryable/behaviors/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function TextParse(): TimelinePipe {
export function BlobParse(): TimelinePipe {

return parseBinderWithErrorCheck( async (response) => {
const binaryResponseBody = parseToAtob(await response.clone().text());
const binaryResponseBody = parseToAtob(await response.text());
// handle batch responses for things that are base64, like photos https://github.com/pnp/pnpjs/issues/2825
if(binaryResponseBody){
// Create an array buffer from the binary string
Expand Down Expand Up @@ -123,7 +123,12 @@ export function parseBinderWithErrorCheck(impl: (r: Response) => Promise<any>):
instance.on.parse(async (url: URL, response: Response, result: any): Promise<[URL, Response, any]> => {

if (response.ok && typeof result === "undefined") {
result = await impl(response);
const respClone = response.clone();

// https://github.com/node-fetch/node-fetch?tab=readme-ov-file#custom-highwatermark
const [implResult, raw] = await Promise.all([impl(response), respClone.text()]);
result = implResult;
(<any>instance).emit.rawData(raw);
}

return [url, response, result];
Expand Down
4 changes: 0 additions & 4 deletions packages/queryable/queryable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ export class Queryable<R> extends Timeline<typeof DefaultMoments> implements IQu
let response = await this.emit.send(requestUrl, init);
log("Emitted send");

log("Emitting rawData");
this.emit.rawData(await response.clone().text());
log("Emitted rawData");

log("Emitting parse");
[requestUrl, response, result] = await this.emit.parse(requestUrl, response, result);
log("Emitted parse");
Expand Down
1 change: 1 addition & 0 deletions packages/sp/behaviors/request-digest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function RequestDigest(hook?: (url: string, init: RequestInit) => IDigest

digest = await spPost(SPQueryable([this, combine(webUrl, "_api/contextinfo")]).using(JSONParse(),BatchNever()), {
headers: {
"Accept": "application/json",
"X-PnPjs-NoDigest": "1",
},
}).then(p => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/sp/files/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export function fileFromServerRelativePath(base: ISPQueryable, serverRelativePat
*/
export async function fileFromAbsolutePath(base: ISPQueryable, absoluteFilePath: string): Promise<IFile> {

const { WebFullUrl } = await File(this).using(BatchNever()).getContextInfo(absoluteFilePath);
const { WebFullUrl } = await File(base).using(BatchNever()).getContextInfo(absoluteFilePath);
const { pathname } = new URL(absoluteFilePath);
return fileFromServerRelativePath(File([base, combine(WebFullUrl, "_api/web")]), decodeURIComponent(pathname));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sp/folders/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export function folderFromServerRelativePath(base: ISPQueryable, serverRelativeP
*/
export async function folderFromAbsolutePath(base: ISPQueryable, absoluteFolderPath: string): Promise<IFolder> {

const { WebFullUrl } = await Folder(this).using(BatchNever()).getContextInfo(absoluteFolderPath);
const { WebFullUrl } = await Folder(base).using(BatchNever()).getContextInfo(absoluteFolderPath);
const { pathname } = new URL(absoluteFolderPath);
return folderFromServerRelativePath(Folder([base, combine(WebFullUrl, "_api/web")]), decodeURIComponent(pathname));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sp/webs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function rebaseWebUrl(candidate: string, path: string | undefined): string {
// - test if `candidate` already has an api path
// - ensure that we append the correct one as sometimes a web is not defined
// by _api/web, in the case of _api/site/rootweb for example
const matches = /(_api[/|\\](site|web))/i.exec(candidate);
const matches = /(_api[/|\\](site\/rootweb|site|web))/i.exec(candidate);
if (matches?.length > 0) {
// we want just the base url part (before the _api)
candidate = extractWebUrl(candidate);
Expand Down
8 changes: 7 additions & 1 deletion test/sp/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import "@pnp/sp/sites";
import "@pnp/sp/webs";
import "@pnp/sp/lists/web";
import { IDocumentLibraryInformation, IOpenWebByIdResult, ISiteLogoProperties, Site, SiteLogoAspect, SiteLogoType } from "@pnp/sp/sites";
import "@pnp/sp/site-users";
import { IWebEnsureUserResult } from "@pnp/sp/site-users";
import { IWeb } from "@pnp/sp/webs";
import { combine, getRandomString, stringIsNullOrEmpty } from "@pnp/core";
import { IContextInfo } from "@pnp/sp/context-info";
import "@pnp/sp/context-info";


import "@pnp/sp/files";
import { IFiles } from "@pnp/sp/files";
import { readFileSync } from "fs";
Expand Down Expand Up @@ -36,6 +37,11 @@ describe("Sites", function () {
return expect(rootWeb).to.haveOwnProperty("_url");
});

it("rootWeb - ensureUser", async function () {
const user: IWebEnsureUserResult = await this.pnp.sp.site.rootWeb.ensureUser(this.pnp.settings.testUser);
return expect(user.data).to.haveOwnProperty("id");
});

it("getContextInfo", async function () {
const oContext: IContextInfo = await this.pnp.sp.site.getContextInfo();
return expect(oContext).to.haveOwnProperty("SiteFullUrl");
Expand Down

0 comments on commit b436704

Please sign in to comment.