@pnp/cli-microsoft365 7.7.0-beta.72886a7 → 7.7.0-beta.7d3ef49

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 (84) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/Command.js +1 -1
  5. package/dist/cli/cli.js +9 -4
  6. package/dist/m365/commands/setup.js +1 -7
  7. package/dist/m365/entra/commands/app/app-add.js +7 -1
  8. package/dist/m365/entra/commands/app/app-set.js +32 -3
  9. package/dist/m365/entra/commands/pim/pim-role-assignment-add.js +233 -0
  10. package/dist/m365/entra/commands/pim/pim-role-assignment-list.js +122 -0
  11. package/dist/m365/entra/commands/user/user-list.js +20 -7
  12. package/dist/m365/entra/commands.js +2 -0
  13. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.0.js +3 -1
  14. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.1.js +3 -1
  15. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.2.js +3 -1
  16. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.0.js +3 -1
  17. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.1.js +3 -1
  18. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.3.js +3 -1
  19. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.10.0.js +3 -1
  20. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.11.0.js +3 -1
  21. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.12.0.js +3 -1
  22. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.12.1.js +3 -1
  23. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.13.0.js +3 -1
  24. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.13.1.js +3 -1
  25. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.14.0.js +3 -1
  26. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.15.0.js +3 -1
  27. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.15.2.js +3 -1
  28. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.16.0.js +3 -1
  29. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.16.1.js +3 -1
  30. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.0.js +3 -1
  31. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.1.js +3 -1
  32. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.2.js +3 -1
  33. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.3.js +3 -1
  34. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.4.js +3 -1
  35. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.0.js +3 -1
  36. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.1.js +3 -1
  37. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.2.js +3 -1
  38. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.19.0-beta.0.js +25 -0
  39. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.2.0.js +3 -1
  40. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.0.js +3 -1
  41. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.1.js +3 -1
  42. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.2.js +3 -1
  43. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.4.js +3 -1
  44. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.4.0.js +3 -1
  45. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.4.1.js +3 -1
  46. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.5.0.js +3 -1
  47. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.5.1.js +3 -1
  48. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.6.0.js +3 -1
  49. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.7.0.js +3 -1
  50. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.7.1.js +3 -1
  51. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.0.js +3 -1
  52. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.1.js +3 -1
  53. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.2.js +3 -1
  54. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.9.1.js +3 -1
  55. package/dist/m365/spfx/commands/project/project-doctor/generic-rules.js +0 -2
  56. package/dist/m365/spfx/commands/project/project-doctor/rules/FN021001_PKG_spfx_deps_versions_match_project_version.js +3 -2
  57. package/dist/m365/spfx/commands/project/project-doctor/rules/FN021013_PKG_spfx_devdeps_match_version.js +58 -0
  58. package/dist/m365/spfx/commands/project/project-doctor/spfx-deps.js +2 -0
  59. package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
  60. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.19.0-beta.0.js +53 -0
  61. package/dist/m365/spfx/commands/project/project-upgrade.js +16 -13
  62. package/dist/m365/spfx/commands/spfx-doctor.js +15 -0
  63. package/dist/m365/spo/commands/contenttype/contenttype-sync.js +139 -0
  64. package/dist/m365/spo/commands/listitem/listitem-set.js +9 -156
  65. package/dist/m365/spo/commands/page/page-add.js +6 -24
  66. package/dist/m365/spo/commands/page/page-set.js +19 -43
  67. package/dist/m365/spo/commands/site/site-apppermission-remove.js +8 -9
  68. package/dist/m365/spo/commands/site/site-hubsite-connect.js +3 -3
  69. package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +2 -5
  70. package/dist/m365/spo/commands.js +1 -0
  71. package/dist/utils/prompt.js +2 -0
  72. package/dist/utils/spo.js +188 -0
  73. package/dist/utils/validation.js +4 -0
  74. package/docs/docs/cmd/entra/app/app-add.mdx +9 -0
  75. package/docs/docs/cmd/entra/app/app-set.mdx +9 -0
  76. package/docs/docs/cmd/entra/pim/pim-role-assignment-add.mdx +230 -0
  77. package/docs/docs/cmd/entra/pim/pim-role-assignment-list.mdx +224 -0
  78. package/docs/docs/cmd/entra/user/user-list.mdx +36 -15
  79. package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
  80. package/docs/docs/cmd/spo/contenttype/contenttype-sync.mdx +144 -0
  81. package/docs/docs/cmd/spo/page/page-set.mdx +1 -1
  82. package/docs/docs/cmd/spo/site/site-apppermission-add.mdx +1 -1
  83. package/npm-shrinkwrap.json +138 -214
  84. package/package.json +14 -14
package/dist/Command.js CHANGED
@@ -545,7 +545,7 @@ _Command_instances = new WeakSet(), _Command_initTelemetry = function _Command_i
545
545
  autocomplete: this.allowedOutputs
546
546
  }, { option: '--verbose' }, { option: '--debug' });
547
547
  }, _Command_initValidators = function _Command_initValidators() {
548
- this.validators.push((args, command) => this.validateUnknownOptions(args, command), (args, command) => this.validateRequiredOptions(args, command), args => this.validateOutput(args), (args, command) => this.validateOptionSets(args, command));
548
+ this.validators.push(args => this.validateOutput(args), (args, command) => this.validateUnknownOptions(args, command), (args, command) => this.validateRequiredOptions(args, command), (args, command) => this.validateOptionSets(args, command));
549
549
  };
550
550
  export default Command;
551
551
  //# sourceMappingURL=Command.js.map
package/dist/cli/cli.js CHANGED
@@ -17,6 +17,7 @@ import { md } from '../utils/md.js';
17
17
  import { validation } from '../utils/validation.js';
18
18
  import { prompt } from '../utils/prompt.js';
19
19
  import { timings } from './timings.js';
20
+ import chalk from 'chalk';
20
21
  const require = createRequire(import.meta.url);
21
22
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
22
23
  let _config;
@@ -96,7 +97,7 @@ async function execute(rawArgs) {
96
97
  parsedArgs.h ||
97
98
  parsedArgs.help) {
98
99
  if (parsedArgs.output !== 'none') {
99
- printHelp(await getHelpMode(parsedArgs));
100
+ await printHelp(await getHelpMode(parsedArgs));
100
101
  }
101
102
  return;
102
103
  }
@@ -546,13 +547,16 @@ function getFirstNonUndefinedArrayItem(arr) {
546
547
  }
547
548
  return undefined;
548
549
  }
549
- function printHelp(helpMode, exitCode = 0) {
550
+ async function printHelp(helpMode, exitCode = 0) {
550
551
  const properties = {};
551
552
  if (cli.commandToExecute) {
552
553
  properties.command = cli.commandToExecute.name;
553
554
  printCommandHelp(helpMode);
554
555
  }
555
556
  else {
557
+ if (cli.currentCommandName && !cli.commands.some(command => command.name.startsWith(cli.currentCommandName))) {
558
+ await cli.error(chalk.red(`Command '${cli.currentCommandName}' was not found. Below you can find the commands and command groups you can use. For detailed information on a command group, use 'm365 [command group] --help'.`));
559
+ }
556
560
  cli.log();
557
561
  cli.log(`CLI for Microsoft 365 v${app.packageJson().version}`);
558
562
  cli.log(`${app.packageJson().description} `);
@@ -732,7 +736,7 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
732
736
  await cli.error(errorMessage);
733
737
  if (showHelpIfEnabled &&
734
738
  await cli.getSettingWithDefaultValue(settingsNames.showHelpOnFailure, showHelpIfEnabled)) {
735
- printHelp(await getHelpMode(args.options), exitCode);
739
+ await printHelp(await getHelpMode(args.options), exitCode);
736
740
  }
737
741
  else {
738
742
  process.exit(exitCode);
@@ -875,7 +879,8 @@ export const cli = {
875
879
  const spinnerOptions = {
876
880
  text: 'Running command...',
877
881
  /* c8 ignore next 1 */
878
- stream: cli.getSettingWithDefaultValue('errorOutput', 'stderr') === 'stderr' ? process.stderr : process.stdout
882
+ stream: cli.getSettingWithDefaultValue('errorOutput', 'stderr') === 'stderr' ? process.stderr : process.stdout,
883
+ discardStdin: false
879
884
  };
880
885
  cli.spinner = ora(spinnerOptions);
881
886
  //# sourceMappingURL=cli.js.map
@@ -73,13 +73,7 @@ class SetupCommand extends AnonymousCommand {
73
73
  };
74
74
  preferences.experience = await cli.promptForSelection(experienceConfig);
75
75
  const summaryConfig = {
76
- // invoked by inquirer
77
- /* c8 ignore next 6 */
78
- message: async () => {
79
- settings = this.getSettings(preferences);
80
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
81
- return this.getSummaryMessage(settings);
82
- }
76
+ message: this.getSummaryMessage(this.getSettings(preferences))
83
77
  };
84
78
  preferences.summary = await cli.promptForConfirmation(summaryConfig);
85
79
  if (preferences.summary) {
@@ -98,6 +98,9 @@ class EntraAppAddCommand extends GraphCommand {
98
98
  };
99
99
  applicationInfo.keyCredentials = [newKeyCredential];
100
100
  }
101
+ if (args.options.allowPublicClientFlows) {
102
+ applicationInfo.isFallbackPublicClient = true;
103
+ }
101
104
  if (this.verbose) {
102
105
  await logger.logToStderr(`Creating Microsoft Entra app registration...`);
103
106
  }
@@ -657,7 +660,8 @@ _a = EntraAppAddCommand, _EntraAppAddCommand_instances = new WeakSet(), _EntraAp
657
660
  certificateFile: typeof args.options.certificateFile !== 'undefined',
658
661
  certificateBase64Encoded: typeof args.options.certificateBase64Encoded !== 'undefined',
659
662
  certificateDisplayName: typeof args.options.certificateDisplayName !== 'undefined',
660
- grantAdminConsent: typeof args.options.grantAdminConsent !== 'undefined'
663
+ grantAdminConsent: typeof args.options.grantAdminConsent !== 'undefined',
664
+ allowPublicClientFlows: typeof args.options.allowPublicClientFlows !== 'undefined'
661
665
  });
662
666
  });
663
667
  }, _EntraAppAddCommand_initOptions = function _EntraAppAddCommand_initOptions() {
@@ -701,6 +705,8 @@ _a = EntraAppAddCommand, _EntraAppAddCommand_instances = new WeakSet(), _EntraAp
701
705
  option: '--save'
702
706
  }, {
703
707
  option: '--grantAdminConsent'
708
+ }, {
709
+ option: '--allowPublicClientFlows'
704
710
  });
705
711
  }, _EntraAppAddCommand_initValidators = function _EntraAppAddCommand_initValidators() {
706
712
  this.validators.push(async (args) => {
@@ -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 _EntraAppSetCommand_instances, _a, _EntraAppSetCommand_initTelemetry, _EntraAppSetCommand_initOptions, _EntraAppSetCommand_initValidators, _EntraAppSetCommand_initOptionSets;
6
+ var _EntraAppSetCommand_instances, _a, _EntraAppSetCommand_initTelemetry, _EntraAppSetCommand_initOptions, _EntraAppSetCommand_initValidators, _EntraAppSetCommand_initOptionSets, _EntraAppSetCommand_initTypes;
7
7
  import fs from 'fs';
8
8
  import request from '../../../../request.js';
9
9
  import { formatting } from '../../../../utils/formatting.js';
@@ -28,6 +28,7 @@ class EntraAppSetCommand extends GraphCommand {
28
28
  __classPrivateFieldGet(this, _EntraAppSetCommand_instances, "m", _EntraAppSetCommand_initOptions).call(this);
29
29
  __classPrivateFieldGet(this, _EntraAppSetCommand_instances, "m", _EntraAppSetCommand_initValidators).call(this);
30
30
  __classPrivateFieldGet(this, _EntraAppSetCommand_instances, "m", _EntraAppSetCommand_initOptionSets).call(this);
31
+ __classPrivateFieldGet(this, _EntraAppSetCommand_instances, "m", _EntraAppSetCommand_initTypes).call(this);
31
32
  }
32
33
  async commandAction(logger, args) {
33
34
  await this.showDeprecationWarning(logger, aadCommands.APP_SET, commands.APP_SET);
@@ -35,6 +36,7 @@ class EntraAppSetCommand extends GraphCommand {
35
36
  let objectId = await this.getAppObjectId(args, logger);
36
37
  objectId = await this.configureUri(args, objectId, logger);
37
38
  objectId = await this.configureRedirectUris(args, objectId, logger);
39
+ objectId = await this.updateAllowPublicClientFlows(args, objectId, logger);
38
40
  await this.configureCertificate(args, objectId, logger);
39
41
  }
40
42
  catch (err) {
@@ -71,6 +73,27 @@ class EntraAppSetCommand extends GraphCommand {
71
73
  const result = await cli.handleMultipleResultsFound(`Multiple Microsoft Entra application registration with name '${name}' found.`, resultAsKeyValuePair);
72
74
  return result.id;
73
75
  }
76
+ async updateAllowPublicClientFlows(args, objectId, logger) {
77
+ if (args.options.allowPublicClientFlows === undefined) {
78
+ return objectId;
79
+ }
80
+ if (this.verbose) {
81
+ await logger.logToStderr(`Configuring Entra application AllowPublicClientFlows option...`);
82
+ }
83
+ const applicationInfo = {
84
+ isFallbackPublicClient: args.options.allowPublicClientFlows
85
+ };
86
+ const requestOptions = {
87
+ url: `${this.resource}/v1.0/myorganization/applications/${objectId}`,
88
+ headers: {
89
+ 'content-type': 'application/json;odata.metadata=none'
90
+ },
91
+ responseType: 'json',
92
+ data: applicationInfo
93
+ };
94
+ await request.patch(requestOptions);
95
+ return objectId;
96
+ }
74
97
  async configureUri(args, objectId, logger) {
75
98
  if (!args.options.uris) {
76
99
  return objectId;
@@ -249,14 +272,18 @@ _a = EntraAppSetCommand, _EntraAppSetCommand_instances = new WeakSet(), _EntraAp
249
272
  uris: typeof args.options.uris !== 'undefined',
250
273
  certificateFile: typeof args.options.certificateFile !== 'undefined',
251
274
  certificateBase64Encoded: typeof args.options.certificateBase64Encoded !== 'undefined',
252
- certificateDisplayName: typeof args.options.certificateDisplayName !== 'undefined'
275
+ certificateDisplayName: typeof args.options.certificateDisplayName !== 'undefined',
276
+ allowPublicClientFlows: typeof args.options.allowPublicClientFlows !== 'undefined'
253
277
  });
254
278
  });
255
279
  }, _EntraAppSetCommand_initOptions = function _EntraAppSetCommand_initOptions() {
256
280
  this.options.unshift({ option: '--appId [appId]' }, { option: '--objectId [objectId]' }, { option: '-n, --name [name]' }, { option: '-u, --uris [uris]' }, { option: '-r, --redirectUris [redirectUris]' }, { option: '--certificateFile [certificateFile]' }, { option: '--certificateBase64Encoded [certificateBase64Encoded]' }, { option: '--certificateDisplayName [certificateDisplayName]' }, {
257
281
  option: '--platform [platform]',
258
282
  autocomplete: _a.aadApplicationPlatform
259
- }, { option: '--redirectUrisToRemove [redirectUrisToRemove]' });
283
+ }, { option: '--redirectUrisToRemove [redirectUrisToRemove]' }, {
284
+ option: '--allowPublicClientFlows [allowPublicClientFlows]',
285
+ autocomplete: ['true', 'false']
286
+ });
260
287
  }, _EntraAppSetCommand_initValidators = function _EntraAppSetCommand_initValidators() {
261
288
  this.validators.push(async (args) => {
262
289
  if (args.options.certificateFile && args.options.certificateBase64Encoded) {
@@ -279,6 +306,8 @@ _a = EntraAppSetCommand, _EntraAppSetCommand_instances = new WeakSet(), _EntraAp
279
306
  });
280
307
  }, _EntraAppSetCommand_initOptionSets = function _EntraAppSetCommand_initOptionSets() {
281
308
  this.optionSets.push({ options: ['appId', 'objectId', 'name'] });
309
+ }, _EntraAppSetCommand_initTypes = function _EntraAppSetCommand_initTypes() {
310
+ this.types.boolean.push('allowPublicClientFlows');
282
311
  };
283
312
  EntraAppSetCommand.aadApplicationPlatform = ['spa', 'web', 'publicClient'];
284
313
  export default new EntraAppSetCommand();
@@ -0,0 +1,233 @@
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 _EntraPimRoleAssignmentAddCommand_instances, _EntraPimRoleAssignmentAddCommand_initTelemetry, _EntraPimRoleAssignmentAddCommand_initOptions, _EntraPimRoleAssignmentAddCommand_initValidators, _EntraPimRoleAssignmentAddCommand_initOptionSets;
7
+ import request from '../../../../request.js';
8
+ import GraphCommand from '../../../base/GraphCommand.js';
9
+ import commands from '../../commands.js';
10
+ import { roleDefinition } from '../../../../utils/roleDefinition.js';
11
+ import { validation } from '../../../../utils/validation.js';
12
+ import { entraUser } from '../../../../utils/entraUser.js';
13
+ import { entraGroup } from '../../../../utils/entraGroup.js';
14
+ import { accessToken } from '../../../../utils/accessToken.js';
15
+ import auth from '../../../../Auth.js';
16
+ class EntraPimRoleAssignmentAddCommand extends GraphCommand {
17
+ get name() {
18
+ return commands.PIM_ROLE_ASSIGNMENT_ADD;
19
+ }
20
+ get description() {
21
+ return 'Request activation of an Entra role assignment for a user or group';
22
+ }
23
+ constructor() {
24
+ super();
25
+ _EntraPimRoleAssignmentAddCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentAddCommand_instances, "m", _EntraPimRoleAssignmentAddCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentAddCommand_instances, "m", _EntraPimRoleAssignmentAddCommand_initOptions).call(this);
28
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentAddCommand_instances, "m", _EntraPimRoleAssignmentAddCommand_initValidators).call(this);
29
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentAddCommand_instances, "m", _EntraPimRoleAssignmentAddCommand_initOptionSets).call(this);
30
+ }
31
+ async commandAction(logger, args) {
32
+ const { userId, userName, groupId, groupName, startDateTime, endDateTime, ticketNumber, ticketSystem } = args.options;
33
+ try {
34
+ const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
35
+ const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(token);
36
+ if (isAppOnlyAccessToken) {
37
+ throw 'When running with application permissions either userId, userName, groupId or groupName is required';
38
+ }
39
+ const roleDefinitionId = await this.getRoleDefinitionId(args.options, logger);
40
+ const principalId = await this.getPrincipalId(args.options, logger);
41
+ const requestOptions = {
42
+ url: `${this.resource}/v1.0/roleManagement/directory/roleAssignmentScheduleRequests`,
43
+ headers: {
44
+ 'accept': 'application/json;odata.metadata=none'
45
+ },
46
+ responseType: 'json',
47
+ data: {
48
+ principalId: principalId,
49
+ roleDefinitionId: roleDefinitionId,
50
+ directoryScopeId: this.getDirectoryScope(args.options),
51
+ action: !userId && !userName && !groupId && !groupName ? 'selfActivate' : 'adminAssign',
52
+ justification: args.options.justification,
53
+ scheduleInfo: {
54
+ startDateTime: startDateTime,
55
+ expiration: {
56
+ duration: this.getDuration(args.options),
57
+ endDateTime: endDateTime,
58
+ type: this.getExpirationType(args.options)
59
+ }
60
+ },
61
+ ticketInfo: {
62
+ ticketNumber: ticketNumber,
63
+ ticketSystem: ticketSystem
64
+ }
65
+ }
66
+ };
67
+ const response = await request.post(requestOptions);
68
+ await logger.log(response);
69
+ }
70
+ catch (err) {
71
+ this.handleRejectedODataJsonPromise(err);
72
+ }
73
+ }
74
+ async getRoleDefinitionId(options, logger) {
75
+ if (options.roleDefinitionId) {
76
+ return options.roleDefinitionId;
77
+ }
78
+ if (this.verbose) {
79
+ await logger.logToStderr(`Retrieving role definition by its name '${options.roleDefinitionName}'`);
80
+ }
81
+ const role = await roleDefinition.getRoleDefinitionByDisplayName(options.roleDefinitionName);
82
+ return role.id;
83
+ }
84
+ async getPrincipalId(options, logger) {
85
+ if (options.userId || options.groupId) {
86
+ return options.userId || options.groupId;
87
+ }
88
+ if (options.userName) {
89
+ if (this.verbose) {
90
+ await logger.logToStderr(`Retrieving user by its name '${options.userName}'`);
91
+ }
92
+ return await entraUser.getUserIdByUpn(options.userName);
93
+ }
94
+ else if (options.groupName) {
95
+ if (this.verbose) {
96
+ await logger.logToStderr(`Retrieving group by its name '${options.groupName}'`);
97
+ }
98
+ return await entraGroup.getGroupIdByDisplayName(options.groupName);
99
+ }
100
+ if (this.verbose) {
101
+ await logger.logToStderr(`Retrieving id of the current user`);
102
+ }
103
+ const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
104
+ return accessToken.getUserIdFromAccessToken(token);
105
+ }
106
+ getExpirationType(options) {
107
+ if (options.endDateTime) {
108
+ return 'afterDateTime';
109
+ }
110
+ if (options.noExpiration) {
111
+ return 'noExpiration';
112
+ }
113
+ return 'afterDuration';
114
+ }
115
+ getDuration(options) {
116
+ if (!options.duration && !options.endDateTime && !options.noExpiration) {
117
+ return 'PT8H';
118
+ }
119
+ return options.duration;
120
+ }
121
+ getDirectoryScope(options) {
122
+ if (options.administrativeUnitId) {
123
+ return `/administrativeUnits/${options.administrativeUnitId}`;
124
+ }
125
+ if (options.applicationId) {
126
+ return `/${options.applicationId}`;
127
+ }
128
+ return '/';
129
+ }
130
+ }
131
+ _EntraPimRoleAssignmentAddCommand_instances = new WeakSet(), _EntraPimRoleAssignmentAddCommand_initTelemetry = function _EntraPimRoleAssignmentAddCommand_initTelemetry() {
132
+ this.telemetry.push((args) => {
133
+ Object.assign(this.telemetryProperties, {
134
+ roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined',
135
+ roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
136
+ userId: typeof args.options.userId !== 'undefined',
137
+ userName: typeof args.options.userName !== 'undefined',
138
+ groupId: typeof args.options.groupId !== 'undefined',
139
+ groupName: typeof args.options.groupName !== 'undefined',
140
+ administrativeUnitId: typeof args.options.administrativeUnitId !== 'undefined',
141
+ applicationId: typeof args.options.applicationId !== 'undefined',
142
+ justification: typeof args.options.justification !== 'undefined',
143
+ startDateTime: typeof args.options.startDateTime !== 'undefined',
144
+ endDateTime: typeof args.options.endDateTime !== 'undefined',
145
+ duration: typeof args.options.duration !== 'undefined',
146
+ ticketNumber: typeof args.options.ticketNumber !== 'undefined',
147
+ ticketSystem: typeof args.options.ticketSystem !== 'undefined',
148
+ noExpiration: !!args.options.noExpiration
149
+ });
150
+ });
151
+ }, _EntraPimRoleAssignmentAddCommand_initOptions = function _EntraPimRoleAssignmentAddCommand_initOptions() {
152
+ this.options.unshift({
153
+ option: '-n, --roleDefinitionName [roleDefinitionName]'
154
+ }, {
155
+ option: '-i, --roleDefinitionId [roleDefinitionId]'
156
+ }, {
157
+ option: "--userId [userId]"
158
+ }, {
159
+ option: "--userName [userName]"
160
+ }, {
161
+ option: "--groupId [groupId]"
162
+ }, {
163
+ option: "--groupName [groupName]"
164
+ }, {
165
+ option: "--administrativeUnitId [administrativeUnitId]"
166
+ }, {
167
+ option: "--applicationId [applicationId]"
168
+ }, {
169
+ option: "-j, --justification [justification]"
170
+ }, {
171
+ option: "-s, --startDateTime [startDateTime]"
172
+ }, {
173
+ option: "-e, --endDateTime [endDateTime]"
174
+ }, {
175
+ option: "-d, --duration [duration]"
176
+ }, {
177
+ option: "--ticketNumber [ticketNumber]"
178
+ }, {
179
+ option: "--ticketSystem [ticketSystem]"
180
+ }, {
181
+ option: "--no-expiration"
182
+ });
183
+ }, _EntraPimRoleAssignmentAddCommand_initValidators = function _EntraPimRoleAssignmentAddCommand_initValidators() {
184
+ this.validators.push(async (args) => {
185
+ if (args.options.roleDefinitionId && !validation.isValidGuid(args.options.roleDefinitionId)) {
186
+ return `${args.options.roleDefinitionId} is not a valid GUID`;
187
+ }
188
+ if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
189
+ return `${args.options.userId} is not a valid GUID`;
190
+ }
191
+ if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
192
+ return `${args.options.groupId} is not a valid GUID`;
193
+ }
194
+ if (args.options.startDateTime && !validation.isValidISODateTime(args.options.startDateTime)) {
195
+ return `${args.options.startDateTime} is not a valid ISO 8601 date time string`;
196
+ }
197
+ if (args.options.endDateTime && !validation.isValidISODateTime(args.options.endDateTime)) {
198
+ return `${args.options.endDateTime} is not a valid ISO 8601 date time string`;
199
+ }
200
+ if (args.options.duration && !validation.isValidISODuration(args.options.duration)) {
201
+ return `${args.options.duration} is not a valid ISO 8601 duration`;
202
+ }
203
+ if (args.options.administrativeUnitId && !validation.isValidGuid(args.options.administrativeUnitId)) {
204
+ return `${args.options.administrativeUnitId} is not a valid GUID`;
205
+ }
206
+ if (args.options.applicationId && !validation.isValidGuid(args.options.applicationId)) {
207
+ return `${args.options.applicationId} is not a valid GUID`;
208
+ }
209
+ return true;
210
+ });
211
+ }, _EntraPimRoleAssignmentAddCommand_initOptionSets = function _EntraPimRoleAssignmentAddCommand_initOptionSets() {
212
+ this.optionSets.push({ options: ['roleDefinitionName', 'roleDefinitionId'] });
213
+ this.optionSets.push({
214
+ options: ['noExpiration', 'endDateTime', 'duration'],
215
+ runsWhen: (args) => {
216
+ return !!args.options.noExpiration || args.options.endDateTime !== undefined || args.options.duration !== undefined;
217
+ }
218
+ });
219
+ this.optionSets.push({
220
+ options: ['userId', 'userName', 'groupId', 'groupName'],
221
+ runsWhen: (args) => {
222
+ return args.options.userId !== undefined || args.options.userName !== undefined || args.options.groupId !== undefined || args.options.groupName !== undefined;
223
+ }
224
+ });
225
+ this.optionSets.push({
226
+ options: ['administrativeUnitId', 'applicationId'],
227
+ runsWhen: (args) => {
228
+ return args.options.administrativeUnitId !== undefined || args.options.applicationId !== undefined;
229
+ }
230
+ });
231
+ };
232
+ export default new EntraPimRoleAssignmentAddCommand();
233
+ //# sourceMappingURL=pim-role-assignment-add.js.map
@@ -0,0 +1,122 @@
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 _EntraPimRoleAssignmentListCommand_instances, _EntraPimRoleAssignmentListCommand_initTelemetry, _EntraPimRoleAssignmentListCommand_initOptions, _EntraPimRoleAssignmentListCommand_initValidators, _EntraPimRoleAssignmentListCommand_initOptionSets;
7
+ import GraphCommand from '../../../base/GraphCommand.js';
8
+ import commands from '../../commands.js';
9
+ import { validation } from '../../../../utils/validation.js';
10
+ import { entraUser } from '../../../../utils/entraUser.js';
11
+ import { entraGroup } from '../../../../utils/entraGroup.js';
12
+ import { odata } from '../../../../utils/odata.js';
13
+ class EntraPimRoleAssignmentListCommand extends GraphCommand {
14
+ get name() {
15
+ return commands.PIM_ROLE_ASSIGNMENT_LIST;
16
+ }
17
+ get description() {
18
+ return 'Retrieves a list of Entra role assignments for a user or group';
19
+ }
20
+ constructor() {
21
+ super();
22
+ _EntraPimRoleAssignmentListCommand_instances.add(this);
23
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentListCommand_instances, "m", _EntraPimRoleAssignmentListCommand_initTelemetry).call(this);
24
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentListCommand_instances, "m", _EntraPimRoleAssignmentListCommand_initOptions).call(this);
25
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentListCommand_instances, "m", _EntraPimRoleAssignmentListCommand_initValidators).call(this);
26
+ __classPrivateFieldGet(this, _EntraPimRoleAssignmentListCommand_instances, "m", _EntraPimRoleAssignmentListCommand_initOptionSets).call(this);
27
+ }
28
+ async commandAction(logger, args) {
29
+ const queryParameters = [];
30
+ const filters = [];
31
+ const expands = [];
32
+ try {
33
+ const principalId = await this.getPrincipalId(logger, args.options);
34
+ if (principalId) {
35
+ filters.push(`principalId eq '${principalId}'`);
36
+ }
37
+ if (args.options.startDateTime) {
38
+ filters.push(`startDateTime ge ${args.options.startDateTime}`);
39
+ }
40
+ if (filters.length > 0) {
41
+ queryParameters.push(`$filter=${filters.join(' and ')}`);
42
+ }
43
+ expands.push('roleDefinition($select=displayName)');
44
+ if (args.options.includePrincipalDetails) {
45
+ expands.push('principal');
46
+ }
47
+ queryParameters.push(`$expand=${expands.join(',')}`);
48
+ const queryString = `?${queryParameters.join('&')}`;
49
+ const url = `${this.resource}/v1.0/roleManagement/directory/roleAssignmentScheduleInstances${queryString}`;
50
+ const results = await odata.getAllItems(url);
51
+ await logger.log(results);
52
+ }
53
+ catch (err) {
54
+ this.handleRejectedODataJsonPromise(err);
55
+ }
56
+ }
57
+ async getPrincipalId(logger, options) {
58
+ let principalId = options.userId;
59
+ if (options.userName) {
60
+ if (this.verbose) {
61
+ await logger.logToStderr(`Retrieving user by its name '${options.userName}'`);
62
+ }
63
+ principalId = await entraUser.getUserIdByUpn(options.userName);
64
+ }
65
+ else if (options.groupId) {
66
+ principalId = options.groupId;
67
+ }
68
+ else if (options.groupName) {
69
+ if (this.verbose) {
70
+ await logger.logToStderr(`Retrieving group by its name '${options.groupName}'`);
71
+ }
72
+ principalId = await entraGroup.getGroupIdByDisplayName(options.groupName);
73
+ }
74
+ return principalId;
75
+ }
76
+ }
77
+ _EntraPimRoleAssignmentListCommand_instances = new WeakSet(), _EntraPimRoleAssignmentListCommand_initTelemetry = function _EntraPimRoleAssignmentListCommand_initTelemetry() {
78
+ this.telemetry.push((args) => {
79
+ Object.assign(this.telemetryProperties, {
80
+ userId: typeof args.options.userId !== 'undefined',
81
+ userName: typeof args.options.userName !== 'undefined',
82
+ groupId: typeof args.options.groupId !== 'undefined',
83
+ groupName: typeof args.options.groupName !== 'undefined',
84
+ startDateTime: typeof args.options.startDateTime !== 'undefined',
85
+ includePrincipalDetails: !!args.options.includePrincipalDetails
86
+ });
87
+ });
88
+ }, _EntraPimRoleAssignmentListCommand_initOptions = function _EntraPimRoleAssignmentListCommand_initOptions() {
89
+ this.options.unshift({
90
+ option: "--userId [userId]"
91
+ }, {
92
+ option: "--userName [userName]"
93
+ }, {
94
+ option: "--groupId [groupId]"
95
+ }, {
96
+ option: "--groupName [groupName]"
97
+ }, {
98
+ option: "-s, --startDateTime [startDateTime]"
99
+ }, {
100
+ option: "--includePrincipalDetails [includePrincipalDetails]"
101
+ });
102
+ }, _EntraPimRoleAssignmentListCommand_initValidators = function _EntraPimRoleAssignmentListCommand_initValidators() {
103
+ this.validators.push(async (args) => {
104
+ if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
105
+ return `${args.options.userId} is not a valid GUID`;
106
+ }
107
+ if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
108
+ return `${args.options.groupId} is not a valid GUID`;
109
+ }
110
+ if (args.options.startDateTime && !validation.isValidISODateTime(args.options.startDateTime)) {
111
+ return `${args.options.startDateTime} is not a valid ISO 8601 date time string`;
112
+ }
113
+ return true;
114
+ });
115
+ }, _EntraPimRoleAssignmentListCommand_initOptionSets = function _EntraPimRoleAssignmentListCommand_initOptionSets() {
116
+ this.optionSets.push({
117
+ options: ['userId', 'userName', 'groupId', 'groupName'],
118
+ runsWhen: (args) => args.options.userId || args.options.userName || args.options.groupId || args.options.groupName
119
+ });
120
+ };
121
+ export default new EntraPimRoleAssignmentListCommand();
122
+ //# sourceMappingURL=pim-role-assignment-list.js.map
@@ -31,17 +31,22 @@ class EntraUserListCommand extends GraphCommand {
31
31
  async commandAction(logger, args) {
32
32
  await this.showDeprecationWarning(logger, aadCommands.USER_LIST, commands.USER_LIST);
33
33
  try {
34
+ const selectProperties = args.options.properties ? args.options.properties : 'id,displayName,mail,userPrincipalName';
35
+ const allSelectProperties = selectProperties.split(',');
36
+ const propertiesWithSlash = allSelectProperties.filter(item => item.includes('/'));
37
+ const fieldExpand = propertiesWithSlash
38
+ .map(p => `${p.split('/')[0]}($select=${p.split('/')[1]})`)
39
+ .join(',');
40
+ const expandParam = fieldExpand.length > 0 ? `&$expand=${fieldExpand}` : '';
41
+ const selectParam = allSelectProperties.filter(item => !item.includes('/'));
34
42
  let filter = '';
35
- const properties = args.options.properties ?
36
- args.options.properties.split(',').map(p => p.trim()) :
37
- ['userPrincipalName', 'displayName'];
38
43
  try {
39
44
  filter = this.getFilter(args.options);
40
45
  }
41
46
  catch (ex) {
42
47
  throw ex;
43
48
  }
44
- const url = `${this.resource}/v1.0/users?$select=${properties.join(',')}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
49
+ const url = `${this.resource}/v1.0/users?$select=${selectParam}${expandParam}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
45
50
  const users = await odata.getAllItems(url);
46
51
  await logger.log(users);
47
52
  }
@@ -52,6 +57,7 @@ class EntraUserListCommand extends GraphCommand {
52
57
  getFilter(options) {
53
58
  const filters = {};
54
59
  const excludeOptions = [
60
+ 'type',
55
61
  'properties',
56
62
  'p',
57
63
  'd',
@@ -72,7 +78,10 @@ class EntraUserListCommand extends GraphCommand {
72
78
  });
73
79
  let filter = Object.keys(filters).map(key => `startsWith(${key}, '${filters[key]}')`).join(' and ');
74
80
  if (filter.length > 0) {
75
- filter = '$filter=' + filter;
81
+ filter = `$filter=${filter}`;
82
+ }
83
+ if (options.type) {
84
+ filter += filter.length > 0 ? ` and userType eq '${options.type}'` : `$filter=userType eq '${options.type}'`;
76
85
  }
77
86
  return filter;
78
87
  }
@@ -80,11 +89,15 @@ class EntraUserListCommand extends GraphCommand {
80
89
  _EntraUserListCommand_instances = new WeakSet(), _EntraUserListCommand_initTelemetry = function _EntraUserListCommand_initTelemetry() {
81
90
  this.telemetry.push((args) => {
82
91
  Object.assign(this.telemetryProperties, {
83
- properties: args.options.properties
92
+ type: typeof args.options.type !== 'undefined',
93
+ properties: typeof args.options.properties !== 'undefined'
84
94
  });
85
95
  });
86
96
  }, _EntraUserListCommand_initOptions = function _EntraUserListCommand_initOptions() {
87
- this.options.unshift({ option: '-p, --properties [properties]' });
97
+ this.options.unshift({
98
+ option: "--type [type]",
99
+ autocomplete: ["Member", "Guest"]
100
+ }, { option: '-p, --properties [properties]' });
88
101
  };
89
102
  export default new EntraUserListCommand();
90
103
  //# sourceMappingURL=user-list.js.map
@@ -74,6 +74,8 @@ export default {
74
74
  OAUTH2GRANT_LIST: `${prefix} oauth2grant list`,
75
75
  OAUTH2GRANT_REMOVE: `${prefix} oauth2grant remove`,
76
76
  OAUTH2GRANT_SET: `${prefix} oauth2grant set`,
77
+ PIM_ROLE_ASSIGNMENT_ADD: `${prefix} pim role assignment add`,
78
+ PIM_ROLE_ASSIGNMENT_LIST: `${prefix} pim role assignment list`,
77
79
  POLICY_LIST: `${prefix} policy list`,
78
80
  SITECLASSIFICATION_DISABLE: `${prefix} siteclassification disable`,
79
81
  SITECLASSIFICATION_ENABLE: `${prefix} siteclassification enable`,
@@ -1,7 +1,9 @@
1
1
  import { FN002004_DEVDEP_gulp } from './rules/FN002004_DEVDEP_gulp.js';
2
2
  import { FN002013_DEVDEP_types_webpack_env } from './rules/FN002013_DEVDEP_types_webpack_env.js';
3
+ import { FN021001_PKG_spfx_deps_versions_match_project_version } from './rules/FN021001_PKG_spfx_deps_versions_match_project_version.js';
3
4
  export default [
4
5
  new FN002004_DEVDEP_gulp('~3.9.1'),
5
- new FN002013_DEVDEP_types_webpack_env('>=1.12.1 <1.14.0')
6
+ new FN002013_DEVDEP_types_webpack_env('>=1.12.1 <1.14.0'),
7
+ new FN021001_PKG_spfx_deps_versions_match_project_version()
6
8
  ];
7
9
  //# sourceMappingURL=doctor-1.0.0.js.map
@@ -1,7 +1,9 @@
1
1
  import { FN002004_DEVDEP_gulp } from './rules/FN002004_DEVDEP_gulp.js';
2
2
  import { FN002013_DEVDEP_types_webpack_env } from './rules/FN002013_DEVDEP_types_webpack_env.js';
3
+ import { FN021001_PKG_spfx_deps_versions_match_project_version } from './rules/FN021001_PKG_spfx_deps_versions_match_project_version.js';
3
4
  export default [
4
5
  new FN002004_DEVDEP_gulp('~3.9.1'),
5
- new FN002013_DEVDEP_types_webpack_env('>=1.12.1 <1.14.0')
6
+ new FN002013_DEVDEP_types_webpack_env('>=1.12.1 <1.14.0'),
7
+ new FN021001_PKG_spfx_deps_versions_match_project_version()
6
8
  ];
7
9
  //# sourceMappingURL=doctor-1.0.1.js.map
@@ -1,7 +1,9 @@
1
1
  import { FN002004_DEVDEP_gulp } from './rules/FN002004_DEVDEP_gulp.js';
2
2
  import { FN002013_DEVDEP_types_webpack_env } from './rules/FN002013_DEVDEP_types_webpack_env.js';
3
+ import { FN021001_PKG_spfx_deps_versions_match_project_version } from './rules/FN021001_PKG_spfx_deps_versions_match_project_version.js';
3
4
  export default [
4
5
  new FN002004_DEVDEP_gulp('~3.9.1'),
5
- new FN002013_DEVDEP_types_webpack_env('>=1.12.1 <1.14.0')
6
+ new FN002013_DEVDEP_types_webpack_env('>=1.12.1 <1.14.0'),
7
+ new FN021001_PKG_spfx_deps_versions_match_project_version()
6
8
  ];
7
9
  //# sourceMappingURL=doctor-1.0.2.js.map