@kaena1/ecomm-contained-utils 1.0.0 → 1.0.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/index.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export declare interface ComponentManifest {
|
|
|
7
7
|
styleUrl?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
declare interface CountdownbannerProps {
|
|
11
|
+
isEnabled: boolean;
|
|
12
|
+
startDatetime: Date;
|
|
13
|
+
endDatetime: Date;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
export declare function fetchManifest(manifestUrl: string): Promise<RemoteManifest>;
|
|
11
18
|
|
|
12
19
|
/**
|
|
@@ -26,6 +33,29 @@ export declare interface ImportMapConfig {
|
|
|
26
33
|
|
|
27
34
|
export declare const ImportMapScripts: () => JSX.Element;
|
|
28
35
|
|
|
36
|
+
declare interface MintFooterProps {
|
|
37
|
+
footerNav: WP_REST_API_Nav_Menu_Items;
|
|
38
|
+
subfooterNav: WP_REST_API_Nav_Menu_Items;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare interface MintHeaderProps {
|
|
42
|
+
primaryNav: {
|
|
43
|
+
left: WP_REST_API_Nav_Menu_Items;
|
|
44
|
+
right: WP_REST_API_Nav_Menu_Items;
|
|
45
|
+
};
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare interface MintLayoutProps {
|
|
50
|
+
config: {
|
|
51
|
+
NEXT_PUBLIC_SITE_URL: string;
|
|
52
|
+
};
|
|
53
|
+
headerProps?: MintHeaderProps;
|
|
54
|
+
footerProps?: MintFooterProps;
|
|
55
|
+
countdownbannerProps?: Partial<CountdownbannerProps>;
|
|
56
|
+
slimBannerProps?: Partial<SlimbannerProps>;
|
|
57
|
+
}
|
|
58
|
+
|
|
29
59
|
export declare class ModuleLoader {
|
|
30
60
|
private loadedModules;
|
|
31
61
|
private importMapInjected;
|
|
@@ -110,6 +140,11 @@ declare interface RemoteRendererProps {
|
|
|
110
140
|
errorFallback?: (error: string) => default_2.ReactNode;
|
|
111
141
|
}
|
|
112
142
|
|
|
143
|
+
declare interface SlimbannerProps {
|
|
144
|
+
bannerMessage: string;
|
|
145
|
+
isEnabled: boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
113
148
|
export declare function useRemoteComponent(options: UseRemoteComponentOptions): UseRemoteComponentReturn;
|
|
114
149
|
|
|
115
150
|
export declare interface UseRemoteComponentOptions {
|
|
@@ -124,4 +159,33 @@ export declare interface UseRemoteComponentReturn extends RemoteComponentState {
|
|
|
124
159
|
clearError: () => void;
|
|
125
160
|
}
|
|
126
161
|
|
|
162
|
+
declare interface WP_REST_API_Content {
|
|
163
|
+
rendered: string;
|
|
164
|
+
raw: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare interface WP_REST_API_Nav_Menu_Item {
|
|
168
|
+
id: number;
|
|
169
|
+
title: WP_REST_API_Content;
|
|
170
|
+
status: string;
|
|
171
|
+
url: string;
|
|
172
|
+
attr_title: string;
|
|
173
|
+
description: string;
|
|
174
|
+
type: string;
|
|
175
|
+
type_label: string;
|
|
176
|
+
object: string;
|
|
177
|
+
object_id: number;
|
|
178
|
+
parent: number;
|
|
179
|
+
menu_order: number;
|
|
180
|
+
target: string;
|
|
181
|
+
classes: string[];
|
|
182
|
+
xfn: string[];
|
|
183
|
+
invalid: boolean;
|
|
184
|
+
meta: Record<string, string>;
|
|
185
|
+
menus: number;
|
|
186
|
+
_links: Record<string, []>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare type WP_REST_API_Nav_Menu_Items = WP_REST_API_Nav_Menu_Item[];
|
|
190
|
+
|
|
127
191
|
export { }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { mapMintLayoutResponseToProps as i } from "../../../mappers/mapMintLayoutResponseToProps.js";
|
|
3
|
+
async function c(o, n, s) {
|
|
4
|
+
const [e, r] = s.split("|"), t = await fetch(
|
|
5
|
+
`${n}/mint/components/mintLayout/v1`,
|
|
6
|
+
{
|
|
7
|
+
method: "POST",
|
|
8
|
+
headers: {
|
|
9
|
+
"Content-Type": "application/json",
|
|
10
|
+
Authorization: "Basic " + Buffer.from(e + ":" + r).toString("base64")
|
|
11
|
+
},
|
|
12
|
+
body: JSON.stringify({})
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
if (!t.ok)
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Failed to fetch mint layout props: ${JSON.stringify(await t.json())}`
|
|
18
|
+
);
|
|
19
|
+
const a = await t.json();
|
|
20
|
+
return i(o, a);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
c as getMintLayoutProps
|
|
24
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const p = (n, e) => {
|
|
2
|
+
const t = r(e.widgets, "countdown"), a = t ? i(e.theme.countdown, t) : void 0, o = r(e.widgets, "slim-banner"), s = o ? m(o) : void 0;
|
|
3
|
+
return {
|
|
4
|
+
config: {
|
|
5
|
+
NEXT_PUBLIC_SITE_URL: n
|
|
6
|
+
},
|
|
7
|
+
headerProps: {
|
|
8
|
+
primaryNav: {
|
|
9
|
+
left: e.menuItems["primary-navigation-left"],
|
|
10
|
+
right: e.menuItems["primary-navigation-right"]
|
|
11
|
+
},
|
|
12
|
+
className: "mint-header-class"
|
|
13
|
+
},
|
|
14
|
+
footerProps: {
|
|
15
|
+
footerNav: e.menuItems["footer-menu"],
|
|
16
|
+
subfooterNav: e.menuItems["footer-legal-pages"]
|
|
17
|
+
},
|
|
18
|
+
countdownbannerProps: a ?? {},
|
|
19
|
+
slimBannerProps: s ?? {}
|
|
20
|
+
};
|
|
21
|
+
}, i = (n, e) => ({
|
|
22
|
+
isEnabled: n.is_enabled || !1,
|
|
23
|
+
startDatetime: new Date(n.start_datetime_utc || ""),
|
|
24
|
+
endDatetime: new Date(n.end_datetime_utc || ""),
|
|
25
|
+
message: e.rendered || ""
|
|
26
|
+
}), m = (n) => ({
|
|
27
|
+
bannerMessage: n.rendered || "",
|
|
28
|
+
isEnabled: !0
|
|
29
|
+
}), r = (n, e) => {
|
|
30
|
+
var t;
|
|
31
|
+
return (t = n.find((a) => a.name === e)) == null ? void 0 : t.data;
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
p as mapMintLayoutResponseToProps
|
|
35
|
+
};
|
package/dist/server.d.ts
CHANGED
|
@@ -5,6 +5,13 @@ export declare interface ComponentManifest {
|
|
|
5
5
|
styleUrl?: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
declare interface CountdownbannerProps {
|
|
9
|
+
isEnabled: boolean;
|
|
10
|
+
startDatetime: Date;
|
|
11
|
+
endDatetime: Date;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export declare function fetchManifest(manifestUrl: string): Promise<RemoteManifest>;
|
|
9
16
|
|
|
10
17
|
/**
|
|
@@ -17,6 +24,8 @@ export declare const generateImportMap: (config?: ImportMapConfig) => object;
|
|
|
17
24
|
|
|
18
25
|
export declare const generateImportMapJson: (config?: ImportMapConfig) => string;
|
|
19
26
|
|
|
27
|
+
export declare function getMintLayoutProps(NEXT_PUBLIC_SITE_URL: string, ECOMM_API_URL: string, ECOMM_API_STANDALONE_DEVICE_CREDS: string): Promise<MintLayoutProps>;
|
|
28
|
+
|
|
20
29
|
export declare interface ImportMapConfig {
|
|
21
30
|
reactVersion?: string;
|
|
22
31
|
reactDomVersion?: string;
|
|
@@ -24,6 +33,29 @@ export declare interface ImportMapConfig {
|
|
|
24
33
|
|
|
25
34
|
export declare const ImportMapScripts: () => JSX.Element;
|
|
26
35
|
|
|
36
|
+
declare interface MintFooterProps {
|
|
37
|
+
footerNav: WP_REST_API_Nav_Menu_Items;
|
|
38
|
+
subfooterNav: WP_REST_API_Nav_Menu_Items;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare interface MintHeaderProps {
|
|
42
|
+
primaryNav: {
|
|
43
|
+
left: WP_REST_API_Nav_Menu_Items;
|
|
44
|
+
right: WP_REST_API_Nav_Menu_Items;
|
|
45
|
+
};
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare interface MintLayoutProps {
|
|
50
|
+
config: {
|
|
51
|
+
NEXT_PUBLIC_SITE_URL: string;
|
|
52
|
+
};
|
|
53
|
+
headerProps?: MintHeaderProps;
|
|
54
|
+
footerProps?: MintFooterProps;
|
|
55
|
+
countdownbannerProps?: Partial<CountdownbannerProps>;
|
|
56
|
+
slimBannerProps?: Partial<SlimbannerProps>;
|
|
57
|
+
}
|
|
58
|
+
|
|
27
59
|
export declare interface ModuleLoadOptions {
|
|
28
60
|
bundleUrl: string;
|
|
29
61
|
componentName: string;
|
|
@@ -51,6 +83,11 @@ export declare interface RemoteManifest {
|
|
|
51
83
|
generatedAt: string;
|
|
52
84
|
}
|
|
53
85
|
|
|
86
|
+
declare interface SlimbannerProps {
|
|
87
|
+
bannerMessage: string;
|
|
88
|
+
isEnabled: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
54
91
|
export declare interface UseRemoteComponentOptions {
|
|
55
92
|
manifest: ComponentManifest;
|
|
56
93
|
componentName: string;
|
|
@@ -63,4 +100,33 @@ export declare interface UseRemoteComponentReturn extends RemoteComponentState {
|
|
|
63
100
|
clearError: () => void;
|
|
64
101
|
}
|
|
65
102
|
|
|
103
|
+
declare interface WP_REST_API_Content {
|
|
104
|
+
rendered: string;
|
|
105
|
+
raw: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare interface WP_REST_API_Nav_Menu_Item {
|
|
109
|
+
id: number;
|
|
110
|
+
title: WP_REST_API_Content;
|
|
111
|
+
status: string;
|
|
112
|
+
url: string;
|
|
113
|
+
attr_title: string;
|
|
114
|
+
description: string;
|
|
115
|
+
type: string;
|
|
116
|
+
type_label: string;
|
|
117
|
+
object: string;
|
|
118
|
+
object_id: number;
|
|
119
|
+
parent: number;
|
|
120
|
+
menu_order: number;
|
|
121
|
+
target: string;
|
|
122
|
+
classes: string[];
|
|
123
|
+
xfn: string[];
|
|
124
|
+
invalid: boolean;
|
|
125
|
+
meta: Record<string, string>;
|
|
126
|
+
menus: number;
|
|
127
|
+
_links: Record<string, []>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare type WP_REST_API_Nav_Menu_Items = WP_REST_API_Nav_Menu_Item[];
|
|
131
|
+
|
|
66
132
|
export { }
|
package/dist/server.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { fetchManifest as
|
|
1
|
+
import { fetchManifest as t } from "./services/fetchManifest.js";
|
|
2
2
|
import { generateImportMap as p, generateImportMapJson as m } from "./services/ImportMapService.js";
|
|
3
3
|
import { ImportMapScripts as f } from "./components/ImportMapScripts.js";
|
|
4
4
|
import { RemoteLinks as s } from "./components/RemoteLinks.js";
|
|
5
|
+
import { getMintLayoutProps as M } from "./lib/api/server/getMintLayoutProps/getMintLayoutProps.js";
|
|
5
6
|
export {
|
|
6
7
|
f as ImportMapScripts,
|
|
7
8
|
s as RemoteLinks,
|
|
8
|
-
|
|
9
|
+
t as fetchManifest,
|
|
9
10
|
p as generateImportMap,
|
|
10
|
-
m as generateImportMapJson
|
|
11
|
+
m as generateImportMapJson,
|
|
12
|
+
M as getMintLayoutProps
|
|
11
13
|
};
|
package/package.json
CHANGED