@pnp/cli-microsoft365 12.1.0-beta.ab87e08 → 12.1.0-beta.f55735f

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 (43) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/m365/spfx/commands/package/package-generate.js +30 -51
  4. package/dist/m365/spfx/commands/project/project-azuredevops-pipeline-add.js +27 -62
  5. package/dist/m365/spfx/commands/project/project-doctor.js +20 -51
  6. package/dist/m365/spfx/commands/project/project-externalize.js +16 -26
  7. package/dist/m365/spfx/commands/project/project-github-workflow-add.js +28 -65
  8. package/dist/m365/spfx/commands/project/project-permissions-grant.js +4 -2
  9. package/dist/m365/spfx/commands/project/project-rename.js +17 -29
  10. package/dist/m365/spfx/commands/project/project-upgrade.js +0 -3
  11. package/dist/m365/spfx/commands/spfx-doctor.js +23 -47
  12. package/dist/m365/viva/commands/connections/connections-app-create.js +36 -42
  13. package/dist/m365/viva/commands/engage/engage-community-add.js +75 -71
  14. package/dist/m365/viva/commands/engage/engage-community-get.js +8 -16
  15. package/dist/m365/viva/commands/engage/engage-community-list.js +5 -0
  16. package/dist/m365/viva/commands/engage/engage-community-remove.js +28 -48
  17. package/dist/m365/viva/commands/engage/engage-community-set.js +43 -66
  18. package/dist/m365/viva/commands/engage/engage-community-user-add.js +7 -12
  19. package/dist/m365/viva/commands/engage/engage-community-user-list.js +1 -1
  20. package/dist/m365/viva/commands/engage/engage-community-user-remove.js +4 -2
  21. package/dist/m365/viva/commands/engage/engage-message-add.js +22 -52
  22. package/dist/m365/viva/commands/engage/engage-message-get.js +8 -23
  23. package/dist/m365/viva/commands/engage/engage-message-like-set.js +10 -39
  24. package/dist/m365/viva/commands/engage/engage-message-list.js +22 -66
  25. package/dist/m365/viva/commands/engage/engage-message-remove.js +9 -32
  26. package/dist/m365/viva/commands/engage/engage-network-list.js +8 -22
  27. package/dist/m365/viva/commands/engage/engage-report-activitycounts.js +2 -1
  28. package/dist/m365/viva/commands/engage/engage-report-activityusercounts.js +2 -1
  29. package/dist/m365/viva/commands/engage/engage-report-activityuserdetail.js +2 -1
  30. package/dist/m365/viva/commands/engage/engage-report-deviceusagedistributionusercounts.js +2 -1
  31. package/dist/m365/viva/commands/engage/engage-report-deviceusageusercounts.js +2 -1
  32. package/dist/m365/viva/commands/engage/engage-report-deviceusageuserdetail.js +2 -1
  33. package/dist/m365/viva/commands/engage/engage-report-groupsactivitycounts.js +2 -1
  34. package/dist/m365/viva/commands/engage/engage-report-groupsactivitydetail.js +2 -1
  35. package/dist/m365/viva/commands/engage/engage-report-groupsactivitygroupcounts.js +2 -1
  36. package/dist/m365/viva/commands/engage/engage-role-list.js +5 -0
  37. package/dist/m365/viva/commands/engage/engage-role-member-add.js +3 -5
  38. package/dist/m365/viva/commands/engage/engage-role-member-list.js +1 -1
  39. package/dist/m365/viva/commands/engage/engage-role-member-remove.js +4 -2
  40. package/dist/m365/viva/commands/engage/engage-search.js +16 -65
  41. package/dist/m365/viva/commands/engage/engage-user-get.js +15 -33
  42. package/dist/m365/viva/commands/engage/engage-user-list.js +22 -57
  43. package/package.json +1 -1
@@ -1,25 +1,19 @@
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 _SpfxProjectRenameCommand_instances, _SpfxProjectRenameCommand_initTelemetry, _SpfxProjectRenameCommand_initOptions;
7
1
  import fs from 'fs';
8
2
  import path from 'path';
9
3
  import { v4 } from 'uuid';
4
+ import { z } from 'zod';
5
+ import { globalOptionsZod } from '../../../../Command.js';
10
6
  import { CommandError } from '../../../../Command.js';
11
7
  import commands from '../../commands.js';
12
8
  import { BaseProjectCommand } from './base-project-command.js';
9
+ export const options = z.strictObject({
10
+ ...globalOptionsZod.shape,
11
+ newName: z.string().alias('n'),
12
+ generateNewId: z.boolean().optional()
13
+ });
13
14
  class SpfxProjectRenameCommand extends BaseProjectCommand {
14
- get name() {
15
- return commands.PROJECT_RENAME;
16
- }
17
- get description() {
18
- return 'Renames SharePoint Framework project';
19
- }
20
15
  constructor() {
21
- super();
22
- _SpfxProjectRenameCommand_instances.add(this);
16
+ super(...arguments);
23
17
  this.generateNewId = () => {
24
18
  return v4();
25
19
  };
@@ -132,8 +126,15 @@ class SpfxProjectRenameCommand extends BaseProjectCommand {
132
126
  }
133
127
  }
134
128
  };
135
- __classPrivateFieldGet(this, _SpfxProjectRenameCommand_instances, "m", _SpfxProjectRenameCommand_initTelemetry).call(this);
136
- __classPrivateFieldGet(this, _SpfxProjectRenameCommand_instances, "m", _SpfxProjectRenameCommand_initOptions).call(this);
129
+ }
130
+ get name() {
131
+ return commands.PROJECT_RENAME;
132
+ }
133
+ get description() {
134
+ return 'Renames SharePoint Framework project';
135
+ }
136
+ get schema() {
137
+ return options;
137
138
  }
138
139
  async commandAction(logger, args) {
139
140
  this.projectRootPath = this.getProjectRoot(process.cwd());
@@ -165,19 +166,6 @@ class SpfxProjectRenameCommand extends BaseProjectCommand {
165
166
  }
166
167
  }
167
168
  }
168
- _SpfxProjectRenameCommand_instances = new WeakSet(), _SpfxProjectRenameCommand_initTelemetry = function _SpfxProjectRenameCommand_initTelemetry() {
169
- this.telemetry.push((args) => {
170
- Object.assign(this.telemetryProperties, {
171
- generateNewId: args.options.generateNewId
172
- });
173
- });
174
- }, _SpfxProjectRenameCommand_initOptions = function _SpfxProjectRenameCommand_initOptions() {
175
- this.options.unshift({
176
- option: '-n, --newName <newName>'
177
- }, {
178
- option: '--generateNewId'
179
- });
180
- };
181
169
  SpfxProjectRenameCommand.ERROR_NO_PROJECT_ROOT_FOLDER = 1;
182
170
  export default new SpfxProjectRenameCommand();
183
171
  //# sourceMappingURL=project-rename.js.map
@@ -25,9 +25,6 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
25
25
  get description() {
26
26
  return 'Upgrades SharePoint Framework project to the specified version';
27
27
  }
28
- get allowedOutputs() {
29
- return ['json', 'text', 'md', 'tour'];
30
- }
31
28
  get schema() {
32
29
  return options;
33
30
  }
@@ -1,15 +1,26 @@
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 _SpfxDoctorCommand_instances, _SpfxDoctorCommand_initTelemetry, _SpfxDoctorCommand_initOptions, _SpfxDoctorCommand_initValidators;
7
1
  import child_process from 'child_process';
8
2
  import { satisfies } from 'semver';
3
+ import { z } from 'zod';
4
+ import { globalOptionsZod } from '../../../Command.js';
9
5
  import { CheckStatus, formatting } from '../../../utils/formatting.js';
6
+ import { zod } from '../../../utils/zod.js';
10
7
  import commands from '../commands.js';
11
8
  import { BaseProjectCommand } from './project/base-project-command.js';
12
9
  import { SharePointVersion, versions } from './SpfxCompatibilityMatrix.js';
10
+ const environments = {
11
+ sp2016: 'sp2016',
12
+ sp2019: 'sp2019',
13
+ spo: 'spo'
14
+ };
15
+ const spfxVersions = Object.keys(versions);
16
+ export const options = z.strictObject({
17
+ ...globalOptionsZod.shape,
18
+ env: zod.coercedEnum(environments).optional().alias('e'),
19
+ spfxVersion: z.enum(spfxVersions, {
20
+ error: `The specified version is not a supported SharePoint Framework version. Supported versions are ${spfxVersions.join(', ')}`
21
+ }).optional().alias('v'),
22
+ output: z.enum(['text', 'json']).optional().alias('o')
23
+ });
13
24
  /**
14
25
  * Where to search for the particular npm package: only in the current project,
15
26
  * in global packages or both
@@ -29,8 +40,10 @@ var HandlePromise;
29
40
  HandlePromise[HandlePromise["Continue"] = 1] = "Continue";
30
41
  })(HandlePromise || (HandlePromise = {}));
31
42
  class SpfxDoctorCommand extends BaseProjectCommand {
32
- get allowedOutputs() {
33
- return ['text', 'json'];
43
+ constructor() {
44
+ super(...arguments);
45
+ this.output = '';
46
+ this.resultsObject = [];
34
47
  }
35
48
  get name() {
36
49
  return commands.DOCTOR;
@@ -38,14 +51,8 @@ class SpfxDoctorCommand extends BaseProjectCommand {
38
51
  get description() {
39
52
  return 'Verifies environment configuration for using the specific version of the SharePoint Framework';
40
53
  }
41
- constructor() {
42
- super();
43
- _SpfxDoctorCommand_instances.add(this);
44
- this.output = '';
45
- this.resultsObject = [];
46
- __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initTelemetry).call(this);
47
- __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initOptions).call(this);
48
- __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initValidators).call(this);
54
+ get schema() {
55
+ return options;
49
56
  }
50
57
  async commandAction(logger, args) {
51
58
  if (!args.options.output) {
@@ -430,36 +437,5 @@ class SpfxDoctorCommand extends BaseProjectCommand {
430
437
  }
431
438
  }
432
439
  }
433
- _SpfxDoctorCommand_instances = new WeakSet(), _SpfxDoctorCommand_initTelemetry = function _SpfxDoctorCommand_initTelemetry() {
434
- this.telemetry.push((args) => {
435
- Object.assign(this.telemetryProperties, {
436
- env: args.options.env,
437
- spfxVersion: args.options.spfxVersion
438
- });
439
- });
440
- }, _SpfxDoctorCommand_initOptions = function _SpfxDoctorCommand_initOptions() {
441
- this.options.unshift({
442
- option: '-e, --env [env]',
443
- autocomplete: ['sp2016', 'sp2019', 'spo']
444
- }, {
445
- option: '-v, --spfxVersion [spfxVersion]',
446
- autocomplete: Object.keys(versions)
447
- });
448
- }, _SpfxDoctorCommand_initValidators = function _SpfxDoctorCommand_initValidators() {
449
- this.validators.push(async (args) => {
450
- if (args.options.env) {
451
- const sp = this.spVersionStringToEnum(args.options.env);
452
- if (!sp) {
453
- return `${args.options.env} is not a valid SharePoint version. Valid versions are sp2016, sp2019 or spo`;
454
- }
455
- }
456
- if (args.options.spfxVersion) {
457
- if (!versions[args.options.spfxVersion]) {
458
- return `${args.options.spfxVersion} is not a supported SharePoint Framework version. Supported versions are ${Object.keys(versions).join(', ')}`;
459
- }
460
- }
461
- return true;
462
- });
463
- };
464
440
  export default new SpfxDoctorCommand();
465
441
  //# sourceMappingURL=spfx-doctor.js.map
@@ -1,16 +1,31 @@
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 _VivaConnectionsAppCreateCommand_instances, _VivaConnectionsAppCreateCommand_initOptions, _VivaConnectionsAppCreateCommand_initValidators;
7
1
  import AdmZip from 'adm-zip';
8
2
  import fs from 'fs';
9
3
  import path from 'path';
10
4
  import { v4 } from 'uuid';
5
+ import { z } from 'zod';
6
+ import { globalOptionsZod } from '../../../../Command.js';
11
7
  import AnonymousCommand from '../../../base/AnonymousCommand.js';
12
8
  import commands from '../../commands.js';
13
9
  import { spo } from '../../../../utils/spo.js';
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ portalUrl: z.string(),
13
+ name: z.string().max(30, { message: 'App name must not exceed 30 characters' }),
14
+ description: z.string().max(80, { message: 'Description must not exceed 80 characters' }),
15
+ longDescription: z.string().max(4000, { message: 'Long description must not exceed 4000 characters' }),
16
+ privacyPolicyUrl: z.string().optional(),
17
+ termsOfUseUrl: z.string().optional(),
18
+ companyName: z.string(),
19
+ companyWebsiteUrl: z.string(),
20
+ coloredIconPath: z.string().refine(val => fs.existsSync(path.resolve(val)), {
21
+ error: e => `File ${path.resolve(e.input)} doesn't exist`
22
+ }),
23
+ outlineIconPath: z.string().refine(val => fs.existsSync(path.resolve(val)), {
24
+ error: e => `File ${path.resolve(e.input)} doesn't exist`
25
+ }),
26
+ accentColor: z.string().optional(),
27
+ force: z.boolean().optional()
28
+ });
14
29
  class VivaConnectionsAppCreateCommand extends AnonymousCommand {
15
30
  get name() {
16
31
  return commands.CONNECTIONS_APP_CREATE;
@@ -18,11 +33,20 @@ class VivaConnectionsAppCreateCommand extends AnonymousCommand {
18
33
  get description() {
19
34
  return 'Creates Viva Connections app';
20
35
  }
21
- constructor() {
22
- super();
23
- _VivaConnectionsAppCreateCommand_instances.add(this);
24
- __classPrivateFieldGet(this, _VivaConnectionsAppCreateCommand_instances, "m", _VivaConnectionsAppCreateCommand_initOptions).call(this);
25
- __classPrivateFieldGet(this, _VivaConnectionsAppCreateCommand_instances, "m", _VivaConnectionsAppCreateCommand_initValidators).call(this);
36
+ get schema() {
37
+ return options;
38
+ }
39
+ getRefinedSchema(schema) {
40
+ return schema
41
+ .superRefine((opts, ctx) => {
42
+ const appFilePath = path.resolve(`${opts.name}.zip`);
43
+ if (fs.existsSync(appFilePath) && !opts.force) {
44
+ ctx.addIssue({
45
+ message: `File ${path.resolve(`${opts.name}.zip`)} already exists. Delete the file or use the --force option to overwrite the existing file`,
46
+ code: z.ZodIssueCode.custom
47
+ });
48
+ }
49
+ });
26
50
  }
27
51
  async commandAction(logger, args) {
28
52
  try {
@@ -133,40 +157,10 @@ class VivaConnectionsAppCreateCommand extends AnonymousCommand {
133
157
  }
134
158
  async getWeb(args, logger) {
135
159
  if (this.verbose) {
136
- await logger.logToStderr(`Checking if site ${args.options.url} exists...`);
160
+ await logger.logToStderr(`Checking if site ${args.options.portalUrl} exists...`);
137
161
  }
138
162
  return await spo.getWeb(args.options.portalUrl, logger, this.verbose);
139
163
  }
140
164
  }
141
- _VivaConnectionsAppCreateCommand_instances = new WeakSet(), _VivaConnectionsAppCreateCommand_initOptions = function _VivaConnectionsAppCreateCommand_initOptions() {
142
- this.options.unshift({ option: '--portalUrl <portalUrl>' }, { option: '--name <name>' }, { option: '--description <description>' }, { option: '--longDescription <longDescription>' }, { option: '--privacyPolicyUrl [privacyPolicyUrl]' }, { option: '--termsOfUseUrl [termsOfUseUrl]' }, { option: '--companyName <companyName>' }, { option: '--companyWebsiteUrl <companyWebsiteUrl>' }, { option: '--coloredIconPath <coloredIconPath>' }, { option: '--outlineIconPath <outlineIconPath>' }, { option: '--accentColor [accentColor]' }, { option: '--force' });
143
- }, _VivaConnectionsAppCreateCommand_initValidators = function _VivaConnectionsAppCreateCommand_initValidators() {
144
- this.validators.push(async (args) => {
145
- if (args.options.name.length > 30) {
146
- return `App name must not exceed 30 characters`;
147
- }
148
- if (args.options.description &&
149
- args.options.description.length > 80) {
150
- return 'Description must not exceed 80 characters';
151
- }
152
- if (args.options.longDescription &&
153
- args.options.longDescription.length > 4000) {
154
- return 'Long description must not exceed 4000 characters';
155
- }
156
- const appFilePath = path.resolve(`${args.options.name}.zip`);
157
- if (fs.existsSync(appFilePath) && !args.options.force) {
158
- return `File ${appFilePath} already exists. Delete the file or use the --force option to overwrite the existing file`;
159
- }
160
- const coloredIconPath = path.resolve(args.options.coloredIconPath);
161
- if (!fs.existsSync(coloredIconPath)) {
162
- return `File ${coloredIconPath} doesn't exist`;
163
- }
164
- const outlineIconPath = path.resolve(args.options.outlineIconPath);
165
- if (!fs.existsSync(outlineIconPath)) {
166
- return `File ${outlineIconPath} doesn't exist`;
167
- }
168
- return true;
169
- });
170
- };
171
165
  export default new VivaConnectionsAppCreateCommand();
172
166
  //# sourceMappingURL=connections-app-create.js.map
@@ -1,11 +1,5 @@
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 _VivaEngageCommunityAddCommand_instances, _VivaEngageCommunityAddCommand_initTelemetry, _VivaEngageCommunityAddCommand_initOptions, _VivaEngageCommunityAddCommand_initValidators, _VivaEngageCommunityAddCommand_initTypes, _VivaEngageCommunityAddCommand_initOptionSets;
7
- import GraphCommand from '../../../base/GraphCommand.js';
8
- import commands from '../../commands.js';
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
9
3
  import request from '../../../../request.js';
10
4
  import { validation } from '../../../../utils/validation.js';
11
5
  import { accessToken } from '../../../../utils/accessToken.js';
@@ -13,23 +7,86 @@ import auth from '../../../../Auth.js';
13
7
  import { formatting } from '../../../../utils/formatting.js';
14
8
  import { entraUser } from '../../../../utils/entraUser.js';
15
9
  import { setTimeout } from 'timers/promises';
10
+ import GraphCommand from '../../../base/GraphCommand.js';
11
+ import commands from '../../commands.js';
12
+ export const options = z.strictObject({
13
+ ...globalOptionsZod.shape,
14
+ displayName: z.string(),
15
+ description: z.string(),
16
+ privacy: z.enum(['public', 'private']),
17
+ adminEntraIds: z.string().optional(),
18
+ adminEntraUserNames: z.string().optional(),
19
+ wait: z.boolean().optional()
20
+ });
16
21
  class VivaEngageCommunityAddCommand extends GraphCommand {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.pollingInterval = 5000;
25
+ }
17
26
  get name() {
18
27
  return commands.ENGAGE_COMMUNITY_ADD;
19
28
  }
20
29
  get description() {
21
30
  return 'Creates a new community in Viva Engage';
22
31
  }
23
- constructor() {
24
- super();
25
- _VivaEngageCommunityAddCommand_instances.add(this);
26
- this.pollingInterval = 5000;
27
- this.privacyOptions = ['public', 'private'];
28
- __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initTelemetry).call(this);
29
- __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initOptions).call(this);
30
- __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initValidators).call(this);
31
- __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initTypes).call(this);
32
- __classPrivateFieldGet(this, _VivaEngageCommunityAddCommand_instances, "m", _VivaEngageCommunityAddCommand_initOptionSets).call(this);
32
+ get schema() {
33
+ return options;
34
+ }
35
+ getRefinedSchema(schema) {
36
+ return schema
37
+ .refine(opts => opts.displayName.length <= 255, {
38
+ message: `The maximum amount of characters for 'displayName' is 255.`
39
+ })
40
+ .refine(opts => opts.description.length <= 1024, {
41
+ message: `The maximum amount of characters for 'description' is 1024.`
42
+ })
43
+ .superRefine((opts, ctx) => {
44
+ if (opts.adminEntraIds) {
45
+ const items = opts.adminEntraIds.split(',').map(s => s.trim());
46
+ const invalid = items.filter(item => !validation.isValidGuid(item));
47
+ if (invalid.length > 0) {
48
+ ctx.addIssue({
49
+ code: z.ZodIssueCode.custom,
50
+ message: `The following GUIDs are invalid for the option 'adminEntraIds': ${invalid.join(', ')}`
51
+ });
52
+ }
53
+ }
54
+ })
55
+ .refine(opts => {
56
+ if (!opts.adminEntraIds) {
57
+ return true;
58
+ }
59
+ return formatting.splitAndTrim(opts.adminEntraIds).length <= 20;
60
+ }, {
61
+ message: 'Maximum of 20 admins allowed. Please reduce the number of users and try again.'
62
+ })
63
+ .superRefine((opts, ctx) => {
64
+ if (opts.adminEntraUserNames) {
65
+ const items = opts.adminEntraUserNames.split(',').map(s => s.trim());
66
+ const invalid = items.filter(item => !validation.isValidUserPrincipalName(item));
67
+ if (invalid.length > 0) {
68
+ ctx.addIssue({
69
+ code: z.ZodIssueCode.custom,
70
+ message: `The following user principal names are invalid for the option 'adminEntraUserNames': ${invalid.join(', ')}`
71
+ });
72
+ }
73
+ }
74
+ })
75
+ .refine(opts => {
76
+ if (!opts.adminEntraUserNames) {
77
+ return true;
78
+ }
79
+ return formatting.splitAndTrim(opts.adminEntraUserNames).length <= 20;
80
+ }, {
81
+ message: 'Maximum of 20 admins allowed. Please reduce the number of users and try again.'
82
+ })
83
+ .refine(opts => !opts.adminEntraIds || !opts.adminEntraUserNames, {
84
+ message: 'Specify either adminEntraIds or adminEntraUserNames, but not both.',
85
+ params: {
86
+ customCode: 'optionSet',
87
+ options: ['adminEntraIds', 'adminEntraUserNames']
88
+ }
89
+ });
33
90
  }
34
91
  async commandAction(logger, args) {
35
92
  const { displayName, description, privacy, adminEntraIds, adminEntraUserNames, wait } = args.options;
@@ -109,58 +166,5 @@ class VivaEngageCommunityAddCommand extends GraphCommand {
109
166
  return graphUserUrls;
110
167
  }
111
168
  }
112
- _VivaEngageCommunityAddCommand_instances = new WeakSet(), _VivaEngageCommunityAddCommand_initTelemetry = function _VivaEngageCommunityAddCommand_initTelemetry() {
113
- this.telemetry.push((args) => {
114
- Object.assign(this.telemetryProperties, {
115
- adminEntraIds: typeof args.options.adminEntraIds !== 'undefined',
116
- adminEntraUserNames: typeof args.options.adminEntraUserNames !== 'undefined',
117
- wait: !!args.options.wait
118
- });
119
- });
120
- }, _VivaEngageCommunityAddCommand_initOptions = function _VivaEngageCommunityAddCommand_initOptions() {
121
- this.options.unshift({ option: '--displayName <displayName>' }, { option: '--description <description>' }, {
122
- option: '--privacy <privacy>',
123
- autocomplete: this.privacyOptions
124
- }, { option: '--adminEntraIds [adminEntraIds]' }, { option: '--adminEntraUserNames [adminEntraUserNames]' }, { option: '--wait' });
125
- }, _VivaEngageCommunityAddCommand_initValidators = function _VivaEngageCommunityAddCommand_initValidators() {
126
- this.validators.push(async (args) => {
127
- if (args.options.displayName.length > 255) {
128
- return `The maximum amount of characters for 'displayName' is 255.`;
129
- }
130
- if (args.options.description.length > 1024) {
131
- return `The maximum amount of characters for 'description' is 1024.`;
132
- }
133
- if (this.privacyOptions.indexOf(args.options.privacy) === -1) {
134
- return `'${args.options.privacy}' is not a valid value for privacy. Allowed values are: ${this.privacyOptions.join(', ')}.`;
135
- }
136
- if (args.options.adminEntraIds) {
137
- const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.adminEntraIds);
138
- if (isValidGUIDArrayResult !== true) {
139
- return `The following GUIDs are invalid for the option 'adminEntraIds': ${isValidGUIDArrayResult}.`;
140
- }
141
- if (formatting.splitAndTrim(args.options.adminEntraIds).length > 20) {
142
- return `Maximum of 20 admins allowed. Please reduce the number of users and try again.`;
143
- }
144
- }
145
- if (args.options.adminEntraUserNames) {
146
- const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.adminEntraUserNames);
147
- if (isValidUPNArrayResult !== true) {
148
- return `The following user principal names are invalid for the option 'adminEntraUserNames': ${isValidUPNArrayResult}.`;
149
- }
150
- if (formatting.splitAndTrim(args.options.adminEntraUserNames).length > 20) {
151
- return `Maximum of 20 admins allowed. Please reduce the number of users and try again.`;
152
- }
153
- }
154
- return true;
155
- });
156
- }, _VivaEngageCommunityAddCommand_initTypes = function _VivaEngageCommunityAddCommand_initTypes() {
157
- this.types.string.push('displayName', 'description', 'privacy', 'adminEntraIds', 'adminEntraUserNames');
158
- this.types.boolean.push('wait');
159
- }, _VivaEngageCommunityAddCommand_initOptionSets = function _VivaEngageCommunityAddCommand_initOptionSets() {
160
- this.optionSets.push({
161
- options: ['adminEntraIds', 'adminEntraUserNames'],
162
- runsWhen: (args) => args.options.adminEntraIds || args.options.adminEntraUserNames
163
- });
164
- };
165
169
  export default new VivaEngageCommunityAddCommand();
166
170
  //# sourceMappingURL=engage-community-add.js.map
@@ -1,12 +1,12 @@
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 _VivaEngageCommunityGetCommand_instances, _VivaEngageCommunityGetCommand_initOptions, _VivaEngageCommunityGetCommand_initTypes;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import GraphCommand from '../../../base/GraphCommand.js';
8
4
  import commands from '../../commands.js';
9
5
  import request from '../../../../request.js';
6
+ export const options = z.strictObject({
7
+ ...globalOptionsZod.shape,
8
+ id: z.string().alias('i')
9
+ });
10
10
  class VivaEngageCommunityGetCommand extends GraphCommand {
11
11
  get name() {
12
12
  return commands.ENGAGE_COMMUNITY_GET;
@@ -14,11 +14,8 @@ class VivaEngageCommunityGetCommand extends GraphCommand {
14
14
  get description() {
15
15
  return 'Gets information of a Viva Engage community';
16
16
  }
17
- constructor() {
18
- super();
19
- _VivaEngageCommunityGetCommand_instances.add(this);
20
- __classPrivateFieldGet(this, _VivaEngageCommunityGetCommand_instances, "m", _VivaEngageCommunityGetCommand_initOptions).call(this);
21
- __classPrivateFieldGet(this, _VivaEngageCommunityGetCommand_instances, "m", _VivaEngageCommunityGetCommand_initTypes).call(this);
17
+ get schema() {
18
+ return options;
22
19
  }
23
20
  async commandAction(logger, args) {
24
21
  if (this.verbose) {
@@ -40,10 +37,5 @@ class VivaEngageCommunityGetCommand extends GraphCommand {
40
37
  }
41
38
  }
42
39
  }
43
- _VivaEngageCommunityGetCommand_instances = new WeakSet(), _VivaEngageCommunityGetCommand_initOptions = function _VivaEngageCommunityGetCommand_initOptions() {
44
- this.options.unshift({ option: '-i, --id <id>' });
45
- }, _VivaEngageCommunityGetCommand_initTypes = function _VivaEngageCommunityGetCommand_initTypes() {
46
- this.types.string.push('id');
47
- };
48
40
  export default new VivaEngageCommunityGetCommand();
49
41
  //# sourceMappingURL=engage-community-get.js.map
@@ -1,6 +1,8 @@
1
+ import { globalOptionsZod } from '../../../../Command.js';
1
2
  import { odata } from '../../../../utils/odata.js';
2
3
  import GraphCommand from '../../../base/GraphCommand.js';
3
4
  import commands from '../../commands.js';
5
+ export const options = globalOptionsZod.strict();
4
6
  class VivaEngageCommunityListCommand extends GraphCommand {
5
7
  get name() {
6
8
  return commands.ENGAGE_COMMUNITY_LIST;
@@ -11,6 +13,9 @@ class VivaEngageCommunityListCommand extends GraphCommand {
11
13
  defaultProperties() {
12
14
  return ['id', 'displayName', 'privacy'];
13
15
  }
16
+ get schema() {
17
+ return options;
18
+ }
14
19
  async commandAction(logger) {
15
20
  if (this.verbose) {
16
21
  await logger.logToStderr('Getting all Viva Engage communities...');
@@ -1,15 +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 _VivaEngageCommunityRemoveCommand_instances, _VivaEngageCommunityRemoveCommand_initTelemetry, _VivaEngageCommunityRemoveCommand_initOptions, _VivaEngageCommunityRemoveCommand_initValidators, _VivaEngageCommunityRemoveCommand_initOptionSets, _VivaEngageCommunityRemoveCommand_initTypes;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../../cli/cli.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
8
4
  import request from '../../../../request.js';
9
- import { validation } from '../../../../utils/validation.js';
10
5
  import { vivaEngage } from '../../../../utils/vivaEngage.js';
11
6
  import GraphCommand from '../../../base/GraphCommand.js';
12
7
  import commands from '../../commands.js';
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ id: z.string().optional().alias('i'),
11
+ displayName: z.string().optional().alias('n'),
12
+ entraGroupId: z.guid().optional(),
13
+ force: z.boolean().optional().alias('f')
14
+ });
13
15
  class VivaEngageCommunityRemoveCommand extends GraphCommand {
14
16
  get name() {
15
17
  return commands.ENGAGE_COMMUNITY_REMOVE;
@@ -17,14 +19,25 @@ class VivaEngageCommunityRemoveCommand extends GraphCommand {
17
19
  get description() {
18
20
  return 'Removes a Viva Engage community';
19
21
  }
20
- constructor() {
21
- super();
22
- _VivaEngageCommunityRemoveCommand_instances.add(this);
23
- __classPrivateFieldGet(this, _VivaEngageCommunityRemoveCommand_instances, "m", _VivaEngageCommunityRemoveCommand_initTelemetry).call(this);
24
- __classPrivateFieldGet(this, _VivaEngageCommunityRemoveCommand_instances, "m", _VivaEngageCommunityRemoveCommand_initOptions).call(this);
25
- __classPrivateFieldGet(this, _VivaEngageCommunityRemoveCommand_instances, "m", _VivaEngageCommunityRemoveCommand_initValidators).call(this);
26
- __classPrivateFieldGet(this, _VivaEngageCommunityRemoveCommand_instances, "m", _VivaEngageCommunityRemoveCommand_initOptionSets).call(this);
27
- __classPrivateFieldGet(this, _VivaEngageCommunityRemoveCommand_instances, "m", _VivaEngageCommunityRemoveCommand_initTypes).call(this);
22
+ get schema() {
23
+ return options;
24
+ }
25
+ getRefinedSchema(schema) {
26
+ return schema
27
+ .refine(opts => [opts.id, opts.displayName, opts.entraGroupId].some(x => x !== undefined), {
28
+ message: 'Specify either id, displayName, or entraGroupId.',
29
+ params: {
30
+ customCode: 'optionSet',
31
+ options: ['id', 'displayName', 'entraGroupId']
32
+ }
33
+ })
34
+ .refine(opts => [opts.id, opts.displayName, opts.entraGroupId].filter(x => x !== undefined).length <= 1, {
35
+ message: 'Specify either id, displayName, or entraGroupId, but not multiple.',
36
+ params: {
37
+ customCode: 'optionSet',
38
+ options: ['id', 'displayName', 'entraGroupId']
39
+ }
40
+ });
28
41
  }
29
42
  async commandAction(logger, args) {
30
43
  const removeCommunity = async () => {
@@ -62,38 +75,5 @@ class VivaEngageCommunityRemoveCommand extends GraphCommand {
62
75
  }
63
76
  }
64
77
  }
65
- _VivaEngageCommunityRemoveCommand_instances = new WeakSet(), _VivaEngageCommunityRemoveCommand_initTelemetry = function _VivaEngageCommunityRemoveCommand_initTelemetry() {
66
- this.telemetry.push((args) => {
67
- Object.assign(this.telemetryProperties, {
68
- id: args.options.id !== 'undefined',
69
- displayName: args.options.displayName !== 'undefined',
70
- entraGroupId: args.options.entraGroupId !== 'undefined',
71
- force: !!args.options.force
72
- });
73
- });
74
- }, _VivaEngageCommunityRemoveCommand_initOptions = function _VivaEngageCommunityRemoveCommand_initOptions() {
75
- this.options.unshift({
76
- option: '-i, --id [id]'
77
- }, {
78
- option: '-n, --displayName [displayName]'
79
- }, {
80
- option: '--entraGroupId [entraGroupId]'
81
- }, {
82
- option: '-f, --force'
83
- });
84
- }, _VivaEngageCommunityRemoveCommand_initValidators = function _VivaEngageCommunityRemoveCommand_initValidators() {
85
- this.validators.push(async (args) => {
86
- if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
87
- return `${args.options.entraGroupId} is not a valid GUID for the option 'entraGroupId'.`;
88
- }
89
- return true;
90
- });
91
- }, _VivaEngageCommunityRemoveCommand_initOptionSets = function _VivaEngageCommunityRemoveCommand_initOptionSets() {
92
- this.optionSets.push({
93
- options: ['id', 'displayName', 'entraGroupId']
94
- });
95
- }, _VivaEngageCommunityRemoveCommand_initTypes = function _VivaEngageCommunityRemoveCommand_initTypes() {
96
- this.types.string.push('id', 'displayName', 'entraGroupId');
97
- };
98
78
  export default new VivaEngageCommunityRemoveCommand();
99
79
  //# sourceMappingURL=engage-community-remove.js.map