@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
@@ -1,15 +1,30 @@
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 _SpoGroupSetCommand_instances, _SpoGroupSetCommand_initTelemetry, _SpoGroupSetCommand_initOptions, _SpoGroupSetCommand_initTypes, _SpoGroupSetCommand_initValidators, _SpoGroupSetCommand_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 { validation } from '../../../../utils/validation.js';
10
6
  import entraUserGetCommand from '../../../entra/commands/user/user-get.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()
12
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
13
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
14
+ })
15
+ .alias('u'),
16
+ id: z.coerce.number().int().positive().optional().alias('i'),
17
+ name: z.string().optional().alias('n'),
18
+ newName: z.string().optional(),
19
+ description: z.string().optional(),
20
+ allowMembersEditMembership: z.boolean().optional(),
21
+ onlyAllowMembersViewMembership: z.boolean().optional(),
22
+ allowRequestToJoinLeave: z.boolean().optional(),
23
+ autoAcceptRequestToJoinLeave: z.boolean().optional(),
24
+ requestToJoinLeaveEmailSetting: z.string().optional(),
25
+ ownerEmail: z.string().optional(),
26
+ ownerUserName: z.string().optional()
27
+ });
13
28
  class SpoGroupSetCommand extends SpoCommand {
14
29
  get name() {
15
30
  return commands.GROUP_SET;
@@ -17,14 +32,21 @@ class SpoGroupSetCommand extends SpoCommand {
17
32
  get description() {
18
33
  return 'Updates a group in the specified site';
19
34
  }
20
- constructor() {
21
- super();
22
- _SpoGroupSetCommand_instances.add(this);
23
- __classPrivateFieldGet(this, _SpoGroupSetCommand_instances, "m", _SpoGroupSetCommand_initTelemetry).call(this);
24
- __classPrivateFieldGet(this, _SpoGroupSetCommand_instances, "m", _SpoGroupSetCommand_initOptions).call(this);
25
- __classPrivateFieldGet(this, _SpoGroupSetCommand_instances, "m", _SpoGroupSetCommand_initTypes).call(this);
26
- __classPrivateFieldGet(this, _SpoGroupSetCommand_instances, "m", _SpoGroupSetCommand_initValidators).call(this);
27
- __classPrivateFieldGet(this, _SpoGroupSetCommand_instances, "m", _SpoGroupSetCommand_initOptionSets).call(this);
35
+ get schema() {
36
+ return options;
37
+ }
38
+ getRefinedSchema(schema) {
39
+ return schema
40
+ .refine(o => [o.id, o.name].filter(x => x !== undefined).length === 1, {
41
+ error: `Specify either 'id' or 'name', but not both.`,
42
+ params: {
43
+ customCode: 'optionSet',
44
+ options: ['id', 'name']
45
+ }
46
+ })
47
+ .refine(o => [o.ownerEmail, o.ownerUserName].filter(x => x !== undefined).length <= 1, {
48
+ error: `Specify either 'ownerEmail' or 'ownerUserName', but not both.`
49
+ });
28
50
  }
29
51
  async commandAction(logger, args) {
30
52
  if (this.verbose) {
@@ -91,70 +113,5 @@ class SpoGroupSetCommand extends SpoCommand {
91
113
  return response.Id;
92
114
  }
93
115
  }
94
- _SpoGroupSetCommand_instances = new WeakSet(), _SpoGroupSetCommand_initTelemetry = function _SpoGroupSetCommand_initTelemetry() {
95
- this.telemetry.push((args) => {
96
- Object.assign(this.telemetryProperties, {
97
- id: typeof args.options.id !== 'undefined',
98
- name: typeof args.options.name !== 'undefined',
99
- newName: typeof args.options.newName !== 'undefined',
100
- description: typeof args.options.description !== 'undefined',
101
- allowMembersEditMembership: args.options.allowMembersEditMembership,
102
- onlyAllowMembersViewMembership: args.options.onlyAllowMembersViewMembership,
103
- allowRequestToJoinLeave: args.options.allowRequestToJoinLeave,
104
- autoAcceptRequestToJoinLeave: args.options.autoAcceptRequestToJoinLeave,
105
- requestToJoinLeaveEmailSetting: typeof args.options.requestToJoinLeaveEmailSetting !== 'undefined',
106
- ownerEmail: typeof args.options.ownerEmail !== 'undefined',
107
- ownerUserName: typeof args.options.ownerUserName !== 'undefined'
108
- });
109
- });
110
- }, _SpoGroupSetCommand_initOptions = function _SpoGroupSetCommand_initOptions() {
111
- this.options.unshift({
112
- option: '-u, --webUrl <webUrl>'
113
- }, {
114
- option: '-i, --id [id]'
115
- }, {
116
- option: '-n, --name [name]'
117
- }, {
118
- option: '--newName [newName]'
119
- }, {
120
- option: '--description [description]'
121
- }, {
122
- option: '--allowMembersEditMembership [allowMembersEditMembership]',
123
- autocomplete: ['true', 'false']
124
- }, {
125
- option: '--onlyAllowMembersViewMembership [onlyAllowMembersViewMembership]',
126
- autocomplete: ['true', 'false']
127
- }, {
128
- option: '--allowRequestToJoinLeave [allowRequestToJoinLeave]',
129
- autocomplete: ['true', 'false']
130
- }, {
131
- option: '--autoAcceptRequestToJoinLeave [autoAcceptRequestToJoinLeave]',
132
- autocomplete: ['true', 'false']
133
- }, {
134
- option: '--requestToJoinLeaveEmailSetting [requestToJoinLeaveEmailSetting]'
135
- }, {
136
- option: '--ownerEmail [ownerEmail]'
137
- }, {
138
- option: '--ownerUserName [ownerUserName]'
139
- });
140
- }, _SpoGroupSetCommand_initTypes = function _SpoGroupSetCommand_initTypes() {
141
- this.types.boolean.push('allowMembersEditMembership', 'onlyAllowMembersViewMembership', 'allowRequestToJoinLeave', 'autoAcceptRequestToJoinLeave');
142
- }, _SpoGroupSetCommand_initValidators = function _SpoGroupSetCommand_initValidators() {
143
- this.validators.push(async (args) => {
144
- const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
145
- if (isValidSharePointUrl !== true) {
146
- return isValidSharePointUrl;
147
- }
148
- if (args.options.id && isNaN(args.options.id)) {
149
- return `Specified id ${args.options.id} is not a number`;
150
- }
151
- if (args.options.ownerEmail && args.options.ownerUserName) {
152
- return 'Specify either ownerEmail or ownerUserName but not both';
153
- }
154
- return true;
155
- });
156
- }, _SpoGroupSetCommand_initOptionSets = function _SpoGroupSetCommand_initOptionSets() {
157
- this.optionSets.push({ options: ['id', 'name'] });
158
- };
159
116
  export default new SpoGroupSetCommand();
160
117
  //# sourceMappingURL=group-set.js.map
@@ -1,13 +1,19 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _SpoPropertyBagGetCommand_instances, _SpoPropertyBagGetCommand_initTelemetry, _SpoPropertyBagGetCommand_initOptions, _SpoPropertyBagGetCommand_initValidators;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import { spo } from '../../../../utils/spo.js';
8
4
  import { validation } from '../../../../utils/validation.js';
9
5
  import commands from '../../commands.js';
10
6
  import { SpoPropertyBagBaseCommand } from './propertybag-base.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
+ key: z.string().alias('k'),
15
+ folder: z.string().optional()
16
+ });
11
17
  class SpoPropertyBagGetCommand extends SpoPropertyBagBaseCommand {
12
18
  get name() {
13
19
  return commands.PROPERTYBAG_GET;
@@ -15,12 +21,8 @@ class SpoPropertyBagGetCommand extends SpoPropertyBagBaseCommand {
15
21
  get description() {
16
22
  return 'Gets the value of the specified property from the property bag';
17
23
  }
18
- constructor() {
19
- super();
20
- _SpoPropertyBagGetCommand_instances.add(this);
21
- __classPrivateFieldGet(this, _SpoPropertyBagGetCommand_instances, "m", _SpoPropertyBagGetCommand_initTelemetry).call(this);
22
- __classPrivateFieldGet(this, _SpoPropertyBagGetCommand_instances, "m", _SpoPropertyBagGetCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _SpoPropertyBagGetCommand_instances, "m", _SpoPropertyBagGetCommand_initValidators).call(this);
24
+ get schema() {
25
+ return options;
24
26
  }
25
27
  async commandAction(logger, args) {
26
28
  try {
@@ -61,22 +63,5 @@ class SpoPropertyBagGetCommand extends SpoPropertyBagBaseCommand {
61
63
  return null;
62
64
  }
63
65
  }
64
- _SpoPropertyBagGetCommand_instances = new WeakSet(), _SpoPropertyBagGetCommand_initTelemetry = function _SpoPropertyBagGetCommand_initTelemetry() {
65
- this.telemetry.push((args) => {
66
- Object.assign(this.telemetryProperties, {
67
- folder: typeof args.options.folder !== 'undefined'
68
- });
69
- });
70
- }, _SpoPropertyBagGetCommand_initOptions = function _SpoPropertyBagGetCommand_initOptions() {
71
- this.options.unshift({
72
- option: '-u, --webUrl <webUrl>'
73
- }, {
74
- option: '-k, --key <key>'
75
- }, {
76
- option: '--folder [folder]'
77
- });
78
- }, _SpoPropertyBagGetCommand_initValidators = function _SpoPropertyBagGetCommand_initValidators() {
79
- this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.webUrl));
80
- };
81
66
  export default new SpoPropertyBagGetCommand();
82
67
  //# sourceMappingURL=propertybag-get.js.map
@@ -1,13 +1,18 @@
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 _SpoPropertyBagListCommand_instances, _SpoPropertyBagListCommand_initTelemetry, _SpoPropertyBagListCommand_initOptions, _SpoPropertyBagListCommand_initValidators;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import { spo } from '../../../../utils/spo.js';
8
4
  import { validation } from '../../../../utils/validation.js';
9
5
  import commands from '../../commands.js';
10
6
  import { SpoPropertyBagBaseCommand } from './propertybag-base.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
+ folder: z.string().optional()
15
+ });
11
16
  class SpoPropertyBagListCommand extends SpoPropertyBagBaseCommand {
12
17
  get name() {
13
18
  return commands.PROPERTYBAG_LIST;
@@ -15,12 +20,8 @@ class SpoPropertyBagListCommand extends SpoPropertyBagBaseCommand {
15
20
  get description() {
16
21
  return 'Gets property bag values';
17
22
  }
18
- constructor() {
19
- super();
20
- _SpoPropertyBagListCommand_instances.add(this);
21
- __classPrivateFieldGet(this, _SpoPropertyBagListCommand_instances, "m", _SpoPropertyBagListCommand_initTelemetry).call(this);
22
- __classPrivateFieldGet(this, _SpoPropertyBagListCommand_instances, "m", _SpoPropertyBagListCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _SpoPropertyBagListCommand_instances, "m", _SpoPropertyBagListCommand_initValidators).call(this);
23
+ get schema() {
24
+ return options;
24
25
  }
25
26
  async commandAction(logger, args) {
26
27
  try {
@@ -61,20 +62,5 @@ class SpoPropertyBagListCommand extends SpoPropertyBagBaseCommand {
61
62
  return result;
62
63
  }
63
64
  }
64
- _SpoPropertyBagListCommand_instances = new WeakSet(), _SpoPropertyBagListCommand_initTelemetry = function _SpoPropertyBagListCommand_initTelemetry() {
65
- this.telemetry.push((args) => {
66
- Object.assign(this.telemetryProperties, {
67
- folder: typeof args.options.folder !== 'undefined'
68
- });
69
- });
70
- }, _SpoPropertyBagListCommand_initOptions = function _SpoPropertyBagListCommand_initOptions() {
71
- this.options.unshift({
72
- option: '-u, --webUrl <webUrl>'
73
- }, {
74
- option: '--folder [folder]'
75
- });
76
- }, _SpoPropertyBagListCommand_initValidators = function _SpoPropertyBagListCommand_initValidators() {
77
- this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.webUrl));
78
- };
79
65
  export default new SpoPropertyBagListCommand();
80
66
  //# sourceMappingURL=propertybag-list.js.map
@@ -1,17 +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 _SpoPropertyBagRemoveCommand_instances, _SpoPropertyBagRemoveCommand_initTelemetry, _SpoPropertyBagRemoveCommand_initOptions, _SpoPropertyBagRemoveCommand_initValidators;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../../cli/cli.js';
8
3
  import config from '../../../../config.js';
4
+ import { globalOptionsZod } from '../../../../Command.js';
9
5
  import request from '../../../../request.js';
10
6
  import { formatting } from '../../../../utils/formatting.js';
11
7
  import { spo } from '../../../../utils/spo.js';
12
8
  import { validation } from '../../../../utils/validation.js';
13
9
  import commands from '../../commands.js';
14
10
  import { SpoPropertyBagBaseCommand } from './propertybag-base.js';
11
+ export const options = z.strictObject({
12
+ ...globalOptionsZod.shape,
13
+ webUrl: z.string()
14
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
15
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
16
+ })
17
+ .alias('u'),
18
+ key: z.string().alias('k'),
19
+ folder: z.string().optional(),
20
+ force: z.boolean().optional().alias('f')
21
+ });
15
22
  class SpoPropertyBagRemoveCommand extends SpoPropertyBagBaseCommand {
16
23
  get name() {
17
24
  return commands.PROPERTYBAG_REMOVE;
@@ -19,12 +26,8 @@ class SpoPropertyBagRemoveCommand extends SpoPropertyBagBaseCommand {
19
26
  get description() {
20
27
  return 'Removes specified property from the property bag';
21
28
  }
22
- constructor() {
23
- super();
24
- _SpoPropertyBagRemoveCommand_instances.add(this);
25
- __classPrivateFieldGet(this, _SpoPropertyBagRemoveCommand_instances, "m", _SpoPropertyBagRemoveCommand_initTelemetry).call(this);
26
- __classPrivateFieldGet(this, _SpoPropertyBagRemoveCommand_instances, "m", _SpoPropertyBagRemoveCommand_initOptions).call(this);
27
- __classPrivateFieldGet(this, _SpoPropertyBagRemoveCommand_instances, "m", _SpoPropertyBagRemoveCommand_initValidators).call(this);
29
+ get schema() {
30
+ return options;
28
31
  }
29
32
  async commandAction(logger, args) {
30
33
  if (args.options.force) {
@@ -76,25 +79,5 @@ class SpoPropertyBagRemoveCommand extends SpoPropertyBagBaseCommand {
76
79
  }
77
80
  }
78
81
  }
79
- _SpoPropertyBagRemoveCommand_instances = new WeakSet(), _SpoPropertyBagRemoveCommand_initTelemetry = function _SpoPropertyBagRemoveCommand_initTelemetry() {
80
- this.telemetry.push((args) => {
81
- Object.assign(this.telemetryProperties, {
82
- folder: (!(!args.options.folder)).toString(),
83
- force: args.options.force === true
84
- });
85
- });
86
- }, _SpoPropertyBagRemoveCommand_initOptions = function _SpoPropertyBagRemoveCommand_initOptions() {
87
- this.options.unshift({
88
- option: '-u, --webUrl <webUrl>'
89
- }, {
90
- option: '-k, --key <key>'
91
- }, {
92
- option: '--folder [folder]'
93
- }, {
94
- option: '-f, --force'
95
- });
96
- }, _SpoPropertyBagRemoveCommand_initValidators = function _SpoPropertyBagRemoveCommand_initValidators() {
97
- this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.webUrl));
98
- };
99
82
  export default new SpoPropertyBagRemoveCommand();
100
83
  //# sourceMappingURL=propertybag-remove.js.map
@@ -1,13 +1,20 @@
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 _SpoPropertyBagSetCommand_instances, _SpoPropertyBagSetCommand_initTelemetry, _SpoPropertyBagSetCommand_initOptions, _SpoPropertyBagSetCommand_initValidators;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import { spo } from '../../../../utils/spo.js';
8
4
  import { validation } from '../../../../utils/validation.js';
9
5
  import commands from '../../commands.js';
10
6
  import { SpoPropertyBagBaseCommand } from './propertybag-base.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
+ key: z.string().alias('k'),
15
+ value: z.string().alias('v'),
16
+ folder: z.string().optional()
17
+ });
11
18
  class SpoPropertyBagSetCommand extends SpoPropertyBagBaseCommand {
12
19
  get name() {
13
20
  return commands.PROPERTYBAG_SET;
@@ -15,12 +22,8 @@ class SpoPropertyBagSetCommand extends SpoPropertyBagBaseCommand {
15
22
  get description() {
16
23
  return 'Sets the value of the specified property in the property bag. Adds the property if it does not exist';
17
24
  }
18
- constructor() {
19
- super();
20
- _SpoPropertyBagSetCommand_instances.add(this);
21
- __classPrivateFieldGet(this, _SpoPropertyBagSetCommand_instances, "m", _SpoPropertyBagSetCommand_initTelemetry).call(this);
22
- __classPrivateFieldGet(this, _SpoPropertyBagSetCommand_instances, "m", _SpoPropertyBagSetCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _SpoPropertyBagSetCommand_instances, "m", _SpoPropertyBagSetCommand_initValidators).call(this);
25
+ get schema() {
26
+ return options;
24
27
  }
25
28
  async commandAction(logger, args) {
26
29
  try {
@@ -46,24 +49,5 @@ class SpoPropertyBagSetCommand extends SpoPropertyBagBaseCommand {
46
49
  return SpoPropertyBagBaseCommand.setProperty(options.key, options.value, options.webUrl, this.formDigestValue, identityResp, logger, this.debug, options.folder);
47
50
  }
48
51
  }
49
- _SpoPropertyBagSetCommand_instances = new WeakSet(), _SpoPropertyBagSetCommand_initTelemetry = function _SpoPropertyBagSetCommand_initTelemetry() {
50
- this.telemetry.push((args) => {
51
- Object.assign(this.telemetryProperties, {
52
- folder: typeof args.options.folder !== 'undefined'
53
- });
54
- });
55
- }, _SpoPropertyBagSetCommand_initOptions = function _SpoPropertyBagSetCommand_initOptions() {
56
- this.options.unshift({
57
- option: '-u, --webUrl <webUrl>'
58
- }, {
59
- option: '-k, --key <key>'
60
- }, {
61
- option: '-v, --value <value>'
62
- }, {
63
- option: '--folder [folder]'
64
- });
65
- }, _SpoPropertyBagSetCommand_initValidators = function _SpoPropertyBagSetCommand_initValidators() {
66
- this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.webUrl));
67
- };
68
52
  export default new SpoPropertyBagSetCommand();
69
53
  //# sourceMappingURL=propertybag-set.js.map
@@ -1,14 +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 _SpoRoleDefinitionAddCommand_instances, _SpoRoleDefinitionAddCommand_initTelemetry, _SpoRoleDefinitionAddCommand_initOptions, _SpoRoleDefinitionAddCommand_initValidators;
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 { BasePermissions, PermissionKind } from '../../base-permissions.js';
11
7
  import commands from '../../commands.js';
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ webUrl: z.string()
11
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
12
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
13
+ })
14
+ .alias('u'),
15
+ name: z.string().alias('n'),
16
+ description: z.string().optional().alias('d'),
17
+ rights: z.string()
18
+ .optional()
19
+ .autocomplete(Object.keys(PermissionKind)
20
+ .filter(kind => typeof PermissionKind[kind] === 'number'))
21
+ });
12
22
  class SpoRoleDefinitionAddCommand extends SpoCommand {
13
23
  get name() {
14
24
  return commands.ROLEDEFINITION_ADD;
@@ -16,6 +26,9 @@ class SpoRoleDefinitionAddCommand extends SpoCommand {
16
26
  get description() {
17
27
  return 'Adds a new roledefinition to web';
18
28
  }
29
+ get schema() {
30
+ return options;
31
+ }
19
32
  get permissionsKindMap() {
20
33
  const result = [];
21
34
  for (const kind in PermissionKind) {
@@ -25,12 +38,32 @@ class SpoRoleDefinitionAddCommand extends SpoCommand {
25
38
  }
26
39
  return result;
27
40
  }
28
- constructor() {
29
- super();
30
- _SpoRoleDefinitionAddCommand_instances.add(this);
31
- __classPrivateFieldGet(this, _SpoRoleDefinitionAddCommand_instances, "m", _SpoRoleDefinitionAddCommand_initTelemetry).call(this);
32
- __classPrivateFieldGet(this, _SpoRoleDefinitionAddCommand_instances, "m", _SpoRoleDefinitionAddCommand_initOptions).call(this);
33
- __classPrivateFieldGet(this, _SpoRoleDefinitionAddCommand_instances, "m", _SpoRoleDefinitionAddCommand_initValidators).call(this);
41
+ getRefinedSchema(schema) {
42
+ return schema
43
+ .refine((opts) => {
44
+ if (!opts.rights) {
45
+ return true;
46
+ }
47
+ const rights = opts.rights.split(',');
48
+ for (const item of rights) {
49
+ const kind = PermissionKind[item.trim()];
50
+ if (!kind) {
51
+ return false;
52
+ }
53
+ }
54
+ return true;
55
+ }, {
56
+ error: (e) => {
57
+ const rights = e.input.rights.split(',');
58
+ const invalid = rights.filter((item) => {
59
+ const kind = PermissionKind[item.trim()];
60
+ return !kind;
61
+ });
62
+ return {
63
+ message: `Rights option '${invalid[0]}' is not recognized as valid PermissionKind choice. Please note it is case-sensitive. Allowed values are ${this.permissionsKindMap.join('|')}.`
64
+ };
65
+ }
66
+ });
34
67
  }
35
68
  async commandAction(logger, args) {
36
69
  if (this.verbose) {
@@ -68,37 +101,5 @@ class SpoRoleDefinitionAddCommand extends SpoCommand {
68
101
  }
69
102
  }
70
103
  }
71
- _SpoRoleDefinitionAddCommand_instances = new WeakSet(), _SpoRoleDefinitionAddCommand_initTelemetry = function _SpoRoleDefinitionAddCommand_initTelemetry() {
72
- this.telemetry.push((args) => {
73
- Object.assign(this.telemetryProperties, {
74
- rights: args.options.rights,
75
- description: (!(!args.options.description)).toString()
76
- });
77
- });
78
- }, _SpoRoleDefinitionAddCommand_initOptions = function _SpoRoleDefinitionAddCommand_initOptions() {
79
- this.options.unshift({
80
- option: '-u, --webUrl <webUrl>'
81
- }, {
82
- option: '-n, --name <name>'
83
- }, {
84
- option: '-d, --description [description]'
85
- }, {
86
- option: '--rights [rights]',
87
- autocomplete: this.permissionsKindMap
88
- });
89
- }, _SpoRoleDefinitionAddCommand_initValidators = function _SpoRoleDefinitionAddCommand_initValidators() {
90
- this.validators.push(async (args) => {
91
- if (args.options.rights) {
92
- const rights = args.options.rights.split(',');
93
- for (const item of rights) {
94
- const kind = PermissionKind[item.trim()];
95
- if (!kind) {
96
- return `Rights option '${item}' is not recognized as valid PermissionKind choice. Please note it is case-sensitive. Allowed values are ${this.permissionsKindMap.join('|')}.`;
97
- }
98
- }
99
- }
100
- return validation.isValidSharePointUrl(args.options.webUrl);
101
- });
102
- };
103
104
  export default new SpoRoleDefinitionAddCommand();
104
105
  //# sourceMappingURL=roledefinition-add.js.map
@@ -1,15 +1,21 @@
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 _SpoRoleDefinitionGetCommand_instances, _SpoRoleDefinitionGetCommand_initOptions, _SpoRoleDefinitionGetCommand_initValidators;
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 { BasePermissions } from '../../base-permissions.js';
11
7
  import commands from '../../commands.js';
12
8
  import { RoleType } from './RoleType.js';
9
+ export const options = z.strictObject({
10
+ ...globalOptionsZod.shape,
11
+ webUrl: z.string()
12
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
13
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
14
+ })
15
+ .alias('u'),
16
+ id: z.coerce.number()
17
+ .alias('i')
18
+ });
13
19
  class SpoRoleDefinitionGetCommand extends SpoCommand {
14
20
  get name() {
15
21
  return commands.ROLEDEFINITION_GET;
@@ -17,11 +23,8 @@ class SpoRoleDefinitionGetCommand extends SpoCommand {
17
23
  get description() {
18
24
  return 'Gets specified role definition from web by id';
19
25
  }
20
- constructor() {
21
- super();
22
- _SpoRoleDefinitionGetCommand_instances.add(this);
23
- __classPrivateFieldGet(this, _SpoRoleDefinitionGetCommand_instances, "m", _SpoRoleDefinitionGetCommand_initOptions).call(this);
24
- __classPrivateFieldGet(this, _SpoRoleDefinitionGetCommand_instances, "m", _SpoRoleDefinitionGetCommand_initValidators).call(this);
26
+ get schema() {
27
+ return options;
25
28
  }
26
29
  async commandAction(logger, args) {
27
30
  if (this.verbose) {
@@ -48,19 +51,5 @@ class SpoRoleDefinitionGetCommand extends SpoCommand {
48
51
  }
49
52
  }
50
53
  }
51
- _SpoRoleDefinitionGetCommand_instances = new WeakSet(), _SpoRoleDefinitionGetCommand_initOptions = function _SpoRoleDefinitionGetCommand_initOptions() {
52
- this.options.unshift({
53
- option: '-u, --webUrl <webUrl>'
54
- }, {
55
- option: '-i, --id <id>'
56
- });
57
- }, _SpoRoleDefinitionGetCommand_initValidators = function _SpoRoleDefinitionGetCommand_initValidators() {
58
- this.validators.push(async (args) => {
59
- if (isNaN(args.options.id)) {
60
- return `${args.options.id} is not a number`;
61
- }
62
- return validation.isValidSharePointUrl(args.options.webUrl);
63
- });
64
- };
65
54
  export default new SpoRoleDefinitionGetCommand();
66
55
  //# sourceMappingURL=roledefinition-get.js.map
@@ -1,14 +1,18 @@
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 _SpoRoleDefinitionListCommand_instances, _SpoRoleDefinitionListCommand_initOptions, _SpoRoleDefinitionListCommand_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 { validation } from '../../../../utils/validation.js';
10
6
  import SpoCommand from '../../../base/SpoCommand.js';
11
7
  import commands from '../../commands.js';
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ webUrl: z.string()
11
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
12
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
13
+ })
14
+ .alias('u')
15
+ });
12
16
  class SpoRoleDefinitionListCommand extends SpoCommand {
13
17
  get name() {
14
18
  return commands.ROLEDEFINITION_LIST;
@@ -19,11 +23,8 @@ class SpoRoleDefinitionListCommand extends SpoCommand {
19
23
  defaultProperties() {
20
24
  return ['Id', 'Name'];
21
25
  }
22
- constructor() {
23
- super();
24
- _SpoRoleDefinitionListCommand_instances.add(this);
25
- __classPrivateFieldGet(this, _SpoRoleDefinitionListCommand_instances, "m", _SpoRoleDefinitionListCommand_initOptions).call(this);
26
- __classPrivateFieldGet(this, _SpoRoleDefinitionListCommand_instances, "m", _SpoRoleDefinitionListCommand_initValidators).call(this);
26
+ get schema() {
27
+ return options;
27
28
  }
28
29
  async commandAction(logger, args) {
29
30
  if (this.verbose) {
@@ -39,12 +40,5 @@ class SpoRoleDefinitionListCommand extends SpoCommand {
39
40
  }
40
41
  }
41
42
  }
42
- _SpoRoleDefinitionListCommand_instances = new WeakSet(), _SpoRoleDefinitionListCommand_initOptions = function _SpoRoleDefinitionListCommand_initOptions() {
43
- this.options.unshift({
44
- option: '-u, --webUrl <webUrl>'
45
- });
46
- }, _SpoRoleDefinitionListCommand_initValidators = function _SpoRoleDefinitionListCommand_initValidators() {
47
- this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.webUrl));
48
- };
49
43
  export default new SpoRoleDefinitionListCommand();
50
44
  //# sourceMappingURL=roledefinition-list.js.map