@gem-sdk/pages 1.48.0-dev.43 → 1.48.0-dev.87
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.
|
@@ -119,22 +119,78 @@ const fetchThemePageDataByTemplateID = async (data, fetcher)=>{
|
|
|
119
119
|
productOffers: productOffers
|
|
120
120
|
};
|
|
121
121
|
};
|
|
122
|
-
const
|
|
122
|
+
const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
|
|
123
|
+
const variables = {
|
|
124
|
+
libraryTemplateId: data.libraryTemplateId
|
|
125
|
+
};
|
|
126
|
+
const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
|
|
127
|
+
fetcher([
|
|
128
|
+
core.LibraryTemplateDocument,
|
|
129
|
+
variables
|
|
130
|
+
]),
|
|
131
|
+
fetcher([
|
|
132
|
+
core.StorePropertyDocument
|
|
133
|
+
]),
|
|
134
|
+
fetcher([
|
|
135
|
+
core.SaleFunnelDiscountsDocument,
|
|
136
|
+
{
|
|
137
|
+
where: {
|
|
138
|
+
saleFunnelOfferID: data.currentOfferID
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
])
|
|
142
|
+
]);
|
|
143
|
+
if (theme.status === 'rejected') {
|
|
144
|
+
throw new Error(theme.reason?.[0]);
|
|
145
|
+
}
|
|
146
|
+
if (saleFunnelDiscounts.status === 'rejected') {
|
|
147
|
+
throw new Error(saleFunnelDiscounts.reason?.[0]);
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
dataBuilder: theme.value.libraryTemplate,
|
|
151
|
+
pageStyle: undefined,
|
|
152
|
+
storeProperty,
|
|
153
|
+
productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
const getRelevantPageData = async (data)=>{
|
|
157
|
+
const { id, currentOfferID, fetcher, isLibraryTemplate, librarySaleFunnelID } = data;
|
|
158
|
+
if (librarySaleFunnelID) {
|
|
159
|
+
return await fetchThemePageDataByTemplateID({
|
|
160
|
+
libraryTemplateId: id,
|
|
161
|
+
currentOfferID,
|
|
162
|
+
librarySaleFunnelID
|
|
163
|
+
}, fetcher);
|
|
164
|
+
}
|
|
165
|
+
if (isLibraryTemplate && currentOfferID) {
|
|
166
|
+
return await fetchLibraryTemplateDataByID({
|
|
167
|
+
libraryTemplateId: id,
|
|
168
|
+
currentOfferID
|
|
169
|
+
}, fetcher);
|
|
170
|
+
}
|
|
171
|
+
if (currentOfferID) {
|
|
172
|
+
return await fetchPostPurchasePageDataByID({
|
|
173
|
+
themePageId: id,
|
|
174
|
+
currentOfferID
|
|
175
|
+
}, fetcher);
|
|
176
|
+
}
|
|
177
|
+
return await fetchSalePageDataByID({
|
|
178
|
+
themePageId: id
|
|
179
|
+
}, fetcher);
|
|
180
|
+
};
|
|
181
|
+
const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFetcher)=>async (id, currentOfferID, isLibraryTemplate)=>{
|
|
123
182
|
try {
|
|
124
|
-
const { dataBuilder, storeProperty, productOffers, pageStyle } =
|
|
125
|
-
|
|
183
|
+
const { dataBuilder, storeProperty, productOffers, pageStyle } = await getRelevantPageData({
|
|
184
|
+
id,
|
|
126
185
|
currentOfferID,
|
|
186
|
+
fetcher,
|
|
187
|
+
isLibraryTemplate,
|
|
127
188
|
librarySaleFunnelID
|
|
128
|
-
}
|
|
129
|
-
themePageId: id,
|
|
130
|
-
currentOfferID
|
|
131
|
-
}, fetcher) : await fetchSalePageDataByID({
|
|
132
|
-
themePageId: id
|
|
133
|
-
}, fetcher);
|
|
189
|
+
});
|
|
134
190
|
if (!dataBuilder) {
|
|
135
191
|
throw new Error(`No data builder found for slug: /preview/${id}`);
|
|
136
192
|
}
|
|
137
|
-
const pageTemplate = librarySaleFunnelID ? normalize.parseBuilderLibraryTemplate(dataBuilder) : normalize.parseBuilderTemplateV2(dataBuilder);
|
|
193
|
+
const pageTemplate = librarySaleFunnelID || isLibraryTemplate && currentOfferID ? normalize.parseBuilderLibraryTemplate(dataBuilder) : normalize.parseBuilderTemplateV2(dataBuilder);
|
|
138
194
|
const gemPagesStoreFrontFetcher = storeFrontFetcher || fetcher;
|
|
139
195
|
const [elementFontStyle, fontStyle, fallback] = await Promise.all([
|
|
140
196
|
googleFonts.getFontStyleFromPageTemplate(pageTemplate),
|
|
@@ -160,7 +216,9 @@ const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFet
|
|
|
160
216
|
}
|
|
161
217
|
};
|
|
162
218
|
|
|
219
|
+
exports.fetchLibraryTemplateDataByID = fetchLibraryTemplateDataByID;
|
|
163
220
|
exports.fetchPostPurchasePageDataByID = fetchPostPurchasePageDataByID;
|
|
164
221
|
exports.fetchSalePageDataByID = fetchSalePageDataByID;
|
|
165
222
|
exports.fetchThemePageDataByTemplateID = fetchThemePageDataByTemplateID;
|
|
166
223
|
exports.getPostPurchasePropsPreview = getPostPurchasePropsPreview;
|
|
224
|
+
exports.getRelevantPageData = getRelevantPageData;
|
|
@@ -117,22 +117,78 @@ const fetchThemePageDataByTemplateID = async (data, fetcher)=>{
|
|
|
117
117
|
productOffers: productOffers
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
|
-
const
|
|
120
|
+
const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
|
|
121
|
+
const variables = {
|
|
122
|
+
libraryTemplateId: data.libraryTemplateId
|
|
123
|
+
};
|
|
124
|
+
const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
|
|
125
|
+
fetcher([
|
|
126
|
+
LibraryTemplateDocument,
|
|
127
|
+
variables
|
|
128
|
+
]),
|
|
129
|
+
fetcher([
|
|
130
|
+
StorePropertyDocument
|
|
131
|
+
]),
|
|
132
|
+
fetcher([
|
|
133
|
+
SaleFunnelDiscountsDocument,
|
|
134
|
+
{
|
|
135
|
+
where: {
|
|
136
|
+
saleFunnelOfferID: data.currentOfferID
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
])
|
|
140
|
+
]);
|
|
141
|
+
if (theme.status === 'rejected') {
|
|
142
|
+
throw new Error(theme.reason?.[0]);
|
|
143
|
+
}
|
|
144
|
+
if (saleFunnelDiscounts.status === 'rejected') {
|
|
145
|
+
throw new Error(saleFunnelDiscounts.reason?.[0]);
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
dataBuilder: theme.value.libraryTemplate,
|
|
149
|
+
pageStyle: undefined,
|
|
150
|
+
storeProperty,
|
|
151
|
+
productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
const getRelevantPageData = async (data)=>{
|
|
155
|
+
const { id, currentOfferID, fetcher, isLibraryTemplate, librarySaleFunnelID } = data;
|
|
156
|
+
if (librarySaleFunnelID) {
|
|
157
|
+
return await fetchThemePageDataByTemplateID({
|
|
158
|
+
libraryTemplateId: id,
|
|
159
|
+
currentOfferID,
|
|
160
|
+
librarySaleFunnelID
|
|
161
|
+
}, fetcher);
|
|
162
|
+
}
|
|
163
|
+
if (isLibraryTemplate && currentOfferID) {
|
|
164
|
+
return await fetchLibraryTemplateDataByID({
|
|
165
|
+
libraryTemplateId: id,
|
|
166
|
+
currentOfferID
|
|
167
|
+
}, fetcher);
|
|
168
|
+
}
|
|
169
|
+
if (currentOfferID) {
|
|
170
|
+
return await fetchPostPurchasePageDataByID({
|
|
171
|
+
themePageId: id,
|
|
172
|
+
currentOfferID
|
|
173
|
+
}, fetcher);
|
|
174
|
+
}
|
|
175
|
+
return await fetchSalePageDataByID({
|
|
176
|
+
themePageId: id
|
|
177
|
+
}, fetcher);
|
|
178
|
+
};
|
|
179
|
+
const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFetcher)=>async (id, currentOfferID, isLibraryTemplate)=>{
|
|
121
180
|
try {
|
|
122
|
-
const { dataBuilder, storeProperty, productOffers, pageStyle } =
|
|
123
|
-
|
|
181
|
+
const { dataBuilder, storeProperty, productOffers, pageStyle } = await getRelevantPageData({
|
|
182
|
+
id,
|
|
124
183
|
currentOfferID,
|
|
184
|
+
fetcher,
|
|
185
|
+
isLibraryTemplate,
|
|
125
186
|
librarySaleFunnelID
|
|
126
|
-
}
|
|
127
|
-
themePageId: id,
|
|
128
|
-
currentOfferID
|
|
129
|
-
}, fetcher) : await fetchSalePageDataByID({
|
|
130
|
-
themePageId: id
|
|
131
|
-
}, fetcher);
|
|
187
|
+
});
|
|
132
188
|
if (!dataBuilder) {
|
|
133
189
|
throw new Error(`No data builder found for slug: /preview/${id}`);
|
|
134
190
|
}
|
|
135
|
-
const pageTemplate = librarySaleFunnelID ? parseBuilderLibraryTemplate(dataBuilder) : parseBuilderTemplateV2(dataBuilder);
|
|
191
|
+
const pageTemplate = librarySaleFunnelID || isLibraryTemplate && currentOfferID ? parseBuilderLibraryTemplate(dataBuilder) : parseBuilderTemplateV2(dataBuilder);
|
|
136
192
|
const gemPagesStoreFrontFetcher = storeFrontFetcher || fetcher;
|
|
137
193
|
const [elementFontStyle, fontStyle, fallback] = await Promise.all([
|
|
138
194
|
getFontStyleFromPageTemplate(pageTemplate),
|
|
@@ -158,4 +214,4 @@ const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFet
|
|
|
158
214
|
}
|
|
159
215
|
};
|
|
160
216
|
|
|
161
|
-
export { fetchPostPurchasePageDataByID, fetchSalePageDataByID, fetchThemePageDataByTemplateID, getPostPurchasePropsPreview };
|
|
217
|
+
export { fetchLibraryTemplateDataByID, fetchPostPurchasePageDataByID, fetchSalePageDataByID, fetchThemePageDataByTemplateID, getPostPurchasePropsPreview, getRelevantPageData };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ type StaticPagePropsV2 = PageBuilderPropsV2 & {
|
|
|
94
94
|
};
|
|
95
95
|
declare const StaticPageV2: React.FC<StaticPagePropsV2 & AdditionalPageBuilderProps>;
|
|
96
96
|
|
|
97
|
-
declare const getPostPurchasePropsPreview: (fetcher: FetchFunc, librarySaleFunnelID?: string, storeFrontFetcher?: FetchFunc) => (id: string, currentOfferID: string) => Promise<Omit<StaticPagePropsV2, 'publicStoreFrontData'>>;
|
|
97
|
+
declare const getPostPurchasePropsPreview: (fetcher: FetchFunc, librarySaleFunnelID?: string, storeFrontFetcher?: FetchFunc) => (id: string, currentOfferID: string, isLibraryTemplate?: boolean) => Promise<Omit<StaticPagePropsV2, 'publicStoreFrontData'>>;
|
|
98
98
|
|
|
99
99
|
declare const getStaticPagePropsPreview: (fetcher: FetchFunc, shopifyFetcher: FetchFunc) => (slug: string) => Promise<PageBuilderPropsV2>;
|
|
100
100
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "1.48.0-dev.
|
|
3
|
+
"version": "1.48.0-dev.87",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"next": "latest"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "1.48.0-dev.
|
|
29
|
+
"@gem-sdk/core": "1.48.0-dev.86",
|
|
30
30
|
"@gem-sdk/plugin-cookie-bar": "1.48.0-dev.3",
|
|
31
31
|
"@gem-sdk/plugin-quick-view": "1.48.0-dev.3",
|
|
32
32
|
"@gem-sdk/plugin-sticky-add-to-cart": "1.48.0-dev.3"
|