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