2023-06-14 02:26:19 +02:00
|
|
|
import { Model, Schema, Types, model } from "mongoose";
|
2023-09-05 07:37:30 -05:00
|
|
|
import {
|
|
|
|
IFlavourItem,
|
|
|
|
IRawUpgrade,
|
|
|
|
IMiscItem,
|
|
|
|
IInventoryDatabase,
|
|
|
|
IBooster
|
|
|
|
} from "../types/inventoryTypes/inventoryTypes";
|
|
|
|
import { IOid } from "../types/commonTypes";
|
2023-09-06 14:02:54 +04:00
|
|
|
import { ISuitDatabase } from "@/src/types/inventoryTypes/SuitTypes";
|
2023-06-14 02:26:19 +02:00
|
|
|
import { IWeaponDatabase } from "@/src/types/inventoryTypes/weaponTypes";
|
2023-06-04 03:06:22 +02:00
|
|
|
|
|
|
|
const abilityOverrideSchema = new Schema({
|
|
|
|
Ability: String,
|
|
|
|
Index: Number
|
|
|
|
});
|
|
|
|
const colorSchema = new Schema({
|
|
|
|
t0: Number,
|
|
|
|
t1: Number,
|
|
|
|
t2: Number,
|
|
|
|
t3: Number,
|
|
|
|
en: Number,
|
|
|
|
e1: Number,
|
|
|
|
m0: Number,
|
|
|
|
m1: Number
|
|
|
|
});
|
|
|
|
|
2023-06-14 02:26:19 +02:00
|
|
|
const longGunConfigSchema = new Schema({
|
|
|
|
Skins: [String],
|
|
|
|
pricol: colorSchema,
|
|
|
|
attcol: colorSchema,
|
|
|
|
eyecol: colorSchema,
|
|
|
|
sigcol: colorSchema,
|
|
|
|
Upgrades: [String],
|
|
|
|
Songs: [
|
|
|
|
{
|
|
|
|
m: String,
|
|
|
|
b: String,
|
|
|
|
p: String,
|
|
|
|
s: String
|
|
|
|
}
|
|
|
|
],
|
|
|
|
Name: String,
|
|
|
|
AbilityOverride: abilityOverrideSchema,
|
|
|
|
PvpUpgrades: [String],
|
|
|
|
ugly: Boolean
|
|
|
|
});
|
|
|
|
|
|
|
|
// longGunConfigSchema.set("toJSON", {
|
|
|
|
// transform(_document, returnedObject: ISuitDocument) {
|
|
|
|
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
|
|
// returnedObject.ItemId = { $oid: returnedObject._id.toString() } satisfies Oid;
|
|
|
|
// delete returnedObject._id;
|
|
|
|
// delete returnedObject.__v;
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
const WeaponSchema = new Schema({
|
|
|
|
ItemType: String,
|
|
|
|
Configs: [longGunConfigSchema],
|
|
|
|
UpgradeVer: Number,
|
|
|
|
XP: Number,
|
|
|
|
Features: Number,
|
|
|
|
Polarized: Number,
|
|
|
|
Polarity: Schema.Types.Mixed, //todo
|
|
|
|
FocusLens: String,
|
|
|
|
ModSlotPurchases: Number,
|
|
|
|
UpgradeType: Schema.Types.Mixed, //todo
|
|
|
|
UpgradeFingerprint: String,
|
|
|
|
ItemName: String,
|
|
|
|
ModularParts: [String],
|
|
|
|
UnlockLevel: Number
|
|
|
|
});
|
|
|
|
|
2023-08-31 14:29:09 +04:00
|
|
|
const BoosterSchema = new Schema({
|
|
|
|
ExpiryDate: Number,
|
|
|
|
ItemType: String
|
|
|
|
});
|
|
|
|
|
2023-09-06 14:02:54 +04:00
|
|
|
const RawUpgrades = new Schema({
|
|
|
|
ItemType: String,
|
|
|
|
ItemCount: Number
|
|
|
|
});
|
|
|
|
|
|
|
|
RawUpgrades.set("toJSON", {
|
|
|
|
transform(_document, returnedObject) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
|
|
returnedObject.LastAdded = { $oid: returnedObject._id.toString() } satisfies IOid;
|
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const Upgrade = new Schema({
|
|
|
|
UpgradeFingerprint: String,
|
|
|
|
ItemType: String
|
|
|
|
});
|
|
|
|
|
|
|
|
Upgrade.set("toJSON", {
|
|
|
|
transform(_document, returnedObject) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
|
|
returnedObject.ItemId = { $oid: returnedObject._id.toString() } satisfies IOid;
|
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-06-14 02:26:19 +02:00
|
|
|
WeaponSchema.set("toJSON", {
|
2023-07-27 22:15:15 +02:00
|
|
|
transform(_document, returnedObject) {
|
2023-06-14 02:26:19 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
2023-09-05 07:37:30 -05:00
|
|
|
returnedObject.ItemId = { $oid: returnedObject._id.toString() } satisfies IOid;
|
2023-06-14 02:26:19 +02:00
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const polaritySchema = new Schema({
|
|
|
|
Slot: Number,
|
|
|
|
Value: String
|
|
|
|
});
|
|
|
|
|
2023-06-04 03:06:22 +02:00
|
|
|
const suitConfigSchema = new Schema({
|
|
|
|
Skins: [String],
|
|
|
|
pricol: colorSchema,
|
|
|
|
attcol: colorSchema,
|
|
|
|
eyecol: colorSchema,
|
|
|
|
sigcol: colorSchema,
|
|
|
|
Upgrades: [String],
|
|
|
|
Songs: [
|
|
|
|
{
|
|
|
|
m: String,
|
|
|
|
b: String,
|
|
|
|
p: String,
|
|
|
|
s: String
|
|
|
|
}
|
|
|
|
],
|
|
|
|
Name: String,
|
|
|
|
AbilityOverride: abilityOverrideSchema,
|
|
|
|
PvpUpgrades: [String],
|
|
|
|
ugly: Boolean
|
|
|
|
});
|
|
|
|
|
|
|
|
suitConfigSchema.set("toJSON", {
|
|
|
|
transform(_document, returnedObject) {
|
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-06-14 02:26:19 +02:00
|
|
|
const suitSchema = new Schema<ISuitDatabase>({
|
2023-06-04 03:06:22 +02:00
|
|
|
ItemType: String,
|
|
|
|
Configs: [suitConfigSchema],
|
|
|
|
UpgradeVer: Number,
|
|
|
|
XP: Number,
|
|
|
|
InfestationDate: Date,
|
|
|
|
Features: Number,
|
|
|
|
Polarity: [polaritySchema],
|
|
|
|
Polarized: Number,
|
|
|
|
ModSlotPurchases: Number,
|
|
|
|
FocusLens: String,
|
|
|
|
UnlockLevel: Number
|
|
|
|
});
|
|
|
|
|
|
|
|
suitSchema.set("toJSON", {
|
2023-07-27 22:15:15 +02:00
|
|
|
transform(_document, returnedObject) {
|
2023-06-04 03:06:22 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
2023-09-05 07:37:30 -05:00
|
|
|
returnedObject.ItemId = { $oid: returnedObject._id.toString() } satisfies IOid;
|
2023-06-04 03:06:22 +02:00
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-06-14 02:26:19 +02:00
|
|
|
const slotsBinSchema = new Schema(
|
|
|
|
{
|
|
|
|
Slots: Number
|
|
|
|
},
|
|
|
|
{ _id: false }
|
|
|
|
);
|
|
|
|
|
|
|
|
const FlavourItemSchema = new Schema({
|
|
|
|
ItemType: String
|
|
|
|
});
|
|
|
|
|
|
|
|
FlavourItemSchema.set("toJSON", {
|
2023-07-27 22:15:15 +02:00
|
|
|
transform(_document, returnedObject) {
|
2023-06-14 02:26:19 +02:00
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
2023-06-04 03:06:22 +02:00
|
|
|
accountOwnerId: Schema.Types.ObjectId,
|
|
|
|
SubscribedToEmails: Number,
|
|
|
|
Created: Schema.Types.Mixed,
|
|
|
|
RewardSeed: Number,
|
|
|
|
RegularCredits: Number,
|
|
|
|
PremiumCredits: Number,
|
|
|
|
PremiumCreditsFree: Number,
|
|
|
|
FusionPoints: Number,
|
2023-06-14 02:26:19 +02:00
|
|
|
SuitBin: slotsBinSchema,
|
|
|
|
WeaponBin: slotsBinSchema,
|
|
|
|
SentinelBin: slotsBinSchema,
|
2023-06-04 03:06:22 +02:00
|
|
|
SpaceSuitBin: Schema.Types.Mixed,
|
|
|
|
SpaceWeaponBin: Schema.Types.Mixed,
|
|
|
|
PvpBonusLoadoutBin: Schema.Types.Mixed,
|
|
|
|
PveBonusLoadoutBin: Schema.Types.Mixed,
|
|
|
|
RandomModBin: Schema.Types.Mixed,
|
|
|
|
TradesRemaining: Number,
|
|
|
|
DailyAffiliation: Number,
|
|
|
|
DailyAffiliationPvp: Number,
|
|
|
|
DailyAffiliationLibrary: Number,
|
|
|
|
DailyFocus: Number,
|
|
|
|
GiftsRemaining: Number,
|
|
|
|
HandlerPoints: Number,
|
|
|
|
MiscItems: [Schema.Types.Mixed],
|
|
|
|
ChallengesFixVersion: Number,
|
|
|
|
ChallengeProgress: [Schema.Types.Mixed],
|
2023-09-06 14:02:54 +04:00
|
|
|
RawUpgrades: [RawUpgrades],
|
2023-06-04 03:06:22 +02:00
|
|
|
ReceivedStartingGear: Boolean,
|
|
|
|
Suits: [suitSchema],
|
2023-06-14 02:26:19 +02:00
|
|
|
LongGuns: [WeaponSchema],
|
|
|
|
Pistols: [WeaponSchema],
|
|
|
|
Melee: [WeaponSchema],
|
2023-06-04 03:06:22 +02:00
|
|
|
Ships: [Schema.Types.Mixed],
|
|
|
|
QuestKeys: [Schema.Types.Mixed],
|
2023-06-14 02:26:19 +02:00
|
|
|
FlavourItems: [FlavourItemSchema],
|
2023-06-04 03:06:22 +02:00
|
|
|
Scoops: [Schema.Types.Mixed],
|
|
|
|
TrainingRetriesLeft: Number,
|
|
|
|
LoadOutPresets: Schema.Types.Mixed,
|
|
|
|
CurrentLoadOutIds: [Schema.Types.Mixed],
|
|
|
|
Missions: [Schema.Types.Mixed],
|
|
|
|
RandomUpgradesIdentified: Number,
|
|
|
|
LastRegionPlayed: String,
|
|
|
|
XPInfo: [Schema.Types.Mixed],
|
|
|
|
Recipes: [Schema.Types.Mixed],
|
|
|
|
WeaponSkins: [Schema.Types.Mixed],
|
|
|
|
PendingRecipes: [Schema.Types.Mixed],
|
|
|
|
TrainingDate: Schema.Types.Mixed,
|
|
|
|
PlayerLevel: Number,
|
2023-09-06 14:02:54 +04:00
|
|
|
Upgrades: [Upgrade],
|
2023-06-04 03:06:22 +02:00
|
|
|
EquippedGear: [String],
|
|
|
|
DeathMarks: [String],
|
|
|
|
FusionTreasures: [Schema.Types.Mixed],
|
|
|
|
WebFlags: Schema.Types.Mixed,
|
|
|
|
CompletedAlerts: [String],
|
|
|
|
Consumables: [Schema.Types.Mixed],
|
|
|
|
LevelKeys: [Schema.Types.Mixed],
|
|
|
|
TauntHistory: [Schema.Types.Mixed],
|
|
|
|
StoryModeChoice: String,
|
|
|
|
PeriodicMissionCompletions: [Schema.Types.Mixed],
|
|
|
|
KubrowPetEggs: [Schema.Types.Mixed],
|
|
|
|
LoreFragmentScans: [Schema.Types.Mixed],
|
|
|
|
EquippedEmotes: [String],
|
|
|
|
PendingTrades: [Schema.Types.Mixed],
|
2023-08-31 14:29:09 +04:00
|
|
|
Boosters: [BoosterSchema],
|
2023-06-04 03:06:22 +02:00
|
|
|
ActiveDojoColorResearch: String,
|
|
|
|
SentientSpawnChanceBoosters: Schema.Types.Mixed,
|
|
|
|
Affiliations: [Schema.Types.Mixed],
|
|
|
|
QualifyingInvasions: [Schema.Types.Mixed],
|
|
|
|
FactionScores: [Number],
|
|
|
|
SpaceSuits: [Schema.Types.Mixed],
|
|
|
|
SpaceMelee: [Schema.Types.Mixed],
|
|
|
|
SpaceGuns: [Schema.Types.Mixed],
|
|
|
|
ArchwingEnabled: Boolean,
|
|
|
|
PendingSpectreLoadouts: [Schema.Types.Mixed],
|
|
|
|
SpectreLoadouts: [Schema.Types.Mixed],
|
|
|
|
SentinelWeapons: [Schema.Types.Mixed],
|
|
|
|
Sentinels: [Schema.Types.Mixed],
|
|
|
|
EmailItems: [Schema.Types.Mixed],
|
|
|
|
CompletedSyndicates: [String],
|
|
|
|
FocusXP: Schema.Types.Mixed,
|
|
|
|
Wishlist: [String],
|
|
|
|
Alignment: Schema.Types.Mixed,
|
|
|
|
CompletedSorties: [String],
|
|
|
|
LastSortieReward: [Schema.Types.Mixed],
|
|
|
|
Drones: [Schema.Types.Mixed],
|
|
|
|
StepSequencers: [Schema.Types.Mixed],
|
|
|
|
ActiveAvatarImageType: String,
|
|
|
|
KubrowPets: [Schema.Types.Mixed],
|
|
|
|
ShipDecorations: [Schema.Types.Mixed],
|
|
|
|
OperatorAmpBin: Schema.Types.Mixed,
|
|
|
|
DailyAffiliationCetus: Number,
|
|
|
|
DailyAffiliationQuills: Number,
|
|
|
|
DiscoveredMarkers: [Schema.Types.Mixed],
|
|
|
|
CompletedJobs: [Schema.Types.Mixed],
|
|
|
|
FocusAbility: String,
|
|
|
|
FocusUpgrades: [Schema.Types.Mixed],
|
|
|
|
OperatorAmps: [Schema.Types.Mixed],
|
|
|
|
HasContributedToDojo: Boolean,
|
|
|
|
HWIDProtectEnabled: Boolean,
|
|
|
|
KubrowPetPrints: [Schema.Types.Mixed],
|
|
|
|
AlignmentReplay: Schema.Types.Mixed,
|
|
|
|
PersonalGoalProgress: [Schema.Types.Mixed],
|
|
|
|
DailyAffiliationSolaris: Number,
|
|
|
|
SpecialItems: [Schema.Types.Mixed],
|
|
|
|
ThemeStyle: String,
|
|
|
|
ThemeBackground: String,
|
|
|
|
ThemeSounds: String,
|
|
|
|
BountyScore: Number,
|
|
|
|
ChallengeInstanceStates: [Schema.Types.Mixed],
|
|
|
|
LoginMilestoneRewards: [String],
|
|
|
|
OperatorLoadOuts: [Schema.Types.Mixed],
|
|
|
|
DailyAffiliationVentkids: Number,
|
|
|
|
DailyAffiliationVox: Number,
|
|
|
|
RecentVendorPurchases: [Schema.Types.Mixed],
|
|
|
|
Hoverboards: [Schema.Types.Mixed],
|
|
|
|
NodeIntrosCompleted: [String],
|
|
|
|
CompletedJobChains: [Schema.Types.Mixed],
|
|
|
|
SeasonChallengeHistory: [Schema.Types.Mixed],
|
|
|
|
MoaPets: [Schema.Types.Mixed],
|
|
|
|
EquippedInstrument: String,
|
|
|
|
InvasionChainProgress: [Schema.Types.Mixed],
|
|
|
|
DataKnives: [Schema.Types.Mixed],
|
|
|
|
NemesisHistory: [Schema.Types.Mixed],
|
|
|
|
LastNemesisAllySpawnTime: Schema.Types.Mixed,
|
|
|
|
Settings: Schema.Types.Mixed,
|
|
|
|
PersonalTechProjects: [Schema.Types.Mixed],
|
|
|
|
CrewShips: [Schema.Types.Mixed],
|
|
|
|
CrewShipSalvageBin: Schema.Types.Mixed,
|
|
|
|
PlayerSkills: Schema.Types.Mixed,
|
|
|
|
CrewShipAmmo: [Schema.Types.Mixed],
|
|
|
|
CrewShipSalvagedWeaponSkins: [Schema.Types.Mixed],
|
|
|
|
CrewShipWeapons: [Schema.Types.Mixed],
|
|
|
|
CrewShipSalvagedWeapons: [Schema.Types.Mixed],
|
|
|
|
CrewShipWeaponSkins: [Schema.Types.Mixed],
|
|
|
|
TradeBannedUntil: Schema.Types.Mixed,
|
|
|
|
PlayedParkourTutorial: Boolean,
|
|
|
|
SubscribedToEmailsPersonalized: Number,
|
|
|
|
MechBin: Schema.Types.Mixed,
|
|
|
|
DailyAffiliationEntrati: Number,
|
|
|
|
DailyAffiliationNecraloid: Number,
|
|
|
|
MechSuits: [Schema.Types.Mixed],
|
|
|
|
InfestedFoundry: Schema.Types.Mixed,
|
|
|
|
BlessingCooldown: Schema.Types.Mixed,
|
|
|
|
CrewMemberBin: Schema.Types.Mixed,
|
|
|
|
CrewShipHarnesses: [Schema.Types.Mixed],
|
|
|
|
CrewShipRawSalvage: [Schema.Types.Mixed],
|
|
|
|
CrewMembers: [Schema.Types.Mixed],
|
|
|
|
AdultOperatorLoadOuts: [Schema.Types.Mixed],
|
|
|
|
LotusCustomization: Schema.Types.Mixed,
|
|
|
|
UseAdultOperatorLoadout: Boolean,
|
|
|
|
DailyAffiliationZariman: Number,
|
|
|
|
NemesisAbandonedRewards: [String],
|
|
|
|
DailyAffiliationKahl: Number,
|
|
|
|
LastInventorySync: Schema.Types.Mixed,
|
|
|
|
NextRefill: Schema.Types.Mixed,
|
|
|
|
ActiveLandscapeTraps: [Schema.Types.Mixed],
|
|
|
|
EvolutionProgress: [Schema.Types.Mixed],
|
|
|
|
RepVotes: [Schema.Types.Mixed],
|
|
|
|
LeagueTickets: [Schema.Types.Mixed],
|
|
|
|
Quests: [Schema.Types.Mixed],
|
|
|
|
Robotics: [Schema.Types.Mixed],
|
|
|
|
UsedDailyDeals: [Schema.Types.Mixed],
|
|
|
|
LibraryPersonalProgress: [Schema.Types.Mixed],
|
|
|
|
CollectibleSeries: [Schema.Types.Mixed],
|
|
|
|
LibraryAvailableDailyTaskInfo: Schema.Types.Mixed,
|
|
|
|
HasResetAccount: Boolean,
|
|
|
|
PendingCoupon: Schema.Types.Mixed,
|
|
|
|
Harvestable: Boolean,
|
|
|
|
DeathSquadable: Boolean
|
|
|
|
});
|
|
|
|
|
|
|
|
inventorySchema.set("toJSON", {
|
2023-06-05 04:16:49 +08:00
|
|
|
transform(_document, returnedObject) {
|
2023-06-04 03:06:22 +02:00
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-06-14 02:26:19 +02:00
|
|
|
type InventoryDocumentProps = {
|
|
|
|
Suits: Types.DocumentArray<ISuitDatabase>;
|
|
|
|
LongGuns: Types.DocumentArray<IWeaponDatabase>;
|
|
|
|
Pistols: Types.DocumentArray<IWeaponDatabase>;
|
|
|
|
Melee: Types.DocumentArray<IWeaponDatabase>;
|
2023-09-05 07:37:30 -05:00
|
|
|
FlavourItems: Types.DocumentArray<IFlavourItem>;
|
|
|
|
RawUpgrades: Types.DocumentArray<IRawUpgrade>;
|
|
|
|
MiscItems: Types.DocumentArray<IMiscItem>;
|
|
|
|
Boosters: Types.DocumentArray<IBooster>;
|
2023-06-14 02:26:19 +02:00
|
|
|
};
|
|
|
|
|
2023-09-06 14:02:54 +04:00
|
|
|
type InventoryModelType = Model<IInventoryDatabase, object, InventoryDocumentProps>;
|
2023-06-14 02:26:19 +02:00
|
|
|
|
|
|
|
const Inventory = model<IInventoryDatabase, InventoryModelType>("Inventory", inventorySchema);
|
2023-06-04 03:06:22 +02:00
|
|
|
|
2023-06-14 02:26:19 +02:00
|
|
|
export { Inventory };
|