@speedkit/cli 2.31.0 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -1
  3. package/dist/helpers/file-helper.d.ts +6 -0
  4. package/dist/helpers/file-helper.js +6 -0
  5. package/dist/helpers/race.d.ts +1 -1
  6. package/dist/helpers/race.js +8 -9
  7. package/dist/helpers/safe.js +2 -2
  8. package/dist/models/cli-parameters.js +4 -3
  9. package/dist/services/athena/athena-service.js +3 -2
  10. package/dist/services/athena/error/athena-query-error.d.ts +4 -0
  11. package/dist/services/athena/error/athena-query-error.js +9 -0
  12. package/dist/services/athena/error/fetch-credentials-error.d.ts +5 -1
  13. package/dist/services/athena/error/fetch-credentials-error.js +9 -1
  14. package/dist/services/bundler/bundle-service.js +5 -3
  15. package/dist/services/bundler/error/bundle-fetch-error.d.ts +3 -0
  16. package/dist/services/bundler/error/bundle-fetch-error.js +8 -0
  17. package/dist/services/bundler/error/bundle-resolve-error.d.ts +3 -0
  18. package/dist/services/bundler/error/bundle-resolve-error.js +8 -0
  19. package/dist/services/config-api/client.d.ts +1 -1
  20. package/dist/services/config-api/client.js +29 -7
  21. package/dist/services/config-api/error/json-response-error.d.ts +3 -1
  22. package/dist/services/config-api/error/json-response-error.js +4 -1
  23. package/dist/services/config-api/error/login-error.d.ts +3 -3
  24. package/dist/services/config-api/error/login-error.js +3 -4
  25. package/dist/services/config-api/factory/config-api-service-factory.js +2 -1
  26. package/dist/services/config-api-service.d.ts +3 -0
  27. package/dist/services/config-api-service.js +3 -0
  28. package/dist/services/customer-config/customer-config-service-model.d.ts +2 -0
  29. package/dist/services/customer-config/customer-config-service.js +10 -2
  30. package/dist/services/customer-config/templates/config_SpeedKit.js.hbs +35 -1
  31. package/dist/services/customer-config/templates/config_customer.js.hbs +1 -20
  32. package/dist/services/customer-config/templates/config_documentHandler.js.hbs +112 -112
  33. package/dist/services/customer-config/templates/config_dynamicBlocks.es6.hbs +290 -108
  34. package/dist/services/customer-config/templates/config_dynamicStyles.css.hbs +8 -8
  35. package/dist/services/customer-config/templates/config_loadHandler.js.hbs +61 -0
  36. package/dist/services/deploy/error/file-handler-error.d.ts +4 -0
  37. package/dist/services/deploy/error/file-handler-error.js +9 -0
  38. package/dist/services/diff-service.d.ts +3 -0
  39. package/dist/services/diff-service.js +3 -0
  40. package/dist/services/document-handler-runtime/document-handler-server.js +2 -4
  41. package/dist/services/error-handling/error/application-error.d.ts +18 -0
  42. package/dist/services/error-handling/error/application-error.js +28 -0
  43. package/dist/services/error-handling/error/config-file-error.d.ts +4 -0
  44. package/dist/services/error-handling/error/config-file-error.js +9 -0
  45. package/dist/services/error-handling/error/connection-error.d.ts +4 -0
  46. package/dist/services/error-handling/error/connection-error.js +9 -0
  47. package/dist/services/integration-api/error/customer-config-error.d.ts +2 -1
  48. package/dist/services/integration-api/error/customer-config-error.js +2 -1
  49. package/dist/services/integration-api/error/customer-config-legacy-error.d.ts +3 -1
  50. package/dist/services/integration-api/error/customer-config-legacy-error.js +4 -1
  51. package/dist/services/integration-api/error/mandatory-file-missing-error.d.ts +3 -2
  52. package/dist/services/integration-api/error/mandatory-file-missing-error.js +4 -4
  53. package/dist/services/integration-api/error/origin-error.d.ts +2 -1
  54. package/dist/services/integration-api/error/origin-error.js +2 -1
  55. package/dist/services/integration-api/error/read-files-error.d.ts +5 -0
  56. package/dist/services/integration-api/error/read-files-error.js +10 -0
  57. package/dist/services/integration-api/external/external-file-reader.js +8 -2
  58. package/dist/services/integration-api/file-reader.js +12 -4
  59. package/dist/services/integration-api/handler/customer-config-handler.d.ts +1 -0
  60. package/dist/services/integration-api/handler/customer-config-handler.js +22 -5
  61. package/dist/services/integration-api/handler/install-resource-handler.js +2 -1
  62. package/dist/services/integration-api/integration-api-service.js +2 -1
  63. package/dist/services/integration-api/spec/mandatory-files-validator.spec.js +4 -3
  64. package/dist/services/integration-api/validator/customer-config-validator.js +1 -1
  65. package/dist/services/integration-api/validator/mandatory-files-validator.js +6 -2
  66. package/dist/services/onboarding/error/vm-error.d.ts +3 -1
  67. package/dist/services/onboarding/error/vm-error.js +4 -1
  68. package/dist/services/onboarding/fetch-event-handler.js +1 -1
  69. package/dist/services/onboarding/todo-collector.d.ts +1 -1
  70. package/dist/services/onboarding/todo-collector.js +2 -2
  71. package/dist/services/prewarm/csv-reader.js +1 -3
  72. package/dist/services/prewarm/error/invalid-origin-error.d.ts +2 -1
  73. package/dist/services/prewarm/error/invalid-origin-error.js +3 -1
  74. package/dist/services/prewarm/error/read-csv-error.d.ts +4 -5
  75. package/dist/services/prewarm/error/read-csv-error.js +5 -8
  76. package/dist/templates/pops.js +7 -12
  77. package/oclif.manifest.json +7 -1
  78. package/package.json +1 -1
  79. package/dist/helpers/get-chrome-path.d.ts +0 -7
  80. package/dist/helpers/get-chrome-path.js +0 -31
  81. package/dist/helpers/is-executable.d.ts +0 -1
  82. package/dist/helpers/is-executable.js +0 -15
  83. package/dist/helpers/watch-files.d.ts +0 -1
  84. package/dist/helpers/watch-files.js +0 -20
  85. package/dist/services/deploy/error/create-find-temporary-directory-error.d.ts +0 -4
  86. package/dist/services/deploy/error/create-find-temporary-directory-error.js +0 -10
  87. package/dist/services/deploy/error/deploy-app-error.d.ts +0 -2
  88. package/dist/services/deploy/error/deploy-app-error.js +0 -5
  89. package/dist/services/deploy/error/no-active-installation-error.d.ts +0 -4
  90. package/dist/services/deploy/error/no-active-installation-error.js +0 -10
  91. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.d.ts +0 -5
  92. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.js +0 -24
  93. package/dist/services/integration-api/error/handler/origin-handler.d.ts +0 -5
  94. package/dist/services/integration-api/error/handler/origin-handler.js +0 -22
  95. package/dist/services/integration-api/error/load-customer-error.d.ts +0 -4
  96. package/dist/services/integration-api/error/load-customer-error.js +0 -10
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # [2.32.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.31.1...v2.32.0) (2024-06-14)
2
+
3
+
4
+ ### Features
5
+
6
+ * **config-wizard:** update prerendering template ([1f3e26b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/1f3e26b849d12d8f3337e70fde8d49b11cfba9b9))
7
+ * **config-wizard:** update prerendering template ([92cbc1b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/92cbc1bbd8d750b7fcf1677ed602256d6d5d2e65))
8
+ * **config-wizard:** update prerendering template ([1419422](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/1419422a4e8f40307a173ca28688840dd3055661))
9
+ * **config-wizard:** update prerendering template ([3ac8632](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/3ac8632b1f6521af6da7672c0ff8d11d2f6842d5))
10
+ * **config-wizard:** update prerendering template ([4e8e710](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/4e8e71011b3ec969d97d185869638abe8e15fb9d))
11
+
12
+ ## [2.31.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.31.0...v2.31.1) (2024-06-13)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * update pop list ([127a6d1](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/127a6d1b2ec404d7be69fd5d4f3fd6201d3faa9c))
18
+
1
19
  # [2.31.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.30.1...v2.31.0) (2024-06-04)
2
20
 
3
21
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @speedkit/cli
21
21
  $ sk COMMAND
22
22
  running command...
23
23
  $ sk (--version)
24
- @speedkit/cli/2.31.0 linux-x64 node-v20.14.0
24
+ @speedkit/cli/2.32.0 linux-x64 node-v20.14.0
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -1,2 +1,8 @@
1
+ /**
2
+ * @deprecated
3
+ */
1
4
  export declare function createTemporalDirectory(): Promise<null | string>;
5
+ /**
6
+ * @deprecated
7
+ */
2
8
  export declare function readLocalFile(basePath: string, fileName: string): Promise<null | string>;
@@ -6,6 +6,9 @@ const node_fs_1 = require("node:fs");
6
6
  const os = tslib_1.__importStar(require("node:os"));
7
7
  const path = tslib_1.__importStar(require("node:path"));
8
8
  const customer_config_1 = require("./customer-config");
9
+ /**
10
+ * @deprecated
11
+ */
9
12
  async function createTemporalDirectory() {
10
13
  try {
11
14
  return (0, node_fs_1.mkdtempSync)(path.join(os.tmpdir(), "speed-kit-cli-"));
@@ -16,6 +19,9 @@ async function createTemporalDirectory() {
16
19
  }
17
20
  }
18
21
  exports.createTemporalDirectory = createTemporalDirectory;
22
+ /**
23
+ * @deprecated
24
+ */
19
25
  async function readLocalFile(basePath, fileName) {
20
26
  try {
21
27
  const file = await customer_config_1.ConfigFile.loadFile(basePath, fileName);
@@ -1 +1 @@
1
- export declare function race<T>(promise: Promise<T>): Promise<T>;
1
+ export declare function race<T>(promise: Promise<T>, timeout?: number): Promise<T>;
@@ -1,18 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.race = void 0;
4
- const safe_1 = require("./safe");
4
+ const tslib_1 = require("tslib");
5
+ const application_error_1 = tslib_1.__importDefault(require("../services/error-handling/error/application-error"));
5
6
  const DEFAULT_TIMEOUT = 5000;
6
- async function race(promise) {
7
+ class RaceTimeOutError extends application_error_1.default {
8
+ }
9
+ async function race(promise, timeout = DEFAULT_TIMEOUT) {
7
10
  const timeOut = new Promise((resolve, reject) => {
8
11
  setTimeout(() => {
9
- reject("timeout");
10
- }, DEFAULT_TIMEOUT);
12
+ reject(new RaceTimeOutError(`timeout of ${timeout}ms reached`));
13
+ }, timeout);
11
14
  });
12
- const result = await (0, safe_1.safe)(Promise.race([promise, timeOut]));
13
- if (result.success === true) {
14
- return result.data;
15
- }
16
- throw new Error(result.error);
15
+ return Promise.race([promise, timeOut]);
17
16
  }
18
17
  exports.race = race;
@@ -17,7 +17,7 @@ async function safeAsync(promise) {
17
17
  if (error instanceof Error) {
18
18
  return { success: false, error: error.message, errorObj: error };
19
19
  }
20
- return { success: false, error: "Something went wrong" };
20
+ return { success: false, error: "Something went wrong", errorObj: error };
21
21
  }
22
22
  }
23
23
  function safeSync(function_) {
@@ -29,6 +29,6 @@ function safeSync(function_) {
29
29
  if (error instanceof Error) {
30
30
  return { success: false, error: error.message, errorObj: error };
31
31
  }
32
- return { success: false, error: "Something went wrong" };
32
+ return { success: false, error: "Something went wrong", errorObj: error };
33
33
  }
34
34
  }
@@ -83,12 +83,13 @@ exports.CLI_CONFIG_NAME = {
83
83
  char: CLIParametersChar.ConfigName,
84
84
  default: "production",
85
85
  description: "The costumer config name",
86
+ required: false,
86
87
  }),
87
88
  };
88
89
  exports.CLI_CUSTOMER_CONFIG = {
89
90
  [CLIParameters.CustomerPath]: core_1.Args.directory({
90
- name: CLIParameters.CustomerPath, // name of arg to show in help and reference with args[name]
91
- required: true, // make the arg required with `required: true`
92
- description: "The customer config path", // help description
91
+ name: CLIParameters.CustomerPath,
92
+ required: true,
93
+ description: "The customer config path",
93
94
  }),
94
95
  };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AthenaService = void 0;
4
4
  const client_athena_1 = require("@aws-sdk/client-athena");
5
5
  const athena_service_model_1 = require("./athena-service-model");
6
+ const athena_query_error_1 = require("./error/athena-query-error");
6
7
  class AthenaService {
7
8
  client;
8
9
  constructor(client) {
@@ -99,11 +100,11 @@ class AthenaService {
99
100
  const status = result.QueryExecution.Status;
100
101
  switch (status.State) {
101
102
  case client_athena_1.QueryExecutionState.FAILED: {
102
- throw new Error("The Amazon Athena query failed to run with error message: " +
103
+ throw new athena_query_error_1.AthenaQueryError("The Amazon Athena query failed to run with error message: " +
103
104
  status.StateChangeReason);
104
105
  }
105
106
  case client_athena_1.QueryExecutionState.CANCELLED: {
106
- throw new Error("The Amazon Athena query was cancelled.");
107
+ throw new athena_query_error_1.AthenaQueryError("The Amazon Athena query was cancelled.");
107
108
  }
108
109
  case client_athena_1.QueryExecutionState.SUCCEEDED: {
109
110
  return;
@@ -0,0 +1,4 @@
1
+ import ApplicationError from "../../error-handling/error/application-error";
2
+ export declare class AthenaQueryError extends ApplicationError {
3
+ readonly code = "ATHENA_QUERY_FAILED";
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AthenaQueryError = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
6
+ class AthenaQueryError extends application_error_1.default {
7
+ code = "ATHENA_QUERY_FAILED";
8
+ }
9
+ exports.AthenaQueryError = AthenaQueryError;
@@ -1,2 +1,6 @@
1
- export declare class FetchCredentialsError extends Error {
1
+ import ApplicationError from "../../error-handling/error/application-error";
2
+ export declare class FetchCredentialsError extends ApplicationError {
3
+ readonly suggestions: string[];
4
+ readonly code = "AWS_ATHENA_NO_CREDENTIALS";
5
+ readonly reference = "https://www.notion.so/baqend/AWS-Cli-SSO-login-f19af359eb514114aa6a36cd9b65e0c1";
2
6
  }
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FetchCredentialsError = void 0;
4
- class FetchCredentialsError extends Error {
4
+ const tslib_1 = require("tslib");
5
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
6
+ class FetchCredentialsError extends application_error_1.default {
7
+ suggestions = [
8
+ "login to https://bbq.awsapps.com/start/#/ to gather credentials",
9
+ "or run: aws sso login",
10
+ ];
11
+ code = "AWS_ATHENA_NO_CREDENTIALS";
12
+ reference = "https://www.notion.so/baqend/AWS-Cli-SSO-login-f19af359eb514114aa6a36cd9b65e0c1";
5
13
  }
6
14
  exports.FetchCredentialsError = FetchCredentialsError;
@@ -5,6 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const esbuild_1 = require("esbuild");
6
6
  const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
7
7
  const node_url_1 = require("node:url");
8
+ const bundle_resolve_error_1 = require("./error/bundle-resolve-error");
9
+ const bundle_fetch_error_1 = require("./error/bundle-fetch-error");
8
10
  const importCache = {};
9
11
  class BundleService {
10
12
  async bundle({ entryPoints, basePaths, define, target = "es5", minify = true, logLevel = "silent", }) {
@@ -33,7 +35,7 @@ class BundleService {
33
35
  setup(build) {
34
36
  build.onResolve({ filter: /.*/ }, (arguments_) => {
35
37
  if (!entryPoints[arguments_.path]) {
36
- throw new Error("Could not resolve " + arguments_.path);
38
+ throw new bundle_resolve_error_1.BundleResolveError(`Could not resolve "${arguments_.path}"`);
37
39
  }
38
40
  return {
39
41
  path: arguments_.path,
@@ -58,7 +60,7 @@ class BundleService {
58
60
  const [base, path] = arguments_.path.split("/", 2);
59
61
  const url = new node_url_1.URL(path, basePaths[base]).toString();
60
62
  if (!url.startsWith(basePaths[base])) {
61
- throw new Error(`Importing ${path} failed. Can't resolve the path`);
63
+ throw new bundle_resolve_error_1.BundleResolveError(`Importing ${path} failed. Can't resolve the path`);
62
64
  }
63
65
  return {
64
66
  path: url,
@@ -76,7 +78,7 @@ class BundleService {
76
78
  }
77
79
  const fetched = await (0, node_fetch_1.default)(url);
78
80
  if (!fetched.ok) {
79
- throw new Error(`Importing ${url} failed with error ${fetched.status}`);
81
+ throw new bundle_fetch_error_1.BundleFetchError(`Importing ${url} failed with error ${fetched.status}`);
80
82
  }
81
83
  let text = await fetched.text();
82
84
  text = text.replace("window.SpeedKit=window.SpeedKit||{},window.SpeedKit.plugins=window.SpeedKit.plugins||{},window.SpeedKit.plugins.", "export var ");
@@ -0,0 +1,3 @@
1
+ import ApplicationError from "../../error-handling/error/application-error";
2
+ export declare class BundleFetchError extends ApplicationError {
3
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BundleFetchError = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
6
+ class BundleFetchError extends application_error_1.default {
7
+ }
8
+ exports.BundleFetchError = BundleFetchError;
@@ -0,0 +1,3 @@
1
+ import ApplicationError from "../../error-handling/error/application-error";
2
+ export declare class BundleResolveError extends ApplicationError {
3
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BundleResolveError = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
6
+ class BundleResolveError extends application_error_1.default {
7
+ }
8
+ exports.BundleResolveError = BundleResolveError;
@@ -9,6 +9,6 @@ export default class Client {
9
9
  createRequest(requestExtension: RequestExtensionInterface): Promise<RequestInit>;
10
10
  getEntityManager(): Promise<EntityManager>;
11
11
  getModule(moduleName: string): Promise<string>;
12
- send(url: string, requestExtension?: RequestExtensionInterface): Promise<any>;
12
+ send<T>(url: string, requestExtension?: RequestExtensionInterface): Promise<T>;
13
13
  setModule(moduleName: string, moduleCode: string): Promise<string>;
14
14
  }
@@ -4,6 +4,9 @@ const tslib_1 = require("tslib");
4
4
  const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
5
5
  const node_https_1 = require("node:https");
6
6
  const race_1 = require("../../helpers/race");
7
+ const safe_1 = require("../../helpers/safe");
8
+ const json_response_error_1 = tslib_1.__importDefault(require("./error/json-response-error"));
9
+ const connection_error_1 = require("../error-handling/error/connection-error");
7
10
  const REQUEST_TIMEOUT = 10_000;
8
11
  const CONTENT_TYPE = "application/json;charset=UTF-8";
9
12
  class Client {
@@ -30,24 +33,43 @@ class Client {
30
33
  return { ...(0, deepmerge_1.default)(baseRequest, requestExtension), agent: this.agent };
31
34
  }
32
35
  async getEntityManager() {
33
- return (0, race_1.race)(this.entityManagerFactory.getEntityManager(this.app));
36
+ const result = await (0, safe_1.safe)((0, race_1.race)(this.entityManagerFactory.getEntityManager(this.app), REQUEST_TIMEOUT));
37
+ if (result.success === true) {
38
+ return result.data;
39
+ }
40
+ throw new connection_error_1.ConnectionError(`Could not connect to app: ${this.app} - ${result.error}`);
34
41
  }
35
42
  async getModule(moduleName) {
36
43
  const entityManager = await this.getEntityManager();
37
- return entityManager.code.loadCode(moduleName, "module");
44
+ const moduleResponse = await (0, safe_1.safe)(entityManager.code.loadCode(moduleName, "module"));
45
+ if (moduleResponse.success !== true) {
46
+ throw new connection_error_1.ConnectionError(`Could not load module "${moduleName}" from app "${this.app}" - ${moduleResponse.error}`);
47
+ }
48
+ return moduleResponse.data;
38
49
  }
39
50
  async send(url, requestExtension = {}) {
40
51
  const requestInit = await this.createRequest(requestExtension);
41
- const response = await fetch(url, requestInit);
52
+ const responseResult = await (0, safe_1.safe)(fetch(url, requestInit));
53
+ if (responseResult.success !== true) {
54
+ throw new connection_error_1.ConnectionError(responseResult.error);
55
+ }
56
+ const response = responseResult.data;
42
57
  if (response.status !== 200) {
43
- const message = await response.json();
44
- throw new Error(message);
58
+ throw new connection_error_1.ConnectionError(`${response.statusText}`);
45
59
  }
46
- return response.json();
60
+ const jsonResponse = await (0, safe_1.safe)(response.json());
61
+ if (jsonResponse.success !== true) {
62
+ throw new json_response_error_1.default(jsonResponse.error);
63
+ }
64
+ return jsonResponse.data;
47
65
  }
48
66
  async setModule(moduleName, moduleCode) {
49
67
  const entityManager = await this.getEntityManager();
50
- return entityManager.code.saveCode(moduleName, "module", moduleCode);
68
+ const moduleResponse = await (0, safe_1.safe)(entityManager.code.saveCode(moduleName, "module", moduleCode));
69
+ if (moduleResponse.success !== true) {
70
+ throw new connection_error_1.ConnectionError(`Could not save module "${moduleName}" to app "${this.app}" - ${moduleResponse.error}`);
71
+ }
72
+ return moduleResponse.data;
51
73
  }
52
74
  }
53
75
  exports.default = Client;
@@ -1,2 +1,4 @@
1
- export default class JsonResponseError extends Error {
1
+ import ApplicationError from "../../error-handling/error/application-error";
2
+ export default class JsonResponseError extends ApplicationError {
3
+ readonly code = "JSON_RESPONSE_ERROR";
2
4
  }
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- class JsonResponseError extends Error {
3
+ const tslib_1 = require("tslib");
4
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
5
+ class JsonResponseError extends application_error_1.default {
6
+ code = "JSON_RESPONSE_ERROR";
4
7
  }
5
8
  exports.default = JsonResponseError;
@@ -1,5 +1,5 @@
1
- import DeployAppError from "../../deploy/error/deploy-app-error";
2
- export default class LoginError extends DeployAppError {
3
- app: string;
1
+ import ApplicationError from "../../error-handling/error/application-error";
2
+ export default class LoginError extends ApplicationError {
3
+ readonly code = "LOGIN_ERROR";
4
4
  constructor(app: string);
5
5
  }
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const deploy_app_error_1 = tslib_1.__importDefault(require("../../deploy/error/deploy-app-error"));
5
- class LoginError extends deploy_app_error_1.default {
6
- app;
4
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
5
+ class LoginError extends application_error_1.default {
6
+ code = "LOGIN_ERROR";
7
7
  constructor(app) {
8
8
  super(`Could not login to app ${app}`);
9
- this.app = app;
10
9
  }
11
10
  }
12
11
  exports.default = LoginError;
@@ -7,6 +7,7 @@ const entity_manager_factory_1 = tslib_1.__importDefault(require("./entity-manag
7
7
  const node_fs_1 = require("node:fs");
8
8
  const node_os_1 = tslib_1.__importDefault(require("node:os"));
9
9
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
10
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
10
11
  class ConfigApiServiceFactory {
11
12
  context;
12
13
  service = undefined;
@@ -21,7 +22,7 @@ class ConfigApiServiceFactory {
21
22
  }
22
23
  buildService() {
23
24
  if (!this.context.app) {
24
- throw new Error("app is undefined");
25
+ throw new application_error_1.default("app is undefined");
25
26
  }
26
27
  this.createLoginTokenFileIfNotExists();
27
28
  const entityManagerFactory = new entity_manager_factory_1.default();
@@ -1,5 +1,8 @@
1
1
  import { EntityManager } from "baqend";
2
2
  import Install from "../models/install";
3
+ /**
4
+ * @deprecated
5
+ */
3
6
  export default class ConfigApiService {
4
7
  private db;
5
8
  private readonly app;
@@ -8,6 +8,9 @@ const agent = new node_https_1.default.Agent({
8
8
  rejectUnauthorized: false,
9
9
  keepAlive: true,
10
10
  });
11
+ /**
12
+ * @deprecated
13
+ */
11
14
  /* eslint-disable no-console */
12
15
  class ConfigApiService {
13
16
  db;
@@ -28,6 +28,8 @@ export interface CustomerConfigSettings {
28
28
  activateImageOptimisation?: boolean;
29
29
  removeLazyLoading?: boolean;
30
30
  addPreRendering?: boolean;
31
+ supportShadowDomInPreRendering?: boolean;
32
+ shadowDomCustomElementPrefix?: string;
31
33
  activateRumTracking?: boolean;
32
34
  useGATracking?: boolean;
33
35
  withGoogleOptimize?: boolean;
@@ -161,7 +161,7 @@ class CustomerConfigService {
161
161
  }
162
162
  }
163
163
  async getConfigSettings() {
164
- let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, activateRumTracking, useGATracking, withGoogleOptimize, activateCfRocketLoaderWorkaround, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
164
+ let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, supportShadowDomInPreRendering, shadowDomCustomElementPrefix, activateRumTracking, useGATracking, withGoogleOptimize, activateCfRocketLoaderWorkaround, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
165
165
  this.appName = await this.cli.prompt(`Enter SK App Name:`, {
166
166
  validator: (input) => /^[\da-z]+(?:-[\da-z]+)*$/.test(input) ? "" : "No valid kebab-case",
167
167
  defaultAnswer: this.appName,
@@ -207,7 +207,13 @@ class CustomerConfigService {
207
207
  }
208
208
  activateImageOptimisation = await this.cli.confirm("Activate Image Optimisation?", false);
209
209
  removeLazyLoading = await this.cli.confirm("Remove Lazy-Loading?");
210
- addPreRendering = await this.cli.confirm("Add Pre-Rendering? This requires a set-up Lambda function to work. Also requires a DOM-based DocumentHandler.", false);
210
+ if (await this.cli.confirm("Add Pre-Rendering? This requires a set-up Lambda function to work. Also requires a DOM-based DocumentHandler.", false)) {
211
+ addPreRendering = true;
212
+ if (await this.cli.confirm("Does the customer utilize Shadow DOMs? If so additional handling for this will be added.", false)) {
213
+ supportShadowDomInPreRendering = true;
214
+ shadowDomCustomElementPrefix = await this.cli.prompt("Please specify the prefix of the custom elements used (e.g. o2 uses tef-): ", { defaultAnswer: "custom-" });
215
+ }
216
+ }
211
217
  activateRumTracking = await this.cli.confirm("Activate RUM Tracking?");
212
218
  if (activateRumTracking && !isShopify) {
213
219
  useGATracking = await this.cli.confirm("Add Tracking based on Google Analytics' DataLayer?");
@@ -225,6 +231,8 @@ class CustomerConfigService {
225
231
  activateImageOptimisation,
226
232
  removeLazyLoading,
227
233
  addPreRendering,
234
+ supportShadowDomInPreRendering,
235
+ shadowDomCustomElementPrefix,
228
236
  activateRumTracking,
229
237
  useGATracking,
230
238
  withGoogleOptimize,
@@ -25,6 +25,30 @@
25
25
  var ENABLED_HOSTS = getEnabledHosts(ENABLED_HOSTS_CONFIGS);
26
26
  var CURRENT_HOST_CONFIG = getCurrentHostConfig(ENABLED_HOSTS_CONFIGS);
27
27
 
28
+ {{#if addPreRendering}}
29
+ // Pre-rendering specific: disable SK for tablets as they are not covered in lambda
30
+ function isTablet() {
31
+ var userAgent = window.navigator.userAgent.toLowerCase();
32
+ var tabletUAs = [
33
+ /tablet/,
34
+ /ipad/,
35
+ /nexus 7/,
36
+ /nexus 10/,
37
+ /silk\//,
38
+ /\bgt-[pn]\d{4}\b/,
39
+ /\bsm-t\d{3}\b/,
40
+ /^.*android(?!.*mobile|.*smart-tv|.*smarttv|.*aft[tm]|.*crkey).*$/,
41
+ ];
42
+
43
+ if ("ontouchend" in document && userAgent.indexOf("Macintosh") > -1) {
44
+ return true;
45
+ }
46
+ return tabletUAs.some(function (ua) {
47
+ return ua.test(userAgent);
48
+ });
49
+ }
50
+ {{/if}}
51
+
28
52
  /**
29
53
  * @type {SpeedKitConfig}
30
54
  */
@@ -43,9 +67,13 @@
43
67
  {{/if}}
44
68
  preloadDynamicBlocks: true,
45
69
  rumTracking: {{activateRumTracking}},
70
+ {{#if addPreRendering}}
71
+ // Pre-rendering specific: detect device to cover different resolutions when rendered in lambda
72
+ userAgentDetection: true,
73
+ {{/if}}
46
74
  split: CURRENT_HOST_CONFIG.split,
47
75
  splitTestId: CURRENT_HOST_CONFIG.splitTestId,
48
- disabled: !CURRENT_HOST_CONFIG.enabled,
76
+ disabled: !CURRENT_HOST_CONFIG.enabled{{#if addPreRendering}} || isTablet(){{/if}},
49
77
  enabledSites: [
50
78
  {
51
79
  pathname: [
@@ -122,6 +150,12 @@
122
150
  {{/if}}
123
151
  ],
124
152
  blacklist: [
153
+ {{#if addPreRendering}}
154
+ // blacklist tv variations
155
+ {
156
+ tv: true,
157
+ },
158
+ {{/if}}
125
159
  {
126
160
  pathname: [
127
161
  // TODO: adjust/replace this exemplary list
@@ -32,7 +32,7 @@ const shared = {
32
32
  {{/if}}
33
33
  };
34
34
 
35
- const configs = {
35
+ module.exports = {
36
36
  test: {
37
37
  ...shared,
38
38
  app: process.env.TEST_APP,
@@ -58,22 +58,3 @@ const configs = {
58
58
  // bypassDeactivation: false, // comment out when SK deactivation should not be bypassed
59
59
  },
60
60
  };
61
-
62
- const objectMap = (obj, fn) =>
63
- Object.fromEntries(
64
- Object.entries(obj).map(
65
- ([k, v], i) => [k, fn(v, k, i)],
66
- ),
67
- );
68
-
69
- const completeConfig = config => ({
70
- // create installPath automatically if not set:
71
- {{#if shopifyId}}
72
- installPath: `https://${config.app}.app.baqend.com/v1/speedkit/install.js?d=${config.name}&shop=${config.shopifyId}.myshopify.com`,
73
- {{else}}
74
- installPath: `https://${config.app}.app.baqend.com/v1/speedkit/install.js?d=${config.name}`,
75
- {{/if}}
76
- ...config,
77
- });
78
-
79
- module.exports = objectMap(configs, config => completeConfig(config));