@pnp/cli-microsoft365 12.1.0-beta.0c2915d → 12.1.0-beta.ab87e08

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 (31) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/m365/spo/commands/page/page-add.js +31 -68
  4. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +74 -101
  5. package/dist/m365/spo/commands/page/page-column-get.js +15 -32
  6. package/dist/m365/spo/commands/page/page-column-list.js +14 -27
  7. package/dist/m365/spo/commands/page/page-control-get.js +18 -27
  8. package/dist/m365/spo/commands/page/page-control-list.js +13 -20
  9. package/dist/m365/spo/commands/page/page-control-remove.js +1 -1
  10. package/dist/m365/spo/commands/page/page-control-set.js +51 -61
  11. package/dist/m365/spo/commands/page/page-copy.js +15 -31
  12. package/dist/m365/spo/commands/page/page-header-set.js +25 -89
  13. package/dist/m365/spo/commands/page/page-list.js +12 -18
  14. package/dist/m365/spo/commands/page/page-remove.js +16 -39
  15. package/dist/m365/spo/commands/page/page-section-add.js +108 -173
  16. package/dist/m365/spo/commands/page/page-section-get.js +17 -27
  17. package/dist/m365/spo/commands/page/page-section-list.js +13 -20
  18. package/dist/m365/spo/commands/page/page-section-remove.js +4 -1
  19. package/dist/m365/spo/commands/page/page-set.js +50 -100
  20. package/dist/m365/spo/commands/page/page-template-list.js +12 -18
  21. package/dist/m365/spo/commands/page/page-text-add.js +23 -45
  22. package/docs/docs/cmd/spo/listitem/listitem-record-declare.mdx +19 -0
  23. package/docs/docs/cmd/spo/listitem/listitem-record-lock.mdx +21 -0
  24. package/docs/docs/cmd/spo/listitem/listitem-record-undeclare.mdx +21 -0
  25. package/docs/docs/cmd/spo/listitem/listitem-record-unlock.mdx +21 -0
  26. package/docs/docs/cmd/spo/page/page-text-add.mdx +1 -1
  27. package/docs/docs/cmd/viva/engage/engage-community-add.mdx +19 -0
  28. package/docs/docs/cmd/viva/engage/engage-community-get.mdx +19 -0
  29. package/docs/docs/cmd/viva/engage/engage-community-remove.mdx +21 -0
  30. package/docs/docs/cmd/viva/engage/engage-community-set.mdx +19 -0
  31. package/package.json +1 -1
@@ -1,17 +1,69 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _SpoPageSectionAddCommand_instances, _SpoPageSectionAddCommand_initTelemetry, _SpoPageSectionAddCommand_initOptions, _SpoPageSectionAddCommand_initValidators, _SpoPageSectionAddCommand_initTypes;
7
1
  import { v4 } from 'uuid';
2
+ import { z } from 'zod';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import request from '../../../../request.js';
9
5
  import { formatting } from '../../../../utils/formatting.js';
10
6
  import { validation } from '../../../../utils/validation.js';
11
7
  import SpoCommand from '../../../base/SpoCommand.js';
12
8
  import commands from '../../commands.js';
13
- import { CanvasSectionTemplate } from './clientsidepages.js';
14
9
  import { Page } from './Page.js';
10
+ const sectionTemplates = ['OneColumn', 'OneColumnFullWidth', 'TwoColumn', 'ThreeColumn', 'TwoColumnLeft', 'TwoColumnRight', 'Vertical', 'Flexible'];
11
+ const zoneEmphasisValues = ['None', 'Neutral', 'Soft', 'Strong', 'Image', 'Gradient'];
12
+ const iconAlignmentValues = ['Left', 'Right'];
13
+ const fillModeValues = ['ScaleToFill', 'ScaleToFit', 'Tile', 'OriginalSize'];
14
+ const zoneReflowStrategyValues = ['TopToBottom', 'LeftToRight'];
15
+ const MINIMUM_ZONE_HEIGHT = 34;
16
+ export const options = z.strictObject({
17
+ ...globalOptionsZod.shape,
18
+ pageName: z.string().alias('n'),
19
+ webUrl: z.string()
20
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
21
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
22
+ })
23
+ .alias('u'),
24
+ sectionTemplate: z.string().pipe(z.enum(sectionTemplates)).alias('t'),
25
+ order: z.number().int().min(1, { error: 'The value of parameter order must be 1 or higher' }).optional(),
26
+ zoneEmphasis: z.string().pipe(z.preprocess(val => {
27
+ const target = String(val).toLowerCase();
28
+ return zoneEmphasisValues.find(v => v.toLowerCase() === target) ?? val;
29
+ }, z.enum(zoneEmphasisValues))).optional().autocomplete([...zoneEmphasisValues]),
30
+ isLayoutReflowOnTop: z.boolean().optional(),
31
+ isCollapsibleSection: z.boolean().optional(),
32
+ showDivider: z.boolean().optional(),
33
+ iconAlignment: z.string().pipe(z.preprocess(val => {
34
+ const target = String(val).toLowerCase();
35
+ return iconAlignmentValues.find(v => v.toLowerCase() === target) ?? val;
36
+ }, z.enum(iconAlignmentValues))).optional().autocomplete([...iconAlignmentValues]),
37
+ isExpanded: z.boolean().optional(),
38
+ gradientText: z.string().optional(),
39
+ imageUrl: z.string().optional(),
40
+ imageHeight: z.number()
41
+ .int()
42
+ .min(1, { error: 'The value of parameter imageHeight must be 1 or higher' })
43
+ .optional(),
44
+ imageWidth: z.number()
45
+ .int()
46
+ .min(1, { error: 'The value of parameter imageWidth must be 1 or higher' })
47
+ .optional(),
48
+ fillMode: z.string().pipe(z.preprocess(val => {
49
+ const target = String(val).toLowerCase();
50
+ return fillModeValues.find(v => v.toLowerCase() === target) ?? val;
51
+ }, z.enum(fillModeValues))).optional().autocomplete([...fillModeValues]),
52
+ useLightText: z.boolean().optional(),
53
+ overlayColor: z.string().optional(),
54
+ overlayOpacity: z.number().optional(),
55
+ collapsibleTitle: z.string().optional(),
56
+ zoneReflowStrategy: z.string().pipe(z.preprocess(val => {
57
+ const target = String(val).toLowerCase();
58
+ return zoneReflowStrategyValues.find(v => v.toLowerCase() === target) ?? val;
59
+ }, z.enum(zoneReflowStrategyValues))).optional().autocomplete([...zoneReflowStrategyValues]),
60
+ zoneHeight: z.number().int().min(MINIMUM_ZONE_HEIGHT, { error: `The value of parameter zoneHeight must be ${MINIMUM_ZONE_HEIGHT} or higher` }).optional(),
61
+ headingLevel: z.number()
62
+ .refine(level => [2, 3, 4].includes(level), {
63
+ error: 'The value of parameter headingLevel must be 2, 3 or 4'
64
+ })
65
+ .optional()
66
+ });
15
67
  class SpoPageSectionAddCommand extends SpoCommand {
16
68
  get name() {
17
69
  return commands.PAGE_SECTION_ADD;
@@ -19,19 +71,53 @@ class SpoPageSectionAddCommand extends SpoCommand {
19
71
  get description() {
20
72
  return 'Adds section to modern page';
21
73
  }
22
- constructor() {
23
- super();
24
- _SpoPageSectionAddCommand_instances.add(this);
25
- this.sectionTemplate = ['OneColumn', 'OneColumnFullWidth', 'TwoColumn', 'ThreeColumn', 'TwoColumnLeft', 'TwoColumnRight', 'Vertical', 'Flexible'];
26
- this.zoneEmphasis = ['None', 'Neutral', 'Soft', 'Strong', 'Image', 'Gradient'];
27
- this.iconAlignment = ['Left', 'Right'];
28
- this.fillMode = ['ScaleToFill', 'ScaleToFit', 'Tile', 'OriginalSize'];
29
- this.zoneReflowStrategy = ['TopToBottom', 'LeftToRight'];
30
- this.MINIMUM_ZONE_HEIGHT = 34;
31
- __classPrivateFieldGet(this, _SpoPageSectionAddCommand_instances, "m", _SpoPageSectionAddCommand_initTelemetry).call(this);
32
- __classPrivateFieldGet(this, _SpoPageSectionAddCommand_instances, "m", _SpoPageSectionAddCommand_initOptions).call(this);
33
- __classPrivateFieldGet(this, _SpoPageSectionAddCommand_instances, "m", _SpoPageSectionAddCommand_initValidators).call(this);
34
- __classPrivateFieldGet(this, _SpoPageSectionAddCommand_instances, "m", _SpoPageSectionAddCommand_initTypes).call(this);
74
+ get schema() {
75
+ return options;
76
+ }
77
+ getRefinedSchema(schema) {
78
+ return schema
79
+ .refine(opts => opts.isLayoutReflowOnTop === undefined || opts.sectionTemplate === 'Vertical', {
80
+ error: 'Specify isLayoutReflowOnTop when the sectionTemplate is set to Vertical.'
81
+ })
82
+ .refine(opts => opts.zoneEmphasis === 'Image' ||
83
+ (opts.imageUrl === undefined &&
84
+ opts.imageWidth === undefined &&
85
+ opts.imageHeight === undefined &&
86
+ opts.fillMode === undefined), {
87
+ error: 'Specify imageUrl, imageWidth, imageHeight or fillMode only when zoneEmphasis is set to Image'
88
+ })
89
+ .refine(opts => opts.zoneEmphasis !== 'Image' || !!opts.imageUrl, {
90
+ error: 'Specify imageUrl when zoneEmphasis is set to Image',
91
+ path: ['imageUrl'],
92
+ params: {
93
+ customCode: 'required'
94
+ }
95
+ })
96
+ .refine(opts => opts.zoneEmphasis === 'Gradient' || !opts.gradientText, {
97
+ error: 'Specify gradientText only when zoneEmphasis is set to Gradient'
98
+ })
99
+ .refine(opts => opts.zoneEmphasis !== 'Gradient' || !!opts.gradientText, {
100
+ error: 'Specify gradientText when zoneEmphasis is set to Gradient',
101
+ path: ['gradientText'],
102
+ params: {
103
+ customCode: 'required'
104
+ }
105
+ })
106
+ .refine(opts => opts.overlayOpacity === undefined || (opts.overlayOpacity >= 0 && opts.overlayOpacity <= 100), {
107
+ error: 'The value of parameter overlayOpacity must be between 0 and 100'
108
+ })
109
+ .refine(opts => !opts.overlayColor || /^#[0-9a-f]{6}$/i.test(opts.overlayColor), {
110
+ error: 'The value of parameter overlayColor must be a valid hex color'
111
+ })
112
+ .refine(opts => ['Image', 'Gradient'].includes(opts.zoneEmphasis ?? '') ||
113
+ (opts.overlayColor === undefined &&
114
+ opts.overlayOpacity === undefined &&
115
+ !opts.useLightText), {
116
+ error: 'Specify overlayColor, overlayOpacity or useLightText only when zoneEmphasis is set to Image or Gradient'
117
+ })
118
+ .refine(opts => opts.sectionTemplate === 'Flexible' || !(opts.zoneReflowStrategy || opts.zoneHeight), {
119
+ error: 'Specify zoneReflowStrategy or zoneHeight only when sectionTemplate is set to Flexible'
120
+ });
35
121
  }
36
122
  async commandAction(logger, args) {
37
123
  let pageFullName = args.options.pageName.toLowerCase();
@@ -199,7 +285,7 @@ class SpoPageSectionAddCommand extends SpoCommand {
199
285
  }
200
286
  getFlexibleColumn(zoneIndex, sectionIndex, args, zoneId) {
201
287
  const columnValue = this.getColumn(zoneIndex, sectionIndex, 100, args, zoneId);
202
- columnValue.zoneReflowStrategy = { axis: args.options.zoneReflowStrategy ? this.zoneReflowStrategy.indexOf(args.options.zoneReflowStrategy) : 0 };
288
+ columnValue.zoneReflowStrategy = { axis: args.options.zoneReflowStrategy ? zoneReflowStrategyValues.indexOf(args.options.zoneReflowStrategy) : 0 };
203
289
  if (args.options.zoneHeight) {
204
290
  columnValue.zoneHeight = args.options.zoneHeight;
205
291
  }
@@ -253,7 +339,7 @@ class SpoPageSectionAddCommand extends SpoCommand {
253
339
  height: imageHeight ? imageHeight : 955,
254
340
  width: imageWidth ? imageWidth : 555
255
341
  };
256
- backgroundDetails.fillMode = fillMode ? this.fillMode.indexOf(fillMode) : 0;
342
+ backgroundDetails.fillMode = fillMode ? fillModeValues.indexOf(fillMode) : 0;
257
343
  }
258
344
  return backgroundDetails;
259
345
  }
@@ -270,156 +356,5 @@ class SpoPageSectionAddCommand extends SpoCommand {
270
356
  }
271
357
  }
272
358
  }
273
- _SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_initTelemetry = function _SpoPageSectionAddCommand_initTelemetry() {
274
- this.telemetry.push((args) => {
275
- Object.assign(this.telemetryProperties, {
276
- order: typeof args.options.order !== 'undefined',
277
- zoneEmphasis: typeof args.options.zoneEmphasis !== 'undefined',
278
- isLayoutReflowOnTop: !!args.options.isLayoutReflowOnTop,
279
- isCollapsibleSection: !!args.options.isCollapsibleSection,
280
- showDivider: !!typeof args.options.showDivider,
281
- iconAlignment: typeof args.options.iconAlignment !== 'undefined',
282
- isExpanded: !!args.options.isExpanded,
283
- gradientText: typeof args.options.gradientText !== 'undefined',
284
- imageUrl: typeof args.options.imageUrl !== 'undefined',
285
- imageHeight: typeof args.options.imageHeight !== 'undefined',
286
- imageWidth: typeof args.options.imageWidth !== 'undefined',
287
- fillMode: typeof args.options.fillMode !== 'undefined',
288
- useLightText: !!args.options.useLightText,
289
- overlayColor: typeof args.options.overlayColor !== 'undefined',
290
- overlayOpacity: typeof args.options.overlayOpacity !== 'undefined',
291
- collapsibleTitle: typeof args.options.collapsibleTitle !== 'undefined',
292
- zoneReflowStrategy: typeof args.options.zoneReflowStrategy !== 'undefined',
293
- zoneHeight: typeof args.options.zoneHeight !== 'undefined',
294
- headingLevel: typeof args.options.headingLevel !== 'undefined'
295
- });
296
- });
297
- }, _SpoPageSectionAddCommand_initOptions = function _SpoPageSectionAddCommand_initOptions() {
298
- this.options.unshift({
299
- option: '-n, --pageName <pageName>'
300
- }, {
301
- option: '-u, --webUrl <webUrl>'
302
- }, {
303
- option: '-t, --sectionTemplate <sectionTemplate>',
304
- autocomplete: this.sectionTemplate
305
- }, {
306
- option: '--order [order]'
307
- }, {
308
- option: '--zoneEmphasis [zoneEmphasis]',
309
- autocomplete: this.zoneEmphasis
310
- }, {
311
- option: '--isLayoutReflowOnTop'
312
- }, {
313
- option: '--isCollapsibleSection'
314
- }, {
315
- option: '--showDivider'
316
- }, {
317
- option: '--iconAlignment [iconAlignment]',
318
- autocomplete: this.iconAlignment
319
- }, {
320
- option: '--isExpanded'
321
- }, {
322
- option: '--gradientText [gradientText]'
323
- }, {
324
- option: '--imageUrl [imageUrl]'
325
- }, {
326
- option: '--imageHeight [imageHeight]'
327
- }, {
328
- option: '--imageWidth [imageWidth]'
329
- }, {
330
- option: '--fillMode [fillMode]',
331
- autocomplete: this.fillMode
332
- }, {
333
- option: '--useLightText'
334
- }, {
335
- option: '--overlayColor [overlayColor]'
336
- }, {
337
- option: '--overlayOpacity [overlayOpacity]'
338
- }, {
339
- option: '--collapsibleTitle [collapsibleTitle]'
340
- }, {
341
- option: '--zoneReflowStrategy [zoneReflowStrategy]',
342
- autocomplete: this.zoneReflowStrategy
343
- }, {
344
- option: '--zoneHeight [zoneHeight]'
345
- }, {
346
- option: '--headingLevel [headingLevel]'
347
- });
348
- }, _SpoPageSectionAddCommand_initValidators = function _SpoPageSectionAddCommand_initValidators() {
349
- this.validators.push(async (args) => {
350
- if (!(args.options.sectionTemplate in CanvasSectionTemplate)) {
351
- return `${args.options.sectionTemplate} is not a valid section template. Allowed values are OneColumn|OneColumnFullWidth|TwoColumn|ThreeColumn|TwoColumnLeft|TwoColumnRight|Vertical|Flexible`;
352
- }
353
- if (typeof args.options.order !== 'undefined') {
354
- if (!Number.isInteger(args.options.order) || args.options.order < 1) {
355
- return 'The value of parameter order must be 1 or higher';
356
- }
357
- }
358
- if (typeof args.options.zoneEmphasis !== 'undefined') {
359
- if (!this.zoneEmphasis.some(zoneEmphasisValue => zoneEmphasisValue.toLowerCase() === args.options.zoneEmphasis?.toLowerCase())) {
360
- return `The value of parameter zoneEmphasis must be ${this.zoneEmphasis.join(', ')}`;
361
- }
362
- }
363
- if (typeof args.options.isLayoutReflowOnTop !== 'undefined') {
364
- if (args.options.sectionTemplate !== 'Vertical') {
365
- return 'Specify isLayoutReflowOnTop when the sectionTemplate is set to Vertical.';
366
- }
367
- }
368
- if (typeof args.options.iconAlignment !== 'undefined') {
369
- if (!this.iconAlignment.some(iconAlignmentValue => iconAlignmentValue.toLowerCase() === args.options.iconAlignment?.toLowerCase())) {
370
- return `The value of parameter iconAlignment must be ${this.iconAlignment.join(', ')}`;
371
- }
372
- }
373
- if (typeof args.options.fillMode !== 'undefined') {
374
- if (!this.fillMode.some(fillModeValue => fillModeValue.toLowerCase() === args.options.fillMode?.toLowerCase())) {
375
- return `The value of parameter fillMode must be ${this.fillMode.join(', ')}`;
376
- }
377
- }
378
- if (typeof args.options.zoneReflowStrategy !== 'undefined') {
379
- if (!this.zoneReflowStrategy.some(zoneReflowStrategyValue => zoneReflowStrategyValue.toLowerCase() === args.options.zoneReflowStrategy?.toLowerCase())) {
380
- return `The value of parameter zoneReflowStrategy must be ${this.zoneReflowStrategy.join(', ')}`;
381
- }
382
- }
383
- if (typeof args.options.headingLevel !== 'undefined') {
384
- if (![2, 3, 4].some(headingLevelValue => headingLevelValue === args.options.headingLevel)) {
385
- return `The value of parameter headingLevel must be 2, 3 or 4`;
386
- }
387
- }
388
- if (args.options.zoneEmphasis?.toLowerCase() !== 'image' && (args.options.imageUrl || args.options.imageWidth ||
389
- args.options.imageHeight || args.options.fillMode)) {
390
- return 'Specify imageUrl, imageWidth, imageHeight or fillMode only when zoneEmphasis is set to Image';
391
- }
392
- if (args.options.zoneEmphasis?.toLowerCase() === 'image' && !args.options.imageUrl) {
393
- return 'Specify imageUrl when zoneEmphasis is set to Image';
394
- }
395
- if (args.options.zoneEmphasis?.toLowerCase() !== 'gradient' && args.options.gradientText) {
396
- return 'Specify gradientText only when zoneEmphasis is set to Gradient';
397
- }
398
- if (args.options.zoneEmphasis?.toLowerCase() === 'gradient' && !args.options.gradientText) {
399
- return 'Specify gradientText when zoneEmphasis is set to Gradient';
400
- }
401
- if (args.options.overlayOpacity && (args.options.overlayOpacity < 0 || args.options.overlayOpacity > 100)) {
402
- return 'The value of parameter overlayOpacity must be between 0 and 100';
403
- }
404
- if (args.options.overlayColor && !/^#[0-9a-f]{6}$/i.test(args.options.overlayColor)) {
405
- return 'The value of parameter overlayColor must be a valid hex color';
406
- }
407
- if (!(args.options.zoneEmphasis && ['image', 'gradient'].includes(args.options.zoneEmphasis.toLowerCase())) && (args.options.overlayColor || args.options.overlayOpacity || args.options.useLightText)) {
408
- return 'Specify overlayColor or overlayOpacity only when zoneEmphasis is set to Image or Gradient';
409
- }
410
- if (args.options.sectionTemplate?.toLowerCase() !== 'flexible' && (args.options.zoneReflowStrategy || args.options.zoneHeight)) {
411
- return 'Specify zoneReflowStrategy or zoneHeight only when sectionTemplate is set to Flexible';
412
- }
413
- if (typeof args.options.zoneHeight !== 'undefined') {
414
- if (!Number.isInteger(args.options.zoneHeight) || args.options.zoneHeight < this.MINIMUM_ZONE_HEIGHT) {
415
- return `The value of parameter zoneHeight must be ${this.MINIMUM_ZONE_HEIGHT} or higher`;
416
- }
417
- }
418
- return validation.isValidSharePointUrl(args.options.webUrl);
419
- });
420
- }, _SpoPageSectionAddCommand_initTypes = function _SpoPageSectionAddCommand_initTypes() {
421
- this.types.string = ['pageName', 'webUrl', 'sectionTemplate', 'zoneEmphasis', 'iconAlignment', 'gradientText', 'imageUrl', 'fillMode', 'overlayColor', 'collapsibleTitle', 'zoneReflowStrategy'];
422
- this.types.boolean = ['isLayoutReflowOnTop', 'isCollapsibleSection', 'showDivider', 'isExpanded', 'useLightText'];
423
- };
424
359
  export default new SpoPageSectionAddCommand();
425
360
  //# sourceMappingURL=page-section-add.js.map
@@ -1,14 +1,23 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _SpoPageSectionGetCommand_instances, _SpoPageSectionGetCommand_initOptions, _SpoPageSectionGetCommand_initValidators;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../../cli/cli.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import { validation } from '../../../../utils/validation.js';
9
5
  import SpoCommand from '../../../base/SpoCommand.js';
10
6
  import commands from '../../commands.js';
11
7
  import { Page } from './Page.js';
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ webUrl: z.string()
11
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
12
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
13
+ })
14
+ .alias('u'),
15
+ pageName: z.string().alias('n'),
16
+ section: z.number()
17
+ .int()
18
+ .min(1, { error: 'The value of parameter section must be 1 or higher' })
19
+ .alias('s')
20
+ });
12
21
  class SpoPageSectionGetCommand extends SpoCommand {
13
22
  get name() {
14
23
  return commands.PAGE_SECTION_GET;
@@ -16,11 +25,8 @@ class SpoPageSectionGetCommand extends SpoCommand {
16
25
  get description() {
17
26
  return 'Gets information about the specified modern page section';
18
27
  }
19
- constructor() {
20
- super();
21
- _SpoPageSectionGetCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _SpoPageSectionGetCommand_instances, "m", _SpoPageSectionGetCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _SpoPageSectionGetCommand_instances, "m", _SpoPageSectionGetCommand_initValidators).call(this);
28
+ get schema() {
29
+ return options;
24
30
  }
25
31
  async commandAction(logger, args) {
26
32
  try {
@@ -37,21 +43,5 @@ class SpoPageSectionGetCommand extends SpoCommand {
37
43
  }
38
44
  }
39
45
  }
40
- _SpoPageSectionGetCommand_instances = new WeakSet(), _SpoPageSectionGetCommand_initOptions = function _SpoPageSectionGetCommand_initOptions() {
41
- this.options.unshift({
42
- option: '-u, --webUrl <webUrl>'
43
- }, {
44
- option: '-n, --pageName <pageName>'
45
- }, {
46
- option: '-s, --section <section>'
47
- });
48
- }, _SpoPageSectionGetCommand_initValidators = function _SpoPageSectionGetCommand_initValidators() {
49
- this.validators.push(async (args) => {
50
- if (isNaN(args.options.section)) {
51
- return `${args.options.section} is not a number`;
52
- }
53
- return validation.isValidSharePointUrl(args.options.webUrl);
54
- });
55
- };
56
46
  export default new SpoPageSectionGetCommand();
57
47
  //# sourceMappingURL=page-section-get.js.map
@@ -1,14 +1,19 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _SpoPageSectionListCommand_instances, _SpoPageSectionListCommand_initOptions, _SpoPageSectionListCommand_initValidators;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../../cli/cli.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import { validation } from '../../../../utils/validation.js';
9
5
  import SpoCommand from '../../../base/SpoCommand.js';
10
6
  import commands from '../../commands.js';
11
7
  import { Page } from './Page.js';
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ webUrl: z.string()
11
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
12
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
13
+ })
14
+ .alias('u'),
15
+ pageName: z.string().alias('n')
16
+ });
12
17
  class SpoPageSectionListCommand extends SpoCommand {
13
18
  get name() {
14
19
  return commands.PAGE_SECTION_LIST;
@@ -16,11 +21,8 @@ class SpoPageSectionListCommand extends SpoCommand {
16
21
  get description() {
17
22
  return 'Lists sections in the specific modern page';
18
23
  }
19
- constructor() {
20
- super();
21
- _SpoPageSectionListCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _SpoPageSectionListCommand_instances, "m", _SpoPageSectionListCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _SpoPageSectionListCommand_instances, "m", _SpoPageSectionListCommand_initValidators).call(this);
24
+ get schema() {
25
+ return options;
24
26
  }
25
27
  async commandAction(logger, args) {
26
28
  try {
@@ -49,14 +51,5 @@ class SpoPageSectionListCommand extends SpoCommand {
49
51
  }
50
52
  }
51
53
  }
52
- _SpoPageSectionListCommand_instances = new WeakSet(), _SpoPageSectionListCommand_initOptions = function _SpoPageSectionListCommand_initOptions() {
53
- this.options.unshift({
54
- option: '-u, --webUrl <webUrl>'
55
- }, {
56
- option: '-n, --pageName <pageName>'
57
- });
58
- }, _SpoPageSectionListCommand_initValidators = function _SpoPageSectionListCommand_initValidators() {
59
- this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.webUrl));
60
- };
61
54
  export default new SpoPageSectionListCommand();
62
55
  //# sourceMappingURL=page-section-list.js.map
@@ -16,7 +16,10 @@ export const options = z.strictObject({
16
16
  })
17
17
  .alias('u'),
18
18
  pageName: z.string().alias('n'),
19
- section: z.number().alias('s'),
19
+ section: z.number()
20
+ .int()
21
+ .min(1, { error: 'The value of parameter section must be 1 or higher' })
22
+ .alias('s'),
20
23
  force: z.boolean().optional().alias('f')
21
24
  });
22
25
  class SpoPageSectionRemoveCommand extends SpoCommand {
@@ -1,10 +1,6 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _SpoPageSetCommand_instances, _SpoPageSetCommand_initTelemetry, _SpoPageSetCommand_initOptions, _SpoPageSetCommand_initTypes, _SpoPageSetCommand_initValidators;
1
+ import { z } from 'zod';
7
2
  import { Auth } from '../../../../Auth.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import request from '../../../../request.js';
9
5
  import { formatting } from '../../../../utils/formatting.js';
10
6
  import { spo } from '../../../../utils/spo.js';
@@ -13,6 +9,37 @@ import { validation } from '../../../../utils/validation.js';
13
9
  import SpoCommand from '../../../base/SpoCommand.js';
14
10
  import commands from '../../commands.js';
15
11
  import { Page, supportedPageLayouts, supportedPromoteAs } from './Page.js';
12
+ export const options = z.strictObject({
13
+ ...globalOptionsZod.shape,
14
+ webUrl: z.string()
15
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
16
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
17
+ })
18
+ .alias('u'),
19
+ name: z.string().alias('n'),
20
+ layoutType: z.enum(supportedPageLayouts).optional().alias('l'),
21
+ promoteAs: z.enum(supportedPromoteAs).optional().alias('p'),
22
+ demoteFrom: z.enum(['NewsPage']).optional(),
23
+ commentsEnabled: z.boolean().optional().autocomplete(['true', 'false']),
24
+ publish: z.boolean().optional(),
25
+ publishMessage: z.string().optional(),
26
+ description: z.string().optional(),
27
+ title: z.string().optional(),
28
+ content: z.string()
29
+ .refine(content => {
30
+ try {
31
+ JSON.parse(content);
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }, {
38
+ error: 'Specified content is not a valid JSON string.'
39
+ })
40
+ .optional(),
41
+ isRetired: z.boolean().optional().autocomplete(['true', 'false'])
42
+ });
16
43
  class SpoPageSetCommand extends SpoCommand {
17
44
  get name() {
18
45
  return commands.PAGE_SET;
@@ -20,13 +47,23 @@ class SpoPageSetCommand extends SpoCommand {
20
47
  get description() {
21
48
  return 'Updates modern page properties';
22
49
  }
23
- constructor() {
24
- super();
25
- _SpoPageSetCommand_instances.add(this);
26
- __classPrivateFieldGet(this, _SpoPageSetCommand_instances, "m", _SpoPageSetCommand_initTelemetry).call(this);
27
- __classPrivateFieldGet(this, _SpoPageSetCommand_instances, "m", _SpoPageSetCommand_initOptions).call(this);
28
- __classPrivateFieldGet(this, _SpoPageSetCommand_instances, "m", _SpoPageSetCommand_initTypes).call(this);
29
- __classPrivateFieldGet(this, _SpoPageSetCommand_instances, "m", _SpoPageSetCommand_initValidators).call(this);
50
+ get schema() {
51
+ return options;
52
+ }
53
+ getRefinedSchema(schema) {
54
+ return schema
55
+ .refine(opts => !!(opts.layoutType || opts.promoteAs || opts.demoteFrom || opts.commentsEnabled !== undefined ||
56
+ opts.publish || opts.description || opts.title || opts.content || opts.isRetired !== undefined), {
57
+ error: 'Specify at least one option to update.'
58
+ })
59
+ .refine(opts => opts.promoteAs !== 'HomePage' || opts.layoutType === 'Home', {
60
+ error: 'You can only promote home pages as site home page',
61
+ path: ['promoteAs']
62
+ })
63
+ .refine(opts => opts.promoteAs !== 'NewsPage' || !opts.layoutType || opts.layoutType === 'Article', {
64
+ error: 'You can only promote article pages as news article',
65
+ path: ['promoteAs']
66
+ });
30
67
  }
31
68
  async commandAction(logger, args) {
32
69
  const resource = Auth.getResourceFromUrl(args.options.webUrl);
@@ -231,92 +268,5 @@ class SpoPageSetCommand extends SpoCommand {
231
268
  }
232
269
  }
233
270
  }
234
- _SpoPageSetCommand_instances = new WeakSet(), _SpoPageSetCommand_initTelemetry = function _SpoPageSetCommand_initTelemetry() {
235
- this.telemetry.push((args) => {
236
- Object.assign(this.telemetryProperties, {
237
- layoutType: args.options.layoutType || false,
238
- promoteAs: args.options.promoteAs || false,
239
- demotefrom: args.options.demoteFrom || false,
240
- commentsEnabled: args.options.commentsEnabled || false,
241
- publish: args.options.publish || false,
242
- publishMessage: typeof args.options.publishMessage !== 'undefined',
243
- description: typeof args.options.description !== 'undefined',
244
- title: typeof args.options.title !== 'undefined',
245
- content: typeof args.options.content !== 'undefined',
246
- isRetired: typeof args.options.isRetired !== 'undefined'
247
- });
248
- });
249
- }, _SpoPageSetCommand_initOptions = function _SpoPageSetCommand_initOptions() {
250
- this.options.unshift({
251
- option: '-n, --name <name>'
252
- }, {
253
- option: '-u, --webUrl <webUrl>'
254
- }, {
255
- option: '-l, --layoutType [layoutType]',
256
- autocomplete: supportedPageLayouts
257
- }, {
258
- option: '-p, --promoteAs [promoteAs]',
259
- autocomplete: supportedPromoteAs
260
- }, {
261
- option: '--demoteFrom [demoteFrom]',
262
- autocomplete: ['NewsPage']
263
- }, {
264
- option: '--commentsEnabled [commentsEnabled]',
265
- autocomplete: ['true', 'false']
266
- }, {
267
- option: '--publish'
268
- }, {
269
- option: '--publishMessage [publishMessage]'
270
- }, {
271
- option: '--description [description]'
272
- }, {
273
- option: '--title [title]'
274
- }, {
275
- option: '--content [content]'
276
- }, {
277
- option: '--isRetired [isRetired]',
278
- autocomplete: ['true', 'false']
279
- });
280
- }, _SpoPageSetCommand_initTypes = function _SpoPageSetCommand_initTypes() {
281
- this.types.boolean.push('commentsEnabled', 'isRetired');
282
- }, _SpoPageSetCommand_initValidators = function _SpoPageSetCommand_initValidators() {
283
- this.validators.push(async (args) => {
284
- const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
285
- if (isValidSharePointUrl !== true) {
286
- return isValidSharePointUrl;
287
- }
288
- if (!args.options.layoutType && !args.options.promoteAs && !args.options.demoteFrom && args.options.commentsEnabled === undefined &&
289
- !args.options.publish && !args.options.description && !args.options.title && !args.options.content && args.options.isRetired === undefined) {
290
- return 'Specify at least one option to update.';
291
- }
292
- if (args.options.layoutType &&
293
- supportedPageLayouts.indexOf(args.options.layoutType) < 0) {
294
- return `${args.options.layoutType} is not a valid option for layoutType. Allowed values ${supportedPageLayouts.join(', ')}`;
295
- }
296
- if (args.options.promoteAs &&
297
- supportedPromoteAs.indexOf(args.options.promoteAs) < 0) {
298
- return `${args.options.promoteAs} is not a valid option for promoteAs. Allowed values ${supportedPromoteAs.join(', ')}`;
299
- }
300
- if (args.options.demoteFrom &&
301
- args.options.demoteFrom !== 'NewsPage') {
302
- return `${args.options.demoteFrom} is not a valid option for demoteFrom. The only allowed value is 'NewsPage'`;
303
- }
304
- if (args.options.promoteAs === 'HomePage' && args.options.layoutType !== 'Home') {
305
- return 'You can only promote home pages as site home page';
306
- }
307
- if (args.options.promoteAs === 'NewsPage' && args.options.layoutType && args.options.layoutType !== 'Article') {
308
- return 'You can only promote article pages as news article';
309
- }
310
- if (args.options.content) {
311
- try {
312
- JSON.parse(args.options.content);
313
- }
314
- catch (e) {
315
- return `Specified content is not a valid JSON string. Input: ${args.options.content}. Error: ${e}`;
316
- }
317
- }
318
- return true;
319
- });
320
- };
321
271
  export default new SpoPageSetCommand();
322
272
  //# sourceMappingURL=page-set.js.map