UNPKG

warframe-worldstate-parser

Version:

An Open parser for Warframe's Worldstate in Javascript

81 lines (80 loc) 2.76 kB
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs"; import { WorldStateObject } from "./WorldStateObject.mjs"; import { SyndicateJob } from "./SyndicateJob.mjs"; import { Type } from "class-transformer"; import { IsArray, IsString, ValidateNested } from "class-validator"; import { fromNow, node, syndicate, timeDeltaToString } from "warframe-worldstate-data/utilities"; //#region lib/models/SyndicateMission.ts /** * Represents a syndicate daily mission * @augments {WorldStateObject} */ var SyndicateMission = class SyndicateMission extends WorldStateObject { /** * The syndicate that is offering the mission * @type {string} */ syndicate; /** * The syndicate that is offering the mission * @type {string} */ syndicateKey; /** * The nodes on which the missions are taking place * @type {Array.<string>} */ nodes; /** * The jobs for this syndicate. Will normally be [] * @type {Array.<SyndicateJob>} */ jobs; /** * Build a new SyndicateMission with async operations & data * @param data The syndicate mission data * @param deps The dependencies object * @param deps.locale Locale to use for translations * @returns SyndicateMission object w/ async resolution of jobs */ static async build(data, deps = { locale: "en" }) { const syndicateMission = new SyndicateMission(data, deps); if (data.Jobs?.length) syndicateMission.jobs = await Promise.all(data.Jobs.map((job) => SyndicateJob.build(job, syndicateMission.expiry, deps))); else syndicateMission.jobs = []; return syndicateMission; } /** * @param data The syndicate mission data * @param deps The dependencies object * @param deps.locale Locale to use for translations */ constructor(data, { locale = "en" } = { locale: "en" }) { super(data); this.syndicate = syndicate(data.Tag, locale); this.syndicateKey = syndicate(data.Tag, "en"); this.nodes = data.Nodes.map((n) => node(n, locale)); this.jobs = []; this.id = `${this.expiry.getTime()}${data.Tag}`; } /** * Time delta string from now to the expiry */ get eta() { return timeDeltaToString(fromNow(this.expiry)); } }; __decorate([IsString(), __decorateMetadata("design:type", String)], SyndicateMission.prototype, "syndicate", void 0); __decorate([IsString(), __decorateMetadata("design:type", String)], SyndicateMission.prototype, "syndicateKey", void 0); __decorate([ IsArray(), IsString({ each: true }), __decorateMetadata("design:type", Array) ], SyndicateMission.prototype, "nodes", void 0); __decorate([ IsArray(), ValidateNested({ each: true }), Type(() => SyndicateJob), __decorateMetadata("design:type", Array) ], SyndicateMission.prototype, "jobs", void 0); //#endregion export { SyndicateMission };