@pnp/cli-microsoft365 10.10.0-beta.bd186ba → 10.10.0-beta.eb74779

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.devproxy/api-specs/sharepoint-admin.yaml +67 -0
  2. package/.devproxy/api-specs/sharepoint.yaml +230 -0
  3. package/.devproxy/devproxyrc.json +48 -0
  4. package/.devproxy/generate-openapi-spec.json +24 -0
  5. package/.devproxy/spo-csom-types.json +54 -0
  6. package/.eslintrc.cjs +8 -0
  7. package/allCommands.json +1 -1
  8. package/allCommandsFull.json +1 -1
  9. package/dist/cli/cli.js +2 -2
  10. package/dist/m365/app/commands/permission/permission-add.js +8 -1
  11. package/dist/m365/base/SpoCommand.js +1 -0
  12. package/dist/m365/entra/commands/app/app-permission-add.js +5 -18
  13. package/dist/m365/file/commands/file-copy.js +2 -2
  14. package/dist/m365/file/commands/file-move.js +1 -1
  15. package/dist/m365/planner/commands/tenant/tenant-settings-list.js +0 -3
  16. package/dist/m365/spo/commands/contenttype/contenttype-add.js +3 -65
  17. package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +5 -50
  18. package/dist/m365/spo/commands/contenttype/contenttype-field-set.js +4 -48
  19. package/dist/m365/spo/commands/contenttype/contenttype-set.js +8 -58
  20. package/dist/m365/spo/commands/contenttype/contenttype-sync.js +2 -2
  21. package/dist/m365/spo/commands/folder/folder-sharinglink-add.js +1 -1
  22. package/dist/m365/spo/commands/folder/folder-sharinglink-clear.js +1 -1
  23. package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +1 -1
  24. package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +1 -1
  25. package/dist/m365/spo/commands/folder/folder-sharinglink-remove.js +1 -1
  26. package/dist/m365/spo/commands/folder/folder-sharinglink-set.js +1 -1
  27. package/dist/m365/spo/commands/listitem/listitem-batch-set.js +3 -27
  28. package/dist/m365/spo/commands/page/Page.js +16 -1
  29. package/dist/m365/spo/commands/page/page-add.js +1 -1
  30. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -8
  31. package/dist/m365/spo/commands/page/page-control-remove.js +99 -0
  32. package/dist/m365/spo/commands/page/page-control-set.js +1 -1
  33. package/dist/m365/spo/commands/page/page-header-set.js +9 -40
  34. package/dist/m365/spo/commands/page/page-publish.js +2 -10
  35. package/dist/m365/spo/commands/page/page-section-add.js +2 -8
  36. package/dist/m365/spo/commands/page/page-set.js +1 -1
  37. package/dist/m365/spo/commands/site/site-admin-add.js +1 -12
  38. package/dist/m365/spo/commands/site/site-set.js +2 -2
  39. package/dist/m365/spo/commands.js +1 -0
  40. package/dist/utils/entraServicePrincipal.js +21 -0
  41. package/dist/utils/md.js +3 -3
  42. package/dist/utils/spo.js +87 -3
  43. package/docs/docs/cmd/_global.mdx +1 -1
  44. package/docs/docs/cmd/planner/bucket/bucket-add.mdx +19 -0
  45. package/docs/docs/cmd/planner/bucket/bucket-get.mdx +19 -0
  46. package/docs/docs/cmd/planner/bucket/bucket-list.mdx +19 -0
  47. package/docs/docs/cmd/planner/bucket/bucket-remove.mdx +21 -0
  48. package/docs/docs/cmd/planner/bucket/bucket-set.mdx +21 -0
  49. package/docs/docs/cmd/planner/plan/plan-add.mdx +19 -0
  50. package/docs/docs/cmd/planner/plan/plan-get.mdx +19 -0
  51. package/docs/docs/cmd/planner/plan/plan-list.mdx +19 -0
  52. package/docs/docs/cmd/planner/plan/plan-remove.mdx +21 -0
  53. package/docs/docs/cmd/planner/plan/plan-set.mdx +19 -0
  54. package/docs/docs/cmd/planner/roster/roster-add.mdx +19 -0
  55. package/docs/docs/cmd/planner/roster/roster-get.mdx +19 -0
  56. package/docs/docs/cmd/planner/roster/roster-member-add.mdx +19 -0
  57. package/docs/docs/cmd/planner/roster/roster-member-get.mdx +19 -0
  58. package/docs/docs/cmd/planner/roster/roster-member-list.mdx +19 -0
  59. package/docs/docs/cmd/planner/roster/roster-member-remove.mdx +21 -0
  60. package/docs/docs/cmd/planner/roster/roster-plan-list.mdx +19 -0
  61. package/docs/docs/cmd/planner/roster/roster-remove.mdx +21 -0
  62. package/docs/docs/cmd/planner/task/task-add.mdx +19 -0
  63. package/docs/docs/cmd/planner/task/task-checklistitem-add.mdx +19 -0
  64. package/docs/docs/cmd/planner/task/task-checklistitem-list.mdx +19 -0
  65. package/docs/docs/cmd/planner/task/task-checklistitem-remove.mdx +21 -0
  66. package/docs/docs/cmd/planner/task/task-get.mdx +27 -0
  67. package/docs/docs/cmd/planner/task/task-list.mdx +19 -0
  68. package/docs/docs/cmd/planner/task/task-reference-add.mdx +19 -0
  69. package/docs/docs/cmd/planner/task/task-reference-list.mdx +19 -0
  70. package/docs/docs/cmd/planner/task/task-reference-remove.mdx +21 -0
  71. package/docs/docs/cmd/planner/task/task-remove.mdx +21 -0
  72. package/docs/docs/cmd/planner/task/task-set.mdx +19 -0
  73. package/docs/docs/cmd/planner/tenant/tenant-settings-list.mdx +44 -7
  74. package/docs/docs/cmd/planner/tenant/tenant-settings-set.mdx +43 -8
  75. package/docs/docs/cmd/spo/page/page-control-remove.mdx +56 -0
  76. package/npm-shrinkwrap.json +2322 -534
  77. package/package.json +16 -13
@@ -25,7 +25,7 @@ export class Page {
25
25
  }
26
26
  return ClientSidePage.fromHtml(res.ListItemAllFields.CanvasContent1);
27
27
  }
28
- static async checkout(name, webUrl, logger, debug, verbose) {
28
+ static async checkout(name, webUrl, logger, verbose) {
29
29
  if (verbose) {
30
30
  await logger.log(`Checking out ${name} page...`);
31
31
  }
@@ -77,6 +77,21 @@ export class Page {
77
77
  columns: section.columns.map(column => this.getColumnsInformation(column, isJSONOutput))
78
78
  };
79
79
  }
80
+ /**
81
+ * Publish a modern page in SharePoint Online
82
+ * @param webUrl Absolute URL of the SharePoint site where the page is located
83
+ * @param pageName List relative url of the page to publish
84
+ */
85
+ static async publishPage(webUrl, pageName) {
86
+ const filePath = `${urlUtil.getServerRelativeSiteUrl(webUrl)}/SitePages/${pageName}`;
87
+ const requestOptions = {
88
+ url: `${webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(filePath)}')/Publish()`,
89
+ headers: {
90
+ accept: 'application/json;odata=nometadata'
91
+ }
92
+ };
93
+ await request.post(requestOptions);
94
+ }
80
95
  static getPageNameWithExtension(name) {
81
96
  let pageName = name;
82
97
  if (pageName.indexOf('.aspx') < 0) {
@@ -63,7 +63,7 @@ class SpoPageAddCommand extends SpoCommand {
63
63
  itemId = template.UniqueId;
64
64
  const file = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
65
65
  const listItemId = file.Id;
66
- const pageProps = await Page.checkout(pageName, args.options.webUrl, logger, this.debug, this.verbose);
66
+ const pageProps = await Page.checkout(pageName, args.options.webUrl, logger, this.verbose);
67
67
  if (pageProps) {
68
68
  pageId = pageProps.Id;
69
69
  bannerImageUrl = pageProps.BannerImageUrl;
@@ -11,6 +11,7 @@ import { validation } from '../../../../utils/validation.js';
11
11
  import SpoCommand from '../../../base/SpoCommand.js';
12
12
  import commands from '../../commands.js';
13
13
  import { StandardWebPartUtils } from '../../StandardWebPartTypes.js';
14
+ import { Page } from './Page.js';
14
15
  class SpoPageClientSideWebPartAddCommand extends SpoCommand {
15
16
  get name() {
16
17
  return commands.PAGE_CLIENTSIDEWEBPART_ADD;
@@ -52,14 +53,7 @@ class SpoPageClientSideWebPartAddCommand extends SpoCommand {
52
53
  };
53
54
  let page = await request.get(requestOptions);
54
55
  if (!page.IsPageCheckedOutToCurrentUser) {
55
- const requestOptions = {
56
- url: `${args.options.webUrl}/_api/sitepages/pages/GetByUrl('sitepages/${formatting.encodeQueryParameter(pageFullName)}')/checkoutpage`,
57
- headers: {
58
- 'accept': 'application/json;odata=nometadata'
59
- },
60
- responseType: 'json'
61
- };
62
- page = await request.post(requestOptions);
56
+ page = await Page.checkout(pageFullName, args.options.webUrl, logger, this.verbose);
63
57
  }
64
58
  if (page) {
65
59
  layoutWebpartsContent = page.LayoutWebpartsContent;
@@ -0,0 +1,99 @@
1
+ import { globalOptionsZod } from '../../../../Command.js';
2
+ import { z } from 'zod';
3
+ import commands from '../../commands.js';
4
+ import { validation } from '../../../../utils/validation.js';
5
+ import SpoCommand from '../../../base/SpoCommand.js';
6
+ import { zod } from '../../../../utils/zod.js';
7
+ import { cli } from '../../../../cli/cli.js';
8
+ import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
10
+ import { Page } from './Page.js';
11
+ import { urlUtil } from '../../../../utils/urlUtil.js';
12
+ const options = globalOptionsZod
13
+ .extend({
14
+ webUrl: zod.alias('u', z.string())
15
+ .refine(url => validation.isValidSharePointUrl(url) === true, url => ({
16
+ message: `'${url}' is not a valid SharePoint URL.`
17
+ })),
18
+ pageName: zod.alias('n', z.string()),
19
+ id: zod.alias('i', z.string())
20
+ .refine(id => validation.isValidGuid(id), id => ({
21
+ message: `'${id}' is not a valid GUID.`
22
+ })),
23
+ draft: z.boolean().optional(),
24
+ force: zod.alias('f', z.boolean().optional())
25
+ })
26
+ .strict();
27
+ class SpoPageControlRemoveCommand extends SpoCommand {
28
+ get name() {
29
+ return commands.PAGE_CONTROL_REMOVE;
30
+ }
31
+ get description() {
32
+ return 'Removes a control from a modern page';
33
+ }
34
+ get schema() {
35
+ return options;
36
+ }
37
+ async commandAction(logger, args) {
38
+ if (!args.options.force) {
39
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to delete control '${args.options.id}' on page '${args.options.pageName}'?` });
40
+ if (!result) {
41
+ return;
42
+ }
43
+ }
44
+ try {
45
+ if (this.verbose) {
46
+ await logger.logToStderr(`Getting page properties for page '${args.options.pageName}'...`);
47
+ }
48
+ const pageName = urlUtil.removeLeadingSlashes(args.options.pageName.toLowerCase().endsWith('.aspx') ? args.options.pageName : `${args.options.pageName}.aspx`);
49
+ let requestOptions = {
50
+ url: `${args.options.webUrl}/_api/SitePages/Pages/GetByUrl('SitePages/${formatting.encodeQueryParameter(pageName)}')?$select=CanvasContent1`,
51
+ headers: {
52
+ accept: 'application/json;odata=nometadata'
53
+ },
54
+ responseType: 'json'
55
+ };
56
+ const pageProps = await request.get(requestOptions);
57
+ if (!pageProps.CanvasContent1) {
58
+ throw `Page '${pageName}' doesn't contain canvas control '${args.options.id}'.`;
59
+ }
60
+ const pageControls = JSON.parse(pageProps.CanvasContent1);
61
+ const hasControl = pageControls.some(control => control.id?.toLowerCase() === args.options.id.toLowerCase());
62
+ if (!hasControl) {
63
+ throw `Control with ID '${args.options.id}' was not found on page '${pageName}'.`;
64
+ }
65
+ if (this.verbose) {
66
+ await logger.logToStderr('Checking out page...');
67
+ }
68
+ const page = await Page.checkout(pageName, args.options.webUrl, logger, this.verbose);
69
+ const canvasContent = JSON.parse(page.CanvasContent1);
70
+ if (this.verbose) {
71
+ await logger.logToStderr(`Removing control with ID '${args.options.id}' from page...`);
72
+ }
73
+ const pageContent = canvasContent.filter(control => !control.id || control.id.toLowerCase() !== args.options.id.toLowerCase());
74
+ requestOptions = {
75
+ url: `${args.options.webUrl}/_api/SitePages/Pages/GetByUrl('SitePages/${formatting.encodeQueryParameter(pageName)}')/SavePageAsDraft`,
76
+ headers: {
77
+ 'content-type': 'application/json;odata=nometadata',
78
+ accept: 'application/json;odata=nometadata'
79
+ },
80
+ responseType: 'json',
81
+ data: {
82
+ CanvasContent1: JSON.stringify(pageContent)
83
+ }
84
+ };
85
+ await request.patch(requestOptions);
86
+ if (!args.options.draft) {
87
+ if (this.verbose) {
88
+ await logger.logToStderr(`Republishing page...`);
89
+ }
90
+ await Page.publishPage(args.options.webUrl, pageName);
91
+ }
92
+ }
93
+ catch (err) {
94
+ this.handleRejectedODataJsonPromise(err);
95
+ }
96
+ }
97
+ }
98
+ export default new SpoPageControlRemoveCommand();
99
+ //# sourceMappingURL=page-control-remove.js.map
@@ -50,7 +50,7 @@ class SpoPageControlSetCommand extends SpoCommand {
50
50
  await logger.logToStderr(`Control with ID ${args.options.id} found on the page`);
51
51
  }
52
52
  // Check out the page
53
- const page = await Page.checkout(pageName, args.options.webUrl, logger, this.debug, this.verbose);
53
+ const page = await Page.checkout(pageName, args.options.webUrl, logger, this.verbose);
54
54
  // Update the web part data
55
55
  const canvasContent = JSON.parse(page.CanvasContent1);
56
56
  if (this.debug) {
@@ -6,9 +6,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  var _SpoPageHeaderSetCommand_instances, _SpoPageHeaderSetCommand_initTelemetry, _SpoPageHeaderSetCommand_initOptions, _SpoPageHeaderSetCommand_initValidators;
7
7
  import request from '../../../../request.js';
8
8
  import { formatting } from '../../../../utils/formatting.js';
9
+ import { spo } from '../../../../utils/spo.js';
9
10
  import { validation } from '../../../../utils/validation.js';
10
11
  import SpoCommand from '../../../base/SpoCommand.js';
11
12
  import commands from '../../commands.js';
13
+ import { Page } from './Page.js';
12
14
  const BannerWebPartId = 'cbe7b0a9-3504-44dd-a3a3-0e5cacd07788';
13
15
  class SpoPageHeaderSetCommand extends SpoCommand {
14
16
  get name() {
@@ -148,14 +150,7 @@ class SpoPageHeaderSetCommand extends SpoCommand {
148
150
  pageData = await request.get(requestOptions);
149
151
  }
150
152
  else {
151
- const requestOptions = {
152
- url: `${args.options.webUrl}/_api/sitepages/pages/GetByUrl('sitepages/${formatting.encodeQueryParameter(pageFullName)}')/checkoutpage`,
153
- headers: {
154
- 'accept': 'application/json;odata=nometadata'
155
- },
156
- responseType: 'json'
157
- };
158
- pageData = await request.post(requestOptions);
153
+ pageData = await Page.checkout(pageFullName, args.options.webUrl, logger, this.verbose);
159
154
  }
160
155
  switch (args.options.type) {
161
156
  case 'None':
@@ -220,23 +215,23 @@ class SpoPageHeaderSetCommand extends SpoCommand {
220
215
  }
221
216
  else {
222
217
  const res = await Promise.all([
223
- this.getSiteId(args.options.webUrl, this.verbose, logger),
224
- this.getWebId(args.options.webUrl, this.verbose, logger),
218
+ spo.getSiteIdBySPApi(args.options.webUrl, logger, this.verbose),
219
+ spo.getWebId(args.options.webUrl, logger, this.verbose),
225
220
  this.getImageInfo(args.options.webUrl, args.options.imageUrl, this.verbose, logger)
226
221
  ]);
227
222
  header.serverProcessedContent.customMetadata = {
228
223
  imageSource: {
229
- siteId: res[0].Id,
230
- webId: res[1].Id,
224
+ siteId: res[0],
225
+ webId: res[1],
231
226
  listId: res[2].ListId,
232
227
  uniqueId: res[2].UniqueId
233
228
  }
234
229
  };
235
230
  const properties = header.properties;
236
231
  properties.listId = res[2].ListId;
237
- properties.siteId = res[0].Id;
232
+ properties.siteId = res[0];
238
233
  properties.uniqueId = res[2].UniqueId;
239
- properties.webId = res[1].Id;
234
+ properties.webId = res[1];
240
235
  header.properties = properties;
241
236
  }
242
237
  }
@@ -306,32 +301,6 @@ class SpoPageHeaderSetCommand extends SpoCommand {
306
301
  this.handleRejectedODataJsonPromise(err);
307
302
  }
308
303
  }
309
- async getSiteId(siteUrl, verbose, logger) {
310
- if (verbose) {
311
- await logger.logToStderr(`Retrieving information about the site collection...`);
312
- }
313
- const requestOptions = {
314
- url: `${siteUrl}/_api/site?$select=Id`,
315
- headers: {
316
- accept: 'application/json;odata=nometadata'
317
- },
318
- responseType: 'json'
319
- };
320
- return request.get(requestOptions);
321
- }
322
- async getWebId(siteUrl, verbose, logger) {
323
- if (verbose) {
324
- await logger.logToStderr(`Retrieving information about the site...`);
325
- }
326
- const requestOptions = {
327
- url: `${siteUrl}/_api/web?$select=Id`,
328
- headers: {
329
- accept: 'application/json;odata=nometadata'
330
- },
331
- responseType: 'json'
332
- };
333
- return request.get(requestOptions);
334
- }
335
304
  async getImageInfo(siteUrl, imageUrl, verbose, logger) {
336
305
  if (verbose) {
337
306
  await logger.logToStderr(`Retrieving information about the header image...`);
@@ -1,12 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { zod } from '../../../../utils/zod.js';
3
3
  import { globalOptionsZod } from '../../../../Command.js';
4
- import request from '../../../../request.js';
5
- import { formatting } from '../../../../utils/formatting.js';
6
4
  import { urlUtil } from '../../../../utils/urlUtil.js';
7
5
  import { validation } from '../../../../utils/validation.js';
8
6
  import SpoCommand from '../../../base/SpoCommand.js';
9
7
  import commands from '../../commands.js';
8
+ import { Page } from './Page.js';
10
9
  const options = globalOptionsZod
11
10
  .extend({
12
11
  webUrl: zod.alias('u', z.string()
@@ -36,14 +35,7 @@ class SpoPagePublishCommand extends SpoCommand {
36
35
  if (this.verbose) {
37
36
  await logger.logToStderr(`Publishing page ${pageName}...`);
38
37
  }
39
- const filePath = `${urlUtil.getServerRelativeSiteUrl(args.options.webUrl)}/SitePages/${pageName}`;
40
- const requestOptions = {
41
- url: `${args.options.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(filePath)}')/Publish()`,
42
- headers: {
43
- accept: 'application/json;odata=nometadata'
44
- }
45
- };
46
- await request.post(requestOptions);
38
+ await Page.publishPage(args.options.webUrl, pageName);
47
39
  }
48
40
  catch (err) {
49
41
  this.handleRejectedODataJsonPromise(err);
@@ -11,6 +11,7 @@ import { validation } from '../../../../utils/validation.js';
11
11
  import SpoCommand from '../../../base/SpoCommand.js';
12
12
  import commands from '../../commands.js';
13
13
  import { CanvasSectionTemplate } from './clientsidepages.js';
14
+ import { Page } from './Page.js';
14
15
  class SpoPageSectionAddCommand extends SpoCommand {
15
16
  get name() {
16
17
  return commands.PAGE_SECTION_ADD;
@@ -50,14 +51,7 @@ class SpoPageSectionAddCommand extends SpoCommand {
50
51
  const res = await request.get(requestOptions);
51
52
  canvasContent = JSON.parse(res.CanvasContent1 || "[{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]");
52
53
  if (!res.IsPageCheckedOutToCurrentUser) {
53
- requestOptions = {
54
- url: `${args.options.webUrl}/_api/sitepages/pages/GetByUrl('sitepages/${formatting.encodeQueryParameter(pageFullName)}')/checkoutpage`,
55
- headers: {
56
- 'accept': 'application/json;odata=nometadata'
57
- },
58
- responseType: 'json'
59
- };
60
- await request.post(requestOptions);
54
+ await Page.checkout(pageFullName, args.options.webUrl, logger, this.verbose);
61
55
  }
62
56
  // get unique zoneIndex values given each section can have 1 or more
63
57
  // columns each assigned to the zoneIndex of the corresponding section
@@ -52,7 +52,7 @@ class SpoPageSetCommand extends SpoCommand {
52
52
  try {
53
53
  const requestDigestResult = await spo.getRequestDigest(args.options.webUrl);
54
54
  const requestDigest = requestDigestResult.FormDigestValue;
55
- const page = await Page.checkout(args.options.name, args.options.webUrl, logger, this.debug, this.verbose);
55
+ const page = await Page.checkout(args.options.name, args.options.webUrl, logger, this.verbose);
56
56
  if (page) {
57
57
  pageTitle = pageTitle || page.Title;
58
58
  pageId = page.Id;
@@ -125,7 +125,7 @@ class SpoSiteAdminAddCommand extends SpoCommand {
125
125
  const ensuredUserData = await this.ensureUser(args, loginNameToAdd);
126
126
  await this.setSiteAdmin(args.options.siteUrl, loginNameToAdd);
127
127
  if (args.options.primary) {
128
- const siteId = await this.getSiteId(args.options.siteUrl);
128
+ const siteId = await spo.getSiteIdBySPApi(args.options.siteUrl, logger, this.verbose);
129
129
  const previousPrimaryOwner = await this.getSiteOwnerLoginName(args.options.siteUrl);
130
130
  await this.setPrimaryOwnerLoginFromSite(logger, args.options.siteUrl, siteId, ensuredUserData);
131
131
  await this.setSiteAdmin(args.options.siteUrl, previousPrimaryOwner);
@@ -157,17 +157,6 @@ class SpoSiteAdminAddCommand extends SpoCommand {
157
157
  };
158
158
  return request.post(requestOptions);
159
159
  }
160
- async getSiteId(siteUrl) {
161
- const requestOptions = {
162
- url: `${siteUrl}/_api/site?$select=Id`,
163
- headers: {
164
- accept: 'application/json;odata=nometadata'
165
- },
166
- responseType: 'json'
167
- };
168
- const response = await request.get(requestOptions);
169
- return response.Id;
170
- }
171
160
  async getSiteOwnerLoginName(siteUrl) {
172
161
  const requestOptions = {
173
162
  url: `${siteUrl}/_api/site/owner?$select=LoginName`,
@@ -62,7 +62,7 @@ class SpoSiteSetCommand extends SpoCommand {
62
62
  if (this.debug) {
63
63
  await logger.logToStderr(`Setting the site its logo...`);
64
64
  }
65
- const logoUrl = args.options.siteLogoUrl ? urlUtil.getServerRelativePath(args.options.url, args.options.siteLogoUrl) : "";
65
+ const logoUrl = args.options.siteLogoUrl ? urlUtil.getUrlRelativePath(args.options.siteLogoUrl) : "";
66
66
  const requestOptions = {
67
67
  url: `${args.options.url}/_api/siteiconmanager/setsitelogo`,
68
68
  headers: {
@@ -84,7 +84,7 @@ class SpoSiteSetCommand extends SpoCommand {
84
84
  if (this.debug) {
85
85
  await logger.logToStderr(`Setting the site thumbnail...`);
86
86
  }
87
- const thumbnailUrl = args.options.siteThumbnailUrl ? urlUtil.getServerRelativePath(args.options.url, args.options.siteThumbnailUrl) : "";
87
+ const thumbnailUrl = args.options.siteThumbnailUrl ? urlUtil.getUrlRelativePath(args.options.siteThumbnailUrl) : "";
88
88
  const requestOptions = {
89
89
  url: `${args.options.url}/_api/siteiconmanager/setsitelogo`,
90
90
  headers: {
@@ -217,6 +217,7 @@ export default {
217
217
  PAGE_COLUMN_LIST: `${prefix} page column list`,
218
218
  PAGE_CONTROL_GET: `${prefix} page control get`,
219
219
  PAGE_CONTROL_LIST: `${prefix} page control list`,
220
+ PAGE_CONTROL_REMOVE: `${prefix} page control remove`,
220
221
  PAGE_CONTROL_SET: `${prefix} page control set`,
221
222
  PAGE_HEADER_SET: `${prefix} page header set`,
222
223
  PAGE_SECTION_ADD: `${prefix} page section add`,
@@ -1,6 +1,7 @@
1
1
  import { odata } from './odata.js';
2
2
  import { formatting } from './formatting.js';
3
3
  import { cli } from '../cli/cli.js';
4
+ import request from '../request.js';
4
5
  export const entraServicePrincipal = {
5
6
  /**
6
7
  * Get service principal by its appId
@@ -52,6 +53,26 @@ export const entraServicePrincipal = {
52
53
  url += `?$select=${properties}`;
53
54
  }
54
55
  return odata.getAllItems(url);
56
+ },
57
+ /**
58
+ * Create a new service principal for the specified application.
59
+ * @param appId Application ID of the application for which to create a service principal.
60
+ * @returns The created service principal.
61
+ */
62
+ async createServicePrincipal(appId) {
63
+ const url = `https://graph.microsoft.com/v1.0/servicePrincipals`;
64
+ const requestOptions = {
65
+ url: url,
66
+ headers: {
67
+ accept: 'application/json;odata.metadata=none',
68
+ 'content-type': 'application/json;odata=nometadata'
69
+ },
70
+ data: {
71
+ appId
72
+ },
73
+ responseType: 'json'
74
+ };
75
+ return await request.post(requestOptions);
55
76
  }
56
77
  };
57
78
  //# sourceMappingURL=entraServicePrincipal.js.map
package/dist/utils/md.js CHANGED
@@ -13,8 +13,8 @@ function convertHeadings(md) {
13
13
  });
14
14
  }
15
15
  function convertAdmonitions(md) {
16
- const regex = new RegExp(/^:::(\w+)(?:\[([^\]]+)\])?([\s\S]*?):::$/, 'gm');
17
- return md.replace(regex, (_, label, title, content) => label.toLocaleUpperCase() + (title ? EOL + EOL + title : '') + EOL + EOL + content.trim());
16
+ const regex = new RegExp(/^([ \t]*):::(\w+)(?:\[([^\]]+)\])?([\s\S]*?)^\1:::$/, 'gm');
17
+ return md.replace(regex, (_, indent, label, title, content) => indent + label.toLocaleUpperCase() + (title ? EOL + EOL + indent + title : '') + EOL + EOL + indent + content.trim());
18
18
  }
19
19
  function includeContent(md, rootFolder) {
20
20
  const mdxImports = [
@@ -49,7 +49,7 @@ function convertHyperlinks(md) {
49
49
  function convertContentTabs(md) {
50
50
  return md
51
51
  .replace(/<TabItem value="([^"]+)">/gm, '$1')
52
- .replace(/.*<\/?(Tabs|TabItem)>.*\n?/g, '')
52
+ .replace(/.*\n?<\/?(Tabs|TabItem)>.*\n?/g, '')
53
53
  .replace(/```(?:\w+)?\s*([\s\S]*?)\s*```/g, '$1')
54
54
  .trim();
55
55
  }
package/dist/utils/spo.js CHANGED
@@ -1403,13 +1403,13 @@ export const spo = {
1403
1403
  await request.post(requestOptions);
1404
1404
  },
1405
1405
  /**
1406
- * Retrieves the site ID for a given web URL.
1406
+ * Retrieves the site ID for a given web URL by the MS Graph.
1407
1407
  * @param webUrl The web URL for which to retrieve the site ID.
1408
1408
  * @param logger The logger object.
1409
1409
  * @param verbose Set for verbose logging
1410
- * @returns A promise that resolves to the site ID.
1410
+ * @returns The site ID as a string.
1411
1411
  */
1412
- async getSiteId(webUrl, logger, verbose) {
1412
+ async getSiteIdByMSGraph(webUrl, logger, verbose) {
1413
1413
  if (verbose && logger) {
1414
1414
  await logger.logToStderr(`Getting site id for URL: ${webUrl}...`);
1415
1415
  }
@@ -1424,6 +1424,90 @@ export const spo = {
1424
1424
  const site = await request.get(requestOptions);
1425
1425
  return site.id;
1426
1426
  },
1427
+ /**
1428
+ * Retrieves the SharePoint Online site ID for the specified web URL by the SharePoint REST API.
1429
+ * @param webUrl The web URL of the SharePoint Online site to retrieve the site ID for.
1430
+ * @param logger The logger object.
1431
+ * @param verbose Set for verbose logging
1432
+ * @returns The site ID as a string.
1433
+ */
1434
+ async getSiteIdBySPApi(webUrl, logger, verbose) {
1435
+ if (verbose && logger) {
1436
+ await logger.logToStderr(`Getting site id for URL: ${webUrl}...`);
1437
+ }
1438
+ const requestOptions = {
1439
+ url: `${webUrl}/_api/site?$select=Id`,
1440
+ headers: {
1441
+ accept: 'application/json;odata=nometadata'
1442
+ },
1443
+ responseType: 'json'
1444
+ };
1445
+ const siteResponse = await request.get(requestOptions);
1446
+ return siteResponse.Id;
1447
+ },
1448
+ /**
1449
+ * Retrieves the id of a SharePoint web for the specified web URL.
1450
+ * @param webUrl The web URL for which to retrieve the web ID.
1451
+ * @param logger The logger object for logging messages.
1452
+ * @param verbose Set to true for verbose logging.
1453
+ * @returns The web ID as a string.
1454
+ */
1455
+ async getWebId(webUrl, logger, verbose) {
1456
+ if (verbose && logger) {
1457
+ await logger.logToStderr(`Getting web id for URL: ${webUrl}...`);
1458
+ }
1459
+ const requestOptions = {
1460
+ url: `${webUrl}/_api/web?$select=Id`,
1461
+ headers: {
1462
+ accept: 'application/json;odata=nometadata'
1463
+ },
1464
+ responseType: 'json'
1465
+ };
1466
+ const webResponse = await request.get(requestOptions);
1467
+ return webResponse.Id;
1468
+ },
1469
+ /**
1470
+ * Retrieves the ID of a SharePoint list by its title or URL.
1471
+ * @param webUrl The base URL of the SharePoint site.
1472
+ * @param listTitle The title of the list (optional).
1473
+ * @param listUrl The server-relative URL of the list (optional).
1474
+ * @param logger The logger object for logging messages (optional).
1475
+ * @param verbose Set to true for verbose logging (optional).
1476
+ * @returns The list ID as a string.
1477
+ */
1478
+ async getListId(webUrl, listTitle, listUrl, logger, verbose) {
1479
+ if (verbose && logger) {
1480
+ await logger.logToStderr(`Retrieving list id...`);
1481
+ }
1482
+ if (!listTitle && !listUrl) {
1483
+ throw new Error('Either listTitle or listUrl must be provided.');
1484
+ }
1485
+ let listId = '';
1486
+ if (listTitle) {
1487
+ const requestOptions = {
1488
+ url: `${webUrl}/_api/web/lists/getByTitle('${formatting.encodeQueryParameter(listTitle)}')?$select=Id`,
1489
+ headers: {
1490
+ accept: 'application/json;odata=nometadata'
1491
+ },
1492
+ responseType: 'json'
1493
+ };
1494
+ const listResponse = await request.get(requestOptions);
1495
+ listId = listResponse.Id;
1496
+ }
1497
+ else if (listUrl) {
1498
+ const listServerRelativeUrl = urlUtil.getServerRelativePath(webUrl, listUrl);
1499
+ const requestOptions = {
1500
+ url: `${webUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')?$select=Id`,
1501
+ headers: {
1502
+ accept: 'application/json;odata=nometadata'
1503
+ },
1504
+ responseType: 'json'
1505
+ };
1506
+ const listResponse = await request.get(requestOptions);
1507
+ listId = listResponse.Id;
1508
+ }
1509
+ return listId;
1510
+ },
1427
1511
  /**
1428
1512
  * Retrieves the server-relative URL of a folder.
1429
1513
  * @param webUrl Web URL
@@ -1,6 +1,6 @@
1
1
  ```md definition-list
2
2
  `-h, --help [help]`
3
- : Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are `options`, `examples`, `remarks`, `response`, `full`. Default is `options`.
3
+ : Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are `options`, `examples`, `remarks`, `permissions`, `response`, `full`. Default is `options`.
4
4
 
5
5
  `--query [query]`
6
6
  : JMESPath query string. See [http://jmespath.org/](http://jmespath.org/) for more information and examples.
@@ -47,6 +47,25 @@ When using `rosterId`, the command is based on an API that is currently in previ
47
47
 
48
48
  :::
49
49
 
50
+ ## Permissions
51
+
52
+ <Tabs>
53
+ <TabItem value="Delegated">
54
+
55
+ | Resource | Permissions |
56
+ |-----------------|---------------------------------------|
57
+ | Microsoft Graph | Tasks.ReadWrite, GroupMember.Read.All |
58
+
59
+ </TabItem>
60
+ <TabItem value="Application">
61
+
62
+ | Resource | Permissions |
63
+ |-----------------|-------------------------------------------|
64
+ | Microsoft Graph | Tasks.ReadWrite.All, GroupMember.Read.All |
65
+
66
+ </TabItem>
67
+ </Tabs>
68
+
50
69
  ## Examples
51
70
 
52
71
  Adds a Microsoft Planner bucket for a plan based on its ID with an order hint
@@ -47,6 +47,25 @@ When using `rosterId`, the command is based on an API that is currently in previ
47
47
 
48
48
  :::
49
49
 
50
+ ## Permissions
51
+
52
+ <Tabs>
53
+ <TabItem value="Delegated">
54
+
55
+ | Resource | Permissions |
56
+ |-----------------|----------------------------------|
57
+ | Microsoft Graph | Tasks.Read, GroupMember.Read.All |
58
+
59
+ </TabItem>
60
+ <TabItem value="Application">
61
+
62
+ | Resource | Permissions |
63
+ |-----------------|--------------------------------------|
64
+ | Microsoft Graph | Tasks.Read.All, GroupMember.Read.All |
65
+
66
+ </TabItem>
67
+ </Tabs>
68
+
50
69
  ## Examples
51
70
 
52
71
  Gets the specified Microsoft Planner bucket
@@ -41,6 +41,25 @@ When using `rosterId`, the command is based on an API that is currently in previ
41
41
 
42
42
  :::
43
43
 
44
+ ## Permissions
45
+
46
+ <Tabs>
47
+ <TabItem value="Delegated">
48
+
49
+ | Resource | Permissions |
50
+ |-----------------|----------------------------------|
51
+ | Microsoft Graph | Tasks.Read, GroupMember.Read.All |
52
+
53
+ </TabItem>
54
+ <TabItem value="Application">
55
+
56
+ | Resource | Permissions |
57
+ |-----------------|--------------------------------------|
58
+ | Microsoft Graph | Tasks.Read.All, GroupMember.Read.All |
59
+
60
+ </TabItem>
61
+ </Tabs>
62
+
44
63
  ## Examples
45
64
 
46
65
  Lists the Microsoft Planner buckets based on its plan ID