diff --git a/debug/launch/main.ts b/debug/launch/main.ts index 230ee47d3..2a4fdec1e 100644 --- a/debug/launch/main.ts +++ b/debug/launch/main.ts @@ -19,7 +19,7 @@ import { Example } from "./sp.js"; // create a settings file using settings.example.js as a template import(findup("settings.js")).then((settings: { settings: ITestingSettings }) => { - Logger.activeLogLevel = LogLevel.Info; + Logger.activeLogLevel = LogLevel.Info; // // setup console logger Logger.subscribe(ConsoleListener("Debug", { @@ -27,7 +27,7 @@ import(findup("settings.js")).then((settings: { settings: ITestingSettings }) => error: "red", verbose: "lightslategray", warning: "yellow", - })); + })); Example(settings.settings); diff --git a/debug/launch/sp.ts b/debug/launch/sp.ts index dab257330..352e7b5cd 100644 --- a/debug/launch/sp.ts +++ b/debug/launch/sp.ts @@ -3,7 +3,6 @@ import { Logger, LogLevel } from "@pnp/logging"; import { spSetup } from "./setup.js"; import "@pnp/sp/webs"; import "@pnp/sp/lists"; -import "@pnp/sp/items"; declare var process: { exit(code?: number): void }; @@ -11,13 +10,13 @@ export async function Example(settings: ITestingSettings) { const sp = spSetup(settings); - const w = await sp.web(); + const w = await sp.web.lists(); Logger.log({ data: w, level: LogLevel.Info, message: "Web Data", }); - + process.exit(0); } diff --git a/packages/core/util.ts b/packages/core/util.ts index 9bac79d7d..1a0bc2bb2 100644 --- a/packages/core/util.ts +++ b/packages/core/util.ts @@ -34,8 +34,7 @@ export function combine(...paths: (string | null | undefined)[]): string { return paths .filter(path => !stringIsNullOrEmpty(path)) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - .map(path => path!.replace(/^[\\|/]/, "").replace(/[\\|/]$/, "")) + .map(path => path.replace(/^[\\|/]/, "").replace(/[\\|/]$/, "")) .join("/") .replace(/\\/g, "/"); } diff --git a/packages/graph/graphqueryable.ts b/packages/graph/graphqueryable.ts index a05de634a..c53bf3695 100644 --- a/packages/graph/graphqueryable.ts +++ b/packages/graph/graphqueryable.ts @@ -1,4 +1,4 @@ -import { isArray, objectDefinedNotNull } from "@pnp/core"; +import { isArray } from "@pnp/core"; import { IInvokable, Queryable, queryableFactory, op, get, post, patch, del, put } from "@pnp/queryable"; import { ConsistencyLevel } from "./behaviors/consistency-level.js"; import { IPagedResult, Paged } from "./behaviors/paged.js"; @@ -164,13 +164,9 @@ export class _GraphCollection extends _GraphQueryable const q = GraphCollection(this).using(Paged(), ConsistencyLevel()); - const queryParams = ["$search", "$top", "$select", "$expand", "$filter", "$orderby"]; - - for (let i = 0; i < queryParams.length; i++) { - const param = this.query.get(queryParams[i]); - if (objectDefinedNotNull(param)) { - q.query.set(queryParams[i], param); - } + // Issue #3136, some APIs take other query params that need to persist through the paging, so we just include everything + for (const [key, value] of this.query) { + q.query.set(key, value); } return >{ @@ -196,7 +192,6 @@ export class _GraphCollection extends _GraphQueryable }; } } - export interface IGraphCollection extends _GraphCollection { } export const GraphCollection = graphInvokableFactory(_GraphCollection); @@ -205,7 +200,6 @@ export const GraphCollection = graphInvokableFactory(_GraphCol * */ export class _GraphInstance extends _GraphQueryable { } - export interface IGraphInstance extends IInvokable, IGraphQueryable { } export const GraphInstance = graphInvokableFactory(_GraphInstance); diff --git a/packages/graph/pages/types.ts b/packages/graph/pages/types.ts index 02cbc1628..cdbb61fa1 100644 --- a/packages/graph/pages/types.ts +++ b/packages/graph/pages/types.ts @@ -1,8 +1,8 @@ import { combine } from "@pnp/core"; +import { body } from "@pnp/queryable"; import { IDeleteable, IGetById, IUpdateable, defaultPath, deleteable, getById, updateable } from "../decorators.js"; import { graphInvokableFactory, _GraphCollection, _GraphInstance, GraphInit, graphPost } from "../graphqueryable.js"; -import { body } from "@pnp/queryable"; import { ValidWebpart } from "./webpart-types.js"; /** @@ -126,7 +126,6 @@ export class _HorizontalSection extends _GraphInstance { export interface IHorizontalSection extends _HorizontalSection, IUpdateable, IDeleteable { } export const HorizontalSection = graphInvokableFactory(_HorizontalSection); -// @getById(HorizontalSection) @defaultPath("canvasLayout/horizontalSections") export class _HorizontalSections extends _GraphCollection { @@ -139,7 +138,7 @@ export class _HorizontalSections extends _GraphCollection { } +export interface IHorizontalSections extends _HorizontalSections, IGetById { } export const HorizontalSections = graphInvokableFactory(_HorizontalSections); export class _HorizontalSectionColumn extends _GraphInstance { @@ -152,9 +151,14 @@ export interface IHorizontalSectionColumn extends _HorizontalSectionColumn { } export const HorizontalSectionColumn = graphInvokableFactory(_HorizontalSectionColumn); @defaultPath("columns") -@getById(HorizontalSectionColumn) -export class _HorizontalSectionColumns extends _GraphCollection { } -export interface IHorizontalSectionColumns extends _HorizontalSectionColumns, IGetById { } +export class _HorizontalSectionColumns extends _GraphCollection { + + public getById(id: string | number): IHorizontalSectionColumn { + const column = HorizontalSectionColumn(this); + return column.concat(`('${id}')`); + } +} +export interface IHorizontalSectionColumns extends _HorizontalSectionColumns, IGetById { } export const HorizontalSectionColumns = graphInvokableFactory(_HorizontalSectionColumns); @updateable() @@ -189,27 +193,22 @@ export class _Webparts extends _GraphCollection { const base = url.slice(0, url.indexOf(SitePageTypeString) + SitePageTypeString.length); return Webpart([this, base], `webparts/${id}`); } - - /** - * Gets the webpart information by id from the page's collection - * @param id string id of the webpart - * @returns The IWebpart instance - */ - public getByIndex(index: number): IWebpart { - return Webpart(this, `${index}`); - } } export interface IWebparts extends _Webparts, IGetById { } export const Webparts = graphInvokableFactory(_Webparts); - +/** + * Contains info representing a vertical section + */ export interface IVerticalSectionInfo { emphasis: "none" | "netural" | "soft" | "strong" | "unknownFutureValue"; id: string; } - +/** + * Contains info representing a horizontal section + */ export interface IHorizontalSectionInfo { emphasis: "none" | "netural" | "soft" | "strong" | "unknownFutureValue"; id: string; @@ -217,13 +216,18 @@ export interface IHorizontalSectionInfo { columns: IHorizontalSectionColumnInfo[]; } +/** + * Contains info representing a horizontal section column + */ export interface IHorizontalSectionColumnInfo { id: string; width: string; webparts: any[]; } - +/** + * Contains info representing a path user + */ export interface IPageUserInfo { displayName: string; email?: string; diff --git a/packages/queryable/queryable.ts b/packages/queryable/queryable.ts index afe87e4e0..722e652b4 100644 --- a/packages/queryable/queryable.ts +++ b/packages/queryable/queryable.ts @@ -52,6 +52,11 @@ export type QueryParams = { /** Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */ toString(): string; + + /** + * Iterator accessor + */ + [Symbol.iterator](): Iterator<[string, string]>; }; @invokable() diff --git a/tsconfig.json b/tsconfig.json index 74384c7bf..cca0157fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "ES2015", "dom", "ES2017.Object", + "ES2015.Iterable" ], "baseUrl": ".", "rootDir": ".",