@pnp/cli-microsoft365 7.3.0-beta.e0b37b9 → 7.3.0

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 (28) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +3 -0
  4. package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-get.js +112 -0
  5. package/dist/m365/aad/commands.js +1 -0
  6. package/dist/m365/base/PowerAutomateCommand.js +18 -0
  7. package/dist/m365/external/commands/connection/connection-schema-add.js +36 -3
  8. package/dist/m365/flow/commands/environment/environment-get.js +3 -3
  9. package/dist/m365/flow/commands/environment/environment-list.js +3 -3
  10. package/dist/m365/flow/commands/flow-disable.js +3 -3
  11. package/dist/m365/flow/commands/flow-enable.js +3 -3
  12. package/dist/m365/flow/commands/flow-get.js +3 -3
  13. package/dist/m365/flow/commands/flow-list.js +14 -12
  14. package/dist/m365/flow/commands/flow-remove.js +3 -3
  15. package/dist/m365/flow/commands/owner/owner-ensure.js +3 -3
  16. package/dist/m365/flow/commands/owner/owner-list.js +3 -3
  17. package/dist/m365/flow/commands/owner/owner-remove.js +3 -3
  18. package/dist/m365/flow/commands/run/run-cancel.js +3 -3
  19. package/dist/m365/flow/commands/run/run-get.js +3 -3
  20. package/dist/m365/flow/commands/run/run-list.js +8 -7
  21. package/dist/m365/flow/commands/run/run-resubmit.js +4 -4
  22. package/dist/m365/spo/commands/listitem/listitem-batch-add.js +18 -7
  23. package/dist/m365/spo/commands/page/page-add.js +7 -28
  24. package/dist/utils/aadAdministrativeUnit.js +4 -4
  25. package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-get.mdx +130 -0
  26. package/docs/docs/cmd/external/connection/connection-schema-add.mdx +14 -1
  27. package/docs/docs/cmd/spo/listitem/listitem-batch-add.mdx +25 -3
  28. package/package.json +2 -2
@@ -35,9 +35,9 @@ class SpoListItemBatchAddCommand extends SpoCommand {
35
35
  async commandAction(logger, args) {
36
36
  try {
37
37
  if (this.verbose) {
38
- await logger.logToStderr(`Starting to create batch items from csv at path ${args.options.filePath}`);
38
+ await logger.logToStderr(`Starting to create batch items from csv ${args.options.filePath ? `at path ${args.options.filePath}` : 'from content'}`);
39
39
  }
40
- const csvContent = fs.readFileSync(args.options.filePath, 'utf8');
40
+ const csvContent = args.options.filePath ? fs.readFileSync(args.options.filePath, 'utf8') : args.options.csvContent;
41
41
  const jsonContent = formatting.parseCsvToJson(csvContent);
42
42
  await this.addItemsAsBatch(jsonContent, args.options, logger);
43
43
  }
@@ -97,7 +97,7 @@ class SpoListItemBatchAddCommand extends SpoCommand {
97
97
  batchBody.push(`Accept: application/json;odata=nometadata\n`);
98
98
  batchBody.push(`Content-Type: application/json;odata=verbose\n`);
99
99
  batchBody.push(`If-Match: *\n\n`);
100
- batchBody.push(`{\n"formValues": ${JSON.stringify(item)}\n}`);
100
+ batchBody.push(`{\n"formValues": ${JSON.stringify(this.formatFormValues(item))}\n}`);
101
101
  });
102
102
  // close batch body
103
103
  batchBody.push(`\n\n`);
@@ -105,6 +105,13 @@ class SpoListItemBatchAddCommand extends SpoCommand {
105
105
  batchBody.push(`--batch_${batchId}--\n`);
106
106
  return batchBody;
107
107
  }
108
+ formatFormValues(input) {
109
+ // Fix for PS 7
110
+ return input.map(obj => ({
111
+ FieldName: obj.FieldName.replace(/\\"/g, ''),
112
+ FieldValue: obj.FieldValue.replace(/\\"/g, '')
113
+ }));
114
+ }
108
115
  parseBatchResponseBody(response) {
109
116
  const batchResults = [];
110
117
  response.split('\r\n')
@@ -151,6 +158,8 @@ class SpoListItemBatchAddCommand extends SpoCommand {
151
158
  _SpoListItemBatchAddCommand_instances = new WeakSet(), _SpoListItemBatchAddCommand_initTelemetry = function _SpoListItemBatchAddCommand_initTelemetry() {
152
159
  this.telemetry.push((args) => {
153
160
  Object.assign(this.telemetryProperties, {
161
+ filePath: typeof args.options.filePath !== 'undefined',
162
+ csvContent: typeof args.options.csvContent !== 'undefined',
154
163
  listId: typeof args.options.listId !== 'undefined',
155
164
  listTitle: typeof args.options.listTitle !== 'undefined',
156
165
  listUrl: typeof args.options.listUrl !== 'undefined'
@@ -158,9 +167,11 @@ _SpoListItemBatchAddCommand_instances = new WeakSet(), _SpoListItemBatchAddComma
158
167
  });
159
168
  }, _SpoListItemBatchAddCommand_initOptions = function _SpoListItemBatchAddCommand_initOptions() {
160
169
  this.options.unshift({
161
- option: '-p, --filePath <filePath>'
162
- }, {
163
170
  option: '-u, --webUrl <webUrl>'
171
+ }, {
172
+ option: '-p, --filePath [filePath]'
173
+ }, {
174
+ option: '-c, --csvContent [csvContent]'
164
175
  }, {
165
176
  option: '-l, --listId [listId]'
166
177
  }, {
@@ -178,7 +189,7 @@ _SpoListItemBatchAddCommand_instances = new WeakSet(), _SpoListItemBatchAddComma
178
189
  !validation.isValidGuid(args.options.listId)) {
179
190
  return `${args.options.listId} in option listId is not a valid GUID`;
180
191
  }
181
- if (!fs.existsSync(args.options.filePath)) {
192
+ if (args.options.filePath && !fs.existsSync(args.options.filePath)) {
182
193
  return `File with path ${args.options.filePath} does not exist`;
183
194
  }
184
195
  return true;
@@ -186,7 +197,7 @@ _SpoListItemBatchAddCommand_instances = new WeakSet(), _SpoListItemBatchAddComma
186
197
  }, _SpoListItemBatchAddCommand_initTypes = function _SpoListItemBatchAddCommand_initTypes() {
187
198
  this.types.string.push('webUrl', 'filePath', 'listId', 'listTitle', 'listUrl');
188
199
  }, _SpoListItemBatchAddCommand_initOptionSets = function _SpoListItemBatchAddCommand_initOptionSets() {
189
- this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] });
200
+ this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['filePath', 'csvContent'] });
190
201
  };
191
202
  export default new SpoListItemBatchAddCommand();
192
203
  //# sourceMappingURL=listitem-batch-add.js.map
@@ -4,7 +4,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _SpoPageAddCommand_instances, _SpoPageAddCommand_initTelemetry, _SpoPageAddCommand_initOptions, _SpoPageAddCommand_initValidators;
7
- import { Auth } from '../../../../Auth.js';
8
7
  import { cli } from '../../../../cli/cli.js';
9
8
  import request from '../../../../request.js';
10
9
  import { formatting } from '../../../../utils/formatting.js';
@@ -31,11 +30,9 @@ class SpoPageAddCommand extends SpoCommand {
31
30
  __classPrivateFieldGet(this, _SpoPageAddCommand_instances, "m", _SpoPageAddCommand_initValidators).call(this);
32
31
  }
33
32
  async commandAction(logger, args) {
34
- const resource = Auth.getResourceFromUrl(args.options.webUrl);
35
33
  let requestDigest = '';
36
34
  let itemId = '';
37
35
  let pageName = args.options.name;
38
- const serverRelativeSiteUrl = urlUtil.getServerRelativeSiteUrl(args.options.webUrl);
39
36
  const fileNameWithoutExtension = pageName.replace('.aspx', '');
40
37
  let bannerImageUrl = '';
41
38
  let canvasContent1 = '';
@@ -52,39 +49,22 @@ class SpoPageAddCommand extends SpoCommand {
52
49
  const reqDigest = await spo.getRequestDigest(args.options.webUrl);
53
50
  requestDigest = reqDigest.FormDigestValue;
54
51
  let requestOptions = {
55
- url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${serverRelativeSiteUrl}/sitepages')/files/AddTemplateFile`,
52
+ url: `${args.options.webUrl}/_api/sitepages/pages`,
53
+ responseType: 'json',
56
54
  headers: {
57
- 'X-RequestDigest': requestDigest,
58
55
  'content-type': 'application/json;odata=nometadata',
59
56
  accept: 'application/json;odata=nometadata'
60
57
  },
61
58
  data: {
62
- urlOfFile: `${serverRelativeSiteUrl}/sitepages/${pageName}`,
63
- templateFileType: 3
64
- },
65
- responseType: 'json'
59
+ PageLayoutType: args.options.layoutType || 'Article',
60
+ Name: pageName,
61
+ PromotedState: args.options.promoteAs === 'NewsPage' ? 2 : 0,
62
+ Title: pageTitle
63
+ }
66
64
  };
67
65
  const template = await request.post(requestOptions);
68
66
  itemId = template.UniqueId;
69
67
  const listItemId = await this.getFileListItemId(args.options.webUrl, serverRelativeFileUrl);
70
- const layoutType = args.options.layoutType || 'Article';
71
- const listItemSetOptions = {
72
- webUrl: args.options.webUrl,
73
- listUrl: listServerRelativeUrl,
74
- id: listItemId,
75
- systemUpdate: true,
76
- ContentTypeId: '0x0101009D1CB255DA76424F860D91F20E6C4118',
77
- Title: pageTitle,
78
- ClientSideApplicationId: 'b6917cb1-93a0-4b97-a84d-7cf49975d4ec',
79
- PageLayoutType: layoutType,
80
- verbose: this.verbose,
81
- debug: this.debug
82
- };
83
- if (args.options.layoutType === 'Article') {
84
- listItemSetOptions.PromotedState = 0;
85
- listItemSetOptions.BannerImageUrl = `${resource}/_layouts/15/images/sitepagethumbnail.png, /_layouts/15/images/sitepagethumbnail.png`;
86
- }
87
- await cli.executeCommand(spoListItemSetCommand, { options: { ...listItemSetOptions, _: [] } });
88
68
  const pageProps = await Page.checkout(pageName, args.options.webUrl, logger, this.debug, this.verbose);
89
69
  if (pageProps) {
90
70
  pageId = pageProps.Id;
@@ -117,7 +97,6 @@ class SpoPageAddCommand extends SpoCommand {
117
97
  listUrl: listServerRelativeUrl,
118
98
  id: listItemId,
119
99
  systemUpdate: true,
120
- PromotedState: 2,
121
100
  FirstPublishedDate: new Date().toISOString(),
122
101
  verbose: this.verbose,
123
102
  debug: this.debug
@@ -1,7 +1,6 @@
1
- import { odata } from "./odata.js";
2
- import { formatting } from "./formatting.js";
3
- import { cli } from "../cli/cli.js";
4
- const graphResource = 'https://graph.microsoft.com';
1
+ import { odata } from './odata.js';
2
+ import { formatting } from './formatting.js';
3
+ import { cli } from '../cli/cli.js';
5
4
  export const aadAdministrativeUnit = {
6
5
  /**
7
6
  * Get an administrative unit by its display name.
@@ -10,6 +9,7 @@ export const aadAdministrativeUnit = {
10
9
  * @throws Error when administrative unit was not found.
11
10
  */
12
11
  async getAdministrativeUnitByDisplayName(displayName) {
12
+ const graphResource = 'https://graph.microsoft.com';
13
13
  const administrativeUnits = await odata.getAllItems(`${graphResource}/v1.0/directory/administrativeUnits?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`);
14
14
  if (administrativeUnits.length === 0) {
15
15
  throw `The specified administrative unit '${displayName}' does not exist.`;
@@ -0,0 +1,130 @@
1
+ import Global from '/docs/cmd/_global.mdx';
2
+ import Tabs from '@theme/Tabs';
3
+ import TabItem from '@theme/TabItem';
4
+
5
+ # aad administrativeunit member get
6
+
7
+ Retrieves info about a specific member of an administrative unit
8
+
9
+ ## Usage
10
+
11
+ ```sh
12
+ m365 aad administrativeunit member get [options]
13
+ ```
14
+
15
+ ## Options
16
+
17
+ ```md definition-list
18
+ `-i, --id <id>`
19
+ : The id of a member to be retrieved.
20
+
21
+ `-u, --administrativeUnitId [administrativeUnitId]`
22
+ : The id of the administrative unit. Specify either `administrativeUnitId` or `administrativeUnitName`.
23
+
24
+ `-n, --administrativeUnitName [administrativeUnitName]`
25
+ : The name of the administrative unit. Specify either `administrativeUnitId` or `administrativeUnitName`.
26
+
27
+ `-p, --properties [properties]`
28
+ : Comma-separated list of properties to retrieve.
29
+ ```
30
+
31
+ <Global />
32
+
33
+ ## Remarks
34
+
35
+ To get the member of a hidden membership in an administrative unit, the `Member.Read.Hidden` permission is required.
36
+
37
+ When the `properties` option includes values with a `/`, for example: `manager/displayName`, an additional `$expand` query parameter will be included on manager.
38
+
39
+ ## Examples
40
+
41
+ Get information about a member specified by id from an administrative unit specified by id
42
+
43
+ ```sh
44
+ m365 aad administrativeunit member get --id 64131a70-beb9-4ccb-b590-4401e58446ec --administrativeUnitId 03c4c9dc-6f0c-4c4f-a4e6-0c9ed80f54c7
45
+ ```
46
+
47
+ Get information about a member specified by id from an administrative unit specified by name
48
+
49
+ ```sh
50
+ m365 aad administrativeunit member get --id 64131a70-beb9-4ccb-b590-4401e58446ec --administrativeUnitName 'Marketing Division'
51
+ ```
52
+
53
+ ## Response
54
+
55
+ <Tabs>
56
+ <TabItem value="JSON">
57
+
58
+ ```json
59
+ {
60
+ "id": "64131a70-beb9-4ccb-b590-4401e58446ec",
61
+ "businessPhones": [
62
+ "+20 255501070"
63
+ ],
64
+ "displayName": "Pradeep Gupta",
65
+ "givenName": "Pradeep",
66
+ "jobTitle": "Accountant",
67
+ "mail": "PradeepG@contoso.com",
68
+ "mobilePhone": null,
69
+ "officeLocation": "98/2202",
70
+ "preferredLanguage": "en-US",
71
+ "surname": "Gupta",
72
+ "userPrincipalName": "PradeepG@contoso.com",
73
+ "type": "user"
74
+ }
75
+ ```
76
+
77
+ </TabItem>
78
+ <TabItem value="Text">
79
+
80
+ ```text
81
+ businessPhones : ["+20 255501070"]
82
+ displayName : Pradeep Gupta
83
+ givenName : Pradeep
84
+ id : 64131a70-beb9-4ccb-b590-4401e58446ec
85
+ jobTitle : Accountant
86
+ mail : PradeepG@contoso.com
87
+ mobilePhone : null
88
+ officeLocation : 98/2202
89
+ preferredLanguage: en-US
90
+ surname : Gupta
91
+ type : user
92
+ userPrincipalName: PradeepG@contoso.com
93
+ ```
94
+
95
+ </TabItem>
96
+ <TabItem value="CSV">
97
+
98
+ ```csv
99
+ id,displayName,givenName,jobTitle,mail,officeLocation,preferredLanguage,surname,userPrincipalName,type
100
+ 64131a70-beb9-4ccb-b590-4401e58446ec,Pradeep Gupta,Pradeep,Accountant,PradeepG@contoso.com,98/2202,en-US,Gupta,PradeepG@contoso.com,user
101
+ ```
102
+
103
+ </TabItem>
104
+ <TabItem value="Markdown">
105
+
106
+ ```md
107
+ Date: 11/10/2023
108
+
109
+ ## Pradeep Gupta (64131a70-beb9-4ccb-b590-4401e58446ec)
110
+
111
+ Property | Value
112
+ ---------|-------
113
+ id | 64131a70-beb9-4ccb-b590-4401e58446ec
114
+ displayName | Pradeep Gupta
115
+ givenName | Pradeep
116
+ jobTitle | Accountant
117
+ mail | PradeepG@contoso.com
118
+ officeLocation | 98/2202
119
+ preferredLanguage | en-US
120
+ surname | Gupta
121
+ userPrincipalName | PradeepG@contoso.com
122
+ type | user
123
+ ```
124
+
125
+ </TabItem>
126
+ </Tabs>
127
+
128
+ ## More information
129
+
130
+ - Administrative units: https://learn.microsoft.com/entra/identity/role-based-access-control/administrative-units
@@ -24,6 +24,9 @@ m365 search externalconnection schema add
24
24
 
25
25
  `-s, --schema [schema]`
26
26
  : The schema object to be added.
27
+
28
+ `--wait`
29
+ : Wait for the schema to be added before completing the command.
27
30
  ```
28
31
 
29
32
  <Global />
@@ -36,6 +39,16 @@ Adds a new schema to a specific external connection.
36
39
  m365 external connection schema add --externalConnectionId 'CliConnectionId' --schema '{"baseType":"microsoft.graph.externalItem","properties":[{"name":"ticketTitle","type":"String","isSearchable":"true","isRetrievable":"true","labels":["title"]},{"name":"priority","type":"String","isQueryable":"true","isRetrievable":"true","isSearchable":"false"},{"name":"assignee","type":"String","isRetrievable":"true"}]}'
37
40
  ```
38
41
 
42
+ Adds a new schema to a specific external connection and wait for its provisioning to complete.
43
+
44
+ ```sh
45
+ m365 external connection schema add --externalConnectionId 'CliConnectionId' --schema '{"baseType":"microsoft.graph.externalItem","properties":[{"name":"ticketTitle","type":"String","isSearchable":"true","isRetrievable":"true","labels":["title"]},{"name":"priority","type":"String","isQueryable":"true","isRetrievable":"true","isSearchable":"false"},{"name":"assignee","type":"String","isRetrievable":"true"}]}' --wait
46
+ ```
47
+
39
48
  ## Response
40
49
 
41
- The command won't return a response on success.
50
+ Upon executing the command, you'll receive the job status URL. This URL enables manual checking of the job's progress if automated polling fails or for interactive monitoring purposes.
51
+
52
+ ```text
53
+ "https://graph.microsoft.com/v1.0/external/connections/MyApp/operations/795b6888-4093-0fe7-6270-ddbcac9ebd3a"
54
+ ```
@@ -13,12 +13,15 @@ m365 spo listitem batch add [options]
13
13
  ## Options
14
14
 
15
15
  ```md definition-list
16
- `-p, --filePath <filePath>`
17
- : The absolute or relative path to a flat file containing the list items.
18
-
19
16
  `-u, --webUrl <webUrl>`
20
17
  : URL of the site.
21
18
 
19
+ `-p, --filePath [filePath]`
20
+ : The absolute or relative path to a flat file containing the list items. Specify `filePath` or `csvContent`, but not both.
21
+
22
+ `-c, --csvContent [csvContent]`
23
+ : A string content in CSV-format containing the list items. Specify `filePath` or `csvContent`, but not both.
24
+
22
25
  `-l, --listId [listId]`
23
26
  : ID of the list. Specify either `listTitle`, `listId` or `listUrl`, but not multiple.
24
27
 
@@ -54,6 +57,25 @@ Add a batch of items to a list retrieved by title in a specific site
54
57
  m365 spo listitem batch add --filePath "C:\Path\To\Csv\CsvFile.csv" --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Demo List"
55
58
  ```
56
59
 
60
+ Add a batch of items to a list retrieved by title in a specific site using csv content
61
+
62
+ ```sh
63
+ $obj = @(
64
+ [PSCustomObject]@{
65
+ Title = "Item A"
66
+ Age = 10
67
+ },
68
+ [PSCustomObject]@{
69
+ Title = "Item B"
70
+ Age = 20
71
+ }
72
+ )
73
+
74
+ $csvContent = $obj | ConvertTo-Csv -NoTypeInformation -Delimiter "," | Out-String | ForEach-Object { $_.Replace('"','\"') }
75
+
76
+ m365 spo listitem batch add --csvContent $csvContent --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Demo List"
77
+ ```
78
+
57
79
  Add a batch of items to a list retrieved by Id in a specific site
58
80
 
59
81
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "7.3.0-beta.e0b37b9",
3
+ "version": "7.3.0",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -301,4 +301,4 @@
301
301
  "sinon": "^17.0.0",
302
302
  "source-map-support": "^0.5.21"
303
303
  }
304
- }
304
+ }