zcatalyst-cli 1.12.0 → 1.13.1

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 (181) hide show
  1. package/lib/apig-utils.js +39 -39
  2. package/lib/archiver.js +13 -9
  3. package/lib/authentication/index.js +22 -18
  4. package/lib/authentication/login.js +37 -39
  5. package/lib/bin/catalyst.js +15 -15
  6. package/lib/cli_table/src/cell.js +26 -26
  7. package/lib/cli_table/src/layout-manager.js +44 -45
  8. package/lib/cli_table/src/table.js +9 -9
  9. package/lib/cli_table/src/utils.js +35 -36
  10. package/lib/client-utils.js +18 -18
  11. package/lib/client.js +1 -1
  12. package/lib/command_needs/auth.js +7 -7
  13. package/lib/command_needs/rc.js +24 -24
  14. package/lib/commands/apig/disable.js +5 -5
  15. package/lib/commands/apig/enable.js +5 -5
  16. package/lib/commands/apig/status.js +9 -9
  17. package/lib/commands/client/delete.js +19 -19
  18. package/lib/commands/client/setup.js +8 -4
  19. package/lib/commands/deploy.js +18 -14
  20. package/lib/commands/ds/export.js +11 -11
  21. package/lib/commands/ds/import.js +12 -12
  22. package/lib/commands/ds/status.js +15 -15
  23. package/lib/commands/event/generate/index.js +21 -17
  24. package/lib/commands/event/generate/integ.js +7 -3
  25. package/lib/commands/functions/add.js +8 -4
  26. package/lib/commands/functions/config.js +5 -5
  27. package/lib/commands/functions/delete.js +22 -22
  28. package/lib/commands/functions/setup.js +8 -4
  29. package/lib/commands/functions/shell.js +7 -3
  30. package/lib/commands/help.js +4 -4
  31. package/lib/commands/iac/export.js +8 -8
  32. package/lib/commands/iac/import.js +29 -21
  33. package/lib/commands/iac/pack.js +15 -11
  34. package/lib/commands/iac/status.js +6 -2
  35. package/lib/commands/index.js +5 -1
  36. package/lib/commands/init.js +14 -10
  37. package/lib/commands/login.js +5 -1
  38. package/lib/commands/logout.js +5 -1
  39. package/lib/commands/project/list.js +14 -10
  40. package/lib/commands/project/reset.js +5 -5
  41. package/lib/commands/project/use.js +9 -9
  42. package/lib/commands/pull.js +18 -14
  43. package/lib/commands/run.js +13 -9
  44. package/lib/commands/serve.js +5 -1
  45. package/lib/commands/token/generate.js +6 -2
  46. package/lib/commands/token/list.js +7 -3
  47. package/lib/commands/token/revoke.js +6 -2
  48. package/lib/commands/whoami.js +3 -3
  49. package/lib/dc.js +2 -2
  50. package/lib/deploy/features/apig.js +6 -6
  51. package/lib/deploy/features/client.js +1 -1
  52. package/lib/deploy/features/functions/index.js +9 -9
  53. package/lib/deploy/features/index.js +5 -1
  54. package/lib/deploy/index.js +2 -2
  55. package/lib/endpoints/index.js +17 -13
  56. package/lib/endpoints/lib/apig.js +5 -5
  57. package/lib/endpoints/lib/applogic.js +4 -4
  58. package/lib/endpoints/lib/cache.js +3 -3
  59. package/lib/endpoints/lib/catalyst-details.js +1 -1
  60. package/lib/endpoints/lib/client.js +5 -5
  61. package/lib/endpoints/lib/datastore.js +2 -2
  62. package/lib/endpoints/lib/ds-bulk.js +5 -5
  63. package/lib/endpoints/lib/env.js +1 -1
  64. package/lib/endpoints/lib/event-bus.js +1 -1
  65. package/lib/endpoints/lib/filestore.js +2 -2
  66. package/lib/endpoints/lib/functions.js +4 -4
  67. package/lib/endpoints/lib/iac.js +10 -10
  68. package/lib/endpoints/lib/project.js +20 -5
  69. package/lib/endpoints/lib/queue.js +3 -3
  70. package/lib/endpoints/lib/sdk.js +1 -1
  71. package/lib/endpoints/lib/zcql.js +1 -1
  72. package/lib/error.js +1 -1
  73. package/lib/errorOut.js +2 -2
  74. package/lib/event_generate/cache.js +5 -5
  75. package/lib/event_generate/custom.js +2 -2
  76. package/lib/event_generate/datastore.js +5 -5
  77. package/lib/event_generate/filestore.js +5 -5
  78. package/lib/event_generate/integration/cliq.js +3 -3
  79. package/lib/event_generate/user.js +1 -1
  80. package/lib/event_generate/webapp.js +5 -5
  81. package/lib/execute-script.js +19 -15
  82. package/lib/express_middlewares/authenticator.js +29 -4
  83. package/lib/express_middlewares/logger.js +2 -2
  84. package/lib/express_middlewares/unknownReqProxy.js +1 -1
  85. package/lib/fn-utils/index.js +5 -1
  86. package/lib/fn-utils/lib/common.js +44 -44
  87. package/lib/fn-utils/lib/integ.js +9 -9
  88. package/lib/fn-utils/lib/java.js +48 -46
  89. package/lib/fn-utils/lib/node.js +7 -7
  90. package/lib/fn-watcher.js +9 -11
  91. package/lib/iac/status/bundle.js +5 -5
  92. package/lib/iac/status/deploy.js +4 -4
  93. package/lib/index.js +2 -2
  94. package/lib/init/dependencies/npm-install.js +1 -1
  95. package/lib/init/dependencies/package-json.js +6 -6
  96. package/lib/init/features/client/index.js +5 -1
  97. package/lib/init/features/client/initializers/angular.js +16 -12
  98. package/lib/init/features/client/initializers/basic.js +10 -6
  99. package/lib/init/features/client/initializers/lyte.js +11 -7
  100. package/lib/init/features/client/initializers/react.js +13 -9
  101. package/lib/init/features/functions/index.js +23 -14
  102. package/lib/init/features/functions/languages/java.js +10 -10
  103. package/lib/init/features/functions/languages/node.js +9 -9
  104. package/lib/init/features/index.js +12 -8
  105. package/lib/init/features/project.js +20 -20
  106. package/lib/init/index.js +2 -2
  107. package/lib/init/util/client.js +7 -3
  108. package/lib/init/util/functions.js +1 -1
  109. package/lib/init/util/project.js +4 -4
  110. package/lib/internal/api.js +19 -19
  111. package/lib/internal/command.js +20 -16
  112. package/lib/internal/config.js +5 -5
  113. package/lib/internal/credential.js +10 -10
  114. package/lib/internal/crypt.js +5 -5
  115. package/lib/internal/rc.js +5 -5
  116. package/lib/migration/global/1.6.2.js +3 -3
  117. package/lib/migration/index.js +22 -18
  118. package/lib/option-filter.js +34 -30
  119. package/lib/optional-import.js +12 -8
  120. package/lib/plugin-loader.js +7 -3
  121. package/lib/port-resolver.js +4 -4
  122. package/lib/progress.js +2 -2
  123. package/lib/prompt/index.js +6 -2
  124. package/lib/prompt/types/file-path.js +1 -1
  125. package/lib/pull/features/apig.js +9 -9
  126. package/lib/pull/features/client.js +7 -7
  127. package/lib/pull/features/functions/index.js +15 -15
  128. package/lib/pull/features/index.js +5 -1
  129. package/lib/pull/index.js +4 -4
  130. package/lib/repl-server.js +2 -2
  131. package/lib/serve/features/apig.js +1 -1
  132. package/lib/serve/features/index.js +8 -4
  133. package/lib/serve/index.js +15 -11
  134. package/lib/serve/server/index.js +34 -27
  135. package/lib/serve/server/lib/java/JavaaioServer.java +5 -3
  136. package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  137. package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  138. package/lib/serve/server/lib/java/lib/zip4j-2.5.0.jar +0 -0
  139. package/lib/serve/server/lib/master.js +33 -36
  140. package/lib/serve/server/lib/node.js +7 -3
  141. package/lib/serve/server/lib/web_client/index.js +3 -3
  142. package/lib/serve/server/lib/web_client/server.js +22 -19
  143. package/lib/shell/dependencies/http-functions.js +38 -33
  144. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +14 -3
  145. package/lib/shell/dependencies/invoker/bio/node.js +5 -2
  146. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +7 -2
  147. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +7 -2
  148. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +7 -2
  149. package/lib/shell/dependencies/invoker/integ/node.js +8 -4
  150. package/lib/shell/dependencies/local-function.js +44 -40
  151. package/lib/shell/index.js +12 -12
  152. package/lib/shell/prepare/index.js +2 -2
  153. package/lib/shell/prepare/languages/index.js +5 -1
  154. package/lib/shell/prepare/languages/java.js +1 -1
  155. package/lib/throbber/index.js +17 -17
  156. package/lib/throbber/utils.js +9 -9
  157. package/lib/track.js +7 -7
  158. package/lib/util_modules/config/index.js +5 -1
  159. package/lib/util_modules/constants/lib/auth.js +6 -6
  160. package/lib/util_modules/constants/lib/cliq-handlers.js +2 -2
  161. package/lib/util_modules/constants/lib/template.js +21 -21
  162. package/lib/util_modules/constants/lib/urls.js +11 -11
  163. package/lib/util_modules/context-help.js +15 -15
  164. package/lib/util_modules/fs/index.js +5 -1
  165. package/lib/util_modules/fs/lib/async.js +4 -4
  166. package/lib/util_modules/fs/utils.js +1 -1
  167. package/lib/util_modules/logger.js +2 -2
  168. package/lib/util_modules/parser/toml.js +1 -1
  169. package/lib/util_modules/project.js +6 -6
  170. package/lib/util_modules/server.js +53 -0
  171. package/lib/util_modules/shell.js +4 -4
  172. package/lib/winston.js +5 -5
  173. package/package.json +39 -39
  174. package/scripts/postInstall.js +7 -6
  175. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +21 -3
  176. package/{docs → templates/init/functions/node/integ/cliq}/.DS_Store +0 -0
  177. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +21 -5
  178. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -3
  179. package/templates/init/functions/node/integ/cliq/package.json +2 -1
  180. package/templates/init/functions/node/integ/cliq/sample.js +3 -1
  181. package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
@@ -22,7 +22,7 @@ const constants_1 = require("../../util_modules/constants");
22
22
  const js_1 = require("../../util_modules/js");
23
23
  const logger_1 = require("../../util_modules/logger");
24
24
  const option_1 = require("../../util_modules/option");
25
- const yaml_1 = __importDefault(require("yaml"));
25
+ const yaml_1 = require("yaml");
26
26
  const project_1 = require("../../util_modules/project");
27
27
  const path_1 = require("path");
28
28
  const functions_1 = require("../util/functions");
@@ -33,13 +33,13 @@ const fn_utils_1 = require("../../fn-utils");
33
33
  const client_utils_1 = require("../../client-utils");
34
34
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
35
35
  var _a, _b;
36
- const projectAPI = yield endpoints_1.projectAPI();
37
- const defaultRCProjectName = project_1.getDefaultProjectName(null);
38
- const defaultRCProjectId = project_1.getDefaultProjectId(null);
36
+ const projectAPI = yield (0, endpoints_1.projectAPI)();
37
+ const defaultRCProjectName = (0, project_1.getDefaultProjectName)(null);
38
+ const defaultRCProjectId = (0, project_1.getDefaultProjectId)(null);
39
39
  if (defaultRCProjectName !== null &&
40
40
  defaultRCProjectId !== null &&
41
- !option_1.getOptionValue('force', false)) {
42
- logger_1.message(constants_1.FILENAME.rc + ' already has ' + ansi_colors_1.bold(defaultRCProjectName) + ' as a default project.');
41
+ !(0, option_1.getOptionValue)('force', false)) {
42
+ (0, logger_1.message)(constants_1.FILENAME.rc + ' already has ' + (0, ansi_colors_1.bold)(defaultRCProjectName) + ' as a default project.');
43
43
  try {
44
44
  yield projectAPI.getProject(defaultRCProjectId);
45
45
  throw new error_1.default('Skipping project setup, since project directory contains a default project. To overwrite use --force option');
@@ -48,17 +48,17 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
48
48
  if (js_1.JS.get(err, 'context.response.statusCode') !== 404) {
49
49
  throw err;
50
50
  }
51
- logger_1.warning('cleaning up ' +
51
+ (0, logger_1.warning)('cleaning up ' +
52
52
  constants_1.FILENAME.rc +
53
53
  ' since the current default project for this folder is not found in remote');
54
- yield project_1.removeProject(defaultRCProjectId + '');
54
+ yield (0, project_1.removeProject)(defaultRCProjectId + '');
55
55
  }
56
56
  }
57
- logger_1.message('Setting up a new default project for this folder\n');
57
+ (0, logger_1.message)('Setting up a new default project for this folder\n');
58
58
  const allProjects = (yield projectAPI.getAllProjects());
59
59
  if (allProjects.length === 0) {
60
60
  throw new error_1.default('Visit ' +
61
- ansi_colors_1.underline(constants_1.ORIGIN.console) +
61
+ (0, ansi_colors_1.underline)(constants_1.ORIGIN.console) +
62
62
  ' for creation of your first project before you continue.', { exit: 1 });
63
63
  }
64
64
  const projectChoices = [
@@ -83,21 +83,21 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
83
83
  }));
84
84
  let selectedProject = projectAns.project;
85
85
  if (typeof selectedProject !== 'number') {
86
- return project_2.fillProjectPayload(selectedProject);
86
+ return (0, project_2.fillProjectPayload)(selectedProject);
87
87
  }
88
88
  if (selectedProject === 0) {
89
89
  const projectNameAns = yield prompt_1.default.ask(prompt_1.default.question('projectName', 'Provide a name for your new project:', {
90
90
  validate: (ans) => (ans.match(constants_1.REGEX.project.name) ? true : 'Invalid project name')
91
91
  }));
92
92
  selectedProject = yield projectAPI.createProject(projectNameAns.projectName);
93
- return project_2.fillProjectPayload(selectedProject, true);
93
+ return (0, project_2.fillProjectPayload)(selectedProject, true);
94
94
  }
95
- const [zipArchive, template, importRes] = yield import_1.iacImport();
95
+ const [zipArchive, template, importRes] = yield (0, import_1.iacImport)();
96
96
  yield zipArchive
97
97
  .extract(runtime_store_1.default.get('cwd'), '/', { recursive: true, ignoreInitial: false })
98
98
  .finalize();
99
99
  const parsedJSON = js_1.JS.parseJSON(template);
100
- const templateJson = parsedJSON ? parsedJSON : yaml_1.default.parse(template);
100
+ const templateJson = parsedJSON ? parsedJSON : (0, yaml_1.parse)(template);
101
101
  const functions = ((_a = templateJson.components) === null || _a === void 0 ? void 0 : _a.Functions) || [];
102
102
  const client = ((_b = templateJson.components) === null || _b === void 0 ? void 0 : _b.WebClient) || [];
103
103
  yield Promise.all(functions.map(({ properties }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -110,26 +110,26 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
110
110
  ? fn_utils_1.fnUtils.java
111
111
  : null;
112
112
  if (fnUtil === null) {
113
- logger_1.warning(`skipping setup of function(${refinedTargets[0].name}) since provided stack ${stack} is not supported.`);
113
+ (0, logger_1.warning)(`skipping setup of function(${refinedTargets[0].name}) since provided stack ${stack} is not supported.`);
114
114
  return;
115
115
  }
116
116
  yield fnUtil.validate(refinedTargets, 0);
117
117
  if (!refinedTargets[0].valid) {
118
- logger_1.debug('Invalid target : ' +
118
+ (0, logger_1.debug)('Invalid target : ' +
119
119
  refinedTargets[0].name +
120
120
  ' reason : ' +
121
121
  refinedTargets[0].failure_reason);
122
- logger_1.warning(`skipping setup of function(${refinedTargets[0].name}) since the package is invalid. \nContact catalyst support with debug log.`);
122
+ (0, logger_1.warning)(`skipping setup of function(${refinedTargets[0].name}) since the package is invalid. \nContact catalyst support with debug log.`);
123
123
  return;
124
124
  }
125
- functions_1.fillFunctionsInitPayload(source, properties.name, properties.stack, properties.type);
125
+ (0, functions_1.fillFunctionsInitPayload)(source, properties.name, properties.stack, properties.type);
126
126
  })));
127
127
  if (client.length > 0) {
128
128
  const { properties } = client[0];
129
129
  const source = properties.code.path.replace('/', path_1.sep).replace('.zip', '');
130
130
  yield client_utils_1.clientUtils.validate(source);
131
- client_1.fillClientInitPayload(source, properties.app_name);
131
+ (0, client_1.fillClientInitPayload)(source, properties.app_name);
132
132
  }
133
133
  const projectDetails = yield projectAPI.getProject(importRes.project_details.id);
134
- return project_2.fillProjectPayload(projectDetails, true, true);
134
+ return (0, project_2.fillProjectPayload)(projectDetails, true, true);
135
135
  });
package/lib/init/index.js CHANGED
@@ -31,14 +31,14 @@ function init() {
31
31
  errorId: 'INIT-IDX-1',
32
32
  arg: [
33
33
  ansi_colors_1.bold.red(feature),
34
- ansi_colors_1.bold(Object.keys(features_1.default)
34
+ (0, ansi_colors_1.bold)(Object.keys(features_1.default)
35
35
  .map((feat) => '* ' + feat)
36
36
  .join('\n'))
37
37
  ]
38
38
  });
39
39
  }
40
40
  const MODULE = features_1.default[feature];
41
- logger_1.info(ansi_colors_1.bold('\n' + ansi_colors_1.white('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
41
+ (0, logger_1.info)((0, ansi_colors_1.bold)('\n' + (0, ansi_colors_1.white)('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
42
42
  yield MODULE();
43
43
  runtime_store_1.default.set('payload.features', runtime_store_1.default.get('payload.features', []).concat(feature));
44
44
  return init();
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -49,7 +53,7 @@ function directoryOverridePrompt(dir) {
49
53
  return __awaiter(this, void 0, void 0, function* () {
50
54
  const foldeExists = yield ASYNC.dirExists(dir);
51
55
  if (foldeExists) {
52
- const overwriteAns = yield index_js_1.default.ask(index_js_1.default.question('overwrite', 'Directory ' + ansi_colors_1.underline(dir) + ' already exists. Overwrite ?', {
56
+ const overwriteAns = yield index_js_1.default.ask(index_js_1.default.question('overwrite', 'Directory ' + (0, ansi_colors_1.underline)(dir) + ' already exists. Overwrite ?', {
53
57
  type: 'confirm',
54
58
  defaultAns: false
55
59
  }));
@@ -90,7 +94,7 @@ function addDependency(filePath, dep, { dev = false, depPath = [] } = {}) {
90
94
  }
91
95
  catch (e) {
92
96
  const err = error_js_1.default.getErrorInstance(e, { skipHelp: true });
93
- logger_js_1.debug(`unable to write to ${filePath}: ${err.message}`);
97
+ (0, logger_js_1.debug)(`unable to write to ${filePath}: ${err.message}`);
94
98
  }
95
99
  });
96
100
  }
@@ -15,6 +15,6 @@ const fillFunctionsInitPayload = (source, name, stack, type) => {
15
15
  type
16
16
  });
17
17
  runtime_store_1.default.set('payload.functions.targets', existingFns);
18
- runtime_store_1.default.set('payload.functions.source', path_1.dirname(source));
18
+ runtime_store_1.default.set('payload.functions.source', (0, path_1.dirname)(source));
19
19
  };
20
20
  exports.fillFunctionsInitPayload = fillFunctionsInitPayload;
@@ -20,15 +20,15 @@ const constants_1 = require("../../util_modules/constants");
20
20
  const project_1 = require("../../util_modules/project");
21
21
  const fillProjectPayload = (selectedProject, isNew = false, isImport = false) => __awaiter(void 0, void 0, void 0, function* () {
22
22
  runtime_store_1.default.set('payload.project', selectedProject);
23
- runtime_store_1.default.set('project', project_1.transformProject(selectedProject));
24
- const envAPI = yield endpoints_1.envAPI();
25
- const envArr = (yield envAPI.getEnvs(project_1.getProjectId()));
23
+ runtime_store_1.default.set('project', (0, project_1.transformProject)(selectedProject));
24
+ const envAPI = yield (0, endpoints_1.envAPI)();
25
+ const envArr = (yield envAPI.getEnvs((0, project_1.getProjectId)()));
26
26
  const envObj = envArr.find((env) => env.env_name === constants_1.DEFAULT.env_name);
27
27
  if (envObj === undefined) {
28
28
  throw new error_1.default('There is no development environment found for this project. Kindly contact support.', { exit: 2 });
29
29
  }
30
30
  runtime_store_1.default.set('payload.env', envArr);
31
- runtime_store_1.default.set('project.env', project_1.transformEnv(envObj));
31
+ runtime_store_1.default.set('project.env', (0, project_1.transformEnv)(envObj));
32
32
  runtime_store_1.default.set('payload.project.new', isNew);
33
33
  runtime_store_1.default.set('payload.project.import', isImport);
34
34
  });
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -40,18 +44,14 @@ const constants_1 = require("../util_modules/constants");
40
44
  const js_1 = require("../util_modules/js");
41
45
  const logger_1 = require("../util_modules/logger");
42
46
  class API {
43
- constructor({ authNeeded = true, resolveOnError = false, maxRetry = 3, env = constants_1.DEFAULT.env_name, log = {} } = {}) {
47
+ constructor({ authNeeded = true, resolveOnError = false, maxRetry = 3, env = constants_1.DEFAULT.env_name, log = {}, headers = {} } = {}) {
44
48
  this.requestOpts = {
45
49
  url: constants_1.ORIGIN.admin,
46
50
  method: 'GET',
47
51
  json: true,
48
- headers: {
49
- Accept: 'application/vnd.catalyst.v2+json',
50
- 'User-Agent': runtime_store_1.default.get('context.cli.package.name') +
52
+ headers: Object.assign(Object.assign({}, headers), { Accept: 'application/vnd.catalyst.v2+json', 'User-Agent': runtime_store_1.default.get('context.cli.package.name') +
51
53
  '/' +
52
- runtime_store_1.default.get('context.cli.package.version'),
53
- 'X-CATALYST-Environment': env
54
- }
54
+ runtime_store_1.default.get('context.cli.package.version'), 'X-CATALYST-Environment': env })
55
55
  };
56
56
  this.authNeeded = authNeeded;
57
57
  this.resolveOnHTTPError = resolveOnError;
@@ -72,7 +72,7 @@ class API {
72
72
  ? '\nRequest Form: ' + JSON.stringify(this.requestOpts.form)
73
73
  : '';
74
74
  body = this.logOpts.skipReqBody === true ? '\n<request body omitted>' : body;
75
- logger_1.debug('>>>> HTTP REQUEST : ' +
75
+ (0, logger_1.debug)('>>>> HTTP REQUEST : ' +
76
76
  this.requestOpts.method +
77
77
  ' ' +
78
78
  this.requestOpts.url +
@@ -82,15 +82,15 @@ class API {
82
82
  '\n');
83
83
  }
84
84
  _logResp(resp) {
85
- logger_1.debug('<<<< HTTP RESPONSE : ' +
85
+ (0, logger_1.debug)('<<<< HTTP RESPONSE : ' +
86
86
  resp.statusCode +
87
87
  '\n' +
88
88
  'Response Headers: ' +
89
89
  JSON.stringify(resp.headers) +
90
90
  '\n');
91
91
  if (!js_1.JS.isUndefined(resp.timings)) {
92
- logger_1.debug('TOTAL TIME TAKEN : ' + Number(resp.timings.end.toFixed(3)) + ' ms\n');
93
- logger_1.debug('REQUEST PHASES : ' + resp.timingPhases);
92
+ (0, logger_1.debug)('TOTAL TIME TAKEN : ' + Number(resp.timings.end.toFixed(3)) + ' ms\n');
93
+ (0, logger_1.debug)('REQUEST PHASES : ' + resp.timingPhases);
94
94
  }
95
95
  if (this.logOpts.progress !== undefined) {
96
96
  js_1.JS.set(this.logOpts, 'progress.total', resp.headers['content-length']);
@@ -117,13 +117,13 @@ class API {
117
117
  }
118
118
  catch (e) {
119
119
  const err = error_1.default.getErrorInstance(e);
120
- logger_1.debug('API Parsing Error: ' + err.message);
120
+ (0, logger_1.debug)('API Parsing Error: ' + err.message);
121
121
  }
122
122
  }
123
123
  if (resp.statusCode >= 400 && !this.logOpts.skipRespBody) {
124
- logger_1.debug('Response Body : ' + JSON.stringify(resp.body) + '\n');
124
+ (0, logger_1.debug)('Response Body : ' + JSON.stringify(resp.body) + '\n');
125
125
  if (!this.resolveOnHTTPError) {
126
- throw errorResponse_1.default(resp, body);
126
+ throw (0, errorResponse_1.default)(resp, body);
127
127
  }
128
128
  }
129
129
  return {
@@ -142,8 +142,8 @@ class API {
142
142
  exit: 2
143
143
  });
144
144
  }
145
- logger_1.debug('API Error while firing request : ' + err.message + '\n');
146
- logger_1.debug('>>>> RETRYING\n');
145
+ (0, logger_1.debug)('API Error while firing request : ' + err.message + '\n');
146
+ (0, logger_1.debug)('>>>> RETRYING\n');
147
147
  return this._request(true);
148
148
  });
149
149
  }
@@ -155,13 +155,13 @@ class API {
155
155
  return new Promise((resolve, reject) => {
156
156
  const responseBuffer = [];
157
157
  let isJSONResponse = false;
158
- request_1.default(this.requestOpts, (err) => __awaiter(this, void 0, void 0, function* () {
158
+ (0, request_1.default)(this.requestOpts, (err) => __awaiter(this, void 0, void 0, function* () {
159
159
  if (err) {
160
160
  switch (err.code) {
161
161
  case 'ETIMEDOUT':
162
162
  case 'ENOTFOUND':
163
163
  case 'ESOCKETTIMEDOUT':
164
- logger_1.warning(err.code +
164
+ (0, logger_1.warning)(err.code +
165
165
  ' has occured while communicating remote server. Kindly be patient while the cli retries this request.');
166
166
  try {
167
167
  resolve(yield this._retry(err));
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -103,7 +107,7 @@ class Command {
103
107
  }
104
108
  if (this.helpText !== null) {
105
109
  cmd.on('--help', () => {
106
- logger_1.info(this.helpText);
110
+ (0, logger_1.info)(this.helpText);
107
111
  });
108
112
  }
109
113
  cmd.allowUnknownOption(this.allowUnknownOptions);
@@ -118,24 +122,24 @@ class Command {
118
122
  const argCount = cmd._args.length;
119
123
  if (programArgs.slice(-1)[0].args.length > argCount &&
120
124
  !this.allowUnknownOptions) {
121
- return errorOut_1.default(new error_1.default('Too many arguments', {
125
+ return (0, errorOut_1.default)(new error_1.default('Too many arguments', {
122
126
  exit: 1,
123
127
  errorId: 'CMD-1',
124
- arg: [ansi_colors_1.bold(cmd.name()), ansi_colors_1.bold('catalyst help ' + cmd.name())]
128
+ arg: [(0, ansi_colors_1.bold)(cmd.name()), (0, ansi_colors_1.bold)('catalyst help ' + cmd.name())]
125
129
  }));
126
130
  }
127
131
  try {
128
132
  yield runner.apply(this, programArgs);
129
133
  const duration = Date.now() - start;
130
- errorOut_1.default();
131
- yield track_1.default(this.cmdName, 'success', duration);
134
+ (0, errorOut_1.default)();
135
+ yield (0, track_1.default)(this.cmdName, 'success', duration);
132
136
  }
133
137
  catch (err) {
134
138
  const duration = Date.now() - start;
135
139
  const errorEvent = err.exit === 1 ? 'Error (User)' : 'Error (Unexpected)';
136
- const preppedMessage = strip_ansi_1.default(err.message || '');
137
- errorOut_1.default(err);
138
- yield track_1.default(errorEvent, preppedMessage, duration);
140
+ const preppedMessage = (0, strip_ansi_1.default)(err.message || '');
141
+ (0, errorOut_1.default)(err);
142
+ yield (0, track_1.default)(errorEvent, preppedMessage, duration);
139
143
  }
140
144
  }));
141
145
  return cmd;
@@ -149,16 +153,16 @@ class Command {
149
153
  return;
150
154
  }
151
155
  if (js_1.JS.indexOf(this.optIgnores, opts) > -1) {
152
- logger_1.warning('Cannot use option ' +
153
- ansi_colors_1.bold(opts) +
156
+ (0, logger_1.warning)('Cannot use option ' +
157
+ (0, ansi_colors_1.bold)(opts) +
154
158
  ' along with ' +
155
- ansi_colors_1.bold(this.command) +
159
+ (0, ansi_colors_1.bold)(this.command) +
156
160
  ' command. Hence ignored.');
157
161
  return;
158
162
  }
159
- option_1.setGlobalOption(opts, optsValue);
163
+ (0, option_1.setGlobalOption)(opts, optsValue);
160
164
  });
161
- runtime_store_1.default.set('project.root', project_1.getProjectRoot());
165
+ runtime_store_1.default.set('project.root', (0, project_1.getProjectRoot)());
162
166
  runtime_store_1.default.set('cwd', process.cwd());
163
167
  }
164
168
  runner() {
@@ -173,10 +177,10 @@ class Command {
173
177
  runtime_store_1.default.set('opts', Object.assign({ _name: command.name(), unknownOpts }, opts));
174
178
  this._prepare(command);
175
179
  try {
176
- yield migration_1.default(runtime_store_1.default.get('context.cli.package.version'));
180
+ yield (0, migration_1.default)(runtime_store_1.default.get('context.cli.package.version'));
177
181
  }
178
182
  catch (e) {
179
- logger_1.debug(e);
183
+ (0, logger_1.debug)(e);
180
184
  }
181
185
  yield Promise.all(js_1.JS.map(this.beforeRunners, (before) => __awaiter(this, void 0, void 0, function* () {
182
186
  const beforeModule = (yield Promise.resolve().then(() => __importStar(require('../command_needs/' + before.fn)))).default;
@@ -57,9 +57,9 @@ class Config {
57
57
  }
58
58
  static load(canIgnore) {
59
59
  return __awaiter(this, void 0, void 0, function* () {
60
- const pd = project_1.getProjectRoot();
60
+ const pd = (0, project_1.getProjectRoot)();
61
61
  try {
62
- const configPath = path_1.join(pd, constants_1.FILENAME.config);
62
+ const configPath = (0, path_1.join)(pd, constants_1.FILENAME.config);
63
63
  const data = yield fs_1.ASYNC.readJSONFile(configPath, { checkpath: true });
64
64
  if (data !== undefined) {
65
65
  const config = new Config(configPath, data);
@@ -74,16 +74,16 @@ class Config {
74
74
  fileName: __filename
75
75
  });
76
76
  err.errorId = 'CONFIG-1';
77
- err.arg = [ansi_colors_1.bold(constants_1.FILENAME.config), err.message];
77
+ err.arg = [(0, ansi_colors_1.bold)(constants_1.FILENAME.config), err.message];
78
78
  throw err;
79
79
  }
80
80
  if (canIgnore) {
81
- return new Config(path_1.join(pd, constants_1.FILENAME.config));
81
+ return new Config((0, path_1.join)(pd, constants_1.FILENAME.config));
82
82
  }
83
83
  throw new error_1.default('Not in a Catalyst app directory', {
84
84
  exit: 1,
85
85
  errorId: 'CONFIG-2',
86
- arg: [ansi_colors_1.bold(constants_1.FILENAME.config), ansi_colors_1.bold('catalyst init'), pd]
86
+ arg: [(0, ansi_colors_1.bold)(constants_1.FILENAME.config), (0, ansi_colors_1.bold)('catalyst init'), pd]
87
87
  });
88
88
  });
89
89
  }
@@ -28,18 +28,18 @@ class Credential {
28
28
  if (tokenObj.token === undefined ||
29
29
  js_1.JS.isEmpty(tokenObj.token) ||
30
30
  tokenObj.token.slice(1, 2) !== '_') {
31
- const tokenOption = option_1.getGlobalOptionValue('token');
31
+ const tokenOption = (0, option_1.getGlobalOptionValue)('token');
32
32
  if (tokenOption) {
33
33
  throw new error_1.default('Invalid token passed for authentication.', {
34
34
  exit: 1,
35
35
  errorId: 'CRED-1',
36
- arg: [tokenOption, ansi_colors_1.bold('--token')]
36
+ arg: [tokenOption, (0, ansi_colors_1.bold)('--token')]
37
37
  });
38
38
  }
39
39
  throw new error_1.default('Invalid token for authentication', {
40
40
  exit: 0,
41
41
  errorId: 'CRED-2',
42
- arg: [ansi_colors_1.bold('catalyst login --force')]
42
+ arg: [(0, ansi_colors_1.bold)('catalyst login --force')]
43
43
  });
44
44
  }
45
45
  this.cToken = tokenObj.token;
@@ -60,7 +60,7 @@ class Credential {
60
60
  }
61
61
  }
62
62
  _getTokenObjFromStore(pth = 'credential') {
63
- const encryptedToken = config_store_1.default.get(dc_1.getActiveDC() + '.' + pth, null);
63
+ const encryptedToken = config_store_1.default.get((0, dc_1.getActiveDC)() + '.' + pth, null);
64
64
  if (encryptedToken === null) {
65
65
  return null;
66
66
  }
@@ -73,7 +73,7 @@ class Credential {
73
73
  }
74
74
  _setTokenObjToStore(pth) {
75
75
  const encryptObj = Credential.crypt.encrypt(Credential.credentialObject);
76
- config_store_1.default.set(dc_1.getActiveDC() + '.' + pth, encryptObj);
76
+ config_store_1.default.set((0, dc_1.getActiveDC)() + '.' + pth, encryptObj);
77
77
  }
78
78
  _getAccessTokenFromCache() {
79
79
  if (js_1.JS.isEmpty(Credential.credentialObject)) {
@@ -111,7 +111,7 @@ class Credential {
111
111
  }
112
112
  }
113
113
  _destroyTokenObjFromStore(pth = 'credential') {
114
- const activeDC = dc_1.getActiveDC();
114
+ const activeDC = (0, dc_1.getActiveDC)();
115
115
  config_store_1.default.delete(activeDC + '.' + pth);
116
116
  if (pth === 'credential') {
117
117
  config_store_1.default.delete(`${activeDC}.user`);
@@ -121,7 +121,7 @@ class Credential {
121
121
  refreshAccessToken() {
122
122
  var _a, _b;
123
123
  return __awaiter(this, void 0, void 0, function* () {
124
- logger_1.debug('> refreshing access token <');
124
+ (0, logger_1.debug)('> refreshing access token <');
125
125
  const res = yield new api_1.default({ authNeeded: false })
126
126
  .post('/oauth/v2/token', {
127
127
  origin: constants_1.ORIGIN.auth,
@@ -143,10 +143,10 @@ class Credential {
143
143
  });
144
144
  if (!js_1.JS.isString(res.body.access_token)) {
145
145
  throw new error_1.default('unable to refresh access token.', {
146
- original: util_1.inspect(res.body),
146
+ original: (0, util_1.inspect)(res.body),
147
147
  exit: 0,
148
148
  errorId: 'CRED-2',
149
- arg: [ansi_colors_1.bold('catalyst login --force')]
149
+ arg: [(0, ansi_colors_1.bold)('catalyst login --force')]
150
150
  });
151
151
  }
152
152
  this._rebuildTokenCache(res);
@@ -216,7 +216,7 @@ class Credential {
216
216
  throw new error_1.default('Authentication required', {
217
217
  exit: 0,
218
218
  errorId: 'CRED-3',
219
- arg: [ansi_colors_1.bold('catalyst login')]
219
+ arg: [(0, ansi_colors_1.bold)('catalyst login')]
220
220
  });
221
221
  }
222
222
  return Credential.oneTimeToken;
@@ -12,16 +12,16 @@ class Crypt {
12
12
  return value;
13
13
  }
14
14
  const initializationVector = data.slice(0, 16);
15
- const password = crypto_1.pbkdf2Sync(this.encryptionKey, initializationVector.toString(), 1000, 32, 'sha512');
16
- const decipher = crypto_1.createDecipheriv(this.cryptAlgo, password, initializationVector);
15
+ const password = (0, crypto_1.pbkdf2Sync)(this.encryptionKey, initializationVector.toString(), 1000, 32, 'sha512');
16
+ const decipher = (0, crypto_1.createDecipheriv)(this.cryptAlgo, password, initializationVector);
17
17
  data = Buffer.concat([decipher.update(data.slice(17)), decipher.final()]);
18
18
  return this._deserialize(data.toString());
19
19
  }
20
20
  encrypt(value) {
21
21
  const data = this._serialize(value);
22
- const initializationVector = crypto_1.randomBytes(16);
23
- const password = crypto_1.pbkdf2Sync(this.encryptionKey, initializationVector.toString(), 1000, 32, 'sha512');
24
- const cipher = crypto_1.createCipheriv(this.cryptAlgo, password, initializationVector);
22
+ const initializationVector = (0, crypto_1.randomBytes)(16);
23
+ const password = (0, crypto_1.pbkdf2Sync)(this.encryptionKey, initializationVector.toString(), 1000, 32, 'sha512');
24
+ const cipher = (0, crypto_1.createCipheriv)(this.cryptAlgo, password, initializationVector);
25
25
  const dataBuff = Buffer.concat([
26
26
  initializationVector,
27
27
  Buffer.from(':'),
@@ -161,7 +161,7 @@ class RC {
161
161
  throw new error_1.default('Unable to find and remove project object in RC file with project ID : ' + id, { exit: 2 });
162
162
  }
163
163
  if (projectArr.length === 0) {
164
- logger_1.warning('No projects found in ' + constants_1.FILENAME.rc + ' hence removing it.');
164
+ (0, logger_1.warning)('No projects found in ' + constants_1.FILENAME.rc + ' hence removing it.');
165
165
  return this.delete();
166
166
  }
167
167
  this._reIndex(projectArr, removedProjectArr[0].idx, 'project');
@@ -273,11 +273,11 @@ class RC {
273
273
  }
274
274
  static load() {
275
275
  return __awaiter(this, void 0, void 0, function* () {
276
- const pd = project_1.getProjectRoot();
277
- if (yield fs_1.ASYNC.fileExists(path_1.normalize(path_1.join(pd, constants_1.FILENAME.rc)))) {
278
- return RC.loadFile(path_1.normalize(path_1.join(pd, constants_1.FILENAME.rc)));
276
+ const pd = (0, project_1.getProjectRoot)();
277
+ if (yield fs_1.ASYNC.fileExists((0, path_1.normalize)((0, path_1.join)(pd, constants_1.FILENAME.rc)))) {
278
+ return RC.loadFile((0, path_1.normalize)((0, path_1.join)(pd, constants_1.FILENAME.rc)));
279
279
  }
280
- return new RC(path_1.normalize(path_1.join(pd, constants_1.FILENAME.rc)));
280
+ return new RC((0, path_1.normalize)((0, path_1.join)(pd, constants_1.FILENAME.rc)));
281
281
  });
282
282
  }
283
283
  }
@@ -22,9 +22,9 @@ const migrate = () => {
22
22
  if (config_store_1.default.has(constants_1.DC_TYPE.eu.value)) {
23
23
  config_store_1.default.delete(constants_1.DC_TYPE.eu.value + '.usage');
24
24
  }
25
- logger_1.info();
26
- logger_1.info(ansi_colors_1.bold.cyan('Note: ') +
25
+ (0, logger_1.info)();
26
+ (0, logger_1.info)(ansi_colors_1.bold.cyan('Note: ') +
27
27
  'The usage statistics collection will be done based on the consent provided with the login.');
28
- logger_1.info();
28
+ (0, logger_1.info)();
29
29
  };
30
30
  exports.migrate = migrate;