@q2devel/q2-core 1.0.14 → 1.0.16
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/api/pages/page/page.service.d.ts.map +1 -1
- package/dist/api/pages/page/page.service.js +13 -7
- package/dist/hooks/products/useGetProducts.d.ts +22 -0
- package/dist/hooks/products/useGetProducts.d.ts.map +1 -0
- package/dist/hooks/products/useGetProducts.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/page/page.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"page.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/page/page.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C,KAAK,YAAY,GAAG;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CACzC,CAAA;AAED,eAAO,MAAM,OAAO,GAChB,KAAK,WAAW,EAChB,4BAA4C,YAAY,KACzD,OAAO,CAAC,IAAI,GAAG,IAAI,CA8CrB,CAAA"}
|
|
@@ -3,13 +3,15 @@ import mapIncludedResources from '../../../utils/mapIncludedResources';
|
|
|
3
3
|
export const getPage = async (ctx, { pageId, include = ['node_type'], mapFn }) => {
|
|
4
4
|
const cacheKey = ['page', ctx.locale, pageId].join(':');
|
|
5
5
|
if (ctx.getCache) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
try {
|
|
7
|
+
const cached = await ctx.getCache(cacheKey);
|
|
8
|
+
if (cached)
|
|
9
|
+
return cached;
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
|
-
const url = ctx.locale === ctx.defaultLocale
|
|
11
|
-
? `/jsonapi/node/page`
|
|
12
|
-
: `/${ctx.locale}/jsonapi/node/page`;
|
|
14
|
+
const url = ctx.locale === ctx.defaultLocale ? `/jsonapi/node/page` : `/${ctx.locale}/jsonapi/node/page`;
|
|
13
15
|
const params = new DrupalJsonApiParams()
|
|
14
16
|
.addFilter('drupal_internal__nid', pageId)
|
|
15
17
|
.addFilter('langcode', ctx.locale)
|
|
@@ -30,7 +32,11 @@ export const getPage = async (ctx, { pageId, include = ['node_type'], mapFn }) =
|
|
|
30
32
|
});
|
|
31
33
|
const page = mappedPages[0];
|
|
32
34
|
if (ctx.setCache) {
|
|
33
|
-
|
|
35
|
+
try {
|
|
36
|
+
await ctx.setCache(cacheKey, page);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
return page;
|
|
36
42
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CoreContext } from '../../context';
|
|
2
|
+
type UseGetProductsOptions = {
|
|
3
|
+
categoryId?: string[];
|
|
4
|
+
productId?: string;
|
|
5
|
+
searchTerm?: string;
|
|
6
|
+
limit?: number;
|
|
7
|
+
offset?: number;
|
|
8
|
+
filters?: Array<{
|
|
9
|
+
path: string;
|
|
10
|
+
value: string | string[] | null;
|
|
11
|
+
operator?: string;
|
|
12
|
+
}>;
|
|
13
|
+
sort?: string;
|
|
14
|
+
tag?: string;
|
|
15
|
+
include?: string[];
|
|
16
|
+
cache?: boolean;
|
|
17
|
+
mapFnVariations?: (base: any, raw: any) => any;
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare const useGetProducts: (ctx: CoreContext, locale: string, options?: UseGetProductsOptions) => import("@tanstack/react-query").UseQueryResult<import("../..").Product[], Error>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=useGetProducts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetProducts.d.ts","sourceRoot":"","sources":["../../../hooks/products/useGetProducts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,KAAK,qBAAqB,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAA;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,CAAC,CAAA;IACF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,CAAA;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,cAAc,GACvB,KAAK,WAAW,EAChB,QAAQ,MAAM,EACd,UAAU,qBAAqB,qFA+ClC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { getProducts } from '../../api/products/getProducts';
|
|
3
|
+
export const useGetProducts = (ctx, locale, options) => {
|
|
4
|
+
const { categoryId, productId, searchTerm, limit, offset, filters, sort, tag, include, cache, mapFnVariations, enabled = true, } = options || {};
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryKey: [
|
|
7
|
+
'products',
|
|
8
|
+
locale,
|
|
9
|
+
categoryId,
|
|
10
|
+
productId,
|
|
11
|
+
searchTerm,
|
|
12
|
+
limit,
|
|
13
|
+
offset,
|
|
14
|
+
filters,
|
|
15
|
+
sort,
|
|
16
|
+
tag,
|
|
17
|
+
include,
|
|
18
|
+
],
|
|
19
|
+
queryFn: () => getProducts(ctx, {
|
|
20
|
+
categoryId,
|
|
21
|
+
productId,
|
|
22
|
+
searchTerm,
|
|
23
|
+
limit,
|
|
24
|
+
offset,
|
|
25
|
+
filters,
|
|
26
|
+
sort,
|
|
27
|
+
tag,
|
|
28
|
+
include,
|
|
29
|
+
cache,
|
|
30
|
+
mapFnVariations,
|
|
31
|
+
}),
|
|
32
|
+
enabled,
|
|
33
|
+
});
|
|
34
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from './api/checkout/Checkout.service';
|
|
|
26
26
|
export * from './api/checkout/CheckoutService.types';
|
|
27
27
|
export * from './hooks/cart/api/useGetOrderHistory';
|
|
28
28
|
export * from './hooks/wishlist/useWishlist';
|
|
29
|
+
export * from './hooks/products/useGetProducts';
|
|
29
30
|
export * from './context';
|
|
30
31
|
export * from './context/cart/BasketContext';
|
|
31
32
|
export * from './api/cart/Cart.service';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AAErC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AAGpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAG5B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AAGxC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,oCAAoC,CAAA;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A;AAC/C,cAAc,sCAAsC,CAAA;AAEpD,cAAc,qCAAqC,CAAA;AACnD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iCAAiC,CAAA;AAG/C,cAAc,WAAW,CAAA;AACzB,cAAc,8BAA8B,CAAA;AAE5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAE5C,cAAc,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from './api/checkout/Checkout.service';
|
|
|
32
32
|
export * from './api/checkout/CheckoutService.types';
|
|
33
33
|
export * from './hooks/cart/api/useGetOrderHistory';
|
|
34
34
|
export * from './hooks/wishlist/useWishlist';
|
|
35
|
+
export * from './hooks/products/useGetProducts';
|
|
35
36
|
export * from './context';
|
|
36
37
|
export * from './context/cart/BasketContext';
|
|
37
38
|
export * from './api/cart/Cart.service';
|