@pnp/cli-microsoft365 12.0.0-beta.d654135 → 12.0.0-beta.f682e10
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/generate-openapi-spec.json +1 -1
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/googleAnalytics.js +96 -0
- package/dist/m365/spo/commands/file/file-get.js +4 -3
- package/dist/m365/spo/commands/folder/folder-unarchive.js +90 -0
- package/dist/m365/spo/commands/listitem/listitem-get.js +1 -12
- package/dist/m365/spo/commands.js +2 -1
- package/dist/m365/teams/commands/channel/channel-add.js +46 -57
- package/dist/m365/teams/commands/channel/channel-get.js +41 -48
- package/dist/m365/teams/commands/channel/channel-list.js +28 -42
- package/dist/m365/teams/commands/channel/channel-member-add.js +53 -54
- package/dist/m365/teams/commands/channel/channel-member-list.js +47 -55
- package/dist/m365/teams/commands/channel/channel-member-remove.js +62 -62
- package/dist/m365/teams/commands/channel/channel-member-set.js +61 -65
- package/dist/m365/teams/commands/channel/channel-remove.js +47 -49
- package/dist/m365/teams/commands/channel/channel-set.js +47 -54
- package/dist/m365/util/commands/accesstoken/accesstoken-get.js +10 -28
- package/dist/telemetry.js +7 -11
- package/dist/utils/spo.js +1 -3
- package/dist/utils/urlUtil.js +2 -2
- package/docs/docs/cmd/spo/file/file-archive.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-add.mdx +21 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-clear.mdx +23 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-get.mdx +21 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-list.mdx +21 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-remove.mdx +23 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-set.mdx +21 -0
- package/docs/docs/cmd/spo/file/file-unarchive.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-archive.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-sharinglink-add.mdx +21 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-clear.mdx +23 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +21 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +21 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-remove.mdx +23 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-set.mdx +21 -0
- package/docs/docs/cmd/spo/folder/folder-unarchive.mdx +76 -0
- package/docs/docs/cmd/spo/listitem/listitem-get.mdx +0 -6
- package/npm-shrinkwrap.json +324 -3116
- package/package.json +15 -30
- package/dist/appInsights.js +0 -43
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Axios from 'axios';
|
|
2
|
+
import Configstore from 'configstore';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import url from 'url';
|
|
8
|
+
import config from './config.js';
|
|
9
|
+
import { app } from './utils/app.js';
|
|
10
|
+
const measurementId = 'G-4BNT8MQCYT';
|
|
11
|
+
const apiSecret = 'mm_3WD_TRuO-9MKsuZnhDQ';
|
|
12
|
+
const endpoint = 'https://www.google-analytics.com/mp/collect';
|
|
13
|
+
const clientIdSetting = 'telemetryClientId';
|
|
14
|
+
const requestTimeout = 3000;
|
|
15
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
16
|
+
const commonProperties = {
|
|
17
|
+
version: `${app.packageJson().version}${fs.existsSync(path.join(__dirname, `..${path.sep}src`)) ? '-dev' : ''}`,
|
|
18
|
+
node: process.version,
|
|
19
|
+
os: os.platform(),
|
|
20
|
+
env: process.env.CLIMICROSOFT365_ENV ?? '',
|
|
21
|
+
ci: Boolean(process.env.CI).toString()
|
|
22
|
+
};
|
|
23
|
+
function getClientId() {
|
|
24
|
+
const store = new Configstore(config.configstoreName);
|
|
25
|
+
let clientId = store.get(clientIdSetting);
|
|
26
|
+
if (!clientId) {
|
|
27
|
+
clientId = crypto.randomUUID();
|
|
28
|
+
store.set(clientIdSetting, clientId);
|
|
29
|
+
}
|
|
30
|
+
return clientId;
|
|
31
|
+
}
|
|
32
|
+
function getSessionId(sessionId) {
|
|
33
|
+
return parseInt(crypto.createHash('sha256').update(sessionId).digest('hex').substring(0, 12), 16);
|
|
34
|
+
}
|
|
35
|
+
function toEventValue(value) {
|
|
36
|
+
if (typeof value === 'number') {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return String(value);
|
|
40
|
+
}
|
|
41
|
+
function getEvents(commandName, properties, context) {
|
|
42
|
+
const sessionId = getSessionId(context.sessionId);
|
|
43
|
+
const eventProperties = Object.entries(properties).reduce((result, [name, value]) => {
|
|
44
|
+
if (typeof value !== 'undefined') {
|
|
45
|
+
result[name] = toEventValue(value);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}, {});
|
|
49
|
+
return [{
|
|
50
|
+
name: 'command_used',
|
|
51
|
+
params: {
|
|
52
|
+
['command_name']: commandName,
|
|
53
|
+
...commonProperties,
|
|
54
|
+
shell: context.shell,
|
|
55
|
+
...eventProperties,
|
|
56
|
+
['session_id']: sessionId,
|
|
57
|
+
['engagement_time_msec']: 1
|
|
58
|
+
}
|
|
59
|
+
}];
|
|
60
|
+
}
|
|
61
|
+
async function sendEvents(events) {
|
|
62
|
+
const clientId = getClientId();
|
|
63
|
+
const response = await Axios.post(`${endpoint}?measurement_id=${measurementId}&api_secret=${apiSecret}`, {
|
|
64
|
+
['client_id']: clientId,
|
|
65
|
+
events
|
|
66
|
+
}, {
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'application/json'
|
|
69
|
+
},
|
|
70
|
+
timeout: requestTimeout,
|
|
71
|
+
validateStatus: () => true
|
|
72
|
+
});
|
|
73
|
+
if (response.status < 200 || response.status >= 300) {
|
|
74
|
+
throw new Error(`Google Analytics returned ${response.status}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const googleAnalytics = {
|
|
78
|
+
commonProperties,
|
|
79
|
+
trackEvent: async (commandName, properties, context) => {
|
|
80
|
+
await sendEvents(getEvents(commandName, properties, context));
|
|
81
|
+
},
|
|
82
|
+
trackException: async (exception, context) => {
|
|
83
|
+
const description = exception instanceof Error ? exception.message : String(exception);
|
|
84
|
+
await sendEvents([{
|
|
85
|
+
name: 'exception',
|
|
86
|
+
params: {
|
|
87
|
+
description: description.substring(0, 100),
|
|
88
|
+
...commonProperties,
|
|
89
|
+
shell: context.shell,
|
|
90
|
+
['session_id']: getSessionId(context.sessionId),
|
|
91
|
+
['engagement_time_msec']: 1
|
|
92
|
+
}
|
|
93
|
+
}]);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=googleAnalytics.js.map
|
|
@@ -64,9 +64,10 @@ class SpoFileGetCommand extends SpoCommand {
|
|
|
64
64
|
headers: {
|
|
65
65
|
'accept': 'application/json;odata=nometadata'
|
|
66
66
|
},
|
|
67
|
-
//
|
|
68
|
-
// to utf8
|
|
69
|
-
|
|
67
|
+
// Use stream for --asFile, so binary data is piped to disk as-is and
|
|
68
|
+
// isn't encoded to utf8 (which would corrupt it). Use text for
|
|
69
|
+
// --asString. Use json for all other cases.
|
|
70
|
+
responseType: args.options.asFile ? 'stream' : args.options.asString ? 'text' : 'json'
|
|
70
71
|
};
|
|
71
72
|
try {
|
|
72
73
|
const file = await request.get(requestOptions);
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { cli } from '../../../../cli/cli.js';
|
|
7
|
+
import { urlUtil } from '../../../../utils/urlUtil.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
|
+
url: z.string().optional(),
|
|
18
|
+
id: z.uuid().optional().alias('i'),
|
|
19
|
+
force: z.boolean().optional().alias('f')
|
|
20
|
+
});
|
|
21
|
+
class SpoFolderUnarchiveCommand extends SpoCommand {
|
|
22
|
+
get name() {
|
|
23
|
+
return commands.FOLDER_UNARCHIVE;
|
|
24
|
+
}
|
|
25
|
+
get description() {
|
|
26
|
+
return 'Unarchives a folder';
|
|
27
|
+
}
|
|
28
|
+
get schema() {
|
|
29
|
+
return options;
|
|
30
|
+
}
|
|
31
|
+
getRefinedSchema(schema) {
|
|
32
|
+
return schema
|
|
33
|
+
.refine(options => [options.url, options.id].filter(o => o !== undefined).length === 1, {
|
|
34
|
+
error: `Specify 'url' or 'id', but not both.`
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getExcludedOptionsWithUrls() {
|
|
38
|
+
return ['url'];
|
|
39
|
+
}
|
|
40
|
+
async commandAction(logger, args) {
|
|
41
|
+
const { webUrl, url, id, force } = args.options;
|
|
42
|
+
const identifier = url || id;
|
|
43
|
+
if (!force) {
|
|
44
|
+
const result = await cli.promptForConfirmation({ message: `Reactivation could take up to 24 hours. Folders that are reactivated cannot be archived again for a period of time. Are you sure you would like to unarchive this folder?` });
|
|
45
|
+
if (!result) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
if (this.verbose) {
|
|
51
|
+
await logger.logToStderr(`Unarchiving folder ${identifier} at site ${webUrl}...`);
|
|
52
|
+
}
|
|
53
|
+
let requestUrl = `${webUrl}/_api/web`;
|
|
54
|
+
if (id) {
|
|
55
|
+
requestUrl += `/GetFolderById('${formatting.encodeQueryParameter(id)}')`;
|
|
56
|
+
}
|
|
57
|
+
else if (url) {
|
|
58
|
+
const serverRelativePath = urlUtil.getServerRelativePath(webUrl, url);
|
|
59
|
+
requestUrl += `/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(serverRelativePath)}')`;
|
|
60
|
+
}
|
|
61
|
+
requestUrl += '?$select=Exists,ListItemAllFields/Id,ListItemAllFields/ParentList/Id&$expand=ListItemAllFields,ListItemAllFields/ParentList';
|
|
62
|
+
const folderInfo = await request.get({
|
|
63
|
+
url: requestUrl,
|
|
64
|
+
headers: {
|
|
65
|
+
accept: 'application/json;odata=nometadata'
|
|
66
|
+
},
|
|
67
|
+
responseType: 'json'
|
|
68
|
+
});
|
|
69
|
+
if (!folderInfo.Exists) {
|
|
70
|
+
throw `The folder '${identifier}' does not exist.`;
|
|
71
|
+
}
|
|
72
|
+
if (!folderInfo.ListItemAllFields?.ParentList) {
|
|
73
|
+
throw `The folder '${identifier}' is the root folder of a document library and cannot be unarchived. Unarchive a subfolder instead.`;
|
|
74
|
+
}
|
|
75
|
+
const requestOptions = {
|
|
76
|
+
url: `${webUrl}/_api/Lists(guid'${folderInfo.ListItemAllFields.ParentList.Id}')/items(${folderInfo.ListItemAllFields.Id})/UnArchive`,
|
|
77
|
+
headers: {
|
|
78
|
+
accept: 'application/json;odata=nometadata'
|
|
79
|
+
},
|
|
80
|
+
responseType: 'json'
|
|
81
|
+
};
|
|
82
|
+
await request.post(requestOptions);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
this.handleRejectedODataJsonPromise(err);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export default new SpoFolderUnarchiveCommand();
|
|
90
|
+
//# sourceMappingURL=folder-unarchive.js.map
|
|
@@ -11,9 +11,6 @@ import { validation } from '../../../../utils/validation.js';
|
|
|
11
11
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
13
|
class SpoListItemGetCommand extends SpoCommand {
|
|
14
|
-
allowUnknownOptions() {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
14
|
get name() {
|
|
18
15
|
return commands.LISTITEM_GET;
|
|
19
16
|
}
|
|
@@ -30,12 +27,6 @@ class SpoListItemGetCommand extends SpoCommand {
|
|
|
30
27
|
__classPrivateFieldGet(this, _SpoListItemGetCommand_instances, "m", _SpoListItemGetCommand_initOptionSets).call(this);
|
|
31
28
|
}
|
|
32
29
|
async commandAction(logger, args) {
|
|
33
|
-
if (args.options.properties) {
|
|
34
|
-
await this.warn(logger, `Option 'properties' is deprecated. Please use 'fields' instead.`);
|
|
35
|
-
if (!args.options.fields) {
|
|
36
|
-
args.options.fields = args.options.properties;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
30
|
let requestUrl = `${args.options.webUrl}/_api/web`;
|
|
40
31
|
if (args.options.listId) {
|
|
41
32
|
requestUrl += `/lists(guid'${formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
@@ -109,8 +100,6 @@ _SpoListItemGetCommand_instances = new WeakSet(), _SpoListItemGetCommand_initTel
|
|
|
109
100
|
option: '--listUrl [listUrl]'
|
|
110
101
|
}, {
|
|
111
102
|
option: '--fields [fields]'
|
|
112
|
-
}, {
|
|
113
|
-
option: '-p, --properties [properties]'
|
|
114
103
|
}, {
|
|
115
104
|
option: '--withPermissions'
|
|
116
105
|
});
|
|
@@ -135,7 +124,7 @@ _SpoListItemGetCommand_instances = new WeakSet(), _SpoListItemGetCommand_initTel
|
|
|
135
124
|
return true;
|
|
136
125
|
});
|
|
137
126
|
}, _SpoListItemGetCommand_initTypes = function _SpoListItemGetCommand_initTypes() {
|
|
138
|
-
this.types.string.push('webUrl', 'listId', 'listTitle', 'id', 'uniqueId', 'fields'
|
|
127
|
+
this.types.string.push('webUrl', 'listId', 'listTitle', 'id', 'uniqueId', 'fields');
|
|
139
128
|
}, _SpoListItemGetCommand_initOptionSets = function _SpoListItemGetCommand_initOptionSets() {
|
|
140
129
|
this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['id', 'uniqueId'] });
|
|
141
130
|
};
|
|
@@ -72,6 +72,7 @@ export default {
|
|
|
72
72
|
FILE_MOVE: `${prefix} file move`,
|
|
73
73
|
FILE_REMOVE: `${prefix} file remove`,
|
|
74
74
|
FILE_RENAME: `${prefix} file rename`,
|
|
75
|
+
FILE_UNARCHIVE: `${prefix} file unarchive`,
|
|
75
76
|
FILE_RETENTIONLABEL_ENSURE: `${prefix} file retentionlabel ensure`,
|
|
76
77
|
FILE_RETENTIONLABEL_REMOVE: `${prefix} file retentionlabel remove`,
|
|
77
78
|
FILE_ROLEASSIGNMENT_ADD: `${prefix} file roleassignment add`,
|
|
@@ -85,7 +86,6 @@ export default {
|
|
|
85
86
|
FILE_SHARINGLINK_LIST: `${prefix} file sharinglink list`,
|
|
86
87
|
FILE_SHARINGLINK_REMOVE: `${prefix} file sharinglink remove`,
|
|
87
88
|
FILE_SHARINGLINK_SET: `${prefix} file sharinglink set`,
|
|
88
|
-
FILE_UNARCHIVE: `${prefix} file unarchive`,
|
|
89
89
|
FILE_VERSION_CLEAR: `${prefix} file version clear`,
|
|
90
90
|
FILE_VERSION_GET: `${prefix} file version get`,
|
|
91
91
|
FILE_VERSION_KEEP: `${prefix} file version keep`,
|
|
@@ -112,6 +112,7 @@ export default {
|
|
|
112
112
|
FOLDER_SHARINGLINK_LIST: `${prefix} folder sharinglink list`,
|
|
113
113
|
FOLDER_SHARINGLINK_REMOVE: `${prefix} folder sharinglink remove`,
|
|
114
114
|
FOLDER_SHARINGLINK_SET: `${prefix} folder sharinglink set`,
|
|
115
|
+
FOLDER_UNARCHIVE: `${prefix} folder unarchive`,
|
|
115
116
|
GET: `${prefix} get`,
|
|
116
117
|
GROUP_ADD: `${prefix} group add`,
|
|
117
118
|
GROUP_GET: `${prefix} group get`,
|
|
@@ -1,14 +1,30 @@
|
|
|
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 _TeamsChannelAddCommand_instances, _TeamsChannelAddCommand_initTelemetry, _TeamsChannelAddCommand_initOptions, _TeamsChannelAddCommand_initValidators, _TeamsChannelAddCommand_initOptionSets;
|
|
7
1
|
import request from '../../../../request.js';
|
|
8
2
|
import { validation } from '../../../../utils/validation.js';
|
|
9
3
|
import GraphCommand from "../../../base/GraphCommand.js";
|
|
10
4
|
import commands from '../../commands.js';
|
|
11
5
|
import { teams } from '../../../../utils/teams.js';
|
|
6
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export const options = z.strictObject({
|
|
9
|
+
...globalOptionsZod.shape,
|
|
10
|
+
teamId: z.string()
|
|
11
|
+
.refine(val => validation.isValidGuid(val), {
|
|
12
|
+
message: 'The value must be a valid GUID.'
|
|
13
|
+
})
|
|
14
|
+
.optional()
|
|
15
|
+
.alias('i'),
|
|
16
|
+
teamName: z.string()
|
|
17
|
+
.optional(),
|
|
18
|
+
name: z.string()
|
|
19
|
+
.alias('n'),
|
|
20
|
+
description: z.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.alias('d'),
|
|
23
|
+
type: z.enum(['standard', 'private', 'shared'])
|
|
24
|
+
.optional(),
|
|
25
|
+
owner: z.string()
|
|
26
|
+
.optional()
|
|
27
|
+
});
|
|
12
28
|
class TeamsChannelAddCommand extends GraphCommand {
|
|
13
29
|
get name() {
|
|
14
30
|
return commands.CHANNEL_ADD;
|
|
@@ -16,13 +32,30 @@ class TeamsChannelAddCommand extends GraphCommand {
|
|
|
16
32
|
get description() {
|
|
17
33
|
return 'Adds a channel to the specified Microsoft Teams team';
|
|
18
34
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
get schema() {
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
getRefinedSchema(schema) {
|
|
39
|
+
return schema
|
|
40
|
+
.refine(opts => [opts.teamId, opts.teamName].filter(x => x !== undefined).length === 1, {
|
|
41
|
+
message: 'Specify either teamId or teamName, but not both.',
|
|
42
|
+
params: {
|
|
43
|
+
customCode: 'optionSet',
|
|
44
|
+
options: ['teamId', 'teamName']
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.refine(opts => !((opts.type === 'private' || opts.type === 'shared') && !opts.owner), {
|
|
48
|
+
message: 'Specify owner when creating a private or shared channel.',
|
|
49
|
+
params: {
|
|
50
|
+
customCode: 'required'
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.refine(opts => !((opts.type !== 'private' && opts.type !== 'shared') && opts.owner), {
|
|
54
|
+
message: 'Specify owner only when creating a private or shared channel.',
|
|
55
|
+
params: {
|
|
56
|
+
customCode: 'required'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
26
59
|
}
|
|
27
60
|
async commandAction(logger, args) {
|
|
28
61
|
try {
|
|
@@ -66,49 +99,5 @@ class TeamsChannelAddCommand extends GraphCommand {
|
|
|
66
99
|
return request.post(requestOptions);
|
|
67
100
|
}
|
|
68
101
|
}
|
|
69
|
-
_TeamsChannelAddCommand_instances = new WeakSet(), _TeamsChannelAddCommand_initTelemetry = function _TeamsChannelAddCommand_initTelemetry() {
|
|
70
|
-
this.telemetry.push((args) => {
|
|
71
|
-
Object.assign(this.telemetryProperties, {
|
|
72
|
-
description: typeof args.options.description !== 'undefined',
|
|
73
|
-
teamId: typeof args.options.teamId !== 'undefined',
|
|
74
|
-
teamName: typeof args.options.teamName !== 'undefined',
|
|
75
|
-
type: args.options.type || 'standard',
|
|
76
|
-
owner: typeof args.options.owner !== 'undefined'
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}, _TeamsChannelAddCommand_initOptions = function _TeamsChannelAddCommand_initOptions() {
|
|
80
|
-
this.options.unshift({
|
|
81
|
-
option: '-i, --teamId [teamId]'
|
|
82
|
-
}, {
|
|
83
|
-
option: '--teamName [teamName]'
|
|
84
|
-
}, {
|
|
85
|
-
option: '-n, --name <name>'
|
|
86
|
-
}, {
|
|
87
|
-
option: '-d, --description [description]'
|
|
88
|
-
}, {
|
|
89
|
-
option: '--type [type]',
|
|
90
|
-
autocomplete: ['standard', 'private', 'shared']
|
|
91
|
-
}, {
|
|
92
|
-
option: '--owner [owner]'
|
|
93
|
-
});
|
|
94
|
-
}, _TeamsChannelAddCommand_initValidators = function _TeamsChannelAddCommand_initValidators() {
|
|
95
|
-
this.validators.push(async (args) => {
|
|
96
|
-
if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
|
|
97
|
-
return `${args.options.teamId} is not a valid GUID`;
|
|
98
|
-
}
|
|
99
|
-
if (args.options.type && ['standard', 'private', 'shared'].indexOf(args.options.type) === -1) {
|
|
100
|
-
return `${args.options.type} is not a valid type value. Allowed values standard|private|shared.`;
|
|
101
|
-
}
|
|
102
|
-
if ((args.options.type === 'private' || args.options.type === 'shared') && !args.options.owner) {
|
|
103
|
-
return `Specify owner when creating a ${args.options.type} channel.`;
|
|
104
|
-
}
|
|
105
|
-
if ((args.options.type !== 'private' && args.options.type !== 'shared') && args.options.owner) {
|
|
106
|
-
return `Specify owner only when creating a private or shared channel.`;
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
});
|
|
110
|
-
}, _TeamsChannelAddCommand_initOptionSets = function _TeamsChannelAddCommand_initOptionSets() {
|
|
111
|
-
this.optionSets.push({ options: ['teamId', 'teamName'] });
|
|
112
|
-
};
|
|
113
102
|
export default new TeamsChannelAddCommand();
|
|
114
103
|
//# sourceMappingURL=channel-add.js.map
|
|
@@ -1,14 +1,30 @@
|
|
|
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 _TeamsChannelGetCommand_instances, _TeamsChannelGetCommand_initTelemetry, _TeamsChannelGetCommand_initOptions, _TeamsChannelGetCommand_initValidators, _TeamsChannelGetCommand_initOptionSets;
|
|
7
1
|
import request from '../../../../request.js';
|
|
8
2
|
import { validation } from '../../../../utils/validation.js';
|
|
9
3
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
4
|
import commands from '../../commands.js';
|
|
11
5
|
import { teams } from '../../../../utils/teams.js';
|
|
6
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export const options = z.strictObject({
|
|
9
|
+
...globalOptionsZod.shape,
|
|
10
|
+
teamId: z.string()
|
|
11
|
+
.refine(val => validation.isValidGuid(val), {
|
|
12
|
+
message: 'The value must be a valid GUID.'
|
|
13
|
+
})
|
|
14
|
+
.optional(),
|
|
15
|
+
teamName: z.string()
|
|
16
|
+
.optional(),
|
|
17
|
+
id: z.string()
|
|
18
|
+
.refine(val => validation.isValidTeamsChannelId(val), {
|
|
19
|
+
message: 'The value is not a valid Teams channel id.'
|
|
20
|
+
})
|
|
21
|
+
.optional()
|
|
22
|
+
.alias('i'),
|
|
23
|
+
name: z.string()
|
|
24
|
+
.optional(),
|
|
25
|
+
primary: z.boolean()
|
|
26
|
+
.optional()
|
|
27
|
+
});
|
|
12
28
|
class TeamsChannelGetCommand extends GraphCommand {
|
|
13
29
|
get name() {
|
|
14
30
|
return commands.CHANNEL_GET;
|
|
@@ -16,13 +32,25 @@ class TeamsChannelGetCommand extends GraphCommand {
|
|
|
16
32
|
get description() {
|
|
17
33
|
return 'Gets information about the specific Microsoft Teams team channel';
|
|
18
34
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
get schema() {
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
getRefinedSchema(schema) {
|
|
39
|
+
return schema
|
|
40
|
+
.refine(opts => [opts.teamId, opts.teamName].filter(x => x !== undefined).length === 1, {
|
|
41
|
+
message: 'Specify either teamId or teamName, but not both.',
|
|
42
|
+
params: {
|
|
43
|
+
customCode: 'optionSet',
|
|
44
|
+
options: ['teamId', 'teamName']
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.refine(opts => [opts.id, opts.name, opts.primary].filter(x => x !== undefined).length === 1, {
|
|
48
|
+
message: 'Specify either id, name, or primary, but not both.',
|
|
49
|
+
params: {
|
|
50
|
+
customCode: 'optionSet',
|
|
51
|
+
options: ['id', 'name', 'primary']
|
|
52
|
+
}
|
|
53
|
+
});
|
|
26
54
|
}
|
|
27
55
|
async commandAction(logger, args) {
|
|
28
56
|
try {
|
|
@@ -48,40 +76,5 @@ class TeamsChannelGetCommand extends GraphCommand {
|
|
|
48
76
|
}
|
|
49
77
|
}
|
|
50
78
|
}
|
|
51
|
-
_TeamsChannelGetCommand_instances = new WeakSet(), _TeamsChannelGetCommand_initTelemetry = function _TeamsChannelGetCommand_initTelemetry() {
|
|
52
|
-
this.telemetry.push((args) => {
|
|
53
|
-
Object.assign(this.telemetryProperties, {
|
|
54
|
-
teamId: typeof args.options.teamId !== 'undefined',
|
|
55
|
-
teamName: typeof args.options.teamName !== 'undefined',
|
|
56
|
-
id: typeof args.options.id !== 'undefined',
|
|
57
|
-
name: typeof args.options.name !== 'undefined',
|
|
58
|
-
primary: !!args.options.primary
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}, _TeamsChannelGetCommand_initOptions = function _TeamsChannelGetCommand_initOptions() {
|
|
62
|
-
this.options.unshift({
|
|
63
|
-
option: '--teamId [teamId]'
|
|
64
|
-
}, {
|
|
65
|
-
option: '--teamName [teamName]'
|
|
66
|
-
}, {
|
|
67
|
-
option: '-i, --id [id]'
|
|
68
|
-
}, {
|
|
69
|
-
option: '--name [name]'
|
|
70
|
-
}, {
|
|
71
|
-
option: '--primary'
|
|
72
|
-
});
|
|
73
|
-
}, _TeamsChannelGetCommand_initValidators = function _TeamsChannelGetCommand_initValidators() {
|
|
74
|
-
this.validators.push(async (args) => {
|
|
75
|
-
if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
|
|
76
|
-
return `${args.options.teamId} is not a valid GUID`;
|
|
77
|
-
}
|
|
78
|
-
if (args.options.id && !validation.isValidTeamsChannelId(args.options.id)) {
|
|
79
|
-
return `${args.options.id} is not a valid Teams channel id`;
|
|
80
|
-
}
|
|
81
|
-
return true;
|
|
82
|
-
});
|
|
83
|
-
}, _TeamsChannelGetCommand_initOptionSets = function _TeamsChannelGetCommand_initOptionSets() {
|
|
84
|
-
this.optionSets.push({ options: ['teamId', 'teamName'] }, { options: ['id', 'name', 'primary'] });
|
|
85
|
-
};
|
|
86
79
|
export default new TeamsChannelGetCommand();
|
|
87
80
|
//# sourceMappingURL=channel-get.js.map
|
|
@@ -1,14 +1,24 @@
|
|
|
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 _TeamsChannelListCommand_instances, _TeamsChannelListCommand_initTelemetry, _TeamsChannelListCommand_initOptions, _TeamsChannelListCommand_initValidators, _TeamsChannelListCommand_initOptionSets;
|
|
7
1
|
import { odata } from '../../../../utils/odata.js';
|
|
8
2
|
import { teams } from '../../../../utils/teams.js';
|
|
9
3
|
import { validation } from '../../../../utils/validation.js';
|
|
10
4
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
5
|
import commands from '../../commands.js';
|
|
6
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export const options = z.strictObject({
|
|
9
|
+
...globalOptionsZod.shape,
|
|
10
|
+
teamId: z.string()
|
|
11
|
+
.refine(val => validation.isValidGuid(val), {
|
|
12
|
+
message: 'The value must be a valid GUID.'
|
|
13
|
+
})
|
|
14
|
+
.optional()
|
|
15
|
+
.alias('i'),
|
|
16
|
+
teamName: z.string()
|
|
17
|
+
.optional(),
|
|
18
|
+
type: z.enum(['standard', 'private', 'shared'])
|
|
19
|
+
.optional()
|
|
20
|
+
.transform(v => v?.toLowerCase())
|
|
21
|
+
});
|
|
12
22
|
class TeamsChannelListCommand extends GraphCommand {
|
|
13
23
|
get name() {
|
|
14
24
|
return commands.CHANNEL_LIST;
|
|
@@ -19,13 +29,18 @@ class TeamsChannelListCommand extends GraphCommand {
|
|
|
19
29
|
defaultProperties() {
|
|
20
30
|
return ['id', 'displayName'];
|
|
21
31
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
get schema() {
|
|
33
|
+
return options;
|
|
34
|
+
}
|
|
35
|
+
getRefinedSchema(schema) {
|
|
36
|
+
return schema
|
|
37
|
+
.refine(opts => [opts.teamId, opts.teamName].filter(x => x !== undefined).length === 1, {
|
|
38
|
+
message: 'Specify either teamId or teamName, but not both.',
|
|
39
|
+
params: {
|
|
40
|
+
customCode: 'optionSet',
|
|
41
|
+
options: ['teamId', 'teamName']
|
|
42
|
+
}
|
|
43
|
+
});
|
|
29
44
|
}
|
|
30
45
|
async getTeamId(args) {
|
|
31
46
|
if (args.options.teamId) {
|
|
@@ -48,34 +63,5 @@ class TeamsChannelListCommand extends GraphCommand {
|
|
|
48
63
|
}
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
|
-
_TeamsChannelListCommand_instances = new WeakSet(), _TeamsChannelListCommand_initTelemetry = function _TeamsChannelListCommand_initTelemetry() {
|
|
52
|
-
this.telemetry.push((args) => {
|
|
53
|
-
Object.assign(this.telemetryProperties, {
|
|
54
|
-
teamId: typeof args.options.teamId !== 'undefined',
|
|
55
|
-
teamName: typeof args.options.teamName !== 'undefined'
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}, _TeamsChannelListCommand_initOptions = function _TeamsChannelListCommand_initOptions() {
|
|
59
|
-
this.options.unshift({
|
|
60
|
-
option: '-i, --teamId [teamId]'
|
|
61
|
-
}, {
|
|
62
|
-
option: '--teamName [teamName]'
|
|
63
|
-
}, {
|
|
64
|
-
option: '--type [type]',
|
|
65
|
-
autocomplete: ['standard', 'private', 'shared']
|
|
66
|
-
});
|
|
67
|
-
}, _TeamsChannelListCommand_initValidators = function _TeamsChannelListCommand_initValidators() {
|
|
68
|
-
this.validators.push(async (args) => {
|
|
69
|
-
if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
|
|
70
|
-
return `${args.options.teamId} is not a valid GUID`;
|
|
71
|
-
}
|
|
72
|
-
if (args.options.type && ['standard', 'private', 'shared'].indexOf(args.options.type.toLowerCase()) === -1) {
|
|
73
|
-
return `${args.options.type} is not a valid type value. Allowed values standard|private|shared`;
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
});
|
|
77
|
-
}, _TeamsChannelListCommand_initOptionSets = function _TeamsChannelListCommand_initOptionSets() {
|
|
78
|
-
this.optionSets.push({ options: ['teamId', 'teamName'] });
|
|
79
|
-
};
|
|
80
66
|
export default new TeamsChannelListCommand();
|
|
81
67
|
//# sourceMappingURL=channel-list.js.map
|