warframe-worldstate-parser
Version:
An Open parser for Warframe's Worldstate in Javascript
121 lines (120 loc) • 2.96 kB
TypeScript
/**
* @typedef {object} Identifier
* @property {string} $id older identifier schema
* @property {string} $oid newer global identifier schema
*/
/**
* @typedef {object} LegacyTimestamp
* @property {number} sec second-based timestamp
*/
/**
* @typedef {object} Timestamp
* @property {number} $numberLong millisecond-based timestamp
*/
/**
* @typedef {object} ContentTimestamp
* @property {LegacyTimestamp|Timestamp} $date timestamp number wrapper
*/
/**
* @typedef {object} BaseContentObject
* @property {Identifier} _id object identifier
* @property {ContentTimestamp} Activation activation timestamp
* @property {ContentTimestamp} Expiry expiry timestamp
*/
/**
* Represents a generic object from Worldstate
*/
export default class WorldstateObject {
/**
* @param {BaseContentObject} data The object data
*/
constructor(data: BaseContentObject);
/**
* The object's id field
* @type {Identifier.$id|Identifier.$oid}
*/
id: Identifier.$id | Identifier.$oid;
/**
* The date and time at which the void trader arrives
* @type {Date}
*/
activation: Date;
/**
* A string indicating how long it will take for the trader to arrive
* (at time of object creation)
* @type {string}
*/
startString: string;
/**
* The date and time at which the void trader leaves
* @type {Date}
*/
expiry: Date;
/**
* Whether the void trader is active (at time of object creation)
* @type {boolean}
*/
active: boolean;
/**
* Returns a string representation of the object
* @returns {string} basic representation from the id
*/
toString(): string;
/**
* Get whether the trader is currently active
* @returns {boolean} whether the trader is active
*/
isActive(): boolean;
/**
* Get a string indicating how long it will take for the trader to arrive
* @returns {string} time delta string from now to the start
*/
getStartString(): string;
/**
* Get a string indicating how long it will take for the trader to leave
* @returns {string} time delta string from now to the end
*/
getEndString(): string;
}
export type Identifier = {
/**
* older identifier schema
*/
$id: string;
/**
* newer global identifier schema
*/
$oid: string;
};
export type LegacyTimestamp = {
/**
* second-based timestamp
*/
sec: number;
};
export type Timestamp = {
/**
* millisecond-based timestamp
*/
$numberLong: number;
};
export type ContentTimestamp = {
/**
* timestamp number wrapper
*/
$date: LegacyTimestamp | Timestamp;
};
export type BaseContentObject = {
/**
* object identifier
*/
_id: Identifier;
/**
* activation timestamp
*/
Activation: ContentTimestamp;
/**
* expiry timestamp
*/
Expiry: ContentTimestamp;
};