@pnp/cli-microsoft365 10.8.0-beta.708bf27 → 10.8.0-beta.7160233

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.
Files changed (58) hide show
  1. package/.eslintrc.cjs +2 -1
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/Auth.js +82 -22
  5. package/dist/cli/cli.js +1 -1
  6. package/dist/config.js +1 -0
  7. package/dist/m365/adaptivecard/commands/adaptivecard-send.js +54 -67
  8. package/dist/m365/app/commands/app-get.js +5 -2
  9. package/dist/m365/app/commands/app-open.js +9 -22
  10. package/dist/m365/app/commands/permission/permission-add.js +18 -30
  11. package/dist/m365/app/commands/permission/permission-list.js +5 -2
  12. package/dist/m365/base/AppCommand.js +9 -25
  13. package/dist/m365/booking/commands/business/business-get.js +18 -25
  14. package/dist/m365/cli/commands/app/app-reconsent.js +103 -0
  15. package/dist/m365/cli/commands.js +1 -0
  16. package/dist/m365/commands/login.js +1 -1
  17. package/dist/m365/commands/setup.js +1 -2
  18. package/dist/m365/context/commands/context-remove.js +12 -25
  19. package/dist/m365/context/commands/option/option-remove.js +11 -25
  20. package/dist/m365/entra/commands/organization/organization-list.js +51 -0
  21. package/dist/m365/entra/commands.js +1 -0
  22. package/dist/m365/graph/commands/directoryextension/directoryextension-list.js +74 -0
  23. package/dist/m365/graph/commands/openextension/openextension-set.js +107 -0
  24. package/dist/m365/graph/commands.js +2 -0
  25. package/dist/m365/spe/commands/container/container-add.js +85 -0
  26. package/dist/m365/spe/commands/container/container-list.js +2 -9
  27. package/dist/m365/spe/commands/container/container-permission-list.js +52 -0
  28. package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +62 -0
  29. package/dist/m365/spe/commands/container/container-remove.js +99 -0
  30. package/dist/m365/spe/commands/containertype/containertype-add.js +11 -11
  31. package/dist/m365/spe/commands/containertype/containertype-get.js +28 -32
  32. package/dist/m365/spe/commands/containertype/containertype-list.js +14 -4
  33. package/dist/m365/spe/commands/containertype/containertype-remove.js +81 -0
  34. package/dist/m365/spe/commands.js +6 -1
  35. package/dist/m365/spo/commands/page/page-section-add.js +20 -23
  36. package/dist/utils/entraServicePrincipal.js +11 -0
  37. package/dist/utils/formatting.js +12 -0
  38. package/dist/utils/spe.js +77 -0
  39. package/dist/utils/spo.js +0 -18
  40. package/dist/utils/zod.js +26 -1
  41. package/docs/docs/cmd/adaptivecard/adaptivecard-send.mdx +1 -1
  42. package/docs/docs/cmd/cli/app/app-reconsent.mdx +63 -0
  43. package/docs/docs/cmd/entra/organization/organization-list.mdx +154 -0
  44. package/docs/docs/cmd/graph/directoryextension/directoryextension-list.mdx +135 -0
  45. package/docs/docs/cmd/graph/openextension/openextension-set.mdx +97 -0
  46. package/docs/docs/cmd/spe/container/container-activate.mdx +0 -2
  47. package/docs/docs/cmd/spe/container/container-add.mdx +128 -0
  48. package/docs/docs/cmd/spe/container/container-permission-list.mdx +90 -0
  49. package/docs/docs/cmd/spe/container/container-recyclebinitem-list.mdx +96 -0
  50. package/docs/docs/cmd/spe/container/container-remove.mdx +65 -0
  51. package/docs/docs/cmd/spe/containertype/containertype-add.mdx +9 -1
  52. package/docs/docs/cmd/spe/containertype/containertype-get.mdx +8 -0
  53. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +8 -0
  54. package/docs/docs/cmd/spe/containertype/containertype-remove.mdx +52 -0
  55. package/docs/docs/cmd/spo/field/field-get.mdx +0 -1
  56. package/npm-shrinkwrap.json +894 -477
  57. package/package.json +10 -10
  58. package/dist/m365/spe/ContainerProperties.js +0 -2
@@ -0,0 +1,52 @@
1
+ import { cli } from '../../../../cli/cli.js';
2
+ import { z } from 'zod';
3
+ import { zod } from '../../../../utils/zod.js';
4
+ import { globalOptionsZod } from '../../../../Command.js';
5
+ import commands from '../../commands.js';
6
+ import GraphCommand from '../../../base/GraphCommand.js';
7
+ import { odata } from '../../../../utils/odata.js';
8
+ import { formatting } from '../../../../utils/formatting.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ containerId: zod.alias('i', z.string())
12
+ })
13
+ .strict();
14
+ class SpeContainerPermissionListCommand extends GraphCommand {
15
+ get name() {
16
+ return commands.CONTAINER_PERMISSION_LIST;
17
+ }
18
+ get description() {
19
+ return 'Lists permissions of a SharePoint Embedded Container';
20
+ }
21
+ defaultProperties() {
22
+ return ['id', 'userPrincipalName', 'roles'];
23
+ }
24
+ get schema() {
25
+ return options;
26
+ }
27
+ async commandAction(logger, args) {
28
+ try {
29
+ if (this.verbose) {
30
+ await logger.logToStderr(`Retrieving permissions of a SharePoint Embedded Container with id '${args.options.containerId}'...`);
31
+ }
32
+ const containerPermission = await odata.getAllItems(`${this.resource}/v1.0/storage/fileStorage/containers/${formatting.encodeQueryParameter(args.options.containerId)}/permissions`);
33
+ if (!cli.shouldTrimOutput(args.options.output)) {
34
+ await logger.log(containerPermission);
35
+ }
36
+ else {
37
+ await logger.log(containerPermission.map(i => {
38
+ return {
39
+ id: i.id,
40
+ roles: i.roles.join(','),
41
+ userPrincipalName: i.grantedToV2.user.userPrincipalName
42
+ };
43
+ }));
44
+ }
45
+ }
46
+ catch (err) {
47
+ this.handleRejectedODataJsonPromise(err);
48
+ }
49
+ }
50
+ }
51
+ export default new SpeContainerPermissionListCommand();
52
+ //# sourceMappingURL=container-permission-list.js.map
@@ -0,0 +1,62 @@
1
+ import { globalOptionsZod } from '../../../../Command.js';
2
+ import { z } from 'zod';
3
+ import commands from '../../commands.js';
4
+ import { validation } from '../../../../utils/validation.js';
5
+ import { spo } from '../../../../utils/spo.js';
6
+ import GraphCommand from '../../../base/GraphCommand.js';
7
+ import { spe } from '../../../../utils/spe.js';
8
+ import { odata } from '../../../../utils/odata.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ containerTypeId: z.string()
12
+ .refine(id => validation.isValidGuid(id), id => ({
13
+ message: `'${id}' is not a valid GUID.`
14
+ })).optional(),
15
+ containerTypeName: z.string().optional()
16
+ })
17
+ .strict();
18
+ class SpeContainerRecycleBinItemListCommand extends GraphCommand {
19
+ get name() {
20
+ return commands.CONTAINER_RECYCLEBINITEM_LIST;
21
+ }
22
+ get description() {
23
+ return 'Lists deleted containers of a specific container type';
24
+ }
25
+ get schema() {
26
+ return options;
27
+ }
28
+ defaultProperties() {
29
+ return ['id', 'displayName'];
30
+ }
31
+ getRefinedSchema(schema) {
32
+ return schema
33
+ .refine((options) => [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 1, {
34
+ message: 'Use one of the following options: containerTypeId or containerTypeName.'
35
+ });
36
+ }
37
+ async commandAction(logger, args) {
38
+ try {
39
+ const containerTypeId = await this.getContainerTypeId(args.options, logger);
40
+ if (this.verbose) {
41
+ await logger.logToStderr(`Retrieving deleted containers of container type with ID '${containerTypeId}'...`);
42
+ }
43
+ const deletedContainers = await odata.getAllItems(`${this.resource}/v1.0/storage/fileStorage/deletedContainers?$filter=containerTypeId eq ${containerTypeId}`);
44
+ await logger.log(deletedContainers);
45
+ }
46
+ catch (err) {
47
+ this.handleRejectedODataJsonPromise(err);
48
+ }
49
+ }
50
+ async getContainerTypeId(options, logger) {
51
+ if (options.containerTypeId) {
52
+ return options.containerTypeId;
53
+ }
54
+ if (this.verbose) {
55
+ await logger.logToStderr(`Retrieving container type id for container type '${options.containerTypeName}'...`);
56
+ }
57
+ const adminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
58
+ return spe.getContainerTypeIdByName(adminUrl, options.containerTypeName);
59
+ }
60
+ }
61
+ export default new SpeContainerRecycleBinItemListCommand();
62
+ //# sourceMappingURL=container-recyclebinitem-list.js.map
@@ -0,0 +1,99 @@
1
+ import { globalOptionsZod } from '../../../../Command.js';
2
+ import { z } from 'zod';
3
+ import { zod } from '../../../../utils/zod.js';
4
+ import commands from '../../commands.js';
5
+ import { validation } from '../../../../utils/validation.js';
6
+ import { spe } from '../../../../utils/spe.js';
7
+ import { spo } from '../../../../utils/spo.js';
8
+ import GraphCommand from '../../../base/GraphCommand.js';
9
+ import request from '../../../../request.js';
10
+ import { cli } from '../../../../cli/cli.js';
11
+ const options = globalOptionsZod
12
+ .extend({
13
+ id: zod.alias('i', z.string()).optional(),
14
+ name: zod.alias('n', z.string()).optional(),
15
+ containerTypeId: z.string()
16
+ .refine(id => validation.isValidGuid(id), id => ({
17
+ message: `'${id}' is not a valid GUID.`
18
+ })).optional(),
19
+ containerTypeName: z.string().optional(),
20
+ recycle: z.boolean().optional(),
21
+ force: zod.alias('f', z.boolean().optional())
22
+ })
23
+ .strict();
24
+ class SpeContainerRemoveCommand extends GraphCommand {
25
+ get name() {
26
+ return commands.CONTAINER_REMOVE;
27
+ }
28
+ get description() {
29
+ return 'Removes a container';
30
+ }
31
+ get schema() {
32
+ return options;
33
+ }
34
+ getRefinedSchema(schema) {
35
+ return schema
36
+ .refine((options) => [options.id, options.name].filter(o => o !== undefined).length === 1, {
37
+ message: 'Use one of the following options: id or name.'
38
+ })
39
+ .refine((options) => !options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 1, {
40
+ message: 'Use one of the following options when specifying the container name: containerTypeId or containerTypeName.'
41
+ })
42
+ .refine((options) => options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 0, {
43
+ message: 'Options containerTypeId and containerTypeName are only required when deleting a container by name.'
44
+ });
45
+ }
46
+ async commandAction(logger, args) {
47
+ if (!args.options.force) {
48
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove container '${args.options.id || args.options.name}'${!args.options.recycle ? ' permanently' : ''}?` });
49
+ if (!result) {
50
+ return;
51
+ }
52
+ }
53
+ try {
54
+ const containerId = await this.getContainerId(args.options, logger);
55
+ if (this.verbose) {
56
+ await logger.logToStderr(`Removing container with ID '${containerId}'...`);
57
+ }
58
+ const requestOptions = {
59
+ url: `${this.resource}/v1.0/storage/fileStorage/containers/${containerId}`,
60
+ headers: {
61
+ accept: 'application/json;odata.metadata=none'
62
+ },
63
+ responseType: 'json'
64
+ };
65
+ if (args.options.recycle) {
66
+ await request.delete(requestOptions);
67
+ return;
68
+ }
69
+ // Container should be permanently deleted
70
+ requestOptions.url += '/permanentDelete';
71
+ await request.post(requestOptions);
72
+ }
73
+ catch (err) {
74
+ this.handleRejectedODataJsonPromise(err);
75
+ }
76
+ }
77
+ async getContainerId(options, logger) {
78
+ if (options.id) {
79
+ return options.id;
80
+ }
81
+ const containerTypeId = await this.getContainerTypeId(options, logger);
82
+ if (this.verbose) {
83
+ await logger.logToStderr(`Getting container ID for container with name '${options.name}'...`);
84
+ }
85
+ return spe.getContainerIdByName(containerTypeId, options.name);
86
+ }
87
+ async getContainerTypeId(options, logger) {
88
+ if (options.containerTypeId) {
89
+ return options.containerTypeId;
90
+ }
91
+ if (this.verbose) {
92
+ await logger.logToStderr(`Getting container type with name '${options.containerTypeName}'...`);
93
+ }
94
+ const adminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
95
+ return spe.getContainerTypeIdByName(adminUrl, options.containerTypeName);
96
+ }
97
+ }
98
+ export default new SpeContainerRemoveCommand();
99
+ //# sourceMappingURL=container-remove.js.map
@@ -3,14 +3,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _SpeContainertypeAddCommand_instances, _SpeContainertypeAddCommand_initTelemetry, _SpeContainertypeAddCommand_initOptions, _SpeContainertypeAddCommand_initValidators;
6
+ var _SpeContainerTypeAddCommand_instances, _SpeContainerTypeAddCommand_initTelemetry, _SpeContainerTypeAddCommand_initOptions, _SpeContainerTypeAddCommand_initValidators;
7
7
  import config from '../../../../config.js';
8
8
  import request from '../../../../request.js';
9
9
  import { spo } from '../../../../utils/spo.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
- class SpeContainertypeAddCommand extends SpoCommand {
13
+ class SpeContainerTypeAddCommand extends SpoCommand {
14
14
  get name() {
15
15
  return commands.CONTAINERTYPE_ADD;
16
16
  }
@@ -19,10 +19,10 @@ class SpeContainertypeAddCommand extends SpoCommand {
19
19
  }
20
20
  constructor() {
21
21
  super();
22
- _SpeContainertypeAddCommand_instances.add(this);
23
- __classPrivateFieldGet(this, _SpeContainertypeAddCommand_instances, "m", _SpeContainertypeAddCommand_initTelemetry).call(this);
24
- __classPrivateFieldGet(this, _SpeContainertypeAddCommand_instances, "m", _SpeContainertypeAddCommand_initOptions).call(this);
25
- __classPrivateFieldGet(this, _SpeContainertypeAddCommand_instances, "m", _SpeContainertypeAddCommand_initValidators).call(this);
22
+ _SpeContainerTypeAddCommand_instances.add(this);
23
+ __classPrivateFieldGet(this, _SpeContainerTypeAddCommand_instances, "m", _SpeContainerTypeAddCommand_initTelemetry).call(this);
24
+ __classPrivateFieldGet(this, _SpeContainerTypeAddCommand_instances, "m", _SpeContainerTypeAddCommand_initOptions).call(this);
25
+ __classPrivateFieldGet(this, _SpeContainerTypeAddCommand_instances, "m", _SpeContainerTypeAddCommand_initValidators).call(this);
26
26
  }
27
27
  async commandAction(logger, args) {
28
28
  try {
@@ -55,7 +55,7 @@ class SpeContainertypeAddCommand extends SpoCommand {
55
55
  await logger.log(result);
56
56
  }
57
57
  catch (err) {
58
- this.handleRejectedPromise(err);
58
+ this.handleRejectedODataJsonPromise(err);
59
59
  }
60
60
  }
61
61
  replaceString(s) {
@@ -68,7 +68,7 @@ class SpeContainertypeAddCommand extends SpoCommand {
68
68
  return `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Method Name="NewSPOContainerType" Id="4" ObjectPathId="1"><Parameters><Parameter TypeId="{5466648e-c306-441b-9df4-c09deef25cb1}"><Property Name="AzureSubscriptionId" Type="Guid">{${options.azureSubscriptionId}}</Property><Property Name="ContainerTypeId" Type="Guid">{00000000-0000-0000-0000-000000000000}</Property><Property Name="CreationDate" Type="Null" /><Property Name="DisplayName" Type="String">${options.name}</Property><Property Name="ExpiryDate" Type="Null" /><Property Name="IsBillingProfileRequired" Type="Boolean">false</Property><Property Name="OwningAppId" Type="Guid">{${options.applicationId}}</Property><Property Name="OwningTenantId" Type="Guid">{00000000-0000-0000-0000-000000000000}</Property><Property Name="Region" Type="String">${options.region}</Property><Property Name="ResourceGroup" Type="String">${options.resourceGroup}</Property><Property Name="SPContainerTypeBillingClassification" Type="Enum">0</Property></Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`;
69
69
  }
70
70
  }
71
- _SpeContainertypeAddCommand_instances = new WeakSet(), _SpeContainertypeAddCommand_initTelemetry = function _SpeContainertypeAddCommand_initTelemetry() {
71
+ _SpeContainerTypeAddCommand_instances = new WeakSet(), _SpeContainerTypeAddCommand_initTelemetry = function _SpeContainerTypeAddCommand_initTelemetry() {
72
72
  this.telemetry.push((args) => {
73
73
  Object.assign(this.telemetryProperties, {
74
74
  trial: !!args.options.trial,
@@ -77,7 +77,7 @@ _SpeContainertypeAddCommand_instances = new WeakSet(), _SpeContainertypeAddComma
77
77
  region: typeof args.options.region !== 'undefined'
78
78
  });
79
79
  });
80
- }, _SpeContainertypeAddCommand_initOptions = function _SpeContainertypeAddCommand_initOptions() {
80
+ }, _SpeContainerTypeAddCommand_initOptions = function _SpeContainerTypeAddCommand_initOptions() {
81
81
  this.options.unshift({
82
82
  option: '-n, --name <name>'
83
83
  }, {
@@ -91,7 +91,7 @@ _SpeContainertypeAddCommand_instances = new WeakSet(), _SpeContainertypeAddComma
91
91
  }, {
92
92
  option: '--region [region]'
93
93
  });
94
- }, _SpeContainertypeAddCommand_initValidators = function _SpeContainertypeAddCommand_initValidators() {
94
+ }, _SpeContainerTypeAddCommand_initValidators = function _SpeContainerTypeAddCommand_initValidators() {
95
95
  this.validators.push(async (args) => {
96
96
  if (!validation.isValidGuid(args.options.applicationId)) {
97
97
  return `${args.options.applicationId} is not a valid GUID for option applicationId.`;
@@ -111,5 +111,5 @@ _SpeContainertypeAddCommand_instances = new WeakSet(), _SpeContainertypeAddComma
111
111
  return true;
112
112
  });
113
113
  };
114
- export default new SpeContainertypeAddCommand();
114
+ export default new SpeContainerTypeAddCommand();
115
115
  //# sourceMappingURL=containertype-add.js.map
@@ -3,14 +3,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _SpeContainertypeGetCommand_instances, _SpeContainertypeGetCommand_initTelemetry, _SpeContainertypeGetCommand_initOptions, _SpeContainertypeGetCommand_initOptionSets, _SpeContainertypeGetCommand_initValidators, _SpeContainertypeGetCommand_initTypes;
6
+ var _SpeContainerTypeGetCommand_instances, _SpeContainerTypeGetCommand_initTelemetry, _SpeContainerTypeGetCommand_initOptions, _SpeContainerTypeGetCommand_initOptionSets, _SpeContainerTypeGetCommand_initValidators, _SpeContainerTypeGetCommand_initTypes;
7
7
  import config from '../../../../config.js';
8
8
  import request from '../../../../request.js';
9
+ import { spe } from '../../../../utils/spe.js';
9
10
  import { spo } from '../../../../utils/spo.js';
10
11
  import { validation } from '../../../../utils/validation.js';
11
12
  import SpoCommand from '../../../base/SpoCommand.js';
12
13
  import commands from '../../commands.js';
13
- class SpeContainertypeGetCommand extends SpoCommand {
14
+ class SpeContainerTypeGetCommand extends SpoCommand {
14
15
  get name() {
15
16
  return commands.CONTAINERTYPE_GET;
16
17
  }
@@ -19,85 +20,80 @@ class SpeContainertypeGetCommand extends SpoCommand {
19
20
  }
20
21
  constructor() {
21
22
  super();
22
- _SpeContainertypeGetCommand_instances.add(this);
23
- __classPrivateFieldGet(this, _SpeContainertypeGetCommand_instances, "m", _SpeContainertypeGetCommand_initTelemetry).call(this);
24
- __classPrivateFieldGet(this, _SpeContainertypeGetCommand_instances, "m", _SpeContainertypeGetCommand_initOptions).call(this);
25
- __classPrivateFieldGet(this, _SpeContainertypeGetCommand_instances, "m", _SpeContainertypeGetCommand_initValidators).call(this);
26
- __classPrivateFieldGet(this, _SpeContainertypeGetCommand_instances, "m", _SpeContainertypeGetCommand_initOptionSets).call(this);
27
- __classPrivateFieldGet(this, _SpeContainertypeGetCommand_instances, "m", _SpeContainertypeGetCommand_initTypes).call(this);
23
+ _SpeContainerTypeGetCommand_instances.add(this);
24
+ __classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initTelemetry).call(this);
25
+ __classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initOptions).call(this);
26
+ __classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initValidators).call(this);
27
+ __classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initOptionSets).call(this);
28
+ __classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initTypes).call(this);
28
29
  }
29
30
  async commandAction(logger, args) {
30
31
  try {
31
32
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
32
- if (this.verbose) {
33
- await logger.logToStderr(`Getting the Container type...`);
34
- }
35
33
  const containerTypeId = await this.getContainerTypeId(args.options, spoAdminUrl, logger);
36
- const allContainerTypes = await this.getContainerTypeById(containerTypeId, spoAdminUrl, logger);
37
- await logger.log(allContainerTypes);
34
+ const containerType = await this.getContainerTypeById(containerTypeId, spoAdminUrl, logger);
35
+ await logger.log(containerType);
38
36
  }
39
37
  catch (err) {
40
- this.handleRejectedPromise(err);
38
+ this.handleRejectedODataJsonPromise(err);
41
39
  }
42
40
  }
43
41
  async getContainerTypeById(containerTypeId, spoAdminUrl, logger) {
44
- const formDigestInfo = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, this.debug);
42
+ if (this.verbose) {
43
+ await logger.logToStderr(`Getting the Container type...`);
44
+ }
45
45
  const requestOptions = {
46
46
  url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
47
47
  headers: {
48
- 'X-RequestDigest': formDigestInfo.FormDigestValue
48
+ accept: 'application/json;odata=nometadata'
49
49
  },
50
+ responseType: 'json',
50
51
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="49" ObjectPathId="48" /><Method Name="GetSPOContainerTypeById" Id="50" ObjectPathId="48"><Parameters><Parameter Type="Guid">{${containerTypeId}}</Parameter><Parameter Type="Enum">1</Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="48" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
51
52
  };
52
53
  const res = await request.post(requestOptions);
53
- const json = JSON.parse(res);
54
- const response = json[0];
54
+ const response = res[0];
55
55
  if (response.ErrorInfo) {
56
56
  throw response.ErrorInfo.ErrorMessage;
57
57
  }
58
- const containerTypes = json[json.length - 1];
58
+ const containerTypes = res[res.length - 1];
59
59
  return containerTypes;
60
60
  }
61
61
  async getContainerTypeId(options, spoAdminUrl, logger) {
62
62
  if (options.id) {
63
63
  return options.id;
64
64
  }
65
- const containerTypes = await spo.getAllContainerTypes(spoAdminUrl, logger, this.debug);
66
- // Get id of the container type by name
67
- const containerType = containerTypes.find(c => c.DisplayName === options.name);
68
- if (!containerType) {
69
- throw new Error(`Container type with name ${options.name} not found`);
65
+ if (this.verbose) {
66
+ await logger.logToStderr(`Retrieving container type id for container type '${options.containerTypeName}'...`);
70
67
  }
71
- const match = containerType.ContainerTypeId.match(/\/Guid\(([^)]+)\)\//);
72
- return match[1];
68
+ return spe.getContainerTypeIdByName(spoAdminUrl, options.name);
73
69
  }
74
70
  }
75
- _SpeContainertypeGetCommand_instances = new WeakSet(), _SpeContainertypeGetCommand_initTelemetry = function _SpeContainertypeGetCommand_initTelemetry() {
71
+ _SpeContainerTypeGetCommand_instances = new WeakSet(), _SpeContainerTypeGetCommand_initTelemetry = function _SpeContainerTypeGetCommand_initTelemetry() {
76
72
  this.telemetry.push((args) => {
77
73
  Object.assign(this.telemetryProperties, {
78
74
  id: typeof args.options.id !== 'undefined',
79
75
  name: typeof args.options.name !== 'undefined'
80
76
  });
81
77
  });
82
- }, _SpeContainertypeGetCommand_initOptions = function _SpeContainertypeGetCommand_initOptions() {
78
+ }, _SpeContainerTypeGetCommand_initOptions = function _SpeContainerTypeGetCommand_initOptions() {
83
79
  this.options.unshift({
84
80
  option: '-i, --id [id]'
85
81
  }, {
86
82
  option: '-n, --name [name]'
87
83
  });
88
- }, _SpeContainertypeGetCommand_initOptionSets = function _SpeContainertypeGetCommand_initOptionSets() {
84
+ }, _SpeContainerTypeGetCommand_initOptionSets = function _SpeContainerTypeGetCommand_initOptionSets() {
89
85
  this.optionSets.push({
90
86
  options: ['id', 'name']
91
87
  });
92
- }, _SpeContainertypeGetCommand_initValidators = function _SpeContainertypeGetCommand_initValidators() {
88
+ }, _SpeContainerTypeGetCommand_initValidators = function _SpeContainerTypeGetCommand_initValidators() {
93
89
  this.validators.push(async (args) => {
94
90
  if (args.options.id && !validation.isValidGuid(args.options.id)) {
95
91
  return `${args.options.id} is not a valid GUID`;
96
92
  }
97
93
  return true;
98
94
  });
99
- }, _SpeContainertypeGetCommand_initTypes = function _SpeContainertypeGetCommand_initTypes() {
95
+ }, _SpeContainerTypeGetCommand_initTypes = function _SpeContainerTypeGetCommand_initTypes() {
100
96
  this.types.string.push('id', 'name');
101
97
  };
102
- export default new SpeContainertypeGetCommand();
98
+ export default new SpeContainerTypeGetCommand();
103
99
  //# sourceMappingURL=containertype-get.js.map
@@ -1,7 +1,8 @@
1
1
  import SpoCommand from '../../../base/SpoCommand.js';
2
2
  import commands from '../../commands.js';
3
+ import { spe } from '../../../../utils/spe.js';
3
4
  import { spo } from '../../../../utils/spo.js';
4
- class SpeContainertypeListCommand extends SpoCommand {
5
+ class SpeContainerTypeListCommand extends SpoCommand {
5
6
  get name() {
6
7
  return commands.CONTAINERTYPE_LIST;
7
8
  }
@@ -17,13 +18,22 @@ class SpeContainertypeListCommand extends SpoCommand {
17
18
  if (this.verbose) {
18
19
  await logger.logToStderr(`Retrieving list of Container types...`);
19
20
  }
20
- const allContainerTypes = await spo.getAllContainerTypes(spoAdminUrl, logger, this.debug);
21
- await logger.log(allContainerTypes);
21
+ const allContainerTypes = await spe.getAllContainerTypes(spoAdminUrl);
22
+ // The following conversion is done in order not to make breaking changes
23
+ const result = allContainerTypes.map(ct => ({
24
+ _ObjectType_: 'Microsoft.Online.SharePoint.TenantAdministration.SPContainerTypeProperties',
25
+ ...ct,
26
+ AzureSubscriptionId: `/Guid(${ct.AzureSubscriptionId})/`,
27
+ ContainerTypeId: `/Guid(${ct.ContainerTypeId})/`,
28
+ OwningAppId: `/Guid(${ct.OwningAppId})/`,
29
+ OwningTenantId: `/Guid(${ct.OwningTenantId})/`
30
+ }));
31
+ await logger.log(result);
22
32
  }
23
33
  catch (err) {
24
34
  this.handleRejectedPromise(err);
25
35
  }
26
36
  }
27
37
  }
28
- export default new SpeContainertypeListCommand();
38
+ export default new SpeContainerTypeListCommand();
29
39
  //# sourceMappingURL=containertype-list.js.map
@@ -0,0 +1,81 @@
1
+ import { globalOptionsZod } from '../../../../Command.js';
2
+ import { z } from 'zod';
3
+ import { zod } from '../../../../utils/zod.js';
4
+ import SpoCommand from '../../../base/SpoCommand.js';
5
+ import commands from '../../commands.js';
6
+ import { spo } from '../../../../utils/spo.js';
7
+ import { spe } from '../../../../utils/spe.js';
8
+ import { cli } from '../../../../cli/cli.js';
9
+ import { validation } from '../../../../utils/validation.js';
10
+ import request from '../../../../request.js';
11
+ import config from '../../../../config.js';
12
+ const options = globalOptionsZod
13
+ .extend({
14
+ id: zod.alias('i', z.string()
15
+ .refine(id => validation.isValidGuid(id), id => ({
16
+ message: `'${id}' is not a valid GUID.`
17
+ }))
18
+ .optional()),
19
+ name: zod.alias('n', z.string().optional()),
20
+ force: zod.alias('f', z.boolean().optional())
21
+ })
22
+ .strict();
23
+ class SpeContainerTypeRemoveCommand extends SpoCommand {
24
+ get name() {
25
+ return commands.CONTAINERTYPE_REMOVE;
26
+ }
27
+ get description() {
28
+ return 'Remove a specific container type';
29
+ }
30
+ get schema() {
31
+ return options;
32
+ }
33
+ getRefinedSchema(schema) {
34
+ return schema
35
+ .refine(options => [options.id, options.name].filter(o => o !== undefined).length === 1, {
36
+ message: 'Use one of the following options: id, name.'
37
+ });
38
+ }
39
+ async commandAction(logger, args) {
40
+ if (!args.options.force) {
41
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove container type ${args.options.id || args.options.name}?` });
42
+ if (!result) {
43
+ return;
44
+ }
45
+ }
46
+ try {
47
+ const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
48
+ const containerTypeId = await this.getContainerTypeId(args.options, spoAdminUrl, logger);
49
+ const formDigestInfo = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, this.debug);
50
+ if (this.verbose) {
51
+ await logger.logToStderr(`Removing container type ${args.options.id || args.options.name}...`);
52
+ }
53
+ const requestOptions = {
54
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
55
+ headers: {
56
+ 'X-RequestDigest': formDigestInfo.FormDigestValue
57
+ },
58
+ responseType: 'json',
59
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="7" ObjectPathId="6" /><Method Name="RemoveSPOContainerType" Id="8" ObjectPathId="6"><Parameters><Parameter TypeId="{b66ab1ca-fd51-44f9-8cfc-01f5c2a21f99}"><Property Name="ContainerTypeId" Type="Guid">{${containerTypeId}}</Property></Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="6" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
60
+ };
61
+ const result = await request.post(requestOptions);
62
+ if (result[0].ErrorInfo) {
63
+ throw result[0].ErrorInfo.ErrorMessage;
64
+ }
65
+ }
66
+ catch (err) {
67
+ this.handleRejectedODataJsonPromise(err);
68
+ }
69
+ }
70
+ async getContainerTypeId(options, spoAdminUrl, logger) {
71
+ if (options.id) {
72
+ return options.id;
73
+ }
74
+ if (this.verbose) {
75
+ await logger.logToStderr(`Retrieving container type id for container type '${options.name}'...`);
76
+ }
77
+ return spe.getContainerTypeIdByName(spoAdminUrl, options.name);
78
+ }
79
+ }
80
+ export default new SpeContainerTypeRemoveCommand();
81
+ //# sourceMappingURL=containertype-remove.js.map
@@ -1,10 +1,15 @@
1
1
  const prefix = 'spe';
2
2
  export default {
3
3
  CONTAINER_ACTIVATE: `${prefix} container activate`,
4
+ CONTAINER_ADD: `${prefix} container add`,
4
5
  CONTAINER_GET: `${prefix} container get`,
5
6
  CONTAINER_LIST: `${prefix} container list`,
7
+ CONTAINER_REMOVE: `${prefix} container remove`,
8
+ CONTAINER_PERMISSION_LIST: `${prefix} container permission list`,
9
+ CONTAINER_RECYCLEBINITEM_LIST: `${prefix} container recyclebinitem list`,
6
10
  CONTAINERTYPE_ADD: `${prefix} containertype add`,
7
11
  CONTAINERTYPE_GET: `${prefix} containertype get`,
8
- CONTAINERTYPE_LIST: `${prefix} containertype list`
12
+ CONTAINERTYPE_LIST: `${prefix} containertype list`,
13
+ CONTAINERTYPE_REMOVE: `${prefix} containertype remove`
9
14
  };
10
15
  //# sourceMappingURL=commands.js.map
@@ -59,19 +59,25 @@ class SpoPageSectionAddCommand extends SpoCommand {
59
59
  };
60
60
  await request.post(requestOptions);
61
61
  }
62
- // get columns
63
- const columns = canvasContent
64
- .filter(c => typeof c.controlType === 'undefined');
65
62
  // get unique zoneIndex values given each section can have 1 or more
66
63
  // columns each assigned to the zoneIndex of the corresponding section
67
- const zoneIndices = columns
64
+ const zoneIndices = canvasContent
65
+ // Exclude the vertical section
66
+ .filter(c => c.position)
68
67
  .map(c => c.position.zoneIndex)
69
68
  .filter((value, index, array) => {
70
69
  return array.indexOf(value) === index;
71
70
  })
72
- .sort();
73
- // zoneIndex for the new section to add
74
- const zoneIndex = this.getSectionIndex(zoneIndices, args.options.order);
71
+ .sort((a, b) => a - b);
72
+ // Add a new zoneIndex at the end of the array
73
+ zoneIndices.push(zoneIndices.length > 0 ? zoneIndices[zoneIndices.length - 1] + 1 : 1);
74
+ // get section number. if not specified, get the last section
75
+ let section = args.options.order || zoneIndices.length;
76
+ if (section > zoneIndices.length) {
77
+ section = zoneIndices.length;
78
+ }
79
+ // zoneIndex that represents the section where the web part should be added
80
+ const zoneIndex = zoneIndices[section - 1];
75
81
  let zoneId;
76
82
  let backgroundControlToAdd = undefined;
77
83
  if (args.options.zoneEmphasis && ['image', 'gradient'].includes(args.options.zoneEmphasis.toLowerCase())) {
@@ -83,11 +89,17 @@ class SpoPageSectionAddCommand extends SpoCommand {
83
89
  canvasContent.push(backgroundControlToAdd);
84
90
  }
85
91
  }
92
+ // Increment the zoneIndex of all columns that are greater than or equal to the new zoneIndex
93
+ canvasContent.forEach((c) => {
94
+ if (c.position && c.position.zoneIndex >= zoneIndex) {
95
+ c.position.zoneIndex += 1;
96
+ }
97
+ });
86
98
  // get the list of columns to insert based on the selected template
87
99
  const columnsToAdd = this.getColumns(zoneIndex, args, zoneId);
88
100
  // insert the column in the right place in the array so that
89
101
  // it stays sorted ascending by zoneIndex
90
- let pos = canvasContent.findIndex(c => typeof c.controlType === 'undefined' && c.position && c.position.zoneIndex > zoneIndex);
102
+ let pos = canvasContent.findIndex(c => c.position && c.position.zoneIndex >= zoneIndex);
91
103
  if (pos === -1) {
92
104
  pos = canvasContent.length - 1;
93
105
  }
@@ -109,21 +121,6 @@ class SpoPageSectionAddCommand extends SpoCommand {
109
121
  this.handleRejectedODataJsonPromise(err);
110
122
  }
111
123
  }
112
- getSectionIndex(zoneIndices, order) {
113
- // zoneIndex of the first column on the page
114
- const minIndex = zoneIndices.length === 0 ? 0 : zoneIndices[0];
115
- // zoneIndex of the last column on the page
116
- const maxIndex = zoneIndices.length === 0 ? 0 : zoneIndices[zoneIndices.length - 1];
117
- if (!order || order > zoneIndices.length) {
118
- // no order specified, add section to the end
119
- return maxIndex === 0 ? 1 : maxIndex * 2;
120
- }
121
- // add to the beginning
122
- if (order === 1) {
123
- return minIndex / 2;
124
- }
125
- return zoneIndices[order - 2] + ((zoneIndices[order - 1] - zoneIndices[order - 2]) / 2);
126
- }
127
124
  getColumns(zoneIndex, args, zoneId) {
128
125
  const columns = [];
129
126
  let sectionIndex = 1;
@@ -41,6 +41,17 @@ export const entraServicePrincipal = {
41
41
  return await cli.handleMultipleResultsFound(`Multiple service principals with name '${appName}' found in Microsoft Entra ID.`, resultAsKeyValuePair);
42
42
  }
43
43
  return apps[0];
44
+ },
45
+ /**
46
+ * Get all available service principals.
47
+ * @param properties Comma-separated list of properties to include in the response.
48
+ */
49
+ async getServicePrincipals(properties) {
50
+ let url = `https://graph.microsoft.com/v1.0/servicePrincipals`;
51
+ if (properties) {
52
+ url += `?$select=${properties}`;
53
+ }
54
+ return odata.getAllItems(url);
44
55
  }
45
56
  };
46
57
  //# sourceMappingURL=entraServicePrincipal.js.map