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

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 (67) 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 +9 -17
  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/commands/login.js +44 -96
  9. package/dist/m365/commands/setup.js +0 -4
  10. package/dist/m365/entra/commands/m365group/m365group-set.js +66 -29
  11. package/dist/m365/entra/commands/multitenant/MultitenantOrganization.js +2 -0
  12. package/dist/m365/entra/commands/multitenant/multitenant-get.js +32 -0
  13. package/dist/m365/entra/commands.js +1 -0
  14. package/dist/m365/external/commands/connection/connection-doctor.js +10 -24
  15. package/dist/m365/flow/commands/flow-list.js +23 -24
  16. package/dist/m365/graph/commands/subscription/subscription-add.js +4 -2
  17. package/dist/m365/spe/ContainerTypeProperties.js +2 -0
  18. package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
  19. package/dist/m365/spe/commands.js +2 -1
  20. package/dist/m365/spfx/commands/project/base-project-command.js +36 -126
  21. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
  22. package/dist/m365/spo/commands/cdn/cdn-get.js +12 -15
  23. package/dist/m365/spo/commands/cdn/cdn-set.js +6 -4
  24. package/dist/m365/spo/commands/commandset/commandset-get.js +31 -17
  25. package/dist/m365/spo/commands/contenttype/contenttype-field-list.js +124 -0
  26. package/dist/m365/spo/commands/field/field-list.js +1 -1
  27. package/dist/m365/spo/commands/group/group-member-add.js +103 -99
  28. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -3
  29. package/dist/m365/spo/commands/page/page-text-add.js +2 -3
  30. package/dist/m365/spo/commands/spo-search.js +3 -4
  31. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
  32. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
  33. package/dist/m365/spo/commands.js +1 -0
  34. package/dist/m365/teams/commands/meeting/meeting-attendancereport-get.js +119 -0
  35. package/dist/m365/teams/commands/message/message-remove.js +112 -0
  36. package/dist/m365/teams/commands.js +2 -0
  37. package/dist/m365/viva/commands/engage/engage-community-add.js +166 -0
  38. package/dist/m365/viva/commands.js +1 -0
  39. package/dist/utils/formatting.js +30 -1
  40. package/dist/utils/teams.js +49 -0
  41. package/dist/utils/validation.js +19 -0
  42. package/dist/utils/zod.js +124 -0
  43. package/docs/docs/cmd/entra/m365group/m365group-set.mdx +37 -7
  44. package/docs/docs/cmd/entra/multitenant/multitenant-get.mdx +94 -0
  45. package/docs/docs/cmd/external/connection/connection-doctor.mdx +9 -9
  46. package/docs/docs/cmd/flow/flow-list.mdx +114 -56
  47. package/docs/docs/cmd/graph/subscription/subscription-add.mdx +18 -0
  48. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +131 -0
  49. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +85 -36
  50. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +18 -24
  51. package/docs/docs/cmd/spo/cdn/cdn-set.mdx +3 -3
  52. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
  53. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
  54. package/docs/docs/cmd/spo/contenttype/contenttype-field-list.mdx +172 -0
  55. package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +3 -3
  56. package/docs/docs/cmd/spo/field/field-list.mdx +3 -3
  57. package/docs/docs/cmd/spo/group/group-member-add.mdx +34 -27
  58. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
  59. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
  60. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
  61. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
  62. package/docs/docs/cmd/teams/meeting/meeting-attendancereport-get.mdx +138 -0
  63. package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
  64. package/docs/docs/cmd/teams/message/message-remove.mdx +63 -0
  65. package/docs/docs/cmd/viva/engage/engage-community-add.mdx +168 -0
  66. package/npm-shrinkwrap.json +588 -1022
  67. package/package.json +7 -3
@@ -0,0 +1,112 @@
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 _TeamsMessageRemoveCommand_instances, _TeamsMessageRemoveCommand_initTelemetry, _TeamsMessageRemoveCommand_initOptions, _TeamsMessageRemoveCommand_initValidators, _TeamsMessageRemoveCommand_initOptionSets, _TeamsMessageRemoveCommand_initTypes;
7
+ import { cli } from '../../../../cli/cli.js';
8
+ import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
10
+ import { teams } from '../../../../utils/teams.js';
11
+ import { validation } from '../../../../utils/validation.js';
12
+ import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
13
+ import commands from '../../commands.js';
14
+ class TeamsMessageRemoveCommand extends DelegatedGraphCommand {
15
+ get name() {
16
+ return commands.MESSAGE_REMOVE;
17
+ }
18
+ get description() {
19
+ return 'Removes a message from a channel in a Microsoft Teams team';
20
+ }
21
+ constructor() {
22
+ super();
23
+ _TeamsMessageRemoveCommand_instances.add(this);
24
+ __classPrivateFieldGet(this, _TeamsMessageRemoveCommand_instances, "m", _TeamsMessageRemoveCommand_initTelemetry).call(this);
25
+ __classPrivateFieldGet(this, _TeamsMessageRemoveCommand_instances, "m", _TeamsMessageRemoveCommand_initOptions).call(this);
26
+ __classPrivateFieldGet(this, _TeamsMessageRemoveCommand_instances, "m", _TeamsMessageRemoveCommand_initValidators).call(this);
27
+ __classPrivateFieldGet(this, _TeamsMessageRemoveCommand_instances, "m", _TeamsMessageRemoveCommand_initOptionSets).call(this);
28
+ __classPrivateFieldGet(this, _TeamsMessageRemoveCommand_instances, "m", _TeamsMessageRemoveCommand_initTypes).call(this);
29
+ }
30
+ async commandAction(logger, args) {
31
+ const removeTeamMessage = async () => {
32
+ try {
33
+ if (this.verbose) {
34
+ await logger.logToStderr(`Removing message '${args.options.id}' from channel '${args.options.channelId || args.options.channelName}' in team '${args.options.teamId || args.options.teamName}'.`);
35
+ }
36
+ const teamId = args.options.teamId || await teams.getTeamIdByDisplayName(args.options.teamName);
37
+ const channelId = args.options.channelId || await teams.getChannelIdByDisplayName(teamId, args.options.channelName);
38
+ const requestOptions = {
39
+ url: `${this.resource}/v1.0/teams/${teamId}/channels/${formatting.encodeQueryParameter(channelId)}/messages/${args.options.id}/softDelete`,
40
+ headers: {
41
+ accept: 'application/json;odata.metadata=none'
42
+ },
43
+ responseType: 'json'
44
+ };
45
+ await request.post(requestOptions);
46
+ }
47
+ catch (err) {
48
+ if (err.error?.error?.code === 'NotFound') {
49
+ this.handleError('The message was not found in the Teams channel.');
50
+ }
51
+ else {
52
+ this.handleRejectedODataJsonPromise(err);
53
+ }
54
+ }
55
+ };
56
+ if (args.options.force) {
57
+ await removeTeamMessage();
58
+ }
59
+ else {
60
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove this message?` });
61
+ if (result) {
62
+ await removeTeamMessage();
63
+ }
64
+ }
65
+ }
66
+ }
67
+ _TeamsMessageRemoveCommand_instances = new WeakSet(), _TeamsMessageRemoveCommand_initTelemetry = function _TeamsMessageRemoveCommand_initTelemetry() {
68
+ this.telemetry.push((args) => {
69
+ Object.assign(this.telemetryProperties, {
70
+ teamId: typeof args.options.teamId !== 'undefined',
71
+ teamName: typeof args.options.teamName !== 'undefined',
72
+ channelId: typeof args.options.channelId !== 'undefined',
73
+ channelName: typeof args.options.channelName !== 'undefined',
74
+ force: !!args.options.force
75
+ });
76
+ });
77
+ }, _TeamsMessageRemoveCommand_initOptions = function _TeamsMessageRemoveCommand_initOptions() {
78
+ this.options.unshift({
79
+ option: '--teamId [teamId]'
80
+ }, {
81
+ option: '--teamName [teamName]'
82
+ }, {
83
+ option: '--channelId [channelId]'
84
+ }, {
85
+ option: '--channelName [channelName]'
86
+ }, {
87
+ option: '-i, --id <id>'
88
+ }, {
89
+ option: '-f, --force'
90
+ });
91
+ }, _TeamsMessageRemoveCommand_initValidators = function _TeamsMessageRemoveCommand_initValidators() {
92
+ this.validators.push(async (args) => {
93
+ if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
94
+ return `'${args.options.teamId}' is not a valid GUID for 'teamId'.`;
95
+ }
96
+ if (args.options.channelId && !validation.isValidTeamsChannelId(args.options.channelId)) {
97
+ return `'${args.options.channelId}' is not a valid ID for 'channelId'.`;
98
+ }
99
+ return true;
100
+ });
101
+ }, _TeamsMessageRemoveCommand_initOptionSets = function _TeamsMessageRemoveCommand_initOptionSets() {
102
+ this.optionSets.push({
103
+ options: ['teamId', 'teamName']
104
+ }, {
105
+ options: ['channelId', 'channelName']
106
+ });
107
+ }, _TeamsMessageRemoveCommand_initTypes = function _TeamsMessageRemoveCommand_initTypes() {
108
+ this.types.string.push('teamId', 'teamName', 'channelId', 'channelName', 'id');
109
+ this.types.boolean.push('force');
110
+ };
111
+ export default new TeamsMessageRemoveCommand();
112
+ //# sourceMappingURL=message-remove.js.map
@@ -30,12 +30,14 @@ export default {
30
30
  MEETING_ADD: `${prefix} meeting add`,
31
31
  MEETING_GET: `${prefix} meeting get`,
32
32
  MEETING_LIST: `${prefix} meeting list`,
33
+ MEETING_ATTENDANCEREPORT_GET: `${prefix} meeting attendancereport get`,
33
34
  MEETING_ATTENDANCEREPORT_LIST: `${prefix} meeting attendancereport list`,
34
35
  MEETING_TRANSCRIPT_LIST: `${prefix} meeting transcript list`,
35
36
  MEMBERSETTINGS_LIST: `${prefix} membersettings list`,
36
37
  MEMBERSETTINGS_SET: `${prefix} membersettings set`,
37
38
  MESSAGE_GET: `${prefix} message get`,
38
39
  MESSAGE_LIST: `${prefix} message list`,
40
+ MESSAGE_REMOVE: `${prefix} message remove`,
39
41
  MESSAGE_REPLY_LIST: `${prefix} message reply list`,
40
42
  MESSAGE_SEND: `${prefix} message send`,
41
43
  MESSAGINGSETTINGS_LIST: `${prefix} messagingsettings list`,
@@ -0,0 +1,166 @@
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 _VivaEngageCommunityAddCommand_instances, _VivaEngageCommunityAddCommand_initTelemetry, _VivaEngageCommunityAddCommand_initOptions, _VivaEngageCommunityAddCommand_initValidators, _VivaEngageCommunityAddCommand_initTypes, _VivaEngageCommunityAddCommand_initOptionSets;
7
+ import GraphCommand from '../../../base/GraphCommand.js';
8
+ import commands from '../../commands.js';
9
+ import request from '../../../../request.js';
10
+ import { validation } from '../../../../utils/validation.js';
11
+ import { accessToken } from '../../../../utils/accessToken.js';
12
+ import auth from '../../../../Auth.js';
13
+ import { formatting } from '../../../../utils/formatting.js';
14
+ import { entraUser } from '../../../../utils/entraUser.js';
15
+ import { setTimeout } from 'timers/promises';
16
+ class VivaEngageCommunityAddCommand extends GraphCommand {
17
+ get name() {
18
+ return commands.ENGAGE_COMMUNITY_ADD;
19
+ }
20
+ get description() {
21
+ return 'Creates a new community in Viva Engage';
22
+ }
23
+ constructor() {
24
+ super();
25
+ _VivaEngageCommunityAddCommand_instances.add(this);
26
+ this.pollingInterval = 5000;
27
+ this.privacyOptions = ['public', 'private'];
28
+ __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initTelemetry).call(this);
29
+ __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initOptions).call(this);
30
+ __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initValidators).call(this);
31
+ __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initTypes).call(this);
32
+ __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initOptionSets).call(this);
33
+ }
34
+ async commandAction(logger, args) {
35
+ const { displayName, description, privacy, adminEntraIds, adminEntraUserNames, wait } = args.options;
36
+ const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken);
37
+ if (isAppOnlyAccessToken && !adminEntraIds && !adminEntraUserNames) {
38
+ this.handleError(`Specify at least one admin using either adminEntraIds or adminEntraUserNames options when using application permissions.`);
39
+ }
40
+ if (this.verbose) {
41
+ await logger.logToStderr(`Creating a Viva Engage community with display name '${displayName}'...`);
42
+ }
43
+ try {
44
+ const requestOptions = {
45
+ url: `${this.resource}/beta/employeeExperience/communities`,
46
+ headers: {
47
+ accept: 'application/json;odata.metadata=none',
48
+ 'content-type': 'application/json'
49
+ },
50
+ responseType: 'json',
51
+ fullResponse: true,
52
+ data: {
53
+ displayName: displayName,
54
+ description: description,
55
+ privacy: privacy
56
+ }
57
+ };
58
+ const entraIds = await this.getGraphUserUrls(args.options);
59
+ if (entraIds.length > 0) {
60
+ requestOptions.data['owners@odata.bind'] = entraIds;
61
+ }
62
+ const res = await request.post(requestOptions);
63
+ const location = res.headers.location;
64
+ if (!wait) {
65
+ await logger.log(location);
66
+ return;
67
+ }
68
+ let status;
69
+ do {
70
+ if (this.verbose) {
71
+ await logger.logToStderr(`Community still provisioning. Retrying in ${this.pollingInterval / 1000} seconds...`);
72
+ }
73
+ await setTimeout(this.pollingInterval);
74
+ if (this.verbose) {
75
+ await logger.logToStderr(`Checking create community operation status...`);
76
+ }
77
+ const operation = await request.get({
78
+ url: location,
79
+ headers: {
80
+ accept: 'application/json;odata.metadata=none'
81
+ },
82
+ responseType: 'json'
83
+ });
84
+ status = operation.status;
85
+ if (this.verbose) {
86
+ await logger.logToStderr(`Community creation operation status: ${status}`);
87
+ }
88
+ if (status === 'failed') {
89
+ throw `Community creation failed: ${operation.statusDetail}`;
90
+ }
91
+ if (status === 'succeeded') {
92
+ await logger.log(operation);
93
+ }
94
+ } while (status === 'notStarted' || status === 'running');
95
+ }
96
+ catch (err) {
97
+ this.handleRejectedODataJsonPromise(err);
98
+ }
99
+ }
100
+ async getGraphUserUrls(options) {
101
+ let entraIds = [];
102
+ if (options.adminEntraIds) {
103
+ entraIds = formatting.splitAndTrim(options.adminEntraIds);
104
+ }
105
+ else if (options.adminEntraUserNames) {
106
+ entraIds = await entraUser.getUserIdsByUpns(formatting.splitAndTrim(options.adminEntraUserNames));
107
+ }
108
+ const graphUserUrls = entraIds.map(id => `${this.resource}/beta/users/${id}`);
109
+ return graphUserUrls;
110
+ }
111
+ }
112
+ _VivaEngageCommunityAddCommand_instances = new WeakSet(), _VivaEngageCommunityAddCommand_initTelemetry = function _VivaEngageCommunityAddCommand_initTelemetry() {
113
+ this.telemetry.push((args) => {
114
+ Object.assign(this.telemetryProperties, {
115
+ adminEntraIds: typeof args.options.adminEntraIds !== 'undefined',
116
+ adminEntraUserNames: typeof args.options.adminEntraUserNames !== 'undefined',
117
+ wait: !!args.options.wait
118
+ });
119
+ });
120
+ }, _VivaEngageCommunityAddCommand_initOptions = function _VivaEngageCommunityAddCommand_initOptions() {
121
+ this.options.unshift({ option: '--displayName <displayName>' }, { option: '--description <description>' }, {
122
+ option: '--privacy <privacy>',
123
+ autocomplete: this.privacyOptions
124
+ }, { option: '--adminEntraIds [adminEntraIds]' }, { option: '--adminEntraUserNames [adminEntraUserNames]' }, { option: '--wait' });
125
+ }, _VivaEngageCommunityAddCommand_initValidators = function _VivaEngageCommunityAddCommand_initValidators() {
126
+ this.validators.push(async (args) => {
127
+ if (args.options.displayName.length > 255) {
128
+ return `The maximum amount of characters for 'displayName' is 255.`;
129
+ }
130
+ if (args.options.description.length > 1024) {
131
+ return `The maximum amount of characters for 'description' is 1024.`;
132
+ }
133
+ if (this.privacyOptions.indexOf(args.options.privacy) === -1) {
134
+ return `'${args.options.privacy}' is not a valid value for privacy. Allowed values are: ${this.privacyOptions.join(', ')}.`;
135
+ }
136
+ if (args.options.adminEntraIds) {
137
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.adminEntraIds);
138
+ if (isValidGUIDArrayResult !== true) {
139
+ return `The following GUIDs are invalid for the option 'adminEntraIds': ${isValidGUIDArrayResult}.`;
140
+ }
141
+ if (formatting.splitAndTrim(args.options.adminEntraIds).length > 20) {
142
+ return `Maximum of 20 admins allowed. Please reduce the number of users and try again.`;
143
+ }
144
+ }
145
+ if (args.options.adminEntraUserNames) {
146
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.adminEntraUserNames);
147
+ if (isValidUPNArrayResult !== true) {
148
+ return `The following user principal names are invalid for the option 'adminEntraUserNames': ${isValidUPNArrayResult}.`;
149
+ }
150
+ if (formatting.splitAndTrim(args.options.adminEntraUserNames).length > 20) {
151
+ return `Maximum of 20 admins allowed. Please reduce the number of users and try again.`;
152
+ }
153
+ }
154
+ return true;
155
+ });
156
+ }, _VivaEngageCommunityAddCommand_initTypes = function _VivaEngageCommunityAddCommand_initTypes() {
157
+ this.types.string.push('displayName', 'description', 'privacy', 'adminEntraIds', 'adminEntraUserNames');
158
+ this.types.boolean.push('wait');
159
+ }, _VivaEngageCommunityAddCommand_initOptionSets = function _VivaEngageCommunityAddCommand_initOptionSets() {
160
+ this.optionSets.push({
161
+ options: ['adminEntraIds', 'adminEntraUserNames'],
162
+ runsWhen: (args) => args.options.adminEntraIds || args.options.adminEntraUserNames
163
+ });
164
+ };
165
+ export default new VivaEngageCommunityAddCommand();
166
+ //# sourceMappingURL=engage-community-add.js.map
@@ -1,6 +1,7 @@
1
1
  const prefix = 'viva';
2
2
  export default {
3
3
  CONNECTIONS_APP_CREATE: `${prefix} connections app create`,
4
+ ENGAGE_COMMUNITY_ADD: `${prefix} engage community add`,
4
5
  ENGAGE_COMMUNITY_GET: `${prefix} engage community get`,
5
6
  ENGAGE_GROUP_LIST: `${prefix} engage group list`,
6
7
  ENGAGE_GROUP_USER_ADD: `${prefix} engage group user add`,
@@ -9,6 +9,8 @@ export var CheckStatus;
9
9
  (function (CheckStatus) {
10
10
  CheckStatus[CheckStatus["Success"] = 0] = "Success";
11
11
  CheckStatus[CheckStatus["Failure"] = 1] = "Failure";
12
+ CheckStatus[CheckStatus["Information"] = 2] = "Information";
13
+ CheckStatus[CheckStatus["Warning"] = 3] = "Warning";
12
14
  })(CheckStatus || (CheckStatus = {}));
13
15
  export const formatting = {
14
16
  escapeXml(s) {
@@ -37,6 +39,22 @@ export const formatting = {
37
39
  parseJsonWithBom(s) {
38
40
  return JSON.parse(s.replace(/^\uFEFF/, ''));
39
41
  },
42
+ /**
43
+ * Tries to parse a string as JSON. If it fails, returns the original string.
44
+ * @param value JSON string to parse.
45
+ * @returns JSON object or the original string if parsing fails.
46
+ */
47
+ tryParseJson(value) {
48
+ try {
49
+ if (typeof value !== 'string') {
50
+ return value;
51
+ }
52
+ return JSON.parse(value);
53
+ }
54
+ catch {
55
+ return value;
56
+ }
57
+ },
40
58
  filterObject(obj, propertiesToInclude) {
41
59
  const objKeys = Object.keys(obj);
42
60
  return propertiesToInclude
@@ -152,7 +170,18 @@ export const formatting = {
152
170
  process.env.TERM === 'xterm-256color';
153
171
  const success = primarySupported ? '✔' : '√';
154
172
  const failure = primarySupported ? '✖' : '×';
155
- return `${result === CheckStatus.Success ? chalk.green(success) : chalk.red(failure)} ${message}`;
173
+ const information = 'i';
174
+ const warning = '!';
175
+ switch (result) {
176
+ case CheckStatus.Success:
177
+ return `${chalk.green(success)} ${message}`;
178
+ case CheckStatus.Failure:
179
+ return `${chalk.red(failure)} ${message}`;
180
+ case CheckStatus.Information:
181
+ return `${chalk.blue(information)} ${message}`;
182
+ case CheckStatus.Warning:
183
+ return `${chalk.yellow(warning)} ${message}`;
184
+ }
156
185
  },
157
186
  convertArrayToHashTable(key, array) {
158
187
  const resultAsKeyValuePair = {};
@@ -0,0 +1,49 @@
1
+ import { formatting } from './formatting.js';
2
+ import { odata } from './odata.js';
3
+ import { cli } from '../cli/cli.js';
4
+ const graphResource = 'https://graph.microsoft.com';
5
+ export const teams = {
6
+ /**
7
+ * Retrieve the id of a team by its name.
8
+ * @param displayName Name of the team to retrieve.
9
+ * @throws Error if the team cannot be found.
10
+ * @throws Error when multiple teams with the same name and prompting is disabled.
11
+ * @returns The ID of the team.
12
+ */
13
+ async getTeamIdByDisplayName(displayName) {
14
+ const teams = await odata.getAllItems(`${graphResource}/v1.0/teams?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'&$select=id`);
15
+ if (!teams.length) {
16
+ throw Error(`The specified team '${displayName}' does not exist.`);
17
+ }
18
+ if (teams.length > 1) {
19
+ const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', teams);
20
+ const result = await cli.handleMultipleResultsFound(`Multiple teams with name '${displayName}' found.`, resultAsKeyValuePair);
21
+ return result.id;
22
+ }
23
+ return teams[0].id;
24
+ },
25
+ /**
26
+ * Retrieves the channel ID by its name in a Microsoft Teams team.
27
+ * @param teamId The ID of the team.
28
+ * @param name The name of the channel.
29
+ * @returns The ID of the channel.
30
+ * @throws Throws an error if the specified channel does not exist in the team.
31
+ */
32
+ async getChannelIdByDisplayName(teamId, name) {
33
+ const channelRequestOptions = {
34
+ url: `${graphResource}/v1.0/teams/${teamId}/channels?$filter=displayName eq '${formatting.encodeQueryParameter(name)}'&$select=id`,
35
+ headers: {
36
+ accept: 'application/json;odata.metadata=none'
37
+ },
38
+ responseType: 'json'
39
+ };
40
+ const response = await odata.getAllItems(channelRequestOptions);
41
+ // Only one channel can have the same name in a team
42
+ const channelItem = response[0];
43
+ if (!channelItem) {
44
+ throw Error(`The channel '${name}' does not exist in the Microsoft Teams team with ID '${teamId}'.`);
45
+ }
46
+ return channelItem.id;
47
+ }
48
+ };
49
+ //# sourceMappingURL=teams.js.map
@@ -1,3 +1,4 @@
1
+ import { formatting } from "./formatting.js";
1
2
  export const validation = {
2
3
  isValidGuidArray(guidsString) {
3
4
  const guids = guidsString.split(',').map(guid => guid.trim());
@@ -33,6 +34,24 @@ export const validation = {
33
34
  // verify if the upn is a valid upn. @meusername will be replaced in a later stage with the actual username of the logged in user
34
35
  return upnRegEx.test(upn) || upn.toLowerCase().trim() === '@meusername';
35
36
  },
37
+ /**
38
+ * Validates if the provided number is a valid positive integer (1 or higher).
39
+ * @param integer Integer value.
40
+ * @returns True if integer, false otherwise.
41
+ */
42
+ isValidPositiveInteger(integer) {
43
+ return !isNaN(Number(integer)) && Number.isInteger(+integer) && +integer > 0;
44
+ },
45
+ /**
46
+ * Validates an array of integers. The integers must be positive (1 or higher).
47
+ * @param integerString Comma-separated string of integers.
48
+ * @returns True if the integers are valid, an error message with the invalid integers otherwise.
49
+ */
50
+ isValidPositiveIntegerArray(integerString) {
51
+ const integers = formatting.splitAndTrim(integerString);
52
+ const invalidIntegers = integers.filter(integer => !this.isValidPositiveInteger(integer));
53
+ return invalidIntegers.length > 0 ? invalidIntegers.join(', ') : true;
54
+ },
36
55
  isDateInRange(date, monthOffset) {
37
56
  const d = new Date(date);
38
57
  const cutoffDate = new Date();
@@ -0,0 +1,124 @@
1
+ import { z } from 'zod';
2
+ function parseEffect(def, _options, _currentOption) {
3
+ return def.schema._def;
4
+ }
5
+ function parseIntersection(def, _options, _currentOption) {
6
+ if (def.left._def.typeName !== z.ZodFirstPartyTypeKind.ZodAny) {
7
+ return def.left._def;
8
+ }
9
+ if (def.right._def.typeName !== z.ZodFirstPartyTypeKind.ZodAny) {
10
+ return def.right._def;
11
+ }
12
+ return;
13
+ }
14
+ function parseObject(def, options, _currentOption) {
15
+ const properties = def.shape();
16
+ for (const key in properties) {
17
+ const property = properties[key];
18
+ const option = {
19
+ name: key,
20
+ long: key,
21
+ short: property._def.alias,
22
+ required: true,
23
+ type: 'string'
24
+ };
25
+ parseDef(property._def, options, option);
26
+ options.push(option);
27
+ }
28
+ return;
29
+ }
30
+ function parseString(_def, _options, currentOption) {
31
+ if (currentOption) {
32
+ currentOption.type = 'string';
33
+ }
34
+ return;
35
+ }
36
+ function parseNumber(_def, _options, currentOption) {
37
+ if (currentOption) {
38
+ currentOption.type = 'number';
39
+ }
40
+ return;
41
+ }
42
+ function parseBoolean(_def, _options, currentOption) {
43
+ if (currentOption) {
44
+ currentOption.type = 'boolean';
45
+ }
46
+ return;
47
+ }
48
+ function parseOptional(def, _options, currentOption) {
49
+ if (currentOption) {
50
+ currentOption.required = false;
51
+ }
52
+ return def.innerType._def;
53
+ }
54
+ function parseDefault(def, _options, currentOption) {
55
+ if (currentOption) {
56
+ currentOption.required = false;
57
+ }
58
+ return def.innerType._def;
59
+ }
60
+ function parseEnum(def, _options, currentOption) {
61
+ if (currentOption) {
62
+ currentOption.type = 'string';
63
+ currentOption.autocomplete = def.values;
64
+ }
65
+ return;
66
+ }
67
+ function parseNativeEnum(def, _options, currentOption) {
68
+ if (currentOption) {
69
+ currentOption.type = 'string';
70
+ currentOption.autocomplete = Object.getOwnPropertyNames(def.values);
71
+ }
72
+ return;
73
+ }
74
+ function getParseFn(typeName) {
75
+ switch (typeName) {
76
+ case z.ZodFirstPartyTypeKind.ZodEffects:
77
+ return parseEffect;
78
+ case z.ZodFirstPartyTypeKind.ZodObject:
79
+ return parseObject;
80
+ case z.ZodFirstPartyTypeKind.ZodOptional:
81
+ return parseOptional;
82
+ case z.ZodFirstPartyTypeKind.ZodString:
83
+ return parseString;
84
+ case z.ZodFirstPartyTypeKind.ZodNumber:
85
+ return parseNumber;
86
+ case z.ZodFirstPartyTypeKind.ZodBoolean:
87
+ return parseBoolean;
88
+ case z.ZodFirstPartyTypeKind.ZodEnum:
89
+ return parseEnum;
90
+ case z.ZodFirstPartyTypeKind.ZodNativeEnum:
91
+ return parseNativeEnum;
92
+ case z.ZodFirstPartyTypeKind.ZodDefault:
93
+ return parseDefault;
94
+ case z.ZodFirstPartyTypeKind.ZodIntersection:
95
+ return parseIntersection;
96
+ default:
97
+ return;
98
+ }
99
+ }
100
+ function parseDef(def, options, currentOption) {
101
+ let parsedDef = def;
102
+ do {
103
+ const parse = getParseFn(parsedDef.typeName);
104
+ if (!parse) {
105
+ break;
106
+ }
107
+ parsedDef = parse(parsedDef, options, currentOption);
108
+ if (!parsedDef) {
109
+ break;
110
+ }
111
+ } while (parsedDef);
112
+ }
113
+ export const zod = {
114
+ alias(alias, type) {
115
+ type._def.alias = alias;
116
+ return type;
117
+ },
118
+ schemaToOptions(schema) {
119
+ const options = [];
120
+ parseDef(schema._def, options);
121
+ return options;
122
+ }
123
+ };
124
+ //# sourceMappingURL=zod.js.map
@@ -35,10 +35,22 @@ m365 aad m365group set [options]
35
35
  : Comma-separated list of Microsoft 365 Group members to add
36
36
 
37
37
  `--isPrivate [isPrivate]`
38
- : Set to true if the Microsoft 365 Group should be private and to false if it should be public (default)
38
+ : Set to `true` if the Microsoft 365 Group should be private and `false` if it should be public.
39
39
 
40
40
  `-l, --logoPath [logoPath]`
41
41
  : Local path to the image file to use as group logo
42
+
43
+ `--allowExternalSenders [allowExternalSenders]`
44
+ : Indicates if people external to the organization can send messages to the group. Valid values: `true`, `false`.
45
+
46
+ `--autoSubscribeNewMembers [autoSubscribeNewMembers]`
47
+ : Indicates if new members added to the group will be auto-subscribed to receive email notifications. Valid values: `true`, `false`.
48
+
49
+ `--hideFromAddressLists [hideFromAddressLists]`
50
+ : Indicates if the group is not displayed in certain parts of the Outlook UI: the Address Book, address lists for selecting message recipients, and the Browse Groups dialog for searching groups. Valid values: `true`, `false`.
51
+
52
+ `--hideFromOutlookClients [hideFromOutlookClients]`
53
+ : Indicates if the group is not displayed in Outlook clients, such as Outlook for Windows and Outlook on the web. Valid values: `true`, `false`.
42
54
  ```
43
55
 
44
56
  <Global />
@@ -49,38 +61,56 @@ When updating group's owners and members, the command will add newly specified u
49
61
 
50
62
  When specifying the path to the logo image you can use both relative and absolute paths. Note, that ~ in the path, will not be resolved and will most likely result in an error.
51
63
 
64
+ :::note
65
+
66
+ Options `allowExternalSenders` and `autoSubscribeNewMembers` can only be set using delegated permissions.
67
+
68
+ :::
69
+
52
70
  ## Examples
53
71
 
54
- Update Microsoft 365 Group display name
72
+ Update Microsoft 365 Group display name.
55
73
 
56
74
  ```sh
57
75
  m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --displayName Finance
58
76
  ```
59
77
 
60
- Change Microsoft 365 Group visibility to public
78
+ Change Microsoft 365 Group visibility to public.
61
79
 
62
80
  ```sh
63
- m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --isPrivate false
81
+ m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --isPrivate `false`
64
82
  ```
65
83
 
66
- Add new Microsoft 365 Group owners
84
+ Add new Microsoft 365 Group owners.
67
85
 
68
86
  ```sh
69
87
  m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --owners "DebraB@contoso.onmicrosoft.com,DiegoS@contoso.onmicrosoft.com"
70
88
  ```
71
89
 
72
- Add new Microsoft 365 Group members
90
+ Add new Microsoft 365 Group members.
73
91
 
74
92
  ```sh
75
93
  m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --members "DebraB@contoso.onmicrosoft.com,DiegoS@contoso.onmicrosoft.com"
76
94
  ```
77
95
 
78
- Update Microsoft 365 Group logo
96
+ Update Microsoft 365 Group logo.
79
97
 
80
98
  ```sh
81
99
  m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --logoPath images/logo.png
82
100
  ```
83
101
 
102
+ Hide the Microsoft 365 group from the address lists and the Outlook clients.
103
+
104
+ ```sh
105
+ m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --hideFromOutlookClients true --hideFromAddressLists true
106
+ ```
107
+
108
+ Auto-subscribe new members to receive email notifications and do not allow external senders to send messages to the group.
109
+
110
+ ```sh
111
+ m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --autoSubscribeNewMembers true --allowExternalSenders false
112
+ ```
113
+
84
114
  ## Response
85
115
 
86
116
  The command won't return a response on success.