@speedkit/cli 4.43.0-beta.1 → 4.43.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 (86) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +12 -2
  3. package/dist/commands/onboarding.d.ts +3 -0
  4. package/dist/commands/onboarding.js +7 -1
  5. package/dist/services/bundler/bundle-service-factory.d.ts +1 -6
  6. package/dist/services/bundler/bundle-service-factory.js +2 -9
  7. package/dist/services/bundler/bundle-service.d.ts +1 -10
  8. package/dist/services/bundler/bundle-service.js +1 -16
  9. package/dist/services/bundler/index.d.ts +0 -1
  10. package/dist/services/bundler/index.js +0 -1
  11. package/dist/services/cli/cli-environment.js +0 -1
  12. package/dist/services/cli/cli-settings.d.ts +0 -5
  13. package/dist/services/cli/cli-settings.js +0 -1
  14. package/dist/services/deploy/checks/activation/customer-approval-check.js +1 -1
  15. package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +3 -2
  16. package/dist/services/deploy/checks/pre-deploy/split-change-check.js +3 -2
  17. package/dist/services/deploy/deploy-service-factory.js +1 -1
  18. package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +1 -1
  19. package/dist/services/document-handler-runtime/document-handler-runtime-model.d.ts +0 -2
  20. package/dist/services/document-handler-runtime/document-handler-runtime-model.js +0 -2
  21. package/dist/services/document-handler-runtime/document-handler-server.d.ts +0 -17
  22. package/dist/services/document-handler-runtime/document-handler-server.js +20 -82
  23. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +1 -1
  24. package/dist/services/integration-api/integration-api-factory.js +1 -1
  25. package/dist/services/integration-api/integration-api-model.d.ts +1 -2
  26. package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +8 -70
  27. package/dist/services/integration-api/struct/customer-config.d.ts +1 -19
  28. package/dist/services/integration-api/struct/customer-config.js +3 -11
  29. package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +4 -9
  30. package/dist/services/integration-api/struct/speed-kit-config-file.js +10 -30
  31. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +8 -24
  32. package/dist/services/onboarding/error/inject-installation-error.d.ts +6 -0
  33. package/dist/services/onboarding/error/inject-installation-error.js +11 -0
  34. package/dist/services/onboarding/error/inject-target-error.d.ts +6 -0
  35. package/dist/services/onboarding/error/inject-target-error.js +11 -0
  36. package/dist/services/onboarding/error/missing-customer-path-error.d.ts +1 -1
  37. package/dist/services/onboarding/error/missing-customer-path-error.js +2 -1
  38. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +4 -14
  39. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +6 -45
  40. package/dist/services/onboarding/fetch-events/document-rewrite.d.ts +19 -0
  41. package/dist/services/onboarding/fetch-events/document-rewrite.js +47 -0
  42. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +5 -1
  43. package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +7 -2
  44. package/dist/services/onboarding/html-rewrites.d.ts +3 -3
  45. package/dist/services/onboarding/html-rewrites.js +3 -3
  46. package/dist/services/onboarding/index.d.ts +1 -1
  47. package/dist/services/onboarding/index.js +1 -1
  48. package/dist/services/onboarding/inject/content-security-policy.d.ts +14 -0
  49. package/dist/services/onboarding/inject/content-security-policy.js +54 -0
  50. package/dist/services/onboarding/inject/deployed-installation.d.ts +15 -0
  51. package/dist/services/onboarding/inject/deployed-installation.js +32 -0
  52. package/dist/services/onboarding/inject/foreign-install-request.d.ts +27 -0
  53. package/dist/services/onboarding/inject/foreign-install-request.js +50 -0
  54. package/dist/services/onboarding/inject/inject-document-rewrite.d.ts +23 -0
  55. package/dist/services/onboarding/inject/inject-document-rewrite.js +52 -0
  56. package/dist/services/onboarding/inject/inject-service.d.ts +32 -0
  57. package/dist/services/onboarding/inject/inject-service.js +72 -0
  58. package/dist/services/onboarding/inject/injected-installation.d.ts +29 -0
  59. package/dist/services/onboarding/inject/injected-installation.js +37 -0
  60. package/dist/services/onboarding/onboarding-service-build-context.d.ts +15 -1
  61. package/dist/services/onboarding/onboarding-service-build-context.js +31 -2
  62. package/dist/services/onboarding/onboarding-service-factory.d.ts +23 -5
  63. package/dist/services/onboarding/onboarding-service-factory.js +87 -7
  64. package/dist/services/onboarding/spec/inject/content-security-policy.spec.js +47 -0
  65. package/dist/services/onboarding/spec/inject/deployed-installation.spec.d.ts +1 -0
  66. package/dist/services/onboarding/spec/inject/deployed-installation.spec.js +49 -0
  67. package/dist/services/onboarding/spec/inject/foreign-install-request.spec.d.ts +1 -0
  68. package/dist/services/onboarding/spec/inject/foreign-install-request.spec.js +47 -0
  69. package/dist/services/onboarding/spec/inject/inject-document-rewrite.spec.d.ts +1 -0
  70. package/dist/services/onboarding/spec/inject/inject-document-rewrite.spec.js +66 -0
  71. package/dist/services/onboarding/spec/inject/injected-installation.spec.d.ts +1 -0
  72. package/dist/services/onboarding/spec/inject/injected-installation.spec.js +24 -0
  73. package/dist/services/onboarding/spec/onboarding-service-build-context.spec.d.ts +1 -0
  74. package/dist/services/onboarding/spec/onboarding-service-build-context.spec.js +22 -0
  75. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +53 -2
  76. package/dist/services/onboarding/templates/install-speed-kit-html-template.js +3 -0
  77. package/dist/services/onboarding/templates/install-speed-kit-js-template.js +0 -5
  78. package/dist/services/query-builder/query-builder-factory.js +3 -3
  79. package/oclif.manifest.json +26 -3
  80. package/package.json +1 -2
  81. package/dist/services/bundler/error/packjockel-error.d.ts +0 -3
  82. package/dist/services/bundler/error/packjockel-error.js +0 -3
  83. package/dist/services/bundler/packjockel-service.d.ts +0 -70
  84. package/dist/services/bundler/packjockel-service.js +0 -171
  85. package/dist/services/bundler/spec/packjockel-service.spec.js +0 -149
  86. /package/dist/services/{bundler/spec/packjockel-service.spec.d.ts → onboarding/spec/inject/content-security-policy.spec.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
- # [4.43.0-beta.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.42.0...v4.43.0-beta.1) (2026-10-08)
1
+ # [4.43.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.42.0...v4.43.0) (2026-10-09)
2
2
 
3
3
 
4
4
  ### Features
5
5
 
6
- * bundle with packjockel for customers with the configPlugins feature ([32e7ce6](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/32e7ce69a51b7501e32a65e4f38773daffc58a03))
6
+ * **onboarding:** add --inject, a deployed installation on the real site ([fcc0a97](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/fcc0a9708e3acdd3a32a2a96f4779c59534242c5))
7
7
 
8
8
  # [4.42.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.41.2...v4.42.0) (2026-10-07)
9
9
 
package/README.md CHANGED
@@ -728,10 +728,10 @@ Start a local dev environment for building and testing the Speed Kit configurati
728
728
  ```
729
729
  USAGE
730
730
  $ sk onboarding [CUSTOMERPATH] [-c <value>] [-t] [-d <value>] [-p] [--debugPort <value>] [-v] [-s]
731
- [--headless] [--browse] [--browserFetch]
731
+ [--headless] [--app <value> [--inject [<installationId>] | --browse]] [--browserFetch]
732
732
 
733
733
  ARGUMENTS
734
- [CUSTOMERPATH] The customer config path (optional with --browse)
734
+ [CUSTOMERPATH] The customer config path (optional with --browse and --inject)
735
735
 
736
736
  FLAGS
737
737
  -c, --configName=<value> [default: production] The costumer config name
@@ -740,6 +740,8 @@ FLAGS
740
740
  -s, --ignoreContentSecurityPolicy Removes header/meta "content-security-policy" for origin-responses
741
741
  -t, --useTestConfig Override app with configured testApp
742
742
  -v, --verboseLevel Show all messages
743
+ --app=<value> The app of the installation that --inject uses. Wins over the app of the customer
744
+ config.
743
745
  --browse Open the live site in the onboarding Chrome, with its extensions, but without
744
746
  request interception or Speed Kit injection. Takes the domain from -d or from the
745
747
  customer config.
@@ -750,6 +752,10 @@ FLAGS
750
752
  distinct ports to run multiple onboarding processes at once.
751
753
  --headless Run Chrome in headless mode (for CI environments). Implicitly enables remote
752
754
  debugging port.
755
+ --inject=[<installationId>] Inject a deployed Speed Kit installation into the site, for a customer that has not
756
+ installed Speed Kit. Without a value it uses the latest deployed installation. With
757
+ an id it uses that testing installation. Needs no local config: without a
758
+ CUSTOMERPATH, pass --app and -d.
753
759
 
754
760
  DESCRIPTION
755
761
  Start a local dev environment for building and testing the Speed Kit configuration
@@ -762,6 +768,10 @@ EXAMPLES
762
768
  $ sk onboarding --browse -d www.decathlon.de --headless --debugPort 9290
763
769
 
764
770
  $ sk onboarding customers/decathlon.de --browse -p
771
+
772
+ $ sk onboarding customers/decathlon.de --inject
773
+
774
+ $ sk onboarding customers/decathlon.de --inject <installationId>
765
775
  ```
766
776
 
767
777
  ## `sk origin-request CUSTOMERPATH PAGEURL`
@@ -17,11 +17,14 @@ export default class Onboarding extends SkCommand<OnboardingServiceBuildContext>
17
17
  ignoreContentSecurityPolicy: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
18
  headless: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
19
  browse: import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
+ inject: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
21
+ app: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
20
22
  browserFetch: import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
23
  useTestConfig: import("@oclif/core/interfaces").BooleanFlag<boolean>;
22
24
  configName: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
23
25
  };
24
26
  static examples: string[];
27
+ init(): Promise<void>;
25
28
  /** Onboarding runs the customer's documentHandler, with its node modules. */
26
29
  protected customerPathForModules(args: Record<string, unknown>): string | undefined;
27
30
  run(): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { SkCommand } from "../base/sk-command.js";
2
- import { OnboardingServiceBuildContext, OnboardingServiceFactory, } from "../services/onboarding/index.js";
2
+ import { OnboardingServiceBuildContext, OnboardingServiceFactory, withInjectDefault, } from "../services/onboarding/index.js";
3
3
  export default class Onboarding extends SkCommand {
4
4
  static description = "Start a local dev environment for building and testing the Speed Kit configuration";
5
5
  static buildContext = OnboardingServiceBuildContext;
@@ -10,7 +10,13 @@ export default class Onboarding extends SkCommand {
10
10
  `$ sk onboarding customers/decathlon.de -c production -d www.decathlon.de`,
11
11
  `$ sk onboarding --browse -d www.decathlon.de --headless --debugPort 9290`,
12
12
  `$ sk onboarding customers/decathlon.de --browse -p`,
13
+ `$ sk onboarding customers/decathlon.de --inject`,
14
+ `$ sk onboarding customers/decathlon.de --inject <installationId>`,
13
15
  ];
16
+ async init() {
17
+ this.argv = withInjectDefault(this.argv);
18
+ await super.init();
19
+ }
14
20
  /** Onboarding runs the customer's documentHandler, with its node modules. */
15
21
  customerPathForModules(args) {
16
22
  return args.customerPath;
@@ -1,11 +1,6 @@
1
1
  import { BundleService } from "./bundle-service.js";
2
2
  export declare class BundleServiceFactory {
3
3
  private customerFolder?;
4
- private packjockelPath;
5
- /**
6
- * @param customerFolder the directory bundled code resolves its own imports from
7
- * @param packjockelPath the `PACKJOCKEL_PATH` setting; empty means the installed npm package
8
- */
9
- constructor(customerFolder?: string, packjockelPath?: string);
4
+ constructor(customerFolder?: string);
10
5
  buildService(): BundleService;
11
6
  }
@@ -1,17 +1,10 @@
1
1
  import { BundleService } from "./bundle-service.js";
2
- import { PackjockelService, resolvePackjockelBinary, } from "./packjockel-service.js";
3
2
  export class BundleServiceFactory {
4
3
  customerFolder;
5
- packjockelPath;
6
- /**
7
- * @param customerFolder the directory bundled code resolves its own imports from
8
- * @param packjockelPath the `PACKJOCKEL_PATH` setting; empty means the installed npm package
9
- */
10
- constructor(customerFolder, packjockelPath = "") {
4
+ constructor(customerFolder) {
11
5
  this.customerFolder = customerFolder;
12
- this.packjockelPath = packjockelPath;
13
6
  }
14
7
  buildService() {
15
- return new BundleService(this.customerFolder, new PackjockelService(resolvePackjockelBinary(this.packjockelPath)));
8
+ return new BundleService(this.customerFolder);
16
9
  }
17
10
  }
@@ -1,5 +1,4 @@
1
1
  import { PluginBuild, LogLevel } from "esbuild";
2
- import type { PackjockelService } from "./packjockel-service.js";
3
2
  export type BundleEntryPoints = Record<string, string>;
4
3
  export type BundleBasePaths = Record<string, string>;
5
4
  /**
@@ -9,18 +8,10 @@ export type BundleBasePaths = Record<string, string>;
9
8
  export type BundleResolveFallback = (specifier: string) => Promise<string | null>;
10
9
  export declare class BundleService {
11
10
  private moduleDiscoveryDir;
12
- private readonly packjockelService?;
13
11
  /**
14
12
  * @param moduleDiscoveryDir the directory bundled code resolves its own imports from
15
- * @param packjockelService bundles instead of esbuild for customers with the `configPlugins` feature
16
13
  */
17
- constructor(moduleDiscoveryDir: string, packjockelService?: PackjockelService);
18
- /**
19
- * The packjockel bundler for customers with the `configPlugins` feature.
20
- *
21
- * @throws ApplicationError when the service was built without one
22
- */
23
- get packjockel(): PackjockelService;
14
+ constructor(moduleDiscoveryDir: string);
24
15
  bundle({ entryPoints, basePaths, define, target, minify, logLevel, alias, platform, resolveFallback, packages, }: {
25
16
  entryPoints: BundleEntryPoints;
26
17
  basePaths?: BundleBasePaths;
@@ -4,31 +4,16 @@ import { URL } from "node:url";
4
4
  import { BundleResolveError } from "./error/bundle-resolve-error.js";
5
5
  import { BundleFetchError } from "./error/bundle-fetch-error.js";
6
6
  import { resolve } from "node:path";
7
- import ApplicationError from "../error-handling/error/application-error.js";
8
7
  const FALLBACK_NAMESPACE = "bundle-resolve-fallback";
9
8
  const RELATIVE_SPECIFIER = /^\.{1,2}\//;
10
9
  const importCache = {};
11
10
  export class BundleService {
12
11
  moduleDiscoveryDir;
13
- packjockelService;
14
12
  /**
15
13
  * @param moduleDiscoveryDir the directory bundled code resolves its own imports from
16
- * @param packjockelService bundles instead of esbuild for customers with the `configPlugins` feature
17
14
  */
18
- constructor(moduleDiscoveryDir, packjockelService) {
15
+ constructor(moduleDiscoveryDir) {
19
16
  this.moduleDiscoveryDir = moduleDiscoveryDir;
20
- this.packjockelService = packjockelService;
21
- }
22
- /**
23
- * The packjockel bundler for customers with the `configPlugins` feature.
24
- *
25
- * @throws ApplicationError when the service was built without one
26
- */
27
- get packjockel() {
28
- if (!this.packjockelService) {
29
- throw new ApplicationError("This bundler has no packjockel");
30
- }
31
- return this.packjockelService;
32
17
  }
33
18
  async bundle({ entryPoints, basePaths, define, target = "es5", minify = true, logLevel = "silent", alias = {}, platform, resolveFallback, packages = "bundle", }) {
34
19
  const plugins = [];
@@ -1,3 +1,2 @@
1
1
  export * from "./bundle-service-factory.js";
2
2
  export * from "./bundle-service.js";
3
- export * from "./packjockel-service.js";
@@ -1,3 +1,2 @@
1
1
  export * from "./bundle-service-factory.js";
2
2
  export * from "./bundle-service.js";
3
- export * from "./packjockel-service.js";
@@ -16,7 +16,6 @@ const environmentMapping = {
16
16
  ideaDirectory: "IDEA_INITIAL_DIRECTORY",
17
17
  slackToken: "SLACK_TOKEN",
18
18
  testApp: "TEST_APP",
19
- packjockelPath: "PACKJOCKEL_PATH",
20
19
  };
21
20
  const CONFIG_FILE_NAME = "config.json";
22
21
  /** Variables CI providers set besides `CI`. */
@@ -24,11 +24,6 @@ export interface CliSettings {
24
24
  ideaDirectory: string;
25
25
  slackToken: string;
26
26
  testApp: string;
27
- /**
28
- * the packjockel binary, run for customers with the `configPlugins` feature; empty means the one of
29
- * the installed `@speedkit/packjockel` package
30
- */
31
- packjockelPath: string;
32
27
  browserChannel: string;
33
28
  browserBuildId: string;
34
29
  browserAutoUpdate: boolean;
@@ -11,7 +11,6 @@ export function defaultSettings() {
11
11
  ideaDirectory: "",
12
12
  slackToken: "",
13
13
  testApp: "",
14
- packjockelPath: "",
15
14
  browserChannel: "",
16
15
  browserBuildId: "",
17
16
  browserAutoUpdate: false,
@@ -50,7 +50,7 @@ export class CustomerApprovalCheck {
50
50
  const configFile = await VirtualSpeedKitConfigFile.createRemote(speedKitConfig, this.bundler);
51
51
  const splits = [];
52
52
  for (const origin of this.customer.origins) {
53
- const result = await safe(configFile.evaluate(this.customer, origin));
53
+ const result = await safe(configFile.evaluate(this.customer.app, origin));
54
54
  if (result.success === false) {
55
55
  // An unreadable config is not proof that the split is 0, so keep the
56
56
  // approval question rather than skipping it.
@@ -61,10 +61,11 @@ export class DeviceDetectionChangedCheck {
61
61
  }
62
62
  async checkForChangedDeviceDetection(speedKitConfigFile, activeSpeedKitConfig) {
63
63
  const remoteConfigFile = await VirtualSpeedKitConfigFile.createRemote(activeSpeedKitConfig, this.bundler);
64
+ const app = this.customerConfig.app;
64
65
  const origin = this.customerConfig.origins[0];
65
66
  const changes = [];
66
- const localSpeedKit = await speedKitConfigFile.evaluate(this.customerConfig, origin);
67
- const remoteSpeedKit = await remoteConfigFile.evaluate(this.customerConfig, origin);
67
+ const localSpeedKit = await speedKitConfigFile.evaluate(app, origin);
68
+ const remoteSpeedKit = await remoteConfigFile.evaluate(app, origin);
68
69
  if ((localSpeedKit.detectDevice && !remoteSpeedKit.detectDevice) ||
69
70
  (!localSpeedKit.detectDevice && remoteSpeedKit.detectDevice)) {
70
71
  changes.push("detectDevice");
@@ -63,10 +63,11 @@ export class SplitChangeCheck {
63
63
  }
64
64
  async checkSplitsForEachOrigin(speedKitConfigFile, activeSpeedKitConfig) {
65
65
  const remoteConfigFile = await VirtualSpeedKitConfigFile.createRemote(activeSpeedKitConfig, this.bundler);
66
+ const app = this.customerConfig.app;
66
67
  const changes = [];
67
68
  for (const origin of this.customerConfig.origins) {
68
- const localSpeedKit = await speedKitConfigFile.evaluate(this.customerConfig, origin);
69
- const remoteSpeedKit = await remoteConfigFile.evaluate(this.customerConfig, origin);
69
+ const localSpeedKit = await speedKitConfigFile.evaluate(app, origin);
70
+ const remoteSpeedKit = await remoteConfigFile.evaluate(app, origin);
70
71
  // check for split change
71
72
  if (localSpeedKit.split !== remoteSpeedKit.split) {
72
73
  changes.push({
@@ -60,7 +60,7 @@ export default class DeployServiceFactory {
60
60
  })).getService();
61
61
  const policy = this.policyOverride ?? new InteractiveDeployPolicy(cliService);
62
62
  const installResourceBuilder = new InstallResourceBuilder(configApi);
63
- const bundler = new BundleServiceFactory("./", this.context.environment.settings.packjockelPath).buildService();
63
+ const bundler = new BundleServiceFactory("./").buildService();
64
64
  const deletedFilesChecker = new DeletedFileCheck(cliService, policy, this.context.hasArtifacts);
65
65
  this.service = new DeployService(files, [
66
66
  new CustomerConfigHandler(customer, configApi, configName, diffService, cliService, installResourceBuilder, policy),
@@ -63,6 +63,6 @@ export class MergeRequestDeployServiceFactory {
63
63
  whitelist: [],
64
64
  }))
65
65
  .buildService()
66
- .run()), new LiveStateCheck(diffService), new CustomerApprovalCheck(cliService, deployFactory.files.getCustomerConfig().config, policy, new BundleServiceFactory("./", this.context.environment.settings.packjockelPath).buildService()), deployFactory.configApi, deployFactory.files, deployFactory.configName, deployService);
66
+ .run()), new LiveStateCheck(diffService), new CustomerApprovalCheck(cliService, deployFactory.files.getCustomerConfig().config, policy, new BundleServiceFactory("./").buildService()), deployFactory.configApi, deployFactory.files, deployFactory.configName, deployService);
67
67
  }
68
68
  }
@@ -4,6 +4,4 @@ export declare const LOCAL_DYNAMIC_FETCHER = "custom_dynamicFetcher";
4
4
  export declare const LOCAL_DYNAMIC_FETCHER_CONFIG = "config_dynamicBlocks";
5
5
  export declare const LOCAL_STYLES = "config_dynamicStyles";
6
6
  export declare const LATEST_DYNAMIC_FETCHER_URL = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
7
- /** Where the imports of the latest dynamic fetcher resolve. */
8
- export declare const DYNAMIC_FETCHER_BASE_PATH = "https://www.baqend.com/speed-kit/latest/";
9
7
  export declare const LOCAL_TRIGGERED_BY = "STREAM:QA";
@@ -4,8 +4,6 @@ export const LOCAL_DYNAMIC_FETCHER = "custom_dynamicFetcher";
4
4
  export const LOCAL_DYNAMIC_FETCHER_CONFIG = "config_dynamicBlocks";
5
5
  export const LOCAL_STYLES = "config_dynamicStyles";
6
6
  export const LATEST_DYNAMIC_FETCHER_URL = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
7
- /** Where the imports of the latest dynamic fetcher resolve. */
8
- export const DYNAMIC_FETCHER_BASE_PATH = "https://www.baqend.com/speed-kit/latest/";
9
7
  // Local runs have no persistent cache, so an origin HTML is served straight to the developer and may
10
8
  // legitimately be older than the default five minutes. STREAM:QA relaxes the document handler's
11
9
  // Shopify staleness check to one hour, see ONE_HOUR_STALENESS_TRIGGERS in document-handler.
@@ -13,11 +13,6 @@ export declare class DocumentHandlerServer {
13
13
  private entityManager?;
14
14
  private documentHandlerCode;
15
15
  private documentHandlerConfigCode;
16
- /**
17
- * The packjockel bundle for a customer with the `configPlugins` feature: the handler, its config
18
- * and the Speed Kit config in one CommonJS module, which exports `post`.
19
- */
20
- private documentHandlerBundle?;
21
16
  private database;
22
17
  /** Sources of app modules already looked up; `null` marks a lookup that came back empty. */
23
18
  private readonly appModules;
@@ -27,23 +22,11 @@ export declare class DocumentHandlerServer {
27
22
  */
28
23
  constructor(customerConfig: CustomerConfig, files: FileListInterface, bundler: BundleService, cli: CliServiceInterface, workSpace: string, verboseLevel?: boolean, entityManager?: EntityManager);
29
24
  transform(contentType: string, html: string, variation: string, url: string, headers: Record<string, string>): Promise<DocumentHandlerResponse>;
30
- /** Runs the handler in the context, and returns the config, which calls its `post`. */
31
- private createScript;
32
- /** Loads the packjockel bundle like a CommonJS module, and calls the `post` it exports. */
33
- private createBundleScript;
34
- private getDocumentHandlerConfigPath;
35
25
  private getTransformFunctionWrapper;
36
26
  buildDocumentHandler(): Promise<void>;
37
- /**
38
- * Bundles the handler, its config and the Speed Kit config into one module, the way the server
39
- * deploys a customer with the `configPlugins` feature.
40
- */
41
- private bundleWithPackjockel;
42
27
  private deactivateReleaseAndDeploymentDetection;
43
28
  private getDocumentHandler;
44
29
  private getDynamicFetcher;
45
- /** The customer's own dynamic fetcher, or else the source of the latest one. */
46
- private getDynamicFetcherSource;
47
30
  private getDynamicFetcherConfig;
48
31
  private getStyles;
49
32
  private getDocumentHandlerConfig;
@@ -1,9 +1,7 @@
1
- import { DYNAMIC_FETCHER_BASE_PATH, LATEST_DYNAMIC_FETCHER_URL, LOCAL_DOCUMENT_HANDLER, LOCAL_DOCUMENT_HANDLER_CONFIG, LOCAL_DYNAMIC_FETCHER, LOCAL_DYNAMIC_FETCHER_CONFIG, LOCAL_STYLES, } from "./document-handler-runtime-model.js";
1
+ import { LATEST_DYNAMIC_FETCHER_URL, LOCAL_DOCUMENT_HANDLER, LOCAL_DOCUMENT_HANDLER_CONFIG, LOCAL_DYNAMIC_FETCHER, LOCAL_DYNAMIC_FETCHER_CONFIG, LOCAL_STYLES, } from "./document-handler-runtime-model.js";
2
2
  import RequiredFileNotFoundError from "./error/required-file-not-found-error.js";
3
3
  import DatabaseMock from "./templates/database-mock.js";
4
4
  import * as vm from "node:vm";
5
- import { speedKitConfigBasePath, } from "../bundler/index.js";
6
- import { usesConfigPlugins, } from "../integration-api/index.js";
7
5
  import { INTEGRATION_FILES } from "../../models/files.js";
8
6
  // documentHandlerDependencies
9
7
  import fetch from "node-fetch";
@@ -27,11 +25,6 @@ export class DocumentHandlerServer {
27
25
  entityManager;
28
26
  documentHandlerCode;
29
27
  documentHandlerConfigCode;
30
- /**
31
- * The packjockel bundle for a customer with the `configPlugins` feature: the handler, its config
32
- * and the Speed Kit config in one CommonJS module, which exports `post`.
33
- */
34
- documentHandlerBundle;
35
28
  database;
36
29
  /** Sources of app modules already looked up; `null` marks a lookup that came back empty. */
37
30
  appModules = new Map();
@@ -49,11 +42,7 @@ export class DocumentHandlerServer {
49
42
  this.entityManager = entityManager;
50
43
  }
51
44
  async transform(contentType, html, variation, url, headers) {
52
- const configPlugins = usesConfigPlugins(this.customerConfig);
53
- const built = configPlugins
54
- ? this.documentHandlerBundle
55
- : this.documentHandlerCode && this.documentHandlerConfigCode;
56
- if (!built) {
45
+ if (!this.documentHandlerCode || !this.documentHandlerConfigCode) {
57
46
  await this.buildDocumentHandler();
58
47
  }
59
48
  const skInternalRequest = new Request(url, html, variation, headers, {
@@ -68,21 +57,26 @@ export class DocumentHandlerServer {
68
57
  skInternalError: {},
69
58
  Abort: DocumentHandlerAbort,
70
59
  APP: this.customerConfig.app,
71
- // packjockel defines these in the bundle itself.
72
- ...(configPlugins
73
- ? {}
74
- : {
75
- DYNAMIC_FETCHER: await this.getDynamicFetcher(),
76
- DYNAMIC_FETCHER_CONFIG: await this.getDynamicFetcherConfig(),
77
- CUSTOM_STYLES: this.getStyles(),
78
- }),
60
+ DYNAMIC_FETCHER: await this.getDynamicFetcher(),
61
+ DYNAMIC_FETCHER_CONFIG: await this.getDynamicFetcherConfig(),
62
+ CUSTOM_STYLES: this.getStyles(),
79
63
  ...this.getContextVars(),
80
64
  ...this.createNodeVmContext(),
81
65
  skErrorContext: {},
82
66
  };
83
- const script = configPlugins
84
- ? this.createBundleScript()
85
- : this.createScript(vmContext);
67
+ const customDocumentHandlerFile = this.files.getByName(INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER);
68
+ if (customDocumentHandlerFile.path) {
69
+ vm.runInNewContext(this.documentHandlerCode, vmContext, {
70
+ filename: customDocumentHandlerFile.path,
71
+ displayErrors: true,
72
+ });
73
+ }
74
+ else {
75
+ vm.runInNewContext(this.documentHandlerCode, vmContext);
76
+ }
77
+ const script = new vm.Script(this.documentHandlerConfigCode + this.getTransformFunctionWrapper(), {
78
+ filename: this.files.getByName("config_documentHandler").path,
79
+ });
86
80
  const vmResponse = await safe(new Promise((resolve, reject) => {
87
81
  vmContext.skInternalResponse.resolve = resolve;
88
82
  // @ts-expect-error reject is unknown
@@ -98,66 +92,17 @@ export class DocumentHandlerServer {
98
92
  }
99
93
  throw new DocumentHandlerTransformError(vmResponse.errorObj);
100
94
  }
101
- /** Runs the handler in the context, and returns the config, which calls its `post`. */
102
- createScript(vmContext) {
103
- const customDocumentHandlerFile = this.files.getByName(INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER);
104
- if (customDocumentHandlerFile.path) {
105
- vm.runInNewContext(this.documentHandlerCode, vmContext, {
106
- filename: customDocumentHandlerFile.path,
107
- displayErrors: true,
108
- });
109
- }
110
- else {
111
- vm.runInNewContext(this.documentHandlerCode, vmContext);
112
- }
113
- return new vm.Script(this.documentHandlerConfigCode + this.getTransformFunctionWrapper(), { filename: this.getDocumentHandlerConfigPath() });
114
- }
115
- /** Loads the packjockel bundle like a CommonJS module, and calls the `post` it exports. */
116
- createBundleScript() {
117
- return new vm.Script(`(function (module, exports) {\n${this.documentHandlerBundle}\n})(module, module.exports);\n\n` +
118
- `module.exports.post(db, skInternalRequest, skInternalResponse).catch((error)=>reject(error));`, { filename: this.getDocumentHandlerConfigPath() });
119
- }
120
- getDocumentHandlerConfigPath() {
121
- return this.files.getByName("config_documentHandler")
122
- .path;
123
- }
124
95
  getTransformFunctionWrapper() {
125
96
  return `\n\npost(db, skInternalRequest, skInternalResponse).catch((error)=>reject(error));`;
126
97
  }
127
98
  async buildDocumentHandler() {
128
99
  this.cli.startAction("DOCUMENTHANDLER:BUILD", "rebuild documentHandler");
129
- if (usesConfigPlugins(this.customerConfig)) {
130
- this.documentHandlerBundle = await this.bundleWithPackjockel();
131
- this.cli.successAction("DOCUMENTHANDLER:BUILD");
132
- return;
133
- }
134
100
  this.documentHandlerCode = await this.bundleDocumentHandlerCode("custom_documentHandler.js", await this.getDocumentHandler());
135
101
  this.documentHandlerConfigCode = await this.bundleDocumentHandlerCode("config_documentHandler.js", this.deactivateReleaseAndDeploymentDetection());
136
102
  this.cli.successAction("DOCUMENTHANDLER:BUILD");
137
103
  }
138
- /**
139
- * Bundles the handler, its config and the Speed Kit config into one module, the way the server
140
- * deploys a customer with the `configPlugins` feature.
141
- */
142
- async bundleWithPackjockel() {
143
- return this.bundler.packjockel.bundleDocumentHandler({
144
- documentHandler: await this.getDocumentHandler(),
145
- documentHandlerConfig: this.deactivateReleaseAndDeploymentDetection(),
146
- speedKitConfig: this.files
147
- .getByName(INTEGRATION_FILES.CONFIG.SPEED_KIT)
148
- .getContent(),
149
- appName: this.customerConfig.app,
150
- dynamicFetcher: await this.getDynamicFetcherSource(),
151
- dynamicFetcherConfig: await this.getDynamicFetcherConfig(),
152
- customStyle: this.getStyles(),
153
- basePaths: {
154
- "speed-kit-config": speedKitConfigBasePath(this.customerConfig.configPluginsVersion),
155
- "dynamic-fetcher": DYNAMIC_FETCHER_BASE_PATH,
156
- },
157
- });
158
- }
159
104
  deactivateReleaseAndDeploymentDetection() {
160
- return this.getDocumentHandlerConfig().replace(/const documentHandler =|export default new /, (selected) => {
105
+ return this.getDocumentHandlerConfig().replace("const documentHandler =", (selected) => {
161
106
  return (`config["executeDeploymentDetection"] = false;config["executeReleaseDetection"] = false;\n` +
162
107
  selected);
163
108
  });
@@ -168,17 +113,10 @@ export class DocumentHandlerServer {
168
113
  .getContent();
169
114
  }
170
115
  async getDynamicFetcher() {
171
- if (!this.files.hasFile(LOCAL_DYNAMIC_FETCHER)) {
172
- return await this.bundleDynamicFetcher({ "dynamic-fetcher": DYNAMIC_FETCHER_BASE_PATH }, await this.getDynamicFetcherSource());
173
- }
174
- return this.getDynamicFetcherSource();
175
- }
176
- /** The customer's own dynamic fetcher, or else the source of the latest one. */
177
- async getDynamicFetcherSource() {
178
116
  // todo use fetchRemoteFile from integration api
179
117
  if (!this.files.hasFile(LOCAL_DYNAMIC_FETCHER)) {
180
118
  const response = await fetch(LATEST_DYNAMIC_FETCHER_URL);
181
- return await response.text();
119
+ return await this.bundleDynamicFetcher({ "dynamic-fetcher": "https://www.baqend.com/speed-kit/latest/" }, await response.text());
182
120
  }
183
121
  return this.files
184
122
  .getByName(INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER)
@@ -25,7 +25,7 @@ export default class DocumentHandlerRuntimeServiceFactory {
25
25
  const customerConfig = this.getCustomerConfig(files);
26
26
  const cliService = this.context.environment.cli;
27
27
  await this.installAdditionalDependencies(customerConfig, cliService);
28
- const bundler = new BundleServiceFactory(this.context.customerPath, this.context.environment.settings.packjockelPath).buildService();
28
+ const bundler = new BundleServiceFactory(this.context.customerPath).buildService();
29
29
  // the non-prompting lookup: the document handler runs with a session when
30
30
  // there is one and without when there is not, so it must not stop the
31
31
  // command at a login prompt to find out
@@ -30,7 +30,7 @@ export class IntegrationApiFactory {
30
30
  const virtualFileHandler = new VirtualFileHandler(cli);
31
31
  this.service = new IntegrationApiService(fileReader, virtualFileHandler, new MandatoryFilesValidator(), [
32
32
  new CustomerConfigHandler(fileReader, cli, new CustomerConfigValidator(), this.context.configName, this.context.environment.settings.testApp, this.context.useTestConfig ?? false),
33
- new InstallResourceHandler(fileReader, new BundleServiceFactory("./", this.context.environment.settings.packjockelPath).buildService()),
33
+ new InstallResourceHandler(fileReader, new BundleServiceFactory("./").buildService()),
34
34
  new ServerConfigHandler(fileReader),
35
35
  new ModuleHandler(fileReader),
36
36
  ], new FileWriter(fs, this.context.basePath), this.whitelist.length === 0);
@@ -13,7 +13,6 @@ export * from "./virtual/external-recipe.js";
13
13
  export * from "./virtual/static-recipe.js";
14
14
  export * from "./external/external-file-reader.js";
15
15
  import type { SpeedKitConfig } from "./struct/speed-kit-config.js";
16
- import type { SpeedKitConfigCustomer } from "./struct/speed-kit-config-file.js";
17
16
  import { CustomerConfig } from "./struct/customer-config.js";
18
17
  import { RoFile } from "./struct/ro-file.js";
19
18
  import { VirtualFile } from "./struct/virtual-file.js";
@@ -90,7 +89,7 @@ export interface InstallResourceInterface extends ConfigFileInterface, FileInter
90
89
  readonly remoteKey: string;
91
90
  }
92
91
  export interface SpeedKitConfigInterface extends InstallResourceInterface {
93
- evaluate(customer: SpeedKitConfigCustomer, origin: string): Promise<SpeedKitConfig>;
92
+ evaluate(app: string, origin: string): Promise<SpeedKitConfig>;
94
93
  }
95
94
  export interface CustomerConfigInterface extends ConfigFileInterface {
96
95
  config: CustomerConfig;