@pnp/cli-microsoft365 11.4.0-beta.f54089d → 11.4.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.
@@ -0,0 +1,96 @@
1
+ import { globalOptionsZod } from '../../../../Command.js';
2
+ import { z } from 'zod';
3
+ import commands from '../../commands.js';
4
+ import GraphCommand from '../../../base/GraphCommand.js';
5
+ import { spe } from '../../../../utils/spe.js';
6
+ import { odata } from '../../../../utils/odata.js';
7
+ import { formatting } from '../../../../utils/formatting.js';
8
+ import { cli } from '../../../../cli/cli.js';
9
+ import request from '../../../../request.js';
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ id: z.string().optional().alias('i'),
13
+ name: z.string().optional().alias('n'),
14
+ containerTypeId: z.uuid().optional(),
15
+ containerTypeName: z.string().optional(),
16
+ force: z.boolean().optional().alias('f')
17
+ });
18
+ class SpeContainerRecycleBinItemRemoveCommand extends GraphCommand {
19
+ get name() {
20
+ return commands.CONTAINER_RECYCLEBINITEM_REMOVE;
21
+ }
22
+ get description() {
23
+ return 'Permanently removes a container from the recycle bin';
24
+ }
25
+ get schema() {
26
+ return options;
27
+ }
28
+ getRefinedSchema(schema) {
29
+ return schema
30
+ .refine((options) => [options.id, options.name].filter(o => o !== undefined).length === 1, {
31
+ error: 'Use one of the following options: id or name.'
32
+ })
33
+ .refine((options) => !options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 1, {
34
+ error: 'Use one of the following options when specifying the container name: containerTypeId or containerTypeName.'
35
+ })
36
+ .refine((options) => options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 0, {
37
+ error: 'Options containerTypeId and containerTypeName are only required when removing a container by name.'
38
+ });
39
+ }
40
+ async commandAction(logger, args) {
41
+ if (!args.options.force) {
42
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to permanently remove deleted container '${args.options.id || args.options.name}'?` });
43
+ if (!result) {
44
+ return;
45
+ }
46
+ }
47
+ try {
48
+ const containerId = await this.getContainerId(args.options, logger);
49
+ if (this.verbose) {
50
+ await logger.logToStderr(`Permanently removing deleted container with ID '${containerId}'...`);
51
+ }
52
+ const requestOptions = {
53
+ url: `${this.resource}/v1.0/storage/fileStorage/deletedContainers/${containerId}`,
54
+ headers: {
55
+ accept: 'application/json;odata.metadata=none'
56
+ },
57
+ responseType: 'json'
58
+ };
59
+ await request.delete(requestOptions);
60
+ }
61
+ catch (err) {
62
+ this.handleRejectedODataJsonPromise(err);
63
+ }
64
+ }
65
+ async getContainerId(options, logger) {
66
+ if (options.id) {
67
+ return options.id;
68
+ }
69
+ if (this.verbose) {
70
+ await logger.logToStderr(`Retrieving container with name '${options.name}'...`);
71
+ }
72
+ const containerTypeId = await this.getContainerTypeId(options, logger);
73
+ const containers = await odata.getAllItems(`${this.resource}/v1.0/storage/fileStorage/deletedContainers?$filter=containerTypeId eq ${containerTypeId}&$select=id,displayName`);
74
+ const matchingContainers = containers.filter(c => c.displayName.toLowerCase() === options.name.toLowerCase());
75
+ if (matchingContainers.length === 0) {
76
+ throw new Error(`The specified container '${options.name}' does not exist.`);
77
+ }
78
+ if (matchingContainers.length > 1) {
79
+ const containerKeyValuePair = formatting.convertArrayToHashTable('id', matchingContainers);
80
+ const container = await cli.handleMultipleResultsFound(`Multiple containers with name '${options.name}' found.`, containerKeyValuePair);
81
+ return container.id;
82
+ }
83
+ return matchingContainers[0].id;
84
+ }
85
+ async getContainerTypeId(options, logger) {
86
+ if (options.containerTypeId) {
87
+ return options.containerTypeId;
88
+ }
89
+ if (this.verbose) {
90
+ await logger.logToStderr(`Getting container type with name '${options.containerTypeName}'...`);
91
+ }
92
+ return spe.getContainerTypeIdByName(options.containerTypeName);
93
+ }
94
+ }
95
+ export default new SpeContainerRecycleBinItemRemoveCommand();
96
+ //# sourceMappingURL=container-recyclebinitem-remove.js.map
@@ -7,6 +7,7 @@ export default {
7
7
  CONTAINER_REMOVE: `${prefix} container remove`,
8
8
  CONTAINER_PERMISSION_LIST: `${prefix} container permission list`,
9
9
  CONTAINER_RECYCLEBINITEM_LIST: `${prefix} container recyclebinitem list`,
10
+ CONTAINER_RECYCLEBINITEM_REMOVE: `${prefix} container recyclebinitem remove`,
10
11
  CONTAINER_RECYCLEBINITEM_RESTORE: `${prefix} container recyclebinitem restore`,
11
12
  CONTAINERTYPE_ADD: `${prefix} containertype add`,
12
13
  CONTAINERTYPE_GET: `${prefix} containertype get`,
@@ -0,0 +1,166 @@
1
+ import request from '../../../../request.js';
2
+ import { formatting } from '../../../../utils/formatting.js';
3
+ import { urlUtil } from '../../../../utils/urlUtil.js';
4
+ import { validation } from '../../../../utils/validation.js';
5
+ import SpoCommand from '../../../base/SpoCommand.js';
6
+ import commands from '../../commands.js';
7
+ import { globalOptionsZod } from '../../../../Command.js';
8
+ import z from 'zod';
9
+ var AllowedFieldTypeKind;
10
+ (function (AllowedFieldTypeKind) {
11
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Integer"] = 1] = "Integer";
12
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Text"] = 2] = "Text";
13
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Note"] = 3] = "Note";
14
+ AllowedFieldTypeKind[AllowedFieldTypeKind["DateTime"] = 4] = "DateTime";
15
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Counter"] = 5] = "Counter";
16
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Choice"] = 6] = "Choice";
17
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Boolean"] = 8] = "Boolean";
18
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Number"] = 9] = "Number";
19
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Currency"] = 10] = "Currency";
20
+ AllowedFieldTypeKind[AllowedFieldTypeKind["URL"] = 11] = "URL";
21
+ AllowedFieldTypeKind[AllowedFieldTypeKind["Computed"] = 12] = "Computed";
22
+ AllowedFieldTypeKind[AllowedFieldTypeKind["MultiChoice"] = 15] = "MultiChoice";
23
+ AllowedFieldTypeKind[AllowedFieldTypeKind["GridChoice"] = 16] = "GridChoice";
24
+ })(AllowedFieldTypeKind || (AllowedFieldTypeKind = {}));
25
+ export const options = z.strictObject({
26
+ ...globalOptionsZod.shape,
27
+ siteUrl: z.string().refine(url => validation.isValidSharePointUrl(url) === true, {
28
+ error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
29
+ }).alias('u'),
30
+ listTitle: z.string().optional(),
31
+ listId: z.string().uuid()
32
+ .refine(value => validation.isValidGuid(value), {
33
+ error: e => `'${e.input}' in parameter listId is not a valid GUID.`
34
+ }).optional(),
35
+ listUrl: z.string().optional(),
36
+ columnId: z.string().uuid()
37
+ .refine(value => validation.isValidGuid(value), {
38
+ error: e => `'${e.input}' in parameter columnId is not a valid GUID.`
39
+ }).optional().alias('i'),
40
+ columnTitle: z.string().optional().alias('t'),
41
+ columnInternalName: z.string().optional(),
42
+ prompt: z.string().optional(),
43
+ isEnabled: z.boolean().optional()
44
+ }).strict();
45
+ class SppAutofillColumnSetCommand extends SpoCommand {
46
+ get name() {
47
+ return commands.AUTOFILLCOLUMN_SET;
48
+ }
49
+ get description() {
50
+ return 'Applies the autofill option to the selected column';
51
+ }
52
+ get schema() {
53
+ return options;
54
+ }
55
+ getRefinedSchema(schema) {
56
+ return schema
57
+ .refine(options => [options.columnId, options.columnTitle, options.columnInternalName].filter(Boolean).length === 1, {
58
+ message: `Specify exactly one of the following options: 'columnId', 'columnTitle' or 'columnInternalName'.`
59
+ })
60
+ .refine(options => [options.listTitle, options.listId, options.listUrl].filter(Boolean).length === 1, {
61
+ message: `Specify exactly one of the following options: 'listTitle', 'listId' or 'listUrl'.`
62
+ });
63
+ }
64
+ async commandAction(logger, args) {
65
+ try {
66
+ if (this.verbose) {
67
+ await logger.log(`Applying an autofill column to a column...`);
68
+ }
69
+ const siteUrl = urlUtil.removeTrailingSlashes(args.options.siteUrl);
70
+ const listInstance = await this.getDocumentLibraryInfo(siteUrl, args.options);
71
+ if (listInstance.BaseType !== 1) {
72
+ throw Error(`The specified list is not a document library.`);
73
+ }
74
+ const column = await this.getColumn(siteUrl, args.options, listInstance.Id);
75
+ if (!Object.values(AllowedFieldTypeKind).includes(column.FieldTypeKind)) {
76
+ throw Error(`The specified column has incorrect type.`);
77
+ }
78
+ if (column.AutofillInfo) {
79
+ await this.updateAutoFillColumnSettings(siteUrl, args.options, column.Id, listInstance.Id, column.AutofillInfo);
80
+ return;
81
+ }
82
+ if (!args.options.prompt) {
83
+ throw Error(`The prompt parameter is required when setting the autofill column for the first time.`);
84
+ }
85
+ await this.applyAutoFillColumnSettings(siteUrl, args.options, column.Id, column.Title, listInstance.Id);
86
+ }
87
+ catch (err) {
88
+ this.handleRejectedODataJsonPromise(err);
89
+ }
90
+ }
91
+ getDocumentLibraryInfo(siteUrl, options) {
92
+ let requestUrl = `${siteUrl}/_api/web`;
93
+ if (options.listId) {
94
+ requestUrl += `/lists(guid'${formatting.encodeQueryParameter(options.listId)}')`;
95
+ }
96
+ else if (options.listTitle) {
97
+ requestUrl += `/lists/getByTitle('${formatting.encodeQueryParameter(options.listTitle)}')`;
98
+ }
99
+ else if (options.listUrl) {
100
+ const listServerRelativeUrl = urlUtil.getServerRelativePath(siteUrl, options.listUrl);
101
+ requestUrl += `/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
102
+ }
103
+ const requestOptions = {
104
+ url: `${requestUrl}?$select=Id,BaseType`,
105
+ headers: {
106
+ 'accept': 'application/json;odata=nometadata'
107
+ },
108
+ responseType: 'json'
109
+ };
110
+ return request.get(requestOptions);
111
+ }
112
+ getColumn(siteUrl, options, listId) {
113
+ let fieldRestUrl = '';
114
+ if (options.columnId) {
115
+ fieldRestUrl = `/getbyid('${formatting.encodeQueryParameter(options.columnId)}')`;
116
+ }
117
+ else {
118
+ fieldRestUrl = `/getbyinternalnameortitle('${formatting.encodeQueryParameter((options.columnTitle || options.columnInternalName))}')`;
119
+ }
120
+ const requestOptions = {
121
+ url: `${siteUrl}/_api/web/lists(guid'${formatting.encodeQueryParameter(listId)}')/fields${fieldRestUrl}?&$select=Id,Title,FieldTypeKind,AutofillInfo`,
122
+ headers: {
123
+ accept: 'application/json;odata=nometadata'
124
+ },
125
+ responseType: 'json'
126
+ };
127
+ return request.get(requestOptions);
128
+ }
129
+ updateAutoFillColumnSettings(siteUrl, options, columnId, listInstanceId, autofillInfo) {
130
+ const autofillInfoObj = JSON.parse(autofillInfo);
131
+ const requestOptions = {
132
+ url: `${siteUrl}/_api/machinelearning/SetColumnLLMInfo`,
133
+ headers: {
134
+ accept: 'application/json;odata=nometadata'
135
+ },
136
+ responseType: 'json',
137
+ data: {
138
+ autofillPrompt: options.prompt ?? autofillInfoObj.LLM.Prompt,
139
+ columnId: columnId,
140
+ docLibId: `{${listInstanceId}}`,
141
+ isEnabled: options.isEnabled !== undefined ? options.isEnabled : autofillInfoObj.LLM.IsEnabled
142
+ }
143
+ };
144
+ return request.post(requestOptions);
145
+ }
146
+ applyAutoFillColumnSettings(siteUrl, options, columnId, columnTitle, listInstanceId) {
147
+ const requestOptions = {
148
+ url: `${siteUrl}/_api/machinelearning/SetSyntexPoweredColumnPrompts`,
149
+ headers: {
150
+ accept: 'application/json;odata=nometadata'
151
+ },
152
+ data: {
153
+ docLibId: `{${listInstanceId}}`,
154
+ syntexPoweredColumnPrompts: JSON.stringify([{
155
+ columnId: columnId,
156
+ columnName: columnTitle,
157
+ prompt: options.prompt,
158
+ isEnabled: options.isEnabled !== undefined ? options.isEnabled : true
159
+ }])
160
+ }
161
+ };
162
+ return request.post(requestOptions);
163
+ }
164
+ }
165
+ export default new SppAutofillColumnSetCommand();
166
+ //# sourceMappingURL=autofillcolumn-set.js.map
@@ -1,5 +1,6 @@
1
1
  const prefix = 'spp';
2
2
  export default {
3
+ AUTOFILLCOLUMN_SET: `${prefix} autofillcolumn set`,
3
4
  CONTENTCENTER_LIST: `${prefix} contentcenter list`,
4
5
  MODEL_APPLY: `${prefix} model apply`,
5
6
  MODEL_GET: `${prefix} model get`,
@@ -0,0 +1,79 @@
1
+ import Global from '/docs/cmd/_global.mdx';
2
+ import Tabs from '@theme/Tabs';
3
+ import TabItem from '@theme/TabItem';
4
+
5
+ # spe container recyclebinitem remove
6
+
7
+ Permanently removes a container from the recycle bin
8
+
9
+ ## Usage
10
+
11
+ ```sh
12
+ m365 spe container recyclebinitem remove [options]
13
+ ```
14
+
15
+ ## Options
16
+
17
+ ```md definition-list
18
+ `-i, --id [id]`
19
+ : The container id. Specify either `id` or `name` but not both.
20
+
21
+ `-n, --name [name]`
22
+ : The display name of the Container. Specify either `id` or `name` but not both.
23
+
24
+ `--containerTypeId [containerTypeId]`
25
+ : The container type ID of the container instance. Use either `containerTypeId` or `containerTypeName` but not both.
26
+
27
+ `--containerTypeName [containerTypeName]`
28
+ : The container type name of the container instance. Use either `containerTypeId` or `containerTypeName` but not both.
29
+
30
+ `-f, --force`
31
+ : Don't prompt for confirmation.
32
+ ```
33
+
34
+ <Global />
35
+
36
+ ## Permissions
37
+
38
+ <Tabs>
39
+ <TabItem value="Delegated">
40
+
41
+ | Resource | Permissions |
42
+ |-----------------|--------------------------------------------------------------------|
43
+ | Microsoft Graph | FileStorageContainer.Selected, FileStorageContainerType.Manage.All |
44
+
45
+ </TabItem>
46
+ <TabItem value="Application">
47
+
48
+ This command only supports application permissions when using the `containerTypeId` option.
49
+
50
+ | Resource | Permissions |
51
+ |-----------------|-------------------------------|
52
+ | Microsoft Graph | FileStorageContainer.Selected |
53
+
54
+ </TabItem>
55
+ </Tabs>
56
+
57
+ ## Examples
58
+
59
+ Remove a deleted container by ID.
60
+
61
+ ```sh
62
+ m365 spe container recyclebinitem remove --id "b!ISJs1WRro0y0EWgkUYcktDa0mE8zSlFEqFzqRn70Zwp1CEtDEBZgQICPkRbil_5Z"
63
+ ```
64
+
65
+ Remove a deleted container by using its name and container type ID.
66
+
67
+ ```sh
68
+ m365 spe container recyclebinitem remove --containerTypeId "91710488-5756-407f-9046-fbe5f0b4de73" --name "Invoices"
69
+ ```
70
+
71
+ Remove a deleted container by using its name and container type name.
72
+
73
+ ```sh
74
+ m365 spe container recyclebinitem remove --containerTypeName "My container type name" --name "Invoices"
75
+ ```
76
+
77
+ ## Response
78
+
79
+ The command won't return a response on success.
@@ -0,0 +1,104 @@
1
+ import Global from '/docs/cmd/_global.mdx';
2
+ import Tabs from '@theme/Tabs';
3
+ import TabItem from '@theme/TabItem';
4
+
5
+ # spp autofillcolumn set
6
+
7
+ Applies the autofill option to the selected column
8
+
9
+ ## Usage
10
+
11
+ ```sh
12
+ m365 spp autofillcolumn set [options]
13
+ ```
14
+
15
+ ## Options
16
+
17
+ ```md definition-list
18
+ `-u, --siteUrl <siteUrl>`
19
+ : The URL of the target site.
20
+
21
+ `--listTitle [listTitle]`
22
+ : The title of the library on which to apply the model. Specify either `listTitle`, `listId`, or `listUrl` but not multiple.
23
+
24
+ `--listId [listId]`
25
+ : The ID of the library on which to apply the model. Specify either `listTitle`, `listId`, or `listUrl` but not multiple.
26
+
27
+ `--listUrl [listUrl]`
28
+ : Server or web-relative URL of the library on which to apply the model. Specify either `listTitle`, `listId`, or `listUrl` but not multiple.
29
+
30
+ `-i, --columnId [columnId]`
31
+ : ID of the column to which the autofill option will be assigned. Specify either `columnId`, `columnTitle` or `columnInternalName`.
32
+
33
+ `-t, --columnTitle [columnTitle]`
34
+ : Title of the column to which the autofill option will be assigned. Specify either `columnId`, `columnTitle` or `columnInternalName`.
35
+
36
+ `--columnInternalName [columnInternalName]`
37
+ : The internal name (case-sensitive) of the column to which the autofill option will be assigned. Specify either `columnId`, `columnTitle` or `columnInternalName`.
38
+
39
+ `--prompt [prompt]`
40
+ : The text in natural language that will be used to extract specific information or generate information from files within a SharePoint library.
41
+
42
+ `--isEnabled [isEnabled]`
43
+ : Enables or disables the autofill column feature.
44
+ ```
45
+
46
+ <Global />
47
+
48
+ ## Remarks
49
+
50
+ The `prompt` parameter is required when setting the autofill column for the first time.
51
+
52
+ ## Examples
53
+
54
+ Applies an autofill column on a selected column to a document library based on the list id.
55
+
56
+ ```sh
57
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listId "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc" --columnId "1045e69d-21fb-4214-a25a-9bdfa7cb63a2" --prompt "Write a 2-line summary of the document"
58
+ ```
59
+
60
+ Applies an autofill column on a selected column to a document library based on the list title.
61
+
62
+ ```sh
63
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listTitle "Documents" --columnId "1045e69d-21fb-4214-a25a-9bdfa7cb63a2" --prompt "Write a 2-line summary of the document"
64
+ ```
65
+
66
+ Applies an autofill column on a selected column to a document library based on the list url.
67
+
68
+ ```sh
69
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listUrl '/Shared Documents' --columnId "1045e69d-21fb-4214-a25a-9bdfa7cb63a2" --prompt "Write a 2-line summary of the document"
70
+ ```
71
+
72
+ Applies an autofill column on a selected column to a document library based on the list id and column title.
73
+
74
+ ```sh
75
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listId "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc" --columnTitle "ColumnTitle" --prompt "Write a 2-line summary of the document"
76
+ ```
77
+
78
+ Applies an autofill column on a selected column to a document library based on the list id and column internal name.
79
+
80
+ ```sh
81
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listId "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc" --columnInternalName "ColumnTitle" --prompt "Write a 2-line summary of the document"
82
+ ```
83
+
84
+ Disables the autofill column for a selected column in a document library, based on the list id and column title.
85
+
86
+ ```sh
87
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listId "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc" --columnTitle "ColumnTitle" --isEnabled false
88
+ ```
89
+
90
+ Reenable the autofill column for a selected column in a document library, based on the list id and column title.
91
+
92
+ ```sh
93
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listId "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc" --columnTitle "ColumnTitle" --isEnabled true
94
+ ```
95
+
96
+ Modifies the prompt for the autofill column
97
+
98
+ ```sh
99
+ m365 spp autofillcolumn set --siteUrl "https://contoso.sharepoint.com/sites/mainSite" --listId "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc" --columnTitle "ColumnTitle" --isEnabled true --prompt "Write a 1-line summary of the document"
100
+ ```
101
+
102
+ ## Response
103
+
104
+ The command won't return a response on success.
package/eslint.config.mjs CHANGED
@@ -23,6 +23,7 @@ const dictionary = [
23
23
  'assets',
24
24
  'assignment',
25
25
  'audit',
26
+ 'autofill',
26
27
  'azure',
27
28
  'bin',
28
29
  'builder',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "11.4.0-beta.f54089d",
3
+ "version": "11.4.0",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -331,4 +331,4 @@
331
331
  "source-map-support": "^0.5.21",
332
332
  "tsc-watch": "^7.2.0"
333
333
  }
334
- }
334
+ }