@pnp/cli-microsoft365 12.0.0 → 12.1.0-beta.79db3d9

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 (25) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/cli/cli.js +19 -18
  4. package/dist/m365/spo/commands/eventreceiver/eventreceiver-get.js +39 -65
  5. package/dist/m365/spo/commands/eventreceiver/eventreceiver-list.js +28 -56
  6. package/dist/m365/spo/commands/eventreceiver/eventreceiver-remove.js +40 -68
  7. package/dist/m365/spo/commands/externaluser/externaluser-list.js +24 -66
  8. package/dist/m365/spo/commands/group/group-add.js +19 -60
  9. package/dist/m365/spo/commands/group/group-get.js +32 -45
  10. package/dist/m365/spo/commands/group/group-list.js +13 -27
  11. package/dist/m365/spo/commands/group/group-member-add.js +52 -84
  12. package/dist/m365/spo/commands/group/group-member-list.js +24 -38
  13. package/dist/m365/spo/commands/group/group-member-remove.js +49 -68
  14. package/dist/m365/spo/commands/group/group-remove.js +25 -45
  15. package/dist/m365/spo/commands/group/group-set.js +36 -79
  16. package/dist/m365/spo/commands/propertybag/propertybag-get.js +14 -29
  17. package/dist/m365/spo/commands/propertybag/propertybag-list.js +13 -27
  18. package/dist/m365/spo/commands/propertybag/propertybag-remove.js +15 -32
  19. package/dist/m365/spo/commands/propertybag/propertybag-set.js +15 -31
  20. package/dist/m365/spo/commands/roledefinition/roledefinition-add.js +45 -44
  21. package/dist/m365/spo/commands/roledefinition/roledefinition-get.js +14 -25
  22. package/dist/m365/spo/commands/roledefinition/roledefinition-list.js +12 -18
  23. package/dist/m365/spo/commands/roledefinition/roledefinition-remove.js +15 -35
  24. package/npm-shrinkwrap.json +2 -2
  25. package/package.json +2 -2
package/dist/cli/cli.js CHANGED
@@ -47,6 +47,21 @@ const yargsConfiguration = {
47
47
  'boolean-negation': true,
48
48
  'camel-case-expansion': false
49
49
  };
50
+ function isMissingRequiredValueError(error, options) {
51
+ if (error.code !== 'invalid_type') {
52
+ return false;
53
+ }
54
+ let currentValue = options;
55
+ for (const pathSegment of error.path) {
56
+ if (currentValue === null ||
57
+ typeof currentValue !== 'object' ||
58
+ !Object.prototype.hasOwnProperty.call(currentValue, pathSegment)) {
59
+ return true;
60
+ }
61
+ currentValue = currentValue[pathSegment];
62
+ }
63
+ return false;
64
+ }
50
65
  function getConfig() {
51
66
  if (!_config) {
52
67
  _config = new Configstore(config.configstoreName);
@@ -159,15 +174,14 @@ async function execute(rawArgs) {
159
174
  const shouldPrompt = cli.getSettingWithDefaultValue(settingsNames.prompt, true);
160
175
  if (!shouldPrompt) {
161
176
  result.error.issues.forEach(e => {
162
- if (e.code === 'invalid_type' &&
163
- e.input === undefined) {
177
+ if (isMissingRequiredValueError(e, cli.optionsFromArgs.options)) {
164
178
  e.message = `Required option not specified`;
165
179
  }
166
180
  });
167
181
  return cli.closeWithError(result.error, cli.optionsFromArgs, true);
168
182
  }
169
183
  const missingRequiredValuesErrors = result.error.issues
170
- .filter(e => (e.code === 'invalid_type' && e.input === undefined) ||
184
+ .filter(e => isMissingRequiredValueError(e, cli.optionsFromArgs.options) ||
171
185
  (e.code === 'custom' && e.params?.customCode === 'required'));
172
186
  const optionSetErrors = result.error.issues
173
187
  .filter(e => e.code === 'custom' && e.params?.customCode === 'optionSet');
@@ -922,24 +936,11 @@ async function promptForOptionSetNameAndValue(args, options) {
922
936
  await cli.error(`🌶️ Please specify one of the following options:`);
923
937
  const selectedOptionName = await prompt.forSelection({ message: `Option to use:`, choices: options.map((choice) => { return { name: choice, value: choice }; }) });
924
938
  const optionValue = await prompt.forInput({ message: `${selectedOptionName}:` });
925
- let coercedValue = optionValue;
926
- // Basic type coercion to align with how CLI arguments are typically parsed
927
- if (typeof optionValue === 'string') {
928
- const trimmed = optionValue.trim();
929
- if (trimmed === 'true') {
930
- coercedValue = true;
931
- }
932
- else if (trimmed === 'false') {
933
- coercedValue = false;
934
- }
935
- else if (trimmed !== '' && !isNaN(Number(trimmed))) {
936
- coercedValue = Number(trimmed);
937
- }
938
- }
939
+ const parsedOptions = getCommandOptionsFromArgs([`--${selectedOptionName}`, optionValue], cli.commandToExecute);
939
940
  options
940
941
  .filter(optionName => optionName !== selectedOptionName)
941
942
  .forEach(optionName => args.options[optionName] = undefined);
942
- args.options[selectedOptionName] = coercedValue;
943
+ args.options[selectedOptionName] = parsedOptions[selectedOptionName];
943
944
  await cli.error('');
944
945
  }
945
946
  export const cli = {
@@ -1,16 +1,28 @@
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 _SpoEventreceiverGetCommand_instances, _SpoEventreceiverGetCommand_initTelemetry, _SpoEventreceiverGetCommand_initOptions, _SpoEventreceiverGetCommand_initValidators, _SpoEventreceiverGetCommand_initOptionSets;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../../cli/cli.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import request from '../../../../request.js';
9
5
  import { formatting } from '../../../../utils/formatting.js';
10
6
  import { urlUtil } from '../../../../utils/urlUtil.js';
11
7
  import { validation } from '../../../../utils/validation.js';
12
8
  import SpoCommand from '../../../base/SpoCommand.js';
13
9
  import commands from '../../commands.js';
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ webUrl: z.string().refine(url => validation.isValidSharePointUrl(url) === true, {
13
+ error: e => `${e.input} is not a valid SharePoint Online site URL.`
14
+ }).alias('u'),
15
+ listId: z.string().refine(val => validation.isValidGuid(val), {
16
+ error: e => `${e.input} is not a valid GUID.`
17
+ }).optional(),
18
+ listTitle: z.string().optional(),
19
+ listUrl: z.string().optional(),
20
+ id: z.string().refine(val => validation.isValidGuid(val), {
21
+ error: e => `${e.input} is not a valid GUID.`
22
+ }).optional().alias('i'),
23
+ name: z.string().optional().alias('n'),
24
+ scope: z.enum(['web', 'site']).optional().alias('s')
25
+ });
14
26
  class SpoEventreceiverGetCommand extends SpoCommand {
15
27
  get name() {
16
28
  return commands.EVENTRECEIVER_GET;
@@ -18,13 +30,27 @@ class SpoEventreceiverGetCommand extends SpoCommand {
18
30
  get description() {
19
31
  return 'Gets a specific event receiver attached to the web, site or list (if any of the list options are filled in) by receiver name of id';
20
32
  }
21
- constructor() {
22
- super();
23
- _SpoEventreceiverGetCommand_instances.add(this);
24
- __classPrivateFieldGet(this, _SpoEventreceiverGetCommand_instances, "m", _SpoEventreceiverGetCommand_initTelemetry).call(this);
25
- __classPrivateFieldGet(this, _SpoEventreceiverGetCommand_instances, "m", _SpoEventreceiverGetCommand_initOptions).call(this);
26
- __classPrivateFieldGet(this, _SpoEventreceiverGetCommand_instances, "m", _SpoEventreceiverGetCommand_initValidators).call(this);
27
- __classPrivateFieldGet(this, _SpoEventreceiverGetCommand_instances, "m", _SpoEventreceiverGetCommand_initOptionSets).call(this);
33
+ get schema() {
34
+ return options;
35
+ }
36
+ getRefinedSchema(schema) {
37
+ return schema
38
+ .refine(opts => [opts.id, opts.name].filter(x => x !== undefined).length === 1, {
39
+ message: `Specify either 'id' or 'name', but not both.`,
40
+ params: {
41
+ customCode: 'optionSet',
42
+ options: ['id', 'name']
43
+ }
44
+ })
45
+ .refine(opts => {
46
+ const listOptions = [opts.listId, opts.listTitle, opts.listUrl];
47
+ return !(listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1);
48
+ }, {
49
+ message: `Specify either list id or title or list url`
50
+ })
51
+ .refine(opts => !(opts.scope === 'site' && (opts.listId || opts.listUrl || opts.listTitle)), {
52
+ message: 'Scope cannot be set to site when retrieving list event receivers.'
53
+ });
28
54
  }
29
55
  async commandAction(logger, args) {
30
56
  try {
@@ -83,57 +109,5 @@ class SpoEventreceiverGetCommand extends SpoCommand {
83
109
  }
84
110
  }
85
111
  }
86
- _SpoEventreceiverGetCommand_instances = new WeakSet(), _SpoEventreceiverGetCommand_initTelemetry = function _SpoEventreceiverGetCommand_initTelemetry() {
87
- this.telemetry.push((args) => {
88
- Object.assign(this.telemetryProperties, {
89
- listId: typeof args.options.listId !== 'undefined',
90
- listTitle: typeof args.options.listTitle !== 'undefined',
91
- listUrl: typeof args.options.listUrl !== 'undefined',
92
- scope: typeof args.options.scope !== 'undefined',
93
- id: typeof args.options.id !== 'undefined',
94
- name: typeof args.options.name !== 'undefined'
95
- });
96
- });
97
- }, _SpoEventreceiverGetCommand_initOptions = function _SpoEventreceiverGetCommand_initOptions() {
98
- this.options.unshift({
99
- option: '-u, --webUrl <webUrl>'
100
- }, {
101
- option: '--listTitle [listTitle]'
102
- }, {
103
- option: '--listId [listId]'
104
- }, {
105
- option: '--listUrl [listUrl]'
106
- }, {
107
- option: '-n, --name [name]'
108
- }, {
109
- option: '-i, --id [id]'
110
- }, {
111
- option: '-s, --scope [scope]',
112
- autocomplete: ['web', 'site']
113
- });
114
- }, _SpoEventreceiverGetCommand_initValidators = function _SpoEventreceiverGetCommand_initValidators() {
115
- this.validators.push(async (args) => {
116
- const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
117
- if (isValidSharePointUrl !== true) {
118
- return isValidSharePointUrl;
119
- }
120
- const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
121
- if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
122
- return `Specify either list id or title or list url`;
123
- }
124
- if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
125
- return `${args.options.listId} is not a valid GUID`;
126
- }
127
- if (args.options.scope && ['web', 'site'].indexOf(args.options.scope) === -1) {
128
- return `${args.options.scope} is not a valid type value. Allowed values web|site.`;
129
- }
130
- if (args.options.scope && args.options.scope === 'site' && (args.options.listId || args.options.listUrl || args.options.listTitle)) {
131
- return 'Scope cannot be set to site when retrieving list event receivers.';
132
- }
133
- return true;
134
- });
135
- }, _SpoEventreceiverGetCommand_initOptionSets = function _SpoEventreceiverGetCommand_initOptionSets() {
136
- this.optionSets.push({ options: ['name', 'id'] });
137
- };
138
112
  export default new SpoEventreceiverGetCommand();
139
113
  //# sourceMappingURL=eventreceiver-get.js.map
@@ -1,15 +1,23 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _SpoEventreceiverListCommand_instances, _SpoEventreceiverListCommand_initTelemetry, _SpoEventreceiverListCommand_initOptions, _SpoEventreceiverListCommand_initValidators;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import { formatting } from '../../../../utils/formatting.js';
8
4
  import { odata } from '../../../../utils/odata.js';
9
5
  import { urlUtil } from '../../../../utils/urlUtil.js';
10
6
  import { validation } from '../../../../utils/validation.js';
11
7
  import SpoCommand from '../../../base/SpoCommand.js';
12
8
  import commands from '../../commands.js';
9
+ export const options = z.strictObject({
10
+ ...globalOptionsZod.shape,
11
+ webUrl: z.string().refine(url => validation.isValidSharePointUrl(url) === true, {
12
+ error: e => `${e.input} is not a valid SharePoint Online site URL.`
13
+ }).alias('u'),
14
+ listId: z.string().refine(val => validation.isValidGuid(val), {
15
+ error: e => `${e.input} is not a valid GUID.`
16
+ }).optional(),
17
+ listTitle: z.string().optional(),
18
+ listUrl: z.string().optional(),
19
+ scope: z.enum(['web', 'site']).optional().alias('s')
20
+ });
13
21
  class SpoEventreceiverListCommand extends SpoCommand {
14
22
  get name() {
15
23
  return commands.EVENTRECEIVER_LIST;
@@ -20,12 +28,20 @@ class SpoEventreceiverListCommand extends SpoCommand {
20
28
  defaultProperties() {
21
29
  return ['ReceiverId', 'ReceiverName'];
22
30
  }
23
- constructor() {
24
- super();
25
- _SpoEventreceiverListCommand_instances.add(this);
26
- __classPrivateFieldGet(this, _SpoEventreceiverListCommand_instances, "m", _SpoEventreceiverListCommand_initTelemetry).call(this);
27
- __classPrivateFieldGet(this, _SpoEventreceiverListCommand_instances, "m", _SpoEventreceiverListCommand_initOptions).call(this);
28
- __classPrivateFieldGet(this, _SpoEventreceiverListCommand_instances, "m", _SpoEventreceiverListCommand_initValidators).call(this);
31
+ get schema() {
32
+ return options;
33
+ }
34
+ getRefinedSchema(schema) {
35
+ return schema
36
+ .refine(opts => {
37
+ const listOptions = [opts.listId, opts.listTitle, opts.listUrl];
38
+ return !(listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1);
39
+ }, {
40
+ message: `Specify either list id or title or list url`
41
+ })
42
+ .refine(opts => !(opts.scope === 'site' && (opts.listId || opts.listUrl || opts.listTitle)), {
43
+ message: 'Scope cannot be set to site when retrieving list event receivers.'
44
+ });
29
45
  }
30
46
  async commandAction(logger, args) {
31
47
  let requestUrl = `${args.options.webUrl}/_api/`;
@@ -55,49 +71,5 @@ class SpoEventreceiverListCommand extends SpoCommand {
55
71
  }
56
72
  }
57
73
  }
58
- _SpoEventreceiverListCommand_instances = new WeakSet(), _SpoEventreceiverListCommand_initTelemetry = function _SpoEventreceiverListCommand_initTelemetry() {
59
- this.telemetry.push((args) => {
60
- Object.assign(this.telemetryProperties, {
61
- listId: typeof args.options.listId !== 'undefined',
62
- listTitle: typeof args.options.listTitle !== 'undefined',
63
- listUrl: typeof args.options.listUrl !== 'undefined',
64
- scope: typeof args.options.scope !== 'undefined'
65
- });
66
- });
67
- }, _SpoEventreceiverListCommand_initOptions = function _SpoEventreceiverListCommand_initOptions() {
68
- this.options.unshift({
69
- option: '-u, --webUrl <webUrl>'
70
- }, {
71
- option: '--listTitle [listTitle]'
72
- }, {
73
- option: '--listId [listId]'
74
- }, {
75
- option: '--listUrl [listUrl]'
76
- }, {
77
- option: '-s, --scope [scope]',
78
- autocomplete: ['web', 'site']
79
- });
80
- }, _SpoEventreceiverListCommand_initValidators = function _SpoEventreceiverListCommand_initValidators() {
81
- this.validators.push(async (args) => {
82
- const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
83
- if (isValidSharePointUrl !== true) {
84
- return isValidSharePointUrl;
85
- }
86
- const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
87
- if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
88
- return `Specify either list id or title or list url`;
89
- }
90
- if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
91
- return `${args.options.listId} is not a valid GUID`;
92
- }
93
- if (args.options.scope && ['web', 'site'].indexOf(args.options.scope) === -1) {
94
- return `${args.options.scope} is not a valid type value. Allowed values web|site.`;
95
- }
96
- if (args.options.scope && args.options.scope === 'site' && (args.options.listId || args.options.listUrl || args.options.listTitle)) {
97
- return 'Scope cannot be set to site when retrieving list event receivers.';
98
- }
99
- return true;
100
- });
101
- };
102
74
  export default new SpoEventreceiverListCommand();
103
75
  //# sourceMappingURL=eventreceiver-list.js.map
@@ -1,10 +1,6 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _SpoEventreceiverRemoveCommand_instances, _SpoEventreceiverRemoveCommand_initTelemetry, _SpoEventreceiverRemoveCommand_initOptions, _SpoEventreceiverRemoveCommand_initValidators, _SpoEventreceiverRemoveCommand_initOptionSets;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../../cli/cli.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import request from '../../../../request.js';
9
5
  import { formatting } from '../../../../utils/formatting.js';
10
6
  import { urlUtil } from '../../../../utils/urlUtil.js';
@@ -12,6 +8,23 @@ import { validation } from '../../../../utils/validation.js';
12
8
  import SpoCommand from '../../../base/SpoCommand.js';
13
9
  import commands from '../../commands.js';
14
10
  import getCommand from './eventreceiver-get.js';
11
+ export const options = z.strictObject({
12
+ ...globalOptionsZod.shape,
13
+ webUrl: z.string().refine(url => validation.isValidSharePointUrl(url) === true, {
14
+ error: e => `${e.input} is not a valid SharePoint Online site URL.`
15
+ }).alias('u'),
16
+ listId: z.string().refine(val => validation.isValidGuid(val), {
17
+ error: e => `${e.input} is not a valid GUID.`
18
+ }).optional(),
19
+ listTitle: z.string().optional(),
20
+ listUrl: z.string().optional(),
21
+ id: z.string().refine(val => validation.isValidGuid(val), {
22
+ error: e => `${e.input} is not a valid GUID.`
23
+ }).optional().alias('i'),
24
+ name: z.string().optional().alias('n'),
25
+ scope: z.enum(['web', 'site']).optional().alias('s'),
26
+ force: z.boolean().optional().alias('f')
27
+ });
15
28
  class SpoEventreceiverRemoveCommand extends SpoCommand {
16
29
  get name() {
17
30
  return commands.EVENTRECEIVER_REMOVE;
@@ -19,13 +32,27 @@ class SpoEventreceiverRemoveCommand extends SpoCommand {
19
32
  get description() {
20
33
  return 'Removes event receivers for the specified web, site, or list.';
21
34
  }
22
- constructor() {
23
- super();
24
- _SpoEventreceiverRemoveCommand_instances.add(this);
25
- __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initTelemetry).call(this);
26
- __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initOptions).call(this);
27
- __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initValidators).call(this);
28
- __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initOptionSets).call(this);
35
+ get schema() {
36
+ return options;
37
+ }
38
+ getRefinedSchema(schema) {
39
+ return schema
40
+ .refine(opts => [opts.id, opts.name].filter(x => x !== undefined).length === 1, {
41
+ message: `Specify either 'id' or 'name', but not both.`,
42
+ params: {
43
+ customCode: 'optionSet',
44
+ options: ['id', 'name']
45
+ }
46
+ })
47
+ .refine(opts => {
48
+ const listOptions = [opts.listId, opts.listTitle, opts.listUrl];
49
+ return !(listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1);
50
+ }, {
51
+ message: `Specify either list id or title or list url`
52
+ })
53
+ .refine(opts => !(opts.scope === 'site' && (opts.listId || opts.listUrl || opts.listTitle)), {
54
+ message: 'Scope cannot be set to site when retrieving list event receivers.'
55
+ });
29
56
  }
30
57
  async commandAction(logger, args) {
31
58
  if (args.options.force) {
@@ -86,60 +113,5 @@ class SpoEventreceiverRemoveCommand extends SpoCommand {
86
113
  return eventReceiver.ReceiverId;
87
114
  }
88
115
  }
89
- _SpoEventreceiverRemoveCommand_instances = new WeakSet(), _SpoEventreceiverRemoveCommand_initTelemetry = function _SpoEventreceiverRemoveCommand_initTelemetry() {
90
- this.telemetry.push((args) => {
91
- Object.assign(this.telemetryProperties, {
92
- listId: typeof args.options.listId !== 'undefined',
93
- listTitle: typeof args.options.listTitle !== 'undefined',
94
- listUrl: typeof args.options.listUrl !== 'undefined',
95
- scope: args.options.scope || 'web',
96
- id: typeof args.options.id !== 'undefined',
97
- name: typeof args.options.name !== 'undefined',
98
- force: !!args.options.force
99
- });
100
- });
101
- }, _SpoEventreceiverRemoveCommand_initOptions = function _SpoEventreceiverRemoveCommand_initOptions() {
102
- this.options.unshift({
103
- option: '-u, --webUrl <webUrl>'
104
- }, {
105
- option: '--listTitle [listTitle]'
106
- }, {
107
- option: '--listId [listId]'
108
- }, {
109
- option: '--listUrl [listUrl]'
110
- }, {
111
- option: '-n, --name [name]'
112
- }, {
113
- option: '-i, --id [id]'
114
- }, {
115
- option: '-s, --scope [scope]',
116
- autocomplete: ['web', 'site']
117
- }, {
118
- option: '-f, --force'
119
- });
120
- }, _SpoEventreceiverRemoveCommand_initValidators = function _SpoEventreceiverRemoveCommand_initValidators() {
121
- this.validators.push(async (args) => {
122
- const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
123
- if (isValidSharePointUrl !== true) {
124
- return isValidSharePointUrl;
125
- }
126
- const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
127
- if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
128
- return `Specify either list id or title or list url`;
129
- }
130
- if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
131
- return `${args.options.listId} is not a valid GUID`;
132
- }
133
- if (args.options.scope && ['web', 'site'].indexOf(args.options.scope) === -1) {
134
- return `${args.options.scope} is not a valid type value. Allowed values web|site.`;
135
- }
136
- if (args.options.scope && args.options.scope === 'site' && (args.options.listId || args.options.listUrl || args.options.listTitle)) {
137
- return 'Scope cannot be set to site when retrieving list event receivers.';
138
- }
139
- return true;
140
- });
141
- }, _SpoEventreceiverRemoveCommand_initOptionSets = function _SpoEventreceiverRemoveCommand_initOptionSets() {
142
- this.optionSets.push({ options: ['name', 'id'] });
143
- };
144
116
  export default new SpoEventreceiverRemoveCommand();
145
117
  //# sourceMappingURL=eventreceiver-remove.js.map
@@ -1,16 +1,32 @@
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 _SpoExternalUserListCommand_instances, _SpoExternalUserListCommand_initTelemetry, _SpoExternalUserListCommand_initOptions, _SpoExternalUserListCommand_initValidators;
1
+ import { z } from 'zod';
7
2
  import config from '../../../../config.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import request from '../../../../request.js';
9
5
  import { formatting } from '../../../../utils/formatting.js';
10
6
  import { spo } from '../../../../utils/spo.js';
11
7
  import { validation } from '../../../../utils/validation.js';
12
8
  import SpoCommand from '../../../base/SpoCommand.js';
13
9
  import commands from '../../commands.js';
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ filter: z.string().optional(),
13
+ pageSize: z.string().refine(val => {
14
+ const num = parseInt(val);
15
+ return !isNaN(num) && num >= 1 && num <= 50;
16
+ }, {
17
+ error: e => `pageSize must be between 1 and 50. The specified value ${e.input} is not valid.`
18
+ }).optional().alias('p'),
19
+ position: z.string().refine(val => {
20
+ const num = parseInt(val);
21
+ return !isNaN(num) && num >= 0;
22
+ }, {
23
+ error: e => `position must be greater than or equal to 0. The specified value ${e.input} is not valid.`
24
+ }).optional().alias('i'),
25
+ sortOrder: z.enum(['asc', 'desc']).optional().alias('s'),
26
+ siteUrl: z.string().refine(url => validation.isValidSharePointUrl(url) === true, {
27
+ error: e => `${e.input} is not a valid SharePoint Online site URL.`
28
+ }).optional().alias('u')
29
+ });
14
30
  class SpoExternalUserListCommand extends SpoCommand {
15
31
  get name() {
16
32
  return commands.EXTERNALUSER_LIST;
@@ -18,12 +34,8 @@ class SpoExternalUserListCommand extends SpoCommand {
18
34
  get description() {
19
35
  return 'Lists external users in the tenant';
20
36
  }
21
- constructor() {
22
- super();
23
- _SpoExternalUserListCommand_instances.add(this);
24
- __classPrivateFieldGet(this, _SpoExternalUserListCommand_instances, "m", _SpoExternalUserListCommand_initTelemetry).call(this);
25
- __classPrivateFieldGet(this, _SpoExternalUserListCommand_instances, "m", _SpoExternalUserListCommand_initOptions).call(this);
26
- __classPrivateFieldGet(this, _SpoExternalUserListCommand_instances, "m", _SpoExternalUserListCommand_initValidators).call(this);
37
+ get schema() {
38
+ return options;
27
39
  }
28
40
  async commandAction(logger, args) {
29
41
  try {
@@ -69,59 +81,5 @@ class SpoExternalUserListCommand extends SpoCommand {
69
81
  }
70
82
  }
71
83
  }
72
- _SpoExternalUserListCommand_instances = new WeakSet(), _SpoExternalUserListCommand_initTelemetry = function _SpoExternalUserListCommand_initTelemetry() {
73
- this.telemetry.push((args) => {
74
- Object.assign(this.telemetryProperties, {
75
- filter: (!(!args.options.filter)).toString(),
76
- pageSize: (!(!args.options.pageSize)).toString(),
77
- position: (!(!args.options.position)).toString(),
78
- sortOrder: (!(!args.options.sortOrder)).toString(),
79
- siteUrl: (!(!args.options.siteUrl)).toString()
80
- });
81
- });
82
- }, _SpoExternalUserListCommand_initOptions = function _SpoExternalUserListCommand_initOptions() {
83
- this.options.unshift({
84
- option: '--filter [filter]'
85
- }, {
86
- option: '-p, --pageSize [pageSize]'
87
- }, {
88
- option: '-i, --position [position]'
89
- }, {
90
- option: '-s, --sortOrder [sortOrder]',
91
- autocomplete: ['asc', 'desc']
92
- }, {
93
- option: '-u, --siteUrl [siteUrl]'
94
- });
95
- }, _SpoExternalUserListCommand_initValidators = function _SpoExternalUserListCommand_initValidators() {
96
- this.validators.push(async (args) => {
97
- if (args.options.pageSize) {
98
- const pageSize = parseInt(args.options.pageSize);
99
- if (isNaN(pageSize)) {
100
- return `${args.options.pageSize} is not a valid number`;
101
- }
102
- if (pageSize < 1 || pageSize > 50) {
103
- return 'pageSize must be between 1 and 50';
104
- }
105
- }
106
- if (args.options.position) {
107
- const position = parseInt(args.options.position);
108
- if (isNaN(position)) {
109
- return `${args.options.position} is not a valid number`;
110
- }
111
- if (position < 0) {
112
- return 'position must be greater than or 0';
113
- }
114
- }
115
- if (args.options.sortOrder &&
116
- args.options.sortOrder !== 'asc' &&
117
- args.options.sortOrder !== 'desc') {
118
- return `${args.options.sortOrder} is not a valid sortOrder value. Allowed values asc|desc`;
119
- }
120
- if (args.options.siteUrl) {
121
- return validation.isValidSharePointUrl(args.options.siteUrl);
122
- }
123
- return true;
124
- });
125
- };
126
84
  export default new SpoExternalUserListCommand();
127
85
  //# sourceMappingURL=externaluser-list.js.map
@@ -1,13 +1,24 @@
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 _SpoGroupAddCommand_instances, _SpoGroupAddCommand_initTelemetry, _SpoGroupAddCommand_initOptions, _SpoGroupAddCommand_initTypes, _SpoGroupAddCommand_initValidators, _SpoGroupAddCommand_initOptionSets;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import request from '../../../../request.js';
8
4
  import { validation } from '../../../../utils/validation.js';
9
5
  import SpoCommand from '../../../base/SpoCommand.js';
10
6
  import commands from '../../commands.js';
7
+ export const options = z.strictObject({
8
+ ...globalOptionsZod.shape,
9
+ webUrl: z.string()
10
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
11
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
12
+ })
13
+ .alias('u'),
14
+ name: z.string().alias('n'),
15
+ description: z.string().optional(),
16
+ allowMembersEditMembership: z.boolean().optional(),
17
+ onlyAllowMembersViewMembership: z.boolean().optional(),
18
+ allowRequestToJoinLeave: z.boolean().optional(),
19
+ autoAcceptRequestToJoinLeave: z.boolean().optional(),
20
+ requestToJoinLeaveEmailSetting: z.string().optional()
21
+ });
11
22
  class SpoGroupAddCommand extends SpoCommand {
12
23
  get name() {
13
24
  return commands.GROUP_ADD;
@@ -15,14 +26,8 @@ class SpoGroupAddCommand extends SpoCommand {
15
26
  get description() {
16
27
  return 'Creates group in the specified site';
17
28
  }
18
- constructor() {
19
- super();
20
- _SpoGroupAddCommand_instances.add(this);
21
- __classPrivateFieldGet(this, _SpoGroupAddCommand_instances, "m", _SpoGroupAddCommand_initTelemetry).call(this);
22
- __classPrivateFieldGet(this, _SpoGroupAddCommand_instances, "m", _SpoGroupAddCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _SpoGroupAddCommand_instances, "m", _SpoGroupAddCommand_initTypes).call(this);
24
- __classPrivateFieldGet(this, _SpoGroupAddCommand_instances, "m", _SpoGroupAddCommand_initValidators).call(this);
25
- __classPrivateFieldGet(this, _SpoGroupAddCommand_instances, "m", _SpoGroupAddCommand_initOptionSets).call(this);
29
+ get schema() {
30
+ return options;
26
31
  }
27
32
  async commandAction(logger, args) {
28
33
  const requestOptions = {
@@ -50,51 +55,5 @@ class SpoGroupAddCommand extends SpoCommand {
50
55
  }
51
56
  }
52
57
  }
53
- _SpoGroupAddCommand_instances = new WeakSet(), _SpoGroupAddCommand_initTelemetry = function _SpoGroupAddCommand_initTelemetry() {
54
- this.telemetry.push((args) => {
55
- Object.assign(this.telemetryProperties, {
56
- description: typeof args.options.description !== 'undefined',
57
- allowMembersEditMembership: args.options.allowMembersEditMembership,
58
- onlyAllowMembersViewMembership: args.options.onlyAllowMembersViewMembership,
59
- allowRequestToJoinLeave: args.options.allowRequestToJoinLeave,
60
- autoAcceptRequestToJoinLeave: args.options.autoAcceptRequestToJoinLeave,
61
- requestToJoinLeaveEmailSetting: typeof args.options.requestToJoinLeaveEmailSetting !== 'undefined'
62
- });
63
- });
64
- }, _SpoGroupAddCommand_initOptions = function _SpoGroupAddCommand_initOptions() {
65
- this.options.unshift({
66
- option: '-u, --webUrl <webUrl>'
67
- }, {
68
- option: '-n, --name <name>'
69
- }, {
70
- option: '--description [description]'
71
- }, {
72
- option: '--allowMembersEditMembership [allowMembersEditMembership]',
73
- autocomplete: ['true', 'false']
74
- }, {
75
- option: '--onlyAllowMembersViewMembership [onlyAllowMembersViewMembership]',
76
- autocomplete: ['true', 'false']
77
- }, {
78
- option: '--allowRequestToJoinLeave [allowRequestToJoinLeave]',
79
- autocomplete: ['true', 'false']
80
- }, {
81
- option: '--autoAcceptRequestToJoinLeave [autoAcceptRequestToJoinLeave]',
82
- autocomplete: ['true', 'false']
83
- }, {
84
- option: '--requestToJoinLeaveEmailSetting [requestToJoinLeaveEmailSetting]'
85
- });
86
- }, _SpoGroupAddCommand_initTypes = function _SpoGroupAddCommand_initTypes() {
87
- this.types.boolean.push('allowMembersEditMembership', 'onlyAllowMembersViewMembership', 'allowRequestToJoinLeave', 'autoAcceptRequestToJoinLeave');
88
- }, _SpoGroupAddCommand_initValidators = function _SpoGroupAddCommand_initValidators() {
89
- this.validators.push(async (args) => {
90
- const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
91
- if (isValidSharePointUrl !== true) {
92
- return isValidSharePointUrl;
93
- }
94
- return true;
95
- });
96
- }, _SpoGroupAddCommand_initOptionSets = function _SpoGroupAddCommand_initOptionSets() {
97
- this.optionSets.push({ options: ['id', 'name'] });
98
- };
99
58
  export default new SpoGroupAddCommand();
100
59
  //# sourceMappingURL=group-add.js.map