8000 feat: @discordjs/structures by Qjuh · Pull Request #10900 · discordjs/discord.js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: @discordjs/structures #10900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
97037e7
chore: init /structures
ckohen Sep 2, 2023
b27c691
feat: base structure
ckohen Sep 2, 2023
4ff0ec4
feat: initial structures design attempt
ckohen Dec 5, 2023
6595b5a
refactor(Structure): use unknown to store in kData
ckohen Dec 6, 2023
8c414a9
feat(Structure): add Invite
ckohen Dec 7, 2023
8f429e1
refactor: symbol names and override location
ckohen Dec 7, 2023
45244e9
fix: don't possibly return 0 if discord borks
ckohen Dec 8, 2023
98b201f
refactor: use getter value instead of api
ckohen Dec 8, 2023
8d668ea
refactor: cache createdTimestamp value
ckohen Dec 8, 2023
12dd4e6
docs: better docs for what's done so far
ckohen Dec 9, 2023
2333bdf
feat: add Mixin
ckohen Feb 12, 2024
857e0a1
refactor(User): remove bitfield getters and add displayName
ckohen Feb 15, 2024
cdc212f
feat(structures): add Connection
ckohen Feb 15, 2024
9ef4007
feat(structures): add Channel base
ckohen Feb 15, 2024
44a456a
refactor(Mixin): trace prototype chain, allow construction
ckohen Mar 13, 2024
df65185
fix(structures): fix mixin behavior
ckohen Jan 14, 2025
30ff0d7
fix(structures): data optimization call behavior from perf testing
ckohen Jan 17, 2025
18e5204
feat: channel mixins
Qjuh May 15, 2025
a3ab941
chore: update deps
Qjuh May 15, 2025
a64387c
feat: channels and mixins
Qjuh May 16, 2025
5cd079c
chore: more typeguard tests
Qjuh May 16, 2025
d136d81
fix: tests and some other issues
Qjuh May 17, 2025
ff8f8bd
feat: add ChannelWebhookMixin
Qjuh May 17, 2025
589f90c
fix: more tests
Qjuh May 17, 2025
8b1e176
chore: tests and docs
Qjuh May 17, 2025
545cd60
chore: docs
Qjuh May 17, 2025
a37c546
fix: remove unneccessary omitted
Qjuh May 18, 2025
7483ae3
chore: apply code suggestions
Qjuh May 18, 2025
c08796d
refactor: change how extended invite works
Qjuh May 18, 2025
87e8d12
fix: type imports
Qjuh May 18, 2025
734c4d1
Apply suggestions from code review
Qjuh May 18, 2025
4618f18
fix: tests
Qjuh May 19, 2025
d45807b
chore: add jsdoc
Qjuh May 19, 2025
dd2f22e
refactor: apply code suggestions
Qjuh May 20, 2025
02b19bd
fix: don't instantiate sub-structures
Qjuh May 21, 2025
9fde895
fix: don't do null default twice
Qjuh May 21, 2025
153afb7
chore: use formatters, add _cache
Qjuh May 22, 2025
ad1b6f7
chore: lockfile
Qjuh May 22, 2025
9733b70
chore: move MixinTypes to declaratiion file
Qjuh May 23, 2025
ba4f5c2
fix: tests
Qjuh May 23, 2025
4e2de51
fix: don't include source d.ts files for docs
Qjuh May 23, 2025
4a09cc7
feat: bitfields
Qjuh May 23, 2025
edaeb7c
feat: more bitfields
Qjuh May 23, 2025
c17f0cd
Merge branch 'main' into feat/structures
Qjuh May 25, 2025
d965487
Merge branch 'main' into feat/structures
Qjuh May 29, 2025
f3cef03
Merge branch 'main' into feat/structures
Qjuh May 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pnpm-lock.yaml @discordjs/core
/packages/proxy-container/ @discordjs/proxy
/packages/rest/ @discordjs/rest
/packages/scripts/ @discordjs/scripts
/packages/structures/ @discordjs/structures
/packages/ui/ @discordjs/ui
/packages/util/ @discordjs/util
/packages/voice/ @discordjs/core
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/01-package_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ body:
- proxy
- proxy-container
- rest
- structures
- ui
- util
- voice
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/03-feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ body:
- proxy
- proxy-container
- rest
- structures
- ui
- util
- voice
Expand Down
3 changes: 3 additions & 0 deletions .github/issue-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ packages:proxy-container:
packages:rest:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nrest\\n"
packages:structures:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nstructures\\n"
packages:ui:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\ui\\n"
Expand Down
5 changes: 5 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ packages:rest:
- any-glob-to-any-file:
- packages/rest/*
- packages/rest/**/*
packages:structures:
- changed-files:
- any-glob-to-any-file:
- packages/structures/*
- packages/structures/**/*
packages:ui:
- changed-files:
- any-glob-to-any-file:
Expand Down
2 changes: 2 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
color: fbca04
- name: packages:rest
color: fbca04
- name: packages:structures
color: fbca04
- name: packages:ui
color: fbca04
- name: packages:util
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deprecate-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- '@discordjs/next'
- '@discordjs/proxy'
- '@discordjs/rest'
- '@discordjs/structures'
- '@discordjs/util'
- '@discordjs/voice'
- '@discordjs/ws'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
- name: Move docs to correct directory
if: ${{ env.REF_TYPE == 'branch' }}
run: |
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "formatters" "next" "proxy" "rest" "util" "voice" "ws")
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "formatters" "next" "proxy" "rest" "structures" "util" "voice" "ws")
for PACKAGE in "${PACKAGES[@]}"; do
if [[ "${PACKAGE}" == "discord.js" ]]; then
mkdir -p "out/${PACKAGE}"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
folder: 'proxy'
- package: '@discordjs/rest'
folder: 'rest'
- package: '@discordjs/structures'
folder: 'structures'
- package: '@discordjs/util'
folder: 'util'
- package: '@discordjs/voice'
Expand Down
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Imagine a bot... the most popular way to build discord bots",
"private": true,
"scripts": {
"build:copy_readme": "cpy \"../../packages/(discord.js|brokers|builders|collection|core|formatters|next|proxy|rest|util|voice|ws)/README.md\" \"src/assets/readme\" --rename='home-{{basename}}'",
"build:copy_readme": "cpy \"../../packages/(discord.js|brokers|builders|collection|core|formatters|next|proxy|rest|structures|util|voice|ws)/README.md\" \"src/assets/readme\" --rename='home-{{basename}}'",
"build:check": "tsc --noEmit",
"build:local": "cross-env NEXT_PUBLIC_LOCAL_DEV=true pnpm run build:prod",
"build:prod": "pnpm run build:copy_readme && pnpm run build:next",
Expand Down
1 change: 1 addition & 0 deletions apps/website/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const PACKAGES = [
{ name: 'next' },
{ name: 'proxy' },
{ name: 'rest' },
{ name: 'structures' },
{ name: 'util' },
{ name: 'voice' },
{ name: 'ws' },
Expand Down
7 changes: 7 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ export default tseslint.config(
'unicorn/prefer-node-protocol': 0,
},
},
{
files: [`packages/structures/**/*${commonFiles}`],
rules: {
'@typescript-eslint/no-empty-object-type': 0,
'@typescript-eslint/no-unsafe-declaration-merging': 0,
},
},
{
files: [`packages/voice/**/*${commonFiles}`],
rules: {
Expand Down
9 changes: 9 additions & 0 deletions packages/actions/src/uploadCoverage/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ runs:
flags: rest
token: ${{ inputs.CODECOV_TOKEN }}

- name: Upload Structures Coverage
if: ${{ hashFiles('packages/structures/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
with:
files: ./packages/structures/coverage/cobertura-coverage.xml
disable_search: true
flags: rest
token: ${{ inputs.CODECOV_TOKEN }}

- name: Upload Util Coverage
if: ${{ hashFiles('packages/util/coverage/cobertura-coverage.xml') != '' }}
uses: codecov/codecov-action@v4
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const PACKAGES = [
'next',
'proxy',
'rest',
'structures',
'util',
'voice',
'ws',
Expand Down
1 change: 1 addition & 0 deletions packages/structures/.cliff-jumperrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "name": "structures", "org": "discordjs", "packagePath": "packages/structures", "identifierBase": false }
28 changes: 28 additions & 0 deletions packages/structures/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Packages
node_modules

# Log files
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Env
.env

# Dist
dist
dist-docs

# Docs
docs/**/*
!docs/README.md

# Miscellaneous
.turbo
.tmp
coverage
2 changes: 2 additions & 0 deletions packages/structures/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/** @type {import('lint-staged').Config} */
module.exports = require('../../.lintstagedrc.json');
8 changes: 8 additions & 0 deletions packages/structures/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.turbo
coverage
dist
dist-docs
docs/docs.api.json
CHANGELOG.md
tsup.config.bundled*
vitest.config.ts.timestamp*
2 changes: 2 additions & 0 deletions packages/structures/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/** @type {import('prettier').Config} */
module.exports = require('../../.prettierrc.json');
191 changes: 191 additions & 0 deletions packages/structures/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

Copyright 2023 Noel Buechler
Copyright 2023 Chai Kohen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Loading
0