1347 lines
38 KiB
TypeScript
Raw Normal View History

2025-01-31 14:15:36 +01:00
import { Document, HydratedDocument, Model, Schema, Types, model } from "mongoose";
import {
IFlavourItem,
IRawUpgrade,
IMiscItem,
IInventoryDatabase,
2023-09-11 13:20:07 +02:00
IBooster,
2025-01-20 12:19:32 +01:00
IInventoryClient,
ISlots,
2025-01-31 14:15:36 +01:00
IMailboxDatabase,
2024-01-25 14:49:45 +01:00
IDuviriInfo,
IPendingRecipe as IPendingRecipeDatabase,
2024-02-12 14:31:28 +01:00
IPendingRecipeResponse,
ITypeCount,
IFocusXP,
2025-01-20 12:19:32 +01:00
IFocusUpgrade,
2024-02-12 14:31:28 +01:00
ITypeXPItem,
IChallengeProgress,
IStepSequencer,
IAffiliation,
INotePacks,
ICompletedJobChain,
ISeasonChallenge,
2024-02-12 14:31:28 +01:00
IPlayerSkills,
ISettings,
2025-01-20 12:19:32 +01:00
IInfestedFoundryDatabase,
IHelminthResource,
IMissionDatabase,
2024-02-12 14:31:28 +01:00
IConsumedSuit,
2025-01-24 14:13:21 +01:00
IQuestStage,
2024-02-12 14:31:28 +01:00
IQuestKeyDatabase,
2025-01-24 14:13:21 +01:00
IQuestKeyClient,
2024-02-12 14:31:28 +01:00
IFusionTreasure,
ISpectreLoadout,
IWeaponSkinDatabase,
ITaunt,
2024-02-12 14:31:28 +01:00
IPeriodicMissionCompletionDatabase,
IPeriodicMissionCompletionResponse,
ILoreFragmentScan,
IEvolutionProgress,
2024-12-23 22:47:58 +01:00
IEndlessXpProgress,
ICrewShipPortGuns,
ICrewShipCustomization,
ICrewShipWeapon,
ICrewShipPilotWeapon,
2025-01-05 13:34:41 +01:00
IShipExterior,
IHelminthFoodRecord,
ICrewShipMembersDatabase,
IDialogueHistoryDatabase,
IDialogueDatabase,
IDialogueGift,
ICompletedDialogue,
2025-01-20 12:19:32 +01:00
IDialogueClient,
IUpgradeDatabase,
ICrewShipMemberDatabase,
ICrewShipMemberClient,
2025-01-31 14:15:36 +01:00
IMailboxClient,
TEquipmentKey,
equipmentKeys,
IKubrowPetDetailsDatabase,
ITraits,
IKubrowPetDetailsClient,
IKubrowPetEggDatabase,
IKubrowPetEggClient,
ICustomMarkers,
IMarkerInfo,
IMarker,
ICalendarProgress,
IPendingCouponDatabase,
IPendingCouponClient,
ILibraryDailyTaskInfo,
IDroneDatabase,
IDroneClient
} from "../../types/inventoryTypes/inventoryTypes";
import { IOid } from "../../types/commonTypes";
import {
IAbilityOverride,
IColor,
IItemConfig,
IOperatorConfigDatabase,
IPolarity,
IEquipmentDatabase,
IArchonCrystalUpgrade,
IEquipmentClient
} from "@/src/types/inventoryTypes/commonInventoryTypes";
2024-02-12 14:31:28 +01:00
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
2024-12-23 22:47:58 +01:00
import { EquipmentSelectionSchema } from "./loadoutModel";
2024-02-12 14:31:28 +01:00
2025-01-03 09:06:50 +01:00
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
2024-02-12 14:31:28 +01:00
const focusXPSchema = new Schema<IFocusXP>(
{
AP_POWER: Number,
AP_TACTIC: Number,
AP_DEFENSE: Number,
AP_ATTACK: Number,
AP_WARD: Number
},
{ _id: false }
);
2025-01-20 12:19:32 +01:00
const focusUpgradeSchema = new Schema<IFocusUpgrade>(
2024-02-12 14:31:28 +01:00
{
ItemType: String,
Level: Number,
IsUniversal: Boolean
},
{ _id: false }
);
2024-01-25 14:49:45 +01:00
const pendingRecipeSchema = new Schema<IPendingRecipeDatabase>(
{
ItemType: String,
CompletionDate: Date
},
{ id: false }
);
pendingRecipeSchema.virtual("ItemId").get(function () {
return { $oid: this._id.toString() };
});
pendingRecipeSchema.set("toJSON", {
virtuals: true,
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
(returnedObject as IPendingRecipeResponse).CompletionDate = {
$date: { $numberLong: (returnedObject as IPendingRecipeDatabase).CompletionDate.getTime().toString() }
};
}
});
const polaritySchema = new Schema<IPolarity>(
{
Slot: Number,
Value: String
},
{ _id: false }
);
const abilityOverrideSchema = new Schema<IAbilityOverride>(
{
Ability: String,
Index: Number
},
{ _id: false }
);
export const colorSchema = new Schema<IColor>(
{
t0: Number,
t1: Number,
t2: Number,
t3: Number,
en: Number,
e1: Number,
m0: Number,
m1: Number
},
{ _id: false }
);
const operatorConfigSchema = new Schema<IOperatorConfigDatabase>(
{
Skins: [String],
pricol: colorSchema,
attcol: colorSchema,
sigcol: colorSchema,
eyecol: colorSchema,
facial: colorSchema,
syancol: colorSchema,
cloth: colorSchema,
Upgrades: [String],
Name: String, // not sure if possible in operator
ugly: Boolean // not sure if possible in operator
},
{ id: false }
);
operatorConfigSchema.virtual("ItemId").get(function () {
return { $oid: this._id.toString() } satisfies IOid;
});
operatorConfigSchema.set("toJSON", {
virtuals: true,
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
}
});
///TODO: clearly seperate the different config schemas. (suit and weapon and so on)
const ItemConfigSchema = new Schema<IItemConfig>(
{
Skins: [String],
pricol: colorSchema,
attcol: colorSchema,
sigcol: colorSchema,
eyecol: colorSchema,
facial: colorSchema,
syancol: colorSchema,
Upgrades: [String],
Songs: {
type: [
{
m: String,
b: String,
p: String,
s: String
}
],
default: undefined
},
Name: String,
AbilityOverride: abilityOverrideSchema,
PvpUpgrades: [String],
ugly: Boolean
},
{ _id: false }
);
ItemConfigSchema.set("toJSON", {
transform(_document, returnedObject) {
delete returnedObject.__v;
}
});
const ArchonCrystalUpgradeSchema = new Schema<IArchonCrystalUpgrade>(
{
UpgradeType: String,
Color: String
},
{ _id: false }
);
ArchonCrystalUpgradeSchema.set("toJSON", {
transform(_document, returnedObject) {
delete returnedObject.__v;
}
});
2024-02-12 14:31:28 +01:00
const boosterSchema = new Schema<IBooster>(
{
ExpiryDate: Number,
ItemType: String
},
{ _id: false }
);
2023-08-31 14:29:09 +04:00
const RawUpgrades = new Schema<IRawUpgrade>(
{
ItemType: String,
ItemCount: Number
},
{ id: false }
);
RawUpgrades.virtual("LastAdded").get(function () {
return { $oid: this._id.toString() } satisfies IOid;
});
RawUpgrades.set("toJSON", {
virtuals: true,
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
}
});
2025-01-20 12:19:32 +01:00
const upgradeSchema = new Schema<IUpgradeDatabase>(
2024-02-12 14:31:28 +01:00
{
UpgradeFingerprint: String,
2025-01-19 01:57:52 +01:00
PendingRerollFingerprint: { type: String, required: false },
2024-02-12 14:31:28 +01:00
ItemType: String
},
{ id: false }
);
2025-01-20 12:19:32 +01:00
upgradeSchema.virtual("ItemId").get(function () {
2024-02-12 14:31:28 +01:00
return toOid(this._id);
});
2025-01-20 12:19:32 +01:00
upgradeSchema.set("toJSON", {
virtuals: true,
2023-07-27 22:15:15 +02:00
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
}
});
const slotsBinSchema = new Schema<ISlots>(
{
Slots: Number,
Extra: Number
},
{ _id: false }
);
const FlavourItemSchema = new Schema(
{
ItemType: String
},
{ _id: false }
);
FlavourItemSchema.set("toJSON", {
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
}
});
2025-01-31 14:15:36 +01:00
const MailboxSchema = new Schema<IMailboxDatabase>(
{
2025-01-31 14:15:36 +01:00
LastInboxId: Schema.Types.ObjectId
},
{ id: false, _id: false }
);
MailboxSchema.set("toJSON", {
transform(_document, returnedObject) {
2025-01-31 14:15:36 +01:00
const mailboxDatabase = returnedObject as HydratedDocument<IMailboxDatabase, { __v?: number }>;
delete mailboxDatabase.__v;
(returnedObject as IMailboxClient).LastInboxId = toOid(mailboxDatabase.LastInboxId);
}
});
const DuviriInfoSchema = new Schema<IDuviriInfo>(
{
Seed: Number,
NumCompletions: { type: Number, default: 0 }
},
{
_id: false,
id: false
}
);
DuviriInfoSchema.set("toJSON", {
2023-07-27 22:15:15 +02:00
transform(_document, returnedObject) {
delete returnedObject.__v;
}
});
2024-02-12 14:31:28 +01:00
const TypeXPItemSchema = new Schema<ITypeXPItem>(
{
ItemType: String,
XP: Number
},
{ _id: false }
);
const droneSchema = new Schema<IDroneDatabase>(
{
ItemType: String,
CurrentHP: Number,
RepairStart: { type: Date, default: undefined }
},
{ id: false }
);
droneSchema.set("toJSON", {
virtuals: true,
transform(_document, obj) {
const client = obj as IDroneClient;
const db = obj as IDroneDatabase;
client.ItemId = toOid(db._id);
delete obj._id;
delete obj.__v;
}
});
2024-02-12 14:31:28 +01:00
const challengeProgressSchema = new Schema<IChallengeProgress>(
{
Progress: Number,
Name: String,
Completed: [String]
},
{ _id: false }
);
const notePacksSchema = new Schema<INotePacks>(
{
MELODY: String,
BASS: String,
PERCUSSION: String
},
{ _id: false }
);
const StepSequencersSchema = new Schema<IStepSequencer>(
{
NotePacks: notePacksSchema,
FingerPrint: String,
Name: String
},
{ id: false }
);
StepSequencersSchema.virtual("ItemId").get(function () {
return { $oid: this._id.toString() } satisfies IOid;
});
StepSequencersSchema.set("toJSON", {
virtuals: true,
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
}
});
const kubrowPetEggSchema = new Schema<IKubrowPetEggDatabase>(
{
ItemType: String
},
{ id: false }
);
kubrowPetEggSchema.set("toJSON", {
virtuals: true,
transform(_document, obj) {
const client = obj as IKubrowPetEggClient;
const db = obj as IKubrowPetEggDatabase;
client.ExpirationDate = { $date: { $numberLong: "2000000000000" } };
client.ItemId = toOid(db._id);
delete obj._id;
delete obj.__v;
}
});
2024-02-12 14:31:28 +01:00
const affiliationsSchema = new Schema<IAffiliation>(
{
Initiated: Boolean,
Standing: Number,
Title: Number,
FreeFavorsEarned: { type: [Number], default: undefined },
FreeFavorsUsed: { type: [Number], default: undefined },
2024-02-12 14:31:28 +01:00
Tag: String
},
{ _id: false }
);
const completedJobChainsSchema = new Schema<ICompletedJobChain>(
{
LocationTag: String,
Jobs: [String]
},
{ _id: false }
);
const seasonChallengeHistorySchema = new Schema<ISeasonChallenge>(
2024-02-12 14:31:28 +01:00
{
challenge: String,
id: String
},
{ _id: false }
);
//TODO: check whether this is complete
const playerSkillsSchema = new Schema<IPlayerSkills>(
{
LPP_NONE: { type: Number, default: 0 },
2025-01-06 05:36:18 +01:00
LPP_SPACE: { type: Number, default: 0 },
LPS_PILOTING: { type: Number, default: 0 },
LPS_GUNNERY: { type: Number, default: 0 },
LPS_TACTICAL: { type: Number, default: 0 },
LPS_ENGINEERING: { type: Number, default: 0 },
LPS_COMMAND: { type: Number, default: 0 },
LPP_DRIFTER: { type: Number, default: 0 },
LPS_DRIFT_COMBAT: { type: Number, default: 0 },
LPS_DRIFT_RIDING: { type: Number, default: 0 },
LPS_DRIFT_OPPORTUNITY: { type: Number, default: 0 },
LPS_DRIFT_ENDURANCE: { type: Number, default: 0 }
2024-02-12 14:31:28 +01:00
},
{ _id: false }
);
const settingsSchema = new Schema<ISettings>({
FriendInvRestriction: String,
GiftMode: String,
GuildInvRestriction: String,
ShowFriendInvNotifications: Boolean,
TradingRulesConfirmed: Boolean
});
2025-01-03 05:22:56 +01:00
const consumedSchuitsSchema = new Schema<IConsumedSuit>(
{
s: String,
c: colorSchema
},
{ _id: false }
);
2024-02-12 14:31:28 +01:00
2025-01-05 13:34:41 +01:00
const helminthFoodRecordSchema = new Schema<IHelminthFoodRecord>(
{
ItemType: String,
Date: Number
},
{ _id: false }
);
const helminthResourceSchema = new Schema<IHelminthResource>(
{
ItemType: String,
Count: Number,
RecentlyConvertedResources: { type: [helminthFoodRecordSchema], default: undefined }
},
{ _id: false }
);
const missionSchema = new Schema<IMissionDatabase>(
{
Tag: String,
Completes: { type: Number, default: 0 },
Tier: { type: Number, required: false }
},
{ _id: false }
);
2025-01-31 17:24:42 +01:00
const questProgressSchema = new Schema<IQuestStage>(
{
c: Number,
i: Boolean,
m: Boolean,
b: []
},
{ _id: false }
);
2024-02-12 14:31:28 +01:00
const questKeysSchema = new Schema<IQuestKeyDatabase>(
{
Progress: { type: [questProgressSchema], default: [] },
2024-02-12 14:31:28 +01:00
unlock: Boolean,
Completed: Boolean,
2025-01-31 17:24:42 +01:00
CustomData: String,
2024-02-12 14:31:28 +01:00
CompletionDate: Date,
ItemType: String
},
{
_id: false
}
);
questKeysSchema.set("toJSON", {
transform(_doc, ret, _options) {
const questKeysDatabase = ret as IQuestKeyDatabase;
if (questKeysDatabase.CompletionDate) {
2025-01-24 14:13:21 +01:00
(questKeysDatabase as IQuestKeyClient).CompletionDate = toMongoDate(questKeysDatabase.CompletionDate);
2024-02-12 14:31:28 +01:00
}
}
});
const fusionTreasuresSchema = new Schema<IFusionTreasure>().add(typeCountSchema).add({ Sockets: Number });
const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
{
2025-01-06 01:21:37 +01:00
ItemType: String,
Suits: String,
2024-02-12 14:31:28 +01:00
LongGuns: String,
2025-01-06 01:21:37 +01:00
LongGunsModularParts: { type: [String], default: undefined },
2024-02-12 14:31:28 +01:00
Pistols: String,
2025-01-06 01:21:37 +01:00
PistolsModularParts: { type: [String], default: undefined },
Melee: String,
MeleeModularParts: { type: [String], default: undefined }
2024-02-12 14:31:28 +01:00
},
{ _id: false }
);
const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>(
2024-02-12 14:31:28 +01:00
{
ItemType: String
},
{ id: false }
);
weaponSkinsSchema.virtual("ItemId").get(function () {
return { $oid: this._id.toString() };
});
weaponSkinsSchema.set("toJSON", {
virtuals: true,
transform(_doc, ret, _options) {
delete ret._id;
delete ret.__v;
}
});
2024-02-12 14:31:28 +01:00
const tauntSchema = new Schema<ITaunt>(
2024-02-12 14:31:28 +01:00
{
node: String,
state: String
},
{ _id: false }
);
const periodicMissionCompletionsSchema = new Schema<IPeriodicMissionCompletionDatabase>(
{
date: Date,
tag: String,
count: Number
},
{ _id: false }
);
periodicMissionCompletionsSchema.set("toJSON", {
transform(_doc, ret, _options) {
const periodicMissionCompletionDatabase = ret as IPeriodicMissionCompletionDatabase;
(periodicMissionCompletionDatabase as unknown as IPeriodicMissionCompletionResponse).date = toMongoDate(
periodicMissionCompletionDatabase.date
);
}
});
const loreFragmentScansSchema = new Schema<ILoreFragmentScan>(
{
Progress: Number,
Region: String,
ItemType: String
},
{ _id: false }
);
const evolutionProgressSchema = new Schema<IEvolutionProgress>(
{
Progress: Number,
Rank: Number,
ItemType: String
},
{ _id: false }
);
const endlessXpProgressSchema = new Schema<IEndlessXpProgress>(
{
Category: String,
Choices: [String]
},
{ _id: false }
);
2024-12-23 22:47:58 +01:00
const crewShipPilotWeaponSchema = new Schema<ICrewShipPilotWeapon>(
{
PRIMARY_A: EquipmentSelectionSchema,
SECONDARY_A: EquipmentSelectionSchema
},
{ _id: false }
);
const crewShipPortGunsSchema = new Schema<ICrewShipPortGuns>(
{
PRIMARY_A: EquipmentSelectionSchema
},
{ _id: false }
);
const crewShipWeaponSchema = new Schema<ICrewShipWeapon>(
{
PILOT: crewShipPilotWeaponSchema,
PORT_GUNS: crewShipPortGunsSchema
},
{ _id: false }
);
const shipExteriorSchema = new Schema<IShipExterior>(
{
SkinFlavourItem: String,
Colors: colorSchema,
ShipAttachments: { HOOD_ORNAMENT: String }
},
{ _id: false }
);
const crewShipCustomizationSchema = new Schema<ICrewShipCustomization>(
{
CrewshipInterior: shipExteriorSchema
},
{ _id: false }
);
const crewShipMemberSchema = new Schema<ICrewShipMemberDatabase>(
2024-12-23 22:47:58 +01:00
{
ItemId: { type: Schema.Types.ObjectId, required: false },
NemesisFingerprint: { type: Number, required: false }
2024-12-23 22:47:58 +01:00
},
{ _id: false }
);
crewShipMemberSchema.set("toJSON", {
2024-12-23 22:47:58 +01:00
virtuals: true,
transform(_doc, obj) {
const db = obj as ICrewShipMemberDatabase;
const client = obj as ICrewShipMemberClient;
if (db.ItemId) {
client.ItemId = toOid(db.ItemId);
}
2024-12-23 22:47:58 +01:00
}
});
const crewShipMembersSchema = new Schema<ICrewShipMembersDatabase>(
{
SLOT_A: { type: crewShipMemberSchema, required: false },
SLOT_B: { type: crewShipMemberSchema, required: false },
SLOT_C: { type: crewShipMemberSchema, required: false }
},
{ _id: false }
);
const dialogueGiftSchema = new Schema<IDialogueGift>(
{
Item: String,
GiftedQuantity: Number
},
{ _id: false }
);
const completedDialogueSchema = new Schema<ICompletedDialogue>(
{
Id: { type: String, required: true },
Booleans: { type: [String], required: true },
Choices: { type: [Number], required: true }
},
{ _id: false }
);
const dialogueSchema = new Schema<IDialogueDatabase>(
{
Rank: Number,
Chemistry: Number,
AvailableDate: Date,
AvailableGiftDate: Date,
RankUpExpiry: Date,
BountyChemExpiry: Date,
//QueuedDialogues: ???
Gifts: { type: [dialogueGiftSchema], default: [] },
Booleans: { type: [String], default: [] },
Completed: { type: [completedDialogueSchema], default: [] },
DialogueName: String
},
{ _id: false }
);
dialogueSchema.set("toJSON", {
virtuals: true,
transform(_doc, ret) {
const db = ret as IDialogueDatabase;
const client = ret as IDialogueClient;
client.AvailableDate = toMongoDate(db.AvailableDate);
client.AvailableGiftDate = toMongoDate(db.AvailableGiftDate);
client.RankUpExpiry = toMongoDate(db.RankUpExpiry);
client.BountyChemExpiry = toMongoDate(db.BountyChemExpiry);
}
});
const dialogueHistorySchema = new Schema<IDialogueHistoryDatabase>(
{
YearIteration: { type: Number, required: true },
Dialogues: { type: [dialogueSchema], required: false }
},
{ _id: false }
);
const traitsSchema = new Schema<ITraits>(
{
BaseColor: String,
SecondaryColor: String,
TertiaryColor: String,
AccentColor: String,
EyeColor: String,
FurPattern: String,
Personality: String,
BodyType: String,
Head: { type: String, required: false },
Tail: { type: String, required: false }
},
{ _id: false }
);
const detailsSchema = new Schema<IKubrowPetDetailsDatabase>(
{
Name: String,
IsPuppy: Boolean,
HasCollar: Boolean,
PrintsRemaining: Number,
Status: String,
HatchDate: Date,
DominantTraits: traitsSchema,
RecessiveTraits: traitsSchema,
IsMale: Boolean,
Size: Number
},
{ _id: false }
);
detailsSchema.set("toJSON", {
transform(_doc, returnedObject) {
delete returnedObject.__v;
const db = returnedObject as IKubrowPetDetailsDatabase;
const client = returnedObject as IKubrowPetDetailsClient;
client.HatchDate = toMongoDate(db.HatchDate);
}
});
const EquipmentSchema = new Schema<IEquipmentDatabase>(
{
ItemType: String,
Configs: { type: [ItemConfigSchema], default: [] },
UpgradeVer: { type: Number, default: 101 },
XP: { type: Number, default: 0 },
Features: Number,
Polarized: Number,
Polarity: [polaritySchema],
FocusLens: String,
ModSlotPurchases: Number,
CustomizationSlotPurchases: Number,
UpgradeType: String,
UpgradeFingerprint: String,
ItemName: String,
InfestationDate: Date,
InfestationDays: Number,
InfestationType: String,
ModularParts: { type: [String], default: undefined },
UnlockLevel: Number,
Expiry: Date,
SkillTree: String,
OffensiveUpgrade: String,
DefensiveUpgrade: String,
UpgradesExpiry: Date,
ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined },
Weapon: crewShipWeaponSchema,
Customization: crewShipCustomizationSchema,
RailjackImage: FlavourItemSchema,
CrewMembers: crewShipMembersSchema,
Details: detailsSchema
},
{ id: false }
);
EquipmentSchema.virtual("ItemId").get(function () {
return { $oid: this._id.toString() } satisfies IOid;
});
EquipmentSchema.set("toJSON", {
virtuals: true,
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
const db = returnedObject as IEquipmentDatabase;
const client = returnedObject as IEquipmentClient;
if (db.InfestationDate) {
client.InfestationDate = toMongoDate(db.InfestationDate);
}
}
});
const equipmentFields: Record<string, { type: (typeof EquipmentSchema)[] }> = {};
equipmentKeys.forEach(key => {
equipmentFields[key] = { type: [EquipmentSchema] };
});
const infestedFoundrySchema = new Schema<IInfestedFoundryDatabase>(
{
Name: String,
Resources: { type: [helminthResourceSchema], default: undefined },
Slots: Number,
XP: Number,
ConsumedSuits: { type: [consumedSchuitsSchema], default: undefined },
InvigorationIndex: Number,
InvigorationSuitOfferings: { type: [String], default: undefined },
InvigorationsApplied: Number,
LastConsumedSuit: { type: EquipmentSchema, default: undefined },
AbilityOverrideUnlockCooldown: Date
},
{ _id: false }
);
infestedFoundrySchema.set("toJSON", {
transform(_doc, ret, _options) {
if (ret.AbilityOverrideUnlockCooldown) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
ret.AbilityOverrideUnlockCooldown = toMongoDate(ret.AbilityOverrideUnlockCooldown);
}
}
});
const markerSchema = new Schema<IMarker>(
{
anchorName: String,
color: Number,
label: String,
x: Number,
y: Number,
z: Number,
showInHud: Boolean
},
{ _id: false }
);
const markerInfoSchema = new Schema<IMarkerInfo>(
{
icon: String,
markers: [markerSchema]
},
{ _id: false }
);
const CustomMarkersSchema = new Schema<ICustomMarkers>(
{
tag: String,
markerInfos: [markerInfoSchema]
},
{ _id: false }
);
const calenderProgressSchema = new Schema<ICalendarProgress>(
{
Version: { type: Number, default: 19 },
Iteration: { type: Number, default: 2 },
YearProgress: {
Upgrades: { type: [] }
},
SeasonProgress: {
SeasonType: String,
LastCompletedDayIdx: { type: Number, default: -1 },
LastCompletedChallengeDayIdx: { type: Number, default: -1 },
ActivatedChallenges: []
}
},
{ _id: false }
);
const pendingCouponSchema = new Schema<IPendingCouponDatabase>(
{
Expiry: { type: Date, default: new Date(0) },
Discount: { type: Number, default: 0 }
},
{ _id: false }
);
pendingCouponSchema.set("toJSON", {
transform(_doc, ret, _options) {
(ret as IPendingCouponClient).Expiry = toMongoDate((ret as IPendingCouponDatabase).Expiry);
}
});
const libraryDailyTaskInfoSchema = new Schema<ILibraryDailyTaskInfo>(
{
EnemyTypes: [String],
EnemyLocTag: String,
EnemyIcon: String,
Scans: Number,
ScansRequired: Number,
RewardStoreItem: String,
RewardQuantity: Number,
RewardStanding: Number
},
{ _id: false }
);
2024-02-12 14:31:28 +01:00
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
{
accountOwnerId: Schema.Types.ObjectId,
SubscribedToEmails: { type: Number, default: 0 },
SubscribedToEmailsPersonalized: { type: Number, default: 0 },
2024-02-12 14:31:28 +01:00
RewardSeed: Number,
//Credit
RegularCredits: { type: Number, default: 0 },
2024-02-12 14:31:28 +01:00
//Platinum
PremiumCredits: { type: Number, default: 0 },
2024-02-12 14:31:28 +01:00
//Gift Platinum(Non trade)
PremiumCreditsFree: { type: Number, default: 0 },
2024-02-12 14:31:28 +01:00
//Endo
FusionPoints: { type: Number, default: 0 },
//Regal Aya
PrimeTokens: { type: Number, default: 0 },
2024-02-12 14:31:28 +01:00
//Slots
SuitBin: { type: slotsBinSchema, default: { Slots: 3 } },
WeaponBin: { type: slotsBinSchema, default: { Slots: 11 } },
SentinelBin: { type: slotsBinSchema, default: { Slots: 10 } },
SpaceSuitBin: { type: slotsBinSchema, default: { Slots: 4 } },
SpaceWeaponBin: { type: slotsBinSchema, default: { Slots: 4 } },
PvpBonusLoadoutBin: { type: slotsBinSchema, default: { Slots: 0 } },
PveBonusLoadoutBin: { type: slotsBinSchema, default: { Slots: 0 } },
RandomModBin: { type: slotsBinSchema, default: { Slots: 15 } },
OperatorAmpBin: { type: slotsBinSchema, default: { Slots: 8 } },
CrewShipSalvageBin: { type: slotsBinSchema, default: { Slots: 8 } },
MechBin: { type: slotsBinSchema, default: { Slots: 4 } },
CrewMemberBin: { type: slotsBinSchema, default: { Slots: 3 } },
2024-02-12 14:31:28 +01:00
...equipmentFields,
2024-02-12 14:31:28 +01:00
//How many trades do you have left
TradesRemaining: { type: Number, default: 0 },
2024-02-12 14:31:28 +01:00
//How many Gift do you have left*(gift spends the trade)
GiftsRemaining: { type: Number, default: 8 },
2024-02-12 14:31:28 +01:00
//Curent trade info Giving or Getting items
PendingTrades: [Schema.Types.Mixed],
//Syndicate currently being pledged to.
SupportedSyndicate: String,
2024-02-12 14:31:28 +01:00
//Curent Syndicates rank\exp
Affiliations: [affiliationsSchema],
//Syndicates Missions complate(Navigation->Syndicate)
CompletedSyndicates: [String],
//Daily Syndicates Exp
DailyAffiliation: { type: Number, default: 16000 },
DailyAffiliationPvp: { type: Number, default: 16000 },
DailyAffiliationLibrary: { type: Number, default: 16000 },
DailyAffiliationCetus: { type: Number, default: 16000 },
DailyAffiliationQuills: { type: Number, default: 16000 },
DailyAffiliationSolaris: { type: Number, default: 16000 },
DailyAffiliationVentkids: { type: Number, default: 16000 },
DailyAffiliationVox: { type: Number, default: 16000 },
DailyAffiliationEntrati: { type: Number, default: 16000 },
DailyAffiliationNecraloid: { type: Number, default: 16000 },
DailyAffiliationZariman: { type: Number, default: 16000 },
DailyAffiliationKahl: { type: Number, default: 16000 },
DailyAffiliationCavia: { type: Number, default: 16000 },
DailyAffiliationHex: { type: Number, default: 16000 },
2024-02-12 14:31:28 +01:00
//Daily Focus limit
DailyFocus: { type: Number, default: 250000 },
2024-02-12 14:31:28 +01:00
//Focus XP per School
FocusXP: focusXPSchema,
//Curent active like Active school focuses is = "Zenurik"
FocusAbility: String,
//The treeways of the Focus school.(Active and passive Ability)
2025-01-20 12:19:32 +01:00
FocusUpgrades: [focusUpgradeSchema],
2024-02-12 14:31:28 +01:00
//Achievement
ChallengeProgress: [challengeProgressSchema],
//Account Item like Ferrite,Form,Kuva etc
MiscItems: [typeCountSchema],
//Non Upgrade Mods Example:I have 999 item WeaponElectricityDamageMod (only "ItemCount"+"ItemType")
RawUpgrades: [RawUpgrades],
//Upgrade Mods\Riven\Arcane Example:"UpgradeFingerprint"+"ItemType"+""
2025-01-20 12:19:32 +01:00
Upgrades: [upgradeSchema],
2024-02-12 14:31:28 +01:00
//The Mandachord(Octavia) is a step sequencer
StepSequencers: [StepSequencersSchema],
KubrowPetEggs: [kubrowPetEggSchema],
2024-02-12 14:31:28 +01:00
//Prints Cat(3 Prints)\Kubrow(2 Prints) Pets
KubrowPetPrints: [Schema.Types.Mixed],
//Item for EquippedGear example:Scaner,LoadoutTechSummon etc
Consumables: [typeCountSchema],
//Weel Emotes+Gear
EquippedEmotes: [String],
EquippedGear: [String],
//Equipped Shawzin
EquippedInstrument: String,
ReceivedStartingGear: Boolean,
ArchwingEnabled: Boolean,
//Use Operator\Drifter
UseAdultOperatorLoadout: Boolean,
//Operator
OperatorLoadOuts: [operatorConfigSchema],
//Drifter
AdultOperatorLoadOuts: [operatorConfigSchema],
// Kahl
KahlLoadOuts: [operatorConfigSchema],
2024-02-12 14:31:28 +01:00
//LandingCraft like Liset
Ships: { type: [Schema.Types.ObjectId], ref: "Ships" },
2024-02-12 14:31:28 +01:00
// /Lotus/Types/Items/ShipDecos/
ShipDecorations: [typeCountSchema],
//Railjack/Components(https://warframe.fandom.com/wiki/Railjack/Components)
CrewShipRawSalvage: [typeCountSchema],
2024-02-12 14:31:28 +01:00
//Default RailJack
CrewShipAmmo: [typeCountSchema],
CrewShipWeapons: [Schema.Types.Mixed],
CrewShipWeaponSkins: [upgradeSchema],
2024-02-12 14:31:28 +01:00
//NPC Crew and weapon
CrewMembers: [Schema.Types.Mixed],
CrewShipSalvagedWeaponSkins: [Schema.Types.Mixed],
CrewShipSalvagedWeapons: [Schema.Types.Mixed],
//Complete Mission\Quests
Missions: [missionSchema],
2024-02-12 14:31:28 +01:00
QuestKeys: [questKeysSchema],
ActiveQuest: { type: String, default: "" },
2024-02-12 14:31:28 +01:00
//item like DojoKey or Boss missions key
LevelKeys: [Schema.Types.Mixed],
//Active quests
Quests: [Schema.Types.Mixed],
//Cosmetics like profile glyphs\Kavasa Prime Kubrow Collar\Game Theme etc
FlavourItems: [FlavourItemSchema],
//Mastery Rank*(Need item XPInfo to rank up)
PlayerLevel: { type: Number, default: 0 },
2024-02-12 14:31:28 +01:00
//Item Mastery Rank exp
XPInfo: [TypeXPItemSchema],
//Mastery Rank next availability
TrainingDate: { type: Date, default: new Date(0) },
2024-02-12 14:31:28 +01:00
//you saw last played Region when you opened the star map
LastRegionPlayed: String,
//Blueprints for Foundry
Recipes: [typeCountSchema],
//Crafting Blueprint(Item Name + CompletionDate)
PendingRecipes: [pendingRecipeSchema],
//Skins for Suits, Weapons etc.
WeaponSkins: [weaponSkinsSchema],
//Ayatan Item
FusionTreasures: [fusionTreasuresSchema],
//only used for Maroo apparently - { "node": "TreasureTutorial", "state": "TS_COMPLETED" }
TauntHistory: { type: [tauntSchema], default: undefined },
2024-02-12 14:31:28 +01:00
//noShow2FA,VisitPrimeVault etc
WebFlags: Schema.Types.Mixed,
//Id CompletedAlerts
CompletedAlerts: [String],
//Warframe\Duviri
StoryModeChoice: { type: String, default: "WARFRAME" },
2024-02-12 14:31:28 +01:00
//Alert->Kuva Siphon
PeriodicMissionCompletions: [periodicMissionCompletionsSchema],
//Codex->LoreFragment
LoreFragmentScans: [loreFragmentScansSchema],
//Resource,Credit,Affinity etc or Bless any boosters
Boosters: [boosterSchema],
BlessingCooldown: Date, // Date convert to IMongoDate
//the color your clan requests like Items/Research/DojoColors/DojoColorPlainsB
ActiveDojoColorResearch: String,
SentientSpawnChanceBoosters: Schema.Types.Mixed,
QualifyingInvasions: [Schema.Types.Mixed],
FactionScores: [Number],
2025-01-06 01:21:37 +01:00
// https://warframe.fandom.com/wiki/Specter_(Tenno)
PendingSpectreLoadouts: { type: [spectreLoadoutsSchema], default: undefined },
SpectreLoadouts: { type: [spectreLoadoutsSchema], default: undefined },
2024-02-12 14:31:28 +01:00
//New Quest Email
EmailItems: [TypeXPItemSchema],
//Profile->Wishlist
Wishlist: [String],
//https://warframe.fandom.com/wiki/Alignment
//like "Alignment": { "Wisdom": 9, "Alignment": 1 },
Alignment: Schema.Types.Mixed,
AlignmentReplay: Schema.Types.Mixed,
//https://warframe.fandom.com/wiki/Sortie
CompletedSorties: [String],
LastSortieReward: [Schema.Types.Mixed],
// Resource Extractor Drones
Drones: [droneSchema],
2024-02-12 14:31:28 +01:00
//Active profile ico
ActiveAvatarImageType: String,
// open location store like EidolonPlainsDiscoverable or OrbVallisCaveDiscoverable
DiscoveredMarkers: [Schema.Types.Mixed],
//Open location mission like "JobId" + "StageCompletions"
CompletedJobs: [Schema.Types.Mixed],
//Game mission\ivent score example "Tag": "WaterFight", "Best": 170, "Count": 1258,
PersonalGoalProgress: [Schema.Types.Mixed],
//Setting interface Style
ThemeStyle: String,
ThemeBackground: String,
ThemeSounds: String,
//Daily LoginRewards
LoginMilestoneRewards: [String],
//You first Dialog with NPC or use new Item
NodeIntrosCompleted: [String],
//Current guild id, if applicable.
GuildId: { type: Schema.Types.ObjectId, ref: "Guild" },
2024-02-12 14:31:28 +01:00
//https://warframe.fandom.com/wiki/Heist
//ProfitTaker(1-4) Example:"LocationTag": "EudicoHeists", "Jobs":Mission name
CompletedJobChains: [completedJobChainsSchema],
//Night Wave Challenge
SeasonChallengeHistory: [seasonChallengeHistorySchema],
LibraryPersonalTarget: String,
2024-02-12 14:31:28 +01:00
//Cephalon Simaris Entries Example:"TargetType"+"Scans"(1-10)+"Completed": true|false
LibraryPersonalProgress: [Schema.Types.Mixed],
//Cephalon Simaris Daily Task
LibraryAvailableDailyTaskInfo: libraryDailyTaskInfoSchema,
LibraryActiveDailyTaskInfo: libraryDailyTaskInfoSchema,
2024-02-12 14:31:28 +01:00
//https://warframe.fandom.com/wiki/Invasion
InvasionChainProgress: [Schema.Types.Mixed],
//CorpusLich or GrineerLich
NemesisAbandonedRewards: [String],
//CorpusLich\KuvaLich
NemesisHistory: [Schema.Types.Mixed],
LastNemesisAllySpawnTime: Schema.Types.Mixed,
//TradingRulesConfirmed,ShowFriendInvNotifications(Option->Social)
Settings: settingsSchema,
//Railjack craft
//https://warframe.fandom.com/wiki/Rising_Tide
PersonalTechProjects: [Schema.Types.Mixed],
//Modulars lvl and exp(Railjack|Duviri)
//https://warframe.fandom.com/wiki/Intrinsics
2025-01-06 05:36:18 +01:00
PlayerSkills: { type: playerSkillsSchema, default: {} },
2024-02-12 14:31:28 +01:00
//TradeBannedUntil data
TradeBannedUntil: Schema.Types.Mixed,
//https://warframe.fandom.com/wiki/Helminth
InfestedFoundry: infestedFoundrySchema,
NextRefill: Schema.Types.Mixed, // Date, convert to IMongoDate
//Purchase this new permanent skin from the Lotus customization options in Personal Quarters located in your Orbiter.
//https://warframe.fandom.com/wiki/Lotus#The_New_War
LotusCustomization: Schema.Types.Mixed,
//Progress+Rank+ItemType(ZarimanPumpShotgun)
//https://warframe.fandom.com/wiki/Incarnon
EvolutionProgress: { type: [evolutionProgressSchema], default: undefined },
2024-02-12 14:31:28 +01:00
//https://warframe.fandom.com/wiki/Loc-Pin
CustomMarkers: { type: [CustomMarkersSchema], default: undefined },
2024-02-12 14:31:28 +01:00
//Unknown and system
DuviriInfo: DuviriInfoSchema,
Mailbox: MailboxSchema,
HandlerPoints: Number,
ChallengesFixVersion: Number,
PlayedParkourTutorial: Boolean,
ActiveLandscapeTraps: [Schema.Types.Mixed],
RepVotes: [Schema.Types.Mixed],
LeagueTickets: [Schema.Types.Mixed],
HasContributedToDojo: Boolean,
HWIDProtectEnabled: Boolean,
LoadOutPresets: { type: Schema.Types.ObjectId, ref: "Loadout" },
CurrentLoadOutIds: [Schema.Types.Mixed],
RandomUpgradesIdentified: Number,
BountyScore: Number,
ChallengeInstanceStates: [Schema.Types.Mixed],
RecentVendorPurchases: [Schema.Types.Mixed],
Robotics: [Schema.Types.Mixed],
UsedDailyDeals: [Schema.Types.Mixed],
CollectibleSeries: [Schema.Types.Mixed],
HasResetAccount: { type: Boolean, default: false },
2024-02-12 14:31:28 +01:00
//Discount Coupon
PendingCoupon: pendingCouponSchema,
2024-02-12 14:31:28 +01:00
//Like BossAladV,BossCaptainVor come for you on missions % chance
DeathMarks: [String],
//Zanuka
Harvestable: Boolean,
//Grustag three
DeathSquadable: Boolean,
EndlessXP: { type: [endlessXpProgressSchema], default: undefined },
DialogueHistory: dialogueHistorySchema,
CalendarProgress: calenderProgressSchema
2024-02-12 14:31:28 +01:00
},
{ timestamps: { createdAt: "Created", updatedAt: false } }
2024-02-12 14:31:28 +01:00
);
inventorySchema.set("toJSON", {
2023-06-05 04:16:49 +08:00
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
2025-01-03 22:17:34 +01:00
delete returnedObject.accountOwnerId;
2023-09-11 13:20:07 +02:00
2024-02-12 14:31:28 +01:00
const inventoryDatabase = returnedObject as IInventoryDatabase;
2025-01-20 12:19:32 +01:00
const inventoryResponse = returnedObject as IInventoryClient;
2023-09-11 13:20:07 +02:00
2024-02-12 14:31:28 +01:00
inventoryResponse.TrainingDate = toMongoDate(inventoryDatabase.TrainingDate);
inventoryResponse.Created = toMongoDate(inventoryDatabase.Created);
if (inventoryDatabase.GuildId) {
inventoryResponse.GuildId = toOid(inventoryDatabase.GuildId);
}
if (inventoryDatabase.BlessingCooldown) {
2024-02-12 14:31:28 +01:00
inventoryResponse.BlessingCooldown = toMongoDate(inventoryDatabase.BlessingCooldown);
}
}
});
2024-02-12 14:31:28 +01:00
// type overwrites for subdocuments/subdocument arrays
2025-01-24 14:13:21 +01:00
export type InventoryDocumentProps = {
FlavourItems: Types.DocumentArray<IFlavourItem>;
RawUpgrades: Types.DocumentArray<IRawUpgrade>;
2025-01-20 12:19:32 +01:00
Upgrades: Types.DocumentArray<IUpgradeDatabase>;
MiscItems: Types.DocumentArray<IMiscItem>;
Boosters: Types.DocumentArray<IBooster>;
2025-01-20 12:19:32 +01:00
OperatorLoadOuts: Types.DocumentArray<IOperatorConfigDatabase>;
AdultOperatorLoadOuts: Types.DocumentArray<IOperatorConfigDatabase>;
KahlLoadOuts: Types.DocumentArray<IOperatorConfigDatabase>;
2024-01-25 14:49:45 +01:00
PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>;
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
QuestKeys: Types.DocumentArray<IQuestKeyDatabase>;
Drones: Types.DocumentArray<IDroneDatabase>;
CrewShipWeaponSkins: Types.DocumentArray<IUpgradeDatabase>;
} & { [K in TEquipmentKey]: Types.DocumentArray<IEquipmentDatabase> };
// eslint-disable-next-line @typescript-eslint/ban-types
type InventoryModelType = Model<IInventoryDatabase, {}, InventoryDocumentProps>;
2024-02-12 14:31:28 +01:00
export const Inventory = model<IInventoryDatabase, InventoryModelType>("Inventory", inventorySchema);
2025-01-03 22:17:34 +01:00
// eslint-disable-next-line @typescript-eslint/ban-types
export type TInventoryDatabaseDocument = Document<unknown, {}, IInventoryDatabase> &
Omit<
IInventoryDatabase & {
_id: Types.ObjectId;
} & {
__v: number;
},
keyof InventoryDocumentProps
> &
InventoryDocumentProps;