📜 ChangelogsVersion: v2.0
On this page
📜 Notable Versions
⚒️ Bug Fixes
Section titled “⚒️ Bug Fixes”- Fix
addXP(),removeXP(),setXP(),addLevel(),removeLevel(),setLevel(), andreset()auto-managing a"modified"flag on user records. Flags are developer-defined data; simply-xp no longer adds, removes, or interprets any flag value during XP/level operations. - Fix
Database.findOne(),find(),findAll(), andupdateOne()declaring variables directly insideswitch/caseblocks. - Fix use-before-define declarations in
Database.ts,connect.ts, andxplogs.ts, and a non-Unicode regex in the build script. No behavior change. - Fix circular imports across internal modules. Public exports and behavior are unchanged.
- Fix
connect()performing synchronous filesystem reads while detecting installed database adapters; it is now non-blocking. - Fix non-Unicode regular expressions in
cards.tsandutilities.ts.
✅ Additions
Section titled “✅ Additions”Database.find()andDatabase.findAll()now support an optionallimitparameter for top-N reads.leaderboard()now uses adapter-level limiting whenguildIdandlimitare provided.- Connect-time index enforcement now includes unique user records (
guild + user), unique level-role records (guild + level), and leaderboard ranking indexes for guild and global XP ordering. - Add
XpEvents.add(). Register event callbacks without replacing existing ones, and get back a function that removes them again.XpEvents.on()still holds a single callback object, so plugins (and anything that has to coexist with other listeners) should useadd(). - Add
Database.namespace()(a namespaced key/value store:get,set,delete,keys,clear) so plugins can persist their own data on both MongoDB and SQLite without touchingxp.databaseor the simply-xp tables. Storage is created lazily on first write, so plugins that never store anything cost nothing. - Add optional
Plugin.destroy()andunregisterPlugins(). Plugins can now clean up timers, handles, and listeners. Failures stay isolated per plugin, exactly like registration. - Add
Database.countUsersWithMoreXp(), the shared leaderboard position lookup used internally byfetch()andrankCard().
⭐ Improvements
Section titled “⭐ Improvements”- Bump
@napi-rs/canvasto V1. better-sqlite3V13 is now supported and tested. The supported range is V7 through V13.- The supported version ranges for
better-sqlite3andmongodbare now defined once, inconnect.ts, and read byMigrate.tsandutilities.tsinstead of being duplicated as separate hardcoded numbers in each file. - Database adapters (
better-sqlite3,mongodb) are now optional peer dependencies with explicit runtime detection. - Minimum supported Node.js lowered from
>=15.5.0to>=14.0.0for simply-xp itself. Note that the adapters set their own version requirements. On older runtimes, install an older adapter major. clean({ db: true })now performs awaited set-based cleanup and warns on cleanup failures instead of failing silently.- Card and chart renderers now always execute cleanup in
finallypaths, guaranteeing cache release on both success and error. fetch()andrankCard()position lookups now use adapter-specific count queries instead of loading full guild user arrays into memory.syncUsersXpRate()now performs set-based updates filtered byxp_ratemismatch instead of per-user read/write loops.leaderboard()now assignspositiondirectly onto each row instead of spreading it into a new object per row.
🔀 Changes
Section titled “🔀 Changes”registerPlugins()now returnsPromise<void>and should be awaited.updateOptions()now returnsPromise<void>and should be awaited.registerPlugins()version compatibility matching forrequiredVersionsis now deterministic.- Public
Plugin.initializetyping now explicitly accepts both synchronous and asynchronous initializers (void | Promise<void>). - Public
LevelRoletyping now reflects thatrolesmay be omitted when usingLevelRoles.delete()to remove a full level entry. - Missing adapter detection now throws a catchable
XpFatalwith codeSX_ADAPTER_MISSING. - Leaderboard tie ranking is now XP-only:
- Adapter-level sorting no longer applies a user-ID tiebreak.
leaderboard()now emits shared positions for equal XP, matchingfetch().
addXP()/removeXP()docs now explicitly describe intentional negative-delta behavior.- Build/publish scripts now compile (
tsc) before minifying and publishing, reducing stale publish artifact risk. - Linting moved from ESLint to Oxlint. Run it with
npm run lint(ornpm run lint:fix). - A small number of lint rules are switched off deliberately, each with the reason recorded in
.oxlintrc.json(e.g.unicorn/no-array-sortsuggestsArray#toSorted(), which needs Node 20 and would break the Node 14 floor). - Add a CI workflow that runs Oxlint, the typecheck, the build, and the regression suite on Node 22.
- Remove the
modulefield frompackage.json. It pointed atlib/xp.js, which is CommonJS, but bundlers readmoduleas an ESM entry point. They now correctly fall back tomain.
⚒️ Bug Fixes
Section titled “⚒️ Bug Fixes”- Fix
https()not preserving query strings and non-standard ports, not enforcing total request timeout, and not returning immediately on unexpected status codes. - Fix adapter version detection falsely reporting installed
better-sqlite3/mongodbpackages as missing on runtimes that require import attributes for JSON module loading. - Fix
connect()not remediating duplicate user and level-role records before uniqueness enforcement. It now remediates first and fails fast if uniqueness still cannot be guaranteed. - Fix
connect()andupdateOptions()not rejecting invalidxp_ratevalues (<= 0, non-finite), and ignoring explicitnotify: false. - Fix
connect()default database fallback not applying correctly when using normalizedoptions.type, and not consistently seedingxp.dbNamefor MongoDB. - Fix SQLite
connect()error handling swallowing non-coded setup errors; it now always rethrows with fullXpFatalcontext. - Fix
addXP()/removeXP()object validation rejecting valid zero values. - Fix
addXP(),removeXP(),setXP(),addLevel(), andremoveLevel()using read/modify/write flows vulnerable to race conditions. - Fix MongoDB add/remove mutation event deltas by using atomic pre-state snapshots (
findOneAndUpdatewithreturnDocument: "before") for delta paths. - Fix
setXP()not consistently recalculating level from resulting XP and not awaitinglevelUp/levelDowncallbacks. - Fix
fetch()auto-create flow callingcreate()with incorrect argument order. - Fix
fetch()triggering hidden cleanup side-effects. - Fix
reset()risking username-based targeting mismatches; it now updates and deletes by stableguild + useridentity. - Fix SQLite JSON parsing for
flagsandlevelrolefields not handling malformed payloads gracefully. - Fix SQLite level-role schema compatibility by migrating legacy
gidcolumn usage toguildand normalizing parser fallback. - Fix
LevelRolesSQLite and MongoDB query paths not consistently matching records bylevelrole.level, causing update and delete misses. - Fix
LevelRoles.add(),delete(),set(), anddeleteAll()returning errors withfalseinstead of throwingXpFatallike the rest of the public API.deleteAll()and the “remove some roles” path ofdelete()also now reportfalsewhen nothing was actually deleted. - Fix
create()throwing on MongoDB, but not SQLite, when called for a user that already exists. - Fix
compareCard()auto-create guard validatinguser2data againstuser1. - Fix
rankCard(),charts(), andleaderboardCard()not guarding math and fallback paths for zero or invalid totals and missing guild images. - Fix
Migrate.roleSetup()SQLite flow using schema-rebuild behavior instead of transactional row migration. - Fix
registerPlugins()surfacing unhandled rejections on async failures; they are now routed throughXpLog. - Fix
setLevel(),addLevel(), andremoveLevel()not firinglevelUp/levelDownevents. - Fix
updateOptions()MongoDB policy drift by enforcing the same minimum version floor asconnect()(v4+). - Fix the bundled
Baloo2-Regular.woff2fallback font not being produced by the build. - Fix unnecessary escape sequences in the
SX_ADAPTER_MISSINGmessage templates, and an unused catch binding inupdateOptions().
❌ Removals
Section titled “❌ Removals”- Remove the
auto_cleanoption fromconnect(),updateOptions(), and thexpruntime surface (XPClient). - Remove support for MongoDB v3. The minimum supported version is now v4.
- Remove the deprecated top-level compatibility aliases. Use
DatabaseandMigratedirectly. - Remove the unsupported
Plugin.functionsfrom the public plugin contract. - Remove ESLint entirely. Oxlint replaces it.