@speedkit/cli 2.14.3 → 2.16.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 (113) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +5 -2
  3. package/dist/commands/generate-pop-config.js +6 -5
  4. package/dist/dummy.spec.js +4 -4
  5. package/dist/helpers/build-query-helper.js +49 -35
  6. package/dist/helpers/file-helper.d.ts +2 -8
  7. package/dist/helpers/file-helper.js +6 -41
  8. package/dist/helpers/get-parsed-config.js +7 -7
  9. package/dist/helpers/getChromePath.js +11 -7
  10. package/dist/helpers/isDirectory.js +1 -1
  11. package/dist/helpers/isFile.js +1 -1
  12. package/dist/helpers/normalize.d.ts +2 -0
  13. package/dist/helpers/normalize.js +14 -12
  14. package/dist/helpers/race.js +3 -1
  15. package/dist/helpers/scrape.js +3 -2
  16. package/dist/helpers/speedKitRuleToRegExp.js +2 -2
  17. package/dist/models/cli-parameters.d.ts +2 -2
  18. package/dist/models/cli-parameters.js +8 -2
  19. package/dist/models/files.js +13 -13
  20. package/dist/services/athena/athena-service-factory.d.ts +13 -0
  21. package/dist/services/athena/athena-service-factory.js +40 -0
  22. package/dist/services/athena/athena-service-model.d.ts +4 -0
  23. package/dist/services/athena/athena-service-model.js +7 -0
  24. package/dist/services/{athena-service.d.ts → athena/athena-service.d.ts} +4 -8
  25. package/dist/services/{athena-service.js → athena/athena-service.js} +12 -36
  26. package/dist/services/athena/error/fetch-credentials-error.d.ts +2 -0
  27. package/dist/services/athena/error/fetch-credentials-error.js +6 -0
  28. package/dist/services/athena/index.d.ts +4 -0
  29. package/dist/services/athena/index.js +7 -0
  30. package/dist/services/bundler/bundle-service-factory.d.ts +1 -1
  31. package/dist/services/bundler/bundle-service.d.ts +2 -2
  32. package/dist/services/bundler/bundle-service.js +29 -23
  33. package/dist/services/bundler/index.d.ts +2 -2
  34. package/dist/services/cli/cli-service.js +5 -5
  35. package/dist/services/cli/hooks.js +2 -2
  36. package/dist/services/cli/index.d.ts +3 -3
  37. package/dist/services/config-api/client.d.ts +1 -1
  38. package/dist/services/config-api/client.js +9 -7
  39. package/dist/services/config-api/config-api-service.js +20 -8
  40. package/dist/services/config-api/factory/config-api-service-factory.js +1 -1
  41. package/dist/services/config-api/interface/request-extension-interface.d.ts +2 -2
  42. package/dist/services/customer-config/customer-config-service-context.js +1 -1
  43. package/dist/services/customer-config/customer-config-service.d.ts +1 -0
  44. package/dist/services/customer-config/customer-config-service.js +68 -57
  45. package/dist/services/customer-config/index.d.ts +4 -4
  46. package/dist/services/deploy/builder/install-resource-builder.js +9 -7
  47. package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +2 -2
  48. package/dist/services/deploy/checks/post-deploy/save-files-check.js +2 -2
  49. package/dist/services/deploy/deploy-service.js +7 -7
  50. package/dist/services/deploy/handler/customer-config-handler.js +12 -11
  51. package/dist/services/deploy/handler/install-resource-handler.js +14 -12
  52. package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +10 -10
  53. package/dist/services/deploy/handler/module-handler.js +9 -9
  54. package/dist/services/deploy/handler/module-modifier/deployment-detection-modifier.js +2 -2
  55. package/dist/services/deploy/handler/server-config-handler.js +4 -4
  56. package/dist/services/deploy/interface/install.d.ts +1 -1
  57. package/dist/services/document-handler-runtime/context/document-handler-runtime-context.js +37 -18
  58. package/dist/services/document-handler-runtime/document-handler-runtime-service.js +45 -35
  59. package/dist/services/document-handler-runtime/document-handler-server.js +56 -33
  60. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js +1 -1
  61. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +20 -16
  62. package/dist/services/document-handler-runtime/templates/abstract-template.d.ts +1 -1
  63. package/dist/services/document-handler-runtime/templates/abstract-template.js +1 -1
  64. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.js +1 -1
  65. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.js +1 -1
  66. package/dist/services/error-handling/abstract/abstract-error-handling-factory.js +1 -1
  67. package/dist/services/error-handling/abstract/abstract-error-handling-service.js +1 -1
  68. package/dist/services/error-handling/error/handler/default-error-handler.d.ts +1 -1
  69. package/dist/services/error-handling/error/handler/default-error-handler.js +1 -1
  70. package/dist/services/error-handling/error-handling-service.js +2 -2
  71. package/dist/services/integration-api/context/integration-api-context.js +1 -1
  72. package/dist/services/integration-api/external/external-file-reader.js +1 -1
  73. package/dist/services/integration-api/factory/integration-api-service-factory.js +3 -3
  74. package/dist/services/integration-api/file-list.js +6 -4
  75. package/dist/services/integration-api/file-reader.js +17 -12
  76. package/dist/services/integration-api/handler/file-handler.d.ts +1 -1
  77. package/dist/services/integration-api/handler/file-handler.js +8 -4
  78. package/dist/services/integration-api/handler/install-resource-handler.js +21 -20
  79. package/dist/services/integration-api/handler/server-config-handler.js +1 -3
  80. package/dist/services/integration-api/integration-api-model.d.ts +2 -2
  81. package/dist/services/integration-api/integration-api-service.js +10 -7
  82. package/dist/services/integration-api/struct/customer-config.js +3 -2
  83. package/dist/services/integration-api/struct/file.js +4 -4
  84. package/dist/services/integration-api/struct/module-file.d.ts +1 -1
  85. package/dist/services/integration-api/struct/module-file.js +3 -1
  86. package/dist/services/integration-api/struct/server-config-file.d.ts +1 -1
  87. package/dist/services/integration-api/validator/customer-config-validator.js +13 -4
  88. package/dist/services/integration-api/validator/mandatory-files-validator.js +9 -5
  89. package/dist/services/integration-api/virtual/virtual-file-handler.js +1 -1
  90. package/dist/services/onboarding/dashboard/frontend-dist/assets/{index-87b53ed4.css → index-e3bd4f6e.css} +1 -1
  91. package/dist/services/onboarding/dashboard/frontend-dist/assets/{main-274b5625.js → main-215271c2.js} +3 -3
  92. package/dist/services/onboarding/dashboard/frontend-dist/index.html +2 -2
  93. package/dist/services/onboarding/dashboard/index.d.ts +2 -1
  94. package/dist/services/onboarding/dashboard/index.js +6 -5
  95. package/dist/services/onboarding/dashboard/request-diff-service.d.ts +4 -2
  96. package/dist/services/onboarding/dashboard/request-diff-service.js +23 -14
  97. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +1 -0
  98. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +18 -1
  99. package/dist/services/onboarding/onboarding-service-factory.d.ts +0 -1
  100. package/dist/services/onboarding/onboarding-service-factory.js +9 -34
  101. package/dist/services/pop-config/index.d.ts +3 -0
  102. package/dist/services/pop-config/index.js +6 -0
  103. package/dist/services/pop-config/pop-config-factory.d.ts +4 -0
  104. package/dist/services/pop-config/pop-config-factory.js +12 -0
  105. package/dist/services/pop-config/pop-config-model.d.ts +6 -0
  106. package/dist/services/pop-config/pop-config-model.js +2 -0
  107. package/dist/services/pop-config/pop-config-service.d.ts +7 -0
  108. package/dist/services/pop-config/pop-config-service.js +39 -0
  109. package/dist/services/prewarm-service.js +22 -16
  110. package/oclif.manifest.json +1 -1
  111. package/package.json +2 -4
  112. package/dist/services/onboarding/dashboard/athena-service.d.ts +0 -11
  113. package/dist/services/onboarding/dashboard/athena-service.js +0 -75
@@ -1,24 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TEST_PACKAGE_JSON = exports.TEST_RUNTIME_FILE_NAME = exports.TEST_FILE_NAME_PREFIX = exports.TEST_ORESTES_MOCK_FILE_NAME = exports.TEST_DATABASE_MOCK_FILE_NAME = exports.TEST_DOCUMENT_HANDLER_FILE_NAME = exports.LATEST_DYNAMIC_FETCHER_URL = exports.LATEST_DOCUMENT_HANDLER_URL = exports.LOCAL_STYLES = exports.LOCAL_DYNAMIC_FETCHER_CONFIG = exports.LOCAL_DYNAMIC_FETCHER = exports.LOCAL_DOCUMENT_HANDLER_CONFIG = exports.LOCAL_DOCUMENT_HANDLER = exports.CUSTOMER_CONFIG = void 0;
4
- exports.CUSTOMER_CONFIG = 'config_customer';
5
- exports.LOCAL_DOCUMENT_HANDLER = 'custom_documentHandler';
6
- exports.LOCAL_DOCUMENT_HANDLER_CONFIG = 'config_documentHandler';
7
- exports.LOCAL_DYNAMIC_FETCHER = 'custom_dynamicFetcher';
8
- exports.LOCAL_DYNAMIC_FETCHER_CONFIG = 'config_dynamicBlocks';
9
- exports.LOCAL_STYLES = 'config_dynamicStyles';
10
- exports.LATEST_DOCUMENT_HANDLER_URL = 'https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js';
11
- exports.LATEST_DYNAMIC_FETCHER_URL = 'https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js';
12
- exports.TEST_DOCUMENT_HANDLER_FILE_NAME = 'testDocumentHandler';
13
- exports.TEST_DATABASE_MOCK_FILE_NAME = 'database-mock';
14
- exports.TEST_ORESTES_MOCK_FILE_NAME = 'orestes-mock';
15
- exports.TEST_FILE_NAME_PREFIX = 'document';
16
- exports.TEST_RUNTIME_FILE_NAME = 'runtime';
17
- exports.TEST_PACKAGE_JSON = 'package';
18
- const FILE_DEPENDENCIES = [exports.LOCAL_DOCUMENT_HANDLER_CONFIG, exports.LOCAL_DYNAMIC_FETCHER_CONFIG, exports.LOCAL_STYLES, exports.TEST_DATABASE_MOCK_FILE_NAME, exports.TEST_ORESTES_MOCK_FILE_NAME, exports.TEST_DOCUMENT_HANDLER_FILE_NAME, exports.TEST_PACKAGE_JSON, exports.TEST_RUNTIME_FILE_NAME];
4
+ exports.CUSTOMER_CONFIG = "config_customer";
5
+ exports.LOCAL_DOCUMENT_HANDLER = "custom_documentHandler";
6
+ exports.LOCAL_DOCUMENT_HANDLER_CONFIG = "config_documentHandler";
7
+ exports.LOCAL_DYNAMIC_FETCHER = "custom_dynamicFetcher";
8
+ exports.LOCAL_DYNAMIC_FETCHER_CONFIG = "config_dynamicBlocks";
9
+ exports.LOCAL_STYLES = "config_dynamicStyles";
10
+ exports.LATEST_DOCUMENT_HANDLER_URL = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
11
+ exports.LATEST_DYNAMIC_FETCHER_URL = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
12
+ exports.TEST_DOCUMENT_HANDLER_FILE_NAME = "testDocumentHandler";
13
+ exports.TEST_DATABASE_MOCK_FILE_NAME = "database-mock";
14
+ exports.TEST_ORESTES_MOCK_FILE_NAME = "orestes-mock";
15
+ exports.TEST_FILE_NAME_PREFIX = "document";
16
+ exports.TEST_RUNTIME_FILE_NAME = "runtime";
17
+ exports.TEST_PACKAGE_JSON = "package";
18
+ const FILE_DEPENDENCIES = [
19
+ exports.LOCAL_DOCUMENT_HANDLER_CONFIG,
20
+ exports.LOCAL_DYNAMIC_FETCHER_CONFIG,
21
+ exports.LOCAL_STYLES,
22
+ exports.TEST_DATABASE_MOCK_FILE_NAME,
23
+ exports.TEST_ORESTES_MOCK_FILE_NAME,
24
+ exports.TEST_DOCUMENT_HANDLER_FILE_NAME,
25
+ exports.TEST_PACKAGE_JSON,
26
+ exports.TEST_RUNTIME_FILE_NAME,
27
+ ];
19
28
  class DocumentHandlerRuntimeContext {
20
29
  verboseLevel;
21
- fileDependencies = FILE_DEPENDENCIES.concat([exports.LOCAL_DOCUMENT_HANDLER, exports.LOCAL_DYNAMIC_FETCHER]);
30
+ fileDependencies = FILE_DEPENDENCIES.concat([
31
+ exports.LOCAL_DOCUMENT_HANDLER,
32
+ exports.LOCAL_DYNAMIC_FETCHER,
33
+ ]);
22
34
  customerPath;
23
35
  configName;
24
36
  testNames;
@@ -31,11 +43,18 @@ class DocumentHandlerRuntimeContext {
31
43
  let dependencies = [];
32
44
  if (this.testNames && this.testNames.length >= 1) {
33
45
  this.testNames.forEach((testName) => {
34
- dependencies = dependencies.concat([`${exports.TEST_FILE_NAME_PREFIX}-${testName}`]);
46
+ dependencies = dependencies.concat([
47
+ `${exports.TEST_FILE_NAME_PREFIX}-${testName}`,
48
+ ]);
35
49
  });
36
50
  this.fileDependencies = this.fileDependencies.concat(dependencies);
37
51
  }
38
- this.requiredFiles = [exports.CUSTOMER_CONFIG, exports.LOCAL_DOCUMENT_HANDLER_CONFIG, exports.LOCAL_DYNAMIC_FETCHER_CONFIG, exports.LOCAL_STYLES];
52
+ this.requiredFiles = [
53
+ exports.CUSTOMER_CONFIG,
54
+ exports.LOCAL_DOCUMENT_HANDLER_CONFIG,
55
+ exports.LOCAL_DYNAMIC_FETCHER_CONFIG,
56
+ exports.LOCAL_STYLES,
57
+ ];
39
58
  }
40
59
  }
41
60
  exports.default = DocumentHandlerRuntimeContext;
@@ -14,7 +14,9 @@ class DocumentHandlerRuntimeService {
14
14
  customerConfig;
15
15
  cli;
16
16
  config;
17
- constructor(files, customerConfig, cli, config, preHook, postHook) {
17
+ constructor(files, customerConfig, cli, config,
18
+ /* eslint-disable @typescript-eslint/no-unused-vars */
19
+ preHook, postHook) {
18
20
  this.files = files;
19
21
  this.customerConfig = customerConfig;
20
22
  this.cli = cli;
@@ -33,17 +35,17 @@ class DocumentHandlerRuntimeService {
33
35
  }
34
36
  outputInstructionMessage() {
35
37
  this.cli.spacer();
36
- this.cli.writeSuccess('check files in: ./.local/test/');
38
+ this.cli.writeSuccess("check files in: ./.local/test/");
37
39
  this.cli.spacer();
38
40
  if (this.config) {
39
- this.cli.writeWarning('### generated testCases:');
40
- this.cli.write('to run testCases either open testFile in ./.local/test/ and use intelliJ to run currentFile');
41
- this.cli.write('or switch to folder `cd ./.local/test/` and run `node ./.local/test/TEST_CASE.js`');
41
+ this.cli.writeWarning("### generated testCases:");
42
+ this.cli.write("to run testCases either open testFile in ./.local/test/ and use intelliJ to run currentFile");
43
+ this.cli.write("or switch to folder `cd ./.local/test/` and run `node ./.local/test/TEST_CASE.js`");
42
44
  this.cli.spacer();
43
45
  }
44
- this.cli.writeWarning('### usage of runtime.js:');
45
- this.cli.write('open file `./.local/src/runtime.js` customize your testCases as needed');
46
- this.cli.write('f.e.: add more testCases, change the variation or set a custom header');
46
+ this.cli.writeWarning("### usage of runtime.js:");
47
+ this.cli.write("open file `./.local/src/runtime.js` customize your testCases as needed");
48
+ this.cli.write("f.e.: add more testCases, change the variation or set a custom header");
47
49
  this.cli.code(`
48
50
  // defaultTestCase
49
51
  const files = [
@@ -55,29 +57,29 @@ class DocumentHandlerRuntimeService {
55
57
  },
56
58
  ]`);
57
59
  this.cli.spacer();
58
- this.cli.write('run current file with intellij or run node ./.local/src/runtime.js');
59
- this.cli.write('the runtime will now loop your given files, download them, and write the output to');
60
- this.cli.write('./.local/$FILE$ITERATION$VARIATION_processed.html');
60
+ this.cli.write("run current file with intellij or run node ./.local/src/runtime.js");
61
+ this.cli.write("the runtime will now loop your given files, download them, and write the output to");
62
+ this.cli.write("./.local/$FILE$ITERATION$VARIATION_processed.html");
61
63
  this.cli.spacer();
62
- this.cli.writeWarning('### usage of debugger with runtime.js:');
63
- this.cli.write('Its also possible to set breakpoints in the generated file: ./.local/src/testDocumentHandler.js');
64
- this.cli.write('1. set breakpoints as you wish');
65
- this.cli.write('2. open file ./.local/src/runtime.js');
66
- this.cli.write('3. debug current file with intellij');
64
+ this.cli.writeWarning("### usage of debugger with runtime.js:");
65
+ this.cli.write("Its also possible to set breakpoints in the generated file: ./.local/src/testDocumentHandler.js");
66
+ this.cli.write("1. set breakpoints as you wish");
67
+ this.cli.write("2. open file ./.local/src/runtime.js");
68
+ this.cli.write("3. debug current file with intellij");
67
69
  }
68
70
  async createDocumentHandlerFile() {
69
71
  const docHandler = await this.getDocumentHandler();
70
72
  const docHandlerConfig = this.getDocumentHandlerConfig()
71
- .replace('APP', this.escapeFileContent(this.customerConfig.app))
72
- .replace('DYNAMIC_FETCHER', await this.getDynamicFetcher())
73
- .replace('DYNAMIC_FETCHER_CONFIG', this.getDynamicFetcherConfig())
74
- .replace('CUSTOM_STYLES', this.getStyles())
73
+ .replace("APP", this.escapeFileContent(this.customerConfig.app))
74
+ .replace("DYNAMIC_FETCHER", await this.getDynamicFetcher())
75
+ .replace("DYNAMIC_FETCHER_CONFIG", this.getDynamicFetcherConfig())
76
+ .replace("CUSTOM_STYLES", this.getStyles())
75
77
  .replace(this.getConfigTransformSearchTemplate(), this.getConfigTransformReplaceTemplate());
76
78
  const file = this.getTestDocHandlerFile();
77
79
  const isNew = file.getContent().length < 1;
78
- file.setContent(`${this.getSeparator('Context')} ${this.getContextVars()} ${docHandler} ${this.getSeparator('start config_documentHandler')} ${docHandlerConfig}`);
80
+ file.setContent(`${this.getSeparator("Context")} ${this.getContextVars()} ${docHandler} ${this.getSeparator("start config_documentHandler")} ${docHandlerConfig}`);
79
81
  await file.updateFile();
80
- this.cli.writeSuccess(`${isNew ? 'created' : 'updated'} documentHandler from config`);
82
+ this.cli.writeSuccess(`${isNew ? "created" : "updated"} documentHandler from config`);
81
83
  }
82
84
  async createDataBaseMockFile() {
83
85
  const file = this.files.getByName(document_handler_runtime_context_1.TEST_DATABASE_MOCK_FILE_NAME);
@@ -90,7 +92,7 @@ class DocumentHandlerRuntimeService {
90
92
  const dataBaseMock = new database_mock_1.default();
91
93
  file.setContent(dataBaseMock.render(dataBaseMock.buildContext(this.customerConfig.origins[0], this.customerConfig.app)));
92
94
  await file.updateFile();
93
- this.cli.writeSuccess('created db-mock file');
95
+ this.cli.writeSuccess("created db-mock file");
94
96
  }
95
97
  async createTestCases(names) {
96
98
  names.map(async (name) => this.createTestCase(name));
@@ -117,7 +119,7 @@ class DocumentHandlerRuntimeService {
117
119
  return;
118
120
  }
119
121
  }
120
- file.setContent(runtime.render(runtime.buildContext(this.customerConfig.origins[0], 'test')));
122
+ file.setContent(runtime.render(runtime.buildContext(this.customerConfig.origins[0], "test")));
121
123
  await file.updateFile();
122
124
  this.cli.writeSuccess(`created runtime file: ${document_handler_runtime_context_1.TEST_RUNTIME_FILE_NAME}`);
123
125
  }
@@ -155,17 +157,23 @@ class DocumentHandlerRuntimeService {
155
157
  const response = await (0, node_fetch_1.default)(document_handler_runtime_context_1.LATEST_DOCUMENT_HANDLER_URL);
156
158
  return await response.text();
157
159
  }
158
- return this.files.getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER).getContent();
160
+ return this.files
161
+ .getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER)
162
+ .getContent();
159
163
  }
160
164
  async getDynamicFetcher() {
161
165
  if (!this.files.hasFile(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER)) {
162
166
  const response = await (0, node_fetch_1.default)(document_handler_runtime_context_1.LATEST_DYNAMIC_FETCHER_URL);
163
167
  return this.escapeFileContent2(await response.text());
164
168
  }
165
- return this.escapeFileContent(this.files.getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER).getContent());
169
+ return this.escapeFileContent(this.files
170
+ .getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER)
171
+ .getContent());
166
172
  }
167
173
  getDynamicFetcherConfig() {
168
- return this.escapeFileContent(this.files.getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER_CONFIG).getContent());
174
+ return this.escapeFileContent(this.files
175
+ .getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER_CONFIG)
176
+ .getContent());
169
177
  }
170
178
  getStyles() {
171
179
  return this.escapeFileContent(this.files.getByName(document_handler_runtime_context_1.LOCAL_STYLES).getContent());
@@ -173,7 +181,9 @@ class DocumentHandlerRuntimeService {
173
181
  getDocumentHandlerConfig() {
174
182
  const docHandlerFile = this.files.getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG);
175
183
  if (!docHandlerFile) {
176
- throw new required_file_not_found_error_1.default({ message: `file ${document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG} not found` });
184
+ throw new required_file_not_found_error_1.default({
185
+ message: `file ${document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG} not found`,
186
+ });
177
187
  }
178
188
  return docHandlerFile.getContent();
179
189
  }
@@ -187,13 +197,12 @@ class DocumentHandlerRuntimeService {
187
197
  return `\`${escapedContent}\``;
188
198
  }
189
199
  escapeFileContent2(content) {
190
- const escapedContent = content
191
- .replace(/'/g, "\\'");
200
+ const escapedContent = content.replace(/'/g, "\\'");
192
201
  return `'${escapedContent}'`;
193
202
  }
194
203
  getContextVars() {
195
- let template = '';
196
- for (let key in this.customerConfig) {
204
+ let template = "";
205
+ for (const key in this.customerConfig) {
197
206
  template += `var ${key.toUpperCase()} = '${this.customerConfig[key]}';\n`;
198
207
  }
199
208
  return template;
@@ -202,12 +211,13 @@ class DocumentHandlerRuntimeService {
202
211
  return /export.const.post(?:.|\n)*?documentHandler\.transform(?:.|\n)*?}/;
203
212
  }
204
213
  getConfigTransformReplaceTemplate() {
205
- return this.getSeparator('end config_documentHandler') + `\n \n
214
+ return (this.getSeparator("end config_documentHandler") +
215
+ `\n \n
206
216
  // Annotate the CommonJS export names for ESM import in node:
207
217
  module.exports = documentHandler
208
- `;
218
+ `);
209
219
  }
210
- getSeparator(headline = '') {
220
+ getSeparator(headline = "") {
211
221
  return `
212
222
  /*
213
223
  * ====================================================================
@@ -10,7 +10,7 @@ const vm_error_1 = require("../onboarding/error/vm-error");
10
10
  const path_1 = tslib_1.__importDefault(require("path"));
11
11
  const files_1 = require("../../models/files");
12
12
  // documentHandlerDependencies
13
- var fetch = require('node-fetch');
13
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
14
14
  class DocumentHandlerServer {
15
15
  customerConfig;
16
16
  files;
@@ -31,28 +31,31 @@ class DocumentHandlerServer {
31
31
  await this.buildDocumentHandler();
32
32
  }
33
33
  const skInternalRequest = {
34
- query: { variation, headers: JSON.stringify(headers), url }, body: html
34
+ query: { variation, headers: JSON.stringify(headers), url },
35
+ body: html,
35
36
  };
36
37
  const vmContext = {
37
38
  db: await this.createDataBaseMock(),
38
39
  skInternalRequest,
39
40
  skInternalHtml: "",
40
41
  skInternalError: {},
41
- 'Abort': Error,
42
- 'APP': this.customerConfig.app,
43
- 'DYNAMIC_FETCHER': await this.getDynamicFetcher(),
44
- 'DYNAMIC_FETCHER_CONFIG': await this.getDynamicFetcherConfig(),
45
- 'CUSTOM_STYLES': this.getStyles(),
42
+ Abort: Error,
43
+ APP: this.customerConfig.app,
44
+ DYNAMIC_FETCHER: await this.getDynamicFetcher(),
45
+ DYNAMIC_FETCHER_CONFIG: await this.getDynamicFetcherConfig(),
46
+ CUSTOM_STYLES: this.getStyles(),
46
47
  ...this.createNodeVmContext(),
47
48
  };
48
49
  const script = new vm.Script(this.documentHandlerCode + this.getTransformFunctionWrapper());
49
50
  try {
50
51
  return await (async () => {
51
52
  return await new Promise((resolve, reject) => {
52
- // @ts-ignore
53
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
54
+ // @ts-expect-error
53
55
  vmContext.resolve = resolve;
54
- // @ts-ignore
56
+ // @ts-expect-error
55
57
  vmContext.reject = reject;
58
+ /* eslint-enable @typescript-eslint/ban-ts-comment */
56
59
  const context = vm.createContext(vmContext);
57
60
  script.runInContext(context);
58
61
  });
@@ -70,27 +73,32 @@ class DocumentHandlerServer {
70
73
  }
71
74
  async buildDocumentHandler() {
72
75
  this.documentHandlerCode = await this.createDocumentHandlerFile();
73
- this.cli.writeSuccess('rebuild documentHandler');
76
+ this.cli.writeSuccess("rebuild documentHandler");
74
77
  }
75
78
  async createDocumentHandlerFile() {
76
79
  const docHandler = await this.getDocumentHandler();
77
- const docHandlerConfig = this.getDocumentHandlerConfig()
78
- .replace('export const post', 'const post');
80
+ const docHandlerConfig = this.getDocumentHandlerConfig().replace("export const post", "const post");
79
81
  return `${this.getContextVars()} ${docHandler} ${docHandlerConfig}`;
80
82
  }
81
83
  async getDocumentHandler() {
82
- return this.files.getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER).getContent();
84
+ return this.files
85
+ .getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER)
86
+ .getContent();
83
87
  }
84
88
  async getDynamicFetcher() {
85
89
  // todo use fetchRemoteFile from integration api
86
90
  if (!this.files.hasFile(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER)) {
87
- const response = await fetch(document_handler_runtime_context_1.LATEST_DYNAMIC_FETCHER_URL);
88
- return await this.bundleDynamicFetcher({ 'dynamic-fetcher': 'https://www.baqend.com/speed-kit/latest/' }, await response.text());
91
+ const response = await (0, node_fetch_1.default)(document_handler_runtime_context_1.LATEST_DYNAMIC_FETCHER_URL);
92
+ return await this.bundleDynamicFetcher({ "dynamic-fetcher": "https://www.baqend.com/speed-kit/latest/" }, await response.text());
89
93
  }
90
- return this.files.getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER).getContent();
94
+ return this.files
95
+ .getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER)
96
+ .getContent();
91
97
  }
92
98
  async getDynamicFetcherConfig() {
93
- return this.files.getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER_CONFIG).getContent();
99
+ return this.files
100
+ .getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER_CONFIG)
101
+ .getContent();
94
102
  }
95
103
  getStyles() {
96
104
  return this.files.getByName(document_handler_runtime_context_1.LOCAL_STYLES).getContent();
@@ -98,13 +106,15 @@ class DocumentHandlerServer {
98
106
  getDocumentHandlerConfig() {
99
107
  const docHandlerFile = this.files.getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG);
100
108
  if (!docHandlerFile) {
101
- throw new required_file_not_found_error_1.default({ message: `file ${document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG} not found` });
109
+ throw new required_file_not_found_error_1.default({
110
+ message: `file ${document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG} not found`,
111
+ });
102
112
  }
103
113
  return docHandlerFile.getContent();
104
114
  }
105
115
  getContextVars() {
106
- let template = '';
107
- for (let key in this.customerConfig) {
116
+ let template = "";
117
+ for (const key in this.customerConfig) {
108
118
  template += `var ${key.toUpperCase()} = '${this.customerConfig[key]}';\n`;
109
119
  }
110
120
  return template;
@@ -112,13 +122,19 @@ class DocumentHandlerServer {
112
122
  async createDataBaseMock() {
113
123
  const vmConsole = {
114
124
  log: (context) => {
115
- this.verboseLevel ? this.cli.write(`[documentHandler.dbLog]: ${JSON.stringify(context)}`) : "";
125
+ this.verboseLevel
126
+ ? this.cli.write(`[documentHandler.dbLog]: ${JSON.stringify(context)}`)
127
+ : "";
116
128
  },
117
129
  info: (context) => {
118
- this.verboseLevel ? this.cli.writeWarning(`[documentHandler.dbLog]: ${JSON.stringify(context)}`) : "";
130
+ this.verboseLevel
131
+ ? this.cli.writeWarning(`[documentHandler.dbLog]: ${JSON.stringify(context)}`)
132
+ : "";
119
133
  },
120
134
  error: (context) => {
121
- this.verboseLevel ? this.cli.writeError(`[documentHandler.dbLog]: ${JSON.stringify(context)}`) : "";
135
+ this.verboseLevel
136
+ ? this.cli.writeError(`[documentHandler.dbLog]: ${JSON.stringify(context)}`)
137
+ : "";
122
138
  },
123
139
  };
124
140
  if (!this.database) {
@@ -134,31 +150,38 @@ class DocumentHandlerServer {
134
150
  const context = {
135
151
  process: this.createProcessPartial(),
136
152
  require: this.createRequireMock(),
137
- 'URL': URL,
138
- 'fetch': this.createFetchMock(),
139
- 'Buffer': Buffer,
153
+ URL: URL,
154
+ fetch: this.createFetchMock(),
155
+ Buffer: Buffer,
140
156
  };
141
157
  if (this.verboseLevel) {
142
- context['console'] = console;
158
+ context["console"] = console;
143
159
  }
144
160
  return context;
145
161
  }
146
162
  createRequireMock() {
147
163
  return (module) => {
148
- if (module === 'baqend') {
164
+ if (module === "baqend") {
149
165
  return { baqend: { message: { RevalidateAssets: () => true } } };
150
166
  }
151
- if (module.includes('fetch')) {
167
+ if (module.includes("fetch")) {
152
168
  return this.createFetchMock();
153
169
  }
154
170
  const fileExtension = path_1.default.extname(module);
155
171
  const moduleFileName = path_1.default.basename(module, fileExtension);
156
172
  if (this.files.hasFile(moduleFileName)) {
157
- const vmContext = { module: { exports: {} }, exports: {}, ...this.createNodeVmContext() };
158
- vm.runInNewContext(this.files.getByName(moduleFileName).getContent(), vmContext);
173
+ const vmContext = {
174
+ module: { exports: {} },
175
+ exports: {},
176
+ ...this.createNodeVmContext(),
177
+ };
178
+ vm.runInNewContext(this.files
179
+ .getByName(moduleFileName)
180
+ .getContent(), vmContext);
159
181
  return { ...vmContext.module.exports, ...vmContext.exports };
160
182
  }
161
183
  try {
184
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
162
185
  const outerModule = require(module);
163
186
  return outerModule;
164
187
  }
@@ -173,12 +196,12 @@ class DocumentHandlerServer {
173
196
  if (this.verboseLevel) {
174
197
  this.cli.writeWarning(`[documentHandler.fetch]: ${url}`);
175
198
  }
176
- return fetch(url, options);
199
+ return (0, node_fetch_1.default)(url, options);
177
200
  };
178
201
  }
179
202
  createProcessPartial() {
180
203
  return {
181
- hrtime: process.hrtime
204
+ hrtime: process.hrtime,
182
205
  };
183
206
  }
184
207
  /**
@@ -8,7 +8,7 @@ class RequiredFileNotFoundHandler {
8
8
  }
9
9
  handle(error) {
10
10
  console.error(error.message);
11
- console.warn('Did you choose the correct folder?');
11
+ console.warn("Did you choose the correct folder?");
12
12
  }
13
13
  }
14
14
  exports.default = RequiredFileNotFoundHandler;
@@ -25,21 +25,24 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
25
25
  const integrationApi = this.prepareIntegrationApi();
26
26
  const files = await this.getIntegrationFiles(integrationApi);
27
27
  this.checkRequiredFiles(files);
28
- const cliService = (new cli_1.CliServiceFactory()).getService();
28
+ const cliService = new cli_1.CliServiceFactory().getService();
29
29
  const customerConfig = this.getCustomerConfig(files);
30
30
  this.preparePackageJson(integrationApi, customerConfig);
31
31
  return new document_handler_runtime_service_1.default(files, customerConfig, cliService, { testNames: this.context.testNames || [] }, customerConfig.skCliPre, customerConfig.skCliPost);
32
32
  }
33
33
  async buildDocumentHandlerServer() {
34
34
  const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, []);
35
- const files = this.files || await new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig).buildService().run();
35
+ const files = this.files ||
36
+ (await new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig)
37
+ .buildService()
38
+ .run());
36
39
  const customerConfig = this.getCustomerConfig(files);
37
40
  const bundler = new bundler_1.BundleServiceFactory().buildService();
38
- const cliService = (new cli_1.CliServiceFactory()).getService();
41
+ const cliService = new cli_1.CliServiceFactory().getService();
39
42
  return new document_handler_server_1.DocumentHandlerServer(customerConfig, files, bundler, cliService, this.context.verboseLevel);
40
43
  }
41
44
  prepareIntegrationApi() {
42
- const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, this.context.fileDependencies, ['.git', '.idea', 'node_modules']);
45
+ const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, this.context.fileDependencies, [".git", ".idea", "node_modules"]);
43
46
  return new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig).buildService();
44
47
  }
45
48
  async getIntegrationFiles(integrationApi) {
@@ -51,16 +54,18 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
51
54
  checkRequiredFiles(files) {
52
55
  this.context.requiredFiles.forEach((requiredFile) => {
53
56
  if (!files.hasFile(requiredFile)) {
54
- throw new required_file_not_found_error_1.default({ message: `file ${requiredFile} not found` });
57
+ throw new required_file_not_found_error_1.default({
58
+ message: `file ${requiredFile} not found`,
59
+ });
55
60
  }
56
61
  });
57
62
  }
58
63
  createNeededFolderStructure(integrationApi) {
59
- integrationApi.createFolder('.local');
60
- integrationApi.createFolder('.local/test');
61
- integrationApi.createFolder('.local/test/src');
62
- integrationApi.createFolder('.local/test/tmp');
63
- integrationApi.createFolder('.local/test/tmp/server');
64
+ integrationApi.createFolder(".local");
65
+ integrationApi.createFolder(".local/test");
66
+ integrationApi.createFolder(".local/test/src");
67
+ integrationApi.createFolder(".local/test/tmp");
68
+ integrationApi.createFolder(".local/test/tmp/server");
64
69
  }
65
70
  prepareLocalDocumentHandler(integrationApi) {
66
71
  if (!integrationApi.fileExists(`.local/test/src/${document_handler_runtime_context_1.TEST_DOCUMENT_HANDLER_FILE_NAME}`)) {
@@ -80,8 +85,9 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
80
85
  }
81
86
  }
82
87
  preparePackageJson(integrationApi, customerConfig) {
83
- if (customerConfig.dependencies && !integrationApi.fileExists(`.local/test/${document_handler_runtime_context_1.TEST_PACKAGE_JSON}`, 'json')) {
84
- integrationApi.writeFile(`.local/test/${document_handler_runtime_context_1.TEST_PACKAGE_JSON}`, 'json');
88
+ if (customerConfig.dependencies &&
89
+ !integrationApi.fileExists(`.local/test/${document_handler_runtime_context_1.TEST_PACKAGE_JSON}`, "json")) {
90
+ integrationApi.writeFile(`.local/test/${document_handler_runtime_context_1.TEST_PACKAGE_JSON}`, "json");
85
91
  }
86
92
  }
87
93
  prepareTestCases(integrationApi) {
@@ -94,13 +100,11 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
94
100
  }
95
101
  }
96
102
  getCustomerConfig(files) {
97
- const configFile = files.getByName('config_customer');
103
+ const configFile = files.getByName("config_customer");
98
104
  return configFile.config;
99
105
  }
100
106
  static getErrorHandlers() {
101
- return [
102
- new required_file_not_found_handler_1.default()
103
- ];
107
+ return [new required_file_not_found_handler_1.default()];
104
108
  }
105
109
  }
106
110
  exports.default = DocumentHandlerRuntimeServiceFactory;
@@ -1,7 +1,7 @@
1
1
  import TemplateInterface from "../interface/template-interface";
2
2
  import TemplateParam from "../interface/template-param-interface";
3
3
  import TemplateContextInterface from "../interface/template-context-interface";
4
- import { Template } from 'handlebars';
4
+ import { Template } from "handlebars";
5
5
  export default abstract class AbstractTemplate implements TemplateInterface {
6
6
  _buildContext(...params: TemplateParam[]): TemplateContextInterface;
7
7
  render(context: TemplateContextInterface): string;
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const handlebars_1 = tslib_1.__importDefault(require("handlebars"));
5
5
  class AbstractTemplate {
6
6
  _buildContext(...params) {
7
- let context = {};
7
+ const context = {};
8
8
  params.forEach(({ key, value }) => {
9
9
  context[key] = value;
10
10
  });
@@ -13,7 +13,7 @@ class AbstractAsyncErrorHandlingFactory {
13
13
  }
14
14
  }
15
15
  getErrorHandler() {
16
- return (new error_handling_factory_1.default()).buildService();
16
+ return new error_handling_factory_1.default().buildService();
17
17
  }
18
18
  }
19
19
  exports.default = AbstractAsyncErrorHandlingFactory;
@@ -12,7 +12,7 @@ class AbstractAsyncErrorHandlingService {
12
12
  }
13
13
  }
14
14
  getErrorHandler() {
15
- return (new error_handling_factory_1.default()).buildService();
15
+ return new error_handling_factory_1.default().buildService();
16
16
  }
17
17
  }
18
18
  exports.default = AbstractAsyncErrorHandlingService;
@@ -13,7 +13,7 @@ class AbstractErrorHandlingFactory {
13
13
  }
14
14
  }
15
15
  getErrorHandler() {
16
- return (new error_handling_factory_1.default()).buildService();
16
+ return new error_handling_factory_1.default().buildService();
17
17
  }
18
18
  }
19
19
  exports.default = AbstractErrorHandlingFactory;
@@ -13,7 +13,7 @@ class AbstractErrorHandlingService {
13
13
  }
14
14
  }
15
15
  getErrorHandler() {
16
- return (new error_handling_factory_1.default()).buildService();
16
+ return new error_handling_factory_1.default().buildService();
17
17
  }
18
18
  }
19
19
  exports.default = AbstractErrorHandlingService;
@@ -1,5 +1,5 @@
1
1
  import ErrorHandlerInterface from "../../interface/error-handler-interface";
2
2
  export default class DefaultErrorHandler implements ErrorHandlerInterface {
3
- canHandle(error: Error): boolean;
3
+ canHandle(_error: Error): boolean;
4
4
  handle(error: Error): Promise<any>;
5
5
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  class DefaultErrorHandler {
5
- canHandle(error) {
5
+ canHandle(_error) {
6
6
  return true;
7
7
  }
8
8
  async handle(error) {
@@ -11,14 +11,14 @@ class ErrorHandlingService {
11
11
  core_1.ux.log(` === An error appeared =====`);
12
12
  core_1.ux.log(` ===========================\n`);
13
13
  for (let iterator = 0; iterator < this.handlers.length; iterator++) {
14
- let handler = this.handlers[iterator];
14
+ const handler = this.handlers[iterator];
15
15
  if (handler.canHandle(error)) {
16
16
  handler.handle(error);
17
17
  core_1.ux.exit(1);
18
18
  return;
19
19
  }
20
20
  }
21
- core_1.ux.warn('unhandled error:');
21
+ core_1.ux.warn("unhandled error:");
22
22
  core_1.ux.info(`type of error: ${typeof error}`);
23
23
  core_1.ux.log(error);
24
24
  core_1.ux.exit(1);
@@ -4,7 +4,7 @@ exports.DEFAULT_BLOCKED_FOLDERS = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const dotenv = tslib_1.__importStar(require("dotenv"));
6
6
  dotenv.config();
7
- exports.DEFAULT_BLOCKED_FOLDERS = ['test', '.local', '.git', '.idea'];
7
+ exports.DEFAULT_BLOCKED_FOLDERS = ["test", ".local", ".git", ".idea"];
8
8
  class IntegrationApiContext {
9
9
  basePath;
10
10
  configName;