@pnp/cli-microsoft365 10.8.0-beta.26ade35 → 10.8.0-beta.7160233

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 (41) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/config.js +1 -0
  5. package/dist/m365/app/commands/app-get.js +5 -2
  6. package/dist/m365/app/commands/app-open.js +9 -22
  7. package/dist/m365/app/commands/permission/permission-add.js +18 -30
  8. package/dist/m365/app/commands/permission/permission-list.js +5 -2
  9. package/dist/m365/base/AppCommand.js +9 -25
  10. package/dist/m365/booking/commands/business/business-get.js +18 -25
  11. package/dist/m365/cli/commands/app/app-reconsent.js +103 -0
  12. package/dist/m365/cli/commands.js +1 -0
  13. package/dist/m365/context/commands/context-remove.js +12 -25
  14. package/dist/m365/context/commands/option/option-remove.js +11 -25
  15. package/dist/m365/graph/commands/directoryextension/directoryextension-list.js +74 -0
  16. package/dist/m365/graph/commands.js +1 -0
  17. package/dist/m365/spe/commands/container/container-add.js +85 -0
  18. package/dist/m365/spe/commands/container/container-list.js +2 -9
  19. package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +62 -0
  20. package/dist/m365/spe/commands/container/container-remove.js +99 -0
  21. package/dist/m365/spe/commands/containertype/containertype-add.js +11 -11
  22. package/dist/m365/spe/commands/containertype/containertype-get.js +28 -32
  23. package/dist/m365/spe/commands/containertype/containertype-list.js +14 -4
  24. package/dist/m365/spe/commands/containertype/containertype-remove.js +81 -0
  25. package/dist/m365/spe/commands.js +5 -1
  26. package/dist/utils/entraServicePrincipal.js +11 -0
  27. package/dist/utils/formatting.js +12 -0
  28. package/dist/utils/spe.js +77 -0
  29. package/dist/utils/spo.js +0 -18
  30. package/docs/docs/cmd/cli/app/app-reconsent.mdx +63 -0
  31. package/docs/docs/cmd/graph/directoryextension/directoryextension-list.mdx +135 -0
  32. package/docs/docs/cmd/spe/container/container-activate.mdx +0 -2
  33. package/docs/docs/cmd/spe/container/container-add.mdx +128 -0
  34. package/docs/docs/cmd/spe/container/container-recyclebinitem-list.mdx +96 -0
  35. package/docs/docs/cmd/spe/container/container-remove.mdx +65 -0
  36. package/docs/docs/cmd/spe/containertype/containertype-add.mdx +9 -1
  37. package/docs/docs/cmd/spe/containertype/containertype-get.mdx +8 -0
  38. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +8 -0
  39. package/docs/docs/cmd/spe/containertype/containertype-remove.mdx +52 -0
  40. package/package.json +1 -1
  41. package/dist/m365/spe/ContainerProperties.js +0 -2
package/dist/config.js CHANGED
@@ -18,6 +18,7 @@ export default {
18
18
  'https://graph.microsoft.com/Directory.ReadWrite.All',
19
19
  'https://graph.microsoft.com/ExternalConnection.ReadWrite.All',
20
20
  'https://graph.microsoft.com/ExternalItem.ReadWrite.All',
21
+ 'https://graph.microsoft.com/FileStorageContainer.Selected',
21
22
  'https://graph.microsoft.com/Group.ReadWrite.All',
22
23
  'https://graph.microsoft.com/IdentityProvider.ReadWrite.All',
23
24
  'https://graph.microsoft.com/InformationProtectionPolicy.Read',
@@ -1,6 +1,6 @@
1
- import AppCommand from '../../base/AppCommand.js';
2
- import commands from '../commands.js';
3
1
  import { entraApp } from '../../../utils/entraApp.js';
2
+ import AppCommand, { appCommandOptions } from '../../base/AppCommand.js';
3
+ import commands from '../commands.js';
4
4
  class AppGetCommand extends AppCommand {
5
5
  get name() {
6
6
  return commands.GET;
@@ -8,6 +8,9 @@ class AppGetCommand extends AppCommand {
8
8
  get description() {
9
9
  return 'Retrieves information about the current Microsoft Entra app';
10
10
  }
11
+ get schema() {
12
+ return appCommandOptions;
13
+ }
11
14
  async commandAction(logger, args) {
12
15
  try {
13
16
  const app = await entraApp.getAppRegistrationByAppId(args.options.appId);
@@ -1,14 +1,14 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _AppOpenCommand_instances, _AppOpenCommand_initTelemetry, _AppOpenCommand_initOptions;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../cli/cli.js';
8
3
  import { settingsNames } from '../../../settingsNames.js';
9
4
  import { browserUtil } from '../../../utils/browserUtil.js';
10
- import AppCommand from '../../base/AppCommand.js';
5
+ import AppCommand, { appCommandOptions } from '../../base/AppCommand.js';
11
6
  import commands from '../commands.js';
7
+ const options = appCommandOptions
8
+ .extend({
9
+ preview: z.boolean().optional().default(false)
10
+ })
11
+ .strict();
12
12
  class AppOpenCommand extends AppCommand {
13
13
  get name() {
14
14
  return commands.OPEN;
@@ -16,11 +16,8 @@ class AppOpenCommand extends AppCommand {
16
16
  get description() {
17
17
  return 'Opens Microsoft Entra app in the Microsoft Entra ID portal';
18
18
  }
19
- constructor() {
20
- super();
21
- _AppOpenCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initOptions).call(this);
19
+ get schema() {
20
+ return options;
24
21
  }
25
22
  async commandAction(logger, args) {
26
23
  try {
@@ -41,15 +38,5 @@ class AppOpenCommand extends AppCommand {
41
38
  await browserUtil.open(url);
42
39
  }
43
40
  }
44
- _AppOpenCommand_instances = new WeakSet(), _AppOpenCommand_initTelemetry = function _AppOpenCommand_initTelemetry() {
45
- this.telemetry.push((args) => {
46
- Object.assign(this.telemetryProperties, {
47
- appId: typeof args.options.appId !== 'undefined',
48
- preview: typeof args.options.preview !== 'undefined'
49
- });
50
- });
51
- }, _AppOpenCommand_initOptions = function _AppOpenCommand_initOptions() {
52
- this.options.unshift({ option: '--appId [appId]' }, { option: '--preview' });
53
- };
54
41
  export default new AppOpenCommand();
55
42
  //# sourceMappingURL=app-open.js.map
@@ -1,14 +1,16 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _AppPermissionAddCommand_instances, _AppPermissionAddCommand_initTelemetry, _AppPermissionAddCommand_initOptions, _AppPermissionAddCommand_initOptionSets;
1
+ import { z } from 'zod';
7
2
  import request from '../../../../request.js';
8
3
  import { formatting } from '../../../../utils/formatting.js';
9
4
  import { odata } from '../../../../utils/odata.js';
10
- import AppCommand from '../../../base/AppCommand.js';
5
+ import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
11
6
  import commands from '../../commands.js';
7
+ const options = appCommandOptions
8
+ .extend({
9
+ applicationPermissions: z.string().optional(),
10
+ delegatedPermissions: z.string().optional(),
11
+ grantAdminConsent: z.boolean().optional()
12
+ })
13
+ .strict();
12
14
  var ScopeType;
13
15
  (function (ScopeType) {
14
16
  ScopeType["Role"] = "Role";
@@ -21,12 +23,15 @@ class AppPermissionAddCommand extends AppCommand {
21
23
  get description() {
22
24
  return 'Adds the specified application and/or delegated permissions to the current Microsoft Entra app API permissions';
23
25
  }
24
- constructor() {
25
- super();
26
- _AppPermissionAddCommand_instances.add(this);
27
- __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initTelemetry).call(this);
28
- __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initOptions).call(this);
29
- __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initOptionSets).call(this);
26
+ get schema() {
27
+ return options;
28
+ }
29
+ getRefinedSchema(schema) {
30
+ return schema
31
+ .refine(options => options.applicationPermissions || options.delegatedPermissions, {
32
+ message: 'Specify at least one of applicationPermissions or delegatedPermissions, or both.',
33
+ path: ['delegatedPermissions']
34
+ });
30
35
  }
31
36
  async commandAction(logger, args) {
32
37
  try {
@@ -194,22 +199,5 @@ class AppPermissionAddCommand extends AppCommand {
194
199
  return request.post(requestOptions);
195
200
  }
196
201
  }
197
- _AppPermissionAddCommand_instances = new WeakSet(), _AppPermissionAddCommand_initTelemetry = function _AppPermissionAddCommand_initTelemetry() {
198
- this.telemetry.push((args) => {
199
- Object.assign(this.telemetryProperties, {
200
- appId: typeof args.options.appId !== 'undefined',
201
- applicationPermissions: typeof args.options.applicationPermissions !== 'undefined',
202
- delegatedPermissions: typeof args.options.delegatedPermissions !== 'undefined',
203
- grantAdminConsent: !!args.options.grantAdminConsent
204
- });
205
- });
206
- }, _AppPermissionAddCommand_initOptions = function _AppPermissionAddCommand_initOptions() {
207
- this.options.unshift({ option: '--appId [appId]' }, { option: '--applicationPermissions [applicationPermissions]' }, { option: '--delegatedPermissions [delegatedPermissions]' }, { option: '--grantAdminConsent' });
208
- }, _AppPermissionAddCommand_initOptionSets = function _AppPermissionAddCommand_initOptionSets() {
209
- this.optionSets.push({
210
- options: ['applicationPermissions', 'delegatedPermissions'],
211
- runsWhen: (args) => args.options.delegatedPermissions === undefined && args.options.applicationPermissions === undefined
212
- });
213
- };
214
202
  export default new AppPermissionAddCommand();
215
203
  //# sourceMappingURL=permission-add.js.map
@@ -1,7 +1,7 @@
1
1
  import request from '../../../../request.js';
2
- import AppCommand from '../../../base/AppCommand.js';
3
- import commands from '../../commands.js';
4
2
  import { entraApp } from '../../../../utils/entraApp.js';
3
+ import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
4
+ import commands from '../../commands.js';
5
5
  var GetServicePrincipal;
6
6
  (function (GetServicePrincipal) {
7
7
  GetServicePrincipal[GetServicePrincipal["withPermissions"] = 0] = "withPermissions";
@@ -14,6 +14,9 @@ class AppPermissionListCommand extends AppCommand {
14
14
  get description() {
15
15
  return 'Lists API permissions for the current Microsoft Entra app';
16
16
  }
17
+ get schema() {
18
+ return appCommandOptions;
19
+ }
17
20
  async commandAction(logger) {
18
21
  try {
19
22
  const servicePrincipal = await this.getServicePrincipal({ appId: this.appId }, logger, GetServicePrincipal.withPermissions);
@@ -1,23 +1,18 @@
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 _AppCommand_instances, _AppCommand_initOptions, _AppCommand_initValidators;
7
1
  import fs from 'fs';
2
+ import { z } from 'zod';
8
3
  import { cli } from '../../cli/cli.js';
9
- import Command, { CommandError } from '../../Command.js';
10
- import { validation } from '../../utils/validation.js';
4
+ import Command, { CommandError, globalOptionsZod } from '../../Command.js';
11
5
  import { formatting } from '../../utils/formatting.js';
12
- class AppCommand extends Command {
6
+ export const appCommandOptions = globalOptionsZod
7
+ .extend({
8
+ appId: z.string().uuid().optional()
9
+ });
10
+ export default class AppCommand extends Command {
13
11
  get resource() {
14
12
  return 'https://graph.microsoft.com';
15
13
  }
16
- constructor() {
17
- super();
18
- _AppCommand_instances.add(this);
19
- __classPrivateFieldGet(this, _AppCommand_instances, "m", _AppCommand_initOptions).call(this);
20
- __classPrivateFieldGet(this, _AppCommand_instances, "m", _AppCommand_initValidators).call(this);
14
+ get schema() {
15
+ return appCommandOptions;
21
16
  }
22
17
  async action(logger, args) {
23
18
  const m365rcJsonPath = '.m365rc.json';
@@ -63,15 +58,4 @@ class AppCommand extends Command {
63
58
  }
64
59
  }
65
60
  }
66
- _AppCommand_instances = new WeakSet(), _AppCommand_initOptions = function _AppCommand_initOptions() {
67
- this.options.unshift({ option: '--appId [appId]' });
68
- }, _AppCommand_initValidators = function _AppCommand_initValidators() {
69
- this.validators.push(async (args) => {
70
- if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
71
- return `${args.options.appId} is not a valid GUID`;
72
- }
73
- return true;
74
- });
75
- };
76
- export default AppCommand;
77
61
  //# sourceMappingURL=AppCommand.js.map
@@ -1,14 +1,17 @@
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 _BookingBusinessGetCommand_instances, _BookingBusinessGetCommand_initTelemetry, _BookingBusinessGetCommand_initOptions, _BookingBusinessGetCommand_initOptionSets;
1
+ import { z } from 'zod';
2
+ import { cli } from '../../../../cli/cli.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
7
4
  import request from '../../../../request.js';
8
5
  import { formatting } from '../../../../utils/formatting.js';
6
+ import { zod } from '../../../../utils/zod.js';
9
7
  import GraphCommand from '../../../base/GraphCommand.js';
10
8
  import commands from '../../commands.js';
11
- import { cli } from '../../../../cli/cli.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ id: zod.alias('i', z.string().optional()),
12
+ name: zod.alias('n', z.string().optional())
13
+ })
14
+ .strict();
12
15
  class BookingBusinessGetCommand extends GraphCommand {
13
16
  get name() {
14
17
  return commands.BUSINESS_GET;
@@ -16,12 +19,14 @@ class BookingBusinessGetCommand extends GraphCommand {
16
19
  get description() {
17
20
  return 'Retrieve the specified Microsoft Bookings business.';
18
21
  }
19
- constructor() {
20
- super();
21
- _BookingBusinessGetCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _BookingBusinessGetCommand_instances, "m", _BookingBusinessGetCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _BookingBusinessGetCommand_instances, "m", _BookingBusinessGetCommand_initOptions).call(this);
24
- __classPrivateFieldGet(this, _BookingBusinessGetCommand_instances, "m", _BookingBusinessGetCommand_initOptionSets).call(this);
22
+ get schema() {
23
+ return options;
24
+ }
25
+ getRefinedSchema(schema) {
26
+ return schema
27
+ .refine(options => options.id || options.name, {
28
+ message: 'Specify either id or name'
29
+ });
25
30
  }
26
31
  async commandAction(logger, args) {
27
32
  try {
@@ -65,17 +70,5 @@ class BookingBusinessGetCommand extends GraphCommand {
65
70
  return bookingBusinesses[0].id;
66
71
  }
67
72
  }
68
- _BookingBusinessGetCommand_instances = new WeakSet(), _BookingBusinessGetCommand_initTelemetry = function _BookingBusinessGetCommand_initTelemetry() {
69
- this.telemetry.push((args) => {
70
- Object.assign(this.telemetryProperties, {
71
- id: typeof args.options.id !== 'undefined',
72
- name: typeof args.options.name !== 'undefined'
73
- });
74
- });
75
- }, _BookingBusinessGetCommand_initOptions = function _BookingBusinessGetCommand_initOptions() {
76
- this.options.unshift({ option: '-i, --id [id]' }, { option: '-n, --name [name]' });
77
- }, _BookingBusinessGetCommand_initOptionSets = function _BookingBusinessGetCommand_initOptionSets() {
78
- this.optionSets.push({ options: ['id', 'name'] });
79
- };
80
73
  export default new BookingBusinessGetCommand();
81
74
  //# sourceMappingURL=business-get.js.map
@@ -0,0 +1,103 @@
1
+ import GraphCommand from '../../../base/GraphCommand.js';
2
+ import commands from '../../commands.js';
3
+ import auth from '../../../../Auth.js';
4
+ import config from '../../../../config.js';
5
+ import { urlUtil } from '../../../../utils/urlUtil.js';
6
+ import request from '../../../../request.js';
7
+ import { cli } from '../../../../cli/cli.js';
8
+ import { settingsNames } from '../../../../settingsNames.js';
9
+ import { browserUtil } from '../../../../utils/browserUtil.js';
10
+ import { entraApp } from '../../../../utils/entraApp.js';
11
+ import { entraServicePrincipal } from '../../../../utils/entraServicePrincipal.js';
12
+ class CliAppReconsentCommand extends GraphCommand {
13
+ get name() {
14
+ return commands.APP_RECONSENT;
15
+ }
16
+ get description() {
17
+ return 'Reconsent all permission scopes used in CLI for Microsoft 365';
18
+ }
19
+ async commandAction(logger) {
20
+ try {
21
+ const appId = auth.connection.appId;
22
+ if (this.verbose) {
23
+ await logger.logToStderr(`Adding all missing permission scopes used in CLI for Microsoft 365 to application with ID '${appId}'...`);
24
+ }
25
+ const application = await entraApp.getAppRegistrationByAppId(appId, ['requiredResourceAccess', 'id']);
26
+ await this.addCliAppScopes(logger, application.requiredResourceAccess);
27
+ await this.updateAppScopes(logger, application.id, application.requiredResourceAccess);
28
+ const consentUrl = `https://login.microsoftonline.com/${auth.connection.tenant}/adminconsent?client_id=${appId}`;
29
+ await logger.log(`To consent to the new scopes for your Microsoft Entra application registration, please navigate to the following URL: ${consentUrl}`);
30
+ if (cli.getSettingWithDefaultValue(settingsNames.autoOpenLinksInBrowser, false)) {
31
+ await browserUtil.open(consentUrl);
32
+ }
33
+ }
34
+ catch (err) {
35
+ this.handleRejectedODataJsonPromise(err);
36
+ }
37
+ }
38
+ async addCliAppScopes(logger, appScopes) {
39
+ const allCliScopes = config.allScopes;
40
+ const servicePrincipals = await entraServicePrincipal.getServicePrincipals('displayName,appId,oauth2PermissionScopes,servicePrincipalNames');
41
+ if (this.verbose) {
42
+ await logger.logToStderr(`Verifying if all ${allCliScopes.length} permission scopes are present in the app registration...`);
43
+ }
44
+ for (const cliScope of allCliScopes) {
45
+ // Extract service principal name and scope from the URL string
46
+ const spName = urlUtil.removeTrailingSlashes(cliScope.substring(0, cliScope.lastIndexOf('/')));
47
+ const scopeName = cliScope.substring(cliScope.lastIndexOf('/') + 1);
48
+ // Find the matching service principal by name
49
+ const servicePrincipal = servicePrincipals.find(sp => sp.servicePrincipalNames?.some(name => urlUtil.removeTrailingSlashes(name).toLowerCase() === spName.toLowerCase()));
50
+ if (!servicePrincipal) {
51
+ if (this.verbose) {
52
+ await logger.logToStderr(`Service principal with name '${spName}' not found. Skipping scope '${scopeName}'.`);
53
+ }
54
+ continue;
55
+ }
56
+ // Find the matching scope in the service principal
57
+ const scope = servicePrincipal.oauth2PermissionScopes?.find(s => s.value?.toLowerCase() === scopeName.toLowerCase());
58
+ if (!scope) {
59
+ if (this.verbose) {
60
+ await logger.logToStderr(`Scope '${scopeName}' not found in service principal '${spName}'. Skipping scope...`);
61
+ }
62
+ continue;
63
+ }
64
+ // Check if the service principal is already present in the app registration
65
+ let appSp = appScopes.find(sp => sp.resourceAppId?.toLowerCase() === servicePrincipal.appId.toLowerCase());
66
+ if (!appSp) {
67
+ // Service principal is not present in the app registration, let's add it
68
+ appSp = {
69
+ resourceAppId: servicePrincipal.appId,
70
+ resourceAccess: []
71
+ };
72
+ appScopes.push(appSp);
73
+ }
74
+ // Check if the scope is already present in the app registration
75
+ const isAppScopePresent = appSp.resourceAccess.some(s => s.id?.toLowerCase() === scope.id.toLowerCase());
76
+ if (!isAppScopePresent) {
77
+ // Scope is not present in the app registration, let's add it
78
+ appSp.resourceAccess.push({
79
+ id: scope.id,
80
+ type: 'Scope'
81
+ });
82
+ }
83
+ }
84
+ }
85
+ async updateAppScopes(logger, appId, appScopes) {
86
+ if (this.verbose) {
87
+ await logger.logToStderr(`Updating permission scopes of application with ID '${appId}'...`);
88
+ }
89
+ const requestOptions = {
90
+ url: `${this.resource}/v1.0/applications/${appId}`,
91
+ headers: {
92
+ accept: 'application/json;odata.metadata=none'
93
+ },
94
+ responseType: 'json',
95
+ data: {
96
+ requiredResourceAccess: appScopes
97
+ }
98
+ };
99
+ await request.patch(requestOptions);
100
+ }
101
+ }
102
+ export default new CliAppReconsentCommand();
103
+ //# sourceMappingURL=app-reconsent.js.map
@@ -1,5 +1,6 @@
1
1
  const prefix = 'cli';
2
2
  export default {
3
+ APP_RECONSENT: `${prefix} app reconsent`,
3
4
  COMPLETION_CLINK_UPDATE: `${prefix} completion clink update`,
4
5
  COMPLETION_PWSH_SETUP: `${prefix} completion pwsh setup`,
5
6
  COMPLETION_PWSH_UPDATE: `${prefix} completion pwsh update`,
@@ -1,14 +1,15 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _ContextRemoveCommand_instances, _ContextRemoveCommand_initTelemetry, _ContextRemoveCommand_initOptions;
7
1
  import fs from 'fs';
2
+ import { z } from 'zod';
8
3
  import { cli } from '../../../cli/cli.js';
9
- import { CommandError } from '../../../Command.js';
4
+ import { CommandError, globalOptionsZod } from '../../../Command.js';
5
+ import { zod } from '../../../utils/zod.js';
10
6
  import AnonymousCommand from '../../base/AnonymousCommand.js';
11
7
  import commands from '../commands.js';
8
+ const options = globalOptionsZod
9
+ .extend({
10
+ force: zod.alias('f', z.boolean().optional())
11
+ })
12
+ .strict();
12
13
  class ContextRemoveCommand extends AnonymousCommand {
13
14
  get name() {
14
15
  return commands.REMOVE;
@@ -16,20 +17,17 @@ class ContextRemoveCommand extends AnonymousCommand {
16
17
  get description() {
17
18
  return 'Removes the CLI for Microsoft 365 context in the current working folder';
18
19
  }
19
- constructor() {
20
- super();
21
- _ContextRemoveCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initOptions).call(this);
20
+ get schema() {
21
+ return options;
24
22
  }
25
23
  async commandAction(logger, args) {
26
24
  if (args.options.force) {
27
- await this.removeContext();
25
+ this.removeContext();
28
26
  }
29
27
  else {
30
28
  const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the context?` });
31
29
  if (result) {
32
- await this.removeContext();
30
+ this.removeContext();
33
31
  }
34
32
  }
35
33
  }
@@ -70,16 +68,5 @@ class ContextRemoveCommand extends AnonymousCommand {
70
68
  }
71
69
  }
72
70
  }
73
- _ContextRemoveCommand_instances = new WeakSet(), _ContextRemoveCommand_initTelemetry = function _ContextRemoveCommand_initTelemetry() {
74
- this.telemetry.push((args) => {
75
- Object.assign(this.telemetryProperties, {
76
- force: !!args.options.force
77
- });
78
- });
79
- }, _ContextRemoveCommand_initOptions = function _ContextRemoveCommand_initOptions() {
80
- this.options.unshift({
81
- option: '-f, --force'
82
- });
83
- };
84
71
  export default new ContextRemoveCommand();
85
72
  //# sourceMappingURL=context-remove.js.map
@@ -1,14 +1,16 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _ContextOptionRemoveCommand_instances, _ContextOptionRemoveCommand_initTelemetry, _ContextOptionRemoveCommand_initOptions;
7
1
  import fs from 'fs';
2
+ import { z } from 'zod';
8
3
  import { cli } from '../../../../cli/cli.js';
9
- import { CommandError } from '../../../../Command.js';
4
+ import { CommandError, globalOptionsZod } from '../../../../Command.js';
5
+ import { zod } from '../../../../utils/zod.js';
10
6
  import ContextCommand from '../../../base/ContextCommand.js';
11
7
  import commands from '../../commands.js';
8
+ const options = globalOptionsZod
9
+ .extend({
10
+ name: zod.alias('n', z.string()),
11
+ force: zod.alias('f', z.boolean().optional())
12
+ })
13
+ .strict();
12
14
  class ContextOptionRemoveCommand extends ContextCommand {
13
15
  get name() {
14
16
  return commands.OPTION_REMOVE;
@@ -16,11 +18,8 @@ class ContextOptionRemoveCommand extends ContextCommand {
16
18
  get description() {
17
19
  return 'Removes an already available name from local context file.';
18
20
  }
19
- constructor() {
20
- super();
21
- _ContextOptionRemoveCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _ContextOptionRemoveCommand_instances, "m", _ContextOptionRemoveCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _ContextOptionRemoveCommand_instances, "m", _ContextOptionRemoveCommand_initTelemetry).call(this);
21
+ get schema() {
22
+ return options;
24
23
  }
25
24
  async commandAction(logger, args) {
26
25
  if (this.verbose) {
@@ -70,18 +69,5 @@ class ContextOptionRemoveCommand extends ContextCommand {
70
69
  }
71
70
  }
72
71
  }
73
- _ContextOptionRemoveCommand_instances = new WeakSet(), _ContextOptionRemoveCommand_initTelemetry = function _ContextOptionRemoveCommand_initTelemetry() {
74
- this.telemetry.push((args) => {
75
- Object.assign(this.telemetryProperties, {
76
- force: !!args.options.force
77
- });
78
- });
79
- }, _ContextOptionRemoveCommand_initOptions = function _ContextOptionRemoveCommand_initOptions() {
80
- this.options.unshift({
81
- option: '-n, --name <name>'
82
- }, {
83
- option: '-f, --force'
84
- });
85
- };
86
72
  export default new ContextOptionRemoveCommand();
87
73
  //# sourceMappingURL=option-remove.js.map
@@ -0,0 +1,74 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import request from '../../../../request.js';
4
+ import commands from '../../commands.js';
5
+ import GraphCommand from '../../../base/GraphCommand.js';
6
+ import { validation } from '../../../../utils/validation.js';
7
+ import { entraApp } from '../../../../utils/entraApp.js';
8
+ import { odata } from '../../../../utils/odata.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ appId: z.string().refine(id => validation.isValidGuid(id), id => ({
12
+ message: `'${id}' is not a valid GUID.`
13
+ })).optional(),
14
+ appObjectId: z.string().refine(id => validation.isValidGuid(id), id => ({
15
+ message: `'${id}' is not a valid GUID.`
16
+ })).optional(),
17
+ appName: z.string().optional()
18
+ })
19
+ .strict();
20
+ class GraphDirectoryExtensionListCommand extends GraphCommand {
21
+ get name() {
22
+ return commands.DIRECTORYEXTENSION_LIST;
23
+ }
24
+ get description() {
25
+ return 'Retrieves a list of directory extensions';
26
+ }
27
+ defaultProperties() {
28
+ return ['id', 'name', 'appDisplayName'];
29
+ }
30
+ get schema() {
31
+ return options;
32
+ }
33
+ getRefinedSchema(schema) {
34
+ return schema
35
+ .refine(options => ([options.appId, options.appObjectId, options.appName].filter(x => x !== undefined).length <= 1), {
36
+ message: 'Specify either appId, appObjectId, or appName, but not multiple.'
37
+ });
38
+ }
39
+ async commandAction(logger, args) {
40
+ try {
41
+ if (args.options.appId || args.options.appObjectId || args.options.appName) {
42
+ const appObjectId = await this.getAppObjectId(args.options);
43
+ const endpoint = `${this.resource}/v1.0/applications/${appObjectId}/extensionProperties/`;
44
+ const items = await odata.getAllItems(endpoint);
45
+ await logger.log(items);
46
+ }
47
+ else {
48
+ const requestOptions = {
49
+ url: `${this.resource}/v1.0/directoryObjects/getAvailableExtensionProperties`,
50
+ headers: {
51
+ 'content-type': 'application/json;odata.metadata=none'
52
+ },
53
+ responseType: 'json'
54
+ };
55
+ const res = await request.post(requestOptions);
56
+ await logger.log(res.value);
57
+ }
58
+ }
59
+ catch (err) {
60
+ this.handleRejectedODataJsonPromise(err);
61
+ }
62
+ }
63
+ async getAppObjectId(options) {
64
+ if (options.appObjectId) {
65
+ return options.appObjectId;
66
+ }
67
+ if (options.appId) {
68
+ return (await entraApp.getAppRegistrationByAppId(options.appId, ["id"])).id;
69
+ }
70
+ return (await entraApp.getAppRegistrationByAppName(options.appName, ["id"])).id;
71
+ }
72
+ }
73
+ export default new GraphDirectoryExtensionListCommand();
74
+ //# sourceMappingURL=directoryextension-list.js.map
@@ -3,6 +3,7 @@ export default {
3
3
  CHANGELOG_LIST: `${prefix} changelog list`,
4
4
  DIRECTORYEXTENSION_ADD: `${prefix} directoryextension add`,
5
5
  DIRECTORYEXTENSION_GET: `${prefix} directoryextension get`,
6
+ DIRECTORYEXTENSION_LIST: `${prefix} directoryextension list`,
6
7
  DIRECTORYEXTENSION_REMOVE: `${prefix} directoryextension remove`,
7
8
  OPENEXTENSION_ADD: `${prefix} openextension add`,
8
9
  OPENEXTENSION_GET: `${prefix} openextension get`,