@speedkit/cli 2.26.0 → 2.28.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 (147) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/dist/models/files.d.ts +4 -0
  4. package/dist/models/files.js +4 -0
  5. package/dist/services/cli/error/cli-type-error.d.ts +1 -2
  6. package/dist/services/cli/error/cli-type-error.js +1 -3
  7. package/dist/services/config-api/context/config-api-context.d.ts +1 -2
  8. package/dist/services/config-api/factory/config-api-service-factory.js +1 -2
  9. package/dist/services/config-api/interface/config-api-context-interface.d.ts +1 -2
  10. package/dist/services/customer-config/customer-config-service.js +0 -3
  11. package/dist/services/customer-config/templates/config_documentHandler.js.hbs +0 -4
  12. package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +1 -1
  13. package/dist/services/deploy/checks/pre-deploy/split-change-check.d.ts +1 -2
  14. package/dist/services/deploy/deploy-service-factory.js +3 -4
  15. package/dist/services/deploy/deploy-service.d.ts +3 -2
  16. package/dist/services/deploy/deploy-service.js +23 -1
  17. package/dist/services/deploy/handler/customer-config-handler.d.ts +4 -5
  18. package/dist/services/deploy/handler/customer-config-handler.js +2 -2
  19. package/dist/services/deploy/handler/install-resource-handler.d.ts +3 -4
  20. package/dist/services/deploy/handler/install-resource-handler.js +2 -3
  21. package/dist/services/deploy/handler/module-handler.d.ts +8 -5
  22. package/dist/services/deploy/handler/module-handler.js +2 -3
  23. package/dist/services/deploy/handler/server-config-handler.d.ts +9 -6
  24. package/dist/services/deploy/handler/server-config-handler.js +6 -4
  25. package/dist/services/document-handler-runtime/document-handler-runtime-service.d.ts +2 -3
  26. package/dist/services/document-handler-runtime/document-handler-runtime-service.js +2 -6
  27. package/dist/services/document-handler-runtime/document-handler-server.d.ts +1 -2
  28. package/dist/services/document-handler-runtime/document-handler-server.js +2 -5
  29. package/dist/services/document-handler-runtime/error/required-file-not-found-error.d.ts +1 -2
  30. package/dist/services/document-handler-runtime/error/required-file-not-found-error.js +1 -3
  31. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.d.ts +3 -6
  32. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +9 -18
  33. package/dist/services/integration-api/error/customer-config-legacy-error.d.ts +1 -2
  34. package/dist/services/integration-api/error/customer-config-legacy-error.js +1 -3
  35. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.d.ts +1 -2
  36. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.js +1 -1
  37. package/dist/services/integration-api/error/handler/origin-handler.d.ts +1 -2
  38. package/dist/services/integration-api/error/handler/origin-handler.js +1 -1
  39. package/dist/services/integration-api/error/origin-error.d.ts +1 -2
  40. package/dist/services/integration-api/error/origin-error.js +1 -3
  41. package/dist/services/integration-api/file-list.d.ts +3 -5
  42. package/dist/services/integration-api/file-list.js +6 -10
  43. package/dist/services/integration-api/file-reader.d.ts +14 -6
  44. package/dist/services/integration-api/file-reader.js +8 -8
  45. package/dist/services/integration-api/file-writer.d.ts +10 -2
  46. package/dist/services/integration-api/file-writer.js +9 -6
  47. package/dist/services/integration-api/handler/customer-config-handler.js +6 -8
  48. package/dist/services/integration-api/handler/install-resource-handler.js +3 -4
  49. package/dist/services/integration-api/handler/module-handler.js +2 -2
  50. package/dist/services/integration-api/handler/server-config-handler.js +2 -2
  51. package/dist/services/integration-api/index.d.ts +3 -0
  52. package/dist/services/integration-api/index.js +6 -0
  53. package/dist/services/integration-api/integration-api-factory.d.ts +13 -0
  54. package/dist/services/integration-api/integration-api-factory.js +50 -0
  55. package/dist/services/integration-api/integration-api-model.d.ts +33 -14
  56. package/dist/services/integration-api/integration-api-model.js +37 -0
  57. package/dist/services/integration-api/integration-api-service.d.ts +1 -2
  58. package/dist/services/integration-api/integration-api-service.js +3 -23
  59. package/dist/services/integration-api/spec/customer-config-validator.spec.d.ts +1 -0
  60. package/dist/services/integration-api/spec/customer-config-validator.spec.js +50 -0
  61. package/dist/services/integration-api/spec/file-list.spec.d.ts +1 -0
  62. package/dist/services/integration-api/spec/file-list.spec.js +163 -0
  63. package/dist/services/integration-api/spec/file-reader.spec.d.ts +1 -0
  64. package/dist/services/integration-api/spec/file-reader.spec.js +71 -0
  65. package/dist/services/integration-api/spec/file-writer.spec.d.ts +1 -0
  66. package/dist/services/integration-api/spec/file-writer.spec.js +55 -0
  67. package/dist/services/integration-api/spec/integration-api-service.spec.d.ts +1 -0
  68. package/dist/services/integration-api/spec/integration-api-service.spec.js +122 -0
  69. package/dist/services/integration-api/spec/mandatory-files-validator.spec.d.ts +1 -0
  70. package/dist/services/integration-api/spec/mandatory-files-validator.spec.js +105 -0
  71. package/dist/services/integration-api/struct/customer-config-file.d.ts +3 -4
  72. package/dist/services/integration-api/struct/customer-config-file.js +7 -6
  73. package/dist/services/integration-api/struct/customer-config.d.ts +3 -5
  74. package/dist/services/integration-api/struct/customer-config.js +5 -8
  75. package/dist/services/integration-api/struct/file.d.ts +4 -4
  76. package/dist/services/integration-api/struct/file.js +6 -6
  77. package/dist/services/integration-api/struct/install-resource-file.d.ts +4 -3
  78. package/dist/services/integration-api/struct/install-resource-file.js +7 -5
  79. package/dist/services/integration-api/struct/module-file.d.ts +4 -3
  80. package/dist/services/integration-api/struct/module-file.js +7 -5
  81. package/dist/services/integration-api/struct/ro-file.d.ts +2 -2
  82. package/dist/services/integration-api/struct/ro-file.js +1 -1
  83. package/dist/services/integration-api/struct/server-config-file.d.ts +5 -4
  84. package/dist/services/integration-api/struct/server-config-file.js +7 -5
  85. package/dist/services/integration-api/struct/virtual-file.d.ts +2 -2
  86. package/dist/services/integration-api/struct/virtual-file.js +2 -1
  87. package/dist/services/integration-api/validator/customer-config-validator.d.ts +5 -1
  88. package/dist/services/integration-api/validator/customer-config-validator.js +28 -17
  89. package/dist/services/integration-api/virtual/static-recipe.d.ts +6 -0
  90. package/dist/services/integration-api/virtual/static-recipe.js +14 -0
  91. package/dist/services/integration-api/virtual/virtual-file-handler.js +2 -2
  92. package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +1 -2
  93. package/dist/services/onboarding/dashboard/index.d.ts +1 -1
  94. package/dist/services/onboarding/dashboard/parameter-query-builder.d.ts +1 -2
  95. package/dist/services/onboarding/fetch-event-handler.d.ts +1 -1
  96. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +1 -2
  97. package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +1 -1
  98. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +1 -1
  99. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +1 -1
  100. package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +1 -2
  101. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +1 -1
  102. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +1 -2
  103. package/dist/services/onboarding/file-events/file-watcher.d.ts +1 -2
  104. package/dist/services/onboarding/file-events/file-watcher.js +3 -3
  105. package/dist/services/onboarding/onboarding-service-factory.js +9 -13
  106. package/dist/services/onboarding/onboarding-service.d.ts +1 -1
  107. package/dist/services/onboarding/todo-collector.js +2 -2
  108. package/dist/services/pull/pull-service-factory.js +3 -4
  109. package/dist/services/pull/pull-service.d.ts +1 -1
  110. package/dist/services/pull/pull-service.js +2 -3
  111. package/oclif.manifest.json +1 -1
  112. package/package.json +5 -5
  113. package/dist/services/context/error/context-runtime-error.d.ts +0 -3
  114. package/dist/services/context/error/context-runtime-error.js +0 -7
  115. package/dist/services/context/interface/context-interface.d.ts +0 -2
  116. package/dist/services/context/interface/context-interface.js +0 -2
  117. package/dist/services/customer-config/templates/deploymentDetection.es6.hbs +0 -303
  118. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.d.ts +0 -6
  119. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js +0 -14
  120. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.d.ts +0 -6
  121. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.js +0 -19
  122. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.d.ts +0 -6
  123. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.js +0 -18
  124. package/dist/services/error-handling/abstract/abstract-error-handling-factory.d.ts +0 -6
  125. package/dist/services/error-handling/abstract/abstract-error-handling-factory.js +0 -19
  126. package/dist/services/error-handling/abstract/abstract-error-handling-service.d.ts +0 -6
  127. package/dist/services/error-handling/abstract/abstract-error-handling-service.js +0 -19
  128. package/dist/services/error-handling/error/application-error.d.ts +0 -5
  129. package/dist/services/error-handling/error/application-error.js +0 -11
  130. package/dist/services/error-handling/error-handling-service.d.ts +0 -7
  131. package/dist/services/error-handling/error-handling-service.js +0 -27
  132. package/dist/services/error-handling/factory/error-handling-factory.d.ts +0 -5
  133. package/dist/services/error-handling/factory/error-handling-factory.js +0 -22
  134. package/dist/services/error-handling/interface/error-context-interface.d.ts +0 -6
  135. package/dist/services/error-handling/interface/error-context-interface.js +0 -2
  136. package/dist/services/error-handling/interface/error-handler-interface.d.ts +0 -5
  137. package/dist/services/error-handling/interface/error-handler-interface.js +0 -2
  138. package/dist/services/error-handling/interface/error-handling-factory-interface.d.ts +0 -8
  139. package/dist/services/error-handling/interface/error-handling-factory-interface.js +0 -2
  140. package/dist/services/error-handling/interface/error-handling-service-interface.d.ts +0 -8
  141. package/dist/services/error-handling/interface/error-handling-service-interface.js +0 -2
  142. package/dist/services/integration-api/context/integration-api-context.d.ts +0 -9
  143. package/dist/services/integration-api/context/integration-api-context.js +0 -20
  144. package/dist/services/integration-api/error/handler/customer-config-handler.d.ts +0 -5
  145. package/dist/services/integration-api/error/handler/customer-config-handler.js +0 -19
  146. package/dist/services/integration-api/factory/integration-api-service-factory.d.ts +0 -13
  147. package/dist/services/integration-api/factory/integration-api-service-factory.js +0 -55
@@ -1,39 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const integration_api_context_1 = tslib_1.__importDefault(require("../../integration-api/context/integration-api-context"));
5
- const integration_api_service_factory_1 = tslib_1.__importDefault(require("../../integration-api/factory/integration-api-service-factory"));
4
+ const integration_api_1 = require("../../integration-api");
6
5
  const document_handler_runtime_context_1 = require("../context/document-handler-runtime-context");
7
6
  const document_handler_runtime_service_1 = tslib_1.__importDefault(require("../document-handler-runtime-service"));
8
- const abstract_async_error_handling_factory_1 = tslib_1.__importDefault(require("../../error-handling/abstract/abstract-async-error-handling-factory"));
9
7
  const cli_1 = require("../../cli");
10
- const required_file_not_found_handler_1 = tslib_1.__importDefault(require("../error/handler/required-file-not-found-handler"));
11
8
  const required_file_not_found_error_1 = tslib_1.__importDefault(require("../error/required-file-not-found-error"));
12
9
  const document_handler_server_1 = require("../document-handler-server");
13
10
  const bundler_1 = require("../../bundler");
14
- class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling_factory_1.default {
11
+ class DocumentHandlerRuntimeServiceFactory {
15
12
  context;
16
13
  cliConfig;
17
14
  files;
18
15
  constructor(context, cliConfig, files) {
19
- super();
20
16
  this.context = context;
21
17
  this.cliConfig = cliConfig;
22
18
  this.files = files;
23
19
  }
24
- async _buildService() {
20
+ async buildService() {
25
21
  const integrationApi = this.prepareIntegrationApi();
26
22
  const files = await this.getIntegrationFiles(integrationApi);
27
23
  this.checkRequiredFiles(files);
28
24
  const cliService = new cli_1.CliServiceFactory().getService();
29
25
  const customerConfig = this.getCustomerConfig(files);
30
26
  this.preparePackageJson(integrationApi, customerConfig);
31
- return new document_handler_runtime_service_1.default(files, customerConfig, cliService, { testNames: this.context.testNames || [] }, customerConfig.skCliPre, customerConfig.skCliPost);
27
+ return new document_handler_runtime_service_1.default(files, customerConfig, cliService, { testNames: this.context.testNames || [] });
32
28
  }
33
29
  async buildDocumentHandlerServer() {
34
- const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, []);
30
+ const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, []);
35
31
  const files = this.files ||
36
- (await new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig)
32
+ (await new integration_api_1.IntegrationApiFactory(integrationApiContext, this.cliConfig)
37
33
  .buildService()
38
34
  .run());
39
35
  const customerConfig = this.getCustomerConfig(files);
@@ -42,8 +38,8 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
42
38
  return new document_handler_server_1.DocumentHandlerServer(customerConfig, files, bundler, cliService, this.context.verboseLevel);
43
39
  }
44
40
  prepareIntegrationApi() {
45
- const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, this.context.fileDependencies, [".git", ".idea", "node_modules"]);
46
- return new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig).buildService();
41
+ const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, this.context.fileDependencies, [".git", ".idea", "node_modules"]);
42
+ return new integration_api_1.IntegrationApiFactory(integrationApiContext, this.cliConfig).buildService();
47
43
  }
48
44
  async getIntegrationFiles(integrationApi) {
49
45
  this.createNeededFolderStructure(integrationApi);
@@ -54,9 +50,7 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
54
50
  checkRequiredFiles(files) {
55
51
  for (const requiredFile of this.context.requiredFiles) {
56
52
  if (!files.hasFile(requiredFile)) {
57
- throw new required_file_not_found_error_1.default({
58
- message: `file ${requiredFile} not found`,
59
- });
53
+ throw new required_file_not_found_error_1.default(`file ${requiredFile} not found`);
60
54
  }
61
55
  }
62
56
  }
@@ -103,8 +97,5 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
103
97
  const configFile = files.getByName("config_customer");
104
98
  return configFile.config;
105
99
  }
106
- static getErrorHandlers() {
107
- return [new required_file_not_found_handler_1.default()];
108
- }
109
100
  }
110
101
  exports.default = DocumentHandlerRuntimeServiceFactory;
@@ -1,3 +1,2 @@
1
- import ApplicationError from "../../error-handling/error/application-error";
2
- export default class CustomerConfigLegacyError extends ApplicationError {
1
+ export default class CustomerConfigLegacyError extends Error {
3
2
  }
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
5
- class CustomerConfigLegacyError extends application_error_1.default {
3
+ class CustomerConfigLegacyError extends Error {
6
4
  }
7
5
  exports.default = CustomerConfigLegacyError;
@@ -1,6 +1,5 @@
1
1
  import CustomerConfigLegacyError from "../customer-config-legacy-error";
2
- import ErrorHandlerInterface from "../../../error-handling/interface/error-handler-interface";
3
- export default class CustomerConfigLegacyHandler implements ErrorHandlerInterface {
2
+ export default class CustomerConfigLegacyHandler {
4
3
  canHandle(error: Error): boolean;
5
4
  handle(error: CustomerConfigLegacyError): void;
6
5
  }
@@ -10,7 +10,7 @@ class CustomerConfigLegacyHandler {
10
10
  }
11
11
  handle(error) {
12
12
  core_1.ux.log();
13
- core_1.ux.log(chalk_1.default.red(`config ${chalk_1.default.bold.white(error.context.configName)} not found`));
13
+ core_1.ux.log(chalk_1.default.red(`config ${chalk_1.default.bold.white(error.message)} not found`));
14
14
  core_1.ux.log();
15
15
  core_1.ux.log(chalk_1.default.italic("Is this still a legacy customer config format?"));
16
16
  core_1.ux.log(chalk_1.default.italic("Make sure to export the different app configs under their config names like:"));
@@ -1,6 +1,5 @@
1
- import ErrorHandlerInterface from "../../../error-handling/interface/error-handler-interface";
2
1
  import OriginError from "../origin-error";
3
- export default class OriginHandler implements ErrorHandlerInterface {
2
+ export default class OriginHandler {
4
3
  canHandle(error: Error): boolean;
5
4
  handle(error: OriginError): void;
6
5
  }
@@ -10,7 +10,7 @@ class OriginHandler {
10
10
  }
11
11
  handle(error) {
12
12
  core_1.ux.log();
13
- core_1.ux.log(chalk_1.default.red(error.context.message));
13
+ core_1.ux.log(chalk_1.default.red(error.message));
14
14
  core_1.ux.log();
15
15
  core_1.ux.log(chalk_1.default.italic("Example entry:"));
16
16
  core_1.ux.log(chalk_1.default.bgBlack.hidden(" origins: ['https://speedkit.com', 'https://baqend.com'], "));
@@ -1,3 +1,2 @@
1
- import ApplicationError from "../../error-handling/error/application-error";
2
- export default class OriginError extends ApplicationError {
1
+ export default class OriginError extends Error {
3
2
  }
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
5
- class OriginError extends application_error_1.default {
3
+ class OriginError extends Error {
6
4
  }
7
5
  exports.default = OriginError;
@@ -1,6 +1,4 @@
1
- import { CustomerConfigInterface, FileInterface, FileListInterface, InstallResourceInterface, ModuleInterface, ServerConfigInterface } from "./integration-api-model";
2
- import { RoFile } from "./struct/ro-file";
3
- import { VirtualFile } from "./struct/virtual-file";
1
+ import { CustomerConfigInterface, FILE_TYPE, FileInterface, FileListInterface, InstallResourceInterface, ModuleInterface, ServerConfigInterface, RoFile, VirtualFile } from "./integration-api-model";
4
2
  export default class FileList implements FileListInterface {
5
3
  files: FileInterface[];
6
4
  addFile(file: FileInterface): void;
@@ -9,8 +7,8 @@ export default class FileList implements FileListInterface {
9
7
  getModules(): ModuleInterface[];
10
8
  getServerConfig(): ServerConfigInterface;
11
9
  getCustomerConfig(): CustomerConfigInterface;
12
- getTypes(): any[];
13
- getByType(type: any): FileInterface[];
10
+ getTypes(): FILE_TYPE[];
11
+ getByType<T>(type: FILE_TYPE): FileInterface[] | T[];
14
12
  getByName<T>(name: string): T;
15
13
  filter(callback: (file: FileInterface) => boolean): void;
16
14
  concat(fileList: FileListInterface): void;
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const module_file_1 = tslib_1.__importDefault(require("./struct/module-file"));
5
- const server_config_file_1 = tslib_1.__importDefault(require("./struct/server-config-file"));
6
- const customer_config_file_1 = tslib_1.__importDefault(require("./struct/customer-config-file"));
7
- const install_resource_file_1 = tslib_1.__importDefault(require("./struct/install-resource-file"));
3
+ const integration_api_model_1 = require("./integration-api-model");
8
4
  class FileList {
9
5
  files = [];
10
6
  addFile(file) {
@@ -21,23 +17,23 @@ class FileList {
21
17
  }
22
18
  getInstallResources() {
23
19
  return this.files.filter((file) => {
24
- return file instanceof install_resource_file_1.default;
20
+ return file instanceof integration_api_model_1.InstallResourceFile;
25
21
  });
26
22
  }
27
23
  getModules() {
28
24
  return this.files.filter((file) => {
29
- return file instanceof module_file_1.default;
25
+ return file instanceof integration_api_model_1.ModuleFile;
30
26
  });
31
27
  }
32
28
  getServerConfig() {
33
29
  const configFiles = this.files.filter((file) => {
34
- return file instanceof server_config_file_1.default;
30
+ return file instanceof integration_api_model_1.ServerConfigFile;
35
31
  });
36
32
  return configFiles.shift();
37
33
  }
38
34
  getCustomerConfig() {
39
35
  const configFiles = this.files.filter((file) => {
40
- return file instanceof customer_config_file_1.default;
36
+ return file instanceof integration_api_model_1.CustomerConfigFile;
41
37
  });
42
38
  return configFiles.shift();
43
39
  }
@@ -51,7 +47,7 @@ class FileList {
51
47
  }
52
48
  getByType(type) {
53
49
  return this.files.filter((file) => {
54
- return file instanceof type;
50
+ return file.type === type;
55
51
  });
56
52
  }
57
53
  getByName(name) {
@@ -1,15 +1,23 @@
1
+ /// <reference types="node" />
2
+ import { Dirent } from "node:fs";
1
3
  export default class FileReader {
4
+ private fileSystem;
2
5
  readonly configName: string;
3
6
  private readonly basePath;
4
7
  private readonly whiteList;
5
8
  private readonly blockedFolders;
6
9
  allowedExtensions: string[];
7
- constructor(configName: string, basePath: string, whiteList?: string[], blockedFolders?: string[]);
8
- getFileList(directoryName?: string): Promise<string[]>;
10
+ constructor(fileSystem: {
11
+ readFileSync: (path: string, options: "utf-8") => string;
12
+ readdirSync: (path: string, options: {
13
+ withFileTypes: boolean;
14
+ }) => Dirent[];
15
+ }, configName: string, basePath: string, whiteList?: string[], blockedFolders?: string[]);
16
+ getFileList(basePath?: string): string[];
9
17
  getContent(path: string): Promise<string>;
10
- isAllowedFolder(folderName: string): boolean;
11
- isAllowedFile(fileName: string): boolean;
12
- getFileExtension(fileName: string): string;
13
- isWhiteListed(fileName: string): boolean;
18
+ private isAllowedFolder;
19
+ private isAllowedFile;
20
+ private getFileExtension;
21
+ private isWhiteListed;
14
22
  private mapEnvironment;
15
23
  }
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const node_fs_1 = require("node:fs");
5
4
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
- const promises_1 = require("node:fs/promises");
7
5
  const CUSTOMER_CONFIG_FILE = "config_customer";
8
6
  const DEFAULT_ENV = "production";
9
7
  class FileReader {
8
+ fileSystem;
10
9
  configName;
11
10
  basePath;
12
11
  whiteList;
13
12
  blockedFolders;
14
13
  allowedExtensions = ["js", "es6", "json", "css"];
15
- constructor(configName, basePath, whiteList = [], blockedFolders = []) {
14
+ constructor(fileSystem, configName, basePath, whiteList = [], blockedFolders = []) {
15
+ this.fileSystem = fileSystem;
16
16
  this.configName = configName;
17
17
  this.basePath = basePath;
18
18
  this.whiteList = whiteList;
19
19
  this.blockedFolders = blockedFolders;
20
20
  }
21
- async getFileList(directoryName = this.basePath) {
21
+ getFileList(basePath = this.basePath) {
22
22
  let files = [];
23
- const items = await node_fs_1.promises.readdir(directoryName, {
23
+ const items = this.fileSystem.readdirSync(basePath, {
24
24
  withFileTypes: true,
25
25
  });
26
26
  for (const item of items) {
@@ -28,19 +28,19 @@ class FileReader {
28
28
  if (this.isAllowedFolder(item.name)) {
29
29
  files = [
30
30
  ...files,
31
- ...(await this.getFileList(node_path_1.default.resolve(directoryName, item.name))),
31
+ ...this.getFileList(node_path_1.default.resolve(basePath, item.name)),
32
32
  ];
33
33
  }
34
34
  continue;
35
35
  }
36
36
  if (this.isAllowedFile(item.name)) {
37
- files.push(node_path_1.default.resolve(directoryName, item.name));
37
+ files.push(node_path_1.default.resolve(basePath, item.name));
38
38
  }
39
39
  }
40
40
  return this.mapEnvironment(files);
41
41
  }
42
42
  async getContent(path) {
43
- return (0, promises_1.readFile)(path, "utf-8");
43
+ return this.fileSystem.readFileSync(path, "utf-8");
44
44
  }
45
45
  isAllowedFolder(folderName) {
46
46
  return !this.blockedFolders.some((entry) => {
@@ -1,6 +1,14 @@
1
1
  export default class FileWriter {
2
- basePath: string;
3
- constructor(basePath: string);
2
+ private fileSystem;
3
+ readonly basePath: string;
4
+ constructor(fileSystem: {
5
+ writeFileSync: (path: string, content: string) => void;
6
+ mkdirSync: (path: string, options: {
7
+ recursive: boolean;
8
+ }) => void;
9
+ existsSync: (path: string) => boolean;
10
+ unlinkSync: (path: string) => void;
11
+ }, basePath: string);
4
12
  writeFile(fileName: string, extension: string, content: string): void;
5
13
  mkdir(directoryPath: string): void;
6
14
  hasFile(fileName: string, extension: string): boolean;
@@ -1,24 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const node_fs_1 = require("node:fs");
5
4
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
5
  class FileWriter {
6
+ fileSystem;
7
7
  basePath;
8
- constructor(basePath) {
8
+ constructor(fileSystem, basePath) {
9
+ this.fileSystem = fileSystem;
9
10
  this.basePath = basePath;
10
11
  }
11
12
  writeFile(fileName, extension, content) {
12
- (0, node_fs_1.writeFileSync)(this.getPath(fileName, extension), content);
13
+ this.fileSystem.writeFileSync(this.getPath(fileName, extension), content);
13
14
  }
14
15
  mkdir(directoryPath) {
15
- (0, node_fs_1.mkdirSync)(node_path_1.default.resolve(this.basePath, directoryPath), { recursive: true });
16
+ this.fileSystem.mkdirSync(node_path_1.default.resolve(this.basePath, directoryPath), {
17
+ recursive: true,
18
+ });
16
19
  }
17
20
  hasFile(fileName, extension) {
18
- return (0, node_fs_1.existsSync)(this.getPath(fileName, extension));
21
+ return this.fileSystem.existsSync(this.getPath(fileName, extension));
19
22
  }
20
23
  removeFile(fileName, extension) {
21
- (0, node_fs_1.unlinkSync)(this.getPath(fileName, extension));
24
+ this.fileSystem.unlinkSync(this.getPath(fileName, extension));
22
25
  }
23
26
  getPath(fileName, extension) {
24
27
  return node_path_1.default.resolve(this.basePath, `${fileName}.${extension}`);
@@ -4,8 +4,8 @@ const tslib_1 = require("tslib");
4
4
  const vm = tslib_1.__importStar(require("node:vm"));
5
5
  const customer_config_error_1 = tslib_1.__importDefault(require("../error/customer-config-error"));
6
6
  const customer_config_legacy_error_1 = tslib_1.__importDefault(require("../error/customer-config-legacy-error"));
7
- const customer_config_1 = tslib_1.__importDefault(require("../struct/customer-config"));
8
- const customer_config_file_1 = tslib_1.__importDefault(require("../struct/customer-config-file"));
7
+ const customer_config_1 = require("../struct/customer-config");
8
+ const customer_config_file_1 = require("../struct/customer-config-file");
9
9
  const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
10
10
  class CustomerConfigHandler extends file_handler_1.default {
11
11
  cli;
@@ -27,7 +27,7 @@ class CustomerConfigHandler extends file_handler_1.default {
27
27
  const fileContent = await this.fileReader.getContent(filePath);
28
28
  const config = await this.loadConfig(fileContent, filePath);
29
29
  this.validator.validate(config);
30
- return new customer_config_file_1.default(this.getFileName(filePath), filePath, fileContent, config, this.configName, this.testApp);
30
+ return new customer_config_file_1.CustomerConfigFile(this.getFileName(filePath), filePath, fileContent, config, this.configName, this.testApp);
31
31
  }
32
32
  async loadConfig(fileContent, filePath) {
33
33
  if ((fileContent.includes("process.env.TEST_APP") && this.testApp === null) ||
@@ -49,16 +49,14 @@ class CustomerConfigHandler extends file_handler_1.default {
49
49
  typeof configs === "string" ||
50
50
  "origins" in configs ||
51
51
  "name" in configs) {
52
- throw new customer_config_legacy_error_1.default({
53
- configName: this.configName,
54
- });
52
+ throw new customer_config_legacy_error_1.default(this.configName);
55
53
  }
56
54
  if (this.configName in configs) {
57
- return customer_config_1.default.createFrom(configs[this.configName], this.configName);
55
+ return customer_config_1.CustomerConfig.createFrom(configs[this.configName], this.configName);
58
56
  }
59
57
  this.cli.writeWarning(`config: ${this.configName} does not exist.`);
60
58
  const selectedConfig = await this.cli.select("please select config: ", Object.keys(configs).map((option) => ({ name: option, value: option })));
61
- return customer_config_1.default.createFrom(configs[selectedConfig], selectedConfig);
59
+ return customer_config_1.CustomerConfig.createFrom(configs[selectedConfig], selectedConfig);
62
60
  }
63
61
  }
64
62
  exports.default = CustomerConfigHandler;
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
5
- const install_resource_file_1 = tslib_1.__importDefault(require("../struct/install-resource-file"));
6
- const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
5
+ const integration_api_model_1 = require("../integration-api-model");
7
6
  const PREDICTIVE_PRELOADING = "predictive-preloading";
8
7
  class InstallResourceHandler extends file_handler_1.default {
9
8
  allowedFiles = [
@@ -33,11 +32,11 @@ class InstallResourceHandler extends file_handler_1.default {
33
32
  }
34
33
  async handle(filePath) {
35
34
  const fileName = this.getFileName(filePath);
36
- return new install_resource_file_1.default(fileName, filePath, await this.getFileContent(fileName, filePath), this.getRemoteKey(fileName));
35
+ return new integration_api_model_1.InstallResourceFile(fileName, filePath, await this.getFileContent(fileName, filePath), this.getRemoteKey(fileName));
37
36
  }
38
37
  getRemoteKey(fileName) {
39
38
  if (!this.remoteKeyMapping[fileName]) {
40
- throw new application_error_1.default({ message: `unknown fileName ${fileName}` });
39
+ throw new Error(`unknown fileName ${fileName}`);
41
40
  }
42
41
  return this.remoteKeyMapping[fileName];
43
42
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
5
- const module_file_1 = tslib_1.__importDefault(require("../struct/module-file"));
5
+ const module_file_1 = require("../struct/module-file");
6
6
  class ModuleHandler extends file_handler_1.default {
7
7
  blackList = [];
8
8
  /**
@@ -14,7 +14,7 @@ class ModuleHandler extends file_handler_1.default {
14
14
  return !this.blackList.includes(this.getFileName(filePath));
15
15
  }
16
16
  async handle(filePath) {
17
- return new module_file_1.default(this.getFileName(filePath), filePath, await this.fileReader.getContent(filePath), module_file_1.default);
17
+ return new module_file_1.ModuleFile(this.getFileName(filePath), filePath, await this.fileReader.getContent(filePath), module_file_1.ModuleFile);
18
18
  }
19
19
  }
20
20
  exports.default = ModuleHandler;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
5
- const server_config_file_1 = tslib_1.__importDefault(require("../struct/server-config-file"));
5
+ const integration_api_model_1 = require("../integration-api-model");
6
6
  class ServerConfigHandler extends file_handler_1.default {
7
7
  allowedFiles = ["orestes_config"];
8
8
  canHandle(filePath) {
@@ -10,7 +10,7 @@ class ServerConfigHandler extends file_handler_1.default {
10
10
  }
11
11
  async handle(filePath) {
12
12
  const fileContent = await this.fileReader.getContent(filePath);
13
- return new server_config_file_1.default(this.getFileName(filePath), filePath, fileContent, this.getConfig(fileContent));
13
+ return new integration_api_model_1.ServerConfigFile(this.getFileName(filePath), filePath, fileContent, this.getConfig(fileContent));
14
14
  }
15
15
  getConfig(content) {
16
16
  return JSON.parse(content);
@@ -0,0 +1,3 @@
1
+ export * from "./integration-api-model";
2
+ export * from "./integration-api-factory";
3
+ export * from "./integration-api-service";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./integration-api-model"), exports);
5
+ tslib_1.__exportStar(require("./integration-api-factory"), exports);
6
+ tslib_1.__exportStar(require("./integration-api-service"), exports);
@@ -0,0 +1,13 @@
1
+ import { IntegrationApiService } from "./integration-api-service";
2
+ import { IntegrationApiContext } from "./integration-api-model";
3
+ import { UserCliConfig } from "../../helpers/cli-config";
4
+ export declare class IntegrationApiFactory {
5
+ private context;
6
+ private cliConfig;
7
+ service?: IntegrationApiService;
8
+ private fileReader?;
9
+ constructor(context: IntegrationApiContext, cliConfig: UserCliConfig);
10
+ buildService(): IntegrationApiService;
11
+ private build;
12
+ private getFileReader;
13
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegrationApiFactory = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const integration_api_service_1 = require("./integration-api-service");
6
+ const file_reader_1 = tslib_1.__importDefault(require("./file-reader"));
7
+ const mandatory_files_validator_1 = tslib_1.__importDefault(require("./validator/mandatory-files-validator"));
8
+ const customer_config_handler_1 = tslib_1.__importDefault(require("./handler/customer-config-handler"));
9
+ const customer_config_validator_1 = tslib_1.__importDefault(require("./validator/customer-config-validator"));
10
+ const install_resource_handler_1 = tslib_1.__importDefault(require("./handler/install-resource-handler"));
11
+ const module_handler_1 = tslib_1.__importDefault(require("./handler/module-handler"));
12
+ const server_config_handler_1 = tslib_1.__importDefault(require("./handler/server-config-handler"));
13
+ const file_writer_1 = tslib_1.__importDefault(require("./file-writer"));
14
+ const cli_1 = require("../cli");
15
+ const virtual_file_handler_1 = require("./virtual/virtual-file-handler");
16
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
17
+ class IntegrationApiFactory {
18
+ context;
19
+ cliConfig;
20
+ service = undefined;
21
+ fileReader;
22
+ constructor(context, cliConfig) {
23
+ this.context = context;
24
+ this.cliConfig = cliConfig;
25
+ }
26
+ buildService() {
27
+ if (!(this.service instanceof integration_api_service_1.IntegrationApiService)) {
28
+ this.build();
29
+ }
30
+ return this.service;
31
+ }
32
+ build() {
33
+ const fileReader = this.getFileReader();
34
+ const cli = new cli_1.CliServiceFactory().getService();
35
+ const virtualFileHandler = new virtual_file_handler_1.VirtualFileHandler(cli);
36
+ this.service = new integration_api_service_1.IntegrationApiService(fileReader, virtualFileHandler, new mandatory_files_validator_1.default(), [
37
+ new customer_config_handler_1.default(fileReader, cli, new customer_config_validator_1.default(), this.context.configName, this.cliConfig.testApp),
38
+ new install_resource_handler_1.default(fileReader),
39
+ new server_config_handler_1.default(fileReader),
40
+ new module_handler_1.default(fileReader),
41
+ ], new file_writer_1.default(node_fs_1.default, this.context.basePath), this.context.whiteList.length === 0);
42
+ }
43
+ getFileReader() {
44
+ if (!this.fileReader) {
45
+ this.fileReader = new file_reader_1.default(node_fs_1.default, this.context.configName, this.context.basePath, this.context.whiteList, this.context.blockedFolders);
46
+ }
47
+ return this.fileReader;
48
+ }
49
+ }
50
+ exports.IntegrationApiFactory = IntegrationApiFactory;
@@ -1,4 +1,15 @@
1
- import CustomerConfig from "./struct/customer-config";
1
+ export * from "./struct/customer-config";
2
+ export * from "./struct/file";
3
+ export * from "./struct/customer-config-file";
4
+ export * from "./struct/module-file";
5
+ export * from "./struct/install-resource-file";
6
+ export * from "./struct/server-config-file";
7
+ export * from "./struct/ro-file";
8
+ export * from "./struct/virtual-file";
9
+ export * from "./virtual/virtual-file-handler";
10
+ export * from "./virtual/external-recipe";
11
+ export * from "./external/external-file-reader";
12
+ import { CustomerConfig } from "./struct/customer-config";
2
13
  import { RoFile } from "./struct/ro-file";
3
14
  import { VirtualFile } from "./struct/virtual-file";
4
15
  export interface CustomerConfigOnboardingFile {
@@ -13,8 +24,6 @@ export interface CustomerConfigOnboardingFile {
13
24
  };
14
25
  };
15
26
  }
16
- type FileType = InstallResourceInterface | ModuleInterface | ServerConfigInterface | FileInterface | RoFile | VirtualFile;
17
- type FileTypes = FileType[];
18
27
  export interface FileListInterface {
19
28
  files: (InstallResourceInterface | ModuleInterface | ServerConfigInterface | FileInterface | RoFile | VirtualFile)[];
20
29
  addFile(file: FileInterface): void;
@@ -22,20 +31,14 @@ export interface FileListInterface {
22
31
  getModules(): ModuleInterface[];
23
32
  getServerConfig(): ServerConfigInterface;
24
33
  getCustomerConfig(): CustomerConfigInterface;
25
- getByType(type: any): FileTypes;
26
- getTypes(): any[];
34
+ getByType<T>(type: FILE_TYPE): FileInterface[] | T[];
35
+ getTypes(): FILE_TYPE[];
27
36
  filter(callback: (file: FileInterface) => boolean): void;
28
37
  hasFile(fileName: string): boolean;
29
38
  getByName<T>(name: string): T;
30
39
  concat(fileList: FileListInterface): void;
31
40
  replace(replace: InstallResourceInterface | ModuleInterface | ServerConfigInterface | FileInterface | RoFile | VirtualFile): void;
32
41
  }
33
- export interface IntegrationApiContextInterface {
34
- basePath: string;
35
- configName: string;
36
- whiteList: string[];
37
- blockedFolders: string[];
38
- }
39
42
  export interface IntegrationApiHandler {
40
43
  canHandle(filePath: string): boolean;
41
44
  handle(filePath: string): Promise<FileInterface>;
@@ -47,9 +50,18 @@ export interface MandatoryFilesConfigInterface {
47
50
  or: string[];
48
51
  };
49
52
  }
53
+ export declare enum FILE_TYPE {
54
+ CONFIG_FILE = "config",
55
+ INSTALL_FILE = "install",
56
+ MODULE_FILE = "module",
57
+ SERVER_FILE = "server",
58
+ VIRTUAL_FILE = "virtual",
59
+ READONLY_FILE = "readonly",
60
+ CUSTOMER_FILE = "customer"
61
+ }
50
62
  export interface FileInterface {
51
- readonly type: any;
52
63
  readonly name: string;
64
+ readonly type: FILE_TYPE;
53
65
  skipFile(): void;
54
66
  shouldSkipFile(): boolean;
55
67
  getContent(): string;
@@ -71,7 +83,7 @@ export interface ServerConfigInterface extends ConfigFileInterface, FileInterfac
71
83
  export interface InstallResourceInterface extends ConfigFileInterface, FileInterface {
72
84
  readonly remoteKey: string;
73
85
  }
74
- export interface CustomerConfigInterface extends ConfigFileInterface, FileInterface {
86
+ export interface CustomerConfigInterface extends ConfigFileInterface {
75
87
  config: CustomerConfig;
76
88
  readonly configName: string;
77
89
  }
@@ -86,4 +98,11 @@ export type VirtualFileConfig = {
86
98
  recipe: VirtualFileRecipe;
87
99
  overrideLocalFile?: boolean;
88
100
  };
89
- export {};
101
+ export declare const DEFAULT_BLOCKED_FOLDERS: string[];
102
+ export declare class IntegrationApiContext {
103
+ readonly basePath: string;
104
+ readonly configName: string;
105
+ readonly whiteList: string[];
106
+ readonly blockedFolders: string[];
107
+ constructor(basePath: string, configName: string, whitelist: string[], blockedFolders?: string[]);
108
+ }