@pnp/cli-microsoft365 10.8.0-beta.cdb5c81 → 10.8.0

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,6 +1,6 @@
1
- import AppCommand from '../../base/AppCommand.js';
2
- import commands from '../commands.js';
3
1
  import { entraApp } from '../../../utils/entraApp.js';
2
+ import AppCommand, { appCommandOptions } from '../../base/AppCommand.js';
3
+ import commands from '../commands.js';
4
4
  class AppGetCommand extends AppCommand {
5
5
  get name() {
6
6
  return commands.GET;
@@ -8,6 +8,9 @@ class AppGetCommand extends AppCommand {
8
8
  get description() {
9
9
  return 'Retrieves information about the current Microsoft Entra app';
10
10
  }
11
+ get schema() {
12
+ return appCommandOptions;
13
+ }
11
14
  async commandAction(logger, args) {
12
15
  try {
13
16
  const app = await entraApp.getAppRegistrationByAppId(args.options.appId);
@@ -1,14 +1,14 @@
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 _AppOpenCommand_instances, _AppOpenCommand_initTelemetry, _AppOpenCommand_initOptions;
1
+ import { z } from 'zod';
7
2
  import { cli } from '../../../cli/cli.js';
8
3
  import { settingsNames } from '../../../settingsNames.js';
9
4
  import { browserUtil } from '../../../utils/browserUtil.js';
10
- import AppCommand from '../../base/AppCommand.js';
5
+ import AppCommand, { appCommandOptions } from '../../base/AppCommand.js';
11
6
  import commands from '../commands.js';
7
+ const options = appCommandOptions
8
+ .extend({
9
+ preview: z.boolean().optional().default(false)
10
+ })
11
+ .strict();
12
12
  class AppOpenCommand extends AppCommand {
13
13
  get name() {
14
14
  return commands.OPEN;
@@ -16,11 +16,8 @@ class AppOpenCommand extends AppCommand {
16
16
  get description() {
17
17
  return 'Opens Microsoft Entra app in the Microsoft Entra ID portal';
18
18
  }
19
- constructor() {
20
- super();
21
- _AppOpenCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initOptions).call(this);
19
+ get schema() {
20
+ return options;
24
21
  }
25
22
  async commandAction(logger, args) {
26
23
  try {
@@ -41,15 +38,5 @@ class AppOpenCommand extends AppCommand {
41
38
  await browserUtil.open(url);
42
39
  }
43
40
  }
44
- _AppOpenCommand_instances = new WeakSet(), _AppOpenCommand_initTelemetry = function _AppOpenCommand_initTelemetry() {
45
- this.telemetry.push((args) => {
46
- Object.assign(this.telemetryProperties, {
47
- appId: typeof args.options.appId !== 'undefined',
48
- preview: typeof args.options.preview !== 'undefined'
49
- });
50
- });
51
- }, _AppOpenCommand_initOptions = function _AppOpenCommand_initOptions() {
52
- this.options.unshift({ option: '--appId [appId]' }, { option: '--preview' });
53
- };
54
41
  export default new AppOpenCommand();
55
42
  //# sourceMappingURL=app-open.js.map
@@ -1,14 +1,16 @@
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 _AppPermissionAddCommand_instances, _AppPermissionAddCommand_initTelemetry, _AppPermissionAddCommand_initOptions, _AppPermissionAddCommand_initOptionSets;
1
+ import { z } from 'zod';
7
2
  import request from '../../../../request.js';
8
3
  import { formatting } from '../../../../utils/formatting.js';
9
4
  import { odata } from '../../../../utils/odata.js';
10
- import AppCommand from '../../../base/AppCommand.js';
5
+ import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
11
6
  import commands from '../../commands.js';
7
+ const options = appCommandOptions
8
+ .extend({
9
+ applicationPermissions: z.string().optional(),
10
+ delegatedPermissions: z.string().optional(),
11
+ grantAdminConsent: z.boolean().optional()
12
+ })
13
+ .strict();
12
14
  var ScopeType;
13
15
  (function (ScopeType) {
14
16
  ScopeType["Role"] = "Role";
@@ -21,12 +23,15 @@ class AppPermissionAddCommand extends AppCommand {
21
23
  get description() {
22
24
  return 'Adds the specified application and/or delegated permissions to the current Microsoft Entra app API permissions';
23
25
  }
24
- constructor() {
25
- super();
26
- _AppPermissionAddCommand_instances.add(this);
27
- __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initTelemetry).call(this);
28
- __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initOptions).call(this);
29
- __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initOptionSets).call(this);
26
+ get schema() {
27
+ return options;
28
+ }
29
+ getRefinedSchema(schema) {
30
+ return schema
31
+ .refine(options => options.applicationPermissions || options.delegatedPermissions, {
32
+ message: 'Specify at least one of applicationPermissions or delegatedPermissions, or both.',
33
+ path: ['delegatedPermissions']
34
+ });
30
35
  }
31
36
  async commandAction(logger, args) {
32
37
  try {
@@ -194,22 +199,5 @@ class AppPermissionAddCommand extends AppCommand {
194
199
  return request.post(requestOptions);
195
200
  }
196
201
  }
197
- _AppPermissionAddCommand_instances = new WeakSet(), _AppPermissionAddCommand_initTelemetry = function _AppPermissionAddCommand_initTelemetry() {
198
- this.telemetry.push((args) => {
199
- Object.assign(this.telemetryProperties, {
200
- appId: typeof args.options.appId !== 'undefined',
201
- applicationPermissions: typeof args.options.applicationPermissions !== 'undefined',
202
- delegatedPermissions: typeof args.options.delegatedPermissions !== 'undefined',
203
- grantAdminConsent: !!args.options.grantAdminConsent
204
- });
205
- });
206
- }, _AppPermissionAddCommand_initOptions = function _AppPermissionAddCommand_initOptions() {
207
- this.options.unshift({ option: '--appId [appId]' }, { option: '--applicationPermissions [applicationPermissions]' }, { option: '--delegatedPermissions [delegatedPermissions]' }, { option: '--grantAdminConsent' });
208
- }, _AppPermissionAddCommand_initOptionSets = function _AppPermissionAddCommand_initOptionSets() {
209
- this.optionSets.push({
210
- options: ['applicationPermissions', 'delegatedPermissions'],
211
- runsWhen: (args) => args.options.delegatedPermissions === undefined && args.options.applicationPermissions === undefined
212
- });
213
- };
214
202
  export default new AppPermissionAddCommand();
215
203
  //# sourceMappingURL=permission-add.js.map
@@ -1,7 +1,7 @@
1
1
  import request from '../../../../request.js';
2
- import AppCommand from '../../../base/AppCommand.js';
3
- import commands from '../../commands.js';
4
2
  import { entraApp } from '../../../../utils/entraApp.js';
3
+ import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
4
+ import commands from '../../commands.js';
5
5
  var GetServicePrincipal;
6
6
  (function (GetServicePrincipal) {
7
7
  GetServicePrincipal[GetServicePrincipal["withPermissions"] = 0] = "withPermissions";
@@ -14,6 +14,9 @@ class AppPermissionListCommand extends AppCommand {
14
14
  get description() {
15
15
  return 'Lists API permissions for the current Microsoft Entra app';
16
16
  }
17
+ get schema() {
18
+ return appCommandOptions;
19
+ }
17
20
  async commandAction(logger) {
18
21
  try {
19
22
  const servicePrincipal = await this.getServicePrincipal({ appId: this.appId }, logger, GetServicePrincipal.withPermissions);
@@ -1,23 +1,18 @@
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 _AppCommand_instances, _AppCommand_initOptions, _AppCommand_initValidators;
7
1
  import fs from 'fs';
2
+ import { z } from 'zod';
8
3
  import { cli } from '../../cli/cli.js';
9
- import Command, { CommandError } from '../../Command.js';
10
- import { validation } from '../../utils/validation.js';
4
+ import Command, { CommandError, globalOptionsZod } from '../../Command.js';
11
5
  import { formatting } from '../../utils/formatting.js';
12
- class AppCommand extends Command {
6
+ export const appCommandOptions = globalOptionsZod
7
+ .extend({
8
+ appId: z.string().uuid().optional()
9
+ });
10
+ export default class AppCommand extends Command {
13
11
  get resource() {
14
12
  return 'https://graph.microsoft.com';
15
13
  }
16
- constructor() {
17
- super();
18
- _AppCommand_instances.add(this);
19
- __classPrivateFieldGet(this, _AppCommand_instances, "m", _AppCommand_initOptions).call(this);
20
- __classPrivateFieldGet(this, _AppCommand_instances, "m", _AppCommand_initValidators).call(this);
14
+ get schema() {
15
+ return appCommandOptions;
21
16
  }
22
17
  async action(logger, args) {
23
18
  const m365rcJsonPath = '.m365rc.json';
@@ -63,15 +58,4 @@ class AppCommand extends Command {
63
58
  }
64
59
  }
65
60
  }
66
- _AppCommand_instances = new WeakSet(), _AppCommand_initOptions = function _AppCommand_initOptions() {
67
- this.options.unshift({ option: '--appId [appId]' });
68
- }, _AppCommand_initValidators = function _AppCommand_initValidators() {
69
- this.validators.push(async (args) => {
70
- if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
71
- return `${args.options.appId} is not a valid GUID`;
72
- }
73
- return true;
74
- });
75
- };
76
- export default AppCommand;
77
61
  //# sourceMappingURL=AppCommand.js.map
@@ -1,14 +1,17 @@
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 _BookingBusinessGetCommand_instances, _BookingBusinessGetCommand_initTelemetry, _BookingBusinessGetCommand_initOptions, _BookingBusinessGetCommand_initOptionSets;
1
+ import { z } from 'zod';
2
+ import { cli } from '../../../../cli/cli.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
7
4
  import request from '../../../../request.js';
8
5
  import { formatting } from '../../../../utils/formatting.js';
6
+ import { zod } from '../../../../utils/zod.js';
9
7
  import GraphCommand from '../../../base/GraphCommand.js';
10
8
  import commands from '../../commands.js';
11
- import { cli } from '../../../../cli/cli.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ id: zod.alias('i', z.string().optional()),
12
+ name: zod.alias('n', z.string().optional())
13
+ })
14
+ .strict();
12
15
  class BookingBusinessGetCommand extends GraphCommand {
13
16
  get name() {
14
17
  return commands.BUSINESS_GET;
@@ -16,12 +19,14 @@ class BookingBusinessGetCommand extends GraphCommand {
16
19
  get description() {
17
20
  return 'Retrieve the specified Microsoft Bookings business.';
18
21
  }
19
- constructor() {
20
- super();
21
- _BookingBusinessGetCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _BookingBusinessGetCommand_instances, "m", _BookingBusinessGetCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _BookingBusinessGetCommand_instances, "m", _BookingBusinessGetCommand_initOptions).call(this);
24
- __classPrivateFieldGet(this, _BookingBusinessGetCommand_instances, "m", _BookingBusinessGetCommand_initOptionSets).call(this);
22
+ get schema() {
23
+ return options;
24
+ }
25
+ getRefinedSchema(schema) {
26
+ return schema
27
+ .refine(options => options.id || options.name, {
28
+ message: 'Specify either id or name'
29
+ });
25
30
  }
26
31
  async commandAction(logger, args) {
27
32
  try {
@@ -65,17 +70,5 @@ class BookingBusinessGetCommand extends GraphCommand {
65
70
  return bookingBusinesses[0].id;
66
71
  }
67
72
  }
68
- _BookingBusinessGetCommand_instances = new WeakSet(), _BookingBusinessGetCommand_initTelemetry = function _BookingBusinessGetCommand_initTelemetry() {
69
- this.telemetry.push((args) => {
70
- Object.assign(this.telemetryProperties, {
71
- id: typeof args.options.id !== 'undefined',
72
- name: typeof args.options.name !== 'undefined'
73
- });
74
- });
75
- }, _BookingBusinessGetCommand_initOptions = function _BookingBusinessGetCommand_initOptions() {
76
- this.options.unshift({ option: '-i, --id [id]' }, { option: '-n, --name [name]' });
77
- }, _BookingBusinessGetCommand_initOptionSets = function _BookingBusinessGetCommand_initOptionSets() {
78
- this.optionSets.push({ options: ['id', 'name'] });
79
- };
80
73
  export default new BookingBusinessGetCommand();
81
74
  //# sourceMappingURL=business-get.js.map
@@ -1,14 +1,15 @@
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 _ContextRemoveCommand_instances, _ContextRemoveCommand_initTelemetry, _ContextRemoveCommand_initOptions;
7
1
  import fs from 'fs';
2
+ import { z } from 'zod';
8
3
  import { cli } from '../../../cli/cli.js';
9
- import { CommandError } from '../../../Command.js';
4
+ import { CommandError, globalOptionsZod } from '../../../Command.js';
5
+ import { zod } from '../../../utils/zod.js';
10
6
  import AnonymousCommand from '../../base/AnonymousCommand.js';
11
7
  import commands from '../commands.js';
8
+ const options = globalOptionsZod
9
+ .extend({
10
+ force: zod.alias('f', z.boolean().optional())
11
+ })
12
+ .strict();
12
13
  class ContextRemoveCommand extends AnonymousCommand {
13
14
  get name() {
14
15
  return commands.REMOVE;
@@ -16,20 +17,17 @@ class ContextRemoveCommand extends AnonymousCommand {
16
17
  get description() {
17
18
  return 'Removes the CLI for Microsoft 365 context in the current working folder';
18
19
  }
19
- constructor() {
20
- super();
21
- _ContextRemoveCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initOptions).call(this);
20
+ get schema() {
21
+ return options;
24
22
  }
25
23
  async commandAction(logger, args) {
26
24
  if (args.options.force) {
27
- await this.removeContext();
25
+ this.removeContext();
28
26
  }
29
27
  else {
30
28
  const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the context?` });
31
29
  if (result) {
32
- await this.removeContext();
30
+ this.removeContext();
33
31
  }
34
32
  }
35
33
  }
@@ -70,16 +68,5 @@ class ContextRemoveCommand extends AnonymousCommand {
70
68
  }
71
69
  }
72
70
  }
73
- _ContextRemoveCommand_instances = new WeakSet(), _ContextRemoveCommand_initTelemetry = function _ContextRemoveCommand_initTelemetry() {
74
- this.telemetry.push((args) => {
75
- Object.assign(this.telemetryProperties, {
76
- force: !!args.options.force
77
- });
78
- });
79
- }, _ContextRemoveCommand_initOptions = function _ContextRemoveCommand_initOptions() {
80
- this.options.unshift({
81
- option: '-f, --force'
82
- });
83
- };
84
71
  export default new ContextRemoveCommand();
85
72
  //# sourceMappingURL=context-remove.js.map
@@ -1,14 +1,16 @@
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 _ContextOptionRemoveCommand_instances, _ContextOptionRemoveCommand_initTelemetry, _ContextOptionRemoveCommand_initOptions;
7
1
  import fs from 'fs';
2
+ import { z } from 'zod';
8
3
  import { cli } from '../../../../cli/cli.js';
9
- import { CommandError } from '../../../../Command.js';
4
+ import { CommandError, globalOptionsZod } from '../../../../Command.js';
5
+ import { zod } from '../../../../utils/zod.js';
10
6
  import ContextCommand from '../../../base/ContextCommand.js';
11
7
  import commands from '../../commands.js';
8
+ const options = globalOptionsZod
9
+ .extend({
10
+ name: zod.alias('n', z.string()),
11
+ force: zod.alias('f', z.boolean().optional())
12
+ })
13
+ .strict();
12
14
  class ContextOptionRemoveCommand extends ContextCommand {
13
15
  get name() {
14
16
  return commands.OPTION_REMOVE;
@@ -16,11 +18,8 @@ class ContextOptionRemoveCommand extends ContextCommand {
16
18
  get description() {
17
19
  return 'Removes an already available name from local context file.';
18
20
  }
19
- constructor() {
20
- super();
21
- _ContextOptionRemoveCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _ContextOptionRemoveCommand_instances, "m", _ContextOptionRemoveCommand_initOptions).call(this);
23
- __classPrivateFieldGet(this, _ContextOptionRemoveCommand_instances, "m", _ContextOptionRemoveCommand_initTelemetry).call(this);
21
+ get schema() {
22
+ return options;
24
23
  }
25
24
  async commandAction(logger, args) {
26
25
  if (this.verbose) {
@@ -70,18 +69,5 @@ class ContextOptionRemoveCommand extends ContextCommand {
70
69
  }
71
70
  }
72
71
  }
73
- _ContextOptionRemoveCommand_instances = new WeakSet(), _ContextOptionRemoveCommand_initTelemetry = function _ContextOptionRemoveCommand_initTelemetry() {
74
- this.telemetry.push((args) => {
75
- Object.assign(this.telemetryProperties, {
76
- force: !!args.options.force
77
- });
78
- });
79
- }, _ContextOptionRemoveCommand_initOptions = function _ContextOptionRemoveCommand_initOptions() {
80
- this.options.unshift({
81
- option: '-n, --name <name>'
82
- }, {
83
- option: '-f, --force'
84
- });
85
- };
86
72
  export default new ContextOptionRemoveCommand();
87
73
  //# sourceMappingURL=option-remove.js.map
@@ -0,0 +1,74 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import request from '../../../../request.js';
4
+ import commands from '../../commands.js';
5
+ import GraphCommand from '../../../base/GraphCommand.js';
6
+ import { validation } from '../../../../utils/validation.js';
7
+ import { entraApp } from '../../../../utils/entraApp.js';
8
+ import { odata } from '../../../../utils/odata.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ appId: z.string().refine(id => validation.isValidGuid(id), id => ({
12
+ message: `'${id}' is not a valid GUID.`
13
+ })).optional(),
14
+ appObjectId: z.string().refine(id => validation.isValidGuid(id), id => ({
15
+ message: `'${id}' is not a valid GUID.`
16
+ })).optional(),
17
+ appName: z.string().optional()
18
+ })
19
+ .strict();
20
+ class GraphDirectoryExtensionListCommand extends GraphCommand {
21
+ get name() {
22
+ return commands.DIRECTORYEXTENSION_LIST;
23
+ }
24
+ get description() {
25
+ return 'Retrieves a list of directory extensions';
26
+ }
27
+ defaultProperties() {
28
+ return ['id', 'name', 'appDisplayName'];
29
+ }
30
+ get schema() {
31
+ return options;
32
+ }
33
+ getRefinedSchema(schema) {
34
+ return schema
35
+ .refine(options => ([options.appId, options.appObjectId, options.appName].filter(x => x !== undefined).length <= 1), {
36
+ message: 'Specify either appId, appObjectId, or appName, but not multiple.'
37
+ });
38
+ }
39
+ async commandAction(logger, args) {
40
+ try {
41
+ if (args.options.appId || args.options.appObjectId || args.options.appName) {
42
+ const appObjectId = await this.getAppObjectId(args.options);
43
+ const endpoint = `${this.resource}/v1.0/applications/${appObjectId}/extensionProperties/`;
44
+ const items = await odata.getAllItems(endpoint);
45
+ await logger.log(items);
46
+ }
47
+ else {
48
+ const requestOptions = {
49
+ url: `${this.resource}/v1.0/directoryObjects/getAvailableExtensionProperties`,
50
+ headers: {
51
+ 'content-type': 'application/json;odata.metadata=none'
52
+ },
53
+ responseType: 'json'
54
+ };
55
+ const res = await request.post(requestOptions);
56
+ await logger.log(res.value);
57
+ }
58
+ }
59
+ catch (err) {
60
+ this.handleRejectedODataJsonPromise(err);
61
+ }
62
+ }
63
+ async getAppObjectId(options) {
64
+ if (options.appObjectId) {
65
+ return options.appObjectId;
66
+ }
67
+ if (options.appId) {
68
+ return (await entraApp.getAppRegistrationByAppId(options.appId, ["id"])).id;
69
+ }
70
+ return (await entraApp.getAppRegistrationByAppName(options.appName, ["id"])).id;
71
+ }
72
+ }
73
+ export default new GraphDirectoryExtensionListCommand();
74
+ //# sourceMappingURL=directoryextension-list.js.map
@@ -3,6 +3,7 @@ export default {
3
3
  CHANGELOG_LIST: `${prefix} changelog list`,
4
4
  DIRECTORYEXTENSION_ADD: `${prefix} directoryextension add`,
5
5
  DIRECTORYEXTENSION_GET: `${prefix} directoryextension get`,
6
+ DIRECTORYEXTENSION_LIST: `${prefix} directoryextension list`,
6
7
  DIRECTORYEXTENSION_REMOVE: `${prefix} directoryextension remove`,
7
8
  OPENEXTENSION_ADD: `${prefix} openextension add`,
8
9
  OPENEXTENSION_GET: `${prefix} openextension get`,
@@ -43,6 +43,9 @@ class SpoListGetCommand extends SpoCommand {
43
43
  const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.url);
44
44
  requestUrl += `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
45
45
  }
46
+ else if (args.options.default) {
47
+ requestUrl += `DefaultDocumentLibrary`;
48
+ }
46
49
  const fieldsProperties = this.formatSelectProperties(args.options.properties, args.options.withPermissions);
47
50
  const queryParams = [];
48
51
  if (fieldsProperties.selectProperties.length > 0) {
@@ -113,11 +116,12 @@ class SpoListGetCommand extends SpoCommand {
113
116
  _SpoListGetCommand_instances = new WeakSet(), _SpoListGetCommand_initTelemetry = function _SpoListGetCommand_initTelemetry() {
114
117
  this.telemetry.push((args) => {
115
118
  Object.assign(this.telemetryProperties, {
116
- id: (!(!args.options.id)).toString(),
117
- title: (!(!args.options.title)).toString(),
118
- url: (!(!args.options.url)).toString(),
119
- properties: (!(!args.options.properties)).toString(),
120
- withPermissions: typeof args.options.withPermissions !== 'undefined'
119
+ id: typeof args.options.id !== 'undefined',
120
+ title: typeof args.options.title !== 'undefined',
121
+ url: typeof args.options.url !== 'undefined',
122
+ properties: typeof args.options.properties !== 'undefined',
123
+ withPermissions: !!args.options.withPermissions,
124
+ default: !!args.options.default
121
125
  });
122
126
  });
123
127
  }, _SpoListGetCommand_initOptions = function _SpoListGetCommand_initOptions() {
@@ -129,6 +133,8 @@ _SpoListGetCommand_instances = new WeakSet(), _SpoListGetCommand_initTelemetry =
129
133
  option: '-t, --title [title]'
130
134
  }, {
131
135
  option: '--url [url]'
136
+ }, {
137
+ option: '--default'
132
138
  }, {
133
139
  option: '-p, --properties [properties]'
134
140
  }, {
@@ -148,7 +154,7 @@ _SpoListGetCommand_instances = new WeakSet(), _SpoListGetCommand_initTelemetry =
148
154
  return true;
149
155
  });
150
156
  }, _SpoListGetCommand_initOptionSets = function _SpoListGetCommand_initOptionSets() {
151
- this.optionSets.push({ options: ['id', 'title', 'url'] });
157
+ this.optionSets.push({ options: ['id', 'title', 'url', 'default'] });
152
158
  };
153
159
  export default new SpoListGetCommand();
154
160
  //# sourceMappingURL=list-get.js.map
@@ -0,0 +1,130 @@
1
+ import request from '../../../../request.js';
2
+ import { formatting } from '../../../../utils/formatting.js';
3
+ import { spp } from '../../../../utils/spp.js';
4
+ import { urlUtil } from '../../../../utils/urlUtil.js';
5
+ import { validation } from '../../../../utils/validation.js';
6
+ import SpoCommand from '../../../base/SpoCommand.js';
7
+ import commands from '../../commands.js';
8
+ import { z } from 'zod';
9
+ import { globalOptionsZod } from '../../../../Command.js';
10
+ import { zod } from '../../../../utils/zod.js';
11
+ const options = globalOptionsZod
12
+ .extend({
13
+ contentCenterUrl: zod.alias('c', z.string()
14
+ .refine(url => validation.isValidSharePointUrl(url) === true, url => ({
15
+ message: `'${url}' is not a valid SharePoint Online site URL.`
16
+ }))),
17
+ webUrl: zod.alias('u', z.string()
18
+ .refine(url => validation.isValidSharePointUrl(url) === true, url => ({
19
+ message: `'${url}' is not a valid SharePoint Online site URL.`
20
+ }))),
21
+ id: zod.alias('i', z.string()
22
+ .refine(id => validation.isValidGuid(id) === true, id => ({
23
+ message: `${id} is not a valid GUID.`
24
+ })).optional()),
25
+ title: zod.alias('t', z.string()).optional(),
26
+ listTitle: z.string().optional(),
27
+ listId: z.string()
28
+ .refine(listId => validation.isValidGuid(listId) === true, listId => ({
29
+ message: `${listId} is not a valid GUID.`
30
+ })).optional(),
31
+ listUrl: z.string().optional(),
32
+ viewOption: z.enum(['NewViewAsDefault', 'DoNotChangeDefault', 'TileViewAsDefault']).optional()
33
+ })
34
+ .strict();
35
+ class SppModelApplyCommand extends SpoCommand {
36
+ get name() {
37
+ return commands.MODEL_APPLY;
38
+ }
39
+ get description() {
40
+ return 'Applies (or syncs) a trained document understanding model to a document library';
41
+ }
42
+ get schema() {
43
+ return options;
44
+ }
45
+ getRefinedSchema(schema) {
46
+ return schema
47
+ .refine(options => [options.id, options.title].filter(x => x !== undefined).length === 1, {
48
+ message: `Specify exactly one of the following options: 'id' or 'title'.`
49
+ })
50
+ .refine(options => [options.listTitle, options.listId, options.listUrl].filter(x => x !== undefined).length === 1, {
51
+ message: `Specify exactly one of the following options: 'listTitle', 'listId' or 'listUrl'.`
52
+ });
53
+ }
54
+ async commandAction(logger, args) {
55
+ try {
56
+ const contentCenterUrl = urlUtil.removeTrailingSlashes(args.options.contentCenterUrl);
57
+ await spp.assertSiteIsContentCenter(contentCenterUrl, logger, this.verbose);
58
+ let model = null;
59
+ if (args.options.title) {
60
+ model = await spp.getModelByTitle(contentCenterUrl, args.options.title, logger, this.verbose);
61
+ }
62
+ else {
63
+ model = await spp.getModelById(contentCenterUrl, args.options.id, logger, this.verbose);
64
+ }
65
+ if (this.verbose) {
66
+ await logger.log(`Retrieving list information...`);
67
+ }
68
+ const listInstance = await this.getListInfo(args.options.webUrl, args.options.listId, args.options.listTitle, args.options.listUrl);
69
+ if (listInstance.BaseType !== 1) {
70
+ throw `The specified list is not a document library.`;
71
+ }
72
+ if (this.verbose) {
73
+ await logger.log(`Applying model '${model.ModelName}' to document library '${listInstance.RootFolder.ServerRelativeUrl}'...`);
74
+ }
75
+ const requestOptions = {
76
+ url: `${contentCenterUrl}/_api/machinelearning/publications`,
77
+ headers: {
78
+ accept: 'application/json;odata=nometadata',
79
+ 'Content-Type': 'application/json;odata=verbose'
80
+ },
81
+ responseType: 'json',
82
+ data: {
83
+ __metadata: { type: 'Microsoft.Office.Server.ContentCenter.SPMachineLearningPublicationsEntityData' },
84
+ Publications: {
85
+ results: [
86
+ {
87
+ ModelUniqueId: model.UniqueId,
88
+ TargetSiteUrl: args.options.webUrl,
89
+ TargetWebServerRelativeUrl: urlUtil.getServerRelativeSiteUrl(args.options.webUrl),
90
+ TargetLibraryServerRelativeUrl: listInstance.RootFolder.ServerRelativeUrl,
91
+ ViewOption: args.options.viewOption ?? "NewViewAsDefault"
92
+ }
93
+ ]
94
+ }
95
+ }
96
+ };
97
+ const result = await request.post(requestOptions);
98
+ const resultDetails = result.Details;
99
+ if (resultDetails && resultDetails[0]?.ErrorMessage) {
100
+ throw resultDetails[0].ErrorMessage;
101
+ }
102
+ }
103
+ catch (err) {
104
+ this.handleRejectedODataJsonPromise(err);
105
+ }
106
+ }
107
+ getListInfo(webUrl, listId, listTitle, listUrl) {
108
+ let requestUrl = `${webUrl}/_api/web`;
109
+ if (listId) {
110
+ requestUrl += `/lists(guid'${formatting.encodeQueryParameter(listId)}')`;
111
+ }
112
+ else if (listTitle) {
113
+ requestUrl += `/lists/getByTitle('${formatting.encodeQueryParameter(listTitle)}')`;
114
+ }
115
+ else if (listUrl) {
116
+ const listServerRelativeUrl = urlUtil.getServerRelativePath(webUrl, listUrl);
117
+ requestUrl += `/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
118
+ }
119
+ const requestOptions = {
120
+ url: `${requestUrl}?$select=BaseType,RootFolder/ServerRelativeUrl&$expand=RootFolder`,
121
+ headers: {
122
+ accept: 'application/json;odata=nometadata'
123
+ },
124
+ responseType: 'json'
125
+ };
126
+ return request.get(requestOptions);
127
+ }
128
+ }
129
+ export default new SppModelApplyCommand();
130
+ //# sourceMappingURL=model-apply.js.map