"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const sequelize_1=require("sequelize");class nftListing extends sequelize_1.Model{static initModel(e){return nftListing.init({id:{type:sequelize_1.DataTypes.UUID,defaultValue:sequelize_1.DataTypes.UUIDV4,primaryKey:!0,allowNull:!1},tokenId:{type:sequelize_1.DataTypes.UUID,allowNull:!1,validate:{notNull:{msg:"tokenId: Token ID cannot be null"},isUUID:{args:4,msg:"tokenId: Token ID must be a valid UUID"}}},sellerId:{type:sequelize_1.DataTypes.UUID,allowNull:!1,validate:{notNull:{msg:"sellerId: Seller ID cannot be null"},isUUID:{args:4,msg:"sellerId: Seller ID must be a valid UUID"}}},type:{type:sequelize_1.DataTypes.ENUM("FIXED_PRICE","AUCTION","BUNDLE"),allowNull:!1,defaultValue:"FIXED_PRICE",validate:{isIn:{args:[["FIXED_PRICE","AUCTION","BUNDLE"]],msg:"type: Type must be one of 'FIXED_PRICE', 'AUCTION', or 'BUNDLE'"}}},price:{type:sequelize_1.DataTypes.DECIMAL(36,18),allowNull:!0,validate:{min:{args:[0],msg:"price: Price must be non-negative"}}},currency:{type:sequelize_1.DataTypes.STRING(10),allowNull:!1,defaultValue:"ETH",validate:{notEmpty:{msg:"currency: Currency must not be empty"}}},currentBid:{type:sequelize_1.DataTypes.DECIMAL(36,18),allowNull:!0,validate:{min:{args:[0],msg:"currentBid: Current bid must be non-negative"}}},startingBid:{type:sequelize_1.DataTypes.DECIMAL(36,18),allowNull:!0,validate:{min:{args:[0],msg:"startingBid: Starting bid must be non-negative"}}},reservePrice:{type:sequelize_1.DataTypes.DECIMAL(36,18),allowNull:!0,validate:{min:{args:[0],msg:"reservePrice: Reserve price must be non-negative"}}},minBidIncrement:{type:sequelize_1.DataTypes.DECIMAL(36,18),allowNull:!0,validate:{min:{args:[0],msg:"minBidIncrement: Minimum bid increment must be non-negative"}}},buyNowPrice:{type:sequelize_1.DataTypes.DECIMAL(36,18),allowNull:!0,validate:{min:{args:[0],msg:"buyNowPrice: Buy now price must be non-negative"}}},auctionContractAddress:{type:sequelize_1.DataTypes.STRING(255),allowNull:!0},bundleTokenIds:{type:sequelize_1.DataTypes.TEXT,allowNull:!0},startTime:{type:sequelize_1.DataTypes.DATE,allowNull:!0},endTime:{type:sequelize_1.DataTypes.DATE,allowNull:!0},status:{type:sequelize_1.DataTypes.ENUM("ACTIVE","SOLD","CANCELLED","EXPIRED"),allowNull:!1,defaultValue:"ACTIVE",validate:{isIn:{args:[["ACTIVE","SOLD","CANCELLED","EXPIRED"]],msg:"status: Status must be one of 'ACTIVE', 'SOLD', 'CANCELLED', or 'EXPIRED'"}}},soldAt:{type:sequelize_1.DataTypes.DATE,allowNull:!0},cancelledAt:{type:sequelize_1.DataTypes.DATE,allowNull:!0},endedAt:{type:sequelize_1.DataTypes.DATE,allowNull:!0},views:{type:sequelize_1.DataTypes.INTEGER,allowNull:!1,defaultValue:0,validate:{min:{args:[0],msg:"views: Views must be non-negative"}}},likes:{type:sequelize_1.DataTypes.INTEGER,allowNull:!1,defaultValue:0,validate:{min:{args:[0],msg:"likes: Likes must be non-negative"}}},metadata:{type:sequelize_1.DataTypes.JSON,allowNull:!0,get(){const e=this.getDataValue("metadata");return e?JSON.parse(e):null},set(e){this.setDataValue("metadata",JSON.stringify(e))}}},{sequelize:e,modelName:"nftListing",tableName:"nft_listing",timestamps:!0,paranoid:!0,indexes:[{name:"PRIMARY",unique:!0,using:"BTREE",fields:[{name:"id"}]},{name:"nftListingTokenIdx",using:"BTREE",fields:[{name:"tokenId"}]},{name:"nftListingSellerIdx",using:"BTREE",fields:[{name:"sellerId"}]},{name:"nftListingStatusIdx",using:"BTREE",fields:[{name:"status"}]},{name:"nftListingTypeIdx",using:"BTREE",fields:[{name:"type"}]},{name:"nftListingPriceIdx",using:"BTREE",fields:[{name:"price"}]}]})}static associate(e){nftListing.belongsTo(e.nftToken,{as:"token",foreignKey:"tokenId",onDelete:"CASCADE",onUpdate:"CASCADE"});nftListing.belongsTo(e.user,{as:"seller",foreignKey:"sellerId",onDelete:"CASCADE",onUpdate:"CASCADE"});nftListing.hasMany(e.nftBid,{as:"bids",foreignKey:"listingId",onDelete:"CASCADE",onUpdate:"CASCADE"});nftListing.hasMany(e.nftOffer,{as:"offers",foreignKey:"listingId",onDelete:"CASCADE",onUpdate:"CASCADE"});nftListing.hasMany(e.nftActivity,{as:"activities",foreignKey:"listingId",onDelete:"CASCADE",onUpdate:"CASCADE"})}}exports.default=nftListing;