@pnp/cli-microsoft365 11.7.0-beta.bd906c5 → 11.7.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.
Files changed (51) hide show
  1. package/.devproxy/api-specs/sharepoint.yaml +53 -0
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/m365/context/commands/option/option-list.js +6 -1
  5. package/dist/m365/entra/commands/resourcenamespace/resourcenamespace-list.js +6 -0
  6. package/dist/m365/external/commands/connection/connection-list.js +6 -0
  7. package/dist/m365/outlook/commands/calendar/calendar-set.js +132 -0
  8. package/dist/m365/outlook/commands/calendargroup/calendargroup-get.js +114 -0
  9. package/dist/m365/outlook/commands.js +2 -0
  10. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.js +13 -1
  11. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.js +24 -3
  12. package/dist/m365/spo/commands/brandcenter/brandcenter-colors-list.js +59 -0
  13. package/dist/m365/spo/commands/file/file-archive.js +83 -0
  14. package/dist/m365/spo/commands/propertybag/propertybag-set.js +3 -9
  15. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-add.js +20 -0
  16. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +27 -2
  17. package/dist/m365/spo/commands/tenant/tenant-settings-set.js +5 -1
  18. package/dist/m365/spo/commands.js +2 -0
  19. package/dist/request.js +0 -16
  20. package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +21 -0
  21. package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +19 -0
  22. package/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx +21 -0
  23. package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +21 -0
  24. package/docs/docs/cmd/entra/roledefinition/roledefinition-add.mdx +19 -0
  25. package/docs/docs/cmd/entra/roledefinition/roledefinition-get.mdx +19 -0
  26. package/docs/docs/cmd/entra/roledefinition/roledefinition-list.mdx +19 -0
  27. package/docs/docs/cmd/entra/roledefinition/roledefinition-remove.mdx +21 -0
  28. package/docs/docs/cmd/entra/roledefinition/roledefinition-set.mdx +21 -0
  29. package/docs/docs/cmd/entra/siteclassification/siteclassification-disable.mdx +21 -0
  30. package/docs/docs/cmd/entra/siteclassification/siteclassification-enable.mdx +21 -0
  31. package/docs/docs/cmd/entra/siteclassification/siteclassification-get.mdx +19 -0
  32. package/docs/docs/cmd/entra/siteclassification/siteclassification-set.mdx +20 -0
  33. package/docs/docs/cmd/external/connection/connection-add.mdx +21 -0
  34. package/docs/docs/cmd/external/connection/connection-doctor.mdx +19 -0
  35. package/docs/docs/cmd/external/connection/connection-get.mdx +19 -0
  36. package/docs/docs/cmd/external/connection/connection-list.mdx +19 -0
  37. package/docs/docs/cmd/external/connection/connection-remove.mdx +21 -0
  38. package/docs/docs/cmd/external/connection/connection-schema-add.mdx +21 -0
  39. package/docs/docs/cmd/external/connection/connection-urltoitemresolver-add.mdx +21 -0
  40. package/docs/docs/cmd/external/item/item-add.mdx +19 -0
  41. package/docs/docs/cmd/outlook/calendar/calendar-set.mdx +178 -0
  42. package/docs/docs/cmd/outlook/calendargroup/calendargroup-get.mdx +125 -0
  43. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.mdx +14 -11
  44. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-set.mdx +9 -6
  45. package/docs/docs/cmd/spo/brandcenter/brandcenter-colors-list.mdx +115 -0
  46. package/docs/docs/cmd/spo/file/file-archive.mdx +68 -0
  47. package/docs/docs/cmd/spo/propertybag/propertybag-set.mdx +1 -1
  48. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.mdx +13 -10
  49. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx +7 -4
  50. package/docs/docs/cmd/spo/tenant/tenant-settings-set.mdx +3 -0
  51. package/package.json +2 -2
@@ -1,7 +1,9 @@
1
1
  import fs from 'fs';
2
- import { CommandError } from '../../../../Command.js';
2
+ import { z } from 'zod';
3
+ import { CommandError, globalOptionsZod } from '../../../../Command.js';
3
4
  import ContextCommand from '../../../base/ContextCommand.js';
4
5
  import commands from '../../commands.js';
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
5
7
  class ContextOptionListCommand extends ContextCommand {
6
8
  get name() {
7
9
  return commands.OPTION_LIST;
@@ -9,6 +11,9 @@ class ContextOptionListCommand extends ContextCommand {
9
11
  get description() {
10
12
  return 'List all options added to the context';
11
13
  }
14
+ get schema() {
15
+ return options;
16
+ }
12
17
  async commandAction(logger) {
13
18
  if (this.verbose) {
14
19
  await logger.logToStderr(`Retrieving context options...`);
@@ -1,6 +1,9 @@
1
1
  import { odata } from '../../../../utils/odata.js';
2
2
  import GraphCommand from '../../../base/GraphCommand.js';
3
3
  import commands from '../../commands.js';
4
+ import { z } from 'zod';
5
+ import { globalOptionsZod } from '../../../../Command.js';
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
4
7
  class EntraResourcenamespaceListCommand extends GraphCommand {
5
8
  get name() {
6
9
  return commands.RESOURCENAMESPACE_LIST;
@@ -8,6 +11,9 @@ class EntraResourcenamespaceListCommand extends GraphCommand {
8
11
  get description() {
9
12
  return 'Get a list of the RBAC resource namespaces and their properties';
10
13
  }
14
+ get schema() {
15
+ return options;
16
+ }
11
17
  defaultProperties() {
12
18
  return ['id', 'name'];
13
19
  }
@@ -1,6 +1,9 @@
1
1
  import { odata } from '../../../../utils/odata.js';
2
2
  import GraphCommand from '../../../base/GraphCommand.js';
3
3
  import commands from '../../commands.js';
4
+ import { z } from 'zod';
5
+ import { globalOptionsZod } from '../../../../Command.js';
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
4
7
  class ExternalConnectionListCommand extends GraphCommand {
5
8
  get name() {
6
9
  return commands.CONNECTION_LIST;
@@ -11,6 +14,9 @@ class ExternalConnectionListCommand extends GraphCommand {
11
14
  alias() {
12
15
  return [commands.EXTERNALCONNECTION_LIST];
13
16
  }
17
+ get schema() {
18
+ return options;
19
+ }
14
20
  defaultProperties() {
15
21
  return ['id', 'name', 'state'];
16
22
  }
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import GraphCommand from '../../../base/GraphCommand.js';
4
+ import commands from '../../commands.js';
5
+ import { validation } from '../../../../utils/validation.js';
6
+ import request from '../../../../request.js';
7
+ import { accessToken } from '../../../../utils/accessToken.js';
8
+ import auth from '../../../../Auth.js';
9
+ import { calendarGroup } from '../../../../utils/calendarGroup.js';
10
+ const calendarColors = ['auto', 'lightBlue', 'lightGreen', 'lightOrange', 'lightGray', 'lightYellow', 'lightTeal', 'lightPink', 'lightBrown', 'lightRed', 'maxColor'];
11
+ export const options = z.strictObject({
12
+ ...globalOptionsZod.shape,
13
+ id: z.string().alias('i'),
14
+ name: z.string().optional().alias('n'),
15
+ userId: z.string().refine(id => validation.isValidGuid(id), {
16
+ error: e => `'${e.input}' is not a valid GUID.`
17
+ }).optional(),
18
+ userName: z.string().refine(name => validation.isValidUserPrincipalName(name), {
19
+ error: e => `'${e.input}' is not a valid UPN.`
20
+ }).optional(),
21
+ calendarGroupId: z.string().optional(),
22
+ calendarGroupName: z.string().optional(),
23
+ color: z.enum(calendarColors).optional(),
24
+ isDefault: z.boolean().optional()
25
+ });
26
+ class OutlookCalendarSetCommand extends GraphCommand {
27
+ get name() {
28
+ return commands.CALENDAR_SET;
29
+ }
30
+ get description() {
31
+ return 'Updates a calendar for a user';
32
+ }
33
+ get schema() {
34
+ return options;
35
+ }
36
+ getRefinedSchema(schema) {
37
+ return schema
38
+ .refine(options => !(options.userId && options.userName), {
39
+ error: 'Specify either userId or userName, but not both.'
40
+ })
41
+ .refine(options => !(options.calendarGroupId && options.calendarGroupName), {
42
+ error: 'Specify either calendarGroupId or calendarGroupName, but not both.'
43
+ })
44
+ .refine(options => [options.name, options.color, options.isDefault].filter(o => o !== undefined).length > 0, {
45
+ error: 'Specify at least one of the following options: name, color, or isDefault.'
46
+ });
47
+ }
48
+ async commandAction(logger, args) {
49
+ try {
50
+ const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
51
+ const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(token);
52
+ let requestUrl;
53
+ if (isAppOnlyAccessToken) {
54
+ if (!args.options.userId && !args.options.userName) {
55
+ throw 'When running with application permissions either userId or userName is required.';
56
+ }
57
+ const userIdentifier = args.options.userId ?? args.options.userName;
58
+ requestUrl = this.buildRequestUrl(userIdentifier);
59
+ }
60
+ else {
61
+ if (args.options.userId || args.options.userName) {
62
+ const currentUserId = accessToken.getUserIdFromAccessToken(token);
63
+ const currentUserName = accessToken.getUserNameFromAccessToken(token);
64
+ const isOtherUser = (args.options.userId && args.options.userId !== currentUserId) ||
65
+ (args.options.userName && args.options.userName.toLowerCase() !== currentUserName?.toLowerCase());
66
+ if (isOtherUser) {
67
+ const scopes = accessToken.getScopesFromAccessToken(token);
68
+ const hasSharedScope = scopes.some(s => s === 'Calendars.ReadWrite.Shared');
69
+ if (!hasSharedScope) {
70
+ throw 'To update calendars of other users, the Entra ID application used for authentication must have the Calendars.ReadWrite.Shared delegated permission assigned.';
71
+ }
72
+ }
73
+ const userIdentifier = args.options.userId ?? args.options.userName;
74
+ requestUrl = this.buildRequestUrl(userIdentifier);
75
+ }
76
+ else {
77
+ requestUrl = this.buildRequestUrl(undefined);
78
+ }
79
+ }
80
+ if (this.verbose) {
81
+ await logger.logToStderr(`Updating calendar '${args.options.id}'...`);
82
+ }
83
+ let calendarGroupId = args.options.calendarGroupId;
84
+ if (args.options.calendarGroupName) {
85
+ const userIdForGroup = args.options.userId ?? args.options.userName ?? accessToken.getUserIdFromAccessToken(token);
86
+ const calendarGroupResult = await calendarGroup.getUserCalendarGroupByName(userIdForGroup, args.options.calendarGroupName, 'id');
87
+ calendarGroupId = calendarGroupResult.id;
88
+ }
89
+ const url = this.buildCalendarUrl(requestUrl, args.options.id, calendarGroupId);
90
+ const requestOptions = {
91
+ url,
92
+ headers: {
93
+ accept: 'application/json;odata.metadata=none'
94
+ },
95
+ responseType: 'json',
96
+ data: this.createRequestBody(args)
97
+ };
98
+ const result = await request.patch(requestOptions);
99
+ await logger.log(result);
100
+ }
101
+ catch (err) {
102
+ this.handleRejectedODataJsonPromise(err);
103
+ }
104
+ }
105
+ buildRequestUrl(userIdentifier) {
106
+ if (userIdentifier) {
107
+ return `${this.resource}/v1.0/users('${userIdentifier}')`;
108
+ }
109
+ return `${this.resource}/v1.0/me`;
110
+ }
111
+ buildCalendarUrl(baseUrl, calendarId, calendarGroupId) {
112
+ if (calendarGroupId) {
113
+ return `${baseUrl}/calendarGroups/${calendarGroupId}/calendars/${calendarId}`;
114
+ }
115
+ return `${baseUrl}/calendars/${calendarId}`;
116
+ }
117
+ createRequestBody(args) {
118
+ const data = {};
119
+ if (args.options.name !== undefined) {
120
+ data.name = args.options.name;
121
+ }
122
+ if (args.options.color !== undefined) {
123
+ data.color = args.options.color;
124
+ }
125
+ if (args.options.isDefault !== undefined) {
126
+ data.isDefaultCalendar = args.options.isDefault;
127
+ }
128
+ return data;
129
+ }
130
+ }
131
+ export default new OutlookCalendarSetCommand();
132
+ //# sourceMappingURL=calendar-set.js.map
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ import GraphCommand from '../../../base/GraphCommand.js';
3
+ import commands from '../../commands.js';
4
+ import { validation } from '../../../../utils/validation.js';
5
+ import { globalOptionsZod } from '../../../../Command.js';
6
+ import { formatting } from '../../../../utils/formatting.js';
7
+ import { odata } from '../../../../utils/odata.js';
8
+ import request from '../../../../request.js';
9
+ import { accessToken } from '../../../../utils/accessToken.js';
10
+ import auth from '../../../../Auth.js';
11
+ export const options = z.strictObject({
12
+ ...globalOptionsZod.shape,
13
+ id: z.string().optional(),
14
+ name: z.string().optional(),
15
+ userId: z.string().refine(id => validation.isValidGuid(id), {
16
+ error: e => `'${e.input}' is not a valid GUID.`
17
+ }).optional(),
18
+ userName: z.string().refine(name => validation.isValidUserPrincipalName(name), {
19
+ error: e => `'${e.input}' is not a valid UPN.`
20
+ }).optional()
21
+ });
22
+ class OutlookCalendarGroupGetCommand extends GraphCommand {
23
+ get name() {
24
+ return commands.CALENDARGROUP_GET;
25
+ }
26
+ get description() {
27
+ return 'Retrieve information about a calendar group for a user';
28
+ }
29
+ get schema() {
30
+ return options;
31
+ }
32
+ getRefinedSchema(schema) {
33
+ return schema
34
+ .refine(o => !(o.id && o.name), {
35
+ error: 'Specify either id or name, but not both.'
36
+ })
37
+ .refine(o => Boolean(o.id || o.name), {
38
+ error: 'Specify either id or name.'
39
+ })
40
+ .refine(o => !(o.userId && o.userName), {
41
+ error: 'Specify either userId or userName, but not both.'
42
+ });
43
+ }
44
+ async commandAction(logger, args) {
45
+ try {
46
+ const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
47
+ const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(token);
48
+ let userIdentifier = undefined;
49
+ if (args.options.userId || args.options.userName) {
50
+ userIdentifier = args.options.userId ?? args.options.userName;
51
+ }
52
+ const encodedUserIdentifier = userIdentifier
53
+ ? formatting.encodeQueryParameter(userIdentifier)
54
+ : undefined;
55
+ if (isAppOnlyAccessToken) {
56
+ if (!args.options.userId && !args.options.userName) {
57
+ throw 'When running with application permissions either userId or userName is required.';
58
+ }
59
+ }
60
+ else {
61
+ if (args.options.userId || args.options.userName) {
62
+ const currentUserId = accessToken.getUserIdFromAccessToken(token);
63
+ const currentUserName = accessToken.getUserNameFromAccessToken(token);
64
+ const isOtherUser = (args.options.userId && args.options.userId !== currentUserId) ||
65
+ (args.options.userName && args.options.userName.toLowerCase() !== currentUserName?.toLowerCase());
66
+ if (isOtherUser) {
67
+ const scopes = accessToken.getScopesFromAccessToken(token);
68
+ const hasSharedScope = scopes.some(s => s === 'Calendars.Read.Shared' || s === 'Calendars.ReadWrite.Shared');
69
+ if (!hasSharedScope) {
70
+ throw `To retrieve calendar groups of other users, the Entra ID application used for authentication must have either the Calendars.Read.Shared or Calendars.ReadWrite.Shared delegated permission assigned.`;
71
+ }
72
+ }
73
+ }
74
+ }
75
+ const getCalendarGroupByName = async (calendarGroupName) => {
76
+ const userPath = encodedUserIdentifier ? `users('${encodedUserIdentifier}')` : 'me';
77
+ const calendarGroups = await odata.getAllItems(`${this.resource}/v1.0/${userPath}/calendarGroups?$filter=name eq '${formatting.encodeQueryParameter(calendarGroupName)}'`);
78
+ if (calendarGroups.length === 0) {
79
+ throw `The specified calendar group '${calendarGroupName}' does not exist.`;
80
+ }
81
+ return calendarGroups[0];
82
+ };
83
+ if (args.options.name) {
84
+ if (this.verbose) {
85
+ await logger.logToStderr(`Retrieving calendar group '${args.options.name}'...`);
86
+ }
87
+ const result = await getCalendarGroupByName(args.options.name);
88
+ await logger.log(result);
89
+ }
90
+ else {
91
+ const calendarGroupId = args.options.id;
92
+ const userPath = encodedUserIdentifier ? `users('${encodedUserIdentifier}')` : 'me';
93
+ const requestUrl = `${this.resource}/v1.0/${userPath}/calendarGroups/${calendarGroupId}`;
94
+ if (this.verbose) {
95
+ await logger.logToStderr(`Retrieving calendar group '${calendarGroupId}'...`);
96
+ }
97
+ const requestOptions = {
98
+ url: requestUrl,
99
+ headers: {
100
+ accept: 'application/json;odata.metadata=none'
101
+ },
102
+ responseType: 'json'
103
+ };
104
+ const result = await request.get(requestOptions);
105
+ await logger.log(result);
106
+ }
107
+ }
108
+ catch (err) {
109
+ this.handleRejectedODataJsonPromise(err);
110
+ }
111
+ }
112
+ }
113
+ export default new OutlookCalendarGroupGetCommand();
114
+ //# sourceMappingURL=calendargroup-get.js.map
@@ -3,6 +3,8 @@ export default {
3
3
  CALENDAR_ADD: `${prefix} calendar add`,
4
4
  CALENDAR_GET: `${prefix} calendar get`,
5
5
  CALENDAR_REMOVE: `${prefix} calendar remove`,
6
+ CALENDAR_SET: `${prefix} calendar set`,
7
+ CALENDARGROUP_GET: `${prefix} calendargroup get`,
6
8
  CALENDARGROUP_LIST: `${prefix} calendargroup list`,
7
9
  CALENDARGROUP_SET: `${prefix} calendargroup set`,
8
10
  EVENT_CANCEL: `${prefix} event cancel`,
@@ -31,7 +31,8 @@ class SpoApplicationCustomizerAddCommand extends SpoCommand {
31
31
  Name: args.options.title,
32
32
  Description: args.options.description,
33
33
  Location: 'ClientSideExtension.ApplicationCustomizer',
34
- ClientSideComponentId: args.options.clientSideComponentId
34
+ ClientSideComponentId: args.options.clientSideComponentId,
35
+ HostProperties: args.options.hostProperties || ''
35
36
  };
36
37
  if (args.options.clientSideComponentProperties) {
37
38
  requestBody.ClientSideComponentProperties = args.options.clientSideComponentProperties;
@@ -59,6 +60,8 @@ _a = SpoApplicationCustomizerAddCommand, _SpoApplicationCustomizerAddCommand_ins
59
60
  option: '--description [description]'
60
61
  }, {
61
62
  option: '--clientSideComponentProperties [clientSideComponentProperties]'
63
+ }, {
64
+ option: '--hostProperties [hostProperties]'
62
65
  }, {
63
66
  option: '-s, --scope [scope]', autocomplete: _a.scopes
64
67
  });
@@ -67,6 +70,7 @@ _a = SpoApplicationCustomizerAddCommand, _SpoApplicationCustomizerAddCommand_ins
67
70
  Object.assign(this.telemetryProperties, {
68
71
  description: typeof args.options.description !== 'undefined',
69
72
  clientSideComponentProperties: typeof args.options.clientSideComponentProperties !== 'undefined',
73
+ hostProperties: typeof args.options.hostProperties !== 'undefined',
70
74
  scope: typeof args.options.scope !== 'undefined'
71
75
  });
72
76
  });
@@ -89,6 +93,14 @@ _a = SpoApplicationCustomizerAddCommand, _SpoApplicationCustomizerAddCommand_ins
89
93
  return `An error has occurred while parsing clientSideComponentProperties: ${e}`;
90
94
  }
91
95
  }
96
+ if (args.options.hostProperties) {
97
+ try {
98
+ JSON.parse(args.options.hostProperties);
99
+ }
100
+ catch (e) {
101
+ return `An error has occurred while parsing hostProperties: ${e}`;
102
+ }
103
+ }
92
104
  if (args.options.scope && _a.scopes.indexOf(args.options.scope) < 0) {
93
105
  return `${args.options.scope} is not a valid value for allowedMembers. Valid values are ${_a.scopes.join(', ')}`;
94
106
  }
@@ -37,11 +37,13 @@ class SpoApplicationCustomizerSetCommand extends SpoCommand {
37
37
  }
38
38
  }
39
39
  async updateAppCustomizer(logger, options, appCustomizer) {
40
- const { clientSideComponentProperties, webUrl, newTitle, description } = options;
40
+ const { clientSideComponentProperties, hostProperties, webUrl, newTitle, description } = options;
41
41
  if (this.verbose) {
42
42
  await logger.logToStderr(`Updating application customizer with ID '${appCustomizer.Id}' on the site '${webUrl}'...`);
43
43
  }
44
- const requestBody = {};
44
+ const requestBody = {
45
+ HostProperties: hostProperties
46
+ };
45
47
  if (newTitle) {
46
48
  requestBody.Title = newTitle;
47
49
  }
@@ -106,6 +108,8 @@ _SpoApplicationCustomizerSetCommand_instances = new WeakSet(), _SpoApplicationCu
106
108
  option: '--description [description]'
107
109
  }, {
108
110
  option: '-p, --clientSideComponentProperties [clientSideComponentProperties]'
111
+ }, {
112
+ option: '--hostProperties [hostProperties]'
109
113
  }, {
110
114
  option: '-s, --scope [scope]', autocomplete: this.allowedScopes
111
115
  });
@@ -118,6 +122,7 @@ _SpoApplicationCustomizerSetCommand_instances = new WeakSet(), _SpoApplicationCu
118
122
  newTitle: typeof args.options.newTitle !== 'undefined',
119
123
  description: typeof args.options.description !== 'undefined',
120
124
  clientSideComponentProperties: typeof args.options.clientSideComponentProperties !== 'undefined',
125
+ hostProperties: typeof args.options.hostProperties !== 'undefined',
121
126
  scope: typeof args.options.scope !== 'undefined'
122
127
  });
123
128
  });
@@ -132,7 +137,23 @@ _SpoApplicationCustomizerSetCommand_instances = new WeakSet(), _SpoApplicationCu
132
137
  if (args.options.scope && this.allowedScopes.indexOf(args.options.scope) === -1) {
133
138
  return `'${args.options.scope}' is not a valid application customizer scope. Allowed values are: ${this.allowedScopes.join(',')}`;
134
139
  }
135
- if (!args.options.newTitle && args.options.description === undefined && !args.options.clientSideComponentProperties) {
140
+ if (args.options.clientSideComponentProperties) {
141
+ try {
142
+ JSON.parse(args.options.clientSideComponentProperties);
143
+ }
144
+ catch (e) {
145
+ return `An error has occurred while parsing clientSideComponentProperties: ${e}`;
146
+ }
147
+ }
148
+ if (args.options.hostProperties) {
149
+ try {
150
+ JSON.parse(args.options.hostProperties);
151
+ }
152
+ catch (e) {
153
+ return `An error has occurred while parsing hostProperties: ${e}`;
154
+ }
155
+ }
156
+ if (!args.options.newTitle && args.options.description === undefined && !args.options.clientSideComponentProperties && args.options.hostProperties === undefined) {
136
157
  return `Please specify an option to be updated`;
137
158
  }
138
159
  return validation.isValidSharePointUrl(args.options.webUrl);
@@ -0,0 +1,59 @@
1
+ import commands from '../../commands.js';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import request from '../../../../request.js';
4
+ import { odata } from '../../../../utils/odata.js';
5
+ import { spo } from '../../../../utils/spo.js';
6
+ import SpoCommand from '../../../base/SpoCommand.js';
7
+ const options = globalOptionsZod.strict();
8
+ class SpoBrandCenterColorsListCommand extends SpoCommand {
9
+ get name() {
10
+ return commands.BRANDCENTER_COLORS_LIST;
11
+ }
12
+ get description() {
13
+ return 'Lists the brand center colors';
14
+ }
15
+ defaultProperties() {
16
+ return ['ColorCode', 'Title', 'IsVisible'];
17
+ }
18
+ get schema() {
19
+ return options;
20
+ }
21
+ async commandAction(logger) {
22
+ if (this.verbose) {
23
+ await logger.logToStderr(`Retrieving brand center colors...`);
24
+ }
25
+ try {
26
+ const spoUrl = await spo.getSpoUrl(logger, this.verbose);
27
+ const configRequestOptions = {
28
+ url: `${spoUrl}/_api/Brandcenter/Configuration`,
29
+ headers: {
30
+ accept: 'application/json;odata=nometadata'
31
+ },
32
+ responseType: 'json'
33
+ };
34
+ const config = await request.get(configRequestOptions);
35
+ if (!config.BrandColorsListUrl) {
36
+ if (this.verbose) {
37
+ await logger.logToStderr('Brand colors list not found.');
38
+ }
39
+ await logger.log([]);
40
+ return;
41
+ }
42
+ if (this.verbose) {
43
+ await logger.logToStderr(`Brand colors list found at '${config.BrandColorsListUrl.DecodedUrl}'.`);
44
+ }
45
+ const items = await odata.getAllItems(`${config.SiteUrl}/_api/web/lists(guid'${config.BrandColorsListId}')/items?$select=OData__SPColorTitle,OData__SPColorCode,OData__SPColorVisible`);
46
+ const result = items.map(item => ({
47
+ Title: item.OData__SPColorTitle,
48
+ ColorCode: item.OData__SPColorCode,
49
+ IsVisible: item.OData__SPColorVisible
50
+ }));
51
+ await logger.log(result);
52
+ }
53
+ catch (err) {
54
+ this.handleRejectedODataJsonPromise(err);
55
+ }
56
+ }
57
+ }
58
+ export default new SpoBrandCenterColorsListCommand();
59
+ //# sourceMappingURL=brandcenter-colors-list.js.map
@@ -0,0 +1,83 @@
1
+ import commands from '../../commands.js';
2
+ import SpoCommand from '../../../base/SpoCommand.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
4
+ import { z } from 'zod';
5
+ import { validation } from '../../../../utils/validation.js';
6
+ import { cli } from '../../../../cli/cli.js';
7
+ import { urlUtil } from '../../../../utils/urlUtil.js';
8
+ import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ webUrl: z.string()
13
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
14
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
15
+ })
16
+ .alias('u'),
17
+ url: z.string().optional(),
18
+ id: z.uuid().optional().alias('i'),
19
+ force: z.boolean().optional().alias('f')
20
+ });
21
+ class SpoFileArchiveCommand extends SpoCommand {
22
+ get name() {
23
+ return commands.FILE_ARCHIVE;
24
+ }
25
+ get description() {
26
+ return 'Archives a file';
27
+ }
28
+ get schema() {
29
+ return options;
30
+ }
31
+ getRefinedSchema(schema) {
32
+ return schema
33
+ .refine(options => [options.url, options.id].filter(o => o !== undefined).length === 1, {
34
+ error: `Specify 'url' or 'id', but not both.`
35
+ });
36
+ }
37
+ getExcludedOptionsWithUrls() {
38
+ return ['url'];
39
+ }
40
+ async commandAction(logger, args) {
41
+ const { webUrl, url, id, force, verbose } = args.options;
42
+ if (!force) {
43
+ const result = await cli.promptForConfirmation({ message: `Are you sure you would like to archive this item? You will be able to reactivate it instantly for the first 7 days. After that, it will take up to 24 hours to reactivate.` });
44
+ if (!result) {
45
+ return;
46
+ }
47
+ }
48
+ try {
49
+ if (verbose) {
50
+ await logger.logToStderr(`Archiving file ${url || id} at site ${webUrl}...`);
51
+ }
52
+ let requestUrl = `${webUrl}/_api/web`;
53
+ if (id) {
54
+ requestUrl += `/GetFileById('${formatting.encodeQueryParameter(id)}')`;
55
+ }
56
+ else if (url) {
57
+ const serverRelativePath = urlUtil.getServerRelativePath(webUrl, url);
58
+ requestUrl += `/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(serverRelativePath)}')`;
59
+ }
60
+ requestUrl += '?$select=ListId,ListItemAllFields/Id&$expand=ListItemAllFields';
61
+ const fileInfo = await request.get({
62
+ url: requestUrl,
63
+ headers: {
64
+ accept: 'application/json;odata=nometadata'
65
+ },
66
+ responseType: 'json'
67
+ });
68
+ const requestOptions = {
69
+ url: `${webUrl}/_api/Lists(guid'${fileInfo.ListId}')/items(${fileInfo.ListItemAllFields.Id})/Archive`,
70
+ headers: {
71
+ accept: 'application/json;odata=nometadata'
72
+ },
73
+ responseType: 'json'
74
+ };
75
+ await request.post(requestOptions);
76
+ }
77
+ catch (err) {
78
+ this.handleRejectedODataJsonPromise(err);
79
+ }
80
+ }
81
+ }
82
+ export default new SpoFileArchiveCommand();
83
+ //# sourceMappingURL=file-archive.js.map
@@ -28,12 +28,6 @@ class SpoPropertyBagSetCommand extends SpoPropertyBagBaseCommand {
28
28
  this.formDigestValue = contextResponse.FormDigestValue;
29
29
  let identityResp = await spo.getCurrentWebIdentity(args.options.webUrl, this.formDigestValue);
30
30
  const webIdentityResp = identityResp;
31
- // Check if web no script enabled or not
32
- // Cannot set property bag value if no script is enabled
33
- const isNoScriptSite = await this.isNoScriptSite(identityResp, args.options, logger);
34
- if (isNoScriptSite) {
35
- throw 'Site has NoScript enabled, and setting property bag values is not supported';
36
- }
37
31
  const opts = args.options;
38
32
  if (opts.folder) {
39
33
  // get the folder guid instead of the web guid
@@ -42,15 +36,15 @@ class SpoPropertyBagSetCommand extends SpoPropertyBagBaseCommand {
42
36
  await this.setProperty(identityResp, args.options, logger);
43
37
  }
44
38
  catch (err) {
39
+ if (err.toString().indexOf('E_ACCESSDENIED') > -1) {
40
+ await logger.logToStderr('Tip: If a site has NoScript enabled, setting the property bag value may result in exceptions.');
41
+ }
45
42
  this.handleRejectedPromise(err);
46
43
  }
47
44
  }
48
45
  setProperty(identityResp, options, logger) {
49
46
  return SpoPropertyBagBaseCommand.setProperty(options.key, options.value, options.webUrl, this.formDigestValue, identityResp, logger, this.debug, options.folder);
50
47
  }
51
- isNoScriptSite(webIdentityResp, options, logger) {
52
- return SpoPropertyBagBaseCommand.isNoScriptSite(options.webUrl, this.formDigestValue, webIdentityResp, logger, this.debug);
53
- }
54
48
  }
55
49
  _SpoPropertyBagSetCommand_instances = new WeakSet(), _SpoPropertyBagSetCommand_initTelemetry = function _SpoPropertyBagSetCommand_initTelemetry() {
56
50
  this.telemetry.push((args) => {
@@ -120,6 +120,7 @@ class SpoTenantApplicationCustomizerAddCommand extends SpoCommand {
120
120
  TenantWideExtensionSequence: 0,
121
121
  TenantWideExtensionListTemplate: 0,
122
122
  TenantWideExtensionComponentProperties: options.clientSideComponentProperties || '',
123
+ TenantWideExtensionHostProperties: options.hostProperties || '',
123
124
  TenantWideExtensionWebTemplate: options.webTemplate || '',
124
125
  TenantWideExtensionDisabled: false,
125
126
  verbose: this.verbose,
@@ -133,6 +134,7 @@ _SpoTenantApplicationCustomizerAddCommand_instances = new WeakSet(), _SpoTenantA
133
134
  this.telemetry.push((args) => {
134
135
  Object.assign(this.telemetryProperties, {
135
136
  clientSideComponentProperties: typeof args.options.clientSideComponentProperties !== 'undefined',
137
+ hostProperties: typeof args.options.hostProperties !== 'undefined',
136
138
  webTemplate: typeof args.options.webTemplate !== 'undefined'
137
139
  });
138
140
  });
@@ -143,6 +145,8 @@ _SpoTenantApplicationCustomizerAddCommand_instances = new WeakSet(), _SpoTenantA
143
145
  option: '-i, --clientSideComponentId <clientSideComponentId>'
144
146
  }, {
145
147
  option: '-p, --clientSideComponentProperties [clientSideComponentProperties]'
148
+ }, {
149
+ option: '--hostProperties [hostProperties]'
146
150
  }, {
147
151
  option: '-w, --webTemplate [webTemplate]'
148
152
  });
@@ -151,6 +155,22 @@ _SpoTenantApplicationCustomizerAddCommand_instances = new WeakSet(), _SpoTenantA
151
155
  if (!validation.isValidGuid(args.options.clientSideComponentId)) {
152
156
  return `${args.options.clientSideComponentId} is not a valid GUID`;
153
157
  }
158
+ if (args.options.clientSideComponentProperties) {
159
+ try {
160
+ JSON.parse(args.options.clientSideComponentProperties);
161
+ }
162
+ catch (e) {
163
+ return `An error has occurred while parsing clientSideComponentProperties: ${e}`;
164
+ }
165
+ }
166
+ if (args.options.hostProperties) {
167
+ try {
168
+ JSON.parse(args.options.hostProperties);
169
+ }
170
+ catch (e) {
171
+ return `An error has occurred while parsing hostProperties: ${e}`;
172
+ }
173
+ }
154
174
  return true;
155
175
  });
156
176
  };