wiki-plugin-shoppe 0.0.34 → 0.0.35
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/package.json +1 -1
- package/server/server.js +32 -16
package/package.json
CHANGED
package/server/server.js
CHANGED
|
@@ -1186,8 +1186,13 @@ async function processArchive(zipPath, onProgress = () => {}) {
|
|
|
1186
1186
|
const images = fs.readdirSync(entryPath).filter(f => IMAGE_EXTS.has(path.extname(f).toLowerCase()));
|
|
1187
1187
|
const heroFile = images.find(f => /^hero\.(jpg|jpeg|png|webp)$/i.test(f)) || images[0];
|
|
1188
1188
|
if (heroFile) {
|
|
1189
|
-
|
|
1190
|
-
|
|
1189
|
+
try {
|
|
1190
|
+
const heroBuf = fs.readFileSync(path.join(entryPath, heroFile));
|
|
1191
|
+
await sanoraUploadImage(tenant, title, heroBuf, heroFile);
|
|
1192
|
+
} catch (imgErr) {
|
|
1193
|
+
console.warn(`[shoppe] ⚠️ image upload for ${title}: ${imgErr.message}`);
|
|
1194
|
+
results.warnings.push(`Image upload for "${title}" failed: ${imgErr.message}`);
|
|
1195
|
+
}
|
|
1191
1196
|
}
|
|
1192
1197
|
|
|
1193
1198
|
results.products.push({ title, order, price, shipping });
|
|
@@ -3705,30 +3710,41 @@ async function startServer(params) {
|
|
|
3705
3710
|
}
|
|
3706
3711
|
});
|
|
3707
3712
|
|
|
3708
|
-
// Music feed —
|
|
3713
|
+
// Music feed — builds { albums, tracks } from Sanora products directly
|
|
3709
3714
|
app.get('/plugin/shoppe/:identifier/music/feed', async (req, res) => {
|
|
3710
3715
|
try {
|
|
3711
3716
|
const tenant = getTenantByIdentifier(req.params.identifier);
|
|
3712
3717
|
if (!tenant) return res.status(404).json({ error: 'Shoppe not found' });
|
|
3713
|
-
const
|
|
3714
|
-
|
|
3715
|
-
|
|
3718
|
+
const sanoraUrl = getSanoraUrl();
|
|
3719
|
+
const productsResp = await fetchWithRetry(`${sanoraUrl}/products/${tenant.uuid}`, { timeout: 15000 });
|
|
3720
|
+
if (!productsResp.ok) return res.status(502).json({ error: 'Could not load products' });
|
|
3721
|
+
const products = await productsResp.json();
|
|
3716
3722
|
|
|
3717
3723
|
const albums = [];
|
|
3718
3724
|
const tracks = [];
|
|
3719
|
-
for (const
|
|
3720
|
-
|
|
3721
|
-
const
|
|
3722
|
-
|
|
3723
|
-
if (
|
|
3725
|
+
for (const [key, product] of Object.entries(products)) {
|
|
3726
|
+
if (product.category !== 'music') continue;
|
|
3727
|
+
const cover = product.image ? `${sanoraUrl}/images/${product.image}` : null;
|
|
3728
|
+
const artifacts = product.artifacts || [];
|
|
3729
|
+
if (artifacts.length > 1) {
|
|
3724
3730
|
albums.push({
|
|
3725
|
-
name:
|
|
3731
|
+
name: product.title || key,
|
|
3726
3732
|
cover,
|
|
3727
|
-
description:
|
|
3728
|
-
tracks:
|
|
3733
|
+
description: product.description || '',
|
|
3734
|
+
tracks: artifacts.map((a, i) => ({
|
|
3735
|
+
number: i + 1,
|
|
3736
|
+
title: `Track ${i + 1}`,
|
|
3737
|
+
src: `${sanoraUrl}/artifacts/${a}`,
|
|
3738
|
+
type: 'audio/mpeg'
|
|
3739
|
+
}))
|
|
3740
|
+
});
|
|
3741
|
+
} else if (artifacts.length === 1) {
|
|
3742
|
+
tracks.push({
|
|
3743
|
+
title: product.title || key,
|
|
3744
|
+
src: `${sanoraUrl}/artifacts/${artifacts[0]}`,
|
|
3745
|
+
cover,
|
|
3746
|
+
description: product.description || ''
|
|
3729
3747
|
});
|
|
3730
|
-
} else {
|
|
3731
|
-
tracks.push({ title: item.name, src: mediaItems[0].url, cover, description: item.summary || '' });
|
|
3732
3748
|
}
|
|
3733
3749
|
}
|
|
3734
3750
|
res.json({ albums, tracks });
|