@pnp/cli-microsoft365 6.0.0-beta.62647c9 → 6.0.0-beta.636d726

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 (54) hide show
  1. package/dist/m365/aad/commands/user/user-guest-add.js +103 -0
  2. package/dist/m365/aad/commands.js +1 -0
  3. package/dist/m365/outlook/commands/message/message-get.js +97 -0
  4. package/dist/m365/outlook/commands.js +1 -0
  5. package/dist/m365/spo/commands/field/field-add.js +26 -1
  6. package/dist/m365/spo/commands/field/field-set.js +23 -13
  7. package/dist/m365/spo/commands/folder/folder-roleinheritance-break.js +11 -1
  8. package/dist/m365/spo/commands/folder/folder-roleinheritance-reset.js +12 -1
  9. package/dist/m365/spo/commands/listitem/listitem-add.js +24 -14
  10. package/dist/m365/spo/commands/listitem/listitem-attachment-list.js +18 -8
  11. package/dist/m365/spo/commands/listitem/listitem-get.js +18 -8
  12. package/dist/m365/spo/commands/listitem/listitem-isrecord.js +20 -10
  13. package/dist/m365/spo/commands/listitem/listitem-list.js +21 -11
  14. package/dist/m365/spo/commands/listitem/listitem-record-declare.js +19 -12
  15. package/dist/m365/spo/commands/listitem/listitem-record-undeclare.js +24 -21
  16. package/dist/m365/spo/commands/listitem/listitem-remove.js +19 -11
  17. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +13 -5
  18. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +13 -5
  19. package/dist/m365/spo/commands/listitem/listitem-set.js +52 -44
  20. package/dist/m365/spo/commands/roledefinition/roledefinition-list.js +15 -2
  21. package/dist/m365/spo/commands/{hubsite/hubsite-theme-sync.js → site/site-hubsite-theme-sync.js} +11 -11
  22. package/dist/m365/spo/commands.js +2 -2
  23. package/dist/m365/todo/commands/task/task-get.js +108 -0
  24. package/dist/m365/todo/commands.js +1 -0
  25. package/docs/docs/cmd/aad/user/user-guest-add.md +107 -0
  26. package/docs/docs/cmd/adaptivecard/adaptivecard-send.md +3 -0
  27. package/docs/docs/cmd/graph/schemaextension/schemaextension-add.md +4 -11
  28. package/docs/docs/cmd/graph/schemaextension/schemaextension-set.md +4 -10
  29. package/docs/docs/cmd/outlook/message/message-get.md +48 -0
  30. package/docs/docs/cmd/spo/customaction/customaction-add.md +3 -0
  31. package/docs/docs/cmd/spo/customaction/customaction-set.md +3 -2
  32. package/docs/docs/cmd/spo/field/field-add.md +20 -2
  33. package/docs/docs/cmd/spo/field/field-set.md +15 -3
  34. package/docs/docs/cmd/spo/folder/folder-roleinheritance-break.md +6 -0
  35. package/docs/docs/cmd/spo/folder/folder-roleinheritance-reset.md +6 -0
  36. package/docs/docs/cmd/spo/list/list-view-set.md +14 -3
  37. package/docs/docs/cmd/spo/listitem/listitem-add.md +11 -2
  38. package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +11 -2
  39. package/docs/docs/cmd/spo/listitem/listitem-get.md +11 -2
  40. package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +12 -2
  41. package/docs/docs/cmd/spo/listitem/listitem-list.md +10 -1
  42. package/docs/docs/cmd/spo/listitem/listitem-record-declare.md +7 -4
  43. package/docs/docs/cmd/spo/listitem/listitem-record-undeclare.md +11 -2
  44. package/docs/docs/cmd/spo/listitem/listitem-remove.md +11 -2
  45. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-break.md +7 -4
  46. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-reset.md +8 -5
  47. package/docs/docs/cmd/spo/listitem/listitem-set.md +7 -4
  48. package/docs/docs/cmd/spo/page/page-clientsidewebpart-add.md +5 -10
  49. package/docs/docs/cmd/spo/page/page-control-set.md +2 -1
  50. package/docs/docs/cmd/spo/{hubsite/hubsite-theme-sync.md → site/site-hubsite-theme-sync.md} +5 -5
  51. package/docs/docs/cmd/spo/term/term-add.md +5 -0
  52. package/docs/docs/cmd/spo/term/term-set-add.md +6 -1
  53. package/docs/docs/cmd/todo/task/task-get.md +75 -0
  54. package/package.json +1 -1
@@ -0,0 +1,103 @@
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 _AadUserGuestAddCommand_instances, _AadUserGuestAddCommand_initTelemetry, _AadUserGuestAddCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const GraphCommand_1 = require("../../../base/GraphCommand");
20
+ const commands_1 = require("../../commands");
21
+ class AadUserGuestAddCommand extends GraphCommand_1.default {
22
+ constructor() {
23
+ super();
24
+ _AadUserGuestAddCommand_instances.add(this);
25
+ __classPrivateFieldGet(this, _AadUserGuestAddCommand_instances, "m", _AadUserGuestAddCommand_initTelemetry).call(this);
26
+ __classPrivateFieldGet(this, _AadUserGuestAddCommand_instances, "m", _AadUserGuestAddCommand_initOptions).call(this);
27
+ }
28
+ get name() {
29
+ return commands_1.default.USER_GUEST_ADD;
30
+ }
31
+ get description() {
32
+ return 'Invite an external user to the organization';
33
+ }
34
+ defaultProperties() {
35
+ return ['id', 'inviteRedeemUrl', 'invitedUserDisplayName', 'invitedUserEmailAddress', 'invitedUserType', 'resetRedemption', 'sendInvitationMessage', 'status'];
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ try {
40
+ const requestOptions = {
41
+ url: `${this.resource}/v1.0/invitations`,
42
+ headers: {
43
+ accept: 'application/json;odata.metadata=none'
44
+ },
45
+ responseType: 'json',
46
+ data: {
47
+ invitedUserEmailAddress: args.options.emailAddress,
48
+ inviteRedirectUrl: args.options.inviteRedirectUrl || 'https://myapplications.microsoft.com',
49
+ invitedUserDisplayName: args.options.displayName,
50
+ sendInvitationMessage: args.options.sendInvitationMessage,
51
+ invitedUserMessageInfo: {
52
+ customizedMessageBody: args.options.welcomeMessage,
53
+ messageLanguage: args.options.messageLanguage || 'en-US',
54
+ ccRecipients: args.options.ccRecipients ? this.mapEmailsToRecipients([args.options.ccRecipients]) : undefined
55
+ }
56
+ }
57
+ };
58
+ const result = yield request_1.default.post(requestOptions);
59
+ logger.log(result);
60
+ }
61
+ catch (err) {
62
+ this.handleRejectedODataJsonPromise(err);
63
+ }
64
+ });
65
+ }
66
+ mapEmailsToRecipients(emails) {
67
+ return emails.map(mail => ({
68
+ emailAddress: {
69
+ address: mail.trim()
70
+ }
71
+ }));
72
+ }
73
+ }
74
+ _AadUserGuestAddCommand_instances = new WeakSet(), _AadUserGuestAddCommand_initTelemetry = function _AadUserGuestAddCommand_initTelemetry() {
75
+ this.telemetry.push((args) => {
76
+ Object.assign(this.telemetryProperties, {
77
+ displayName: typeof args.options.displayName !== 'undefined',
78
+ inviteRedirectUrl: typeof args.options.inviteRedirectUrl !== 'undefined',
79
+ welcomeMessage: typeof args.options.welcomeMessage !== 'undefined',
80
+ messageLanguage: typeof args.options.messageLanguage !== 'undefined',
81
+ ccRecipients: typeof args.options.ccRecipients !== 'undefined',
82
+ sendInvitationMessage: !!args.options.sendInvitationMessage
83
+ });
84
+ });
85
+ }, _AadUserGuestAddCommand_initOptions = function _AadUserGuestAddCommand_initOptions() {
86
+ this.options.unshift({
87
+ option: '--emailAddress <emailAddress>'
88
+ }, {
89
+ option: '--displayName [displayName]'
90
+ }, {
91
+ option: '--inviteRedirectUrl [inviteRedirectUrl]'
92
+ }, {
93
+ option: '--welcomeMessage [welcomeMessage]'
94
+ }, {
95
+ option: '--messageLanguage [messageLanguage]'
96
+ }, {
97
+ option: '--ccRecipients [ccRecipients]'
98
+ }, {
99
+ option: '--sendInvitationMessage'
100
+ });
101
+ };
102
+ module.exports = new AadUserGuestAddCommand();
103
+ //# sourceMappingURL=user-guest-add.js.map
@@ -54,6 +54,7 @@ exports.default = {
54
54
  SP_ADD: `${prefix} sp add`,
55
55
  SP_GET: `${prefix} sp get`,
56
56
  USER_GET: `${prefix} user get`,
57
+ USER_GUEST_ADD: `${prefix} user guest add`,
57
58
  USER_HIBP: `${prefix} user hibp`,
58
59
  USER_LIST: `${prefix} user list`,
59
60
  USER_PASSWORD_VALIDATE: `${prefix} user password validate`,
@@ -0,0 +1,97 @@
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 _OutlookMessageGetCommand_instances, _OutlookMessageGetCommand_initTelemetry, _OutlookMessageGetCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Auth_1 = require("../../../../Auth");
19
+ const request_1 = require("../../../../request");
20
+ const GraphCommand_1 = require("../../../base/GraphCommand");
21
+ const commands_1 = require("../../commands");
22
+ class OutlookMessageGetCommand extends GraphCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _OutlookMessageGetCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _OutlookMessageGetCommand_instances, "m", _OutlookMessageGetCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _OutlookMessageGetCommand_instances, "m", _OutlookMessageGetCommand_initOptions).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.MESSAGE_GET;
31
+ }
32
+ get description() {
33
+ return 'Retrieves specified message';
34
+ }
35
+ commandAction(logger, args) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ try {
38
+ const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[this.resource].accessToken);
39
+ if (this.verbose) {
40
+ logger.logToStderr(`Retrieving message with id ${args.options.id} using ${isAppOnlyAuth ? 'app only permissions' : 'delegated permissions'}`);
41
+ }
42
+ let requestUrl = '';
43
+ if (isAppOnlyAuth) {
44
+ if (!args.options.userId && !args.options.userPrincipalName) {
45
+ throw `The option 'userId' or 'userPrincipalName' is required when retrieving an email using app only credentials`;
46
+ }
47
+ if (args.options.userId && args.options.userPrincipalName) {
48
+ throw `Both options 'userId' and 'userPrincipalName' cannot be set when retrieving an email using app only credentials`;
49
+ }
50
+ requestUrl += `users/${args.options.userId ? args.options.userId : args.options.userPrincipalName}`;
51
+ }
52
+ else {
53
+ if (args.options.userId && args.options.userPrincipalName) {
54
+ throw `Both options 'userId' and 'userPrincipalName' cannot be set when retrieving an email using delegated credentials`;
55
+ }
56
+ if (args.options.userId || args.options.userPrincipalName) {
57
+ requestUrl += `users/${args.options.userId ? args.options.userId : args.options.userPrincipalName}`;
58
+ }
59
+ else {
60
+ requestUrl += 'me';
61
+ }
62
+ }
63
+ requestUrl += `/messages/${args.options.id}`;
64
+ const requestOptions = {
65
+ url: `${this.resource}/v1.0/${requestUrl}`,
66
+ headers: {
67
+ accept: 'application/json;odata.metadata=none'
68
+ },
69
+ responseType: 'json'
70
+ };
71
+ const res = yield request_1.default.get(requestOptions);
72
+ logger.log(res);
73
+ }
74
+ catch (err) {
75
+ this.handleRejectedODataJsonPromise(err);
76
+ }
77
+ });
78
+ }
79
+ }
80
+ _OutlookMessageGetCommand_instances = new WeakSet(), _OutlookMessageGetCommand_initTelemetry = function _OutlookMessageGetCommand_initTelemetry() {
81
+ this.telemetry.push((args) => {
82
+ Object.assign(this.telemetryProperties, {
83
+ userId: typeof args.options.userId !== 'undefined',
84
+ userPrincipalName: typeof args.options.userPrincipalName !== 'undefined'
85
+ });
86
+ });
87
+ }, _OutlookMessageGetCommand_initOptions = function _OutlookMessageGetCommand_initOptions() {
88
+ this.options.unshift({
89
+ option: '-i, --id <id>'
90
+ }, {
91
+ option: '--userId [userId]'
92
+ }, {
93
+ option: '--userPrincipalName [userPrincipalName]'
94
+ });
95
+ };
96
+ module.exports = new OutlookMessageGetCommand();
97
+ //# sourceMappingURL=message-get.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'outlook';
4
4
  exports.default = {
5
5
  MAIL_SEND: `${prefix} mail send`,
6
+ MESSAGE_GET: `${prefix} message get`,
6
7
  MESSAGE_LIST: `${prefix} message list`,
7
8
  MESSAGE_MOVE: `${prefix} message move`,
8
9
  REPORT_MAILACTIVITYCOUNTS: `${prefix} report mailactivitycounts`,
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
20
  const spo_1 = require("../../../../utils/spo");
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");
@@ -38,9 +39,20 @@ class SpoFieldAddCommand extends SpoCommand_1.default {
38
39
  commandAction(logger, args) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
41
  try {
42
+ let requestUrl = `${args.options.webUrl}/_api/web`;
43
+ if (args.options.listId) {
44
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
45
+ }
46
+ else if (args.options.listTitle) {
47
+ requestUrl += `/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
48
+ }
49
+ else if (args.options.listUrl) {
50
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
51
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
52
+ }
41
53
  const reqDigest = yield spo_1.spo.getRequestDigest(args.options.webUrl);
42
54
  const requestOptions = {
43
- url: `${args.options.webUrl}/_api/web/${(args.options.listTitle ? `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/` : '')}fields/CreateFieldAsXml`,
55
+ url: `${requestUrl}/fields/CreateFieldAsXml`,
44
56
  headers: {
45
57
  'X-RequestDigest': reqDigest.FormDigestValue,
46
58
  accept: 'application/json;odata=nometadata'
@@ -99,6 +111,8 @@ _SpoFieldAddCommand_instances = new WeakSet(), _SpoFieldAddCommand_initTelemetry
99
111
  this.telemetry.push((args) => {
100
112
  Object.assign(this.telemetryProperties, {
101
113
  listTitle: typeof args.options.listTitle !== 'undefined',
114
+ listId: typeof args.options.listId !== 'undefined',
115
+ listUrl: typeof args.options.listUrl !== 'undefined',
102
116
  options: typeof args.options.options !== 'undefined'
103
117
  });
104
118
  });
@@ -107,6 +121,10 @@ _SpoFieldAddCommand_instances = new WeakSet(), _SpoFieldAddCommand_initTelemetry
107
121
  option: '-u, --webUrl <webUrl>'
108
122
  }, {
109
123
  option: '-l, --listTitle [listTitle]'
124
+ }, {
125
+ option: '--listId [listId]'
126
+ }, {
127
+ option: '--listUrl [listUrl]'
110
128
  }, {
111
129
  option: '-x, --xml <xml>'
112
130
  }, {
@@ -118,6 +136,13 @@ _SpoFieldAddCommand_instances = new WeakSet(), _SpoFieldAddCommand_initTelemetry
118
136
  if (isValidSharePointUrl !== true) {
119
137
  return isValidSharePointUrl;
120
138
  }
139
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
140
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
141
+ return `Specify either list id or title or list url, but not multiple`;
142
+ }
143
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
144
+ return `${args.options.listId} in option listId is not a valid GUID`;
145
+ }
121
146
  if (args.options.options) {
122
147
  let optionsError = true;
123
148
  const options = ['DefaultValue', 'AddToDefaultContentType', 'AddToNoContentType', 'AddToAllContentTypes', 'AddFieldInternalNameHint', 'AddFieldToDefaultView', 'AddFieldCheckDisplayName'];
@@ -19,6 +19,7 @@ const config_1 = require("../../../../config");
19
19
  const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
21
  const spo_1 = require("../../../../utils/spo");
22
+ const urlUtil_1 = require("../../../../utils/urlUtil");
22
23
  const validation_1 = require("../../../../utils/validation");
23
24
  const SpoCommand_1 = require("../../../base/SpoCommand");
24
25
  const commands_1 = require("../../commands");
@@ -45,23 +46,27 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
45
46
  try {
46
47
  const reqDigest = yield spo_1.spo.getRequestDigest(args.options.webUrl);
47
48
  const requestDigest = reqDigest.FormDigestValue;
48
- let list = undefined;
49
- if (args.options.listId || args.options.listTitle) {
50
- const listQuery = args.options.listId ?
51
- `<Method Id="663" ParentId="7" Name="GetById"><Parameters><Parameter Type="Guid">${formatting_1.formatting.escapeXml(args.options.listId)}</Parameter></Parameters></Method>` :
52
- `<Method Id="663" ParentId="7" Name="GetByTitle"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.listTitle)}</Parameter></Parameters></Method>`;
49
+ let fieldsParentIdentity = '<Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />';
50
+ if (args.options.listId || args.options.listTitle || args.options.listUrl) {
51
+ let requestData = '';
52
+ if (args.options.listId) {
53
+ requestData = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="664" ObjectPathId="663" /><Query Id="665" ObjectPathId="663"><Query SelectAllProperties="false"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="663" ParentId="7" Name="GetById"><Parameters><Parameter Type="Guid">${formatting_1.formatting.escapeXml(args.options.listId)}</Parameter></Parameters></Method><Property Id="7" ParentId="5" Name="Lists" /><Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /></ObjectPaths></Request>`;
54
+ }
55
+ else if (args.options.listTitle) {
56
+ requestData = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="664" ObjectPathId="663" /><Query Id="665" ObjectPathId="663"><Query SelectAllProperties="false"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="663" ParentId="7" Name="GetByTitle"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.listTitle)}</Parameter></Parameters></Method><Property Id="7" ParentId="5" Name="Lists" /><Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /></ObjectPaths></Request>`;
57
+ }
58
+ else if (args.options.listUrl) {
59
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
60
+ requestData = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectPath Id="4" ObjectPathId="3" /><ObjectPath Id="6" ObjectPathId="5" /><Query Id="7" ObjectPathId="5"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><StaticProperty Id="1" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /><Property Id="3" ParentId="1" Name="Web" /><Method Id="5" ParentId="3" Name="GetList"><Parameters><Parameter Type="String">${listServerRelativeUrl}</Parameter></Parameters></Method></ObjectPaths></Request>`;
61
+ }
53
62
  const requestOptions = {
54
63
  url: `${args.options.webUrl}/_vti_bin/client.svc/ProcessQuery`,
55
64
  headers: {
56
65
  'X-RequestDigest': requestDigest
57
66
  },
58
- data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="664" ObjectPathId="663" /><Query Id="665" ObjectPathId="663"><Query SelectAllProperties="false"><Properties /></Query></Query></Actions><ObjectPaths>${listQuery}<Property Id="7" ParentId="5" Name="Lists" /><Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /></ObjectPaths></Request>`
67
+ data: requestData
59
68
  };
60
- list = yield request_1.default.post(requestOptions);
61
- }
62
- // by default retrieve the column from the site
63
- let fieldsParentIdentity = '<Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />';
64
- if (list) {
69
+ const list = yield request_1.default.post(requestOptions);
65
70
  const json = JSON.parse(list);
66
71
  const response = json[0];
67
72
  if (response.ErrorInfo) {
@@ -113,6 +118,7 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
113
118
  'webUrl',
114
119
  'listId',
115
120
  'listTitle',
121
+ 'listUrl',
116
122
  'id',
117
123
  'title',
118
124
  'updateExistingLists',
@@ -134,6 +140,7 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
134
140
  title: typeof args.options.title !== 'undefined',
135
141
  listId: typeof args.options.listId !== 'undefined',
136
142
  listTitle: typeof args.options.listTitle !== 'undefined',
143
+ listUrl: typeof args.options.listUrl !== 'undefined',
137
144
  updateExistingLists: !!args.options.updateExistingLists
138
145
  });
139
146
  });
@@ -144,6 +151,8 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
144
151
  option: '--listId [listId]'
145
152
  }, {
146
153
  option: '--listTitle [listTitle]'
154
+ }, {
155
+ option: '--listUrl [listUrl]'
147
156
  }, {
148
157
  option: '-i, --id [id]'
149
158
  }, {
@@ -157,8 +166,9 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
157
166
  if (isValidSharePointUrl !== true) {
158
167
  return isValidSharePointUrl;
159
168
  }
160
- if (args.options.listId && args.options.listTitle) {
161
- return `Specify listId or listTitle but not both`;
169
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
170
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
171
+ return `Specify either list id or title or list url, but not multiple`;
162
172
  }
163
173
  if (args.options.listId &&
164
174
  !validation_1.validation.isValidGuid(args.options.listId)) {
@@ -20,6 +20,7 @@ const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
21
  const validation_1 = require("../../../../utils/validation");
22
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const urlUtil_1 = require("../../../../utils/urlUtil");
23
24
  const commands_1 = require("../../commands");
24
25
  class SpoFolderRoleInheritanceBreakCommand extends SpoCommand_1.default {
25
26
  constructor() {
@@ -38,10 +39,19 @@ class SpoFolderRoleInheritanceBreakCommand extends SpoCommand_1.default {
38
39
  commandAction(logger, args) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
41
  const keepExistingPermissions = !args.options.clearExistingPermissions;
42
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl);
43
+ const roleFolderUrl = urlUtil_1.urlUtil.getWebRelativePath(args.options.webUrl, args.options.folderUrl);
44
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
41
45
  const breakFolderRoleInheritance = () => __awaiter(this, void 0, void 0, function* () {
42
46
  try {
47
+ if (roleFolderUrl.split('/').length === 2) {
48
+ requestUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}')`;
49
+ }
50
+ else {
51
+ requestUrl += `GetFolderByServerRelativeUrl('${encodeURIComponent(serverRelativeUrl)}')/ListItemAllFields`;
52
+ }
43
53
  const requestOptions = {
44
- url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(args.options.folderUrl)}')/ListItemAllFields/breakroleinheritance(${keepExistingPermissions})`,
54
+ url: `${requestUrl}/breakroleinheritance(${keepExistingPermissions})`,
45
55
  headers: {
46
56
  accept: 'application/json'
47
57
  },
@@ -16,9 +16,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
16
16
  var _SpoFolderRoleInheritanceResetCommand_instances, _SpoFolderRoleInheritanceResetCommand_initTelemetry, _SpoFolderRoleInheritanceResetCommand_initOptions, _SpoFolderRoleInheritanceResetCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const Cli_1 = require("../../../../cli/Cli");
19
+ const formatting_1 = require("../../../../utils/formatting");
19
20
  const request_1 = require("../../../../request");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const urlUtil_1 = require("../../../../utils/urlUtil");
22
24
  const commands_1 = require("../../commands");
23
25
  class SpoFolderRoleInheritanceResetCommand extends SpoCommand_1.default {
24
26
  constructor() {
@@ -36,10 +38,19 @@ class SpoFolderRoleInheritanceResetCommand extends SpoCommand_1.default {
36
38
  }
37
39
  commandAction(logger, args) {
38
40
  return __awaiter(this, void 0, void 0, function* () {
41
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl);
42
+ const roleFolderUrl = urlUtil_1.urlUtil.getWebRelativePath(args.options.webUrl, args.options.folderUrl);
43
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
39
44
  const resetFolderRoleInheritance = () => __awaiter(this, void 0, void 0, function* () {
40
45
  try {
46
+ if (roleFolderUrl.split('/').length === 2) {
47
+ requestUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}')`;
48
+ }
49
+ else {
50
+ requestUrl += `GetFolderByServerRelativeUrl('${encodeURIComponent(serverRelativeUrl)}')/ListItemAllFields`;
51
+ }
41
52
  const requestOptions = {
42
- url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${args.options.folderUrl}')/ListItemAllFields/resetroleinheritance`,
53
+ url: `${requestUrl}/resetroleinheritance`,
43
54
  headers: {
44
55
  accept: 'application/json;odata=nometadata'
45
56
  },
@@ -44,18 +44,24 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
44
44
  commandAction(logger, args) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
46
  try {
47
- const listIdArgument = args.options.listId || '';
48
- const listTitleArgument = args.options.listTitle || '';
49
- const listRestUrl = (args.options.listId ?
50
- `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(listIdArgument)}')`
51
- : `${args.options.webUrl}/_api/web/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(listTitleArgument)}')`);
47
+ let requestUrl = `${args.options.webUrl}/_api/web`;
48
+ if (args.options.listId) {
49
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
50
+ }
51
+ else if (args.options.listTitle) {
52
+ requestUrl += `/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
53
+ }
54
+ else if (args.options.listUrl) {
55
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
56
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
57
+ }
52
58
  let contentTypeName = '';
53
59
  let targetFolderServerRelativeUrl = '';
54
60
  if (this.verbose) {
55
- logger.logToStderr(`Getting content types for list...`);
61
+ logger.logToStderr(`Getting content types for list ${args.options.listId || args.options.listTitle || args.options.listUrl}...`);
56
62
  }
57
63
  let requestOptions = {
58
- url: `${listRestUrl}/contenttypes?$select=Name,Id`,
64
+ url: `${requestUrl}/contenttypes?$select=Name,Id`,
59
65
  headers: {
60
66
  'accept': 'application/json;odata=nometadata'
61
67
  },
@@ -90,7 +96,7 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
90
96
  logger.logToStderr('setting up folder lookup response ...');
91
97
  }
92
98
  requestOptions = {
93
- url: `${listRestUrl}/rootFolder`,
99
+ url: `${requestUrl}/rootFolder`,
94
100
  headers: {
95
101
  'accept': 'application/json;odata=nometadata'
96
102
  },
@@ -101,7 +107,7 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
101
107
  yield spo_1.spo.ensureFolder(args.options.webUrl, targetFolderServerRelativeUrl, logger, this.debug);
102
108
  }
103
109
  if (this.verbose) {
104
- logger.logToStderr(`Creating item in list ${args.options.listId || args.options.listTitle} in site ${args.options.webUrl}...`);
110
+ logger.logToStderr(`Creating item in list ${args.options.listId || args.options.listTitle || args.options.listUrl} in site ${args.options.webUrl}...`);
105
111
  }
106
112
  const requestBody = {
107
113
  formValues: this.mapRequestBody(args.options)
@@ -123,7 +129,7 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
123
129
  });
124
130
  }
125
131
  requestOptions = {
126
- url: `${listRestUrl}/AddValidateUpdateItemUsingPath()`,
132
+ url: `${requestUrl}/AddValidateUpdateItemUsingPath()`,
127
133
  headers: {
128
134
  'accept': 'application/json;odata=nometadata'
129
135
  },
@@ -142,10 +148,10 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
142
148
  logger.logToStderr(`Id returned by AddValidateUpdateItemUsingPath: ${idField}`);
143
149
  }
144
150
  if (idField.length === 0) {
145
- return Promise.reject(`Item didn't add successfully`);
151
+ throw `Item didn't add successfully`;
146
152
  }
147
153
  requestOptions = {
148
- url: `${listRestUrl}/items(${idField[0].FieldValue})`,
154
+ url: `${requestUrl}/items(${idField[0].FieldValue})`,
149
155
  headers: {
150
156
  'accept': 'application/json;odata=nometadata'
151
157
  },
@@ -164,6 +170,7 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
164
170
  const excludeOptions = [
165
171
  'listTitle',
166
172
  'listId',
173
+ 'listUrl',
167
174
  'webUrl',
168
175
  'contentType',
169
176
  'folder',
@@ -184,6 +191,7 @@ _SpoListItemAddCommand_instances = new WeakSet(), _SpoListItemAddCommand_initTel
184
191
  Object.assign(this.telemetryProperties, {
185
192
  listId: typeof args.options.listId !== 'undefined',
186
193
  listTitle: typeof args.options.listTitle !== 'undefined',
194
+ listUrl: typeof args.options.listUrl !== 'undefined',
187
195
  contentType: typeof args.options.contentType !== 'undefined',
188
196
  folder: typeof args.options.folder !== 'undefined'
189
197
  });
@@ -195,6 +203,8 @@ _SpoListItemAddCommand_instances = new WeakSet(), _SpoListItemAddCommand_initTel
195
203
  option: '-l, --listId [listId]'
196
204
  }, {
197
205
  option: '-t, --listTitle [listTitle]'
206
+ }, {
207
+ option: '--listUrl [listUrl]'
198
208
  }, {
199
209
  option: '-c, --contentType [contentType]'
200
210
  }, {
@@ -213,9 +223,9 @@ _SpoListItemAddCommand_instances = new WeakSet(), _SpoListItemAddCommand_initTel
213
223
  return true;
214
224
  }));
215
225
  }, _SpoListItemAddCommand_initTypes = function _SpoListItemAddCommand_initTypes() {
216
- this.types.string.push('webUrl', 'listId', 'listTitle', 'contentType', 'folder');
226
+ this.types.string.push('webUrl', 'listId', 'listTitle', 'listUrl', 'contentType', 'folder');
217
227
  }, _SpoListItemAddCommand_initOptionSets = function _SpoListItemAddCommand_initOptionSets() {
218
- this.optionSets.push(['listId', 'listTitle']);
228
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
219
229
  };
220
230
  module.exports = new SpoListItemAddCommand();
221
231
  //# sourceMappingURL=listitem-add.js.map
@@ -17,6 +17,7 @@ var _SpoListItemAttachmentListCommand_instances, _SpoListItemAttachmentListComma
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,13 +41,19 @@ class SpoListItemAttachmentListCommand extends SpoCommand_1.default {
40
41
  }
41
42
  commandAction(logger, args) {
42
43
  return __awaiter(this, void 0, void 0, function* () {
43
- const listIdArgument = args.options.listId || '';
44
- const listTitleArgument = args.options.listTitle || '';
45
- const listRestUrl = (args.options.listId ?
46
- `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(listIdArgument)}')`
47
- : `${args.options.webUrl}/_api/web/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(listTitleArgument)}')`);
44
+ let requestUrl = `${args.options.webUrl}/_api/web`;
45
+ if (args.options.listId) {
46
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
47
+ }
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)}')`;
54
+ }
48
55
  const requestOptions = {
49
- url: `${listRestUrl}/items(${args.options.itemId})?$select=AttachmentFiles&$expand=AttachmentFiles`,
56
+ url: `${requestUrl}/items(${args.options.itemId})?$select=AttachmentFiles&$expand=AttachmentFiles`,
50
57
  method: 'GET',
51
58
  headers: {
52
59
  'accept': 'application/json;odata=nometadata'
@@ -74,7 +81,8 @@ _SpoListItemAttachmentListCommand_instances = new WeakSet(), _SpoListItemAttachm
74
81
  this.telemetry.push((args) => {
75
82
  Object.assign(this.telemetryProperties, {
76
83
  listId: typeof args.options.listId !== 'undefined',
77
- listTitle: typeof args.options.listTitle !== 'undefined'
84
+ listTitle: typeof args.options.listTitle !== 'undefined',
85
+ listUrl: typeof args.options.listUrl !== 'undefined'
78
86
  });
79
87
  });
80
88
  }, _SpoListItemAttachmentListCommand_initOptions = function _SpoListItemAttachmentListCommand_initOptions() {
@@ -86,6 +94,8 @@ _SpoListItemAttachmentListCommand_instances = new WeakSet(), _SpoListItemAttachm
86
94
  option: '--listId [listId]'
87
95
  }, {
88
96
  option: '--listTitle [listTitle]'
97
+ }, {
98
+ option: '--listUrl [listUrl]'
89
99
  });
90
100
  }, _SpoListItemAttachmentListCommand_initValidators = function _SpoListItemAttachmentListCommand_initValidators() {
91
101
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -102,7 +112,7 @@ _SpoListItemAttachmentListCommand_instances = new WeakSet(), _SpoListItemAttachm
102
112
  return true;
103
113
  }));
104
114
  }, _SpoListItemAttachmentListCommand_initOptionSets = function _SpoListItemAttachmentListCommand_initOptionSets() {
105
- this.optionSets.push(['listId', 'listTitle']);
115
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
106
116
  };
107
117
  module.exports = new SpoListItemAttachmentListCommand();
108
118
  //# sourceMappingURL=listitem-attachment-list.js.map