@pnp/cli-microsoft365 10.10.0-beta.eb74779 → 10.11.0-beta.c2217b6

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.
@@ -0,0 +1,104 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import { zod } from '../../../../utils/zod.js';
4
+ import GraphCommand from '../../../base/GraphCommand.js';
5
+ import commands from '../../commands.js';
6
+ import { validation } from '../../../../utils/validation.js';
7
+ import request from '../../../../request.js';
8
+ import { odata } from '../../../../utils/odata.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ id: zod.alias('i', z.string().refine(id => validation.isValidGuid(id), id => ({
12
+ message: `'${id}' is not a valid GUID.`
13
+ })).optional()),
14
+ displayName: zod.alias('d', z.string().optional()),
15
+ marketingNotificationEmails: z.string().refine(emails => validation.isValidUserPrincipalNameArray(emails) === true, invalidEmails => ({
16
+ message: `The following marketing notification emails are invalid: ${invalidEmails}.`
17
+ })).transform((value) => value.split(',')).optional(),
18
+ securityComplianceNotificationMails: z.string().refine(emails => validation.isValidUserPrincipalNameArray(emails) === true, invalidEmails => ({
19
+ message: `The following security compliance notification emails are invalid: ${invalidEmails}.`
20
+ })).transform((value) => value.split(',')).optional(),
21
+ securityComplianceNotificationPhones: z.string().transform((value) => value.split(',')).optional(),
22
+ technicalNotificationMails: z.string().refine(emails => validation.isValidUserPrincipalNameArray(emails) === true, invalidEmails => ({
23
+ message: `The following technical notification emails are invalid: ${invalidEmails}.`
24
+ })).transform((value) => value.split(',')).optional(),
25
+ contactEmail: z.string().refine(id => validation.isValidUserPrincipalName(id), id => ({
26
+ message: `'${id}' is not a valid email.`
27
+ })).optional(),
28
+ statementUrl: z.string().optional()
29
+ })
30
+ .strict();
31
+ class EntraOrganizationSetCommand extends GraphCommand {
32
+ get name() {
33
+ return commands.ORGANIZATION_SET;
34
+ }
35
+ get description() {
36
+ return 'Updates info about the organization';
37
+ }
38
+ get schema() {
39
+ return options;
40
+ }
41
+ getRefinedSchema(schema) {
42
+ return schema
43
+ .refine(options => !(options.id && options.displayName), {
44
+ message: 'Specify either id or displayName, but not both'
45
+ })
46
+ .refine(options => options.id || options.displayName, {
47
+ message: 'Specify either id or displayName'
48
+ })
49
+ .refine(options => [options.contactEmail, options.marketingNotificationEmails, options.securityComplianceNotificationMails, options.securityComplianceNotificationPhones,
50
+ options.statementUrl, options.technicalNotificationMails].filter(o => o !== undefined).length > 0, {
51
+ message: 'Specify at least one of the following options: contactEmail, marketingNotificationEmails, securityComplianceNotificationMails, securityComplianceNotificationPhones, statementUrl, or technicalNotificationMails'
52
+ });
53
+ }
54
+ async commandAction(logger, args) {
55
+ try {
56
+ let organizationId = args.options.id;
57
+ if (args.options.displayName) {
58
+ organizationId = await this.getOrganizationIdByDisplayName(args.options.displayName);
59
+ }
60
+ if (args.options.verbose) {
61
+ await logger.logToStderr(`Updating organization with ID ${organizationId}...`);
62
+ }
63
+ const data = {
64
+ marketingNotificationEmails: args.options.marketingNotificationEmails,
65
+ securityComplianceNotificationMails: args.options.securityComplianceNotificationMails,
66
+ securityComplianceNotificationPhones: args.options.securityComplianceNotificationPhones,
67
+ technicalNotificationMails: args.options.technicalNotificationMails
68
+ };
69
+ if (args.options.contactEmail || args.options.statementUrl) {
70
+ data.privacyProfile = {};
71
+ }
72
+ if (args.options.contactEmail) {
73
+ data.privacyProfile.contactEmail = args.options.contactEmail;
74
+ }
75
+ if (args.options.statementUrl) {
76
+ data.privacyProfile.statementUrl = args.options.statementUrl;
77
+ }
78
+ const requestOptions = {
79
+ url: `${this.resource}/v1.0/organization/${organizationId}`,
80
+ headers: {
81
+ accept: 'application/json;odata.metadata=none',
82
+ 'content-type': 'application/json'
83
+ },
84
+ data: data,
85
+ responseType: 'json'
86
+ };
87
+ await request.patch(requestOptions);
88
+ }
89
+ catch (err) {
90
+ this.handleRejectedODataJsonPromise(err);
91
+ }
92
+ }
93
+ async getOrganizationIdByDisplayName(displayName) {
94
+ const url = `${this.resource}/v1.0/organization?$select=id,displayName`;
95
+ // the endpoint always returns one item
96
+ const organizations = await odata.getAllItems(url);
97
+ if (organizations[0].displayName !== displayName) {
98
+ throw `The specified organization '${displayName}' does not exist.`;
99
+ }
100
+ return organizations[0].id;
101
+ }
102
+ }
103
+ export default new EntraOrganizationSetCommand();
104
+ //# sourceMappingURL=organization-set.js.map
@@ -84,6 +84,7 @@ export default {
84
84
  OAUTH2GRANT_REMOVE: `${prefix} oauth2grant remove`,
85
85
  OAUTH2GRANT_SET: `${prefix} oauth2grant set`,
86
86
  ORGANIZATION_LIST: `${prefix} organization list`,
87
+ ORGANIZATION_SET: `${prefix} organization set`,
87
88
  PIM_ROLE_ASSIGNMENT_ADD: `${prefix} pim role assignment add`,
88
89
  PIM_ROLE_ASSIGNMENT_LIST: `${prefix} pim role assignment list`,
89
90
  PIM_ROLE_ASSIGNMENT_REMOVE: `${prefix} pim role assignment remove`,
@@ -1,48 +1,62 @@
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 _SpoHomeSiteRemoveCommand_instances, _SpoHomeSiteRemoveCommand_initTelemetry, _SpoHomeSiteRemoveCommand_initOptions;
1
+ import { z } from 'zod';
2
+ import { zod } from '../../../../utils/zod.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
4
+ import { validation } from '../../../../utils/validation.js';
7
5
  import { cli } from '../../../../cli/cli.js';
8
6
  import config from '../../../../config.js';
9
7
  import request from '../../../../request.js';
10
8
  import { spo } from '../../../../utils/spo.js';
11
9
  import SpoCommand from '../../../base/SpoCommand.js';
12
10
  import commands from '../../commands.js';
11
+ const options = globalOptionsZod
12
+ .extend({
13
+ url: zod.alias('u', z.string()
14
+ .refine(url => validation.isValidSharePointUrl(url) === true, url => ({
15
+ message: `'${url}' is not a valid SharePoint Online site URL.`
16
+ })).optional()),
17
+ force: zod.alias('f', z.boolean().optional())
18
+ })
19
+ .strict();
13
20
  class SpoHomeSiteRemoveCommand extends SpoCommand {
14
21
  get name() {
15
22
  return commands.HOMESITE_REMOVE;
16
23
  }
17
24
  get description() {
18
- return 'Removes the current Home Site';
25
+ return 'Removes a Home Site';
19
26
  }
20
- constructor() {
21
- super();
22
- _SpoHomeSiteRemoveCommand_instances.add(this);
23
- __classPrivateFieldGet(this, _SpoHomeSiteRemoveCommand_instances, "m", _SpoHomeSiteRemoveCommand_initTelemetry).call(this);
24
- __classPrivateFieldGet(this, _SpoHomeSiteRemoveCommand_instances, "m", _SpoHomeSiteRemoveCommand_initOptions).call(this);
27
+ get schema() {
28
+ return options;
25
29
  }
26
30
  async commandAction(logger, args) {
27
31
  const removeHomeSite = async () => {
28
32
  try {
33
+ if (this.verbose) {
34
+ await logger.logToStderr(`Removing ${args.options.url ? `'${args.options.url}' as home site` : 'the current home site'}...`);
35
+ }
29
36
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
30
37
  const reqDigest = await spo.getRequestDigest(spoAdminUrl);
31
- const requestOptions = {
32
- url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
33
- headers: {
34
- 'X-RequestDigest': reqDigest.FormDigestValue
35
- },
36
- data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="28" ObjectPathId="27" /><Method Name="RemoveSPHSite" Id="29" ObjectPathId="27" /></Actions><ObjectPaths><Constructor Id="27" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
37
- };
38
- const res = await request.post(requestOptions);
39
- const json = JSON.parse(res);
40
- const response = json[0];
41
- if (response.ErrorInfo) {
42
- throw response.ErrorInfo.ErrorMessage;
38
+ if (args.options.url) {
39
+ await this.removeHomeSiteByUrl(args.options.url, spoAdminUrl, logger);
40
+ await logger.log(`${args.options.url} has been removed as a Home Site. It may take some time for the change to apply. Check aka.ms/homesites for details.`);
43
41
  }
44
42
  else {
45
- await logger.log(json[json.length - 1]);
43
+ await this.warn(logger, `The current way this command works is deprecated and will change in the next major release. The '--url' option will become required.`);
44
+ const requestOptions = {
45
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
46
+ headers: {
47
+ 'X-RequestDigest': reqDigest.FormDigestValue
48
+ },
49
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="28" ObjectPathId="27" /><Method Name="RemoveSPHSite" Id="29" ObjectPathId="27" /></Actions><ObjectPaths><Constructor Id="27" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
50
+ };
51
+ const res = await request.post(requestOptions);
52
+ const json = JSON.parse(res);
53
+ const response = json[0];
54
+ if (response.ErrorInfo) {
55
+ throw response.ErrorInfo.ErrorMessage;
56
+ }
57
+ else {
58
+ await logger.log(json[json.length - 1]);
59
+ }
46
60
  }
47
61
  }
48
62
  catch (err) {
@@ -53,23 +67,29 @@ class SpoHomeSiteRemoveCommand extends SpoCommand {
53
67
  await removeHomeSite();
54
68
  }
55
69
  else {
56
- const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the Home Site?` });
70
+ const result = await cli.promptForConfirmation({
71
+ message: args.options.url
72
+ ? `Are you sure you want to remove '${args.options.url}' as home site?`
73
+ : `Are you sure you want to remove the current home site?`
74
+ });
57
75
  if (result) {
58
76
  await removeHomeSite();
59
77
  }
60
78
  }
61
79
  }
80
+ async removeHomeSiteByUrl(siteUrl, spoAdminUrl, logger) {
81
+ const siteAdminProperties = await spo.getSiteAdminPropertiesByUrl(siteUrl, false, logger, this.verbose);
82
+ const requestOptions = {
83
+ url: `${spoAdminUrl}/_api/SPO.Tenant/RemoveTargetedSite`,
84
+ headers: {
85
+ accept: 'application/json;odata=nometadata'
86
+ },
87
+ data: {
88
+ siteId: siteAdminProperties.SiteId
89
+ }
90
+ };
91
+ await request.post(requestOptions);
92
+ }
62
93
  }
63
- _SpoHomeSiteRemoveCommand_instances = new WeakSet(), _SpoHomeSiteRemoveCommand_initTelemetry = function _SpoHomeSiteRemoveCommand_initTelemetry() {
64
- this.telemetry.push((args) => {
65
- Object.assign(this.telemetryProperties, {
66
- force: args.options.force || false
67
- });
68
- });
69
- }, _SpoHomeSiteRemoveCommand_initOptions = function _SpoHomeSiteRemoveCommand_initOptions() {
70
- this.options.unshift({
71
- option: '-f, --force'
72
- });
73
- };
74
94
  export default new SpoHomeSiteRemoveCommand();
75
95
  //# sourceMappingURL=homesite-remove.js.map
@@ -1,53 +1,126 @@
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 _SpoListViewAddCommand_instances, _SpoListViewAddCommand_initTelemetry, _SpoListViewAddCommand_initOptions, _SpoListViewAddCommand_initValidators, _SpoListViewAddCommand_initOptionSets;
1
+ import { globalOptionsZod } from '../../../../Command.js';
7
2
  import request from '../../../../request.js';
8
3
  import { formatting } from '../../../../utils/formatting.js';
9
4
  import { urlUtil } from '../../../../utils/urlUtil.js';
10
5
  import { validation } from '../../../../utils/validation.js';
11
6
  import SpoCommand from '../../../base/SpoCommand.js';
12
7
  import commands from '../../commands.js';
8
+ import { z } from 'zod';
9
+ import { zod } from '../../../../utils/zod.js';
10
+ const options = globalOptionsZod
11
+ .extend({
12
+ webUrl: zod.alias('u', z.string()
13
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
14
+ message: 'webUrl is not a valid SharePoint site URL.'
15
+ })),
16
+ listId: z.string()
17
+ .refine(id => validation.isValidGuid(id), id => ({
18
+ message: `'${id}' is not a valid GUID.`
19
+ })).optional(),
20
+ listTitle: z.string().optional(),
21
+ listUrl: z.string().optional(),
22
+ title: z.string().min(1, 'Cannot be empty.'),
23
+ fields: z.string().optional(),
24
+ viewQuery: z.string().optional(),
25
+ personal: z.boolean().optional(),
26
+ default: z.boolean().optional(),
27
+ paged: z.boolean().optional(),
28
+ rowLimit: z.number().int().positive().optional(),
29
+ customFormatter: z.string()
30
+ .refine(formatter => {
31
+ try {
32
+ JSON.parse(formatter);
33
+ return true;
34
+ }
35
+ catch {
36
+ return false;
37
+ }
38
+ }, {
39
+ message: 'Custom formatter must be a valid JSON string.'
40
+ })
41
+ .optional(),
42
+ type: z.enum(['list', 'calendar', 'gallery', 'kanban']).optional(),
43
+ calendarStartDateField: z.string().min(1, 'Cannot be empty.').optional(),
44
+ calendarEndDateField: z.string().min(1, 'Cannot be empty.').optional(),
45
+ calendarTitleField: z.string().min(1, 'Cannot be empty.').optional(),
46
+ calendarSubTitleField: z.string().min(1, 'Cannot be empty.').optional(),
47
+ calendarDefaultLayout: z.enum(['month', 'week', 'workWeek', 'day']).optional(),
48
+ kanbanBucketField: z.string().min(1, 'Cannot be empty.').optional()
49
+ })
50
+ .strict();
13
51
  class SpoListViewAddCommand extends SpoCommand {
14
52
  get name() {
15
53
  return commands.LIST_VIEW_ADD;
16
54
  }
17
55
  get description() {
18
- return 'Adds a new view to a SharePoint list.';
56
+ return 'Adds a new view to a SharePoint list';
19
57
  }
20
- constructor() {
21
- super();
22
- _SpoListViewAddCommand_instances.add(this);
23
- __classPrivateFieldGet(this, _SpoListViewAddCommand_instances, "m", _SpoListViewAddCommand_initTelemetry).call(this);
24
- __classPrivateFieldGet(this, _SpoListViewAddCommand_instances, "m", _SpoListViewAddCommand_initOptions).call(this);
25
- __classPrivateFieldGet(this, _SpoListViewAddCommand_instances, "m", _SpoListViewAddCommand_initValidators).call(this);
26
- __classPrivateFieldGet(this, _SpoListViewAddCommand_instances, "m", _SpoListViewAddCommand_initOptionSets).call(this);
58
+ get schema() {
59
+ return options;
60
+ }
61
+ getRefinedSchema(schema) {
62
+ return schema
63
+ .refine((options) => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
64
+ message: 'Use one of the following options: listId, listTitle, or listUrl.'
65
+ })
66
+ .refine((options) => !options.personal || !options.default, {
67
+ message: 'Default view cannot be a personal view.'
68
+ })
69
+ .refine((options) => options.type !== 'calendar' || [options.calendarStartDateField, options.calendarEndDateField, options.calendarTitleField].filter(o => o === undefined).length === 0, {
70
+ message: 'When type is calendar, do specify calendarStartDateField, calendarEndDateField, and calendarTitleField.'
71
+ })
72
+ .refine((options) => options.type === 'calendar' || [options.calendarStartDateField, options.calendarEndDateField, options.calendarTitleField].filter(o => o === undefined).length === 3, {
73
+ message: 'When type is not calendar, do not specify calendarStartDateField, calendarEndDateField, and calendarTitleField.'
74
+ })
75
+ .refine((options) => options.type !== 'kanban' || options.kanbanBucketField !== undefined, {
76
+ message: 'When type is kanban, do specify kanbanBucketField.'
77
+ })
78
+ .refine((options) => options.type === 'kanban' || options.kanbanBucketField === undefined, {
79
+ message: 'When type is not kanban, do not specify kanbanBucketField.'
80
+ })
81
+ .refine((options) => options.type === 'calendar' || options.fields !== undefined, {
82
+ message: 'When type is not calendar, do specify fields.'
83
+ });
27
84
  }
28
85
  async commandAction(logger, args) {
29
- const requestOptions = {
30
- url: this.getRestUrl(args.options),
31
- headers: {
32
- 'content-type': 'application/json;odata=verbose',
33
- accept: 'application/json;odata=nometadata'
34
- },
35
- responseType: 'json',
36
- data: {
37
- parameters: {
38
- Title: args.options.title,
39
- ViewFields: {
40
- results: args.options.fields.split(',')
41
- },
42
- Query: args.options.viewQuery,
43
- PersonalView: !!args.options.personal,
44
- SetAsDefaultView: !!args.options.default,
45
- Paged: !!args.options.paged,
46
- RowLimit: args.options.rowLimit ? +args.options.rowLimit : 30
47
- }
48
- }
49
- };
50
86
  try {
87
+ if (this.verbose) {
88
+ await logger.logToStderr(`Adding view '${args.options.title}' to list...`);
89
+ }
90
+ let apiUrl = `${args.options.webUrl}/_api/web/`;
91
+ if (args.options.listId) {
92
+ apiUrl += `lists(guid'${formatting.encodeQueryParameter(args.options.listId)}')`;
93
+ }
94
+ else if (args.options.listTitle) {
95
+ apiUrl += `lists/getByTitle('${formatting.encodeQueryParameter(args.options.listTitle)}')`;
96
+ }
97
+ else if (args.options.listUrl) {
98
+ apiUrl += `GetList('${formatting.encodeQueryParameter(urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl))}')`;
99
+ }
100
+ apiUrl += '/views/add';
101
+ const requestOptions = {
102
+ url: apiUrl,
103
+ headers: {
104
+ 'content-type': 'application/json;odata=verbose',
105
+ accept: 'application/json;odata=nometadata'
106
+ },
107
+ responseType: 'json',
108
+ data: {
109
+ parameters: {
110
+ Title: args.options.title,
111
+ ViewFields: {
112
+ results: args.options.fields?.split(',').map(f => f.trim()) ?? []
113
+ },
114
+ Query: args.options.viewQuery,
115
+ PersonalView: !!args.options.personal,
116
+ SetAsDefaultView: !!args.options.default,
117
+ Paged: !!args.options.paged,
118
+ RowLimit: args.options.rowLimit ?? 30,
119
+ CustomFormatter: args.options.customFormatter
120
+ }
121
+ }
122
+ };
123
+ this.setViewTypeSpecificParameters(args.options, requestOptions.data.parameters);
51
124
  const result = await request.post(requestOptions);
52
125
  await logger.log(result);
53
126
  }
@@ -55,62 +128,42 @@ class SpoListViewAddCommand extends SpoCommand {
55
128
  this.handleRejectedODataJsonPromise(err);
56
129
  }
57
130
  }
58
- getRestUrl(options) {
59
- let result = `${options.webUrl}/_api/web/`;
60
- if (options.listId) {
61
- result += `lists(guid'${formatting.encodeQueryParameter(options.listId)}')`;
62
- }
63
- else if (options.listTitle) {
64
- result += `lists/getByTitle('${formatting.encodeQueryParameter(options.listTitle)}')`;
65
- }
66
- else if (options.listUrl) {
67
- result += `GetList('${formatting.encodeQueryParameter(urlUtil.getServerRelativePath(options.webUrl, options.listUrl))}')`;
68
- }
69
- result += '/views/add';
70
- return result;
71
- }
72
- }
73
- _SpoListViewAddCommand_instances = new WeakSet(), _SpoListViewAddCommand_initTelemetry = function _SpoListViewAddCommand_initTelemetry() {
74
- this.telemetry.push((args) => {
75
- Object.assign(this.telemetryProperties, {
76
- listId: typeof args.options.listId !== 'undefined',
77
- listTitle: typeof args.options.listTitle !== 'undefined',
78
- listUrl: typeof args.options.listUrl !== 'undefined',
79
- title: typeof args.options.title !== 'undefined',
80
- viewQuery: typeof args.options.viewQuery !== 'undefined',
81
- personal: !!args.options.personal,
82
- default: !!args.options.default,
83
- orderedView: !!args.options.orderedView,
84
- paged: !!args.options.paged,
85
- rowLimit: typeof args.options.rowLimit !== 'undefined'
86
- });
87
- });
88
- }, _SpoListViewAddCommand_initOptions = function _SpoListViewAddCommand_initOptions() {
89
- this.options.unshift({ option: '-u, --webUrl <webUrl>' }, { option: '--listId [listId]' }, { option: '--listTitle [listTitle]' }, { option: '--listUrl [listUrl]' }, { option: '--title <title>' }, { option: '--fields <fields>' }, { option: '--viewQuery [viewQuery]' }, { option: '--personal' }, { option: '--default' }, { option: '--paged' }, { option: '--rowLimit [rowLimit]' });
90
- }, _SpoListViewAddCommand_initValidators = function _SpoListViewAddCommand_initValidators() {
91
- this.validators.push(async (args) => {
92
- const webUrlValidation = validation.isValidSharePointUrl(args.options.webUrl);
93
- if (webUrlValidation !== true) {
94
- return webUrlValidation;
131
+ setViewTypeSpecificParameters(options, requestBody) {
132
+ if (options.type === 'calendar') {
133
+ const defaultView = options.calendarDefaultLayout ?? 'month';
134
+ const titleField = options.calendarTitleField;
135
+ const subTitleField = options.calendarSubTitleField ?? '';
136
+ // Following fields are required for calendar view, order is important
137
+ const viewFields = [options.calendarStartDateField, options.calendarEndDateField, titleField, subTitleField].filter(field => field !== '');
138
+ // Add any additional fields specified by the user
139
+ const extraViewFields = requestBody.ViewFields.results.filter((field) => !viewFields.includes(field.trim()));
140
+ viewFields.push(...extraViewFields);
141
+ requestBody.CalendarViewStyles = `<CalendarViewStyle Title="Day" Type="day" Template="CalendarViewdayChrome" Sequence="1" Default="${String(defaultView === 'day').toUpperCase()}" /><CalendarViewStyle Title="Week" Type="week" Template="CalendarViewweekChrome" Sequence="2" Default="${String(defaultView === 'week').toUpperCase()}" /><CalendarViewStyle Title="Month" Type="month" Template="CalendarViewmonthChrome" Sequence="3" Default="${String(defaultView === 'month').toUpperCase()}" /><CalendarViewStyle Title="Work week" Type="workweek" Template="CalendarViewweekChrome" Sequence="4" Default="${String(defaultView === 'workWeek').toUpperCase()}" />`;
142
+ requestBody.Query = `<Where><DateRangesOverlap><FieldRef Name='${options.calendarStartDateField}' /><FieldRef Name='${options.calendarEndDateField}' /><Value Type='DateTime'><Month /></Value></DateRangesOverlap></Where>`;
143
+ requestBody.ViewData = `<FieldRef Name="${titleField}" Type="CalendarMonthTitle" /><FieldRef Name="${titleField}" Type="CalendarWeekTitle" /><FieldRef Name="${subTitleField}" Type="CalendarWeekLocation" /><FieldRef Name="${titleField}" Type="CalendarDayTitle" /><FieldRef Name="${subTitleField}" Type="CalendarDayLocation" />`;
144
+ requestBody.ViewFields.results = viewFields;
145
+ requestBody.ViewType2 = 'MODERNCALENDAR';
146
+ return;
95
147
  }
96
- if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
97
- return `${args.options.listId} in option listId is not a valid GUID`;
148
+ if (options.type === 'gallery') {
149
+ requestBody.ViewType2 = 'TILES';
150
+ return;
98
151
  }
99
- if (args.options.rowLimit !== undefined) {
100
- if (isNaN(args.options.rowLimit)) {
101
- return `${args.options.rowLimit} is not a number`;
152
+ if (options.type === 'kanban') {
153
+ // Add the bucket field to the view fields if it is not already included
154
+ const viewFields = requestBody.ViewFields.results;
155
+ if (!viewFields.includes(options.kanbanBucketField)) {
156
+ viewFields.push(options.kanbanBucketField);
102
157
  }
103
- if (+args.options.rowLimit <= 0) {
104
- return 'rowLimit option must be greater than 0.';
158
+ if (!options.customFormatter) {
159
+ requestBody.CustomFormatter = '{}';
105
160
  }
161
+ requestBody.ViewData = `<FieldRef Name="${options.kanbanBucketField}" Type="KanbanPivotColumn" />`;
162
+ requestBody.ViewType2 = 'KANBAN';
163
+ return;
106
164
  }
107
- if (args.options.personal && args.options.default) {
108
- return 'Default view cannot be a personal view.';
109
- }
110
- return true;
111
- });
112
- }, _SpoListViewAddCommand_initOptionSets = function _SpoListViewAddCommand_initOptionSets() {
113
- this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] });
114
- };
165
+ }
166
+ ;
167
+ }
115
168
  export default new SpoListViewAddCommand();
116
169
  //# sourceMappingURL=list-view-add.js.map
@@ -30,6 +30,10 @@ export var CanvasSectionTemplate;
30
30
  /// Vertical
31
31
  /// </summary>
32
32
  CanvasSectionTemplate[CanvasSectionTemplate["Vertical"] = 6] = "Vertical";
33
+ /// <summary>
34
+ /// Flexible
35
+ /// </summary>
36
+ CanvasSectionTemplate[CanvasSectionTemplate["Flexible"] = 7] = "Flexible";
33
37
  })(CanvasSectionTemplate || (CanvasSectionTemplate = {}));
34
38
  /**
35
39
  * Section background shading