@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/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
|
-
|
|
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({
|
|
@@ -4161,9 +4185,12 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4161
4185
|
}
|
|
4162
4186
|
const payload = {
|
|
4163
4187
|
storeId: this.config.storeId,
|
|
4164
|
-
available: params.filters?.[0]?.available ?? true,
|
|
4165
4188
|
collectionHandles: handles
|
|
4166
4189
|
};
|
|
4190
|
+
const availability = params.filters?.[0]?.available;
|
|
4191
|
+
if (typeof availability === "boolean") {
|
|
4192
|
+
payload.available = availability;
|
|
4193
|
+
}
|
|
4167
4194
|
if (params.filters && params.filters.length > 0) {
|
|
4168
4195
|
const filter = params.filters[0];
|
|
4169
4196
|
if (filter.price?.min !== void 0) {
|
|
@@ -4188,7 +4215,40 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4188
4215
|
PRODUCT_ENDPOINTS.getCollectionsByHandles(options?.version),
|
|
4189
4216
|
"POST",
|
|
4190
4217
|
payload,
|
|
4191
|
-
|
|
4218
|
+
{
|
|
4219
|
+
...options || {},
|
|
4220
|
+
// The same tags the single-collection `getCollection` attaches, one set
|
|
4221
|
+
// per requested handle. This is the batch form of that read, so it has to
|
|
4222
|
+
// carry the same invalidation coverage: without it, moving a template from
|
|
4223
|
+
// COLLECTION to COLLECTION_BY_HANDLES silently opts the page out of
|
|
4224
|
+
// webhook invalidation, and it stays stale until its own `revalidate`
|
|
4225
|
+
// window elapses.
|
|
4226
|
+
//
|
|
4227
|
+
// Not hypothetical: home pages render their product grids through this
|
|
4228
|
+
// read, so `revalidateTag(collection:<handle>)` from a product.updated
|
|
4229
|
+
// webhook — which did purge that product's PDP and its collection page —
|
|
4230
|
+
// matched nothing on the home page, and an edited title sat there for the
|
|
4231
|
+
// rest of the ISR window.
|
|
4232
|
+
//
|
|
4233
|
+
// Same rationale and the same deliberate omission of `revalidate` as
|
|
4234
|
+
// getProductsByHandles above. Tagging a POST works: Next records a fetch's
|
|
4235
|
+
// tags on the enclosing page's cache entry before it decides whether the
|
|
4236
|
+
// response itself is cacheable.
|
|
4237
|
+
//
|
|
4238
|
+
// The type guard mirrors getProductsByHandles — CacheTags.collection()
|
|
4239
|
+
// calls .trim() on its argument and this array is widget-supplied, so a
|
|
4240
|
+
// stray null would throw and fail the whole read, not just one tag.
|
|
4241
|
+
next: {
|
|
4242
|
+
...options?.next || {},
|
|
4243
|
+
tags: [
|
|
4244
|
+
CacheTags.collections(),
|
|
4245
|
+
...handles.filter(
|
|
4246
|
+
(h) => typeof h === "string" && h.trim() !== ""
|
|
4247
|
+
).map((h) => CacheTags.collection(h)),
|
|
4248
|
+
...options?.next?.tags || []
|
|
4249
|
+
]
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4192
4252
|
);
|
|
4193
4253
|
if (!result || !result.collections) {
|
|
4194
4254
|
return formatResponse({
|
|
@@ -4246,7 +4306,24 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4246
4306
|
PRODUCT_ENDPOINTS.getCollectionFilters(options?.version, handle),
|
|
4247
4307
|
"GET",
|
|
4248
4308
|
void 0,
|
|
4249
|
-
|
|
4309
|
+
{
|
|
4310
|
+
...options || {},
|
|
4311
|
+
// Facets are derived from this collection's products — price range, brands,
|
|
4312
|
+
// availability — so anything that invalidates the collection invalidates its
|
|
4313
|
+
// filters. One tag, keyed on the same handle, means the existing
|
|
4314
|
+
// product.updated / collection.updated purges already cover them.
|
|
4315
|
+
//
|
|
4316
|
+
// No broad `collections` tag here, unlike getCollection: a filter set belongs
|
|
4317
|
+
// to exactly one collection, and bulk collection events already purge every
|
|
4318
|
+
// affected handle individually.
|
|
4319
|
+
next: {
|
|
4320
|
+
...options?.next || {},
|
|
4321
|
+
tags: [
|
|
4322
|
+
CacheTags.collection(handle),
|
|
4323
|
+
...options?.next?.tags || []
|
|
4324
|
+
]
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4250
4327
|
);
|
|
4251
4328
|
if (!result) {
|
|
4252
4329
|
return formatResponse({
|