@pnp/cli-microsoft365 6.11.0-beta.6b1d864 → 6.11.0-beta.b75e15f
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/m365/spfx/commands/project/project-doctor/{doctor-1.18.0-beta.1.js → doctor-1.18.0-beta.5.js} +1 -1
- package/dist/m365/spfx/commands/project/project-doctor.js +1 -1
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.15.2.js +1 -1
- package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.18.0-beta.1.js → upgrade-1.18.0-beta.5.js} +26 -26
- package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
- package/dist/m365/spfx/commands/spfx-doctor.js +3 -3
- package/dist/m365/spo/commands/app/SpoAppBaseCommand.js +26 -14
- package/dist/m365/spo/commands/app/app-add.js +9 -9
- package/dist/m365/spo/commands/orgassetslibrary/orgassetslibrary-add.js +32 -3
- package/dist/m365/spo/commands/site/site-ensure.js +18 -69
- package/dist/utils/aadGroup.js +20 -0
- package/dist/utils/spo.js +600 -0
- package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-add.mdx +14 -1
- package/package.json +1 -1
|
@@ -20,4 +20,4 @@ module.exports = [
|
|
|
20
20
|
new FN002016_DEVDEP_types_react_dom_1.FN002016_DEVDEP_types_react_dom('17'),
|
|
21
21
|
new FN002019_DEVDEP_microsoft_rush_stack_compiler_1.FN002019_DEVDEP_microsoft_rush_stack_compiler(['4.5'])
|
|
22
22
|
];
|
|
23
|
-
//# sourceMappingURL=doctor-1.18.0-beta.
|
|
23
|
+
//# sourceMappingURL=doctor-1.18.0-beta.5.js.map
|
|
@@ -78,7 +78,7 @@ class SpfxProjectDoctorCommand extends base_project_command_1.BaseProjectCommand
|
|
|
78
78
|
'1.17.2',
|
|
79
79
|
'1.17.3',
|
|
80
80
|
'1.17.4',
|
|
81
|
-
'1.18.0-beta.
|
|
81
|
+
'1.18.0-beta.5'
|
|
82
82
|
];
|
|
83
83
|
__classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initTelemetry).call(this);
|
|
84
84
|
__classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initOptions).call(this);
|
|
@@ -105,7 +105,7 @@ module.exports = [
|
|
|
105
105
|
'fixWith': 'symbol'
|
|
106
106
|
},
|
|
107
107
|
'Function': {
|
|
108
|
-
'message': 'The \\'Function\\' type accepts any function-like value
|
|
108
|
+
'message': 'The \\'Function\\' type accepts any function-like value.\\nIt provides no type safety when calling the function, which can be a common source of bugs.\\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \\'new\\'.\\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -29,33 +29,33 @@ const FN002023_DEVDEP_microsoft_eslint_config_spfx_1 = require("./rules/FN002023
|
|
|
29
29
|
const FN010001_YORC_version_1 = require("./rules/FN010001_YORC_version");
|
|
30
30
|
const FN010010_YORC_sdkVersions_teams_js_1 = require("./rules/FN010010_YORC_sdkVersions_teams_js");
|
|
31
31
|
module.exports = [
|
|
32
|
-
new FN001001_DEP_microsoft_sp_core_library_1.FN001001_DEP_microsoft_sp_core_library('1.18.0-beta.
|
|
33
|
-
new FN001002_DEP_microsoft_sp_lodash_subset_1.FN001002_DEP_microsoft_sp_lodash_subset('1.18.0-beta.
|
|
34
|
-
new FN001003_DEP_microsoft_sp_office_ui_fabric_core_1.FN001003_DEP_microsoft_sp_office_ui_fabric_core('1.18.0-beta.
|
|
35
|
-
new FN001004_DEP_microsoft_sp_webpart_base_1.FN001004_DEP_microsoft_sp_webpart_base('1.18.0-beta.
|
|
36
|
-
new FN001011_DEP_microsoft_sp_dialog_1.FN001011_DEP_microsoft_sp_dialog('1.18.0-beta.
|
|
37
|
-
new FN001012_DEP_microsoft_sp_application_base_1.FN001012_DEP_microsoft_sp_application_base('1.18.0-beta.
|
|
38
|
-
new FN001014_DEP_microsoft_sp_listview_extensibility_1.FN001014_DEP_microsoft_sp_listview_extensibility('1.18.0-beta.
|
|
39
|
-
new FN001021_DEP_microsoft_sp_property_pane_1.FN001021_DEP_microsoft_sp_property_pane('1.18.0-beta.
|
|
32
|
+
new FN001001_DEP_microsoft_sp_core_library_1.FN001001_DEP_microsoft_sp_core_library('1.18.0-beta.5'),
|
|
33
|
+
new FN001002_DEP_microsoft_sp_lodash_subset_1.FN001002_DEP_microsoft_sp_lodash_subset('1.18.0-beta.5'),
|
|
34
|
+
new FN001003_DEP_microsoft_sp_office_ui_fabric_core_1.FN001003_DEP_microsoft_sp_office_ui_fabric_core('1.18.0-beta.5'),
|
|
35
|
+
new FN001004_DEP_microsoft_sp_webpart_base_1.FN001004_DEP_microsoft_sp_webpart_base('1.18.0-beta.5'),
|
|
36
|
+
new FN001011_DEP_microsoft_sp_dialog_1.FN001011_DEP_microsoft_sp_dialog('1.18.0-beta.5'),
|
|
37
|
+
new FN001012_DEP_microsoft_sp_application_base_1.FN001012_DEP_microsoft_sp_application_base('1.18.0-beta.5'),
|
|
38
|
+
new FN001014_DEP_microsoft_sp_listview_extensibility_1.FN001014_DEP_microsoft_sp_listview_extensibility('1.18.0-beta.5'),
|
|
39
|
+
new FN001021_DEP_microsoft_sp_property_pane_1.FN001021_DEP_microsoft_sp_property_pane('1.18.0-beta.5'),
|
|
40
40
|
new FN001022_DEP_office_ui_fabric_react_1.FN001022_DEP_office_ui_fabric_react('', false),
|
|
41
|
-
new FN001023_DEP_microsoft_sp_component_base_1.FN001023_DEP_microsoft_sp_component_base('1.18.0-beta.
|
|
42
|
-
new FN001024_DEP_microsoft_sp_diagnostics_1.FN001024_DEP_microsoft_sp_diagnostics('1.18.0-beta.
|
|
43
|
-
new FN001025_DEP_microsoft_sp_dynamic_data_1.FN001025_DEP_microsoft_sp_dynamic_data('1.18.0-beta.
|
|
44
|
-
new FN001026_DEP_microsoft_sp_extension_base_1.FN001026_DEP_microsoft_sp_extension_base('1.18.0-beta.
|
|
45
|
-
new FN001027_DEP_microsoft_sp_http_1.FN001027_DEP_microsoft_sp_http('1.18.0-beta.
|
|
46
|
-
new FN001028_DEP_microsoft_sp_list_subscription_1.FN001028_DEP_microsoft_sp_list_subscription('1.18.0-beta.
|
|
47
|
-
new FN001029_DEP_microsoft_sp_loader_1.FN001029_DEP_microsoft_sp_loader('1.18.0-beta.
|
|
48
|
-
new FN001030_DEP_microsoft_sp_module_interfaces_1.FN001030_DEP_microsoft_sp_module_interfaces('1.18.0-beta.
|
|
49
|
-
new FN001031_DEP_microsoft_sp_odata_types_1.FN001031_DEP_microsoft_sp_odata_types('1.18.0-beta.
|
|
50
|
-
new FN001032_DEP_microsoft_sp_page_context_1.FN001032_DEP_microsoft_sp_page_context('1.18.0-beta.
|
|
41
|
+
new FN001023_DEP_microsoft_sp_component_base_1.FN001023_DEP_microsoft_sp_component_base('1.18.0-beta.5'),
|
|
42
|
+
new FN001024_DEP_microsoft_sp_diagnostics_1.FN001024_DEP_microsoft_sp_diagnostics('1.18.0-beta.5'),
|
|
43
|
+
new FN001025_DEP_microsoft_sp_dynamic_data_1.FN001025_DEP_microsoft_sp_dynamic_data('1.18.0-beta.5'),
|
|
44
|
+
new FN001026_DEP_microsoft_sp_extension_base_1.FN001026_DEP_microsoft_sp_extension_base('1.18.0-beta.5'),
|
|
45
|
+
new FN001027_DEP_microsoft_sp_http_1.FN001027_DEP_microsoft_sp_http('1.18.0-beta.5'),
|
|
46
|
+
new FN001028_DEP_microsoft_sp_list_subscription_1.FN001028_DEP_microsoft_sp_list_subscription('1.18.0-beta.5'),
|
|
47
|
+
new FN001029_DEP_microsoft_sp_loader_1.FN001029_DEP_microsoft_sp_loader('1.18.0-beta.5'),
|
|
48
|
+
new FN001030_DEP_microsoft_sp_module_interfaces_1.FN001030_DEP_microsoft_sp_module_interfaces('1.18.0-beta.5'),
|
|
49
|
+
new FN001031_DEP_microsoft_sp_odata_types_1.FN001031_DEP_microsoft_sp_odata_types('1.18.0-beta.5'),
|
|
50
|
+
new FN001032_DEP_microsoft_sp_page_context_1.FN001032_DEP_microsoft_sp_page_context('1.18.0-beta.5'),
|
|
51
51
|
new FN001035_DEP_fluentui_react_1.FN001035_DEP_fluentui_react('8.106.4'),
|
|
52
|
-
new FN001013_DEP_microsoft_decorators_1.FN001013_DEP_microsoft_decorators('1.18.0-beta.
|
|
53
|
-
new FN001034_DEP_microsoft_sp_adaptive_card_extension_base_1.FN001034_DEP_microsoft_sp_adaptive_card_extension_base('1.18.0-beta.
|
|
54
|
-
new FN002022_DEVDEP_microsoft_eslint_plugin_spfx_1.FN002022_DEVDEP_microsoft_eslint_plugin_spfx('1.18.0-beta.
|
|
55
|
-
new FN002023_DEVDEP_microsoft_eslint_config_spfx_1.FN002023_DEVDEP_microsoft_eslint_config_spfx('1.18.0-beta.
|
|
56
|
-
new FN002001_DEVDEP_microsoft_sp_build_web_1.FN002001_DEVDEP_microsoft_sp_build_web('1.18.0-beta.
|
|
57
|
-
new FN002002_DEVDEP_microsoft_sp_module_interfaces_1.FN002002_DEVDEP_microsoft_sp_module_interfaces('1.18.0-beta.
|
|
58
|
-
new FN010001_YORC_version_1.FN010001_YORC_version('1.18.0-beta.
|
|
52
|
+
new FN001013_DEP_microsoft_decorators_1.FN001013_DEP_microsoft_decorators('1.18.0-beta.5'),
|
|
53
|
+
new FN001034_DEP_microsoft_sp_adaptive_card_extension_base_1.FN001034_DEP_microsoft_sp_adaptive_card_extension_base('1.18.0-beta.5'),
|
|
54
|
+
new FN002022_DEVDEP_microsoft_eslint_plugin_spfx_1.FN002022_DEVDEP_microsoft_eslint_plugin_spfx('1.18.0-beta.5'),
|
|
55
|
+
new FN002023_DEVDEP_microsoft_eslint_config_spfx_1.FN002023_DEVDEP_microsoft_eslint_config_spfx('1.18.0-beta.5'),
|
|
56
|
+
new FN002001_DEVDEP_microsoft_sp_build_web_1.FN002001_DEVDEP_microsoft_sp_build_web('1.18.0-beta.5'),
|
|
57
|
+
new FN002002_DEVDEP_microsoft_sp_module_interfaces_1.FN002002_DEVDEP_microsoft_sp_module_interfaces('1.18.0-beta.5'),
|
|
58
|
+
new FN010001_YORC_version_1.FN010001_YORC_version('1.18.0-beta.5'),
|
|
59
59
|
new FN010010_YORC_sdkVersions_teams_js_1.FN010010_YORC_sdkVersions_teams_js('2.12.0')
|
|
60
60
|
];
|
|
61
|
-
//# sourceMappingURL=upgrade-1.18.0-beta.
|
|
61
|
+
//# sourceMappingURL=upgrade-1.18.0-beta.5.js.map
|
|
@@ -82,7 +82,7 @@ class SpfxProjectUpgradeCommand extends base_project_command_1.BaseProjectComman
|
|
|
82
82
|
'1.17.2',
|
|
83
83
|
'1.17.3',
|
|
84
84
|
'1.17.4',
|
|
85
|
-
'1.18.0-beta.
|
|
85
|
+
'1.18.0-beta.5'
|
|
86
86
|
];
|
|
87
87
|
__classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initTelemetry).call(this);
|
|
88
88
|
__classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initOptions).call(this);
|
|
@@ -535,14 +535,14 @@ class SpfxDoctorCommand extends base_project_command_1.BaseProjectCommand {
|
|
|
535
535
|
fix: 'npm i -g yo@4'
|
|
536
536
|
}
|
|
537
537
|
},
|
|
538
|
-
'1.18.0-beta.
|
|
538
|
+
'1.18.0-beta.5': {
|
|
539
539
|
gulpCli: {
|
|
540
540
|
range: '^1 || ^2',
|
|
541
541
|
fix: 'npm i -g gulp-cli@2'
|
|
542
542
|
},
|
|
543
543
|
node: {
|
|
544
|
-
range: '>=16.
|
|
545
|
-
fix: 'Install Node.js >=16.
|
|
544
|
+
range: '>=16.14.0 <17.0.0',
|
|
545
|
+
fix: 'Install Node.js >=16.14.0 <17.0.0'
|
|
546
546
|
},
|
|
547
547
|
sp: SharePointVersion.SPO,
|
|
548
548
|
yo: {
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.SpoAppBaseCommand = void 0;
|
|
4
13
|
const request_1 = require("../../../../request");
|
|
5
14
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
6
15
|
class SpoAppBaseCommand extends SpoCommand_1.default {
|
|
7
16
|
getAppCatalogSiteUrl(logger, authSiteUrl, args) {
|
|
8
|
-
return
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9
18
|
if (args.options.appCatalogScope === 'sitecollection') {
|
|
10
|
-
|
|
19
|
+
// trim trailing slashes if there are any
|
|
20
|
+
const appCatalogUrl = args.options.appCatalogUrl.replace(/\/$/, '');
|
|
21
|
+
const appCatalogUrlChunks = appCatalogUrl.split('/');
|
|
22
|
+
// Trim the last part of the URL if it ends on '/appcatalog', but don't trim it if the site URL is called like that (/sites/appcatalog).
|
|
23
|
+
if (appCatalogUrl.toLowerCase().endsWith('/appcatalog') && appCatalogUrlChunks.length !== 5) {
|
|
24
|
+
return appCatalogUrl.substring(0, appCatalogUrl.lastIndexOf('/'));
|
|
25
|
+
}
|
|
11
26
|
}
|
|
12
27
|
if (args.options.appCatalogUrl) {
|
|
13
|
-
return
|
|
28
|
+
return args.options.appCatalogUrl.replace(/\/$/, '');
|
|
29
|
+
}
|
|
30
|
+
if (this.verbose) {
|
|
31
|
+
logger.logToStderr('Getting tenant app catalog url...');
|
|
14
32
|
}
|
|
15
33
|
const requestOptions = {
|
|
16
34
|
url: `${authSiteUrl}/_api/SP_TenantSettings_Current`,
|
|
@@ -19,17 +37,11 @@ class SpoAppBaseCommand extends SpoCommand_1.default {
|
|
|
19
37
|
},
|
|
20
38
|
responseType: 'json'
|
|
21
39
|
};
|
|
22
|
-
request_1.default
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
reject('Tenant app catalog is not configured.');
|
|
29
|
-
})
|
|
30
|
-
.catch((err) => {
|
|
31
|
-
reject(err);
|
|
32
|
-
});
|
|
40
|
+
const response = yield request_1.default.get(requestOptions);
|
|
41
|
+
if (response.CorporateCatalogUrl) {
|
|
42
|
+
return response.CorporateCatalogUrl;
|
|
43
|
+
}
|
|
44
|
+
throw new Error('Tenant app catalog is not configured.');
|
|
33
45
|
});
|
|
34
46
|
}
|
|
35
47
|
}
|
|
@@ -33,6 +33,7 @@ class SpoAppAddCommand extends SpoAppBaseCommand_1.SpoAppBaseCommand {
|
|
|
33
33
|
constructor() {
|
|
34
34
|
super();
|
|
35
35
|
_SpoAppAddCommand_instances.add(this);
|
|
36
|
+
this.appCatalogScopeOptions = ['tenant', 'sitecollection'];
|
|
36
37
|
__classPrivateFieldGet(this, _SpoAppAddCommand_instances, "m", _SpoAppAddCommand_initTelemetry).call(this);
|
|
37
38
|
__classPrivateFieldGet(this, _SpoAppAddCommand_instances, "m", _SpoAppAddCommand_initOptions).call(this);
|
|
38
39
|
__classPrivateFieldGet(this, _SpoAppAddCommand_instances, "m", _SpoAppAddCommand_initValidators).call(this);
|
|
@@ -75,9 +76,9 @@ class SpoAppAddCommand extends SpoAppBaseCommand_1.SpoAppBaseCommand {
|
|
|
75
76
|
_SpoAppAddCommand_instances = new WeakSet(), _SpoAppAddCommand_initTelemetry = function _SpoAppAddCommand_initTelemetry() {
|
|
76
77
|
this.telemetry.push((args) => {
|
|
77
78
|
Object.assign(this.telemetryProperties, {
|
|
78
|
-
overwrite:
|
|
79
|
+
overwrite: !!args.options.overwrite,
|
|
79
80
|
appCatalogScope: args.options.appCatalogScope || 'tenant',
|
|
80
|
-
appCatalogUrl:
|
|
81
|
+
appCatalogUrl: typeof args.options.appCatalogUrl !== 'undefined'
|
|
81
82
|
});
|
|
82
83
|
});
|
|
83
84
|
}, _SpoAppAddCommand_initOptions = function _SpoAppAddCommand_initOptions() {
|
|
@@ -85,7 +86,7 @@ _SpoAppAddCommand_instances = new WeakSet(), _SpoAppAddCommand_initTelemetry = f
|
|
|
85
86
|
option: '-p, --filePath <filePath>'
|
|
86
87
|
}, {
|
|
87
88
|
option: '-s, --appCatalogScope [appCatalogScope]',
|
|
88
|
-
autocomplete:
|
|
89
|
+
autocomplete: this.appCatalogScopeOptions
|
|
89
90
|
}, {
|
|
90
91
|
option: '-u, --appCatalogUrl [appCatalogUrl]'
|
|
91
92
|
}, {
|
|
@@ -93,14 +94,13 @@ _SpoAppAddCommand_instances = new WeakSet(), _SpoAppAddCommand_initTelemetry = f
|
|
|
93
94
|
});
|
|
94
95
|
}, _SpoAppAddCommand_initValidators = function _SpoAppAddCommand_initValidators() {
|
|
95
96
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
// verify either 'tenant' or 'sitecollection' specified if scope provided
|
|
97
97
|
if (args.options.appCatalogScope) {
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
98
|
+
const appCatalogScope = args.options.appCatalogScope.toLowerCase();
|
|
99
|
+
if (this.appCatalogScopeOptions.indexOf(appCatalogScope) === -1) {
|
|
100
|
+
return `${args.options.appCatalogScope} is not a valid appCatalogScope. Allowed values are: ${this.appCatalogScopeOptions.join(', ')}`;
|
|
101
101
|
}
|
|
102
|
-
if (
|
|
103
|
-
return `You must specify appCatalogUrl when
|
|
102
|
+
if (appCatalogScope === 'sitecollection' && !args.options.appCatalogUrl) {
|
|
103
|
+
return `You must specify appCatalogUrl when appCatalogScope is sitecollection`;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
const fullPath = path.resolve(args.options.filePath);
|
|
@@ -21,6 +21,12 @@ const spo_1 = require("../../../../utils/spo");
|
|
|
21
21
|
const validation_1 = require("../../../../utils/validation");
|
|
22
22
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
23
23
|
const commands_1 = require("../../commands");
|
|
24
|
+
var OrgAssetType;
|
|
25
|
+
(function (OrgAssetType) {
|
|
26
|
+
OrgAssetType[OrgAssetType["ImageDocumentLibrary"] = 1] = "ImageDocumentLibrary";
|
|
27
|
+
OrgAssetType[OrgAssetType["OfficeTemplateLibrary"] = 2] = "OfficeTemplateLibrary";
|
|
28
|
+
OrgAssetType[OrgAssetType["OfficeFontLibrary"] = 4] = "OfficeFontLibrary";
|
|
29
|
+
})(OrgAssetType || (OrgAssetType = {}));
|
|
24
30
|
class SpoOrgAssetsLibraryAddCommand extends SpoCommand_1.default {
|
|
25
31
|
get name() {
|
|
26
32
|
return commands_1.default.ORGASSETSLIBRARY_ADD;
|
|
@@ -42,6 +48,7 @@ class SpoOrgAssetsLibraryAddCommand extends SpoCommand_1.default {
|
|
|
42
48
|
const cdnType = cdnTypeString === 'Private' ? 1 : 0;
|
|
43
49
|
const thumbnailSchema = typeof args.options.thumbnailUrl === 'undefined' ? `<Parameter Type="Null" />` : `<Parameter Type="String">${args.options.thumbnailUrl}</Parameter>`;
|
|
44
50
|
try {
|
|
51
|
+
const orgAssetType = this.getOrgAssetType(args.options.orgAssetType);
|
|
45
52
|
spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
|
|
46
53
|
const reqDigest = yield spo_1.spo.getRequestDigest(spoAdminUrl);
|
|
47
54
|
const requestOptions = {
|
|
@@ -49,7 +56,7 @@ class SpoOrgAssetsLibraryAddCommand extends SpoCommand_1.default {
|
|
|
49
56
|
headers: {
|
|
50
57
|
'X-RequestDigest': reqDigest.FormDigestValue
|
|
51
58
|
},
|
|
52
|
-
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Method Name="AddToOrgAssetsLibAndCdnWithType" Id="11" ObjectPathId="8"><Parameters><Parameter Type="Enum">${cdnType}</Parameter><Parameter Type="String">${args.options.libraryUrl}</Parameter>${thumbnailSchema}<Parameter Type="Enum"
|
|
59
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Method Name="AddToOrgAssetsLibAndCdnWithType" Id="11" ObjectPathId="8"><Parameters><Parameter Type="Enum">${cdnType}</Parameter><Parameter Type="String">${args.options.libraryUrl}</Parameter>${thumbnailSchema}<Parameter Type="Enum">${orgAssetType}</Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="8" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
53
60
|
};
|
|
54
61
|
const res = yield request_1.default.post(requestOptions);
|
|
55
62
|
const json = JSON.parse(res);
|
|
@@ -63,12 +70,23 @@ class SpoOrgAssetsLibraryAddCommand extends SpoCommand_1.default {
|
|
|
63
70
|
}
|
|
64
71
|
});
|
|
65
72
|
}
|
|
73
|
+
getOrgAssetType(orgAssetType) {
|
|
74
|
+
switch (orgAssetType) {
|
|
75
|
+
case 'OfficeTemplateLibrary':
|
|
76
|
+
return OrgAssetType.OfficeTemplateLibrary;
|
|
77
|
+
case 'OfficeFontLibrary':
|
|
78
|
+
return OrgAssetType.OfficeFontLibrary;
|
|
79
|
+
default:
|
|
80
|
+
return OrgAssetType.ImageDocumentLibrary;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
66
83
|
}
|
|
67
84
|
_SpoOrgAssetsLibraryAddCommand_instances = new WeakSet(), _SpoOrgAssetsLibraryAddCommand_initTelemetry = function _SpoOrgAssetsLibraryAddCommand_initTelemetry() {
|
|
68
85
|
this.telemetry.push((args) => {
|
|
69
86
|
Object.assign(this.telemetryProperties, {
|
|
70
87
|
cdnType: args.options.cdnType || 'Private',
|
|
71
|
-
thumbnailUrl: typeof args.options.thumbnailUrl !== 'undefined'
|
|
88
|
+
thumbnailUrl: typeof args.options.thumbnailUrl !== 'undefined',
|
|
89
|
+
orgAssetType: args.options.orgAssetType
|
|
72
90
|
});
|
|
73
91
|
});
|
|
74
92
|
}, _SpoOrgAssetsLibraryAddCommand_initOptions = function _SpoOrgAssetsLibraryAddCommand_initOptions() {
|
|
@@ -78,7 +96,10 @@ _SpoOrgAssetsLibraryAddCommand_instances = new WeakSet(), _SpoOrgAssetsLibraryAd
|
|
|
78
96
|
option: '--thumbnailUrl [thumbnailUrl]'
|
|
79
97
|
}, {
|
|
80
98
|
option: '--cdnType [cdnType]',
|
|
81
|
-
autocomplete:
|
|
99
|
+
autocomplete: SpoOrgAssetsLibraryAddCommand.cdnTypes
|
|
100
|
+
}, {
|
|
101
|
+
option: '--orgAssetType [orgAssetType]',
|
|
102
|
+
autocomplete: SpoOrgAssetsLibraryAddCommand.orgAssetTypes
|
|
82
103
|
});
|
|
83
104
|
}, _SpoOrgAssetsLibraryAddCommand_initValidators = function _SpoOrgAssetsLibraryAddCommand_initValidators() {
|
|
84
105
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -86,8 +107,16 @@ _SpoOrgAssetsLibraryAddCommand_instances = new WeakSet(), _SpoOrgAssetsLibraryAd
|
|
|
86
107
|
if (typeof args.options.thumbnailUrl !== 'undefined' && isValidThumbnailUrl !== true) {
|
|
87
108
|
return isValidThumbnailUrl;
|
|
88
109
|
}
|
|
110
|
+
if (args.options.cdnType && SpoOrgAssetsLibraryAddCommand.cdnTypes.indexOf(args.options.cdnType) < 0) {
|
|
111
|
+
return `${args.options.cdnType} is not a valid value for cdnType. Valid values are ${SpoOrgAssetsLibraryAddCommand.cdnTypes.join(', ')}`;
|
|
112
|
+
}
|
|
113
|
+
if (args.options.orgAssetType && SpoOrgAssetsLibraryAddCommand.orgAssetTypes.indexOf(args.options.orgAssetType) < 0) {
|
|
114
|
+
return `${args.options.orgAssetType} is not a valid value for orgAssetType. Valid values are ${SpoOrgAssetsLibraryAddCommand.orgAssetTypes.join(', ')}`;
|
|
115
|
+
}
|
|
89
116
|
return validation_1.validation.isValidSharePointUrl(args.options.libraryUrl);
|
|
90
117
|
}));
|
|
91
118
|
};
|
|
119
|
+
SpoOrgAssetsLibraryAddCommand.orgAssetTypes = ['ImageDocumentLibrary', 'OfficeTemplateLibrary', 'OfficeFontLibrary'];
|
|
120
|
+
SpoOrgAssetsLibraryAddCommand.cdnTypes = ['Public', 'Private'];
|
|
92
121
|
module.exports = new SpoOrgAssetsLibraryAddCommand();
|
|
93
122
|
//# sourceMappingURL=orgassetslibrary-add.js.map
|
|
@@ -16,14 +16,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
16
16
|
var _SpoSiteEnsureCommand_instances, _SpoSiteEnsureCommand_initOptions, _SpoSiteEnsureCommand_initTypes, _SpoSiteEnsureCommand_initValidators;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const chalk = require("chalk");
|
|
19
|
-
const Cli_1 = require("../../../../cli/Cli");
|
|
20
19
|
const validation_1 = require("../../../../utils/validation");
|
|
21
20
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
22
21
|
const commands_1 = require("../../commands");
|
|
23
|
-
const spoWebGetCommand = require("../web/web-get");
|
|
24
22
|
const SharingCapabilities_1 = require("./SharingCapabilities");
|
|
25
|
-
const
|
|
26
|
-
const spoSiteSetCommand = require("./site-set");
|
|
23
|
+
const spo_1 = require("../../../../utils/spo");
|
|
27
24
|
class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
28
25
|
get name() {
|
|
29
26
|
return commands_1.default.SITE_ENSURE;
|
|
@@ -42,10 +39,7 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
42
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
40
|
try {
|
|
44
41
|
const res = yield this.ensureSite(logger, args);
|
|
45
|
-
|
|
46
|
-
logger.logToStderr(res.stderr);
|
|
47
|
-
}
|
|
48
|
-
logger.log(res.stdout);
|
|
42
|
+
logger.log(res);
|
|
49
43
|
if (this.verbose) {
|
|
50
44
|
logger.logToStderr(chalk.green('DONE'));
|
|
51
45
|
}
|
|
@@ -63,9 +57,9 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
63
57
|
}
|
|
64
58
|
catch (err) {
|
|
65
59
|
if (this.debug) {
|
|
66
|
-
logger.logToStderr(err
|
|
60
|
+
logger.logToStderr(err);
|
|
67
61
|
}
|
|
68
|
-
if (err.error
|
|
62
|
+
if (err.error !== '404 FILE NOT FOUND') {
|
|
69
63
|
throw err;
|
|
70
64
|
}
|
|
71
65
|
if (this.verbose) {
|
|
@@ -74,12 +68,15 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
74
68
|
return this.createSite(args, logger);
|
|
75
69
|
}
|
|
76
70
|
if (this.debug) {
|
|
77
|
-
logger.logToStderr(getWebOutput
|
|
71
|
+
logger.logToStderr(getWebOutput);
|
|
78
72
|
}
|
|
79
73
|
if (this.verbose) {
|
|
80
74
|
logger.logToStderr(`Site found at ${args.options.url}. Checking if site matches conditions...`);
|
|
81
75
|
}
|
|
82
|
-
const web =
|
|
76
|
+
const web = {
|
|
77
|
+
Configuration: getWebOutput.Configuration,
|
|
78
|
+
WebTemplate: getWebOutput.WebTemplate
|
|
79
|
+
};
|
|
83
80
|
if (args.options.type) {
|
|
84
81
|
// type was specified so we need to check if the existing site matches
|
|
85
82
|
// it. If not, we throw an error and stop
|
|
@@ -112,51 +109,20 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
112
109
|
});
|
|
113
110
|
}
|
|
114
111
|
getWeb(args, logger) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
debug: this.debug,
|
|
122
|
-
verbose: this.verbose
|
|
123
|
-
};
|
|
124
|
-
return Cli_1.Cli.executeCommandWithOutput(spoWebGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
if (this.verbose) {
|
|
114
|
+
logger.logToStderr(`Checking if site ${args.options.url} exists...`);
|
|
115
|
+
}
|
|
116
|
+
return yield spo_1.spo.getWeb(args.options.url, logger, this.verbose);
|
|
117
|
+
});
|
|
125
118
|
}
|
|
126
119
|
createSite(args, logger) {
|
|
127
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
121
|
if (this.verbose) {
|
|
129
122
|
logger.logToStderr(`Creating site...`);
|
|
130
123
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
title: args.options.title,
|
|
134
|
-
alias: args.options.alias,
|
|
135
|
-
description: args.options.description,
|
|
136
|
-
classification: args.options.classification,
|
|
137
|
-
isPublic: args.options.isPublic,
|
|
138
|
-
lcid: args.options.lcid,
|
|
139
|
-
url: typeof args.options.type === 'undefined' || args.options.type === 'TeamSite' ? undefined : args.options.url,
|
|
140
|
-
owners: args.options.owners,
|
|
141
|
-
shareByEmailEnabled: args.options.shareByEmailEnabled,
|
|
142
|
-
siteDesign: args.options.siteDesign,
|
|
143
|
-
siteDesignId: args.options.siteDesignId,
|
|
144
|
-
timeZone: args.options.timeZone,
|
|
145
|
-
webTemplate: args.options.webTemplate,
|
|
146
|
-
resourceQuota: args.options.resourceQuota,
|
|
147
|
-
resourceQuotaWarningLevel: args.options.resourceQuotaWarningLevel,
|
|
148
|
-
storageQuota: args.options.storageQuota,
|
|
149
|
-
storageQuotaWarningLevel: args.options.storageQuotaWarningLevel,
|
|
150
|
-
removeDeletedSite: args.options.removeDeletedSite,
|
|
151
|
-
wait: args.options.wait,
|
|
152
|
-
verbose: this.verbose,
|
|
153
|
-
debug: this.debug
|
|
154
|
-
};
|
|
155
|
-
const validationResult = yield spoSiteAddCommand.validate({ options: options }, Cli_1.Cli.getCommandInfo(spoSiteAddCommand));
|
|
156
|
-
if (validationResult !== true) {
|
|
157
|
-
throw validationResult;
|
|
158
|
-
}
|
|
159
|
-
return Cli_1.Cli.executeCommandWithOutput(spoSiteAddCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
124
|
+
const url = typeof args.options.type === 'undefined' || args.options.type === 'TeamSite' ? undefined : args.options.url;
|
|
125
|
+
return yield spo_1.spo.addSite(args.options.title, logger, this.verbose, args.options.wait, args.options.type, args.options.alias, args.options.description, args.options.owners, args.options.shareByEmailEnabled, args.options.removeDeletedSite, args.options.classification, args.options.isPublic, args.options.lcid, url, args.options.siteDesign, args.options.siteDesignId, args.options.timeZone, args.options.webTemplate, args.options.resourceQuota, args.options.resourceQuotaWarningLevel, args.options.storageQuota, args.options.storageQuotaWarningLevel);
|
|
160
126
|
});
|
|
161
127
|
}
|
|
162
128
|
updateSite(args, logger) {
|
|
@@ -164,24 +130,7 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
164
130
|
if (this.verbose) {
|
|
165
131
|
logger.logToStderr(`Updating site...`);
|
|
166
132
|
}
|
|
167
|
-
|
|
168
|
-
classification: args.options.classification,
|
|
169
|
-
disableFlows: args.options.disableFlows,
|
|
170
|
-
isPublic: args.options.isPublic,
|
|
171
|
-
owners: args.options.owners,
|
|
172
|
-
shareByEmailEnabled: args.options.shareByEmailEnabled,
|
|
173
|
-
siteDesignId: args.options.siteDesignId,
|
|
174
|
-
title: args.options.title,
|
|
175
|
-
url: args.options.url,
|
|
176
|
-
sharingCapability: args.options.sharingCapability,
|
|
177
|
-
verbose: this.verbose,
|
|
178
|
-
debug: this.debug
|
|
179
|
-
};
|
|
180
|
-
const validationResult = yield spoSiteSetCommand.validate({ options: options }, Cli_1.Cli.getCommandInfo(spoSiteSetCommand));
|
|
181
|
-
if (validationResult !== true) {
|
|
182
|
-
throw validationResult;
|
|
183
|
-
}
|
|
184
|
-
return Cli_1.Cli.executeCommandWithOutput(spoSiteSetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
133
|
+
return yield spo_1.spo.updateSite(args.options.url, logger, this.verbose, args.options.title, args.options.classification, args.options.disableFlows, args.options.isPublic, args.options.owners, args.options.shareByEmailEnabled, args.options.siteDesignId, args.options.sharingCapability);
|
|
185
134
|
});
|
|
186
135
|
}
|
|
187
136
|
/**
|
package/dist/utils/aadGroup.js
CHANGED
|
@@ -71,6 +71,26 @@ exports.aadGroup = {
|
|
|
71
71
|
}
|
|
72
72
|
return groups[0].id;
|
|
73
73
|
});
|
|
74
|
+
},
|
|
75
|
+
setGroup(id, isPrivate, logger, verbose) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
if (verbose && logger) {
|
|
78
|
+
logger.logToStderr(`Updating Microsoft 365 Group ${id}...`);
|
|
79
|
+
}
|
|
80
|
+
const update = {};
|
|
81
|
+
if (typeof isPrivate !== 'undefined') {
|
|
82
|
+
update.visibility = isPrivate ? 'Private' : 'Public';
|
|
83
|
+
}
|
|
84
|
+
const requestOptions = {
|
|
85
|
+
url: `${graphResource}/v1.0/groups/${id}`,
|
|
86
|
+
headers: {
|
|
87
|
+
'accept': 'application/json;odata.metadata=none'
|
|
88
|
+
},
|
|
89
|
+
responseType: 'json',
|
|
90
|
+
data: update
|
|
91
|
+
};
|
|
92
|
+
yield request_1.default.patch(requestOptions);
|
|
93
|
+
});
|
|
74
94
|
}
|
|
75
95
|
};
|
|
76
96
|
//# sourceMappingURL=aadGroup.js.map
|
package/dist/utils/spo.js
CHANGED
|
@@ -20,6 +20,8 @@ const request_1 = require("../request");
|
|
|
20
20
|
const formatting_1 = require("./formatting");
|
|
21
21
|
const odata_1 = require("./odata");
|
|
22
22
|
const RoleType_1 = require("../m365/spo/commands/roledefinition/RoleType");
|
|
23
|
+
const aadGroup_1 = require("./aadGroup");
|
|
24
|
+
const SharingCapabilities_1 = require("../m365/spo/commands/site/SharingCapabilities");
|
|
23
25
|
exports.spo = {
|
|
24
26
|
getRequestDigest(siteUrl) {
|
|
25
27
|
const requestOptions = {
|
|
@@ -702,6 +704,604 @@ exports.spo = {
|
|
|
702
704
|
roledefinition.RoleTypeKindValue = RoleType_1.RoleType[roledefinition.RoleTypeKind];
|
|
703
705
|
return roledefinition;
|
|
704
706
|
});
|
|
707
|
+
},
|
|
708
|
+
/**
|
|
709
|
+
* Adds a SharePoint site.
|
|
710
|
+
* @param type Type of sites to add. Allowed values TeamSite, CommunicationSite, ClassicSite, default TeamSite
|
|
711
|
+
* @param title Site title
|
|
712
|
+
* @param alias Site alias, used in the URL and in the team site group e-mail (applies to type TeamSite)
|
|
713
|
+
* @param url Site URL (applies to type CommunicationSite, ClassicSite)
|
|
714
|
+
* @param timeZone Integer representing time zone to use for the site (applies to type ClassicSite)
|
|
715
|
+
* @param description Site description
|
|
716
|
+
* @param lcid Site language in the LCID format
|
|
717
|
+
* @param owners Comma-separated list of users to set as site owners (applies to type TeamSite, ClassicSite)
|
|
718
|
+
* @param isPublic Determines if the associated group is public or not (applies to type TeamSite)
|
|
719
|
+
* @param classification Site classification (applies to type TeamSite, CommunicationSite)
|
|
720
|
+
* @param siteDesignType of communication site to create. Allowed values Topic, Showcase, Blank, default Topic. When creating a communication site, specify either siteDesign or siteDesignId (applies to type CommunicationSite)
|
|
721
|
+
* @param siteDesignId Id of the custom site design to use to create the site. When creating a communication site, specify either siteDesign or siteDesignId (applies to type CommunicationSite)
|
|
722
|
+
* @param shareByEmailEnabled Determines whether it's allowed to share file with guests (applies to type CommunicationSite)
|
|
723
|
+
* @param webTemplate Template to use for creating the site. Default `STS#0` (applies to type ClassicSite)
|
|
724
|
+
* @param resourceQuota The quota for this site collection in Sandboxed Solutions units. Default 0 (applies to type ClassicSite)
|
|
725
|
+
* @param resourceQuotaWarningLevel The warning level for the resource quota. Default 0 (applies to type ClassicSite)
|
|
726
|
+
* @param storageQuota The storage quota for this site collection in megabytes. Default 100 (applies to type ClassicSite)
|
|
727
|
+
* @param storageQuotaWarningLevel The warning level for the storage quota in megabytes. Default 100 (applies to type ClassicSite)
|
|
728
|
+
* @param removeDeletedSite Set, to remove existing deleted site with the same URL from the Recycle Bin (applies to type ClassicSite)
|
|
729
|
+
* @param wait Wait for the site to be provisioned before completing the command (applies to type ClassicSite)
|
|
730
|
+
* @param logger the Logger object
|
|
731
|
+
* @param verbose set if verbose logging should be logged
|
|
732
|
+
*/
|
|
733
|
+
addSite(title, logger, verbose, wait, type, alias, description, owners, shareByEmailEnabled, removeDeletedSite, classification, isPublic, lcid, url, siteDesign, siteDesignId, timeZone, webTemplate, resourceQuota, resourceQuotaWarningLevel, storageQuota, storageQuotaWarningLevel) {
|
|
734
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
735
|
+
if (type === 'ClassicSite') {
|
|
736
|
+
const spoAdminUrl = yield exports.spo.getSpoAdminUrl(logger, verbose);
|
|
737
|
+
let context = yield exports.spo.ensureFormDigest(spoAdminUrl, logger, undefined, verbose);
|
|
738
|
+
let exists;
|
|
739
|
+
if (removeDeletedSite) {
|
|
740
|
+
exists = yield exports.spo.siteExists(url, logger, verbose);
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
// assume site doesn't exist
|
|
744
|
+
exists = false;
|
|
745
|
+
}
|
|
746
|
+
if (exists) {
|
|
747
|
+
if (verbose) {
|
|
748
|
+
logger.logToStderr('Site exists in the recycle bin');
|
|
749
|
+
}
|
|
750
|
+
yield exports.spo.deleteSiteFromTheRecycleBin(url, logger, verbose, wait);
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
if (verbose) {
|
|
754
|
+
logger.logToStderr('Site not found');
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
context = yield exports.spo.ensureFormDigest(spoAdminUrl, logger, context, verbose);
|
|
758
|
+
if (verbose) {
|
|
759
|
+
logger.logToStderr(`Creating site collection ${url}...`);
|
|
760
|
+
}
|
|
761
|
+
const lcidOption = typeof lcid === 'number' ? lcid : 1033;
|
|
762
|
+
const storageQuotaOption = typeof storageQuota === 'number' ? storageQuota : 100;
|
|
763
|
+
const storageQuotaWarningLevelOption = typeof storageQuotaWarningLevel === 'number' ? storageQuotaWarningLevel : 100;
|
|
764
|
+
const resourceQuotaOption = typeof resourceQuota === 'number' ? resourceQuota : 0;
|
|
765
|
+
const resourceQuotaWarningLevelOption = typeof resourceQuotaWarningLevel === 'number' ? resourceQuotaWarningLevel : 0;
|
|
766
|
+
const webTemplateOption = webTemplate || 'STS#0';
|
|
767
|
+
const requestOptions = {
|
|
768
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
769
|
+
headers: {
|
|
770
|
+
'X-RequestDigest': context.FormDigestValue
|
|
771
|
+
},
|
|
772
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="4" ObjectPathId="3" /><ObjectPath Id="6" ObjectPathId="5" /><Query Id="7" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query></Query><Query Id="8" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Constructor Id="3" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="5" ParentId="3" Name="CreateSite"><Parameters><Parameter TypeId="{11f84fff-b8cf-47b6-8b50-34e692656606}"><Property Name="CompatibilityLevel" Type="Int32">0</Property><Property Name="Lcid" Type="UInt32">${lcidOption}</Property><Property Name="Owner" Type="String">${formatting_1.formatting.escapeXml(owners)}</Property><Property Name="StorageMaximumLevel" Type="Int64">${storageQuotaOption}</Property><Property Name="StorageWarningLevel" Type="Int64">${storageQuotaWarningLevelOption}</Property><Property Name="Template" Type="String">${formatting_1.formatting.escapeXml(webTemplateOption)}</Property><Property Name="TimeZoneId" Type="Int32">${timeZone}</Property><Property Name="Title" Type="String">${formatting_1.formatting.escapeXml(title)}</Property><Property Name="Url" Type="String">${formatting_1.formatting.escapeXml(url)}</Property><Property Name="UserCodeMaximumLevel" Type="Double">${resourceQuotaOption}</Property><Property Name="UserCodeWarningLevel" Type="Double">${resourceQuotaWarningLevelOption}</Property></Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
773
|
+
};
|
|
774
|
+
const res = yield request_1.default.post(requestOptions);
|
|
775
|
+
const json = JSON.parse(res);
|
|
776
|
+
const response = json[0];
|
|
777
|
+
if (response.ErrorInfo) {
|
|
778
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
const operation = json[json.length - 1];
|
|
782
|
+
const isComplete = operation.IsComplete;
|
|
783
|
+
if (!wait || isComplete) {
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
yield new Promise((resolve, reject) => {
|
|
787
|
+
setTimeout(() => {
|
|
788
|
+
exports.spo.waitUntilFinished({
|
|
789
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
790
|
+
siteUrl: spoAdminUrl,
|
|
791
|
+
resolve,
|
|
792
|
+
reject,
|
|
793
|
+
logger,
|
|
794
|
+
currentContext: context,
|
|
795
|
+
verbose: verbose,
|
|
796
|
+
debug: verbose
|
|
797
|
+
});
|
|
798
|
+
}, operation.PollingInterval);
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
const isTeamSite = type !== 'CommunicationSite';
|
|
804
|
+
const spoUrl = yield exports.spo.getSpoUrl(logger, verbose);
|
|
805
|
+
if (verbose) {
|
|
806
|
+
logger.logToStderr(`Creating new site...`);
|
|
807
|
+
}
|
|
808
|
+
let requestOptions = {};
|
|
809
|
+
if (isTeamSite) {
|
|
810
|
+
requestOptions = {
|
|
811
|
+
url: `${spoUrl}/_api/GroupSiteManager/CreateGroupEx`,
|
|
812
|
+
headers: {
|
|
813
|
+
'content-type': 'application/json; odata=verbose; charset=utf-8',
|
|
814
|
+
accept: 'application/json;odata=nometadata'
|
|
815
|
+
},
|
|
816
|
+
responseType: 'json',
|
|
817
|
+
data: {
|
|
818
|
+
displayName: title,
|
|
819
|
+
alias: alias,
|
|
820
|
+
isPublic: isPublic,
|
|
821
|
+
optionalParams: {
|
|
822
|
+
Description: description || '',
|
|
823
|
+
CreationOptions: {
|
|
824
|
+
results: [],
|
|
825
|
+
Classification: classification || ''
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
if (lcid) {
|
|
831
|
+
requestOptions.data.optionalParams.CreationOptions.results.push(`SPSiteLanguage:${lcid}`);
|
|
832
|
+
}
|
|
833
|
+
if (owners) {
|
|
834
|
+
requestOptions.data.optionalParams.Owners = {
|
|
835
|
+
results: owners.split(',').map(o => o.trim())
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
if (siteDesignId) {
|
|
841
|
+
siteDesignId = siteDesignId;
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
if (siteDesign) {
|
|
845
|
+
switch (siteDesign) {
|
|
846
|
+
case 'Topic':
|
|
847
|
+
siteDesignId = '00000000-0000-0000-0000-000000000000';
|
|
848
|
+
break;
|
|
849
|
+
case 'Showcase':
|
|
850
|
+
siteDesignId = '6142d2a0-63a5-4ba0-aede-d9fefca2c767';
|
|
851
|
+
break;
|
|
852
|
+
case 'Blank':
|
|
853
|
+
siteDesignId = 'f6cc5403-0d63-442e-96c0-285923709ffc';
|
|
854
|
+
break;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
siteDesignId = '00000000-0000-0000-0000-000000000000';
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
requestOptions = {
|
|
862
|
+
url: `${spoUrl}/_api/SPSiteManager/Create`,
|
|
863
|
+
headers: {
|
|
864
|
+
'content-type': 'application/json;odata=nometadata',
|
|
865
|
+
accept: 'application/json;odata=nometadata'
|
|
866
|
+
},
|
|
867
|
+
responseType: 'json',
|
|
868
|
+
data: {
|
|
869
|
+
request: {
|
|
870
|
+
Title: title,
|
|
871
|
+
Url: url,
|
|
872
|
+
ShareByEmailEnabled: shareByEmailEnabled,
|
|
873
|
+
Description: description || '',
|
|
874
|
+
Classification: classification || '',
|
|
875
|
+
WebTemplate: 'SITEPAGEPUBLISHING#0',
|
|
876
|
+
SiteDesignId: siteDesignId
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
if (lcid) {
|
|
881
|
+
requestOptions.data.request.Lcid = lcid;
|
|
882
|
+
}
|
|
883
|
+
if (owners) {
|
|
884
|
+
requestOptions.data.request.Owner = owners;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const res = yield request_1.default.post(requestOptions);
|
|
888
|
+
if (isTeamSite) {
|
|
889
|
+
if (res.ErrorMessage !== null) {
|
|
890
|
+
throw res.ErrorMessage;
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
return res.SiteUrl;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
else {
|
|
897
|
+
if (res.SiteStatus === 2) {
|
|
898
|
+
return res.SiteUrl;
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
throw 'An error has occurred while creating the site';
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
},
|
|
907
|
+
/**
|
|
908
|
+
* Checks if a site exists
|
|
909
|
+
* Returns a boolean
|
|
910
|
+
* @param url The url of the site
|
|
911
|
+
* @param logger the Logger object
|
|
912
|
+
* @param verbose set if verbose logging should be logged
|
|
913
|
+
*/
|
|
914
|
+
siteExists(url, logger, verbose) {
|
|
915
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
916
|
+
const spoAdminUrl = yield exports.spo.getSpoAdminUrl(logger, verbose);
|
|
917
|
+
const context = yield exports.spo.ensureFormDigest(spoAdminUrl, logger, undefined, verbose);
|
|
918
|
+
if (verbose) {
|
|
919
|
+
logger.logToStderr(`Checking if the site ${url} exists...`);
|
|
920
|
+
}
|
|
921
|
+
const requestOptions = {
|
|
922
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
923
|
+
headers: {
|
|
924
|
+
'X-RequestDigest': context.FormDigestValue
|
|
925
|
+
},
|
|
926
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="197" ObjectPathId="196" /><ObjectPath Id="199" ObjectPathId="198" /><Query Id="200" ObjectPathId="198"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Constructor Id="196" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="198" ParentId="196" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter><Parameter Type="Boolean">false</Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
927
|
+
};
|
|
928
|
+
const res1 = yield request_1.default.post(requestOptions);
|
|
929
|
+
const json = JSON.parse(res1);
|
|
930
|
+
const response = json[0];
|
|
931
|
+
if (response.ErrorInfo) {
|
|
932
|
+
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.Online.SharePoint.Common.SpoNoSiteException') {
|
|
933
|
+
return yield this.siteExistsInTheRecycleBin(url, logger, verbose);
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
const site = json[json.length - 1];
|
|
941
|
+
return site.Status === 'Recycled';
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
},
|
|
945
|
+
/**
|
|
946
|
+
* Checks if a site exists in the recycle bin
|
|
947
|
+
* Returns a boolean
|
|
948
|
+
* @param url The url of the site
|
|
949
|
+
* @param logger the Logger object
|
|
950
|
+
* @param verbose set if verbose logging should be logged
|
|
951
|
+
*/
|
|
952
|
+
siteExistsInTheRecycleBin(url, logger, verbose) {
|
|
953
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
954
|
+
if (verbose) {
|
|
955
|
+
logger.logToStderr(`Site doesn't exist. Checking if the site ${url} exists in the recycle bin...`);
|
|
956
|
+
}
|
|
957
|
+
const spoAdminUrl = yield exports.spo.getSpoAdminUrl(logger, verbose);
|
|
958
|
+
const context = yield exports.spo.ensureFormDigest(spoAdminUrl, logger, undefined, verbose);
|
|
959
|
+
const requestOptions = {
|
|
960
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
961
|
+
headers: {
|
|
962
|
+
'X-RequestDigest': context.FormDigestValue
|
|
963
|
+
},
|
|
964
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="181" ObjectPathId="180" /><Query Id="182" ObjectPathId="180"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="180" ParentId="175" Name="GetDeletedSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
965
|
+
};
|
|
966
|
+
const res = yield request_1.default.post(requestOptions);
|
|
967
|
+
const json = JSON.parse(res);
|
|
968
|
+
const response = json[0];
|
|
969
|
+
if (response.ErrorInfo) {
|
|
970
|
+
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.SharePoint.Client.UnknownError') {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
974
|
+
}
|
|
975
|
+
const site = json[json.length - 1];
|
|
976
|
+
return site.Status === 'Recycled';
|
|
977
|
+
});
|
|
978
|
+
},
|
|
979
|
+
/**
|
|
980
|
+
* Deletes a site from the recycle bin
|
|
981
|
+
* @param url The url of the site
|
|
982
|
+
* @param logger the Logger object
|
|
983
|
+
* @param verbose set if verbose logging should be logged
|
|
984
|
+
* @param wait set to wait until finished
|
|
985
|
+
*/
|
|
986
|
+
deleteSiteFromTheRecycleBin(url, logger, verbose, wait) {
|
|
987
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
988
|
+
const spoAdminUrl = yield exports.spo.getSpoAdminUrl(logger, verbose);
|
|
989
|
+
const context = yield exports.spo.ensureFormDigest(spoAdminUrl, logger, undefined, verbose);
|
|
990
|
+
if (verbose) {
|
|
991
|
+
logger.logToStderr(`Deleting site ${url} from the recycle bin...`);
|
|
992
|
+
}
|
|
993
|
+
const requestOptions = {
|
|
994
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
995
|
+
headers: {
|
|
996
|
+
'X-RequestDigest': context.FormDigestValue
|
|
997
|
+
},
|
|
998
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="185" ObjectPathId="184" /><Query Id="186" ObjectPathId="184"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="184" ParentId="175" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
999
|
+
};
|
|
1000
|
+
const response = yield request_1.default.post(requestOptions);
|
|
1001
|
+
const json = JSON.parse(response);
|
|
1002
|
+
const responseContent = json[0];
|
|
1003
|
+
if (responseContent.ErrorInfo) {
|
|
1004
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
1005
|
+
}
|
|
1006
|
+
const operation = json[json.length - 1];
|
|
1007
|
+
const isComplete = operation.IsComplete;
|
|
1008
|
+
if (!wait || isComplete) {
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
yield new Promise((resolve, reject) => {
|
|
1012
|
+
setTimeout(() => {
|
|
1013
|
+
exports.spo.waitUntilFinished({
|
|
1014
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
1015
|
+
siteUrl: spoAdminUrl,
|
|
1016
|
+
resolve,
|
|
1017
|
+
reject,
|
|
1018
|
+
logger,
|
|
1019
|
+
currentContext: context,
|
|
1020
|
+
verbose: verbose,
|
|
1021
|
+
debug: verbose
|
|
1022
|
+
});
|
|
1023
|
+
}, operation.PollingInterval);
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
},
|
|
1027
|
+
/**
|
|
1028
|
+
* Updates a site with the given properties
|
|
1029
|
+
* @param url The url of the site
|
|
1030
|
+
* @param logger The logger object
|
|
1031
|
+
* @param verbose Set for verbose logging
|
|
1032
|
+
* @param title The new title
|
|
1033
|
+
* @param classification The classification to be updated
|
|
1034
|
+
* @param disableFlows If flows should be disabled or not
|
|
1035
|
+
* @param isPublic If site should be public or private
|
|
1036
|
+
* @param owners The owners to be updated
|
|
1037
|
+
* @param shareByEmailEnabled If share by e-mail should be enabled or not
|
|
1038
|
+
* @param siteDesignId The site design to be updated
|
|
1039
|
+
* @param sharingCapability The sharing capability to be updated
|
|
1040
|
+
*/
|
|
1041
|
+
updateSite(url, logger, verbose, title, classification, disableFlows, isPublic, owners, shareByEmailEnabled, siteDesignId, sharingCapability) {
|
|
1042
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1043
|
+
const tenantId = yield exports.spo.getTenantId(logger, verbose);
|
|
1044
|
+
const spoAdminUrl = yield exports.spo.getSpoAdminUrl(logger, verbose);
|
|
1045
|
+
let context = yield exports.spo.ensureFormDigest(spoAdminUrl, logger, undefined, verbose);
|
|
1046
|
+
if (verbose) {
|
|
1047
|
+
logger.logToStderr('Loading site IDs...');
|
|
1048
|
+
}
|
|
1049
|
+
const requestOptions = {
|
|
1050
|
+
url: `${url}/_api/site?$select=GroupId,Id`,
|
|
1051
|
+
headers: {
|
|
1052
|
+
accept: 'application/json;odata=nometadata'
|
|
1053
|
+
},
|
|
1054
|
+
responseType: 'json'
|
|
1055
|
+
};
|
|
1056
|
+
const siteInfo = yield request_1.default.get(requestOptions);
|
|
1057
|
+
const groupId = siteInfo.GroupId;
|
|
1058
|
+
const siteId = siteInfo.Id;
|
|
1059
|
+
const isGroupConnectedSite = groupId !== '00000000-0000-0000-0000-000000000000';
|
|
1060
|
+
if (verbose) {
|
|
1061
|
+
logger.logToStderr(`Retrieved site IDs. siteId: ${siteId}, groupId: ${groupId}`);
|
|
1062
|
+
}
|
|
1063
|
+
if (isGroupConnectedSite) {
|
|
1064
|
+
if (verbose) {
|
|
1065
|
+
logger.logToStderr(`Site attached to group ${groupId}`);
|
|
1066
|
+
}
|
|
1067
|
+
if (typeof title !== 'undefined' &&
|
|
1068
|
+
typeof isPublic !== 'undefined' &&
|
|
1069
|
+
typeof owners !== 'undefined') {
|
|
1070
|
+
const promises = [];
|
|
1071
|
+
if (typeof title !== 'undefined') {
|
|
1072
|
+
const requestOptions = {
|
|
1073
|
+
url: `${spoAdminUrl}/_api/SPOGroup/UpdateGroupPropertiesBySiteId`,
|
|
1074
|
+
headers: {
|
|
1075
|
+
accept: 'application/json;odata=nometadata',
|
|
1076
|
+
'content-type': 'application/json;charset=utf-8',
|
|
1077
|
+
'X-RequestDigest': context.FormDigestValue
|
|
1078
|
+
},
|
|
1079
|
+
data: {
|
|
1080
|
+
groupId: groupId,
|
|
1081
|
+
siteId: siteId,
|
|
1082
|
+
displayName: title
|
|
1083
|
+
},
|
|
1084
|
+
responseType: 'json'
|
|
1085
|
+
};
|
|
1086
|
+
promises.push(request_1.default.post(requestOptions));
|
|
1087
|
+
}
|
|
1088
|
+
if (typeof isPublic !== 'undefined') {
|
|
1089
|
+
promises.push(aadGroup_1.aadGroup.setGroup(groupId, (isPublic === false), logger, verbose));
|
|
1090
|
+
}
|
|
1091
|
+
if (typeof owners !== 'undefined') {
|
|
1092
|
+
promises.push(exports.spo.setGroupifiedSiteOwners(spoAdminUrl, groupId, owners, logger, verbose));
|
|
1093
|
+
}
|
|
1094
|
+
yield Promise.all(promises);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
if (verbose) {
|
|
1099
|
+
logger.logToStderr('Site is not group connected');
|
|
1100
|
+
}
|
|
1101
|
+
if (typeof isPublic !== 'undefined') {
|
|
1102
|
+
throw `The isPublic option can't be set on a site that is not groupified`;
|
|
1103
|
+
}
|
|
1104
|
+
if (owners) {
|
|
1105
|
+
yield Promise.all(owners.split(',').map((o) => __awaiter(this, void 0, void 0, function* () {
|
|
1106
|
+
yield exports.spo.setSiteAdmin(spoAdminUrl, context, url, o.trim());
|
|
1107
|
+
})));
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
context = yield exports.spo.ensureFormDigest(spoAdminUrl, logger, context, verbose);
|
|
1111
|
+
if (verbose) {
|
|
1112
|
+
logger.logToStderr(`Updating site ${url} properties...`);
|
|
1113
|
+
}
|
|
1114
|
+
let updatedProperties = false;
|
|
1115
|
+
if (!isGroupConnectedSite) {
|
|
1116
|
+
if (title !== undefined) {
|
|
1117
|
+
updatedProperties = true;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
else {
|
|
1121
|
+
if (classification !== undefined || disableFlows !== undefined || shareByEmailEnabled !== undefined || sharingCapability !== undefined) {
|
|
1122
|
+
updatedProperties = true;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
if (updatedProperties) {
|
|
1126
|
+
let propertyId = 27;
|
|
1127
|
+
const payload = [];
|
|
1128
|
+
if (!isGroupConnectedSite) {
|
|
1129
|
+
if (title) {
|
|
1130
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Title"><Parameter Type="String">${formatting_1.formatting.escapeXml(title)}</Parameter></SetProperty>`);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
if (typeof classification === 'string') {
|
|
1134
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Classification"><Parameter Type="String">${formatting_1.formatting.escapeXml(classification)}</Parameter></SetProperty>`);
|
|
1135
|
+
}
|
|
1136
|
+
if (typeof disableFlows !== 'undefined') {
|
|
1137
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="DisableFlows"><Parameter Type="Boolean">${disableFlows}</Parameter></SetProperty>`);
|
|
1138
|
+
}
|
|
1139
|
+
if (typeof shareByEmailEnabled !== 'undefined') {
|
|
1140
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="ShareByEmailEnabled"><Parameter Type="Boolean">${shareByEmailEnabled}</Parameter></SetProperty>`);
|
|
1141
|
+
}
|
|
1142
|
+
if (sharingCapability) {
|
|
1143
|
+
const sharingCapabilityOption = SharingCapabilities_1.SharingCapabilities[sharingCapability];
|
|
1144
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="SharingCapability"><Parameter Type="Enum">${sharingCapabilityOption}</Parameter></SetProperty>`);
|
|
1145
|
+
}
|
|
1146
|
+
const pos = tenantId.indexOf('|') + 1;
|
|
1147
|
+
const requestOptionsUpdateProperties = {
|
|
1148
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
1149
|
+
headers: {
|
|
1150
|
+
'X-RequestDigest': context.FormDigestValue
|
|
1151
|
+
},
|
|
1152
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions>${payload.join('')}<ObjectPath Id="14" ObjectPathId="13" /><ObjectIdentityQuery Id="15" ObjectPathId="5" /><Query Id="16" ObjectPathId="13"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Identity Id="5" Name="53d8499e-d0d2-5000-cb83-9ade5be42ca4|${tenantId.substr(pos, tenantId.indexOf('&') - pos)}
SiteProperties
${formatting_1.formatting.encodeQueryParameter(url)}" /><Method Id="13" ParentId="5" Name="Update" /></ObjectPaths></Request>`
|
|
1153
|
+
};
|
|
1154
|
+
const res = yield request_1.default.post(requestOptionsUpdateProperties);
|
|
1155
|
+
const json = JSON.parse(res);
|
|
1156
|
+
const response = json[0];
|
|
1157
|
+
if (response.ErrorInfo) {
|
|
1158
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
1159
|
+
}
|
|
1160
|
+
else {
|
|
1161
|
+
const operation = json[json.length - 1];
|
|
1162
|
+
const isComplete = operation.IsComplete;
|
|
1163
|
+
if (!isComplete) {
|
|
1164
|
+
yield new Promise((resolve, reject) => {
|
|
1165
|
+
setTimeout(() => {
|
|
1166
|
+
exports.spo.waitUntilFinished({
|
|
1167
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
1168
|
+
siteUrl: spoAdminUrl,
|
|
1169
|
+
resolve,
|
|
1170
|
+
reject,
|
|
1171
|
+
logger,
|
|
1172
|
+
currentContext: context,
|
|
1173
|
+
verbose: verbose,
|
|
1174
|
+
debug: verbose
|
|
1175
|
+
});
|
|
1176
|
+
}, operation.PollingInterval);
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
if (siteDesignId) {
|
|
1182
|
+
yield exports.spo.applySiteDesign(siteDesignId, url, logger, verbose);
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
},
|
|
1186
|
+
/**
|
|
1187
|
+
* Updates the groupified site owners
|
|
1188
|
+
* @param spoAdminUrl The SharePoint admin url
|
|
1189
|
+
* @param groupId The ID of the group
|
|
1190
|
+
* @param owners The owners to be updated
|
|
1191
|
+
* @param logger The logger object
|
|
1192
|
+
* @param verbose Set for verbose logging
|
|
1193
|
+
*/
|
|
1194
|
+
setGroupifiedSiteOwners(spoAdminUrl, groupId, owners, logger, verbose) {
|
|
1195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1196
|
+
const splittedOwners = owners.split(',').map(o => o.trim());
|
|
1197
|
+
if (verbose) {
|
|
1198
|
+
logger.logToStderr('Retrieving user information to set group owners...');
|
|
1199
|
+
}
|
|
1200
|
+
const requestOptions = {
|
|
1201
|
+
url: `https://graph.microsoft.com/v1.0/users?$filter=${splittedOwners.map(o => `userPrincipalName eq '${o}'`).join(' or ')}&$select=id`,
|
|
1202
|
+
headers: {
|
|
1203
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
1204
|
+
},
|
|
1205
|
+
responseType: 'json'
|
|
1206
|
+
};
|
|
1207
|
+
return request_1.default.get(requestOptions)
|
|
1208
|
+
.then((res) => {
|
|
1209
|
+
if (res.value.length === 0) {
|
|
1210
|
+
return Promise.resolve();
|
|
1211
|
+
}
|
|
1212
|
+
return Promise.all(res.value.map(user => {
|
|
1213
|
+
const requestOptions = {
|
|
1214
|
+
url: `${spoAdminUrl}/_api/SP.Directory.DirectorySession/Group('${groupId}')/Owners/Add(objectId='${user.id}', principalName='')`,
|
|
1215
|
+
headers: {
|
|
1216
|
+
'content-type': 'application/json;odata=verbose'
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
return request_1.default.post(requestOptions);
|
|
1220
|
+
}));
|
|
1221
|
+
});
|
|
1222
|
+
});
|
|
1223
|
+
},
|
|
1224
|
+
/**
|
|
1225
|
+
* Updates the site admin
|
|
1226
|
+
* @param spoAdminUrl The SharePoint admin url
|
|
1227
|
+
* @param context The FormDigestInfo
|
|
1228
|
+
* @param siteUrl The url of the site where the owners has to be updated
|
|
1229
|
+
* @param principal The principal of the admin
|
|
1230
|
+
* @param logger The logger object
|
|
1231
|
+
* @param verbose Set for verbose logging
|
|
1232
|
+
*/
|
|
1233
|
+
setSiteAdmin(spoAdminUrl, context, siteUrl, principal, logger, verbose) {
|
|
1234
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1235
|
+
if (verbose && logger) {
|
|
1236
|
+
logger.logToStderr(`Updating site admin ${principal} on ${siteUrl}...`);
|
|
1237
|
+
}
|
|
1238
|
+
const requestOptions = {
|
|
1239
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
1240
|
+
headers: {
|
|
1241
|
+
'X-RequestDigest': context.FormDigestValue
|
|
1242
|
+
},
|
|
1243
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="48" ObjectPathId="47" /></Actions><ObjectPaths><Method Id="47" ParentId="34" Name="SetSiteAdmin"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(siteUrl)}</Parameter><Parameter Type="String">${formatting_1.formatting.escapeXml(principal)}</Parameter><Parameter Type="Boolean">true</Parameter></Parameters></Method><Constructor Id="34" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
1244
|
+
};
|
|
1245
|
+
const res = yield request_1.default.post(requestOptions);
|
|
1246
|
+
const json = JSON.parse(res);
|
|
1247
|
+
const response = json[0];
|
|
1248
|
+
if (response.ErrorInfo) {
|
|
1249
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
1250
|
+
}
|
|
1251
|
+
else {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
},
|
|
1256
|
+
/**
|
|
1257
|
+
* Applies a site design
|
|
1258
|
+
* @param id The ID of the site design (GUID)
|
|
1259
|
+
* @param webUrl The url of the site where the design should be applied
|
|
1260
|
+
* @param logger The logger object
|
|
1261
|
+
* @param verbose Set for verbose logging
|
|
1262
|
+
*/
|
|
1263
|
+
applySiteDesign(id, webUrl, logger, verbose) {
|
|
1264
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1265
|
+
if (verbose) {
|
|
1266
|
+
logger.logToStderr(`Applying site design ${id}...`);
|
|
1267
|
+
}
|
|
1268
|
+
const spoUrl = yield exports.spo.getSpoUrl(logger, verbose);
|
|
1269
|
+
const requestOptions = {
|
|
1270
|
+
url: `${spoUrl}/_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.ApplySiteDesign`,
|
|
1271
|
+
headers: {
|
|
1272
|
+
'content-type': 'application/json;charset=utf-8',
|
|
1273
|
+
accept: 'application/json;odata=nometadata'
|
|
1274
|
+
},
|
|
1275
|
+
data: {
|
|
1276
|
+
siteDesignId: id,
|
|
1277
|
+
webUrl: webUrl
|
|
1278
|
+
},
|
|
1279
|
+
responseType: 'json'
|
|
1280
|
+
};
|
|
1281
|
+
yield request_1.default.post(requestOptions);
|
|
1282
|
+
});
|
|
1283
|
+
},
|
|
1284
|
+
/**
|
|
1285
|
+
* Gets the web properties for a given url
|
|
1286
|
+
* @param url The url of the web
|
|
1287
|
+
* @param logger The logger object
|
|
1288
|
+
* @param verbose Set for verbose logging
|
|
1289
|
+
*/
|
|
1290
|
+
getWeb(url, logger, verbose) {
|
|
1291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1292
|
+
if (verbose && logger) {
|
|
1293
|
+
logger.logToStderr(`Getting the web properties for ${url}`);
|
|
1294
|
+
}
|
|
1295
|
+
const requestOptions = {
|
|
1296
|
+
url: `${url}/_api/web`,
|
|
1297
|
+
headers: {
|
|
1298
|
+
'accept': 'application/json;odata=nometadata'
|
|
1299
|
+
},
|
|
1300
|
+
responseType: 'json'
|
|
1301
|
+
};
|
|
1302
|
+
const webProperties = yield request_1.default.get(requestOptions);
|
|
1303
|
+
return webProperties;
|
|
1304
|
+
});
|
|
705
1305
|
}
|
|
706
1306
|
};
|
|
707
1307
|
//# sourceMappingURL=spo.js.map
|
|
@@ -16,11 +16,14 @@ m365 spo orgassetslibrary add [options]
|
|
|
16
16
|
`--libraryUrl <libraryUrl>`
|
|
17
17
|
: The URL of the library to promote.
|
|
18
18
|
|
|
19
|
-
`--thumbnailUrl
|
|
19
|
+
`--thumbnailUrl [thumbnailUrl]`
|
|
20
20
|
: The URL of the thumbnail to render.
|
|
21
21
|
|
|
22
22
|
`--cdnType [cdnType]`
|
|
23
23
|
: Specifies the CDN type. Allowed values `Public`, `Private`. Default `Private`.
|
|
24
|
+
|
|
25
|
+
`--orgAssetType [orgAssetType]`
|
|
26
|
+
: Specifies the type of organizational library. Allowed values `ImageDocumentLibrary`, `OfficeTemplateLibrary`, `OfficeFontLibrary`. Defaults to `ImageDocumentLibrary`.
|
|
24
27
|
```
|
|
25
28
|
|
|
26
29
|
<Global />
|
|
@@ -33,6 +36,10 @@ To use this command you have to have permissions to access the tenant admin site
|
|
|
33
36
|
|
|
34
37
|
:::
|
|
35
38
|
|
|
39
|
+
To enable CDN in your tenant use the [spo cdn set](../cdn/cdn-set.mdx) command.
|
|
40
|
+
|
|
41
|
+
The document library on which you run the command must at least have read permissions for all users, except external users.
|
|
42
|
+
|
|
36
43
|
## Examples
|
|
37
44
|
|
|
38
45
|
Promotes an existing library to become an organization assets library
|
|
@@ -47,6 +54,12 @@ Promotes an existing library to become an organization assets library with Thumb
|
|
|
47
54
|
m365 spo orgassetslibrary --libraryUrl "https://contoso.sharepoint.com/SiteAssets" --thumbnailUrl "https://contoso.sharepoint.com/assets/logo.png"
|
|
48
55
|
```
|
|
49
56
|
|
|
57
|
+
Promotes an existing library to become an organization assets Office template library
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
m365 spo orgassetslibrary add --libraryUrl "https://contoso.sharepoint.com/SiteAssets" --orgAssetType "OfficeTemplateLibrary"
|
|
61
|
+
```
|
|
62
|
+
|
|
50
63
|
## Response
|
|
51
64
|
|
|
52
65
|
The command won't return a response on success.
|
package/package.json
CHANGED