@pnp/cli-microsoft365 11.4.0-beta.37c2235 → 11.4.0-beta.810a987
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/m365/spp/commands/autofillcolumn/autofillcolumn-set.js +166 -0
- package/dist/m365/spp/commands.js +1 -0
- package/docs/docs/cmd/spp/autofillcolumn/autofillcolumn-set.mdx +104 -0
- package/eslint.config.mjs +1 -0
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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
package/package.json
CHANGED