@pnp/cli-microsoft365 11.9.0-beta.8c1ee05 → 11.9.0-beta.93bd508

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 (73) hide show
  1. package/.devproxy/api-specs/sharepoint.yaml +82 -0
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/m365/cli/commands/app/app-reconsent.js +8 -0
  5. package/dist/m365/cli/commands/cli-consent.js +8 -31
  6. package/dist/m365/cli/commands/cli-doctor.js +6 -1
  7. package/dist/m365/cli/commands/cli-issue.js +8 -36
  8. package/dist/m365/cli/commands/completion/completion-clink-update.js +8 -0
  9. package/dist/m365/cli/commands/completion/completion-pwsh-setup.js +8 -16
  10. package/dist/m365/cli/commands/completion/completion-pwsh-update.js +8 -0
  11. package/dist/m365/cli/commands/completion/completion-sh-setup.js +8 -0
  12. package/dist/m365/cli/commands/completion/completion-sh-update.js +8 -0
  13. package/dist/m365/cli/commands/config/config-get.js +9 -32
  14. package/dist/m365/cli/commands/config/config-list.js +8 -0
  15. package/dist/m365/cli/commands/config/config-reset.js +9 -34
  16. package/dist/m365/cli/commands/config/config-set.js +86 -70
  17. package/dist/m365/commands/request.js +26 -60
  18. package/dist/m365/commands/search.js +59 -77
  19. package/dist/m365/commands/setup.js +16 -31
  20. package/dist/m365/commands/version.js +6 -0
  21. package/dist/m365/connection/commands/connection-remove.js +9 -29
  22. package/dist/m365/connection/commands/connection-use.js +8 -26
  23. package/dist/m365/context/commands/context-init.js +6 -0
  24. package/dist/m365/context/commands/option/option-set.js +9 -18
  25. package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-add.js +32 -63
  26. package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-get.js +21 -45
  27. package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-list.js +32 -53
  28. package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-remove.js +34 -74
  29. package/dist/m365/entra/commands/administrativeunit/administrativeunit-roleassignment-add.js +37 -57
  30. package/dist/m365/entra/commands/multitenant/multitenant-get.js +8 -1
  31. package/dist/m365/entra/commands/multitenant/multitenant-remove.js +8 -22
  32. package/dist/m365/entra/commands/multitenant/multitenant-set.js +15 -36
  33. package/dist/m365/entra/commands/oauth2grant/oauth2grant-add.js +10 -31
  34. package/dist/m365/entra/commands/oauth2grant/oauth2grant-list.js +8 -24
  35. package/dist/m365/entra/commands/oauth2grant/oauth2grant-remove.js +9 -17
  36. package/dist/m365/entra/commands/oauth2grant/oauth2grant-set.js +9 -17
  37. package/dist/m365/outlook/commands/calendar/calendar-get.js +1 -1
  38. package/dist/m365/spe/commands/container/container-get.js +54 -26
  39. package/dist/m365/spe/commands/container/container-permission-list.js +43 -4
  40. package/dist/m365/spe/commands/container/container-set.js +77 -0
  41. package/dist/m365/spe/commands.js +1 -0
  42. package/dist/m365/spo/commands/file/file-unarchive.js +83 -0
  43. package/dist/m365/spo/commands/folder/folder-archive.js +89 -0
  44. package/dist/m365/spo/commands.js +2 -0
  45. package/dist/m365/viva/commands/engage/engage-role-member-add.js +79 -0
  46. package/dist/m365/viva/commands.js +1 -0
  47. package/docs/docs/cmd/outlook/calendar/calendar-get.mdx +7 -7
  48. package/docs/docs/cmd/spe/container/container-get.mdx +24 -3
  49. package/docs/docs/cmd/spe/container/container-permission-list.mdx +24 -3
  50. package/docs/docs/cmd/spe/container/container-set.mdx +160 -0
  51. package/docs/docs/cmd/spo/app/app-add.mdx +19 -0
  52. package/docs/docs/cmd/spo/app/app-deploy.mdx +21 -0
  53. package/docs/docs/cmd/spo/app/app-get.mdx +19 -0
  54. package/docs/docs/cmd/spo/app/app-install.mdx +21 -0
  55. package/docs/docs/cmd/spo/app/app-instance-list.mdx +19 -0
  56. package/docs/docs/cmd/spo/app/app-list.mdx +19 -0
  57. package/docs/docs/cmd/spo/app/app-remove.mdx +21 -0
  58. package/docs/docs/cmd/spo/app/app-retract.mdx +21 -0
  59. package/docs/docs/cmd/spo/app/app-teamspackage-download.mdx +21 -0
  60. package/docs/docs/cmd/spo/app/app-uninstall.mdx +21 -0
  61. package/docs/docs/cmd/spo/app/app-upgrade.mdx +21 -0
  62. package/docs/docs/cmd/spo/apppage/apppage-add.mdx +19 -1
  63. package/docs/docs/cmd/spo/apppage/apppage-set.mdx +21 -0
  64. package/docs/docs/cmd/spo/commandset/commandset-add.mdx +19 -0
  65. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +19 -0
  66. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +19 -0
  67. package/docs/docs/cmd/spo/commandset/commandset-remove.mdx +21 -0
  68. package/docs/docs/cmd/spo/commandset/commandset-set.mdx +21 -0
  69. package/docs/docs/cmd/spo/file/file-unarchive.mdx +68 -0
  70. package/docs/docs/cmd/spo/folder/folder-archive.mdx +73 -0
  71. package/docs/docs/cmd/viva/engage/engage-role-member-add.mdx +76 -0
  72. package/npm-shrinkwrap.json +273 -128
  73. package/package.json +18 -18
@@ -1,12 +1,13 @@
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 _EntraMultitenantSetCommand_instances, _EntraMultitenantSetCommand_initTelemetry, _EntraMultitenantSetCommand_initOptions, _EntraMultitenantSetCommand_initValidators, _EntraMultitenantSetCommand_initTypes;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import request from '../../../../request.js';
8
4
  import GraphCommand from '../../../base/GraphCommand.js';
9
5
  import commands from '../../commands.js';
6
+ export const options = globalOptionsZod
7
+ .extend({
8
+ displayName: z.string().optional().alias('n'),
9
+ description: z.string().optional().alias('d')
10
+ }).strict();
10
11
  class EntraMultitenantSetCommand extends GraphCommand {
11
12
  get name() {
12
13
  return commands.MULTITENANT_SET;
@@ -14,13 +15,14 @@ class EntraMultitenantSetCommand extends GraphCommand {
14
15
  get description() {
15
16
  return 'Updates the properties of a multitenant organization';
16
17
  }
17
- constructor() {
18
- super();
19
- _EntraMultitenantSetCommand_instances.add(this);
20
- __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initTelemetry).call(this);
21
- __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initOptions).call(this);
22
- __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initValidators).call(this);
23
- __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initTypes).call(this);
18
+ get schema() {
19
+ return options;
20
+ }
21
+ getRefinedSchema(schema) {
22
+ return schema
23
+ .refine(options => options.displayName || options.description, {
24
+ error: 'Specify either displayName or description or both'
25
+ });
24
26
  }
25
27
  async commandAction(logger, args) {
26
28
  if (this.verbose) {
@@ -45,28 +47,5 @@ class EntraMultitenantSetCommand extends GraphCommand {
45
47
  }
46
48
  }
47
49
  }
48
- _EntraMultitenantSetCommand_instances = new WeakSet(), _EntraMultitenantSetCommand_initTelemetry = function _EntraMultitenantSetCommand_initTelemetry() {
49
- this.telemetry.push((args) => {
50
- Object.assign(this.telemetryProperties, {
51
- displayName: typeof args.options.displayName !== 'undefined',
52
- description: typeof args.options.description !== 'undefined'
53
- });
54
- });
55
- }, _EntraMultitenantSetCommand_initOptions = function _EntraMultitenantSetCommand_initOptions() {
56
- this.options.unshift({
57
- option: '-n, --displayName [displayName]'
58
- }, {
59
- option: '-d, --description [description]'
60
- });
61
- }, _EntraMultitenantSetCommand_initValidators = function _EntraMultitenantSetCommand_initValidators() {
62
- this.validators.push(async (args) => {
63
- if (!args.options.displayName && !args.options.description) {
64
- return 'Specify either displayName or description or both.';
65
- }
66
- return true;
67
- });
68
- }, _EntraMultitenantSetCommand_initTypes = function _EntraMultitenantSetCommand_initTypes() {
69
- this.types.string.push('displayName', 'description');
70
- };
71
50
  export default new EntraMultitenantSetCommand();
72
51
  //# sourceMappingURL=multitenant-set.js.map
@@ -1,13 +1,14 @@
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 _EntraOAuth2GrantAddCommand_instances, _EntraOAuth2GrantAddCommand_initOptions, _EntraOAuth2GrantAddCommand_initValidators;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import request from '../../../../request.js';
8
- import { validation } from '../../../../utils/validation.js';
9
4
  import GraphCommand from '../../../base/GraphCommand.js';
10
5
  import commands from '../../commands.js';
6
+ export const options = globalOptionsZod
7
+ .extend({
8
+ clientId: z.uuid().alias('i'),
9
+ resourceId: z.uuid().alias('r'),
10
+ scope: z.string().alias('s')
11
+ }).strict();
11
12
  class EntraOAuth2GrantAddCommand extends GraphCommand {
12
13
  get name() {
13
14
  return commands.OAUTH2GRANT_ADD;
@@ -15,11 +16,8 @@ class EntraOAuth2GrantAddCommand extends GraphCommand {
15
16
  get description() {
16
17
  return 'Grant the specified service principal OAuth2 permissions to the specified resource';
17
18
  }
18
- constructor() {
19
- super();
20
- _EntraOAuth2GrantAddCommand_instances.add(this);
21
- __classPrivateFieldGet(this, _EntraOAuth2GrantAddCommand_instances, "m", _EntraOAuth2GrantAddCommand_initOptions).call(this);
22
- __classPrivateFieldGet(this, _EntraOAuth2GrantAddCommand_instances, "m", _EntraOAuth2GrantAddCommand_initValidators).call(this);
19
+ get schema() {
20
+ return options;
23
21
  }
24
22
  async commandAction(logger, args) {
25
23
  if (this.verbose) {
@@ -47,24 +45,5 @@ class EntraOAuth2GrantAddCommand extends GraphCommand {
47
45
  }
48
46
  }
49
47
  }
50
- _EntraOAuth2GrantAddCommand_instances = new WeakSet(), _EntraOAuth2GrantAddCommand_initOptions = function _EntraOAuth2GrantAddCommand_initOptions() {
51
- this.options.unshift({
52
- option: '-i, --clientId <clientId>'
53
- }, {
54
- option: '-r, --resourceId <resourceId>'
55
- }, {
56
- option: '-s, --scope <scope>'
57
- });
58
- }, _EntraOAuth2GrantAddCommand_initValidators = function _EntraOAuth2GrantAddCommand_initValidators() {
59
- this.validators.push(async (args) => {
60
- if (!validation.isValidGuid(args.options.clientId)) {
61
- return `${args.options.clientId} is not a valid GUID`;
62
- }
63
- if (!validation.isValidGuid(args.options.resourceId)) {
64
- return `${args.options.resourceId} is not a valid GUID`;
65
- }
66
- return true;
67
- });
68
- };
69
48
  export default new EntraOAuth2GrantAddCommand();
70
49
  //# sourceMappingURL=oauth2grant-add.js.map
@@ -1,14 +1,13 @@
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 _EntraOAuth2GrantListCommand_instances, _EntraOAuth2GrantListCommand_initOptions, _EntraOAuth2GrantListCommand_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
- import { validation } from '../../../../utils/validation.js';
10
5
  import GraphCommand from '../../../base/GraphCommand.js';
11
6
  import commands from '../../commands.js';
7
+ export const options = globalOptionsZod
8
+ .extend({
9
+ spObjectId: z.uuid().alias('i')
10
+ }).strict();
12
11
  class EntraOAuth2GrantListCommand extends GraphCommand {
13
12
  get name() {
14
13
  return commands.OAUTH2GRANT_LIST;
@@ -19,11 +18,8 @@ class EntraOAuth2GrantListCommand extends GraphCommand {
19
18
  defaultProperties() {
20
19
  return ['objectId', 'resourceId', 'scope'];
21
20
  }
22
- constructor() {
23
- super();
24
- _EntraOAuth2GrantListCommand_instances.add(this);
25
- __classPrivateFieldGet(this, _EntraOAuth2GrantListCommand_instances, "m", _EntraOAuth2GrantListCommand_initOptions).call(this);
26
- __classPrivateFieldGet(this, _EntraOAuth2GrantListCommand_instances, "m", _EntraOAuth2GrantListCommand_initValidators).call(this);
21
+ get schema() {
22
+ return options;
27
23
  }
28
24
  async commandAction(logger, args) {
29
25
  if (this.verbose) {
@@ -38,17 +34,5 @@ class EntraOAuth2GrantListCommand extends GraphCommand {
38
34
  }
39
35
  }
40
36
  }
41
- _EntraOAuth2GrantListCommand_instances = new WeakSet(), _EntraOAuth2GrantListCommand_initOptions = function _EntraOAuth2GrantListCommand_initOptions() {
42
- this.options.unshift({
43
- option: '-i, --spObjectId <spObjectId>'
44
- });
45
- }, _EntraOAuth2GrantListCommand_initValidators = function _EntraOAuth2GrantListCommand_initValidators() {
46
- this.validators.push(async (args) => {
47
- if (!validation.isValidGuid(args.options.spObjectId)) {
48
- return `${args.options.spObjectId} is not a valid GUID`;
49
- }
50
- return true;
51
- });
52
- };
53
37
  export default new EntraOAuth2GrantListCommand();
54
38
  //# sourceMappingURL=oauth2grant-list.js.map
@@ -1,14 +1,15 @@
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 _EntraOAuth2GrantRemoveCommand_instances, _EntraOAuth2GrantRemoveCommand_initOptions;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import { cli } from '../../../../cli/cli.js';
8
4
  import request from '../../../../request.js';
9
5
  import { formatting } from '../../../../utils/formatting.js';
10
6
  import GraphCommand from '../../../base/GraphCommand.js';
11
7
  import commands from '../../commands.js';
8
+ export const options = globalOptionsZod
9
+ .extend({
10
+ grantId: z.string().alias('i'),
11
+ force: z.boolean().optional().alias('f')
12
+ }).strict();
12
13
  class EntraOAuth2GrantRemoveCommand extends GraphCommand {
13
14
  get name() {
14
15
  return commands.OAUTH2GRANT_REMOVE;
@@ -16,10 +17,8 @@ class EntraOAuth2GrantRemoveCommand extends GraphCommand {
16
17
  get description() {
17
18
  return 'Remove specified service principal OAuth2 permissions';
18
19
  }
19
- constructor() {
20
- super();
21
- _EntraOAuth2GrantRemoveCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _EntraOAuth2GrantRemoveCommand_instances, "m", _EntraOAuth2GrantRemoveCommand_initOptions).call(this);
20
+ get schema() {
21
+ return options;
23
22
  }
24
23
  async commandAction(logger, args) {
25
24
  const removeOauth2Grant = async () => {
@@ -51,12 +50,5 @@ class EntraOAuth2GrantRemoveCommand extends GraphCommand {
51
50
  }
52
51
  }
53
52
  }
54
- _EntraOAuth2GrantRemoveCommand_instances = new WeakSet(), _EntraOAuth2GrantRemoveCommand_initOptions = function _EntraOAuth2GrantRemoveCommand_initOptions() {
55
- this.options.unshift({
56
- option: '-i, --grantId <grantId>'
57
- }, {
58
- option: '-f, --force'
59
- });
60
- };
61
53
  export default new EntraOAuth2GrantRemoveCommand();
62
54
  //# sourceMappingURL=oauth2grant-remove.js.map
@@ -1,13 +1,14 @@
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 _EntraOAuth2GrantSetCommand_instances, _EntraOAuth2GrantSetCommand_initOptions;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import request from '../../../../request.js';
8
4
  import { formatting } from '../../../../utils/formatting.js';
9
5
  import GraphCommand from '../../../base/GraphCommand.js';
10
6
  import commands from '../../commands.js';
7
+ export const options = globalOptionsZod
8
+ .extend({
9
+ grantId: z.string().alias('i'),
10
+ scope: z.string().alias('s')
11
+ }).strict();
11
12
  class EntraOAuth2GrantSetCommand extends GraphCommand {
12
13
  get name() {
13
14
  return commands.OAUTH2GRANT_SET;
@@ -15,10 +16,8 @@ class EntraOAuth2GrantSetCommand extends GraphCommand {
15
16
  get description() {
16
17
  return 'Update OAuth2 permissions for the service principal';
17
18
  }
18
- constructor() {
19
- super();
20
- _EntraOAuth2GrantSetCommand_instances.add(this);
21
- __classPrivateFieldGet(this, _EntraOAuth2GrantSetCommand_instances, "m", _EntraOAuth2GrantSetCommand_initOptions).call(this);
19
+ get schema() {
20
+ return options;
22
21
  }
23
22
  async commandAction(logger, args) {
24
23
  if (this.verbose) {
@@ -42,12 +41,5 @@ class EntraOAuth2GrantSetCommand extends GraphCommand {
42
41
  }
43
42
  }
44
43
  }
45
- _EntraOAuth2GrantSetCommand_instances = new WeakSet(), _EntraOAuth2GrantSetCommand_initOptions = function _EntraOAuth2GrantSetCommand_initOptions() {
46
- this.options.unshift({
47
- option: '-i, --grantId <grantId>'
48
- }, {
49
- option: '-s, --scope <scope>'
50
- });
51
- };
52
44
  export default new EntraOAuth2GrantSetCommand();
53
45
  //# sourceMappingURL=oauth2grant-set.js.map
@@ -35,7 +35,7 @@ class OutlookCalendarGetCommand extends GraphCommand {
35
35
  .refine(options => [options.id, options.name].filter(x => x !== undefined).length === 1, {
36
36
  error: 'Specify either id or name, but not both'
37
37
  })
38
- .refine(options => !(options.userId && options.userName), {
38
+ .refine(options => [options.userId, options.userName].filter(x => x !== undefined).length === 1, {
39
39
  error: 'Specify either userId or userName, but not both'
40
40
  })
41
41
  .refine(options => !(options.calendarGroupId && options.calendarGroupName), {
@@ -1,12 +1,16 @@
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 _SpeContainerGetCommand_instances, _SpeContainerGetCommand_initOptions, _SpeContainerGetCommand_initTypes;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import GraphCommand from '../../../base/GraphCommand.js';
8
4
  import commands from '../../commands.js';
9
5
  import request from '../../../../request.js';
6
+ import { spe } from '../../../../utils/spe.js';
7
+ export const options = z.strictObject({
8
+ ...globalOptionsZod.shape,
9
+ id: z.string().alias('i').optional(),
10
+ name: z.string().alias('n').optional(),
11
+ containerTypeId: z.uuid().optional(),
12
+ containerTypeName: z.string().optional()
13
+ });
10
14
  class SpeContainerGetCommand extends GraphCommand {
11
15
  get name() {
12
16
  return commands.CONTAINER_GET;
@@ -14,24 +18,34 @@ class SpeContainerGetCommand extends GraphCommand {
14
18
  get description() {
15
19
  return 'Gets a container of a specific container type';
16
20
  }
17
- constructor() {
18
- super();
19
- _SpeContainerGetCommand_instances.add(this);
20
- __classPrivateFieldGet(this, _SpeContainerGetCommand_instances, "m", _SpeContainerGetCommand_initOptions).call(this);
21
- __classPrivateFieldGet(this, _SpeContainerGetCommand_instances, "m", _SpeContainerGetCommand_initTypes).call(this);
21
+ get schema() {
22
+ return options;
23
+ }
24
+ getRefinedSchema(schema) {
25
+ return schema
26
+ .refine((opts) => [opts.id, opts.name].filter(value => value !== undefined).length === 1, {
27
+ message: 'Specify either id or name, but not both.'
28
+ })
29
+ .refine((options) => !options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 1, {
30
+ error: 'Use one of the following options when specifying the container name: containerTypeId or containerTypeName.'
31
+ })
32
+ .refine((options) => options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 0, {
33
+ error: 'Options containerTypeId and containerTypeName are only required when retrieving a container by name.'
34
+ });
22
35
  }
23
36
  async commandAction(logger, args) {
24
- if (this.verbose) {
25
- await logger.logToStderr(`Getting a container with id '${args.options.id}'...`);
26
- }
27
- const requestOptions = {
28
- url: `${this.resource}/v1.0/storage/fileStorage/containers/${args.options.id}`,
29
- headers: {
30
- accept: 'application/json;odata.metadata=none'
31
- },
32
- responseType: 'json'
33
- };
34
37
  try {
38
+ const containerId = await this.resolveContainerId(args.options, logger);
39
+ if (this.verbose) {
40
+ await logger.logToStderr(`Getting a container with id '${containerId}'...`);
41
+ }
42
+ const requestOptions = {
43
+ url: `${this.resource}/v1.0/storage/fileStorage/containers/${containerId}`,
44
+ headers: {
45
+ accept: 'application/json;odata.metadata=none'
46
+ },
47
+ responseType: 'json'
48
+ };
35
49
  const res = await request.get(requestOptions);
36
50
  await logger.log(res);
37
51
  }
@@ -39,11 +53,25 @@ class SpeContainerGetCommand extends GraphCommand {
39
53
  this.handleRejectedODataJsonPromise(err);
40
54
  }
41
55
  }
56
+ async resolveContainerId(options, logger) {
57
+ if (options.id) {
58
+ return options.id;
59
+ }
60
+ if (this.verbose) {
61
+ await logger.logToStderr(`Resolving container id from name '${options.name}'...`);
62
+ }
63
+ const containerTypeId = await this.getContainerTypeId(options, logger);
64
+ return spe.getContainerIdByName(containerTypeId, options.name);
65
+ }
66
+ async getContainerTypeId(options, logger) {
67
+ if (options.containerTypeId) {
68
+ return options.containerTypeId;
69
+ }
70
+ if (this.verbose) {
71
+ await logger.logToStderr(`Getting container type with name '${options.containerTypeName}'...`);
72
+ }
73
+ return spe.getContainerTypeIdByName(options.containerTypeName);
74
+ }
42
75
  }
43
- _SpeContainerGetCommand_instances = new WeakSet(), _SpeContainerGetCommand_initOptions = function _SpeContainerGetCommand_initOptions() {
44
- this.options.unshift({ option: '-i, --id <id>' });
45
- }, _SpeContainerGetCommand_initTypes = function _SpeContainerGetCommand_initTypes() {
46
- this.types.string.push('id');
47
- };
48
76
  export default new SpeContainerGetCommand();
49
77
  //# sourceMappingURL=container-get.js.map
@@ -1,13 +1,17 @@
1
1
  import { cli } from '../../../../cli/cli.js';
2
2
  import { z } from 'zod';
3
- import { globalOptionsZod } from '../../../../Command.js';
3
+ import { CommandError, globalOptionsZod } from '../../../../Command.js';
4
4
  import commands from '../../commands.js';
5
5
  import GraphCommand from '../../../base/GraphCommand.js';
6
6
  import { odata } from '../../../../utils/odata.js';
7
7
  import { formatting } from '../../../../utils/formatting.js';
8
+ import { spe } from '../../../../utils/spe.js';
8
9
  export const options = z.strictObject({
9
10
  ...globalOptionsZod.shape,
10
- containerId: z.string().alias('i')
11
+ containerId: z.string().alias('i').optional(),
12
+ containerName: z.string().alias('n').optional(),
13
+ containerTypeId: z.uuid().optional(),
14
+ containerTypeName: z.string().optional()
11
15
  });
12
16
  class SpeContainerPermissionListCommand extends GraphCommand {
13
17
  get name() {
@@ -22,12 +26,25 @@ class SpeContainerPermissionListCommand extends GraphCommand {
22
26
  get schema() {
23
27
  return options;
24
28
  }
29
+ getRefinedSchema(schema) {
30
+ return schema
31
+ .refine((opts) => [opts.containerId, opts.containerName].filter(value => value !== undefined).length === 1, {
32
+ message: 'Specify either id or name, but not both.'
33
+ })
34
+ .refine((options) => !options.containerName || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 1, {
35
+ error: 'Use one of the following options when specifying the container name: containerTypeId or containerTypeName.'
36
+ })
37
+ .refine((options) => options.containerName || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 0, {
38
+ error: 'Options containerTypeId and containerTypeName are only required when retrieving a container by name.'
39
+ });
40
+ }
25
41
  async commandAction(logger, args) {
26
42
  try {
43
+ const containerId = await this.resolveContainerId(args.options, logger);
27
44
  if (this.verbose) {
28
- await logger.logToStderr(`Retrieving permissions of a SharePoint Embedded Container with id '${args.options.containerId}'...`);
45
+ await logger.logToStderr(`Retrieving permissions of a SharePoint Embedded Container with id '${containerId}'...`);
29
46
  }
30
- const containerPermission = await odata.getAllItems(`${this.resource}/v1.0/storage/fileStorage/containers/${formatting.encodeQueryParameter(args.options.containerId)}/permissions`);
47
+ const containerPermission = await odata.getAllItems(`${this.resource}/v1.0/storage/fileStorage/containers/${formatting.encodeQueryParameter(containerId)}/permissions`);
31
48
  if (!cli.shouldTrimOutput(args.options.output)) {
32
49
  await logger.log(containerPermission);
33
50
  }
@@ -42,9 +59,31 @@ class SpeContainerPermissionListCommand extends GraphCommand {
42
59
  }
43
60
  }
44
61
  catch (err) {
62
+ if (err instanceof CommandError) {
63
+ throw err;
64
+ }
45
65
  this.handleRejectedODataJsonPromise(err);
46
66
  }
47
67
  }
68
+ async resolveContainerId(options, logger) {
69
+ if (options.containerId) {
70
+ return options.containerId;
71
+ }
72
+ if (this.verbose) {
73
+ await logger.logToStderr(`Resolving container id from name '${options.containerName}'...`);
74
+ }
75
+ const containerTypeId = await this.getContainerTypeId(options, logger);
76
+ return spe.getContainerIdByName(containerTypeId, options.containerName);
77
+ }
78
+ async getContainerTypeId(options, logger) {
79
+ if (options.containerTypeId) {
80
+ return options.containerTypeId;
81
+ }
82
+ if (this.verbose) {
83
+ await logger.logToStderr(`Getting container type with name '${options.containerTypeName}'...`);
84
+ }
85
+ return spe.getContainerTypeIdByName(options.containerTypeName);
86
+ }
48
87
  }
49
88
  export default new SpeContainerPermissionListCommand();
50
89
  //# sourceMappingURL=container-permission-list.js.map
@@ -0,0 +1,77 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import GraphCommand from '../../../base/GraphCommand.js';
4
+ import commands from '../../commands.js';
5
+ import request from '../../../../request.js';
6
+ import { validation } from '../../../../utils/validation.js';
7
+ export const options = z.strictObject({
8
+ ...globalOptionsZod.shape,
9
+ id: z.string().alias('i'),
10
+ newName: z.string().optional(),
11
+ description: z.string().optional(),
12
+ isOcrEnabled: z.boolean().optional(),
13
+ isItemVersioningEnabled: z.boolean().optional(),
14
+ itemMajorVersionLimit: z.number()
15
+ .refine(numb => validation.isValidPositiveInteger(numb), {
16
+ error: e => `'${e.input}' is not a valid positive integer.`
17
+ }).optional()
18
+ });
19
+ class SpeContainerSetCommand extends GraphCommand {
20
+ get name() {
21
+ return commands.CONTAINER_SET;
22
+ }
23
+ get description() {
24
+ return 'Updates a SharePoint Embedded container';
25
+ }
26
+ get schema() {
27
+ return options;
28
+ }
29
+ getRefinedSchema(schema) {
30
+ return schema
31
+ .refine(o => o.newName !== undefined || o.description !== undefined || o.isOcrEnabled !== undefined || o.isItemVersioningEnabled !== undefined || o.itemMajorVersionLimit !== undefined, {
32
+ error: 'Specify at least one of newName, description, isOcrEnabled, isItemVersioningEnabled, or itemMajorVersionLimit.'
33
+ });
34
+ }
35
+ async commandAction(logger, args) {
36
+ if (this.verbose) {
37
+ await logger.logToStderr(`Updating container '${args.options.id}'...`);
38
+ }
39
+ try {
40
+ const data = {};
41
+ if (args.options.newName !== undefined) {
42
+ data.displayName = args.options.newName;
43
+ }
44
+ if (args.options.description !== undefined) {
45
+ data.description = args.options.description;
46
+ }
47
+ const settings = {};
48
+ if (args.options.isOcrEnabled !== undefined) {
49
+ settings.isOcrEnabled = args.options.isOcrEnabled;
50
+ }
51
+ if (args.options.isItemVersioningEnabled !== undefined) {
52
+ settings.isItemVersioningEnabled = args.options.isItemVersioningEnabled;
53
+ }
54
+ if (args.options.itemMajorVersionLimit !== undefined) {
55
+ settings.itemMajorVersionLimit = args.options.itemMajorVersionLimit;
56
+ }
57
+ if (Object.keys(settings).length > 0) {
58
+ data.settings = settings;
59
+ }
60
+ const requestOptions = {
61
+ url: `${this.resource}/v1.0/storage/fileStorage/containers/${args.options.id}`,
62
+ headers: {
63
+ accept: 'application/json;odata.metadata=none'
64
+ },
65
+ responseType: 'json',
66
+ data
67
+ };
68
+ const container = await request.patch(requestOptions);
69
+ await logger.log(container);
70
+ }
71
+ catch (err) {
72
+ this.handleRejectedODataJsonPromise(err);
73
+ }
74
+ }
75
+ }
76
+ export default new SpeContainerSetCommand();
77
+ //# sourceMappingURL=container-set.js.map
@@ -5,6 +5,7 @@ export default {
5
5
  CONTAINER_GET: `${prefix} container get`,
6
6
  CONTAINER_LIST: `${prefix} container list`,
7
7
  CONTAINER_REMOVE: `${prefix} container remove`,
8
+ CONTAINER_SET: `${prefix} container set`,
8
9
  CONTAINER_PERMISSION_LIST: `${prefix} container permission list`,
9
10
  CONTAINER_RECYCLEBINITEM_LIST: `${prefix} container recyclebinitem list`,
10
11
  CONTAINER_RECYCLEBINITEM_REMOVE: `${prefix} container recyclebinitem remove`,
@@ -0,0 +1,83 @@
1
+ import commands from '../../commands.js';
2
+ import SpoCommand from '../../../base/SpoCommand.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
4
+ import { z } from 'zod';
5
+ import { validation } from '../../../../utils/validation.js';
6
+ import { cli } from '../../../../cli/cli.js';
7
+ import { urlUtil } from '../../../../utils/urlUtil.js';
8
+ import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ webUrl: z.string()
13
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
14
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
15
+ })
16
+ .alias('u'),
17
+ url: z.string().optional(),
18
+ id: z.uuid().optional().alias('i'),
19
+ force: z.boolean().optional().alias('f')
20
+ });
21
+ class SpoFileUnarchiveCommand extends SpoCommand {
22
+ get name() {
23
+ return commands.FILE_UNARCHIVE;
24
+ }
25
+ get description() {
26
+ return 'Unarchives a file';
27
+ }
28
+ get schema() {
29
+ return options;
30
+ }
31
+ getRefinedSchema(schema) {
32
+ return schema
33
+ .refine(options => [options.url, options.id].filter(o => o !== undefined).length === 1, {
34
+ error: `Specify 'url' or 'id', but not both.`
35
+ });
36
+ }
37
+ getExcludedOptionsWithUrls() {
38
+ return ['url'];
39
+ }
40
+ async commandAction(logger, args) {
41
+ const { webUrl, url, id, force, verbose } = args.options;
42
+ if (!force) {
43
+ const result = await cli.promptForConfirmation({ message: `Reactivation could take up to 24 hours. Files that are reactivated cannot be archived again for 30 days. Are you sure you would like to unarchive this item?` });
44
+ if (!result) {
45
+ return;
46
+ }
47
+ }
48
+ try {
49
+ if (verbose) {
50
+ await logger.logToStderr(`Unarchiving file '${url || id}' at site '${webUrl}'...`);
51
+ }
52
+ let requestUrl = `${webUrl}/_api/web`;
53
+ if (id) {
54
+ requestUrl += `/GetFileById('${formatting.encodeQueryParameter(id)}')`;
55
+ }
56
+ else if (url) {
57
+ const serverRelativePath = urlUtil.getServerRelativePath(webUrl, url);
58
+ requestUrl += `/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(serverRelativePath)}')`;
59
+ }
60
+ requestUrl += '?$select=ListId,ListItemAllFields/Id&$expand=ListItemAllFields';
61
+ const fileInfo = await request.get({
62
+ url: requestUrl,
63
+ headers: {
64
+ accept: 'application/json;odata=nometadata'
65
+ },
66
+ responseType: 'json'
67
+ });
68
+ const requestOptions = {
69
+ url: `${webUrl}/_api/Lists(guid'${fileInfo.ListId}')/items(${fileInfo.ListItemAllFields.Id})/UnArchive`,
70
+ headers: {
71
+ accept: 'application/json;odata=nometadata'
72
+ },
73
+ responseType: 'json'
74
+ };
75
+ await request.post(requestOptions);
76
+ }
77
+ catch (err) {
78
+ this.handleRejectedODataJsonPromise(err);
79
+ }
80
+ }
81
+ }
82
+ export default new SpoFileUnarchiveCommand();
83
+ //# sourceMappingURL=file-unarchive.js.map