Updated types
This commit is contained in:
parent
223acdc708
commit
c51864317b
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/10ScopesAndTypes/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/10ScopesAndTypes/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/10ScopesAndTypes/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/10ScopesAndTypes/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/10ScopesAndTypes/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/10ScopesAndTypes/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/11BundleLoadingSample/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/11BundleLoadingSample/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/11BundleLoadingSample/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/11BundleLoadingSample/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/11BundleLoadingSample/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/11BundleLoadingSample/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/12ClassExtensionOverride/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/12ClassExtensionOverride/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/12ClassExtensionOverride/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/12ClassExtensionOverride/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/12ClassExtensionOverride/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/12ClassExtensionOverride/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/13.1AddTraderWithAssortJSON/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/13.1AddTraderWithAssortJSON/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/13.1AddTraderWithAssortJSON/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/13.1AddTraderWithAssortJSON/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/13.1AddTraderWithAssortJSON/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/13.1AddTraderWithAssortJSON/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/13AddTrader/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/13AddTrader/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/13AddTrader/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/13AddTrader/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/13AddTrader/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/13AddTrader/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/14AfterDBLoadHook/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/14AfterDBLoadHook/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/14AfterDBLoadHook/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/14AfterDBLoadHook/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/14AfterDBLoadHook/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/14AfterDBLoadHook/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/15HttpListenerExample/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/15HttpListenerExample/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/15HttpListenerExample/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/15HttpListenerExample/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/15HttpListenerExample/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/15HttpListenerExample/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/16ImporterUtil/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/16ImporterUtil/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/16ImporterUtil/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/16ImporterUtil/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/16ImporterUtil/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/16ImporterUtil/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/17AsyncImporterWithDependency1/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/17AsyncImporterWithDependency1/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/17AsyncImporterWithDependency1/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/17AsyncImporterWithDependency1/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
@ -3,11 +3,13 @@ import { OnUpdate } from "@spt/di/OnUpdate";
|
|||||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { SaveServer } from "@spt/servers/SaveServer";
|
import { SaveServer } from "@spt/servers/SaveServer";
|
||||||
|
import { BackupService } from "@spt/services/BackupService";
|
||||||
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
export declare class SaveCallbacks implements OnLoad, OnUpdate {
|
||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
|
protected backupService: BackupService;
|
||||||
protected coreConfig: ICoreConfig;
|
protected coreConfig: ICoreConfig;
|
||||||
constructor(saveServer: SaveServer, configServer: ConfigServer);
|
constructor(saveServer: SaveServer, configServer: ConfigServer, backupService: BackupService);
|
||||||
onLoad(): Promise<void>;
|
onLoad(): Promise<void>;
|
||||||
getRoute(): string;
|
getRoute(): string;
|
||||||
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
onUpdate(secondsSinceLastRun: number): Promise<boolean>;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||||
|
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IDeleteFriendRequest } from "@spt/models/eft/dialog/IDeleteFriendRequest";
|
||||||
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
import { IFriendRequestData } from "@spt/models/eft/dialog/IFriendRequestData";
|
||||||
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
import { IFriendRequestSendResponse } from "@spt/models/eft/dialog/IFriendRequestSendResponse";
|
||||||
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
import { IGetAllAttachmentsResponse } from "@spt/models/eft/dialog/IGetAllAttachmentsResponse";
|
||||||
@ -20,11 +23,13 @@ export declare class DialogueController {
|
|||||||
protected saveServer: SaveServer;
|
protected saveServer: SaveServer;
|
||||||
protected timeUtil: TimeUtil;
|
protected timeUtil: TimeUtil;
|
||||||
protected dialogueHelper: DialogueHelper;
|
protected dialogueHelper: DialogueHelper;
|
||||||
|
protected notificationSendHelper: NotificationSendHelper;
|
||||||
|
protected profileHelper: ProfileHelper;
|
||||||
protected mailSendService: MailSendService;
|
protected mailSendService: MailSendService;
|
||||||
protected localisationService: LocalisationService;
|
protected localisationService: LocalisationService;
|
||||||
protected configServer: ConfigServer;
|
protected configServer: ConfigServer;
|
||||||
protected dialogueChatBots: IDialogueChatBot[];
|
protected dialogueChatBots: IDialogueChatBot[];
|
||||||
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
constructor(logger: ILogger, saveServer: SaveServer, timeUtil: TimeUtil, dialogueHelper: DialogueHelper, notificationSendHelper: NotificationSendHelper, profileHelper: ProfileHelper, mailSendService: MailSendService, localisationService: LocalisationService, configServer: ConfigServer, dialogueChatBots: IDialogueChatBot[]);
|
||||||
registerChatBot(chatBot: IDialogueChatBot): void;
|
registerChatBot(chatBot: IDialogueChatBot): void;
|
||||||
/** Handle onUpdate spt event */
|
/** Handle onUpdate spt event */
|
||||||
update(): void;
|
update(): void;
|
||||||
@ -151,4 +156,6 @@ export declare class DialogueController {
|
|||||||
protected messageHasExpired(message: IMessage): boolean;
|
protected messageHasExpired(message: IMessage): boolean;
|
||||||
/** Handle client/friend/request/send */
|
/** Handle client/friend/request/send */
|
||||||
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
sendFriendRequest(sessionID: string, request: IFriendRequestData): IFriendRequestSendResponse;
|
||||||
|
/** Handle client/friend/delete */
|
||||||
|
deleteFriend(sessionID: string, request: IDeleteFriendRequest): void;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
import { IItem } from "@spt/models/eft/common/tables/IItem";
|
||||||
|
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
|
||||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||||
import { BonusType } from "@spt/models/enums/BonusType";
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
@ -90,6 +91,24 @@ export declare class ProfileHelper {
|
|||||||
* @returns ISptProfile object
|
* @returns ISptProfile object
|
||||||
*/
|
*/
|
||||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Get full representation of a players profile JSON by the account ID, or undefined if not found
|
||||||
|
* @param accountId Account ID to find
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getFullProfileByAccountId(accountID: string): ISptProfile | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given session ID
|
||||||
|
* @param sessionID The session ID to return the profile for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromSessionId(sessionID: string): ISearchFriendResponse | undefined;
|
||||||
|
/**
|
||||||
|
* Retrieve a ChatRoomMember formatted profile for the given PMC profile data
|
||||||
|
* @param pmcProfile The PMC profile data to format into a ChatRoomMember structure
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getChatRoomMemberFromPmcProfile(pmcProfile: IPmcData): ISearchFriendResponse;
|
||||||
/**
|
/**
|
||||||
* Get a PMC profile by its session id
|
* Get a PMC profile by its session id
|
||||||
* @param sessionID Profile id to return
|
* @param sessionID Profile id to return
|
||||||
|
@ -8,4 +8,5 @@ export interface Info {
|
|||||||
Side: string;
|
Side: string;
|
||||||
Level: number;
|
Level: number;
|
||||||
MemberCategory: number;
|
MemberCategory: number;
|
||||||
|
SelectedMemberCategory: number;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ export interface ISptProfile {
|
|||||||
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
traderPurchases?: Record<string, Record<string, ITraderPurchaseData>>;
|
||||||
/** Achievements earned by player */
|
/** Achievements earned by player */
|
||||||
achievements: Record<string, number>;
|
achievements: Record<string, number>;
|
||||||
|
/** List of friend profile IDs */
|
||||||
|
friends: string[];
|
||||||
}
|
}
|
||||||
export declare class ITraderPurchaseData {
|
export declare class ITraderPurchaseData {
|
||||||
count: number;
|
count: number;
|
||||||
|
5
TypeScript/17AsyncImporterWithDependency2/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
5
TypeScript/17AsyncImporterWithDependency2/types/models/eft/ws/IWsFriendsListAccept.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||||
|
import { ISearchFriendResponse } from "../profile/ISearchFriendResponse";
|
||||||
|
export interface IWsFriendsListAccept extends IWsNotificationEvent {
|
||||||
|
profile: ISearchFriendResponse;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export interface IWsNotificationEvent {
|
export interface IWsNotificationEvent {
|
||||||
type: string;
|
type: string;
|
||||||
eventId: string;
|
eventId?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export declare enum ConfigTypes {
|
export declare enum ConfigTypes {
|
||||||
AIRDROP = "spt-airdrop",
|
AIRDROP = "spt-airdrop",
|
||||||
|
BACKUP = "spt-backup",
|
||||||
BOT = "spt-bot",
|
BOT = "spt-bot",
|
||||||
PMC = "spt-pmc",
|
PMC = "spt-pmc",
|
||||||
CORE = "spt-core",
|
CORE = "spt-core",
|
||||||
|
12
TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
12
TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IBackupConfig.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
|
||||||
|
export interface IBackupConfig extends IBaseConfig {
|
||||||
|
kind: "spt-backup";
|
||||||
|
enabled: boolean;
|
||||||
|
maxBackups: number;
|
||||||
|
directory: string;
|
||||||
|
backupInterval: IBackupConfigInterval;
|
||||||
|
}
|
||||||
|
export interface IBackupConfigInterval {
|
||||||
|
enabled: boolean;
|
||||||
|
intervalMinutes: number;
|
||||||
|
}
|
98
TypeScript/17AsyncImporterWithDependency2/types/services/BackupService.d.ts
vendored
Normal file
98
TypeScript/17AsyncImporterWithDependency2/types/services/BackupService.d.ts
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
|
import { IBackupConfig } from "@spt/models/spt/config/IBackupConfig";
|
||||||
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
export declare class BackupService {
|
||||||
|
protected logger: ILogger;
|
||||||
|
protected preSptModLoader: PreSptModLoader;
|
||||||
|
protected configServer: ConfigServer;
|
||||||
|
protected backupConfig: IBackupConfig;
|
||||||
|
protected readonly activeServerMods: string[];
|
||||||
|
protected readonly profileDir = "./user/profiles";
|
||||||
|
constructor(logger: ILogger, preSptModLoader: PreSptModLoader, configServer: ConfigServer);
|
||||||
|
/**
|
||||||
|
* Initializes the backup process.
|
||||||
|
*
|
||||||
|
* This method orchestrates the profile backup service. Handles copying profiles to a backup directory and cleaning
|
||||||
|
* up old backups if the number exceeds the configured maximum.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the backup process is complete.
|
||||||
|
*/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Fetches the names of all JSON files in the profile directory.
|
||||||
|
*
|
||||||
|
* This method normalizes the profile directory path and reads all files within it. It then filters the files to
|
||||||
|
* include only those with a `.json` extension and returns their names.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves to an array of JSON file names.
|
||||||
|
*/
|
||||||
|
protected fetchProfileFiles(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Check to see if the backup service is enabled via the config.
|
||||||
|
*
|
||||||
|
* @returns True if enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
protected isEnabled(): boolean;
|
||||||
|
/**
|
||||||
|
* Generates the target directory path for the backup. The directory path is constructed using the `directory` from
|
||||||
|
* the configuration and the current backup date.
|
||||||
|
*
|
||||||
|
* @returns The target directory path for the backup.
|
||||||
|
*/
|
||||||
|
protected generateBackupTargetDir(): string;
|
||||||
|
/**
|
||||||
|
* Generates a formatted backup date string in the format `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @returns The formatted backup date string.
|
||||||
|
*/
|
||||||
|
protected generateBackupDate(): string;
|
||||||
|
/**
|
||||||
|
* Cleans up old backups in the backup directory.
|
||||||
|
*
|
||||||
|
* This method reads the backup directory, and sorts backups by modification time. If the number of backups exceeds
|
||||||
|
* the configured maximum, it deletes the oldest backups.
|
||||||
|
*
|
||||||
|
* @returns A promise that resolves when the cleanup is complete.
|
||||||
|
*/
|
||||||
|
protected cleanBackups(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Retrieves and sorts the backup file paths from the specified directory.
|
||||||
|
*
|
||||||
|
* @param dir - The directory to search for backup files.
|
||||||
|
* @returns A promise that resolves to an array of sorted backup file paths.
|
||||||
|
*/
|
||||||
|
private getBackupPaths;
|
||||||
|
/**
|
||||||
|
* Compares two backup folder names based on their extracted dates.
|
||||||
|
*
|
||||||
|
* @param a - The name of the first backup folder.
|
||||||
|
* @param b - The name of the second backup folder.
|
||||||
|
* @returns The difference in time between the two dates in milliseconds, or `null` if either date is invalid.
|
||||||
|
*/
|
||||||
|
private compareBackupDates;
|
||||||
|
/**
|
||||||
|
* Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`.
|
||||||
|
*
|
||||||
|
* @param folderName - The name of the folder from which to extract the date.
|
||||||
|
* @returns A Date object if the folder name is in the correct format, otherwise null.
|
||||||
|
*/
|
||||||
|
private extractDateFromFolderName;
|
||||||
|
/**
|
||||||
|
* Removes excess backups from the backup directory.
|
||||||
|
*
|
||||||
|
* @param backups - An array of backup file names to be removed.
|
||||||
|
* @returns A promise that resolves when all specified backups have been removed.
|
||||||
|
*/
|
||||||
|
private removeExcessBackups;
|
||||||
|
/**
|
||||||
|
* Start the backup interval if enabled in the configuration.
|
||||||
|
*/
|
||||||
|
protected startBackupInterval(): void;
|
||||||
|
/**
|
||||||
|
* Get an array of active server mod details.
|
||||||
|
*
|
||||||
|
* @returns An array of mod names.
|
||||||
|
*/
|
||||||
|
protected getActiveServerMods(): string[];
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user