@pnp/cli-microsoft365 9.0.0-beta.2f8dd1e → 9.0.0-beta.33615bd

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 (118) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/Auth.js +10 -18
  5. package/dist/Command.js +49 -2
  6. package/dist/chili/chili.js +0 -23
  7. package/dist/cli/cli.js +61 -101
  8. package/dist/m365/app/commands/permission/permission-add.js +9 -9
  9. package/dist/m365/commands/login.js +44 -96
  10. package/dist/m365/commands/setup.js +0 -4
  11. package/dist/m365/connection/commands/connection-remove.js +6 -2
  12. package/dist/m365/connection/commands/connection-set.js +4 -1
  13. package/dist/m365/connection/commands/connection-use.js +25 -4
  14. package/dist/m365/entra/commands/group/group-user-list.js +4 -4
  15. package/dist/m365/entra/commands/m365group/m365group-conversation-post-list.js +4 -4
  16. package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-list.js +3 -3
  17. package/dist/m365/entra/commands/m365group/m365group-set.js +66 -29
  18. package/dist/m365/entra/commands/m365group/m365group-user-list.js +6 -9
  19. package/dist/m365/entra/commands/multitenant/MultitenantOrganization.js +2 -0
  20. package/dist/m365/entra/commands/multitenant/multitenant-add.js +65 -0
  21. package/dist/m365/entra/commands/multitenant/multitenant-get.js +32 -0
  22. package/dist/m365/entra/commands/multitenant/multitenant-remove.js +118 -0
  23. package/dist/m365/entra/commands/multitenant/multitenant-set.js +72 -0
  24. package/dist/m365/entra/commands.js +4 -0
  25. package/dist/m365/external/commands/connection/connection-doctor.js +10 -24
  26. package/dist/m365/flow/commands/flow-list.js +23 -24
  27. package/dist/m365/graph/commands/subscription/subscription-add.js +4 -2
  28. package/dist/m365/outlook/commands/message/message-get.js +11 -11
  29. package/dist/m365/spe/ContainerTypeProperties.js +2 -0
  30. package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
  31. package/dist/m365/spe/commands.js +2 -1
  32. package/dist/m365/spfx/commands/project/base-project-command.js +36 -126
  33. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
  34. package/dist/m365/spo/commands/cdn/cdn-get.js +12 -15
  35. package/dist/m365/spo/commands/cdn/cdn-set.js +6 -4
  36. package/dist/m365/spo/commands/commandset/commandset-get.js +31 -17
  37. package/dist/m365/spo/commands/contenttype/contenttype-field-list.js +124 -0
  38. package/dist/m365/spo/commands/field/field-list.js +1 -1
  39. package/dist/m365/spo/commands/file/file-roleassignment-add.js +1 -1
  40. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +1 -1
  41. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
  42. package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +1 -1
  43. package/dist/m365/spo/commands/group/group-member-add.js +103 -99
  44. package/dist/m365/spo/commands/list/list-list.js +1 -4
  45. package/dist/m365/spo/commands/list/list-roleassignment-add.js +46 -21
  46. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +48 -46
  47. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -3
  48. package/dist/m365/spo/commands/page/page-text-add.js +2 -3
  49. package/dist/m365/spo/commands/site/site-appcatalog-remove.js +48 -24
  50. package/dist/m365/spo/commands/spo-search.js +3 -4
  51. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
  52. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
  53. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-restore.js +2 -22
  54. package/dist/m365/spo/commands.js +1 -0
  55. package/dist/m365/teams/commands/meeting/meeting-attendancereport-get.js +119 -0
  56. package/dist/m365/teams/commands/message/message-remove.js +112 -0
  57. package/dist/m365/teams/commands.js +2 -0
  58. package/dist/m365/viva/commands/engage/engage-community-add.js +166 -0
  59. package/dist/m365/viva/commands.js +1 -0
  60. package/dist/utils/formatting.js +30 -1
  61. package/dist/utils/spo.js +37 -6
  62. package/dist/utils/teams.js +49 -0
  63. package/dist/utils/validation.js +19 -0
  64. package/dist/utils/zod.js +124 -0
  65. package/docs/docs/cmd/app/permission/permission-add.mdx +5 -5
  66. package/docs/docs/cmd/connection/connection-use.mdx +8 -2
  67. package/docs/docs/cmd/entra/group/group-user-list.mdx +7 -7
  68. package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +5 -5
  69. package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx +3 -3
  70. package/docs/docs/cmd/entra/m365group/m365group-set.mdx +37 -7
  71. package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +1 -1
  72. package/docs/docs/cmd/entra/multitenant/multitenant-add.mdx +107 -0
  73. package/docs/docs/cmd/entra/multitenant/multitenant-get.mdx +94 -0
  74. package/docs/docs/cmd/entra/multitenant/multitenant-remove.mdx +58 -0
  75. package/docs/docs/cmd/entra/multitenant/multitenant-set.mdx +53 -0
  76. package/docs/docs/cmd/external/connection/connection-doctor.mdx +9 -9
  77. package/docs/docs/cmd/flow/flow-list.mdx +114 -56
  78. package/docs/docs/cmd/graph/subscription/subscription-add.mdx +18 -0
  79. package/docs/docs/cmd/outlook/message/message-get.mdx +5 -5
  80. package/docs/docs/cmd/planner/plan/plan-remove.mdx +1 -1
  81. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +102 -0
  82. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +87 -38
  83. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +22 -28
  84. package/docs/docs/cmd/spo/cdn/cdn-set.mdx +3 -3
  85. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
  86. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
  87. package/docs/docs/cmd/spo/contenttype/contenttype-field-list.mdx +172 -0
  88. package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +3 -3
  89. package/docs/docs/cmd/spo/field/field-list.mdx +3 -3
  90. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +1 -1
  91. package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +2 -2
  92. package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
  93. package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +1 -1
  94. package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +1 -1
  95. package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +2 -2
  96. package/docs/docs/cmd/spo/group/group-member-add.mdx +34 -27
  97. package/docs/docs/cmd/spo/list/list-list.mdx +5 -7
  98. package/docs/docs/cmd/spo/list/list-roleassignment-add.mdx +15 -3
  99. package/docs/docs/cmd/spo/list/list-roleassignment-remove.mdx +15 -3
  100. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-ensure.mdx +4 -4
  101. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.mdx +1 -1
  102. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.mdx +9 -9
  103. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-remove.mdx +7 -7
  104. package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +11 -2
  105. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.mdx +1 -1
  106. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
  107. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
  108. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
  109. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
  110. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.mdx +2 -49
  111. package/docs/docs/cmd/spo/web/web-roleassignment-add.mdx +1 -1
  112. package/docs/docs/cmd/spo/web/web-roleassignment-remove.mdx +1 -1
  113. package/docs/docs/cmd/teams/meeting/meeting-attendancereport-get.mdx +138 -0
  114. package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
  115. package/docs/docs/cmd/teams/message/message-remove.mdx +63 -0
  116. package/docs/docs/cmd/viva/engage/engage-community-add.mdx +168 -0
  117. package/npm-shrinkwrap.json +588 -1022
  118. package/package.json +7 -3
@@ -1,17 +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 _LoginCommand_instances, _a, _LoginCommand_initTelemetry, _LoginCommand_initOptions, _LoginCommand_initValidators;
7
1
  import fs from 'fs';
2
+ import { z } from 'zod';
8
3
  import auth, { AuthType, CloudType } from '../../Auth.js';
9
- import Command, { CommandError } from '../../Command.js';
4
+ import Command, { CommandError, globalOptionsZod } from '../../Command.js';
5
+ import { cli } from '../../cli/cli.js';
10
6
  import config from '../../config.js';
11
- import { misc } from '../../utils/misc.js';
12
- import commands from './commands.js';
13
7
  import { settingsNames } from '../../settingsNames.js';
14
- import { cli } from '../../cli/cli.js';
8
+ import { zod } from '../../utils/zod.js';
9
+ import commands from './commands.js';
10
+ const options = globalOptionsZod
11
+ .extend({
12
+ authType: zod.alias('t', z.enum(['certificate', 'deviceCode', 'password', 'identity', 'browser', 'secret']).optional()),
13
+ cloud: z.nativeEnum(CloudType).optional().default(CloudType.Public),
14
+ userName: zod.alias('u', z.string().optional()),
15
+ password: zod.alias('p', z.string().optional()),
16
+ certificateFile: zod.alias('c', z.string().optional()
17
+ .refine(filePath => !filePath || fs.existsSync(filePath), filePath => ({
18
+ message: `Certificate file ${filePath} does not exist`
19
+ }))),
20
+ certificateBase64Encoded: z.string().optional(),
21
+ thumbprint: z.string().optional(),
22
+ appId: z.string().optional(),
23
+ tenant: z.string().optional(),
24
+ secret: zod.alias('s', z.string().optional()),
25
+ connectionName: z.string().optional()
26
+ })
27
+ .strict();
15
28
  class LoginCommand extends Command {
16
29
  get name() {
17
30
  return commands.LOGIN;
@@ -19,12 +32,26 @@ class LoginCommand extends Command {
19
32
  get description() {
20
33
  return 'Log in to Microsoft 365';
21
34
  }
22
- constructor() {
23
- super();
24
- _LoginCommand_instances.add(this);
25
- __classPrivateFieldGet(this, _LoginCommand_instances, "m", _LoginCommand_initTelemetry).call(this);
26
- __classPrivateFieldGet(this, _LoginCommand_instances, "m", _LoginCommand_initOptions).call(this);
27
- __classPrivateFieldGet(this, _LoginCommand_instances, "m", _LoginCommand_initValidators).call(this);
35
+ get schema() {
36
+ return options;
37
+ }
38
+ getRefinedSchema(schema) {
39
+ return schema
40
+ .refine(options => options.authType !== 'password' || options.userName, {
41
+ message: 'Username is required when using password authentication'
42
+ })
43
+ .refine(options => options.authType !== 'password' || options.password, {
44
+ message: 'Password is required when using password authentication'
45
+ })
46
+ .refine(options => options.authType !== 'certificate' || !(options.certificateFile && options.certificateBase64Encoded), {
47
+ message: 'Specify either certificateFile or certificateBase64Encoded, but not both.'
48
+ })
49
+ .refine(options => options.authType !== 'certificate' || options.certificateFile || options.certificateBase64Encoded, {
50
+ message: 'Specify either certificateFile or certificateBase64Encoded'
51
+ })
52
+ .refine(options => options.authType !== 'secret' || options.secret, {
53
+ message: 'Secret is required when using secret authentication'
54
+ });
28
55
  }
29
56
  async commandAction(logger, args) {
30
57
  // disconnect before re-connecting
@@ -64,12 +91,7 @@ class LoginCommand extends Command {
64
91
  auth.connection.secret = args.options.secret;
65
92
  break;
66
93
  }
67
- if (args.options.cloud) {
68
- auth.connection.cloudType = CloudType[args.options.cloud];
69
- }
70
- else {
71
- auth.connection.cloudType = CloudType.Public;
72
- }
94
+ auth.connection.cloudType = args.options.cloud;
73
95
  try {
74
96
  await auth.ensureAccessToken(auth.defaultResource, logger, this.debug);
75
97
  auth.connection.active = true;
@@ -102,79 +124,5 @@ class LoginCommand extends Command {
102
124
  await this.commandAction(logger, args);
103
125
  }
104
126
  }
105
- _a = LoginCommand, _LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function _LoginCommand_initTelemetry() {
106
- this.telemetry.push((args) => {
107
- Object.assign(this.telemetryProperties, {
108
- authType: args.options.authType || cli.getSettingWithDefaultValue(settingsNames.authType, 'deviceCode'),
109
- cloud: args.options.cloud ?? CloudType.Public
110
- });
111
- });
112
- }, _LoginCommand_initOptions = function _LoginCommand_initOptions() {
113
- this.options.unshift({
114
- option: '-t, --authType [authType]',
115
- autocomplete: _a.allowedAuthTypes
116
- }, {
117
- option: '-u, --userName [userName]'
118
- }, {
119
- option: '-p, --password [password]'
120
- }, {
121
- option: '-c, --certificateFile [certificateFile]'
122
- }, {
123
- option: '--certificateBase64Encoded [certificateBase64Encoded]'
124
- }, {
125
- option: '--thumbprint [thumbprint]'
126
- }, {
127
- option: '--appId [appId]'
128
- }, {
129
- option: '--tenant [tenant]'
130
- }, {
131
- option: '-s, --secret [secret]'
132
- }, {
133
- option: '--cloud [cloud]',
134
- autocomplete: misc.getEnums(CloudType)
135
- }, {
136
- option: '--connectionName [connectionName]'
137
- });
138
- }, _LoginCommand_initValidators = function _LoginCommand_initValidators() {
139
- this.validators.push(async (args) => {
140
- const authType = args.options.authType || cli.getSettingWithDefaultValue(settingsNames.authType, 'deviceCode');
141
- if (authType === 'password') {
142
- if (!args.options.userName) {
143
- return 'Required option userName missing';
144
- }
145
- if (!args.options.password) {
146
- return 'Required option password missing';
147
- }
148
- }
149
- if (authType === 'certificate') {
150
- if (args.options.certificateFile && args.options.certificateBase64Encoded) {
151
- return 'Specify either certificateFile or certificateBase64Encoded, but not both.';
152
- }
153
- if (!args.options.certificateFile && !args.options.certificateBase64Encoded) {
154
- return 'Specify either certificateFile or certificateBase64Encoded';
155
- }
156
- if (args.options.certificateFile) {
157
- if (!fs.existsSync(args.options.certificateFile)) {
158
- return `File '${args.options.certificateFile}' does not exist`;
159
- }
160
- }
161
- }
162
- if (authType &&
163
- _a.allowedAuthTypes.indexOf(authType) < 0) {
164
- return `'${authType}' is not a valid authentication type. Allowed authentication types are ${_a.allowedAuthTypes.join(', ')}`;
165
- }
166
- if (authType === 'secret') {
167
- if (!args.options.secret) {
168
- return 'Required option secret missing';
169
- }
170
- }
171
- if (args.options.cloud &&
172
- typeof CloudType[args.options.cloud] === 'undefined') {
173
- return `${args.options.cloud} is not a valid value for cloud. Valid options are ${misc.getEnums(CloudType).join(', ')}`;
174
- }
175
- return true;
176
- });
177
- };
178
- LoginCommand.allowedAuthTypes = ['certificate', 'deviceCode', 'password', 'identity', 'browser', 'secret'];
179
127
  export default new LoginCommand();
180
128
  //# sourceMappingURL=login.js.map
@@ -42,8 +42,6 @@ class SetupCommand extends AnonymousCommand {
42
42
  await this.configureSettings(settings, true, logger);
43
43
  return;
44
44
  }
45
- // stop the spinner. Fixes #5598
46
- cli.spinner.stop();
47
45
  await logger.logToStderr(`Welcome to the CLI for Microsoft 365 setup!`);
48
46
  await logger.logToStderr(`This command will guide you through the process of configuring the CLI for your needs.`);
49
47
  await logger.logToStderr(`Please, answer the following questions and we'll define a set of settings to best match how you intend to use the CLI.`);
@@ -85,8 +83,6 @@ class SetupCommand extends AnonymousCommand {
85
83
  await logger.logToStderr('');
86
84
  await logger.logToStderr('Configuring settings...');
87
85
  await logger.logToStderr('');
88
- // start the spinner. Fixes #5598
89
- cli.spinner.start();
90
86
  await this.configureSettings(settings, false, logger);
91
87
  if (!this.verbose) {
92
88
  await logger.logToStderr('');
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _ConnectionRemoveCommand_instances, _ConnectionRemoveCommand_initTelemetry, _ConnectionRemoveCommand_initOptions;
6
+ var _ConnectionRemoveCommand_instances, _ConnectionRemoveCommand_initTelemetry, _ConnectionRemoveCommand_initOptions, _ConnectionRemoveCommand_initTypes;
7
7
  import auth from '../../../Auth.js';
8
8
  import commands from '../commands.js';
9
9
  import Command, { CommandError } from '../../../Command.js';
@@ -20,6 +20,7 @@ class ConnectionRemoveCommand extends Command {
20
20
  _ConnectionRemoveCommand_instances.add(this);
21
21
  __classPrivateFieldGet(this, _ConnectionRemoveCommand_instances, "m", _ConnectionRemoveCommand_initTelemetry).call(this);
22
22
  __classPrivateFieldGet(this, _ConnectionRemoveCommand_instances, "m", _ConnectionRemoveCommand_initOptions).call(this);
23
+ __classPrivateFieldGet(this, _ConnectionRemoveCommand_instances, "m", _ConnectionRemoveCommand_initTypes).call(this);
23
24
  }
24
25
  async commandAction(logger, args) {
25
26
  const deleteConnection = async () => {
@@ -53,7 +54,7 @@ class ConnectionRemoveCommand extends Command {
53
54
  _ConnectionRemoveCommand_instances = new WeakSet(), _ConnectionRemoveCommand_initTelemetry = function _ConnectionRemoveCommand_initTelemetry() {
54
55
  this.telemetry.push((args) => {
55
56
  Object.assign(this.telemetryProperties, {
56
- force: (!(!args.options.force)).toString()
57
+ force: !!args.options.force
57
58
  });
58
59
  });
59
60
  }, _ConnectionRemoveCommand_initOptions = function _ConnectionRemoveCommand_initOptions() {
@@ -62,6 +63,9 @@ _ConnectionRemoveCommand_instances = new WeakSet(), _ConnectionRemoveCommand_ini
62
63
  }, {
63
64
  option: '-f, --force'
64
65
  });
66
+ }, _ConnectionRemoveCommand_initTypes = function _ConnectionRemoveCommand_initTypes() {
67
+ this.types.string.push('name');
68
+ this.types.boolean.push('force');
65
69
  };
66
70
  export default new ConnectionRemoveCommand();
67
71
  //# sourceMappingURL=connection-remove.js.map
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _ConnectionSetCommand_instances, _ConnectionSetCommand_initOptions, _ConnectionSetCommand_initValidators;
6
+ var _ConnectionSetCommand_instances, _ConnectionSetCommand_initOptions, _ConnectionSetCommand_initValidators, _ConnectionSetCommand_initTypes;
7
7
  import auth from '../../../Auth.js';
8
8
  import commands from '../commands.js';
9
9
  import Command, { CommandError } from '../../../Command.js';
@@ -19,6 +19,7 @@ class ConnectionSetCommand extends Command {
19
19
  _ConnectionSetCommand_instances.add(this);
20
20
  __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initOptions).call(this);
21
21
  __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initValidators).call(this);
22
+ __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initTypes).call(this);
22
23
  }
23
24
  async commandAction(logger, args) {
24
25
  const connection = await auth.getConnection(args.options.name);
@@ -51,6 +52,8 @@ _ConnectionSetCommand_instances = new WeakSet(), _ConnectionSetCommand_initOptio
51
52
  }
52
53
  return true;
53
54
  });
55
+ }, _ConnectionSetCommand_initTypes = function _ConnectionSetCommand_initTypes() {
56
+ this.types.string.push('name', 'newName');
54
57
  };
55
58
  export default new ConnectionSetCommand();
56
59
  //# sourceMappingURL=connection-set.js.map
@@ -3,10 +3,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _ConnectionUseCommand_instances, _ConnectionUseCommand_initOptions;
6
+ var _ConnectionUseCommand_instances, _ConnectionUseCommand_initTelemetry, _ConnectionUseCommand_initOptions, _ConnectionUseCommand_initTypes;
7
7
  import auth from '../../../Auth.js';
8
8
  import commands from '../commands.js';
9
9
  import Command, { CommandError } from '../../../Command.js';
10
+ import { formatting } from '../../../utils/formatting.js';
11
+ import { cli } from '../../../cli/cli.js';
10
12
  class ConnectionUseCommand extends Command {
11
13
  get name() {
12
14
  return commands.USE;
@@ -18,9 +20,20 @@ class ConnectionUseCommand extends Command {
18
20
  super();
19
21
  _ConnectionUseCommand_instances.add(this);
20
22
  __classPrivateFieldGet(this, _ConnectionUseCommand_instances, "m", _ConnectionUseCommand_initOptions).call(this);
23
+ __classPrivateFieldGet(this, _ConnectionUseCommand_instances, "m", _ConnectionUseCommand_initTelemetry).call(this);
24
+ __classPrivateFieldGet(this, _ConnectionUseCommand_instances, "m", _ConnectionUseCommand_initTypes).call(this);
21
25
  }
22
26
  async commandAction(logger, args) {
23
- const connection = await auth.getConnection(args.options.name);
27
+ let connection;
28
+ if (args.options.name) {
29
+ connection = await auth.getConnection(args.options.name);
30
+ }
31
+ else {
32
+ const connections = await auth.getAllConnections();
33
+ connections.sort((a, b) => a.name.localeCompare(b.name));
34
+ const keyValuePair = formatting.convertArrayToHashTable('name', connections);
35
+ connection = await cli.handleMultipleResultsFound('Please select the connection you want to activate.', keyValuePair);
36
+ }
24
37
  if (this.verbose) {
25
38
  await logger.logToStderr(`Switching to connection '${connection.identityName}', appId: ${connection.appId}, tenantId: ${connection.identityTenantId}...`);
26
39
  }
@@ -42,10 +55,18 @@ class ConnectionUseCommand extends Command {
42
55
  await this.commandAction(logger, args);
43
56
  }
44
57
  }
45
- _ConnectionUseCommand_instances = new WeakSet(), _ConnectionUseCommand_initOptions = function _ConnectionUseCommand_initOptions() {
58
+ _ConnectionUseCommand_instances = new WeakSet(), _ConnectionUseCommand_initTelemetry = function _ConnectionUseCommand_initTelemetry() {
59
+ this.telemetry.push((args) => {
60
+ Object.assign(this.telemetryProperties, {
61
+ name: typeof args.options.name !== 'undefined'
62
+ });
63
+ });
64
+ }, _ConnectionUseCommand_initOptions = function _ConnectionUseCommand_initOptions() {
46
65
  this.options.unshift({
47
- option: '-n, --name <name>'
66
+ option: '-n, --name [name]'
48
67
  });
68
+ }, _ConnectionUseCommand_initTypes = function _ConnectionUseCommand_initTypes() {
69
+ this.types.string.push('name');
49
70
  };
50
71
  export default new ConnectionUseCommand();
51
72
  //# sourceMappingURL=connection-use.js.map
@@ -65,7 +65,7 @@ class EntraGroupUserListCommand extends GraphCommand {
65
65
  if (this.verbose) {
66
66
  await logger.logToStderr('Retrieving Group Id...');
67
67
  }
68
- return await entraGroup.getGroupIdByDisplayName(options.groupDisplayName);
68
+ return await entraGroup.getGroupIdByDisplayName(options.groupName);
69
69
  }
70
70
  async getUsers(options, role, groupId, logger) {
71
71
  const { properties, filter } = options;
@@ -111,7 +111,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
111
111
  this.telemetry.push((args) => {
112
112
  Object.assign(this.telemetryProperties, {
113
113
  groupId: typeof args.options.groupId !== 'undefined',
114
- groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
114
+ groupName: typeof args.options.groupName !== 'undefined',
115
115
  role: typeof args.options.role !== 'undefined',
116
116
  properties: typeof args.options.properties !== 'undefined',
117
117
  filter: typeof args.options.filter !== 'undefined'
@@ -121,7 +121,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
121
121
  this.options.unshift({
122
122
  option: "-i, --groupId [groupId]"
123
123
  }, {
124
- option: "-n, --groupDisplayName [groupDisplayName]"
124
+ option: "-n, --groupName [groupName]"
125
125
  }, {
126
126
  option: "-r, --role [role]",
127
127
  autocomplete: ["Owner", "Member"]
@@ -132,7 +132,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
132
132
  });
133
133
  }, _EntraGroupUserListCommand_initOptionSets = function _EntraGroupUserListCommand_initOptionSets() {
134
134
  this.optionSets.push({
135
- options: ['groupId', 'groupDisplayName']
135
+ options: ['groupId', 'groupName']
136
136
  });
137
137
  }, _EntraGroupUserListCommand_initValidators = function _EntraGroupUserListCommand_initValidators() {
138
138
  this.validators.push(async (args) => {
@@ -51,7 +51,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand {
51
51
  if (args.options.groupId) {
52
52
  return formatting.encodeQueryParameter(args.options.groupId);
53
53
  }
54
- const group = await entraGroup.getGroupByDisplayName(args.options.groupDisplayName);
54
+ const group = await entraGroup.getGroupByDisplayName(args.options.groupName);
55
55
  return group.id;
56
56
  }
57
57
  }
@@ -59,14 +59,14 @@ _EntraM365GroupConversationPostListCommand_instances = new WeakSet(), _EntraM365
59
59
  this.telemetry.push((args) => {
60
60
  Object.assign(this.telemetryProperties, {
61
61
  groupId: typeof args.options.groupId !== 'undefined',
62
- groupDisplayName: typeof args.options.groupDisplayName !== 'undefined'
62
+ groupName: typeof args.options.groupName !== 'undefined'
63
63
  });
64
64
  });
65
65
  }, _EntraM365GroupConversationPostListCommand_initOptions = function _EntraM365GroupConversationPostListCommand_initOptions() {
66
66
  this.options.unshift({
67
67
  option: '-i, --groupId [groupId]'
68
68
  }, {
69
- option: '-d, --groupDisplayName [groupDisplayName]'
69
+ option: '-d, --groupName [groupName]'
70
70
  }, {
71
71
  option: '-t, --threadId <threadId>'
72
72
  });
@@ -78,7 +78,7 @@ _EntraM365GroupConversationPostListCommand_instances = new WeakSet(), _EntraM365
78
78
  return true;
79
79
  });
80
80
  }, _EntraM365GroupConversationPostListCommand_initOptionSets = function _EntraM365GroupConversationPostListCommand_initOptionSets() {
81
- this.optionSets.push({ options: ['groupId', 'groupDisplayName'] });
81
+ this.optionSets.push({ options: ['groupId', 'groupName'] });
82
82
  };
83
83
  export default new EntraM365GroupConversationPostListCommand();
84
84
  //# sourceMappingURL=m365group-conversation-post-list.js.map
@@ -32,7 +32,7 @@ class EntraM365GroupRecycleBinItemListCommand extends GraphCommand {
32
32
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_RECYCLEBINITEM_LIST, commands.M365GROUP_RECYCLEBINITEM_LIST);
33
33
  try {
34
34
  const filter = `?$filter=groupTypes/any(c:c+eq+'Unified')`;
35
- const displayNameFilter = args.options.groupDisplayName ? ` and startswith(DisplayName,'${formatting.encodeQueryParameter(args.options.groupDisplayName).replace(/'/g, `''`)}')` : '';
35
+ const displayNameFilter = args.options.groupName ? ` and startswith(DisplayName,'${formatting.encodeQueryParameter(args.options.groupName).replace(/'/g, `''`)}')` : '';
36
36
  const mailNicknameFilter = args.options.groupMailNickname ? ` and startswith(MailNickname,'${formatting.encodeQueryParameter(args.options.groupMailNickname).replace(/'/g, `''`)}')` : '';
37
37
  const topCount = '&$top=100';
38
38
  const endpoint = `${this.resource}/v1.0/directory/deletedItems/Microsoft.Graph.Group${filter}${displayNameFilter}${mailNicknameFilter}${topCount}`;
@@ -47,13 +47,13 @@ class EntraM365GroupRecycleBinItemListCommand extends GraphCommand {
47
47
  _EntraM365GroupRecycleBinItemListCommand_instances = new WeakSet(), _EntraM365GroupRecycleBinItemListCommand_initTelemetry = function _EntraM365GroupRecycleBinItemListCommand_initTelemetry() {
48
48
  this.telemetry.push((args) => {
49
49
  Object.assign(this.telemetryProperties, {
50
- groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
50
+ groupName: typeof args.options.groupName !== 'undefined',
51
51
  groupMailNickname: typeof args.options.groupMailNickname !== 'undefined'
52
52
  });
53
53
  });
54
54
  }, _EntraM365GroupRecycleBinItemListCommand_initOptions = function _EntraM365GroupRecycleBinItemListCommand_initOptions() {
55
55
  this.options.unshift({
56
- option: '-d, --groupDisplayName [groupDisplayName]'
56
+ option: '-d, --groupName [groupName]'
57
57
  }, {
58
58
  option: '-m, --groupMailNickname [groupMailNickname]'
59
59
  });
@@ -13,6 +13,8 @@ import GraphCommand from '../../../base/GraphCommand.js';
13
13
  import commands from '../../commands.js';
14
14
  import { entraGroup } from '../../../../utils/entraGroup.js';
15
15
  import aadCommands from '../../aadCommands.js';
16
+ import { accessToken } from '../../../../utils/accessToken.js';
17
+ import auth from '../../../../Auth.js';
16
18
  class EntraM365GroupSetCommand extends GraphCommand {
17
19
  get name() {
18
20
  return commands.M365GROUP_SET;
@@ -35,22 +37,22 @@ class EntraM365GroupSetCommand extends GraphCommand {
35
37
  async commandAction(logger, args) {
36
38
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_SET, commands.M365GROUP_SET);
37
39
  try {
40
+ if ((args.options.allowExternalSenders !== undefined || args.options.autoSubscribeNewMembers !== undefined) && accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken)) {
41
+ throw `Option 'allowExternalSenders' and 'autoSubscribeNewMembers' can only be used when using delegated permissions.`;
42
+ }
38
43
  const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.id);
39
44
  if (!isUnifiedGroup) {
40
45
  throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
41
46
  }
42
- if (args.options.displayName || args.options.description || typeof args.options.isPrivate !== 'undefined') {
43
- if (this.verbose) {
44
- await logger.logToStderr(`Updating Microsoft 365 Group ${args.options.id}...`);
45
- }
46
- const update = {};
47
- if (args.options.displayName) {
48
- update.displayName = args.options.displayName;
49
- }
50
- if (args.options.description) {
51
- update.description = args.options.description;
52
- }
53
- if (typeof args.options.isPrivate !== 'undefined') {
47
+ if (this.verbose) {
48
+ await logger.logToStderr(`Updating Microsoft 365 Group ${args.options.id}...`);
49
+ }
50
+ if (args.options.displayName || args.options.description !== undefined || args.options.isPrivate !== undefined) {
51
+ const update = {
52
+ displayName: args.options.displayName,
53
+ description: args.options.description !== '' ? args.options.description : null
54
+ };
55
+ if (args.options.isPrivate !== undefined) {
54
56
  update.visibility = args.options.isPrivate ? 'Private' : 'Public';
55
57
  }
56
58
  const requestOptions = {
@@ -63,6 +65,24 @@ class EntraM365GroupSetCommand extends GraphCommand {
63
65
  };
64
66
  await request.patch(requestOptions);
65
67
  }
68
+ // This has to be a separate request due to some Graph API limitations. Otherwise it will throw an error.
69
+ if (args.options.allowExternalSenders !== undefined || args.options.autoSubscribeNewMembers !== undefined || args.options.hideFromAddressLists !== undefined || args.options.hideFromOutlookClients !== undefined) {
70
+ const requestBody = {
71
+ allowExternalSenders: args.options.allowExternalSenders,
72
+ autoSubscribeNewMembers: args.options.autoSubscribeNewMembers,
73
+ hideFromAddressLists: args.options.hideFromAddressLists,
74
+ hideFromOutlookClients: args.options.hideFromOutlookClients
75
+ };
76
+ const requestOptions = {
77
+ url: `${this.resource}/v1.0/groups/${args.options.id}`,
78
+ headers: {
79
+ accept: 'application/json;odata.metadata=none'
80
+ },
81
+ responseType: 'json',
82
+ data: requestBody
83
+ };
84
+ await request.patch(requestOptions);
85
+ }
66
86
  if (args.options.logoPath) {
67
87
  const fullPath = path.resolve(args.options.logoPath);
68
88
  if (this.verbose) {
@@ -172,8 +192,12 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
172
192
  description: typeof args.options.description !== 'undefined',
173
193
  owners: typeof args.options.owners !== 'undefined',
174
194
  members: typeof args.options.members !== 'undefined',
175
- isPrivate: args.options.isPrivate,
176
- logoPath: typeof args.options.logoPath !== 'undefined'
195
+ isPrivate: !!args.options.isPrivate,
196
+ logoPath: typeof args.options.logoPath !== 'undefined',
197
+ allowExternalSenders: !!args.options.allowExternalSenders,
198
+ autoSubscribeNewMembers: !!args.options.autoSubscribeNewMembers,
199
+ hideFromAddressLists: !!args.options.hideFromAddressLists,
200
+ hideFromOutlookClients: !!args.options.hideFromOutlookClients
177
201
  });
178
202
  });
179
203
  }, _EntraM365GroupSetCommand_initOptions = function _EntraM365GroupSetCommand_initOptions() {
@@ -192,36 +216,49 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
192
216
  autocomplete: ['true', 'false']
193
217
  }, {
194
218
  option: '-l, --logoPath [logoPath]'
219
+ }, {
220
+ option: '--allowExternalSenders [allowExternalSenders]',
221
+ autocomplete: ['true', 'false']
222
+ }, {
223
+ option: '--autoSubscribeNewMembers [autoSubscribeNewMembers]',
224
+ autocomplete: ['true', 'false']
225
+ }, {
226
+ option: '--hideFromAddressLists [hideFromAddressLists]',
227
+ autocomplete: ['true', 'false']
228
+ }, {
229
+ option: '--hideFromOutlookClients [hideFromOutlookClients]',
230
+ autocomplete: ['true', 'false']
195
231
  });
196
232
  }, _EntraM365GroupSetCommand_initTypes = function _EntraM365GroupSetCommand_initTypes() {
197
- this.types.boolean.push('isPrivate');
233
+ this.types.boolean.push('isPrivate', 'allowEternalSenders', 'autoSubscribeNewMembers', 'hideFromAddressLists', 'hideFromOutlookClients');
234
+ this.types.string.push('id', 'displayName', 'description', 'owners', 'members', 'logoPath');
198
235
  }, _EntraM365GroupSetCommand_initValidators = function _EntraM365GroupSetCommand_initValidators() {
199
236
  this.validators.push(async (args) => {
200
237
  if (!args.options.displayName &&
201
- !args.options.description &&
238
+ args.options.description === undefined &&
202
239
  !args.options.members &&
203
240
  !args.options.owners &&
204
- typeof args.options.isPrivate === 'undefined' &&
205
- !args.options.logoPath) {
206
- return 'Specify at least one property to update';
241
+ args.options.isPrivate === undefined &&
242
+ !args.options.logoPath &&
243
+ args.options.allowExternalSenders === undefined &&
244
+ args.options.autoSubscribeNewMembers === undefined &&
245
+ args.options.hideFromAddressLists === undefined &&
246
+ args.options.hideFromOutlookClients === undefined) {
247
+ return 'Specify at least one option to update.';
207
248
  }
208
249
  if (!validation.isValidGuid(args.options.id)) {
209
250
  return `${args.options.id} is not a valid GUID`;
210
251
  }
211
252
  if (args.options.owners) {
212
- const owners = args.options.owners.split(',').map(o => o.trim());
213
- for (let i = 0; i < owners.length; i++) {
214
- if (owners[i].indexOf('@') < 0) {
215
- return `${owners[i]} is not a valid userPrincipalName`;
216
- }
253
+ const isValidArray = validation.isValidUserPrincipalNameArray(args.options.owners);
254
+ if (isValidArray !== true) {
255
+ return `Option 'owners' contains one or more invalid UPNs: ${isValidArray}.`;
217
256
  }
218
257
  }
219
258
  if (args.options.members) {
220
- const members = args.options.members.split(',').map(m => m.trim());
221
- for (let i = 0; i < members.length; i++) {
222
- if (members[i].indexOf('@') < 0) {
223
- return `${members[i]} is not a valid userPrincipalName`;
224
- }
259
+ const isValidArray = validation.isValidUserPrincipalNameArray(args.options.members);
260
+ if (isValidArray !== true) {
261
+ return `Option 'members' contains one or more invalid UPNs: ${isValidArray}.`;
225
262
  }
226
263
  }
227
264
  if (args.options.logoPath) {
@@ -31,9 +31,6 @@ class EntraM365GroupUserListCommand extends GraphCommand {
31
31
  async commandAction(logger, args) {
32
32
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_LIST, commands.M365GROUP_USER_LIST);
33
33
  try {
34
- if (args.options.role === 'Guest') {
35
- await this.warn(logger, `Value 'Guest' for the option role is deprecated. Use --filter "userType eq 'Guest'" instead.`);
36
- }
37
34
  const groupId = await this.getGroupId(args.options, logger);
38
35
  const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
39
36
  if (!isUnifiedGroup) {
@@ -42,9 +39,9 @@ class EntraM365GroupUserListCommand extends GraphCommand {
42
39
  let users = [];
43
40
  if (!args.options.role || args.options.role === 'Owner') {
44
41
  const owners = await this.getUsers(args.options, 'Owners', groupId, logger);
45
- owners.forEach(owner => users.push({ ...owner, roles: ['Owner'], userType: 'Owner' }));
42
+ owners.forEach(owner => users.push({ ...owner, roles: ['Owner'] }));
46
43
  }
47
- if (!args.options.role || args.options.role === 'Member' || args.options.role === 'Guest') {
44
+ if (!args.options.role || args.options.role === 'Member') {
48
45
  const members = await this.getUsers(args.options, 'Members', groupId, logger);
49
46
  members.forEach((member) => {
50
47
  const user = users.find((u) => u.id === member.id);
@@ -57,7 +54,7 @@ class EntraM365GroupUserListCommand extends GraphCommand {
57
54
  });
58
55
  }
59
56
  if (args.options.role) {
60
- users = users.filter(i => i.userType === args.options.role);
57
+ users = users.filter(i => i.roles.indexOf(args.options.role) > -1);
61
58
  }
62
59
  await logger.log(users);
63
60
  }
@@ -128,7 +125,7 @@ _EntraM365GroupUserListCommand_instances = new WeakSet(), _EntraM365GroupUserLis
128
125
  option: "-n, --groupDisplayName [groupDisplayName]"
129
126
  }, {
130
127
  option: "-r, --role [type]",
131
- autocomplete: ["Owner", "Member", "Guest"]
128
+ autocomplete: ["Owner", "Member"]
132
129
  }, {
133
130
  option: "-p, --properties [properties]"
134
131
  }, {
@@ -144,8 +141,8 @@ _EntraM365GroupUserListCommand_instances = new WeakSet(), _EntraM365GroupUserLis
144
141
  return `${args.options.groupId} is not a valid GUID`;
145
142
  }
146
143
  if (args.options.role) {
147
- if (['Owner', 'Member', 'Guest'].indexOf(args.options.role) === -1) {
148
- return `${args.options.role} is not a valid role value. Allowed values Owner|Member|Guest`;
144
+ if (['Owner', 'Member'].indexOf(args.options.role) === -1) {
145
+ return `${args.options.role} is not a valid role value. Allowed values Owner|Member`;
149
146
  }
150
147
  }
151
148
  return true;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MultitenantOrganization.js.map