@pnp/cli-microsoft365 6.0.0 → 6.1.0-beta.54cca1f

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 (62) hide show
  1. package/.eslintrc.js +2 -0
  2. package/dist/cli/Cli.js +48 -5
  3. package/dist/m365/planner/commands/plan/plan-set.js +305 -0
  4. package/dist/m365/planner/commands/tenant/tenant-settings-set.js +4 -7
  5. package/dist/m365/planner/commands.js +1 -0
  6. package/dist/m365/pp/commands/chatbot/chatbot-get.js +111 -0
  7. package/dist/m365/pp/commands/chatbot/chatbot-remove.js +131 -0
  8. package/dist/m365/pp/commands/dataverse/dataverse-table-row-list.js +95 -0
  9. package/dist/m365/pp/commands/solution/solution-publisher-add.js +101 -0
  10. package/dist/m365/pp/commands.js +4 -0
  11. package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +38 -0
  12. package/dist/m365/purview/commands.js +7 -0
  13. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.16.1.js +23 -0
  14. package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
  15. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +63 -0
  16. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015009_FILE_config_sass_json.js +14 -0
  17. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0.js +2 -0
  18. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.16.1.js +59 -0
  19. package/dist/m365/spfx/commands/project/project-upgrade.js +2 -1
  20. package/dist/m365/spfx/commands/spfx-doctor.js +15 -0
  21. package/dist/m365/spo/commands/contenttype/contenttype-set.js +78 -31
  22. package/dist/m365/spo/commands/file/file-get.js +5 -17
  23. package/dist/m365/spo/commands/folder/folder-get.js +1 -9
  24. package/dist/m365/spo/commands/listitem/listitem-get.js +4 -16
  25. package/dist/m365/spo/commands/listitem/listitem-list.js +2 -2
  26. package/dist/m365/spo/commands/listitem/listitem-set.js +7 -4
  27. package/dist/m365/spo/commands/navigation/navigation-node-add.js +5 -1
  28. package/dist/m365/spo/commands/roledefinition/roledefinition-list.js +2 -13
  29. package/dist/m365/spo/commands/web/web-get.js +5 -16
  30. package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +121 -0
  31. package/dist/m365/teams/commands/user/user-app-list.js +1 -1
  32. package/dist/m365/teams/commands.js +1 -0
  33. package/dist/utils/formatting.js +37 -0
  34. package/docs/docs/cmd/cli/cli-consent.md +20 -0
  35. package/docs/docs/cmd/cli/cli-doctor.md +50 -0
  36. package/docs/docs/cmd/cli/cli-issue.md +20 -0
  37. package/docs/docs/cmd/cli/cli-reconsent.md +20 -0
  38. package/docs/docs/cmd/cli/completion/completion-clink-update.md +5 -1
  39. package/docs/docs/cmd/cli/completion/completion-pwsh-setup.md +5 -1
  40. package/docs/docs/cmd/cli/completion/completion-pwsh-update.md +5 -1
  41. package/docs/docs/cmd/cli/completion/completion-sh-setup.md +21 -1
  42. package/docs/docs/cmd/cli/completion/completion-sh-update.md +4 -0
  43. package/docs/docs/cmd/cli/config/config-get.md +22 -0
  44. package/docs/docs/cmd/cli/config/config-reset.md +4 -0
  45. package/docs/docs/cmd/cli/config/config-set.md +4 -0
  46. package/docs/docs/cmd/planner/plan/plan-set.md +144 -0
  47. package/docs/docs/cmd/pp/chatbot/chatbot-get.md +123 -0
  48. package/docs/docs/cmd/pp/chatbot/chatbot-remove.md +52 -0
  49. package/docs/docs/cmd/pp/dataverse/dataverse-table-row-list.md +90 -0
  50. package/docs/docs/cmd/pp/solution/solution-publisher-add.md +49 -0
  51. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.md +81 -0
  52. package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +4 -0
  53. package/docs/docs/cmd/search/externalconnection/externalconnection-get.md +38 -0
  54. package/docs/docs/cmd/search/externalconnection/externalconnection-list.md +38 -0
  55. package/docs/docs/cmd/search/externalconnection/externalconnection-remove.md +4 -0
  56. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  57. package/docs/docs/cmd/spo/contenttype/contenttype-set.md +15 -1
  58. package/docs/docs/cmd/spo/navigation/navigation-node-add.md +6 -6
  59. package/docs/docs/cmd/teams/meeting/meeting-attendancereport-list.md +69 -0
  60. package/docs/docs/cmd/teams/user/user-app-list.md +6 -0
  61. package/npm-shrinkwrap.json +2 -2
  62. package/package.json +2 -2
package/.eslintrc.js CHANGED
@@ -37,6 +37,7 @@ const dictionary = [
37
37
  'installed',
38
38
  'is',
39
39
  'issue',
40
+ 'label',
40
41
  'list',
41
42
  'management',
42
43
  'member',
@@ -52,6 +53,7 @@ const dictionary = [
52
53
  'property',
53
54
  'records',
54
55
  'recycle',
56
+ 'retention',
55
57
  'role',
56
58
  'room',
57
59
  'schema',
package/dist/cli/Cli.js CHANGED
@@ -22,6 +22,7 @@ const settingsNames_1 = require("../settingsNames");
22
22
  const formatting_1 = require("../utils/formatting");
23
23
  const fsUtil_1 = require("../utils/fsUtil");
24
24
  const md_1 = require("../utils/md");
25
+ const validation_1 = require("../utils/validation");
25
26
  const packageJSON = require('../../package.json');
26
27
  class Cli {
27
28
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -83,9 +84,15 @@ class Cli {
83
84
  // we have found a command to execute. Parse args again taking into
84
85
  // account short and long options, option types and whether the command
85
86
  // supports known and unknown options or not
86
- this.optionsFromArgs = {
87
- options: this.getCommandOptionsFromArgs(rawArgs, this.commandToExecute)
88
- };
87
+ try {
88
+ this.optionsFromArgs = {
89
+ options: this.getCommandOptionsFromArgs(rawArgs, this.commandToExecute)
90
+ };
91
+ }
92
+ catch (e) {
93
+ const optionsWithoutShorts = Cli.removeShortOptions({ options: parsedArgs });
94
+ return this.closeWithError(e.message, optionsWithoutShorts, false);
95
+ }
89
96
  }
90
97
  else {
91
98
  this.optionsFromArgs = {
@@ -208,6 +215,11 @@ class Cli {
208
215
  });
209
216
  }
210
217
  catch (err) {
218
+ // restoring the command and logger is done here instead of in a 'finally' because there were issues with the code coverage tool
219
+ // restore the original command name
220
+ cli.currentCommandName = parentCommandName;
221
+ // restore the original logger
222
+ request_1.default.logger = currentLogger;
211
223
  throw {
212
224
  error: err,
213
225
  stderr: logErr.join(os.EOL)
@@ -339,11 +351,15 @@ class Cli {
339
351
  const minimistOptions = {
340
352
  alias: {}
341
353
  };
354
+ let argsToParse = args;
342
355
  if (commandInfo) {
343
356
  const commandTypes = commandInfo.command.types;
344
357
  if (commandTypes) {
345
358
  minimistOptions.string = commandTypes.string;
346
- minimistOptions.boolean = commandTypes.boolean;
359
+ // minimist will parse unused boolean options to 'false' (unused options => options that are not included in the args)
360
+ // But in the CLI booleans are nullable. They can can be true, false or undefined.
361
+ // For this reason we only pass boolean types that are actually used as arg.
362
+ minimistOptions.boolean = commandTypes.boolean.filter(optionName => args.some(arg => `--${optionName}` === arg || `-${optionName}` === arg));
347
363
  }
348
364
  minimistOptions.alias = {};
349
365
  commandInfo.options.forEach(option => {
@@ -351,8 +367,35 @@ class Cli {
351
367
  minimistOptions.alias[option.short] = option.long;
352
368
  }
353
369
  });
370
+ argsToParse = this.getRewrittenArgs(args, commandTypes);
354
371
  }
355
- return minimist(args, minimistOptions);
372
+ return minimist(argsToParse, minimistOptions);
373
+ }
374
+ /**
375
+ * Rewrites arguments (if necessary) before passing them into minimist.
376
+ * Currently only boolean values are checked and fixed.
377
+ * Args are only checked and rewritten if the option has been added to the 'types.boolean' array.
378
+ */
379
+ getRewrittenArgs(args, commandTypes) {
380
+ const booleanTypes = commandTypes.boolean;
381
+ if (booleanTypes.length === 0) {
382
+ return args;
383
+ }
384
+ return args.map((arg, index, array) => {
385
+ if (arg.startsWith('-') || index === 0) {
386
+ return arg;
387
+ }
388
+ // This line checks if the current arg is a value that belongs to a boolean option.
389
+ if (booleanTypes.some(t => `--${t}` === array[index - 1] || `-${t}` === array[index - 1])) {
390
+ const rewrittenBoolean = formatting_1.formatting.rewriteBooleanValue(arg);
391
+ if (!validation_1.validation.isValidBoolean(rewrittenBoolean)) {
392
+ const optionName = array[index - 1];
393
+ throw new Error(`The value '${arg}' for option '${optionName}' is not a valid boolean`);
394
+ }
395
+ return rewrittenBoolean;
396
+ }
397
+ return arg;
398
+ });
356
399
  }
357
400
  static formatOutput(logStatement, options) {
358
401
  if (logStatement instanceof Date) {
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _PlannerPlanSetCommand_instances, _PlannerPlanSetCommand_initTelemetry, _PlannerPlanSetCommand_initOptions, _PlannerPlanSetCommand_initValidators, _PlannerPlanSetCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Auth_1 = require("../../../../Auth");
19
+ const request_1 = require("../../../../request");
20
+ const accessToken_1 = require("../../../../utils/accessToken");
21
+ const formatting_1 = require("../../../../utils/formatting");
22
+ const validation_1 = require("../../../../utils/validation");
23
+ const aadGroup_1 = require("../../../../utils/aadGroup");
24
+ const planner_1 = require("../../../../utils/planner");
25
+ const GraphCommand_1 = require("../../../base/GraphCommand");
26
+ const commands_1 = require("../../commands");
27
+ class PlannerPlanSetCommand extends GraphCommand_1.default {
28
+ constructor() {
29
+ super();
30
+ _PlannerPlanSetCommand_instances.add(this);
31
+ __classPrivateFieldGet(this, _PlannerPlanSetCommand_instances, "m", _PlannerPlanSetCommand_initTelemetry).call(this);
32
+ __classPrivateFieldGet(this, _PlannerPlanSetCommand_instances, "m", _PlannerPlanSetCommand_initOptions).call(this);
33
+ __classPrivateFieldGet(this, _PlannerPlanSetCommand_instances, "m", _PlannerPlanSetCommand_initValidators).call(this);
34
+ __classPrivateFieldGet(this, _PlannerPlanSetCommand_instances, "m", _PlannerPlanSetCommand_initOptionSets).call(this);
35
+ }
36
+ get name() {
37
+ return commands_1.default.PLAN_SET;
38
+ }
39
+ get description() {
40
+ return 'Updates a Microsoft Planner plan';
41
+ }
42
+ defaultProperties() {
43
+ return ['id', 'title', 'createdDateTime', 'owner'];
44
+ }
45
+ allowUnknownOptions() {
46
+ return true;
47
+ }
48
+ getGroupId(args) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const { ownerGroupId, ownerGroupName } = args.options;
51
+ if (ownerGroupId) {
52
+ return ownerGroupId;
53
+ }
54
+ const group = yield aadGroup_1.aadGroup.getGroupByDisplayName(ownerGroupName);
55
+ return group.id;
56
+ });
57
+ }
58
+ getPlanId(args) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const { id, title } = args.options;
61
+ if (id) {
62
+ return id;
63
+ }
64
+ const groupId = yield this.getGroupId(args);
65
+ const plan = yield planner_1.planner.getPlanByTitle(title, groupId);
66
+ return plan.id;
67
+ });
68
+ }
69
+ getUserIds(options) {
70
+ if (options.shareWithUserIds) {
71
+ return Promise.resolve(options.shareWithUserIds.split(','));
72
+ }
73
+ const userNames = options.shareWithUserNames;
74
+ const userArr = userNames.split(',').map(o => o.trim());
75
+ const promises = userArr.map(user => {
76
+ const requestOptions = {
77
+ url: `${this.resource}/v1.0/users?$filter=userPrincipalName eq '${formatting_1.formatting.encodeQueryParameter(user)}'&$select=id,userPrincipalName`,
78
+ headers: {
79
+ 'content-type': 'application/json'
80
+ },
81
+ responseType: 'json'
82
+ };
83
+ return request_1.default.get(requestOptions);
84
+ });
85
+ return Promise
86
+ .all(promises)
87
+ .then((usersRes) => {
88
+ const userUpns = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.userPrincipalName; });
89
+ const userIds = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.id; });
90
+ // Find the members where no graph response was found
91
+ const invalidUsers = userArr.filter(user => !userUpns.some((upn) => (upn === null || upn === void 0 ? void 0 : upn.toLowerCase()) === user.toLowerCase()));
92
+ if (invalidUsers && invalidUsers.length > 0) {
93
+ return Promise.reject(`Cannot proceed with planner plan creation. The following users provided are invalid: ${invalidUsers.join(',')}`);
94
+ }
95
+ return Promise.resolve(userIds);
96
+ });
97
+ }
98
+ generateSharedWith(options) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const sharedWith = {};
101
+ const userIds = yield this.getUserIds(options);
102
+ userIds.map(x => sharedWith[x] = true);
103
+ return sharedWith;
104
+ });
105
+ }
106
+ getPlanEtag(planId) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const requestOptions = {
109
+ url: `${this.resource}/v1.0/planner/plans/${planId}`,
110
+ headers: {
111
+ accept: 'application/json'
112
+ },
113
+ responseType: 'json'
114
+ };
115
+ const response = yield request_1.default.get(requestOptions);
116
+ return response['@odata.etag'];
117
+ });
118
+ }
119
+ getPlanDetailsEtag(planId) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const requestOptions = {
122
+ url: `${this.resource}/v1.0/planner/plans/${planId}/details`,
123
+ headers: {
124
+ accept: 'application/json'
125
+ },
126
+ responseType: 'json'
127
+ };
128
+ const response = yield request_1.default.get(requestOptions);
129
+ return response['@odata.etag'];
130
+ });
131
+ }
132
+ getPlanDetails(plan) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ const requestOptionsTaskDetails = {
135
+ url: `${this.resource}/v1.0/planner/plans/${plan.id}/details`,
136
+ headers: {
137
+ 'accept': 'application/json;odata.metadata=none',
138
+ 'Prefer': 'return=representation'
139
+ },
140
+ responseType: 'json'
141
+ };
142
+ const planDetails = yield request_1.default.get(requestOptionsTaskDetails);
143
+ return Object.assign(Object.assign({}, plan), planDetails);
144
+ });
145
+ }
146
+ updatePlanDetails(options, planId) {
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ const plan = yield planner_1.planner.getPlanById(planId);
149
+ const categories = {};
150
+ let categoriesCount = 0;
151
+ Object.keys(options).forEach(key => {
152
+ if (key.indexOf('category') !== -1) {
153
+ categories[key] = options[key];
154
+ categoriesCount++;
155
+ }
156
+ });
157
+ if (!options.shareWithUserIds && !options.shareWithUserNames && categoriesCount === 0) {
158
+ return this.getPlanDetails(plan);
159
+ }
160
+ const requestBody = {};
161
+ if (options.shareWithUserIds || options.shareWithUserNames) {
162
+ const sharedWith = yield this.generateSharedWith(options);
163
+ requestBody['sharedWith'] = sharedWith;
164
+ }
165
+ if (categoriesCount > 0) {
166
+ requestBody['categoryDescriptions'] = categories;
167
+ }
168
+ const etag = yield this.getPlanDetailsEtag(planId);
169
+ const requestOptionsPlanDetails = {
170
+ url: `${this.resource}/v1.0/planner/plans/${planId}/details`,
171
+ headers: {
172
+ 'accept': 'application/json;odata.metadata=none',
173
+ 'If-Match': etag,
174
+ 'Prefer': 'return=representation'
175
+ },
176
+ responseType: 'json',
177
+ data: requestBody
178
+ };
179
+ const planDetails = yield request_1.default.patch(requestOptionsPlanDetails);
180
+ return Object.assign(Object.assign({}, plan), planDetails);
181
+ });
182
+ }
183
+ commandAction(logger, args) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ if (accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
186
+ this.handleError('This command does not support application permissions.');
187
+ return;
188
+ }
189
+ try {
190
+ const planId = yield this.getPlanId(args);
191
+ if (args.options.newTitle) {
192
+ const etag = yield this.getPlanEtag(planId);
193
+ const requestOptions = {
194
+ url: `${this.resource}/v1.0/planner/plans/${planId}`,
195
+ headers: {
196
+ accept: 'application/json;odata.metadata=none',
197
+ 'If-Match': etag,
198
+ 'Prefer': 'return=representation'
199
+ },
200
+ responseType: 'json',
201
+ data: {
202
+ "title": args.options.newTitle
203
+ }
204
+ };
205
+ yield request_1.default.patch(requestOptions);
206
+ }
207
+ const result = yield this.updatePlanDetails(args.options, planId);
208
+ logger.log(result);
209
+ }
210
+ catch (err) {
211
+ this.handleRejectedODataJsonPromise(err);
212
+ }
213
+ });
214
+ }
215
+ }
216
+ _PlannerPlanSetCommand_instances = new WeakSet(), _PlannerPlanSetCommand_initTelemetry = function _PlannerPlanSetCommand_initTelemetry() {
217
+ this.telemetry.push((args) => {
218
+ Object.assign(this.telemetryProperties, {
219
+ id: typeof args.options.id !== 'undefined',
220
+ title: typeof args.options.title !== 'undefined',
221
+ ownerGroupId: typeof args.options.ownerGroupId !== 'undefined',
222
+ ownerGroupName: typeof args.options.ownerGroupName !== 'undefined',
223
+ newTitle: typeof args.options.newTitle !== 'undefined',
224
+ shareWithUserIds: typeof args.options.shareWithUserIds !== 'undefined',
225
+ shareWithUserNames: typeof args.options.shareWithUserNames !== 'undefined'
226
+ });
227
+ });
228
+ }, _PlannerPlanSetCommand_initOptions = function _PlannerPlanSetCommand_initOptions() {
229
+ this.options.unshift({
230
+ option: '-i, --id [id]'
231
+ }, {
232
+ option: '-t, --title [title]'
233
+ }, {
234
+ option: '--ownerGroupId [ownerGroupId]'
235
+ }, {
236
+ option: '--ownerGroupName [ownerGroupName]'
237
+ }, {
238
+ option: '--newTitle [newTitle]'
239
+ }, {
240
+ option: '--shareWithUserIds [shareWithUserIds]'
241
+ }, {
242
+ option: '--shareWithUserNames [shareWithUserNames]'
243
+ });
244
+ }, _PlannerPlanSetCommand_initValidators = function _PlannerPlanSetCommand_initValidators() {
245
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
246
+ if (args.options.title) {
247
+ if (args.options.ownerGroupId && !validation_1.validation.isValidGuid(args.options.ownerGroupId)) {
248
+ return `${args.options.ownerGroupId} is not a valid GUID`;
249
+ }
250
+ if (!args.options.ownerGroupId && !args.options.ownerGroupName) {
251
+ return 'Specify either ownerGroupId or ownerGroupName when using title';
252
+ }
253
+ if (args.options.ownerGroupId && args.options.ownerGroupName) {
254
+ return 'Specify either ownerGroupId or ownerGroupName when using title but not both';
255
+ }
256
+ }
257
+ if (args.options.shareWithUserIds && args.options.shareWithUserNames) {
258
+ return 'Specify either shareWithUserIds or shareWithUserNames but not both';
259
+ }
260
+ if (args.options.shareWithUserIds && !validation_1.validation.isValidGuidArray(args.options.shareWithUserIds.split(','))) {
261
+ return 'shareWithUserIds contains invalid GUID';
262
+ }
263
+ const allowedCategories = [
264
+ 'category1',
265
+ 'category2',
266
+ 'category3',
267
+ 'category4',
268
+ 'category5',
269
+ 'category6',
270
+ 'category7',
271
+ 'category8',
272
+ 'category9',
273
+ 'category10',
274
+ 'category11',
275
+ 'category12',
276
+ 'category13',
277
+ 'category14',
278
+ 'category15',
279
+ 'category16',
280
+ 'category17',
281
+ 'category18',
282
+ 'category19',
283
+ 'category20',
284
+ 'category21',
285
+ 'category22',
286
+ 'category23',
287
+ 'category24',
288
+ 'category25'
289
+ ];
290
+ let invalidCategoryOptions = false;
291
+ Object.keys(args.options).forEach(key => {
292
+ if (key.indexOf('category') !== -1 && allowedCategories.indexOf(key) === -1) {
293
+ invalidCategoryOptions = true;
294
+ }
295
+ });
296
+ if (invalidCategoryOptions) {
297
+ return 'Specify category values between category1 to category25';
298
+ }
299
+ return true;
300
+ }));
301
+ }, _PlannerPlanSetCommand_initOptionSets = function _PlannerPlanSetCommand_initOptionSets() {
302
+ this.optionSets.push({ options: ['id', 'title'] });
303
+ };
304
+ module.exports = new PlannerPlanSetCommand();
305
+ //# sourceMappingURL=plan-set.js.map
@@ -13,10 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  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");
14
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
- var _PlannerTenantSettingsSetCommand_instances, _PlannerTenantSettingsSetCommand_initTelemetry, _PlannerTenantSettingsSetCommand_initOptions, _PlannerTenantSettingsSetCommand_initValidators;
16
+ var _PlannerTenantSettingsSetCommand_instances, _PlannerTenantSettingsSetCommand_initTelemetry, _PlannerTenantSettingsSetCommand_initOptions, _PlannerTenantSettingsSetCommand_initTypes, _PlannerTenantSettingsSetCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
- const validation_1 = require("../../../../utils/validation");
20
19
  const PlannerCommand_1 = require("../../../base/PlannerCommand");
21
20
  const commands_1 = require("../../commands");
22
21
  class PlannerTenantSettingsSetCommand extends PlannerCommand_1.default {
@@ -25,6 +24,7 @@ class PlannerTenantSettingsSetCommand extends PlannerCommand_1.default {
25
24
  _PlannerTenantSettingsSetCommand_instances.add(this);
26
25
  __classPrivateFieldGet(this, _PlannerTenantSettingsSetCommand_instances, "m", _PlannerTenantSettingsSetCommand_initTelemetry).call(this);
27
26
  __classPrivateFieldGet(this, _PlannerTenantSettingsSetCommand_instances, "m", _PlannerTenantSettingsSetCommand_initOptions).call(this);
27
+ __classPrivateFieldGet(this, _PlannerTenantSettingsSetCommand_instances, "m", _PlannerTenantSettingsSetCommand_initTypes).call(this);
28
28
  __classPrivateFieldGet(this, _PlannerTenantSettingsSetCommand_instances, "m", _PlannerTenantSettingsSetCommand_initValidators).call(this);
29
29
  }
30
30
  get name() {
@@ -92,6 +92,8 @@ _PlannerTenantSettingsSetCommand_instances = new WeakSet(), _PlannerTenantSettin
92
92
  option: '--allowPlannerMobilePushNotifications [allowPlannerMobilePushNotifications]',
93
93
  autocomplete: ['true', 'false']
94
94
  });
95
+ }, _PlannerTenantSettingsSetCommand_initTypes = function _PlannerTenantSettingsSetCommand_initTypes() {
96
+ this.types.boolean.push('isPlannerAllowed', 'allowCalendarSharing', 'allowTenantMoveWithDataLoss', 'allowTenantMoveWithDataMigration', 'allowRosterCreation', 'allowPlannerMobilePushNotifications');
95
97
  }, _PlannerTenantSettingsSetCommand_initValidators = function _PlannerTenantSettingsSetCommand_initValidators() {
96
98
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
97
99
  const optionsArray = [
@@ -101,11 +103,6 @@ _PlannerTenantSettingsSetCommand_instances = new WeakSet(), _PlannerTenantSettin
101
103
  if (optionsArray.every(o => typeof o === 'undefined')) {
102
104
  return 'You must specify at least one option';
103
105
  }
104
- for (const option of optionsArray) {
105
- if (typeof option !== 'undefined' && !validation_1.validation.isValidBoolean(option)) {
106
- return `Value '${option}' is not a valid boolean`;
107
- }
108
- }
109
106
  return true;
110
107
  }));
111
108
  };
@@ -11,6 +11,7 @@ exports.default = {
11
11
  PLAN_GET: `${prefix} plan get`,
12
12
  PLAN_LIST: `${prefix} plan list`,
13
13
  PLAN_REMOVE: `${prefix} plan remove`,
14
+ PLAN_SET: `${prefix} plan set`,
14
15
  TASK_ADD: `${prefix} task add`,
15
16
  TASK_CHECKLISTITEM_ADD: `${prefix} task checklistitem add`,
16
17
  TASK_CHECKLISTITEM_LIST: `${prefix} task checklistitem list`,
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _PpChatbotGetCommand_instances, _PpChatbotGetCommand_initTelemetry, _PpChatbotGetCommand_initOptions, _PpChatbotGetCommand_initOptionSets, _PpChatbotGetCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
19
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
20
+ const commands_1 = require("../../commands");
21
+ const request_1 = require("../../../../request");
22
+ const validation_1 = require("../../../../utils/validation");
23
+ const formatting_1 = require("../../../../utils/formatting");
24
+ class PpChatbotGetCommand extends PowerPlatformCommand_1.default {
25
+ constructor() {
26
+ super();
27
+ _PpChatbotGetCommand_instances.add(this);
28
+ __classPrivateFieldGet(this, _PpChatbotGetCommand_instances, "m", _PpChatbotGetCommand_initTelemetry).call(this);
29
+ __classPrivateFieldGet(this, _PpChatbotGetCommand_instances, "m", _PpChatbotGetCommand_initOptions).call(this);
30
+ __classPrivateFieldGet(this, _PpChatbotGetCommand_instances, "m", _PpChatbotGetCommand_initValidators).call(this);
31
+ __classPrivateFieldGet(this, _PpChatbotGetCommand_instances, "m", _PpChatbotGetCommand_initOptionSets).call(this);
32
+ }
33
+ get name() {
34
+ return commands_1.default.CHATBOT_GET;
35
+ }
36
+ get description() {
37
+ return 'Get information about the specified chatbot';
38
+ }
39
+ defaultProperties() {
40
+ return ['name', 'botid', 'publishedon', 'createdon', 'modifiedon'];
41
+ }
42
+ commandAction(logger, args) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ if (this.verbose) {
45
+ logger.logToStderr(`Retrieving chatbot '${args.options.id || args.options.name}'...`);
46
+ }
47
+ try {
48
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
49
+ const res = yield this.getChatbot(dynamicsApiUrl, args.options);
50
+ logger.log(res);
51
+ }
52
+ catch (err) {
53
+ this.handleRejectedODataJsonPromise(err);
54
+ }
55
+ });
56
+ }
57
+ getChatbot(dynamicsApiUrl, options) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const requestOptions = {
60
+ headers: {
61
+ accept: 'application/json;odata.metadata=none'
62
+ },
63
+ responseType: 'json'
64
+ };
65
+ if (options.id) {
66
+ requestOptions.url = `${dynamicsApiUrl}/api/data/v9.1/bots(${options.id})`;
67
+ const result = yield request_1.default.get(requestOptions);
68
+ return result;
69
+ }
70
+ requestOptions.url = `${dynamicsApiUrl}/api/data/v9.1/bots?$filter=name eq '${formatting_1.formatting.encodeQueryParameter(options.name)}'`;
71
+ const result = yield request_1.default.get(requestOptions);
72
+ if (result.value.length > 1) {
73
+ throw `Multiple chatbots with name '${options.name}' found: ${result.value.map(x => x.botid).join(',')}`;
74
+ }
75
+ if (result.value.length === 0) {
76
+ throw `The specified chatbot '${options.name}' does not exist.`;
77
+ }
78
+ return result.value[0];
79
+ });
80
+ }
81
+ }
82
+ _PpChatbotGetCommand_instances = new WeakSet(), _PpChatbotGetCommand_initTelemetry = function _PpChatbotGetCommand_initTelemetry() {
83
+ this.telemetry.push((args) => {
84
+ Object.assign(this.telemetryProperties, {
85
+ id: typeof args.options.id !== 'undefined',
86
+ name: typeof args.options.name !== 'undefined',
87
+ asAdmin: !!args.options.asAdmin
88
+ });
89
+ });
90
+ }, _PpChatbotGetCommand_initOptions = function _PpChatbotGetCommand_initOptions() {
91
+ this.options.unshift({
92
+ option: '-e, --environment <environment>'
93
+ }, {
94
+ option: '-i, --id [id]'
95
+ }, {
96
+ option: '-n, --name [name]'
97
+ }, {
98
+ option: '--asAdmin'
99
+ });
100
+ }, _PpChatbotGetCommand_initOptionSets = function _PpChatbotGetCommand_initOptionSets() {
101
+ this.optionSets.push({ options: ['id', 'name'] });
102
+ }, _PpChatbotGetCommand_initValidators = function _PpChatbotGetCommand_initValidators() {
103
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
104
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
105
+ return `${args.options.id} is not a valid GUID`;
106
+ }
107
+ return true;
108
+ }));
109
+ };
110
+ module.exports = new PpChatbotGetCommand();
111
+ //# sourceMappingURL=chatbot-get.js.map