diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0448cbb32..717ee2358 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,12 +11,10 @@ jobs: # 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@v4 - with: - ref: main + - uses: actions/checkout@v4 # setup nodejs - name: Use Node.js 18 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 registry-url: 'https://registry.npmjs.org' @@ -31,6 +29,6 @@ jobs: run: | npm run clean npm run package - npm run just-publish + npm run just-publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index fd57c71ab..7fb078f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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). +## 4.1.1 - 2024-June-05 + +### Fixed + +- graph + - Fixed batching issues that fails when batched call returns 204 + ## 4.1.0 - 2024-May-24 ### Fixed diff --git a/docs/concepts/batching.md b/docs/concepts/batching.md index c6d657954..ebad734fa 100644 --- a/docs/concepts/batching.md +++ b/docs/concepts/batching.md @@ -217,41 +217,3 @@ await execute(); ``` > In addition you cannot continue using a batch after execute. Once execute has resolved the batch is done. You should create a new batch using one of the described methods to conduct another batched call. - -## Case where batch result returns an object that can be invoked - -In the following example, the results of adding items to the list is an object with a type of **IItemAddResult** which is `{data: any, item: IItem}`. Since version v1 the expectation is that the `item` object is immediately usable to make additional queries. When this object is the result of a batched call, this was not the case so we have added additional code to reset the observers using the original base from witch the batch was created, mimicing the behavior had the **IItem** been created from that base withyout a batch involved. We use [CopyFrom](../core/behaviors.md#CopyFrom) to ensure that we maintain the references to the InternalResolve and InternalReject events through the end of this timelines lifecycle. - -```TypeScript -import { createBatch } from "@pnp/sp/batching"; -import { SPDefault } from "@pnp/nodejs"; -import { IList } from "@pnp/sp/lists"; -import "@pnp/sp/items/list"; - -const sp = spfi("https://tenant.sharepoint.com/sites/dev").using(SPDefault({ /* ... */ })); - -// in one part of your application you setup a list instance -const list: IList = sp.web.lists.getByTitle("MyList"); - -const [batchedListBehavior, execute] = createBatch(list); -// this list is now batching all its requests -list.using(batchedListBehavior); - -let res: IItemAddResult[] = []; - -// these will all occur within a single batch -list.items.add({ Title: `1: ${getRandomString(4)}` }).then(r => res.push(r)); -list.items.add({ Title: `2: ${getRandomString(4)}` }).then(r => res.push(r)); -list.items.add({ Title: `3: ${getRandomString(4)}` }).then(r => res.push(r)); -list.items.add({ Title: `4: ${getRandomString(4)}` }).then(r => res.push(r)); - -await execute(); - -let newItems: IItem[] = []; - -for(let i=0; i(); - newItems.push(newItem); -} -``` diff --git a/docs/graph/taxonomy.md b/docs/graph/taxonomy.md index 79055a5c3..33de66cd8 100644 --- a/docs/graph/taxonomy.md +++ b/docs/graph/taxonomy.md @@ -32,36 +32,6 @@ const graph = graphfi(...); // get term store data const info: ITermStoreInfo = await graph.sites.getById("contoso.sharepoint.com,91dd2418-8fb9-4e0e-919d-c1b31e938386,285cc5a1-cf50-4e4d-8d93-5ba5a8e76e01").termStore(); -``` -### SearchTerm - -Search for terms starting with provided label under entire termStore or a termSet or a parent term. - -The following properties are valid for the supplied query: `label: string`, `setId?: string`, `parentTermId?: string`, `languageTag?: string`, `stringMatchOption?: "ExactMatch" | "StartsWith"`. - -```TypeScript -import { graphfi } from "@pnp/graph"; -import "@pnp/graph/taxonomy"; - -const graph = graphfi(...); - -// minimally requires the label -const results1 = await graph.termStore.searchTerm({ - label: "test", -}); - -// other properties can be included as needed -const results2 = await graph.termStore.searchTerm({ - label: "test", - setId: "{guid}", -}); - -// other properties can be included as needed -const results3 = await graph.termStore.searchTerm({ - label: "test", - setId: "{guid}", - stringMatchOption: "ExactMatch", -}); ``` ### Update @@ -404,8 +374,6 @@ const termInfo2 = await graph.termStore.groups.getById("338666a8-1111-2222-3333- ### Delete -_Added in 3.10.0_ - ```TypeScript import { graphfi, SPFxToken, SPFx } from "@pnp/graph"; import "@pnp/graph/taxonomy"; diff --git a/docs/sp/items.md b/docs/sp/items.md index f6828df7c..9f1170090 100644 --- a/docs/sp/items.md +++ b/docs/sp/items.md @@ -194,17 +194,16 @@ import { spfi } from "@pnp/sp"; import "@pnp/sp/webs"; import "@pnp/sp/lists"; import "@pnp/sp/items"; -import { IItemAddResult } from "@pnp/sp/items"; const sp = spfi(...); // add an item to the list -const iar: IItemAddResult = await sp.web.lists.getByTitle("My List").items.add({ +const item = await sp.web.lists.getByTitle("My List").items.add({ Title: "Title", Description: "Description" }); -console.log(iar); +console.log(item); ``` ### Content Type diff --git a/docs/transition-guide.md b/docs/transition-guide.md index 9184ce37d..c780d20c3 100644 --- a/docs/transition-guide.md +++ b/docs/transition-guide.md @@ -13,7 +13,9 @@ To better support Taxonomy authentication and control we've moved our Taxonomy i ## Add/Update methods no longer returning data and a queryable instance -The primary breaking change will be with add and update method return values. We are not going to return what the calling endpoint returns so anywhere that you are referencing the return objects `data` property you will need to remove that reference. Many of the graph endpoints do return the added or updated object but most of the SharePoint ones return 204, which would translate into a return type of void. +The primary breaking change will be with add and update method return values. We are going to return what the calling endpoint returns in all cases instead of an object that includes data property and an "item" property. This means anywhere that you are referencing the return objects `data` property you will need to remove that reference. Many of the graph endpoints return the added or updated object so, other than changing the reference this will not impact your code. + +SharePoint returns the object for add events but many update events return 204, which would translate into a return type of void. In that case you will have to adjust your code to make a second call if you want to validate that the item has been updated: Ex: @@ -23,10 +25,24 @@ Ex: const newTitle = update.data.Title; // Version 4 - await sp.web.lists.getByTitle("My List").items.getById(1)..update({Title: "My New Title"}); + await sp.web.lists.getByTitle("My List").items.getById(1).update({Title: "My New Title"}); const updatedItem = await sp.web.lists.getByTitle("My List").items.getById(1)(); ``` +As stated before, when adding items in both graph and SharePoint the call will return the object that was created. So you can get the newly created objects `id` by simply referencing it directly: + +Ex: + + ```TypeScript + // Version 3 + const newItem = await sp.web.lists.getByTitle("My List").items.add({Title: "My New Title"}); + const newItemId = newItem.data.Id; + + // Version 4 + const newItem = await sp.web.lists.getByTitle("My List").items.add({Title: "My New Title"}); + const newItemId = newItem.Id; + ``` + ## Async Iterator Pattern As an updated pattern we are recommending you move to an async iterator pattern to get more than 5000 items from a list. diff --git a/package-lock.json b/package-lock.json index 215bba194..1c006ee1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pnp/monorepo", - "version": "4.1.0", + "version": "4.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@pnp/monorepo", - "version": "4.1.0", + "version": "4.1.1", "license": "MIT", "devDependencies": { "@azure/identity": "4.2.0", @@ -255,12 +255,12 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.6.tgz", - "integrity": "sha512-ZJhac6FkEd1yhG2AHOmfcXG4ceoLltoCVJjN5XsWN9BifBQr+cHJbWi0h68HZuSORq+3WtJ2z0hwF2NG1b5kcA==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", + "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", "dev": true, "dependencies": { - "@babel/highlight": "^7.24.6", + "@babel/highlight": "^7.24.7", "picocolors": "^1.0.0" }, "engines": { @@ -268,21 +268,21 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.6.tgz", - "integrity": "sha512-4yA7s865JHaqUdRbnaxarZREuPTHrjpDT+pXoAZ1yhyo6uFnIEpS8VMu16siFOHDpZNKYv5BObhsB//ycbICyw==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", + "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.6.tgz", - "integrity": "sha512-2YnuOp4HAk2BsBrJJvYCbItHx0zWscI1C3zgWkz+wDyD9I7GIVrfnLyrR4Y1VR+7p+chAEcrgRQYZAGIKMV7vQ==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", + "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.24.6", + "@babel/helper-validator-identifier": "^7.24.7", "chalk": "^2.4.2", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" @@ -387,9 +387,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", + "integrity": "sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -793,9 +793,9 @@ } }, "node_modules/@pnp/core": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@pnp/core/-/core-4.0.1.tgz", - "integrity": "sha512-Z+FiQDR1BPLuzoU8IpL3rmpiPa4+kvu997uVDfTmOhXv7YWlCOgTQa0scJoqGDZZCkTUwl07KGZ8A6nT76gA5w==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@pnp/core/-/core-4.1.0.tgz", + "integrity": "sha512-YWBe5mEZ4jcNxpagz79gkHG2kODVM9x2buuwiDkl25Hwn32iUz8FU44HQz/EOEf5b2+RrMOxreF6GiuOH2URGQ==", "dev": true, "dependencies": { "tslib": "2.6.2" @@ -809,9 +809,9 @@ } }, "node_modules/@pnp/logging": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@pnp/logging/-/logging-4.0.1.tgz", - "integrity": "sha512-+HVb3EFvSuEis2Wn7kHVhReEyFsB8Vtb2PfRWGcHQiCXGuje9y2oJb8HLxpV5+IdS2qoqpktrZa6ADf8+EkOVQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@pnp/logging/-/logging-4.1.0.tgz", + "integrity": "sha512-DF/UAi9+U7vhbN4pB77JAbwzd8QKGcpcA5clmwQ0kBSLrDnvyVkunpxEQdT47GCAjQyqn+8tYn+/IOxOXI1M9w==", "dev": true, "dependencies": { "tslib": "2.6.2" @@ -940,9 +940,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.1.tgz", - "integrity": "sha512-ej0phymbFLoCB26dbbq5PGScsf2JAJ4IJHjG10LalgUV36XKTmA4GdA+PVllKvRk0sEKt64X8975qFnkSi0hqA==", + "version": "4.19.3", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.3.tgz", + "integrity": "sha512-KOzM7MhcBFlmnlr/fzISFF5vGWVSvN6fTd4T+ExOt08bA/dA5kpSzY52nMsI1KDFmUREpJelPYyuslLRSjjgCg==", "dev": true, "dependencies": { "@types/node": "*", @@ -1659,9 +1659,9 @@ } }, "node_modules/ajv-formats/node_modules/ajv": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.13.0.tgz", - "integrity": "sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==", + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.16.0.tgz", + "integrity": "sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.3", @@ -2061,9 +2061,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001621", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001621.tgz", - "integrity": "sha512-+NLXZiviFFKX0fk8Piwv3PfLPGtRqJeq2TiNoUff/qB5KJgwecJTvCXDpmlyP/eCI/GUEmp/h/y5j0yckiiZrA==", + "version": "1.0.30001628", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001628.tgz", + "integrity": "sha512-S3BnR4Kh26TBxbi5t5kpbcUlLJb9lhtDXISDPwOfI+JoC+ik0QksvkZtUVyikw3hjnkgkMPSJ8oIM9yMm9vflA==", "dev": true, "funding": [ { @@ -2178,9 +2178,9 @@ } }, "node_modules/chrome-trace-event": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", - "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz", + "integrity": "sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==", "dev": true, "engines": { "node": ">=6.0" @@ -2424,9 +2424,9 @@ } }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -2487,9 +2487,9 @@ } }, "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", + "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", "dev": true, "dependencies": { "type-detect": "^4.0.0" @@ -2741,9 +2741,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.782", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.782.tgz", - "integrity": "sha512-JUfU61e8tr+i5Y1FKXcKs+Xe+rJ+CEqm4cgv1kMihPE2EvYHmYyVr3Im/+1+Z5B29Be2EEGCZCwAc6Tazdl1Yg==", + "version": "1.4.790", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.790.tgz", + "integrity": "sha512-eVGeQxpaBYbomDBa/Mehrs28MdvCXfJmEFzaMFsv8jH/MJDLIylJN81eTJ5kvx7B7p18OiPK0BkC06lydEy63A==", "dev": true }, "node_modules/emoji-regex": { @@ -2771,9 +2771,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.16.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.1.tgz", - "integrity": "sha512-4U5pNsuDl0EhuZpq46M5xPslstkviJuhrdobaRDBk2Jy2KO37FDAJl4lb2KlNabxT0m4MTK2UHNrsAcphE8nyw==", + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.0.tgz", + "integrity": "sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==", "dev": true, "dependencies": { "graceful-fs": "^4.2.4", @@ -3575,6 +3575,7 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", @@ -4411,9 +4412,9 @@ } }, "node_modules/jackspeak": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.1.2.tgz", - "integrity": "sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", + "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" @@ -5056,6 +5057,29 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/mocha/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mocha/node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -6067,6 +6091,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, "dependencies": { "glob": "^7.1.3" @@ -6092,6 +6117,7 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", @@ -7238,9 +7264,9 @@ } }, "node_modules/webpack-dev-middleware/node_modules/ajv": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.13.0.tgz", - "integrity": "sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==", + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.16.0.tgz", + "integrity": "sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.3", @@ -7350,9 +7376,9 @@ } }, "node_modules/webpack-dev-server/node_modules/ajv": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.13.0.tgz", - "integrity": "sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==", + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.16.0.tgz", + "integrity": "sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.3", diff --git a/package.json b/package.json index f65dcc08d..6ae609e1b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@pnp/monorepo", "private": true, "type": "module", - "version": "4.1.0", + "version": "4.1.1", "description": "A JavaScript library for SharePoint & Graph development.", "devDependencies": { "@azure/identity": "4.2.0", diff --git a/packages/graph/batching.ts b/packages/graph/batching.ts index 8fea1e78a..9384dc637 100644 --- a/packages/graph/batching.ts +++ b/packages/graph/batching.ts @@ -375,8 +375,6 @@ function parseResponse(graphResponse: IGraphBatchResponse): ParsedGraphResponse // the array of requests and make it easier to map them by index const responseId = parseInt(response.id, 10) - 1; - const contentType = response.headers["Content-Type"]; - const { status, statusText, headers, body } = response; const init = { status, statusText, headers }; @@ -397,7 +395,7 @@ function parseResponse(graphResponse: IGraphBatchResponse): ParsedGraphResponse // eslint-disable-next-line @typescript-eslint/dot-notation parsedResponses[responseId] = new Response(jsS({ location: headers["Location"] || "" }), init); - } else if (status === 200 && /^image[\\|/]/i.test(contentType)) { + } else if (status === 200 && /^image[\\|/]/i.test(headers["Content-Type"] || "")) { // this handles the case where image content is returned as base 64 data in the batch body, such as /me/photos/$value (https://github.com/pnp/pnpjs/issues/2825) diff --git a/test/graph/calendars.ts b/test/graph/calendars.ts index 5a121e7f5..dbfd2017e 100644 --- a/test/graph/calendars.ts +++ b/test/graph/calendars.ts @@ -6,6 +6,7 @@ import "@pnp/graph/attachments"; import { HttpRequestError } from "@pnp/queryable"; import { getRandomString, stringIsNullOrEmpty } from "@pnp/core"; import getValidUser from "./utilities/getValidUser.js"; +import { fail } from "assert"; // TODO:: test recording setup describe("Calendar", function () { @@ -460,8 +461,8 @@ describe("Calendar", function () { // currently not working it.skip("Get Event Attachments", async function () { - // const attachment = await this.pnp.graph.users.getById(testUserName).events.getById(testEventID).attachments.addFile( - // { name: "Test.txt" }, "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk"); + // const attachment = await this.pnp.graph.users.getById(testUserName).events.getById(testEventID).attachments.addFile( + // { name: "Test.txt" }, "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk"); const attachments = await this.pnp.graph.users.getById(testUserName).events.getById(testEventID).attachments(); return expect(attachments.length).is.greaterThan(0); @@ -606,16 +607,20 @@ describe("Calendar", function () { allowedRoles: ["read", "write"], }); - await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id).update({ - role: "write", - }); + if (permission.id) { + await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id).update({ + role: "write", + }); - const updatedPermission = await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id)(); - if (updatedPermission.id && updatedPermission.role === "write") { - passed = true; - await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).delete(); + const updatedPermission = await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).calendarPermissions.getById(permission.id)(); + if (updatedPermission.id && updatedPermission.role === "write") { + passed = true; + await this.pnp.graph.users.getById(testUserName).calendars.getById(calendar.id).delete(); + } + return expect(passed).is.true; + } else { + return fail("Permissions could not be created on the calendar object, test could not be completed."); } - return expect(passed).is.true; }); // This logs to the console when it passes, ignore those messages diff --git a/test/graph/contacts.ts b/test/graph/contacts.ts index c62d8f0b7..06b6ef7c9 100644 --- a/test/graph/contacts.ts +++ b/test/graph/contacts.ts @@ -194,9 +194,8 @@ describe("Contacts", function () { try { // This passes the first time through, expecting it to fail on second pass. // If we try to find a folder that doesn't exist this returns a 404 - await this.pnp.graph.users.getById(testUserName).contactFolders.getById(folder.id)(); - deletedFolderFound = true; - + const deletedFolder = await this.pnp.graph.users.getById(testUserName).contactFolders.getById(folder.id)(); + deletedFolderFound = (deletedFolder?.id.length> 0); } catch (e) { if (e?.isHttpRequestError) { if ((e).status === 404) { diff --git a/test/sp/clientside-pages.ts b/test/sp/clientside-pages.ts index e92dc0226..7d6734f57 100644 --- a/test/sp/clientside-pages.ts +++ b/test/sp/clientside-pages.ts @@ -375,7 +375,7 @@ describe("Clientside Pages", function () { await page.save(); const page2 = await this.pnp.sp.web.loadClientsidePage(pageUrl); - expect(page2.authorByLine).to.eq(userPrincipalName); + expect(page2.authorByLine.toLowerCase()).to.eq(userPrincipalName.toLowerCase()); })); it("setAuthorByLoginName()", pnpTest("8eb5897e-8b43-45ba-acbc-468495e189fe", async function () { @@ -385,7 +385,7 @@ describe("Clientside Pages", function () { const page2 = await this.pnp.sp.web.loadClientsidePage(pageUrl); - expect(page2.authorByLine).to.eq(userPrincipalName); + expect(page2.authorByLine.toLowerCase()).to.eq(userPrincipalName.toLowerCase()); })); });