Skip to content

fix(plugin-gateway): drop the @discordjs/structures dev snapshot dependency - #127

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
claude/issue-121-drop-structures
Sep 26, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
claude/issue-121-drop-structures

Conversation

@RedStar071

Copy link
Copy Markdown
Member

🔗 Linked issue

Part of #121 (item 6: production dependency on a @discordjs/structures dev snapshot).

🧭 Context

@wolfstar/plugin-gateway pinned @discordjs/[email protected]. That snapshot, and its @discordjs/formatters dependency, declare engines.node >= 24.17.0, which the package had to pass on to every consumer. Dev tags can also disappear or change. The package only used a small part of it: the Structure base, BitField/PermissionsBitField, four flags bitfields, and the Partialize type.

📚 Description

The parts that were used are now copied into the package (about 330 lines), and the dependency is removed. The source is the upstream TypeScript at the snapshot's own commit (dbb749062), checked against the snapshot's dist.

  • Symbols: kData, kPatch and kClone keep their Symbol.for("djs.structures.*") keys, so they are the same symbols @discordjs/structures uses. Mixin's enrichToJSON hook still works through the same djs.structures.mixin.toJSON key. A new test checks the keys.
  • Public API unchanged: I built main first and diffed the export lists. The built index.d.ts declares the same 296 exports and index.js exposes the same 153 runtime exports, and neither references @discordjs/structures any more.
  • Engines: with the snapshot gone, the strictest remaining requirement is Node 20: @discordjs/core, @discordjs/ws, @wolfstar/plugin-cache and the peer @wolfstar/http-framework all require >=20. The source uses nothing newer than Node 20; the newest API is Array#toSorted. So engines.node goes from >=24.17.0 to >=20.0.0, like the other packages in this repo.
  • Attribution: upstream is Apache-2.0 and ships a LICENSE but no NOTICE. Each adapted file starts with a /*! … */ block naming the source, both copyright holders and the license, and saying what was changed (section 4(b)). /*! survives bundling; I checked it is present in dist.

Worth knowing when reviewing:

  • Structure no longer extends an upstream class; it declares those members itself. Its unused second type parameter is renamed _Omitted so the unused-parameter check passes. Callers pass it by position, so nothing breaks.
  • BitField.resolve now only recognises this package's BitField instances. A bitfield built with the real @discordjs/structures would no longer resolve. Nothing in this repo does that.

Key changes

File Change
src/structures/Structure.ts upstream base (DataTemplate, constructor, kPatch, kClone, optimizeData, toJSON) merged in, replacing the BaseStructure.prototype[...].call workaround
src/util/BitField.ts, src/util/PermissionsBitField.ts copied from upstream instead of re-exported
src/util/flags.ts Activity/Attachment/Channel/MessageFlagsBitField now extend NumberFlagsBitField with the same behavior (resolve returns a bigint, toJSON a number)
src/util/types.ts internal Partialize (not re-exported)
package.json / pnpm-lock.yaml dependency removed (lockfile regenerated by pnpm); engines.node set to >=20.0.0
README, tests, changeset note updated; symbol-key test; patch

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Workflow / CI change

Pre-flight Checklist

  • I have read the Contributing Guidelines (if applicable)
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (42 files, 460 tests after merging main)
  • I have updated the documentation accordingly
  • I added a changeset with pnpm changeset

Also checked: pnpm lint, pnpm typecheck, and the builds of plugin-cache and plugin-gateway (attw and publint clean).

🤖 Generated with Claude Code

https://claude.ai/code/session_01RBWEHLtNzWNykJMPqeqqbB


Generated by Claude Code

…ndency

Adapt the parts of @discordjs/structures the package used into its own sources: the Structure
base (merged into Structure), BitField, PermissionsBitField, and the Partialize type, keeping
upstream's Apache-2.0 copyright notice in each file. The four flags bitfields it shipped now
derive from NumberFlagsBitField. kData, kPatch, and kClone keep their Symbol.for keys, so they
stay the very same symbols as upstream's.

Without the snapshot, the strictest remaining dependency requires Node.js 20, so engines.node
goes from >=24.17.0 to >=20.0.0. The built export list is unchanged.

Refs #121

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RBWEHLtNzWNykJMPqeqqbB
@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

◈ PR Lens

🟢 +2 new · 🟠 ~4 changed · 🔴 -1 removed · 2 flows · 13 files · commit 14b1e81


Architecture

Architecture diagram for wolfstar-project/plugins at 14b1e81

7 components touched across 5 lanes.

Play the interactive walkthrough


Inside the changed components — 2 views

Component view — Data structures

In-tree Structure base class and entity models replacing @⁠discordjs/structures

Architecture view of Component view — Data structures in wolfstar-project/plugins

Component view — Bitfields and permissions

In-tree BitField base, PermissionsBitField, and flag utilities

Architecture view of Component view — Bitfields and permissions in wolfstar-project/plugins

Data flow

Data flow diagram for wolfstar-project/plugins at 14b1e81

Patching and cloning a structure · Evaluating permissions with admin override

Follow each request, response and payload


The other flows — 1 sequence

Evaluating permissions with admin override

Sequence diagram of Evaluating permissions with admin override in wolfstar-project/plugins

View

  • Architecture lens
  • Data flow lens
  • Expand every detail

Tip

The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change

🪧 More tips
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists
  • Untick Architecture lens or Data flow lens under View to hide a diagram, or tick Expand every detail to open every section. The comment redraws in a few seconds
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through
  • Open a diagram on the canvas, then press W or click play to walk through the change one step at a time
  • The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture and data flow row. Drawing still runs as before
  • Set github.draw: on-demand in .github/pr-lens.yml and PR Lens stops drawing pull requests on its own. Comment @pr-lens draw on a pull request when you want that one drawn
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works
  • Push a commit and the drawing stays, with a note that it is out of date. Tick Redraw in the note to draw the new head
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion

Thanks for using PR Lens! It's built by Coldtea, free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

@wolfstarbot wolfstarbot added the packages:plugin-gateway Changes in plugin-gateway label Sep 26, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the full diff replacing @discordjs/structures with an in-package reimplementation.

  • Structure base: DataTemplate, constructor, kPatch, kClone, optimizeData, and toJSON are now defined directly on Structure instead of delegating to BaseStructure.prototype[...].call(...). kData/kPatch/kClone keep the same Symbol.for("djs.structures.*") keys, verified by a new test.
  • BitField/PermissionsBitField: copied from upstream instead of re-exported; NumberFlagsBitField (unchanged, pre-existing in this package) continues to convert 32-bit numeric enum flags to bigint via resolve/toJSON.
  • flags.ts: Activity/Attachment/Channel/MessageFlagsBitField now extend NumberFlagsBitField directly instead of the upstream re-exports, with identical resolve/toJSON behavior.
  • types.ts: internal Partialize type, replacing the upstream import.
  • package.json/lockfile: dependency removed, engines.node widened from >=24.17.0 to >=20.0.0, matching every other package in the monorepo.
  • README/tests/changeset: attribution note updated, a symbol-identity test added, changeset added.

I traced Structure's constructor/[kPatch]/[kClone]/toJSON and the BitField/PermissionsBitField/flags class hierarchy against the described upstream behavior and didn't find a behavioral divergence. Each adapted file carries a /*! attribution header naming the source, copyright holders, license, and what changed, which is sufficient given the repo itself is Apache-2.0 licensed (same license, so the existing root LICENSE file already satisfies redistribution). engines.node: >=20.0.0 matches plugin-cache, plugin-api, plugin-logger, plugin-i18next, plugin-sharder, and plugin-subcommands-advanced. Remaining @discordjs/structures mentions in Mixin.ts/Channel.ts are design-convention references, not stale import claims, so they're still accurate.

Pullfrog  | View workflow run | Using Claude Sonnet | 𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages:plugin-gateway Changes in plugin-gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants