@pnp/cli-microsoft365 9.0.0-beta.2f8dd1e → 9.0.0-beta.62575a1
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/.eslintrc.cjs +1 -0
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Auth.js +1 -9
- package/dist/chili/chili.js +0 -23
- package/dist/cli/cli.js +1 -63
- package/dist/m365/commands/setup.js +0 -4
- package/dist/m365/entra/commands/m365group/m365group-set.js +66 -29
- package/dist/m365/entra/commands/multitenant/MultitenantOrganization.js +2 -0
- package/dist/m365/entra/commands/multitenant/multitenant-get.js +32 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/external/commands/connection/connection-doctor.js +10 -24
- package/dist/m365/flow/commands/flow-list.js +23 -24
- package/dist/m365/graph/commands/subscription/subscription-add.js +4 -2
- package/dist/m365/spfx/commands/project/base-project-command.js +36 -126
- package/dist/m365/spo/commands/cdn/cdn-get.js +12 -15
- package/dist/m365/spo/commands/cdn/cdn-set.js +6 -4
- package/dist/m365/spo/commands/contenttype/contenttype-field-list.js +124 -0
- package/dist/m365/spo/commands/field/field-list.js +1 -1
- package/dist/m365/spo/commands/group/group-member-add.js +103 -99
- package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -3
- package/dist/m365/spo/commands/page/page-text-add.js +2 -3
- package/dist/m365/spo/commands/spo-search.js +3 -4
- package/dist/m365/spo/commands.js +1 -0
- package/dist/m365/teams/commands/meeting/meeting-attendancereport-get.js +119 -0
- package/dist/m365/teams/commands/message/message-remove.js +112 -0
- package/dist/m365/teams/commands.js +2 -0
- package/dist/m365/viva/commands/engage/engage-community-add.js +166 -0
- package/dist/m365/viva/commands.js +1 -0
- package/dist/utils/formatting.js +14 -1
- package/dist/utils/teams.js +49 -0
- package/dist/utils/validation.js +19 -0
- package/docs/docs/cmd/entra/m365group/m365group-set.mdx +37 -7
- package/docs/docs/cmd/entra/multitenant/multitenant-get.mdx +94 -0
- package/docs/docs/cmd/external/connection/connection-doctor.mdx +9 -9
- package/docs/docs/cmd/flow/flow-list.mdx +114 -56
- package/docs/docs/cmd/graph/subscription/subscription-add.mdx +18 -0
- package/docs/docs/cmd/spo/cdn/cdn-set.mdx +3 -3
- package/docs/docs/cmd/spo/contenttype/contenttype-field-list.mdx +172 -0
- package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +3 -3
- package/docs/docs/cmd/spo/field/field-list.mdx +3 -3
- package/docs/docs/cmd/spo/group/group-member-add.mdx +34 -27
- package/docs/docs/cmd/teams/meeting/meeting-attendancereport-get.mdx +138 -0
- package/docs/docs/cmd/teams/message/message-remove.mdx +63 -0
- package/docs/docs/cmd/viva/engage/engage-community-add.mdx +168 -0
- package/npm-shrinkwrap.json +0 -195
- package/package.json +2 -2
|
@@ -4,6 +4,7 @@ import { formatting } from '../../../../utils/formatting.js';
|
|
|
4
4
|
import { fsUtil } from '../../../../utils/fsUtil.js';
|
|
5
5
|
import AnonymousCommand from "../../../base/AnonymousCommand.js";
|
|
6
6
|
import { ScssFile, TsFile } from "./project-model/index.js";
|
|
7
|
+
import { CommandError } from '../../../../Command.js';
|
|
7
8
|
export class BaseProjectCommand extends AnonymousCommand {
|
|
8
9
|
constructor() {
|
|
9
10
|
super(...arguments);
|
|
@@ -31,105 +32,17 @@ export class BaseProjectCommand extends AnonymousCommand {
|
|
|
31
32
|
}
|
|
32
33
|
catch { }
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(copyAssetsJsonPath, 'utf-8'));
|
|
47
|
-
project.copyAssetsJson = JSON.parse(source);
|
|
48
|
-
project.copyAssetsJson.source = source;
|
|
49
|
-
}
|
|
50
|
-
catch { }
|
|
51
|
-
}
|
|
52
|
-
const deployAzureStorageJsonPath = path.join(projectRootPath, 'config/deploy-azure-storage.json');
|
|
53
|
-
if (fs.existsSync(deployAzureStorageJsonPath)) {
|
|
54
|
-
try {
|
|
55
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(deployAzureStorageJsonPath, 'utf-8'));
|
|
56
|
-
project.deployAzureStorageJson = JSON.parse(source);
|
|
57
|
-
project.deployAzureStorageJson.source = source;
|
|
58
|
-
}
|
|
59
|
-
catch { }
|
|
60
|
-
}
|
|
61
|
-
const packageJsonPath = path.join(projectRootPath, 'package.json');
|
|
62
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
63
|
-
try {
|
|
64
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
65
|
-
project.packageJson = JSON.parse(source);
|
|
66
|
-
project.packageJson.source = source;
|
|
67
|
-
}
|
|
68
|
-
catch { }
|
|
69
|
-
}
|
|
70
|
-
const packageSolutionJsonPath = path.join(projectRootPath, 'config/package-solution.json');
|
|
71
|
-
if (fs.existsSync(packageSolutionJsonPath)) {
|
|
72
|
-
try {
|
|
73
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(packageSolutionJsonPath, 'utf-8'));
|
|
74
|
-
project.packageSolutionJson = JSON.parse(source);
|
|
75
|
-
project.packageSolutionJson.source = source;
|
|
76
|
-
}
|
|
77
|
-
catch { }
|
|
78
|
-
}
|
|
79
|
-
const serveJsonPath = path.join(projectRootPath, 'config/serve.json');
|
|
80
|
-
if (fs.existsSync(serveJsonPath)) {
|
|
81
|
-
try {
|
|
82
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(serveJsonPath, 'utf-8'));
|
|
83
|
-
project.serveJson = JSON.parse(source);
|
|
84
|
-
project.serveJson.source = source;
|
|
85
|
-
}
|
|
86
|
-
catch { }
|
|
87
|
-
}
|
|
88
|
-
const tsConfigJsonPath = path.join(projectRootPath, 'tsconfig.json');
|
|
89
|
-
if (fs.existsSync(tsConfigJsonPath)) {
|
|
90
|
-
try {
|
|
91
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(tsConfigJsonPath, 'utf-8'));
|
|
92
|
-
project.tsConfigJson = JSON.parse(source);
|
|
93
|
-
project.tsConfigJson.source = source;
|
|
94
|
-
}
|
|
95
|
-
catch { }
|
|
96
|
-
}
|
|
97
|
-
const tsLintJsonPath = path.join(projectRootPath, 'config/tslint.json');
|
|
98
|
-
if (fs.existsSync(tsLintJsonPath)) {
|
|
99
|
-
try {
|
|
100
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(tsLintJsonPath, 'utf-8'));
|
|
101
|
-
project.tsLintJson = JSON.parse(source);
|
|
102
|
-
project.tsLintJson.source = source;
|
|
103
|
-
}
|
|
104
|
-
catch { }
|
|
105
|
-
}
|
|
106
|
-
const tsLintJsonRootPath = path.join(projectRootPath, 'tslint.json');
|
|
107
|
-
if (fs.existsSync(tsLintJsonRootPath)) {
|
|
108
|
-
try {
|
|
109
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(tsLintJsonRootPath, 'utf-8'));
|
|
110
|
-
project.tsLintJsonRoot = JSON.parse(source);
|
|
111
|
-
project.tsLintJsonRoot.source = source;
|
|
112
|
-
}
|
|
113
|
-
catch { }
|
|
114
|
-
}
|
|
115
|
-
const writeManifestJsonPath = path.join(projectRootPath, 'config/write-manifests.json');
|
|
116
|
-
if (fs.existsSync(writeManifestJsonPath)) {
|
|
117
|
-
try {
|
|
118
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(writeManifestJsonPath, 'utf-8'));
|
|
119
|
-
project.writeManifestsJson = JSON.parse(source);
|
|
120
|
-
project.writeManifestsJson.source = source;
|
|
121
|
-
}
|
|
122
|
-
catch { }
|
|
123
|
-
}
|
|
124
|
-
const yoRcJsonPath = path.join(projectRootPath, '.yo-rc.json');
|
|
125
|
-
if (fs.existsSync(yoRcJsonPath)) {
|
|
126
|
-
try {
|
|
127
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(yoRcJsonPath, 'utf-8'));
|
|
128
|
-
project.yoRcJson = JSON.parse(source);
|
|
129
|
-
project.yoRcJson.source = source;
|
|
130
|
-
}
|
|
131
|
-
catch { }
|
|
132
|
-
}
|
|
35
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'config.json'), project, 'configJson');
|
|
36
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'copy-assets.json'), project, 'copyAssetsJson');
|
|
37
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'deploy-azure-storage.json'), project, 'deployAzureStorageJson');
|
|
38
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'package.json'), project, 'packageJson');
|
|
39
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'package-solution.json'), project, 'packageSolutionJson');
|
|
40
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'serve.json'), project, 'serveJson');
|
|
41
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'tsconfig.json'), project, 'tsConfigJson');
|
|
42
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'tslint.json'), project, 'tsLintJson');
|
|
43
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'tslint.json'), project, 'tsLintJsonRoot');
|
|
44
|
+
this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'write-manifests.json'), project, 'writeManifestsJson');
|
|
45
|
+
this.readAndParseJsonFile(path.join(projectRootPath, '.yo-rc.json'), project, 'yoRcJson');
|
|
133
46
|
const gulpfileJsPath = path.join(projectRootPath, 'gulpfile.js');
|
|
134
47
|
if (fs.existsSync(gulpfileJsPath)) {
|
|
135
48
|
project.gulpfileJs = {
|
|
@@ -141,33 +54,9 @@ export class BaseProjectCommand extends AnonymousCommand {
|
|
|
141
54
|
project.esLintRcJs = new TsFile(esLintRcJsPath);
|
|
142
55
|
}
|
|
143
56
|
project.vsCode = {};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(vsCodeSettingsPath, 'utf-8'));
|
|
148
|
-
project.vsCode.settingsJson = JSON.parse(source);
|
|
149
|
-
project.vsCode.settingsJson.source = source;
|
|
150
|
-
}
|
|
151
|
-
catch { }
|
|
152
|
-
}
|
|
153
|
-
const vsCodeExtensionsPath = path.join(projectRootPath, '.vscode', 'extensions.json');
|
|
154
|
-
if (fs.existsSync(vsCodeExtensionsPath)) {
|
|
155
|
-
try {
|
|
156
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(vsCodeExtensionsPath, 'utf-8'));
|
|
157
|
-
project.vsCode.extensionsJson = JSON.parse(source);
|
|
158
|
-
project.vsCode.extensionsJson.source = source;
|
|
159
|
-
}
|
|
160
|
-
catch { }
|
|
161
|
-
}
|
|
162
|
-
const vsCodeLaunchPath = path.join(projectRootPath, '.vscode', 'launch.json');
|
|
163
|
-
if (fs.existsSync(vsCodeLaunchPath)) {
|
|
164
|
-
try {
|
|
165
|
-
const source = formatting.removeSingleLineComments(fs.readFileSync(vsCodeLaunchPath, 'utf-8'));
|
|
166
|
-
project.vsCode.launchJson = JSON.parse(source);
|
|
167
|
-
project.vsCode.launchJson.source = source;
|
|
168
|
-
}
|
|
169
|
-
catch { }
|
|
170
|
-
}
|
|
57
|
+
this.readAndParseJsonFile(path.join(projectRootPath, '.vscode', 'settings.json'), project, 'vsCode.settingsJson');
|
|
58
|
+
this.readAndParseJsonFile(path.join(projectRootPath, '.vscode', 'extensions.json'), project, 'vsCode.extensionsJson');
|
|
59
|
+
this.readAndParseJsonFile(path.join(projectRootPath, '.vscode', 'launch.json'), project, 'vsCode.launchJson');
|
|
171
60
|
const srcFiles = fsUtil.readdirR(path.join(projectRootPath, 'src'));
|
|
172
61
|
const manifestFiles = srcFiles.filter(f => f.endsWith('.manifest.json'));
|
|
173
62
|
const manifests = manifestFiles.map((f) => {
|
|
@@ -233,5 +122,26 @@ export class BaseProjectCommand extends AnonymousCommand {
|
|
|
233
122
|
catch { }
|
|
234
123
|
return undefined;
|
|
235
124
|
}
|
|
125
|
+
readAndParseJsonFile(filePath, project, keyPath) {
|
|
126
|
+
if (fs.existsSync(filePath)) {
|
|
127
|
+
try {
|
|
128
|
+
const source = formatting.removeSingleLineComments(fs.readFileSync(filePath, 'utf-8'));
|
|
129
|
+
const keys = keyPath.split('.');
|
|
130
|
+
let current = project;
|
|
131
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
132
|
+
current = current[keys[i]];
|
|
133
|
+
}
|
|
134
|
+
const finalKey = keys[keys.length - 1];
|
|
135
|
+
current[finalKey] = JSON.parse(source);
|
|
136
|
+
if (typeof current[finalKey] === 'object' && current[finalKey] !== null) {
|
|
137
|
+
current[finalKey].source = source;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
throw new CommandError(`The file ${filePath} is not a valid JSON file or is not utf-8 encoded. Error: ${error}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return project;
|
|
145
|
+
}
|
|
236
146
|
}
|
|
237
147
|
//# sourceMappingURL=base-project-command.js.map
|
|
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
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
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _SpoCdnGetCommand_instances, _SpoCdnGetCommand_initTelemetry, _SpoCdnGetCommand_initOptions, _SpoCdnGetCommand_initValidators;
|
|
6
|
+
var _SpoCdnGetCommand_instances, _SpoCdnGetCommand_initTelemetry, _SpoCdnGetCommand_initOptions, _SpoCdnGetCommand_initValidators, _SpoCdnGetCommand_initTypes;
|
|
7
7
|
import config from '../../../../config.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
9
|
import { spo } from '../../../../utils/spo.js';
|
|
@@ -19,9 +19,11 @@ class SpoCdnGetCommand extends SpoCommand {
|
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
_SpoCdnGetCommand_instances.add(this);
|
|
22
|
+
this.validTypes = ['Public', 'Private'];
|
|
22
23
|
__classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initTelemetry).call(this);
|
|
23
24
|
__classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initOptions).call(this);
|
|
24
25
|
__classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initValidators).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initTypes).call(this);
|
|
25
27
|
}
|
|
26
28
|
async commandAction(logger, args) {
|
|
27
29
|
const cdnTypeString = args.options.type || 'Public';
|
|
@@ -48,15 +50,11 @@ class SpoCdnGetCommand extends SpoCommand {
|
|
|
48
50
|
if (response.ErrorInfo) {
|
|
49
51
|
throw response.ErrorInfo.ErrorMessage;
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
await logger.logToStderr(`${(cdnType === 0 ? 'Public' : 'Private')} CDN at ${spoAdminUrl} is ${(result === true ? 'enabled' : 'disabled')}`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
await logger.logToStderr(result);
|
|
58
|
-
}
|
|
53
|
+
const result = json[json.length - 1];
|
|
54
|
+
if (this.verbose) {
|
|
55
|
+
await logger.logToStderr(`${cdnType === 0 ? 'Public' : 'Private'} CDN at ${spoAdminUrl} is ${result === true ? 'enabled' : 'disabled'}`);
|
|
59
56
|
}
|
|
57
|
+
await logger.log(result);
|
|
60
58
|
}
|
|
61
59
|
catch (err) {
|
|
62
60
|
this.handleRejectedPromise(err);
|
|
@@ -72,18 +70,17 @@ _SpoCdnGetCommand_instances = new WeakSet(), _SpoCdnGetCommand_initTelemetry = f
|
|
|
72
70
|
}, _SpoCdnGetCommand_initOptions = function _SpoCdnGetCommand_initOptions() {
|
|
73
71
|
this.options.unshift({
|
|
74
72
|
option: '-t, --type [type]',
|
|
75
|
-
autocomplete:
|
|
73
|
+
autocomplete: this.validTypes
|
|
76
74
|
});
|
|
77
75
|
}, _SpoCdnGetCommand_initValidators = function _SpoCdnGetCommand_initValidators() {
|
|
78
76
|
this.validators.push(async (args) => {
|
|
79
|
-
if (args.options.type) {
|
|
80
|
-
|
|
81
|
-
args.options.type !== 'Private') {
|
|
82
|
-
return `${args.options.type} is not a valid CDN type. Allowed values are Public|Private`;
|
|
83
|
-
}
|
|
77
|
+
if (args.options.type && !this.validTypes.includes(args.options.type)) {
|
|
78
|
+
return `'${args.options.type}' is not a valid CDN type. Allowed values are: ${this.validTypes.join(', ')}.`;
|
|
84
79
|
}
|
|
85
80
|
return true;
|
|
86
81
|
});
|
|
82
|
+
}, _SpoCdnGetCommand_initTypes = function _SpoCdnGetCommand_initTypes() {
|
|
83
|
+
this.types.string.push('type');
|
|
87
84
|
};
|
|
88
85
|
export default new SpoCdnGetCommand();
|
|
89
86
|
//# sourceMappingURL=cdn-get.js.map
|
|
@@ -19,6 +19,7 @@ class SpoCdnSetCommand extends SpoCommand {
|
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
_SpoCdnSetCommand_instances.add(this);
|
|
22
|
+
this.validTypes = ['Public', 'Private', 'Both'];
|
|
22
23
|
__classPrivateFieldGet(this, _SpoCdnSetCommand_instances, "m", _SpoCdnSetCommand_initTelemetry).call(this);
|
|
23
24
|
__classPrivateFieldGet(this, _SpoCdnSetCommand_instances, "m", _SpoCdnSetCommand_initOptions).call(this);
|
|
24
25
|
__classPrivateFieldGet(this, _SpoCdnSetCommand_instances, "m", _SpoCdnSetCommand_initTypes).call(this);
|
|
@@ -104,7 +105,7 @@ _SpoCdnSetCommand_instances = new WeakSet(), _SpoCdnSetCommand_initTelemetry = f
|
|
|
104
105
|
Object.assign(this.telemetryProperties, {
|
|
105
106
|
cdnType: args.options.type || 'Public',
|
|
106
107
|
enabled: args.options.enabled,
|
|
107
|
-
noDefaultOrigins:
|
|
108
|
+
noDefaultOrigins: !!args.options.noDefaultOrigins
|
|
108
109
|
});
|
|
109
110
|
});
|
|
110
111
|
}, _SpoCdnSetCommand_initOptions = function _SpoCdnSetCommand_initOptions() {
|
|
@@ -113,18 +114,19 @@ _SpoCdnSetCommand_instances = new WeakSet(), _SpoCdnSetCommand_initTelemetry = f
|
|
|
113
114
|
autocomplete: ['true', 'false']
|
|
114
115
|
}, {
|
|
115
116
|
option: '-t, --type [type]',
|
|
116
|
-
autocomplete:
|
|
117
|
+
autocomplete: this.validTypes
|
|
117
118
|
}, {
|
|
118
119
|
option: '--noDefaultOrigins'
|
|
119
120
|
});
|
|
120
121
|
}, _SpoCdnSetCommand_initTypes = function _SpoCdnSetCommand_initTypes() {
|
|
121
|
-
this.types.boolean.push('enabled');
|
|
122
|
+
this.types.boolean.push('enabled', 'noDefaultOrigins');
|
|
123
|
+
this.types.string.push('type');
|
|
122
124
|
}, _SpoCdnSetCommand_initValidators = function _SpoCdnSetCommand_initValidators() {
|
|
123
125
|
this.validators.push(async (args) => {
|
|
124
126
|
if (args.options.type) {
|
|
125
127
|
if (args.options.type !== 'Public' && args.options.type !== 'Both' &&
|
|
126
128
|
args.options.type !== 'Private') {
|
|
127
|
-
return `${args.options.type} is not a valid CDN type. Allowed values are
|
|
129
|
+
return `${args.options.type} is not a valid CDN type. Allowed values are ${this.validTypes.join(', ')}.`;
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
return true;
|
|
@@ -0,0 +1,124 @@
|
|
|
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 _SpoContentTypeFieldListCommand_instances, _SpoContentTypeFieldListCommand_initTelemetry, _SpoContentTypeFieldListCommand_initOptions, _SpoContentTypeFieldListCommand_initValidators, _SpoContentTypeFieldListCommand_initTypes, _SpoContentTypeFieldListCommand_initOptionSets;
|
|
7
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
8
|
+
import { odata } from '../../../../utils/odata.js';
|
|
9
|
+
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
10
|
+
import { validation } from '../../../../utils/validation.js';
|
|
11
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
|
+
import commands from '../../commands.js';
|
|
13
|
+
class SpoContentTypeFieldListCommand extends SpoCommand {
|
|
14
|
+
get name() {
|
|
15
|
+
return commands.CONTENTTYPE_FIELD_LIST;
|
|
16
|
+
}
|
|
17
|
+
get description() {
|
|
18
|
+
return 'Lists fields for a given site or list content type';
|
|
19
|
+
}
|
|
20
|
+
defaultProperties() {
|
|
21
|
+
return ['Id', 'Title', 'InternalName', 'Hidden'];
|
|
22
|
+
}
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
_SpoContentTypeFieldListCommand_instances.add(this);
|
|
26
|
+
__classPrivateFieldGet(this, _SpoContentTypeFieldListCommand_instances, "m", _SpoContentTypeFieldListCommand_initTelemetry).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _SpoContentTypeFieldListCommand_instances, "m", _SpoContentTypeFieldListCommand_initOptions).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _SpoContentTypeFieldListCommand_instances, "m", _SpoContentTypeFieldListCommand_initValidators).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _SpoContentTypeFieldListCommand_instances, "m", _SpoContentTypeFieldListCommand_initTypes).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _SpoContentTypeFieldListCommand_instances, "m", _SpoContentTypeFieldListCommand_initOptionSets).call(this);
|
|
31
|
+
}
|
|
32
|
+
async commandAction(logger, args) {
|
|
33
|
+
try {
|
|
34
|
+
if (this.verbose) {
|
|
35
|
+
await logger.logToStderr(`Retrieving fields for content type '${args.options.contentTypeId || args.options.contentTypeName}' in site ${args.options.webUrl}...`);
|
|
36
|
+
}
|
|
37
|
+
let requestUrl = `${args.options.webUrl}/_api/web`;
|
|
38
|
+
if (args.options.listId) {
|
|
39
|
+
requestUrl += `/lists(guid'${formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
40
|
+
}
|
|
41
|
+
else if (args.options.listTitle) {
|
|
42
|
+
requestUrl += `/lists/getByTitle('${formatting.encodeQueryParameter(args.options.listTitle)}')`;
|
|
43
|
+
}
|
|
44
|
+
else if (args.options.listUrl) {
|
|
45
|
+
const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
|
|
46
|
+
requestUrl += `/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
47
|
+
}
|
|
48
|
+
requestUrl += '/contentTypes';
|
|
49
|
+
const contentTypeId = await this.getContentTypeId(requestUrl, logger, args.options.contentTypeId, args.options.contentTypeName);
|
|
50
|
+
requestUrl += `('${formatting.encodeQueryParameter(contentTypeId)}')/fields`;
|
|
51
|
+
if (args.options.properties) {
|
|
52
|
+
requestUrl += `?$select=${args.options.properties}`;
|
|
53
|
+
}
|
|
54
|
+
const res = await odata.getAllItems(requestUrl);
|
|
55
|
+
await logger.log(res);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
this.handleRejectedODataJsonPromise(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async getContentTypeId(requestUrl, logger, contentTypeId, contentTypeName) {
|
|
62
|
+
if (contentTypeId) {
|
|
63
|
+
return contentTypeId;
|
|
64
|
+
}
|
|
65
|
+
if (this.verbose) {
|
|
66
|
+
await logger.logToStderr(`Retrieving content type id for content type '${contentTypeName}'.`);
|
|
67
|
+
}
|
|
68
|
+
const res = await odata.getAllItems(`${requestUrl}?$filter=Name eq '${formatting.encodeQueryParameter(contentTypeName)}'&$select=StringId`);
|
|
69
|
+
if (res.length === 0) {
|
|
70
|
+
throw `Content type with name ${contentTypeName} not found.`;
|
|
71
|
+
}
|
|
72
|
+
return res[0].StringId;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
_SpoContentTypeFieldListCommand_instances = new WeakSet(), _SpoContentTypeFieldListCommand_initTelemetry = function _SpoContentTypeFieldListCommand_initTelemetry() {
|
|
76
|
+
this.telemetry.push((args) => {
|
|
77
|
+
Object.assign(this.telemetryProperties, {
|
|
78
|
+
contentTypeId: typeof args.options.contentTypeId !== 'undefined',
|
|
79
|
+
contentTypeName: typeof args.options.contentTypeName !== 'undefined',
|
|
80
|
+
listId: typeof args.options.listId !== 'undefined',
|
|
81
|
+
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
82
|
+
listUrl: typeof args.options.listUrl !== 'undefined',
|
|
83
|
+
properties: typeof args.options.properties !== 'undefined'
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}, _SpoContentTypeFieldListCommand_initOptions = function _SpoContentTypeFieldListCommand_initOptions() {
|
|
87
|
+
this.options.unshift({
|
|
88
|
+
option: '-u, --webUrl <webUrl>'
|
|
89
|
+
}, {
|
|
90
|
+
option: '-i, --contentTypeId [contentTypeId]'
|
|
91
|
+
}, {
|
|
92
|
+
option: '-n, --contentTypeName [contentTypeName]'
|
|
93
|
+
}, {
|
|
94
|
+
option: '-l, --listTitle [listTitle]'
|
|
95
|
+
}, {
|
|
96
|
+
option: '--listId [listId]'
|
|
97
|
+
}, {
|
|
98
|
+
option: '--listUrl [listUrl]'
|
|
99
|
+
}, {
|
|
100
|
+
option: '-p, --properties [properties]'
|
|
101
|
+
});
|
|
102
|
+
}, _SpoContentTypeFieldListCommand_initValidators = function _SpoContentTypeFieldListCommand_initValidators() {
|
|
103
|
+
this.validators.push(async (args) => {
|
|
104
|
+
const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
|
|
105
|
+
if (isValidSharePointUrl !== true) {
|
|
106
|
+
return isValidSharePointUrl;
|
|
107
|
+
}
|
|
108
|
+
if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
|
|
109
|
+
return `${args.options.listId} is not a valid GUID for option 'listId'.`;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
});
|
|
113
|
+
}, _SpoContentTypeFieldListCommand_initTypes = function _SpoContentTypeFieldListCommand_initTypes() {
|
|
114
|
+
this.types.string.push('webUrl', 'contentTypeId', 'contentTypeName', 'listTitle', 'listId', 'listUrl', 'properties');
|
|
115
|
+
}, _SpoContentTypeFieldListCommand_initOptionSets = function _SpoContentTypeFieldListCommand_initOptionSets() {
|
|
116
|
+
this.optionSets.push({
|
|
117
|
+
options: ['contentTypeId', 'contentTypeName']
|
|
118
|
+
}, {
|
|
119
|
+
options: ['listId', 'listTitle', 'listUrl'],
|
|
120
|
+
runsWhen: (args) => args.options.listId || args.options.listTitle || args.options.listUrl
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
export default new SpoContentTypeFieldListCommand();
|
|
124
|
+
//# sourceMappingURL=contenttype-field-list.js.map
|
|
@@ -18,7 +18,7 @@ class SpoFieldListCommand extends SpoCommand {
|
|
|
18
18
|
return 'Retrieves columns for the specified list or site';
|
|
19
19
|
}
|
|
20
20
|
defaultProperties() {
|
|
21
|
-
return ['Id', 'Title', '
|
|
21
|
+
return ['Id', 'Title', 'InternalName', 'Hidden'];
|
|
22
22
|
}
|
|
23
23
|
constructor() {
|
|
24
24
|
super();
|