@pnp/cli-microsoft365 9.0.0-beta.33615bd → 9.0.0-beta.59b026e
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/config.js +1 -1
- package/dist/m365/commands/status.js +2 -2
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +13 -13
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +18 -18
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +1 -1
- package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
- package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
- package/dist/m365/flow/commands/flow-get.js +1 -1
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +1 -1
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +1 -10
- package/dist/m365/spo/commands/file/file-copy.js +55 -34
- package/dist/m365/spo/commands/folder/folder-set.js +0 -4
- package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +86 -0
- package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
- package/dist/m365/spo/commands/list/ListInstance.js +6 -1
- package/dist/m365/spo/commands/list/list-get.js +9 -3
- package/dist/m365/spo/commands/site/site-remove.js +1 -7
- package/dist/m365/spo/commands.js +2 -1
- package/dist/utils/drive.js +61 -0
- package/dist/utils/spo.js +106 -0
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-add.mdx +12 -12
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-get.mdx +14 -14
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-list.mdx +5 -5
- package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
- package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
- package/docs/docs/cmd/flow/flow-get.mdx +149 -283
- package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +11 -12
- package/docs/docs/cmd/spo/file/file-copy.mdx +119 -12
- package/docs/docs/cmd/spo/folder/folder-set.mdx +0 -6
- package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
- package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
- package/docs/docs/cmd/spo/site/site-remove.mdx +0 -3
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
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 _SpoFolderSharingLinkListCommand_instances, _SpoFolderSharingLinkListCommand_initTelemetry, _SpoFolderSharingLinkListCommand_initOptions, _SpoFolderSharingLinkListCommand_initOptionSets, _SpoFolderSharingLinkListCommand_initValidators, _SpoFolderSharingLinkListCommand_initTypes;
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import { spo } from '../../../../utils/spo.js';
|
|
9
|
+
import { odata } from '../../../../utils/odata.js';
|
|
10
|
+
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
11
|
+
import { drive } from '../../../../utils/drive.js';
|
|
12
|
+
import { validation } from '../../../../utils/validation.js';
|
|
13
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
14
|
+
import commands from '../../commands.js';
|
|
15
|
+
class SpoFolderSharingLinkListCommand extends SpoCommand {
|
|
16
|
+
get name() {
|
|
17
|
+
return commands.FOLDER_SHARINGLINK_LIST;
|
|
18
|
+
}
|
|
19
|
+
get description() {
|
|
20
|
+
return 'Lists all the sharing links of a specific folder';
|
|
21
|
+
}
|
|
22
|
+
defaultProperties() {
|
|
23
|
+
return ['id', 'scope', 'roles', 'link'];
|
|
24
|
+
}
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
_SpoFolderSharingLinkListCommand_instances.add(this);
|
|
28
|
+
this.allowedScopes = ['anonymous', 'users', 'organization'];
|
|
29
|
+
__classPrivateFieldGet(this, _SpoFolderSharingLinkListCommand_instances, "m", _SpoFolderSharingLinkListCommand_initTelemetry).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _SpoFolderSharingLinkListCommand_instances, "m", _SpoFolderSharingLinkListCommand_initOptions).call(this);
|
|
31
|
+
__classPrivateFieldGet(this, _SpoFolderSharingLinkListCommand_instances, "m", _SpoFolderSharingLinkListCommand_initOptionSets).call(this);
|
|
32
|
+
__classPrivateFieldGet(this, _SpoFolderSharingLinkListCommand_instances, "m", _SpoFolderSharingLinkListCommand_initValidators).call(this);
|
|
33
|
+
__classPrivateFieldGet(this, _SpoFolderSharingLinkListCommand_instances, "m", _SpoFolderSharingLinkListCommand_initTypes).call(this);
|
|
34
|
+
}
|
|
35
|
+
async commandAction(logger, args) {
|
|
36
|
+
if (this.verbose) {
|
|
37
|
+
await logger.logToStderr(`Retrieving sharing links for folder ${args.options.folderId || args.options.folderUrl}...`);
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const relFolderUrl = await spo.getFolderServerRelativeUrl(args.options.webUrl, args.options.folderUrl, args.options.folderId, logger, args.options.verbose);
|
|
41
|
+
const absoluteFolderUrl = urlUtil.getAbsoluteUrl(args.options.webUrl, relFolderUrl);
|
|
42
|
+
const folderUrl = new URL(absoluteFolderUrl);
|
|
43
|
+
const siteId = await spo.getSiteId(args.options.webUrl);
|
|
44
|
+
const driveDetails = await drive.getDriveByUrl(siteId, folderUrl, logger, args.options.verbose);
|
|
45
|
+
const itemId = await drive.getDriveItemId(driveDetails, folderUrl, logger, args.options.verbose);
|
|
46
|
+
let requestUrl = `https://graph.microsoft.com/v1.0/drives/${driveDetails.id}/items/${itemId}/permissions?$filter=Link ne null`;
|
|
47
|
+
if (args.options.scope) {
|
|
48
|
+
requestUrl += ` and Link/Scope eq '${args.options.scope}'`;
|
|
49
|
+
}
|
|
50
|
+
const sharingLinks = await odata.getAllItems(requestUrl);
|
|
51
|
+
// remove grantedToIdentities from the sharing link object
|
|
52
|
+
const filteredSharingLinks = sharingLinks.map(link => {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
54
|
+
const { grantedToIdentities, ...filteredLink } = link;
|
|
55
|
+
return filteredLink;
|
|
56
|
+
});
|
|
57
|
+
if (!args.options.output || !cli.shouldTrimOutput(args.options.output)) {
|
|
58
|
+
await logger.log(filteredSharingLinks);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
//converted to text friendly output
|
|
62
|
+
await logger.log(filteredSharingLinks.map(i => {
|
|
63
|
+
return {
|
|
64
|
+
id: i.id,
|
|
65
|
+
roles: i.roles.join(','),
|
|
66
|
+
link: i.link.webUrl,
|
|
67
|
+
scope: i.link.scope
|
|
68
|
+
};
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
this.handleRejectedODataJsonPromise(err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
_SpoFolderSharingLinkListCommand_instances = new WeakSet(), _SpoFolderSharingLinkListCommand_initTelemetry = function _SpoFolderSharingLinkListCommand_initTelemetry() {
|
|
78
|
+
this.telemetry.push((args) => {
|
|
79
|
+
Object.assign(this.telemetryProperties, {
|
|
80
|
+
folderUrl: typeof args.options.folderUrl !== 'undefined',
|
|
81
|
+
folderId: typeof args.options.folderId !== 'undefined',
|
|
82
|
+
scope: typeof args.options.scope !== 'undefined'
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}, _SpoFolderSharingLinkListCommand_initOptions = function _SpoFolderSharingLinkListCommand_initOptions() {
|
|
86
|
+
this.options.unshift({ option: '-u, --webUrl <webUrl>' }, { option: '--folderUrl [folderUrl]' }, { option: '--folderId [folderId]' }, {
|
|
87
|
+
option: '-s, --scope [scope]',
|
|
88
|
+
autocomplete: this.allowedScopes
|
|
89
|
+
});
|
|
90
|
+
}, _SpoFolderSharingLinkListCommand_initOptionSets = function _SpoFolderSharingLinkListCommand_initOptionSets() {
|
|
91
|
+
this.optionSets.push({ options: ['folderUrl', 'folderId'] });
|
|
92
|
+
}, _SpoFolderSharingLinkListCommand_initValidators = function _SpoFolderSharingLinkListCommand_initValidators() {
|
|
93
|
+
this.validators.push(async (args) => {
|
|
94
|
+
const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
|
|
95
|
+
if (isValidSharePointUrl !== true) {
|
|
96
|
+
return isValidSharePointUrl;
|
|
97
|
+
}
|
|
98
|
+
if (args.options.folderId && !validation.isValidGuid(args.options.folderId)) {
|
|
99
|
+
return `${args.options.folderId} is not a valid GUID`;
|
|
100
|
+
}
|
|
101
|
+
if (args.options.scope && !this.allowedScopes.some(scope => scope === args.options.scope)) {
|
|
102
|
+
return `'${args.options.scope}' is not a valid scope. Allowed values are: ${this.allowedScopes.join(',')}`;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
});
|
|
106
|
+
}, _SpoFolderSharingLinkListCommand_initTypes = function _SpoFolderSharingLinkListCommand_initTypes() {
|
|
107
|
+
this.types.string.push('webUrl', 'folderUrl', 'folderId', 'scope');
|
|
108
|
+
};
|
|
109
|
+
export default new SpoFolderSharingLinkListCommand();
|
|
110
|
+
//# sourceMappingURL=folder-sharinglink-list.js.map
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var DefaultTrimModeType;
|
|
2
|
+
(function (DefaultTrimModeType) {
|
|
3
|
+
DefaultTrimModeType[DefaultTrimModeType["NoExpiration"] = 0] = "NoExpiration";
|
|
4
|
+
DefaultTrimModeType[DefaultTrimModeType["ExpireAfter"] = 1] = "ExpireAfter";
|
|
5
|
+
DefaultTrimModeType[DefaultTrimModeType["AutoExpiration"] = 2] = "AutoExpiration";
|
|
6
|
+
})(DefaultTrimModeType || (DefaultTrimModeType = {}));
|
|
2
7
|
//# sourceMappingURL=ListInstance.js.map
|
|
@@ -10,6 +10,7 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
11
11
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
|
+
import { DefaultTrimModeType } from "./ListInstance.js";
|
|
13
14
|
import { ListPrincipalType } from './ListPrincipalType.js';
|
|
14
15
|
class SpoListGetCommand extends SpoCommand {
|
|
15
16
|
get name() {
|
|
@@ -49,9 +50,11 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
49
50
|
if (fieldsProperties.expandProperties.length > 0) {
|
|
50
51
|
queryParams.push(`$expand=${fieldsProperties.expandProperties.join(',')}`);
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
if (queryParams.length === 0) {
|
|
54
|
+
queryParams.push(`$expand=VersionPolicies`);
|
|
55
|
+
}
|
|
53
56
|
const requestOptions = {
|
|
54
|
-
url: `${requestUrl}
|
|
57
|
+
url: `${requestUrl}?${queryParams.join('&')}`,
|
|
55
58
|
headers: {
|
|
56
59
|
'accept': 'application/json;odata=nometadata'
|
|
57
60
|
},
|
|
@@ -64,6 +67,9 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
64
67
|
r.Member.PrincipalTypeString = ListPrincipalType[r.Member.PrincipalType];
|
|
65
68
|
});
|
|
66
69
|
}
|
|
70
|
+
if (listInstance.VersionPolicies) {
|
|
71
|
+
listInstance.VersionPolicies.DefaultTrimModeValue = DefaultTrimModeType[listInstance.VersionPolicies.DefaultTrimMode];
|
|
72
|
+
}
|
|
67
73
|
await logger.log(listInstance);
|
|
68
74
|
}
|
|
69
75
|
catch (err) {
|
|
@@ -74,7 +80,7 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
74
80
|
const selectProperties = [];
|
|
75
81
|
let expandProperties = [];
|
|
76
82
|
if (withPermissions) {
|
|
77
|
-
expandProperties = ['HasUniqueRoleAssignments', 'RoleAssignments/Member', 'RoleAssignments/RoleDefinitionBindings'];
|
|
83
|
+
expandProperties = ['HasUniqueRoleAssignments', 'RoleAssignments/Member', 'RoleAssignments/RoleDefinitionBindings', 'VersionPolicies'];
|
|
78
84
|
}
|
|
79
85
|
if (properties) {
|
|
80
86
|
properties.split(',').forEach((property) => {
|
|
@@ -31,9 +31,6 @@ class SpoSiteRemoveCommand extends SpoCommand {
|
|
|
31
31
|
__classPrivateFieldGet(this, _SpoSiteRemoveCommand_instances, "m", _SpoSiteRemoveCommand_initTypes).call(this);
|
|
32
32
|
}
|
|
33
33
|
async commandAction(logger, args) {
|
|
34
|
-
if (args.options.wait) {
|
|
35
|
-
await this.warn(logger, `Option 'wait' is deprecated and will be removed in the next major release.`);
|
|
36
|
-
}
|
|
37
34
|
if (args.options.force) {
|
|
38
35
|
await this.removeSite(logger, args.options);
|
|
39
36
|
}
|
|
@@ -196,7 +193,6 @@ _SpoSiteRemoveCommand_instances = new WeakSet(), _SpoSiteRemoveCommand_initTelem
|
|
|
196
193
|
Object.assign(this.telemetryProperties, {
|
|
197
194
|
skipRecycleBin: !!args.options.skipRecycleBin,
|
|
198
195
|
fromRecycleBin: !!args.options.fromRecycleBin,
|
|
199
|
-
wait: !!args.options.wait,
|
|
200
196
|
force: !!args.options.force
|
|
201
197
|
});
|
|
202
198
|
});
|
|
@@ -207,8 +203,6 @@ _SpoSiteRemoveCommand_instances = new WeakSet(), _SpoSiteRemoveCommand_initTelem
|
|
|
207
203
|
option: '--skipRecycleBin'
|
|
208
204
|
}, {
|
|
209
205
|
option: '--fromRecycleBin'
|
|
210
|
-
}, {
|
|
211
|
-
option: '--wait'
|
|
212
206
|
}, {
|
|
213
207
|
option: '-f, --force'
|
|
214
208
|
});
|
|
@@ -230,7 +224,7 @@ _SpoSiteRemoveCommand_instances = new WeakSet(), _SpoSiteRemoveCommand_initTelem
|
|
|
230
224
|
});
|
|
231
225
|
}, _SpoSiteRemoveCommand_initTypes = function _SpoSiteRemoveCommand_initTypes() {
|
|
232
226
|
this.types.string.push('url');
|
|
233
|
-
this.types.boolean.push('skipRecycleBin', 'fromRecycleBin', '
|
|
227
|
+
this.types.boolean.push('skipRecycleBin', 'fromRecycleBin', 'force');
|
|
234
228
|
};
|
|
235
229
|
export default new SpoSiteRemoveCommand();
|
|
236
230
|
//# sourceMappingURL=site-remove.js.map
|
|
@@ -92,7 +92,6 @@ export default {
|
|
|
92
92
|
FOLDER_LIST: `${prefix} folder list`,
|
|
93
93
|
FOLDER_MOVE: `${prefix} folder move`,
|
|
94
94
|
FOLDER_REMOVE: `${prefix} folder remove`,
|
|
95
|
-
FOLDER_RENAME: `${prefix} folder rename`,
|
|
96
95
|
FOLDER_SET: `${prefix} folder set`,
|
|
97
96
|
FOLDER_RETENTIONLABEL_ENSURE: `${prefix} folder retentionlabel ensure`,
|
|
98
97
|
FOLDER_RETENTIONLABEL_REMOVE: `${prefix} folder retentionlabel remove`,
|
|
@@ -100,6 +99,8 @@ export default {
|
|
|
100
99
|
FOLDER_ROLEASSIGNMENT_ADD: `${prefix} folder roleassignment add`,
|
|
101
100
|
FOLDER_ROLEINHERITANCE_BREAK: `${prefix} folder roleinheritance break`,
|
|
102
101
|
FOLDER_ROLEINHERITANCE_RESET: `${prefix} folder roleinheritance reset`,
|
|
102
|
+
FOLDER_SHARINGLINK_GET: `${prefix} folder sharinglink get`,
|
|
103
|
+
FOLDER_SHARINGLINK_LIST: `${prefix} folder sharinglink list`,
|
|
103
104
|
GET: `${prefix} get`,
|
|
104
105
|
GROUP_ADD: `${prefix} group add`,
|
|
105
106
|
GROUP_GET: `${prefix} group get`,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import request from "../request.js";
|
|
2
|
+
export const drive = {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the Drive associated with the specified site and URL.
|
|
5
|
+
* @param siteId Site ID
|
|
6
|
+
* @param url Drive URL
|
|
7
|
+
* @param logger The logger object
|
|
8
|
+
* @param verbose Set for verbose logging
|
|
9
|
+
* @returns The Drive associated with the drive URL.
|
|
10
|
+
*/
|
|
11
|
+
async getDriveByUrl(siteId, url, logger, verbose) {
|
|
12
|
+
if (verbose && logger) {
|
|
13
|
+
await logger.logToStderr(`Retrieving drive information for URL: ${url.href}`);
|
|
14
|
+
}
|
|
15
|
+
const requestOptions = {
|
|
16
|
+
url: `https://graph.microsoft.com/v1.0/sites/${siteId}/drives?$select=webUrl,id`,
|
|
17
|
+
headers: {
|
|
18
|
+
accept: 'application/json;odata.metadata=none'
|
|
19
|
+
},
|
|
20
|
+
responseType: 'json'
|
|
21
|
+
};
|
|
22
|
+
const drives = await request.get(requestOptions);
|
|
23
|
+
const lowerCaseFolderUrl = url.href.toLowerCase();
|
|
24
|
+
const drive = drives.value
|
|
25
|
+
.sort((a, b) => b.webUrl.localeCompare(a.webUrl))
|
|
26
|
+
.find((d) => {
|
|
27
|
+
const driveUrl = d.webUrl.toLowerCase();
|
|
28
|
+
return lowerCaseFolderUrl.startsWith(driveUrl) &&
|
|
29
|
+
(driveUrl.length === lowerCaseFolderUrl.length ||
|
|
30
|
+
lowerCaseFolderUrl[driveUrl.length] === '/');
|
|
31
|
+
});
|
|
32
|
+
if (!drive) {
|
|
33
|
+
throw new Error(`Drive '${url.href}' not found`);
|
|
34
|
+
}
|
|
35
|
+
return drive;
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the ID of a drive item (file, folder, etc.) associated with the given drive and item URL.
|
|
39
|
+
* @param drive The Drive object containing the item
|
|
40
|
+
* @param itemUrl Item URL
|
|
41
|
+
* @param logger The logger object
|
|
42
|
+
* @param verbose Set for verbose logging
|
|
43
|
+
* @returns Drive item ID
|
|
44
|
+
*/
|
|
45
|
+
async getDriveItemId(drive, itemUrl, logger, verbose) {
|
|
46
|
+
const relativeItemUrl = itemUrl.href.replace(new RegExp(`${drive.webUrl}`, 'i'), '').replace(/\/+$/, '');
|
|
47
|
+
if (verbose && logger) {
|
|
48
|
+
await logger.logToStderr(`Retrieving drive item ID for URL: ${relativeItemUrl}`);
|
|
49
|
+
}
|
|
50
|
+
const requestOptions = {
|
|
51
|
+
url: `https://graph.microsoft.com/v1.0/drives/${drive.id}/root${relativeItemUrl ? `:${relativeItemUrl}` : ''}?$select=id`,
|
|
52
|
+
headers: {
|
|
53
|
+
accept: 'application/json;odata.metadata=none'
|
|
54
|
+
},
|
|
55
|
+
responseType: 'json'
|
|
56
|
+
};
|
|
57
|
+
const driveItem = await request.get(requestOptions);
|
|
58
|
+
return driveItem?.id;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=drive.js.map
|
package/dist/utils/spo.js
CHANGED
|
@@ -12,6 +12,16 @@ import { RoleType } from '../m365/spo/commands/roledefinition/RoleType.js';
|
|
|
12
12
|
import { entraGroup } from './entraGroup.js';
|
|
13
13
|
import { SharingCapabilities } from '../m365/spo/commands/site/SharingCapabilities.js';
|
|
14
14
|
import { setTimeout } from 'timers/promises';
|
|
15
|
+
export var CreateCopyJobsNameConflictBehavior;
|
|
16
|
+
(function (CreateCopyJobsNameConflictBehavior) {
|
|
17
|
+
CreateCopyJobsNameConflictBehavior[CreateCopyJobsNameConflictBehavior["Fail"] = 0] = "Fail";
|
|
18
|
+
CreateCopyJobsNameConflictBehavior[CreateCopyJobsNameConflictBehavior["Replace"] = 1] = "Replace";
|
|
19
|
+
CreateCopyJobsNameConflictBehavior[CreateCopyJobsNameConflictBehavior["Rename"] = 2] = "Rename";
|
|
20
|
+
})(CreateCopyJobsNameConflictBehavior || (CreateCopyJobsNameConflictBehavior = {}));
|
|
21
|
+
// Wrapping this into a settings object so we can alter the values in tests
|
|
22
|
+
export const settings = {
|
|
23
|
+
pollingInterval: 3000
|
|
24
|
+
};
|
|
15
25
|
export const spo = {
|
|
16
26
|
async getRequestDigest(siteUrl) {
|
|
17
27
|
const requestOptions = {
|
|
@@ -1405,6 +1415,38 @@ export const spo = {
|
|
|
1405
1415
|
const site = await request.get(requestOptions);
|
|
1406
1416
|
return site.id;
|
|
1407
1417
|
},
|
|
1418
|
+
/**
|
|
1419
|
+
* Retrieves the server-relative URL of a folder.
|
|
1420
|
+
* @param webUrl Web URL
|
|
1421
|
+
* @param folderUrl Folder URL
|
|
1422
|
+
* @param folderId Folder ID
|
|
1423
|
+
* @param logger The logger object
|
|
1424
|
+
* @param verbose Set for verbose logging
|
|
1425
|
+
* @returns The server-relative URL of the folder
|
|
1426
|
+
*/
|
|
1427
|
+
async getFolderServerRelativeUrl(webUrl, folderUrl, folderId, logger, verbose) {
|
|
1428
|
+
if (verbose && logger) {
|
|
1429
|
+
await logger.logToStderr(`Retrieving server-relative URL for folder ${folderUrl ? `URL: ${folderUrl}` : `ID: ${folderId}`}`);
|
|
1430
|
+
}
|
|
1431
|
+
let requestUrl = `${webUrl}/_api/web/`;
|
|
1432
|
+
if (folderUrl) {
|
|
1433
|
+
const folderServerRelativeUrl = urlUtil.getServerRelativePath(webUrl, folderUrl);
|
|
1434
|
+
requestUrl += `GetFolderByServerRelativePath(decodedUrl='${formatting.encodeQueryParameter(folderServerRelativeUrl)}')`;
|
|
1435
|
+
}
|
|
1436
|
+
else {
|
|
1437
|
+
requestUrl += `GetFolderById('${folderId}')`;
|
|
1438
|
+
}
|
|
1439
|
+
requestUrl += '?$select=ServerRelativeUrl';
|
|
1440
|
+
const requestOptions = {
|
|
1441
|
+
url: requestUrl,
|
|
1442
|
+
headers: {
|
|
1443
|
+
accept: 'application/json;odata=nometadata'
|
|
1444
|
+
},
|
|
1445
|
+
responseType: 'json'
|
|
1446
|
+
};
|
|
1447
|
+
const res = await request.get(requestOptions);
|
|
1448
|
+
return res.ServerRelativeUrl;
|
|
1449
|
+
},
|
|
1408
1450
|
/**
|
|
1409
1451
|
* Retrieves the ObjectIdentity from a SharePoint site
|
|
1410
1452
|
* @param webUrl web url
|
|
@@ -1484,6 +1526,70 @@ export const spo = {
|
|
|
1484
1526
|
};
|
|
1485
1527
|
const itemsResponse = await request.get(requestOptionsItems);
|
|
1486
1528
|
return (itemsResponse);
|
|
1529
|
+
},
|
|
1530
|
+
/**
|
|
1531
|
+
* Create a SharePoint copy job to copy a file/folder to another location.
|
|
1532
|
+
* @param webUrl Absolute web URL where the source file/folder is located.
|
|
1533
|
+
* @param sourceUrl Absolute URL of the source file/folder.
|
|
1534
|
+
* @param destinationUrl Absolute URL of the destination folder.
|
|
1535
|
+
* @param options Options for the copy job.
|
|
1536
|
+
* @returns Copy job information. Use {@link spo.getCopyJobResult} to get the result of the copy job.
|
|
1537
|
+
*/
|
|
1538
|
+
async createCopyJob(webUrl, sourceUrl, destinationUrl, options) {
|
|
1539
|
+
const requestOptions = {
|
|
1540
|
+
url: `${webUrl}/_api/Site/CreateCopyJobs`,
|
|
1541
|
+
headers: {
|
|
1542
|
+
accept: 'application/json;odata=nometadata'
|
|
1543
|
+
},
|
|
1544
|
+
responseType: 'json',
|
|
1545
|
+
data: {
|
|
1546
|
+
destinationUri: destinationUrl,
|
|
1547
|
+
exportObjectUris: [sourceUrl],
|
|
1548
|
+
options: {
|
|
1549
|
+
NameConflictBehavior: options?.nameConflictBehavior ?? CreateCopyJobsNameConflictBehavior.Fail,
|
|
1550
|
+
AllowSchemaMismatch: true,
|
|
1551
|
+
BypassSharedLock: !!options?.bypassSharedLock,
|
|
1552
|
+
IgnoreVersionHistory: !!options?.ignoreVersionHistory,
|
|
1553
|
+
CustomizedItemName: options?.newName ? [options.newName] : undefined,
|
|
1554
|
+
SameWebCopyMoveOptimization: true
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
const response = await request.post(requestOptions);
|
|
1559
|
+
return response.value[0];
|
|
1560
|
+
},
|
|
1561
|
+
/**
|
|
1562
|
+
* Poll until the copy job is finished and return the result.
|
|
1563
|
+
* @param webUrl Absolute web URL where the copy job was created.
|
|
1564
|
+
* @param copyJobInfo Information about the copy job.
|
|
1565
|
+
* @throws Error if the copy job has failed.
|
|
1566
|
+
* @returns Information about the destination object.
|
|
1567
|
+
*/
|
|
1568
|
+
async getCopyJobResult(webUrl, copyJobInfo) {
|
|
1569
|
+
const requestOptions = {
|
|
1570
|
+
url: `${webUrl}/_api/Site/GetCopyJobProgress`,
|
|
1571
|
+
headers: {
|
|
1572
|
+
accept: 'application/json;odata=nometadata'
|
|
1573
|
+
},
|
|
1574
|
+
responseType: 'json',
|
|
1575
|
+
data: {
|
|
1576
|
+
copyJobInfo: copyJobInfo
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
let progress = await request.post(requestOptions);
|
|
1580
|
+
while (progress.JobState !== 0) {
|
|
1581
|
+
await setTimeout(settings.pollingInterval);
|
|
1582
|
+
progress = await request.post(requestOptions);
|
|
1583
|
+
}
|
|
1584
|
+
const logs = progress.Logs.map(l => JSON.parse(l));
|
|
1585
|
+
// Check if the job has failed
|
|
1586
|
+
const errorLog = logs.find(l => l.Event === 'JobError');
|
|
1587
|
+
if (errorLog) {
|
|
1588
|
+
throw new Error(errorLog.Message);
|
|
1589
|
+
}
|
|
1590
|
+
// Get the destination object information
|
|
1591
|
+
const objectInfo = logs.find(l => l.Event === 'JobFinishedObjectInfo');
|
|
1592
|
+
return objectInfo;
|
|
1487
1593
|
}
|
|
1488
1594
|
};
|
|
1489
1595
|
//# sourceMappingURL=spo.js.map
|
|
@@ -22,39 +22,39 @@ m365 entra sp add [options]
|
|
|
22
22
|
## Options
|
|
23
23
|
|
|
24
24
|
```md definition-list
|
|
25
|
-
|
|
26
|
-
: ID of the app for which the enterprise application should be created
|
|
25
|
+
`-i, --id [id]`
|
|
26
|
+
: ID of the app for which the enterprise application should be created.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
: Display name of the app for which the enterprise application should be created
|
|
28
|
+
`-n, --displayName [displayName]`
|
|
29
|
+
: Display name of the app for which the enterprise application should be created.
|
|
30
30
|
|
|
31
31
|
`--objectId [objectId]`
|
|
32
|
-
: ObjectId of the app for which the enterprise application should be created
|
|
32
|
+
: ObjectId of the app for which the enterprise application should be created.
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
<Global />
|
|
36
36
|
|
|
37
37
|
## Remarks
|
|
38
38
|
|
|
39
|
-
Specify either the `
|
|
39
|
+
Specify either the `id`, `displayName` or `objectId`. If you specify more than one option value, the command will fail with an error.
|
|
40
40
|
|
|
41
41
|
If you register an application in the portal, an application object as well as an enterprise application object are automatically created in your home tenant. If you register an application using CLI for Microsoft 365 or the Microsoft Graph, you'll need to create the enterprise application separately. To register/create an application using the CLI for Microsoft 365, use the [m365 entra app add](../app/app-add.mdx) command.
|
|
42
42
|
|
|
43
43
|
## Examples
|
|
44
44
|
|
|
45
|
-
Creates an enterprise application for a registered Entra app with
|
|
45
|
+
Creates an enterprise application for a registered Entra app with the specified id.
|
|
46
46
|
|
|
47
47
|
```sh
|
|
48
|
-
m365 entra enterpriseapp add --
|
|
48
|
+
m365 entra enterpriseapp add --id b2307a39-e878-458b-bc90-03bc578531d6
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
Creates an enterprise application for a registered Entra app with
|
|
51
|
+
Creates an enterprise application for a registered Entra app with the specified displayName.
|
|
52
52
|
|
|
53
53
|
```sh
|
|
54
|
-
m365 entra enterpriseapp add --
|
|
54
|
+
m365 entra enterpriseapp add --displayName "Microsoft Graph"
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Creates an enterprise application for a registered Entra app with objectId
|
|
57
|
+
Creates an enterprise application for a registered Entra app with the specified objectId.
|
|
58
58
|
|
|
59
59
|
```sh
|
|
60
60
|
m365 entra enterpriseapp add --objectId b2307a39-e878-458b-bc90-03bc578531d6
|
|
@@ -172,7 +172,7 @@ m365 entra enterpriseapp add --objectId b2307a39-e878-458b-bc90-03bc578531d6
|
|
|
172
172
|
<TabItem value="Markdown">
|
|
173
173
|
|
|
174
174
|
```md
|
|
175
|
-
# entra enterpriseapp add --
|
|
175
|
+
# entra enterpriseapp add --id "8da75b6a-4272-4b17-8ee1-20ba66e2b06f"
|
|
176
176
|
|
|
177
177
|
Date: 2023-06-02
|
|
178
178
|
|
|
@@ -22,40 +22,40 @@ m365 entra sp get [options]
|
|
|
22
22
|
## Options
|
|
23
23
|
|
|
24
24
|
```md definition-list
|
|
25
|
-
`-i, --
|
|
26
|
-
: ID of the application for which the enterprise application should be retrieved
|
|
25
|
+
`-i, --id [id]`
|
|
26
|
+
: ID of the application for which the enterprise application should be retrieved.
|
|
27
27
|
|
|
28
|
-
`-n, --
|
|
29
|
-
: Display name of the application for which the enterprise application should be retrieved
|
|
28
|
+
`-n, --displayName [displayName]`
|
|
29
|
+
: Display name of the application for which the enterprise application should be retrieved.
|
|
30
30
|
|
|
31
|
-
`--
|
|
32
|
-
: ObjectId of the application for which the enterprise application should be retrieved
|
|
31
|
+
`--objectId [objectId]`
|
|
32
|
+
: ObjectId of the application for which the enterprise application should be retrieved.
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
<Global />
|
|
36
36
|
|
|
37
37
|
## Remarks
|
|
38
38
|
|
|
39
|
-
Specify either the `
|
|
39
|
+
Specify either the `id`, `objectId` or `displayName`. If you specify more than one option value, the command will fail with an error.
|
|
40
40
|
|
|
41
41
|
## Examples
|
|
42
42
|
|
|
43
|
-
Return details about the enterprise application with
|
|
43
|
+
Return details about the enterprise application with the specified id.
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
|
-
m365 entra enterpriseapp get --
|
|
46
|
+
m365 entra enterpriseapp get --id b2307a39-e878-458b-bc90-03bc578531d6
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Return details about the
|
|
49
|
+
Return details about the enterprise application with the specified displayName.
|
|
50
50
|
|
|
51
51
|
```sh
|
|
52
|
-
m365 entra enterpriseapp get --
|
|
52
|
+
m365 entra enterpriseapp get --displayName "Microsoft Graph"
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
Return details about the enterprise application with ObjectId
|
|
55
|
+
Return details about the enterprise application with the specified ObjectId.
|
|
56
56
|
|
|
57
57
|
```sh
|
|
58
|
-
m365 entra enterpriseapp get --
|
|
58
|
+
m365 entra enterpriseapp get --objectId b2307a39-e878-458b-bc90-03bc578531dd
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
## Response
|
|
@@ -198,7 +198,7 @@ m365 entra enterpriseapp get --appObjectId b2307a39-e878-458b-bc90-03bc578531dd
|
|
|
198
198
|
<TabItem value="Markdown">
|
|
199
199
|
|
|
200
200
|
```md
|
|
201
|
-
# entra enterpriseapp get --
|
|
201
|
+
# entra enterpriseapp get --id "ac7c9b4b-83b0-4a5e-ace2-a3530162c8f8"
|
|
202
202
|
|
|
203
203
|
Date: 2023-06-02
|
|
204
204
|
|
|
@@ -22,24 +22,24 @@ m365 entra sp list [options]
|
|
|
22
22
|
## Options
|
|
23
23
|
|
|
24
24
|
```md definition-list
|
|
25
|
-
|
|
26
|
-
: Returns only enterprise applications with the specified name
|
|
25
|
+
`-n, --displayName [displayName]`
|
|
26
|
+
: Returns only enterprise applications with the specified name.
|
|
27
27
|
|
|
28
28
|
`--tag [tag]`
|
|
29
|
-
: Returns only enterprise applications with the specified tag
|
|
29
|
+
: Returns only enterprise applications with the specified tag.
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
<Global />
|
|
33
33
|
|
|
34
34
|
## Examples
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Returns a list of all enterprise applications.
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
39
|
m365 entra enterpriseapp list
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Returns a list of all enterprise applications that comply with the specified display name and the tag parameters.
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
45
|
m365 entra enterpriseapp list --displayName "My custom enterprise application" --tag "WindowsAzureActiveDirectoryIntegratedApp"
|
|
@@ -26,13 +26,25 @@ m365 teams user add
|
|
|
26
26
|
|
|
27
27
|
```md definition-list
|
|
28
28
|
`-i, --groupId [groupId]`
|
|
29
|
-
: The ID of the Microsoft 365
|
|
29
|
+
: The ID of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
|
|
30
|
+
|
|
31
|
+
`--groupName [groupName]`
|
|
32
|
+
: The display name of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
|
|
30
33
|
|
|
31
34
|
`--teamId [teamId]`
|
|
32
|
-
: The ID of the Teams team
|
|
35
|
+
: The ID of the Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
|
|
36
|
+
|
|
37
|
+
`--teamName [teamName]`
|
|
38
|
+
: The display name of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
|
|
39
|
+
|
|
40
|
+
`-n, --userName [userName]`
|
|
41
|
+
: (deprecated) User's UPN (User Principal Name), e.g. johndoe@example.com.
|
|
42
|
+
|
|
43
|
+
`--ids [ids]`
|
|
44
|
+
: Microsoft Entra IDs of users. You can also pass a comma-separated list of IDs. Specify either `ids` or `userNames` but not both.
|
|
33
45
|
|
|
34
|
-
|
|
35
|
-
:
|
|
46
|
+
`--userNames [userNames]`
|
|
47
|
+
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify either `ids` or `userNames` but not both.
|
|
36
48
|
|
|
37
49
|
`-r, --role [role]`
|
|
38
50
|
: The role to be assigned to the new user: `Owner,Member`. Default `Member`
|
|
@@ -42,22 +54,28 @@ m365 teams user add
|
|
|
42
54
|
|
|
43
55
|
## Examples
|
|
44
56
|
|
|
45
|
-
Add a new member to the specified Microsoft 365 Group
|
|
57
|
+
Add a new member with the userNames parameter to the specified Microsoft 365 Group
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
m365 entra m365group user add --groupId '00000000-0000-0000-0000-000000000000' --userNames 'anne.matthews@contoso.onmicrosoft.com'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Add multiple new owners with the userNames parameter to the specified Microsoft 365 Group
|
|
46
64
|
|
|
47
65
|
```sh
|
|
48
|
-
m365 entra m365group user add --
|
|
66
|
+
m365 entra m365group user add --groupName 'Contoso' --userNames 'anne.matthews@contoso.onmicrosoft.com, john.doe@contoso.onmicrosoft.com' --role Owner
|
|
49
67
|
```
|
|
50
68
|
|
|
51
|
-
Add a new
|
|
69
|
+
Add a new member with the userNames parameter to the specified Microsoft Teams team
|
|
52
70
|
|
|
53
71
|
```sh
|
|
54
|
-
m365 entra m365group
|
|
72
|
+
m365 entra m365group member add --teamId '00000000-0000-0000-0000-000000000000' --userNames 'anne.matthews@contoso.onmicrosoft.com' --role Member
|
|
55
73
|
```
|
|
56
74
|
|
|
57
|
-
Add
|
|
75
|
+
Add multiple new members with the ids parameter to the specified Microsoft Teams team
|
|
58
76
|
|
|
59
77
|
```sh
|
|
60
|
-
m365
|
|
78
|
+
m365 entra m365group user add --teamName 'Engineering' --ids '74a3b772-3122-447b-b9da-10895e238219,dd3d21e4-a142-46b9-8482-bca8fe9596b3' --role Member
|
|
61
79
|
```
|
|
62
80
|
|
|
63
81
|
## Response
|