@pnp/cli-microsoft365 6.0.0-beta.9e3459d → 6.0.0-beta.a0a813f

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 (58) hide show
  1. package/.eslintrc.js +15 -2
  2. package/dist/m365/aad/commands/app/app-add.js +36 -13
  3. package/dist/m365/outlook/commands/mail/mail-send.js +1 -1
  4. package/dist/m365/planner/commands/bucket/bucket-get.js +1 -1
  5. package/dist/m365/pp/commands/Environment.js +3 -0
  6. package/dist/m365/pp/commands/card/card-list.js +68 -0
  7. package/dist/m365/pp/commands/dataverse/dataverse-table-list.js +6 -12
  8. package/dist/m365/pp/commands/environment/environment-get.js +75 -0
  9. package/dist/m365/pp/commands.js +2 -0
  10. package/dist/m365/spo/commands/eventreceiver/EventReceiver.js +3 -0
  11. package/dist/m365/spo/commands/eventreceiver/eventreceiver-remove.js +182 -0
  12. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +129 -0
  13. package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +168 -0
  14. package/dist/m365/spo/commands/group/AssociatedGroupPropertiesCollection.js +3 -0
  15. package/dist/m365/spo/commands/group/group-list.js +49 -10
  16. package/dist/m365/spo/commands/list/list-contenttype-add.js +21 -18
  17. package/dist/m365/spo/commands/list/list-contenttype-default-set.js +59 -47
  18. package/dist/m365/spo/commands/list/list-contenttype-list.js +16 -8
  19. package/dist/m365/spo/commands/list/list-contenttype-remove.js +16 -8
  20. package/dist/m365/spo/commands/list/list-roleassignment-add.js +10 -10
  21. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +8 -8
  22. package/dist/m365/spo/commands/list/list-roleinheritance-break.js +14 -6
  23. package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +14 -6
  24. package/dist/m365/spo/commands/list/list-webhook-add.js +19 -11
  25. package/dist/m365/spo/commands/list/list-webhook-get.js +17 -9
  26. package/dist/m365/spo/commands/list/list-webhook-list.js +23 -24
  27. package/dist/m365/spo/commands/list/list-webhook-remove.js +19 -11
  28. package/dist/m365/spo/commands/list/list-webhook-set.js +18 -10
  29. package/dist/m365/spo/commands/listitem/listitem-roleassignment-remove.js +8 -8
  30. package/dist/m365/spo/commands/web/web-roleassignment-add.js +10 -10
  31. package/dist/m365/spo/commands/web/web-roleassignment-remove.js +8 -8
  32. package/dist/m365/spo/commands.js +3 -0
  33. package/dist/m365/teams/commands/channel/channel-add.js +9 -9
  34. package/dist/m365/todo/commands/task/task-set.js +53 -1
  35. package/docs/docs/cmd/pp/card/card-list.md +33 -0
  36. package/docs/docs/cmd/pp/dataverse/dataverse-table-list.md +2 -2
  37. package/docs/docs/cmd/pp/environment/environment-get.md +38 -0
  38. package/docs/docs/cmd/pp/environment/environment-list.md +1 -1
  39. package/docs/docs/cmd/pp/solution/solution-list.md +2 -2
  40. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-get.md +2 -2
  41. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.md +69 -0
  42. package/docs/docs/cmd/spo/file/file-roleinheritance-break.md +54 -0
  43. package/docs/docs/cmd/spo/folder/folder-roleassignment-remove.md +57 -0
  44. package/docs/docs/cmd/spo/group/group-list.md +10 -1
  45. package/docs/docs/cmd/spo/list/list-contenttype-add.md +15 -6
  46. package/docs/docs/cmd/spo/list/list-contenttype-default-set.md +16 -7
  47. package/docs/docs/cmd/spo/list/list-contenttype-list.md +15 -6
  48. package/docs/docs/cmd/spo/list/list-contenttype-remove.md +16 -7
  49. package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +11 -8
  50. package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +16 -7
  51. package/docs/docs/cmd/spo/list/list-webhook-add.md +15 -16
  52. package/docs/docs/cmd/spo/list/list-webhook-get.md +15 -6
  53. package/docs/docs/cmd/spo/list/list-webhook-list.md +16 -7
  54. package/docs/docs/cmd/spo/list/list-webhook-remove.md +12 -10
  55. package/docs/docs/cmd/spo/list/list-webhook-set.md +13 -11
  56. package/docs/docs/cmd/teams/channel/channel-add.md +4 -4
  57. package/docs/docs/cmd/todo/task/task-set.md +29 -2
  58. package/package.json +5 -1
package/.eslintrc.js CHANGED
@@ -174,7 +174,19 @@ module.exports = {
174
174
  "eqeqeq": [
175
175
  "error",
176
176
  "always"
177
- ]
177
+ ],
178
+ "@typescript-eslint/naming-convention": [
179
+ "error",
180
+ {
181
+ "selector": [
182
+ "method"
183
+ ],
184
+ "format": [
185
+ "camelCase"
186
+ ]
187
+ }
188
+ ],
189
+ "@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }]
178
190
  },
179
191
  "overrides": [
180
192
  {
@@ -185,7 +197,8 @@ module.exports = {
185
197
  "no-console": "error",
186
198
  "@typescript-eslint/no-empty-function": "off",
187
199
  "cli-microsoft365/correct-command-class-name": "off",
188
- "cli-microsoft365/correct-command-name": "off"
200
+ "cli-microsoft365/correct-command-name": "off",
201
+ "@typescript-eslint/explicit-function-return-type": "off"
189
202
  }
190
203
  },
191
204
  {
@@ -206,8 +206,6 @@ class AadAppAddCommand extends GraphCommand_1.default {
206
206
  delete v2Manifest.appId;
207
207
  delete v2Manifest.publisherDomain;
208
208
  // extract secrets from the manifest. Store them in a separate variable
209
- // and remove them from the manifest because we need to create them
210
- // separately
211
209
  const secrets = this.getSecretsFromManifest(v2Manifest);
212
210
  // Azure Portal returns v2 manifest whereas the Graph API expects a v1.6
213
211
  if (args.options.apisApplication || args.options.apisDelegated) {
@@ -215,6 +213,33 @@ class AadAppAddCommand extends GraphCommand_1.default {
215
213
  // otherwise, they will be skipped in the app update
216
214
  v2Manifest.requiredResourceAccess = appInfo.requiredResourceAccess;
217
215
  }
216
+ if (args.options.redirectUris) {
217
+ // take submitted redirectUris/platform as options
218
+ // otherwise, they will be removed from the app
219
+ v2Manifest.replyUrlsWithType = args.options.redirectUris.split(',').map(u => {
220
+ return {
221
+ url: u.trim(),
222
+ type: this.translatePlatformToType(args.options.platform)
223
+ };
224
+ });
225
+ }
226
+ if (args.options.multitenant) {
227
+ // override manifest setting when using multitenant flag
228
+ v2Manifest.signInAudience = 'AzureADMultipleOrgs';
229
+ }
230
+ if (args.options.implicitFlow) {
231
+ // remove manifest settings when using implicitFlow flag
232
+ delete v2Manifest.oauth2AllowIdTokenImplicitFlow;
233
+ delete v2Manifest.oauth2AllowImplicitFlow;
234
+ }
235
+ if (args.options.scopeName) {
236
+ // override manifest setting when using options.
237
+ delete v2Manifest.oauth2Permissions;
238
+ }
239
+ if (args.options.certificateFile || args.options.certificateBase64Encoded) {
240
+ // override manifest setting when using options.
241
+ delete v2Manifest.keyCredentials;
242
+ }
218
243
  const graphManifest = this.transformManifest(v2Manifest);
219
244
  const updateAppRequestOptions = {
220
245
  url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
@@ -425,7 +450,6 @@ class AadAppAddCommand extends GraphCommand_1.default {
425
450
  return odata_1.odata
426
451
  .getAllItems(`${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`)
427
452
  .then(servicePrincipals => {
428
- var _a;
429
453
  let resolvedApis = [];
430
454
  try {
431
455
  if (args.options.apisDelegated || args.options.apisApplication) {
@@ -448,17 +472,10 @@ class AadAppAddCommand extends GraphCommand_1.default {
448
472
  }
449
473
  });
450
474
  }
451
- if (typeof ((_a = this.manifest) === null || _a === void 0 ? void 0 : _a.requiredResourceAccess) !== 'undefined' && this.manifest.requiredResourceAccess.length > 0) {
475
+ else {
452
476
  const manifestApis = this.manifest.requiredResourceAccess;
453
477
  manifestApis.forEach(manifestApi => {
454
- const requiredResource = resolvedApis.find(api => api.resourceAppId === manifestApi.resourceAppId);
455
- if (requiredResource) {
456
- // exclude if any duplicate required resources in both manifest and submitted options
457
- requiredResource.resourceAccess.push(...manifestApi.resourceAccess.filter(manRes => !requiredResource.resourceAccess.some(res => res.id === manRes.id)));
458
- }
459
- else {
460
- resolvedApis.push(manifestApi);
461
- }
478
+ resolvedApis.push(manifestApi);
462
479
  const app = servicePrincipals.find(servicePrincipals => servicePrincipals.appId === manifestApi.resourceAppId);
463
480
  if (app) {
464
481
  manifestApi.resourceAccess.forEach((res => {
@@ -547,7 +564,7 @@ class AadAppAddCommand extends GraphCommand_1.default {
547
564
  }
548
565
  }
549
566
  configureSecret(args, appInfo, logger) {
550
- if (!args.options.withSecret) {
567
+ if (!args.options.withSecret || (appInfo.secrets && appInfo.secrets.length > 0)) {
551
568
  return Promise.resolve(appInfo);
552
569
  }
553
570
  if (this.verbose) {
@@ -643,6 +660,12 @@ class AadAppAddCommand extends GraphCommand_1.default {
643
660
  }
644
661
  return Promise.resolve(appInfo);
645
662
  }
663
+ translatePlatformToType(platform) {
664
+ if (platform === 'publicClient') {
665
+ return 'InstalledClient';
666
+ }
667
+ return platform.charAt(0).toUpperCase() + platform.substring(1);
668
+ }
646
669
  }
647
670
  _AadAppAddCommand_instances = new WeakSet(), _AadAppAddCommand_initTelemetry = function _AadAppAddCommand_initTelemetry() {
648
671
  this.telemetry.push((args) => {
@@ -129,7 +129,7 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
129
129
  if (args.options.bodyContentType &&
130
130
  args.options.bodyContentType !== 'Text' &&
131
131
  args.options.bodyContentType !== 'HTML') {
132
- return `${args.options.bodyContents} is not a valid value for the bodyContents option. Allowed values are Text|HTML`;
132
+ return `${args.options.bodyContentType} is not a valid value for the bodyContentType option. Allowed values are Text|HTML`;
133
133
  }
134
134
  if (args.options.saveToSentItems &&
135
135
  args.options.saveToSentItems !== 'true' &&
@@ -96,7 +96,7 @@ class PlannerBucketGetCommand extends GraphCommand_1.default {
96
96
  const requestOptions = {
97
97
  url: `${this.resource}/v1.0/planner/buckets/${id}`,
98
98
  headers: {
99
- accept: 'application/json'
99
+ accept: 'application/json;odata.metadata=none'
100
100
  },
101
101
  responseType: 'json'
102
102
  };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Environment.js.map
@@ -0,0 +1,68 @@
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 _PpCardListCommand_instances, _PpCardListCommand_initTelemetry, _PpCardListCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const odata_1 = require("../../../../utils/odata");
19
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PpCardListCommand extends PowerPlatformCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _PpCardListCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _PpCardListCommand_instances, "m", _PpCardListCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _PpCardListCommand_instances, "m", _PpCardListCommand_initOptions).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.CARD_LIST;
31
+ }
32
+ get description() {
33
+ return 'Lists Microsoft Power Platform cards in the specified Power Platform environment.';
34
+ }
35
+ defaultProperties() {
36
+ return ['name', 'cardid', 'publishdate', 'createdon', 'modifiedon'];
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Retrieving list of cards`);
42
+ }
43
+ try {
44
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
45
+ const items = yield odata_1.odata.getAllItems(`${dynamicsApiUrl}/api/data/v9.1/cards?$expand=owninguser($select=azureactivedirectoryobjectid,fullname)`);
46
+ logger.log(items);
47
+ }
48
+ catch (err) {
49
+ this.handleRejectedODataJsonPromise(err);
50
+ }
51
+ });
52
+ }
53
+ }
54
+ _PpCardListCommand_instances = new WeakSet(), _PpCardListCommand_initTelemetry = function _PpCardListCommand_initTelemetry() {
55
+ this.telemetry.push((args) => {
56
+ Object.assign(this.telemetryProperties, {
57
+ asAdmin: !!args.options.asAdmin
58
+ });
59
+ });
60
+ }, _PpCardListCommand_initOptions = function _PpCardListCommand_initOptions() {
61
+ this.options.unshift({
62
+ option: '-e, --environment <environment>'
63
+ }, {
64
+ option: '-a, --asAdmin'
65
+ });
66
+ };
67
+ module.exports = new PpCardListCommand();
68
+ //# sourceMappingURL=card-list.js.map
@@ -15,7 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _PpDataverseTableListCommand_instances, _PpDataverseTableListCommand_initTelemetry, _PpDataverseTableListCommand_initOptions;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const request_1 = require("../../../../request");
18
+ const odata_1 = require("../../../../utils/odata");
19
19
  const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
20
  const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
21
  const commands_1 = require("../../commands");
@@ -33,24 +33,18 @@ class PpDataverseTableListCommand extends PowerPlatformCommand_1.default {
33
33
  return 'Lists dataverse tables in a given environment';
34
34
  }
35
35
  defaultProperties() {
36
- return ['SchemaName', 'EntitySetName', 'IsManaged'];
36
+ return ['SchemaName', 'EntitySetName', 'LogicalName', 'IsManaged'];
37
37
  }
38
38
  commandAction(logger, args) {
39
39
  return __awaiter(this, void 0, void 0, function* () {
40
40
  if (this.verbose) {
41
41
  logger.logToStderr(`Retrieving list of tables for which the user is an admin...`);
42
42
  }
43
- const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
44
- const requestOptions = {
45
- url: `${dynamicsApiUrl}/api/data/v9.0/EntityDefinitions?$select=MetadataId,IsCustomEntity,IsManaged,SchemaName,IconVectorName,LogicalName,EntitySetName,IsActivity,DataProviderId,IsRenameable,IsCustomizable,CanCreateForms,CanCreateViews,CanCreateCharts,CanCreateAttributes,CanChangeTrackingBeEnabled,CanModifyAdditionalSettings,CanChangeHierarchicalRelationship,CanEnableSyncToExternalSearchIndex&$filter=(IsIntersect eq false and IsLogicalEntity eq false and%0APrimaryNameAttribute ne null and PrimaryNameAttribute ne %27%27 and ObjectTypeCode gt 0 and%0AObjectTypeCode ne 4712 and ObjectTypeCode ne 4724 and ObjectTypeCode ne 9933 and ObjectTypeCode ne 9934 and%0AObjectTypeCode ne 9935 and ObjectTypeCode ne 9947 and ObjectTypeCode ne 9945 and ObjectTypeCode ne 9944 and%0AObjectTypeCode ne 9942 and ObjectTypeCode ne 9951 and ObjectTypeCode ne 2016 and ObjectTypeCode ne 9949 and%0AObjectTypeCode ne 9866 and ObjectTypeCode ne 9867 and ObjectTypeCode ne 9868) and (IsCustomizable/Value eq true or IsCustomEntity eq true or IsManaged eq false or IsMappable/Value eq true or IsRenameable/Value eq true)&api-version=9.1`,
46
- headers: {
47
- accept: 'application/json;odata.metadata=none'
48
- },
49
- responseType: 'json'
50
- };
51
43
  try {
52
- const res = yield request_1.default.get(requestOptions);
53
- logger.log(res.value);
44
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
45
+ const endpoint = `${dynamicsApiUrl}/api/data/v9.0/EntityDefinitions?$select=MetadataId,IsCustomEntity,IsManaged,SchemaName,IconVectorName,LogicalName,EntitySetName,IsActivity,DataProviderId,IsRenameable,IsCustomizable,CanCreateForms,CanCreateViews,CanCreateCharts,CanCreateAttributes,CanChangeTrackingBeEnabled,CanModifyAdditionalSettings,CanChangeHierarchicalRelationship,CanEnableSyncToExternalSearchIndex&$filter=(IsIntersect eq false and IsLogicalEntity eq false and%0APrimaryNameAttribute ne null and PrimaryNameAttribute ne %27%27 and ObjectTypeCode gt 0 and%0AObjectTypeCode ne 4712 and ObjectTypeCode ne 4724 and ObjectTypeCode ne 9933 and ObjectTypeCode ne 9934 and%0AObjectTypeCode ne 9935 and ObjectTypeCode ne 9947 and ObjectTypeCode ne 9945 and ObjectTypeCode ne 9944 and%0AObjectTypeCode ne 9942 and ObjectTypeCode ne 9951 and ObjectTypeCode ne 2016 and ObjectTypeCode ne 9949 and%0AObjectTypeCode ne 9866 and ObjectTypeCode ne 9867 and ObjectTypeCode ne 9868) and (IsCustomizable/Value eq true or IsCustomEntity eq true or IsManaged eq false or IsMappable/Value eq true or IsRenameable/Value eq true)&api-version=9.1`;
46
+ const res = yield odata_1.odata.getAllItems(endpoint);
47
+ logger.log(res);
54
48
  }
55
49
  catch (err) {
56
50
  this.handleRejectedODataJsonPromise(err);
@@ -0,0 +1,75 @@
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 _PpEnvironmentGetCommand_instances, _PpEnvironmentGetCommand_initTelemetry, _PpEnvironmentGetCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
20
+ const commands_1 = require("../../commands");
21
+ class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
22
+ constructor() {
23
+ super();
24
+ _PpEnvironmentGetCommand_instances.add(this);
25
+ __classPrivateFieldGet(this, _PpEnvironmentGetCommand_instances, "m", _PpEnvironmentGetCommand_initTelemetry).call(this);
26
+ __classPrivateFieldGet(this, _PpEnvironmentGetCommand_instances, "m", _PpEnvironmentGetCommand_initOptions).call(this);
27
+ }
28
+ get name() {
29
+ return commands_1.default.ENVIRONMENT_GET;
30
+ }
31
+ get description() {
32
+ return 'Gets information about the specified Power Platform environment';
33
+ }
34
+ defaultProperties() {
35
+ return ['name', 'id'];
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ let url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments`;
40
+ if (args.options.asAdmin) {
41
+ url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments`;
42
+ }
43
+ const requestOptions = {
44
+ url: `${url}?api-version=2020-10-01`,
45
+ headers: {
46
+ accept: 'application/json'
47
+ },
48
+ responseType: 'json'
49
+ };
50
+ const res = yield request_1.default.get(requestOptions);
51
+ const environmentItem = res.value.filter((env) => {
52
+ return env.name === args.options.name;
53
+ })[0];
54
+ if (!environmentItem) {
55
+ throw `The specified Power Platform environment does not exist`;
56
+ }
57
+ logger.log(environmentItem);
58
+ });
59
+ }
60
+ }
61
+ _PpEnvironmentGetCommand_instances = new WeakSet(), _PpEnvironmentGetCommand_initTelemetry = function _PpEnvironmentGetCommand_initTelemetry() {
62
+ this.telemetry.push((args) => {
63
+ Object.assign(this.telemetryProperties, {
64
+ asAdmin: !!args.options.asAdmin
65
+ });
66
+ });
67
+ }, _PpEnvironmentGetCommand_initOptions = function _PpEnvironmentGetCommand_initOptions() {
68
+ this.options.unshift({
69
+ option: '-n, --name <name>'
70
+ }, {
71
+ option: '-a, --asAdmin'
72
+ });
73
+ };
74
+ module.exports = new PpEnvironmentGetCommand();
75
+ //# sourceMappingURL=environment-get.js.map
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'pp';
4
4
  exports.default = {
5
+ CARD_LIST: `${prefix} card list`,
5
6
  DATAVERSE_TABLE_LIST: `${prefix} dataverse table list`,
7
+ ENVIRONMENT_GET: `${prefix} environment get`,
6
8
  ENVIRONMENT_LIST: `${prefix} environment list`,
7
9
  GATEWAY_LIST: `${prefix} gateway list`,
8
10
  MANAGEMENTAPP_ADD: `${prefix} managementapp add`,
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=EventReceiver.js.map
@@ -0,0 +1,182 @@
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 _SpoEventreceiverRemoveCommand_instances, _SpoEventreceiverRemoveCommand_initTelemetry, _SpoEventreceiverRemoveCommand_initOptions, _SpoEventreceiverRemoveCommand_initValidators, _SpoEventreceiverRemoveCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
21
+ const validation_1 = require("../../../../utils/validation");
22
+ const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const commands_1 = require("../../commands");
24
+ const request_1 = require("../../../../request");
25
+ const getCommand = require('./eventreceiver-get');
26
+ class SpoEventreceiverRemoveCommand extends SpoCommand_1.default {
27
+ constructor() {
28
+ super();
29
+ _SpoEventreceiverRemoveCommand_instances.add(this);
30
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initTelemetry).call(this);
31
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initOptions).call(this);
32
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initValidators).call(this);
33
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initOptionSets).call(this);
34
+ }
35
+ get name() {
36
+ return commands_1.default.EVENTRECEIVER_REMOVE;
37
+ }
38
+ get description() {
39
+ return 'Removes event receivers for the specified web, site, or list.';
40
+ }
41
+ commandAction(logger, args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ const getEventReceiversOutput = yield this.getEventReceivers(args.options);
45
+ const eventReceivers = JSON.parse(getEventReceiversOutput.stdout);
46
+ if (!eventReceivers.length) {
47
+ throw Error(`Specified event receiver with ${args.options.id !== undefined ? `id ${args.options.id}` : `name ${args.options.name}`} cannot be found`);
48
+ }
49
+ if (eventReceivers.length > 1) {
50
+ throw Error(`Multiple eventreceivers with ${args.options.id !== undefined ? `id ${args.options.id} found` : `name ${args.options.name}, ids: ${eventReceivers.map(x => x.ReceiverId)} found`}`);
51
+ }
52
+ if (args.options.confirm) {
53
+ yield this.removeEventReceiver(args.options);
54
+ }
55
+ else {
56
+ const result = yield Cli_1.Cli.prompt({
57
+ type: 'confirm',
58
+ name: 'continue',
59
+ default: false,
60
+ message: `Are you sure you want to remove event receiver with ${args.options.id !== undefined ? `id ${args.options.id}` : `name ${args.options.name}`}?`
61
+ });
62
+ if (result.continue) {
63
+ yield this.removeEventReceiver(args.options);
64
+ }
65
+ }
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedODataJsonPromise(err);
69
+ }
70
+ });
71
+ }
72
+ removeEventReceiver(options) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ let requestUrl = `${options.webUrl}/_api/`;
75
+ let listUrl = '';
76
+ let filter = '?$filter=';
77
+ if (options.listId) {
78
+ listUrl = `lists(guid'${formatting_1.formatting.encodeQueryParameter(options.listId)}')/`;
79
+ }
80
+ else if (options.listTitle) {
81
+ listUrl = `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(options.listTitle)}')/`;
82
+ }
83
+ else if (options.listUrl) {
84
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
85
+ listUrl = `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
86
+ }
87
+ if (!options.scope || options.scope === 'web') {
88
+ requestUrl += `web/${listUrl}eventreceivers`;
89
+ }
90
+ else {
91
+ requestUrl += 'site/eventreceivers';
92
+ }
93
+ if (options.id) {
94
+ filter += `receiverid eq (guid'${options.id}')`;
95
+ }
96
+ else {
97
+ filter += `receivername eq '${options.name}'`;
98
+ }
99
+ const requestOptions = {
100
+ url: requestUrl + filter,
101
+ headers: {
102
+ 'accept': 'application/json;odata=nometadata'
103
+ },
104
+ responseType: 'json'
105
+ };
106
+ yield request_1.default.delete(requestOptions);
107
+ });
108
+ }
109
+ getEventReceivers(options) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const getOptions = {
112
+ webUrl: options.webUrl,
113
+ listId: options.listId,
114
+ listTitle: options.listTitle,
115
+ listUrl: options.listUrl,
116
+ scope: options.scope,
117
+ id: options.id,
118
+ name: options.name,
119
+ debug: this.debug,
120
+ verbose: this.verbose
121
+ };
122
+ return yield Cli_1.Cli.executeCommandWithOutput(getCommand, { options: Object.assign(Object.assign({}, getOptions), { _: [] }) });
123
+ });
124
+ }
125
+ }
126
+ _SpoEventreceiverRemoveCommand_instances = new WeakSet(), _SpoEventreceiverRemoveCommand_initTelemetry = function _SpoEventreceiverRemoveCommand_initTelemetry() {
127
+ this.telemetry.push((args) => {
128
+ Object.assign(this.telemetryProperties, {
129
+ listId: typeof args.options.listId !== 'undefined',
130
+ listTitle: typeof args.options.listTitle !== 'undefined',
131
+ listUrl: typeof args.options.listUrl !== 'undefined',
132
+ scope: typeof args.options.scope !== 'undefined',
133
+ id: typeof args.options.id !== 'undefined',
134
+ name: typeof args.options.name !== 'undefined',
135
+ confirm: (!(!args.options.confirm)).toString()
136
+ });
137
+ });
138
+ }, _SpoEventreceiverRemoveCommand_initOptions = function _SpoEventreceiverRemoveCommand_initOptions() {
139
+ this.options.unshift({
140
+ option: '-u, --webUrl <webUrl>'
141
+ }, {
142
+ option: '--listTitle [listTitle]'
143
+ }, {
144
+ option: '--listId [listId]'
145
+ }, {
146
+ option: '--listUrl [listUrl]'
147
+ }, {
148
+ option: '-n, --name [name]'
149
+ }, {
150
+ option: '-i, --id [id]'
151
+ }, {
152
+ option: '-s, --scope [scope]',
153
+ autocomplete: ['web', 'site']
154
+ }, {
155
+ option: '--confirm'
156
+ });
157
+ }, _SpoEventreceiverRemoveCommand_initValidators = function _SpoEventreceiverRemoveCommand_initValidators() {
158
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
159
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
160
+ if (isValidSharePointUrl !== true) {
161
+ return isValidSharePointUrl;
162
+ }
163
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
164
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
165
+ return `Specify either list id or title or list url`;
166
+ }
167
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
168
+ return `${args.options.listId} is not a valid GUID`;
169
+ }
170
+ if (args.options.scope && ['web', 'site'].indexOf(args.options.scope) === -1) {
171
+ return `${args.options.scope} is not a valid type value. Allowed values web|site.`;
172
+ }
173
+ if (args.options.scope && args.options.scope === 'site' && (args.options.listId || args.options.listUrl || args.options.listTitle)) {
174
+ return 'Scope cannot be set to site when retrieving list event receivers.';
175
+ }
176
+ return true;
177
+ }));
178
+ }, _SpoEventreceiverRemoveCommand_initOptionSets = function _SpoEventreceiverRemoveCommand_initOptionSets() {
179
+ this.optionSets.push(['name', 'id']);
180
+ };
181
+ module.exports = new SpoEventreceiverRemoveCommand();
182
+ //# sourceMappingURL=eventreceiver-remove.js.map