From 2d3d368528a29f42c2a7b48e9a79424ef540fc26 Mon Sep 17 00:00:00 2001 From: Patrick Rodgers Date: Tue, 27 Jun 2023 19:56:35 -0400 Subject: [PATCH 01/28] new v4 change log, start of graph async iterators for paging --- CHANGELOG.md | 524 +--------------------- debug/launch/graph.ts | 20 +- debug/launch/main.ts | 4 +- docs/graph/onedrive.md | 10 + packages/graph/behaviors/paged.ts | 60 ++- packages/graph/directory-objects/types.ts | 15 +- packages/graph/graphqueryable.ts | 11 +- packages/graph/onedrive/types.ts | 10 +- 8 files changed, 78 insertions(+), 576 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cb5e5160..dc16dabe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,534 +5,12 @@ 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.16.0 - 2023-Jun-9 +## 4.0.0 - 2023-Nov-11 ### Fixed -- sp - - Addresses #2681 - Fix for cannot read properties of undefined (reading 'prototype') - - Addresses #2685 - Fix for multichoice field properties - - Addresses #2688 - Fix for apostorphes in filename - -### Added - -- graph - - Adds shares modules to graph library - -## 3.15.0 - 2023-May-12 - -### Fixed - -- timeline - - Addresses #2669 - Adds code in Timeline emit to ensure we don't create empty observer arrays on the Timeline.observers container due to filtering for once. - -- nodejs - - Modified SPDefault and GraphDefault so empty object is not required. - -- sp - - Addresses #2646 - Issue with creating fields when batching. - - Addresses #2661 - Adding BatchNever to Request-Digest Behavior when retrieving a new RequestDigest token. - -- azidjsclient - - Fix bug with caching in Azure Identity Client wrapper and improve key generation - -## 3.14.0 - 2023-Apr-17 - -### Added - -- sp - - Added groupsitemanager module to help manage team sites. - - Addresses #2565 - Adds a method to Sites to set the site logo vs web property update to set the site logo thumbnail - - Addresses #2602 - adds a tenantAppcatalog property to the root sp object; ensures that web.appcatalog points to the sitecollection appcatalog - -- azidjsclient - - Added new azidjsclient package that supports Azure Identity, most useful for node-js development and managed identity - -- node - Update to node package GraphDefault and SPDefault package to make msal parameter optional (deprecated) and updated the documentation for new guidance on passing the MSAL (and AzureIdentity) auth methods as separate observerable on the using call. - -### Fixed - -- docs - - Updated Taxonomy documentation to call out need for auth token on add/update/delete events. - - Addresses #2604 - Updating Docs for Page Comments to include proper atMention functionality. - -- general - - Updated debug scenarios for spa to make debugging work with settings file. - - Updated package-lock.json for SPFx debugging scenario to fix a bug - -- sp - - Addresses #2629 - Bug fix for missing quotes on sp recycle bin getById method. - - Addresses #2615 - fixes a bug with batching and caching in graph where requests were not resolving correctly, the fix from Version 3 - launch prep 1 #2052 applied to graph lib - -## 3.13.0 - 2023-Mar-17 - -### Added - -- sp - - Added getCurrentUserMemberships to new publishingSitePageService import. - -### Fixed - -- node - - Fixed typing issues with asCanceable wrapper and dropped references in stream.d.ts. - - Fixed setStreamContentChunked to fixed unhandled promise. - -## 3.12.1 - 2023-Feb-14 - -### Fixed - -- sp - - Addresses #2570, #2571 - Removes adding a bearer token by default to SPFx requests - -## 3.12.0 - 2023-Feb-10 - -**Please note:** We are official closing support for v2. Moving forward we will no longer do releases for the v2 version. - -### Added - -- graph - - Addresses #2552 - Adds an SPFx Token behavior to sp and graph libraries - -- sp - - Addresses #2552 - Adds an SPFx Token behavior to sp and graph libraries - - Addresses #2551 - Add typings when fetching Site data and change typings for getDocumentLibraries - -### Fixed - -- core - - Fixes #2539 - Fix unhandlable promise in start() - -- sp - - Fixes #2561 - Changes behavior in processing for saving client side pages to process all controls through the specialSaveHandling function - - Fixes #2558 - Issue with getParentWeb from root site - - Fixes #2550 - Fix for request digest timeout after tab sleeps - -- sp-admin - - Fixes #2518 - Replacing 'CreateGroupForSite' method example by 'AddTenantCdnOrigin' - -## 3.11.0 - 2023-Jan-13 - ### Added -- graph - - Added various methods to OneDrive module; GraphFI.Drives,Drives - delta,Drives - upload,Drive - getItemByPath,Drive - getItemsByPath,DriveItem - moveItem,DriveItem - copyItem,DriveItem - convertContent,DriveItem - upload,DriveItem - preview,Root/DriveItem - analytics,List - IDrive.getList - -### Fixed - -- docs - - General typo fixes and updates - -- core - - Fixes #2507 - Updates the timeline start logic to get a ref to the promise rather than attaching finally directly. - -- sp - - Fixes #2509 - Fix but with item.setImageField - -- node - - Fixes #2532 - Fix setStreamContentChunked: await loading chunks - ### Removed -- graph - - Deprecated OneDrive module; DriveItem - move - replaced by moveItem, DriveItem - setContent - replaced by upload - -## 3.10.0 - 2022-Dec-13 - -### Added - -- queryable - - Added CacheNever behavior - - Adds bindCachingCore method to reuse the caching props calculation logic - -- sp - - Added ability to limit the getSharingInformation returned properties - - Adding support for add/update/delete for taxonomy entities - -- graph - - Added followed endpoint to Drives - - Adds options to Graph - OneDrive sharedWithMe method - -### Fixed - -- docs - - General typo fixes and updates - -- queryable - - Fix for CachingPessimistic behavior - -- sp - - Fixing #2448 appears to have reverted #2414, and now fixed again - -- graph - - Bug fix for DrvieItem.getContent when using Caching behavior - -## 3.9.0 - 2022-Nov-11 - -### Added - -- sp - - Support for multi-line batch responses - -- graph - - Add getting site by resource url instead of id - -### Fixed - -- docs - - General typo fixes and updates - -- sp - - Updates Search and Suggest to be true invokable factories - - Updates docs for search on using factory methods - - Updates logic in sp.search and sp.searchSuggest - - fix to await the completePromises in batches that have no requests due to caching supplying all the results. - -- graph - - This update includes a fix for an improperly formed search endpoint on the root drive. - -## 3.8.0 - 2022-Oct-14 - -### Added - -- sp - - adds storage metrics for IFolder - - adds return of IFolder or IFile from copyByPath and moveByPath - - adds fileFromPath and fileFromAbsolutePath to get an IFile from arbitrary file paths - - adds folderFromPath and folderFromAbsolutePath to get an IFolder from arbitrary file paths - - adds ability to pass all options to IFolder's moveByPath and copyByPath to match IFile - - adds docs/tests for the new stuff - - adds a new sp module context-info allowing for easier retrieval of contextual information - - adds new CacheAlways behavior - - adds additional props to ISearchResult - - adds additional props to site scripts create/update - -### Fixed - -- docs - - General typo fixes - - Fixed service class example - -- graph - - Fixed bug with getAllChildrenAsOrderedTree, #2414 - - Fixed issue with observables missing when adding drive item, #2435 - -## 3.7.0 - 2022-Sept-9 - -### Added - -- docs - - Updated getting started docs -- sp - - added support for item rating - - added support for favorite sites and items -- graph - - added $search and $filter parameters to Count() and Paged Behavior - -### Fixed - -- docs - - sample for ACS authentication -- sp - - updated for escaping query strings - - enchance copyByPath and moveByPath for sp/file allowing for passing all valid params - -## 3.6.0 - 2022-Aug-16 - -### Fixed - -- core - - addresses #2222, #2356 - Updates to simplify url & query escaping -- sp - - addresses #2372 - Fix bugs with sharing - -### Added - -- docs - - added docs for Graph messages - - update for getting started videos - - update to docs around SPBrowser usage and setting baseUrl -- querable - - new JSONHeaderParse behavior -- graph - - addresses #2323 - Special Folder support - - support for Lists, Columns, Content Types -- sp - - update method for content types - - addresses #2357 - add missing properties to IViewInfo typing - -## 3.5.1 - 2022-July-13 - -### Fixed - -- queryable - - Error in SPFx due to tuple check in queryable constructor, adjusted check & added tests - -## 3.5.0 - 2022-July-12 - -### Fixed - -- docs - - Documentation update for config/services setup -- graph - - Addresses #2316 - PR #2318 Remove specific encodeURIComponents to address double encoding. - - PR #2319 - Added tests for certain graph queryable methods -- sp - - Updates lists IRenderListDataParameters & RenderListDataOptions with new values not present originally -- queryable: - - Beta 2 - Support for cancelling requests (see docs for known issues) -- behaviors - - Fixes #2333 - PR #2344 Addresses issues with reviewing caching and batching. - - Fixes #2329 - Argument of type 'WebPartContext' is not assignable to parameter of type 'ISPFXContext'. - -### Added - -- sp-admin - - Added sp-admin library to support tenant admin APIs - -## 3.4.1 - 2022-June-13 - -### Fixed - -- sp: - - Addresses #2315 - PR #2233 addressed issues #2220 #2222 creating a breaking changed for the Safari (iOS) browser, this release reverses that change. - -## 3.4.0 - 2022-June-10 - -### Fixed - -- docs: - - Various documentation updates -- general: - - Major package version updates - - Various test fixes -- sp: - - Fields add() properties can be undefined bug - - Fix issue with RequestDigest expiring when spfi is reinitialized. - -### Added - -- queryable: - - Support for cancelling requests (beta - see docs for known issues) -- sp: - - Added support for Recycle Bin/Second-Stage Recycle Bin - - Added schedulePublished method for client-side pages -- graph: - - Added support for paging - - Added support for Bookings - -## 3.3.2 - 2022-May-18 - -### Fixed - -- package: - - post-install.cjs fixes --docs: - - Various documentation updates - -## 3.3.1 - 2022-May-17 - -### Fixed - -- package: - - post-install.cjs fixes - -## 3.3.0 - 2022-May-16 - -### Fixed - -- docs: - - Various documentation updates - - Fix for batch example in add multiple items to SharePoint list - - Fix for documentation on getting site users - -- graph: - - Fixed bug in OneDrive package with Drive/getById - - encodes the id provided to getById in graph lib to resolve issue with non-guid ids - - fixes the addtional headers functionality in sendEmail in sp - -- sp: - - Addresses issue where created object in library was not getting observer refs supplied for files.addUsingPath - - Fixed issue with search not caching results when using caching behavior - - Added support for "X-PnP-CacheAlways" header to allow non-get requests to be cached correctly - - Added Items property to IViewFilesInfo - - Fixed issue where some objects created from urls were not getting observer refs - - Added an exception if a queryable it executed with no registered observers and a docs entry to explain it - -### Added - -- sp: - - Added getLockedByUser method on files - -- graph: - - Add chat message to Team channel - -## 3.2.0 - 2022-April-08 - -### Fixed - -- node: - - Fix for CommonJS imports with ESM modules. - -- sp: - - Fix issue with sendEmail utility. - - Bug fixes for getAllChildrenAsOrderedTree in Taxonomy. - - Update for issues with stale requestdigest. - - Bug fix for client-side pages for home page so that title is read from the json blob. - - Remove user-agent header for throttling as no longer used. - - Bug fix for renderListDataAsStream method - -- graph: - - Added getById method to Sites. - - Added transitiveMemberOf method to User. - - Added installedApps method to a Team. - -- docs: - - Various documentation copy/paste and typo fixes. - - Updates for getting-started guidance for imports of both @pnp/sp and @pnp/graph in SPFx. - - Updates to remove documentation showing batching adding files; includes new tag on all areas of library that are not supported for batching. - - New documentation for Graph to get SharePoint sites. - - New doucmentation for updating a BCS field in SharePoint. - - Added Graph memberOf and transitiveMemberOf properties. - - Updated docs on the Web() method. - -## 3.1.0 - 2022-March-11 - -- sp: - - Update interface IFieldInfo to include "Choices" - - Fix getAllChildrenAsOrderedTree retrieve properties - - Fix naming of getEditProfileLink and getIsMyPeopleListPublic in Profiles - -- docs: - - Updates to transition guide, getting started, authentication, and fixes for graphUrls, etc - -## 3.0.3 - 2022-March-3 - -- sp: - - Issues preventing search queries from running. #2124 - -## 3.0.2 - 2022-Feb-22 - -- sp: - - Issue in SPFx behavior with improperly using current web's request digest for non-current web calls #2102 - -- docs: - - Updates based on feedback - - Sample updates for v3 - -## 3.0.1 - 2022-Feb-15 - -- sp: - - Fixed root property initializers #2082 - -## 3.0.0 - 2022-Feb-14 - -### Added - -- common/core: - - Introduced "Timeline" concept with Timline, moments, and observers - - delay utility function - -- logging: - - new PnPLogging behavior to integrate with new model - ### Changed - -- Renamed package "odata" -> "queryable" -- Renamed package "common" -> "core" - -- logging: - - listeners are now factory functions (new ConsoleListener() => ConsoleListener()), drop the 'new' - - Console listener now supports pretty printing options with colors and improved formatting (@thechriskent) - -- core: - - improved typings on utility methods such that TS understands the outcome and properly types results - -- queryable: - - changed constructor to also accept a tuple of [queryable, string] to allow easy rebasing of url while inheriting observers - -- sp: - - Renamed export "sp" -> "spfi" with type SPFI - - Changed to using minimal metadata for all requests - - web.update return changed to `Promise` - - web.getParentWeb return changed to `Promise` - - moved items.getAll to seperate import @pnp/sp/items/get-all - - files.getByName => files.getByUrl - - folders.getByName => folders.getByUrl - - fields.add* methods now take title and a single props object with the additional properties for each field - - TimeZones.getById no merges the object & data - - renamed search.execute => search.run due to naming conflict in new base classes - - renamed suggest.execute => suggest.run due to naming conflict in new base classes - - renamed sitedesigns.execute => sitedesigns.run due to naming conflict in new base classes - - renamed sitescripts.execute => sitescripts.run due to naming conflict in new base classes - - odataUrlFrom moved to utils folder - - getParent signature change, path is second param, baseUrl is third param and only supports string - - removed "core" preset - - Improved web and site contructor to correctly rebase the web/site urls regardless of the url supplied (i.e. create a web from any sp queryable) - - Renamed property in IItemUpdateResultData to "etag" from "odata.etag" to make it .etag vs ["odata.etag"] - -- graph: - - Renamed export "graph" -> "graphfi" with type GraphFI - -### Removed - -- logging - - None of the other packages reference logging anymore, removing a dependency, logging still exists and can be used in your project as before and easily with the new behaviors model - -- queryable: - - LambdaParser -> write an observer - - TextParser, BlobParser, JSONParser, BufferParser -> TextParse, BlobParse, JSONParse, BufferParse behaviors - - Removed .get method in favor of invokable pattern. foo.get() => foo() - - Removed .clone, .cloneTo in favor of using factories directly, i.e. this.clone(Web, "path") => Web(this, "path") - - Invokable Extensions is split, with core object extension functionality moved to core - - ensureHeaders => headers = { ...headers, ...moreHeaders } - -- nodejs: - - AdalCertificateFetchClient, AdalFetchClient, MsalFetchClient, SPFetchClient, ProviderHostedRequestContext -> use MSAL behavior - - BearerTokenFetchClient -> use @pnp/Queryable BearerToken behavior - - SPFetchClient -> Use SPNodeFetch which includes SP retry logic - -- core (common): - - Removed global extensions in favor of instance or factory. Global no longer aligned to our scoped model - - Removed `assign` util method use Object.assign or { ...a, ...b} - - Removed `getCtxCallback` util method - - Removed ITypedHash => built in type Record - - Removed `sanitizeGuid` util method, wasn't used - - Removed automatic cache expired item flushing -> use a timeout, shown in docs - -- graph: - - setEndpoint removed => .using(EndPoint("v1.0")) | .using(EndPoint("beta")) - -- sp: - - Removed createBatch from Site, use web.batched or sp.batched - - feature.deactivate => use features.remove - - getTenantAppCatalogWeb moved from root object to IWeb when imported - - removed use of ListItemEntityTypeFullName in item add/update and removed associated methods to get the value - - removed folders.add => folders.addUsingPath - - removed folder.serverRelativeUrl property => use select - - removed web.getFolderByServerRelativeUrl => web.getFolderByServerRelativePath - - removed files.add => files.addUsingPath - - removed file.copyTo => file.copyByPath - - removed file.moveTo => file.moveByPath - - removed version.delete => versions.deleteById - - removed web.getFileByServerRelativeUrl => web.getFileByServerRelativePath - - removed folder.contentTypeOrder => use .select("contentTypeOrder") - - removed folder.uniqueContentTypeOrder => use .select("uniqueContentTypeOrder") - - removed folder.copyTo => use folder.copyByPath - - removed folder.moveTo => use folder.moveByPath - - removed _SPInstance._update => refactored and unused - - removed objectToSPKeyValueCollection - - removed toAbsoluteUrl => use behaviors - - removed IUtilities.createWikiPage - - removed searchWithCaching, use caching behavior - - removed spODataEntity and spODataEntityArray - - removed attachments addMultiple, deleteMultiple, and recycleMultiple => write a for loop in calling code - - removed regional settings.installedLanguages => use getInstalledLanguages - - removed metadata method - -- sp-addinhelpers: - - Dropped entire package, no longer needed - -- config-store: - - Dropped entire package. - diff --git a/debug/launch/graph.ts b/debug/launch/graph.ts index 10659d478..b5d86fd32 100644 --- a/debug/launch/graph.ts +++ b/debug/launch/graph.ts @@ -6,15 +6,15 @@ declare var process: { exit(code?: number): void }; export async function Example(settings: any) { - const graph = graphSetup(settings); + const graph = graphSetup(settings); - const users = await graph.users(); - - Logger.log({ - data: users, - level: LogLevel.Info, - message: "List of Users Data", - }); - - process.exit(0); + for await (const val of graph.users.top(1).paged()) { + console.log(JSON.stringify(val, null, 2)); + } + + const users = await graph.users(); + + const count = await graph.users.count(); + + process.exit(0); } diff --git a/debug/launch/main.ts b/debug/launch/main.ts index 2a4fdec1e..9c9922e07 100644 --- a/debug/launch/main.ts +++ b/debug/launch/main.ts @@ -8,8 +8,8 @@ import { ITestingSettings } from "../../test/load-settings.js"; // add your debugging imports here and prior to submitting a PR git checkout debug/debug.ts // will allow you to keep all your debugging files locally // comment out the example -import { Example } from "./sp.js"; -// import { Example } from "./graph.js"; +// import { Example } from "./sp.js"; +import { Example } from "./graph.js"; // setup the connection to SharePoint using the settings file, you can // override any of the values as you want here, just be sure not to commit diff --git a/docs/graph/onedrive.md b/docs/graph/onedrive.md index 0411cb349..fb4f968ad 100644 --- a/docs/graph/onedrive.md +++ b/docs/graph/onedrive.md @@ -577,6 +577,16 @@ const delta: IDeltaItems = await graph.users.getById("user@tenant.onmicrosoft.co // Get the changes for the drive items from token const delta: IDeltaItems = await graph.me.drive.root.delta("{token}")(); + +// consume all the values using async iterator +for await (const val of delta.next.paged()) { + console.log(JSON.stringify(val, null, 2)); +} + +// consume all the values using async iterator in pages of 20 +for await (const val of delta.next.top(20).paged()) { + console.log(JSON.stringify(val, null, 2)); +} ``` ## Get Drive Item Analytics diff --git a/packages/graph/behaviors/paged.ts b/packages/graph/behaviors/paged.ts index 2d9c67ff7..32c8a6949 100644 --- a/packages/graph/behaviors/paged.ts +++ b/packages/graph/behaviors/paged.ts @@ -7,7 +7,17 @@ export interface IPagedResult { count: number; value: any[] | null; hasNext: boolean; - next(): Promise; + nextLink: string; +} + +export async function Count(col: IGraphQueryableCollection): Promise { + + const q = GraphQueryableCollection(col).using(Paged(), ConsistencyLevel()); + q.query.set("$count", "true"); + q.top(1); + + const y: IPagedResult = await q(); + return y.count; } /** @@ -16,23 +26,12 @@ export interface IPagedResult { * @param col Collection forming the basis of the paged collection, this param is NOT modified * @returns A duplicate collection which will return paged results */ -export function AsPaged(col: IGraphQueryableCollection, supportsCount = false): IGraphQueryableCollection { +export function AsAsyncIterable(col: IGraphQueryableCollection): AsyncIterable { - const q = GraphQueryableCollection(col).using(Paged(supportsCount), ConsistencyLevel()); + const q = GraphQueryableCollection(col).using(Paged(), ConsistencyLevel()); const queryParams = ["$search", "$top", "$select", "$expand", "$filter", "$orderby"]; - if (supportsCount) { - - // we might be constructing our query with a next url that will already contain $count so we need - // to ensure we don't add it again, likewise if it is already in our query collection we don't add it again - if (!q.query.has("$count") && !/\$count=true/i.test(q.toUrl())) { - q.query.set("$count", "true"); - } - - queryParams.push("$count"); - } - for (let i = 0; i < queryParams.length; i++) { const param = col.query.get(queryParams[i]); if (objectDefinedNotNull(param)) { @@ -40,7 +39,32 @@ export function AsPaged(col: IGraphQueryableCollection, supportsCount = false): } } - return q; + return { + + [Symbol.asyncIterator]() { + return { + + _next: q, + + async next() { + + if (this._next === null) { + return { done: true }; + } + + const result: IPagedResult = await this._next(); + + if (result.hasNext) { + this._next = GraphQueryableCollection([this._next, result.nextLink]); + return { done: false, value: result.value }; + } else { + this._next = null; + return { done: false, value: result.value }; + } + }, + }; + }, + }; } /** @@ -48,7 +72,7 @@ export function AsPaged(col: IGraphQueryableCollection, supportsCount = false): * * @returns A TimelinePipe used to configure the queryable */ -export function Paged(supportsCount = false): TimelinePipe { +export function Paged(): TimelinePipe { return (instance: IGraphQueryable) => { @@ -59,14 +83,14 @@ export function Paged(supportsCount = false): TimelinePipe { const json = txt.replace(/\s/ig, "").length > 0 ? JSON.parse(txt) : {}; const nextLink = json["@odata.nextLink"]; - const count = supportsCount && hOP(json, "@odata.count") ? parseInt(json["@odata.count"], 10) : 0; + const count = hOP(json, "@odata.count") ? parseInt(json["@odata.count"], 10) : -1; const hasNext = !stringIsNullOrEmpty(nextLink); result = { count, hasNext, - next: () => (hasNext ? AsPaged(GraphQueryableCollection([instance, nextLink]), supportsCount)() : null), + nextLink: hasNext ? nextLink : null, value: parseODataJSON(json), }; diff --git a/packages/graph/directory-objects/types.ts b/packages/graph/directory-objects/types.ts index ad83019b7..f8d8fd0b1 100644 --- a/packages/graph/directory-objects/types.ts +++ b/packages/graph/directory-objects/types.ts @@ -3,7 +3,7 @@ import { DirectoryObject as IDirectoryObjectType } from "@microsoft/microsoft-gr import { defaultPath, getById, IGetById, deleteable, IDeleteable } from "../decorators.js"; import { body } from "@pnp/queryable"; import { graphPost } from "../operations.js"; -import { AsPaged, IPagedResult } from "../behaviors/paged.js"; +import { AsAsyncIterable, Count } from "../behaviors/paged.js"; /** * Represents a Directory Object entity @@ -65,18 +65,7 @@ export class _DirectoryObjects extends _GraphQ * If the resource doesn't support count, this value will always be zero */ public async count(): Promise { - const q = AsPaged(this, true); - const r: IPagedResult = await q.top(1)(); - return r.count; - } - - /** - * Allows reading through a collection as pages of information whose size is determined by top or the api method's default - * - * @returns an object containing results, the ability to determine if there are more results, and request the next page of results - */ - public paged(): Promise { - return AsPaged(this, true)(); + return Count(this); } } export interface IDirectoryObjects extends _DirectoryObjects, IGetById { } diff --git a/packages/graph/graphqueryable.ts b/packages/graph/graphqueryable.ts index 3582a7979..77d029776 100644 --- a/packages/graph/graphqueryable.ts +++ b/packages/graph/graphqueryable.ts @@ -1,7 +1,7 @@ import { isArray } from "@pnp/core"; import { IInvokable, Queryable, queryableFactory } from "@pnp/queryable"; import { ConsistencyLevel } from "./behaviors/consistency-level.js"; -import { AsPaged, IPagedResult } from "./behaviors/paged.js"; +import { AsAsyncIterable } from "./behaviors/paged.js"; export type GraphInit = string | IGraphQueryable | [IGraphQueryable, string]; @@ -167,9 +167,8 @@ export class _GraphQueryableCollection extends _GraphQueryable< * If the resource doesn't support count, this value will always be zero */ public async count(): Promise { - const q = AsPaged(this); - const r: IPagedResult = await q.top(1)(); - return r.count; + // TODO::do we want to do this, or just attach count to the collections that support it? we could use a decorator for countable on the few collections that support count. + return -1; } /** @@ -177,8 +176,8 @@ export class _GraphQueryableCollection extends _GraphQueryable< * * @returns an object containing results, the ability to determine if there are more results, and request the next page of results */ - public paged(): Promise { - return AsPaged(this)(); + public paged(): AsyncIterable { + return AsAsyncIterable(this); } } export interface IGraphQueryableCollection extends _GraphQueryableCollection { } diff --git a/packages/graph/onedrive/types.ts b/packages/graph/onedrive/types.ts index 17b83294f..c23814466 100644 --- a/packages/graph/onedrive/types.ts +++ b/packages/graph/onedrive/types.ts @@ -14,7 +14,7 @@ import { defaultPath, getById, IGetById, deleteable, IDeleteable, updateable, IU import { body, BlobParse, CacheNever, errorCheck, InjectHeaders } from "@pnp/queryable"; import { graphPatch, graphPost, graphPut } from "../operations.js"; import { driveItemUpload } from "./funcs.js"; -import { AsPaged } from "../behaviors/paged.js"; +import { AsAsyncIterable } from "../behaviors/paged.js"; /** * Describes a Drive instance @@ -153,12 +153,14 @@ export class _Root extends _GraphQueryableInstance { const query = GraphQueryableCollection(this, path); query.on.parse.replace(errorCheck); query.on.parse(async (url: URL, response: Response, result: any): Promise<[URL, Response, any]> => { + const json = await response.json(); const nextLink = json["@odata.nextLink"]; const deltaLink = json["@odata.deltaLink"]; result = { - next: () => (nextLink ? AsPaged(GraphQueryableCollection([this, nextLink]))() : null), + // TODO:: update docs to show how to load next with async iterator + next: () => (nextLink ? GraphQueryableCollection([this, nextLink]) : null), delta: () => (deltaLink ? GraphQueryableCollection([query, deltaLink])() : null), values: json.value, }; @@ -189,7 +191,7 @@ export class _Root extends _GraphQueryableInstance { * @returns IGraphQueryableCollection */ public analytics(analyticsOptions?: IAnalyticsOptions): IGraphQueryableCollection { - const query = `analytics/${analyticsOptions?analyticsOptions.timeRange:"lastSevenDays"}`; + const query = `analytics/${analyticsOptions ? analyticsOptions.timeRange : "lastSevenDays"}`; return GraphQueryableCollection(this, query); } } @@ -360,7 +362,7 @@ export class _DriveItem extends _GraphQueryableInstance { * @returns IGraphQueryableCollection */ public analytics(analyticsOptions?: IAnalyticsOptions): IGraphQueryableCollection { - const query = `analytics/${analyticsOptions?analyticsOptions.timeRange:"lastSevenDays"}`; + const query = `analytics/${analyticsOptions ? analyticsOptions.timeRange : "lastSevenDays"}`; return GraphQueryableCollection(this, query); } } From 34176e33908a0405042004f4a2651fd9e3f5b005 Mon Sep 17 00:00:00 2001 From: Patrick Rodgers Date: Tue, 27 Jun 2023 20:05:23 -0400 Subject: [PATCH 02/28] linting fix --- packages/graph/directory-objects/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graph/directory-objects/types.ts b/packages/graph/directory-objects/types.ts index f8d8fd0b1..c1e8b6c13 100644 --- a/packages/graph/directory-objects/types.ts +++ b/packages/graph/directory-objects/types.ts @@ -3,7 +3,7 @@ import { DirectoryObject as IDirectoryObjectType } from "@microsoft/microsoft-gr import { defaultPath, getById, IGetById, deleteable, IDeleteable } from "../decorators.js"; import { body } from "@pnp/queryable"; import { graphPost } from "../operations.js"; -import { AsAsyncIterable, Count } from "../behaviors/paged.js"; +import { Count } from "../behaviors/paged.js"; /** * Represents a Directory Object entity From 373a49304c56f1ed0dbead97cbc9204e3e9eaac1 Mon Sep 17 00:00:00 2001 From: Patrick Rodgers Date: Thu, 13 Jul 2023 15:28:20 -0400 Subject: [PATCH 03/28] fixing build issues with typings, reverted changes to graph.ts and main.ts in debug-launch --- debug/launch/graph.ts | 22 +++++++++++----------- debug/launch/main.ts | 4 ++-- packages/graph/behaviors/paged.ts | 19 +++++++++++++------ packages/graph/onedrive/types.ts | 7 +++---- packages/graph/onedrive/users.ts | 8 +------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/debug/launch/graph.ts b/debug/launch/graph.ts index b5d86fd32..f2646a551 100644 --- a/debug/launch/graph.ts +++ b/debug/launch/graph.ts @@ -6,15 +6,15 @@ declare var process: { exit(code?: number): void }; export async function Example(settings: any) { - const graph = graphSetup(settings); + const graph = graphSetup(settings); - for await (const val of graph.users.top(1).paged()) { - console.log(JSON.stringify(val, null, 2)); - } - - const users = await graph.users(); - - const count = await graph.users.count(); - - process.exit(0); -} + const users = await graph.users(); + + Logger.log({ + data: users, + level: LogLevel.Info, + message: "List of Users Data", + }); + + process.exit(0); +} \ No newline at end of file diff --git a/debug/launch/main.ts b/debug/launch/main.ts index 9c9922e07..2a4fdec1e 100644 --- a/debug/launch/main.ts +++ b/debug/launch/main.ts @@ -8,8 +8,8 @@ import { ITestingSettings } from "../../test/load-settings.js"; // add your debugging imports here and prior to submitting a PR git checkout debug/debug.ts // will allow you to keep all your debugging files locally // comment out the example -// import { Example } from "./sp.js"; -import { Example } from "./graph.js"; +import { Example } from "./sp.js"; +// import { Example } from "./graph.js"; // setup the connection to SharePoint using the settings file, you can // override any of the values as you want here, just be sure not to commit diff --git a/packages/graph/behaviors/paged.ts b/packages/graph/behaviors/paged.ts index 32c8a6949..94f6a259b 100644 --- a/packages/graph/behaviors/paged.ts +++ b/packages/graph/behaviors/paged.ts @@ -5,12 +5,19 @@ import { ConsistencyLevel } from "./consistency-level.js"; export interface IPagedResult { count: number; - value: any[] | null; + value: any | any[] | null; hasNext: boolean; nextLink: string; } -export async function Count(col: IGraphQueryableCollection): Promise { +/** + * A function that will take a collection defining IGraphQueryableCollection and return the count of items + * in that collection. Not all Graph collections support Count. + * + * @param col The collection to count + * @returns number representing the count + */ +export async function Count(col: IGraphQueryableCollection): Promise { const q = GraphQueryableCollection(col).using(Paged(), ConsistencyLevel()); q.query.set("$count", "true"); @@ -21,12 +28,12 @@ export async function Count(col: IGraphQueryableCollection): Promise { } /** - * Configures a collection query to returned paged results + * Configures a collection query to returned paged results via async iteration * * @param col Collection forming the basis of the paged collection, this param is NOT modified * @returns A duplicate collection which will return paged results */ -export function AsAsyncIterable(col: IGraphQueryableCollection): AsyncIterable { +export function AsAsyncIterable(col: IGraphQueryableCollection): AsyncIterable { const q = GraphQueryableCollection(col).using(Paged(), ConsistencyLevel()); @@ -42,14 +49,14 @@ export function AsAsyncIterable(col: IGraphQueryableCollection): AsyncIterable { return { [Symbol.asyncIterator]() { - return { + return >{ _next: q, async next() { if (this._next === null) { - return { done: true }; + return { done: true, value: undefined }; } const result: IPagedResult = await this._next(); diff --git a/packages/graph/onedrive/types.ts b/packages/graph/onedrive/types.ts index c23814466..a0db35765 100644 --- a/packages/graph/onedrive/types.ts +++ b/packages/graph/onedrive/types.ts @@ -14,7 +14,6 @@ import { defaultPath, getById, IGetById, deleteable, IDeleteable, updateable, IU import { body, BlobParse, CacheNever, errorCheck, InjectHeaders } from "@pnp/queryable"; import { graphPatch, graphPost, graphPut } from "../operations.js"; import { driveItemUpload } from "./funcs.js"; -import { AsAsyncIterable } from "../behaviors/paged.js"; /** * Describes a Drive instance @@ -150,7 +149,7 @@ export class _Root extends _GraphQueryableInstance { public delta(token?: string): IGraphQueryableCollection { const path = `delta${(token) ? `(token=${token})` : ""}`; - const query = GraphQueryableCollection(this, path); + const query: IGraphQueryableCollection = GraphQueryableCollection(this, path); query.on.parse.replace(errorCheck); query.on.parse(async (url: URL, response: Response, result: any): Promise<[URL, Response, any]> => { @@ -192,7 +191,7 @@ export class _Root extends _GraphQueryableInstance { */ public analytics(analyticsOptions?: IAnalyticsOptions): IGraphQueryableCollection { const query = `analytics/${analyticsOptions ? analyticsOptions.timeRange : "lastSevenDays"}`; - return GraphQueryableCollection(this, query); + return >GraphQueryableCollection(this, query); } } export interface IRoot extends _Root { } @@ -363,7 +362,7 @@ export class _DriveItem extends _GraphQueryableInstance { */ public analytics(analyticsOptions?: IAnalyticsOptions): IGraphQueryableCollection { const query = `analytics/${analyticsOptions ? analyticsOptions.timeRange : "lastSevenDays"}`; - return GraphQueryableCollection(this, query); + return >GraphQueryableCollection(this, query); } } export interface IDriveItem extends _DriveItem, IDeleteable, IUpdateable { } diff --git a/packages/graph/onedrive/users.ts b/packages/graph/onedrive/users.ts index 2d21ba12f..0fbdebdeb 100644 --- a/packages/graph/onedrive/users.ts +++ b/packages/graph/onedrive/users.ts @@ -43,13 +43,7 @@ _Drive.prototype.special = function special(specialFolder: SpecialFolder): IDriv return DriveItem(this, `special/${specialFolder}`); }; -export enum SpecialFolder { - "Documents" = "documents", - "Photos" = "photos", - "CameraRoll" = "cameraroll", - "AppRoot" = "approot", - "Music" = "music", -} +export type SpecialFolder = "documents" | "photos" | "cameraroll" | "approot" | "music"; _DriveItem.prototype.restore = function restore(restoreOptions: IItemOptions): Promise { return graphPost(DriveItem(this, "restore"), body(restoreOptions)); From f9e7ff39cf5bb3e966a610ad16a2f5a4de1ce68a Mon Sep 17 00:00:00 2001 From: Patrick Rodgers Date: Thu, 13 Jul 2023 15:50:18 -0400 Subject: [PATCH 04/28] fixing tests for graph paging --- test/graph/paging.ts | 71 ++++++++++---------------------------------- 1 file changed, 16 insertions(+), 55 deletions(-) diff --git a/test/graph/paging.ts b/test/graph/paging.ts index 69052fa4b..844a56a3c 100644 --- a/test/graph/paging.ts +++ b/test/graph/paging.ts @@ -35,29 +35,14 @@ describe("Groups", function () { } }); - it("pages users 1", async function () { - - let users = await this.pnp.graph.users.top(2).paged(); - - expect(users).to.have.property("hasNext", true); - - users = await users.next(); - - expect(users).to.have.property("hasNext", true); - }); - it("pages all users", async function () { const count = await this.pnp.graph.users.count(); const allUsers = []; - let users = await this.pnp.graph.users.top(20).select("displayName").paged(); - allUsers.push(...users.value); - - while (users.hasNext) { - users = await users.next(); - allUsers.push(...users.value); + for await (const users of this.pnp.graph.users.top(20).select("displayName").paged()) { + allUsers.push(...users); } expect(allUsers.length).to.eq(count); @@ -65,18 +50,17 @@ describe("Groups", function () { it("pages groups", async function () { - let groups = await this.pnp.graph.groups.top(2).paged(); + const count = await this.pnp.graph.groups.count(); + + expect(count).is.gt(0); - expect(groups).to.have.property("hasNext", true); - expect(groups).to.have.property("count").gt(0); - expect(groups.value.length).to.eq(2); + const allGroups = []; - groups = await groups.next(); + for await (const groups of this.pnp.graph.groups.top(20).select("displayName").paged()) { + allGroups.push(...groups); + } - expect(groups).to.have.property("hasNext", true); - // count only returns on the first call, not subsequent paged calls - expect(groups).to.have.property("count").eq(0); - expect(groups.value.length).to.eq(2); + expect(allGroups.length).to.eq(count); }); it("groups count", async function () { @@ -86,38 +70,15 @@ describe("Groups", function () { expect(count).to.be.gt(0); }); - it("pages all groups", async function () { - - const count = await this.pnp.graph.groups.count(); - - const allGroups = []; - let groups = await this.pnp.graph.groups.top(20).select("mailNickname").paged(); - - allGroups.push(...groups.value); - - while (groups.hasNext) { - groups = await groups.next(); - allGroups.push(...groups.value); - } - - expect(allGroups.length).to.be.gt((count - 10)).and.lt((count + 10)); - }); - it("pages items", async function () { - let pagedResults = await itemsCol.top(5).paged(); + const allItems = []; - expect(pagedResults.value.length).to.eq(5); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - expect(pagedResults.hasNext).to.be.true; - expect(pagedResults.count).to.eq(0); - - pagedResults = await pagedResults.next(); + for await (const items of itemsCol.paged()) { + allItems.push(...items); + } - expect(pagedResults.value.length).to.eq(5); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - expect(pagedResults.hasNext).to.be.true; - expect(pagedResults.count).to.eq(0); + expect(allItems.length).to.be.gt(0); }); it("items count", async function () { @@ -125,6 +86,6 @@ describe("Groups", function () { const count = await itemsCol.count(); // items doesn't support count, should be zero - expect(count).to.eq(0); + expect(count).to.eq(-1); }); }); From 8dc8efae4f3a2bee21325e86bbcab7fab75b1f54 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:20:32 +0000 Subject: [PATCH 05/28] Added bug report --- .github/ISSUE_TEMPLATE/bug-report.yml | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 000000000..79b48d408 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,78 @@ +name: 🐞 Bug or Error Report +description: Submit a bug or error report. +labels: ['type: something isn't working', 'status: investigate'] + +body: +- type: markdown + attributes: + value: | + - [x] Bug + + This issue type is for submitting bugs or errors you believe you have found with the PnPjs library. If your submission references permission errors or 5xx status code responses, this is almost certainly not a bug with PnPjs but rather and issue with your configuration, please refer to other support options listed on the [new issue chooser page](https://github.dev/juliemturner/pnpjs/issues/new/choose). Please provide as much information as possible so we can best address your submission. Thanks! + + - Follow our guidance on [How To Create Good Issues](https://github.dev/juliemturner/pnpjs/wiki/How-to-Create-Good-Issues). + - Remember to include sufficient details and context. + - If you have multiple questions, suggestions, or bugs, please submit them in separate issues. + + Please provide the following details about your environment. 🚨 *If this section is ignored, your submission will be flagged as **incomplete** & automatically closed.* + + Please specify what version of PnPjs library you are using +- type: dropdown + attributes: + label: Major Version + options: + - 4.x + - 3.x + - 2.x (No longer supported) + - 1.x (No longer supported) + validations: + required: true +- type: input + id: minorver + attributes: + label: Minor Version Number + description: Include the minor and patch version numbers, e.g. for 4.1.0 + placeholder: 1.0 + validations: + required: true +- type: dropdown + attributes: + label: Target environment + options: + - SharePoint Framework + - NodeJS + - Browser App (Hosted external to Microsoft 365 platform) + - other (enter in the "Additional environment details" area below) + validations: + required: true +- type: textarea + attributes: + label: Expected or Desired Behavior + description: Describe what you are trying to accomplish. + value: | + I'm trying to get items from a list in a site. +- type: textarea + attributes: + label: Observed Behavior + description: Describe the results you're getting. + value: | + I'm getting an empty response +- type: textarea + attributes: + label: Steps to Reproduce + description: Please included code fenced example code, OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured. + value: | + Here is the code I'm running + + ```TypeScript + import { spfi } from "@pnp/sp"; + import "@pnp/sp/webs"; + import "@pnp/sp/lists"; + import "@pnp/sp/items"; + + const sp = spfi(...); + + // get all the items from a list + const items: any[] = await sp.web.lists.getByTitle("My List").items(); + console.log(items); + ``` \ No newline at end of file From fe0f544e5f76017079c0c89925db8de0214e7bf0 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:21:29 +0000 Subject: [PATCH 06/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 79b48d408..fb11cfacc 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,6 +1,6 @@ name: 🐞 Bug or Error Report description: Submit a bug or error report. -labels: ['type: something isn't working', 'status: investigate'] +labels: ["type: something isn't working", "status: investigate"] body: - type: markdown @@ -75,4 +75,4 @@ body: // get all the items from a list const items: any[] = await sp.web.lists.getByTitle("My List").items(); console.log(items); - ``` \ No newline at end of file + ``` From f4e4458016159a66fb83f4229d877325117f8f44 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:24:48 +0000 Subject: [PATCH 07/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index fb11cfacc..69fd1b6cf 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -28,13 +28,13 @@ body: validations: required: true - type: input - id: minorver - attributes: - label: Minor Version Number - description: Include the minor and patch version numbers, e.g. for 4.1.0 - placeholder: 1.0 - validations: - required: true + id: minorver + attributes: + label: Minor Version Number + description: Include the minor and patch version numbers, e.g. for 4.1.0 + placeholder: 1.0 + validations: + required: true - type: dropdown attributes: label: Target environment From c149a935e4127e705a6f15538b606a0f3acdb214 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:27:15 +0000 Subject: [PATCH 08/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 69fd1b6cf..d86af624b 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -25,14 +25,14 @@ body: - 3.x - 2.x (No longer supported) - 1.x (No longer supported) - validations: - required: true + validations: + required: true - type: input id: minorver attributes: label: Minor Version Number description: Include the minor and patch version numbers, e.g. for 4.1.0 - placeholder: 1.0 + placeholder: '1.0' validations: required: true - type: dropdown @@ -43,8 +43,8 @@ body: - NodeJS - Browser App (Hosted external to Microsoft 365 platform) - other (enter in the "Additional environment details" area below) - validations: - required: true + validations: + required: true - type: textarea attributes: label: Expected or Desired Behavior From 7be908008c0b13a62143bcbff8693e8f1da89343 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:31:39 +0000 Subject: [PATCH 09/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index d86af624b..bab85cd9b 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -16,7 +16,7 @@ body: Please provide the following details about your environment. 🚨 *If this section is ignored, your submission will be flagged as **incomplete** & automatically closed.* - Please specify what version of PnPjs library you are using + ##Please specify what version of PnPjs library you are using - type: dropdown attributes: label: Major Version From 9e611e50ce1105d9e7324c8a9790cca320cac4ee Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:31:53 +0000 Subject: [PATCH 10/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index bab85cd9b..e28121dbc 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -16,7 +16,7 @@ body: Please provide the following details about your environment. 🚨 *If this section is ignored, your submission will be flagged as **incomplete** & automatically closed.* - ##Please specify what version of PnPjs library you are using + ## Please specify what version of PnPjs library you are using - type: dropdown attributes: label: Major Version From ae4491a215485bb35b5efdb182da41a994cea4da Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:32:10 +0000 Subject: [PATCH 11/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index e28121dbc..3721fa66f 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -16,7 +16,7 @@ body: Please provide the following details about your environment. 🚨 *If this section is ignored, your submission will be flagged as **incomplete** & automatically closed.* - ## Please specify what version of PnPjs library you are using + ### Please specify what version of PnPjs library you are using - type: dropdown attributes: label: Major Version From b44367005fd455b67c99bf71cde1850eba6a1bb2 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:34:15 +0000 Subject: [PATCH 12/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 3721fa66f..45d5e227c 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -45,6 +45,12 @@ body: - other (enter in the "Additional environment details" area below) validations: required: true +- type: textarea + attributes: + label: Additional environment details + description: Please describe the environment you're working in and how you're authenticating. + value: | + I'm using NodeJS and certificate based MSAL for authentication. - type: textarea attributes: label: Expected or Desired Behavior From 21c5ae470fe8419547c45fd5198b892f833b89f1 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Fri, 14 Jul 2023 19:48:55 +0000 Subject: [PATCH 13/28] added enhancements and questions --- .github/ISSUE_TEMPLATE/enhancement.yml | 52 +++++++++++++++++++ .github/ISSUE_TEMPLATE/question.yml | 69 ++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/enhancement.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml new file mode 100644 index 000000000..696c2dc9b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -0,0 +1,52 @@ +name: 🏗 Enhancement +description: Suggest an enhancement +labels: ["type: enhancement", "status: investigate"] + +body: +- type: markdown + attributes: + value: | + - [x] Enhancement + + This issue type is for suggesting or discussing enhancements to the library. + + - Follow our guidance on [How To Create Good Issues](https://github.dev/juliemturner/pnpjs/wiki/How-to-Create-Good-Issues). + - Remember to include sufficient details and context. + - If you have multiple questions, suggestions, or bugs, please submit them in separate issues. + +- type: dropdown + attributes: + label: Target environment + options: + - All + - SharePoint Framework + - NodeJS + - Browser App (Hosted external to Microsoft 365 platform) + - other (enter in the "Additional environment details" area below) + validations: + required: false +- type: textarea + attributes: + label: Additional environment details + description: Please describe the environment you're working in and how you're authenticating. + value: | + I'm using NodeJS and certificate based MSAL for authentication. +- type: textarea + attributes: + label: Enhancement Idea + description: Please included details to describe your situation, code fenced example code OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured and get you the right help more quickly. + value: | + I'm struggling to get a list item. Here is the code I'm running. Can anyone help me figure out what's wrong? + + ```TypeScript + import { spfi } from "@pnp/sp"; + import "@pnp/sp/webs"; + import "@pnp/sp/lists"; + import "@pnp/sp/items"; + + const sp = spfi(...); + + // get all the items from a list + const items: any[] = await sp.web.lists.getByTitle("My List").items(); + console.log(items); + ``` diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 000000000..6f970cca5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,69 @@ +name: ❓ Question/Assistance Needed +description: Ask a question or seek guidance +labels: ["type: question", "help wanted 🐇"] + +body: +- type: markdown + attributes: + value: | + - [x] Question + + This issue type is for asking questions or requesting assistance in using the library. Please provide as much information as possible so a member of the community can best assist you. Thanks! + + - Follow our guidance on [How To Create Good Issues](https://github.dev/juliemturner/pnpjs/wiki/How-to-Create-Good-Issues). + - Remember to include sufficient details and context. + - If you have multiple questions, suggestions, or bugs, please submit them in separate issues. + +- type: dropdown + attributes: + label: What version of PnPjs library you are using + options: + - 4.x + - 3.x + - 2.x (No longer supported) + - 1.x (No longer supported) + validations: + required: false +- type: input + id: minorver + attributes: + label: Minor Version Number + description: Include the minor and patch version numbers, e.g. for 4.1.0 + placeholder: '1.0' + validations: + required: false +- type: dropdown + attributes: + label: Target environment + options: + - SharePoint Framework + - NodeJS + - Browser App (Hosted external to Microsoft 365 platform) + - other (enter in the "Additional environment details" area below) + validations: + required: true +- type: textarea + attributes: + label: Additional environment details + description: Please describe the environment you're working in and how you're authenticating. + value: | + I'm using NodeJS and certificate based MSAL for authentication. +- type: textarea + attributes: + label: Question/Request + description: Please included details to describe your situation, code fenced example code OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured and get you the right help more quickly. + value: | + I'm struggling to get a list item. Here is the code I'm running. Can anyone help me figure out what's wrong? + + ```TypeScript + import { spfi } from "@pnp/sp"; + import "@pnp/sp/webs"; + import "@pnp/sp/lists"; + import "@pnp/sp/items"; + + const sp = spfi(...); + + // get all the items from a list + const items: any[] = await sp.web.lists.getByTitle("My List").items(); + console.log(items); + ``` From fdd270389540eee9ac8b6178c08d84abd0e703f6 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:46:05 +0000 Subject: [PATCH 14/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 45d5e227c..f17f9e202 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -48,9 +48,7 @@ body: - type: textarea attributes: label: Additional environment details - description: Please describe the environment you're working in and how you're authenticating. - value: | - I'm using NodeJS and certificate based MSAL for authentication. + description: Please describe the environment you're working in and how you're authenticating. (e.g I'm using NodeJS and certificate based MSAL for authentication.) - type: textarea attributes: label: Expected or Desired Behavior From 4d44c8663d10e4644a94d614e7fbacbd772161bc Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:49:44 +0000 Subject: [PATCH 15/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index f17f9e202..a9c56f7e8 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -61,12 +61,11 @@ body: description: Describe the results you're getting. value: | I'm getting an empty response -- type: textarea +- type: markdown attributes: - label: Steps to Reproduce - description: Please included code fenced example code, OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured. value: | - Here is the code I'm running + ## Sample + Here is the code I'm running ```TypeScript import { spfi } from "@pnp/sp"; @@ -80,3 +79,8 @@ body: const items: any[] = await sp.web.lists.getByTitle("My List").items(); console.log(items); ``` +- type: textarea + attributes: + label: Steps to Reproduce + description: Please included code fenced example code, OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured. See the sample above. + From 94c8bd759b2012533d1f4ebd34c3c3fdb2427418 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:51:02 +0000 Subject: [PATCH 16/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index a9c56f7e8..dbf0dbd92 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -61,10 +61,14 @@ body: description: Describe the results you're getting. value: | I'm getting an empty response +- type: textarea + attributes: + label: Steps to Reproduce + description: Please included code fenced example code, OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured. See the sample above. - type: markdown attributes: value: | - ## Sample + ### Steps to Reproduce: Sample Here is the code I'm running ```TypeScript @@ -79,8 +83,4 @@ body: const items: any[] = await sp.web.lists.getByTitle("My List").items(); console.log(items); ``` -- type: textarea - attributes: - label: Steps to Reproduce - description: Please included code fenced example code, OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured. See the sample above. From a25ae4c10abc1d2dc3ef1677612566c9a24854b4 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:51:40 +0000 Subject: [PATCH 17/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index dbf0dbd92..d30ad4401 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -68,7 +68,7 @@ body: - type: markdown attributes: value: | - ### Steps to Reproduce: Sample + **Steps to Reproduce: Sample** Here is the code I'm running ```TypeScript From 3b725f5659fdc0876edc8939132dd1b1783db886 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:53:02 +0000 Subject: [PATCH 18/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index d30ad4401..9afc0f009 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -59,7 +59,7 @@ body: attributes: label: Observed Behavior description: Describe the results you're getting. - value: | + placerholder: | I'm getting an empty response - type: textarea attributes: From f0ed20b9dccc3e627c073f4650205510c511cb1b Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:53:41 +0000 Subject: [PATCH 19/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 9afc0f009..bdae53681 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -59,7 +59,7 @@ body: attributes: label: Observed Behavior description: Describe the results you're getting. - placerholder: | + placeholder: | I'm getting an empty response - type: textarea attributes: From cbf04da86d3c034259f97ed4ccbfc1b17c3d2b00 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:54:24 +0000 Subject: [PATCH 20/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index bdae53681..4d69aff0f 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -61,6 +61,8 @@ body: description: Describe the results you're getting. placeholder: | I'm getting an empty response + validations: + required: true - type: textarea attributes: label: Steps to Reproduce From 84a210f3f9ab9251648a1b63bc54635eb08c133c Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 14:55:29 +0000 Subject: [PATCH 21/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 4d69aff0f..e88a15180 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -67,11 +67,8 @@ body: attributes: label: Steps to Reproduce description: Please included code fenced example code, OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured. See the sample above. -- type: markdown - attributes: - value: | - **Steps to Reproduce: Sample** - Here is the code I'm running + placeholder: | + Here is the code I'm running ```TypeScript import { spfi } from "@pnp/sp"; @@ -84,5 +81,8 @@ body: // get all the items from a list const items: any[] = await sp.web.lists.getByTitle("My List").items(); console.log(items); - ``` + ``` + validations: + required: true + From c4bd51087fb1f19e0ba466f7dc2aca66c28b2ccf Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 15:01:11 +0000 Subject: [PATCH 22/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index e88a15180..3bf95f9fa 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -17,6 +17,16 @@ body: Please provide the following details about your environment. 🚨 *If this section is ignored, your submission will be flagged as **incomplete** & automatically closed.* ### Please specify what version of PnPjs library you are using +- type: checkbox + attributes: + label: Issue Type + options: + - Bug + - Enhancement + - Question + value: Bug + validations: + required: true - type: dropdown attributes: label: Major Version From 98acfe2ef07ea56bc958de4fb07935939c0b58b1 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 15:05:32 +0000 Subject: [PATCH 23/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 3bf95f9fa..4656b067a 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -6,8 +6,6 @@ body: - type: markdown attributes: value: | - - [x] Bug - This issue type is for submitting bugs or errors you believe you have found with the PnPjs library. If your submission references permission errors or 5xx status code responses, this is almost certainly not a bug with PnPjs but rather and issue with your configuration, please refer to other support options listed on the [new issue chooser page](https://github.dev/juliemturner/pnpjs/issues/new/choose). Please provide as much information as possible so we can best address your submission. Thanks! - Follow our guidance on [How To Create Good Issues](https://github.dev/juliemturner/pnpjs/wiki/How-to-Create-Good-Issues). @@ -17,16 +15,6 @@ body: Please provide the following details about your environment. 🚨 *If this section is ignored, your submission will be flagged as **incomplete** & automatically closed.* ### Please specify what version of PnPjs library you are using -- type: checkbox - attributes: - label: Issue Type - options: - - Bug - - Enhancement - - Question - value: Bug - validations: - required: true - type: dropdown attributes: label: Major Version From e1b1e7de83dfdce15dcbd9f4bba66dc03710754f Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 18:26:27 +0000 Subject: [PATCH 24/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 4656b067a..42e937b17 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -11,10 +11,6 @@ body: - Follow our guidance on [How To Create Good Issues](https://github.dev/juliemturner/pnpjs/wiki/How-to-Create-Good-Issues). - Remember to include sufficient details and context. - If you have multiple questions, suggestions, or bugs, please submit them in separate issues. - - Please provide the following details about your environment. 🚨 *If this section is ignored, your submission will be flagged as **incomplete** & automatically closed.* - - ### Please specify what version of PnPjs library you are using - type: dropdown attributes: label: Major Version @@ -46,13 +42,19 @@ body: - type: textarea attributes: label: Additional environment details - description: Please describe the environment you're working in and how you're authenticating. (e.g I'm using NodeJS and certificate based MSAL for authentication.) + description: Please describe the environment you're working in and how you're authenticating. + placeholder: | + I'm using NodeJS and certificate based MSAL for authentication. + validations: + required: true - type: textarea attributes: label: Expected or Desired Behavior description: Describe what you are trying to accomplish. - value: | + placeholder: | I'm trying to get items from a list in a site. + validations: + required: true - type: textarea attributes: label: Observed Behavior From 525ad2c5670548550b08742e441514580c71812e Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 18:35:16 +0000 Subject: [PATCH 25/28] Update enhancement.yml --- .github/ISSUE_TEMPLATE/enhancement.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml index 696c2dc9b..93243c902 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.yml +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -6,14 +6,11 @@ body: - type: markdown attributes: value: | - - [x] Enhancement - This issue type is for suggesting or discussing enhancements to the library. - Follow our guidance on [How To Create Good Issues](https://github.dev/juliemturner/pnpjs/wiki/How-to-Create-Good-Issues). - Remember to include sufficient details and context. - If you have multiple questions, suggestions, or bugs, please submit them in separate issues. - - type: dropdown attributes: label: Target environment @@ -29,13 +26,13 @@ body: attributes: label: Additional environment details description: Please describe the environment you're working in and how you're authenticating. - value: | + placeholder: | I'm using NodeJS and certificate based MSAL for authentication. - type: textarea attributes: label: Enhancement Idea description: Please included details to describe your situation, code fenced example code OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured and get you the right help more quickly. - value: | + placeholder: | I'm struggling to get a list item. Here is the code I'm running. Can anyone help me figure out what's wrong? ```TypeScript From eb905fd43ae494badc8c217034803274d2ad91dd Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 18:35:44 +0000 Subject: [PATCH 26/28] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 42e937b17..4f1a53a93 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -33,6 +33,7 @@ body: attributes: label: Target environment options: + - All - SharePoint Framework - NodeJS - Browser App (Hosted external to Microsoft 365 platform) From a14a26a947955f04afb2e3939761c123da35d6bd Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 18:37:10 +0000 Subject: [PATCH 27/28] Update question.yml --- .github/ISSUE_TEMPLATE/question.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 6f970cca5..58aca6ddb 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -6,14 +6,11 @@ body: - type: markdown attributes: value: | - - [x] Question - This issue type is for asking questions or requesting assistance in using the library. Please provide as much information as possible so a member of the community can best assist you. Thanks! - Follow our guidance on [How To Create Good Issues](https://github.dev/juliemturner/pnpjs/wiki/How-to-Create-Good-Issues). - Remember to include sufficient details and context. - If you have multiple questions, suggestions, or bugs, please submit them in separate issues. - - type: dropdown attributes: label: What version of PnPjs library you are using @@ -23,7 +20,7 @@ body: - 2.x (No longer supported) - 1.x (No longer supported) validations: - required: false + required: true - type: input id: minorver attributes: @@ -31,11 +28,12 @@ body: description: Include the minor and patch version numbers, e.g. for 4.1.0 placeholder: '1.0' validations: - required: false + required: true - type: dropdown attributes: label: Target environment options: + - All - SharePoint Framework - NodeJS - Browser App (Hosted external to Microsoft 365 platform) @@ -46,13 +44,15 @@ body: attributes: label: Additional environment details description: Please describe the environment you're working in and how you're authenticating. - value: | + placeholder: | I'm using NodeJS and certificate based MSAL for authentication. + validations: + required: true - type: textarea attributes: label: Question/Request description: Please included details to describe your situation, code fenced example code OR a link to a code snippet using GitHub or CodePen or the like to show how your code is structured and get you the right help more quickly. - value: | + placeholder: | I'm struggling to get a list item. Here is the code I'm running. Can anyone help me figure out what's wrong? ```TypeScript @@ -66,4 +66,6 @@ body: // get all the items from a list const items: any[] = await sp.web.lists.getByTitle("My List").items(); console.log(items); + validations: + required: true ``` From e6ecaf21c1613d4519dfdd61528690e250154311 Mon Sep 17 00:00:00 2001 From: Julie Turner Date: Mon, 24 Jul 2023 18:38:21 +0000 Subject: [PATCH 28/28] Update question.yml --- .github/ISSUE_TEMPLATE/question.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 58aca6ddb..139c787fc 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -66,6 +66,6 @@ body: // get all the items from a list const items: any[] = await sp.web.lists.getByTitle("My List").items(); console.log(items); + ``` validations: required: true - ```