@pnp/cli-microsoft365 7.0.0-beta.14c7857 → 7.0.0-beta.18ce559
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/dist/Command.js +2 -2
- package/dist/cli/Cli.js +1 -1
- package/dist/m365/aad/commands/m365group/m365group-conversation-list.js +5 -0
- package/dist/m365/aad/commands/m365group/m365group-conversation-post-list.js +4 -0
- package/dist/m365/aad/commands/m365group/m365group-get.js +4 -3
- package/dist/m365/aad/commands/m365group/m365group-remove.js +5 -0
- package/dist/m365/aad/commands/m365group/m365group-renew.js +5 -0
- package/dist/m365/aad/commands/m365group/m365group-set.js +5 -0
- package/dist/m365/aad/commands/m365group/m365group-teamify.js +11 -6
- package/dist/m365/aad/commands/m365group/m365group-user-add.js +5 -0
- package/dist/m365/aad/commands/m365group/m365group-user-list.js +5 -0
- package/dist/m365/aad/commands/m365group/m365group-user-remove.js +5 -0
- package/dist/m365/aad/commands/m365group/m365group-user-set.js +5 -0
- package/dist/m365/flow/commands/flow-export.js +13 -13
- package/dist/m365/pa/commands/connector/connector-export.js +5 -5
- package/dist/m365/pp/commands/chatbot/chatbot-list.js +2 -2
- package/dist/m365/spo/commands/listitem/listitem-attachment-add.js +127 -0
- package/dist/m365/spo/commands/listitem/listitem-attachment-get.js +97 -0
- package/dist/m365/spo/commands/listitem/listitem-attachment-remove.js +121 -0
- package/dist/m365/spo/commands/listitem/listitem-attachment-set.js +115 -0
- package/dist/m365/spo/commands/user/user-get.js +10 -10
- package/dist/m365/spo/commands.js +4 -0
- package/dist/utils/aadGroup.js +16 -0
- package/docs/docs/_clisettings.mdx +1 -1
- package/docs/docs/cmd/flow/flow-export.mdx +11 -11
- package/docs/docs/cmd/pa/connector/connector-export.mdx +3 -3
- package/docs/docs/cmd/pp/chatbot/chatbot-list.mdx +4 -4
- package/docs/docs/cmd/spo/listitem/listitem-attachment-add.mdx +110 -0
- package/docs/docs/cmd/spo/listitem/listitem-attachment-get.mdx +104 -0
- package/docs/docs/cmd/spo/listitem/listitem-attachment-remove.mdx +58 -0
- package/docs/docs/cmd/spo/listitem/listitem-attachment-set.mdx +58 -0
- package/docs/docs/cmd/spo/user/user-get.mdx +8 -8
- package/package.json +1 -1
package/dist/Command.js
CHANGED
|
@@ -74,7 +74,7 @@ class Command {
|
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
async validateRequiredOptions(args, command) {
|
|
77
|
-
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt,
|
|
77
|
+
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
78
78
|
let inquirer;
|
|
79
79
|
let prompted = false;
|
|
80
80
|
for (let i = 0; i < command.options.length; i++) {
|
|
@@ -109,7 +109,7 @@ class Command {
|
|
|
109
109
|
return true;
|
|
110
110
|
}
|
|
111
111
|
let inquirer;
|
|
112
|
-
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt,
|
|
112
|
+
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
113
113
|
const argsOptions = Object.keys(args.options);
|
|
114
114
|
for (const optionSet of optionsSets.sort(opt => opt.runsWhen ? 0 : 1)) {
|
|
115
115
|
if (optionSet.runsWhen && !optionSet.runsWhen(args)) {
|
package/dist/cli/Cli.js
CHANGED
|
@@ -815,7 +815,7 @@ export class Cli {
|
|
|
815
815
|
return response;
|
|
816
816
|
}
|
|
817
817
|
static async handleMultipleResultsFound(message, values) {
|
|
818
|
-
const prompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt,
|
|
818
|
+
const prompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
819
819
|
if (!prompt) {
|
|
820
820
|
throw new Error(`${message} Found: ${Object.keys(values).join(', ')}.`);
|
|
821
821
|
}
|
|
@@ -8,6 +8,7 @@ import { odata } from '../../../../utils/odata.js';
|
|
|
8
8
|
import { validation } from '../../../../utils/validation.js';
|
|
9
9
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
10
|
import commands from '../../commands.js';
|
|
11
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
11
12
|
class AadM365GroupConversationListCommand extends GraphCommand {
|
|
12
13
|
get name() {
|
|
13
14
|
return commands.M365GROUP_CONVERSATION_LIST;
|
|
@@ -26,6 +27,10 @@ class AadM365GroupConversationListCommand extends GraphCommand {
|
|
|
26
27
|
}
|
|
27
28
|
async commandAction(logger, args) {
|
|
28
29
|
try {
|
|
30
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(args.options.groupId);
|
|
31
|
+
if (!isUnifiedGroup) {
|
|
32
|
+
throw Error(`Specified group with id '${args.options.groupId}' is not a Microsoft 365 group.`);
|
|
33
|
+
}
|
|
29
34
|
const conversations = await odata.getAllItems(`${this.resource}/v1.0/groups/${args.options.groupId}/conversations`);
|
|
30
35
|
await logger.log(conversations);
|
|
31
36
|
}
|
|
@@ -31,6 +31,10 @@ class AadM365GroupConversationPostListCommand extends GraphCommand {
|
|
|
31
31
|
async commandAction(logger, args) {
|
|
32
32
|
try {
|
|
33
33
|
const retrievedgroupId = await this.getGroupId(args);
|
|
34
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(retrievedgroupId);
|
|
35
|
+
if (!isUnifiedGroup) {
|
|
36
|
+
throw Error(`Specified group with id '${retrievedgroupId}' is not a Microsoft 365 group.`);
|
|
37
|
+
}
|
|
34
38
|
const posts = await odata.getAllItems(`${this.resource}/v1.0/groups/${retrievedgroupId}/threads/${args.options.threadId}/posts`);
|
|
35
39
|
await logger.log(posts);
|
|
36
40
|
}
|
|
@@ -25,10 +25,11 @@ class AadM365GroupGetCommand extends GraphCommand {
|
|
|
25
25
|
async commandAction(logger, args) {
|
|
26
26
|
let group;
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
throw `Specified group with id '${args.options.id}' is not a Microsoft 365 group
|
|
28
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(args.options.id);
|
|
29
|
+
if (!isUnifiedGroup) {
|
|
30
|
+
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
31
31
|
}
|
|
32
|
+
group = await aadGroup.getGroupById(args.options.id);
|
|
32
33
|
if (args.options.includeSiteUrl) {
|
|
33
34
|
const requestOptions = {
|
|
34
35
|
url: `${this.resource}/v1.0/groups/${group.id}/drive?$select=webUrl`,
|
|
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _AadM365GroupRemoveCommand_instances, _AadM365GroupRemoveCommand_initTelemetry, _AadM365GroupRemoveCommand_initOptions, _AadM365GroupRemoveCommand_initValidators;
|
|
7
7
|
import { Cli } from '../../../../cli/Cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
9
10
|
import { validation } from '../../../../utils/validation.js';
|
|
10
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
12
|
import commands from '../../commands.js';
|
|
@@ -29,6 +30,10 @@ class AadM365GroupRemoveCommand extends GraphCommand {
|
|
|
29
30
|
await logger.logToStderr(`Removing Microsoft 365 Group: ${args.options.id}...`);
|
|
30
31
|
}
|
|
31
32
|
try {
|
|
33
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(args.options.id);
|
|
34
|
+
if (!isUnifiedGroup) {
|
|
35
|
+
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
36
|
+
}
|
|
32
37
|
const requestOptions = {
|
|
33
38
|
url: `${this.resource}/v1.0/groups/${args.options.id}`,
|
|
34
39
|
headers: {
|
|
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _AadM365GroupRenewCommand_instances, _AadM365GroupRenewCommand_initOptions, _AadM365GroupRenewCommand_initValidators;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
8
9
|
import { validation } from '../../../../utils/validation.js';
|
|
9
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
11
|
import commands from '../../commands.js';
|
|
@@ -26,6 +27,10 @@ class AadM365GroupRenewCommand extends GraphCommand {
|
|
|
26
27
|
await logger.logToStderr(`Renewing Microsoft 365 group's expiration: ${args.options.id}...`);
|
|
27
28
|
}
|
|
28
29
|
try {
|
|
30
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(args.options.id);
|
|
31
|
+
if (!isUnifiedGroup) {
|
|
32
|
+
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
33
|
+
}
|
|
29
34
|
const requestOptions = {
|
|
30
35
|
url: `${this.resource}/v1.0/groups/${args.options.id}/renew/`,
|
|
31
36
|
headers: {
|
|
@@ -11,6 +11,7 @@ import request from '../../../../request.js';
|
|
|
11
11
|
import { validation } from '../../../../utils/validation.js';
|
|
12
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
13
|
import commands from '../../commands.js';
|
|
14
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
14
15
|
class AadM365GroupSetCommand extends GraphCommand {
|
|
15
16
|
get name() {
|
|
16
17
|
return commands.M365GROUP_SET;
|
|
@@ -29,6 +30,10 @@ class AadM365GroupSetCommand extends GraphCommand {
|
|
|
29
30
|
}
|
|
30
31
|
async commandAction(logger, args) {
|
|
31
32
|
try {
|
|
33
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(args.options.id);
|
|
34
|
+
if (!isUnifiedGroup) {
|
|
35
|
+
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
36
|
+
}
|
|
32
37
|
if (args.options.displayName || args.options.description || typeof args.options.isPrivate !== 'undefined') {
|
|
33
38
|
if (this.verbose) {
|
|
34
39
|
await logger.logToStderr(`Updating Microsoft 365 Group ${args.options.id}...`);
|
|
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _AadM365GroupTeamifyCommand_instances, _AadM365GroupTeamifyCommand_initTelemetry, _AadM365GroupTeamifyCommand_initOptions, _AadM365GroupTeamifyCommand_initValidators, _AadM365GroupTeamifyCommand_initOptionSets;
|
|
7
7
|
import { Cli } from '../../../../cli/Cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
9
10
|
import { formatting } from '../../../../utils/formatting.js';
|
|
10
11
|
import { validation } from '../../../../utils/validation.js';
|
|
11
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
@@ -25,12 +26,12 @@ class AadM365GroupTeamifyCommand extends GraphCommand {
|
|
|
25
26
|
__classPrivateFieldGet(this, _AadM365GroupTeamifyCommand_instances, "m", _AadM365GroupTeamifyCommand_initValidators).call(this);
|
|
26
27
|
__classPrivateFieldGet(this, _AadM365GroupTeamifyCommand_instances, "m", _AadM365GroupTeamifyCommand_initOptionSets).call(this);
|
|
27
28
|
}
|
|
28
|
-
async getGroupId(
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
29
|
+
async getGroupId(options) {
|
|
30
|
+
if (options.id) {
|
|
31
|
+
return options.id;
|
|
31
32
|
}
|
|
32
33
|
const requestOptions = {
|
|
33
|
-
url: `${this.resource}/v1.0/groups?$filter=mailNickname eq '${formatting.encodeQueryParameter(
|
|
34
|
+
url: `${this.resource}/v1.0/groups?$filter=mailNickname eq '${formatting.encodeQueryParameter(options.mailNickname)}'`,
|
|
34
35
|
headers: {
|
|
35
36
|
accept: 'application/json;odata.metadata=none'
|
|
36
37
|
},
|
|
@@ -43,13 +44,18 @@ class AadM365GroupTeamifyCommand extends GraphCommand {
|
|
|
43
44
|
}
|
|
44
45
|
if (response.value.length > 1) {
|
|
45
46
|
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
|
|
46
|
-
const result = await Cli.handleMultipleResultsFound(`Multiple Microsoft 365 Groups with name '${
|
|
47
|
+
const result = await Cli.handleMultipleResultsFound(`Multiple Microsoft 365 Groups with name '${options.mailNickname}' found.`, resultAsKeyValuePair);
|
|
47
48
|
return result.id;
|
|
48
49
|
}
|
|
49
50
|
return groupItem.id;
|
|
50
51
|
}
|
|
51
52
|
async commandAction(logger, args) {
|
|
52
53
|
try {
|
|
54
|
+
const groupId = await this.getGroupId(args.options);
|
|
55
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(groupId);
|
|
56
|
+
if (!isUnifiedGroup) {
|
|
57
|
+
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
58
|
+
}
|
|
53
59
|
const data = {
|
|
54
60
|
"memberSettings": {
|
|
55
61
|
"allowCreatePrivateChannels": true,
|
|
@@ -64,7 +70,6 @@ class AadM365GroupTeamifyCommand extends GraphCommand {
|
|
|
64
70
|
"giphyContentRating": "strict"
|
|
65
71
|
}
|
|
66
72
|
};
|
|
67
|
-
const groupId = await this.getGroupId(args);
|
|
68
73
|
const requestOptions = {
|
|
69
74
|
url: `${this.resource}/v1.0/groups/${formatting.encodeQueryParameter(groupId)}/team`,
|
|
70
75
|
headers: {
|
|
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _AadM365GroupUserAddCommand_instances, _AadM365GroupUserAddCommand_initTelemetry, _AadM365GroupUserAddCommand_initOptions, _AadM365GroupUserAddCommand_initValidators, _AadM365GroupUserAddCommand_initOptionSets;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
8
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
9
10
|
import { validation } from '../../../../utils/validation.js';
|
|
10
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
@@ -31,6 +32,10 @@ class AadM365GroupUserAddCommand extends GraphCommand {
|
|
|
31
32
|
async commandAction(logger, args) {
|
|
32
33
|
try {
|
|
33
34
|
const providedGroupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
|
|
35
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(providedGroupId);
|
|
36
|
+
if (!isUnifiedGroup) {
|
|
37
|
+
throw Error(`Specified group with id '${providedGroupId}' is not a Microsoft 365 group.`);
|
|
38
|
+
}
|
|
34
39
|
let requestOptions = {
|
|
35
40
|
url: `${this.resource}/v1.0/users/${formatting.encodeQueryParameter(args.options.userName)}/id`,
|
|
36
41
|
headers: {
|
|
@@ -8,6 +8,7 @@ import { odata } from '../../../../utils/odata.js';
|
|
|
8
8
|
import { validation } from '../../../../utils/validation.js';
|
|
9
9
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
10
|
import commands from '../../commands.js';
|
|
11
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
11
12
|
class AadM365GroupUserListCommand extends GraphCommand {
|
|
12
13
|
get name() {
|
|
13
14
|
return commands.M365GROUP_USER_LIST;
|
|
@@ -24,6 +25,10 @@ class AadM365GroupUserListCommand extends GraphCommand {
|
|
|
24
25
|
}
|
|
25
26
|
async commandAction(logger, args) {
|
|
26
27
|
try {
|
|
28
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(args.options.groupId);
|
|
29
|
+
if (!isUnifiedGroup) {
|
|
30
|
+
throw Error(`Specified group with id '${args.options.groupId}' is not a Microsoft 365 group.`);
|
|
31
|
+
}
|
|
27
32
|
let users = await this.getOwners(args.options.groupId, logger);
|
|
28
33
|
if (args.options.role !== 'Owner') {
|
|
29
34
|
const membersAndGuests = await this.getMembersAndGuests(args.options.groupId, logger);
|
|
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _AadM365GroupUserRemoveCommand_instances, _AadM365GroupUserRemoveCommand_initTelemetry, _AadM365GroupUserRemoveCommand_initOptions, _AadM365GroupUserRemoveCommand_initValidators, _AadM365GroupUserRemoveCommand_initOptionSets;
|
|
7
7
|
import { Cli } from '../../../../cli/Cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
9
10
|
import { formatting } from '../../../../utils/formatting.js';
|
|
10
11
|
import { validation } from '../../../../utils/validation.js';
|
|
11
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
@@ -33,6 +34,10 @@ class AadM365GroupUserRemoveCommand extends GraphCommand {
|
|
|
33
34
|
const groupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
|
|
34
35
|
const removeUser = async () => {
|
|
35
36
|
try {
|
|
37
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(groupId);
|
|
38
|
+
if (!isUnifiedGroup) {
|
|
39
|
+
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
40
|
+
}
|
|
36
41
|
// retrieve user
|
|
37
42
|
const user = await request.get({
|
|
38
43
|
url: `${this.resource}/v1.0/users/${formatting.encodeQueryParameter(args.options.userName)}/id`,
|
|
@@ -10,6 +10,7 @@ import { validation } from '../../../../utils/validation.js';
|
|
|
10
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
11
|
import teamsCommands from '../../../teams/commands.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
13
14
|
class AadM365GroupUserSetCommand extends GraphCommand {
|
|
14
15
|
get name() {
|
|
15
16
|
return commands.M365GROUP_USER_SET;
|
|
@@ -31,6 +32,10 @@ class AadM365GroupUserSetCommand extends GraphCommand {
|
|
|
31
32
|
async commandAction(logger, args) {
|
|
32
33
|
try {
|
|
33
34
|
const groupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
|
|
35
|
+
const isUnifiedGroup = await aadGroup.isUnifiedGroup(groupId);
|
|
36
|
+
if (!isUnifiedGroup) {
|
|
37
|
+
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
38
|
+
}
|
|
34
39
|
let users = await this.getOwners(groupId, logger);
|
|
35
40
|
const membersAndGuests = await this.getMembersAndGuests(groupId, logger);
|
|
36
41
|
users = users.concat(membersAndGuests);
|
|
@@ -29,7 +29,7 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
29
29
|
let filenameFromApi = '';
|
|
30
30
|
const formatArgument = args.options.format ? args.options.format.toLowerCase() : '';
|
|
31
31
|
if (this.verbose) {
|
|
32
|
-
await logger.logToStderr(`Retrieving package resources for Microsoft Flow ${args.options.
|
|
32
|
+
await logger.logToStderr(`Retrieving package resources for Microsoft Flow ${args.options.name}...`);
|
|
33
33
|
}
|
|
34
34
|
try {
|
|
35
35
|
let res;
|
|
@@ -46,7 +46,7 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
46
46
|
},
|
|
47
47
|
data: {
|
|
48
48
|
"baseResourceIds": [
|
|
49
|
-
`/providers/Microsoft.Flow/flows/${args.options.
|
|
49
|
+
`/providers/Microsoft.Flow/flows/${args.options.name}`
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
52
|
responseType: 'json'
|
|
@@ -57,11 +57,11 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
57
57
|
throw res.errors[0].message;
|
|
58
58
|
}
|
|
59
59
|
if (this.verbose) {
|
|
60
|
-
await logger.logToStderr(`Initiating package export for Microsoft Flow ${args.options.
|
|
60
|
+
await logger.logToStderr(`Initiating package export for Microsoft Flow ${args.options.name}...`);
|
|
61
61
|
}
|
|
62
62
|
let requestOptions = {
|
|
63
63
|
url: formatArgument === 'json' ?
|
|
64
|
-
`https://management.azure.com/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.
|
|
64
|
+
`https://management.azure.com/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`
|
|
65
65
|
: `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/exportPackage?api-version=2016-11-01`,
|
|
66
66
|
headers: {
|
|
67
67
|
accept: 'application/json'
|
|
@@ -78,7 +78,7 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
78
78
|
});
|
|
79
79
|
requestOptions['data'] = {
|
|
80
80
|
"includedResourceIds": [
|
|
81
|
-
`/providers/Microsoft.Flow/flows/${args.options.
|
|
81
|
+
`/providers/Microsoft.Flow/flows/${args.options.name}`
|
|
82
82
|
],
|
|
83
83
|
"details": {
|
|
84
84
|
"displayName": args.options.packageDisplayName,
|
|
@@ -91,7 +91,7 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
91
91
|
}
|
|
92
92
|
res = formatArgument === 'json' ? await request.get(requestOptions) : await request.post(requestOptions);
|
|
93
93
|
if (this.verbose) {
|
|
94
|
-
await logger.logToStderr(`Getting file for Microsoft Flow ${args.options.
|
|
94
|
+
await logger.logToStderr(`Getting file for Microsoft Flow ${args.options.name}...`);
|
|
95
95
|
}
|
|
96
96
|
const downloadFileUrl = formatArgument === 'json' ? '' : res.packageLink.value;
|
|
97
97
|
const filenameRegEx = /([^\/]+\.zip)/i;
|
|
@@ -105,7 +105,7 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
105
105
|
}
|
|
106
106
|
requestOptions = {
|
|
107
107
|
url: formatArgument === 'json' ?
|
|
108
|
-
`https://management.azure.com/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.
|
|
108
|
+
`https://management.azure.com/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}/exportToARMTemplate?api-version=2016-11-01`
|
|
109
109
|
: downloadFileUrl,
|
|
110
110
|
// Set responseType to arraybuffer, otherwise binary data will be encoded
|
|
111
111
|
// to utf8 and binary data is corrupt
|
|
@@ -149,27 +149,27 @@ _FlowExportCommand_instances = new WeakSet(), _FlowExportCommand_initTelemetry =
|
|
|
149
149
|
});
|
|
150
150
|
}, _FlowExportCommand_initOptions = function _FlowExportCommand_initOptions() {
|
|
151
151
|
this.options.unshift({
|
|
152
|
-
option: '-
|
|
152
|
+
option: '-n, --name <name>'
|
|
153
153
|
}, {
|
|
154
154
|
option: '-e, --environmentName <environmentName>'
|
|
155
155
|
}, {
|
|
156
|
-
option: '-
|
|
156
|
+
option: '-d, --packageDisplayName [packageDisplayName]'
|
|
157
157
|
}, {
|
|
158
|
-
option: '
|
|
158
|
+
option: '--packageDescription [packageDescription]'
|
|
159
159
|
}, {
|
|
160
160
|
option: '-c, --packageCreatedBy [packageCreatedBy]'
|
|
161
161
|
}, {
|
|
162
162
|
option: '-s, --packageSourceEnvironment [packageSourceEnvironment]'
|
|
163
163
|
}, {
|
|
164
|
-
option: '--format [format]'
|
|
164
|
+
option: '-f, --format [format]'
|
|
165
165
|
}, {
|
|
166
166
|
option: '-p, --path [path]'
|
|
167
167
|
});
|
|
168
168
|
}, _FlowExportCommand_initValidators = function _FlowExportCommand_initValidators() {
|
|
169
169
|
this.validators.push(async (args) => {
|
|
170
170
|
const lowerCaseFormat = args.options.format ? args.options.format.toLowerCase() : '';
|
|
171
|
-
if (!validation.isValidGuid(args.options.
|
|
172
|
-
return `${args.options.
|
|
171
|
+
if (!validation.isValidGuid(args.options.name)) {
|
|
172
|
+
return `${args.options.name} is not a valid GUID`;
|
|
173
173
|
}
|
|
174
174
|
if (args.options.format && (lowerCaseFormat !== 'json' && lowerCaseFormat !== 'zip')) {
|
|
175
175
|
return 'Option format must be json or zip. Default is zip';
|
|
@@ -29,9 +29,9 @@ class PaConnectorExportCommand extends PowerAppsCommand {
|
|
|
29
29
|
__classPrivateFieldGet(this, _PaConnectorExportCommand_instances, "m", _PaConnectorExportCommand_initValidators).call(this);
|
|
30
30
|
}
|
|
31
31
|
async commandAction(logger, args) {
|
|
32
|
-
const outputFolder = path.resolve(args.options.outputFolder || '.', args.options.
|
|
32
|
+
const outputFolder = path.resolve(args.options.outputFolder || '.', args.options.name);
|
|
33
33
|
const requestOptions = {
|
|
34
|
-
url: `${this.resource}/providers/Microsoft.PowerApps/apis/${formatting.encodeQueryParameter(args.options.
|
|
34
|
+
url: `${this.resource}/providers/Microsoft.PowerApps/apis/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01&$filter=environment%20eq%20%27${formatting.encodeQueryParameter(args.options.environmentName)}%27%20and%20IsCustomApi%20eq%20%27True%27`,
|
|
35
35
|
headers: {
|
|
36
36
|
accept: 'application/json'
|
|
37
37
|
},
|
|
@@ -53,7 +53,7 @@ class PaConnectorExportCommand extends PowerAppsCommand {
|
|
|
53
53
|
const settings = {
|
|
54
54
|
apiDefinition: "apiDefinition.swagger.json",
|
|
55
55
|
apiProperties: "apiProperties.json",
|
|
56
|
-
connectorId: args.options.
|
|
56
|
+
connectorId: args.options.name,
|
|
57
57
|
environment: args.options.environmentName,
|
|
58
58
|
icon: "icon.png",
|
|
59
59
|
powerAppsApiVersion: "2016-11-01",
|
|
@@ -157,7 +157,7 @@ _PaConnectorExportCommand_instances = new WeakSet(), _PaConnectorExportCommand_i
|
|
|
157
157
|
this.options.unshift({
|
|
158
158
|
option: '-e, --environmentName <environmentName>'
|
|
159
159
|
}, {
|
|
160
|
-
option: '-
|
|
160
|
+
option: '-n, --name <name>'
|
|
161
161
|
}, {
|
|
162
162
|
option: '--outputFolder [outputFolder]'
|
|
163
163
|
});
|
|
@@ -167,7 +167,7 @@ _PaConnectorExportCommand_instances = new WeakSet(), _PaConnectorExportCommand_i
|
|
|
167
167
|
!fs.existsSync(path.resolve(args.options.outputFolder))) {
|
|
168
168
|
return `Specified output folder ${args.options.outputFolder} doesn't exist`;
|
|
169
169
|
}
|
|
170
|
-
const outputFolder = path.resolve(args.options.outputFolder || '.', args.options.
|
|
170
|
+
const outputFolder = path.resolve(args.options.outputFolder || '.', args.options.name);
|
|
171
171
|
if (fs.existsSync(outputFolder)) {
|
|
172
172
|
return `Connector output folder ${outputFolder} already exists`;
|
|
173
173
|
}
|
|
@@ -16,7 +16,7 @@ class PpChatbotListCommand extends PowerPlatformCommand {
|
|
|
16
16
|
return 'Lists Microsoft Power Platform chatbots in the specified Power Platform environment';
|
|
17
17
|
}
|
|
18
18
|
defaultProperties() {
|
|
19
|
-
return ['
|
|
19
|
+
return ['name', 'botid', 'publishedOn', 'createdOn', 'botModifiedOn'];
|
|
20
20
|
}
|
|
21
21
|
constructor() {
|
|
22
22
|
super();
|
|
@@ -55,7 +55,7 @@ class PpChatbotListCommand extends PowerPlatformCommand {
|
|
|
55
55
|
<attribute name='timezoneruleversionnumber' alias='timezoneRuleVersionNumber' />,
|
|
56
56
|
<attribute name='utcconversiontimezonecode' alias='utcConversionTimezoneCode' />,
|
|
57
57
|
<attribute name='versionnumber' alias='versionNumber' />,
|
|
58
|
-
<attribute name='name' alias='
|
|
58
|
+
<attribute name='name' alias='name' />,
|
|
59
59
|
<attribute name='botid' alias='cdsBotId' />,
|
|
60
60
|
<attribute name='ownerid' alias='ownerId' />,
|
|
61
61
|
<attribute name='synchronizationstatus' alias='synchronizationStatus' />
|
|
@@ -0,0 +1,127 @@
|
|
|
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 _SpoListItemAttachmentAddCommand_instances, _SpoListItemAttachmentAddCommand_initTelemetry, _SpoListItemAttachmentAddCommand_initOptions, _SpoListItemAttachmentAddCommand_initValidators, _SpoListItemAttachmentAddCommand_initOptionSets;
|
|
7
|
+
import request from '../../../../request.js';
|
|
8
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
9
|
+
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
10
|
+
import { validation } from '../../../../utils/validation.js';
|
|
11
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
|
+
import commands from '../../commands.js';
|
|
13
|
+
import fs from 'fs';
|
|
14
|
+
class SpoListItemAttachmentAddCommand extends SpoCommand {
|
|
15
|
+
get name() {
|
|
16
|
+
return commands.LISTITEM_ATTACHMENT_ADD;
|
|
17
|
+
}
|
|
18
|
+
get description() {
|
|
19
|
+
return 'Adds an attachment to a list item';
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
_SpoListItemAttachmentAddCommand_instances.add(this);
|
|
24
|
+
__classPrivateFieldGet(this, _SpoListItemAttachmentAddCommand_instances, "m", _SpoListItemAttachmentAddCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _SpoListItemAttachmentAddCommand_instances, "m", _SpoListItemAttachmentAddCommand_initOptions).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _SpoListItemAttachmentAddCommand_instances, "m", _SpoListItemAttachmentAddCommand_initValidators).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _SpoListItemAttachmentAddCommand_instances, "m", _SpoListItemAttachmentAddCommand_initOptionSets).call(this);
|
|
28
|
+
}
|
|
29
|
+
async commandAction(logger, args) {
|
|
30
|
+
if (this.verbose) {
|
|
31
|
+
await logger.logToStderr(`Adding an attachment to list item with id ${args.options.listItemId} on list ${args.options.listId || args.options.listTitle || args.options.listUrl} on web ${args.options.webUrl}.`);
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const fileName = this.getFileName(args.options.filePath, args.options.fileName);
|
|
35
|
+
const fileBody = fs.readFileSync(args.options.filePath);
|
|
36
|
+
const requestOptions = {
|
|
37
|
+
url: `${args.options.webUrl}/_api/web/${this.getListUrl(args.options.webUrl, args.options.listId, args.options.listTitle, args.options.listUrl)}/items(${args.options.listItemId})/AttachmentFiles/add(FileName='${fileName}')`,
|
|
38
|
+
headers: {
|
|
39
|
+
'accept': 'application/json;odata=nometadata'
|
|
40
|
+
},
|
|
41
|
+
data: fileBody,
|
|
42
|
+
responseType: 'json'
|
|
43
|
+
};
|
|
44
|
+
const response = await request.post(requestOptions);
|
|
45
|
+
await logger.log(response);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
if (err.error &&
|
|
49
|
+
err.error['odata.error'] &&
|
|
50
|
+
err.error['odata.error'].message && err.error['odata.error'].message.value.indexOf('The document or folder name was not changed.') > -1) {
|
|
51
|
+
this.handleError(err.error['odata.error'].message.value.split('\n')[0]);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.handleRejectedODataJsonPromise(err);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
getFileName(filePath, fileName) {
|
|
59
|
+
if (!fileName) {
|
|
60
|
+
return filePath.replace(/^.*[\\\/]/, '');
|
|
61
|
+
}
|
|
62
|
+
const extension = filePath.split('.').pop();
|
|
63
|
+
if (!fileName.endsWith(`.${extension}`)) {
|
|
64
|
+
fileName += `.${extension}`;
|
|
65
|
+
}
|
|
66
|
+
return fileName;
|
|
67
|
+
}
|
|
68
|
+
getListUrl(webUrl, listId, listTitle, listUrl) {
|
|
69
|
+
if (listId) {
|
|
70
|
+
return `lists(guid'${formatting.encodeQueryParameter(listId)}')`;
|
|
71
|
+
}
|
|
72
|
+
else if (listTitle) {
|
|
73
|
+
return `lists/getByTitle('${formatting.encodeQueryParameter(listTitle)}')`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const listServerRelativeUrl = urlUtil.getServerRelativePath(webUrl, listUrl);
|
|
77
|
+
return `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_SpoListItemAttachmentAddCommand_instances = new WeakSet(), _SpoListItemAttachmentAddCommand_initTelemetry = function _SpoListItemAttachmentAddCommand_initTelemetry() {
|
|
82
|
+
this.telemetry.push((args) => {
|
|
83
|
+
Object.assign(this.telemetryProperties, {
|
|
84
|
+
listId: typeof args.options.listId !== 'undefined',
|
|
85
|
+
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
86
|
+
listUrl: typeof args.options.listUrl !== 'undefined',
|
|
87
|
+
fileName: typeof args.options.fileName !== 'undefined'
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}, _SpoListItemAttachmentAddCommand_initOptions = function _SpoListItemAttachmentAddCommand_initOptions() {
|
|
91
|
+
this.options.unshift({
|
|
92
|
+
option: '-u, --webUrl <webUrl>'
|
|
93
|
+
}, {
|
|
94
|
+
option: '--listId [listId]'
|
|
95
|
+
}, {
|
|
96
|
+
option: '--listTitle [listTitle]'
|
|
97
|
+
}, {
|
|
98
|
+
option: '--listUrl [listUrl]'
|
|
99
|
+
}, {
|
|
100
|
+
option: '--listItemId <listItemId>'
|
|
101
|
+
}, {
|
|
102
|
+
option: '-p, --filePath <filePath>'
|
|
103
|
+
}, {
|
|
104
|
+
option: '-n, --fileName [fileName]'
|
|
105
|
+
});
|
|
106
|
+
}, _SpoListItemAttachmentAddCommand_initValidators = function _SpoListItemAttachmentAddCommand_initValidators() {
|
|
107
|
+
this.validators.push(async (args) => {
|
|
108
|
+
const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
|
|
109
|
+
if (isValidSharePointUrl !== true) {
|
|
110
|
+
return isValidSharePointUrl;
|
|
111
|
+
}
|
|
112
|
+
if (isNaN(args.options.listItemId)) {
|
|
113
|
+
return `${args.options.listItemId} in option listItemId is not a valid number.`;
|
|
114
|
+
}
|
|
115
|
+
if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
|
|
116
|
+
return `${args.options.listId} in option listId is not a valid GUID.`;
|
|
117
|
+
}
|
|
118
|
+
if (!fs.existsSync(args.options.filePath)) {
|
|
119
|
+
return `File with path '${args.options.filePath}' was not found.`;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
});
|
|
123
|
+
}, _SpoListItemAttachmentAddCommand_initOptionSets = function _SpoListItemAttachmentAddCommand_initOptionSets() {
|
|
124
|
+
this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] });
|
|
125
|
+
};
|
|
126
|
+
export default new SpoListItemAttachmentAddCommand();
|
|
127
|
+
//# sourceMappingURL=listitem-attachment-add.js.map
|