shop-client 3.19.0 → 3.20.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.
@@ -299,35 +299,17 @@ function createProductOperations(baseUrl, storeDomain, fetchProducts, productsDt
299
299
  return finalProducts != null ? finalProducts : [];
300
300
  }
301
301
  async function findEnhancedInternal(productHandle, options) {
302
- var _a;
303
302
  const apiKey = options.apiKey;
304
303
  if (!apiKey || typeof apiKey !== "string" || !apiKey.trim()) {
305
304
  throw new Error("apiKey is required");
306
305
  }
306
+ const updatedAt = options.updatedAt;
307
+ if (!updatedAt || typeof updatedAt !== "string" || !updatedAt.trim()) {
308
+ throw new Error("updatedAt is required");
309
+ }
310
+ const updatedAtTrimmed = updatedAt.trim();
307
311
  const baseProduct = await findInternal(productHandle, { minimal: false });
308
312
  if (!baseProduct) return null;
309
- let updatedAt = (_a = baseProduct.updatedAt) == null ? void 0 : _a.toISOString();
310
- if (updatedAt == null ? void 0 : updatedAt.endsWith(".000Z")) {
311
- updatedAt = updatedAt.replace(".000Z", "Z");
312
- }
313
- if (!updatedAt) {
314
- const url = `${baseUrl}products/${encodeURIComponent(baseProduct.handle)}.js`;
315
- const resp2 = await rateLimitedFetch(url, {
316
- rateLimitClass: "products:single",
317
- timeoutMs: 7e3,
318
- retry: { maxRetries: 1, baseDelayMs: 200 }
319
- });
320
- if (!resp2.ok) {
321
- if (resp2.status === 404) return null;
322
- throw new Error(`HTTP ${resp2.status}: ${resp2.statusText}`);
323
- }
324
- const raw = await resp2.json();
325
- if (typeof raw.updated_at === "string" && raw.updated_at.trim()) {
326
- updatedAt = raw.updated_at;
327
- } else {
328
- throw new Error("updatedAt missing for product");
329
- }
330
- }
331
313
  const endpoint = typeof options.endpoint === "string" && options.endpoint.trim() || "https://shopify-product-enrichment-worker.ninjacode.workers.dev";
332
314
  let hostname = storeDomain;
333
315
  try {
@@ -344,7 +326,7 @@ function createProductOperations(baseUrl, storeDomain, fetchProducts, productsDt
344
326
  body: JSON.stringify({
345
327
  storeDomain: hostname,
346
328
  handle: baseProduct.handle,
347
- updatedAt
329
+ updatedAt: updatedAtTrimmed
348
330
  }),
349
331
  rateLimitClass: "products:enhanced",
350
332
  timeoutMs: 15e3,
@@ -391,35 +373,17 @@ function createProductOperations(baseUrl, storeDomain, fetchProducts, productsDt
391
373
  };
392
374
  }
393
375
  async function findEnhancedMinimalInternal(productHandle, options) {
394
- var _a;
395
376
  const apiKey = options.apiKey;
396
377
  if (!apiKey || typeof apiKey !== "string" || !apiKey.trim()) {
397
378
  throw new Error("apiKey is required");
398
379
  }
380
+ const updatedAt = options.updatedAt;
381
+ if (!updatedAt || typeof updatedAt !== "string" || !updatedAt.trim()) {
382
+ throw new Error("updatedAt is required");
383
+ }
384
+ const updatedAtTrimmed = updatedAt.trim();
399
385
  const baseProduct = await findInternal(productHandle, { minimal: false });
400
386
  if (!baseProduct) return null;
401
- let updatedAt = (_a = baseProduct.updatedAt) == null ? void 0 : _a.toISOString();
402
- if (updatedAt == null ? void 0 : updatedAt.endsWith(".000Z")) {
403
- updatedAt = updatedAt.replace(".000Z", "Z");
404
- }
405
- if (!updatedAt) {
406
- const url = `${baseUrl}products/${encodeURIComponent(baseProduct.handle)}.js`;
407
- const resp2 = await rateLimitedFetch(url, {
408
- rateLimitClass: "products:single",
409
- timeoutMs: 7e3,
410
- retry: { maxRetries: 1, baseDelayMs: 200 }
411
- });
412
- if (!resp2.ok) {
413
- if (resp2.status === 404) return null;
414
- throw new Error(`HTTP ${resp2.status}: ${resp2.statusText}`);
415
- }
416
- const raw = await resp2.json();
417
- if (typeof raw.updated_at === "string" && raw.updated_at.trim()) {
418
- updatedAt = raw.updated_at;
419
- } else {
420
- throw new Error("updatedAt missing for product");
421
- }
422
- }
423
387
  const endpoint = typeof options.endpoint === "string" && options.endpoint.trim() || "https://shopify-product-enrichment-worker.ninjacode.workers.dev";
424
388
  let hostname = storeDomain;
425
389
  try {
@@ -436,7 +400,7 @@ function createProductOperations(baseUrl, storeDomain, fetchProducts, productsDt
436
400
  body: JSON.stringify({
437
401
  storeDomain: hostname,
438
402
  handle: baseProduct.handle,
439
- updatedAt
403
+ updatedAt: updatedAtTrimmed
440
404
  }),
441
405
  rateLimitClass: "products:enhanced",
442
406
  timeoutMs: 15e3,
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-GYQQU54C.mjs";
7
7
  import {
8
8
  createProductOperations
9
- } from "./chunk-5DGSCBYT.mjs";
9
+ } from "./chunk-52BV6EJZ.mjs";
10
10
  import {
11
11
  createShopOperations,
12
12
  getInfoForShop
@@ -34,10 +34,12 @@ interface ProductOperations {
34
34
  * @param productHandle - The handle of the product to find.
35
35
  * @param options - Options for the request.
36
36
  * @param options.apiKey - API key for the enhancement service. Required for authentication via x-api-key header.
37
+ * @param options.updatedAt - Product updatedAt timestamp used to cache-bust/invalidate enrichment.
37
38
  * @param options.endpoint - Optional custom endpoint URL for the enhancement service. Defaults to the standard worker URL.
38
39
  */
39
40
  findEnhanced(productHandle: string, options: {
40
41
  apiKey: string;
42
+ updatedAt: string;
41
43
  endpoint?: string;
42
44
  }): Promise<EnhancedProductResponse | null>;
43
45
  /**
@@ -141,6 +143,7 @@ interface ProductOperations {
141
143
  }): Promise<MinimalProduct | null>;
142
144
  findEnhanced(productHandle: string, options: {
143
145
  apiKey: string;
146
+ updatedAt: string;
144
147
  endpoint?: string;
145
148
  }): Promise<EnhancedProductResponse<MinimalProduct> | null>;
146
149
  showcased(): Promise<MinimalProduct[]>;
package/dist/products.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProductOperations
3
- } from "./chunk-5DGSCBYT.mjs";
3
+ } from "./chunk-52BV6EJZ.mjs";
4
4
  import "./chunk-4GPP2KXF.mjs";
5
5
  import "./chunk-U3RQRBXZ.mjs";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shop-client",
3
- "version": "3.19.0",
3
+ "version": "3.20.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",