Skip to content
Version: v2.0
On this page

📜 Notable Versions

  • Fix addXP(), removeXP(), setXP(), addLevel(), removeLevel(), setLevel(), and reset() 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(), and updateOne() declaring variables directly inside switch/case blocks.
  • Fix use-before-define declarations in Database.ts, connect.ts, and xplogs.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.ts and utilities.ts.

  • Database.find() and Database.findAll() now support an optional limit parameter for top-N reads.
  • leaderboard() now uses adapter-level limiting when guildId and limit are 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 use add().
  • 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 touching xp.database or the simply-xp tables. Storage is created lazily on first write, so plugins that never store anything cost nothing.
  • Add optional Plugin.destroy() and unregisterPlugins(). 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 by fetch() and rankCard().
  • Bump @napi-rs/canvas to V1.
  • better-sqlite3 V13 is now supported and tested. The supported range is V7 through V13.
  • The supported version ranges for better-sqlite3 and mongodb are now defined once, in connect.ts, and read by Migrate.ts and utilities.ts instead 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.0 to >=14.0.0 for 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 finally paths, guaranteeing cache release on both success and error.
  • fetch() and rankCard() position lookups now use adapter-specific count queries instead of loading full guild user arrays into memory.
  • syncUsersXpRate() now performs set-based updates filtered by xp_rate mismatch instead of per-user read/write loops.
  • leaderboard() now assigns position directly onto each row instead of spreading it into a new object per row.
  • registerPlugins() now returns Promise<void> and should be awaited.
  • updateOptions() now returns Promise<void> and should be awaited.
  • registerPlugins() version compatibility matching for requiredVersions is now deterministic.
  • Public Plugin.initialize typing now explicitly accepts both synchronous and asynchronous initializers (void | Promise<void>).
  • Public LevelRole typing now reflects that roles may be omitted when using LevelRoles.delete() to remove a full level entry.
  • Missing adapter detection now throws a catchable XpFatal with code SX_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, matching fetch().
  • 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 (or npm 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-sort suggests Array#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 module field from package.json. It pointed at lib/xp.js, which is CommonJS, but bundlers read module as an ESM entry point. They now correctly fall back to main.
  • 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 / mongodb packages 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() and updateOptions() not rejecting invalid xp_rate values (<= 0, non-finite), and ignoring explicit notify: false.
  • Fix connect() default database fallback not applying correctly when using normalized options.type, and not consistently seeding xp.dbName for MongoDB.
  • Fix SQLite connect() error handling swallowing non-coded setup errors; it now always rethrows with full XpFatal context.
  • Fix addXP() / removeXP() object validation rejecting valid zero values.
  • Fix addXP(), removeXP(), setXP(), addLevel(), and removeLevel() using read/modify/write flows vulnerable to race conditions.
  • Fix MongoDB add/remove mutation event deltas by using atomic pre-state snapshots (findOneAndUpdate with returnDocument: "before") for delta paths.
  • Fix setXP() not consistently recalculating level from resulting XP and not awaiting levelUp / levelDown callbacks.
  • Fix fetch() auto-create flow calling create() with incorrect argument order.
  • Fix fetch() triggering hidden cleanup side-effects.
  • Fix reset() risking username-based targeting mismatches; it now updates and deletes by stable guild + user identity.
  • Fix SQLite JSON parsing for flags and levelrole fields not handling malformed payloads gracefully.
  • Fix SQLite level-role schema compatibility by migrating legacy gid column usage to guild and normalizing parser fallback.
  • Fix LevelRoles SQLite and MongoDB query paths not consistently matching records by levelrole.level, causing update and delete misses.
  • Fix LevelRoles.add(), delete(), set(), and deleteAll() returning errors with false instead of throwing XpFatal like the rest of the public API. deleteAll() and the “remove some roles” path of delete() also now report false when 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 validating user2 data against user1.
  • Fix rankCard(), charts(), and leaderboardCard() 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 through XpLog.
  • Fix setLevel(), addLevel(), and removeLevel() not firing levelUp / levelDown events.
  • Fix updateOptions() MongoDB policy drift by enforcing the same minimum version floor as connect() (v4+).
  • Fix the bundled Baloo2-Regular.woff2 fallback font not being produced by the build.
  • Fix unnecessary escape sequences in the SX_ADAPTER_MISSING message templates, and an unused catch binding in updateOptions().
  • Remove the auto_clean option from connect(), updateOptions(), and the xp runtime surface (XPClient).
  • Remove support for MongoDB v3. The minimum supported version is now v4.
  • Remove the deprecated top-level compatibility aliases. Use Database and Migrate directly.
  • Remove the unsupported Plugin.functions from the public plugin contract.
  • Remove ESLint entirely. Oxlint replaces it.