@sap/cli-core 2025.17.0 → 2025.20.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.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/cache/cache.js +16 -28
- package/cache/index.d.ts +2 -2
- package/cache/index.js +2 -12
- package/cache/secrets/SecretsStorageImpl.d.ts +2 -2
- package/cache/secrets/SecretsStorageImpl.js +18 -22
- package/cache/secrets/SecretsStorageSingleton.d.ts +1 -1
- package/cache/secrets/SecretsStorageSingleton.js +1 -5
- package/cache/secrets/types.d.ts +1 -1
- package/cache/secrets/types.js +1 -2
- package/cache/secrets/utils.d.ts +1 -1
- package/cache/secrets/utils.js +20 -27
- package/cache/utils.js +8 -15
- package/commands/config.command/cache.command/clean.command.d.ts +1 -1
- package/commands/config.command/cache.command/clean.command.js +10 -12
- package/commands/config.command/cache.command/index.d.ts +1 -1
- package/commands/config.command/cache.command/index.js +5 -10
- package/commands/config.command/cache.command/init.command/index.d.ts +1 -1
- package/commands/config.command/cache.command/init.command/index.js +29 -36
- package/commands/config.command/cache.command/init.command/utils.d.ts +1 -1
- package/commands/config.command/cache.command/init.command/utils.js +6 -13
- package/commands/config.command/cache.command/show.command.d.ts +1 -1
- package/commands/config.command/cache.command/show.command.js +7 -9
- package/commands/config.command/host.command.d.ts +1 -1
- package/commands/config.command/host.command.js +19 -23
- package/commands/config.command/index.d.ts +1 -1
- package/commands/config.command/index.js +5 -45
- package/commands/config.command/passcode.command.d.ts +1 -1
- package/commands/config.command/passcode.command.js +12 -16
- package/commands/config.command/secrets.command/check.command.d.ts +1 -2
- package/commands/config.command/secrets.command/check.command.js +10 -14
- package/commands/config.command/secrets.command/index.d.ts +1 -1
- package/commands/config.command/secrets.command/index.js +6 -11
- package/commands/config.command/secrets.command/refresh.command.d.ts +1 -1
- package/commands/config.command/secrets.command/refresh.command.js +5 -7
- package/commands/config.command/secrets.command/reset.command.d.ts +1 -1
- package/commands/config.command/secrets.command/reset.command.js +6 -8
- package/commands/config.command/secrets.command/show.command.d.ts +1 -1
- package/commands/config.command/secrets.command/show.command.js +8 -10
- package/commands/handler/authentication/index.d.ts +1 -1
- package/commands/handler/authentication/index.js +18 -21
- package/commands/handler/authentication/oauth/index.d.ts +1 -1
- package/commands/handler/authentication/oauth/index.js +13 -16
- package/commands/handler/authentication/oauth/secretsProvider/cache.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/cache.js +5 -9
- package/commands/handler/authentication/oauth/secretsProvider/file.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/file.js +20 -25
- package/commands/handler/authentication/oauth/secretsProvider/index.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/index.js +6 -10
- package/commands/handler/authentication/oauth/secretsProvider/options.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/options.js +25 -29
- package/commands/handler/authentication/oauth/tokenProvider/getToken.d.ts +1 -1
- package/commands/handler/authentication/oauth/tokenProvider/getToken.js +16 -20
- package/commands/handler/authentication/oauth/tokenProvider/index.d.ts +1 -1
- package/commands/handler/authentication/oauth/tokenProvider/index.js +7 -11
- package/commands/handler/authentication/oauth/tokenProvider/refreshToken.d.ts +1 -1
- package/commands/handler/authentication/oauth/tokenProvider/refreshToken.js +5 -9
- package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.d.ts +1 -1
- package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.js +19 -24
- package/commands/handler/authentication/oauth/tokenProvider/utils.js +30 -36
- package/commands/handler/authentication/oauth/utils.d.ts +1 -1
- package/commands/handler/authentication/oauth/utils.js +15 -24
- package/commands/handler/authentication/passcode/function.d.ts +1 -1
- package/commands/handler/authentication/passcode/function.js +11 -13
- package/commands/handler/authentication/passcode/index.d.ts +1 -1
- package/commands/handler/authentication/passcode/index.js +14 -17
- package/commands/handler/authentication/passcode/input.d.ts +1 -1
- package/commands/handler/authentication/passcode/input.js +13 -20
- package/commands/handler/authentication/passcode/setPasscode.d.ts +1 -1
- package/commands/handler/authentication/passcode/setPasscode.js +9 -13
- package/commands/handler/authentication/passcode/types.js +1 -2
- package/commands/handler/authentication/technicalJWT/cf.js +9 -11
- package/commands/handler/authentication/technicalJWT/exec.d.ts +5 -6
- package/commands/handler/authentication/technicalJWT/exec.js +15 -19
- package/commands/handler/authentication/technicalJWT/index.d.ts +1 -1
- package/commands/handler/authentication/technicalJWT/index.js +8 -12
- package/commands/handler/authentication/technicalJWT/types.d.ts +1 -1
- package/commands/handler/authentication/technicalJWT/types.js +1 -4
- package/commands/handler/authentication/technicalJWT/utils.js +20 -27
- package/commands/handler/authentication/utils.js +3 -7
- package/commands/handler/checkOptionsExistence.d.ts +1 -1
- package/commands/handler/checkOptionsExistence.js +5 -9
- package/commands/handler/error.d.ts +1 -1
- package/commands/handler/error.js +4 -8
- package/commands/handler/fail.d.ts +1 -1
- package/commands/handler/fail.js +3 -7
- package/commands/handler/fetch/fetch.d.ts +1 -1
- package/commands/handler/fetch/fetch.js +26 -27
- package/commands/handler/fetch/index.d.ts +1 -1
- package/commands/handler/fetch/index.js +10 -14
- package/commands/handler/fetch/utils.d.ts +2 -2
- package/commands/handler/fetch/utils.js +56 -75
- package/commands/handler/force.d.ts +1 -1
- package/commands/handler/force.js +8 -15
- package/commands/handler/index.d.ts +18 -18
- package/commands/handler/index.js +18 -39
- package/commands/handler/input/file.d.ts +1 -1
- package/commands/handler/input/file.js +22 -29
- package/commands/handler/input/index.d.ts +1 -1
- package/commands/handler/input/index.js +4 -8
- package/commands/handler/input/input.d.ts +1 -1
- package/commands/handler/input/input.js +16 -23
- package/commands/handler/mandatoryOptions.d.ts +1 -1
- package/commands/handler/mandatoryOptions.js +13 -17
- package/commands/handler/next.d.ts +1 -1
- package/commands/handler/next.js +4 -8
- package/commands/handler/options/env.d.ts +1 -1
- package/commands/handler/options/env.js +8 -12
- package/commands/handler/options/file.d.ts +1 -1
- package/commands/handler/options/file.js +8 -12
- package/commands/handler/options/index.d.ts +1 -1
- package/commands/handler/options/index.js +15 -19
- package/commands/handler/options/option.d.ts +1 -1
- package/commands/handler/options/option.js +12 -13
- package/commands/handler/options/utils.d.ts +4 -2
- package/commands/handler/options/utils.js +18 -26
- package/commands/handler/or.d.ts +1 -1
- package/commands/handler/or.js +3 -7
- package/commands/handler/parseArguments.d.ts +1 -1
- package/commands/handler/parseArguments.js +11 -15
- package/commands/handler/resilient.d.ts +1 -1
- package/commands/handler/resilient.js +3 -7
- package/commands/handler/root/index.d.ts +1 -1
- package/commands/handler/root/index.js +3 -7
- package/commands/handler/stackTrace.d.ts +1 -1
- package/commands/handler/stackTrace.js +3 -7
- package/commands/handler/succeed.d.ts +1 -1
- package/commands/handler/succeed.js +3 -7
- package/commands/handler/utils.d.ts +1 -1
- package/commands/handler/utils.js +17 -27
- package/commands/login.command.d.ts +1 -1
- package/commands/login.command.js +41 -45
- package/commands/logout.command.d.ts +1 -1
- package/commands/logout.command.js +15 -17
- package/commands/openAPI.command/index.d.ts +1 -1
- package/commands/openAPI.command/index.js +20 -24
- package/commands/openAPI.command/utils.d.ts +1 -1
- package/commands/openAPI.command/utils.js +47 -97
- package/commands/utils.d.ts +1 -1
- package/commands/utils.js +6 -11
- package/config/core.d.ts +1 -1
- package/config/core.js +12 -25
- package/config/index.d.ts +1 -1
- package/config/index.js +45 -49
- package/configureLoggers.js +2 -6
- package/constants.d.ts +1 -1
- package/constants.js +57 -63
- package/discovery/index.d.ts +1 -1
- package/discovery/index.js +32 -45
- package/discovery/utils.js +5 -12
- package/dwc/dwc.js +63 -76
- package/dwc/run.js +15 -19
- package/dwc/utils.d.ts +1 -1
- package/dwc/utils.js +43 -38
- package/index.d.ts +4 -4
- package/index.js +22 -68
- package/logger/index.d.ts +2 -2
- package/logger/index.js +17 -22
- package/logger/types.js +1 -2
- package/logger/utils.d.ts +1 -1
- package/logger/utils.js +4 -8
- package/module.d.ts +3 -3
- package/module.js +10 -48
- package/package.json +9 -7
- package/result/ResultHandlerFactory.d.ts +1 -1
- package/result/ResultHandlerFactory.js +1 -5
- package/result/ResultHandlerImpl.d.ts +1 -1
- package/result/ResultHandlerImpl.js +1 -5
- package/result/types.js +1 -2
- package/settings/index.d.ts +1 -1
- package/settings/index.js +11 -17
- package/types.d.ts +1 -1
- package/types.js +6 -9
- package/utils/commands.d.ts +3 -3
- package/utils/commands.js +23 -36
- package/utils/http/httpsAgent.js +16 -26
- package/utils/http/index.d.ts +1 -1
- package/utils/http/index.js +28 -35
- package/utils/http/utils.d.ts +1 -1
- package/utils/http/utils.js +4 -9
- package/utils/openUtils.js +8 -14
- package/utils/options.d.ts +1 -1
- package/utils/options.js +5 -10
- package/utils/utils.d.ts +2 -2
- package/utils/utils.js +42 -94
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const os_1 = require("os");
|
|
11
|
-
const url_1 = require("url");
|
|
12
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
13
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
14
|
-
const constants_1 = require("../../../constants");
|
|
15
|
-
const logger_1 = require("../../../logger");
|
|
16
|
-
const config_1 = require("../../../config");
|
|
17
|
-
const utils_1 = require("../utils");
|
|
18
|
-
const ResultHandlerFactory_1 = require("../../../result/ResultHandlerFactory");
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import { set } from "lodash-es";
|
|
3
|
+
import { EOL } from "os";
|
|
4
|
+
import { URL } from "url";
|
|
5
|
+
import { get as getConfig, set as setConfig } from "../../../config/index.js";
|
|
6
|
+
import { AuthenticationMethod, OPTION_OUTPUT, SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH, X_CSRF_TOKEN, X_DSP_API_DEPRECATED_PROPERTIES, X_OUTPUT_FILE_NAME, } from "../../../constants.js";
|
|
7
|
+
import { get as getLogger } from "../../../logger/index.js";
|
|
8
|
+
import { ResultHandlerFactory } from "../../../result/ResultHandlerFactory.js";
|
|
9
|
+
import { getAuthenticationMethod, getTargetHost } from "../utils.js";
|
|
19
10
|
const CURLY_OPEN_ENCODED = encodeURIComponent("{");
|
|
20
11
|
const CURLY_CLOSED_ENCODED = encodeURIComponent("}");
|
|
21
|
-
const checkConfiguration = (config) => {
|
|
12
|
+
export const checkConfiguration = (config) => {
|
|
22
13
|
if (!config.authorization) {
|
|
23
14
|
throw new Error("no authorization header");
|
|
24
15
|
}
|
|
@@ -29,28 +20,26 @@ const checkConfiguration = (config) => {
|
|
|
29
20
|
throw new Error("no publicfqdn");
|
|
30
21
|
}
|
|
31
22
|
};
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
if (authenticationMethod === constants_1.AuthenticationMethod.passcode) {
|
|
23
|
+
export const removeLeadingPathSegmentForPasscode = (path) => {
|
|
24
|
+
const authenticationMethod = getAuthenticationMethod();
|
|
25
|
+
if (authenticationMethod === AuthenticationMethod.passcode) {
|
|
36
26
|
const segments = path.split("/");
|
|
37
|
-
if (
|
|
27
|
+
if (SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH.includes(segments[1])) {
|
|
38
28
|
segments.splice(1, 1);
|
|
39
29
|
return segments.join("/");
|
|
40
30
|
}
|
|
41
31
|
}
|
|
42
32
|
return path;
|
|
43
33
|
};
|
|
44
|
-
exports.removeLeadingPathSegmentForPasscode = removeLeadingPathSegmentForPasscode;
|
|
45
34
|
const getUrl = (path) => {
|
|
46
35
|
if (path.startsWith("http")) {
|
|
47
|
-
return new
|
|
36
|
+
return new URL(path);
|
|
48
37
|
}
|
|
49
|
-
const pathInt =
|
|
50
|
-
const targetHost =
|
|
51
|
-
return new
|
|
38
|
+
const pathInt = removeLeadingPathSegmentForPasscode(path);
|
|
39
|
+
const targetHost = getTargetHost();
|
|
40
|
+
return new URL(`${targetHost}${pathInt}`);
|
|
52
41
|
};
|
|
53
|
-
const handleMappingIn = (mapping, url, value, headers, bodyWrapper) => {
|
|
42
|
+
export const handleMappingIn = (mapping, url, value, headers, bodyWrapper) => {
|
|
54
43
|
if (mapping.in === "query") {
|
|
55
44
|
url.searchParams.append(mapping.name, value);
|
|
56
45
|
}
|
|
@@ -67,11 +56,10 @@ const handleMappingIn = (mapping, url, value, headers, bodyWrapper) => {
|
|
|
67
56
|
// eslint-disable-next-line no-param-reassign
|
|
68
57
|
bodyWrapper.body = {};
|
|
69
58
|
}
|
|
70
|
-
|
|
59
|
+
set(bodyWrapper.body, mapping.name, value);
|
|
71
60
|
}
|
|
72
61
|
};
|
|
73
|
-
|
|
74
|
-
const getValueFromMappping = (mapping, config) => {
|
|
62
|
+
export const getValueFromMappping = (mapping, config) => {
|
|
75
63
|
if (mapping.source.type === "value") {
|
|
76
64
|
return mapping.source.value;
|
|
77
65
|
}
|
|
@@ -84,17 +72,15 @@ const getValueFromMappping = (mapping, config) => {
|
|
|
84
72
|
// mapping.source.type === "option"
|
|
85
73
|
return config.options[mapping.source.name];
|
|
86
74
|
};
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const value = (0, exports.getValueFromMappping)(mapping, config);
|
|
75
|
+
export const handleParameterMapping = (config, url, headers, bodyWrapper) => (mapping) => {
|
|
76
|
+
const value = getValueFromMappping(mapping, config);
|
|
90
77
|
if (value === undefined || value === null) {
|
|
91
78
|
return;
|
|
92
79
|
}
|
|
93
|
-
|
|
80
|
+
handleMappingIn(mapping, url, value, headers, bodyWrapper);
|
|
94
81
|
};
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const config = (0, config_1.get)();
|
|
82
|
+
export const buildParameters = (path, parameterMappings) => {
|
|
83
|
+
const config = getConfig();
|
|
98
84
|
const bodyWrapper = {
|
|
99
85
|
body: undefined,
|
|
100
86
|
};
|
|
@@ -109,67 +95,65 @@ const buildParameters = (path, parameterMappings) => {
|
|
|
109
95
|
bodyWrapper.body = config.data.content;
|
|
110
96
|
}
|
|
111
97
|
const url = getUrl(path);
|
|
112
|
-
parameterMappings?.forEach(
|
|
98
|
+
parameterMappings?.forEach(handleParameterMapping(config, url, headers, bodyWrapper));
|
|
113
99
|
return {
|
|
114
100
|
url,
|
|
115
101
|
headers,
|
|
116
102
|
body: bodyWrapper.body,
|
|
117
103
|
};
|
|
118
104
|
};
|
|
119
|
-
exports.buildParameters = buildParameters;
|
|
120
105
|
/**
|
|
121
106
|
* If --output is present: Return value of --output if defined, otherwise take value from outputPath.
|
|
122
107
|
* If --output is not present, print response to console
|
|
123
108
|
* @param outputPath Optional path defined by server
|
|
124
109
|
* @returns Path to output file
|
|
125
110
|
*/
|
|
126
|
-
function getOutputFileName(outputPath = "") {
|
|
127
|
-
const config = (
|
|
128
|
-
if (typeof config.options[
|
|
129
|
-
config.options[
|
|
111
|
+
export function getOutputFileName(outputPath = "") {
|
|
112
|
+
const config = getConfig();
|
|
113
|
+
if (typeof config.options[OPTION_OUTPUT.longName] === "boolean" &&
|
|
114
|
+
config.options[OPTION_OUTPUT.longName]) {
|
|
130
115
|
return outputPath;
|
|
131
116
|
}
|
|
132
|
-
return config.options[
|
|
117
|
+
return config.options[OPTION_OUTPUT.longName];
|
|
133
118
|
}
|
|
134
|
-
function checkResponseDataForInvalidLoginData(response) {
|
|
119
|
+
export function checkResponseDataForInvalidLoginData(response) {
|
|
135
120
|
if (
|
|
136
121
|
// jira.tools.sap/browse/DW101-73607
|
|
137
122
|
typeof response === "string" &&
|
|
138
123
|
response.includes("Please contact your system administrator and ensure you have an active account on this system.")) {
|
|
139
|
-
const logger = (
|
|
124
|
+
const logger = getLogger("checkResponseDataForInvalidLoginData");
|
|
140
125
|
logger.output("WARNING: You are using an access token which is not known to the tenant. Please check your login credentials.");
|
|
141
126
|
logger.debug(response);
|
|
142
127
|
return true;
|
|
143
128
|
}
|
|
144
129
|
return false;
|
|
145
130
|
}
|
|
146
|
-
const handleResponseData = async (data, outputPath) => {
|
|
131
|
+
export const handleResponseData = async (data, outputPath) => {
|
|
147
132
|
checkResponseDataForInvalidLoginData(data);
|
|
148
|
-
const config = (
|
|
133
|
+
const config = getConfig();
|
|
149
134
|
if (!config.doNotStoreResult) {
|
|
150
|
-
|
|
135
|
+
ResultHandlerFactory.get().setResult(data);
|
|
151
136
|
}
|
|
152
137
|
if (config.doNotProcessResponseData) {
|
|
153
138
|
return;
|
|
154
139
|
}
|
|
155
|
-
const { output } = (
|
|
140
|
+
const { output } = getLogger("handler.fetch");
|
|
156
141
|
const formatted = config.options.pretty
|
|
157
142
|
? JSON.stringify(data, null, 2)
|
|
158
143
|
: JSON.stringify(data);
|
|
159
144
|
const outputFileName = getOutputFileName(outputPath);
|
|
160
145
|
if (outputFileName) {
|
|
161
|
-
await
|
|
146
|
+
await fs.writeFile(outputFileName, formatted);
|
|
162
147
|
}
|
|
163
148
|
else {
|
|
164
149
|
output(formatted);
|
|
165
150
|
}
|
|
166
151
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (headers[constants_1.X_DSP_API_DEPRECATED_PROPERTIES]) {
|
|
152
|
+
export function handleResponseHeaders(headers) {
|
|
153
|
+
const { error, output } = getLogger("handler.fetch.handleResponseHeaders");
|
|
154
|
+
if (headers[X_DSP_API_DEPRECATED_PROPERTIES]) {
|
|
171
155
|
try {
|
|
172
|
-
const deprecatedProperties = JSON.parse(headers[
|
|
156
|
+
const deprecatedProperties = JSON.parse(headers[X_DSP_API_DEPRECATED_PROPERTIES]);
|
|
173
157
|
const deprecatedPropertiesStr = deprecatedProperties
|
|
174
158
|
.map((dp) => {
|
|
175
159
|
let msg = dp.name;
|
|
@@ -187,37 +171,35 @@ function handleResponseHeaders(headers) {
|
|
|
187
171
|
}
|
|
188
172
|
return msg;
|
|
189
173
|
})
|
|
190
|
-
.reduce((prev, curr) => `${prev}${
|
|
174
|
+
.reduce((prev, curr) => `${prev}${EOL}\t${curr}`, "");
|
|
191
175
|
output(`WARNING: the following properties are deprecated:${deprecatedPropertiesStr}`);
|
|
192
176
|
}
|
|
193
177
|
catch (err) {
|
|
194
|
-
error(`failed to parse deprecated properties via header ${
|
|
178
|
+
error(`failed to parse deprecated properties via header ${X_DSP_API_DEPRECATED_PROPERTIES}`, err);
|
|
195
179
|
}
|
|
196
180
|
}
|
|
197
181
|
}
|
|
198
|
-
const handleResponse = async (data, headers) => {
|
|
199
|
-
if (headers?.[
|
|
200
|
-
(
|
|
182
|
+
export const handleResponse = async (data, headers) => {
|
|
183
|
+
if (headers?.[X_CSRF_TOKEN]) {
|
|
184
|
+
setConfig({ [X_CSRF_TOKEN]: headers[X_CSRF_TOKEN] });
|
|
201
185
|
}
|
|
202
186
|
else {
|
|
203
187
|
if (data) {
|
|
204
|
-
await
|
|
188
|
+
await handleResponseData(data, headers?.[X_OUTPUT_FILE_NAME]);
|
|
205
189
|
}
|
|
206
190
|
if (headers) {
|
|
207
191
|
handleResponseHeaders(headers);
|
|
208
192
|
}
|
|
209
193
|
}
|
|
210
194
|
};
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
const config = (0, config_1.get)();
|
|
216
|
-
const { url, body, headers } = (0, exports.buildParameters)(path, parameterMappings);
|
|
195
|
+
export const configRequiresBody = (method) => ["POST", "PUT", "PATCH"].includes(method.toUpperCase());
|
|
196
|
+
export const buildHttpConfig = async (method, path, parameterMappings) => {
|
|
197
|
+
const config = getConfig();
|
|
198
|
+
const { url, body, headers } = buildParameters(path, parameterMappings);
|
|
217
199
|
const httpConfig = {
|
|
218
200
|
url: url.toString(),
|
|
219
201
|
method,
|
|
220
|
-
data:
|
|
202
|
+
data: configRequiresBody(method) ? body : undefined,
|
|
221
203
|
headers: {
|
|
222
204
|
...config.authorization,
|
|
223
205
|
...headers,
|
|
@@ -225,9 +207,8 @@ const buildHttpConfig = async (method, path, parameterMappings) => {
|
|
|
225
207
|
publicfqdn: config.publicfqdn,
|
|
226
208
|
},
|
|
227
209
|
};
|
|
228
|
-
if (
|
|
229
|
-
delete httpConfig.headers
|
|
210
|
+
if (getAuthenticationMethod() === AuthenticationMethod.oauth) {
|
|
211
|
+
delete httpConfig.headers.publicfqdn;
|
|
230
212
|
}
|
|
231
213
|
return httpConfig;
|
|
232
214
|
};
|
|
233
|
-
exports.buildHttpConfig = buildHttpConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../types";
|
|
1
|
+
import { Handler } from "../../types.js";
|
|
2
2
|
export declare const create: (message: string) => Handler;
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.create = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const config_1 = require("../../config");
|
|
9
|
-
const constants_1 = require("../../constants");
|
|
10
|
-
const options_1 = require("./options");
|
|
1
|
+
import { kebabCase } from "lodash-es";
|
|
2
|
+
import { get as getConfig } from "../../config/index.js";
|
|
3
|
+
import { OPTION_FORCE } from "../../constants.js";
|
|
4
|
+
import { create as createOptionsHandler } from "./options/index.js";
|
|
11
5
|
const PARAM_REGEX = /{.*}/;
|
|
12
6
|
const replacer = (toBeReplaced) => {
|
|
13
7
|
const param = toBeReplaced.slice(1, -1);
|
|
14
|
-
return `{${
|
|
8
|
+
return `{${kebabCase(param)}}`;
|
|
15
9
|
};
|
|
16
|
-
const create = (message) => (
|
|
10
|
+
export const create = (message) => createOptionsHandler([
|
|
17
11
|
{
|
|
18
|
-
...
|
|
12
|
+
...OPTION_FORCE,
|
|
19
13
|
required: true,
|
|
20
14
|
prompts: {
|
|
21
15
|
type: "confirm",
|
|
22
16
|
initial: true,
|
|
23
17
|
message: () => {
|
|
24
|
-
const config = (
|
|
18
|
+
const config = getConfig();
|
|
25
19
|
let intMessage = message.replace(PARAM_REGEX, replacer);
|
|
26
20
|
Object.entries(config.options).forEach((option) => {
|
|
27
21
|
intMessage = intMessage.replace(`{${option[0]}}`, option[1]);
|
|
@@ -32,4 +26,3 @@ const create = (message) => (0, options_1.create)([
|
|
|
32
26
|
},
|
|
33
27
|
},
|
|
34
28
|
], undefined, false, true);
|
|
35
|
-
exports.create = create;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { create as createRootHandler } from "./root";
|
|
2
|
-
export { create as createMandatoryOptionsHandler } from "./mandatoryOptions";
|
|
3
|
-
export { create as createNextHandler } from "./next";
|
|
4
|
-
export { create as createOrHandler } from "./or";
|
|
5
|
-
export { create as createParseArgumentsHandler } from "./parseArguments";
|
|
6
|
-
export { create as createAuthenticationHandler } from "./authentication";
|
|
7
|
-
export { create as createPasscodeHandler } from "./authentication/passcode";
|
|
8
|
-
export { create as createOauthHandler } from "./authentication/oauth";
|
|
9
|
-
export { create as createForceHandler } from "./force";
|
|
10
|
-
export { create as createFetchHandler } from "./fetch";
|
|
11
|
-
export { create as createOptionsHandler } from "./options";
|
|
12
|
-
export { create as createInputHandler } from "./input";
|
|
13
|
-
export { create as createCheckOptionsExistence } from "./checkOptionsExistence";
|
|
14
|
-
export { create as createFailHandler } from "./fail";
|
|
15
|
-
export { create as createSucceedHandler } from "./succeed";
|
|
16
|
-
export { create as createErrorHandler } from "./error";
|
|
17
|
-
export { create as createResilientHandler } from "./resilient";
|
|
18
|
-
export { create as createStackTraceHandler } from "./stackTrace";
|
|
1
|
+
export { create as createRootHandler } from "./root/index.js";
|
|
2
|
+
export { create as createMandatoryOptionsHandler } from "./mandatoryOptions.js";
|
|
3
|
+
export { create as createNextHandler } from "./next.js";
|
|
4
|
+
export { create as createOrHandler } from "./or.js";
|
|
5
|
+
export { create as createParseArgumentsHandler } from "./parseArguments.js";
|
|
6
|
+
export { create as createAuthenticationHandler } from "./authentication/index.js";
|
|
7
|
+
export { create as createPasscodeHandler } from "./authentication/passcode/index.js";
|
|
8
|
+
export { create as createOauthHandler } from "./authentication/oauth/index.js";
|
|
9
|
+
export { create as createForceHandler } from "./force.js";
|
|
10
|
+
export { create as createFetchHandler } from "./fetch/index.js";
|
|
11
|
+
export { create as createOptionsHandler } from "./options/index.js";
|
|
12
|
+
export { create as createInputHandler } from "./input/index.js";
|
|
13
|
+
export { create as createCheckOptionsExistence } from "./checkOptionsExistence.js";
|
|
14
|
+
export { create as createFailHandler } from "./fail.js";
|
|
15
|
+
export { create as createSucceedHandler } from "./succeed.js";
|
|
16
|
+
export { create as createErrorHandler } from "./error.js";
|
|
17
|
+
export { create as createResilientHandler } from "./resilient.js";
|
|
18
|
+
export { create as createStackTraceHandler } from "./stackTrace.js";
|
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "createOauthHandler", { enumerable: true, get: function () { return oauth_1.create; } });
|
|
20
|
-
var force_1 = require("./force");
|
|
21
|
-
Object.defineProperty(exports, "createForceHandler", { enumerable: true, get: function () { return force_1.create; } });
|
|
22
|
-
var fetch_1 = require("./fetch");
|
|
23
|
-
Object.defineProperty(exports, "createFetchHandler", { enumerable: true, get: function () { return fetch_1.create; } });
|
|
24
|
-
var options_1 = require("./options");
|
|
25
|
-
Object.defineProperty(exports, "createOptionsHandler", { enumerable: true, get: function () { return options_1.create; } });
|
|
26
|
-
var input_1 = require("./input");
|
|
27
|
-
Object.defineProperty(exports, "createInputHandler", { enumerable: true, get: function () { return input_1.create; } });
|
|
28
|
-
var checkOptionsExistence_1 = require("./checkOptionsExistence");
|
|
29
|
-
Object.defineProperty(exports, "createCheckOptionsExistence", { enumerable: true, get: function () { return checkOptionsExistence_1.create; } });
|
|
30
|
-
var fail_1 = require("./fail");
|
|
31
|
-
Object.defineProperty(exports, "createFailHandler", { enumerable: true, get: function () { return fail_1.create; } });
|
|
32
|
-
var succeed_1 = require("./succeed");
|
|
33
|
-
Object.defineProperty(exports, "createSucceedHandler", { enumerable: true, get: function () { return succeed_1.create; } });
|
|
34
|
-
var error_1 = require("./error");
|
|
35
|
-
Object.defineProperty(exports, "createErrorHandler", { enumerable: true, get: function () { return error_1.create; } });
|
|
36
|
-
var resilient_1 = require("./resilient");
|
|
37
|
-
Object.defineProperty(exports, "createResilientHandler", { enumerable: true, get: function () { return resilient_1.create; } });
|
|
38
|
-
var stackTrace_1 = require("./stackTrace");
|
|
39
|
-
Object.defineProperty(exports, "createStackTraceHandler", { enumerable: true, get: function () { return stackTrace_1.create; } });
|
|
1
|
+
export { create as createRootHandler } from "./root/index.js";
|
|
2
|
+
export { create as createMandatoryOptionsHandler } from "./mandatoryOptions.js";
|
|
3
|
+
export { create as createNextHandler } from "./next.js";
|
|
4
|
+
export { create as createOrHandler } from "./or.js";
|
|
5
|
+
export { create as createParseArgumentsHandler } from "./parseArguments.js";
|
|
6
|
+
export { create as createAuthenticationHandler } from "./authentication/index.js";
|
|
7
|
+
export { create as createPasscodeHandler } from "./authentication/passcode/index.js";
|
|
8
|
+
export { create as createOauthHandler } from "./authentication/oauth/index.js";
|
|
9
|
+
export { create as createForceHandler } from "./force.js";
|
|
10
|
+
export { create as createFetchHandler } from "./fetch/index.js";
|
|
11
|
+
export { create as createOptionsHandler } from "./options/index.js";
|
|
12
|
+
export { create as createInputHandler } from "./input/index.js";
|
|
13
|
+
export { create as createCheckOptionsExistence } from "./checkOptionsExistence.js";
|
|
14
|
+
export { create as createFailHandler } from "./fail.js";
|
|
15
|
+
export { create as createSucceedHandler } from "./succeed.js";
|
|
16
|
+
export { create as createErrorHandler } from "./error.js";
|
|
17
|
+
export { create as createResilientHandler } from "./resilient.js";
|
|
18
|
+
export { create as createStackTraceHandler } from "./stackTrace.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../../types";
|
|
1
|
+
import { Handler } from "../../../types.js";
|
|
2
2
|
export declare const create: () => Handler;
|
|
@@ -1,52 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const logger_1 = require("../../../logger");
|
|
12
|
-
const constants_1 = require("../../../constants");
|
|
13
|
-
const checkOptionsExistence_1 = require("../checkOptionsExistence");
|
|
14
|
-
const next_1 = require("../next");
|
|
15
|
-
const options_1 = require("../options");
|
|
16
|
-
const utils_1 = require("../../../logger/utils");
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import FormData from "form-data";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { get as getConfig, set as setConfig } from "../../../config/index.js";
|
|
5
|
+
import { get } from "../../../logger/index.js";
|
|
6
|
+
import { OPTION_FILE_PATH, OPTION_INPUT, X_OUTPUT_FILE_NAME, } from "../../../constants.js";
|
|
7
|
+
import { create as createCheckOptionsExistence } from "../checkOptionsExistence.js";
|
|
8
|
+
import { create as createNextHandler } from "../next.js";
|
|
9
|
+
import { create as createOptionsHandler } from "../options/index.js";
|
|
10
|
+
import { logVerbose } from "../../../logger/utils.js";
|
|
17
11
|
const readBodyFromFile = async () => async () => {
|
|
18
|
-
const config = (
|
|
19
|
-
const filePath = config.options[
|
|
20
|
-
const logger =
|
|
12
|
+
const config = getConfig();
|
|
13
|
+
const filePath = config.options[OPTION_FILE_PATH.longName];
|
|
14
|
+
const logger = get("commands.handler.input.file");
|
|
21
15
|
const { debug, trace } = logger;
|
|
22
16
|
debug("reading request body from %s", filePath);
|
|
23
17
|
try {
|
|
24
18
|
if (filePath.endsWith(".json")) {
|
|
25
|
-
(
|
|
19
|
+
setConfig({
|
|
26
20
|
data: {
|
|
27
21
|
type: "json",
|
|
28
|
-
content: JSON.parse(await
|
|
22
|
+
content: JSON.parse(await fs.readFile(filePath, "utf-8")),
|
|
29
23
|
},
|
|
30
24
|
});
|
|
31
25
|
}
|
|
32
26
|
else {
|
|
33
|
-
const form = new
|
|
34
|
-
form.append("file",
|
|
35
|
-
(
|
|
27
|
+
const form = new FormData();
|
|
28
|
+
form.append("file", fs.createReadStream(filePath));
|
|
29
|
+
setConfig({
|
|
36
30
|
data: {
|
|
37
31
|
type: "file",
|
|
38
32
|
content: form,
|
|
39
33
|
},
|
|
40
34
|
});
|
|
41
35
|
}
|
|
42
|
-
const filename =
|
|
43
|
-
(
|
|
36
|
+
const filename = path.basename(filePath);
|
|
37
|
+
setConfig({ headers: { [X_OUTPUT_FILE_NAME]: filename } });
|
|
44
38
|
}
|
|
45
39
|
catch (err) {
|
|
46
|
-
|
|
40
|
+
logVerbose(logger, `Failed to read content from file ${filePath}. Does the file really exist and does it contain valid JSON?`);
|
|
47
41
|
trace(`Failed to read content from file ${filePath}`, err);
|
|
48
42
|
throw err;
|
|
49
43
|
}
|
|
50
44
|
};
|
|
51
|
-
const create = () => (
|
|
52
|
-
exports.create = create;
|
|
45
|
+
export const create = () => createNextHandler("file.input.handler", createCheckOptionsExistence(OPTION_INPUT), createOptionsHandler(OPTION_FILE_PATH, { readEnv: true, readFile: true, readOptions: true }, true, true), readBodyFromFile);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../../types";
|
|
1
|
+
import { Handler } from "../../../types.js";
|
|
2
2
|
export declare const create: () => Handler;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const input_1 = require("./input");
|
|
6
|
-
const file_1 = require("./file");
|
|
7
|
-
const create = () => (0, or_1.create)("commands.handler.input", (0, file_1.create)(), (0, input_1.create)());
|
|
8
|
-
exports.create = create;
|
|
1
|
+
import { create as createOrHandler } from "../or.js";
|
|
2
|
+
import { create as createInputHandler } from "./input.js";
|
|
3
|
+
import { create as createFileHandler } from "./file.js";
|
|
4
|
+
export const create = () => createOrHandler("commands.handler.input", createFileHandler(), createInputHandler());
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../../types";
|
|
1
|
+
import { Handler } from "../../../types.js";
|
|
2
2
|
export declare const create: () => Handler;
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const constants_1 = require("../../../constants");
|
|
10
|
-
const logger_1 = require("../../../logger");
|
|
11
|
-
const commands_1 = require("../../../utils/commands");
|
|
12
|
-
const utils_1 = require("../../../logger/utils");
|
|
13
|
-
const create = () => async (command) => {
|
|
14
|
-
command.addOption(await (0, commands_1.buildOption)(command, constants_1.OPTION_INPUT));
|
|
1
|
+
import prompts from "prompts";
|
|
2
|
+
import { get as getConfig, set as setConfig } from "../../../config/index.js";
|
|
3
|
+
import { OPTION_FILE_PATH, OPTION_INPUT } from "../../../constants.js";
|
|
4
|
+
import { get } from "../../../logger/index.js";
|
|
5
|
+
import { buildOption } from "../../../utils/commands.js";
|
|
6
|
+
import { logVerbose } from "../../../logger/utils.js";
|
|
7
|
+
export const create = () => async (command) => {
|
|
8
|
+
command.addOption(await buildOption(command, OPTION_INPUT));
|
|
15
9
|
return async () => {
|
|
16
|
-
const config = (
|
|
17
|
-
const logger =
|
|
18
|
-
if (config.options[
|
|
19
|
-
throw new Error(`input provided through option --${
|
|
10
|
+
const config = getConfig();
|
|
11
|
+
const logger = get("handler.input.input");
|
|
12
|
+
if (config.options[OPTION_FILE_PATH.longName]) {
|
|
13
|
+
throw new Error(`input provided through option --${OPTION_FILE_PATH.longName}`);
|
|
20
14
|
}
|
|
21
|
-
let input = config.options[
|
|
15
|
+
let input = config.options[OPTION_INPUT.longName];
|
|
22
16
|
if (!input) {
|
|
23
|
-
input = (await
|
|
17
|
+
input = (await prompts.prompt({
|
|
24
18
|
type: "text",
|
|
25
19
|
message: `Please provide input as a string to use for the command:`,
|
|
26
20
|
name: "value",
|
|
@@ -31,7 +25,7 @@ const create = () => async (command) => {
|
|
|
31
25
|
}
|
|
32
26
|
logger.debug("reading request body from data");
|
|
33
27
|
try {
|
|
34
|
-
(
|
|
28
|
+
setConfig({
|
|
35
29
|
data: {
|
|
36
30
|
type: "json",
|
|
37
31
|
content: JSON.parse(input),
|
|
@@ -39,9 +33,8 @@ const create = () => async (command) => {
|
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
35
|
catch (err) {
|
|
42
|
-
|
|
36
|
+
logVerbose(logger, "Failed to parse input data. Is it a valid escaped JSON string?");
|
|
43
37
|
throw err;
|
|
44
38
|
}
|
|
45
39
|
};
|
|
46
40
|
};
|
|
47
|
-
exports.create = create;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../types";
|
|
1
|
+
import { Handler } from "../../types.js";
|
|
2
2
|
export declare const create: () => Handler;
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const utils_1 = require("../../utils/utils");
|
|
7
|
-
const next_1 = require("./next");
|
|
8
|
-
const options_1 = require("./options");
|
|
1
|
+
import { set as setConfig, get as getConfig } from "../../config/index.js";
|
|
2
|
+
import { OPTION_HOST, OPTION_OPTIONS_FILE, OPTION_VERBOSE, } from "../../constants.js";
|
|
3
|
+
import { getInfoFromTenant, parseTenant } from "../../utils/utils.js";
|
|
4
|
+
import { create as createNextHandler } from "./next.js";
|
|
5
|
+
import { create as createOptionsHandler } from "./options/index.js";
|
|
9
6
|
const MANDATORY_OPTIONS = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{ ...
|
|
7
|
+
OPTION_VERBOSE,
|
|
8
|
+
OPTION_OPTIONS_FILE,
|
|
9
|
+
{ ...OPTION_HOST, required: true },
|
|
13
10
|
];
|
|
14
11
|
const post = async () => async () => {
|
|
15
|
-
const config = (
|
|
16
|
-
const tenant =
|
|
17
|
-
const info =
|
|
12
|
+
const config = getConfig();
|
|
13
|
+
const tenant = parseTenant(config.options[OPTION_HOST.longName]);
|
|
14
|
+
const info = getInfoFromTenant(tenant, config.verbose);
|
|
18
15
|
for (const [key, value] of Object.entries(info)) {
|
|
19
16
|
if (!config[key]) {
|
|
20
|
-
(
|
|
17
|
+
setConfig({ [key]: value });
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
};
|
|
24
|
-
const create = () => (
|
|
25
|
-
exports.create = create;
|
|
21
|
+
export const create = () => createNextHandler("mandatoryOptions.handler", createOptionsHandler(MANDATORY_OPTIONS), post);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../types";
|
|
1
|
+
import { Handler } from "../../types.js";
|
|
2
2
|
export declare const create: (origin: string, ...handlers: Array<Handler>) => Handler;
|