Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 data removal - TEST #2990

Closed
wants to merge 14 commits into from
2 changes: 1 addition & 1 deletion docs/concepts/batching.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ let newItems: IItem[] = [];

for(let i=0; i<res.length; i++){
//This line will correctly resolve
const newItem = await res[i].item.select("Title")<{Title: string}>();
const newItem = await res[i].select("Title")<{Title: string}>();
newItems.push(newItem);
}
```
2 changes: 1 addition & 1 deletion docs/contributing/debug-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Items", () => {

// execute a request to ensure we have a list
const ler = await sp.web.lists.ensure("ItemTestList", "Used to test item operations");
list = ler.list;
list = sp.web.lists.getById(ler.Id);

// in this case we want to have some items in the list for testing so we add those
// only if the list was just created
Expand Down
2 changes: 1 addition & 1 deletion docs/graph/calendars.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ More information can be found in the official Graph documentation:
- [Calendar Resource Type](https://docs.microsoft.com/en-us/graph/api/resources/calendar?view=graph-rest-1.0)
- [Event Resource Type](https://docs.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0)

## ICalendar, ICalendars, ICalendarGroup, ICalendarGroups, ICalendarPermission, ICalendarPermissions, ICalendarView, IEvent, IEvents, IEventAddResult, IForwardEvent, IGetScheduleRequest
## ICalendar, ICalendars, ICalendarGroup, ICalendarGroups, ICalendarPermission, ICalendarPermissions, ICalendarView, IEvent, IEvents, IForwardEvent, IGetScheduleRequest

[![Invokable Banner](https://img.shields.io/badge/Invokable-informational.svg)](../concepts/invokable.md) [![Selective Imports Banner](https://img.shields.io/badge/Selective%20Imports-informational.svg)](../concepts/selective-imports.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/graph/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ More information can be found in the official Graph documentation:

- [List Item Resource Type](https://docs.microsoft.com/en-us/graph/api/resources/listitem?view=graph-rest-1.0)

## IListItems, IListItem, IListItemAddResult, IDocumentSetVersion, IDocumentSetVersions IDocumentSetVersionAddResult,
## IListItems, IListItem, IDocumentSetVersion, IDocumentSetVersions IDocumentSetVersionAddResult,
[![Selective Imports Banner](https://img.shields.io/badge/Selective%20Imports-informational.svg)](../concepts/selective-imports.md)

### Get list items
Expand Down
2 changes: 1 addition & 1 deletion docs/sp/clientside-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ const far = await sp.web.getFolderByServerRelativePath("/sites/dev/Shared Docume
const page = await sp.web.addClientsidePage("MyPage", "Page Title");

// set the banner image
page.setBannerImage(far.data.ServerRelativeUrl);
page.setBannerImage(far.ServerRelativeUrl);

// publish the page
await page.save();
Expand Down
186 changes: 69 additions & 117 deletions docs/sp/fields.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/sp/folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ import "@pnp/sp/lists";
const sp = spfi(...);

const newFolderResult = await sp.web.rootFolder.folders.getByUrl("Shared Documents").folders.addUsingPath("My New Folder");
const item = await newFolderResult.folder.listItemAllFields();
const item = await sp.web.rootFolder.folders.getByUrl("Shared Documents").folders.getByUrl(newFolderResult.Name).listItemAllFields();

await sp.web.lists.getByTitle("Documents").items.getById(item.ID).update({
ContentTypeId: "0x0120001E76ED75A3E3F3408811F0BF56C4CDDD",
Expand Down
2 changes: 1 addition & 1 deletion docs/sp/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ const newItem = await sp.web.lists.getByTitle("TestList").items.add({
const updateVal = {};
updateVal[fields[0].InternalName] = "-1;#New Term|bb046161-49cc-41bd-a459-5667175920d4;#-1;#New 2|0069972e-67f1-4c5e-99b6-24ac5c90b7c9";
// execute the update call
await newItem.item.update(updateVal);
await sp.web.lists.getByTitle("TestList").items.getById(newItem.Id).update(updateVal);
```

### Update BCS Field
Expand Down
4 changes: 2 additions & 2 deletions docs/sp/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const sp = spfi(...);
const listAddResult = await sp.web.lists.add("My new list");

// we can work with the list created using the IListAddResult.list property:
const r = await listAddResult.list.select("Title")();
const r = await sp.web.lists.getByTitle(listAddResult.list.select("Title")();

// log newly created list title to console
console.log(r.Title);
Expand Down Expand Up @@ -457,7 +457,7 @@ import "@pnp/sp/lists";

const sp = spfi(...);
const fld = await sp.site.rootWeb.fields.addText("MyField");
await sp.web.lists.getByTitle("MyList").fields.createFieldAsXml(fld.data.SchemaXml);
await sp.web.lists.getByTitle("MyList").fields.createFieldAsXml(fld.SchemaXml);
```

### folders
Expand Down
14 changes: 4 additions & 10 deletions docs/sp/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ import "@pnp/sp/navigation";

const result = await nav.add("Node Title", "/sites/dev/pages/mypage.aspx", true);

const nodeDataRaw = result.data;

// request the data from the created node
const nodeData = result.node();
```

### moveAfter
Expand All @@ -113,10 +109,8 @@ import "@pnp/sp/navigation";

const node1result = await nav.add(`Testing - ${getRandomString(4)} (1)`, url, true);
const node2result = await nav.add(`Testing - ${getRandomString(4)} (2)`, url, true);
const node1 = await node1result.node();
const node2 = await node2result.node();

await nav.moveAfter(node1.Id, node2.Id);
await nav.moveAfter(node1result.Id, node2result.Id);
```

### Delete
Expand All @@ -129,14 +123,14 @@ import "@pnp/sp/navigation";
const node1result = await nav.add(`Testing - ${getRandomString(4)}`, url, true);
let nodes = await nav();
// check we added a node
let index = nodes.findIndex(n => n.Id === node1result.data.Id)
let index = nodes.findIndex(n => n.Id === node1result.Id)
// index >= 0

// delete a node
await nav.getById(node1result.data.Id).delete();
await nav.getById(node1result.Id).delete();

nodes = await nav();
index = nodes.findIndex(n => n.Id === node1result.data.Id)
index = nodes.findIndex(n => n.Id === node1result.Id)
// index = -1
```

Expand Down
4 changes: 2 additions & 2 deletions docs/sp/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const sp = spfi(...);

// ensure we have a list
const ler = await sp.web.lists.ensure("SecurityTestingList");
const list: IList = ler.list;
const list: IList = sp.web.lists.getById(ler.Id);

// role assignments (see section below)
await list.roleAssignments();
Expand Down Expand Up @@ -97,7 +97,7 @@ const sp = spfi(...);

// ensure we have a list
const ler = await sp.web.lists.ensure("SecurityTestingList");
const list: IList = ler.list;
const list: IList = sp.web.lists.getById(ler.Id);

// list role assignments
const assignments = await list.roleAssignments();
Expand Down
2 changes: 1 addition & 1 deletion docs/sp/site-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const sp = spfi(...);
const user = await sp.web.ensureUser("userLoginname")
const users = await sp.web.siteUsers;

await users.add(user.data.LoginName);
await users.add(user.LoginName);
```

### Get user by Id, Email, or LoginName
Expand Down
1 change: 0 additions & 1 deletion packages/core/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ function addObserver(target: Record<string, any>, moment: string, observer: Vali
if (!isFunc(observer)) {
throw Error("Observers must be functions.");
}

if (!Reflect.has(target, moment)) {

// if we don't have a registration for this moment, then we just add a new prop
Expand Down
1 change: 0 additions & 1 deletion packages/graph/calendars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export {
ICalendarView,
IEvent,
IEvents,
IEventAddResult,
IForwardEvent,
IGetScheduleRequest,
} from "./types.js";
8 changes: 0 additions & 8 deletions packages/graph/calendars/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,6 @@ export class _CalendarPermissions extends _GraphCollection<ICalendarPermissionTy
export interface ICalendarPermissions extends _CalendarPermissions, IGetById<ICalendarPermission>, IAddable<ICalendarPermissionType, ICalendarPermissionType> { }
export const CalendarPermissions = graphInvokableFactory<ICalendarPermissions>(_CalendarPermissions);

/**
* EventAddResult
*/
export interface IEventAddResult {
data: IEventType;
event: IEvent;
}

export interface IForwardEvent {
Comment?: string;
ToRecipients: Recipient[];
Expand Down
18 changes: 2 additions & 16 deletions packages/graph/columns/addColumns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { IColumn } from "./types.js";
import { graphPost } from "../graphqueryable.js";
import { body } from "@pnp/queryable";
import {
Expand All @@ -10,19 +9,6 @@ import {
*
* @param column a JSON representation of a Column object.
*/
export const addColumn = async function(column: IColumnDefinition): Promise<IColumnAddResult> {
const data = await graphPost(this, body(column));

return {
data,
column: (<any>this).getById(data.id),
};
export const addColumn = async function(column: IColumnDefinition): Promise<IColumnDefinition> {
return graphPost(this, body(column));
};

/**
* IColumnAddResult
*/
export interface IColumnAddResult {
column: IColumn;
data: IColumnDefinition;
}
17 changes: 7 additions & 10 deletions packages/graph/columns/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { addProp, body } from "@pnp/queryable";
import { graphPost } from "../graphqueryable.js";
import { _ContentType } from "../content-types/types.js";
import { Columns, IColumns,IColumn, _Columns } from "./types.js";
import { IColumnAddResult } from "./addColumns.js";
import {
ColumnDefinition as IColumnDefinition,
} from "@microsoft/microsoft-graph-types";

declare module "./types" {
interface _Columns {
addRef(siteColumn: IColumn): Promise<IColumnAddResult>;
addRef(siteColumn: IColumn): Promise<IColumnDefinition>;
}

interface IColumns {
addRef(siteColumn: IColumn): Promise<IColumnAddResult>;
addRef(siteColumn: IColumn): Promise<IColumnDefinition>;
}
}

Expand All @@ -20,14 +22,9 @@ declare module "./types" {
*
* @param siteColumn the site column to add.
*/
_Columns.prototype.addRef = async function(siteColumn: IColumn): Promise<IColumnAddResult> {
_Columns.prototype.addRef = async function(siteColumn: IColumn): Promise<IColumnDefinition> {
const postBody = { "sourceColumn@odata.bind": `https://graph.microsoft.com/v1.0/${siteColumn.toUrl()}`};
const data = await graphPost(this, body(postBody));

return {
data,
column: (<any>this).getById(data.id),
};
return graphPost(this, body(postBody));
};

declare module "../content-types/types" {
Expand Down
4 changes: 0 additions & 4 deletions packages/graph/columns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import "./lists.js";
import "./sites.js";
import "./content-types.js";

export {
IColumnAddResult,
} from "./addColumns.js";

export {
Columns,
IColumns,
Expand Down
6 changes: 3 additions & 3 deletions packages/graph/columns/lists.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addProp } from "@pnp/queryable";
import { _List } from "../lists/types.js";
import { addColumn, IColumnAddResult } from "./addColumns.js";
import { addColumn } from "./addColumns.js";
import { Columns, IColumns, _Columns } from "./types.js";
import {
ColumnDefinition as IColumnDefinition,
Expand All @@ -9,11 +9,11 @@ import {

declare module "./types" {
interface _Columns {
add(column: IColumnDefinition): Promise<IColumnAddResult>;
add(column: IColumnDefinition): Promise<IColumnDefinition>;
}

interface IColumns {
add(column: IColumnDefinition): Promise<IColumnAddResult>;
add(column: IColumnDefinition): Promise<IColumnDefinition>;
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/graph/columns/sites.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addProp } from "@pnp/queryable";
import { addColumn, IColumnAddResult } from "./addColumns.js";
import { addColumn } from "./addColumns.js";
import { Columns, IColumns, _Columns } from "./types.js";
import {
ColumnDefinition as IColumnDefinition,
Expand All @@ -8,11 +8,11 @@ import { _Site } from "../sites/types.js";

declare module "./types" {
interface _Columns {
add(column: IColumnDefinition): Promise<IColumnAddResult>;
add(column: IColumnDefinition): Promise<IColumnDefinition>;
}

interface IColumns {
add(column: IColumnDefinition): Promise<IColumnAddResult>;
add(column: IColumnDefinition): Promise<IColumnDefinition>;
}
}

Expand Down
2 changes: 0 additions & 2 deletions packages/graph/contacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import "./users.js";

export {
Contact,
IContactAddResult,
ContactFolder,
IContactFolderAddResult,
ContactFolders,
Contacts,
IContact,
Expand Down
34 changes: 4 additions & 30 deletions packages/graph/contacts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class _Contacts extends _GraphCollection<IContactType[]> {
surName: string,
emailAddresses: IEmailAddressType[],
businessPhones: string[],
additionalProperties: Record<string, any> = {}): Promise<IContactAddResult> {
additionalProperties: Record<string, any> = {}): Promise<IContactType> {

const postBody = {
businessPhones,
Expand All @@ -43,12 +43,7 @@ export class _Contacts extends _GraphCollection<IContactType[]> {
...additionalProperties,
};

const data = await graphPost(this, body(postBody));

return {
contact: (<any>this).getById(data.id),
data,
};
return graphPost(this, body(postBody));
}
}
export interface IContacts extends _Contacts, IGetById<IContact> { }
Expand Down Expand Up @@ -90,36 +85,15 @@ export class _ContactFolders extends _GraphCollection<IContactFolderType[]> {
* @param displayName The folder's display name.
* @param parentFolderId The ID of the folder's parent folder.
*/
public async add(displayName: string, parentFolderId?: string): Promise<IContactFolderAddResult> {
public async add(displayName: string, parentFolderId?: string): Promise<IContactFolderType> {

const postBody = {
displayName: displayName,
parentFolderId: parentFolderId,
};

const data = await graphPost(this, body(postBody));

return {
contactFolder: (<any>this).getById(data.id),
data,
};
return graphPost(this, body(postBody));
}
}
export interface IContactFolders extends _ContactFolders, IGetById<IContactFolder> { }
export const ContactFolders = graphInvokableFactory<IContactFolders>(_ContactFolders);

/**
* IContactFolderAddResult
*/
export interface IContactFolderAddResult {
data: IContactFolderType;
contactFolder: IContactFolder;
}

/**
* IContactAddResult
*/
export interface IContactAddResult {
data: IContactType;
contact: IContact;
}
1 change: 0 additions & 1 deletion packages/graph/groups/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export {
GroupType,
Groups,
IGroup,
IGroupAddResult,
IGroups,
} from "./types.js";

Expand Down
Loading