@speedkit/cli 2.70.0 → 2.70.1

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.70.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.70.0...v2.70.1) (2024-12-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **prewarm:** set variationString in correct case ([627959d](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/627959d1d997601840c13a679a304b573c985e6f))
7
+
1
8
  # [2.70.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.69.1...v2.70.0) (2024-12-12)
2
9
 
3
10
 
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.70.0 linux-x64 node-v20.18.1
24
+ @speedkit/cli/2.70.1 linux-x64 node-v20.18.1
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -14,4 +14,20 @@ export declare class AssetApiClient {
14
14
  increaseMaxRequestsPerSecond(): void;
15
15
  private isValidUrl;
16
16
  private setRateLimit;
17
+ /**
18
+ * handle parameter "bqvariation"
19
+ * reflect behaviour of SpeedKit.
20
+ * - do not send default variation
21
+ * - send mobile/tablet/tv as lowercase
22
+ * - send customVariations as they are
23
+ *
24
+ * As orestes will always make variations uppercase and does not care for caseSensitivity,
25
+ * a caseMissMatch on fastly will also resolve in a cacheMiss.
26
+ * That is why we need to preWarm in the correct case always.
27
+ *
28
+ * @param variation
29
+ * @param assetUrl
30
+ * @private
31
+ */
32
+ private setVariationParameter;
17
33
  }
@@ -27,9 +27,7 @@ class AssetApiClient {
27
27
  async fetchURL(url, variation) {
28
28
  this.isValidUrl(url);
29
29
  const assetUrl = new node_url_1.URL((0, normalize_1.normalize)(url, this.sortParameters));
30
- if (variation !== "DEFAULT" && variation !== "DESKTOP") {
31
- assetUrl.searchParams.set("bqvariation", variation);
32
- }
30
+ this.setVariationParameter(variation, assetUrl);
33
31
  assetUrl.searchParams.set("bqpass", "1");
34
32
  return (0, node_fetch_1.default)(`https://${this.app}.app.baqend.com/v1/asset/${assetUrl.toString()}`, {
35
33
  agent: this.agent,
@@ -68,5 +66,33 @@ class AssetApiClient {
68
66
  setRateLimit(limit) {
69
67
  this.rateLimit = limit > 1 ? Math.floor(limit) : 1;
70
68
  }
69
+ /**
70
+ * handle parameter "bqvariation"
71
+ * reflect behaviour of SpeedKit.
72
+ * - do not send default variation
73
+ * - send mobile/tablet/tv as lowercase
74
+ * - send customVariations as they are
75
+ *
76
+ * As orestes will always make variations uppercase and does not care for caseSensitivity,
77
+ * a caseMissMatch on fastly will also resolve in a cacheMiss.
78
+ * That is why we need to preWarm in the correct case always.
79
+ *
80
+ * @param variation
81
+ * @param assetUrl
82
+ * @private
83
+ */
84
+ setVariationParameter(variation, assetUrl) {
85
+ // on default or desktop do net set variationParam
86
+ if (variation === "default" || variation === "desktop") {
87
+ return;
88
+ }
89
+ // on tv|tablet|mobile set variation as lowerCase
90
+ if (__1.DEFAULT_VARIATIONS.includes(variation.toLowerCase())) {
91
+ assetUrl.searchParams.set("bqvariation", variation.toLowerCase());
92
+ return;
93
+ }
94
+ // on any other customVariation set variation as it is
95
+ assetUrl.searchParams.set("bqvariation", variation);
96
+ }
71
97
  }
72
98
  exports.AssetApiClient = AssetApiClient;
@@ -37,3 +37,4 @@ export declare const TIMING_HEADER_KEY = "server-timing";
37
37
  export declare const PROGRESS_BAR_FORMAT = "[{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | error:{errors} | rate: {rate} | retry: {retry}";
38
38
  export declare const VARIATION_SEPARATOR = ",";
39
39
  export declare const DEFAULT_VARIATION: string[];
40
+ export declare const DEFAULT_VARIATIONS: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_VARIATION = exports.VARIATION_SEPARATOR = exports.PROGRESS_BAR_FORMAT = exports.TIMING_HEADER_KEY = exports.TIMING_HEADER_ERROR_CODE_SELECTOR = exports.RATE_LIMIT_CODES = exports.RATE_LIMIT_MULTIPLICATOR = exports.MAX_REQUESTS_PER_SECOND = exports.DEFAULT_REQUESTS_PER_SECOND = exports.TIMOUT_AFTER_DETECTED_RATE_LIMIT = exports.FETCH_TIMEOUT = exports.MIN_TIME_TO_FETCH_BATCH = exports.ItemStatus = exports.PreWarmContext = void 0;
3
+ exports.DEFAULT_VARIATIONS = exports.DEFAULT_VARIATION = exports.VARIATION_SEPARATOR = exports.PROGRESS_BAR_FORMAT = exports.TIMING_HEADER_KEY = exports.TIMING_HEADER_ERROR_CODE_SELECTOR = exports.RATE_LIMIT_CODES = exports.RATE_LIMIT_MULTIPLICATOR = exports.MAX_REQUESTS_PER_SECOND = exports.DEFAULT_REQUESTS_PER_SECOND = exports.TIMOUT_AFTER_DETECTED_RATE_LIMIT = exports.FETCH_TIMEOUT = exports.MIN_TIME_TO_FETCH_BATCH = exports.ItemStatus = exports.PreWarmContext = void 0;
4
4
  class PreWarmContext {
5
5
  app;
6
6
  path;
@@ -36,4 +36,5 @@ exports.TIMING_HEADER_ERROR_CODE_SELECTOR = /errorcode;desc=([^,]*),/;
36
36
  exports.TIMING_HEADER_KEY = "server-timing";
37
37
  exports.PROGRESS_BAR_FORMAT = "[{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | error:{errors} | rate: {rate} | retry: {retry}";
38
38
  exports.VARIATION_SEPARATOR = ",";
39
- exports.DEFAULT_VARIATION = ["DEFAULT"];
39
+ exports.DEFAULT_VARIATION = ["default"];
40
+ exports.DEFAULT_VARIATIONS = ["mobile", "tablet", "tv"];
@@ -712,5 +712,5 @@
712
712
  ]
713
713
  }
714
714
  },
715
- "version": "2.70.0"
715
+ "version": "2.70.1"
716
716
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.70.0",
4
+ "version": "2.70.1",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"