@pnp/cli-microsoft365 5.9.0-beta.174dde9 → 5.9.0-beta.1f313f7

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 (132) hide show
  1. package/.eslintrc.js +4 -2
  2. package/dist/Command.js +16 -2
  3. package/dist/m365/aad/commands/app/app-add.js +37 -13
  4. package/dist/m365/commands/status.js +6 -1
  5. package/dist/m365/outlook/commands/mail/mail-send.js +55 -31
  6. package/dist/m365/planner/commands/bucket/bucket-get.js +1 -1
  7. package/dist/m365/pp/commands/Environment.js +3 -0
  8. package/dist/m365/pp/commands/card/card-get.js +110 -0
  9. package/dist/m365/pp/commands/environment/environment-get.js +75 -0
  10. package/dist/m365/pp/commands/gateway/gateway-get.js +70 -0
  11. package/dist/m365/pp/commands/solution/solution-get.js +117 -0
  12. package/dist/m365/pp/commands.js +4 -0
  13. package/dist/m365/spfx/commands/project/project-doctor.js +4 -1
  14. package/dist/m365/spfx/commands/project/project-externalize.js +4 -1
  15. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010001_YORC_version.js +2 -1
  16. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010002_YORC_isCreatingSolution.js +2 -1
  17. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010003_YORC_packageManager.js +2 -1
  18. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010004_YORC_componentType.js +2 -1
  19. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010005_YORC_environment.js +2 -1
  20. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010006_YORC_framework.js +3 -2
  21. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010007_YORC_isDomainIsolated.js +2 -1
  22. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010008_YORC_nodeVersion.js +2 -1
  23. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010009_YORC_sdkVersions_microsoft_graph_client.js +56 -0
  24. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010010_YORC_sdkVersions_teams_js.js +56 -0
  25. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.16.0-beta.1.js → upgrade-1.16.0-beta.2.js} +44 -28
  26. package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
  27. package/dist/m365/spfx/commands/spfx-doctor.js +3 -3
  28. package/dist/m365/spo/commands/contenttype/contenttype-add.js +82 -43
  29. package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +53 -21
  30. package/dist/m365/spo/commands/contenttype/contenttype-get.js +35 -14
  31. package/dist/m365/spo/commands/field/field-add.js +26 -1
  32. package/dist/m365/spo/commands/field/field-set.js +23 -13
  33. package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +168 -0
  34. package/dist/m365/spo/commands/list/list-contenttype-add.js +21 -18
  35. package/dist/m365/spo/commands/list/list-contenttype-default-set.js +59 -47
  36. package/dist/m365/spo/commands/list/list-contenttype-list.js +16 -8
  37. package/dist/m365/spo/commands/list/list-contenttype-remove.js +16 -8
  38. package/dist/m365/spo/commands/list/list-roleassignment-add.js +1 -1
  39. package/dist/m365/spo/commands/list/list-roleinheritance-break.js +14 -6
  40. package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +15 -7
  41. package/dist/m365/spo/commands/list/list-webhook-add.js +19 -11
  42. package/dist/m365/spo/commands/list/list-webhook-get.js +17 -10
  43. package/dist/m365/spo/commands/list/list-webhook-list.js +23 -24
  44. package/dist/m365/spo/commands/list/list-webhook-remove.js +19 -11
  45. package/dist/m365/spo/commands/list/list-webhook-set.js +18 -10
  46. package/dist/m365/spo/commands/listitem/listitem-add.js +24 -14
  47. package/dist/m365/spo/commands/listitem/listitem-attachment-list.js +18 -8
  48. package/dist/m365/spo/commands/listitem/listitem-get.js +18 -8
  49. package/dist/m365/spo/commands/listitem/listitem-isrecord.js +20 -10
  50. package/dist/m365/spo/commands/listitem/listitem-list.js +27 -11
  51. package/dist/m365/spo/commands/listitem/listitem-record-declare.js +19 -12
  52. package/dist/m365/spo/commands/listitem/listitem-record-undeclare.js +24 -21
  53. package/dist/m365/spo/commands/listitem/listitem-remove.js +19 -11
  54. package/dist/m365/spo/commands/listitem/listitem-roleassignment-add.js +239 -0
  55. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +13 -5
  56. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +14 -6
  57. package/dist/m365/spo/commands/listitem/listitem-set.js +52 -44
  58. package/dist/m365/spo/commands/web/web-roleinheritance-break.js +100 -0
  59. package/dist/m365/spo/commands.js +3 -0
  60. package/dist/m365/todo/commands/list/list-get.js +89 -0
  61. package/dist/m365/todo/commands/task/task-add.js +55 -3
  62. package/dist/m365/todo/commands/task/task-get.js +108 -0
  63. package/dist/m365/todo/commands/task/task-set.js +53 -1
  64. package/dist/m365/todo/commands.js +2 -0
  65. package/docs/docs/_clisettings.md +19 -0
  66. package/docs/docs/cmd/outlook/mail/mail-send.md +13 -0
  67. package/docs/docs/cmd/planner/bucket/bucket-add.md +29 -0
  68. package/docs/docs/cmd/planner/bucket/bucket-get.md +29 -0
  69. package/docs/docs/cmd/planner/bucket/bucket-list.md +30 -0
  70. package/docs/docs/cmd/planner/bucket/bucket-remove.md +4 -0
  71. package/docs/docs/cmd/planner/bucket/bucket-set.md +4 -0
  72. package/docs/docs/cmd/planner/plan/plan-add.md +123 -0
  73. package/docs/docs/cmd/planner/plan/plan-get.md +75 -0
  74. package/docs/docs/cmd/planner/plan/plan-list.md +45 -0
  75. package/docs/docs/cmd/planner/plan/plan-remove.md +4 -0
  76. package/docs/docs/cmd/pp/card/card-get.md +51 -0
  77. package/docs/docs/cmd/pp/environment/environment-get.md +38 -0
  78. package/docs/docs/cmd/pp/gateway/gateway-get.md +24 -0
  79. package/docs/docs/cmd/pp/solution/solution-get.md +51 -0
  80. package/docs/docs/cmd/spfx/project/project-rename.md +1 -14
  81. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  82. package/docs/docs/cmd/spo/contenttype/contenttype-add.md +20 -2
  83. package/docs/docs/cmd/spo/contenttype/contenttype-field-remove.md +22 -4
  84. package/docs/docs/cmd/spo/contenttype/contenttype-get.md +21 -3
  85. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-get.md +2 -2
  86. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.md +2 -2
  87. package/docs/docs/cmd/spo/field/field-add.md +20 -2
  88. package/docs/docs/cmd/spo/field/field-set.md +11 -2
  89. package/docs/docs/cmd/spo/folder/folder-roleassignment-remove.md +57 -0
  90. package/docs/docs/cmd/spo/list/list-contenttype-add.md +16 -7
  91. package/docs/docs/cmd/spo/list/list-contenttype-default-set.md +16 -7
  92. package/docs/docs/cmd/spo/list/list-contenttype-list.md +15 -6
  93. package/docs/docs/cmd/spo/list/list-contenttype-remove.md +17 -8
  94. package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +11 -8
  95. package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +14 -5
  96. package/docs/docs/cmd/spo/list/list-webhook-add.md +15 -16
  97. package/docs/docs/cmd/spo/list/list-webhook-get.md +16 -7
  98. package/docs/docs/cmd/spo/list/list-webhook-list.md +16 -7
  99. package/docs/docs/cmd/spo/list/list-webhook-remove.md +12 -10
  100. package/docs/docs/cmd/spo/list/list-webhook-set.md +14 -12
  101. package/docs/docs/cmd/spo/listitem/listitem-add.md +11 -2
  102. package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +11 -2
  103. package/docs/docs/cmd/spo/listitem/listitem-get.md +11 -2
  104. package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +12 -2
  105. package/docs/docs/cmd/spo/listitem/listitem-list.md +12 -3
  106. package/docs/docs/cmd/spo/listitem/listitem-record-declare.md +7 -4
  107. package/docs/docs/cmd/spo/listitem/listitem-record-undeclare.md +11 -2
  108. package/docs/docs/cmd/spo/listitem/listitem-remove.md +11 -2
  109. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.md +81 -0
  110. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-break.md +7 -4
  111. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-reset.md +11 -2
  112. package/docs/docs/cmd/spo/listitem/listitem-set.md +7 -4
  113. package/docs/docs/cmd/spo/web/web-roleinheritance-break.md +44 -0
  114. package/docs/docs/cmd/tenant/id/id-get.md +20 -0
  115. package/docs/docs/cmd/tenant/report/report-activeusercounts.md +35 -0
  116. package/docs/docs/cmd/tenant/report/report-activeuserdetail.md +49 -0
  117. package/docs/docs/cmd/tenant/report/report-office365activationcounts.md +32 -0
  118. package/docs/docs/cmd/tenant/report/report-office365activationsusercounts.md +30 -0
  119. package/docs/docs/cmd/tenant/report/report-office365activationsuserdetail.md +36 -0
  120. package/docs/docs/cmd/tenant/report/report-servicesusercounts.md +41 -0
  121. package/docs/docs/cmd/tenant/security/security-alerts-list.md +105 -0
  122. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +87 -0
  123. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +91 -0
  124. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +62 -0
  125. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +51 -0
  126. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +64 -0
  127. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +52 -0
  128. package/docs/docs/cmd/todo/list/list-get.md +61 -0
  129. package/docs/docs/cmd/todo/task/task-add.md +32 -5
  130. package/docs/docs/cmd/todo/task/task-get.md +75 -0
  131. package/docs/docs/cmd/todo/task/task-set.md +29 -2
  132. package/package.json +12 -4
@@ -20,6 +20,7 @@ const config_1 = require("../../../../config");
20
20
  const request_1 = require("../../../../request");
21
21
  const formatting_1 = require("../../../../utils/formatting");
22
22
  const spo_1 = require("../../../../utils/spo");
23
+ const urlUtil_1 = require("../../../../utils/urlUtil");
23
24
  const validation_1 = require("../../../../utils/validation");
24
25
  const SpoCommand_1 = require("../../../base/SpoCommand");
25
26
  const commands_1 = require("../../commands");
@@ -42,7 +43,13 @@ class SpoContentTypeAddCommand extends SpoCommand_1.default {
42
43
  commandAction(logger, args) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
45
  try {
45
- const parentInfo = yield this.getParentInfo(args.options.listTitle, args.options.webUrl, logger);
46
+ let parentInfo = '';
47
+ if (!args.options.listId && !args.options.listTitle && !args.options.listUrl) {
48
+ parentInfo = '<Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />';
49
+ }
50
+ else {
51
+ parentInfo = yield this.getParentInfo(args.options, logger);
52
+ }
46
53
  if (this.verbose) {
47
54
  logger.logToStderr(`Retrieving request digest...`);
48
55
  }
@@ -69,6 +76,8 @@ class SpoContentTypeAddCommand extends SpoCommand_1.default {
69
76
  const options = {
70
77
  webUrl: args.options.webUrl,
71
78
  listTitle: args.options.listTitle,
79
+ listUrl: args.options.listUrl,
80
+ listId: args.options.listId,
72
81
  id: args.options.id,
73
82
  output: 'json',
74
83
  debug: this.debug,
@@ -90,60 +99,79 @@ class SpoContentTypeAddCommand extends SpoCommand_1.default {
90
99
  }
91
100
  });
92
101
  }
93
- getParentInfo(listTitle, webUrl, logger) {
94
- return new Promise((resolve, reject) => {
95
- if (!listTitle) {
96
- resolve('<Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />');
97
- return;
102
+ getParentInfo(options, logger) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ const siteId = yield this.getSiteId(options.webUrl, logger);
105
+ const webId = yield this.getWebId(options.webUrl, logger);
106
+ const listId = yield this.getListId(options, logger);
107
+ return `<Identity Id="5" Name="1a48869e-c092-0000-1f61-81ec89809537|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:web:${webId}:list:${listId}" />`;
108
+ });
109
+ }
110
+ getSiteId(webUrl, logger) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ if (this.verbose) {
113
+ logger.logToStderr(`Retrieving site collection id...`);
98
114
  }
99
- let siteId = '';
100
- let webId = '';
101
- (() => {
102
- if (this.verbose) {
103
- logger.logToStderr(`Retrieving site collection id...`);
104
- }
105
- const requestOptions = {
106
- url: `${webUrl}/_api/site?$select=Id`,
107
- headers: {
108
- accept: 'application/json;odata=nometadata'
109
- },
110
- responseType: 'json'
111
- };
112
- return request_1.default.get(requestOptions);
113
- })()
114
- .then((res) => {
115
- siteId = res.Id;
116
- if (this.verbose) {
117
- logger.logToStderr(`Retrieving site id...`);
118
- }
115
+ const requestOptions = {
116
+ url: `${webUrl}/_api/site?$select=Id`,
117
+ headers: {
118
+ accept: 'application/json;odata=nometadata'
119
+ },
120
+ responseType: 'json'
121
+ };
122
+ const siteResponse = yield request_1.default.get(requestOptions);
123
+ return siteResponse.Id;
124
+ });
125
+ }
126
+ getWebId(webUrl, logger) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ if (this.verbose) {
129
+ logger.logToStderr(`Retrieving web id...`);
130
+ }
131
+ const requestOptions = {
132
+ url: `${webUrl}/_api/web?$select=Id`,
133
+ headers: {
134
+ accept: 'application/json;odata=nometadata'
135
+ },
136
+ responseType: 'json'
137
+ };
138
+ const webResponse = yield request_1.default.get(requestOptions);
139
+ return webResponse.Id;
140
+ });
141
+ }
142
+ getListId(options, logger) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ if (this.verbose) {
145
+ logger.logToStderr(`Retrieving list id...`);
146
+ }
147
+ let listId = '';
148
+ if (options.listId) {
149
+ return options.listId;
150
+ }
151
+ else if (options.listTitle) {
119
152
  const requestOptions = {
120
- url: `${webUrl}/_api/web?$select=Id`,
153
+ url: `${options.webUrl}/_api/web/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(options.listTitle)}')?$select=Id`,
121
154
  headers: {
122
155
  accept: 'application/json;odata=nometadata'
123
156
  },
124
157
  responseType: 'json'
125
158
  };
126
- return request_1.default.get(requestOptions);
127
- })
128
- .then((res) => {
129
- webId = res.Id;
130
- if (this.verbose) {
131
- logger.logToStderr(`Retrieving list id...`);
132
- }
159
+ const listResponse = yield request_1.default.get(requestOptions);
160
+ listId = listResponse.Id;
161
+ }
162
+ else if (options.listUrl) {
163
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
133
164
  const requestOptions = {
134
- url: `${webUrl}/_api/web/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(listTitle)}')?$select=Id`,
165
+ url: `${options.webUrl}/_api/web/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')?$select=Id`,
135
166
  headers: {
136
167
  accept: 'application/json;odata=nometadata'
137
168
  },
138
169
  responseType: 'json'
139
170
  };
140
- return request_1.default.get(requestOptions);
141
- })
142
- .then((res) => {
143
- resolve(`<Identity Id="5" Name="1a48869e-c092-0000-1f61-81ec89809537|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:web:${webId}:list:${res.Id}" />`);
144
- }, (error) => {
145
- reject(error);
146
- });
171
+ const listResponse = yield request_1.default.get(requestOptions);
172
+ listId = listResponse.Id;
173
+ }
174
+ return listId;
147
175
  });
148
176
  }
149
177
  }
@@ -160,6 +188,10 @@ _SpoContentTypeAddCommand_instances = new WeakSet(), _SpoContentTypeAddCommand_i
160
188
  option: '-u, --webUrl <webUrl>'
161
189
  }, {
162
190
  option: '-l, --listTitle [listTitle]'
191
+ }, {
192
+ option: '--listId [listId]'
193
+ }, {
194
+ option: '--listUrl [listUrl]'
163
195
  }, {
164
196
  option: '-i, --id <id>'
165
197
  }, {
@@ -170,7 +202,14 @@ _SpoContentTypeAddCommand_instances = new WeakSet(), _SpoContentTypeAddCommand_i
170
202
  option: '-g, --group [group]'
171
203
  });
172
204
  }, _SpoContentTypeAddCommand_initValidators = function _SpoContentTypeAddCommand_initValidators() {
173
- this.validators.push((args) => __awaiter(this, void 0, void 0, function* () { return validation_1.validation.isValidSharePointUrl(args.options.webUrl); }));
205
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
206
+ if (args.options.listId) {
207
+ if (!validation_1.validation.isValidGuid(args.options.listId)) {
208
+ return `${args.options.listId} is not a valid GUID`;
209
+ }
210
+ }
211
+ return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
212
+ }));
174
213
  }, _SpoContentTypeAddCommand_initTypes = function _SpoContentTypeAddCommand_initTypes() {
175
214
  this.types.string.push('id', 'i');
176
215
  };
@@ -19,6 +19,7 @@ const Cli_1 = require("../../../../cli/Cli");
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");
@@ -72,30 +73,25 @@ class SpoContentTypeFieldRemoveCommand extends SpoCommand_1.default {
72
73
  logger.logToStderr(`WebId: ${webId}`);
73
74
  }
74
75
  let listId = undefined;
75
- // If ListTitle is provided
76
- if (args.options.listTitle) {
77
- // Request for the ListId
78
- const requestOptions = {
79
- url: `${args.options.webUrl}/_api/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')?$select=Id`,
80
- headers: {
81
- accept: 'application/json;odata=nometadata'
82
- },
83
- responseType: 'json'
84
- };
85
- const list = yield request_1.default.get(requestOptions);
86
- listId = list.Id;
87
- if (this.debug) {
88
- logger.logToStderr(`ListId: ${listId}`);
89
- }
76
+ if (args.options.listId) {
77
+ listId = args.options.listId;
78
+ }
79
+ else if (args.options.listTitle) {
80
+ listId = yield this.getListIdFromListTitle(args.options.webUrl, args.options.listTitle);
81
+ }
82
+ else if (args.options.listUrl) {
83
+ listId = yield this.getListIdFromListUrl(args.options.webUrl, args.options.listUrl);
84
+ }
85
+ if (this.debug) {
86
+ logger.logToStderr(`ListId: ${listId}`);
90
87
  }
91
88
  const reqDigest = yield spo_1.spo.getRequestDigest(args.options.webUrl);
92
89
  const requestDigest = reqDigest.FormDigestValue;
93
- const updateChildContentTypes = args.options.listTitle ? false : args.options.updateChildContentTypes === true;
90
+ const updateChildContentTypes = args.options.listTitle || args.options.listId || args.options.listUrl ? false : args.options.updateChildContentTypes === true;
94
91
  if (this.debug) {
95
- const additionalLog = args.options.listTitle ? `; ListTitle='${args.options.listTitle}'` : ` ; UpdateChildContentTypes='${updateChildContentTypes}`;
92
+ const additionalLog = args.options.listTitle ? `; ListTitle='${args.options.listTitle}'` : args.options.listId ? `; ListId='${args.options.listId}'` : args.options.listUrl ? `; ListUrl='${args.options.listUrl}'` : ` ; UpdateChildContentTypes='${updateChildContentTypes}`;
96
93
  logger.logToStderr(`Remove FieldLink from ContentType. FieldLinkId='${args.options.fieldLinkId}' ; ContentTypeId='${args.options.contentTypeId}' ${additionalLog}`);
97
94
  logger.logToStderr(`Execute ProcessQuery.`);
98
- logger.logToStderr('');
99
95
  }
100
96
  let requestBody = '';
101
97
  if (listId) {
@@ -138,13 +134,42 @@ class SpoContentTypeFieldRemoveCommand extends SpoCommand_1.default {
138
134
  }
139
135
  });
140
136
  }
137
+ getListIdFromListTitle(webUrl, listTitle) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const requestOptions = {
140
+ url: `${webUrl}/_api/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(listTitle)}')?$select=Id`,
141
+ headers: {
142
+ accept: 'application/json;odata=nometadata'
143
+ },
144
+ responseType: 'json'
145
+ };
146
+ const list = yield request_1.default.get(requestOptions);
147
+ return list.Id;
148
+ });
149
+ }
150
+ getListIdFromListUrl(webUrl, listUrl) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(webUrl, listUrl);
153
+ const requestOptions = {
154
+ url: `${webUrl}/_api/web/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')?$select=Id`,
155
+ headers: {
156
+ accept: 'application/json;odata=nometadata'
157
+ },
158
+ responseType: 'json'
159
+ };
160
+ const list = yield request_1.default.get(requestOptions);
161
+ return list.Id;
162
+ });
163
+ }
141
164
  }
142
165
  _SpoContentTypeFieldRemoveCommand_instances = new WeakSet(), _SpoContentTypeFieldRemoveCommand_initTelemetry = function _SpoContentTypeFieldRemoveCommand_initTelemetry() {
143
166
  this.telemetry.push((args) => {
144
167
  Object.assign(this.telemetryProperties, {
145
- listTitle: (!(!args.options.listTitle)).toString(),
146
- updateChildContentTypes: (!(!args.options.updateChildContentTypes)).toString(),
147
- confirm: (!(!args.options.confirm)).toString()
168
+ listTitle: typeof args.options.listTitle !== 'undefined',
169
+ listId: typeof args.options.listId !== 'undefined',
170
+ listUrl: typeof args.options.listUrl !== 'undefined',
171
+ updateChildContentTypes: !!args.options.updateChildContentTypes,
172
+ confirm: !!args.options.confirm
148
173
  });
149
174
  });
150
175
  }, _SpoContentTypeFieldRemoveCommand_initOptions = function _SpoContentTypeFieldRemoveCommand_initOptions() {
@@ -152,6 +177,10 @@ _SpoContentTypeFieldRemoveCommand_instances = new WeakSet(), _SpoContentTypeFiel
152
177
  option: '-u, --webUrl <webUrl>'
153
178
  }, {
154
179
  option: '-l, --listTitle [listTitle]'
180
+ }, {
181
+ option: '--listId [listId]'
182
+ }, {
183
+ option: '--listUrl [listUrl]'
155
184
  }, {
156
185
  option: '-i, --contentTypeId <contentTypeId>'
157
186
  }, {
@@ -166,6 +195,9 @@ _SpoContentTypeFieldRemoveCommand_instances = new WeakSet(), _SpoContentTypeFiel
166
195
  if (!validation_1.validation.isValidGuid(args.options.fieldLinkId)) {
167
196
  return `${args.options.fieldLinkId} is not a valid GUID`;
168
197
  }
198
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
199
+ return `${args.options.listId} is not a valid GUID`;
200
+ }
169
201
  return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
170
202
  }));
171
203
  }, _SpoContentTypeFieldRemoveCommand_initTypes = function _SpoContentTypeFieldRemoveCommand_initTypes() {
@@ -17,6 +17,7 @@ var _SpoContentTypeGetCommand_instances, _SpoContentTypeGetCommand_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,21 +39,32 @@ class SpoContentTypeGetCommand extends SpoCommand_1.default {
38
39
  }
39
40
  commandAction(logger, args) {
40
41
  return __awaiter(this, void 0, void 0, function* () {
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
+ }
53
+ requestUrl += "/contenttypes";
54
+ if (args.options.id) {
55
+ requestUrl += `('${encodeURIComponent(args.options.id)}')`;
56
+ }
57
+ else if (args.options.name) {
58
+ requestUrl += `?$filter=Name eq '${encodeURIComponent(args.options.name)}'`;
59
+ }
60
+ const requestOptions = {
61
+ url: requestUrl,
62
+ headers: {
63
+ accept: 'application/json;odata=nometadata'
64
+ },
65
+ responseType: 'json'
66
+ };
41
67
  try {
42
- let requestUrl = `${args.options.webUrl}/_api/web/${(args.options.listTitle ? `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/` : '')}contenttypes`;
43
- if (args.options.id) {
44
- requestUrl += `('${encodeURIComponent(args.options.id)}')`;
45
- }
46
- else if (args.options.name) {
47
- requestUrl += `?$filter=Name eq '${encodeURIComponent(args.options.name)}'`;
48
- }
49
- const requestOptions = {
50
- url: requestUrl,
51
- headers: {
52
- accept: 'application/json;odata=nometadata'
53
- },
54
- responseType: 'json'
55
- };
56
68
  let res = yield request_1.default.get(requestOptions);
57
69
  let errorMessage = '';
58
70
  if (args.options.name) {
@@ -80,7 +92,9 @@ class SpoContentTypeGetCommand extends SpoCommand_1.default {
80
92
  _SpoContentTypeGetCommand_instances = new WeakSet(), _SpoContentTypeGetCommand_initTelemetry = function _SpoContentTypeGetCommand_initTelemetry() {
81
93
  this.telemetry.push((args) => {
82
94
  Object.assign(this.telemetryProperties, {
95
+ listId: typeof args.options.listId !== 'undefined',
83
96
  listTitle: typeof args.options.listTitle !== 'undefined',
97
+ listUrl: typeof args.options.listUrl !== 'undefined',
84
98
  id: typeof args.options.id !== 'undefined',
85
99
  name: typeof args.options.name !== 'undefined'
86
100
  });
@@ -90,6 +104,10 @@ _SpoContentTypeGetCommand_instances = new WeakSet(), _SpoContentTypeGetCommand_i
90
104
  option: '-u, --webUrl <webUrl>'
91
105
  }, {
92
106
  option: '-l, --listTitle [listTitle]'
107
+ }, {
108
+ option: '--listId [listId]'
109
+ }, {
110
+ option: '--listUrl [listUrl]'
93
111
  }, {
94
112
  option: '-i, --id [id]'
95
113
  }, {
@@ -101,6 +119,9 @@ _SpoContentTypeGetCommand_instances = new WeakSet(), _SpoContentTypeGetCommand_i
101
119
  if (isValidSharePointUrl !== true) {
102
120
  return isValidSharePointUrl;
103
121
  }
122
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
123
+ return `${args.options.listId} is not a valid GUID`;
124
+ }
104
125
  return true;
105
126
  }));
106
127
  }, _SpoContentTypeGetCommand_initTypes = function _SpoContentTypeGetCommand_initTypes() {
@@ -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");
@@ -48,23 +49,27 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
48
49
  try {
49
50
  const reqDigest = yield spo_1.spo.getRequestDigest(args.options.webUrl);
50
51
  const requestDigest = reqDigest.FormDigestValue;
51
- let list = undefined;
52
- if (args.options.listId || args.options.listTitle) {
53
- const listQuery = args.options.listId ?
54
- `<Method Id="663" ParentId="7" Name="GetById"><Parameters><Parameter Type="Guid">${formatting_1.formatting.escapeXml(args.options.listId)}</Parameter></Parameters></Method>` :
55
- `<Method Id="663" ParentId="7" Name="GetByTitle"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.listTitle)}</Parameter></Parameters></Method>`;
52
+ let fieldsParentIdentity = '<Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />';
53
+ if (args.options.listId || args.options.listTitle || args.options.listUrl) {
54
+ let requestData = '';
55
+ if (args.options.listId) {
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="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>`;
57
+ }
58
+ else if (args.options.listTitle) {
59
+ 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>`;
60
+ }
61
+ else if (args.options.listUrl) {
62
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
63
+ 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>`;
64
+ }
56
65
  const requestOptions = {
57
66
  url: `${args.options.webUrl}/_vti_bin/client.svc/ProcessQuery`,
58
67
  headers: {
59
68
  'X-RequestDigest': requestDigest
60
69
  },
61
- 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>`
70
+ data: requestData
62
71
  };
63
- list = yield request_1.default.post(requestOptions);
64
- }
65
- // by default retrieve the column from the site
66
- let fieldsParentIdentity = '<Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />';
67
- if (list) {
72
+ const list = yield request_1.default.post(requestOptions);
68
73
  const json = JSON.parse(list);
69
74
  const response = json[0];
70
75
  if (response.ErrorInfo) {
@@ -116,6 +121,7 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
116
121
  'webUrl',
117
122
  'listId',
118
123
  'listTitle',
124
+ 'listUrl',
119
125
  'id',
120
126
  'name',
121
127
  'title',
@@ -139,6 +145,7 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
139
145
  name: typeof args.options.name !== 'undefined',
140
146
  listId: typeof args.options.listId !== 'undefined',
141
147
  listTitle: typeof args.options.listTitle !== 'undefined',
148
+ listUrl: typeof args.options.listUrl !== 'undefined',
142
149
  updateExistingLists: !!args.options.updateExistingLists
143
150
  });
144
151
  });
@@ -149,6 +156,8 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
149
156
  option: '--listId [listId]'
150
157
  }, {
151
158
  option: '--listTitle [listTitle]'
159
+ }, {
160
+ option: '--listUrl [listUrl]'
152
161
  }, {
153
162
  option: '-i, --id [id]'
154
163
  }, {
@@ -164,8 +173,9 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
164
173
  if (isValidSharePointUrl !== true) {
165
174
  return isValidSharePointUrl;
166
175
  }
167
- if (args.options.listId && args.options.listTitle) {
168
- return `Specify listId or listTitle but not both`;
176
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
177
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
178
+ return `Specify either list id or title or list url, but not multiple`;
169
179
  }
170
180
  if (args.options.listId &&
171
181
  !validation_1.validation.isValidGuid(args.options.listId)) {