@shopkit/data-layer 1.4.3 → 1.4.4

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/dist/index.mjs CHANGED
@@ -3805,7 +3805,31 @@ var ProductService2 = class extends BaseCustomService {
3805
3805
  PRODUCT_ENDPOINTS.getProducts(options?.version),
3806
3806
  "POST",
3807
3807
  requestParams,
3808
- options
3808
+ {
3809
+ ...options || {},
3810
+ // A list read cannot know which products come back before it runs, so it
3811
+ // takes the broad `products` tag — the one place a broad tag is the correct
3812
+ // answer rather than a blunt one. Per-product reads deliberately omit it
3813
+ // (see getProduct), which is what keeps `revalidateTag("products")` from
3814
+ // becoming a catalog-wide PDP purge: it lands only on the surfaces that
3815
+ // actually render a list — sitemaps, search endpoints, PLP rails.
3816
+ //
3817
+ // This is the producer that tag had been missing. Merchant inventory routes
3818
+ // have been calling `revalidateTag("products")` all along, against nothing:
3819
+ // no read attached it, so those deliveries returned 200 having invalidated
3820
+ // nothing. Same failure the removed `search.reindex` event had, mirrored to
3821
+ // the producer side.
3822
+ //
3823
+ // No `search` tag on a query-bearing read: it would be attached only
3824
+ // alongside `products` and purged only alongside `products`, so it could
3825
+ // never invalidate anything `products` did not already reach. See the note
3826
+ // on CACHE_INVALIDATION_TYPES in @shopkit/webhooks — a tag with no
3827
+ // independent effect is the same dead weight as one with no producer.
3828
+ next: {
3829
+ ...options?.next || {},
3830
+ tags: [CacheTags.products(), ...options?.next?.tags || []]
3831
+ }
3832
+ }
3809
3833
  );
3810
3834
  if (!result || !result.products) {
3811
3835
  return formatResponse({
@@ -4188,7 +4212,40 @@ var ProductService2 = class extends BaseCustomService {
4188
4212
  PRODUCT_ENDPOINTS.getCollectionsByHandles(options?.version),
4189
4213
  "POST",
4190
4214
  payload,
4191
- options
4215
+ {
4216
+ ...options || {},
4217
+ // The same tags the single-collection `getCollection` attaches, one set
4218
+ // per requested handle. This is the batch form of that read, so it has to
4219
+ // carry the same invalidation coverage: without it, moving a template from
4220
+ // COLLECTION to COLLECTION_BY_HANDLES silently opts the page out of
4221
+ // webhook invalidation, and it stays stale until its own `revalidate`
4222
+ // window elapses.
4223
+ //
4224
+ // Not hypothetical: home pages render their product grids through this
4225
+ // read, so `revalidateTag(collection:<handle>)` from a product.updated
4226
+ // webhook — which did purge that product's PDP and its collection page —
4227
+ // matched nothing on the home page, and an edited title sat there for the
4228
+ // rest of the ISR window.
4229
+ //
4230
+ // Same rationale and the same deliberate omission of `revalidate` as
4231
+ // getProductsByHandles above. Tagging a POST works: Next records a fetch's
4232
+ // tags on the enclosing page's cache entry before it decides whether the
4233
+ // response itself is cacheable.
4234
+ //
4235
+ // The type guard mirrors getProductsByHandles — CacheTags.collection()
4236
+ // calls .trim() on its argument and this array is widget-supplied, so a
4237
+ // stray null would throw and fail the whole read, not just one tag.
4238
+ next: {
4239
+ ...options?.next || {},
4240
+ tags: [
4241
+ CacheTags.collections(),
4242
+ ...handles.filter(
4243
+ (h) => typeof h === "string" && h.trim() !== ""
4244
+ ).map((h) => CacheTags.collection(h)),
4245
+ ...options?.next?.tags || []
4246
+ ]
4247
+ }
4248
+ }
4192
4249
  );
4193
4250
  if (!result || !result.collections) {
4194
4251
  return formatResponse({
@@ -4246,7 +4303,24 @@ var ProductService2 = class extends BaseCustomService {
4246
4303
  PRODUCT_ENDPOINTS.getCollectionFilters(options?.version, handle),
4247
4304
  "GET",
4248
4305
  void 0,
4249
- options
4306
+ {
4307
+ ...options || {},
4308
+ // Facets are derived from this collection's products — price range, brands,
4309
+ // availability — so anything that invalidates the collection invalidates its
4310
+ // filters. One tag, keyed on the same handle, means the existing
4311
+ // product.updated / collection.updated purges already cover them.
4312
+ //
4313
+ // No broad `collections` tag here, unlike getCollection: a filter set belongs
4314
+ // to exactly one collection, and bulk collection events already purge every
4315
+ // affected handle individually.
4316
+ next: {
4317
+ ...options?.next || {},
4318
+ tags: [
4319
+ CacheTags.collection(handle),
4320
+ ...options?.next?.tags || []
4321
+ ]
4322
+ }
4323
+ }
4250
4324
  );
4251
4325
  if (!result) {
4252
4326
  return formatResponse({