@shopkit/data-layer 1.4.3 → 1.4.5
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/adapters/index.js +81 -4
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +81 -4
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/index.js +81 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -3812,7 +3812,31 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
3812
3812
|
PRODUCT_ENDPOINTS.getProducts(options?.version),
|
|
3813
3813
|
"POST",
|
|
3814
3814
|
requestParams,
|
|
3815
|
-
|
|
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({
|
|
@@ -4168,9 +4192,12 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4168
4192
|
}
|
|
4169
4193
|
const payload = {
|
|
4170
4194
|
storeId: this.config.storeId,
|
|
4171
|
-
available: params.filters?.[0]?.available ?? true,
|
|
4172
4195
|
collectionHandles: handles
|
|
4173
4196
|
};
|
|
4197
|
+
const availability = params.filters?.[0]?.available;
|
|
4198
|
+
if (typeof availability === "boolean") {
|
|
4199
|
+
payload.available = availability;
|
|
4200
|
+
}
|
|
4174
4201
|
if (params.filters && params.filters.length > 0) {
|
|
4175
4202
|
const filter = params.filters[0];
|
|
4176
4203
|
if (filter.price?.min !== void 0) {
|
|
@@ -4195,7 +4222,40 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4195
4222
|
PRODUCT_ENDPOINTS.getCollectionsByHandles(options?.version),
|
|
4196
4223
|
"POST",
|
|
4197
4224
|
payload,
|
|
4198
|
-
|
|
4225
|
+
{
|
|
4226
|
+
...options || {},
|
|
4227
|
+
// The same tags the single-collection `getCollection` attaches, one set
|
|
4228
|
+
// per requested handle. This is the batch form of that read, so it has to
|
|
4229
|
+
// carry the same invalidation coverage: without it, moving a template from
|
|
4230
|
+
// COLLECTION to COLLECTION_BY_HANDLES silently opts the page out of
|
|
4231
|
+
// webhook invalidation, and it stays stale until its own `revalidate`
|
|
4232
|
+
// window elapses.
|
|
4233
|
+
//
|
|
4234
|
+
// Not hypothetical: home pages render their product grids through this
|
|
4235
|
+
// read, so `revalidateTag(collection:<handle>)` from a product.updated
|
|
4236
|
+
// webhook — which did purge that product's PDP and its collection page —
|
|
4237
|
+
// matched nothing on the home page, and an edited title sat there for the
|
|
4238
|
+
// rest of the ISR window.
|
|
4239
|
+
//
|
|
4240
|
+
// Same rationale and the same deliberate omission of `revalidate` as
|
|
4241
|
+
// getProductsByHandles above. Tagging a POST works: Next records a fetch's
|
|
4242
|
+
// tags on the enclosing page's cache entry before it decides whether the
|
|
4243
|
+
// response itself is cacheable.
|
|
4244
|
+
//
|
|
4245
|
+
// The type guard mirrors getProductsByHandles — CacheTags.collection()
|
|
4246
|
+
// calls .trim() on its argument and this array is widget-supplied, so a
|
|
4247
|
+
// stray null would throw and fail the whole read, not just one tag.
|
|
4248
|
+
next: {
|
|
4249
|
+
...options?.next || {},
|
|
4250
|
+
tags: [
|
|
4251
|
+
cacheTags.CacheTags.collections(),
|
|
4252
|
+
...handles.filter(
|
|
4253
|
+
(h) => typeof h === "string" && h.trim() !== ""
|
|
4254
|
+
).map((h) => cacheTags.CacheTags.collection(h)),
|
|
4255
|
+
...options?.next?.tags || []
|
|
4256
|
+
]
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4199
4259
|
);
|
|
4200
4260
|
if (!result || !result.collections) {
|
|
4201
4261
|
return formatResponse({
|
|
@@ -4253,7 +4313,24 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4253
4313
|
PRODUCT_ENDPOINTS.getCollectionFilters(options?.version, handle),
|
|
4254
4314
|
"GET",
|
|
4255
4315
|
void 0,
|
|
4256
|
-
|
|
4316
|
+
{
|
|
4317
|
+
...options || {},
|
|
4318
|
+
// Facets are derived from this collection's products — price range, brands,
|
|
4319
|
+
// availability — so anything that invalidates the collection invalidates its
|
|
4320
|
+
// filters. One tag, keyed on the same handle, means the existing
|
|
4321
|
+
// product.updated / collection.updated purges already cover them.
|
|
4322
|
+
//
|
|
4323
|
+
// No broad `collections` tag here, unlike getCollection: a filter set belongs
|
|
4324
|
+
// to exactly one collection, and bulk collection events already purge every
|
|
4325
|
+
// affected handle individually.
|
|
4326
|
+
next: {
|
|
4327
|
+
...options?.next || {},
|
|
4328
|
+
tags: [
|
|
4329
|
+
cacheTags.CacheTags.collection(handle),
|
|
4330
|
+
...options?.next?.tags || []
|
|
4331
|
+
]
|
|
4332
|
+
}
|
|
4333
|
+
}
|
|
4257
4334
|
);
|
|
4258
4335
|
if (!result) {
|
|
4259
4336
|
return formatResponse({
|