import mongoose, { Schema, model } from "mongoose"; import { IShipmentCost, IShipmentProviders } from "./Abstraction/IShipmentProviders"; import { DeliveryType } from "../../../common/enums/shipment.enum"; // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports const AutoIncrement = require("mongoose-sequence")(mongoose); const ShipmentCostSchema = new Schema( { weightRange: { min: { type: Number, required: true }, max: { type: Number, required: true }, }, cost_first: { type: Number, required: true }, cost_rest: { type: Number, required: true }, }, { _id: false }, ); const ShipmentSchema = new Schema( { _id: Number, name: { type: String, unique: true, required: true }, description: String, // availableShippingDays: { type: [String], require: true }, costs: [ShipmentCostSchema], deliveryType: { type: String, enum: DeliveryType, required: true }, deliveryTime: { type: Number, required: true }, payDeliveryFeeOnDelivery: { type: Boolean, default: false }, deleted: { type: Boolean, default: false }, }, { timestamps: true, toJSON: { versionKey: false }, _id: false, id: false }, ); ShipmentSchema.plugin(AutoIncrement, { id: "shipment_id", inc_field: "_id", start_seq: 100 }); const ShipmentModel = model("Shipment", ShipmentSchema); export { ShipmentModel, IShipmentProviders };