@sap/cli-core 2023.17.0 → 2023.18.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +179 -2
  2. package/cache/secrets/SecretsStorageImpl.d.ts +22 -0
  3. package/cache/secrets/SecretsStorageImpl.js +147 -0
  4. package/cache/secrets/SecretsStorageSingleton.d.ts +4 -0
  5. package/cache/secrets/SecretsStorageSingleton.js +7 -0
  6. package/cache/secrets/types.d.ts +11 -0
  7. package/cache/secrets/types.js +2 -0
  8. package/cache/secrets/utils.d.ts +2 -0
  9. package/cache/secrets/utils.js +18 -0
  10. package/commands/{cache.command → config.command/cache.command}/clean.command.d.ts +1 -1
  11. package/commands/{cache.command → config.command/cache.command}/clean.command.js +3 -3
  12. package/commands/{cache.command → config.command/cache.command}/index.d.ts +1 -1
  13. package/commands/config.command/cache.command/init.command.d.ts +4 -0
  14. package/commands/{cache.command → config.command/cache.command}/init.command.js +15 -8
  15. package/commands/{cache.command → config.command/cache.command}/show.command.d.ts +1 -1
  16. package/commands/{cache.command → config.command/cache.command}/show.command.js +4 -4
  17. package/commands/{host.command.d.ts → config.command/host.command.d.ts} +1 -1
  18. package/commands/{host.command.js → config.command/host.command.js} +12 -12
  19. package/commands/config.command/index.d.ts +2 -0
  20. package/commands/config.command/index.js +19 -0
  21. package/commands/{passcode.command.d.ts → config.command/passcode.command.d.ts} +1 -1
  22. package/commands/{passcode.command.js → config.command/passcode.command.js} +8 -8
  23. package/commands/{secrets.command → config.command/secrets.command}/index.d.ts +1 -1
  24. package/commands/{secrets.command → config.command/secrets.command}/index.js +2 -1
  25. package/commands/config.command/secrets.command/reset.command.d.ts +3 -0
  26. package/commands/config.command/secrets.command/reset.command.js +17 -0
  27. package/commands/{secrets.command → config.command/secrets.command}/show.command.d.ts +1 -1
  28. package/commands/{secrets.command → config.command/secrets.command}/show.command.js +14 -7
  29. package/commands/handler/authentication/oauth/secretsProvider/cache.js +4 -5
  30. package/commands/handler/authentication/oauth/secretsProvider/file.js +3 -3
  31. package/commands/handler/authentication/oauth/secretsProvider/options.js +12 -6
  32. package/commands/handler/authentication/oauth/tokenProvider/getToken.js +5 -61
  33. package/commands/handler/authentication/oauth/tokenProvider/refreshToken.js +1 -1
  34. package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.js +4 -4
  35. package/commands/handler/authentication/oauth/tokenProvider/utils.d.ts +2 -0
  36. package/commands/handler/authentication/oauth/tokenProvider/utils.js +77 -4
  37. package/commands/handler/authentication/oauth/utils.d.ts +0 -4
  38. package/commands/handler/authentication/oauth/utils.js +13 -27
  39. package/commands/handler/authentication/passcode/function.js +1 -1
  40. package/commands/handler/authentication/passcode/input.js +2 -2
  41. package/commands/handler/authentication/passcode/setPasscode.js +1 -1
  42. package/commands/handler/authentication/technicalJWT/index.js +2 -2
  43. package/commands/handler/checkOptionsExistence.js +1 -1
  44. package/commands/handler/error.js +2 -2
  45. package/commands/handler/fail.js +1 -1
  46. package/commands/handler/fetch/fetch.js +1 -1
  47. package/commands/handler/fetch/utils.js +1 -1
  48. package/commands/handler/input/file.js +1 -1
  49. package/commands/handler/input/input.js +2 -2
  50. package/commands/handler/mandatoryOptions.js +1 -1
  51. package/commands/handler/next.js +3 -2
  52. package/commands/handler/options/env.js +1 -2
  53. package/commands/handler/options/file.js +1 -1
  54. package/commands/handler/options/index.js +5 -4
  55. package/commands/handler/options/option.js +1 -1
  56. package/commands/handler/options/pipe.js +1 -1
  57. package/commands/handler/options/utils.d.ts +1 -1
  58. package/commands/handler/options/utils.js +11 -4
  59. package/commands/handler/or.js +3 -2
  60. package/commands/handler/parseArguments.js +1 -1
  61. package/commands/handler/resilient.js +2 -2
  62. package/commands/handler/root/index.js +2 -2
  63. package/commands/handler/stackTrace.js +2 -2
  64. package/commands/handler/succeed.js +1 -1
  65. package/commands/login.command.js +34 -4
  66. package/commands/logout.command.js +16 -6
  67. package/commands/openAPI.command/index.js +3 -8
  68. package/commands/openAPI.command/utils.js +4 -13
  69. package/commands/utils.d.ts +2 -0
  70. package/commands/utils.js +8 -0
  71. package/config/core.d.ts +1 -0
  72. package/config/core.js +5 -1
  73. package/config/index.js +1 -0
  74. package/constants.d.ts +3 -1
  75. package/constants.js +34 -5
  76. package/discovery/index.js +0 -4
  77. package/dwc/dwc.js +15 -26
  78. package/dwc/run.js +2 -0
  79. package/dwc/utils.d.ts +2 -0
  80. package/dwc/utils.js +34 -2
  81. package/index.d.ts +2 -1
  82. package/index.js +4 -1
  83. package/logger/index.d.ts +1 -10
  84. package/logger/types.d.ts +10 -0
  85. package/logger/types.js +2 -0
  86. package/logger/utils.d.ts +2 -0
  87. package/logger/utils.js +12 -0
  88. package/package.json +3 -2
  89. package/types.d.ts +9 -3
  90. package/utils/commands.d.ts +2 -2
  91. package/utils/commands.js +23 -11
  92. package/utils/http/index.js +0 -1
  93. package/utils/utils.d.ts +5 -1
  94. package/utils/utils.js +15 -4
  95. package/commands/cache.command/init.command.d.ts +0 -3
  96. /package/commands/{cache.command → config.command/cache.command}/index.js +0 -0
@@ -18,14 +18,15 @@ const create = (options, { readPipe, readEnv, readFile, readOptions } = {
18
18
  readEnv: true,
19
19
  readFile: true,
20
20
  readOptions: true,
21
- }, promptAlways = false, throwIfHandlersFailed = false) => (command) => {
21
+ }, promptAlways = false, throwIfHandlersFailed = false) => async (command) => {
22
22
  const intOptions = Array.isArray(options) ? options : [options];
23
- (0, utils_1.checkOptions)(intOptions, command);
23
+ await (0, utils_1.checkOptions)(intOptions, command);
24
24
  return async () => {
25
25
  for (const option of intOptions) {
26
- await (0, or_1.create)((0, checkOptionsExistence_1.create)(option, false), (0, or_1.create)(createHandler(readPipe, option, (0, pipe_1.create)(option)), createHandler(readEnv, option, (0, env_1.create)(option)), createHandler(readFile, option, (0, file_1.create)(option)), createHandler(readOptions, option, (0, option_1.create)(option, promptAlways))), throwIfHandlersFailed
26
+ const handler = (0, or_1.create)((0, checkOptionsExistence_1.create)(option, false), (0, or_1.create)(createHandler(readPipe, option, (0, pipe_1.create)(option)), createHandler(readEnv, option, (0, env_1.create)(option)), createHandler(readFile, option, (0, file_1.create)(option)), createHandler(readOptions, option, (0, option_1.create)(option, promptAlways))), throwIfHandlersFailed
27
27
  ? (0, fail_1.create)()
28
- : (0, succeed_1.create)())(command)();
28
+ : (0, succeed_1.create)());
29
+ await (await handler(command))();
29
30
  }
30
31
  };
31
32
  };
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = void 0;
4
4
  const logger_1 = require("../../../logger");
5
5
  const utils_1 = require("./utils");
6
- const create = (option, promptAlways = false) => () => async () => {
6
+ const create = (option, promptAlways = false) => async () => async () => {
7
7
  const { debug } = (0, logger_1.get)("commands.handler.options.option");
8
8
  debug(`reading option ${option.longName} from options`);
9
9
  if (option.required || promptAlways) {
@@ -24,7 +24,7 @@ const getDataFromPipe = () => {
24
24
  return data;
25
25
  };
26
26
  /* jscpd:ignore-start */
27
- const create = (option) => () => async () => {
27
+ const create = (option) => async () => async () => {
28
28
  const { debug } = getLogger();
29
29
  /* jscpd:ignore-end */
30
30
  debug(`reading option ${option.longName} from pipe`);
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import { Option } from "../../../types";
3
- export declare const checkOptions: (options: Array<Option> | Option, command: Command) => void;
3
+ export declare const checkOptions: (options: Array<Option> | Option, command: Command) => Promise<void>;
4
4
  export declare const promptForValue: (option: Option) => Promise<string>;
5
5
  export declare const setOption: (option: Option, value: string) => void;
6
6
  export declare const getValueFromOptionsFile: (filePath: string, { longName }: Option) => Promise<string>;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
3
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
4
  };
@@ -10,19 +9,27 @@ const fs_extra_1 = require("fs-extra");
10
9
  const logger_1 = require("../../../logger");
11
10
  const commands_1 = require("../../../utils/commands");
12
11
  const config_1 = require("../../../config");
13
- const checkOptions = (options, command) => {
12
+ const checkOptions = async (options, command) => {
14
13
  const intOptions = Array.isArray(options) ? options : [options];
15
14
  for (const option of intOptions) {
16
15
  if (!(0, commands_1.isOptionAlreadyRegistered)(option, command)) {
17
- command.addOption((0, commands_1.buildOption)({ ...option, required: false }));
16
+ // eslint-disable-next-line no-await-in-loop
17
+ command.addOption(await (0, commands_1.buildOption)({ ...option, required: false }));
18
18
  }
19
19
  }
20
20
  };
21
21
  exports.checkOptions = checkOptions;
22
22
  const promptForValue = async (option) => {
23
+ let choices = [];
24
+ if (option.choices) {
25
+ choices =
26
+ typeof option.choices === "function"
27
+ ? await option.choices()
28
+ : option.choices;
29
+ }
23
30
  const { value } = await prompts_1.default.prompt({
24
31
  type: option.prompts.type,
25
- choices: option.choices?.map((choice) => ({
32
+ choices: choices.map((choice) => ({
26
33
  title: choice,
27
34
  value: choice,
28
35
  })),
@@ -5,10 +5,11 @@ const logger_1 = require("../../logger");
5
5
  const getLogger = () => (0, logger_1.get)("commands.handlers.or");
6
6
  const create = (...handlers) => {
7
7
  const { stack } = new Error();
8
- return (command) => {
8
+ return async (command) => {
9
9
  const commandHandlers = [];
10
10
  for (const handler of handlers) {
11
- commandHandlers.push(handler(command));
11
+ // eslint-disable-next-line no-await-in-loop
12
+ commandHandlers.push(await handler(command));
12
13
  }
13
14
  return async (...args) => {
14
15
  const { debug, trace } = getLogger();
@@ -6,7 +6,7 @@ const config_1 = require("../../config");
6
6
  const utils_1 = require("./utils");
7
7
  const constants_1 = require("../../constants");
8
8
  const logger_1 = require("../../logger");
9
- const create = (handlerArgs) => () => async (...args) => {
9
+ const create = (handlerArgs) => async () => async (...args) => {
10
10
  const { debug } = (0, logger_1.get)("commands.handler.parseArguments");
11
11
  const command = args[args.length - 1].name();
12
12
  const options = Object.entries(args[args.length - 2])
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = void 0;
4
4
  const logger_1 = require("../../logger");
5
- const create = (handler) => (command) => {
6
- const commandHandler = handler(command);
5
+ const create = (handler) => async (command) => {
6
+ const commandHandler = await handler(command);
7
7
  return async (...args) => {
8
8
  try {
9
9
  await commandHandler(...args);
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = void 0;
4
4
  const logger_1 = require("../../../logger");
5
- const create = (handler, errorMessage = "Command failed") => (command) => {
5
+ const create = (handler, errorMessage = "Command failed") => async (command) => {
6
6
  const { output } = (0, logger_1.get)("handler.root");
7
- const hdlr = handler(command);
7
+ const hdlr = await handler(command);
8
8
  return async (...args) => {
9
9
  try {
10
10
  await hdlr(...args);
@@ -4,8 +4,8 @@ exports.create = void 0;
4
4
  const logger_1 = require("../../logger");
5
5
  const create = (handler) => {
6
6
  const { stack } = new Error();
7
- return (command) => {
8
- const commandHandler = handler(command);
7
+ return async (command) => {
8
+ const commandHandler = await handler(command);
9
9
  return async (...args) => {
10
10
  try {
11
11
  await commandHandler(...args);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.create = void 0;
4
4
  const logger_1 = require("../../logger");
5
- const create = () => () => async () => {
5
+ const create = () => async () => async () => {
6
6
  const { debug } = (0, logger_1.get)("commands.handler.succeed");
7
7
  debug(`running succeed handler`);
8
8
  };
@@ -2,15 +2,45 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const handler_1 = require("./handler");
4
4
  const constants_1 = require("../constants");
5
- const utils_1 = require("./handler/authentication/oauth/utils");
6
- const store = () => async () => {
7
- await (0, utils_1.storeSecrets)();
5
+ const logger_1 = require("../logger");
6
+ const options_1 = require("../utils/options");
7
+ const init_command_1 = require("./config.command/cache.command/init.command");
8
+ const utils_1 = require("../cache/secrets/utils");
9
+ const utils_2 = require("../logger/utils");
10
+ const utils_3 = require("../utils/utils");
11
+ const getLogger = () => (0, logger_1.get)("commands.login");
12
+ const verifyHost = async () => async () => {
13
+ const logger = getLogger();
14
+ try {
15
+ const url = (0, utils_1.getTenantUrl)();
16
+ logger.debug(`url defined as ${url}`);
17
+ }
18
+ catch (err) {
19
+ logger.error("tenant URL not defined. use option -H, --host");
20
+ (0, utils_2.logVerbose)(logger, "specify the tenant URL using option --host");
21
+ throw new Error("tenant URL not defined. use option -H, --host");
22
+ }
23
+ };
24
+ const initializeCache = async () => async () => {
25
+ const { warn, info } = getLogger();
26
+ info("initializing cache after successful login");
27
+ try {
28
+ (0, options_1.getOptionValueFromConfig)(constants_1.OPTION_HOST);
29
+ await (await (0, init_command_1.init)())();
30
+ }
31
+ catch (err) {
32
+ warn(`option ${(0, utils_3.buildOptionName)(constants_1.OPTION_HOST)} not defined, skipping cache init`);
33
+ }
8
34
  };
9
35
  const loginCommand = {
10
36
  type: "command",
11
37
  command: "login",
12
38
  description: "log in to your account using interactive OAuth authentication",
13
39
  options: [],
14
- handler: (0, handler_1.createNextHandler)((0, handler_1.createParseArgumentsHandler)(), (0, handler_1.createOptionsHandler)([constants_1.OPTION_VERBOSE, constants_1.OPTION_OPTIONS_FILE]), (0, handler_1.createOauthHandler)(), store),
40
+ handler: (0, handler_1.createNextHandler)((0, handler_1.createParseArgumentsHandler)(), (0, handler_1.createOptionsHandler)([
41
+ { ...constants_1.OPTION_HOST, hidden: false, required: true },
42
+ constants_1.OPTION_VERBOSE,
43
+ constants_1.OPTION_OPTIONS_FILE,
44
+ ]), verifyHost, (0, handler_1.createOauthHandler)(), initializeCache),
15
45
  };
16
46
  exports.default = loginCommand;
@@ -1,21 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const cache_1 = require("../cache");
3
+ const SecretsStorageSingleton_1 = require("../cache/secrets/SecretsStorageSingleton");
4
4
  const constants_1 = require("../constants");
5
5
  const logger_1 = require("../logger");
6
- const handler = () => async () => {
6
+ const config_1 = require("../config");
7
+ const handler_1 = require("./handler");
8
+ const utils_1 = require("../logger/utils");
9
+ const utils_2 = require("./utils");
10
+ const handler = async () => async () => {
7
11
  try {
8
- await (0, cache_1.deleteFile)(constants_1.CACHE_SECRETS_FILE);
12
+ const config = (0, config_1.get)();
13
+ SecretsStorageSingleton_1.SecretsStorageSingleton.SINGLETON.deleteSecretById(config.options[constants_1.OPTION_LOGIN_ID.longName]);
9
14
  }
10
15
  catch (err) {
11
- const { error } = (0, logger_1.get)("commands.logout");
12
- error("failed to delete secrets file from cache", err);
16
+ const logger = (0, logger_1.get)("commands.logout");
17
+ logger.error("failed to delete secrets file from cache", err);
18
+ (0, utils_1.logVerbose)(logger, err.message);
19
+ throw new Error("failed to delete secrets file from cache");
13
20
  }
14
21
  };
15
22
  const logoutCommand = {
16
23
  type: "command",
17
24
  command: "logout",
18
25
  description: "log out from your account",
19
- handler,
26
+ handler: (0, handler_1.createNextHandler)((0, handler_1.createParseArgumentsHandler)(), (0, handler_1.createOptionsHandler)([
27
+ { ...constants_1.OPTION_LOGIN_ID, choices: utils_2.getChoices },
28
+ constants_1.OPTION_VERBOSE,
29
+ ]), handler),
20
30
  };
21
31
  exports.default = logoutCommand;
@@ -59,7 +59,6 @@ const addCommands = async (program) => {
59
59
  let remove;
60
60
  try {
61
61
  const parameterMappings = [];
62
- // eslint-disable-next-line
63
62
  const operation = pathItem[method];
64
63
  const cmd = addCommandToArray(doc, commands, operation.operationId.split(" "), 0);
65
64
  remove = cmd.remove;
@@ -70,16 +69,11 @@ const addCommands = async (program) => {
70
69
  (0, utils_1.handleResponses)(operation, command);
71
70
  (0, utils_1.handleParameters)(operation, doc, parameterMappings, command, (0, utils_1.getSchema)(pathItem.parameters || [], doc));
72
71
  const readPathResponseHandler = (0, utils_1.handleReadPathHandler)(doc, operation);
73
- setHandler(command, method, (0, utils_1.updatePath)(doc, path), parameterMappings, readPathResponseHandler, ...[
74
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
75
- (0, handler_1.createOptionsHandler)(command.options),
76
- ...handler,
77
- ]);
72
+ setHandler(command, method, (0, utils_1.updatePath)(doc, path), parameterMappings, readPathResponseHandler, ...[(0, handler_1.createOptionsHandler)(command.options), ...handler]);
78
73
  delete command.options;
79
74
  }
80
75
  catch (err) {
81
76
  error("cannot add command", err.stack);
82
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
83
77
  remove();
84
78
  }
85
79
  }
@@ -87,7 +81,8 @@ const addCommands = async (program) => {
87
81
  for (const command of commands) {
88
82
  trace("adding command %s", JSON.stringify(command));
89
83
  try {
90
- (0, commands_1.buildCommand)(program, command);
84
+ // eslint-disable-next-line no-await-in-loop
85
+ await (0, commands_1.buildCommand)(program, command);
91
86
  }
92
87
  catch (err) {
93
88
  error("error while adding command %s", JSON.stringify(command, null, 2), err.stack);
@@ -67,7 +67,6 @@ const getPathItem = (doc, operation, path) => {
67
67
  throw new Error(`path ${operation["x-read-path"]} does not support GET operation`);
68
68
  };
69
69
  const outputReadCommand = (doc, operation, response, path) => {
70
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
71
70
  const locationSegments = (0, exports.getSegments)(response.headers.location);
72
71
  const pathSegments = (0, exports.getSegments)(path);
73
72
  let params = "";
@@ -76,9 +75,7 @@ const outputReadCommand = (doc, operation, response, path) => {
76
75
  }
77
76
  const pathItem = getPathItem(doc, operation, path);
78
77
  const { output } = getLogger();
79
- output(`Use ${(0, config_1.get)()[constants_1.CLI_NAME]} ${
80
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
81
- pathItem.get.operationId} ${params} to retrieve the entity you just created`);
78
+ output(`Use ${(0, config_1.get)()[constants_1.CLI_NAME]} ${pathItem.get.operationId} ${params} to retrieve the entity you just created`);
82
79
  };
83
80
  const readPathHandlerFunction = (doc, operation, path) => async (response) => {
84
81
  const { debug } = getLogger();
@@ -291,9 +288,7 @@ const handleRequestBody = (operation, handler, doc, parameterMappings, command)
291
288
  (0, exports.buildOptionFromType)(doc, "body", key.key, {
292
289
  ...key.schema,
293
290
  required: key.required,
294
- }, parameterMappings,
295
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
296
- command.options, key.schema.description);
291
+ }, parameterMappings, command.options, key.schema.description);
297
292
  });
298
293
  }
299
294
  };
@@ -306,11 +301,9 @@ const handleForceOption = (operation, handler) => {
306
301
  exports.handleForceOption = handleForceOption;
307
302
  const handleResponses = (operation, command) => {
308
303
  if (operation.responses?.[200]) {
309
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
310
304
  (0, exports.addOptionToCommand)(constants_1.OPTION_OUTPUT, command.options);
311
305
  }
312
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
313
- (0, exports.addOptionToCommand)(constants_1.OPTION_PRETTY, command.options);
306
+ (0, exports.addOptionToCommand)(constants_1.OPTION_NO_PRETTY, command.options);
314
307
  };
315
308
  exports.handleResponses = handleResponses;
316
309
  const handleParameters = (operation, doc, parameterMappings, command, topLevelParameters = []) => {
@@ -322,9 +315,7 @@ const handleParameters = (operation, doc, parameterMappings, command, topLevelPa
322
315
  ...parameter.schema,
323
316
  allowEmptyValue: parameter.allowEmptyValue,
324
317
  required: parameter.required,
325
- }, parameterMappings,
326
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
327
- command.options, parameter.description);
318
+ }, parameterMappings, command.options, parameter.description);
328
319
  }
329
320
  catch (err) {
330
321
  error("cannot add option", err.stack);
@@ -0,0 +1,2 @@
1
+ import { ChoicesFunction } from "../types";
2
+ export declare const getChoices: ChoicesFunction;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChoices = void 0;
4
+ const SecretsStorageSingleton_1 = require("../cache/secrets/SecretsStorageSingleton");
5
+ const getChoices = async () => {
6
+ return SecretsStorageSingleton_1.SecretsStorageSingleton.SINGLETON.getAllSecrets().map((secret) => secret.id.toString(10));
7
+ };
8
+ exports.getChoices = getChoices;
package/config/core.d.ts CHANGED
@@ -8,3 +8,4 @@ export declare const getAuthenticationMethods: () => Array<AuthenticationMethod>
8
8
  export declare const getVersion: () => string;
9
9
  export declare const isDeprecated: () => boolean;
10
10
  export declare const getDeprecationMessage: () => string | undefined;
11
+ export declare const getGenericOptionsHelp: () => string;
package/config/core.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDeprecationMessage = exports.isDeprecated = exports.getVersion = exports.getAuthenticationMethods = exports.getSapHelp = exports.getDiscoveryPath = exports.getDescription = exports.getPackageName = exports.getName = void 0;
3
+ exports.getGenericOptionsHelp = exports.getDeprecationMessage = exports.isDeprecated = exports.getVersion = exports.getAuthenticationMethods = exports.getSapHelp = exports.getDiscoveryPath = exports.getDescription = exports.getPackageName = exports.getName = void 0;
4
+ /* jscpd:ignore-start */
4
5
  const constants_1 = require("../constants");
6
+ /* jscpd:ignore-end */
5
7
  const index_1 = require("./index");
6
8
  const getName = () => (0, index_1.get)()[constants_1.CLI_NAME];
7
9
  exports.getName = getName;
@@ -21,3 +23,5 @@ const isDeprecated = () => (0, index_1.get)()[constants_1.CLI_DEPRECATED] || fal
21
23
  exports.isDeprecated = isDeprecated;
22
24
  const getDeprecationMessage = () => (0, index_1.get)()[constants_1.CLI_DEPRECATION_MESSAGE];
23
25
  exports.getDeprecationMessage = getDeprecationMessage;
26
+ const getGenericOptionsHelp = () => (0, index_1.get)()[constants_1.CLI_GENERIC_OPTIONS_HELP];
27
+ exports.getGenericOptionsHelp = getGenericOptionsHelp;
package/config/index.js CHANGED
@@ -24,6 +24,7 @@ const CONFIGS_TO_KEEP = [
24
24
  constants_1.CLI_VERSION,
25
25
  constants_1.CLI_DEPRECATED,
26
26
  constants_1.CLI_DEPRECATION_MESSAGE,
27
+ constants_1.CLI_GENERIC_OPTIONS_HELP,
27
28
  ];
28
29
  const initialize = () => {
29
30
  const keep = {};
package/constants.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare const CLI_VERSION = "cli-version";
14
14
  export declare const CLI_DEPRECATED = "cli-deprecated";
15
15
  export declare const CLI_DEPRECATION_MESSAGE = "cli-deprecation-message";
16
16
  export declare const CLI_SUPPORTED_AUTHENTICATION_METHODS = "cli-supported-authentication-methods";
17
+ export declare const CLI_GENERIC_OPTIONS_HELP = "cli-generic-options-help";
17
18
  export declare const SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH: string[];
18
19
  export declare const DISCOVERY_METADATA_PATH = "discovery-metadata.json";
19
20
  export declare const X_CSRF_TOKEN = "x-csrf-token";
@@ -23,8 +24,9 @@ export declare const CACHE_SECRETS_FILE = "secrets.json";
23
24
  export declare const OPTION_VERSION: Option;
24
25
  export declare const OPTION_HELP: Option;
25
26
  export declare const OPTION_HOST: Option;
27
+ export declare const OPTION_LOGIN_ID: Option;
26
28
  export declare const OPTION_OUTPUT: Option;
27
- export declare const OPTION_PRETTY: Option;
29
+ export declare const OPTION_NO_PRETTY: Option;
28
30
  export declare const OPTION_VERBOSE: Option;
29
31
  export declare const OPTION_FORCE: Option;
30
32
  export declare const OPTION_CLIENT_ID: Option;
package/constants.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.OPTION_INPUT = exports.OPTION_FILE_PATH = exports.OPTION_OPTIONS_FILE = exports.CONFIG_PASSCODE_FUNCTION = exports.OPTION_PASSCODE = exports.OPTION_CODE = exports.OPTION_SECRETS_FILE = exports.OPTION_EXPIRES_IN = exports.OPTION_REFRESH_TOKEN = exports.OPTION_ACCESS_TOKEN = exports.OPTION_TOKEN_URL = exports.OPTION_AUTHORIZATION_URL = exports.OPTION_CLIENT_SECRET = exports.OPTION_CLIENT_ID = exports.OPTION_FORCE = exports.OPTION_VERBOSE = exports.OPTION_PRETTY = exports.OPTION_OUTPUT = exports.OPTION_HOST = exports.OPTION_HELP = exports.OPTION_VERSION = exports.CACHE_SECRETS_FILE = exports.PATH_TO_ERROR_HTML = exports.PATH_TO_SUCCESS_HTML = exports.X_CSRF_TOKEN = exports.DISCOVERY_METADATA_PATH = exports.SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = exports.CLI_SUPPORTED_AUTHENTICATION_METHODS = exports.CLI_DEPRECATION_MESSAGE = exports.CLI_DEPRECATED = exports.CLI_VERSION = exports.CLI_SAP_HELP = exports.CLI_DISCOVERY_PATH = exports.CLI_DESCRIPTION = exports.CLI_PACKAGE_NAME = exports.CLI_NAME = exports.AuthenticationMethod = exports.DISCOVERY_DOCUMENT_PREFIX = exports.VERSION = void 0;
6
+ exports.OPTION_INPUT = exports.OPTION_FILE_PATH = exports.OPTION_OPTIONS_FILE = exports.CONFIG_PASSCODE_FUNCTION = exports.OPTION_PASSCODE = exports.OPTION_CODE = exports.OPTION_SECRETS_FILE = exports.OPTION_EXPIRES_IN = exports.OPTION_REFRESH_TOKEN = exports.OPTION_ACCESS_TOKEN = exports.OPTION_TOKEN_URL = exports.OPTION_AUTHORIZATION_URL = exports.OPTION_CLIENT_SECRET = exports.OPTION_CLIENT_ID = exports.OPTION_FORCE = exports.OPTION_VERBOSE = exports.OPTION_NO_PRETTY = exports.OPTION_OUTPUT = exports.OPTION_LOGIN_ID = exports.OPTION_HOST = exports.OPTION_HELP = exports.OPTION_VERSION = exports.CACHE_SECRETS_FILE = exports.PATH_TO_ERROR_HTML = exports.PATH_TO_SUCCESS_HTML = exports.X_CSRF_TOKEN = exports.DISCOVERY_METADATA_PATH = exports.SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = exports.CLI_GENERIC_OPTIONS_HELP = exports.CLI_SUPPORTED_AUTHENTICATION_METHODS = exports.CLI_DEPRECATION_MESSAGE = exports.CLI_DEPRECATED = exports.CLI_VERSION = exports.CLI_SAP_HELP = exports.CLI_DISCOVERY_PATH = exports.CLI_DESCRIPTION = exports.CLI_PACKAGE_NAME = exports.CLI_NAME = exports.AuthenticationMethod = exports.DISCOVERY_DOCUMENT_PREFIX = exports.VERSION = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const utils_1 = require("./utils/utils");
9
9
  exports.VERSION = (0, utils_1.getVersion)();
@@ -22,6 +22,7 @@ exports.CLI_VERSION = "cli-version";
22
22
  exports.CLI_DEPRECATED = "cli-deprecated";
23
23
  exports.CLI_DEPRECATION_MESSAGE = "cli-deprecation-message";
24
24
  exports.CLI_SUPPORTED_AUTHENTICATION_METHODS = "cli-supported-authentication-methods";
25
+ exports.CLI_GENERIC_OPTIONS_HELP = "cli-generic-options-help";
25
26
  exports.SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = ["dwaas-core"];
26
27
  exports.DISCOVERY_METADATA_PATH = "discovery-metadata.json";
27
28
  exports.X_CSRF_TOKEN = "x-csrf-token";
@@ -31,33 +32,50 @@ exports.CACHE_SECRETS_FILE = "secrets.json";
31
32
  exports.OPTION_VERSION = {
32
33
  longName: "version",
33
34
  description: "print version",
35
+ hidden: true,
34
36
  };
35
37
  exports.OPTION_HELP = {
36
38
  longName: "help",
37
39
  description: "print help for a command",
38
40
  args: [{ name: "command" }],
41
+ hidden: true,
39
42
  };
40
43
  exports.OPTION_HOST = {
41
44
  longName: "host",
42
45
  description: "specifies the url where the tenant is hosted",
43
46
  args: [{ name: "host" }],
47
+ hidden: true,
44
48
  prompts: {
45
- message: "URL of the SAP Data Warehouse Cloud system to connect to:",
49
+ message: "URL of the system to connect to:",
46
50
  type: "text",
47
51
  },
48
52
  };
53
+ exports.OPTION_LOGIN_ID = {
54
+ longName: "login-id",
55
+ description: "specifies the login ID",
56
+ args: [{ name: "id" }],
57
+ default: "0",
58
+ required: true,
59
+ prompts: {
60
+ message: "ID of the login to logout from",
61
+ type: "select",
62
+ },
63
+ };
49
64
  exports.OPTION_OUTPUT = {
50
65
  longName: "output",
51
66
  description: "specifies the file to store the output of the command",
52
67
  args: [{ name: "output" }],
68
+ hidden: true,
53
69
  };
54
- exports.OPTION_PRETTY = {
55
- longName: "pretty",
56
- description: "pretty-formats JSON responses",
70
+ exports.OPTION_NO_PRETTY = {
71
+ longName: "no-pretty",
72
+ description: "do not pretty-format JSON responses",
73
+ hidden: true,
57
74
  };
58
75
  exports.OPTION_VERBOSE = {
59
76
  longName: "verbose",
60
77
  description: "print detailed log information to console",
78
+ hidden: true,
61
79
  };
62
80
  exports.OPTION_FORCE = {
63
81
  longName: "force",
@@ -67,6 +85,7 @@ exports.OPTION_CLIENT_ID = {
67
85
  longName: "client-id",
68
86
  description: "client id for interactive oauth session authentication",
69
87
  args: [{ name: "id" }],
88
+ hidden: true,
70
89
  prompts: {
71
90
  type: "text",
72
91
  message: `Please enter your client ID:`,
@@ -76,6 +95,7 @@ exports.OPTION_CLIENT_SECRET = {
76
95
  longName: "client-secret",
77
96
  description: "client secret for interactive oauth session authentication",
78
97
  args: [{ name: "secret" }],
98
+ hidden: true,
79
99
  prompts: {
80
100
  type: "password",
81
101
  message: `Please enter your client secret:`,
@@ -85,6 +105,7 @@ exports.OPTION_AUTHORIZATION_URL = {
85
105
  longName: "authorization-url",
86
106
  description: "authorization url for interactive oauth session authentication",
87
107
  args: [{ name: "url" }],
108
+ hidden: true,
88
109
  prompts: {
89
110
  type: "text",
90
111
  message: `Please enter your authorization URL:`,
@@ -94,6 +115,7 @@ exports.OPTION_TOKEN_URL = {
94
115
  longName: "token-url",
95
116
  description: "token url for interactive oauth session authentication",
96
117
  args: [{ name: "url" }],
118
+ hidden: true,
97
119
  prompts: {
98
120
  type: "text",
99
121
  message: `Please enter your token URL:`,
@@ -103,6 +125,7 @@ exports.OPTION_ACCESS_TOKEN = {
103
125
  longName: "access-token",
104
126
  description: "access token for interactive oauth session authentication",
105
127
  args: [{ name: "token" }],
128
+ hidden: true,
106
129
  prompts: {
107
130
  type: "password",
108
131
  message: `Please enter your access token:`,
@@ -112,6 +135,7 @@ exports.OPTION_REFRESH_TOKEN = {
112
135
  longName: "refresh-token",
113
136
  description: "refresh token for interactive oauth session authentication",
114
137
  args: [{ name: "token" }],
138
+ hidden: true,
115
139
  prompts: {
116
140
  type: "password",
117
141
  message: `Please enter your refresh token:`,
@@ -121,6 +145,7 @@ exports.OPTION_EXPIRES_IN = {
121
145
  longName: "expires-in",
122
146
  description: "expires in information for interactive oauth session authentication",
123
147
  args: [{ name: "expires" }],
148
+ hidden: true,
124
149
  prompts: {
125
150
  type: "number",
126
151
  message: `Please enter a value for expires in:`,
@@ -130,6 +155,7 @@ exports.OPTION_SECRETS_FILE = {
130
155
  longName: "secrets-file",
131
156
  description: "path to secrets file",
132
157
  args: [{ name: "file" }],
158
+ hidden: true,
133
159
  prompts: {
134
160
  type: "text",
135
161
  message: `Please enter the path to the secrets file:`,
@@ -139,6 +165,7 @@ exports.OPTION_CODE = {
139
165
  longName: "code",
140
166
  description: "code for oauth token retrieval",
141
167
  args: [{ name: "code" }],
168
+ hidden: true,
142
169
  prompts: {
143
170
  type: "text",
144
171
  message: `Please enter the code for retrieving the oauth access_token and refresh_token:`,
@@ -148,12 +175,14 @@ exports.OPTION_PASSCODE = {
148
175
  longName: "passcode",
149
176
  description: "passcode for interactive session authentication",
150
177
  args: [{ name: "passcode" }],
178
+ hidden: true,
151
179
  };
152
180
  exports.CONFIG_PASSCODE_FUNCTION = "passcodeFunction";
153
181
  exports.OPTION_OPTIONS_FILE = {
154
182
  longName: "options-file",
155
183
  description: "path to options file",
156
184
  args: [{ name: "file" }],
185
+ hidden: true,
157
186
  };
158
187
  exports.OPTION_FILE_PATH = {
159
188
  longName: "file-path",
@@ -41,13 +41,11 @@ const initMetadata = async () => {
41
41
  };
42
42
  const getMetadata = async () => {
43
43
  await initMetadata();
44
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
44
  return metadata;
46
45
  };
47
46
  exports.getMetadata = getMetadata;
48
47
  const addMetadata = async ({ tenant, addedAt, }) => {
49
48
  await initMetadata();
50
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
51
49
  metadata = metadata.filter((t) => t.tenant !== tenant);
52
50
  metadata.push({ tenant, addedAt });
53
51
  await (0, cache_1.writeFile)(constants_1.DISCOVERY_METADATA_PATH, JSON.stringify(metadata));
@@ -63,7 +61,6 @@ exports.clear = clear;
63
61
  const init = async () => {
64
62
  const { trace, error, debug } = getLogger();
65
63
  if (initialized) {
66
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67
64
  return document;
68
65
  }
69
66
  initialized = true;
@@ -101,7 +98,6 @@ const init = async () => {
101
98
  error("discovery document contains invalid data", result.errors);
102
99
  throw new Error("discovery document contains invalid data");
103
100
  }
104
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
105
101
  return document;
106
102
  };
107
103
  exports.init = init;