@pnp/cli-microsoft365 10.4.0-beta.946980f → 10.4.0-beta.b552c1b

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.
@@ -12,7 +12,7 @@ import url from 'url';
12
12
  import { app } from './utils/app.js';
13
13
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
14
14
  appInsights
15
- .setup('6b908c80-d09f-4cf6-8274-e54349a0149a')
15
+ .setup('InstrumentationKey=6b908c80-d09f-4cf6-8274-e54349a0149a;IngestionEndpoint=https://westeurope-3.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=d42020c6-da32-44f7-bbb7-666f0b3a664d')
16
16
  .setInternalLogging(false, false);
17
17
  // append -dev to the version number when ran locally
18
18
  // to distinguish production and dev version of the CLI
package/dist/config.js CHANGED
@@ -34,7 +34,7 @@ export default {
34
34
  'https://graph.microsoft.com/Place.Read.All',
35
35
  'https://graph.microsoft.com/Policy.Read.All',
36
36
  'https://graph.microsoft.com/RecordsManagement.ReadWrite.All',
37
- 'https://graph.microsoft.com/Reports.ReadWrite.All',
37
+ 'https://graph.microsoft.com/Reports.Read.All',
38
38
  'https://graph.microsoft.com/ReportSettings.ReadWrite.All',
39
39
  'https://graph.microsoft.com/RoleAssignmentSchedule.ReadWrite.Directory',
40
40
  'https://graph.microsoft.com/RoleEligibilitySchedule.Read.Directory',
@@ -271,6 +271,12 @@ export class ClientSidePage {
271
271
  for (let i = 0; i < this.sections.length; i++) {
272
272
  html.push(this.sections[i].toHtml());
273
273
  }
274
+ if (this.pageSettings) {
275
+ html.push(this.pageSettings.toHtml());
276
+ }
277
+ if (this.backgroundSettings) {
278
+ html.push(this.backgroundSettings.toHtml());
279
+ }
274
280
  html.push("</div>");
275
281
  return html.join("");
276
282
  }
@@ -286,17 +292,23 @@ export class ClientSidePage {
286
292
  // gather our controls from the supplied html
287
293
  getBoundedDivMarkup(html, /<div\b[^>]*data-sp-canvascontrol[^>]*?>/i, markup => {
288
294
  // get the control type
289
- const ct = /controlType&quot;&#58;(\d*?),/i.exec(markup);
295
+ const ct = /controlType&quot;&#58;(\d*?)(,|&)/i.exec(markup);
290
296
  // if no control type is present this is a column which we give type 0 to let us process it
291
- const controlType = ct == null || ct.length < 2 ? 0 : parseInt(ct[1], 10);
297
+ const controlType = ct == null || ct.length < 0 ? -1 : parseInt(ct[1], 10);
292
298
  let control = null;
293
299
  switch (controlType) {
294
- case 0:
300
+ case -1:
295
301
  // empty canvas column
296
302
  control = new CanvasColumn(null, 0);
297
303
  control.fromHtml(markup);
298
304
  page.mergeColumnToTree(control);
299
305
  break;
306
+ case 0:
307
+ // page settings
308
+ control = new PageSettings();
309
+ control.fromHtml(markup);
310
+ page.pageSettings = control;
311
+ break;
300
312
  case 3:
301
313
  // client side webpart
302
314
  control = new ClientSideWebpart("");
@@ -309,6 +321,12 @@ export class ClientSidePage {
309
321
  control.fromHtml(markup);
310
322
  page.mergePartToTree(control);
311
323
  break;
324
+ case 14:
325
+ // backgroundSection
326
+ control = new BackgroundSettings();
327
+ control.fromHtml(markup);
328
+ page.backgroundSettings = control;
329
+ break;
312
330
  }
313
331
  });
314
332
  // refresh all the orders within the tree
@@ -364,7 +382,7 @@ export class ClientSidePage {
364
382
  }
365
383
  const sections = this.sections.filter(s => s.order === zoneIndex);
366
384
  if (sections.length < 1) {
367
- section = new CanvasSection(this, zoneIndex);
385
+ section = new CanvasSection(this, zoneIndex, [], control?.controlData?.position.zoneId, control.controlData?.zoneGroupMetadata);
368
386
  this.sections.push(section);
369
387
  }
370
388
  else {
@@ -392,7 +410,7 @@ export class ClientSidePage {
392
410
  let section = null;
393
411
  const sections = this.sections.filter(s => s.order === order);
394
412
  if (sections.length < 1) {
395
- section = new CanvasSection(this, order);
413
+ section = new CanvasSection(this, order, [], column.controlData?.position?.zoneId, column.controlData?.zoneGroupMetadata);
396
414
  this.sections.push(section);
397
415
  }
398
416
  else {
@@ -403,10 +421,12 @@ export class ClientSidePage {
403
421
  }
404
422
  }
405
423
  export class CanvasSection {
406
- constructor(page, order, columns = []) {
424
+ constructor(page, order, columns = [], zoneId, zoneGroupMetadata) {
407
425
  this.page = page;
408
426
  this.order = order;
409
427
  this.columns = columns;
428
+ this.zoneId = zoneId;
429
+ this.zoneGroupMetadata = zoneGroupMetadata;
410
430
  }
411
431
  /**
412
432
  * Default column (this.columns[0]) for this section
@@ -457,6 +477,20 @@ class CanvasControl {
457
477
  this.id = this.controlData.id;
458
478
  }
459
479
  }
480
+ export class PageSettings extends CanvasControl {
481
+ constructor() {
482
+ super(0, "1.0");
483
+ }
484
+ getControlData() {
485
+ return this.controlData;
486
+ }
487
+ toHtml() {
488
+ return `<div data-sp-canvascontrol="" data-sp-canvasdataversion="${this.dataVersion}" data-sp-controldata="${this.jsonData}"></div>`;
489
+ }
490
+ fromHtml(html) {
491
+ super.fromHtml(html);
492
+ }
493
+ }
460
494
  export class CanvasColumn extends CanvasControl {
461
495
  constructor(section, order, factor = 12, controls = [], dataVersion = "1.0") {
462
496
  super(0, dataVersion);
@@ -513,8 +547,10 @@ export class CanvasColumn extends CanvasControl {
513
547
  position: {
514
548
  sectionFactor: this.factor,
515
549
  sectionIndex: this.order,
516
- zoneIndex: this.section ? this.section.order : 0
550
+ zoneIndex: this.section ? this.section.order : 0,
551
+ zoneId: this.section?.zoneId
517
552
  },
553
+ zoneGroupMetadata: this.section?.zoneGroupMetadata,
518
554
  };
519
555
  }
520
556
  /**
@@ -543,6 +579,58 @@ export class ClientSidePart extends CanvasControl {
543
579
  }
544
580
  }
545
581
  }
582
+ export class BackgroundSettings extends ClientSidePart {
583
+ constructor() {
584
+ super(0, "1.0");
585
+ this.propertieJson = {};
586
+ this.serverProcessedContent = null;
587
+ }
588
+ getControlData() {
589
+ return {
590
+ controlType: this.controlType
591
+ };
592
+ }
593
+ toHtml() {
594
+ // will form the value of the data-sp-webpartdata attribute
595
+ const data = {
596
+ dataVersion: this.dataVersion,
597
+ instanceId: this.id,
598
+ properties: this.propertieJson,
599
+ serverProcessedContent: this.serverProcessedContent,
600
+ };
601
+ const html = [];
602
+ html.push(`<div data-sp-canvascontrol="" data-sp-canvasdataversion="${this.dataVersion}" data-sp-controldata="${this.jsonData}">`);
603
+ html.push(`<div data-sp-webpart="" data-sp-webpartdataversion="${this.dataVersion}" data-sp-webpartdata="${ClientSidePage.jsonToEscapedString(data)}">`);
604
+ html.push(`<div data-sp-componentid="">`);
605
+ html.push("</div>");
606
+ html.push(`<div data-sp-htmlproperties="">`);
607
+ for (let imageSource in this.serverProcessedContent?.imageSources) {
608
+ html.push(`<img data-sp-prop-name="${imageSource}" src="${this.serverProcessedContent?.imageSources[imageSource]}" />`);
609
+ }
610
+ html.push("</div>");
611
+ html.push("</div>");
612
+ html.push("</div>");
613
+ return html.join("");
614
+ }
615
+ setProperties(properties) {
616
+ this.propertieJson = extend(this.propertieJson, properties);
617
+ return this;
618
+ }
619
+ fromHtml(html) {
620
+ super.fromHtml(html);
621
+ const webPartData = ClientSidePage.escapedStringToJson(getAttrValueFromString(html, "data-sp-webpartdata"));
622
+ this.setProperties(webPartData.properties);
623
+ if (typeof webPartData.serverProcessedContent !== "undefined") {
624
+ this.serverProcessedContent = webPartData.serverProcessedContent;
625
+ }
626
+ if (typeof webPartData.dynamicDataPaths !== "undefined") {
627
+ this.dynamicDataPaths = webPartData.dynamicDataPaths;
628
+ }
629
+ if (typeof webPartData.dynamicDataValues !== "undefined") {
630
+ this.dynamicDataValues = webPartData.dynamicDataValues;
631
+ }
632
+ }
633
+ }
546
634
  export class ClientSideText extends ClientSidePart {
547
635
  constructor(text = "") {
548
636
  super(4, "1.0");
@@ -570,8 +658,10 @@ export class ClientSideText extends ClientSidePart {
570
658
  controlIndex: this.order,
571
659
  sectionFactor: this.column ? this.column.factor : 0,
572
660
  sectionIndex: this.column ? this.column.order : 0,
573
- zoneIndex: this.column && this.column.section ? this.column.section.order : 0
661
+ zoneIndex: this.column && this.column.section ? this.column.section.order : 0,
662
+ zoneId: this.column?.section?.zoneId
574
663
  },
664
+ zoneGroupMetadata: this.column?.section?.zoneGroupMetadata,
575
665
  };
576
666
  }
577
667
  toHtml(index) {
@@ -684,9 +774,11 @@ export class ClientSideWebpart extends ClientSidePart {
684
774
  controlIndex: this.order,
685
775
  sectionFactor: this.column ? this.column.factor : 0,
686
776
  sectionIndex: this.column ? this.column.order : 0,
687
- zoneIndex: this.column && this.column.section ? this.column.section.order : 0
777
+ zoneIndex: this.column && this.column.section ? this.column.section.order : 0,
778
+ zoneId: this.column?.section?.zoneId
688
779
  },
689
780
  webPartId: this.webPartId,
781
+ zoneGroupMetadata: this.column?.section?.zoneGroupMetadata,
690
782
  };
691
783
  }
692
784
  renderHtmlProperties() {
@@ -132,7 +132,8 @@ class SpoPageClientSideWebPartAddCommand extends SpoCommand {
132
132
  id: webPart.id,
133
133
  position: Object.assign({}, control.position),
134
134
  webPartId: webPart.webPartId,
135
- emphasis: {}
135
+ emphasis: {},
136
+ zoneGroupMetadata: control.zoneGroupMetadata
136
137
  }, webPart);
137
138
  if (!control.controlType) {
138
139
  // it's an empty column so we need to replace it with the web part
@@ -10,7 +10,7 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
10
10
  import { validation } from '../../../../utils/validation.js';
11
11
  import SpoCommand from '../../../base/SpoCommand.js';
12
12
  import commands from '../../commands.js';
13
- import { ClientSideText } from './clientsidepages.js';
13
+ import { CanvasSection, ClientSideText } from './clientsidepages.js';
14
14
  import { Page } from './Page.js';
15
15
  class SpoPageTextAddCommand extends SpoCommand {
16
16
  get name() {
@@ -46,6 +46,12 @@ class SpoPageTextAddCommand extends SpoCommand {
46
46
  const page = await Page.getPage(pageName, args.options.webUrl, logger, this.debug, this.verbose);
47
47
  const section = (args.options.section || 1) - 1;
48
48
  const column = (args.options.column || 1) - 1;
49
+ // Add a new section when page does not contain any sections
50
+ if (page.sections.length < 1) {
51
+ const newSection = new CanvasSection(page, 1);
52
+ newSection.defaultColumn;
53
+ page.sections.push(newSection);
54
+ }
49
55
  // Make sure the section is in range
50
56
  if (section >= page.sections.length) {
51
57
  throw new Error(`Invalid section '${section + 1}'`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "10.4.0-beta.946980f",
3
+ "version": "10.4.0-beta.b552c1b",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",