diff --git a/CHANGELOG.md b/CHANGELOG.md index c06be4efc..64f4dd851 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.23.0 - 2024-Feb-19 + +- graph + - Addresses #2911 - fixed Photos endpoint bug + - Add getSchedule to Calendar + +- queryable + - Addresses #2890 - fixed node clone bug - reverts new rawData emit to fix bug introduced that broke batching/cashing + ## 3.22.0 - 2024-Jan-15 - sp diff --git a/docs/graph/calendars.md b/docs/graph/calendars.md index b25ce0dbc..51f22940f 100644 --- a/docs/graph/calendars.md +++ b/docs/graph/calendars.md @@ -177,6 +177,33 @@ await graph.users.getById('user@tenant.onmicrosoft.com').events.getById(EVENT_ID await graph.me.events.getById(EVENT_ID).delete(); ``` +## Get Schedules + +Get the free/busy availability information for a collection of users, distributions lists, or resources (rooms or equipment) for a specified time period. + +```TypeScript +import { graphfi } from "@pnp/graph"; +import '@pnp/graph/calendars'; +import '@pnp/graph/users'; + +const graph = graphfi(...); + +await graph.users.getById('user@tenant.onmicrosoft.com').calendar.schedule.get( +{ + "startTime": { + "dateTime": "2017-04-15T12:00:00", + "timeZone": "Pacific Standard Time" + }, + "endTime": { + "dateTime": "2017-04-15T14:00:00", + "timeZone": "Pacific Standard Time" + }, + "schedules": [ + "user@tenant.onmicrosoft.com" + ], + "availabilityViewInterval": 30 +}); +``` ## Get Calendar for a Group diff --git a/docs/queryable/behaviors.md b/docs/queryable/behaviors.md index b7fb91964..5bc94e91f 100644 --- a/docs/queryable/behaviors.md +++ b/docs/queryable/behaviors.md @@ -176,19 +176,16 @@ export function Caching(props?: ICachingProps): TimelinePipe { const cached = getCachedValue(); // we need to ensure that result stays "undefined" unless we mean to set null as the result - if (cached === null) { + 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) { - setCachedValue(response); - })); + this.on.post(async function (url: URL, result: any) { + setCachedValue(result); + return [url, result]; + }); } else { - // if we find it in cache, override send request, and continue flow through timeline and parsers. - this.on.auth.clear(); - this.on.send.replace(async function (this: Queryable) { - return new Response(cached, {}); - }); + result = cached; } } diff --git a/docs/sp/files.md b/docs/sp/files.md index d97378989..9077c3cc1 100644 --- a/docs/sp/files.md +++ b/docs/sp/files.md @@ -136,6 +136,8 @@ The addUsingPath method, supports the percent or pound characters in file names. When using EnsureUniqueFileName property, you must omit the Overwrite parameter. +![Batching Not Supported Banner](https://img.shields.io/badge/Batching%20Not%20Supported-important.svg) + ```TypeScript import { spfi } from "@pnp/sp"; import "@pnp/sp/webs"; diff --git a/package-lock.json b/package-lock.json index 80a89018d..3930ea08f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pnp/monorepo", - "version": "3.22.0", + "version": "3.23.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@pnp/monorepo", - "version": "3.22.0", + "version": "3.23.0", "license": "MIT", "devDependencies": { "@azure/identity": "3.4.1", @@ -67,26 +67,38 @@ } }, "node_modules/@azure/core-auth": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.5.0.tgz", - "integrity": "sha512-udzoBuYG1VBoHVohDTrvKjyzel34zt77Bhp7dQntVGGD0ehVq48owENbBG8fIgkHRNUBQH5k1r0hpoMu5L8+kw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.6.0.tgz", + "integrity": "sha512-3X9wzaaGgRaBCwhLQZDtFp5uLIXCPrGbwJNWPPugvL4xbIGgScv77YzzxToKGLAKvG9amDoofMoP+9hsH1vs1w==", "dev": true, "dependencies": { - "@azure/abort-controller": "^1.0.0", + "@azure/abort-controller": "^2.0.0", "@azure/core-util": "^1.1.0", "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-auth/node_modules/@azure/abort-controller": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", + "dev": true, + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" } }, "node_modules/@azure/core-client": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.7.3.tgz", - "integrity": "sha512-kleJ1iUTxcO32Y06dH9Pfi9K4U+Tlb111WXEnbt7R/ne+NLRwppZiTGJuTD5VVoxTMK5NTbEtm5t2vcdNCFe2g==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.8.0.tgz", + "integrity": "sha512-+gHS3gEzPlhyQBMoqVPOTeNH031R5DM/xpCvz72y38C09rg4Hui/1sJS/ujoisDZbbSHyuRLVWdFlwL0pIFwbg==", "dev": true, "dependencies": { - "@azure/abort-controller": "^1.0.0", + "@azure/abort-controller": "^2.0.0", "@azure/core-auth": "^1.4.0", "@azure/core-rest-pipeline": "^1.9.1", "@azure/core-tracing": "^1.0.0", @@ -95,16 +107,28 @@ "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-client/node_modules/@azure/abort-controller": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", + "dev": true, + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" } }, "node_modules/@azure/core-rest-pipeline": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.13.0.tgz", - "integrity": "sha512-a62aP/wppgmnfIkJLfcB4ssPBcH94WzrzPVJ3tlJt050zX4lfmtnvy95D3igDo3f31StO+9BgPrzvkj4aOxnoA==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.14.0.tgz", + "integrity": "sha512-Tp4M6NsjCmn9L5p7HsW98eSOS7A0ibl3e5ntZglozT0XuD/0y6i36iW829ZbBq0qihlGgfaeFpkLjZ418KDm1Q==", "dev": true, "dependencies": { - "@azure/abort-controller": "^1.1.0", + "@azure/abort-controller": "^2.0.0", "@azure/core-auth": "^1.4.0", "@azure/core-tracing": "^1.0.1", "@azure/core-util": "^1.3.0", @@ -117,6 +141,18 @@ "node": ">=18.0.0" } }, + "node_modules/@azure/core-rest-pipeline/node_modules/@azure/abort-controller": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", + "dev": true, + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/@azure/core-tracing": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.0.1.tgz", @@ -130,16 +166,28 @@ } }, "node_modules/@azure/core-util": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.6.1.tgz", - "integrity": "sha512-h5taHeySlsV9qxuK64KZxy4iln1BtMYlNt5jbuEFN3UFSAd1EwKg/Gjl5a6tZ/W8t6li3xPnutOx7zbDyXnPmQ==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.7.0.tgz", + "integrity": "sha512-Zq2i3QO6k9DA8vnm29mYM4G8IE9u1mhF1GUabVEqPNX8Lj833gdxQ2NAFxt2BZsfAL+e9cT8SyVN7dFVJ/Hf0g==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-util/node_modules/@azure/abort-controller": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", "dev": true, "dependencies": { - "@azure/abort-controller": "^1.0.0", "tslib": "^2.2.0" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" } }, "node_modules/@azure/identity": { @@ -168,12 +216,12 @@ } }, "node_modules/@azure/identity/node_modules/@azure/msal-node": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.6.1.tgz", - "integrity": "sha512-wYwz83pWatTNWUCkTi3cAOXbchad5FnZz/pbZz7b8Z6FuEqohXcTtg6BLip9SmcjN6FlbwUdJIZYOof2v1Gnrg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.6.4.tgz", + "integrity": "sha512-nNvEPx009/80UATCToF+29NZYocn01uKrB91xtFr7bSqkqO1PuQGXRyYwryWRztUrYZ1YsSbw9A+LmwOhpVvcg==", "dev": true, "dependencies": { - "@azure/msal-common": "14.6.0", + "@azure/msal-common": "14.7.1", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" }, @@ -194,21 +242,21 @@ } }, "node_modules/@azure/msal-browser": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-3.7.0.tgz", - "integrity": "sha512-ktDB/Gf7UDgYBJOnoIlh70lxIo4e1/D2UgHuayB4RntN1IlusfTtIVH3k8NpJMdl+38tfTXIaUoR+qlr5voZEg==", + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-3.10.0.tgz", + "integrity": "sha512-mnmi8dCXVNZI+AGRq0jKQ3YiodlIC4W9npr6FCB9WN6NQT+6rq+cIlxgUb//BjLyzKsnYo+i4LROGeMyU+6v1A==", "dev": true, "dependencies": { - "@azure/msal-common": "14.6.0" + "@azure/msal-common": "14.7.1" }, "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-common": { - "version": "14.6.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.6.0.tgz", - "integrity": "sha512-AGusT/JvxdzJIYi5u0n97cmhd3pUT6UuI6rEkT5iDeT2FGcV0/EB8pk+dy6GLPpYg9vhDCuyoYrEZGd+2UeCCQ==", + "version": "14.7.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.7.1.tgz", + "integrity": "sha512-v96btzjM7KrAu4NSEdOkhQSTGOuNUIIsUdB8wlyB9cdgl5KqEKnTonHUZ8+khvZ6Ap542FCErbnTyDWl8lZ2rA==", "dev": true, "engines": { "node": ">=0.8.0" @@ -529,9 +577,9 @@ } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", - "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, "engines": { "node": ">=6.0.0" @@ -563,9 +611,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.21", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz", - "integrity": "sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==", + "version": "0.3.22", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.22.tgz", + "integrity": "sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -766,9 +814,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "4.17.41", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz", - "integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==", + "version": "4.17.43", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.43.tgz", + "integrity": "sha512-oaYtiBirUOPQGSWNGPWnzyAFJ0BP3cwvN4oWZQY+zUBwpVIGsKUkpBpSztp74drYcjavs7SKFZ4DX1V2QeN8rg==", "dev": true, "dependencies": { "@types/node": "*", @@ -903,9 +951,9 @@ "dev": true }, "node_modules/@types/semver": { - "version": "7.5.6", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", - "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.7.tgz", + "integrity": "sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==", "dev": true }, "node_modules/@types/send": { @@ -2081,9 +2129,9 @@ "dev": true }, "node_modules/browserslist": { - "version": "4.22.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", - "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", + "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==", "dev": true, "funding": [ { @@ -2100,8 +2148,8 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001565", - "electron-to-chromium": "^1.4.601", + "caniuse-lite": "^1.0.30001587", + "electron-to-chromium": "^1.4.668", "node-releases": "^2.0.14", "update-browserslist-db": "^1.0.13" }, @@ -2166,14 +2214,19 @@ } }, "node_modules/call-bind": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", - "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dev": true, "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.1", - "set-function-length": "^1.1.1" + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2231,9 +2284,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001576", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001576.tgz", - "integrity": "sha512-ff5BdakGe2P3SQsMsiqmt1Lc8221NR1VzHj5jXN5vBny9A6fpze94HiVV/n7XRosOlsShJcvMv5mdnpjOGCEgg==", + "version": "1.0.30001588", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001588.tgz", + "integrity": "sha512-+hVY9jE44uKLkH0SrUTqxjxqNTOWHsbnQDIKjwkZ3lNTzUUVdBLBGXtj/q5Mp5u98r3droaZAewQuEDzjQdZlQ==", "dev": true, "funding": [ { @@ -2309,16 +2362,10 @@ } }, "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -2331,6 +2378,9 @@ "engines": { "node": ">= 8.10.0" }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, "optionalDependencies": { "fsevents": "~2.3.2" } @@ -2868,17 +2918,20 @@ } }, "node_modules/define-data-property": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", - "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, "dependencies": { - "get-intrinsic": "^1.2.1", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/define-lazy-prop": { @@ -3109,9 +3162,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.630", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.630.tgz", - "integrity": "sha512-osHqhtjojpCsACVnuD11xO5g9xaCyw7Qqn/C2KParkMv42i8jrJJgx3g7mkHfpxwhy9MnOJr8+pKOdZ7qzgizg==", + "version": "1.4.673", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.673.tgz", + "integrity": "sha512-zjqzx4N7xGdl5468G+vcgzDhaHkaYgVcf9MqgexcTqsl2UHSCmOj/Bi3HAprg4BZCpC7HyD8a6nZl6QAZf72gw==", "dev": true }, "node_modules/emoji-regex": { @@ -3161,9 +3214,9 @@ } }, "node_modules/envinfo": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.0.tgz", - "integrity": "sha512-G9/6xF1FPbIw0TtalAMaVPpiq2aDEuKLXM314jPVAO9r2fo2a4BLqMNkmRS7O/xPPZ+COAhGIz3ETvHEV3eUcg==", + "version": "7.11.1", + "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.1.tgz", + "integrity": "sha512-8PiZgZNIB4q/Lw4AhOvAfB/ityHAd2bli3lESSWmWSzSsl5dKpy5N1d1Rfkd2teq/g9xN90lc6o98DOjMeYHpg==", "dev": true, "bin": { "envinfo": "dist/cli.js" @@ -3181,6 +3234,27 @@ "is-arrayish": "^0.2.1" } }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/es-module-lexer": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.4.1.tgz", @@ -3236,9 +3310,9 @@ } }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "dev": true, "engines": { "node": ">=6" @@ -3750,9 +3824,9 @@ } }, "node_modules/fastq": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", - "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -4112,16 +4186,20 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, "dependencies": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -5222,12 +5300,12 @@ } }, "node_modules/has-property-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", - "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, "dependencies": { - "get-intrinsic": "^1.2.2" + "es-define-property": "^1.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -5321,9 +5399,9 @@ } }, "node_modules/hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", "dev": true, "dependencies": { "function-bind": "^1.1.2" @@ -5520,9 +5598,9 @@ } }, "node_modules/ignore": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", - "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true, "engines": { "node": ">= 4" @@ -6932,6 +7010,33 @@ "balanced-match": "^1.0.0" } }, + "node_modules/mocha/node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/mocha/node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -8597,9 +8702,9 @@ } }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -8777,14 +8882,15 @@ "dev": true }, "node_modules/set-function-length": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", - "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", "dev": true, "dependencies": { - "define-data-property": "^1.1.1", + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.3", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.1" }, @@ -8877,14 +8983,18 @@ } }, "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", + "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", "dev": true, "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -9085,9 +9195,9 @@ } }, "node_modules/spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", "dev": true }, "node_modules/spdx-expression-parse": { @@ -9101,9 +9211,9 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.16.tgz", - "integrity": "sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.17.tgz", + "integrity": "sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==", "dev": true }, "node_modules/spdy": { @@ -9247,9 +9357,9 @@ "dev": true }, "node_modules/stream-shift": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.2.tgz", - "integrity": "sha512-rV4Bovi9xx0BFzOb/X0B2GqoIjvqPCttZdu0Wgtx2Dxkj7ETyWl9gmqJ4EutWRLvtZWm8dxE+InQZX1IryZn/w==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", + "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", "dev": true }, "node_modules/string_decoder": { @@ -9398,9 +9508,9 @@ } }, "node_modules/terser": { - "version": "5.26.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.26.0.tgz", - "integrity": "sha512-dytTGoE2oHgbNV9nTzgBEPaqAWvcJNl66VZ0BkJqlvp71IjO8CxdBx/ykCNb47cLnCmCvRZ6ZR0tLkqvZCdVBQ==", + "version": "5.27.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.27.2.tgz", + "integrity": "sha512-sHXmLSkImesJ4p5apTeT63DsV4Obe1s37qT8qvwHRmVxKTBH7Rv9Wr26VcAMmLbmk9UliiwK8z+657NyJHHy/w==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", @@ -10154,9 +10264,9 @@ } }, "node_modules/web-streams-polyfill": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz", - "integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", "dev": true, "engines": { "node": ">= 8" diff --git a/package.json b/package.json index 880f7c18a..a7f27b12f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@pnp/monorepo", "private": true, "type": "module", - "version": "3.22.0", + "version": "3.23.0", "description": "A JavaScript library for SharePoint & Graph development.", "devDependencies": { "@azure/identity": "3.4.1", diff --git a/packages/graph/batching.ts b/packages/graph/batching.ts index 5e306a203..5ce525782 100644 --- a/packages/graph/batching.ts +++ b/packages/graph/batching.ts @@ -1,4 +1,4 @@ -import { isUrlAbsolute, hOP, TimelinePipe, getGUID, CopyFrom, objectDefinedNotNull, isFunc, combine } from "@pnp/core"; +import { isUrlAbsolute, hOP, TimelinePipe, getGUID, CopyFrom, objectDefinedNotNull, isFunc, combine, jsS } from "@pnp/core"; import { parseBinderWithErrorCheck, Queryable, body, InjectHeaders } from "@pnp/queryable"; import { IGraphQueryable, _GraphQueryable } from "./graphqueryable.js"; import { graphPost } from "./operations.js"; @@ -48,9 +48,7 @@ interface IGraphBatchResponseFragment { statusText?: string; method: string; url: string; - headers?: string[][] | { - [key: string]: string; - }; + headers?: [string, string][] | Record; body?: any; } @@ -373,36 +371,60 @@ function formatRequests(requests: RequestRecord[], batchId: string): IGraphBatch }); } -function parseResponse(graphResponse: IGraphBatchResponse): Promise { +function parseResponse(graphResponse: IGraphBatchResponse): ParsedGraphResponse { - return new Promise((resolve, reject) => { + // we need to see if we have an error and report that + if (hOP(graphResponse, "error")) { + throw Error(`Error Porcessing Batch: (${graphResponse.error.code}) ${graphResponse.error.message}`); + } - // we need to see if we have an error and report that - if (hOP(graphResponse, "error")) { - return reject(Error(`Error Porcessing Batch: (${graphResponse.error.code}) ${graphResponse.error.message}`)); - } + const parsedResponses: Response[] = new Array(graphResponse.responses.length).fill(null); - const parsedResponses: Response[] = new Array(graphResponse.responses.length).fill(null); + for (let i = 0; i < graphResponse.responses.length; ++i) { - for (let i = 0; i < graphResponse.responses.length; ++i) { + const response = graphResponse.responses[i]; + // we create the request id by adding 1 to the index, so we place the response by subtracting one to match + // 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 }; - const response = graphResponse.responses[i]; - // we create the request id by adding 1 to the index, so we place the response by subtracting one to match - // the array of requests and make it easier to map them by index - const responseId = parseInt(response.id, 10) - 1; - if (response.status === 204) { + // this is to handle special cases before we pass to the default parsing logic + if (status === 204) { - parsedResponses[responseId] = new Response(); - } else { + // this handles cases where the response body is empty and has a 204 response status (No Content) + parsedResponses[responseId] = new Response(null, init); - parsedResponses[responseId] = new Response(JSON.stringify(response.body), response); - } + } else if (status === 302) { + + // this is the case where (probably) a file download was included in the batch and the service has returned a 302 redirect to that file + // the url should be in the response's location header, so we transform the response to a 200 with the location in the body as 302 will be an + // error in the default parser used on the individual request + + init.status = 200; + // 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)) { + + // 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) + + const encoder = new TextEncoder(); + parsedResponses[responseId] = new Response(encoder.encode(body), init); + + } else { + + // this is the default case where we have a json body which we remake into a string for the downstream parser to parse again + // a bit circular, but this provides consistent behavior for downstream parsers + + parsedResponses[responseId] = new Response(jsS(body), init); } + } - resolve({ - nextLink: graphResponse.nextLink, - responses: parsedResponses, - }); - }); + return { + nextLink: graphResponse.nextLink, + responses: parsedResponses, + }; } diff --git a/packages/graph/calendars/types.ts b/packages/graph/calendars/types.ts index 009a969f9..a1c4c6744 100644 --- a/packages/graph/calendars/types.ts +++ b/packages/graph/calendars/types.ts @@ -1,5 +1,10 @@ import { body } from "@pnp/queryable"; -import { Event as IEventType, Calendar as ICalendarType } from "@microsoft/microsoft-graph-types"; +import { + Event as IEventType, + Calendar as ICalendarType, + ScheduleInformation as IScheduleInformationType, + DateTimeTimeZone as IDateTimeTimeZoneType, +} from "@microsoft/microsoft-graph-types"; import { _GraphQueryableCollection, _GraphQueryableInstance, graphInvokableFactory } from "../graphqueryable.js"; import { defaultPath, IDeleteable, deleteable, IUpdateable, updateable, getById, IGetById } from "../decorators.js"; import { graphPost } from "../operations.js"; @@ -10,11 +15,22 @@ import { calendarView, instances } from "./funcs.js"; */ export class _Calendar extends _GraphQueryableInstance { + public calendarView = calendarView; + public get events(): IEvents { return Events(this); } - public calendarView = calendarView; + /** + * Get the free/busy availability information for a collection of users, + * distributions lists, or resources (rooms or equipment) for a specified time period. + * + * @param properties The set of properties used to get the schedule + */ + public async getSchedule(properties: IGetScheduleRequest): Promise { + return graphPost(Calendar(this, "getSchedule"), body(properties)); + } + } export interface ICalendar extends _Calendar { } export const Calendar = graphInvokableFactory(_Calendar); @@ -71,3 +87,23 @@ export interface IEventAddResult { data: IEventType; event: IEvent; } + +export interface IGetScheduleRequest { + /** + * A collection of SMTP addresses of users, distribution lists, or resources to get availability information for. + */ + schedules: string[]; + /** + * The date, time, and time zone that the period starts. + */ + startTime: IDateTimeTimeZoneType; + /** + * The date, time, and time zone that the period ends. + */ + endTime: IDateTimeTimeZoneType; + /** + * Represents the duration of a time slot in an availabilityView in the response. + * The default is 30 minutes, minimum is 5, maximum is 1440. Optional. + */ + availabilityViewInterval?: number; +} diff --git a/packages/graph/content-types/types.ts b/packages/graph/content-types/types.ts index 5dd4cce29..bb37ef9de 100644 --- a/packages/graph/content-types/types.ts +++ b/packages/graph/content-types/types.ts @@ -83,7 +83,7 @@ export class _ContentTypes extends _GraphQueryableCollection { const creator = ContentType(this, "addCopyFromContentTypeHub").using(JSONHeaderParse()); const data = await graphPost(creator, body({ contentTypeId })); - const pendingLocation = data.headers.location || null; + const pendingLocation = data?.headers?.location || null; return { data: data.data, contentType: (this).getById(data.id), diff --git a/packages/queryable/behaviors/caching.ts b/packages/queryable/behaviors/caching.ts index c88d402b4..f1dad8446 100644 --- a/packages/queryable/behaviors/caching.ts +++ b/packages/queryable/behaviors/caching.ts @@ -97,16 +97,13 @@ export function Caching(props?: ICachingProps): TimelinePipe { 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 - instance.on.rawData(noInherit(async function (response) { - setCachedValue(response); + this.on.post(noInherit(async function (url: URL, result: any) { + setCachedValue(result); + return [url, result]; })); } else { - // if we find it in cache, override send request, and continue flow through timeline and parsers. - this.on.auth.clear(); - this.on.send.replace(async function (this: Queryable) { - return new Response(cached, {}); - }); + result = cached; } } diff --git a/packages/queryable/behaviors/parsers.ts b/packages/queryable/behaviors/parsers.ts index 6fe2fe264..68b171310 100644 --- a/packages/queryable/behaviors/parsers.ts +++ b/packages/queryable/behaviors/parsers.ts @@ -1,5 +1,5 @@ import { Queryable } from "../queryable.js"; -import { hOP, TimelinePipe, parseToAtob } from "@pnp/core"; +import { hOP, TimelinePipe } from "@pnp/core"; import { isFunc } from "@pnp/core"; export function DefaultParse(): TimelinePipe { @@ -25,21 +25,7 @@ export function TextParse(): TimelinePipe { export function BlobParse(): TimelinePipe { - return parseBinderWithErrorCheck( async (response) => { - 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 - const arrayBuffer = new ArrayBuffer(binaryResponseBody.length); - const uint8Array = new Uint8Array(arrayBuffer); - for (let i = 0; i < binaryResponseBody.length; i++) { - uint8Array[i] = binaryResponseBody.charCodeAt(i); - } - // Create a Blob from the array buffer - return new Blob([arrayBuffer], {type:response.headers.get("Content-Type")}); - } - return response.blob(); - }); + return parseBinderWithErrorCheck(r => r.blob()); } export function JSONParse(): TimelinePipe { @@ -69,8 +55,7 @@ export function JSONHeaderParse(): TimelinePipe { // patch to handle cases of 200 response with no or whitespace only bodies (#487 & #545) const txt = await response.text(); const json = txt.replace(/\s/ig, "").length > 0 ? JSON.parse(txt) : {}; - const all = { data: { ...parseODataJSON(json) }, headers: { ...response.headers } }; - return all; + return { data: { ...parseODataJSON(json) }, headers: { ...response.headers } }; }); } @@ -123,12 +108,7 @@ export function parseBinderWithErrorCheck(impl: (r: Response) => Promise): instance.on.parse(async (url: URL, response: Response, result: any): Promise<[URL, Response, any]> => { if (response.ok && typeof result === "undefined") { - 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; - (instance).emit.rawData(raw); + result = await impl(response); } return [url, response, result]; diff --git a/packages/queryable/queryable.ts b/packages/queryable/queryable.ts index b1db19f6f..d30904fbe 100644 --- a/packages/queryable/queryable.ts +++ b/packages/queryable/queryable.ts @@ -25,7 +25,6 @@ const DefaultMoments = { parse: asyncReduce(), post: asyncReduce(), data: broadcast(), - rawData: broadcast(), } as const; export type QueryableInit = Queryable | string | [Queryable, string]; diff --git a/test/graph/calendars.ts b/test/graph/calendars.ts index 68251730b..992f76e28 100644 --- a/test/graph/calendars.ts +++ b/test/graph/calendars.ts @@ -79,6 +79,28 @@ describe("Calendar", function () { return expect(calendar).is.not.null; }); + it("Get User's Schedule", async function () { + const startDate: Date = new Date(); + startDate.setDate(startDate.getDate() + 1); + const endDate: Date = startDate; + endDate.setHours(startDate.getHours() + 10); + const schedule = await this.pnp.graph.users.getById(testUserName).calendar.getSchedule( + { + "schedules": [ + testUserName, + ], + "startTime": { + "dateTime": startDate.toISOString(), + "timeZone": "Pacific Standard Time", + }, + "endTime": { + "dateTime": endDate.toISOString(), + "timeZone": "Pacific Standard Time", + }, + }); + return expect(schedule).is.not.null; + }); + it("Get Events From User's Default Calendar", async function () { const events = await this.pnp.graph.users.getById(testUserName).calendar.events(); return expect(events.length).is.greaterThan(0);