@toebean/npc-vortex-api
Version:
A utility package for npc for Vortex.
270 lines • 16.9 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.untrackMod = exports.trackMod = exports.resolveCollectionUrl = exports.rateCollectionRevision = exports.getValidationResult = exports.getTrending = exports.getTrackedMods = exports.getRecentlyUpdatedMods = exports.getRateLimits = exports.getMyCollections = exports.getModInfo = exports.getModFiles = exports.getLatestUpdated = exports.getLatestAdded = exports.getGames = exports.getGameInfo = exports.getFileInfo = exports.getFileByMd5 = exports.getEndorsements = exports.getDownloadUrls = exports.getColorSchemes = exports.getCollections = exports.getCollectionRevision = exports.getCollection = exports.getChangelogs = exports.endorseMod = exports.schemas = void 0;
const path_1 = require("path");
const npc_1 = require("@toebean/npc");
const zod_1 = require("zod");
const schemas_1 = require("./schemas");
const namespace = (0, path_1.join)('vortex', 'nexus');
exports.schemas = __importStar(require("./schemas"));
/**
* Endorse or abstain from endorsing a mod.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.endorseMod}
*/
const endorseMod = async (options) => schemas_1.iEndorseResponseSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'endorseMod'), ...options }));
exports.endorseMod = endorseMod;
/**
* Retrieve all changelogs for a mod.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getChangelogs}
*/
const getChangelogs = async (options) => schemas_1.iChangelogsSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getChangelogs'), ...options }));
exports.getChangelogs = getChangelogs;
/**
* Retrieves details about a collection.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getCollection}
*/
const getCollection = async (options) => schemas_1.iCollectionSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getCollection'), ...options }));
exports.getCollection = getCollection;
/**
* Retrieves details about a collection revision.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getCollectionRevision}
*/
const getCollectionRevision = async (options) => schemas_1.iRevisionSchema.parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getCollectionRevision'),
...options,
}));
exports.getCollectionRevision = getCollectionRevision;
/**
* Retrieves all collections for a game.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getCollections}
*/
const getCollections = async (options) => schemas_1.iCollectionSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getCollections'),
...options,
}));
exports.getCollections = getCollections;
/**
* Retrieves a list of color schemes used by Nexus Mods.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getColorSchemes}
*/
const getColorSchemes = async (options) => schemas_1.iColourSchemeSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getColorSchemes'),
...options,
}));
exports.getColorSchemes = getColorSchemes;
/**
* Retrieves a list of download links for a file.
* @remarks If the user isn't premium on Nexus Mods, this requires a key that can only be generated on the website.
* The key is part of the `nxm:` links which are generated for the "Download with Manager" button on the website.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getDownloadUrls}
*/
const getDownloadUrls = async (options) => schemas_1.iDownloadURLSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getDownloadUrls'),
...options,
}));
exports.getDownloadUrls = getDownloadUrls;
/**
* Retrieves a list of endorsements the user has given.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getEndorsements}
*/
const getEndorsements = async (options) => schemas_1.iEndorsementSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getEndorsements'),
...options,
}));
exports.getEndorsements = getEndorsements;
/**
* Searches for a file by md5 hash and retrieves information about all matching files.
* Can be used to lookup a file when you don't know its Nexus Mods mod and file id.
* @remarks Note that there may be multiple files matching the same md5 hash, as multiple users may have uploaded the same file or (less likely),
* md5 hash collisions are possible and the file may be completely unrelated but happens to have the same hash. It is your responsibility to filter the
* list of results and determine whether any of them match the file you are looking for, e.g. by comparing file size, contents, name of the mod, etc.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getFileByMd5}
*/
const getFileByMd5 = async (options) => schemas_1.iMD5ResultSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getFileByMd5'),
...options,
}));
exports.getFileByMd5 = getFileByMd5;
/**
* Retrieves details about a file.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getFileInfo}
*/
const getFileInfo = async (options) => schemas_1.iFileInfoSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getFileInfo'), ...options }));
exports.getFileInfo = getFileInfo;
/**
* Retrieves details about a specific game.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getGameInfo}
*/
const getGameInfo = async (options) => schemas_1.iGameInfoSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getGameInfo'), ...options }));
exports.getGameInfo = getGameInfo;
/**
* Retrieves a list of all games currently supported by Nexus Mods.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getGames}
*/
const getGames = async (options) => schemas_1.iGameListEntrySchema
.array()
.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getGames'), ...options }));
exports.getGames = getGames;
/**
* Retrieves a list of the latest added mods for a game.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getLatestAdded}
*/
const getLatestAdded = async (options) => schemas_1.iModInfoSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getLatestAdded'),
...options,
}));
exports.getLatestAdded = getLatestAdded;
/**
* Retrieves a list of the latest updated mods for a game.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getLatestUpdated}
*/
const getLatestUpdated = async (options) => schemas_1.iModInfoSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getLatestUpdated'),
...options,
}));
exports.getLatestUpdated = getLatestUpdated;
/**
* Retrieves a list of files uploaded for a mod.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getModFiles}
*/
const getModFiles = async (options) => schemas_1.iModFilesSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getModFiles'), ...options }));
exports.getModFiles = getModFiles;
/**
* Retrieves details about a mod.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getModInfo}
*/
const getModInfo = async (options) => schemas_1.iModInfoSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getModInfo'), ...options }));
exports.getModInfo = getModInfo;
/**
* Retrieves a list of collections the user has created.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getMyCollections}
*/
const getMyCollections = async (options) => schemas_1.iRevisionSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getMyCollections'),
...options,
}));
exports.getMyCollections = getMyCollections;
/**
* Retrieves information about the rate limits for the user.
* @remarks This call does not affect your rate limits.
* @returns A {@link !Promise Promise} which when resolved, passes details of the user's remaining rate limits to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getRateLimits}
*/
const getRateLimits = async (options) => zod_1.z.object({ daily: zod_1.z.number(), hourly: zod_1.z.number() }).parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getRateLimits'),
...options,
}));
exports.getRateLimits = getRateLimits;
/**
* Retrieves a list of mods that have recently been updated for a game.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getRecentlyUpdatedMods}
*/
const getRecentlyUpdatedMods = async (options) => schemas_1.iUpdateEntrySchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getRecentlyUpdatedMods'),
...options,
}));
exports.getRecentlyUpdatedMods = getRecentlyUpdatedMods;
/**
* Retrieves a list of all mods the user is tracking.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getTrackedMods}
*/
const getTrackedMods = async (options) => schemas_1.iTrackedModSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getTrackedMods'),
...options,
}));
exports.getTrackedMods = getTrackedMods;
/**
* Retrieves a list of trending mods for a game.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getTrending}
*/
const getTrending = async (options) => schemas_1.iModInfoSchema
.array()
.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'getTrending'), ...options }));
exports.getTrending = getTrending;
/**
* Retrieves the last key validation result.
* @remarks This call does not affect your rate limits.
* @returns A {@link !Promise Promise} which when resolved, passes the last key validation result to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.getValidationResult}
*/
const getValidationResult = async (options) => schemas_1.iValidateKeyResponseSchema.parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'getValidationResult'),
...options,
}));
exports.getValidationResult = getValidationResult;
/**
* Rate a collection revision.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.rateCollectionRevision}
*/
const rateCollectionRevision = async (options) => zod_1.z.any().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'rateCollectionRevision'),
...options,
}));
exports.rateCollectionRevision = rateCollectionRevision;
/**
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.resolveCollectionUrl}
*/
const resolveCollectionUrl = async (options) => schemas_1.iDownloadURLSchema.array().parse(await (0, npc_1.call)({
endpoint: (0, path_1.join)(namespace, 'resolveCollectionUrl'),
...options,
}));
exports.resolveCollectionUrl = resolveCollectionUrl;
/**
* Track a mod.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.trackMod}
*/
const trackMod = async (options) => schemas_1.iTrackedModSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'trackMod'), ...options }));
exports.trackMod = trackMod;
/**
* Stop tracking a mod.
* @returns A {@link !Promise Promise} which when resolved, passes the response from the Nexus Mods API to its {@link !Promise.then then} handler(s).
* @see {@link https://toebeann.github.io/npc-vortex-api/stable/?page=nexus.Function.untrackMod}
*/
const untrackMod = async (options) => schemas_1.iTrackedModSchema.parse(await (0, npc_1.call)({ endpoint: (0, path_1.join)(namespace, 'untrackMod'), ...options }));
exports.untrackMod = untrackMod;
//# sourceMappingURL=index.js.map