@speedkit/cli 2.26.0 → 2.27.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 (144) hide show
  1. package/CHANGELOG.md +18 -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/deploy/checks/post-deploy/save-files-check.d.ts +1 -1
  11. package/dist/services/deploy/checks/pre-deploy/split-change-check.d.ts +1 -2
  12. package/dist/services/deploy/deploy-service-factory.js +3 -4
  13. package/dist/services/deploy/deploy-service.d.ts +3 -2
  14. package/dist/services/deploy/deploy-service.js +23 -1
  15. package/dist/services/deploy/handler/customer-config-handler.d.ts +4 -5
  16. package/dist/services/deploy/handler/customer-config-handler.js +2 -2
  17. package/dist/services/deploy/handler/install-resource-handler.d.ts +3 -4
  18. package/dist/services/deploy/handler/install-resource-handler.js +2 -3
  19. package/dist/services/deploy/handler/module-handler.d.ts +8 -5
  20. package/dist/services/deploy/handler/module-handler.js +2 -3
  21. package/dist/services/deploy/handler/server-config-handler.d.ts +9 -6
  22. package/dist/services/deploy/handler/server-config-handler.js +6 -4
  23. package/dist/services/document-handler-runtime/document-handler-runtime-service.d.ts +2 -3
  24. package/dist/services/document-handler-runtime/document-handler-runtime-service.js +2 -6
  25. package/dist/services/document-handler-runtime/document-handler-server.d.ts +1 -2
  26. package/dist/services/document-handler-runtime/document-handler-server.js +2 -5
  27. package/dist/services/document-handler-runtime/error/required-file-not-found-error.d.ts +1 -2
  28. package/dist/services/document-handler-runtime/error/required-file-not-found-error.js +1 -3
  29. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.d.ts +3 -6
  30. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +9 -18
  31. package/dist/services/integration-api/error/customer-config-legacy-error.d.ts +1 -2
  32. package/dist/services/integration-api/error/customer-config-legacy-error.js +1 -3
  33. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.d.ts +1 -2
  34. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.js +1 -1
  35. package/dist/services/integration-api/error/handler/origin-handler.d.ts +1 -2
  36. package/dist/services/integration-api/error/handler/origin-handler.js +1 -1
  37. package/dist/services/integration-api/error/origin-error.d.ts +1 -2
  38. package/dist/services/integration-api/error/origin-error.js +1 -3
  39. package/dist/services/integration-api/file-list.d.ts +3 -5
  40. package/dist/services/integration-api/file-list.js +6 -10
  41. package/dist/services/integration-api/file-reader.d.ts +14 -6
  42. package/dist/services/integration-api/file-reader.js +8 -8
  43. package/dist/services/integration-api/file-writer.d.ts +10 -2
  44. package/dist/services/integration-api/file-writer.js +9 -6
  45. package/dist/services/integration-api/handler/customer-config-handler.js +6 -8
  46. package/dist/services/integration-api/handler/install-resource-handler.js +3 -4
  47. package/dist/services/integration-api/handler/module-handler.js +2 -2
  48. package/dist/services/integration-api/handler/server-config-handler.js +2 -2
  49. package/dist/services/integration-api/index.d.ts +3 -0
  50. package/dist/services/integration-api/index.js +6 -0
  51. package/dist/services/integration-api/integration-api-factory.d.ts +13 -0
  52. package/dist/services/integration-api/integration-api-factory.js +50 -0
  53. package/dist/services/integration-api/integration-api-model.d.ts +33 -14
  54. package/dist/services/integration-api/integration-api-model.js +37 -0
  55. package/dist/services/integration-api/integration-api-service.d.ts +1 -2
  56. package/dist/services/integration-api/integration-api-service.js +3 -23
  57. package/dist/services/integration-api/spec/customer-config-validator.spec.d.ts +1 -0
  58. package/dist/services/integration-api/spec/customer-config-validator.spec.js +50 -0
  59. package/dist/services/integration-api/spec/file-list.spec.d.ts +1 -0
  60. package/dist/services/integration-api/spec/file-list.spec.js +163 -0
  61. package/dist/services/integration-api/spec/file-reader.spec.d.ts +1 -0
  62. package/dist/services/integration-api/spec/file-reader.spec.js +71 -0
  63. package/dist/services/integration-api/spec/file-writer.spec.d.ts +1 -0
  64. package/dist/services/integration-api/spec/file-writer.spec.js +55 -0
  65. package/dist/services/integration-api/spec/integration-api-service.spec.d.ts +1 -0
  66. package/dist/services/integration-api/spec/integration-api-service.spec.js +122 -0
  67. package/dist/services/integration-api/spec/mandatory-files-validator.spec.d.ts +1 -0
  68. package/dist/services/integration-api/spec/mandatory-files-validator.spec.js +105 -0
  69. package/dist/services/integration-api/struct/customer-config-file.d.ts +3 -4
  70. package/dist/services/integration-api/struct/customer-config-file.js +7 -6
  71. package/dist/services/integration-api/struct/customer-config.d.ts +3 -5
  72. package/dist/services/integration-api/struct/customer-config.js +5 -8
  73. package/dist/services/integration-api/struct/file.d.ts +4 -4
  74. package/dist/services/integration-api/struct/file.js +6 -6
  75. package/dist/services/integration-api/struct/install-resource-file.d.ts +4 -3
  76. package/dist/services/integration-api/struct/install-resource-file.js +7 -5
  77. package/dist/services/integration-api/struct/module-file.d.ts +4 -3
  78. package/dist/services/integration-api/struct/module-file.js +7 -5
  79. package/dist/services/integration-api/struct/ro-file.d.ts +2 -2
  80. package/dist/services/integration-api/struct/ro-file.js +1 -1
  81. package/dist/services/integration-api/struct/server-config-file.d.ts +5 -4
  82. package/dist/services/integration-api/struct/server-config-file.js +7 -5
  83. package/dist/services/integration-api/struct/virtual-file.d.ts +2 -2
  84. package/dist/services/integration-api/struct/virtual-file.js +2 -1
  85. package/dist/services/integration-api/validator/customer-config-validator.d.ts +5 -1
  86. package/dist/services/integration-api/validator/customer-config-validator.js +28 -17
  87. package/dist/services/integration-api/virtual/static-recipe.d.ts +6 -0
  88. package/dist/services/integration-api/virtual/static-recipe.js +14 -0
  89. package/dist/services/integration-api/virtual/virtual-file-handler.js +2 -2
  90. package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +1 -2
  91. package/dist/services/onboarding/dashboard/index.d.ts +1 -1
  92. package/dist/services/onboarding/dashboard/parameter-query-builder.d.ts +1 -2
  93. package/dist/services/onboarding/fetch-event-handler.d.ts +1 -1
  94. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +1 -2
  95. package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +1 -1
  96. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +1 -1
  97. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +1 -1
  98. package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +1 -2
  99. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +1 -1
  100. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +1 -2
  101. package/dist/services/onboarding/file-events/file-watcher.d.ts +1 -2
  102. package/dist/services/onboarding/file-events/file-watcher.js +3 -3
  103. package/dist/services/onboarding/onboarding-service-factory.js +9 -13
  104. package/dist/services/onboarding/onboarding-service.d.ts +1 -1
  105. package/dist/services/onboarding/todo-collector.js +2 -2
  106. package/dist/services/pull/pull-service-factory.js +3 -4
  107. package/dist/services/pull/pull-service.d.ts +1 -1
  108. package/dist/services/pull/pull-service.js +2 -3
  109. package/oclif.manifest.json +1 -1
  110. package/package.json +5 -5
  111. package/dist/services/context/error/context-runtime-error.d.ts +0 -3
  112. package/dist/services/context/error/context-runtime-error.js +0 -7
  113. package/dist/services/context/interface/context-interface.d.ts +0 -2
  114. package/dist/services/context/interface/context-interface.js +0 -2
  115. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.d.ts +0 -6
  116. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js +0 -14
  117. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.d.ts +0 -6
  118. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.js +0 -19
  119. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.d.ts +0 -6
  120. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.js +0 -18
  121. package/dist/services/error-handling/abstract/abstract-error-handling-factory.d.ts +0 -6
  122. package/dist/services/error-handling/abstract/abstract-error-handling-factory.js +0 -19
  123. package/dist/services/error-handling/abstract/abstract-error-handling-service.d.ts +0 -6
  124. package/dist/services/error-handling/abstract/abstract-error-handling-service.js +0 -19
  125. package/dist/services/error-handling/error/application-error.d.ts +0 -5
  126. package/dist/services/error-handling/error/application-error.js +0 -11
  127. package/dist/services/error-handling/error-handling-service.d.ts +0 -7
  128. package/dist/services/error-handling/error-handling-service.js +0 -27
  129. package/dist/services/error-handling/factory/error-handling-factory.d.ts +0 -5
  130. package/dist/services/error-handling/factory/error-handling-factory.js +0 -22
  131. package/dist/services/error-handling/interface/error-context-interface.d.ts +0 -6
  132. package/dist/services/error-handling/interface/error-context-interface.js +0 -2
  133. package/dist/services/error-handling/interface/error-handler-interface.d.ts +0 -5
  134. package/dist/services/error-handling/interface/error-handler-interface.js +0 -2
  135. package/dist/services/error-handling/interface/error-handling-factory-interface.d.ts +0 -8
  136. package/dist/services/error-handling/interface/error-handling-factory-interface.js +0 -2
  137. package/dist/services/error-handling/interface/error-handling-service-interface.d.ts +0 -8
  138. package/dist/services/error-handling/interface/error-handling-service-interface.js +0 -2
  139. package/dist/services/integration-api/context/integration-api-context.d.ts +0 -9
  140. package/dist/services/integration-api/context/integration-api-context.js +0 -20
  141. package/dist/services/integration-api/error/handler/customer-config-handler.d.ts +0 -5
  142. package/dist/services/integration-api/error/handler/customer-config-handler.js +0 -19
  143. package/dist/services/integration-api/factory/integration-api-service-factory.d.ts +0 -13
  144. package/dist/services/integration-api/factory/integration-api-service-factory.js +0 -55
@@ -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
+ }
@@ -1,2 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegrationApiContext = exports.DEFAULT_BLOCKED_FOLDERS = exports.FILE_TYPE = void 0;
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./struct/customer-config"), exports);
6
+ tslib_1.__exportStar(require("./struct/file"), exports);
7
+ tslib_1.__exportStar(require("./struct/customer-config-file"), exports);
8
+ tslib_1.__exportStar(require("./struct/module-file"), exports);
9
+ tslib_1.__exportStar(require("./struct/install-resource-file"), exports);
10
+ tslib_1.__exportStar(require("./struct/server-config-file"), exports);
11
+ tslib_1.__exportStar(require("./struct/ro-file"), exports);
12
+ tslib_1.__exportStar(require("./struct/virtual-file"), exports);
13
+ tslib_1.__exportStar(require("./virtual/virtual-file-handler"), exports);
14
+ tslib_1.__exportStar(require("./virtual/external-recipe"), exports);
15
+ tslib_1.__exportStar(require("./external/external-file-reader"), exports);
16
+ var FILE_TYPE;
17
+ (function (FILE_TYPE) {
18
+ FILE_TYPE["CONFIG_FILE"] = "config";
19
+ FILE_TYPE["INSTALL_FILE"] = "install";
20
+ FILE_TYPE["MODULE_FILE"] = "module";
21
+ FILE_TYPE["SERVER_FILE"] = "server";
22
+ FILE_TYPE["VIRTUAL_FILE"] = "virtual";
23
+ FILE_TYPE["READONLY_FILE"] = "readonly";
24
+ FILE_TYPE["CUSTOMER_FILE"] = "customer";
25
+ })(FILE_TYPE || (exports.FILE_TYPE = FILE_TYPE = {}));
26
+ exports.DEFAULT_BLOCKED_FOLDERS = ["test", ".local", ".git", ".idea"];
27
+ class IntegrationApiContext {
28
+ basePath;
29
+ configName;
30
+ whiteList;
31
+ blockedFolders;
32
+ constructor(basePath, configName, whitelist, blockedFolders) {
33
+ this.basePath = basePath;
34
+ this.configName = configName;
35
+ this.whiteList = whitelist;
36
+ this.blockedFolders = blockedFolders || exports.DEFAULT_BLOCKED_FOLDERS;
37
+ }
38
+ }
39
+ exports.IntegrationApiContext = IntegrationApiContext;
@@ -3,7 +3,7 @@ import MandatoryFilesValidator from "./validator/mandatory-files-validator";
3
3
  import FileWriter from "./file-writer";
4
4
  import { FileListInterface, IntegrationApiHandler, VirtualFileConfig } from "./integration-api-model";
5
5
  import { VirtualFileHandler } from "./virtual/virtual-file-handler";
6
- export default class IntegrationApiService {
6
+ export declare class IntegrationApiService {
7
7
  private fileReader;
8
8
  private virtualFileHandler;
9
9
  private validator;
@@ -17,5 +17,4 @@ export default class IntegrationApiService {
17
17
  createFolder(path: string): void;
18
18
  private collectFiles;
19
19
  private processFile;
20
- private filterFilesToProcess;
21
20
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegrationApiService = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const file_list_1 = tslib_1.__importDefault(require("./file-list"));
5
6
  class IntegrationApiService {
@@ -34,13 +35,12 @@ class IntegrationApiService {
34
35
  this.fileWriter.mkdir(path);
35
36
  }
36
37
  async collectFiles() {
37
- const files = await this.fileReader.getFileList();
38
+ const files = this.fileReader.getFileList();
38
39
  const fileList = new file_list_1.default();
39
40
  for (const file of files) {
40
41
  fileList.addFile(await this.processFile(file));
41
42
  }
42
43
  if (this.shouldValidate) {
43
- this.filterFilesToProcess(fileList);
44
44
  this.validator.validate(fileList);
45
45
  }
46
46
  return fileList;
@@ -54,25 +54,5 @@ class IntegrationApiService {
54
54
  }
55
55
  throw new Error(`No handler found for file: ${file}`);
56
56
  }
57
- filterFilesToProcess(fileList) {
58
- fileList.filter((file) => {
59
- // if we have a documentHandlerConfig we don't need an assetHandler
60
- if (file.name === "speedKit.Asset" &&
61
- fileList.hasFile("config_documentHandler")) {
62
- return false;
63
- }
64
- // if we don't have a documentHandlerConfig we don't need styles
65
- if (file.name === "config_dynamicStyles" &&
66
- !fileList.hasFile("config_documentHandler")) {
67
- return false;
68
- }
69
- // if we don't have a documentHandlerConfig we don't need dynamicBlocks
70
- if (file.name === "config_dynamicBlocks" &&
71
- !fileList.hasFile("config_documentHandler")) {
72
- return false;
73
- }
74
- return true;
75
- });
76
- }
77
57
  }
78
- exports.default = IntegrationApiService;
58
+ exports.IntegrationApiService = IntegrationApiService;