@pnp/cli-microsoft365 10.3.0-beta.d1b978f → 10.3.0-beta.f5e6f85
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/.eslintrc.cjs +1 -0
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/config.js +1 -0
- package/dist/m365/entra/commands/pim/pim-role-assignment-remove.js +186 -0
- package/dist/m365/entra/commands/roledefinition/roledefinition-add.js +58 -0
- package/dist/m365/entra/commands/roledefinition/roledefinition-set.js +84 -0
- package/dist/m365/entra/commands.js +3 -0
- package/dist/m365/exo/commands/approleassignment/approleassignment-add.js +235 -0
- package/dist/m365/exo/commands.js +5 -0
- package/dist/m365/outlook/commands/mailbox/mailbox-settings-set.js +163 -0
- package/dist/m365/outlook/commands.js +1 -0
- package/dist/m365/pp/commands/website/website-get.js +60 -0
- package/dist/m365/pp/commands.js +2 -1
- package/dist/m365/spo/commands/folder/folder-roleassignment-add.js +0 -13
- package/dist/m365/tenant/commands/people/people-pronouns-set.js +46 -0
- package/dist/m365/tenant/commands.js +1 -0
- package/dist/utils/customAppScope.js +29 -0
- package/dist/utils/entraServicePrincipal.js +46 -0
- package/dist/utils/powerPlatform.js +38 -0
- package/dist/utils/roleDefinition.js +23 -0
- package/dist/utils/validation.js +4 -0
- package/docs/docs/cmd/entra/pim/pim-role-assignment-remove.mdx +197 -0
- package/docs/docs/cmd/entra/roledefinition/roledefinition-add.mdx +127 -0
- package/docs/docs/cmd/entra/roledefinition/roledefinition-set.mdx +60 -0
- package/docs/docs/cmd/exo/approleassignment/approleassignment-add.mdx +170 -0
- package/docs/docs/cmd/outlook/mailbox/mailbox-settings-set.mdx +166 -0
- package/docs/docs/cmd/pp/website/website-get.mdx +153 -0
- package/docs/docs/cmd/tenant/people/people-pronouns-set.mdx +82 -0
- package/npm-shrinkwrap.json +54 -74
- package/package.json +9 -9
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
|
+
import { zod } from '../../../../utils/zod.js';
|
|
4
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
5
|
+
import commands from '../../commands.js';
|
|
6
|
+
import { validation } from '../../../../utils/validation.js';
|
|
7
|
+
import request from '../../../../request.js';
|
|
8
|
+
import { accessToken } from '../../../../utils/accessToken.js';
|
|
9
|
+
import auth from '../../../../Auth.js';
|
|
10
|
+
const options = globalOptionsZod
|
|
11
|
+
.extend({
|
|
12
|
+
userId: zod.alias('i', z.string().refine(id => validation.isValidGuid(id), id => ({
|
|
13
|
+
message: `'${id}' is not a valid GUID.`
|
|
14
|
+
})).optional()),
|
|
15
|
+
userName: zod.alias('n', z.string().refine(name => validation.isValidUserPrincipalName(name), name => ({
|
|
16
|
+
message: `'${name}' is not a valid UPN.`
|
|
17
|
+
})).optional()),
|
|
18
|
+
dateFormat: z.string().optional(),
|
|
19
|
+
timeFormat: z.string().optional(),
|
|
20
|
+
timeZone: z.string().optional(),
|
|
21
|
+
language: z.string().optional(),
|
|
22
|
+
delegateMeetingMessageDeliveryOptions: z.enum(['sendToDelegateAndInformationToPrincipal', 'sendToDelegateAndPrincipal', 'sendToDelegateOnly']).optional(),
|
|
23
|
+
workingDays: z.string().transform((value) => value.split(',')).pipe(z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']).array()).optional(),
|
|
24
|
+
workingHoursStartTime: z.string().optional(),
|
|
25
|
+
workingHoursEndTime: z.string().optional(),
|
|
26
|
+
workingHoursTimeZone: z.string().optional(),
|
|
27
|
+
autoReplyExternalAudience: z.enum(['none', 'all', 'contactsOnly']).optional(),
|
|
28
|
+
autoReplyExternalMessage: z.string().optional(),
|
|
29
|
+
autoReplyInternalMessage: z.string().optional(),
|
|
30
|
+
autoReplyStartDateTime: z.string().optional(),
|
|
31
|
+
autoReplyStartTimeZone: z.string().optional(),
|
|
32
|
+
autoReplyEndDateTime: z.string().optional(),
|
|
33
|
+
autoReplyEndTimeZone: z.string().optional(),
|
|
34
|
+
autoReplyStatus: z.enum(['disabled', 'scheduled', 'alwaysEnabled']).optional()
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
class OutlookMailboxSettingsSetCommand extends GraphCommand {
|
|
38
|
+
get name() {
|
|
39
|
+
return commands.MAILBOX_SETTINGS_SET;
|
|
40
|
+
}
|
|
41
|
+
get description() {
|
|
42
|
+
return 'Updates user mailbox settings';
|
|
43
|
+
}
|
|
44
|
+
get schema() {
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
getRefinedSchema(schema) {
|
|
48
|
+
return schema
|
|
49
|
+
.refine(options => [options.workingDays, options.workingHoursStartTime, options.workingHoursEndTime, options.workingHoursTimeZone,
|
|
50
|
+
options.autoReplyStatus, options.autoReplyExternalAudience, options.autoReplyExternalMessage, options.autoReplyInternalMessage,
|
|
51
|
+
options.autoReplyStartDateTime, options.autoReplyStartTimeZone, options.autoReplyEndDateTime, options.autoReplyEndTimeZone,
|
|
52
|
+
options.timeFormat, options.timeZone, options.dateFormat, options.delegateMeetingMessageDeliveryOptions, options.language].filter(o => o !== undefined).length > 0, {
|
|
53
|
+
message: 'Specify at least one of the following options: workingDays, workingHoursStartTime, workingHoursEndTime, workingHoursTimeZone, autoReplyStatus, autoReplyExternalAudience, autoReplyExternalMessage, autoReplyInternalMessage, autoReplyStartDateTime, autoReplyStartTimeZone, autoReplyEndDateTime, autoReplyEndTimeZone, timeFormat, timeZone, dateFormat, delegateMeetingMessageDeliveryOptions, or language'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async commandAction(logger, args) {
|
|
57
|
+
const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken);
|
|
58
|
+
let requestUrl = `${this.resource}/v1.0/me/mailboxSettings`;
|
|
59
|
+
if (isAppOnlyAccessToken) {
|
|
60
|
+
if (args.options.userId && args.options.userName) {
|
|
61
|
+
throw 'When running with application permissions either userId or userName is required, but not both';
|
|
62
|
+
}
|
|
63
|
+
const userIdentifier = args.options.userId ?? args.options.userName;
|
|
64
|
+
if (this.verbose) {
|
|
65
|
+
await logger.logToStderr(`Updating mailbox settings for user ${userIdentifier}...`);
|
|
66
|
+
}
|
|
67
|
+
requestUrl = `${this.resource}/v1.0/users('${userIdentifier}')/mailboxSettings`;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (args.options.userId || args.options.userName) {
|
|
71
|
+
throw 'You can update mailbox settings of other users only if CLI is authenticated in app-only mode';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const requestOptions = {
|
|
75
|
+
url: requestUrl,
|
|
76
|
+
headers: {
|
|
77
|
+
accept: 'application/json;odata.metadata=none'
|
|
78
|
+
},
|
|
79
|
+
responseType: 'json',
|
|
80
|
+
data: this.createRequestBody(args)
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
const result = await request.patch(requestOptions);
|
|
84
|
+
await logger.log(result);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
this.handleRejectedODataJsonPromise(err);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
createRequestBody(args) {
|
|
91
|
+
const data = {};
|
|
92
|
+
if (args.options.dateFormat) {
|
|
93
|
+
data.dateFormat = args.options.dateFormat;
|
|
94
|
+
}
|
|
95
|
+
if (args.options.timeFormat) {
|
|
96
|
+
data.timeFormat = args.options.timeFormat;
|
|
97
|
+
}
|
|
98
|
+
if (args.options.timeZone) {
|
|
99
|
+
data.timeZone = args.options.timeZone;
|
|
100
|
+
}
|
|
101
|
+
if (args.options.delegateMeetingMessageDeliveryOptions) {
|
|
102
|
+
data.delegateMeetingMessageDeliveryOptions = args.options.delegateMeetingMessageDeliveryOptions;
|
|
103
|
+
}
|
|
104
|
+
if (args.options.language) {
|
|
105
|
+
data.language = {
|
|
106
|
+
locale: args.options.language
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (args.options.workingDays || args.options.workingHoursStartTime || args.options.workingHoursEndTime || args.options.workingHoursTimeZone) {
|
|
110
|
+
data['workingHours'] = {};
|
|
111
|
+
}
|
|
112
|
+
if (args.options.workingDays) {
|
|
113
|
+
data.workingHours.daysOfWeek = args.options.workingDays;
|
|
114
|
+
}
|
|
115
|
+
if (args.options.workingHoursStartTime) {
|
|
116
|
+
data.workingHours.startTime = args.options.workingHoursStartTime;
|
|
117
|
+
}
|
|
118
|
+
if (args.options.workingHoursEndTime) {
|
|
119
|
+
data.workingHours.endTime = args.options.workingHoursEndTime;
|
|
120
|
+
}
|
|
121
|
+
if (args.options.workingHoursTimeZone) {
|
|
122
|
+
data.workingHours.timeZone = {
|
|
123
|
+
name: args.options.workingHoursTimeZone
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (args.options.autoReplyStatus || args.options.autoReplyExternalAudience || args.options.autoReplyExternalMessage || args.options.autoReplyInternalMessage || args.options.autoReplyStartDateTime || args.options.autoReplyStartTimeZone || args.options.autoReplyEndDateTime || args.options.autoReplyEndTimeZone) {
|
|
127
|
+
data['automaticRepliesSetting'] = {};
|
|
128
|
+
}
|
|
129
|
+
if (args.options.autoReplyStatus) {
|
|
130
|
+
data.automaticRepliesSetting['status'] = args.options.autoReplyStatus;
|
|
131
|
+
}
|
|
132
|
+
if (args.options.autoReplyExternalAudience) {
|
|
133
|
+
data.automaticRepliesSetting['externalAudience'] = args.options.autoReplyExternalAudience;
|
|
134
|
+
}
|
|
135
|
+
if (args.options.autoReplyExternalMessage) {
|
|
136
|
+
data.automaticRepliesSetting['externalReplyMessage'] = args.options.autoReplyExternalMessage;
|
|
137
|
+
}
|
|
138
|
+
if (args.options.autoReplyInternalMessage) {
|
|
139
|
+
data.automaticRepliesSetting['internalReplyMessage'] = args.options.autoReplyInternalMessage;
|
|
140
|
+
}
|
|
141
|
+
if (args.options.autoReplyStartDateTime || args.options.autoReplyStartTimeZone) {
|
|
142
|
+
data.automaticRepliesSetting['scheduledStartDateTime'] = {};
|
|
143
|
+
}
|
|
144
|
+
if (args.options.autoReplyStartDateTime) {
|
|
145
|
+
data.automaticRepliesSetting['scheduledStartDateTime']['dateTime'] = args.options.autoReplyStartDateTime;
|
|
146
|
+
}
|
|
147
|
+
if (args.options.autoReplyStartTimeZone) {
|
|
148
|
+
data.automaticRepliesSetting['scheduledStartDateTime']['timeZone'] = args.options.autoReplyStartTimeZone;
|
|
149
|
+
}
|
|
150
|
+
if (args.options.autoReplyEndDateTime || args.options.autoReplyEndTimeZone) {
|
|
151
|
+
data.automaticRepliesSetting['scheduledEndDateTime'] = {};
|
|
152
|
+
}
|
|
153
|
+
if (args.options.autoReplyEndDateTime) {
|
|
154
|
+
data.automaticRepliesSetting['scheduledEndDateTime']['dateTime'] = args.options.autoReplyEndDateTime;
|
|
155
|
+
}
|
|
156
|
+
if (args.options.autoReplyEndTimeZone) {
|
|
157
|
+
data.automaticRepliesSetting['scheduledEndDateTime']['timeZone'] = args.options.autoReplyEndTimeZone;
|
|
158
|
+
}
|
|
159
|
+
return data;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export default new OutlookMailboxSettingsSetCommand();
|
|
163
|
+
//# sourceMappingURL=mailbox-settings-set.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
2
|
+
import { powerPlatform } from '../../../../utils/powerPlatform.js';
|
|
3
|
+
import { validation } from '../../../../utils/validation.js';
|
|
4
|
+
import { zod } from '../../../../utils/zod.js';
|
|
5
|
+
import PowerPlatformCommand from '../../../base/PowerPlatformCommand.js';
|
|
6
|
+
import commands from '../../commands.js';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
const options = globalOptionsZod
|
|
9
|
+
.extend({
|
|
10
|
+
url: zod.alias('u', z.string().optional()
|
|
11
|
+
.refine(url => url === undefined || validation.isValidPowerPagesUrl(url) === true, url => ({
|
|
12
|
+
message: `'${url}' is not a valid Power Pages URL.`
|
|
13
|
+
}))),
|
|
14
|
+
id: zod.alias('i', z.string().uuid().optional()),
|
|
15
|
+
name: zod.alias('n', z.string().optional()),
|
|
16
|
+
environmentName: zod.alias('e', z.string())
|
|
17
|
+
}).strict();
|
|
18
|
+
class PpWebSiteGetCommand extends PowerPlatformCommand {
|
|
19
|
+
get name() {
|
|
20
|
+
return commands.WEBSITE_GET;
|
|
21
|
+
}
|
|
22
|
+
get description() {
|
|
23
|
+
return 'Gets information about the specified Power Pages website.';
|
|
24
|
+
}
|
|
25
|
+
defaultProperties() {
|
|
26
|
+
return ['id', 'name', 'websiteUrl', 'tenantId', 'subdomain', 'type', 'status', 'siteVisibility'];
|
|
27
|
+
}
|
|
28
|
+
get schema() {
|
|
29
|
+
return options;
|
|
30
|
+
}
|
|
31
|
+
getRefinedSchema(schema) {
|
|
32
|
+
return schema
|
|
33
|
+
.refine(options => [options.url, options.id, options.name].filter(x => x !== undefined).length === 1, {
|
|
34
|
+
message: `Specify either url, id or name, but not multiple.`
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async commandAction(logger, args) {
|
|
38
|
+
if (this.verbose) {
|
|
39
|
+
await logger.logToStderr(`Retrieving the website...`);
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
let item = null;
|
|
43
|
+
if (args.options.id) {
|
|
44
|
+
item = await powerPlatform.getWebsiteById(args.options.environmentName, args.options.id);
|
|
45
|
+
}
|
|
46
|
+
else if (args.options.name) {
|
|
47
|
+
item = await powerPlatform.getWebsiteByName(args.options.environmentName, args.options.name);
|
|
48
|
+
}
|
|
49
|
+
else if (args.options.url) {
|
|
50
|
+
item = await powerPlatform.getWebsiteByUrl(args.options.environmentName, args.options.url);
|
|
51
|
+
}
|
|
52
|
+
await logger.log(item);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
this.handleRejectedODataJsonPromise(err);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export default new PpWebSiteGetCommand();
|
|
60
|
+
//# sourceMappingURL=website-get.js.map
|
package/dist/m365/pp/commands.js
CHANGED
|
@@ -33,6 +33,7 @@ export default {
|
|
|
33
33
|
SOLUTION_PUBLISHER_LIST: `${prefix} solution publisher list`,
|
|
34
34
|
SOLUTION_PUBLISHER_REMOVE: `${prefix} solution publisher remove`,
|
|
35
35
|
TENANT_SETTINGS_LIST: `${prefix} tenant settings list`,
|
|
36
|
-
TENANT_SETTINGS_SET: `${prefix} tenant settings set
|
|
36
|
+
TENANT_SETTINGS_SET: `${prefix} tenant settings set`,
|
|
37
|
+
WEBSITE_GET: `${prefix} website get`
|
|
37
38
|
};
|
|
38
39
|
//# sourceMappingURL=commands.js.map
|
|
@@ -64,25 +64,12 @@ class SpoFolderRoleAssignmentAddCommand extends SpoCommand {
|
|
|
64
64
|
const siteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
|
|
65
65
|
principalId = siteUser.Id;
|
|
66
66
|
}
|
|
67
|
-
await this.breakRoleAssignment(requestUrl);
|
|
68
67
|
await this.addRoleAssignment(requestUrl, principalId, roleDefinitionId);
|
|
69
68
|
}
|
|
70
69
|
catch (err) {
|
|
71
70
|
this.handleRejectedODataJsonPromise(err);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
async breakRoleAssignment(requestUrl) {
|
|
75
|
-
const requestOptions = {
|
|
76
|
-
url: `${requestUrl}/breakroleinheritance(true)`,
|
|
77
|
-
method: 'POST',
|
|
78
|
-
headers: {
|
|
79
|
-
'accept': 'application/json;odata=nometadata',
|
|
80
|
-
'content-type': 'application/json'
|
|
81
|
-
},
|
|
82
|
-
responseType: 'json'
|
|
83
|
-
};
|
|
84
|
-
return request.post(requestOptions);
|
|
85
|
-
}
|
|
86
73
|
async addRoleAssignment(requestUrl, principalId, roleDefinitionId) {
|
|
87
74
|
const requestOptions = {
|
|
88
75
|
url: `${requestUrl}/roleassignments/addroleassignment(principalid='${principalId}',roledefid='${roleDefinitionId}')`,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
|
+
import request from '../../../../request.js';
|
|
4
|
+
import { zod } from '../../../../utils/zod.js';
|
|
5
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
6
|
+
import commands from '../../commands.js';
|
|
7
|
+
const options = globalOptionsZod
|
|
8
|
+
.extend({
|
|
9
|
+
enabled: zod.alias('e', z.boolean())
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
|
+
class TenantPeoplePronounsSetCommand extends GraphCommand {
|
|
13
|
+
get name() {
|
|
14
|
+
return commands.PEOPLE_PRONOUNS_SET;
|
|
15
|
+
}
|
|
16
|
+
get description() {
|
|
17
|
+
return 'Manage pronouns settings for an organization';
|
|
18
|
+
}
|
|
19
|
+
get schema() {
|
|
20
|
+
return options;
|
|
21
|
+
}
|
|
22
|
+
async commandAction(logger, args) {
|
|
23
|
+
try {
|
|
24
|
+
if (this.verbose) {
|
|
25
|
+
await logger.logToStderr('Updating pronouns settings...');
|
|
26
|
+
}
|
|
27
|
+
const requestOptions = {
|
|
28
|
+
url: `${this.resource}/v1.0/admin/people/pronouns`,
|
|
29
|
+
headers: {
|
|
30
|
+
accept: 'application/json;odata.metadata=none'
|
|
31
|
+
},
|
|
32
|
+
data: {
|
|
33
|
+
isEnabledInOrganization: args.options.enabled
|
|
34
|
+
},
|
|
35
|
+
responseType: 'json'
|
|
36
|
+
};
|
|
37
|
+
const pronouns = await request.patch(requestOptions);
|
|
38
|
+
await logger.log(pronouns);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
this.handleRejectedODataJsonPromise(err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export default new TenantPeoplePronounsSetCommand();
|
|
46
|
+
//# sourceMappingURL=people-pronouns-set.js.map
|
|
@@ -8,6 +8,7 @@ export default {
|
|
|
8
8
|
PEOPLE_PROFILECARDPROPERTY_REMOVE: `${prefix} people profilecardproperty remove`,
|
|
9
9
|
PEOPLE_PROFILECARDPROPERTY_SET: `${prefix} people profilecardproperty set`,
|
|
10
10
|
PEOPLE_PRONOUNS_GET: `${prefix} people pronouns get`,
|
|
11
|
+
PEOPLE_PRONOUNS_SET: `${prefix} people pronouns set`,
|
|
11
12
|
REPORT_ACTIVEUSERCOUNTS: `${prefix} report activeusercounts`,
|
|
12
13
|
REPORT_ACTIVEUSERDETAIL: `${prefix} report activeuserdetail`,
|
|
13
14
|
REPORT_OFFICE365ACTIVATIONCOUNTS: `${prefix} report office365activationcounts`,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cli } from '../cli/cli.js';
|
|
2
|
+
import { formatting } from './formatting.js';
|
|
3
|
+
import { odata } from './odata.js';
|
|
4
|
+
export const customAppScope = {
|
|
5
|
+
/**
|
|
6
|
+
* Get a custom application scope by its name
|
|
7
|
+
* @param displayName Custom application scope display name.
|
|
8
|
+
* @param properties Comma-separated list of properties to include in the response.
|
|
9
|
+
* @returns The custom application scope.
|
|
10
|
+
* @throws Error when role definition was not found.
|
|
11
|
+
*/
|
|
12
|
+
async getCustomAppScopeByDisplayName(displayName, properties) {
|
|
13
|
+
let url = `https://graph.microsoft.com/beta/roleManagement/exchange/customAppScopes?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`;
|
|
14
|
+
if (properties) {
|
|
15
|
+
url += `&$select=${properties}`;
|
|
16
|
+
}
|
|
17
|
+
const customAppScopes = await odata.getAllItems(url);
|
|
18
|
+
if (customAppScopes.length === 0) {
|
|
19
|
+
throw `The specified custom application scope '${displayName}' does not exist.`;
|
|
20
|
+
}
|
|
21
|
+
if (customAppScopes.length > 1) {
|
|
22
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', customAppScopes);
|
|
23
|
+
const selectedCustomAppScope = await cli.handleMultipleResultsFound(`Multiple custom application scopes with name '${displayName}' found.`, resultAsKeyValuePair);
|
|
24
|
+
return selectedCustomAppScope;
|
|
25
|
+
}
|
|
26
|
+
return customAppScopes[0];
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=customAppScope.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { odata } from './odata.js';
|
|
2
|
+
import { formatting } from './formatting.js';
|
|
3
|
+
import { cli } from '../cli/cli.js';
|
|
4
|
+
export const entraServicePrincipal = {
|
|
5
|
+
/**
|
|
6
|
+
* Get service principal by its appId
|
|
7
|
+
* @param appId App id.
|
|
8
|
+
* @param properties Comma-separated list of properties to include in the response.
|
|
9
|
+
* @returns The service principal.
|
|
10
|
+
* @throws Error when service principal was not found.
|
|
11
|
+
*/
|
|
12
|
+
async getServicePrincipalByAppId(appId, properties) {
|
|
13
|
+
let url = `https://graph.microsoft.com/v1.0/servicePrincipals?$filter=appId eq '${appId}'`;
|
|
14
|
+
if (properties) {
|
|
15
|
+
url += `&$select=${properties}`;
|
|
16
|
+
}
|
|
17
|
+
const apps = await odata.getAllItems(url);
|
|
18
|
+
if (apps.length === 0) {
|
|
19
|
+
throw `Service principal with appId '${appId}' not found in Microsoft Entra ID`;
|
|
20
|
+
}
|
|
21
|
+
return apps[0];
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Get service principal by its name
|
|
25
|
+
* @param appName Service principal name.
|
|
26
|
+
* @param properties Comma-separated list of properties to include in the response.
|
|
27
|
+
* @returns The service principal.
|
|
28
|
+
* @throws Error when service principal was not found.
|
|
29
|
+
*/
|
|
30
|
+
async getServicePrincipalByAppName(appName, properties) {
|
|
31
|
+
let url = `https://graph.microsoft.com/v1.0/servicePrincipals?$filter=displayName eq '${formatting.encodeQueryParameter(appName)}'`;
|
|
32
|
+
if (properties) {
|
|
33
|
+
url += `&$select=${properties}`;
|
|
34
|
+
}
|
|
35
|
+
const apps = await odata.getAllItems(url);
|
|
36
|
+
if (apps.length === 0) {
|
|
37
|
+
throw `Service principal with name '${appName}' not found in Microsoft Entra ID`;
|
|
38
|
+
}
|
|
39
|
+
if (apps.length > 1) {
|
|
40
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', apps);
|
|
41
|
+
return await cli.handleMultipleResultsFound(`Multiple service principals with name '${appName}' found in Microsoft Entra ID.`, resultAsKeyValuePair);
|
|
42
|
+
}
|
|
43
|
+
return apps[0];
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=entraServicePrincipal.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { cli } from "../cli/cli.js";
|
|
1
2
|
import request from "../request.js";
|
|
2
3
|
import { formatting } from "./formatting.js";
|
|
4
|
+
import { odata } from "./odata.js";
|
|
3
5
|
const powerPlatformResource = 'https://api.bap.microsoft.com';
|
|
4
6
|
export const powerPlatform = {
|
|
5
7
|
async getDynamicsInstanceApiUrl(environment, asAdmin) {
|
|
@@ -24,6 +26,42 @@ export const powerPlatform = {
|
|
|
24
26
|
catch (ex) {
|
|
25
27
|
throw Error(`The environment '${environment}' could not be retrieved. See the inner exception for more details: ${ex.message}`);
|
|
26
28
|
}
|
|
29
|
+
},
|
|
30
|
+
async getWebsiteById(environment, id) {
|
|
31
|
+
const requestOptions = {
|
|
32
|
+
url: `https://api.powerplatform.com/powerpages/environments/${environment}/websites/${id}?api-version=2022-03-01-preview`,
|
|
33
|
+
headers: {
|
|
34
|
+
accept: 'application/json;odata.metadata=none'
|
|
35
|
+
},
|
|
36
|
+
responseType: 'json'
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
const response = await request.get(requestOptions);
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
catch (ex) {
|
|
43
|
+
throw Error(`The specified Power Page website with id '${id}' does not exist.`);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
async getWebsiteByName(environment, websiteName) {
|
|
47
|
+
const response = await odata.getAllItems(`https://api.powerplatform.com/powerpages/environments/${environment}/websites?api-version=2022-03-01-preview`);
|
|
48
|
+
const items = response.filter(response => response.name === websiteName);
|
|
49
|
+
if (items.length === 0) {
|
|
50
|
+
throw Error(`The specified Power Page website '${websiteName}' does not exist.`);
|
|
51
|
+
}
|
|
52
|
+
if (items.length > 1) {
|
|
53
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('websiteUrl', items);
|
|
54
|
+
return cli.handleMultipleResultsFound(`Multiple Power Page websites with name '${websiteName}' found`, resultAsKeyValuePair);
|
|
55
|
+
}
|
|
56
|
+
return items[0];
|
|
57
|
+
},
|
|
58
|
+
async getWebsiteByUrl(environment, url) {
|
|
59
|
+
const response = await odata.getAllItems(`https://api.powerplatform.com/powerpages/environments/${environment}/websites?api-version=2022-03-01-preview`);
|
|
60
|
+
const items = response.filter(response => response.websiteUrl === url);
|
|
61
|
+
if (items.length === 0) {
|
|
62
|
+
throw Error(`The specified Power Page website with url '${url}' does not exist.`);
|
|
63
|
+
}
|
|
64
|
+
return items[0];
|
|
27
65
|
}
|
|
28
66
|
};
|
|
29
67
|
//# sourceMappingURL=powerPlatform.js.map
|
|
@@ -46,6 +46,29 @@ export const roleDefinition = {
|
|
|
46
46
|
responseType: 'json'
|
|
47
47
|
};
|
|
48
48
|
return await request.get(requestOptions);
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Get an Exchange role by its name
|
|
52
|
+
* @param displayName Role definition display name.
|
|
53
|
+
* @param properties Comma-separated list of properties to include in the response.
|
|
54
|
+
* @returns The role definition.
|
|
55
|
+
* @throws Error when role definition was not found.
|
|
56
|
+
*/
|
|
57
|
+
async getExchangeRoleDefinitionByDisplayName(displayName, properties) {
|
|
58
|
+
let url = `https://graph.microsoft.com/beta/roleManagement/exchange/roleDefinitions?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`;
|
|
59
|
+
if (properties) {
|
|
60
|
+
url += `&$select=${properties}`;
|
|
61
|
+
}
|
|
62
|
+
const roleDefinitions = await odata.getAllItems(url);
|
|
63
|
+
if (roleDefinitions.length === 0) {
|
|
64
|
+
throw `The specified role definition '${displayName}' does not exist.`;
|
|
65
|
+
}
|
|
66
|
+
if (roleDefinitions.length > 1) {
|
|
67
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', roleDefinitions);
|
|
68
|
+
const selectedRoleDefinition = await cli.handleMultipleResultsFound(`Multiple role definitions with name '${displayName}' found.`, resultAsKeyValuePair);
|
|
69
|
+
return selectedRoleDefinition;
|
|
70
|
+
}
|
|
71
|
+
return roleDefinitions[0];
|
|
49
72
|
}
|
|
50
73
|
};
|
|
51
74
|
//# sourceMappingURL=roleDefinition.js.map
|
package/dist/utils/validation.js
CHANGED
|
@@ -357,6 +357,10 @@ export const validation = {
|
|
|
357
357
|
.split(' ')
|
|
358
358
|
.filter(permission => permission.indexOf('/') < 0);
|
|
359
359
|
return invalidPermissions.length > 0 ? invalidPermissions : true;
|
|
360
|
+
},
|
|
361
|
+
isValidPowerPagesUrl(url) {
|
|
362
|
+
const powerPagesUrlPattern = /^https:\/\/[a-zA-Z0-9-]+\.powerappsportals\.com$/;
|
|
363
|
+
return powerPagesUrlPattern.test(url);
|
|
360
364
|
}
|
|
361
365
|
};
|
|
362
366
|
//# sourceMappingURL=validation.js.map
|