@pnp/cli-microsoft365 8.0.0-beta.e6f9331 → 8.1.0-beta.309a9b8

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 (121) 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 +50 -5
  6. package/dist/chili/chili.js +0 -23
  7. package/dist/cli/cli.js +100 -100
  8. package/dist/m365/commands/login.js +49 -96
  9. package/dist/m365/commands/setup.js +0 -4
  10. package/dist/m365/connection/commands/connection-remove.js +6 -2
  11. package/dist/m365/connection/commands/connection-set.js +4 -1
  12. package/dist/m365/connection/commands/connection-use.js +25 -4
  13. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-remove.js +123 -0
  14. package/dist/m365/entra/commands/group/group-set.js +256 -0
  15. package/dist/m365/entra/commands/m365group/m365group-set.js +66 -29
  16. package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
  17. package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
  18. package/dist/m365/entra/commands/multitenant/MultitenantOrganization.js +2 -0
  19. package/dist/m365/entra/commands/multitenant/multitenant-add.js +65 -0
  20. package/dist/m365/entra/commands/multitenant/multitenant-get.js +32 -0
  21. package/dist/m365/entra/commands/multitenant/multitenant-remove.js +118 -0
  22. package/dist/m365/entra/commands/multitenant/multitenant-set.js +72 -0
  23. package/dist/m365/entra/commands.js +7 -0
  24. package/dist/m365/external/commands/connection/connection-doctor.js +10 -24
  25. package/dist/m365/flow/commands/flow-get.js +1 -1
  26. package/dist/m365/flow/commands/flow-list.js +2 -1
  27. package/dist/m365/graph/commands/subscription/subscription-add.js +4 -2
  28. package/dist/m365/onenote/commands/notebook/notebook-add.js +132 -0
  29. package/dist/m365/onenote/commands.js +1 -0
  30. package/dist/m365/pa/commands/app/app-export.js +13 -7
  31. package/dist/m365/spe/ContainerTypeProperties.js +2 -0
  32. package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
  33. package/dist/m365/spe/commands.js +2 -1
  34. package/dist/m365/spfx/commands/project/base-project-command.js +36 -126
  35. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
  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/folder/folder-sharinglink-get.js +86 -0
  44. package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
  45. package/dist/m365/spo/commands/list/ListInstance.js +6 -1
  46. package/dist/m365/spo/commands/list/list-get.js +9 -3
  47. package/dist/m365/spo/commands/list/list-roleassignment-add.js +46 -21
  48. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +48 -46
  49. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -3
  50. package/dist/m365/spo/commands/page/page-text-add.js +2 -3
  51. package/dist/m365/spo/commands/site/site-get.js +12 -16
  52. package/dist/m365/spo/commands/spo-search.js +3 -4
  53. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
  54. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
  55. package/dist/m365/spo/commands.js +3 -0
  56. package/dist/m365/teams/commands/meeting/meeting-attendancereport-get.js +119 -0
  57. package/dist/m365/teams/commands/message/message-remove.js +112 -0
  58. package/dist/m365/teams/commands/message/message-restore.js +106 -0
  59. package/dist/m365/teams/commands.js +3 -0
  60. package/dist/m365/viva/commands/engage/engage-community-add.js +166 -0
  61. package/dist/m365/viva/commands.js +1 -0
  62. package/dist/utils/drive.js +61 -0
  63. package/dist/utils/formatting.js +30 -1
  64. package/dist/utils/spo.js +69 -6
  65. package/dist/utils/teams.js +49 -0
  66. package/dist/utils/zod.js +124 -0
  67. package/docs/docs/cmd/connection/connection-use.mdx +8 -2
  68. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-remove.mdx +65 -0
  69. package/docs/docs/cmd/entra/group/group-add.mdx +0 -4
  70. package/docs/docs/cmd/entra/group/group-set.mdx +89 -0
  71. package/docs/docs/cmd/entra/m365group/m365group-set.mdx +37 -7
  72. package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
  73. package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
  74. package/docs/docs/cmd/entra/multitenant/multitenant-add.mdx +107 -0
  75. package/docs/docs/cmd/entra/multitenant/multitenant-get.mdx +94 -0
  76. package/docs/docs/cmd/entra/multitenant/multitenant-remove.mdx +58 -0
  77. package/docs/docs/cmd/entra/multitenant/multitenant-set.mdx +53 -0
  78. package/docs/docs/cmd/external/connection/connection-doctor.mdx +9 -9
  79. package/docs/docs/cmd/flow/flow-get.mdx +149 -283
  80. package/docs/docs/cmd/graph/subscription/subscription-add.mdx +18 -0
  81. package/docs/docs/cmd/onenote/notebook/notebook-add.mdx +169 -0
  82. package/docs/docs/cmd/pa/app/app-export.mdx +15 -9
  83. package/docs/docs/cmd/planner/plan/plan-remove.mdx +1 -1
  84. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +102 -0
  85. package/docs/docs/cmd/spo/app/app-uninstall.mdx +1 -1
  86. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +87 -38
  87. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +22 -28
  88. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
  89. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
  90. package/docs/docs/cmd/spo/contenttype/contenttype-field-list.mdx +172 -0
  91. package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +3 -3
  92. package/docs/docs/cmd/spo/field/field-list.mdx +3 -3
  93. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +1 -1
  94. package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +2 -2
  95. package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
  96. package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +1 -1
  97. package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +1 -1
  98. package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +2 -2
  99. package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
  100. package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
  101. package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
  102. package/docs/docs/cmd/spo/list/list-roleassignment-add.mdx +15 -3
  103. package/docs/docs/cmd/spo/list/list-roleassignment-remove.mdx +15 -3
  104. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-ensure.mdx +4 -4
  105. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.mdx +1 -1
  106. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.mdx +9 -9
  107. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-remove.mdx +7 -7
  108. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.mdx +1 -1
  109. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
  110. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
  111. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
  112. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
  113. package/docs/docs/cmd/spo/web/web-roleassignment-add.mdx +1 -1
  114. package/docs/docs/cmd/spo/web/web-roleassignment-remove.mdx +1 -1
  115. package/docs/docs/cmd/teams/meeting/meeting-attendancereport-get.mdx +138 -0
  116. package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
  117. package/docs/docs/cmd/teams/message/message-remove.mdx +64 -0
  118. package/docs/docs/cmd/teams/message/message-restore.mdx +62 -0
  119. package/docs/docs/cmd/viva/engage/engage-community-add.mdx +168 -0
  120. package/npm-shrinkwrap.json +987 -1327
  121. package/package.json +27 -24
@@ -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,31 @@ 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
+ path: ['userName']
43
+ })
44
+ .refine(options => options.authType !== 'password' || options.password, {
45
+ message: 'Password is required when using password authentication',
46
+ path: ['password']
47
+ })
48
+ .refine(options => options.authType !== 'certificate' || !(options.certificateFile && options.certificateBase64Encoded), {
49
+ message: 'Specify either certificateFile or certificateBase64Encoded, but not both.',
50
+ path: ['certificateBase64Encoded']
51
+ })
52
+ .refine(options => options.authType !== 'certificate' || options.certificateFile || options.certificateBase64Encoded, {
53
+ message: 'Specify either certificateFile or certificateBase64Encoded',
54
+ path: ['certificateFile']
55
+ })
56
+ .refine(options => options.authType !== 'secret' || options.secret, {
57
+ message: 'Secret is required when using secret authentication',
58
+ path: ['secret']
59
+ });
28
60
  }
29
61
  async commandAction(logger, args) {
30
62
  // disconnect before re-connecting
@@ -64,12 +96,7 @@ class LoginCommand extends Command {
64
96
  auth.connection.secret = args.options.secret;
65
97
  break;
66
98
  }
67
- if (args.options.cloud) {
68
- auth.connection.cloudType = CloudType[args.options.cloud];
69
- }
70
- else {
71
- auth.connection.cloudType = CloudType.Public;
72
- }
99
+ auth.connection.cloudType = args.options.cloud;
73
100
  try {
74
101
  await auth.ensureAccessToken(auth.defaultResource, logger, this.debug);
75
102
  auth.connection.active = true;
@@ -102,79 +129,5 @@ class LoginCommand extends Command {
102
129
  await this.commandAction(logger, args);
103
130
  }
104
131
  }
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
132
  export default new LoginCommand();
180
133
  //# 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
@@ -0,0 +1,123 @@
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 _EntraEnterpriseAppRemoveCommand_instances, _EntraEnterpriseAppRemoveCommand_initTelemetry, _EntraEnterpriseAppRemoveCommand_initOptions, _EntraEnterpriseAppRemoveCommand_initValidators, _EntraEnterpriseAppRemoveCommand_initOptionSets, _EntraEnterpriseAppRemoveCommand_initTypes;
7
+ import { cli } from '../../../../cli/cli.js';
8
+ import request from '../../../../request.js';
9
+ import { odata } from '../../../../utils/odata.js';
10
+ import { formatting } from '../../../../utils/formatting.js';
11
+ import { validation } from '../../../../utils/validation.js';
12
+ import GraphCommand from '../../../base/GraphCommand.js';
13
+ import commands from '../../commands.js';
14
+ class EntraEnterpriseAppRemoveCommand extends GraphCommand {
15
+ get name() {
16
+ return commands.ENTERPRISEAPP_REMOVE;
17
+ }
18
+ get description() {
19
+ return 'Deletes an enterprise application (or service principal)';
20
+ }
21
+ alias() {
22
+ return [commands.SP_REMOVE];
23
+ }
24
+ constructor() {
25
+ super();
26
+ _EntraEnterpriseAppRemoveCommand_instances.add(this);
27
+ __classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initTelemetry).call(this);
28
+ __classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initOptions).call(this);
29
+ __classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initValidators).call(this);
30
+ __classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initOptionSets).call(this);
31
+ __classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initTypes).call(this);
32
+ }
33
+ async commandAction(logger, args) {
34
+ const removeEnterpriseApplication = async () => {
35
+ if (this.verbose) {
36
+ await logger.logToStderr(`Removing enterprise application ${args.options.id || args.options.displayName || args.options.objectId}...`);
37
+ }
38
+ try {
39
+ let url = `${this.resource}/v1.0`;
40
+ if (args.options.id) {
41
+ url += `/servicePrincipals(appId='${args.options.id}')`;
42
+ }
43
+ else {
44
+ const id = await this.getSpId(args.options);
45
+ url += `/servicePrincipals/${id}`;
46
+ }
47
+ const requestOptions = {
48
+ url: url,
49
+ headers: {
50
+ accept: 'application/json;odata.metadata=none'
51
+ },
52
+ responseType: 'json'
53
+ };
54
+ await request.delete(requestOptions);
55
+ }
56
+ catch (err) {
57
+ this.handleRejectedODataJsonPromise(err);
58
+ }
59
+ };
60
+ if (args.options.force) {
61
+ await removeEnterpriseApplication();
62
+ }
63
+ else {
64
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove enterprise application '${args.options.id || args.options.displayName || args.options.objectId}'?` });
65
+ if (result) {
66
+ await removeEnterpriseApplication();
67
+ }
68
+ }
69
+ }
70
+ async getSpId(options) {
71
+ if (options.objectId) {
72
+ return options.objectId;
73
+ }
74
+ const spItemsResponse = await odata.getAllItems(`${this.resource}/v1.0/servicePrincipals?$filter=displayName eq '${formatting.encodeQueryParameter(options.displayName)}'&$select=id`);
75
+ if (spItemsResponse.length === 0) {
76
+ throw `The specified enterprise application does not exist.`;
77
+ }
78
+ if (spItemsResponse.length > 1) {
79
+ const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', spItemsResponse);
80
+ const result = await cli.handleMultipleResultsFound(`Multiple enterprise applications with name '${options.displayName}' found.`, resultAsKeyValuePair);
81
+ return result.id;
82
+ }
83
+ const spItem = spItemsResponse[0];
84
+ return spItem.id;
85
+ }
86
+ }
87
+ _EntraEnterpriseAppRemoveCommand_instances = new WeakSet(), _EntraEnterpriseAppRemoveCommand_initTelemetry = function _EntraEnterpriseAppRemoveCommand_initTelemetry() {
88
+ this.telemetry.push((args) => {
89
+ Object.assign(this.telemetryProperties, {
90
+ id: typeof args.options.id !== 'undefined',
91
+ displayName: typeof args.options.displayName !== 'undefined',
92
+ objectId: typeof args.options.objectId !== 'undefined',
93
+ force: !!args.options.force
94
+ });
95
+ });
96
+ }, _EntraEnterpriseAppRemoveCommand_initOptions = function _EntraEnterpriseAppRemoveCommand_initOptions() {
97
+ this.options.unshift({
98
+ option: '-i, --id [id]'
99
+ }, {
100
+ option: '-n, --displayName [displayName]'
101
+ }, {
102
+ option: '--objectId [objectId]'
103
+ }, {
104
+ option: '-f, --force'
105
+ });
106
+ }, _EntraEnterpriseAppRemoveCommand_initValidators = function _EntraEnterpriseAppRemoveCommand_initValidators() {
107
+ this.validators.push(async (args) => {
108
+ if (args.options.id && !validation.isValidGuid(args.options.id)) {
109
+ return `The option 'id' with value '${args.options.id}' is not a valid GUID.`;
110
+ }
111
+ if (args.options.objectId && !validation.isValidGuid(args.options.objectId)) {
112
+ return `The option 'objectId' with value '${args.options.objectId}' is not a valid GUID.`;
113
+ }
114
+ return true;
115
+ });
116
+ }, _EntraEnterpriseAppRemoveCommand_initOptionSets = function _EntraEnterpriseAppRemoveCommand_initOptionSets() {
117
+ this.optionSets.push({ options: ['id', 'displayName', 'objectId'] });
118
+ }, _EntraEnterpriseAppRemoveCommand_initTypes = function _EntraEnterpriseAppRemoveCommand_initTypes() {
119
+ this.types.string.push('id', 'displayName', 'objectId');
120
+ this.types.boolean.push('force');
121
+ };
122
+ export default new EntraEnterpriseAppRemoveCommand();
123
+ //# sourceMappingURL=enterpriseapp-remove.js.map