@pnp/cli-microsoft365 6.6.0-beta.f944a05 → 6.7.0-beta.87c47df
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.
- package/Dockerfile +1 -0
- package/dist/m365/spo/commands/listitem/ListItemFieldValueResult.js +3 -0
- package/dist/m365/spo/commands/listitem/listitem-add.js +6 -5
- package/dist/m365/spo/commands/listitem/listitem-batch-add.js +18 -1
- package/dist/m365/spo/commands/listitem/listitem-set.js +5 -6
- package/dist/utils/fsUtil.js +1 -1
- package/docs/docs/cmd/spo/listitem/listitem-add.md +12 -1
- package/docs/docs/cmd/spo/listitem/listitem-batch-add.md +12 -9
- package/docs/docs/cmd/spo/listitem/listitem-set.md +12 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/Dockerfile
CHANGED
|
@@ -43,6 +43,7 @@ RUN bash -c 'echo "export PATH=$PATH:/home/cli-microsoft365/.npm-global/bin:/hom
|
|
|
43
43
|
&& bash -c 'echo "export CLIMICROSOFT365_ENV=\"docker\"" >> ~/.bash_profile' \
|
|
44
44
|
&& bash -c 'npm i -g @pnp/cli-microsoft365@${CLI_VERSION} --production --quiet --no-progress' \
|
|
45
45
|
&& bash -c 'echo "source /etc/profile.d/bash_completion.sh" >> ~/.bash_profile' \
|
|
46
|
+
&& bash -c 'echo ". .bashrc" >> ~/.bash_profile' \
|
|
46
47
|
&& bash -c 'npm cache clean --force' \
|
|
47
48
|
&& bash -c 'm365 cli completion sh setup' \
|
|
48
49
|
&& pwsh -c 'm365 cli completion pwsh setup --profile $profile'
|
|
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
15
15
|
};
|
|
16
16
|
var _SpoListItemAddCommand_instances, _SpoListItemAddCommand_initTelemetry, _SpoListItemAddCommand_initOptions, _SpoListItemAddCommand_initValidators, _SpoListItemAddCommand_initTypes, _SpoListItemAddCommand_initOptionSets;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const os = require("os");
|
|
18
19
|
const request_1 = require("../../../../request");
|
|
19
20
|
const formatting_1 = require("../../../../utils/formatting");
|
|
20
21
|
const spo_1 = require("../../../../utils/spo");
|
|
@@ -139,16 +140,16 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
|
|
|
139
140
|
const response = yield request_1.default.post(requestOptions);
|
|
140
141
|
// Response is from /AddValidateUpdateItemUsingPath POST call, perform get on added item to get all field values
|
|
141
142
|
const fieldValues = response.value;
|
|
143
|
+
if (fieldValues.some(f => f.HasException)) {
|
|
144
|
+
throw `Creating the item failed with the following errors: ${os.EOL}${fieldValues.filter(f => f.HasException).map(f => { return `- ${f.FieldName} - ${f.ErrorMessage}`; }).join(os.EOL)}`;
|
|
145
|
+
}
|
|
142
146
|
const idField = fieldValues.filter((thisField) => {
|
|
143
147
|
return (thisField.FieldName === "Id");
|
|
144
148
|
});
|
|
145
149
|
if (this.debug) {
|
|
146
|
-
logger.logToStderr(`
|
|
150
|
+
logger.logToStderr(`Field values returned:`);
|
|
147
151
|
logger.logToStderr(fieldValues);
|
|
148
|
-
logger.logToStderr(`Id returned by AddValidateUpdateItemUsingPath: ${idField}`);
|
|
149
|
-
}
|
|
150
|
-
if (idField.length === 0) {
|
|
151
|
-
throw `Item didn't add successfully`;
|
|
152
|
+
logger.logToStderr(`Id returned by AddValidateUpdateItemUsingPath: ${idField[0].FieldValue}`);
|
|
152
153
|
}
|
|
153
154
|
requestOptions = {
|
|
154
155
|
url: `${requestUrl}/items(${idField[0].FieldValue})`,
|
|
@@ -23,6 +23,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
23
23
|
var _SpoListItemBatchAddCommand_instances, _SpoListItemBatchAddCommand_initTelemetry, _SpoListItemBatchAddCommand_initOptions, _SpoListItemBatchAddCommand_initValidators, _SpoListItemBatchAddCommand_initTypes, _SpoListItemBatchAddCommand_initOptionSets;
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
const fs = require("fs");
|
|
26
|
+
const os = require("os");
|
|
26
27
|
const request_1 = require("../../../../request");
|
|
27
28
|
const uuid_1 = require("uuid");
|
|
28
29
|
const formatting_1 = require("../../../../utils/formatting");
|
|
@@ -116,7 +117,11 @@ class SpoListItemBatchAddCommand extends SpoCommand_1.default {
|
|
|
116
117
|
},
|
|
117
118
|
data: requestBody.join('')
|
|
118
119
|
};
|
|
119
|
-
yield request_1.default.post(requestOptions);
|
|
120
|
+
const response = yield request_1.default.post(requestOptions);
|
|
121
|
+
const parsedResponse = this.parseBatchResponseBody(response);
|
|
122
|
+
if (parsedResponse.some(r => r.HasException)) {
|
|
123
|
+
throw `Creating some items failed with the following errors: ${os.EOL}${parsedResponse.filter(f => f.HasException).map(f => { return `- Line ${f.csvLineNumber}: ${f.FieldName} - ${f.ErrorMessage}`; }).join(os.EOL)}`;
|
|
124
|
+
}
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
127
|
parseBatchRequestBody(items, batchId, requestUrl) {
|
|
@@ -142,6 +147,18 @@ class SpoListItemBatchAddCommand extends SpoCommand_1.default {
|
|
|
142
147
|
batchBody.push(`--batch_${batchId}--\n`);
|
|
143
148
|
return batchBody;
|
|
144
149
|
}
|
|
150
|
+
parseBatchResponseBody(response) {
|
|
151
|
+
const batchResults = [];
|
|
152
|
+
response.split('\r\n')
|
|
153
|
+
.filter((line) => line.startsWith('{'))
|
|
154
|
+
.forEach((line, index) => {
|
|
155
|
+
const parsedResponse = JSON.parse(line);
|
|
156
|
+
parsedResponse.value.forEach((fieldValueResult) => {
|
|
157
|
+
batchResults.push(Object.assign({ csvLineNumber: (index + 2) }, fieldValueResult));
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
return batchResults;
|
|
161
|
+
}
|
|
145
162
|
getSingleItemRequestBody(row) {
|
|
146
163
|
const requestBody = [];
|
|
147
164
|
Object.keys(row).forEach(key => {
|
|
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
15
15
|
};
|
|
16
16
|
var _SpoListItemSetCommand_instances, _SpoListItemSetCommand_initTelemetry, _SpoListItemSetCommand_initOptions, _SpoListItemSetCommand_initValidators, _SpoListItemSetCommand_initTypes, _SpoListItemSetCommand_initOptionSets;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const os = require("os");
|
|
18
19
|
const config_1 = require("../../../../config");
|
|
19
20
|
const request_1 = require("../../../../request");
|
|
20
21
|
const formatting_1 = require("../../../../utils/formatting");
|
|
@@ -185,13 +186,11 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
|
|
|
185
186
|
}
|
|
186
187
|
else {
|
|
187
188
|
// Response is from /ValidateUpdateListItem POST call, perform get on updated item to get all field values
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
throw `
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
itemId = returnedData[0].ItemId;
|
|
189
|
+
const fieldValues = response.value;
|
|
190
|
+
if (fieldValues.some(f => f.HasException)) {
|
|
191
|
+
throw `Updating the items has failed with the following errors: ${os.EOL}${fieldValues.filter(f => f.HasException).map(f => { return `- ${f.FieldName} - ${f.ErrorMessage}`; }).join(os.EOL)}`;
|
|
194
192
|
}
|
|
193
|
+
itemId = fieldValues[0].ItemId;
|
|
195
194
|
}
|
|
196
195
|
const requestOptionsItems = {
|
|
197
196
|
url: `${requestUrl}/items(${itemId})`,
|
package/dist/utils/fsUtil.js
CHANGED
|
@@ -42,7 +42,7 @@ const addFileCommands = {
|
|
|
42
42
|
addFileCommand: 'cat > [FILEPATH] << EOF [FILECONTENT]EOF'
|
|
43
43
|
},
|
|
44
44
|
powershell: {
|
|
45
|
-
addFileCommand: `@
|
|
45
|
+
addFileCommand: `@'[FILECONTENT]'@ | Out-File -FilePath [FILEPATH]`
|
|
46
46
|
},
|
|
47
47
|
cmd: {
|
|
48
48
|
addFileCommand: `echo [FILECONTENT] > [FILEPATH]`
|
|
@@ -30,6 +30,11 @@ m365 spo listitem add [options]
|
|
|
30
30
|
|
|
31
31
|
--8<-- "docs/cmd/_global.md"
|
|
32
32
|
|
|
33
|
+
## Remarks
|
|
34
|
+
|
|
35
|
+
!!! warning "When using DateTime fields"
|
|
36
|
+
When creating a list item with a DateTime field, use the timezone and the format that the site expects, based on its regional settings. Alternatively, a format which works on all regions is the following: `yyyy-MM-dd HH:mm:ss`. However, you should use the local timezone in all situations. UTC date/time or ISO 8601 formatted date/time is not supported.
|
|
37
|
+
|
|
33
38
|
## Examples
|
|
34
39
|
|
|
35
40
|
Add an item with Title _Demo Item_ and content type name _Item_ to list with title _Demo List_ in site _https://contoso.sharepoint.com/sites/project-x_
|
|
@@ -77,7 +82,13 @@ m365 spo listitem add --contentType Item --listUrl /sites/project-x/Documents --
|
|
|
77
82
|
Add an item with a specific Title and multi-choice value
|
|
78
83
|
|
|
79
84
|
```sh
|
|
80
|
-
m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo
|
|
85
|
+
m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo multi-choice Field" --MultiChoiceField "Choice 1;#Choice 2;#Choice 3"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Add an item with a specific Title and DateTime value
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo DateTime Field" --SomeDateTimeField "2023-01-16 15:30:00"
|
|
81
92
|
```
|
|
82
93
|
|
|
83
94
|
## Response
|
|
@@ -27,6 +27,18 @@ m365 spo listitem batch add [options]
|
|
|
27
27
|
|
|
28
28
|
--8<-- "docs/cmd/_global.md"
|
|
29
29
|
|
|
30
|
+
## Remarks
|
|
31
|
+
|
|
32
|
+
A sample CSV can be found below. The first line of the CSV-file should contain the internal column names that you wish to set.
|
|
33
|
+
|
|
34
|
+
```csv
|
|
35
|
+
ContentType,Title,SingleChoiceField,MultiChoiceField,SingleMetadataField,MultiMetadataField,SinglePeopleField,MultiPeopleField,CustomHyperlink,NumberField,DateTimeField
|
|
36
|
+
Item,Title A,Choice 1,Choice 1;#Choice 2,Engineering|4a3cc5f3-a4a6-433e-a07a-746978ff1760;,Engineering|4a3cc5f3-a4a6-433e-a07a-746978ff1760;Finance|f994a4ac-cf34-448e-a22c-2b35fd9bbffa;,[{'Key':'i:0#.f|membership|markh@contoso.com'}],"[{'Key':'i:0#.f|membership|markh@contoso.com'},{'Key':'i:0#.f|membership|john.doe@contoso.com'}]","https://bing.com, URL",5,2023-01-01 10:00:00
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
!!! warning "When using DateTime fields"
|
|
40
|
+
When creating list items with a DateTime field, use the timezone and the format that the site expects, based on its regional settings. Alternatively, a format which works on all regions is the following: `yyyy-MM-dd HH:mm:ss`. However, you should use the local timezone in all situations. UTC date/time or ISO 8601 formatted date/time is not supported.
|
|
41
|
+
|
|
30
42
|
## Examples
|
|
31
43
|
|
|
32
44
|
Add a batch of items to a list retrieved by title in a specific site
|
|
@@ -47,15 +59,6 @@ Add a batch of items to a list defined by server-relative URL in a specific site
|
|
|
47
59
|
m365 spo listitem batch add --filePath "C:\Path\To\Csv\CsvFile.csv" --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl "/sites/project-x/lists/Demo List"
|
|
48
60
|
```
|
|
49
61
|
|
|
50
|
-
## Remarks
|
|
51
|
-
|
|
52
|
-
A sample CSV can be found below. The first line of the CSV-file should contain the internal column names that you wish to set.
|
|
53
|
-
|
|
54
|
-
```csv
|
|
55
|
-
ContentType,Title,SingleChoiceField,MultiChoiceField,SingleMetadataField,MultiMetadataField,SinglePeopleField,MultiPeopleField,CustomHyperlink,NumberField
|
|
56
|
-
Item,Title A,Choice 1,Choice 1;#Choice 2,Engineering|4a3cc5f3-a4a6-433e-a07a-746978ff1760;,Engineering|4a3cc5f3-a4a6-433e-a07a-746978ff1760;Finance|f994a4ac-cf34-448e-a22c-2b35fd9bbffa;,[{'Key':'i:0#.f|membership|markh@contoso.com'}],"[{'Key':'i:0#.f|membership|markh@contoso.com'},{'Key':'i:0#.f|membership|john.doe@contoso.com'}]","https://bing.com, URL",5
|
|
57
|
-
```
|
|
58
|
-
|
|
59
62
|
## Response
|
|
60
63
|
|
|
61
64
|
The command won't return a response on success.
|
|
@@ -33,6 +33,11 @@ m365 spo listitem set [options]
|
|
|
33
33
|
|
|
34
34
|
--8<-- "docs/cmd/_global.md"
|
|
35
35
|
|
|
36
|
+
## Remarks
|
|
37
|
+
|
|
38
|
+
!!! warning "When using DateTime fields"
|
|
39
|
+
When updating a list item with a DateTime field, use the timezone and the format that the site expects, based on its regional settings. Alternatively, a format which works on all regions is the following: `yyyy-MM-dd HH:mm:ss`. However, you should use the local timezone in all situations. UTC date/time or ISO 8601 formatted date/time is not supported.
|
|
40
|
+
|
|
36
41
|
## Examples
|
|
37
42
|
|
|
38
43
|
Update an item with id _147_ with title _Demo Item_ and content type name _Item_ in list with title _Demo List_ in site _https://contoso.sharepoint.com/sites/project-x_
|
|
@@ -74,7 +79,13 @@ m365 spo listitem set --listUrl '/sites/project-x/lists/Demo List' --id 147 --we
|
|
|
74
79
|
Update an item with a specific Title and multi-choice value
|
|
75
80
|
|
|
76
81
|
```sh
|
|
77
|
-
m365 spo listitem set --listTitle "Demo List" --id 147 --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo
|
|
82
|
+
m365 spo listitem set --listTitle "Demo List" --id 147 --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo multi-choice Field" --MultiChoiceField "Choice 1;#Choice 2;#Choice 3"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Update an item with a specific Title and DateTime value
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
m365 spo listitem set --listTitle "Demo List" --id 147 --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo DateTime Field" --SomeDateTimeField "2023-01-16 15:30:00"
|
|
78
89
|
```
|
|
79
90
|
|
|
80
91
|
## Response
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnp/cli-microsoft365",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pnp/cli-microsoft365",
|
|
9
|
-
"version": "6.
|
|
9
|
+
"version": "6.7.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@azure/msal-node": "^1.16.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnp/cli-microsoft365",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0-beta.87c47df",
|
|
4
4
|
"description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/api.js",
|
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
"Nachan, Smita <smita.nachan@gmail.com>",
|
|
164
164
|
"Nadir, Daniaal <daniaal1030@gmail.com>",
|
|
165
165
|
"Narbutas, Valeras <valeras.narbutas@macaw.nl>",
|
|
166
|
+
"Nicolas <nicolascamara29@gmail.com>",
|
|
166
167
|
"Nikolić, Aleksandar <alexandair@live.com>",
|
|
167
168
|
"O'Callaghan, Conor <brioscaibriste@gmail.com>",
|
|
168
169
|
"Otto <berot3@gmail.com>",
|