UNPKG

@backstageai/common

Version:

Common code for Backstage AI services

48 lines (44 loc) 1.7 kB
// models/CustomProduct.js const mongoose = require("mongoose"); const ElementSchema = new mongoose.Schema( { type: { type: String, enum: ["image", "text"], required: true }, content: { type: String, required: true }, // image URL or text content x: { type: Number, default: 0 }, y: { type: Number, default: 0 }, scale: { type: Number, default: 1 }, rotation: { type: Number, default: 0 }, backgroundRemoved: { type: Boolean, default: false }, }, { _id: true } ); const CustomProductSchema = new mongoose.Schema( { template: { type: mongoose.Schema.Types.ObjectId, ref: "ProductTemplate", required: true, }, userId: { type: mongoose.Schema.Types.ObjectId, required: true }, // owner of the custom product elements: [ElementSchema], // design elements (images/text) status: { type: String, enum: ["draft", "finalized", "published"], default: "draft", }, printifyProductId: { type: String }, // ID from Printify after finalization (stubbed) shopifyProductId: { type: String }, // ID from Shopify after publishing (stubbed) marketplaceListingId: { type: String }, // ID from marketplace after publishing (stubbed) publishedToShopify: { type: Boolean, default: false }, publishedToMarketplace: { type: Boolean, default: false }, shareToken: { type: String }, // token for shareable link (generated on share) previewImage: { type: String }, // URL of generated preview image (if any) }, { timestamps: true } ); const UserCustomProduct = mongoose.model( "UserCustomProduct", CustomProductSchema, "userCustomProducts" ); exports.UserCustomProduct = UserCustomProduct;