-
Notifications
You must be signed in to change notification settings - Fork 45
/
index.ts
106 lines (100 loc) · 3.08 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import type { Schemas } from "#shopware";
import { pascalCase } from "scule";
import { resolveComponent } from "vue";
/**
* A composables library compatible with Vue 3 and Shopware 6.
*
* Some more info...
*
* @remarks
* The `widget-lib` defines the {@link IWidget} interface and {@link Widget} class,
* which are used to build widgets.
*
* @packageDocumentation
*/
export * from "./types";
export * from "./cms";
export * from "./createShopwareContext";
export * from "./useAddToCart";
export * from "./useAddress";
export * from "./useBreadcrumbs";
export * from "./useCart";
export * from "./useCartItem";
export * from "./useCategory";
export * from "./useCategorySearch";
export * from "./useCheckout";
export * from "./useCmsBlock";
export * from "./useCmsMeta";
export * from "./useCmsSection";
export * from "./useCmsTranslations";
export * from "./useContext";
export * from "./useCountries";
export * from "./useCustomerOrders";
export * from "./useCustomerPassword";
export * from "./useInternationalization";
export * from "./useLandingSearch";
export * from "./useListing";
export * from "./useLocalWishlist";
export * from "./useNavigation";
export * from "./useNavigationContext";
export * from "./useNavigationSearch";
export * from "./useNewsletter";
export * from "./useNotifications";
export * from "./useOrderDetails";
export * from "./useOrderPayment";
export * from "./usePrice";
export * from "./useProduct";
export * from "./useProductAssociations";
export * from "./useProductConfigurator";
export * from "./useProductPrice";
export * from "./useProductReviews";
export * from "./useProductSearch";
export * from "./useProductSearchSuggest";
export * from "./useProductWishlist";
export * from "./useSalutations";
export * from "./useSessionContext";
export * from "./useShopwareContext";
export * from "./useSyncWishlist";
export * from "./useUrlResolver";
export * from "./useUser";
export * from "./useWishlist";
export * from "./useB2bQuoteManagement";
export function resolveCmsComponent(
content: Schemas["CmsSection"] | Schemas["CmsBlock"] | Schemas["CmsSlot"],
) {
const componentName = content.type;
const type =
content.apiAlias === "cms_block"
? "Block"
: content.apiAlias === "cms_section"
? "Section"
: "Element";
const componentNameToResolve = pascalCase(`Cms-${type}-${componentName}`);
try {
const resolvedComponent = resolveComponent(componentNameToResolve);
return {
componentName,
componentNameToResolve,
isResolved: resolvedComponent !== componentName,
resolvedComponent:
typeof resolvedComponent !== "string" ? resolvedComponent : undefined,
};
} catch (e) {
return {
componentName,
componentNameToResolve,
resolvedComponent: undefined,
resolved: false,
error: (e as Error).message,
};
}
}
// TODO: handle defaults in app
export function getDefaultApiParams(): {
[composableName: string]: unknown;
} {
console.error(
"[@shopware-pwa/composables] `getDefaultApiParams` is deprecated and will be removed in the next major release.",
);
return {};
}