@pnp/cli-microsoft365 5.9.0-beta.0d30334 → 5.9.0-beta.1713b46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/.eslintrc.js +4 -2
  2. package/dist/m365/aad/commands/app/app-add.js +37 -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/environment/environment-get.js +75 -0
  7. package/dist/m365/pp/commands.js +1 -0
  8. package/dist/m365/spo/commands/list/list-roleinheritance-break.js +14 -6
  9. package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +15 -7
  10. package/dist/m365/spo/commands/list/list-webhook-add.js +19 -11
  11. package/dist/m365/spo/commands/list/list-webhook-get.js +17 -9
  12. package/dist/m365/spo/commands/list/list-webhook-list.js +23 -24
  13. package/dist/m365/spo/commands/list/list-webhook-remove.js +19 -11
  14. package/dist/m365/spo/commands/list/list-webhook-set.js +18 -10
  15. package/dist/m365/todo/commands/task/task-set.js +53 -1
  16. package/docs/docs/cmd/pp/environment/environment-get.md +38 -0
  17. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-get.md +2 -2
  18. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.md +2 -2
  19. package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +11 -8
  20. package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +14 -5
  21. package/docs/docs/cmd/spo/list/list-webhook-add.md +15 -16
  22. package/docs/docs/cmd/spo/list/list-webhook-get.md +15 -6
  23. package/docs/docs/cmd/spo/list/list-webhook-list.md +16 -7
  24. package/docs/docs/cmd/spo/list/list-webhook-remove.md +12 -10
  25. package/docs/docs/cmd/spo/list/list-webhook-set.md +13 -11
  26. package/docs/docs/cmd/todo/task/task-set.md +29 -2
  27. package/package.json +4 -1
package/.eslintrc.js CHANGED
@@ -185,7 +185,8 @@ module.exports = {
185
185
  "camelCase"
186
186
  ]
187
187
  }
188
- ]
188
+ ],
189
+ "@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }]
189
190
  },
190
191
  "overrides": [
191
192
  {
@@ -196,7 +197,8 @@ module.exports = {
196
197
  "no-console": "error",
197
198
  "@typescript-eslint/no-empty-function": "off",
198
199
  "cli-microsoft365/correct-command-class-name": "off",
199
- "cli-microsoft365/correct-command-name": "off"
200
+ "cli-microsoft365/correct-command-name": "off",
201
+ "@typescript-eslint/explicit-function-return-type": "off"
200
202
  }
201
203
  },
202
204
  {
@@ -209,8 +209,6 @@ class AadAppAddCommand extends GraphCommand_1.default {
209
209
  delete v2Manifest.appId;
210
210
  delete v2Manifest.publisherDomain;
211
211
  // extract secrets from the manifest. Store them in a separate variable
212
- // and remove them from the manifest because we need to create them
213
- // separately
214
212
  const secrets = this.getSecretsFromManifest(v2Manifest);
215
213
  // Azure Portal returns v2 manifest whereas the Graph API expects a v1.6
216
214
  if (args.options.apisApplication || args.options.apisDelegated) {
@@ -218,6 +216,33 @@ class AadAppAddCommand extends GraphCommand_1.default {
218
216
  // otherwise, they will be skipped in the app update
219
217
  v2Manifest.requiredResourceAccess = appInfo.requiredResourceAccess;
220
218
  }
219
+ if (args.options.redirectUris) {
220
+ // take submitted redirectUris/platform as options
221
+ // otherwise, they will be removed from the app
222
+ v2Manifest.replyUrlsWithType = args.options.redirectUris.split(',').map(u => {
223
+ return {
224
+ url: u.trim(),
225
+ type: this.translatePlatformToType(args.options.platform)
226
+ };
227
+ });
228
+ }
229
+ if (args.options.multitenant) {
230
+ // override manifest setting when using multitenant flag
231
+ v2Manifest.signInAudience = 'AzureADMultipleOrgs';
232
+ }
233
+ if (args.options.implicitFlow) {
234
+ // remove manifest settings when using implicitFlow flag
235
+ delete v2Manifest.oauth2AllowIdTokenImplicitFlow;
236
+ delete v2Manifest.oauth2AllowImplicitFlow;
237
+ }
238
+ if (args.options.scopeName) {
239
+ // override manifest setting when using options.
240
+ delete v2Manifest.oauth2Permissions;
241
+ }
242
+ if (args.options.certificateFile || args.options.certificateBase64Encoded) {
243
+ // override manifest setting when using options.
244
+ delete v2Manifest.keyCredentials;
245
+ }
221
246
  const graphManifest = this.transformManifest(v2Manifest);
222
247
  const updateAppRequestOptions = {
223
248
  url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
@@ -428,7 +453,6 @@ class AadAppAddCommand extends GraphCommand_1.default {
428
453
  return odata_1.odata
429
454
  .getAllItems(`${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`)
430
455
  .then(servicePrincipals => {
431
- var _a;
432
456
  let resolvedApis = [];
433
457
  try {
434
458
  if (args.options.apisDelegated || args.options.apisApplication) {
@@ -451,17 +475,10 @@ class AadAppAddCommand extends GraphCommand_1.default {
451
475
  }
452
476
  });
453
477
  }
454
- if (typeof ((_a = this.manifest) === null || _a === void 0 ? void 0 : _a.requiredResourceAccess) !== 'undefined' && this.manifest.requiredResourceAccess.length > 0) {
478
+ else {
455
479
  const manifestApis = this.manifest.requiredResourceAccess;
456
480
  manifestApis.forEach(manifestApi => {
457
- const requiredResource = resolvedApis.find(api => api.resourceAppId === manifestApi.resourceAppId);
458
- if (requiredResource) {
459
- // exclude if any duplicate required resources in both manifest and submitted options
460
- requiredResource.resourceAccess.push(...manifestApi.resourceAccess.filter(manRes => !requiredResource.resourceAccess.some(res => res.id === manRes.id)));
461
- }
462
- else {
463
- resolvedApis.push(manifestApi);
464
- }
481
+ resolvedApis.push(manifestApi);
465
482
  const app = servicePrincipals.find(servicePrincipals => servicePrincipals.appId === manifestApi.resourceAppId);
466
483
  if (app) {
467
484
  manifestApi.resourceAccess.forEach((res => {
@@ -550,7 +567,7 @@ class AadAppAddCommand extends GraphCommand_1.default {
550
567
  }
551
568
  }
552
569
  configureSecret(args, appInfo, logger) {
553
- if (!args.options.withSecret) {
570
+ if (!args.options.withSecret || (appInfo.secrets && appInfo.secrets.length > 0)) {
554
571
  return Promise.resolve(appInfo);
555
572
  }
556
573
  if (this.verbose) {
@@ -560,6 +577,7 @@ class AadAppAddCommand extends GraphCommand_1.default {
560
577
  .createSecret({ appObjectId: appInfo.id })
561
578
  .then(secret => {
562
579
  appInfo.secret = secret.value;
580
+ appInfo.secrets = [{ displayName: secret.displayName, value: secret.value }];
563
581
  return Promise.resolve(appInfo);
564
582
  });
565
583
  }
@@ -643,6 +661,12 @@ class AadAppAddCommand extends GraphCommand_1.default {
643
661
  }
644
662
  return Promise.resolve(appInfo);
645
663
  }
664
+ translatePlatformToType(platform) {
665
+ if (platform === 'publicClient') {
666
+ return 'InstalledClient';
667
+ }
668
+ return platform.charAt(0).toUpperCase() + platform.substring(1);
669
+ }
646
670
  }
647
671
  _AadAppAddCommand_instances = new WeakSet(), _AadAppAddCommand_initTelemetry = function _AadAppAddCommand_initTelemetry() {
648
672
  this.telemetry.push((args) => {
@@ -132,7 +132,7 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
132
132
  if (args.options.bodyContentType &&
133
133
  args.options.bodyContentType !== 'Text' &&
134
134
  args.options.bodyContentType !== 'HTML') {
135
- return `${args.options.bodyContents} is not a valid value for the bodyContents option. Allowed values are Text|HTML`;
135
+ return `${args.options.bodyContentType} is not a valid value for the bodyContentType option. Allowed values are Text|HTML`;
136
136
  }
137
137
  if (args.options.saveToSentItems &&
138
138
  args.options.saveToSentItems !== 'true' &&
@@ -100,7 +100,7 @@ class PlannerBucketGetCommand extends GraphCommand_1.default {
100
100
  const requestOptions = {
101
101
  url: `${this.resource}/v1.0/planner/buckets/${id}`,
102
102
  headers: {
103
- accept: 'application/json'
103
+ accept: 'application/json;odata.metadata=none'
104
104
  },
105
105
  responseType: 'json'
106
106
  };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Environment.js.map
@@ -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
@@ -4,6 +4,7 @@ const prefix = 'pp';
4
4
  exports.default = {
5
5
  CARD_LIST: `${prefix} card list`,
6
6
  DATAVERSE_TABLE_LIST: `${prefix} dataverse table list`,
7
+ ENVIRONMENT_GET: `${prefix} environment get`,
7
8
  ENVIRONMENT_LIST: `${prefix} environment list`,
8
9
  GATEWAY_LIST: `${prefix} gateway list`,
9
10
  MANAGEMENTAPP_ADD: `${prefix} managementapp add`,
@@ -17,6 +17,7 @@ var _SpoListRoleInheritanceBreakCommand_instances, _SpoListRoleInheritanceBreakC
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
23
  const commands_1 = require("../../commands");
@@ -40,19 +41,23 @@ class SpoListRoleInheritanceBreakCommand extends SpoCommand_1.default {
40
41
  if (this.verbose) {
41
42
  logger.logToStderr(`Breaking role inheritance of list in site at ${args.options.webUrl}...`);
42
43
  }
43
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
44
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
44
45
  if (args.options.listId) {
45
- requestUrl += `(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
46
+ requestUrl += `lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/`;
46
47
  }
47
- else {
48
- requestUrl += `/getbytitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
48
+ else if (args.options.listTitle) {
49
+ requestUrl += `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/`;
50
+ }
51
+ else if (args.options.listUrl) {
52
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
53
+ requestUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
49
54
  }
50
55
  let keepExistingPermissions = true;
51
56
  if (args.options.clearExistingPermissions) {
52
57
  keepExistingPermissions = !args.options.clearExistingPermissions;
53
58
  }
54
59
  const requestOptions = {
55
- url: `${requestUrl}/breakroleinheritance(${keepExistingPermissions})`,
60
+ url: `${requestUrl}breakroleinheritance(${keepExistingPermissions})`,
56
61
  method: 'POST',
57
62
  headers: {
58
63
  'accept': 'application/json;odata=nometadata',
@@ -74,6 +79,7 @@ _SpoListRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListRoleInher
74
79
  Object.assign(this.telemetryProperties, {
75
80
  listId: typeof args.options.listId !== 'undefined',
76
81
  listTitle: typeof args.options.listTitle !== 'undefined',
82
+ listUrl: typeof args.options.listUrl !== 'undefined',
77
83
  clearExistingPermissions: args.options.clearExistingPermissions === true
78
84
  });
79
85
  });
@@ -84,6 +90,8 @@ _SpoListRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListRoleInher
84
90
  option: '-i, --listId [listId]'
85
91
  }, {
86
92
  option: '-t, --listTitle [listTitle]'
93
+ }, {
94
+ option: '--listUrl [listUrl]'
87
95
  }, {
88
96
  option: '-c, --clearExistingPermissions'
89
97
  });
@@ -99,7 +107,7 @@ _SpoListRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListRoleInher
99
107
  return true;
100
108
  }));
101
109
  }, _SpoListRoleInheritanceBreakCommand_initOptionSets = function _SpoListRoleInheritanceBreakCommand_initOptionSets() {
102
- this.optionSets.push(['listId', 'listTitle']);
110
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
103
111
  };
104
112
  module.exports = new SpoListRoleInheritanceBreakCommand();
105
113
  //# sourceMappingURL=list-roleinheritance-break.js.map
@@ -17,6 +17,7 @@ var _SpoListRoleInheritanceResetCommand_instances, _SpoListRoleInheritanceResetC
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
23
  const commands_1 = require("../../commands");
@@ -40,15 +41,19 @@ class SpoListRoleInheritanceResetCommand extends SpoCommand_1.default {
40
41
  if (this.verbose) {
41
42
  logger.logToStderr(`Restore role inheritance of list in site at ${args.options.webUrl}...`);
42
43
  }
43
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
44
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
44
45
  if (args.options.listId) {
45
- requestUrl += `(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
46
+ requestUrl += `lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/`;
46
47
  }
47
- else {
48
- requestUrl += `/getbytitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
48
+ else if (args.options.listTitle) {
49
+ requestUrl += `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/`;
50
+ }
51
+ else if (args.options.listUrl) {
52
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
53
+ requestUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
49
54
  }
50
55
  const requestOptions = {
51
- url: `${requestUrl}/resetroleinheritance`,
56
+ url: `${requestUrl}resetroleinheritance`,
52
57
  method: 'POST',
53
58
  headers: {
54
59
  'accept': 'application/json;odata=nometadata',
@@ -69,7 +74,8 @@ _SpoListRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListRoleInher
69
74
  this.telemetry.push((args) => {
70
75
  Object.assign(this.telemetryProperties, {
71
76
  listId: typeof args.options.listId !== 'undefined',
72
- listTitle: typeof args.options.listTitle !== 'undefined'
77
+ listTitle: typeof args.options.listTitle !== 'undefined',
78
+ listUrl: typeof args.options.listUrl !== 'undefined'
73
79
  });
74
80
  });
75
81
  }, _SpoListRoleInheritanceResetCommand_initOptions = function _SpoListRoleInheritanceResetCommand_initOptions() {
@@ -79,6 +85,8 @@ _SpoListRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListRoleInher
79
85
  option: '-i, --listId [listId]'
80
86
  }, {
81
87
  option: '-t, --listTitle [listTitle]'
88
+ }, {
89
+ option: '--listUrl [listUrl]'
82
90
  });
83
91
  }, _SpoListRoleInheritanceResetCommand_initValidators = function _SpoListRoleInheritanceResetCommand_initValidators() {
84
92
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -92,7 +100,7 @@ _SpoListRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListRoleInher
92
100
  return true;
93
101
  }));
94
102
  }, _SpoListRoleInheritanceResetCommand_initOptionSets = function _SpoListRoleInheritanceResetCommand_initOptionSets() {
95
- this.optionSets.push(['listId', 'listTitle']);
103
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
96
104
  };
97
105
  module.exports = new SpoListRoleInheritanceResetCommand();
98
106
  //# sourceMappingURL=list-roleinheritance-reset.js.map
@@ -17,6 +17,7 @@ var _SpoListWebhookAddCommand_instances, _SpoListWebhookAddCommand_initTelemetry
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
23
  const commands_1 = require("../../commands");
@@ -42,17 +43,21 @@ class SpoListWebhookAddCommand extends SpoCommand_1.default {
42
43
  commandAction(logger, args) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
45
  if (this.verbose) {
45
- logger.logToStderr(`Adding webhook to list ${args.options.listId ? args.options.listId : args.options.listTitle} located at site ${args.options.webUrl}...`);
46
+ logger.logToStderr(`Adding webhook to list ${args.options.listId || args.options.listTitle || args.options.listUrl} located at site ${args.options.webUrl}...`);
46
47
  }
47
- let requestUrl = '';
48
+ let requestUrl = `${args.options.webUrl}/_api/web`;
48
49
  if (args.options.listId) {
49
- requestUrl = `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/Subscriptions')`;
50
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/Subscriptions`;
50
51
  }
51
- else {
52
- requestUrl = `${args.options.webUrl}/_api/web/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/Subscriptions')`;
52
+ else if (args.options.listTitle) {
53
+ requestUrl += `/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/Subscriptions`;
54
+ }
55
+ else if (args.options.listUrl) {
56
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
57
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/Subscriptions`;
53
58
  }
54
59
  const requestBody = {};
55
- requestBody.resource = args.options.listId ? args.options.listId : args.options.listTitle;
60
+ requestBody.resource = args.options.listId || args.options.listTitle || args.options.listUrl;
56
61
  requestBody.notificationUrl = args.options.notificationUrl;
57
62
  // If no expiration date has been provided we will default to the
58
63
  // maximum expiration date of 180 days from now
@@ -84,10 +89,11 @@ class SpoListWebhookAddCommand extends SpoCommand_1.default {
84
89
  _SpoListWebhookAddCommand_instances = new WeakSet(), _SpoListWebhookAddCommand_initTelemetry = function _SpoListWebhookAddCommand_initTelemetry() {
85
90
  this.telemetry.push((args) => {
86
91
  Object.assign(this.telemetryProperties, {
87
- listId: (!(!args.options.listId)).toString(),
88
- listTitle: (!(!args.options.listTitle)).toString(),
89
- expirationDateTime: (!(!args.options.expirationDateTime)).toString(),
90
- clientState: (!(!args.options.clientState)).toString()
92
+ listId: typeof args.options.listId !== 'undefined',
93
+ listTitle: typeof args.options.listTitle !== 'undefined',
94
+ listUrl: typeof args.options.listUrl !== 'undefined',
95
+ expirationDateTime: typeof args.options.expirationDateTime !== 'undefined',
96
+ clientState: typeof args.options.clientState !== 'undefined'
91
97
  });
92
98
  });
93
99
  }, _SpoListWebhookAddCommand_initOptions = function _SpoListWebhookAddCommand_initOptions() {
@@ -97,6 +103,8 @@ _SpoListWebhookAddCommand_instances = new WeakSet(), _SpoListWebhookAddCommand_i
97
103
  option: '-l, --listId [listId]'
98
104
  }, {
99
105
  option: '-t, --listTitle [listTitle]'
106
+ }, {
107
+ option: '--listUrl [listUrl]'
100
108
  }, {
101
109
  option: '-n, --notificationUrl <notificationUrl>'
102
110
  }, {
@@ -129,7 +137,7 @@ _SpoListWebhookAddCommand_instances = new WeakSet(), _SpoListWebhookAddCommand_i
129
137
  return true;
130
138
  }));
131
139
  }, _SpoListWebhookAddCommand_initOptionSets = function _SpoListWebhookAddCommand_initOptionSets() {
132
- this.optionSets.push(['listId', 'listTitle']);
140
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
133
141
  };
134
142
  module.exports = new SpoListWebhookAddCommand();
135
143
  //# sourceMappingURL=list-webhook-add.js.map
@@ -17,6 +17,7 @@ var _SpoListWebhookGetCommand_instances, _SpoListWebhookGetCommand_initTelemetry
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
23
  const commands_1 = require("../../commands");
@@ -38,15 +39,19 @@ class SpoListWebhookGetCommand extends SpoCommand_1.default {
38
39
  commandAction(logger, args) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
41
  if (this.verbose) {
41
- const list = (args.options.listId ? args.options.listId : args.options.listTitle);
42
+ const list = (args.options.listId || args.options.listTitle || args.options.listUrl);
42
43
  logger.logToStderr(`Retrieving information for webhook ${args.options.id} belonging to list ${list} in site at ${args.options.webUrl}...`);
43
44
  }
44
- let requestUrl = '';
45
+ let requestUrl = `${args.options.webUrl}/_api/web`;
45
46
  if (args.options.listId) {
46
- requestUrl = `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/Subscriptions('${formatting_1.formatting.encodeQueryParameter(args.options.id)}')`;
47
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/Subscriptions('${formatting_1.formatting.encodeQueryParameter(args.options.id)}')`;
47
48
  }
48
- else {
49
- requestUrl = `${args.options.webUrl}/_api/web/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/Subscriptions('${formatting_1.formatting.encodeQueryParameter(args.options.id)}')`;
49
+ else if (args.options.listTitle) {
50
+ requestUrl += `/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/Subscriptions('${formatting_1.formatting.encodeQueryParameter(args.options.id)}')`;
51
+ }
52
+ else if (args.options.listUrl) {
53
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
54
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/Subscriptions('${formatting_1.formatting.encodeQueryParameter(args.options.id)}')`;
50
55
  }
51
56
  const requestOptions = {
52
57
  url: requestUrl,
@@ -72,9 +77,10 @@ class SpoListWebhookGetCommand extends SpoCommand_1.default {
72
77
  _SpoListWebhookGetCommand_instances = new WeakSet(), _SpoListWebhookGetCommand_initTelemetry = function _SpoListWebhookGetCommand_initTelemetry() {
73
78
  this.telemetry.push((args) => {
74
79
  Object.assign(this.telemetryProperties, {
75
- listId: (!(!args.options.listId)).toString(),
76
- listTitle: (!(!args.options.listTitle)).toString(),
77
- id: (!(!args.options.id)).toString()
80
+ listId: typeof args.options.listId !== 'undefined',
81
+ listTitle: typeof args.options.listTitle !== 'undefined',
82
+ listUrl: typeof args.options.listUrl !== 'undefined',
83
+ id: typeof args.options.id !== 'undefined'
78
84
  });
79
85
  });
80
86
  }, _SpoListWebhookGetCommand_initOptions = function _SpoListWebhookGetCommand_initOptions() {
@@ -84,6 +90,8 @@ _SpoListWebhookGetCommand_instances = new WeakSet(), _SpoListWebhookGetCommand_i
84
90
  option: '-l, --listId [listId]'
85
91
  }, {
86
92
  option: '-t, --listTitle [listTitle]'
93
+ }, {
94
+ option: '--listUrl [listUrl]'
87
95
  }, {
88
96
  option: '-i, --id [id]'
89
97
  });
@@ -104,7 +112,7 @@ _SpoListWebhookGetCommand_instances = new WeakSet(), _SpoListWebhookGetCommand_i
104
112
  return true;
105
113
  }));
106
114
  }, _SpoListWebhookGetCommand_initOptionSets = function _SpoListWebhookGetCommand_initOptionSets() {
107
- this.optionSets.push(['listId', 'listTitle']);
115
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
108
116
  };
109
117
  module.exports = new SpoListWebhookGetCommand();
110
118
  //# sourceMappingURL=list-webhook-get.js.map
@@ -13,11 +13,12 @@ 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 _SpoListWebhookListCommand_instances, _SpoListWebhookListCommand_initTelemetry, _SpoListWebhookListCommand_initOptions, _SpoListWebhookListCommand_initValidators;
16
+ var _SpoListWebhookListCommand_instances, _SpoListWebhookListCommand_initTelemetry, _SpoListWebhookListCommand_initOptions, _SpoListWebhookListCommand_initValidators, _SpoListWebhookListCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const chalk = require("chalk");
19
19
  const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
+ const urlUtil_1 = require("../../../../utils/urlUtil");
21
22
  const validation_1 = require("../../../../utils/validation");
22
23
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
24
  const commands_1 = require("../../commands");
@@ -28,6 +29,7 @@ class SpoListWebhookListCommand extends SpoCommand_1.default {
28
29
  __classPrivateFieldGet(this, _SpoListWebhookListCommand_instances, "m", _SpoListWebhookListCommand_initTelemetry).call(this);
29
30
  __classPrivateFieldGet(this, _SpoListWebhookListCommand_instances, "m", _SpoListWebhookListCommand_initOptions).call(this);
30
31
  __classPrivateFieldGet(this, _SpoListWebhookListCommand_instances, "m", _SpoListWebhookListCommand_initValidators).call(this);
32
+ __classPrivateFieldGet(this, _SpoListWebhookListCommand_instances, "m", _SpoListWebhookListCommand_initOptionSets).call(this);
31
33
  }
32
34
  get name() {
33
35
  return commands_1.default.LIST_WEBHOOK_LIST;
@@ -47,21 +49,24 @@ class SpoListWebhookListCommand extends SpoCommand_1.default {
47
49
  logger.logToStderr(chalk.yellow(`Option 'id' is deprecated. Please use 'listId' instead`));
48
50
  }
49
51
  if (this.verbose) {
50
- const list = args.options.id ? formatting_1.formatting.encodeQueryParameter(args.options.id) : (args.options.listId ? formatting_1.formatting.encodeQueryParameter(args.options.listId) : (args.options.title ? formatting_1.formatting.encodeQueryParameter(args.options.title) : formatting_1.formatting.encodeQueryParameter(args.options.listTitle)));
51
- logger.logToStderr(`Retrieving webhook information for list ${list} in site at ${args.options.webUrl}...`);
52
+ logger.logToStderr(`Retrieving webhook information for list ${args.options.id || args.options.listId || args.options.listUrl} in site at ${args.options.webUrl}...`);
52
53
  }
53
- let requestUrl = '';
54
+ let requestUrl = `${args.options.webUrl}/_api/web`;
54
55
  if (args.options.id) {
55
- requestUrl = `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.id)}')/Subscriptions`;
56
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.id)}')/Subscriptions`;
56
57
  }
57
58
  else if (args.options.listId) {
58
- requestUrl = `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/Subscriptions`;
59
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/Subscriptions`;
59
60
  }
60
61
  else if (args.options.listTitle) {
61
- requestUrl = `${args.options.webUrl}/_api/web/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/Subscriptions`;
62
+ requestUrl += `/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/Subscriptions`;
62
63
  }
63
- else {
64
- requestUrl = `${args.options.webUrl}/_api/web/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.title)}')/Subscriptions`;
64
+ else if (args.options.title) {
65
+ requestUrl += `/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.title)}')/Subscriptions`;
66
+ }
67
+ else if (args.options.listUrl) {
68
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
69
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/Subscriptions`;
65
70
  }
66
71
  const requestOptions = {
67
72
  url: requestUrl,
@@ -94,10 +99,11 @@ class SpoListWebhookListCommand extends SpoCommand_1.default {
94
99
  _SpoListWebhookListCommand_instances = new WeakSet(), _SpoListWebhookListCommand_initTelemetry = function _SpoListWebhookListCommand_initTelemetry() {
95
100
  this.telemetry.push((args) => {
96
101
  Object.assign(this.telemetryProperties, {
97
- id: (!(!args.options.id)).toString(),
98
- listId: (!(!args.options.listId)).toString(),
99
- listTitle: (!(!args.options.listTitle)).toString(),
100
- title: (!(!args.options.title)).toString()
102
+ id: typeof args.options.id !== 'undefined',
103
+ listId: typeof args.options.listId !== 'undefined',
104
+ listTitle: typeof args.options.listTitle !== 'undefined',
105
+ listUrl: typeof args.options.listUrl !== 'undefined',
106
+ title: typeof args.options.title !== 'undefined'
101
107
  });
102
108
  });
103
109
  }, _SpoListWebhookListCommand_initOptions = function _SpoListWebhookListCommand_initOptions() {
@@ -107,6 +113,8 @@ _SpoListWebhookListCommand_instances = new WeakSet(), _SpoListWebhookListCommand
107
113
  option: '-i, --listId [listId]'
108
114
  }, {
109
115
  option: '-t, --listTitle [listTitle]'
116
+ }, {
117
+ option: '--listUrl [listUrl]'
110
118
  }, {
111
119
  option: '--id [id]'
112
120
  }, {
@@ -128,19 +136,10 @@ _SpoListWebhookListCommand_instances = new WeakSet(), _SpoListWebhookListCommand
128
136
  return `${args.options.listId} is not a valid GUID`;
129
137
  }
130
138
  }
131
- if (args.options.id && args.options.title) {
132
- return 'Specify id or title, but not both';
133
- }
134
- if (args.options.listId && args.options.listTitle) {
135
- return 'Specify listId or listTitle, but not both';
136
- }
137
- if (!args.options.id && !args.options.title) {
138
- if (!args.options.listId && !args.options.listTitle) {
139
- return 'Specify listId or listTitle, one is required';
140
- }
141
- }
142
139
  return true;
143
140
  }));
141
+ }, _SpoListWebhookListCommand_initOptionSets = function _SpoListWebhookListCommand_initOptionSets() {
142
+ this.optionSets.push(['id', 'title', 'listId', 'listTitle', 'listUrl']);
144
143
  };
145
144
  module.exports = new SpoListWebhookListCommand();
146
145
  //# sourceMappingURL=list-webhook-list.js.map