@shopkit/data-layer 1.4.0 → 1.4.2
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 +59 -4
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +59 -4
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/index.js +59 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/adapters/index.mjs
CHANGED
|
@@ -3858,7 +3858,35 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
3858
3858
|
PRODUCT_ENDPOINTS.getProduct(options?.version),
|
|
3859
3859
|
"POST",
|
|
3860
3860
|
payload,
|
|
3861
|
-
|
|
3861
|
+
{
|
|
3862
|
+
...options || {},
|
|
3863
|
+
// Tag the read so `revalidateTag(CacheTags.product(handle))` reaches every
|
|
3864
|
+
// page that rendered this product, at any URL. A product is reachable at
|
|
3865
|
+
// six routes here (/products, /products-b, and the nested
|
|
3866
|
+
// /collections[-b]/[collectionname]/... variants); the webhook knows only
|
|
3867
|
+
// the handle, so it cannot enumerate those paths, and purging the route
|
|
3868
|
+
// pattern would take out every product under every collection.
|
|
3869
|
+
//
|
|
3870
|
+
// Tags apply even though this is a POST: Next records them on the page's
|
|
3871
|
+
// cache entry before it decides whether the fetch itself is cacheable.
|
|
3872
|
+
//
|
|
3873
|
+
// No `revalidate` on purpose — that would cache the response and freeze
|
|
3874
|
+
// `template_suffix`, which drives Page Template assignment and must be
|
|
3875
|
+
// read live. Invalidation and caching are separate knobs; we want only
|
|
3876
|
+
// the first. No broad CacheTags.products() either: callers already fire
|
|
3877
|
+
// `revalidateTag("products")` on routine inventory events, which would
|
|
3878
|
+
// become a catalog-wide purge.
|
|
3879
|
+
//
|
|
3880
|
+
// Handle-keyed to match the taxonomy — the webhook purges by handle, so
|
|
3881
|
+
// an id-keyed tag could never match.
|
|
3882
|
+
next: {
|
|
3883
|
+
...options?.next || {},
|
|
3884
|
+
tags: [
|
|
3885
|
+
...handle ? [CacheTags.product(handle)] : [],
|
|
3886
|
+
...options?.next?.tags || []
|
|
3887
|
+
]
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3862
3890
|
);
|
|
3863
3891
|
if (!result || !result.product) {
|
|
3864
3892
|
return formatResponse({
|
|
@@ -3908,7 +3936,28 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
3908
3936
|
PRODUCT_ENDPOINTS.getProductsByHandles(options?.version),
|
|
3909
3937
|
"POST",
|
|
3910
3938
|
payload,
|
|
3911
|
-
|
|
3939
|
+
{
|
|
3940
|
+
...options || {},
|
|
3941
|
+
// One tag per requested handle, so a single-product webhook invalidates
|
|
3942
|
+
// every multi-product surface that included it (bundles, FBT rails,
|
|
3943
|
+
// hand-picked grids) — not just that product's own page. Same rationale
|
|
3944
|
+
// and same deliberate omission of `revalidate` as getProduct above.
|
|
3945
|
+
//
|
|
3946
|
+
// The type guard is not defensive padding: CacheTags.product() calls
|
|
3947
|
+
// .trim() on its argument, and this array is widget-supplied, so a stray
|
|
3948
|
+
// null would throw here and fail the whole read. Length/count limits are
|
|
3949
|
+
// Next's job — validateTags() drops over-long tags, caps the list, and
|
|
3950
|
+
// logs what it dropped.
|
|
3951
|
+
next: {
|
|
3952
|
+
...options?.next || {},
|
|
3953
|
+
tags: [
|
|
3954
|
+
...handles.filter(
|
|
3955
|
+
(h) => typeof h === "string" && h.trim() !== ""
|
|
3956
|
+
).map((h) => CacheTags.product(h)),
|
|
3957
|
+
...options?.next?.tags || []
|
|
3958
|
+
]
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3912
3961
|
);
|
|
3913
3962
|
if (!result || !result.products) {
|
|
3914
3963
|
return formatResponse({
|
|
@@ -4033,8 +4082,14 @@ var ProductService2 = class extends BaseCustomService {
|
|
|
4033
4082
|
params: queryParams,
|
|
4034
4083
|
...options || {},
|
|
4035
4084
|
// Tag the collection read so a webhook can revalidateTag() it, refreshing
|
|
4036
|
-
// the collection page AND every grid built from it
|
|
4037
|
-
//
|
|
4085
|
+
// the collection page AND every grid built from it — including the home
|
|
4086
|
+
// page, whose entry carries a tag per collection it renders. The handle
|
|
4087
|
+
// keys the entity. See @shopkit/core/cache-tags.
|
|
4088
|
+
//
|
|
4089
|
+
// ("GET only" used to be noted here as if tagging depended on the method.
|
|
4090
|
+
// It does not — see getProduct above, which tags a POST. The method only
|
|
4091
|
+
// affects whether the RESPONSE is cached, not whether the tag is recorded
|
|
4092
|
+
// on the page.)
|
|
4038
4093
|
next: {
|
|
4039
4094
|
...options?.next || {},
|
|
4040
4095
|
tags: [
|