@pnp/cli-microsoft365 11.5.0-beta.083a680 → 11.5.0-beta.9dbb2e8

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.
@@ -1,14 +1,21 @@
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 _SpoSiteHubSiteConnectCommand_instances, _SpoSiteHubSiteConnectCommand_initOptions, _SpoSiteHubSiteConnectCommand_initValidators;
7
1
  import request from '../../../../request.js';
8
2
  import { formatting } from '../../../../utils/formatting.js';
9
3
  import { validation } from '../../../../utils/validation.js';
10
4
  import SpoCommand from '../../../base/SpoCommand.js';
11
5
  import commands from '../../commands.js';
6
+ import { globalOptionsZod } from '../../../../Command.js';
7
+ import { z } from 'zod';
8
+ import { spo } from '../../../../utils/spo.js';
9
+ export const options = z.strictObject({
10
+ ...globalOptionsZod.shape,
11
+ siteUrl: z.string()
12
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
13
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
14
+ })
15
+ .alias('u'),
16
+ id: z.uuid().alias('i'),
17
+ asAdmin: z.boolean().optional()
18
+ });
12
19
  class SpoSiteHubSiteConnectCommand extends SpoCommand {
13
20
  get name() {
14
21
  return commands.SITE_HUBSITE_CONNECT;
@@ -16,11 +23,8 @@ class SpoSiteHubSiteConnectCommand extends SpoCommand {
16
23
  get description() {
17
24
  return 'Connects the specified site collection to the given hub site';
18
25
  }
19
- constructor() {
20
- super();
21
- _SpoSiteHubSiteConnectCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _SpoSiteHubSiteConnectCommand_instances, "m", _SpoSiteHubSiteConnectCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _SpoSiteHubSiteConnectCommand_instances, "m", _SpoSiteHubSiteConnectCommand_initValidators).call(this);
26
+ get schema() {
27
+ return options;
24
28
  }
25
29
  async commandAction(logger, args) {
26
30
  try {
@@ -28,12 +32,22 @@ class SpoSiteHubSiteConnectCommand extends SpoCommand {
28
32
  await logger.logToStderr(`Connecting site collection ${args.options.siteUrl} to hub site ${args.options.id}...`);
29
33
  }
30
34
  const requestOptions = {
31
- url: `${args.options.siteUrl}/_api/site/JoinHubSite('${formatting.encodeQueryParameter(args.options.id)}')`,
32
35
  headers: {
33
36
  accept: 'application/json;odata=nometadata'
34
37
  },
35
38
  responseType: 'json'
36
39
  };
40
+ if (!args.options.asAdmin) {
41
+ requestOptions.url = `${args.options.siteUrl}/_api/site/JoinHubSite('${formatting.encodeQueryParameter(args.options.id)}')`;
42
+ }
43
+ else {
44
+ const tenantAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
45
+ requestOptions.url = `${tenantAdminUrl}/_api/SPO.Tenant/ConnectSiteToHubSiteById`;
46
+ requestOptions.data = {
47
+ siteUrl: args.options.siteUrl,
48
+ hubSiteId: args.options.id
49
+ };
50
+ }
37
51
  await request.post(requestOptions);
38
52
  }
39
53
  catch (err) {
@@ -41,23 +55,5 @@ class SpoSiteHubSiteConnectCommand extends SpoCommand {
41
55
  }
42
56
  }
43
57
  }
44
- _SpoSiteHubSiteConnectCommand_instances = new WeakSet(), _SpoSiteHubSiteConnectCommand_initOptions = function _SpoSiteHubSiteConnectCommand_initOptions() {
45
- this.options.unshift({
46
- option: '-u, --siteUrl <siteUrl>'
47
- }, {
48
- option: '-i, --id <id>'
49
- });
50
- }, _SpoSiteHubSiteConnectCommand_initValidators = function _SpoSiteHubSiteConnectCommand_initValidators() {
51
- this.validators.push(async (args) => {
52
- const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.siteUrl);
53
- if (isValidSharePointUrl !== true) {
54
- return isValidSharePointUrl;
55
- }
56
- if (!validation.isValidGuid(args.options.id)) {
57
- return `${args.options.id} is not a valid GUID`;
58
- }
59
- return true;
60
- });
61
- };
62
58
  export default new SpoSiteHubSiteConnectCommand();
63
59
  //# sourceMappingURL=site-hubsite-connect.js.map
@@ -1,14 +1,21 @@
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 _SpoSiteHubSiteDisconnectCommand_instances, _SpoSiteHubSiteDisconnectCommand_initTelemetry, _SpoSiteHubSiteDisconnectCommand_initOptions, _SpoSiteHubSiteDisconnectCommand_initValidators;
7
1
  import { cli } from '../../../../cli/cli.js';
8
2
  import request from '../../../../request.js';
9
3
  import { validation } from '../../../../utils/validation.js';
10
4
  import SpoCommand from '../../../base/SpoCommand.js';
11
5
  import commands from '../../commands.js';
6
+ import { globalOptionsZod } from '../../../../Command.js';
7
+ import { z } from 'zod';
8
+ import { spo } from '../../../../utils/spo.js';
9
+ export const options = z.strictObject({
10
+ ...globalOptionsZod.shape,
11
+ siteUrl: z.string()
12
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
13
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
14
+ })
15
+ .alias('u'),
16
+ asAdmin: z.boolean().optional(),
17
+ force: z.boolean().alias('f').optional()
18
+ });
12
19
  class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
13
20
  get name() {
14
21
  return commands.SITE_HUBSITE_DISCONNECT;
@@ -16,12 +23,8 @@ class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
16
23
  get description() {
17
24
  return 'Disconnects the specified site collection from its hub site';
18
25
  }
19
- constructor() {
20
- super();
21
- _SpoSiteHubSiteDisconnectCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _SpoSiteHubSiteDisconnectCommand_instances, "m", _SpoSiteHubSiteDisconnectCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _SpoSiteHubSiteDisconnectCommand_instances, "m", _SpoSiteHubSiteDisconnectCommand_initOptions).call(this);
24
- __classPrivateFieldGet(this, _SpoSiteHubSiteDisconnectCommand_instances, "m", _SpoSiteHubSiteDisconnectCommand_initValidators).call(this);
26
+ get schema() {
27
+ return options;
25
28
  }
26
29
  async commandAction(logger, args) {
27
30
  if (args.options.force) {
@@ -40,12 +43,22 @@ class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
40
43
  await logger.logToStderr(`Disconnecting site collection ${args.options.siteUrl} from its hub site...`);
41
44
  }
42
45
  const requestOptions = {
43
- url: `${args.options.siteUrl}/_api/site/JoinHubSite('00000000-0000-0000-0000-000000000000')`,
44
46
  headers: {
45
47
  accept: 'application/json;odata=nometadata'
46
48
  },
47
49
  responseType: 'json'
48
50
  };
51
+ if (!args.options.asAdmin) {
52
+ requestOptions.url = `${args.options.siteUrl}/_api/site/JoinHubSite('00000000-0000-0000-0000-000000000000')`;
53
+ }
54
+ else {
55
+ const tenantAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
56
+ requestOptions.url = `${tenantAdminUrl}/_api/SPO.Tenant/ConnectSiteToHubSiteById`;
57
+ requestOptions.data = {
58
+ siteUrl: args.options.siteUrl,
59
+ hubSiteId: '00000000-0000-0000-0000-000000000000'
60
+ };
61
+ }
49
62
  await request.post(requestOptions);
50
63
  }
51
64
  catch (err) {
@@ -53,20 +66,5 @@ class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
53
66
  }
54
67
  }
55
68
  }
56
- _SpoSiteHubSiteDisconnectCommand_instances = new WeakSet(), _SpoSiteHubSiteDisconnectCommand_initTelemetry = function _SpoSiteHubSiteDisconnectCommand_initTelemetry() {
57
- this.telemetry.push((args) => {
58
- Object.assign(this.telemetryProperties, {
59
- force: args.options.force || false
60
- });
61
- });
62
- }, _SpoSiteHubSiteDisconnectCommand_initOptions = function _SpoSiteHubSiteDisconnectCommand_initOptions() {
63
- this.options.unshift({
64
- option: '-u, --siteUrl <siteUrl>'
65
- }, {
66
- option: '-f, --force'
67
- });
68
- }, _SpoSiteHubSiteDisconnectCommand_initValidators = function _SpoSiteHubSiteDisconnectCommand_initValidators() {
69
- this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.siteUrl));
70
- };
71
69
  export default new SpoSiteHubSiteDisconnectCommand();
72
70
  //# sourceMappingURL=site-hubsite-disconnect.js.map
@@ -1,4 +1,6 @@
1
1
  import Global from '/docs/cmd/_global.mdx';
2
+ import Tabs from '@theme/Tabs';
3
+ import TabItem from '@theme/TabItem';
2
4
 
3
5
  # spo site hubsite connect
4
6
 
@@ -14,10 +16,13 @@ m365 spo site hubsite connect [options]
14
16
 
15
17
  ```md definition-list
16
18
  `-u, --siteUrl <siteUrl>`
17
- : The URL of the site collection to connect to the hub site
19
+ : The URL of the site collection to connect to the hub site.
18
20
 
19
21
  `-i, --id <id>`
20
- : The ID of the hub site to which to connect the site collection
22
+ : The ID of the hub site to which to connect the site collection.
23
+
24
+ `--asAdmin`
25
+ : Connect the site to a hub site as SharePoint admin.
21
26
  ```
22
27
 
23
28
  <Global />
@@ -28,6 +33,25 @@ If the specified site collection is already connected to a hub site, it will be
28
33
 
29
34
  If the specified `id` doesn't point to a valid hub site, you will get a `ResourceNotFoundException` error.
30
35
 
36
+ ## Permissions
37
+
38
+ <Tabs>
39
+ <TabItem value="Delegated">
40
+
41
+ | Resource | Permissions |
42
+ |------------|----------------------|
43
+ | SharePoint | AllSites.FullControl |
44
+
45
+ </TabItem>
46
+ <TabItem value="Application">
47
+
48
+ | Resource | Permissions |
49
+ |------------|-----------------------|
50
+ | SharePoint | Sites.FullControl.All |
51
+
52
+ </TabItem>
53
+ </Tabs>
54
+
31
55
  ## Examples
32
56
 
33
57
  Connect a specific site collection to a hub site
@@ -36,6 +60,12 @@ Connect a specific site collection to a hub site
36
60
  m365 spo site hubsite connect --siteUrl https://contoso.sharepoint.com/sites/contoso-sales --id 255a50b2-527f-4413-8485-57f4c17a24d1
37
61
  ```
38
62
 
63
+ Connect a specific site collection to a hub site as SharePoint admin
64
+
65
+ ```sh
66
+ m365 spo site hubsite connect --siteUrl https://contoso.sharepoint.com/sites/contoso-sales --id 255a50b2-527f-4413-8485-57f4c17a24d1 --asAdmin
67
+ ```
68
+
39
69
  ## Response
40
70
 
41
71
  The command won't return a response on success.
@@ -1,4 +1,6 @@
1
1
  import Global from '/docs/cmd/_global.mdx';
2
+ import Tabs from '@theme/Tabs';
3
+ import TabItem from '@theme/TabItem';
2
4
 
3
5
  # spo site hubsite disconnect
4
6
 
@@ -14,14 +16,36 @@ m365 spo site hubsite disconnect [options]
14
16
 
15
17
  ```md definition-list
16
18
  `-u, --siteUrl <siteUrl>`
17
- : URL of the site collection to disconnect from its hub site
19
+ : URL of the site collection to disconnect from its hub site.
20
+
21
+ `--asAdmin`
22
+ : Disconnect the site from a hub site as SharePoint admin.
18
23
 
19
24
  `-f, --force`
20
- : Don't prompt for confirmation
25
+ : Don't prompt for confirmation.
21
26
  ```
22
27
 
23
28
  <Global />
24
29
 
30
+ ## Permissions
31
+
32
+ <Tabs>
33
+ <TabItem value="Delegated">
34
+
35
+ | Resource | Permissions |
36
+ |------------|----------------------|
37
+ | SharePoint | AllSites.FullControl |
38
+
39
+ </TabItem>
40
+ <TabItem value="Application">
41
+
42
+ | Resource | Permissions |
43
+ |------------|-----------------------|
44
+ | SharePoint | Sites.FullControl.All |
45
+
46
+ </TabItem>
47
+ </Tabs>
48
+
25
49
  ## Examples
26
50
 
27
51
  Disconnect a specific site collection from its hub site. Will prompt for confirmation before disconnecting from the hub site.
@@ -30,6 +54,12 @@ Disconnect a specific site collection from its hub site. Will prompt for confirm
30
54
  m365 spo site hubsite disconnect --siteUrl https://contoso.sharepoint.com/sites/sales
31
55
  ```
32
56
 
57
+ Disconnect a specific site collection from its hub site as SharePoint admin.
58
+
59
+ ```sh
60
+ m365 spo site hubsite disconnect --siteUrl https://contoso.sharepoint.com/sites/sales --asAdmin
61
+ ```
62
+
33
63
  Disconnect a specific site collection from its hub site without prompting for confirmation.
34
64
 
35
65
  ```sh