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