Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 51 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shopify-live-preview-middleware",
"version": "1.1.1",
"version": "1.1.3",
"description": "Shopify Live Preview Middleware Service",
"type": "module",
"main": "src/index.ts",
Expand All @@ -26,8 +26,6 @@
"@fastify/rate-limit": "^10.0.0",
"@fastify/swagger": "^9.7.0",
"@fastify/swagger-ui": "^5.2.5",
"adm-zip": "^0.5.10",
"axios": "^1.15.2",
"dotenv": "^16.5.0",
"fastify": "^5.8.5",
"fastify-plugin": "^5.0.0",
Expand Down
9 changes: 6 additions & 3 deletions src/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ export const getPreviewDataHandler = async (req: FastifyRequest<{ Body: PreviewD
const { live_preview, ctUid, entryUid, locale, theme_variable } = req.body;
const { liquid_path } = theme_variable;

const entryData: { schema: FieldSchema, entry: Entry } = await livePreviewShopify.fetchData(ctUid, entryUid, live_preview, locale) as { schema: FieldSchema, entry: Entry };
const entryData: { schema: FieldSchema[], entry: Entry } = await livePreviewShopify.fetchData(ctUid, entryUid, live_preview, locale) as { schema: FieldSchema[], entry: Entry };
let shopifyData = { ...theme_variable?.payload };

const keyBasedCt = livePreviewShopify.createContentTypeKeyBased([entryData.schema]);

// CDA include_schema=true returns `schema` as the field array itself — pass it
// directly; wrapping it in another array produced an empty key-based map, which
// routed every field (incl. modular blocks) through the generic no-schema branch.
const keyBasedCt = livePreviewShopify.createContentTypeKeyBased(entryData.schema);
const updatedEntry = entryData.entry;

if (_.get(shopifyData, 'product.metafields.contentstack_products', null)) {
Expand Down
Loading