@pnp/cli-microsoft365 9.0.0-beta.62575a1 → 9.0.0-beta.d6b190a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +8 -8
  4. package/dist/Command.js +49 -2
  5. package/dist/cli/cli.js +60 -38
  6. package/dist/m365/commands/login.js +44 -96
  7. package/dist/m365/spe/ContainerTypeProperties.js +2 -0
  8. package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
  9. package/dist/m365/spe/commands.js +2 -1
  10. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
  11. package/dist/m365/spo/commands/commandset/commandset-get.js +31 -17
  12. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
  13. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
  14. package/dist/utils/formatting.js +16 -0
  15. package/dist/utils/zod.js +124 -0
  16. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +131 -0
  17. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +85 -36
  18. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +18 -24
  19. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
  20. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
  21. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
  22. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
  23. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
  24. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
  25. package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
  26. package/npm-shrinkwrap.json +604 -843
  27. package/package.json +6 -2
package/dist/Auth.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AzureCloudInstance } from '@azure/msal-common';
2
+ import assert from 'assert';
2
3
  import { CommandError } from './Command.js';
3
4
  import { FileTokenStorage } from './auth/FileTokenStorage.js';
4
5
  import { msalCachePlugin } from './auth/msalCachePlugin.js';
@@ -6,16 +7,15 @@ import { cli } from './cli/cli.js';
6
7
  import config from './config.js';
7
8
  import request from './request.js';
8
9
  import { settingsNames } from './settingsNames.js';
9
- import { browserUtil } from './utils/browserUtil.js';
10
10
  import * as accessTokenUtil from './utils/accessToken.js';
11
- import assert from 'assert';
11
+ import { browserUtil } from './utils/browserUtil.js';
12
12
  export var CloudType;
13
13
  (function (CloudType) {
14
- CloudType[CloudType["Public"] = 0] = "Public";
15
- CloudType[CloudType["USGov"] = 1] = "USGov";
16
- CloudType[CloudType["USGovHigh"] = 2] = "USGovHigh";
17
- CloudType[CloudType["USGovDoD"] = 3] = "USGovDoD";
18
- CloudType[CloudType["China"] = 4] = "China";
14
+ CloudType["Public"] = "Public";
15
+ CloudType["USGov"] = "USGov";
16
+ CloudType["USGovHigh"] = "USGovHigh";
17
+ CloudType["USGovDoD"] = "USGovDoD";
18
+ CloudType["China"] = "China";
19
19
  })(CloudType || (CloudType = {}));
20
20
  export class Connection {
21
21
  constructor() {
@@ -710,7 +710,7 @@ export class Auth {
710
710
  return details;
711
711
  }
712
712
  }
713
- Auth.cloudEndpoints = [];
713
+ Auth.cloudEndpoints = {};
714
714
  Auth.initialize();
715
715
  export default new Auth();
716
716
  //# sourceMappingURL=Auth.js.map
package/dist/Command.js CHANGED
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
5
5
  };
6
6
  var _Command_instances, _Command_initTelemetry, _Command_initOptions, _Command_initValidators;
7
7
  import os from 'os';
8
+ import { z } from 'zod';
8
9
  import auth from './Auth.js';
9
10
  import { cli } from './cli/cli.js';
10
11
  import request from './request.js';
@@ -13,6 +14,7 @@ import { telemetry } from './telemetry.js';
13
14
  import { accessToken } from './utils/accessToken.js';
14
15
  import { md } from './utils/md.js';
15
16
  import { prompt } from './utils/prompt.js';
17
+ import { zod } from './utils/zod.js';
16
18
  export class CommandError {
17
19
  constructor(message, code) {
18
20
  this.message = message;
@@ -25,10 +27,26 @@ export class CommandErrorWithOutput {
25
27
  this.stderr = stderr;
26
28
  }
27
29
  }
30
+ export const globalOptionsZod = z.object({
31
+ query: z.string().optional(),
32
+ output: zod.alias('o', z.enum(['csv', 'json', 'md', 'text', 'none']).optional()),
33
+ debug: z.boolean().default(false),
34
+ verbose: z.boolean().default(false)
35
+ });
28
36
  class Command {
29
37
  get allowedOutputs() {
30
38
  return ['csv', 'json', 'md', 'text', 'none'];
31
39
  }
40
+ get schema() {
41
+ return undefined;
42
+ }
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ getRefinedSchema(schema) {
45
+ return undefined;
46
+ }
47
+ getSchemaToParse() {
48
+ return this.getRefinedSchema(this.schema) ?? this.schema;
49
+ }
32
50
  constructor() {
33
51
  // These functions must be defined with # so that they're truly private
34
52
  // otherwise you'll get a ts2415 error (Types have separate declarations of
@@ -48,6 +66,9 @@ class Command {
48
66
  string: []
49
67
  };
50
68
  this.validators = [];
69
+ // metadata for command's options
70
+ // used for building telemetry
71
+ this.optionsInfo = [];
51
72
  __classPrivateFieldGet(this, _Command_instances, "m", _Command_initTelemetry).call(this);
52
73
  __classPrivateFieldGet(this, _Command_instances, "m", _Command_initOptions).call(this);
53
74
  __classPrivateFieldGet(this, _Command_instances, "m", _Command_initValidators).call(this);
@@ -410,8 +431,34 @@ class Command {
410
431
  return '';
411
432
  }
412
433
  getTelemetryProperties(args) {
413
- this.telemetry.forEach(t => t(args));
414
- return this.telemetryProperties;
434
+ if (this.schema) {
435
+ const telemetryProperties = {};
436
+ this.optionsInfo.forEach(o => {
437
+ if (o.required) {
438
+ return;
439
+ }
440
+ if (typeof args.options[o.name] === 'undefined') {
441
+ return;
442
+ }
443
+ switch (o.type) {
444
+ case 'string':
445
+ telemetryProperties[o.name] = o.autocomplete ? args.options[o.name] : typeof args.options[o.name] !== 'undefined';
446
+ break;
447
+ case 'boolean':
448
+ telemetryProperties[o.name] = args.options[o.name];
449
+ break;
450
+ case 'number':
451
+ telemetryProperties[o.name] = typeof args.options[o.name] !== 'undefined';
452
+ break;
453
+ }
454
+ ;
455
+ });
456
+ return telemetryProperties;
457
+ }
458
+ else {
459
+ this.telemetry.forEach(t => t(args));
460
+ return this.telemetryProperties;
461
+ }
415
462
  }
416
463
  async getTextOutput(logStatement) {
417
464
  // display object as a list of key-value pairs
package/dist/cli/cli.js CHANGED
@@ -1,22 +1,24 @@
1
1
  import Configstore from 'configstore';
2
2
  import fs from 'fs';
3
- import minimist from 'minimist';
4
3
  import { createRequire } from 'module';
5
4
  import os from 'os';
6
5
  import path from 'path';
7
6
  import { fileURLToPath, pathToFileURL } from 'url';
7
+ import yargs from 'yargs-parser';
8
+ import { ZodError } from 'zod';
8
9
  import Command, { CommandError } from '../Command.js';
9
10
  import config from '../config.js';
10
11
  import request from '../request.js';
11
12
  import { settingsNames } from '../settingsNames.js';
12
13
  import { telemetry } from '../telemetry.js';
13
14
  import { app } from '../utils/app.js';
15
+ import { browserUtil } from '../utils/browserUtil.js';
14
16
  import { formatting } from '../utils/formatting.js';
15
17
  import { md } from '../utils/md.js';
16
- import { validation } from '../utils/validation.js';
17
18
  import { prompt } from '../utils/prompt.js';
19
+ import { validation } from '../utils/validation.js';
20
+ import { zod } from '../utils/zod.js';
18
21
  import { timings } from './timings.js';
19
- import { browserUtil } from '../utils/browserUtil.js';
20
22
  const require = createRequire(import.meta.url);
21
23
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
22
24
  let _config;
@@ -64,7 +66,7 @@ async function execute(rawArgs) {
64
66
  rawArgs.shift();
65
67
  }
66
68
  // parse args to see if a command has been specified
67
- const parsedArgs = minimist(rawArgs);
69
+ const parsedArgs = yargs(rawArgs);
68
70
  // load command
69
71
  await cli.loadCommandFromArgs(parsedArgs._);
70
72
  if (cli.commandToExecute) {
@@ -77,8 +79,7 @@ async function execute(rawArgs) {
77
79
  };
78
80
  }
79
81
  catch (e) {
80
- const optionsWithoutShorts = removeShortOptions({ options: parsedArgs });
81
- return cli.closeWithError(e.message, optionsWithoutShorts, false);
82
+ return cli.closeWithError(e.message, { options: parsedArgs }, false);
82
83
  }
83
84
  }
84
85
  else {
@@ -126,18 +127,30 @@ async function execute(rawArgs) {
126
127
  if (cli.optionsFromArgs.options.output === undefined) {
127
128
  cli.optionsFromArgs.options.output = cli.getSettingWithDefaultValue(settingsNames.output, 'json');
128
129
  }
129
- const startValidation = process.hrtime.bigint();
130
- const validationResult = await cli.commandToExecute.command.validate(cli.optionsFromArgs, cli.commandToExecute);
131
- const endValidation = process.hrtime.bigint();
132
- timings.validation.push(Number(endValidation - startValidation));
133
- if (validationResult !== true) {
134
- return cli.closeWithError(validationResult, cli.optionsFromArgs, true);
130
+ let finalArgs = cli.optionsFromArgs.options;
131
+ if (cli.commandToExecute?.command.schema) {
132
+ const startValidation = process.hrtime.bigint();
133
+ const result = cli.commandToExecute.command.getSchemaToParse().safeParse(cli.optionsFromArgs.options);
134
+ const endValidation = process.hrtime.bigint();
135
+ timings.validation.push(Number(endValidation - startValidation));
136
+ if (!result.success) {
137
+ return cli.closeWithError(result.error, cli.optionsFromArgs, true);
138
+ }
139
+ finalArgs = result.data;
140
+ }
141
+ else {
142
+ const startValidation = process.hrtime.bigint();
143
+ const validationResult = await cli.commandToExecute.command.validate(cli.optionsFromArgs, cli.commandToExecute);
144
+ const endValidation = process.hrtime.bigint();
145
+ timings.validation.push(Number(endValidation - startValidation));
146
+ if (validationResult !== true) {
147
+ return cli.closeWithError(validationResult, cli.optionsFromArgs, true);
148
+ }
135
149
  }
136
- cli.optionsFromArgs = removeShortOptions(cli.optionsFromArgs);
137
150
  const end = process.hrtime.bigint();
138
151
  timings.core.push(Number(end - start));
139
152
  try {
140
- await cli.executeCommand(cli.commandToExecute.command, cli.optionsFromArgs);
153
+ await cli.executeCommand(cli.commandToExecute.command, { options: finalArgs });
141
154
  const endTotal = process.hrtime.bigint();
142
155
  timings.total.push(Number(endTotal - start));
143
156
  await printTimings(rawArgs);
@@ -347,12 +360,14 @@ async function loadCommandFromFile(commandFileUrl) {
347
360
  catch { }
348
361
  }
349
362
  function getCommandInfo(command, filePath = '', helpFilePath = '') {
363
+ const options = command.schema ? zod.schemaToOptions(command.schema) : getCommandOptions(command);
364
+ command.optionsInfo = options;
350
365
  return {
351
366
  aliases: command.alias(),
352
367
  name: command.name,
353
368
  description: command.description,
354
369
  command: command,
355
- options: getCommandOptions(command),
370
+ options,
356
371
  defaultProperties: command.defaultProperties(),
357
372
  file: filePath,
358
373
  help: helpFilePath
@@ -387,36 +402,47 @@ function getCommandOptions(command) {
387
402
  return options;
388
403
  }
389
404
  function getCommandOptionsFromArgs(args, commandInfo) {
390
- const minimistOptions = {
391
- alias: {}
405
+ const yargsOptions = {
406
+ alias: {},
407
+ configuration: {
408
+ "parse-numbers": false,
409
+ "strip-aliased": true,
410
+ "strip-dashed": true
411
+ }
392
412
  };
393
413
  let argsToParse = args;
394
414
  if (commandInfo) {
395
- const commandTypes = commandInfo.command.types;
396
- if (commandTypes) {
397
- minimistOptions.string = commandTypes.string;
398
- // minimist will parse unused boolean options to 'false' (unused options => options that are not included in the args)
399
- // But in the CLI booleans are nullable. They can can be true, false or undefined.
400
- // For this reason we only pass boolean types that are actually used as arg.
401
- minimistOptions.boolean = commandTypes.boolean.filter(optionName => args.some(arg => `--${optionName}` === arg || `-${optionName}` === arg));
402
- }
403
- minimistOptions.alias = {};
415
+ if (commandInfo.command.schema) {
416
+ yargsOptions.string = commandInfo.options.filter(o => o.type === 'string').map(o => o.name);
417
+ yargsOptions.boolean = commandInfo.options.filter(o => o.type === 'boolean').map(o => o.name);
418
+ yargsOptions.number = commandInfo.options.filter(o => o.type === 'number').map(o => o.name);
419
+ argsToParse = getRewrittenArgs(args, yargsOptions.boolean);
420
+ }
421
+ else {
422
+ const commandTypes = commandInfo.command.types;
423
+ if (commandTypes) {
424
+ yargsOptions.string = commandTypes.string;
425
+ // minimist will parse unused boolean options to 'false' (unused options => options that are not included in the args)
426
+ // But in the CLI booleans are nullable. They can can be true, false or undefined.
427
+ // For this reason we only pass boolean types that are actually used as arg.
428
+ yargsOptions.boolean = commandTypes.boolean.filter(optionName => args.some(arg => `--${optionName}` === arg || `-${optionName}` === arg));
429
+ }
430
+ argsToParse = getRewrittenArgs(args, commandTypes.boolean);
431
+ }
404
432
  commandInfo.options.forEach(option => {
405
433
  if (option.short && option.long) {
406
- minimistOptions.alias[option.short] = option.long;
434
+ yargsOptions.alias[option.long] = option.short;
407
435
  }
408
436
  });
409
- argsToParse = getRewrittenArgs(args, commandTypes);
410
437
  }
411
- return minimist(argsToParse, minimistOptions);
438
+ return yargs(argsToParse, yargsOptions);
412
439
  }
413
440
  /**
414
441
  * Rewrites arguments (if necessary) before passing them into minimist.
415
442
  * Currently only boolean values are checked and fixed.
416
443
  * Args are only checked and rewritten if the option has been added to the 'types.boolean' array.
417
444
  */
418
- function getRewrittenArgs(args, commandTypes) {
419
- const booleanTypes = commandTypes.boolean;
445
+ function getRewrittenArgs(args, booleanTypes) {
420
446
  if (booleanTypes.length === 0) {
421
447
  return args;
422
448
  }
@@ -722,6 +748,9 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
722
748
  return process.exit(exitCode);
723
749
  }
724
750
  let errorMessage = error instanceof CommandError ? error.message : error;
751
+ if (error instanceof ZodError) {
752
+ errorMessage = error.errors.map(e => `${e.path}: ${e.message}`).join(os.EOL);
753
+ }
725
754
  if ((!args.options.output || args.options.output === 'json') &&
726
755
  !cli.getSettingWithDefaultValue(settingsNames.printErrorsAsPlainText, true)) {
727
756
  errorMessage = JSON.stringify({ error: errorMessage });
@@ -780,13 +809,6 @@ async function handleMultipleResultsFound(message, values) {
780
809
  const response = await cli.promptForSelection({ message: `Please choose one:`, choices });
781
810
  return values[response];
782
811
  }
783
- function removeShortOptions(args) {
784
- const filteredArgs = JSON.parse(JSON.stringify(args));
785
- const optionsToRemove = Object.getOwnPropertyNames(args.options)
786
- .filter(option => option.length === 1 || option === '--');
787
- optionsToRemove.forEach(option => delete filteredArgs.options[option]);
788
- return filteredArgs;
789
- }
790
812
  function loadOptionValuesFromFiles(args) {
791
813
  const optionNames = Object.getOwnPropertyNames(args.options);
792
814
  optionNames.forEach(option => {
@@ -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,26 @@ 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
+ })
43
+ .refine(options => options.authType !== 'password' || options.password, {
44
+ message: 'Password is required when using password authentication'
45
+ })
46
+ .refine(options => options.authType !== 'certificate' || !(options.certificateFile && options.certificateBase64Encoded), {
47
+ message: 'Specify either certificateFile or certificateBase64Encoded, but not both.'
48
+ })
49
+ .refine(options => options.authType !== 'certificate' || options.certificateFile || options.certificateBase64Encoded, {
50
+ message: 'Specify either certificateFile or certificateBase64Encoded'
51
+ })
52
+ .refine(options => options.authType !== 'secret' || options.secret, {
53
+ message: 'Secret is required when using secret authentication'
54
+ });
28
55
  }
29
56
  async commandAction(logger, args) {
30
57
  // disconnect before re-connecting
@@ -64,12 +91,7 @@ class LoginCommand extends Command {
64
91
  auth.connection.secret = args.options.secret;
65
92
  break;
66
93
  }
67
- if (args.options.cloud) {
68
- auth.connection.cloudType = CloudType[args.options.cloud];
69
- }
70
- else {
71
- auth.connection.cloudType = CloudType.Public;
72
- }
94
+ auth.connection.cloudType = args.options.cloud;
73
95
  try {
74
96
  await auth.ensureAccessToken(auth.defaultResource, logger, this.debug);
75
97
  auth.connection.active = true;
@@ -102,79 +124,5 @@ class LoginCommand extends Command {
102
124
  await this.commandAction(logger, args);
103
125
  }
104
126
  }
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
127
  export default new LoginCommand();
180
128
  //# sourceMappingURL=login.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ContainerTypeProperties.js.map
@@ -0,0 +1,49 @@
1
+ import config from '../../../../config.js';
2
+ import request from '../../../../request.js';
3
+ import { spo } from '../../../../utils/spo.js';
4
+ import SpoCommand from '../../../base/SpoCommand.js';
5
+ import commands from '../../commands.js';
6
+ class SpeContainertypeListCommand extends SpoCommand {
7
+ get name() {
8
+ return commands.CONTAINERTYPE_LIST;
9
+ }
10
+ get description() {
11
+ return 'Lists all Container Types';
12
+ }
13
+ defaultProperties() {
14
+ return ['ContainerTypeId', 'DisplayName', 'OwningAppId'];
15
+ }
16
+ async commandAction(logger) {
17
+ try {
18
+ const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
19
+ if (this.verbose) {
20
+ await logger.logToStderr(`Retrieving list of Container types...`);
21
+ }
22
+ const allContainerTypes = await this.getAllContainerTypes(spoAdminUrl, logger);
23
+ await logger.log(allContainerTypes);
24
+ }
25
+ catch (err) {
26
+ this.handleRejectedPromise(err);
27
+ }
28
+ }
29
+ async getAllContainerTypes(spoAdminUrl, logger) {
30
+ const formDigestInfo = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, this.debug);
31
+ const requestOptions = {
32
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
33
+ headers: {
34
+ 'X-RequestDigest': formDigestInfo.FormDigestValue
35
+ },
36
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="46" ObjectPathId="45" /><Method Name="GetSPOContainerTypes" Id="47" ObjectPathId="45"><Parameters><Parameter Type="Enum">1</Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="45" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
37
+ };
38
+ const res = await request.post(requestOptions);
39
+ const json = JSON.parse(res);
40
+ const response = json[0];
41
+ if (response.ErrorInfo) {
42
+ throw response.ErrorInfo.ErrorMessage;
43
+ }
44
+ const containerTypes = json[json.length - 1];
45
+ return containerTypes;
46
+ }
47
+ }
48
+ export default new SpeContainertypeListCommand();
49
+ //# sourceMappingURL=containertype-list.js.map
@@ -1,5 +1,6 @@
1
1
  const prefix = 'spe';
2
2
  export default {
3
- CONTAINERTYPE_ADD: `${prefix} containertype add`
3
+ CONTAINERTYPE_ADD: `${prefix} containertype add`,
4
+ CONTAINERTYPE_LIST: `${prefix} containertype list`
4
5
  };
5
6
  //# sourceMappingURL=commands.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 _SpoApplicationCustomizerGetCommand_instances, _SpoApplicationCustomizerGetCommand_initTelemetry, _SpoApplicationCustomizerGetCommand_initOptions, _SpoApplicationCustomizerGetCommand_initValidators, _SpoApplicationCustomizerGetCommand_initOptionSets;
6
+ var _SpoApplicationCustomizerGetCommand_instances, _SpoApplicationCustomizerGetCommand_initTelemetry, _SpoApplicationCustomizerGetCommand_initOptions, _SpoApplicationCustomizerGetCommand_initValidators, _SpoApplicationCustomizerGetCommand_initOptionSets, _SpoApplicationCustomizerGetCommand_initTypes;
7
7
  import { formatting } from '../../../../utils/formatting.js';
8
8
  import { spo } from '../../../../utils/spo.js';
9
9
  import { validation } from '../../../../utils/validation.js';
@@ -25,33 +25,22 @@ class SpoApplicationCustomizerGetCommand extends SpoCommand {
25
25
  __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initOptions).call(this);
26
26
  __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initValidators).call(this);
27
27
  __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initOptionSets).call(this);
28
+ __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initTypes).call(this);
28
29
  }
29
30
  async commandAction(logger, args) {
30
31
  try {
31
32
  const customAction = await this.getCustomAction(args.options);
32
- if (customAction) {
33
+ if (!args.options.clientSideComponentProperties) {
33
34
  await logger.log({
34
- ClientSideComponentId: customAction.ClientSideComponentId,
35
- ClientSideComponentProperties: customAction.ClientSideComponentProperties,
36
- CommandUIExtension: customAction.CommandUIExtension,
37
- Description: customAction.Description,
38
- Group: customAction.Group,
39
- Id: customAction.Id,
40
- ImageUrl: customAction.ImageUrl,
41
- Location: customAction.Location,
42
- Name: customAction.Name,
43
- RegistrationId: customAction.RegistrationId,
44
- RegistrationType: customAction.RegistrationType,
35
+ ...customAction,
45
36
  Rights: JSON.stringify(customAction.Rights),
46
- Scope: this.humanizeScope(customAction.Scope),
47
- ScriptBlock: customAction.ScriptBlock,
48
- ScriptSrc: customAction.ScriptSrc,
49
- Sequence: customAction.Sequence,
50
- Title: customAction.Title,
51
- Url: customAction.Url,
52
- VersionOfUserCustomAction: customAction.VersionOfUserCustomAction
37
+ Scope: this.humanizeScope(customAction.Scope)
53
38
  });
54
39
  }
40
+ else {
41
+ const properties = formatting.tryParseJson(customAction.ClientSideComponentProperties);
42
+ await logger.log(properties);
43
+ }
55
44
  }
56
45
  catch (err) {
57
46
  this.handleRejectedPromise(err);
@@ -95,7 +84,8 @@ _SpoApplicationCustomizerGetCommand_instances = new WeakSet(), _SpoApplicationCu
95
84
  title: typeof args.options.title !== 'undefined',
96
85
  id: typeof args.options.id !== 'undefined',
97
86
  clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
98
- scope: typeof args.options.scope !== 'undefined'
87
+ scope: typeof args.options.scope !== 'undefined',
88
+ clientSideComponentProperties: !!args.options.clientSideComponentProperties
99
89
  });
100
90
  });
101
91
  }, _SpoApplicationCustomizerGetCommand_initOptions = function _SpoApplicationCustomizerGetCommand_initOptions() {
@@ -110,6 +100,8 @@ _SpoApplicationCustomizerGetCommand_instances = new WeakSet(), _SpoApplicationCu
110
100
  }, {
111
101
  option: '-s, --scope [scope]',
112
102
  autocomplete: this.allowedScopes
103
+ }, {
104
+ option: '-p, --clientSideComponentProperties'
113
105
  });
114
106
  }, _SpoApplicationCustomizerGetCommand_initValidators = function _SpoApplicationCustomizerGetCommand_initValidators() {
115
107
  this.validators.push(async (args) => {
@@ -126,6 +118,9 @@ _SpoApplicationCustomizerGetCommand_instances = new WeakSet(), _SpoApplicationCu
126
118
  });
127
119
  }, _SpoApplicationCustomizerGetCommand_initOptionSets = function _SpoApplicationCustomizerGetCommand_initOptionSets() {
128
120
  this.optionSets.push({ options: ['title', 'id', 'clientSideComponentId'] });
121
+ }, _SpoApplicationCustomizerGetCommand_initTypes = function _SpoApplicationCustomizerGetCommand_initTypes() {
122
+ this.types.string.push('webUrl', 'title', 'id', 'clientSideComponentId', 'scope');
123
+ this.types.boolean.push('clientSideComponentProperties');
129
124
  };
130
125
  export default new SpoApplicationCustomizerGetCommand();
131
126
  //# sourceMappingURL=applicationcustomizer-get.js.map