@pnp/cli-microsoft365 11.4.0-beta.87732f5 → 11.4.0-beta.f54089d

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 (131) hide show
  1. package/.devproxy/api-specs/sharepoint.yaml +43 -0
  2. package/README.md +1 -1
  3. package/allCommands.json +1 -1
  4. package/allCommandsFull.json +1 -1
  5. package/dist/Auth.js +1 -1
  6. package/dist/AuthServer.js +2 -4
  7. package/dist/Command.js +2 -2
  8. package/dist/cli/cli.js +9 -9
  9. package/dist/m365/adaptivecard/commands/adaptivecard-send.js +10 -11
  10. package/dist/m365/app/commands/app-open.js +3 -4
  11. package/dist/m365/app/commands/permission/permission-add.js +4 -5
  12. package/dist/m365/base/AppCommand.js +3 -3
  13. package/dist/m365/booking/commands/business/business-get.js +6 -8
  14. package/dist/m365/booking/commands/business/business-list.js +2 -1
  15. package/dist/m365/cli/commands/app/app-add.js +5 -7
  16. package/dist/m365/commands/docs.js +1 -1
  17. package/dist/m365/commands/login.js +22 -19
  18. package/dist/m365/commands/logout.js +1 -1
  19. package/dist/m365/commands/status.js +2 -1
  20. package/dist/m365/connection/commands/connection-list.js +2 -1
  21. package/dist/m365/connection/commands/connection-set.js +15 -29
  22. package/dist/m365/context/commands/context-remove.js +4 -6
  23. package/dist/m365/context/commands/option/option-remove.js +5 -7
  24. package/dist/m365/entra/commands/administrativeunit/administrativeunit-add.js +5 -7
  25. package/dist/m365/entra/commands/administrativeunit/administrativeunit-get.js +7 -9
  26. package/dist/m365/entra/commands/administrativeunit/administrativeunit-list.js +4 -5
  27. package/dist/m365/entra/commands/administrativeunit/administrativeunit-remove.js +8 -10
  28. package/dist/m365/entra/commands/license/license-list.js +1 -1
  29. package/dist/m365/entra/commands/m365group/m365group-remove.js +1 -1
  30. package/dist/m365/entra/commands/multitenant/multitenant-add.js +3 -4
  31. package/dist/m365/entra/commands/organization/organization-list.js +4 -6
  32. package/dist/m365/entra/commands/organization/organization-set.js +24 -26
  33. package/dist/m365/entra/commands/roleassignment/roleassignment-add.js +21 -34
  34. package/dist/m365/entra/commands/roledefinition/roledefinition-add.js +8 -10
  35. package/dist/m365/entra/commands/roledefinition/roledefinition-get.js +11 -13
  36. package/dist/m365/entra/commands/roledefinition/roledefinition-list.js +5 -7
  37. package/dist/m365/entra/commands/roledefinition/roledefinition-remove.js +11 -13
  38. package/dist/m365/entra/commands/roledefinition/roledefinition-set.js +15 -17
  39. package/dist/m365/entra/commands/rolepermission/rolepermission-list.js +5 -7
  40. package/dist/m365/entra/commands/user/user-session-revoke.js +9 -13
  41. package/dist/m365/exo/commands/approleassignment/approleassignment-add.js +29 -31
  42. package/dist/m365/flow/commands/environment/environment-get.js +5 -7
  43. package/dist/m365/flow/commands/environment/environment-list.js +2 -1
  44. package/dist/m365/flow/commands/recyclebinitem/recyclebinitem-list.js +4 -6
  45. package/dist/m365/flow/commands/recyclebinitem/recyclebinitem-restore.js +5 -11
  46. package/dist/m365/graph/commands/directoryextension/directoryextension-add.js +11 -13
  47. package/dist/m365/graph/commands/directoryextension/directoryextension-get.js +10 -19
  48. package/dist/m365/graph/commands/directoryextension/directoryextension-list.js +6 -12
  49. package/dist/m365/graph/commands/directoryextension/directoryextension-remove.js +11 -20
  50. package/dist/m365/graph/commands/openextension/openextension-add.js +12 -13
  51. package/dist/m365/graph/commands/openextension/openextension-get.js +12 -14
  52. package/dist/m365/graph/commands/openextension/openextension-list.js +11 -13
  53. package/dist/m365/graph/commands/openextension/openextension-remove.js +13 -15
  54. package/dist/m365/graph/commands/openextension/openextension-set.js +16 -17
  55. package/dist/m365/onedrive/commands/onedrive-list.js +2 -1
  56. package/dist/m365/outlook/commands/mail/mail-searchfolder-add.js +9 -14
  57. package/dist/m365/outlook/commands/mailbox/mailbox-settings-get.js +8 -12
  58. package/dist/m365/outlook/commands/mailbox/mailbox-settings-set.js +15 -15
  59. package/dist/m365/outlook/commands/roomlist/roomlist-list.js +2 -1
  60. package/dist/m365/pa/commands/environment/environment-get.js +5 -7
  61. package/dist/m365/pa/commands/environment/environment-list.js +2 -1
  62. package/dist/m365/planner/commands/tenant/tenant-settings-list.js +1 -1
  63. package/dist/m365/pp/commands/environment/environment-get.js +5 -7
  64. package/dist/m365/pp/commands/environment/environment-list.js +3 -4
  65. package/dist/m365/pp/commands/gateway/gateway-list.js +1 -1
  66. package/dist/m365/pp/commands/tenant/tenant-settings-list.js +1 -1
  67. package/dist/m365/pp/commands/website/website-get.js +12 -12
  68. package/dist/m365/purview/commands/retentionevent/retentionevent-list.js +2 -1
  69. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-list.js +1 -1
  70. package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +1 -1
  71. package/dist/m365/spe/commands/container/container-add.js +10 -15
  72. package/dist/m365/spe/commands/container/container-permission-list.js +4 -6
  73. package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +5 -10
  74. package/dist/m365/spe/commands/container/container-recyclebinitem-restore.js +7 -12
  75. package/dist/m365/spe/commands/container/container-remove.js +10 -16
  76. package/dist/m365/spe/commands/containertype/containertype-add.js +15 -20
  77. package/dist/m365/spe/commands/containertype/containertype-get.js +6 -13
  78. package/dist/m365/spe/commands/containertype/containertype-remove.js +7 -14
  79. package/dist/m365/spfx/commands/project/project-upgrade/rules/DependencyRule.js +56 -14
  80. package/dist/m365/spfx/commands/project/project-upgrade.js +4 -6
  81. package/dist/m365/spo/commands/file/file-add.js +49 -11
  82. package/dist/m365/spo/commands/file/file-version-keep.js +10 -14
  83. package/dist/m365/spo/commands/homesite/homesite-add.js +13 -15
  84. package/dist/m365/spo/commands/homesite/homesite-get.js +8 -9
  85. package/dist/m365/spo/commands/homesite/homesite-remove.js +9 -10
  86. package/dist/m365/spo/commands/homesite/homesite-set.js +13 -14
  87. package/dist/m365/spo/commands/list/DefaultColumnValue.js +2 -0
  88. package/dist/m365/spo/commands/list/list-defaultvalue-clear.js +13 -17
  89. package/dist/m365/spo/commands/list/list-defaultvalue-get.js +124 -0
  90. package/dist/m365/spo/commands/list/list-defaultvalue-list.js +13 -37
  91. package/dist/m365/spo/commands/list/list-defaultvalue-remove.js +12 -16
  92. package/dist/m365/spo/commands/list/list-defaultvalue-set.js +11 -15
  93. package/dist/m365/spo/commands/list/list-view-add.js +16 -20
  94. package/dist/m365/spo/commands/listitem/listitem-set.js +1 -1
  95. package/dist/m365/spo/commands/page/page-control-remove.js +11 -15
  96. package/dist/m365/spo/commands/page/page-get.js +10 -11
  97. package/dist/m365/spo/commands/page/page-header-set.js +97 -89
  98. package/dist/m365/spo/commands/page/page-publish.js +9 -10
  99. package/dist/m365/spo/commands/page/page-section-remove.js +11 -12
  100. package/dist/m365/spo/commands/page/page-set.js +26 -26
  101. package/dist/m365/spo/commands/site/site-appcatalog-list.js +4 -6
  102. package/dist/m365/spo/commands/site/site-get.js +6 -8
  103. package/dist/m365/spo/commands/site/site-sharingpermission-set.js +7 -9
  104. package/dist/m365/spo/commands/site/site-versionpolicy-get.js +11 -13
  105. package/dist/m365/spo/commands/web/web-alert-list.js +20 -27
  106. package/dist/m365/spo/commands/web/web-alert-remove.js +15 -20
  107. package/dist/m365/spo/commands.js +1 -0
  108. package/dist/m365/spp/commands/model/model-apply.js +18 -24
  109. package/dist/m365/teams/commands/callrecord/callrecord-list.js +5 -9
  110. package/dist/m365/teams/commands/chat/chat-message-list.js +26 -27
  111. package/dist/m365/teams/commands/chat/chat-message-send.js +12 -3
  112. package/dist/m365/teams/commands/chat/chatUtil.js +1 -1
  113. package/dist/m365/tenant/commands/people/people-pronouns-set.js +4 -6
  114. package/dist/m365/tenant/commands/report/report-settings-set.js +4 -6
  115. package/dist/m365/viva/commands/engage/engage-community-user-add.js +17 -22
  116. package/dist/m365/viva/commands/engage/engage-community-user-list.js +8 -14
  117. package/dist/m365/viva/commands/engage/engage-community-user-remove.js +14 -22
  118. package/dist/m365/viva/commands/engage/engage-role-member-list.js +6 -11
  119. package/dist/utils/spo.js +30 -2
  120. package/dist/utils/zod.js +41 -76
  121. package/docs/docs/cmd/entra/app/app-permission-add.mdx +19 -0
  122. package/docs/docs/cmd/entra/app/app-permission-list.mdx +19 -0
  123. package/docs/docs/cmd/entra/app/app-permission-remove.mdx +21 -0
  124. package/docs/docs/cmd/spo/file/file-add.mdx +140 -1
  125. package/docs/docs/cmd/spo/list/list-defaultvalue-get.mdx +118 -0
  126. package/docs/docs/cmd/spo/page/page-header-set.mdx +28 -8
  127. package/docs/docs/cmd/spo/page/page-set.mdx +35 -5
  128. package/docs/docs/cmd/teams/chat/chat-message-list.mdx +34 -7
  129. package/docs/docs/cmd/teams/chat/chat-message-send.mdx +23 -1
  130. package/npm-shrinkwrap.json +274 -248
  131. package/package.json +12 -11
package/dist/Auth.js CHANGED
@@ -798,7 +798,7 @@ export class Auth {
798
798
  const existingConnection = allConnections.find(c => c.name === newName);
799
799
  const oldName = connection.name;
800
800
  if (existingConnection) {
801
- throw new CommandError(`The connection name '${newName}' is already in use`);
801
+ throw new CommandError(`The connection name '${newName}' is already in use.`);
802
802
  }
803
803
  connection.name = newName;
804
804
  if (this.connection.name === oldName) {
@@ -1,5 +1,4 @@
1
1
  import http from 'http';
2
- import url from 'url';
3
2
  import { Auth } from './Auth.js';
4
3
  import { browserUtil } from './utils/browserUtil.js';
5
4
  export class AuthServer {
@@ -34,9 +33,8 @@ export class AuthServer {
34
33
  await this.logger.logToStderr(request.url);
35
34
  await this.logger.logToStderr('');
36
35
  }
37
- // url.parse is deprecated but we can't move to URL, because it doesn't
38
- // support server-relative URLs
39
- const queryString = url.parse(request.url, true).query;
36
+ const urlObj = new URL(request.url, 'http://localhost');
37
+ const queryString = Object.fromEntries(urlObj.searchParams.entries());
40
38
  const hasCode = queryString.code !== undefined;
41
39
  const hasError = queryString.error !== undefined;
42
40
  let body = "";
package/dist/Command.js CHANGED
@@ -13,9 +13,9 @@ import { settingsNames } from './settingsNames.js';
13
13
  import { telemetry } from './telemetry.js';
14
14
  import { accessToken } from './utils/accessToken.js';
15
15
  import { md } from './utils/md.js';
16
+ import { optionsUtils } from './utils/optionsUtils.js';
16
17
  import { prompt } from './utils/prompt.js';
17
18
  import { zod } from './utils/zod.js';
18
- import { optionsUtils } from './utils/optionsUtils.js';
19
19
  export class CommandError {
20
20
  constructor(message, code) {
21
21
  this.message = message;
@@ -30,7 +30,7 @@ export class CommandErrorWithOutput {
30
30
  }
31
31
  export const globalOptionsZod = z.object({
32
32
  query: z.string().optional(),
33
- output: zod.alias('o', z.enum(['csv', 'json', 'md', 'text', 'none']).optional()),
33
+ output: z.enum(['csv', 'json', 'md', 'text', 'none']).optional().alias('o'),
34
34
  debug: z.boolean().default(false),
35
35
  verbose: z.boolean().default(false)
36
36
  });
package/dist/cli/cli.js CHANGED
@@ -145,7 +145,7 @@ async function execute(rawArgs) {
145
145
  if (cli.commandToExecute?.command.schema) {
146
146
  while (true) {
147
147
  const startValidation = process.hrtime.bigint();
148
- const result = cli.commandToExecute.command.getSchemaToParse().safeParse(cli.optionsFromArgs.options);
148
+ const result = await cli.commandToExecute.command.getSchemaToParse().safeParseAsync(cli.optionsFromArgs.options);
149
149
  const endValidation = process.hrtime.bigint();
150
150
  timings.validation.push(Number(endValidation - startValidation));
151
151
  if (result.success) {
@@ -153,13 +153,13 @@ async function execute(rawArgs) {
153
153
  break;
154
154
  }
155
155
  else {
156
- const hasNonRequiredErrors = result.error.errors.some(e => e.code !== 'invalid_type' || e.received !== 'undefined');
156
+ const hasNonRequiredErrors = result.error.issues.some(i => i.code !== 'invalid_type');
157
157
  const shouldPrompt = cli.getSettingWithDefaultValue(settingsNames.prompt, true);
158
158
  if (hasNonRequiredErrors === false &&
159
159
  shouldPrompt) {
160
160
  await cli.error('🌶️ Provide values for the following parameters:');
161
- for (const error of result.error.errors) {
162
- const optionName = error.path.join('.');
161
+ for (const issue of result.error.issues) {
162
+ const optionName = issue.path.join('.');
163
163
  const optionInfo = cli.commandToExecute.options.find(o => o.name === optionName);
164
164
  const answer = await cli.promptForValue(optionInfo);
165
165
  // coerce the answer to the correct type
@@ -173,10 +173,10 @@ async function execute(rawArgs) {
173
173
  }
174
174
  }
175
175
  else {
176
- result.error.errors.forEach(e => {
177
- if (e.code === 'invalid_type' &&
178
- e.received === 'undefined') {
179
- e.message = `Required option not specified`;
176
+ result.error.issues.forEach(i => {
177
+ if (i.code === 'invalid_type' &&
178
+ i.input === undefined) {
179
+ i.message = `Required option not specified`;
180
180
  }
181
181
  });
182
182
  return cli.closeWithError(result.error, cli.optionsFromArgs, true);
@@ -793,7 +793,7 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
793
793
  }
794
794
  let errorMessage = error instanceof CommandError ? error.message : error;
795
795
  if (error instanceof ZodError) {
796
- errorMessage = error.errors.map(e => (e.path.length > 0 ? `${e.path.join('.')}: ${e.message}` : e.message)).join(os.EOL);
796
+ errorMessage = error.issues.map(i => (i.path.length > 0 ? `${i.path.join('.')}: ${i.message}` : i.message)).join(os.EOL);
797
797
  }
798
798
  if ((!args.options.output || args.options.output === 'json') &&
799
799
  !cli.getSettingWithDefaultValue(settingsNames.printErrorsAsPlainText, true)) {
@@ -5,17 +5,16 @@ import { optionsUtils } from '../../../utils/optionsUtils.js';
5
5
  import { zod } from '../../../utils/zod.js';
6
6
  import AnonymousCommand from '../../base/AnonymousCommand.js';
7
7
  import commands from '../commands.js';
8
- export const options = globalOptionsZod
9
- .extend({
8
+ export const options = z.looseObject({
9
+ ...globalOptionsZod.shape,
10
10
  url: z.string(),
11
- title: zod.alias('t', z.string().optional()),
12
- description: zod.alias('d', z.string().optional()),
13
- imageUrl: zod.alias('i', z.string().optional()),
14
- actionUrl: zod.alias('a', z.string().optional()),
11
+ title: z.string().optional().alias('t'),
12
+ description: z.string().optional().alias('d'),
13
+ imageUrl: z.string().optional().alias('i'),
14
+ actionUrl: z.string().optional().alias('a'),
15
15
  card: z.string().optional(),
16
16
  cardData: z.string().optional()
17
- })
18
- .passthrough();
17
+ });
19
18
  class AdaptiveCardSendCommand extends AnonymousCommand {
20
19
  get name() {
21
20
  return commands.SEND;
@@ -29,7 +28,7 @@ class AdaptiveCardSendCommand extends AnonymousCommand {
29
28
  getRefinedSchema(schema) {
30
29
  return schema
31
30
  .refine(options => !options.cardData || options.card, {
32
- message: 'When you specify cardData, you must also specify card.',
31
+ error: 'When you specify cardData, you must also specify card.',
33
32
  path: ['cardData']
34
33
  })
35
34
  .refine(options => {
@@ -44,7 +43,7 @@ class AdaptiveCardSendCommand extends AnonymousCommand {
44
43
  }
45
44
  return true;
46
45
  }, {
47
- message: 'Specified card is not a valid JSON string.',
46
+ error: 'Specified card is not a valid JSON string.',
48
47
  path: ['card']
49
48
  })
50
49
  .refine(options => {
@@ -59,7 +58,7 @@ class AdaptiveCardSendCommand extends AnonymousCommand {
59
58
  }
60
59
  return true;
61
60
  }, {
62
- message: 'Specified cardData is not a valid JSON string.',
61
+ error: 'Specified cardData is not a valid JSON string.',
63
62
  path: ['cardData']
64
63
  });
65
64
  }
@@ -4,11 +4,10 @@ import { settingsNames } from '../../../settingsNames.js';
4
4
  import { browserUtil } from '../../../utils/browserUtil.js';
5
5
  import AppCommand, { appCommandOptions } from '../../base/AppCommand.js';
6
6
  import commands from '../commands.js';
7
- const options = appCommandOptions
8
- .extend({
7
+ export const options = z.strictObject({
8
+ ...appCommandOptions.shape,
9
9
  preview: z.boolean().optional().default(false)
10
- })
11
- .strict();
10
+ });
12
11
  class AppOpenCommand extends AppCommand {
13
12
  get name() {
14
13
  return commands.OPEN;
@@ -5,13 +5,12 @@ import { odata } from '../../../../utils/odata.js';
5
5
  import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
6
6
  import commands from '../../commands.js';
7
7
  import { entraServicePrincipal } from '../../../../utils/entraServicePrincipal.js';
8
- const options = appCommandOptions
9
- .extend({
8
+ export const options = z.strictObject({
9
+ ...appCommandOptions.shape,
10
10
  applicationPermissions: z.string().optional(),
11
11
  delegatedPermissions: z.string().optional(),
12
12
  grantAdminConsent: z.boolean().optional()
13
- })
14
- .strict();
13
+ });
15
14
  var ScopeType;
16
15
  (function (ScopeType) {
17
16
  ScopeType["Role"] = "Role";
@@ -30,7 +29,7 @@ class AppPermissionAddCommand extends AppCommand {
30
29
  getRefinedSchema(schema) {
31
30
  return schema
32
31
  .refine(options => options.applicationPermissions || options.delegatedPermissions, {
33
- message: 'Specify at least one of applicationPermissions or delegatedPermissions, or both.',
32
+ error: 'Specify at least one of applicationPermissions or delegatedPermissions, or both.',
34
33
  path: ['delegatedPermissions']
35
34
  });
36
35
  }
@@ -3,9 +3,9 @@ import { z } from 'zod';
3
3
  import { cli } from '../../cli/cli.js';
4
4
  import Command, { CommandError, globalOptionsZod } from '../../Command.js';
5
5
  import { formatting } from '../../utils/formatting.js';
6
- export const appCommandOptions = globalOptionsZod
7
- .extend({
8
- appId: z.string().uuid().optional()
6
+ export const appCommandOptions = z.object({
7
+ ...globalOptionsZod.shape,
8
+ appId: z.uuid().optional()
9
9
  });
10
10
  export default class AppCommand extends Command {
11
11
  get resource() {
@@ -3,15 +3,13 @@ import { cli } from '../../../../cli/cli.js';
3
3
  import { globalOptionsZod } from '../../../../Command.js';
4
4
  import request from '../../../../request.js';
5
5
  import { formatting } from '../../../../utils/formatting.js';
6
- import { zod } from '../../../../utils/zod.js';
7
6
  import GraphCommand from '../../../base/GraphCommand.js';
8
7
  import commands from '../../commands.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();
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ id: z.string().optional().alias('i'),
11
+ name: z.string().optional().alias('n')
12
+ });
15
13
  class BookingBusinessGetCommand extends GraphCommand {
16
14
  get name() {
17
15
  return commands.BUSINESS_GET;
@@ -25,7 +23,7 @@ class BookingBusinessGetCommand extends GraphCommand {
25
23
  getRefinedSchema(schema) {
26
24
  return schema
27
25
  .refine(options => options.id || options.name, {
28
- message: 'Specify either id or name'
26
+ error: 'Specify either id or name'
29
27
  });
30
28
  }
31
29
  async commandAction(logger, args) {
@@ -1,8 +1,9 @@
1
+ import { z } from 'zod';
1
2
  import { globalOptionsZod } from '../../../../Command.js';
2
3
  import { odata } from '../../../../utils/odata.js';
3
4
  import GraphCommand from '../../../base/GraphCommand.js';
4
5
  import commands from '../../commands.js';
5
- const options = globalOptionsZod.strict();
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
6
7
  class BookingBusinessListCommand extends GraphCommand {
7
8
  get name() {
8
9
  return commands.BUSINESS_LIST;
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
2
  import { globalOptionsZod } from '../../../../Command.js';
3
- import { zod } from '../../../../utils/zod.js';
4
3
  import config from '../../../../config.js';
5
4
  import GraphCommand from '../../../base/GraphCommand.js';
6
5
  import commands from '../../commands.js';
@@ -8,13 +7,12 @@ import { cli } from '../../../../cli/cli.js';
8
7
  import { entraApp } from '../../../../utils/entraApp.js';
9
8
  import { accessToken } from '../../../../utils/accessToken.js';
10
9
  import auth from '../../../../Auth.js';
11
- const options = globalOptionsZod
12
- .extend({
13
- name: zod.alias('n', z.string().optional().default('CLI for M365')),
14
- scopes: zod.alias('s', z.string().optional().default('minimal')),
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ name: z.string().optional().default('CLI for M365').alias('n'),
13
+ scopes: z.string().optional().default('minimal').alias('s'),
15
14
  saveToConfig: z.boolean().optional()
16
- })
17
- .strict();
15
+ });
18
16
  class CliAppAddCommand extends GraphCommand {
19
17
  get name() {
20
18
  return commands.APP_ADD;
@@ -5,7 +5,7 @@ import { app } from '../../utils/app.js';
5
5
  import { browserUtil } from '../../utils/browserUtil.js';
6
6
  import AnonymousCommand from '../base/AnonymousCommand.js';
7
7
  import commands from './commands.js';
8
- const options = globalOptionsZod.strict();
8
+ export const options = globalOptionsZod.strict();
9
9
  class DocsCommand extends AnonymousCommand {
10
10
  get name() {
11
11
  return commands.DOCS;
@@ -6,25 +6,28 @@ import { cli } from '../../cli/cli.js';
6
6
  import { settingsNames } from '../../settingsNames.js';
7
7
  import { zod } from '../../utils/zod.js';
8
8
  import commands from './commands.js';
9
- const options = globalOptionsZod
10
- .extend({
11
- authType: zod.alias('t', zod.coercedEnum(AuthType).optional()),
9
+ export const options = z.strictObject({
10
+ ...globalOptionsZod.shape,
11
+ authType: zod.coercedEnum(AuthType).optional().alias('t'),
12
12
  cloud: zod.coercedEnum(CloudType).optional().default(CloudType.Public),
13
- userName: zod.alias('u', z.string().optional()),
14
- password: zod.alias('p', z.string().optional()),
15
- certificateFile: zod.alias('c', z.string().optional()
16
- .refine(filePath => !filePath || fs.existsSync(filePath), filePath => ({
17
- message: `Certificate file ${filePath} does not exist`
18
- }))),
13
+ userName: z.string().optional().alias('u'),
14
+ password: z.string().optional().alias('p'),
15
+ certificateFile: z.string().optional().alias('c')
16
+ .refine(filePath => !filePath || fs.existsSync(filePath), {
17
+ error: e => `Certificate file ${e.input} does not exist`
18
+ }),
19
19
  certificateBase64Encoded: z.string().optional(),
20
20
  thumbprint: z.string().optional(),
21
21
  appId: z.string().optional(),
22
22
  tenant: z.string().optional(),
23
- secret: zod.alias('s', z.string().optional()),
24
- connectionName: z.string().optional(),
23
+ secret: z.string().optional().alias('s'),
24
+ connectionName: z.string()
25
+ .refine(async (name) => !(await auth.getAllConnections()).some(c => c.name === name), {
26
+ error: e => `Connection with name '${e.input}' already exists.`
27
+ })
28
+ .optional(),
25
29
  ensure: z.boolean().optional()
26
- })
27
- .strict();
30
+ });
28
31
  class LoginCommand extends Command {
29
32
  get name() {
30
33
  return commands.LOGIN;
@@ -38,19 +41,19 @@ class LoginCommand extends Command {
38
41
  getRefinedSchema(schema) {
39
42
  return schema
40
43
  .refine(options => typeof options.appId !== 'undefined' || cli.getClientId() || options.authType === 'identity' || options.authType === 'federatedIdentity', {
41
- message: `appId is required. TIP: use the "m365 setup" command to configure the default appId.`,
44
+ error: `appId is required. TIP: use the "m365 setup" command to configure the default appId.`,
42
45
  path: ['appId']
43
46
  })
44
47
  .refine(options => options.authType !== 'password' || options.userName, {
45
- message: 'Username is required when using password authentication.',
48
+ error: 'Username is required when using password authentication.',
46
49
  path: ['userName']
47
50
  })
48
51
  .refine(options => options.authType !== 'password' || options.password, {
49
- message: 'Password is required when using password authentication.',
52
+ error: 'Password is required when using password authentication.',
50
53
  path: ['password']
51
54
  })
52
55
  .refine(options => options.authType !== 'certificate' || !(options.certificateFile && options.certificateBase64Encoded), {
53
- message: 'Specify either certificateFile or certificateBase64Encoded, but not both.',
56
+ error: 'Specify either certificateFile or certificateBase64Encoded, but not both.',
54
57
  path: ['certificateBase64Encoded']
55
58
  })
56
59
  .refine(options => options.authType !== 'certificate' ||
@@ -58,13 +61,13 @@ class LoginCommand extends Command {
58
61
  options.certificateBase64Encoded ||
59
62
  cli.getConfig().get(settingsNames.clientCertificateFile) ||
60
63
  cli.getConfig().get(settingsNames.clientCertificateBase64Encoded), {
61
- message: 'Specify either certificateFile or certificateBase64Encoded.',
64
+ error: 'Specify either certificateFile or certificateBase64Encoded.',
62
65
  path: ['certificateFile']
63
66
  })
64
67
  .refine(options => options.authType !== 'secret' ||
65
68
  options.secret ||
66
69
  cli.getConfig().get(settingsNames.clientSecret), {
67
- message: 'Secret is required when using secret authentication.',
70
+ error: 'Secret is required when using secret authentication.',
68
71
  path: ['secret']
69
72
  });
70
73
  }
@@ -1,7 +1,7 @@
1
1
  import auth from '../../Auth.js';
2
2
  import Command, { CommandError, globalOptionsZod } from '../../Command.js';
3
3
  import commands from './commands.js';
4
- const options = globalOptionsZod.strict();
4
+ export const options = globalOptionsZod.strict();
5
5
  class LogoutCommand extends Command {
6
6
  get name() {
7
7
  return commands.LOGOUT;
@@ -1,7 +1,8 @@
1
+ import { z } from 'zod';
1
2
  import auth from '../../Auth.js';
2
3
  import Command, { CommandError, globalOptionsZod } from '../../Command.js';
3
4
  import commands from './commands.js';
4
- const options = globalOptionsZod.strict();
5
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
5
6
  class StatusCommand extends Command {
6
7
  get name() {
7
8
  return commands.STATUS;
@@ -1,8 +1,9 @@
1
1
  import assert from 'assert';
2
+ import { z } from 'zod';
2
3
  import auth from '../../../Auth.js';
3
4
  import Command, { CommandError, globalOptionsZod } from '../../../Command.js';
4
5
  import commands from '../commands.js';
5
- const options = globalOptionsZod.strict();
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
6
7
  class ConnectionListCommand extends Command {
7
8
  get name() {
8
9
  return commands.LIST;
@@ -1,12 +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 _ConnectionSetCommand_instances, _ConnectionSetCommand_initOptions, _ConnectionSetCommand_initValidators, _ConnectionSetCommand_initTypes;
7
1
  import auth from '../../../Auth.js';
8
2
  import commands from '../commands.js';
9
- import Command, { CommandError } from '../../../Command.js';
3
+ import Command, { CommandError, globalOptionsZod } from '../../../Command.js';
4
+ import z from 'zod';
5
+ export const options = z.strictObject({
6
+ ...globalOptionsZod.shape,
7
+ name: z.string().alias('n')
8
+ .refine(async (name) => (await auth.getAllConnections()).some(c => c.name === name), {
9
+ error: e => `Connection with name '${e.input}' does not exist.`
10
+ }),
11
+ newName: z.string()
12
+ .refine(async (newName) => !(await auth.getAllConnections()).some(c => c.name === newName), {
13
+ error: e => `Connection with name '${e.input}' already exists.`
14
+ })
15
+ });
10
16
  class ConnectionSetCommand extends Command {
11
17
  get name() {
12
18
  return commands.SET;
@@ -14,12 +20,8 @@ class ConnectionSetCommand extends Command {
14
20
  get description() {
15
21
  return 'Rename the specified connection';
16
22
  }
17
- constructor() {
18
- super();
19
- _ConnectionSetCommand_instances.add(this);
20
- __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initOptions).call(this);
21
- __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initValidators).call(this);
22
- __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initTypes).call(this);
23
+ get schema() {
24
+ return options;
23
25
  }
24
26
  async commandAction(logger, args) {
25
27
  const connection = await auth.getConnection(args.options.name);
@@ -39,21 +41,5 @@ class ConnectionSetCommand extends Command {
39
41
  await this.commandAction(logger, args);
40
42
  }
41
43
  }
42
- _ConnectionSetCommand_instances = new WeakSet(), _ConnectionSetCommand_initOptions = function _ConnectionSetCommand_initOptions() {
43
- this.options.unshift({
44
- option: '-n, --name <name>'
45
- }, {
46
- option: '--newName <newName>'
47
- });
48
- }, _ConnectionSetCommand_initValidators = function _ConnectionSetCommand_initValidators() {
49
- this.validators.push(async (args) => {
50
- if (args.options.name === args.options.newName) {
51
- return `Choose a name different from the current one`;
52
- }
53
- return true;
54
- });
55
- }, _ConnectionSetCommand_initTypes = function _ConnectionSetCommand_initTypes() {
56
- this.types.string.push('name', 'newName');
57
- };
58
44
  export default new ConnectionSetCommand();
59
45
  //# sourceMappingURL=connection-set.js.map
@@ -2,14 +2,12 @@ import fs from 'fs';
2
2
  import { z } from 'zod';
3
3
  import { cli } from '../../../cli/cli.js';
4
4
  import { CommandError, globalOptionsZod } from '../../../Command.js';
5
- import { zod } from '../../../utils/zod.js';
6
5
  import AnonymousCommand from '../../base/AnonymousCommand.js';
7
6
  import commands from '../commands.js';
8
- const options = globalOptionsZod
9
- .extend({
10
- force: zod.alias('f', z.boolean().optional())
11
- })
12
- .strict();
7
+ export const options = z.strictObject({
8
+ ...globalOptionsZod.shape,
9
+ force: z.boolean().optional().alias('f')
10
+ });
13
11
  class ContextRemoveCommand extends AnonymousCommand {
14
12
  get name() {
15
13
  return commands.REMOVE;
@@ -2,15 +2,13 @@ import fs from 'fs';
2
2
  import { z } from 'zod';
3
3
  import { cli } from '../../../../cli/cli.js';
4
4
  import { CommandError, globalOptionsZod } from '../../../../Command.js';
5
- import { zod } from '../../../../utils/zod.js';
6
5
  import ContextCommand from '../../../base/ContextCommand.js';
7
6
  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();
7
+ export const options = z.strictObject({
8
+ ...globalOptionsZod.shape,
9
+ name: z.string().alias('n'),
10
+ force: z.boolean().optional().alias('f')
11
+ });
14
12
  class ContextOptionRemoveCommand extends ContextCommand {
15
13
  get name() {
16
14
  return commands.OPTION_REMOVE;
@@ -1,16 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { globalOptionsZod } from '../../../../Command.js';
3
3
  import request from "../../../../request.js";
4
- import { zod } from '../../../../utils/zod.js';
5
4
  import GraphCommand from "../../../base/GraphCommand.js";
6
5
  import commands from "../../commands.js";
7
- const options = globalOptionsZod
8
- .extend({
9
- displayName: zod.alias('n', z.string()),
10
- description: zod.alias('d', z.string().optional()),
6
+ const options = z.looseObject({
7
+ ...globalOptionsZod.shape,
8
+ displayName: z.string().alias('n'),
9
+ description: z.string().optional().alias('d'),
11
10
  hiddenMembership: z.boolean().optional()
12
- })
13
- .passthrough();
11
+ });
14
12
  class EntraAdministrativeUnitAddCommand extends GraphCommand {
15
13
  get name() {
16
14
  return commands.ADMINISTRATIVEUNIT_ADD;
@@ -4,14 +4,12 @@ import GraphCommand from "../../../base/GraphCommand.js";
4
4
  import commands from "../../commands.js";
5
5
  import { entraAdministrativeUnit } from "../../../../utils/entraAdministrativeUnit.js";
6
6
  import { globalOptionsZod } from "../../../../Command.js";
7
- import { zod } from "../../../../utils/zod.js";
8
- const options = globalOptionsZod
9
- .extend({
10
- id: zod.alias('i', z.string().uuid().optional()),
11
- displayName: zod.alias('n', z.string().optional()),
12
- properties: zod.alias('p', z.string().optional())
13
- })
14
- .strict();
7
+ export const options = z.strictObject({
8
+ ...globalOptionsZod.shape,
9
+ id: z.uuid().optional().alias('i'),
10
+ displayName: z.string().optional().alias('n'),
11
+ properties: z.string().optional().alias('p')
12
+ });
15
13
  class EntraAdministrativeUnitGetCommand extends GraphCommand {
16
14
  get name() {
17
15
  return commands.ADMINISTRATIVEUNIT_GET;
@@ -25,7 +23,7 @@ class EntraAdministrativeUnitGetCommand extends GraphCommand {
25
23
  getRefinedSchema(schema) {
26
24
  return schema
27
25
  .refine(options => [options.id, options.displayName].filter(Boolean).length === 1, {
28
- message: 'Specify either id or displayName'
26
+ error: 'Specify either id or displayName'
29
27
  });
30
28
  }
31
29
  async commandAction(logger, args) {
@@ -1,13 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { globalOptionsZod } from '../../../../Command.js';
3
3
  import { odata } from '../../../../utils/odata.js';
4
- import { zod } from '../../../../utils/zod.js';
5
4
  import GraphCommand from '../../../base/GraphCommand.js';
6
5
  import commands from '../../commands.js';
7
- const options = globalOptionsZod
8
- .extend({
9
- properties: zod.alias('p', z.string().optional())
10
- }).strict();
6
+ export const options = z.strictObject({
7
+ ...globalOptionsZod.shape,
8
+ properties: z.string().optional().alias('p')
9
+ });
11
10
  class EntraAdministrativeUnitListCommand extends GraphCommand {
12
11
  get name() {
13
12
  return commands.ADMINISTRATIVEUNIT_LIST;
@@ -3,16 +3,14 @@ import { cli } from '../../../../cli/cli.js';
3
3
  import { globalOptionsZod } from '../../../../Command.js';
4
4
  import request from '../../../../request.js';
5
5
  import { entraAdministrativeUnit } from '../../../../utils/entraAdministrativeUnit.js';
6
- import { zod } from '../../../../utils/zod.js';
7
6
  import GraphCommand from '../../../base/GraphCommand.js';
8
7
  import commands from '../../commands.js';
9
- const options = globalOptionsZod
10
- .extend({
11
- id: zod.alias('i', z.string().uuid().optional()),
12
- displayName: zod.alias('n', z.string().optional()),
13
- force: zod.alias('f', z.boolean().optional())
14
- })
15
- .strict();
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ id: z.uuid().optional().alias('i'),
11
+ displayName: z.string().optional().alias('n'),
12
+ force: z.boolean().optional().alias('f')
13
+ });
16
14
  class EntraAdministrativeUnitRemoveCommand extends GraphCommand {
17
15
  get name() {
18
16
  return commands.ADMINISTRATIVEUNIT_REMOVE;
@@ -26,10 +24,10 @@ class EntraAdministrativeUnitRemoveCommand extends GraphCommand {
26
24
  getRefinedSchema(schema) {
27
25
  return schema
28
26
  .refine(options => options.id || options.displayName, {
29
- message: 'Specify either id or displayName'
27
+ error: 'Specify either id or displayName'
30
28
  })
31
29
  .refine(options => !(options.id && options.displayName), {
32
- message: 'Specify either id or displayName but not both'
30
+ error: 'Specify either id or displayName but not both'
33
31
  });
34
32
  }
35
33
  async commandAction(logger, args) {
@@ -2,7 +2,7 @@ import { odata } from '../../../../utils/odata.js';
2
2
  import GraphCommand from '../../../base/GraphCommand.js';
3
3
  import commands from '../../commands.js';
4
4
  import { globalOptionsZod } from '../../../../Command.js';
5
- const options = globalOptionsZod.strict();
5
+ export const options = globalOptionsZod.strict();
6
6
  class EntraLicenseListCommand extends GraphCommand {
7
7
  get name() {
8
8
  return commands.LICENSE_LIST;
@@ -89,7 +89,7 @@ class EntraM365GroupRemoveCommand extends GraphCommand {
89
89
  await logger.logToStderr(`Deleting the group site: '${url}'...`);
90
90
  }
91
91
  const requestOptions = {
92
- url: `${spoAdminUrl}/_api/GroupSiteManager/Delete?siteUrl='${url}'`,
92
+ url: `${spoAdminUrl}/_api/GroupSiteManager/Delete?siteUrl='${formatting.encodeQueryParameter(url)}'`,
93
93
  headers: {
94
94
  accept: 'application/json;odata=nometadata'
95
95
  },