@pnp/cli-microsoft365 7.2.0-beta.2970c86 → 7.2.0-beta.a021bb1

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.
@@ -18,7 +18,6 @@ class TenantPeopleProfileCardPropertyAddCommand extends GraphCommand {
18
18
  constructor() {
19
19
  super();
20
20
  _TenantPeopleProfileCardPropertyAddCommand_instances.add(this);
21
- this.excludeOptions = ['name', 'displayName', 'debug', 'verbose', 'output'];
22
21
  __classPrivateFieldGet(this, _TenantPeopleProfileCardPropertyAddCommand_instances, "m", _TenantPeopleProfileCardPropertyAddCommand_initTelemetry).call(this);
23
22
  __classPrivateFieldGet(this, _TenantPeopleProfileCardPropertyAddCommand_instances, "m", _TenantPeopleProfileCardPropertyAddCommand_initOptions).call(this);
24
23
  __classPrivateFieldGet(this, _TenantPeopleProfileCardPropertyAddCommand_instances, "m", _TenantPeopleProfileCardPropertyAddCommand_initValidators).call(this);
@@ -72,7 +71,7 @@ class TenantPeopleProfileCardPropertyAddCommand extends GraphCommand {
72
71
  ];
73
72
  }
74
73
  getLocalizations(options) {
75
- const unknownOptions = Object.keys(options).filter(key => !this.excludeOptions.includes(key));
74
+ const unknownOptions = Object.keys(this.getUnknownOptions(options));
76
75
  if (unknownOptions.length === 0) {
77
76
  return [];
78
77
  }
@@ -88,8 +87,12 @@ class TenantPeopleProfileCardPropertyAddCommand extends GraphCommand {
88
87
  }
89
88
  _TenantPeopleProfileCardPropertyAddCommand_instances = new WeakSet(), _TenantPeopleProfileCardPropertyAddCommand_initTelemetry = function _TenantPeopleProfileCardPropertyAddCommand_initTelemetry() {
90
89
  this.telemetry.push((args) => {
90
+ // Add unknown options to telemetry
91
+ const unknownOptions = Object.keys(this.getUnknownOptions(args.options));
92
+ const unknownOptionsObj = unknownOptions.reduce((obj, key) => ({ ...obj, [key]: true }), {});
91
93
  Object.assign(this.telemetryProperties, {
92
- displayName: typeof args.options.displayName !== 'undefined'
94
+ displayName: typeof args.options.displayName !== 'undefined',
95
+ ...unknownOptionsObj
93
96
  });
94
97
  });
95
98
  }, _TenantPeopleProfileCardPropertyAddCommand_initOptions = function _TenantPeopleProfileCardPropertyAddCommand_initOptions() {
@@ -105,13 +108,13 @@ _TenantPeopleProfileCardPropertyAddCommand_instances = new WeakSet(), _TenantPeo
105
108
  if (profileCardPropertyNames.every(n => n.toLowerCase() !== propertyName)) {
106
109
  return `${args.options.name} is not a valid value for name. Allowed values are ${profileCardPropertyNames.join(', ')}`;
107
110
  }
108
- if (propertyName.startsWith("customattribute") && args.options.displayName === undefined) {
111
+ if (propertyName.startsWith('customattribute') && args.options.displayName === undefined) {
109
112
  return `The option 'displayName' is required when adding customAttributes as profile card properties`;
110
113
  }
111
- if (!propertyName.startsWith("customattribute") && args.options.displayName !== undefined) {
114
+ if (!propertyName.startsWith('customattribute') && args.options.displayName !== undefined) {
112
115
  return `The option 'displayName' can only be used when adding customAttributes as profile card properties`;
113
116
  }
114
- const unknownOptions = Object.keys(args.options).filter(key => !this.excludeOptions.includes(key));
117
+ const unknownOptions = Object.keys(this.getUnknownOptions(args.options));
115
118
  if (!propertyName.startsWith('customattribute') && unknownOptions.length > 0) {
116
119
  return `Unknown options like ${unknownOptions.join(', ')} are only supported with customAttributes`;
117
120
  }
@@ -26,8 +26,10 @@ class TenantPeopleProfileCardPropertyGetCommand extends GraphCommand {
26
26
  if (this.verbose) {
27
27
  await logger.logToStderr(`Retrieving information about profile card property '${args.options.name}'...`);
28
28
  }
29
+ // Get the right casing for the profile card property name
30
+ const profileCardProperty = profileCardPropertyNames.find(p => p.toLowerCase() === args.options.name.toLowerCase());
29
31
  const requestOptions = {
30
- url: `${this.resource}/v1.0/admin/people/profileCardProperties/${args.options.name}`,
32
+ url: `${this.resource}/v1.0/admin/people/profileCardProperties/${profileCardProperty}`,
31
33
  headers: {
32
34
  accept: 'application/json;odata.metadata=none'
33
35
  },
@@ -1,6 +1,6 @@
1
1
  import GraphCommand from '../../../base/GraphCommand.js';
2
- import request from '../../../../request.js';
3
2
  import commands from '../../commands.js';
3
+ import { odata } from '../../../../utils/odata.js';
4
4
  class TenantPeopleProfileCardPropertyListCommand extends GraphCommand {
5
5
  get name() {
6
6
  return commands.PEOPLE_PROFILECARDPROPERTY_LIST;
@@ -8,25 +8,15 @@ class TenantPeopleProfileCardPropertyListCommand extends GraphCommand {
8
8
  get description() {
9
9
  return 'Lists all profile card properties';
10
10
  }
11
- constructor() {
12
- super();
13
- }
14
11
  async commandAction(logger, args) {
15
12
  try {
16
13
  if (this.verbose) {
17
- await logger.logToStderr(`Lists all profile card properties...`);
14
+ await logger.logToStderr(`Listing all profile card properties...`);
18
15
  }
19
- const requestOptions = {
20
- url: `${this.resource}/v1.0/admin/people/profileCardProperties`,
21
- headers: {
22
- accept: 'application/json;odata.metadata=none'
23
- },
24
- responseType: 'json'
25
- };
26
- const result = await request.get(requestOptions);
16
+ const result = await odata.getAllItems(`${this.resource}/v1.0/admin/people/profileCardProperties`);
27
17
  let output = result;
28
18
  if (args.options.output && args.options.output !== 'json') {
29
- output = output.value.sort((n1, n2) => {
19
+ output = output.sort((n1, n2) => {
30
20
  const localizations1 = n1.annotations[0]?.localizations?.length ?? 0;
31
21
  const localizations2 = n2.annotations[0]?.localizations?.length ?? 0;
32
22
  if (localizations1 > localizations2) {
@@ -0,0 +1,118 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _TenantPeopleProfileCardPropertySetCommand_instances, _TenantPeopleProfileCardPropertySetCommand_initTelemetry, _TenantPeopleProfileCardPropertySetCommand_initOptions, _TenantPeopleProfileCardPropertySetCommand_initValidators, _TenantPeopleProfileCardPropertySetCommand_initTypes;
7
+ import GraphCommand from '../../../base/GraphCommand.js';
8
+ import request from '../../../../request.js';
9
+ import { profileCardPropertyNames as allProfileCardPropertyNames } from './profileCardProperties.js';
10
+ import commands from '../../commands.js';
11
+ class TenantPeopleProfileCardPropertySetCommand extends GraphCommand {
12
+ get name() {
13
+ return commands.PEOPLE_PROFILECARDPROPERTY_SET;
14
+ }
15
+ get description() {
16
+ return 'Updates a custom attribute to the profile card property';
17
+ }
18
+ constructor() {
19
+ super();
20
+ _TenantPeopleProfileCardPropertySetCommand_instances.add(this);
21
+ this.profileCardPropertyNames = allProfileCardPropertyNames.filter(p => p.toLowerCase().startsWith('customattribute'));
22
+ __classPrivateFieldGet(this, _TenantPeopleProfileCardPropertySetCommand_instances, "m", _TenantPeopleProfileCardPropertySetCommand_initTelemetry).call(this);
23
+ __classPrivateFieldGet(this, _TenantPeopleProfileCardPropertySetCommand_instances, "m", _TenantPeopleProfileCardPropertySetCommand_initOptions).call(this);
24
+ __classPrivateFieldGet(this, _TenantPeopleProfileCardPropertySetCommand_instances, "m", _TenantPeopleProfileCardPropertySetCommand_initValidators).call(this);
25
+ __classPrivateFieldGet(this, _TenantPeopleProfileCardPropertySetCommand_instances, "m", _TenantPeopleProfileCardPropertySetCommand_initTypes).call(this);
26
+ }
27
+ allowUnknownOptions() {
28
+ return true;
29
+ }
30
+ async commandAction(logger, args) {
31
+ try {
32
+ if (this.verbose) {
33
+ await logger.logToStderr(`Updating profile card property '${args.options.name}'...`);
34
+ }
35
+ // Get the right casing for the profile card property name
36
+ const profileCardProperty = this.profileCardPropertyNames.find(p => p.toLowerCase() === args.options.name.toLowerCase());
37
+ const requestOptions = {
38
+ url: `${this.resource}/v1.0/admin/people/profileCardProperties/${profileCardProperty}`,
39
+ headers: {
40
+ accept: 'application/json;odata.metadata=none'
41
+ },
42
+ responseType: 'json',
43
+ data: {
44
+ annotations: [
45
+ {
46
+ displayName: args.options.displayName,
47
+ localizations: this.getLocalizations(args.options)
48
+ }
49
+ ]
50
+ }
51
+ };
52
+ const result = await request.patch(requestOptions);
53
+ let output = result;
54
+ // Transform the output to make it more readable
55
+ if (args.options.output && args.options.output !== 'json' && result.annotations.length > 0) {
56
+ output = result.annotations[0].localizations.reduce((acc, curr) => ({
57
+ ...acc,
58
+ ['displayName ' + curr.languageTag]: curr.displayName
59
+ }), {
60
+ ...result,
61
+ displayName: result.annotations[0].displayName
62
+ });
63
+ delete output.annotations;
64
+ }
65
+ await logger.log(output);
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedODataJsonPromise(err);
69
+ }
70
+ }
71
+ /**
72
+ * Transform option to localization object.
73
+ * @example Transform "--displayName-en-US 'Cost center'" to { languageTag: 'en-US', displayName: 'Cost center' }
74
+ */
75
+ getLocalizations(options) {
76
+ const unknownOptions = this.getUnknownOptions(options);
77
+ const result = Object.keys(unknownOptions).map(o => ({
78
+ languageTag: o.substring(o.indexOf('-') + 1),
79
+ displayName: unknownOptions[o]
80
+ }));
81
+ return result;
82
+ }
83
+ }
84
+ _TenantPeopleProfileCardPropertySetCommand_instances = new WeakSet(), _TenantPeopleProfileCardPropertySetCommand_initTelemetry = function _TenantPeopleProfileCardPropertySetCommand_initTelemetry() {
85
+ this.telemetry.push((args) => {
86
+ // Add unknown options to telemetry
87
+ const unknownOptions = Object.keys(this.getUnknownOptions(args.options));
88
+ const unknownOptionsObj = unknownOptions.reduce((obj, key) => ({ ...obj, [key]: true }), {});
89
+ Object.assign(this.telemetryProperties, {
90
+ displayName: typeof args.options.displayName !== 'undefined',
91
+ ...unknownOptionsObj
92
+ });
93
+ });
94
+ }, _TenantPeopleProfileCardPropertySetCommand_initOptions = function _TenantPeopleProfileCardPropertySetCommand_initOptions() {
95
+ this.options.unshift({
96
+ option: '-n, --name <name>',
97
+ autocomplete: this.profileCardPropertyNames
98
+ }, {
99
+ option: '-d, --displayName <displayName>'
100
+ });
101
+ }, _TenantPeopleProfileCardPropertySetCommand_initValidators = function _TenantPeopleProfileCardPropertySetCommand_initValidators() {
102
+ this.validators.push(async (args) => {
103
+ if (!this.profileCardPropertyNames.some(p => p.toLowerCase() === args.options.name.toLowerCase())) {
104
+ return `'${args.options.name}' is not a valid value for option name. Allowed values are: ${this.profileCardPropertyNames.join(', ')}.`;
105
+ }
106
+ // Unknown options are allowed only if they start with 'displayName-'
107
+ const unknownOptionKeys = Object.keys(this.getUnknownOptions(args.options));
108
+ const invalidOptionKey = unknownOptionKeys.find(o => !o.startsWith('displayName-'));
109
+ if (invalidOptionKey) {
110
+ return `Invalid option: '${invalidOptionKey}'`;
111
+ }
112
+ return true;
113
+ });
114
+ }, _TenantPeopleProfileCardPropertySetCommand_initTypes = function _TenantPeopleProfileCardPropertySetCommand_initTypes() {
115
+ this.types.string.push('name', 'displayName');
116
+ };
117
+ export default new TenantPeopleProfileCardPropertySetCommand();
118
+ //# sourceMappingURL=people-profilecardproperty-set.js.map
@@ -6,6 +6,7 @@ export default {
6
6
  PEOPLE_PROFILECARDPROPERTY_GET: `${prefix} people profilecardproperty get`,
7
7
  PEOPLE_PROFILECARDPROPERTY_LIST: `${prefix} people profilecardproperty list`,
8
8
  PEOPLE_PROFILECARDPROPERTY_REMOVE: `${prefix} people profilecardproperty remove`,
9
+ PEOPLE_PROFILECARDPROPERTY_SET: `${prefix} people profilecardproperty set`,
9
10
  REPORT_ACTIVEUSERCOUNTS: `${prefix} report activeusercounts`,
10
11
  REPORT_ACTIVEUSERDETAIL: `${prefix} report activeuserdetail`,
11
12
  REPORT_OFFICE365ACTIVATIONCOUNTS: `${prefix} report office365activationcounts`,
@@ -66,54 +66,6 @@ m365 tenant people profilecardproperty add --name customAttribute1 --displayName
66
66
 
67
67
  ## Response
68
68
 
69
- ### Standard response
70
-
71
- <Tabs>
72
- <TabItem value="JSON">
73
-
74
- ```json
75
- {
76
- "directoryPropertyName": "UserPrincipalName",
77
- "annotations": []
78
- }
79
- ```
80
-
81
- </TabItem>
82
- <TabItem value="Text">
83
-
84
- ```text
85
- annotations : []
86
- directoryPropertyName: UserPrincipalName
87
- ```
88
-
89
- </TabItem>
90
- <TabItem value="CSV">
91
-
92
- ```csv
93
- directoryPropertyName
94
- UserPrincipalName
95
- ```
96
-
97
- </TabItem>
98
- <TabItem value="Markdown">
99
-
100
- ```md
101
- # tenant people profilecardproperty add --name 'UserPrincipalName'
102
-
103
- Date: 11/2/2023
104
-
105
- Property | Value
106
- ---------|-------
107
- directoryPropertyName | UserPrincipalName
108
- ```
109
-
110
- </TabItem>
111
- </Tabs>
112
-
113
- ### Response with a customAttribute
114
-
115
- When we make use of one of the customAttributes, the response will differ.
116
-
117
69
  <Tabs>
118
70
  <TabItem value="JSON">
119
71
 
@@ -95,3 +95,7 @@ m365 tenant people profilecardproperty get --name customAttribute1
95
95
 
96
96
  </TabItem>
97
97
  </Tabs>
98
+
99
+ ## More information
100
+
101
+ - https://learn.microsoft.com/graph/add-properties-profilecard
@@ -38,8 +38,7 @@ m365 tenant people profilecardproperty list
38
38
  <TabItem value="JSON">
39
39
 
40
40
  ```json
41
- {
42
- "value": [
41
+ [
43
42
  {
44
43
  "directoryPropertyName": "customAttribute1",
45
44
  "annotations": [
@@ -53,13 +52,8 @@ m365 tenant people profilecardproperty list
53
52
  ]
54
53
  }
55
54
  ]
56
- },
57
- {
58
- "directoryPropertyName": "Alias",
59
- "annotations": []
60
55
  }
61
56
  ]
62
- }
63
57
  ```
64
58
 
65
59
  </TabItem>
@@ -69,7 +63,6 @@ m365 tenant people profilecardproperty list
69
63
  directoryPropertyName displayName displayName de
70
64
  --------------------- -------------- --------------
71
65
  customAttribute1 Cost center Kostenstelle
72
- Alias
73
66
  ```
74
67
 
75
68
  </TabItem>
@@ -78,7 +71,6 @@ m365 tenant people profilecardproperty list
78
71
  ```csv
79
72
  directoryPropertyName,displayName,displayName de
80
73
  customAttribute1,Cost center,Kostenstelle
81
- Alias,,
82
74
  ```
83
75
 
84
76
  </TabItem>
@@ -96,11 +88,11 @@ m365 tenant people profilecardproperty list
96
88
  directoryPropertyName | customAttribute1
97
89
  displayName | Cost center
98
90
  displayName de | Kostenstelle
99
-
100
- Property | Value
101
- ---------|-------
102
- directoryPropertyName | Alias
103
91
  ```
104
92
 
105
93
  </TabItem>
106
- </Tabs>
94
+ </Tabs>
95
+
96
+ ## More information
97
+
98
+ - https://learn.microsoft.com/graph/add-properties-profilecard
@@ -0,0 +1,120 @@
1
+ import Global from '/docs/cmd/_global.mdx';
2
+ import Tabs from '@theme/Tabs';
3
+ import TabItem from '@theme/TabItem';
4
+
5
+ # tenant people profilecardproperty set
6
+
7
+ Updates a custom attribute to the profile card property
8
+
9
+ ## Usage
10
+
11
+ ```sh
12
+ m365 tenant people profilecardproperty set [options]
13
+ ```
14
+
15
+ ## Options
16
+
17
+ ```md definition-list
18
+ `-n, --name <name>`
19
+ : The name of the property to update. Allowed values: `customAttribute1`, `customAttribute2`, `customAttribute3`, `customAttribute4`, `customAttribute5`, `customAttribute6`, `customAttribute7`, `customAttribute8`, `customAttribute9`, `customAttribute10`, `customAttribute11`, `customAttribute12`, `customAttribute13`, `customAttribute14`, `customAttribute15`.
20
+
21
+ `-d, --displayName <displayName>`
22
+ : The display name of the property.
23
+ ```
24
+
25
+ <Global />
26
+
27
+ ## Remarks
28
+
29
+ :::info
30
+
31
+ To use this command you must be either **Tenant Administrator** or **Global Administrator**.
32
+
33
+ :::
34
+
35
+ :::info
36
+
37
+ You can specify localized values for the `displayName` as well. These can be entered by suffixing the displayName option with a language code: `--displayName-nl-NL "Kostencentrum"`, `--displayName-de "Kostenstelle"`.
38
+
39
+ :::
40
+
41
+ :::caution
42
+
43
+ When updating an attribute to a profile card, it takes up to 24 hours for the addition to be displayed.
44
+
45
+ :::
46
+
47
+ ## Examples
48
+
49
+ Updates a custom extension attribute to Cost Center
50
+
51
+ ```sh
52
+ m365 tenant people profilecardproperty set --name customAttribute1 --displayName "Cost Center"
53
+ ```
54
+
55
+ Updates a custom extension attribute with translations
56
+
57
+ ```sh
58
+ m365 tenant people profilecardproperty set --name customAttribute1 --displayName "Cost Center" --displayName-nl-NL "Kostencentrum" --displayName-de "Kostenstelle"
59
+ ```
60
+
61
+ ## Response
62
+
63
+ <Tabs>
64
+ <TabItem value="JSON">
65
+
66
+ ```json
67
+ {
68
+ "directoryPropertyName": "customAttribute1",
69
+ "annotations": [
70
+ {
71
+ "displayName": "Cost center",
72
+ "localizations": [
73
+ {
74
+ "languageTag": "nl-NL",
75
+ "displayName": "Kostenplaats"
76
+ }
77
+ ]
78
+ }
79
+ ]
80
+ }
81
+ ```
82
+
83
+ </TabItem>
84
+ <TabItem value="Text">
85
+
86
+ ```text
87
+ directoryPropertyName: customAttribute1
88
+ displayName : Cost center
89
+ displayName nl-NL : Kostenplaats
90
+ ```
91
+
92
+ </TabItem>
93
+ <TabItem value="CSV">
94
+
95
+ ```csv
96
+ directoryPropertyName,displayName,displayName nl-NL
97
+ customAttribute1,Cost center,Kostenplaats
98
+ ```
99
+
100
+ </TabItem>
101
+ <TabItem value="Markdown">
102
+
103
+ ```md
104
+ # tenant people profilecardproperty set --name 'customAttribute1' --displayName 'Cost center' --displayName-nl-NL 'Kostenplaats'
105
+
106
+ Date: 11/2/2023
107
+
108
+ Property | Value
109
+ ---------|-------
110
+ directoryPropertyName | customAttribute1
111
+ displayName | Cost center
112
+ displayName nl-NL | Kostenplaats
113
+ ```
114
+
115
+ </TabItem>
116
+ </Tabs>
117
+
118
+ ## More information
119
+
120
+ - https://learn.microsoft.com/graph/add-properties-profilecard
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "7.2.0-beta.2970c86",
3
+ "version": "7.2.0-beta.a021bb1",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -156,6 +156,7 @@
156
156
  "Hunt, Geoffrey <info@runningdeveloper.com>",
157
157
  "Hvam, Allan <ahp@delegate.dk>",
158
158
  "Jaakke, Robert <robert.jaakke@mavention.nl>",
159
+ "Junker Aaron <aaron.junker@outlook.com>",
159
160
  "Kailasam, Balamurugan <kshsbala@engineer.com>",
160
161
  "Karda, Akash <akashkarda@gmail.com>",
161
162
  "Kasireddy, Prasad <prasad.gietcse@gmail.com>",
@@ -174,6 +175,7 @@
174
175
  "Levert, Sebastien <slevert@outlook.com>",
175
176
  "Lingstuyl, Martin <mlingstuyl@live.com>",
176
177
  "Macháček, Martin <machacek@edhouse.cz>",
178
+ "Maestrini Tobias <tobias@bee365.ch>",
177
179
  "Maillot, Michaël <battosaimykle@gmail.com>",
178
180
  "Mastykarz, Waldek <waldek@mastykarz.nl>",
179
181
  "McDonnell, Kevin <kevin@mcd79.com>",