@pnp/cli-microsoft365 11.4.0-beta.13d597c → 11.4.0-beta.40f818c
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/.devproxy/api-specs/sharepoint.yaml +43 -0
- package/README.md +1 -1
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/AuthServer.js +2 -4
- package/dist/Command.js +2 -2
- package/dist/cli/cli.js +8 -8
- package/dist/m365/adaptivecard/commands/adaptivecard-send.js +10 -11
- package/dist/m365/app/commands/app-open.js +3 -4
- package/dist/m365/app/commands/permission/permission-add.js +4 -5
- package/dist/m365/base/AppCommand.js +3 -3
- package/dist/m365/booking/commands/business/business-get.js +6 -8
- package/dist/m365/booking/commands/business/business-list.js +2 -1
- package/dist/m365/cli/commands/app/app-add.js +5 -7
- package/dist/m365/commands/docs.js +1 -1
- package/dist/m365/commands/login.js +17 -18
- package/dist/m365/commands/logout.js +1 -1
- package/dist/m365/commands/status.js +2 -1
- package/dist/m365/connection/commands/connection-list.js +2 -1
- package/dist/m365/context/commands/context-remove.js +4 -6
- package/dist/m365/context/commands/option/option-remove.js +5 -7
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-add.js +5 -7
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-get.js +7 -9
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-list.js +4 -5
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-remove.js +8 -10
- package/dist/m365/entra/commands/license/license-list.js +1 -1
- package/dist/m365/entra/commands/m365group/m365group-remove.js +1 -1
- package/dist/m365/entra/commands/multitenant/multitenant-add.js +3 -4
- package/dist/m365/entra/commands/organization/organization-list.js +4 -6
- package/dist/m365/entra/commands/organization/organization-set.js +24 -26
- package/dist/m365/entra/commands/roleassignment/roleassignment-add.js +21 -34
- package/dist/m365/entra/commands/roledefinition/roledefinition-add.js +8 -10
- package/dist/m365/entra/commands/roledefinition/roledefinition-get.js +11 -13
- package/dist/m365/entra/commands/roledefinition/roledefinition-list.js +5 -7
- package/dist/m365/entra/commands/roledefinition/roledefinition-remove.js +11 -13
- package/dist/m365/entra/commands/roledefinition/roledefinition-set.js +15 -17
- package/dist/m365/entra/commands/rolepermission/rolepermission-list.js +5 -7
- package/dist/m365/entra/commands/user/user-session-revoke.js +9 -13
- package/dist/m365/exo/commands/approleassignment/approleassignment-add.js +29 -31
- package/dist/m365/flow/commands/environment/environment-get.js +5 -7
- package/dist/m365/flow/commands/environment/environment-list.js +2 -1
- package/dist/m365/flow/commands/recyclebinitem/recyclebinitem-list.js +4 -6
- package/dist/m365/flow/commands/recyclebinitem/recyclebinitem-restore.js +5 -11
- package/dist/m365/graph/commands/directoryextension/directoryextension-add.js +11 -13
- package/dist/m365/graph/commands/directoryextension/directoryextension-get.js +10 -19
- package/dist/m365/graph/commands/directoryextension/directoryextension-list.js +6 -12
- package/dist/m365/graph/commands/directoryextension/directoryextension-remove.js +11 -20
- package/dist/m365/graph/commands/openextension/openextension-add.js +12 -13
- package/dist/m365/graph/commands/openextension/openextension-get.js +12 -14
- package/dist/m365/graph/commands/openextension/openextension-list.js +11 -13
- package/dist/m365/graph/commands/openextension/openextension-remove.js +13 -15
- package/dist/m365/graph/commands/openextension/openextension-set.js +16 -17
- package/dist/m365/onedrive/commands/onedrive-list.js +2 -1
- package/dist/m365/outlook/commands/mail/mail-searchfolder-add.js +9 -14
- package/dist/m365/outlook/commands/mailbox/mailbox-settings-get.js +8 -12
- package/dist/m365/outlook/commands/mailbox/mailbox-settings-set.js +15 -15
- package/dist/m365/outlook/commands/roomlist/roomlist-list.js +2 -1
- package/dist/m365/pa/commands/environment/environment-get.js +5 -7
- package/dist/m365/pa/commands/environment/environment-list.js +2 -1
- package/dist/m365/planner/commands/tenant/tenant-settings-list.js +1 -1
- package/dist/m365/pp/commands/environment/environment-get.js +5 -7
- package/dist/m365/pp/commands/environment/environment-list.js +3 -4
- package/dist/m365/pp/commands/gateway/gateway-list.js +1 -1
- package/dist/m365/pp/commands/tenant/tenant-settings-list.js +1 -1
- package/dist/m365/pp/commands/website/website-get.js +12 -12
- package/dist/m365/purview/commands/retentionevent/retentionevent-list.js +2 -1
- package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-list.js +1 -1
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +1 -1
- package/dist/m365/spe/commands/container/container-add.js +10 -15
- package/dist/m365/spe/commands/container/container-permission-list.js +4 -6
- package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +5 -10
- package/dist/m365/spe/commands/container/container-recyclebinitem-restore.js +7 -12
- package/dist/m365/spe/commands/container/container-remove.js +10 -16
- package/dist/m365/spe/commands/containertype/containertype-add.js +15 -20
- package/dist/m365/spe/commands/containertype/containertype-get.js +6 -13
- package/dist/m365/spe/commands/containertype/containertype-remove.js +7 -14
- package/dist/m365/spfx/commands/project/project-upgrade.js +4 -6
- package/dist/m365/spo/commands/file/file-version-keep.js +10 -14
- package/dist/m365/spo/commands/homesite/homesite-add.js +13 -15
- package/dist/m365/spo/commands/homesite/homesite-get.js +8 -9
- package/dist/m365/spo/commands/homesite/homesite-remove.js +9 -10
- package/dist/m365/spo/commands/homesite/homesite-set.js +13 -14
- package/dist/m365/spo/commands/list/DefaultColumnValue.js +2 -0
- package/dist/m365/spo/commands/list/list-defaultvalue-clear.js +13 -17
- package/dist/m365/spo/commands/list/list-defaultvalue-get.js +124 -0
- package/dist/m365/spo/commands/list/list-defaultvalue-list.js +13 -37
- package/dist/m365/spo/commands/list/list-defaultvalue-remove.js +12 -16
- package/dist/m365/spo/commands/list/list-defaultvalue-set.js +11 -15
- package/dist/m365/spo/commands/list/list-view-add.js +16 -20
- package/dist/m365/spo/commands/page/page-control-remove.js +11 -15
- package/dist/m365/spo/commands/page/page-get.js +10 -11
- package/dist/m365/spo/commands/page/page-publish.js +9 -10
- package/dist/m365/spo/commands/page/page-section-remove.js +11 -12
- package/dist/m365/spo/commands/site/site-appcatalog-list.js +4 -6
- package/dist/m365/spo/commands/site/site-get.js +6 -8
- package/dist/m365/spo/commands/site/site-sharingpermission-set.js +7 -9
- package/dist/m365/spo/commands/site/site-versionpolicy-get.js +11 -13
- package/dist/m365/spo/commands/web/web-alert-list.js +20 -27
- package/dist/m365/spo/commands/web/web-alert-remove.js +15 -20
- package/dist/m365/spo/commands.js +1 -0
- package/dist/m365/spp/commands/model/model-apply.js +18 -24
- package/dist/m365/teams/commands/callrecord/callrecord-list.js +5 -9
- package/dist/m365/teams/commands/chat/chat-message-list.js +26 -27
- package/dist/m365/teams/commands/chat/chat-message-send.js +12 -3
- package/dist/m365/teams/commands/chat/chatUtil.js +1 -1
- package/dist/m365/tenant/commands/people/people-pronouns-set.js +4 -6
- package/dist/m365/tenant/commands/report/report-settings-set.js +4 -6
- package/dist/m365/viva/commands/engage/engage-community-user-add.js +17 -22
- package/dist/m365/viva/commands/engage/engage-community-user-list.js +8 -14
- package/dist/m365/viva/commands/engage/engage-community-user-remove.js +14 -22
- package/dist/m365/viva/commands/engage/engage-role-member-list.js +6 -11
- package/dist/utils/spo.js +29 -0
- package/dist/utils/zod.js +41 -76
- package/docs/docs/cmd/entra/app/app-permission-add.mdx +19 -0
- package/docs/docs/cmd/entra/app/app-permission-list.mdx +19 -0
- package/docs/docs/cmd/entra/app/app-permission-remove.mdx +21 -0
- package/docs/docs/cmd/spo/list/list-defaultvalue-get.mdx +118 -0
- package/docs/docs/cmd/teams/chat/chat-message-list.mdx +34 -7
- package/docs/docs/cmd/teams/chat/chat-message-send.mdx +23 -1
- package/npm-shrinkwrap.json +274 -248
- package/package.json +11 -11
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zod } from '../../../../utils/zod.js';
|
|
3
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
3
|
import { spo } from '../../../../utils/spo.js';
|
|
5
4
|
import { validation } from '../../../../utils/validation.js';
|
|
@@ -7,25 +6,24 @@ import SpoCommand from '../../../base/SpoCommand.js';
|
|
|
7
6
|
import commands from '../../commands.js';
|
|
8
7
|
import request from '../../../../request.js';
|
|
9
8
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
10
|
-
const options =
|
|
11
|
-
.
|
|
12
|
-
url:
|
|
13
|
-
.refine(
|
|
14
|
-
|
|
15
|
-
}))
|
|
9
|
+
export const options = z.strictObject({
|
|
10
|
+
...globalOptionsZod.shape,
|
|
11
|
+
url: z.string()
|
|
12
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
13
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
14
|
+
}).alias('u'),
|
|
16
15
|
audienceIds: z.string()
|
|
17
|
-
.refine(audiences => validation.isValidGuidArray(audiences) === true,
|
|
18
|
-
|
|
19
|
-
})
|
|
16
|
+
.refine(audiences => validation.isValidGuidArray(audiences) === true, {
|
|
17
|
+
error: e => `The following GUIDs are invalid: ${e.input}.`
|
|
18
|
+
}).optional(),
|
|
20
19
|
audienceNames: z.string().optional(),
|
|
21
20
|
vivaConnectionsDefaultStart: z.boolean().optional(),
|
|
22
21
|
isInDraftMode: z.boolean().optional(),
|
|
23
22
|
order: z.number()
|
|
24
|
-
.refine(order => validation.isValidPositiveInteger(order) === true,
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
.strict();
|
|
23
|
+
.refine(order => validation.isValidPositiveInteger(order) === true, {
|
|
24
|
+
error: e => `'${e.input}' is not a positive integer.`
|
|
25
|
+
}).optional()
|
|
26
|
+
});
|
|
29
27
|
class SpoHomeSiteAddCommand extends SpoCommand {
|
|
30
28
|
get name() {
|
|
31
29
|
return commands.HOMESITE_ADD;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zod } from '../../../../utils/zod.js';
|
|
3
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
3
|
import { validation } from '../../../../utils/validation.js';
|
|
5
4
|
import { spo } from '../../../../utils/spo.js';
|
|
@@ -7,14 +6,14 @@ import SpoCommand from '../../../base/SpoCommand.js';
|
|
|
7
6
|
import commands from '../../commands.js';
|
|
8
7
|
import { odata } from '../../../../utils/odata.js';
|
|
9
8
|
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
10
|
-
const options =
|
|
11
|
-
.
|
|
12
|
-
url:
|
|
13
|
-
.refine(url => validation.isValidSharePointUrl(url) === true,
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
export const options = z.strictObject({
|
|
10
|
+
...globalOptionsZod.shape,
|
|
11
|
+
url: 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
|
+
});
|
|
18
17
|
class SpoHomeSiteGetCommand extends SpoCommand {
|
|
19
18
|
get name() {
|
|
20
19
|
return commands.HOMESITE_GET;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zod } from '../../../../utils/zod.js';
|
|
3
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
3
|
import { validation } from '../../../../utils/validation.js';
|
|
5
4
|
import { cli } from '../../../../cli/cli.js';
|
|
@@ -7,15 +6,15 @@ import request from '../../../../request.js';
|
|
|
7
6
|
import { spo } from '../../../../utils/spo.js';
|
|
8
7
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
9
8
|
import commands from '../../commands.js';
|
|
10
|
-
const options =
|
|
11
|
-
.
|
|
12
|
-
url:
|
|
13
|
-
.refine(url => validation.isValidSharePointUrl(url) === true,
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
export const options = z.strictObject({
|
|
10
|
+
...globalOptionsZod.shape,
|
|
11
|
+
url: 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
|
+
force: z.boolean().optional().alias('f')
|
|
17
|
+
});
|
|
19
18
|
class SpoHomeSiteRemoveCommand extends SpoCommand {
|
|
20
19
|
get name() {
|
|
21
20
|
return commands.HOMESITE_REMOVE;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zod } from '../../../../utils/zod.js';
|
|
3
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
3
|
import request from '../../../../request.js';
|
|
5
4
|
import { spo } from '../../../../utils/spo.js';
|
|
@@ -7,24 +6,24 @@ import { validation } from '../../../../utils/validation.js';
|
|
|
7
6
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
8
7
|
import commands from '../../commands.js';
|
|
9
8
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
10
|
-
const
|
|
11
|
-
.
|
|
12
|
-
url:
|
|
13
|
-
.refine(
|
|
14
|
-
|
|
15
|
-
}))
|
|
9
|
+
export const options = z.strictObject({
|
|
10
|
+
...globalOptionsZod.shape,
|
|
11
|
+
url: z.string()
|
|
12
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
13
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
14
|
+
}).alias('u'),
|
|
16
15
|
vivaConnectionsDefaultStart: z.boolean().optional(),
|
|
17
16
|
draftMode: z.boolean().optional(),
|
|
18
17
|
audienceIds: z.string()
|
|
19
|
-
.refine(audiences => validation.isValidGuidArray(audiences) === true,
|
|
20
|
-
|
|
21
|
-
})
|
|
18
|
+
.refine(audiences => validation.isValidGuidArray(audiences) === true, {
|
|
19
|
+
error: e => `The following GUIDs are invalid: ${e.input}.`
|
|
20
|
+
}).optional(),
|
|
22
21
|
audienceNames: z.string().optional(),
|
|
23
22
|
targetedLicenseType: z.enum(['everyone', 'frontLineWorkers', 'informationWorkers']).optional(),
|
|
24
23
|
order: z.number()
|
|
25
|
-
.refine(order => validation.isValidPositiveInteger(order) === true,
|
|
26
|
-
|
|
27
|
-
})
|
|
24
|
+
.refine(order => validation.isValidPositiveInteger(order) === true, {
|
|
25
|
+
error: e => `'${e.input}' is not a positive integer.`
|
|
26
|
+
}).optional()
|
|
28
27
|
});
|
|
29
28
|
class SpoHomeSiteSetCommand extends SpoCommand {
|
|
30
29
|
get name() {
|
|
@@ -34,7 +33,7 @@ class SpoHomeSiteSetCommand extends SpoCommand {
|
|
|
34
33
|
return 'Updates an existing SharePoint home site.';
|
|
35
34
|
}
|
|
36
35
|
get schema() {
|
|
37
|
-
return
|
|
36
|
+
return options;
|
|
38
37
|
}
|
|
39
38
|
getRefinedSchema(schema) {
|
|
40
39
|
return schema
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
2
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { zod } from '../../../../utils/zod.js';
|
|
5
4
|
import commands from '../../commands.js';
|
|
6
5
|
import { DOMParser } from '@xmldom/xmldom';
|
|
7
6
|
import { validation } from '../../../../utils/validation.js';
|
|
@@ -9,23 +8,20 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
|
9
8
|
import request from '../../../../request.js';
|
|
10
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
10
|
import { cli } from '../../../../cli/cli.js';
|
|
12
|
-
const options =
|
|
13
|
-
.
|
|
14
|
-
webUrl:
|
|
15
|
-
.refine(url => validation.isValidSharePointUrl(url) === true,
|
|
16
|
-
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}))),
|
|
22
|
-
listTitle: zod.alias('t', z.string().optional()),
|
|
11
|
+
export const options = z.strictObject({
|
|
12
|
+
...globalOptionsZod.shape,
|
|
13
|
+
webUrl: z.string()
|
|
14
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
15
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
16
|
+
})
|
|
17
|
+
.alias('u'),
|
|
18
|
+
listId: z.uuid().optional().alias('i'),
|
|
19
|
+
listTitle: z.string().optional().alias('t'),
|
|
23
20
|
listUrl: z.string().optional(),
|
|
24
21
|
fieldName: z.string().optional(),
|
|
25
22
|
folderUrl: z.string().optional(),
|
|
26
|
-
force:
|
|
27
|
-
})
|
|
28
|
-
.strict();
|
|
23
|
+
force: z.boolean().optional().alias('f')
|
|
24
|
+
});
|
|
29
25
|
class SpoListDefaultValueClearCommand extends SpoCommand {
|
|
30
26
|
get name() {
|
|
31
27
|
return commands.LIST_DEFAULTVALUE_CLEAR;
|
|
@@ -39,10 +35,10 @@ class SpoListDefaultValueClearCommand extends SpoCommand {
|
|
|
39
35
|
getRefinedSchema(schema) {
|
|
40
36
|
return schema
|
|
41
37
|
.refine(options => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
|
|
42
|
-
|
|
38
|
+
error: 'Use one of the following options: listId, listTitle, listUrl.'
|
|
43
39
|
})
|
|
44
40
|
.refine(options => (options.fieldName !== undefined) !== (options.folderUrl !== undefined) || (options.fieldName === undefined && options.folderUrl === undefined), {
|
|
45
|
-
|
|
41
|
+
error: `Specify 'fieldName' or 'folderUrl', but not both.`
|
|
46
42
|
});
|
|
47
43
|
}
|
|
48
44
|
async commandAction(logger, args) {
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import commands from '../../commands.js';
|
|
2
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
3
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { validation } from '../../../../utils/validation.js';
|
|
6
|
+
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
7
|
+
import { spo } from '../../../../utils/spo.js';
|
|
8
|
+
import request from '../../../../request.js';
|
|
9
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
10
|
+
export const options = z.strictObject({
|
|
11
|
+
...globalOptionsZod.shape,
|
|
12
|
+
webUrl: z.string()
|
|
13
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
14
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
15
|
+
})
|
|
16
|
+
.alias('u'),
|
|
17
|
+
listId: z.uuid().optional().alias('i'),
|
|
18
|
+
listTitle: z.string().optional().alias('t'),
|
|
19
|
+
listUrl: z.string().optional(),
|
|
20
|
+
fieldName: z.string(),
|
|
21
|
+
folderUrl: z.string().optional()
|
|
22
|
+
});
|
|
23
|
+
class SpoListDefaultValueGetCommand extends SpoCommand {
|
|
24
|
+
get name() {
|
|
25
|
+
return commands.LIST_DEFAULTVALUE_GET;
|
|
26
|
+
}
|
|
27
|
+
get description() {
|
|
28
|
+
return 'Gets a specific default column value from a list';
|
|
29
|
+
}
|
|
30
|
+
get schema() {
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
33
|
+
getRefinedSchema(schema) {
|
|
34
|
+
return schema
|
|
35
|
+
.refine(options => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
|
|
36
|
+
error: 'Use one of the following options: listId, listTitle, listUrl.'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async commandAction(logger, args) {
|
|
40
|
+
try {
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
await logger.logToStderr(`Retrieving default column value for field '${args.options.fieldName}' in list '${args.options.listId || args.options.listTitle || args.options.listUrl}'...`);
|
|
43
|
+
await logger.logToStderr('Retrieving list information...');
|
|
44
|
+
}
|
|
45
|
+
const listServerRelUrl = await this.getServerRelativeListUrl(args.options);
|
|
46
|
+
if (this.verbose) {
|
|
47
|
+
await logger.logToStderr('Retrieving default column values...');
|
|
48
|
+
}
|
|
49
|
+
let defaultValues;
|
|
50
|
+
try {
|
|
51
|
+
const defaultValuesXml = await this.getDefaultColumnValuesXml(args.options.webUrl, listServerRelUrl);
|
|
52
|
+
defaultValues = spo.convertDefaultColumnXmlToJson(defaultValuesXml);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (err.status !== 404) {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
// For lists that have never had default column values set, the client_LocationBasedDefaults.html file does not exist.
|
|
59
|
+
defaultValues = [];
|
|
60
|
+
}
|
|
61
|
+
defaultValues = defaultValues.filter(d => d.fieldName.toLowerCase() === args.options.fieldName.toLowerCase());
|
|
62
|
+
if (args.options.folderUrl) {
|
|
63
|
+
const serverRelFolderUrl = urlUtil.removeTrailingSlashes(urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl));
|
|
64
|
+
defaultValues = defaultValues.filter(d => d.folderUrl.toLowerCase() === serverRelFolderUrl.toLowerCase());
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
defaultValues = defaultValues.filter(d => d.folderUrl.toLowerCase() === listServerRelUrl.toLowerCase());
|
|
68
|
+
}
|
|
69
|
+
if (defaultValues.length === 0) {
|
|
70
|
+
throw `No default column value found for field '${args.options.fieldName}'${args.options.folderUrl ? ` in folder '${args.options.folderUrl}'` : ''}.`;
|
|
71
|
+
}
|
|
72
|
+
await logger.log(defaultValues[0]);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
this.handleRejectedODataJsonPromise(err);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async getServerRelativeListUrl(options) {
|
|
79
|
+
const requestOptions = {
|
|
80
|
+
url: `${options.webUrl}/_api/Web`,
|
|
81
|
+
headers: {
|
|
82
|
+
accept: 'application/json;odata=nometadata'
|
|
83
|
+
},
|
|
84
|
+
responseType: 'json'
|
|
85
|
+
};
|
|
86
|
+
if (options.listUrl) {
|
|
87
|
+
const serverRelativeUrl = urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
|
|
88
|
+
requestOptions.url += `/GetList('${serverRelativeUrl}')`;
|
|
89
|
+
}
|
|
90
|
+
else if (options.listId) {
|
|
91
|
+
requestOptions.url += `/Lists('${options.listId}')`;
|
|
92
|
+
}
|
|
93
|
+
else if (options.listTitle) {
|
|
94
|
+
requestOptions.url += `/Lists/GetByTitle('${formatting.encodeQueryParameter(options.listTitle)}')`;
|
|
95
|
+
}
|
|
96
|
+
requestOptions.url += '?$expand=RootFolder&$select=RootFolder/ServerRelativeUrl,BaseTemplate';
|
|
97
|
+
try {
|
|
98
|
+
const response = await request.get(requestOptions);
|
|
99
|
+
if (response.BaseTemplate !== 101) {
|
|
100
|
+
throw `List '${options.listId || options.listTitle || options.listUrl}' is not a document library.`;
|
|
101
|
+
}
|
|
102
|
+
return response.RootFolder.ServerRelativeUrl;
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error.status === 404) {
|
|
106
|
+
throw `List '${options.listId || options.listTitle || options.listUrl}' was not found.`;
|
|
107
|
+
}
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async getDefaultColumnValuesXml(webUrl, listServerRelUrl) {
|
|
112
|
+
const requestOptions = {
|
|
113
|
+
url: `${webUrl}/_api/Web/GetFileByServerRelativePath(decodedUrl='${formatting.encodeQueryParameter(listServerRelUrl + '/Forms/client_LocationBasedDefaults.html')}')/$value`,
|
|
114
|
+
headers: {
|
|
115
|
+
accept: 'application/json;odata=nometadata'
|
|
116
|
+
},
|
|
117
|
+
responseType: 'text'
|
|
118
|
+
};
|
|
119
|
+
const defaultValuesXml = await request.get(requestOptions);
|
|
120
|
+
return defaultValuesXml;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export default new SpoListDefaultValueGetCommand();
|
|
124
|
+
//# sourceMappingURL=list-defaultvalue-get.js.map
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
2
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { zod } from '../../../../utils/zod.js';
|
|
5
4
|
import commands from '../../commands.js';
|
|
6
|
-
import { DOMParser } from '@xmldom/xmldom';
|
|
7
5
|
import { validation } from '../../../../utils/validation.js';
|
|
8
6
|
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
7
|
+
import { spo } from '../../../../utils/spo.js';
|
|
9
8
|
import request from '../../../../request.js';
|
|
10
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
|
-
const options =
|
|
12
|
-
.
|
|
13
|
-
webUrl:
|
|
14
|
-
.refine(url => validation.isValidSharePointUrl(url) === true,
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}))),
|
|
21
|
-
listTitle: zod.alias('t', z.string().optional()),
|
|
10
|
+
export const options = z.strictObject({
|
|
11
|
+
...globalOptionsZod.shape,
|
|
12
|
+
webUrl: z.string()
|
|
13
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
14
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
15
|
+
})
|
|
16
|
+
.alias('u'),
|
|
17
|
+
listId: z.uuid().optional().alias('i'),
|
|
18
|
+
listTitle: z.string().optional().alias('t'),
|
|
22
19
|
listUrl: z.string().optional(),
|
|
23
20
|
folderUrl: z.string().optional()
|
|
24
|
-
})
|
|
25
|
-
.strict();
|
|
21
|
+
});
|
|
26
22
|
class SpoListDefaultValueListCommand extends SpoCommand {
|
|
27
23
|
get name() {
|
|
28
24
|
return commands.LIST_DEFAULTVALUE_LIST;
|
|
@@ -36,7 +32,7 @@ class SpoListDefaultValueListCommand extends SpoCommand {
|
|
|
36
32
|
getRefinedSchema(schema) {
|
|
37
33
|
return schema
|
|
38
34
|
.refine(options => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
|
|
39
|
-
|
|
35
|
+
error: 'Use one of the following options: listId, listTitle, listUrl.'
|
|
40
36
|
});
|
|
41
37
|
}
|
|
42
38
|
async commandAction(logger, args) {
|
|
@@ -52,7 +48,7 @@ class SpoListDefaultValueListCommand extends SpoCommand {
|
|
|
52
48
|
let defaultValues;
|
|
53
49
|
try {
|
|
54
50
|
const defaultValuesXml = await this.getDefaultColumnValuesXml(args.options.webUrl, listServerRelUrl);
|
|
55
|
-
defaultValues =
|
|
51
|
+
defaultValues = spo.convertDefaultColumnXmlToJson(defaultValuesXml);
|
|
56
52
|
}
|
|
57
53
|
catch (err) {
|
|
58
54
|
if (err.status !== 404) {
|
|
@@ -115,26 +111,6 @@ class SpoListDefaultValueListCommand extends SpoCommand {
|
|
|
115
111
|
const defaultValuesXml = await request.get(requestOptions);
|
|
116
112
|
return defaultValuesXml;
|
|
117
113
|
}
|
|
118
|
-
convertXmlToJson(xml) {
|
|
119
|
-
const results = [];
|
|
120
|
-
const parser = new DOMParser();
|
|
121
|
-
const doc = parser.parseFromString(xml, 'application/xml');
|
|
122
|
-
const folderLinks = doc.getElementsByTagName('a');
|
|
123
|
-
for (let i = 0; i < folderLinks.length; i++) {
|
|
124
|
-
const folderUrl = folderLinks[i].getAttribute('href');
|
|
125
|
-
const defaultValues = folderLinks[i].getElementsByTagName('DefaultValue');
|
|
126
|
-
for (let j = 0; j < defaultValues.length; j++) {
|
|
127
|
-
const fieldName = defaultValues[j].getAttribute('FieldName');
|
|
128
|
-
const fieldValue = defaultValues[j].textContent;
|
|
129
|
-
results.push({
|
|
130
|
-
fieldName: fieldName,
|
|
131
|
-
fieldValue: fieldValue,
|
|
132
|
-
folderUrl: decodeURIComponent(folderUrl)
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return results;
|
|
137
|
-
}
|
|
138
114
|
}
|
|
139
115
|
export default new SpoListDefaultValueListCommand();
|
|
140
116
|
//# sourceMappingURL=list-defaultvalue-list.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
2
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { zod } from '../../../../utils/zod.js';
|
|
5
4
|
import commands from '../../commands.js';
|
|
6
5
|
import { DOMParser } from '@xmldom/xmldom';
|
|
7
6
|
import { validation } from '../../../../utils/validation.js';
|
|
@@ -9,23 +8,20 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
|
9
8
|
import request from '../../../../request.js';
|
|
10
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
10
|
import { cli } from '../../../../cli/cli.js';
|
|
12
|
-
const options =
|
|
13
|
-
.
|
|
14
|
-
webUrl:
|
|
15
|
-
.refine(url => validation.isValidSharePointUrl(url) === true,
|
|
16
|
-
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}))),
|
|
22
|
-
listTitle: zod.alias('t', z.string().optional()),
|
|
11
|
+
export const options = z.strictObject({
|
|
12
|
+
...globalOptionsZod.shape,
|
|
13
|
+
webUrl: z.string()
|
|
14
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
15
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
16
|
+
})
|
|
17
|
+
.alias('u'),
|
|
18
|
+
listId: z.uuid().optional().alias('i'),
|
|
19
|
+
listTitle: z.string().optional().alias('t'),
|
|
23
20
|
listUrl: z.string().optional(),
|
|
24
21
|
fieldName: z.string(),
|
|
25
22
|
folderUrl: z.string().optional(),
|
|
26
|
-
force:
|
|
27
|
-
})
|
|
28
|
-
.strict();
|
|
23
|
+
force: z.boolean().optional().alias('f')
|
|
24
|
+
});
|
|
29
25
|
class SpoListDefaultValueRemoveCommand extends SpoCommand {
|
|
30
26
|
get name() {
|
|
31
27
|
return commands.LIST_DEFAULTVALUE_REMOVE;
|
|
@@ -39,7 +35,7 @@ class SpoListDefaultValueRemoveCommand extends SpoCommand {
|
|
|
39
35
|
getRefinedSchema(schema) {
|
|
40
36
|
return schema
|
|
41
37
|
.refine(options => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
|
|
42
|
-
|
|
38
|
+
error: 'Use one of the following options: listId, listTitle, listUrl.'
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
41
|
async commandAction(logger, args) {
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
2
2
|
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { zod } from '../../../../utils/zod.js';
|
|
5
4
|
import commands from '../../commands.js';
|
|
6
5
|
import { DOMParser } from '@xmldom/xmldom';
|
|
7
6
|
import { validation } from '../../../../utils/validation.js';
|
|
8
7
|
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
9
8
|
import request from '../../../../request.js';
|
|
10
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
|
-
const options =
|
|
12
|
-
.
|
|
13
|
-
webUrl:
|
|
14
|
-
.refine(url => validation.isValidSharePointUrl(url) === true,
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}))),
|
|
21
|
-
listTitle: zod.alias('t', z.string().optional()),
|
|
10
|
+
export const options = z.strictObject({
|
|
11
|
+
...globalOptionsZod.shape,
|
|
12
|
+
webUrl: z.string()
|
|
13
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
14
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
15
|
+
})
|
|
16
|
+
.alias('u'),
|
|
17
|
+
listId: z.uuid().optional().alias('i'),
|
|
18
|
+
listTitle: z.string().optional().alias('t'),
|
|
22
19
|
listUrl: z.string().optional(),
|
|
23
20
|
fieldName: z.string(),
|
|
24
21
|
fieldValue: z.string()
|
|
25
22
|
.refine(value => value !== '', `The value cannot be empty. Use 'spo list defaultvalue remove' to remove a default column value.`),
|
|
26
23
|
folderUrl: z.string().optional()
|
|
27
24
|
.refine(url => url === undefined || (!url.includes('#') && !url.includes('%')), 'Due to limitations in SharePoint Online, setting default column values for folders with a # or % character in their path is not supported.')
|
|
28
|
-
})
|
|
29
|
-
.strict();
|
|
25
|
+
});
|
|
30
26
|
class SpoListDefaultValueSetCommand extends SpoCommand {
|
|
31
27
|
get name() {
|
|
32
28
|
return commands.LIST_DEFAULTVALUE_SET;
|
|
@@ -40,7 +36,7 @@ class SpoListDefaultValueSetCommand extends SpoCommand {
|
|
|
40
36
|
getRefinedSchema(schema) {
|
|
41
37
|
return schema
|
|
42
38
|
.refine(options => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
|
|
43
|
-
|
|
39
|
+
error: 'Use one of the following options: listId, listTitle, listUrl.'
|
|
44
40
|
});
|
|
45
41
|
}
|
|
46
42
|
async commandAction(logger, args) {
|
|
@@ -6,17 +6,14 @@ import { validation } from '../../../../utils/validation.js';
|
|
|
6
6
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
7
7
|
import commands from '../../commands.js';
|
|
8
8
|
import { z } from 'zod';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
webUrl: zod.alias('u', z.string()
|
|
9
|
+
export const options = z.strictObject({
|
|
10
|
+
...globalOptionsZod.shape,
|
|
11
|
+
webUrl: z.string()
|
|
13
12
|
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
message: `'${id}' is not a valid GUID.`
|
|
19
|
-
})).optional(),
|
|
13
|
+
error: 'webUrl is not a valid SharePoint site URL.'
|
|
14
|
+
})
|
|
15
|
+
.alias('u'),
|
|
16
|
+
listId: z.uuid().optional(),
|
|
20
17
|
listTitle: z.string().optional(),
|
|
21
18
|
listUrl: z.string().optional(),
|
|
22
19
|
title: z.string().min(1, 'Cannot be empty.'),
|
|
@@ -36,7 +33,7 @@ const options = globalOptionsZod
|
|
|
36
33
|
return false;
|
|
37
34
|
}
|
|
38
35
|
}, {
|
|
39
|
-
|
|
36
|
+
error: 'Custom formatter must be a valid JSON string.'
|
|
40
37
|
})
|
|
41
38
|
.optional(),
|
|
42
39
|
type: z.enum(['list', 'calendar', 'gallery', 'kanban']).optional(),
|
|
@@ -46,8 +43,7 @@ const options = globalOptionsZod
|
|
|
46
43
|
calendarSubTitleField: z.string().min(1, 'Cannot be empty.').optional(),
|
|
47
44
|
calendarDefaultLayout: z.enum(['month', 'week', 'workWeek', 'day']).optional(),
|
|
48
45
|
kanbanBucketField: z.string().min(1, 'Cannot be empty.').optional()
|
|
49
|
-
})
|
|
50
|
-
.strict();
|
|
46
|
+
});
|
|
51
47
|
class SpoListViewAddCommand extends SpoCommand {
|
|
52
48
|
get name() {
|
|
53
49
|
return commands.LIST_VIEW_ADD;
|
|
@@ -61,25 +57,25 @@ class SpoListViewAddCommand extends SpoCommand {
|
|
|
61
57
|
getRefinedSchema(schema) {
|
|
62
58
|
return schema
|
|
63
59
|
.refine((options) => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
|
|
64
|
-
|
|
60
|
+
error: 'Use one of the following options: listId, listTitle, or listUrl.'
|
|
65
61
|
})
|
|
66
62
|
.refine((options) => !options.personal || !options.default, {
|
|
67
|
-
|
|
63
|
+
error: 'Default view cannot be a personal view.'
|
|
68
64
|
})
|
|
69
65
|
.refine((options) => options.type !== 'calendar' || [options.calendarStartDateField, options.calendarEndDateField, options.calendarTitleField].filter(o => o === undefined).length === 0, {
|
|
70
|
-
|
|
66
|
+
error: 'When type is calendar, do specify calendarStartDateField, calendarEndDateField, and calendarTitleField.'
|
|
71
67
|
})
|
|
72
68
|
.refine((options) => options.type === 'calendar' || [options.calendarStartDateField, options.calendarEndDateField, options.calendarTitleField].filter(o => o === undefined).length === 3, {
|
|
73
|
-
|
|
69
|
+
error: 'When type is not calendar, do not specify calendarStartDateField, calendarEndDateField, and calendarTitleField.'
|
|
74
70
|
})
|
|
75
71
|
.refine((options) => options.type !== 'kanban' || options.kanbanBucketField !== undefined, {
|
|
76
|
-
|
|
72
|
+
error: 'When type is kanban, do specify kanbanBucketField.'
|
|
77
73
|
})
|
|
78
74
|
.refine((options) => options.type === 'kanban' || options.kanbanBucketField === undefined, {
|
|
79
|
-
|
|
75
|
+
error: 'When type is not kanban, do not specify kanbanBucketField.'
|
|
80
76
|
})
|
|
81
77
|
.refine((options) => options.type === 'calendar' || options.fields !== undefined, {
|
|
82
|
-
|
|
78
|
+
error: 'When type is not calendar, do specify fields.'
|
|
83
79
|
});
|
|
84
80
|
}
|
|
85
81
|
async commandAction(logger, args) {
|