@pnp/cli-microsoft365 10.10.0-beta.bd186ba → 10.10.0
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.
- package/.devproxy/api-specs/sharepoint-admin.yaml +67 -0
- package/.devproxy/api-specs/sharepoint.yaml +230 -0
- package/.devproxy/devproxyrc.json +48 -0
- package/.devproxy/generate-openapi-spec.json +24 -0
- package/.devproxy/spo-csom-types.json +54 -0
- package/.eslintrc.cjs +8 -0
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/cli/cli.js +2 -2
- package/dist/m365/app/commands/permission/permission-add.js +8 -1
- package/dist/m365/base/SpoCommand.js +1 -0
- package/dist/m365/entra/commands/app/app-permission-add.js +5 -18
- package/dist/m365/entra/commands/organization/organization-set.js +104 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/file/commands/file-copy.js +2 -2
- package/dist/m365/file/commands/file-move.js +1 -1
- package/dist/m365/planner/commands/tenant/tenant-settings-list.js +0 -3
- package/dist/m365/spo/commands/contenttype/contenttype-add.js +3 -65
- package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +5 -50
- package/dist/m365/spo/commands/contenttype/contenttype-field-set.js +4 -48
- package/dist/m365/spo/commands/contenttype/contenttype-set.js +8 -58
- package/dist/m365/spo/commands/contenttype/contenttype-sync.js +2 -2
- package/dist/m365/spo/commands/folder/folder-sharinglink-add.js +1 -1
- package/dist/m365/spo/commands/folder/folder-sharinglink-clear.js +1 -1
- package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +1 -1
- package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +1 -1
- package/dist/m365/spo/commands/folder/folder-sharinglink-remove.js +1 -1
- package/dist/m365/spo/commands/folder/folder-sharinglink-set.js +1 -1
- package/dist/m365/spo/commands/homesite/homesite-remove.js +57 -37
- package/dist/m365/spo/commands/list/list-view-add.js +140 -87
- package/dist/m365/spo/commands/listitem/listitem-batch-set.js +3 -27
- package/dist/m365/spo/commands/page/Page.js +16 -1
- package/dist/m365/spo/commands/page/clientsidepages.js +4 -0
- package/dist/m365/spo/commands/page/page-add.js +1 -1
- package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -8
- package/dist/m365/spo/commands/page/page-control-remove.js +99 -0
- package/dist/m365/spo/commands/page/page-control-set.js +1 -1
- package/dist/m365/spo/commands/page/page-header-set.js +9 -40
- package/dist/m365/spo/commands/page/page-publish.js +2 -10
- package/dist/m365/spo/commands/page/page-section-add.js +75 -21
- package/dist/m365/spo/commands/page/page-set.js +1 -1
- package/dist/m365/spo/commands/site/site-admin-add.js +1 -12
- package/dist/m365/spo/commands/site/site-set.js +2 -2
- package/dist/m365/spo/commands.js +1 -0
- package/dist/utils/entraServicePrincipal.js +21 -0
- package/dist/utils/md.js +3 -3
- package/dist/utils/spo.js +87 -3
- package/docs/docs/cmd/_global.mdx +1 -1
- package/docs/docs/cmd/entra/organization/organization-set.mdx +84 -0
- package/docs/docs/cmd/planner/bucket/bucket-add.mdx +19 -0
- package/docs/docs/cmd/planner/bucket/bucket-get.mdx +19 -0
- package/docs/docs/cmd/planner/bucket/bucket-list.mdx +19 -0
- package/docs/docs/cmd/planner/bucket/bucket-remove.mdx +21 -0
- package/docs/docs/cmd/planner/bucket/bucket-set.mdx +21 -0
- package/docs/docs/cmd/planner/plan/plan-add.mdx +19 -0
- package/docs/docs/cmd/planner/plan/plan-get.mdx +19 -0
- package/docs/docs/cmd/planner/plan/plan-list.mdx +19 -0
- package/docs/docs/cmd/planner/plan/plan-remove.mdx +21 -0
- package/docs/docs/cmd/planner/plan/plan-set.mdx +19 -0
- package/docs/docs/cmd/planner/roster/roster-add.mdx +19 -0
- package/docs/docs/cmd/planner/roster/roster-get.mdx +19 -0
- package/docs/docs/cmd/planner/roster/roster-member-add.mdx +19 -0
- package/docs/docs/cmd/planner/roster/roster-member-get.mdx +19 -0
- package/docs/docs/cmd/planner/roster/roster-member-list.mdx +19 -0
- package/docs/docs/cmd/planner/roster/roster-member-remove.mdx +21 -0
- package/docs/docs/cmd/planner/roster/roster-plan-list.mdx +19 -0
- package/docs/docs/cmd/planner/roster/roster-remove.mdx +21 -0
- package/docs/docs/cmd/planner/task/task-add.mdx +19 -0
- package/docs/docs/cmd/planner/task/task-checklistitem-add.mdx +19 -0
- package/docs/docs/cmd/planner/task/task-checklistitem-list.mdx +19 -0
- package/docs/docs/cmd/planner/task/task-checklistitem-remove.mdx +21 -0
- package/docs/docs/cmd/planner/task/task-get.mdx +27 -0
- package/docs/docs/cmd/planner/task/task-list.mdx +19 -0
- package/docs/docs/cmd/planner/task/task-reference-add.mdx +19 -0
- package/docs/docs/cmd/planner/task/task-reference-list.mdx +19 -0
- package/docs/docs/cmd/planner/task/task-reference-remove.mdx +21 -0
- package/docs/docs/cmd/planner/task/task-remove.mdx +21 -0
- package/docs/docs/cmd/planner/task/task-set.mdx +19 -0
- package/docs/docs/cmd/planner/tenant/tenant-settings-list.mdx +44 -7
- package/docs/docs/cmd/planner/tenant/tenant-settings-set.mdx +43 -8
- package/docs/docs/cmd/spo/homesite/homesite-remove.mdx +6 -3
- package/docs/docs/cmd/spo/list/list-view-add.mdx +53 -10
- package/docs/docs/cmd/spo/page/page-control-remove.mdx +56 -0
- package/docs/docs/cmd/spo/page/page-section-add.mdx +22 -2
- package/npm-shrinkwrap.json +2322 -534
- package/package.json +17 -14
|
@@ -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.
|
|
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
|
-
|
|
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
|
-
|
|
224
|
-
|
|
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]
|
|
230
|
-
webId: res[1]
|
|
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]
|
|
232
|
+
properties.siteId = res[0];
|
|
238
233
|
properties.uniqueId = res[2].UniqueId;
|
|
239
|
-
properties.webId = res[1]
|
|
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
|
-
|
|
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;
|
|
@@ -21,10 +22,12 @@ class SpoPageSectionAddCommand extends SpoCommand {
|
|
|
21
22
|
constructor() {
|
|
22
23
|
super();
|
|
23
24
|
_SpoPageSectionAddCommand_instances.add(this);
|
|
24
|
-
this.sectionTemplate = ['OneColumn', 'OneColumnFullWidth', 'TwoColumn', 'ThreeColumn', 'TwoColumnLeft', 'TwoColumnRight', 'Vertical'];
|
|
25
|
+
this.sectionTemplate = ['OneColumn', 'OneColumnFullWidth', 'TwoColumn', 'ThreeColumn', 'TwoColumnLeft', 'TwoColumnRight', 'Vertical', 'Flexible'];
|
|
25
26
|
this.zoneEmphasis = ['None', 'Neutral', 'Soft', 'Strong', 'Image', 'Gradient'];
|
|
26
27
|
this.iconAlignment = ['Left', 'Right'];
|
|
27
28
|
this.fillMode = ['ScaleToFill', 'ScaleToFit', 'Tile', 'OriginalSize'];
|
|
29
|
+
this.zoneReflowStrategy = ['TopToBottom', 'LeftToRight'];
|
|
30
|
+
this.MINIMUM_ZONE_HEIGHT = 34;
|
|
28
31
|
__classPrivateFieldGet(this, _SpoPageSectionAddCommand_instances, "m", _SpoPageSectionAddCommand_initTelemetry).call(this);
|
|
29
32
|
__classPrivateFieldGet(this, _SpoPageSectionAddCommand_instances, "m", _SpoPageSectionAddCommand_initOptions).call(this);
|
|
30
33
|
__classPrivateFieldGet(this, _SpoPageSectionAddCommand_instances, "m", _SpoPageSectionAddCommand_initValidators).call(this);
|
|
@@ -49,15 +52,14 @@ class SpoPageSectionAddCommand extends SpoCommand {
|
|
|
49
52
|
};
|
|
50
53
|
const res = await request.get(requestOptions);
|
|
51
54
|
canvasContent = JSON.parse(res.CanvasContent1 || "[{\"controlType\":0,\"pageSettingsSlice\":{\"isDefaultDescription\":true,\"isDefaultThumbnail\":true}}]");
|
|
55
|
+
if (args.options.sectionTemplate === 'OneColumnFullWidth') {
|
|
56
|
+
this.ensureFullWidthSectionCanBeAdded(canvasContent);
|
|
57
|
+
}
|
|
58
|
+
if (args.options.sectionTemplate === 'Vertical') {
|
|
59
|
+
this.ensureVerticalSectionCanBeAdded(canvasContent);
|
|
60
|
+
}
|
|
52
61
|
if (!res.IsPageCheckedOutToCurrentUser) {
|
|
53
|
-
|
|
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);
|
|
62
|
+
await Page.checkout(pageFullName, args.options.webUrl, logger, this.verbose);
|
|
61
63
|
}
|
|
62
64
|
// get unique zoneIndex values given each section can have 1 or more
|
|
63
65
|
// columns each assigned to the zoneIndex of the corresponding section
|
|
@@ -148,6 +150,9 @@ class SpoPageSectionAddCommand extends SpoCommand {
|
|
|
148
150
|
case 'Vertical':
|
|
149
151
|
columns.push(this.getVerticalColumn(args, zoneId));
|
|
150
152
|
break;
|
|
153
|
+
case 'Flexible':
|
|
154
|
+
columns.push(this.getFlexibleColumn(zoneIndex, sectionIndex++, args, zoneId));
|
|
155
|
+
break;
|
|
151
156
|
case 'OneColumn':
|
|
152
157
|
default:
|
|
153
158
|
columns.push(this.getColumn(zoneIndex, sectionIndex++, 12, args, zoneId));
|
|
@@ -168,9 +173,9 @@ class SpoPageSectionAddCommand extends SpoCommand {
|
|
|
168
173
|
},
|
|
169
174
|
emphasis: {}
|
|
170
175
|
};
|
|
171
|
-
if (zoneEmphasis && ['none', 'neutral', 'soft', 'strong'].includes(zoneEmphasis?.
|
|
176
|
+
if (zoneEmphasis && ['none', 'neutral', 'soft', 'strong'].includes(zoneEmphasis?.toLowerCase())) {
|
|
172
177
|
// Just these zoneEmphasis values should be added to column emphasis
|
|
173
|
-
const zoneEmphasisValue = ['none', 'neutral', 'soft', 'strong'].indexOf(zoneEmphasis.
|
|
178
|
+
const zoneEmphasisValue = ['none', 'neutral', 'soft', 'strong'].indexOf(zoneEmphasis.toLowerCase());
|
|
174
179
|
columnValue.emphasis = { zoneEmphasis: zoneEmphasisValue };
|
|
175
180
|
}
|
|
176
181
|
if (isCollapsibleSection) {
|
|
@@ -178,8 +183,9 @@ class SpoPageSectionAddCommand extends SpoCommand {
|
|
|
178
183
|
type: 1,
|
|
179
184
|
isExpanded: !!isExpanded,
|
|
180
185
|
showDividerLine: !!showDivider,
|
|
181
|
-
iconAlignment: iconAlignment && iconAlignment.
|
|
182
|
-
displayName: collapsibleTitle
|
|
186
|
+
iconAlignment: iconAlignment && iconAlignment.toLowerCase() === "right" ? "right" : "left",
|
|
187
|
+
displayName: collapsibleTitle,
|
|
188
|
+
headingLevel: args.options.headingLevel ? args.options.headingLevel : 2 //2 is a default heading level
|
|
183
189
|
};
|
|
184
190
|
}
|
|
185
191
|
return columnValue;
|
|
@@ -191,6 +197,14 @@ class SpoPageSectionAddCommand extends SpoCommand {
|
|
|
191
197
|
columnValue.position.controlIndex = 1;
|
|
192
198
|
return columnValue;
|
|
193
199
|
}
|
|
200
|
+
getFlexibleColumn(zoneIndex, sectionIndex, args, zoneId) {
|
|
201
|
+
const columnValue = this.getColumn(zoneIndex, sectionIndex, 100, args, zoneId);
|
|
202
|
+
columnValue.zoneReflowStrategy = { axis: args.options.zoneReflowStrategy ? this.zoneReflowStrategy.indexOf(args.options.zoneReflowStrategy) : 0 };
|
|
203
|
+
if (args.options.zoneHeight) {
|
|
204
|
+
columnValue.zoneHeight = args.options.zoneHeight;
|
|
205
|
+
}
|
|
206
|
+
return columnValue;
|
|
207
|
+
}
|
|
194
208
|
setBackgroundControl(zoneId, backgroundControl, args) {
|
|
195
209
|
const { overlayColor, overlayOpacity, useLightText, imageUrl } = args.options;
|
|
196
210
|
const backgroundDetails = this.getBackgroundDetails(args);
|
|
@@ -243,6 +257,18 @@ class SpoPageSectionAddCommand extends SpoCommand {
|
|
|
243
257
|
}
|
|
244
258
|
return backgroundDetails;
|
|
245
259
|
}
|
|
260
|
+
ensureFullWidthSectionCanBeAdded(canvasContent) {
|
|
261
|
+
const hasVerticalSection = canvasContent.some((c) => c.position?.layoutIndex === 2 && c.position.sectionFactor === 12);
|
|
262
|
+
if (hasVerticalSection) {
|
|
263
|
+
throw "A vertical section already exists on the page. A full-width section cannot be added to a page that already has a vertical section.";
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
ensureVerticalSectionCanBeAdded(canvasContent) {
|
|
267
|
+
const hasFullWidthSection = canvasContent.some((c) => c.position?.layoutIndex === 1 && c.position.sectionFactor === 0);
|
|
268
|
+
if (hasFullWidthSection) {
|
|
269
|
+
throw "A full-width section already exists on the page. A vertical section cannot be added to a page that already has a full-width section.";
|
|
270
|
+
}
|
|
271
|
+
}
|
|
246
272
|
}
|
|
247
273
|
_SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_initTelemetry = function _SpoPageSectionAddCommand_initTelemetry() {
|
|
248
274
|
this.telemetry.push((args) => {
|
|
@@ -262,7 +288,10 @@ _SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_i
|
|
|
262
288
|
useLightText: !!args.options.useLightText,
|
|
263
289
|
overlayColor: typeof args.options.overlayColor !== 'undefined',
|
|
264
290
|
overlayOpacity: typeof args.options.overlayOpacity !== 'undefined',
|
|
265
|
-
collapsibleTitle: typeof args.options.collapsibleTitle !== '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'
|
|
266
295
|
});
|
|
267
296
|
});
|
|
268
297
|
}, _SpoPageSectionAddCommand_initOptions = function _SpoPageSectionAddCommand_initOptions() {
|
|
@@ -308,11 +337,18 @@ _SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_i
|
|
|
308
337
|
option: '--overlayOpacity [overlayOpacity]'
|
|
309
338
|
}, {
|
|
310
339
|
option: '--collapsibleTitle [collapsibleTitle]'
|
|
340
|
+
}, {
|
|
341
|
+
option: '--zoneReflowStrategy [zoneReflowStrategy]',
|
|
342
|
+
autocomplete: this.zoneReflowStrategy
|
|
343
|
+
}, {
|
|
344
|
+
option: '--zoneHeight [zoneHeight]'
|
|
345
|
+
}, {
|
|
346
|
+
option: '--headingLevel [headingLevel]'
|
|
311
347
|
});
|
|
312
348
|
}, _SpoPageSectionAddCommand_initValidators = function _SpoPageSectionAddCommand_initValidators() {
|
|
313
349
|
this.validators.push(async (args) => {
|
|
314
350
|
if (!(args.options.sectionTemplate in CanvasSectionTemplate)) {
|
|
315
|
-
return `${args.options.sectionTemplate} is not a valid section template. Allowed values are OneColumn|OneColumnFullWidth|TwoColumn|ThreeColumn|TwoColumnLeft|TwoColumnRight|Vertical`;
|
|
351
|
+
return `${args.options.sectionTemplate} is not a valid section template. Allowed values are OneColumn|OneColumnFullWidth|TwoColumn|ThreeColumn|TwoColumnLeft|TwoColumnRight|Vertical|Flexible`;
|
|
316
352
|
}
|
|
317
353
|
if (typeof args.options.order !== 'undefined') {
|
|
318
354
|
if (!Number.isInteger(args.options.order) || args.options.order < 1) {
|
|
@@ -320,7 +356,7 @@ _SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_i
|
|
|
320
356
|
}
|
|
321
357
|
}
|
|
322
358
|
if (typeof args.options.zoneEmphasis !== 'undefined') {
|
|
323
|
-
if (!this.zoneEmphasis.some(zoneEmphasisValue => zoneEmphasisValue.
|
|
359
|
+
if (!this.zoneEmphasis.some(zoneEmphasisValue => zoneEmphasisValue.toLowerCase() === args.options.zoneEmphasis?.toLowerCase())) {
|
|
324
360
|
return `The value of parameter zoneEmphasis must be ${this.zoneEmphasis.join(', ')}`;
|
|
325
361
|
}
|
|
326
362
|
}
|
|
@@ -330,20 +366,30 @@ _SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_i
|
|
|
330
366
|
}
|
|
331
367
|
}
|
|
332
368
|
if (typeof args.options.iconAlignment !== 'undefined') {
|
|
333
|
-
if (!this.iconAlignment.some(iconAlignmentValue => iconAlignmentValue.
|
|
369
|
+
if (!this.iconAlignment.some(iconAlignmentValue => iconAlignmentValue.toLowerCase() === args.options.iconAlignment?.toLowerCase())) {
|
|
334
370
|
return `The value of parameter iconAlignment must be ${this.iconAlignment.join(', ')}`;
|
|
335
371
|
}
|
|
336
372
|
}
|
|
337
373
|
if (typeof args.options.fillMode !== 'undefined') {
|
|
338
|
-
if (!this.fillMode.some(fillModeValue => fillModeValue.
|
|
374
|
+
if (!this.fillMode.some(fillModeValue => fillModeValue.toLowerCase() === args.options.fillMode?.toLowerCase())) {
|
|
339
375
|
return `The value of parameter fillMode must be ${this.fillMode.join(', ')}`;
|
|
340
376
|
}
|
|
341
377
|
}
|
|
342
|
-
if (args.options.
|
|
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 ||
|
|
343
389
|
args.options.imageHeight || args.options.fillMode)) {
|
|
344
390
|
return 'Specify imageUrl, imageWidth, imageHeight or fillMode only when zoneEmphasis is set to Image';
|
|
345
391
|
}
|
|
346
|
-
if (args.options.zoneEmphasis?.
|
|
392
|
+
if (args.options.zoneEmphasis?.toLowerCase() === 'image' && !args.options.imageUrl) {
|
|
347
393
|
return 'Specify imageUrl when zoneEmphasis is set to Image';
|
|
348
394
|
}
|
|
349
395
|
if (args.options.zoneEmphasis?.toLowerCase() !== 'gradient' && args.options.gradientText) {
|
|
@@ -361,10 +407,18 @@ _SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_i
|
|
|
361
407
|
if (!(args.options.zoneEmphasis && ['image', 'gradient'].includes(args.options.zoneEmphasis.toLowerCase())) && (args.options.overlayColor || args.options.overlayOpacity || args.options.useLightText)) {
|
|
362
408
|
return 'Specify overlayColor or overlayOpacity only when zoneEmphasis is set to Image or Gradient';
|
|
363
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
|
+
}
|
|
364
418
|
return validation.isValidSharePointUrl(args.options.webUrl);
|
|
365
419
|
});
|
|
366
420
|
}, _SpoPageSectionAddCommand_initTypes = function _SpoPageSectionAddCommand_initTypes() {
|
|
367
|
-
this.types.string = ['pageName', 'webUrl', 'sectionTemplate', 'zoneEmphasis', 'iconAlignment', 'gradientText', 'imageUrl', 'fillMode', 'overlayColor', 'collapsibleTitle'];
|
|
421
|
+
this.types.string = ['pageName', 'webUrl', 'sectionTemplate', 'zoneEmphasis', 'iconAlignment', 'gradientText', 'imageUrl', 'fillMode', 'overlayColor', 'collapsibleTitle', 'zoneReflowStrategy'];
|
|
368
422
|
this.types.boolean = ['isLayoutReflowOnTop', 'isCollapsibleSection', 'showDivider', 'isExpanded', 'useLightText'];
|
|
369
423
|
};
|
|
370
424
|
export default new SpoPageSectionAddCommand();
|
|
@@ -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.
|
|
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
|
|
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.
|
|
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.
|
|
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(
|
|
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(
|
|
52
|
+
.replace(/.*\n?<\/?(Tabs|TabItem)>.*\n?/g, '')
|
|
53
53
|
.replace(/```(?:\w+)?\s*([\s\S]*?)\s*```/g, '$1')
|
|
54
54
|
.trim();
|
|
55
55
|
}
|