@laioutr/app-shopware 0.19.0 → 0.19.1

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/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/app-shopware",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "configKey": "@laioutr/app-shopware",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import { CHECKOUT_ENDPOINT_PATH, ADOPT_SESSION_ENDPOINT_PATH, ORDER_HANDOFF_ENDP
4
4
  import { registerLaioutrApp } from '@laioutr-core/kit';
5
5
 
6
6
  const name = "@laioutr/app-shopware";
7
- const version = "0.19.0";
7
+ const version = "0.19.1";
8
8
 
9
9
  const module$1 = defineNuxtModule({
10
10
  meta: {
@@ -1,4 +1,4 @@
1
1
  import { StorefrontClient } from '../types/shopware.js';
2
2
  export declare const useGetProductParentId: (storefrontClient: StorefrontClient) => (id: string) => Promise<any>;
3
- /** Store parent-ids in the cache. */
4
- export declare const cacheProductParentIds: (productIdsToParentIds: [productId: string, parentId: string][]) => void;
3
+ /** Store parent-ids in the cache. A product with no parent is stored as a cached absence. */
4
+ export declare const cacheProductParentIds: (productIdsToParentIds: [productId: string, parentId: string | undefined][]) => void;
@@ -1,12 +1,16 @@
1
1
  import { useUserlandCache } from "#imports";
2
+ import { ABSENT } from "@laioutr-core/orchestr/types";
2
3
  const useProductParentIdCache = () => useUserlandCache("shopware/product-parent-id");
3
4
  const PRODUCT_PARENT_ID_CACHE_TTL = 60 * 60 * 24 * 7;
4
- const entryOptions = { maxAge: PRODUCT_PARENT_ID_CACHE_TTL };
5
+ const entryOptions = {
6
+ maxAge: PRODUCT_PARENT_ID_CACHE_TTL,
7
+ absentMaxAge: PRODUCT_PARENT_ID_CACHE_TTL
8
+ };
5
9
  export const useGetProductParentId = (storefrontClient) => {
6
10
  const cache = useProductParentIdCache();
7
11
  return async (id) => {
8
12
  const cached = await cache.readOne(id, entryOptions);
9
- if (cached && !cached.absent) {
13
+ if (cached) {
10
14
  return cached.value;
11
15
  }
12
16
  try {
@@ -21,6 +25,7 @@ export const useGetProductParentId = (storefrontClient) => {
21
25
  cache.writeOne(id, parentId, entryOptions);
22
26
  return parentId;
23
27
  }
28
+ cache.writeOne(id, ABSENT, entryOptions);
24
29
  return void 0;
25
30
  } catch {
26
31
  return void 0;
@@ -31,7 +36,7 @@ export const cacheProductParentIds = (productIdsToParentIds) => {
31
36
  useProductParentIdCache().write(
32
37
  productIdsToParentIds.map(([productId, parentId]) => ({
33
38
  key: productId,
34
- value: parentId,
39
+ value: parentId ?? ABSENT,
35
40
  options: entryOptions
36
41
  }))
37
42
  );
@@ -35,7 +35,7 @@ export default defineShopwareQuery(
35
35
  response.data.elements.map((product) => [product.parentId ?? product.id, product.id])
36
36
  );
37
37
  passthrough.set(parentIdToDefaultVariantIdToken, parentIdToDefaultVariantId);
38
- cacheProductParentIds(response.data.elements.map((product) => [product.id, product.parentId ?? product.id]));
38
+ cacheProductParentIds(response.data.elements.map((product) => [product.id, product.parentId]));
39
39
  return {
40
40
  // Return the parent-id, in case the received product is a variant
41
41
  ids: response.data.elements.map((product) => product.parentId ?? product.id),
@@ -42,7 +42,7 @@ export default defineShopwareQuery(
42
42
  response.data.elements.map((product) => [product.parentId ?? product.id, product.id])
43
43
  );
44
44
  passthrough.set(parentIdToDefaultVariantIdToken, parentIdToDefaultVariantId);
45
- cacheProductParentIds(response.data.elements.map((product) => [product.id, product.parentId ?? product.id]));
45
+ cacheProductParentIds(response.data.elements.map((product) => [product.id, product.parentId]));
46
46
  if (context.settings.loadVariantsOnListing) {
47
47
  const allVariants = await fetchAllProducts(context.storefrontClient, {
48
48
  productIds: Object.keys(parentIdToDefaultVariantId),
@@ -32,7 +32,7 @@ export default defineShopwareQuery(ProductSearchQuery, async ({ context, input,
32
32
  response.data.elements.map((product) => [product.parentId ?? product.id, product.id])
33
33
  );
34
34
  passthrough.set(parentIdToDefaultVariantIdToken, parentIdToDefaultVariantId);
35
- cacheProductParentIds(response.data.elements.map((product) => [product.id, product.parentId ?? product.id]));
35
+ cacheProductParentIds(response.data.elements.map((product) => [product.id, product.parentId]));
36
36
  return {
37
37
  // Return the parent-id, in case the received product is a variant
38
38
  ids: response.data.elements.map((product) => product.parentId ?? product.id),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/app-shopware",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "Laioutr integration with Shopware 6",
5
5
  "repository": "github:laioutr/app-shopware",
6
6
  "license": "MIT",