@adobe/spacecat-shared-tokowaka-client 1.7.5 → 1.7.7

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,17 @@
1
+ # [@adobe/spacecat-shared-tokowaka-client-v1.7.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.7.6...@adobe/spacecat-shared-tokowaka-client-v1.7.7) (2026-02-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * export forwarded host compute method ([#1338](https://github.com/adobe/spacecat-shared/issues/1338)) ([91e5f5f](https://github.com/adobe/spacecat-shared/commit/91e5f5fb2b5a7d592886caea940a6313fe1c1c8c))
7
+
8
+ # [@adobe/spacecat-shared-tokowaka-client-v1.7.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.7.5...@adobe/spacecat-shared-tokowaka-client-v1.7.6) (2026-02-09)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * edge-preview api: ignore warmup call failure ([#1327](https://github.com/adobe/spacecat-shared/issues/1327)) ([fbc9f65](https://github.com/adobe/spacecat-shared/commit/fbc9f65bf96e408c878fa3b8b37fbbe29444e08f))
14
+
1
15
  # [@adobe/spacecat-shared-tokowaka-client-v1.7.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tokowaka-client-v1.7.4...@adobe/spacecat-shared-tokowaka-client-v1.7.5) (2026-02-05)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-tokowaka-client",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
4
4
  "description": "Tokowaka Client for SpaceCat - Edge optimization config management",
5
5
  "type": "module",
6
6
  "engines": {
package/src/index.d.ts CHANGED
@@ -147,6 +147,14 @@ export class FastlyKVClient {
147
147
  }): Promise<FastlyKVEntry[]>;
148
148
  }
149
149
 
150
+ /**
151
+ * Compute the forwarded host for edge optimize (bare domain → www; subdomains unchanged).
152
+ * @param url - Full base URL (e.g. https://example.com)
153
+ * @param logger - Optional logger with debug and error methods
154
+ * @returns Host to use (e.g. www.example.com)
155
+ */
156
+ export function calculateForwardedHost(url: string, logger?: { debug?: (msg: string) => void; error?: (msg: string) => void }): string;
157
+
150
158
  /**
151
159
  * Base class for opportunity mappers
152
160
  * Extend this class to create custom mappers for new opportunity types
package/src/index.js CHANGED
@@ -28,6 +28,7 @@ import { getEffectiveBaseURL } from './utils/site-utils.js';
28
28
  import { fetchHtmlWithWarmup, calculateForwardedHost } from './utils/custom-html-utils.js';
29
29
 
30
30
  export { FastlyKVClient } from './fastly-kv-client.js';
31
+ export { calculateForwardedHost } from './utils/custom-html-utils.js';
31
32
 
32
33
  const HTTP_BAD_REQUEST = 400;
33
34
  const HTTP_INTERNAL_SERVER_ERROR = 500;
@@ -187,18 +187,18 @@ export async function fetchHtmlWithWarmup(
187
187
  try {
188
188
  // Warmup call (no retry logic for warmup)
189
189
  log.info(`[${fetchType}] Making warmup call for ${fetchType} HTML with URL: ${fullUrl}`);
190
-
191
190
  const warmupStartTime = Date.now();
192
191
  const warmupResponse = await fetchWithTimeout(fullUrl, fetchOptions);
193
-
194
192
  log.debug(`[${fetchType}] Warmup response status: ${warmupResponse.status} ${warmupResponse.statusText}`);
195
- // Consume the response body to free up the connection
196
193
  await warmupResponse.text();
197
194
  log.info(`[${fetchType}] Warmup call completed in ${Date.now() - warmupStartTime}ms, waiting ${warmupDelayMs}ms...`);
195
+ } catch (warmupError) {
196
+ log.warn(`[${fetchType}] Warmup call failed (ignored): ${warmupError.message}`);
197
+ }
198
198
 
199
- // Wait before actual call
200
- await sleep(warmupDelayMs);
199
+ await sleep(warmupDelayMs);
201
200
 
201
+ try {
202
202
  // Actual call with retry logic
203
203
  log.info(`[${fetchType}] Making actual call for ${fetchType} HTML (max ${maxRetries} retries) with URL: ${fullUrl}`);
204
204
 
@@ -3153,7 +3153,7 @@ describe('TokowakaClient', () => {
3153
3153
  mockSite,
3154
3154
  mockOpportunity,
3155
3155
  mockSuggestions,
3156
- { warmupDelayMs: 0 },
3156
+ { warmupDelayMs: 0, maxRetries: 0, retryDelayMs: 0 },
3157
3157
  );
3158
3158
  expect.fail('Should have thrown error');
3159
3159
  } catch (error) {