This commit is contained in:
Your Name committed 2026-06-28 05:52:46 -04:00
1 parent 5fac4524c8
commit e1d793ce37
69 files changed
+1891 -609

No files matched your search

+5 -1
View File
@@ -30,7 +30,11 @@ export default function DashboardPage() {
const brands = new Set(prods.map(p => p.brand.id)).size
const totalProducts = prods.length
const avgPrice = prods.reduce((acc, curr) => acc + (curr.price || 0), 0) / (totalProducts || 1)
const avgPrice = prods.reduce((acc, curr) => {
const variantPrices = curr.variants?.map(v => v.price || 0) || []
const minPrice = variantPrices.length > 0 ? Math.min(...variantPrices) : 0
return acc + minPrice
}, 0) / (totalProducts || 1)
const validOrders = Array.isArray(orders) ? orders : []
const totalOrders = validOrders.length
-21
View File
@@ -1,21 +0,0 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
await prisma.product.updateMany({
data: {
price: null,
},
});
console.log('Successfully set all Product prices to null');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=delete_products.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"delete_products.d.ts","sourceRoot":"","sources":["delete_products.ts"],"names":[],"mappings":""}
+22
View File
@@ -0,0 +1,22 @@
import prisma from './src/lib/prisma';
async function main() {
console.log('Starting deletion process...');
try {
// Delete all product variants first to avoid foreign key constraint errors
const deletedVariants = await prisma.productVariant.deleteMany({});
console.log(`Deleted ${deletedVariants.count} ProductVariants.`);
// Delete all products
const deletedProducts = await prisma.product.deleteMany({});
console.log(`Deleted ${deletedProducts.count} Products.`);
console.log('Deletion completed successfully.');
}
catch (error) {
console.error('Error deleting products:', error);
process.exit(1);
}
finally {
await prisma.$disconnect();
}
}
main();
//# sourceMappingURL=delete_products.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"delete_products.js","sourceRoot":"","sources":["delete_products.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAE5C,IAAI,CAAC;QACH,2EAA2E;QAC3E,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACnE,OAAO,CAAC,GAAG,CAAC,WAAW,eAAe,CAAC,KAAK,mBAAmB,CAAC,CAAC;QAEjE,sBAAsB;QACtB,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,WAAW,eAAe,CAAC,KAAK,YAAY,CAAC,CAAC;QAE1D,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=query.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["query.ts"],"names":[],"mappings":""}
+8
View File
@@ -0,0 +1,8 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const section = await prisma.pageSection.findUnique({ where: { id: 37 } });
console.log(JSON.stringify(section, null, 2));
}
main().finally(() => prisma.$disconnect());
//# sourceMappingURL=query.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"query.js","sourceRoot":"","sources":["query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;AAClC,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;AACD,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=scratch_seed_product.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"scratch_seed_product.d.ts","sourceRoot":"","sources":["scratch_seed_product.ts"],"names":[],"mappings":""}
+11
View File
@@ -0,0 +1,11 @@
import prisma from './src/lib/prisma';
async function main() {
const brand = await prisma.productBrand.findFirst({ where: { name: 'DDC' } });
let cat = await prisma.category.findFirst({ where: { name: 'Sprockets' } });
if (!cat) {
cat = await prisma.category.create({ data: { name: 'Sprockets' } });
}
console.log(JSON.stringify({ brandId: brand?.id, catId: cat.id }));
}
main().catch(console.error).finally(() => process.exit(0));
//# sourceMappingURL=scratch_seed_product.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_seed_product.js","sourceRoot":"","sources":["scratch_seed_product.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,KAAK,UAAU,IAAI;IACjB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9E,IAAI,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AACD,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=scratch_test.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test.d.ts","sourceRoot":"","sources":["scratch_test.ts"],"names":[],"mappings":""}
+17
View File
@@ -0,0 +1,17 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
prisma.product.findMany({
include: {
category: { include: { translations: true } },
brand: true,
translations: true,
variants: {
include: {
bomItems: { include: { rawMaterial: true } }
},
orderBy: { price: "asc" }
},
images: { orderBy: { order: "asc" } },
}
}).then(console.log).catch(console.error).finally(() => prisma.$disconnect());
//# sourceMappingURL=scratch_test.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test.js","sourceRoot":"","sources":["scratch_test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;AAClC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE;QAC7C,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;aAC7C;YACD,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;SAC1B;QACD,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;KACtC;CACF,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=scratch_test_langs.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_langs.d.ts","sourceRoot":"","sources":["scratch_test_langs.ts"],"names":[],"mappings":""}
+6
View File
@@ -0,0 +1,6 @@
import prisma from './src/lib/prisma';
prisma.storeSettingsTranslation.findMany({ select: { langCode: true } })
.then(x => console.log([...new Set(x.map(r => r.langCode))]))
.catch(console.error)
.finally(() => prisma.$disconnect());
//# sourceMappingURL=scratch_test_langs.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_langs.js","sourceRoot":"","sources":["scratch_test_langs.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,MAAM,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;KACrE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;KACpB,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=scratch_test_menus.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_menus.d.ts","sourceRoot":"","sources":["scratch_test_menus.ts"],"names":[],"mappings":""}
+3
View File
@@ -0,0 +1,3 @@
import prisma from './src/lib/prisma';
prisma.menu.findMany().then(console.log).catch(console.error).finally(() => prisma.$disconnect());
//# sourceMappingURL=scratch_test_menus.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_menus.js","sourceRoot":"","sources":["scratch_test_menus.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=scratch_test_page.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_page.d.ts","sourceRoot":"","sources":["scratch_test_page.ts"],"names":[],"mappings":""}
+15
View File
@@ -0,0 +1,15 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
prisma.page.findUnique({
where: { slug: 'home' },
include: {
translations: true,
sections: {
include: {
translations: true
},
orderBy: { order: "asc" }
}
}
}).then(console.log).catch(console.error).finally(() => prisma.$disconnect());
//# sourceMappingURL=scratch_test_page.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_page.js","sourceRoot":"","sources":["scratch_test_page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;AAClC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;IACrB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACvB,OAAO,EAAE;QACP,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI;aACnB;YACD,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;SAC1B;KACF;CACF,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=scratch_test_page2.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_page2.d.ts","sourceRoot":"","sources":["scratch_test_page2.ts"],"names":[],"mappings":""}
+11
View File
@@ -0,0 +1,11 @@
import prisma from './src/lib/prisma';
prisma.page.findUnique({
where: { slug: 'home' },
include: {
translations: true,
sections: {
orderBy: { order: "asc" }
}
}
}).then(console.log).catch(console.error).finally(() => prisma.$disconnect());
//# sourceMappingURL=scratch_test_page2.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scratch_test_page2.js","sourceRoot":"","sources":["scratch_test_page2.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;IACrB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACvB,OAAO,EAAE;QACP,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;SAC1B;KACF;CACF,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC"}
+11 -1
View File
@@ -27,6 +27,7 @@ import { menusRoute } from "./routes/menus";
import { newsletterRoute } from "./routes/newsletter";
import { mediaRoute } from "./routes/media";
import { contactsRoute } from "./routes/contacts";
import { productAttributesRoute } from "./routes/product-attributes";
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3051;
const CORS_ORIGIN = process.env.CORS_ORIGIN || "http://localhost:5173";
const JWT_SECRET = process.env.JWT_SECRET || "homaroma_secret_2026_brand";
@@ -52,6 +53,15 @@ const allowLanDevOrigin = (request) => {
}
};
const app = new Elysia()
.onRequest(({ request }) => {
console.log(`\n➡️ [${request.method}] ${request.url}`);
})
.onAfterHandle(({ request, set }) => {
console.log(`✅ [${request.method}] ${request.url} → ${set.status ?? 200}`);
})
.onError(({ request, error, set }) => {
console.error(`❌ [${request.method}] ${request.url} → ${set.status ?? 500}`, error?.message ?? error);
})
.onParse(async ({ request }) => {
console.log('[onParse] Incoming request URL:', request.url);
if (request.url.includes('/api/line/webhook')) {
@@ -114,7 +124,7 @@ const app = new Elysia()
}
return file;
})
.group("/api", (app) => app.use(authRoute).use(categoriesRoute).use(productsRoute).use(uploadRoute).use(ordersRoute).use(settingsRoute).use(articlesRoute).use(tiktokRoute).use(rawMaterialsRoute).use(shopeeRoute).use(tiktokOrderRoute).use(lazadaOrderRoute).use(customersRoute).use(couponsRoute).use(reviewsRoute).use(promotionsRoute).use(pagesRoute).use(paymentsRoute).use(profileRoute).use(lineRoutes).use(menusRoute).use(newsletterRoute).use(mediaRoute).use(contactsRoute))
.group("/api", (app) => app.use(authRoute).use(categoriesRoute).use(productsRoute).use(productAttributesRoute).use(uploadRoute).use(ordersRoute).use(settingsRoute).use(articlesRoute).use(tiktokRoute).use(rawMaterialsRoute).use(shopeeRoute).use(tiktokOrderRoute).use(lazadaOrderRoute).use(customersRoute).use(couponsRoute).use(reviewsRoute).use(promotionsRoute).use(pagesRoute).use(paymentsRoute).use(profileRoute).use(lineRoutes).use(menusRoute).use(newsletterRoute).use(mediaRoute).use(contactsRoute))
.listen({ port: PORT, hostname: "0.0.0.0" });
console.log(`🌿 HomAroma API is running at http://${app.server?.hostname}:${app.server?.port}`);
console.log(`📖 Swagger docs: http://${app.server?.hostname}:${app.server?.port}/swagger`);
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cA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;KACF,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,UAAU;CACjB,CAAC,CAAC;IACH,8EAA8E;KAC7E,GAAG,CAAC,oBAAoB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAC3D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;IACpD,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACpB,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;QACjB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;KACD,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CACrB,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,WAAW,CLine truncated
+11 -1
View File
@@ -2,6 +2,16 @@ import { PrismaClient } from "@prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";
declare const prisma: PrismaClient<{
adapter: PrismaPg;
}, never, import("@prisma/client/runtime/client").DefaultArgs>;
log: ({
emit: "stdout";
level: "query";
} | {
emit: "stdout";
level: "error";
} | {
emit: "stdout";
level: "warn";
})[];
}, "query" | "warn" | "error", import("@prisma/client/runtime/client").DefaultArgs>;
export default prisma;
//# sourceMappingURL=prisma.d.ts.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["prisma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAW9C,QAAA,MAAM,MAAM;;8DAAgC,CAAC;AAE7C,eAAe,MAAM,CAAC"}
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["prisma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAW9C,QAAA,MAAM,MAAM;;;;;;;;;;;;mFAOV,CAAC;AAEH,eAAe,MAAM,CAAC"}
+8 -1
View File
@@ -6,6 +6,13 @@ dotenv.config();
const connectionString = process.env.DATABASE_URL;
const pool = new Pool({ connectionString });
const adapter = new PrismaPg(pool);
const prisma = new PrismaClient({ adapter });
const prisma = new PrismaClient({
adapter,
log: [
{ emit: 'stdout', level: 'query' },
{ emit: 'stdout', level: 'error' },
{ emit: 'stdout', level: 'warn' },
],
});
export default prisma;
//# sourceMappingURL=prisma.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"prisma.js","sourceRoot":"","sources":["prisma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,YAAa,CAAC;AAEnD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEnC,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAE7C,eAAe,MAAM,CAAC"}
{"version":3,"file":"prisma.js","sourceRoot":"","sources":["prisma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,YAAa,CAAC;AAEnD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEnC,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC;IAC9B,OAAO;IACP,GAAG,EAAE;QACH,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;QAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;QAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE;KAClC;CACF,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
+20
View File
@@ -0,0 +1,20 @@
export declare const SUPPORTED_LANGS: readonly ["th", "en", "ja", "zh", "vi", "ko"];
export type AttributeType = 'TEXT' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'JSON';
export declare function normalizeAttributeType(type: unknown): AttributeType;
export declare function resolveLocalizedText(baseValue: string | null | undefined, translations: Array<{
langCode: string;
valueText?: string | null;
}> | undefined, lang: string): string;
export declare function resolveDefinitionLocalizedField<T extends {
langCode: string;
label: string;
description?: string | null;
}>(baseValue: string | null | undefined, translations: T[] | undefined, lang: string, field: 'label' | 'description'): string | null;
export declare function getPrimaryOptionValue(value: any): string;
export declare function getLocalizedOptionLabel(value: any, lang: string): string;
export declare function getSelectOptionDisplay(options: any, storedValue: string, lang: string): string;
export declare function validateAttributeValue(type: AttributeType, payload: Record<string, any>): void;
export declare function validateSelectOption(options: any, storedValue: string): void;
export declare function localizeAttributeDefinition(definition: any, lang: string): any;
export declare function localizeProductAttribute(attribute: any, lang: string): any;
//# sourceMappingURL=productAttributes.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"productAttributes.d.ts","sourceRoot":"","sources":["productAttributes.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,+CAAQ,CAAC;AAErC,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAI9E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,CAMnE;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,YAAY,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,GAAG,SAAS,EAChF,IAAI,EAAE,MAAM,UAQb;AAED,wBAAgB,+BAA+B,CAAC,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACxH,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,YAAY,EAAE,CAAC,EAAE,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GAAG,aAAa,iBAQ/B;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAMxD;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS9F;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAmCvF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,QAQrE;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,OAqBxE;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,OA8BpE"}
+152
View File
@@ -0,0 +1,152 @@
const LANGS = ['th', 'en', 'ja', 'zh', 'vi', 'ko'];
export const SUPPORTED_LANGS = LANGS;
const ATTRIBUTE_TYPES = ['TEXT', 'NUMBER', 'BOOLEAN', 'SELECT', 'JSON'];
export function normalizeAttributeType(type) {
const normalized = String(type || '').toUpperCase();
if (!ATTRIBUTE_TYPES.includes(normalized)) {
throw new Error(`Unsupported attribute type '${type}'. Allowed types: ${ATTRIBUTE_TYPES.join(', ')}`);
}
return normalized;
}
export function resolveLocalizedText(baseValue, translations, lang) {
if (lang === 'all')
return baseValue ?? '';
const exact = translations?.find((item) => item.langCode === lang)?.valueText;
if (exact)
return exact;
const thai = translations?.find((item) => item.langCode === 'th')?.valueText;
if (thai)
return thai;
return baseValue ?? '';
}
export function resolveDefinitionLocalizedField(baseValue, translations, lang, field) {
if (lang === 'all')
return baseValue ?? null;
const exact = translations?.find((item) => item.langCode === lang)?.[field];
if (exact !== undefined && exact !== null && exact !== '')
return exact;
const thai = translations?.find((item) => item.langCode === 'th')?.[field];
if (thai !== undefined && thai !== null && thai !== '')
return thai;
return baseValue ?? null;
}
export function getPrimaryOptionValue(value) {
if (typeof value === 'string')
return value;
if (typeof value === 'object' && value !== null) {
return value.th || value.en || Object.values(value)[0] || '';
}
return String(value ?? '');
}
export function getLocalizedOptionLabel(value, lang) {
if (typeof value === 'string')
return value;
if (typeof value === 'object' && value !== null) {
return value[lang] || value[lang.slice(0, 2)] || value.th || value.en || Object.values(value)[0] || '';
}
return String(value ?? '');
}
export function getSelectOptionDisplay(options, storedValue, lang) {
if (!Array.isArray(options))
return storedValue;
for (const option of options) {
const primary = getPrimaryOptionValue(option);
if (primary === storedValue) {
return getLocalizedOptionLabel(option, lang);
}
}
return storedValue;
}
export function validateAttributeValue(type, payload) {
const populated = [
payload.valueText !== undefined && payload.valueText !== null && payload.valueText !== '',
payload.valueNumber !== undefined && payload.valueNumber !== null,
payload.valueBoolean !== undefined && payload.valueBoolean !== null,
payload.valueJson !== undefined && payload.valueJson !== null,
].filter(Boolean).length;
if (populated !== 1) {
throw new Error('Exactly one of valueText, valueNumber, valueBoolean, or valueJson must be provided.');
}
switch (type) {
case 'TEXT':
if (typeof payload.valueText !== 'string')
throw new Error('TEXT attributes require valueText as a string.');
return;
case 'NUMBER':
if (typeof payload.valueNumber !== 'number' || Number.isNaN(payload.valueNumber)) {
throw new Error('NUMBER attributes require valueNumber as a valid number.');
}
return;
case 'BOOLEAN':
if (typeof payload.valueBoolean !== 'boolean') {
throw new Error('BOOLEAN attributes require valueBoolean as a boolean.');
}
return;
case 'JSON':
if (payload.valueJson === undefined || payload.valueJson === null) {
throw new Error('JSON attributes require valueJson.');
}
return;
case 'SELECT':
if (typeof payload.valueText !== 'string')
throw new Error('SELECT attributes require valueText as the stored option key.');
return;
}
}
export function validateSelectOption(options, storedValue) {
if (!Array.isArray(options)) {
throw new Error('SELECT attribute definition must provide options.');
}
const allowed = options.map(getPrimaryOptionValue);
if (!allowed.includes(storedValue)) {
throw new Error(`Invalid SELECT value '${storedValue}'. Allowed values: [${allowed.join(', ')}]`);
}
}
export function localizeAttributeDefinition(definition, lang) {
if (lang === 'all') {
const label = {};
const description = {};
definition.translations?.forEach((translation) => {
label[translation.langCode] = translation.label;
if (translation.description)
description[translation.langCode] = translation.description;
});
return {
...definition,
label,
description,
};
}
return {
...definition,
label: resolveDefinitionLocalizedField(definition.label, definition.translations, lang, 'label') || definition.label,
description: resolveDefinitionLocalizedField(definition.description, definition.translations, lang, 'description'),
};
}
export function localizeProductAttribute(attribute, lang) {
const localizedDefinition = localizeAttributeDefinition(attribute.attributeDefinition, lang);
const type = normalizeAttributeType(attribute.attributeDefinition.type);
const value = type === 'TEXT'
? resolveLocalizedText(attribute.valueText, attribute.translations, lang)
: type === 'SELECT'
? getSelectOptionDisplay(attribute.attributeDefinition.options, attribute.valueText || '', lang)
: attribute.valueBoolean ?? attribute.valueNumber ?? attribute.valueJson ?? attribute.valueText ?? null;
if (lang === 'all') {
const valueTranslations = {};
attribute.translations?.forEach((translation) => {
valueTranslations[translation.langCode] = translation.valueText;
});
return {
...attribute,
attributeDefinition: localizedDefinition,
value,
valueTranslations,
};
}
return {
...attribute,
attributeDefinition: localizedDefinition,
value,
};
}
//# sourceMappingURL=productAttributes.js.map
@@ -0,0 +1 @@
{"version":3,"file":"productAttributes.js","sourceRoot":"","sources":["productAttributes.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAE5D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAIrC,MAAM,eAAe,GAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEzF,MAAM,UAAU,sBAAsB,CAAC,IAAa;IAClD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,I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CAAC,WAAW;gBAAE,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC;QAC3F,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,UAAU;YACb,KAAK;YACL,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,UAAU;QACb,KAAK,EAAE,+BAA+B,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,UAAU,CAAC,KAAK;QACpH,WAAW,EAAE,+BAA+B,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,YAAY,EAAE,IAAI,EAAE,aAAa,CAAC;KACnH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,Line truncated
+8
View File
@@ -94,6 +94,11 @@ export declare const categoriesRoute: Elysia<"/categories", {
};
400: {
readonly message: "Invalid category ID";
} | {
readonly message: "No valid translations provided";
};
404: {
readonly message: "Category not found";
};
422: {
type: "validation";
@@ -104,6 +109,9 @@ export declare const categoriesRoute: Elysia<"/categories", {
property?: string;
expected?: string;
};
500: {
readonly message: any;
};
};
};
};
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["categories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAK,MAAM,QAAQ,CAAC;AAkBnC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgNxB,CAAC"}
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["categories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAK,MAAM,QAAQ,CAAC;AAkBnC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4NxB,CAAC"}
+40 -28
View File
@@ -113,36 +113,48 @@ export const categoriesRoute = new Elysia({ prefix: "/categories" })
const id = parseInt(params.id);
if (isNaN(id))
return status(400, { message: "Invalid category ID" });
const payload = body;
const results = [];
for (const lang of LANGS) {
const name = typeof payload.name === 'string'
? (lang === 'th' ? payload.name : null)
: payload.name?.[lang];
if (!name)
continue;
const existing = await prisma.categoryTranslation.findUnique({
where: { categoryId_langCode: { categoryId: id, langCode: lang } }
try {
const categoryExists = await prisma.category.findUnique({ where: { id } });
if (!categoryExists)
return status(404, { message: "Category not found" });
const payload = body;
const results = [];
for (const lang of LANGS) {
const name = typeof payload.name === 'string'
? (lang === 'th' ? payload.name : null)
: payload.name?.[lang];
if (!name)
continue;
const existing = await prisma.categoryTranslation.findUnique({
where: { categoryId_langCode: { categoryId: id, langCode: lang } }
});
if (existing) {
const updated = await prisma.categoryTranslation.update({
where: { id: existing.id },
data: { name },
});
results.push(updated);
}
else {
const created = await prisma.categoryTranslation.create({
data: { categoryId: id, langCode: lang, name },
});
results.push(created);
}
}
if (results.length === 0) {
return status(400, { message: "No valid translations provided" });
}
const updated = await prisma.category.findUnique({
where: { id },
include: { translations: true, _count: { select: { products: true } } },
});
if (existing) {
const updated = await prisma.categoryTranslation.update({
where: { id: existing.id },
data: { name },
});
results.push(updated);
}
else {
const created = await prisma.categoryTranslation.create({
data: { categoryId: id, langCode: lang, name },
});
results.push(created);
}
return { success: true, translations: results, category: updated };
}
catch (err) {
console.error("Update category translations error:", err);
return status(500, { message: err?.message || "Failed to update translations" });
}
const updated = await prisma.category.findUnique({
where: { id },
include: { translations: true, _count: { select: { products: true } } },
});
return { success: true, translations: results, category: updated };
})
.post("/", async ({ body, status }) => {
try {
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"categories.js","sourceRoot":"","sources":["categories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,MAAM,MAAM,eAAe,CAAC;AAEnC,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEnD,0CAA0C;AAC1C,SAAS,cAAc,CAAC,GAAQ,EAAE,IAAY;IAC5C,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,MAAM,OAAO,GAAQ,EAAE,CAAC;QACxB,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,EAAO,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;WAChE,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;WACvD,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,KAAK,EAAE,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;KACjE,GAAG,CAAC,GAAG,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,GAAG,KAAK,CAAC;SACnC;KACF,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,CAAC,mBAAmB,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;IAC7D,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAEtE,IAAI,CAAC;QACH,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,cAAc;YAAE,OAAO,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAE3E,MAAM,OAAO,GAAG,IAAW,CAAC;QAC5B,MAAM,OAAO,GAAU,EAAE,CAAC;QAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;gBAC3C,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;gBACLine truncated
+2 -2
View File
@@ -54,8 +54,8 @@ export declare const couponsRoute: Elysia<"/coupons", {
usageLimit?: number | null;
expiresAt?: string | null;
type: string;
value: number;
code: string;
value: number;
};
params: {};
query: unknown;
@@ -74,8 +74,8 @@ export declare const couponsRoute: Elysia<"/coupons", {
body: {
type?: string;
isActive?: boolean;
value?: number;
code?: string;
value?: number;
minPurchase?: number;
maxDiscount?: number | null;
usageLimit?: number | null;
+21
View File
@@ -62,6 +62,26 @@ export declare const pagesRoute: Elysia<"/pages", {
};
};
};
} & {
pages: {
sections: {
":sectionId": {
get: {
body: unknown;
params: {
sectionId: string;
} & {};
query: unknown;
headers: unknown;
response: {
[x: string]: any;
[x: number]: any;
[x: symbol]: any;
};
};
};
};
};
} & {
pages: {
newsletter: {
@@ -156,4 +176,5 @@ export declare const pagesRoute: Elysia<"/pages", {
standaloneSchema: {};
response: {};
}, any>;
export declare function hydrateSectionPayload(section: any, lang: string): Promise<any>;
//# sourceMappingURL=pages.d.ts.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAK,MAAM,QAAQ,CAAC;AAgKnC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6dnB,CAAC"}
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAK,MAAM,QAAQ,CAAC;AA0EnC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2cnB,CAAC;AAsKL,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,gBA+CrE"}
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"pages.js","sourceRoot":"","sources":["pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,QAA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uBAAuB,EAAE,CAAC;QAC5C,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC;YACrD,KAAK,EAAE,EAAE,KAAK,EAAE;YAChB,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE,KAAK,EAAE;SAClB,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;QAC1C,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;QACjB,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC1C,CAAC;AACH,CAAC,EACD;IACE,IAAI,EAAE,CALine truncated
+349
View File
@@ -0,0 +1,349 @@
import { Elysia } from "elysia";
export declare const productAttributesRoute: Elysia<"", {
decorator: {};
store: {};
derive: {};
resolve: {};
}, {
typebox: {};
error: {};
}, {
schema: {};
standaloneSchema: {};
macro: {};
macroFn: {};
parser: {};
response: {};
}, {
"product-attributes": {
definitions: {
get: {
body: unknown;
params: {};
query: unknown;
headers: unknown;
response: {
[x: string]: any;
[x: number]: any;
[x: symbol]: any;
};
};
};
};
} & {
"product-attributes": {
definitions: {
":id": {
get: {
body: unknown;
params: {
id: string;
} & {};
query: unknown;
headers: unknown;
response: {
[x: string]: any;
[x: number]: any;
[x: symbol]: any;
};
};
};
};
};
} & {
"product-attributes": {
definitions: {
post: {
body: any;
params: {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
definition: any;
};
400: {
readonly message: "Attribute definition code already exists";
};
500: {
readonly message: any;
};
};
};
};
};
} & {
"product-attributes": {
definitions: {
":id": {
put: {
body: any;
params: {
id: string;
} & {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
definition: any;
};
400: {
readonly message: "Attribute definition code already exists";
};
404: {
readonly message: "Attribute definition not found";
};
422: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
};
500: {
readonly message: any;
};
};
};
};
};
};
} & {
"product-attributes": {
definitions: {
":id": {
translations: {
patch: {
body: any;
params: {
id: string;
} & {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
definition: any;
translations: any[];
};
400: {
readonly message: "No valid translations provided";
};
404: {
readonly message: "Attribute definition not found";
};
422: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
};
500: {
readonly message: any;
};
};
};
};
};
};
};
} & {
products: {
":id": {
attributes: {
get: {
body: unknown;
params: {
id: string;
} & {};
query: unknown;
headers: unknown;
response: {
[x: string]: any;
[x: number]: any;
[x: symbol]: any;
};
};
};
};
};
} & {
products: {
":id": {
attributes: {
post: {
body: any;
params: {
id: string;
} & {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
attribute: any;
};
400: {
readonly message: "attributeDefinitionId is required";
} | {
readonly message: any;
};
404: {
readonly message: any;
};
422: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
};
};
};
};
};
};
} & {
products: {
":id": {
attributes: {
put: {
body: any;
params: {
id: string;
} & {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
attributes: any;
};
400: {
readonly message: "attributes array is required";
} | {
readonly message: any;
};
404: {
readonly message: "Product not found";
} | {
readonly message: any;
};
422: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
};
};
};
};
};
};
} & {
products: {
":id": {
attributes: {
":productAttributeId": {
put: {
body: any;
params: {
id: string;
productAttributeId: string;
} & {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
attribute: any;
};
400: {
readonly message: any;
};
404: {
readonly message: "Product attribute not found";
};
422: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
};
};
};
};
};
};
};
} & {
products: {
":id": {
attributes: {
":productAttributeId": {
translations: {
patch: {
body: any;
params: {
id: string;
productAttributeId: string;
} & {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
attribute: any;
translations: any[];
};
400: {
readonly message: any;
};
404: {
readonly message: "Product attribute not found";
};
422: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
};
};
};
};
};
};
};
};
}, {
derive: {};
resolve: {};
schema: {};
standaloneSchema: {};
response: {};
}, {
derive: {};
resolve: {};
schema: {};
standaloneSchema: {};
response: {};
}>;
//# sourceMappingURL=product-attributes.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"product-attributes.d.ts","sourceRoot":"","sources":["product-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAK,MAAM,QAAQ,CAAC;AAiDnC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqY/B,CAAC"}
@@ -0,0 +1,417 @@
import { Elysia, t } from "elysia";
import prisma from "../lib/prisma";
import { SUPPORTED_LANGS, localizeAttributeDefinition, localizeProductAttribute, normalizeAttributeType, validateAttributeValue, validateSelectOption, } from "../lib/productAttributes";
function parseId(value, label) {
const parsed = parseInt(value);
if (Number.isNaN(parsed)) {
throw new Error(`Invalid ${label}`);
}
return parsed;
}
function buildDefinitionPayload(payload) {
return {
code: payload.code,
label: payload.label,
description: payload.description ?? null,
type: normalizeAttributeType(payload.type),
unit: payload.unit ?? null,
options: payload.options ?? null,
isRequired: Boolean(payload.isRequired),
isFilterable: Boolean(payload.isFilterable),
sortOrder: typeof payload.sortOrder === 'number' ? payload.sortOrder : 0,
categoryId: payload.categoryId ?? null,
};
}
async function assertProductAndDefinitionMatch(productId, attributeDefinitionId) {
const [product, definition] = await Promise.all([
prisma.product.findUnique({ where: { id: productId } }),
prisma.attributeDefinition.findUnique({ where: { id: attributeDefinitionId } }),
]);
if (!product)
throw new Error("Product not found");
if (!definition)
throw new Error("Attribute definition not found");
if (definition.categoryId && definition.categoryId !== product.categoryId) {
throw new Error("Attribute definition category does not match product category");
}
return { product, definition };
}
export const productAttributesRoute = new Elysia()
.get("/product-attributes/definitions", async ({ query }) => {
const lang = query.lang || 'th';
const categoryId = query.categoryId ? parseInt(query.categoryId) : undefined;
const definitions = await prisma.attributeDefinition.findMany({
where: categoryId ? { OR: [{ categoryId }, { categoryId: null }] } : undefined,
include: {
category: true,
translations: true,
},
orderBy: [
{ sortOrder: 'asc' },
{ code: 'asc' },
],
});
return definitions.map((definition) => localizeAttributeDefinition(definition, lang));
})
.get("/product-attributes/definitions/:id", async ({ params, query, status }) => {
try {
const id = parseId(params.id, "attribute definition ID");
const lang = query.lang || 'th';
const definition = await prisma.attributeDefinition.findUnique({
where: { id },
include: {
category: true,
translations: true,
},
});
if (!definition)
return status(404, { message: "Attribute definition not found" });
return localizeAttributeDefinition(definition, lang);
}
catch (err) {
return status(400, { message: err.message });
}
})
.post("/product-attributes/definitions", async ({ body, status }) => {
try {
const payload = body;
const definition = await prisma.attributeDefinition.create({
data: {
...buildDefinitionPayload(payload),
translations: payload.translations && typeof payload.translations === 'object'
? {
create: Object.entries(payload.translations)
.filter(([lang, value]) => SUPPORTED_LANGS.includes(lang) && value && typeof value === 'object' && value.label)
.map(([lang, value]) => ({
langCode: lang,
label: value.label,
description: value.description ?? null,
})),
}
: undefined,
},
include: {
category: true,
translations: true,
},
});
return { success: true, definition };
}
catch (err) {
if (err.code === 'P2002')
return status(400, { message: "Attribute definition code already exists" });
return status(500, { message: err?.message || "Failed to create attribute definition" });
}
}, {
body: t.Any(),
})
.put("/product-attributes/definitions/:id", async ({ params, body, status }) => {
try {
const id = parseId(params.id, "attribute definition ID");
const payload = body;
const definition = await prisma.attributeDefinition.update({
where: { id },
data: buildDefinitionPayload(payload),
include: {
category: true,
translations: true,
},
});
return { success: true, definition };
}
catch (err) {
if (err.code === 'P2025')
return status(404, { message: "Attribute definition not found" });
if (err.code === 'P2002')
return status(400, { message: "Attribute definition code already exists" });
return status(500, { message: err?.message || "Failed to update attribute definition" });
}
}, {
body: t.Any(),
})
.patch("/product-attributes/definitions/:id/translations", async ({ params, body, status }) => {
try {
const id = parseId(params.id, "attribute definition ID");
const definition = await prisma.attributeDefinition.findUnique({ where: { id } });
if (!definition)
return status(404, { message: "Attribute definition not found" });
const payload = body;
const results = [];
for (const lang of SUPPORTED_LANGS) {
const item = payload.translations?.[lang]
|| ((payload.label?.[lang] || payload.description?.[lang]) ? { label: payload.label?.[lang], description: payload.description?.[lang] } : null);
if (!item?.label)
continue;
const existing = await prisma.attributeDefinitionTranslation.findUnique({
where: { attributeDefinitionId_langCode: { attributeDefinitionId: id, langCode: lang } },
});
const data = {
label: item.label,
description: item.description ?? null,
};
if (existing) {
results.push(await prisma.attributeDefinitionTranslation.update({
where: { id: existing.id },
data,
}));
}
else {
results.push(await prisma.attributeDefinitionTranslation.create({
data: {
attributeDefinitionId: id,
langCode: lang,
...data,
},
}));
}
}
if (results.length === 0)
return status(400, { message: "No valid translations provided" });
const updated = await prisma.attributeDefinition.findUnique({
where: { id },
include: { category: true, translations: true },
});
return { success: true, definition: updated, translations: results };
}
catch (err) {
return status(500, { message: err?.message || "Failed to update attribute definition translations" });
}
}, {
body: t.Any(),
})
.get("/products/:id/attributes", async ({ params, query, status }) => {
try {
const productId = parseId(params.id, "product ID");
const lang = query.lang || 'th';
const product = await prisma.product.findUnique({ where: { id: productId } });
if (!product)
return status(404, { message: "Product not found" });
const attributes = await prisma.productAttribute.findMany({
where: { productId },
include: {
translations: true,
attributeDefinition: {
include: {
category: true,
translations: true,
},
},
},
orderBy: [
{ attributeDefinition: { sortOrder: 'asc' } },
{ id: 'asc' },
],
});
return attributes.map((attribute) => localizeProductAttribute(attribute, lang));
}
catch (err) {
return status(400, { message: err.message });
}
})
.post("/products/:id/attributes", async ({ params, body, status }) => {
try {
const productId = parseId(params.id, "product ID");
const payload = body;
const attributeDefinitionId = Number(payload.attributeDefinitionId);
if (!attributeDefinitionId)
return status(400, { message: "attributeDefinitionId is required" });
const { definition } = await assertProductAndDefinitionMatch(productId, attributeDefinitionId);
const type = normalizeAttributeType(definition.type);
validateAttributeValue(type, payload);
if (type === 'SELECT')
validateSelectOption(definition.options, payload.valueText);
const attribute = await prisma.productAttribute.upsert({
where: { productId_attributeDefinitionId: { productId, attributeDefinitionId } },
update: {
valueText: payload.valueText ?? null,
valueNumber: payload.valueNumber ?? null,
valueBoolean: payload.valueBoolean ?? null,
valueJson: payload.valueJson ?? null,
},
create: {
productId,
attributeDefinitionId,
valueText: payload.valueText ?? null,
valueNumber: payload.valueNumber ?? null,
valueBoolean: payload.valueBoolean ?? null,
valueJson: payload.valueJson ?? null,
},
include: {
translations: true,
attributeDefinition: { include: { category: true, translations: true } },
},
});
return { success: true, attribute };
}
catch (err) {
const code = err.message === "Product not found" || err.message === "Attribute definition not found" ? 404 : 400;
return status(code, { message: err.message });
}
}, {
body: t.Any(),
})
.put("/products/:id/attributes", async ({ params, body, status }) => {
try {
const productId = parseId(params.id, "product ID");
const payload = body;
if (!Array.isArray(payload.attributes))
return status(400, { message: "attributes array is required" });
const product = await prisma.product.findUnique({ where: { id: productId } });
if (!product)
return status(404, { message: "Product not found" });
const existing = await prisma.productAttribute.findMany({
where: { productId },
select: { id: true, attributeDefinitionId: true },
});
const incomingDefinitionIds = payload.attributes.map((item) => Number(item.attributeDefinitionId)).filter(Boolean);
const toDelete = existing.filter((item) => !incomingDefinitionIds.includes(item.attributeDefinitionId));
if (toDelete.length > 0) {
await prisma.productAttribute.deleteMany({
where: { id: { in: toDelete.map((item) => item.id) } },
});
}
const results = [];
for (const item of payload.attributes) {
const attributeDefinitionId = Number(item.attributeDefinitionId);
const { definition } = await assertProductAndDefinitionMatch(productId, attributeDefinitionId);
const type = normalizeAttributeType(definition.type);
validateAttributeValue(type, item);
if (type === 'SELECT')
validateSelectOption(definition.options, item.valueText);
const attribute = await prisma.productAttribute.upsert({
where: { productId_attributeDefinitionId: { productId, attributeDefinitionId } },
update: {
valueText: item.valueText ?? null,
valueNumber: item.valueNumber ?? null,
valueBoolean: item.valueBoolean ?? null,
valueJson: item.valueJson ?? null,
},
create: {
productId,
attributeDefinitionId,
valueText: item.valueText ?? null,
valueNumber: item.valueNumber ?? null,
valueBoolean: item.valueBoolean ?? null,
valueJson: item.valueJson ?? null,
},
include: {
translations: true,
attributeDefinition: { include: { category: true, translations: true } },
},
});
if (type === 'TEXT' && item.translations && typeof item.translations === 'object') {
for (const lang of SUPPORTED_LANGS) {
const translatedValue = item.translations[lang];
if (typeof translatedValue !== 'string' || !translatedValue.trim())
continue;
await prisma.productAttributeTranslation.upsert({
where: { productAttributeId_langCode: { productAttributeId: attribute.id, langCode: lang } },
update: { valueText: translatedValue },
create: { productAttributeId: attribute.id, langCode: lang, valueText: translatedValue },
});
}
}
results.push(attribute);
}
const updated = await prisma.productAttribute.findMany({
where: { productId },
include: {
translations: true,
attributeDefinition: { include: { category: true, translations: true } },
},
orderBy: [
{ attributeDefinition: { sortOrder: 'asc' } },
{ id: 'asc' },
],
});
return { success: true, attributes: updated };
}
catch (err) {
const code = err.message === "Product not found" || err.message === "Attribute definition not found" ? 404 : 400;
return status(code, { message: err.message });
}
}, {
body: t.Any(),
})
.put("/products/:id/attributes/:productAttributeId", async ({ params, body, status }) => {
try {
const productId = parseId(params.id, "product ID");
const productAttributeId = parseId(params.productAttributeId, "product attribute ID");
const attribute = await prisma.productAttribute.findUnique({
where: { id: productAttributeId },
include: { attributeDefinition: true },
});
if (!attribute || attribute.productId !== productId) {
return status(404, { message: "Product attribute not found" });
}
const type = normalizeAttributeType(attribute.attributeDefinition.type);
const payload = body;
validateAttributeValue(type, payload);
if (type === 'SELECT')
validateSelectOption(attribute.attributeDefinition.options, payload.valueText);
const updated = await prisma.productAttribute.update({
where: { id: productAttributeId },
data: {
valueText: payload.valueText ?? null,
valueNumber: payload.valueNumber ?? null,
valueBoolean: payload.valueBoolean ?? null,
valueJson: payload.valueJson ?? null,
},
include: {
translations: true,
attributeDefinition: { include: { category: true, translations: true } },
},
});
return { success: true, attribute: updated };
}
catch (err) {
return status(400, { message: err.message });
}
}, {
body: t.Any(),
})
.patch("/products/:id/attributes/:productAttributeId/translations", async ({ params, body, status }) => {
try {
const productId = parseId(params.id, "product ID");
const productAttributeId = parseId(params.productAttributeId, "product attribute ID");
const attribute = await prisma.productAttribute.findUnique({
where: { id: productAttributeId },
include: { attributeDefinition: true, translations: true },
});
if (!attribute || attribute.productId !== productId) {
return status(404, { message: "Product attribute not found" });
}
const type = normalizeAttributeType(attribute.attributeDefinition.type);
if (type !== 'TEXT') {
return status(400, { message: "Only TEXT product attributes support translations in this phase" });
}
const payload = body;
const results = [];
for (const lang of SUPPORTED_LANGS) {
const valueText = payload.translations?.[lang] ?? payload.valueText?.[lang];
if (typeof valueText !== 'string' || !valueText.trim())
continue;
results.push(await prisma.productAttributeTranslation.upsert({
where: { productAttributeId_langCode: { productAttributeId, langCode: lang } },
update: { valueText },
create: { productAttributeId, langCode: lang, valueText },
}));
}
if (results.length === 0)
return status(400, { message: "No valid translations provided" });
const updated = await prisma.productAttribute.findUnique({
where: { id: productAttributeId },
include: {
translations: true,
attributeDefinition: { include: { category: true, translations: true } },
},
});
return { success: true, attribute: updated, translations: results };
}
catch (err) {
return status(400, { message: err.message });
}
}, {
body: t.Any(),
});
//# sourceMappingURL=product-attributes.js.map
@@ -0,0 +1 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AAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;IAC7E,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,yBAAyB,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAW,CAAC;QAC5B,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC;YACzD,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,IAAI,EAAE,sBAAsB,CAAC,OAAO,CAAC;YACrC,OAAO,EAAE;gBACP,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;aACnB;SACF,CAAC,CAAC;QAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACvC,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC,CAAC;QAC5F,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,0CAA0C,EAAE,CAAC,CAAC;QACtG,OAAO,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,IAAI,uCAAuC,EAAE,CAAC,CAAC;IAC3F,CAAC;AACH,CLine truncated
+41 -5
View File
@@ -1,6 +1,8 @@
import { Elysia } from "elysia";
export declare const productsRoute: Elysia<"/products", {
decorator: {};
decorator: {
validateVariants: (options?: any[], variants?: any[]) => void;
};
store: {};
derive: {};
resolve: {};
@@ -139,7 +141,7 @@ export declare const productsRoute: Elysia<"/products", {
};
500: {
readonly success: false;
readonly message: "Failed to update product";
readonly message: any;
};
};
};
@@ -182,7 +184,7 @@ export declare const productsRoute: Elysia<"/products", {
};
500: {
readonly success: false;
readonly message: "Failed to add product image";
readonly message: any;
};
};
};
@@ -203,7 +205,41 @@ export declare const productsRoute: Elysia<"/products", {
};
500: {
readonly success: false;
readonly message: "Failed to create product";
readonly message: any;
};
};
};
};
} & {
products: {
bulk: {
post: {
body: any[];
params: {};
query: unknown;
headers: unknown;
response: {
200: {
success: boolean;
products: any;
};
400: {
readonly success: false;
readonly message: "Payload must be an array of products";
};
422: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
};
500: {
readonly success: false;
readonly message: any;
};
};
};
};
@@ -237,7 +273,7 @@ export declare const productsRoute: Elysia<"/products", {
};
500: {
readonly success: false;
readonly message: "Failed to patch product";
readonly message: any;
};
};
};
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAK,MAAM,QAAQ,CAAC;AAGnC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2bvB,CAAC"}
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAK,MAAM,QAAQ,CAAC;AAInC,eAAO,MAAM,aAAa;;qCACgB,GAAG,EAAE,aAAiB,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4tBlE,CAAC"}
+339 -61
View File
@@ -1,6 +1,41 @@
import { Elysia, t } from "elysia";
import prisma from "../lib/prisma";
import { localizeProductAttribute } from "../lib/productAttributes";
export const productsRoute = new Elysia({ prefix: "/products" })
.decorate("validateVariants", (options = [], variants = []) => {
if (options.length > 3)
throw new Error("Options array length cannot exceed 3.");
const getPrimaryValues = (values) => {
return values.map(val => {
if (typeof val === 'string')
return val;
if (typeof val === 'object' && val !== null) {
return val.th || Object.values(val)[0];
}
return String(val);
});
};
for (const v of variants) {
if (v.option1 && options[0]) {
const validValues = getPrimaryValues(options[0].values);
if (!validValues.includes(v.option1)) {
throw new Error(`Variant option1 '${v.option1}' is not found in options[0].values [${validValues.join(', ')}]`);
}
}
if (v.option2 && options[1]) {
const validValues = getPrimaryValues(options[1].values);
if (!validValues.includes(v.option2)) {
throw new Error(`Variant option2 '${v.option2}' is not found in options[1].values [${validValues.join(', ')}]`);
}
}
if (v.option3 && options[2]) {
const validValues = getPrimaryValues(options[2].values);
if (!validValues.includes(v.option3)) {
throw new Error(`Variant option3 '${v.option3}' is not found in options[2].values [${validValues.join(', ')}]`);
}
}
}
})
.get("/brands", async () => {
return await prisma.productBrand.findMany({
orderBy: { name: "asc" },
@@ -68,6 +103,21 @@ export const productsRoute = new Elysia({ prefix: "/products" })
category: { include: { translations: true } },
brand: true,
translations: true,
attributes: {
include: {
translations: true,
attributeDefinition: {
include: {
category: true,
translations: true,
},
},
},
orderBy: [
{ attributeDefinition: { sortOrder: "asc" } },
{ id: "asc" },
],
},
variants: {
include: {
bomItems: { include: { rawMaterial: true } }
@@ -82,27 +132,35 @@ export const productsRoute = new Elysia({ prefix: "/products" })
prisma.product.count({ where }),
]);
// Map translations
const mappedProducts = products.map(p => {
const mappedProducts = products.map((p) => {
if (lang === 'all') {
const nameObj = {};
const descObj = {};
const detailsObj = {};
p.translations.forEach(t => {
p.translations.forEach((t) => {
nameObj[t.langCode] = t.name;
descObj[t.langCode] = t.description;
detailsObj[t.langCode] = t.details;
});
return { ...p, name: nameObj, description: descObj, details: detailsObj, category: { ...p.category, name: p.category.name } }; // Actually for 'all', keep as is, but wait, category name needs resolving if we want it? Let's just resolve it simply below.
return {
...p,
name: nameObj,
description: descObj,
details: detailsObj,
category: { ...p.category, name: p.category.name },
attributes: p.attributes.map((attribute) => localizeProductAttribute(attribute, lang)),
};
}
else {
const trans = p.translations.find(t => t.langCode === lang) || p.translations.find(t => t.langCode === 'th') || p.translations[0];
const trans = p.translations.find((t) => t.langCode === lang) || p.translations.find((t) => t.langCode === 'th') || p.translations[0];
const catTrans = p.category.translations?.find((t) => t.langCode === lang) || p.category.translations?.find((t) => t.langCode === 'th') || p.category.translations?.[0];
return {
...p,
name: trans?.name || p.name || '',
description: trans?.description || p.description,
details: trans?.details || p.details,
category: { ...p.category, name: catTrans?.name || p.category.name }
category: { ...p.category, name: catTrans?.name || p.category.name },
attributes: p.attributes.map((attribute) => localizeProductAttribute(attribute, lang)),
};
}
});
@@ -132,6 +190,21 @@ export const productsRoute = new Elysia({ prefix: "/products" })
category: { include: { translations: true } },
brand: true,
translations: true,
attributes: {
include: {
translations: true,
attributeDefinition: {
include: {
category: true,
translations: true,
},
},
},
orderBy: [
{ attributeDefinition: { sortOrder: "asc" } },
{ id: "asc" },
],
},
variants: {
include: {
bomItems: { include: { rawMaterial: true } }
@@ -147,31 +220,47 @@ export const productsRoute = new Elysia({ prefix: "/products" })
const nameObj = {};
const descObj = {};
const detailsObj = {};
product.translations.forEach(t => {
product.translations.forEach((t) => {
nameObj[t.langCode] = t.name;
descObj[t.langCode] = t.description;
detailsObj[t.langCode] = t.details;
});
return { ...product, name: nameObj, description: descObj, details: detailsObj };
return {
...product,
name: nameObj,
description: descObj,
details: detailsObj,
attributes: product.attributes.map((attribute) => localizeProductAttribute(attribute, lang)),
};
}
else {
const trans = product.translations.find(t => t.langCode === lang) || product.translations.find(t => t.langCode === 'th') || product.translations[0];
const trans = product.translations.find((t) => t.langCode === lang) || product.translations.find((t) => t.langCode === 'th') || product.translations[0];
const catTrans = product.category.translations?.find((t) => t.langCode === lang) || product.category.translations?.find((t) => t.langCode === 'th') || product.category.translations?.[0];
return {
...product,
name: trans?.name || product.name || '',
description: trans?.description || product.description,
details: trans?.details || product.details,
category: { ...product.category, name: catTrans?.name || product.category.name }
category: { ...product.category, name: catTrans?.name || product.category.name },
attributes: product.attributes.map((attribute) => localizeProductAttribute(attribute, lang)),
};
}
})
.put("/:id", async ({ params, body, status }) => {
.put("/:id", async ({ params, body, status, validateVariants }) => {
const id = parseInt(params.id);
if (isNaN(id))
return status(400, { message: "Invalid product ID" });
const { categoryId, description, details, variants, images } = body;
let options = body.options;
try {
if (variants && Array.isArray(variants)) {
// If options is not passed but variants are, we might need to fetch existing options
if (options === undefined) {
const existingProduct = await prisma.product.findUnique({ where: { id } });
options = existingProduct?.options || [];
}
validateVariants(options, variants);
}
const updatedProduct = await prisma.$transaction(async (tx) => {
// 1. Update basic product info
const updateData = {};
@@ -184,45 +273,97 @@ export const productsRoute = new Elysia({ prefix: "/products" })
data: updateData,
});
// 2. Sync Variants
await tx.productVariant.deleteMany({
where: { productId: id },
});
if (variants && variants.length > 0) {
for (const v of variants) {
await tx.productVariant.create({
data: {
productId: id,
sku: v.sku || null,
barcode: v.barcode || null,
stock: v.stock || 0,
option1: v.option1 || "",
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price || 0,
bomItems: v.bomItems && v.bomItems.length > 0 ? {
create: v.bomItems.map((b) => ({
rawMaterialId: b.rawMaterialId,
quantity: b.quantity,
}))
} : undefined
}
if (variants && Array.isArray(variants)) {
const existingVariants = await tx.productVariant.findMany({ where: { productId: id } });
const incomingIds = variants.map((v) => v.id).filter(Boolean);
// Delete variants not in incoming payload
const variantsToDelete = existingVariants.filter(ev => !incomingIds.includes(ev.id));
if (variantsToDelete.length > 0) {
await tx.productVariant.deleteMany({
where: { id: { in: variantsToDelete.map(ev => ev.id) } }
});
}
for (const v of variants) {
if (v.id) {
// Check if it really belongs to this product
const exists = existingVariants.find(ev => ev.id === v.id);
if (exists) {
await tx.productVariant.update({
where: { id: v.id },
data: {
sku: v.sku || null,
barcode: v.barcode || null,
stock: v.stock || 0,
option1: v.option1 || "",
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price || 0,
bomItems: v.bomItems ? {
deleteMany: {},
create: v.bomItems.map((b) => ({
rawMaterialId: b.rawMaterialId,
quantity: b.quantity,
}))
} : undefined
}
});
}
}
else {
await tx.productVariant.create({
data: {
productId: id,
sku: v.sku || null,
barcode: v.barcode || null,
stock: v.stock || 0,
option1: v.option1 || "",
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price || 0,
bomItems: v.bomItems && v.bomItems.length > 0 ? {
create: v.bomItems.map((b) => ({
rawMaterialId: b.rawMaterialId,
quantity: b.quantity,
}))
} : undefined
}
});
}
}
}
// 3. Sync Images
await tx.productImage.deleteMany({
where: { productId: id },
});
if (images && images.length > 0) {
for (const [idx, img] of images.entries()) {
await tx.productImage.create({
data: {
productId: id,
url: img.url,
order: img.order ?? (typeof img.order === 'number' ? img.order : idx),
}
if (images && Array.isArray(images)) {
const existingImages = await tx.productImage.findMany({ where: { productId: id } });
const incomingImgIds = images.map((img) => img.id).filter(Boolean);
const imagesToDelete = existingImages.filter(ei => !incomingImgIds.includes(ei.id));
if (imagesToDelete.length > 0) {
await tx.productImage.deleteMany({
where: { id: { in: imagesToDelete.map(ei => ei.id) } }
});
}
for (const [idx, img] of images.entries()) {
if (img.id) {
const exists = existingImages.find(ei => ei.id === img.id);
if (exists) {
await tx.productImage.update({
where: { id: img.id },
data: {
url: img.url,
order: img.order ?? (typeof img.order === 'number' ? img.order : idx),
}
});
}
}
else {
await tx.productImage.create({
data: {
productId: id,
url: img.url,
order: img.order ?? (typeof img.order === 'number' ? img.order : idx),
}
});
}
}
}
return prod;
});
@@ -230,7 +371,7 @@ export const productsRoute = new Elysia({ prefix: "/products" })
}
catch (err) {
console.error("Update product error:", err);
return status(500, { success: false, message: "Failed to update product" });
return status(500, { success: false, message: err?.message || "Failed to update product" });
}
}, {
body: t.Any(),
@@ -264,37 +405,70 @@ export const productsRoute = new Elysia({ prefix: "/products" })
}
catch (err) {
console.error("Add product image error:", err);
return status(500, { success: false, message: "Failed to add product image" });
return status(500, { success: false, message: err?.message || "Failed to add product image" });
}
}, {
body: t.Object({
url: t.String()
})
})
.post("/", async ({ body, status }) => {
.post("/", async ({ body, status, validateVariants }) => {
const payload = body;
try {
if (payload.variants && Array.isArray(payload.variants)) {
validateVariants(payload.options || [], payload.variants);
}
const product = await prisma.$transaction(async (tx) => {
let categoryId = payload.categoryId;
if (!categoryId && payload.categoryName) {
let cat = await tx.category.findUnique({ where: { name: payload.categoryName } });
if (!cat) {
cat = await tx.category.create({ data: { name: payload.categoryName } });
}
categoryId = cat.id;
}
let brandId = payload.brandId;
if (!brandId && payload.brandName) {
let brand = await tx.productBrand.findUnique({ where: { name: payload.brandName } });
if (!brand) {
brand = await tx.productBrand.create({ data: { name: payload.brandName } });
}
brandId = brand.id;
}
const prod = await tx.product.create({
data: {
categoryId: payload.categoryId,
brandId: payload.brandId,
categoryId: categoryId,
brandId: brandId,
name: payload.name || "New Product",
price: payload.price || 0,
description: payload.description || "",
details: payload.details || "",
options: payload.options || [],
}
});
await tx.productTranslation.create({
data: {
productId: prod.id,
langCode: 'th',
name: payload.name || "New Product",
description: payload.description || "",
details: payload.details || "",
if (payload.translations && typeof payload.translations === 'object') {
for (const [lang, trans] of Object.entries(payload.translations)) {
await tx.productTranslation.create({
data: {
productId: prod.id,
langCode: lang,
name: trans.name || payload.name || "New Product",
description: trans.description || payload.description || "",
details: trans.details || payload.details || "",
}
});
}
});
}
else {
await tx.productTranslation.create({
data: {
productId: prod.id,
langCode: 'th',
name: payload.name || "New Product",
description: payload.description || "",
details: payload.details || "",
}
});
}
if (payload.variants && payload.variants.length > 0) {
for (const v of payload.variants) {
await tx.productVariant.create({
@@ -328,7 +502,7 @@ export const productsRoute = new Elysia({ prefix: "/products" })
}
catch (err) {
console.error("Create product error:", err);
return status(500, { success: false, message: "Failed to create product" });
return status(500, { success: false, message: err?.message || "Failed to create product" });
}
}, {
body: t.Any(),
@@ -336,6 +510,112 @@ export const productsRoute = new Elysia({ prefix: "/products" })
summary: "Create Product",
tags: ["products"],
},
})
.post("/bulk", async ({ body, status, validateVariants }) => {
const payloadArray = body;
if (!Array.isArray(payloadArray)) {
return status(400, { success: false, message: "Payload must be an array of products" });
}
try {
const createdProducts = await prisma.$transaction(async (tx) => {
const results = [];
for (const payload of payloadArray) {
if (payload.variants && Array.isArray(payload.variants)) {
validateVariants(payload.options || [], payload.variants);
}
let categoryId = payload.categoryId;
if (!categoryId && payload.categoryName) {
let cat = await tx.category.findUnique({ where: { name: payload.categoryName } });
if (!cat) {
cat = await tx.category.create({ data: { name: payload.categoryName } });
}
categoryId = cat.id;
}
let brandId = payload.brandId;
if (!brandId && payload.brandName) {
let brand = await tx.productBrand.findUnique({ where: { name: payload.brandName } });
if (!brand) {
brand = await tx.productBrand.create({ data: { name: payload.brandName } });
}
brandId = brand.id;
}
const prod = await tx.product.create({
data: {
categoryId: categoryId,
brandId: brandId,
name: payload.name || "New Product",
description: payload.description || "",
details: payload.details || "",
options: payload.options || [],
}
});
if (payload.translations && typeof payload.translations === 'object') {
for (const [lang, trans] of Object.entries(payload.translations)) {
await tx.productTranslation.create({
data: {
productId: prod.id,
langCode: lang,
name: trans.name || payload.name || "New Product",
description: trans.description || payload.description || "",
details: trans.details || payload.details || "",
}
});
}
}
else {
await tx.productTranslation.create({
data: {
productId: prod.id,
langCode: 'th',
name: payload.name || "New Product",
description: payload.description || "",
details: payload.details || "",
}
});
}
if (payload.variants && payload.variants.length > 0) {
for (const v of payload.variants) {
await tx.productVariant.create({
data: {
productId: prod.id,
sku: v.sku || null,
barcode: v.barcode || null,
stock: v.stock || 0,
option1: v.option1 || "",
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price || 0,
}
});
}
}
if (payload.images && payload.images.length > 0) {
for (const [idx, img] of payload.images.entries()) {
await tx.productImage.create({
data: {
productId: prod.id,
url: img.url,
order: img.order ?? idx,
}
});
}
}
results.push(prod);
}
return results;
});
return { success: true, products: createdProducts };
}
catch (err) {
console.error("Bulk create products error:", err);
return status(500, { success: false, message: err?.message || "Failed to bulk create products" });
}
}, {
body: t.Array(t.Any()),
detail: {
summary: "Bulk Create Products",
tags: ["products"],
},
})
.patch("/:id", async ({ params, body, status }) => {
const id = parseInt(params.id);
@@ -348,8 +628,6 @@ export const productsRoute = new Elysia({ prefix: "/products" })
prodData.categoryId = payload.categoryId;
if (payload.brandId !== undefined)
prodData.brandId = payload.brandId;
if (payload.price !== undefined)
prodData.price = payload.price;
if (payload.options !== undefined)
prodData.options = payload.options;
const prod = await prisma.product.update({
@@ -412,7 +690,7 @@ export const productsRoute = new Elysia({ prefix: "/products" })
}
catch (err) {
console.error("Patch product error:", err);
return status(500, { success: false, message: "Failed to patch product" });
return status(500, { success: false, message: err?.message || "Failed to patch product" });
}
}, {
body: t.Any(),
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"products.js","sourceRoot":"","sources":["products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,MAAM,MAAM,eAAe,CAAC;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;KAC7D,GAAG,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACzB,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;QACxC,OAAO,EAAE,EAAE,IAAI,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C;IAEX,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YACtB,KAAK;YACL,OAAO,EAAE;gBACP,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE;gBAC7C,KAAK,EAAE,IAAI;gBACX,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE;oBACV,OAAO,EAAE;wBACP,YAAY,EAAE,IAAI;wBAClB,mBAAmB,EAAE;Line truncated
-3
View File
@@ -465,7 +465,6 @@ export const productsRoute = new Elysia({ prefix: "/products" })
categoryId: categoryId,
brandId: brandId,
name: payload.name || "New Product",
price: payload.price || 0,
description: payload.description || "",
details: payload.details || "",
options: payload.options || [],
@@ -582,7 +581,6 @@ export const productsRoute = new Elysia({ prefix: "/products" })
categoryId: categoryId,
brandId: brandId,
name: payload.name || "New Product",
price: payload.price || 0,
description: payload.description || "",
details: payload.details || "",
options: payload.options || [],
@@ -671,7 +669,6 @@ export const productsRoute = new Elysia({ prefix: "/products" })
const prodData: any = {};
if (payload.categoryId !== undefined) prodData.categoryId = payload.categoryId;
if (payload.brandId !== undefined) prodData.brandId = payload.brandId;
if (payload.price !== undefined) prodData.price = payload.price;
if (payload.options !== undefined) prodData.options = payload.options;
const prod = await prisma.product.update({
+2 -2
View File
@@ -54,8 +54,8 @@ export declare const promotionsRoute: Elysia<"/promotions", {
type: string;
isActive: boolean;
value: number;
minPurchase: number;
level: number;
minPurchase: number;
};
params: {};
query: unknown;
@@ -78,8 +78,8 @@ export declare const promotionsRoute: Elysia<"/promotions", {
type: string;
isActive: boolean;
value: number;
minPurchase: number;
level: number;
minPurchase: number;
};
params: {
id: string;
+1 -1
View File
@@ -1 +1 @@
{"root":["./check_cat.ts","./prisma.config.ts","./prisma/seed-pages.ts","./scripts/fix-menus.ts","./scripts/fix-scent-guide.ts","./scripts/migrate-i18n.ts","./scripts/migrate-pages.ts","./scripts/migrate-production.ts","./src/index.ts","./src/lib/lineClient.ts","./src/lib/notifications.ts","./src/lib/prisma.ts","./src/middleware/auth.ts","./src/routes/articles.ts","./src/routes/auth.ts","./src/routes/categories.ts","./src/routes/contacts.ts","./src/routes/coupons.ts","./src/routes/customers.ts","./src/routes/hero.d.ts","./src/routes/lazadaOrder.ts","./src/routes/line.ts","./src/routes/media.ts","./src/routes/menus.ts","./src/routes/newsletter.ts","./src/routes/orders.ts","./src/routes/pages.ts","./src/routes/payments.ts","./src/routes/products.ts","./src/routes/profile.ts","./src/routes/promotions.ts","./src/routes/raw-materials.ts","./src/routes/reviews.ts","./src/routes/settings.ts","./src/routes/shopee.ts","./src/routes/tiktok.ts","./src/routes/tiktokOrder.ts","./src/routes/upload.ts"],"errors":true,"version":"6.0.3"}
{"root":["./check_cat.ts","./delete_products.ts","./prisma.config.ts","./query.ts","./scratch_seed_product.ts","./scratch_test.ts","./scratch_test_langs.ts","./scratch_test_menus.ts","./scratch_test_page.ts","./scratch_test_page2.ts","./prisma/seed-pages.ts","./scripts/fix-menus.ts","./scripts/fix-scent-guide.ts","./scripts/migrate-i18n.ts","./scripts/migrate-pages.ts","./scripts/migrate-production.ts","./src/index.ts","./src/lib/lineClient.ts","./src/lib/notifications.ts","./src/lib/prisma.ts","./src/lib/productAttributes.ts","./src/middleware/auth.ts","./src/routes/articles.ts","./src/routes/auth.ts","./src/routes/categories.ts","./src/routes/contacts.ts","./src/routes/coupons.ts","./src/routes/customers.ts","./src/routes/hero.d.ts","./src/routes/lazadaOrder.ts","./src/routes/line.ts","./src/routes/media.ts","./src/routes/menus.ts","./src/routes/newsletter.ts","./src/routes/orders.ts","./src/routes/pages.ts","./src/routes/payments.ts","./src/routes/product-attributes.ts","./src/routes/products.ts","./src/routes/profile.ts","./src/routes/promotions.ts","./src/routes/raw-materials.ts","./src/routes/reviews.ts","./src/routes/settings.ts","./src/routes/shopee.ts","./src/routes/tiktok.ts","./src/routes/tiktokOrder.ts","./src/routes/upload.ts"],"errors":true,"version":"6.0.3"}
-2
View File
@@ -266,7 +266,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
name: { type: "string" },
description: { type: "string" },
details: { type: "string" },
price: { type: "number", description: "Base price if no variants are provided" },
translations: {
type: "object",
description: "Object with lang codes as keys (e.g. 'th', 'en') and {name, description, details} as values",
@@ -340,7 +339,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
name: { type: "string" },
description: { type: "string" },
details: { type: "string" },
price: { type: "number" },
translations: {
type: "object",
additionalProperties: {
+2 -2
View File
@@ -111,7 +111,7 @@ export default function ProductCard({ product, enableQuickShop = false, category
<div className="mt-auto flex flex-col gap-2 pt-3">
<div className="flex items-center justify-between">
<span className="text-sm font-black text-pop-pink md:text-lg">
{formatPrice(selectedVariant?.price ?? product.variants?.[0]?.price ?? product.price)}
{formatPrice(selectedVariant?.price ?? product.variants?.[0]?.price ?? 0)}
</span>
{!enableQuickShop && (
<span className="flex items-center gap-1 text-[10px] font-bold uppercase tracking-widest text-pop-black transition-transform group-hover:translate-x-1 group-hover:text-pop-pink md:text-xs">
@@ -134,7 +134,7 @@ export default function ProductCard({ product, enableQuickShop = false, category
productId: product.id,
variantId: targetVariant.id,
quantity: 1,
price: targetVariant.price || product.price || 0,
price: targetVariant.price || 0,
productName: displayName,
variantName: [targetVariant.option1, targetVariant.option2, targetVariant.option3].filter(Boolean).map(opt => resolveOptionValue(opt, product.options, i18n.language)).join(' / '),
productImage: product.images?.[0]?.url || getCategoryImage(displayCategoryName)
+1 -1
View File
@@ -163,7 +163,7 @@ export default function ProductDetailPage() {
productId: product.id,
variantId: currentVariant.id,
quantity: 1,
price: currentVariant.price || product.price || 0,
price: currentVariant.price || 0,
productName: displayName,
variantName: [currentVariant.option1, currentVariant.option2, currentVariant.option3].filter(Boolean).map(opt => resolveOptionValue(opt, product.options, i18n.language)).join(' / '),
productImage: product.images?.[0]?.url || getCategoryImage(typeof product.category.name === 'string' ? product.category.name : (product.category.name as any)?.en || '')
@@ -99,7 +99,7 @@ export default function AddToCartSection({ product }: Props) {
productId: product.id,
variantId: currentVariant.id,
quantity: 1,
price: currentVariant.price || product.price || 0,
price: currentVariant.price || 0,
productName,
variantName: variantName || undefined,
productImage: product.images?.[0]?.url || product.category.imageUrl || getCategoryImage(categoryName),
@@ -133,7 +133,7 @@ export default function AddToCartSection({ product }: Props) {
<div className="flex items-baseline gap-3">
<span className="text-4xl font-bold text-brand-primary">
{formatPrice(currentVariant?.price ?? product.price)}
{formatPrice(currentVariant?.price ?? 0)}
</span>
{currentVariantName && <span className="text-sm text-muted-text">/ {currentVariantName}</span>}
</div>
@@ -215,7 +215,7 @@ export default function AddToCartSection({ product }: Props) {
<span className="text-[10px] font-bold uppercase tracking-widest text-muted-text/70">
{currentVariantName || 'Total Price'}
</span>
<span className="text-xl font-bold text-brand-primary">{formatPrice(currentVariant?.price ?? product.price)}</span>
<span className="text-xl font-bold text-brand-primary">{formatPrice(currentVariant?.price ?? 0)}</span>
</div>
<button
onClick={handleAddToCart}
+3 -3
View File
@@ -23,7 +23,7 @@ export default function ProductCard({ product }: ProductCardProps) {
const categoryName = resolveCategoryName(product.category, lang)
const productName = resolveLocalized(product.name, lang) || product.brand.name
const imageUrl = product.images?.[0]?.url || product.category.imageUrl || getCategoryImage(categoryName)
const displayPrice = selectedVariant?.price ?? product.variants[0]?.price ?? product.price
const displayPrice = selectedVariant?.price ?? product.variants[0]?.price ?? 0
const addToCartLabels: Record<string, string> = {
th: 'เพิ่มลงตะกร้า',
@@ -100,7 +100,7 @@ export default function ProductCard({ product }: ProductCardProps) {
<div className="mt-auto flex flex-col gap-2 pt-3">
<div className="flex items-center justify-between">
<span className="text-sm font-black text-brand-primary md:text-lg">
{formatPrice(selectedVariant?.price ?? product.variants?.[0]?.price ?? product.price)}
{formatPrice(selectedVariant?.price ?? product.variants?.[0]?.price ?? 0)}
</span>
</div>
@@ -125,7 +125,7 @@ export default function ProductCard({ product }: ProductCardProps) {
productId: product.id,
variantId: targetVariant.id,
quantity: 1,
price: targetVariant.price || product.price || 0,
price: targetVariant.price || 0,
productName: productName,
variantName: [targetVariant.option1, targetVariant.option2, targetVariant.option3].filter(Boolean).join(' / '),
productImage: imageUrl