mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-28 06:20:11 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
295276a581 | ||
|
|
46bb280690 | ||
|
|
cda030d74e | ||
|
|
79534f2e9d | ||
|
|
e6c12634e9 | ||
|
|
a41e646d3d | ||
|
|
a72e4545a3 | ||
|
|
0785436e2f | ||
|
|
5cd2511798 | ||
|
|
b760be279a | ||
|
|
c47e14570d | ||
|
|
30f95bc938 | ||
|
|
fe220db046 | ||
|
|
2f3b892feb | ||
|
|
574e5c12bd | ||
|
|
3eb77eb89e | ||
|
|
cbee43cdcd | ||
|
|
ecb4c336c0 | ||
|
|
9b68f04fb7 | ||
|
|
82f8ec4366 | ||
|
|
92b6632981 |
33
.github/workflows/check-deno.yml
vendored
33
.github/workflows/check-deno.yml
vendored
@@ -1,33 +0,0 @@
|
||||
name: Deno
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
check_deno:
|
||||
name: Ensure Deno types are in sync with the code
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout Project
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
cache: 'yarn'
|
||||
node-version-file: package.json
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Run Check Script
|
||||
run: node ./scripts/actions/report-deno-not-ran.mjs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
41
.github/workflows/validate-pull-request.yml
vendored
Normal file
41
.github/workflows/validate-pull-request.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: Validate Pull Request
|
||||
on:
|
||||
pull_request:
|
||||
jobs:
|
||||
deno:
|
||||
name: Ensure Deno types are synchronized
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout Project
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
cache: 'yarn'
|
||||
node-version-file: package.json
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Run Check Script
|
||||
run: node ./scripts/actions/report-deno-not-ran.mjs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
validate-supported-versions:
|
||||
runs-on: ubuntu-latest
|
||||
name: Disallow unsupported API versions
|
||||
steps:
|
||||
- name: Check for unsupported API changes
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
PATTERNS="gateway/v6.ts|gateway/v8.ts|payloads/v6/|payloads/v8/|rest/v6/|rest/v8/|rpc/v8.ts|utils/v8.ts|voice/v8.ts|^v6.ts$|^v8.ts$"
|
||||
|
||||
if gh pr view ${{ github.event.pull_request.number }} --repo ${{github.repository}} --json files --jq ".files[].path | select(test(\"$PATTERNS\"))" | grep -q .; then
|
||||
echo "::error::Unsupported API versions modified. Please make changes to current API versions only."
|
||||
exit 1
|
||||
fi
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -66,3 +66,5 @@ docs/*
|
||||
|
||||
# djs repo clone
|
||||
djs
|
||||
|
||||
_generated_
|
||||
|
||||
@@ -38,3 +38,5 @@ utils/v8.ts
|
||||
v8.ts
|
||||
|
||||
.yarn/*
|
||||
djs/*
|
||||
_generated_
|
||||
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,3 +1,22 @@
|
||||
## [0.38.17](https://github.com/discordjs/discord-api-types/compare/0.38.16...0.38.17) (2025-07-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **auditLog:** add `AUTO_MODERATION_QUARANTINE_USER` ([#1310](https://github.com/discordjs/discord-api-types/issues/1310)) ([a72e454](https://github.com/discordjs/discord-api-types/commit/a72e4545a3409388a9c5ec0b5555ecc258de0ac2))
|
||||
* **GuildMemberFlags:** add `AutoModQuarantinedGuildTag` ([#1309](https://github.com/discordjs/discord-api-types/issues/1309)) ([a41e646](https://github.com/discordjs/discord-api-types/commit/a41e646d3d9b9f6bb15c2f6165043ef8042b26bf))
|
||||
|
||||
|
||||
|
||||
## [0.38.16](https://github.com/discordjs/discord-api-types/compare/0.38.15...0.38.16) (2025-07-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **APIApplicationCommandChannelOption:** exclude directory channels ([#1300](https://github.com/discordjs/discord-api-types/issues/1300)) ([574e5c1](https://github.com/discordjs/discord-api-types/commit/574e5c12bddd2c515fd2b96b5705b5ef9f9d2787))
|
||||
|
||||
|
||||
|
||||
## [0.38.15](https://github.com/discordjs/discord-api-types/compare/0.38.14...0.38.15) (2025-07-03)
|
||||
|
||||
|
||||
|
||||
19
deno/CHANGELOG.md
generated
19
deno/CHANGELOG.md
generated
@@ -1,3 +1,22 @@
|
||||
## [0.38.17](https://github.com/discordjs/discord-api-types/compare/0.38.16...0.38.17) (2025-07-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **auditLog:** add `AUTO_MODERATION_QUARANTINE_USER` ([#1310](https://github.com/discordjs/discord-api-types/issues/1310)) ([a72e454](https://github.com/discordjs/discord-api-types/commit/a72e4545a3409388a9c5ec0b5555ecc258de0ac2))
|
||||
* **GuildMemberFlags:** add `AutoModQuarantinedGuildTag` ([#1309](https://github.com/discordjs/discord-api-types/issues/1309)) ([a41e646](https://github.com/discordjs/discord-api-types/commit/a41e646d3d9b9f6bb15c2f6165043ef8042b26bf))
|
||||
|
||||
|
||||
|
||||
## [0.38.16](https://github.com/discordjs/discord-api-types/compare/0.38.15...0.38.16) (2025-07-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **APIApplicationCommandChannelOption:** exclude directory channels ([#1300](https://github.com/discordjs/discord-api-types/issues/1300)) ([574e5c1](https://github.com/discordjs/discord-api-types/commit/574e5c12bddd2c515fd2b96b5705b5ef9f9d2787))
|
||||
|
||||
|
||||
|
||||
## [0.38.15](https://github.com/discordjs/discord-api-types/compare/0.38.14...0.38.15) (2025-07-03)
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ApplicationCommandOptionType } from './shared.ts';
|
||||
|
||||
export interface APIApplicationCommandChannelOption
|
||||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Channel> {
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[];
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM | ChannelType.GuildDirectory>[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase<
|
||||
|
||||
4
deno/payloads/v10/auditLog.ts
generated
4
deno/payloads/v10/auditLog.ts
generated
@@ -207,6 +207,7 @@ export enum AuditLogEvent {
|
||||
AutoModerationBlockMessage,
|
||||
AutoModerationFlagToChannel,
|
||||
AutoModerationUserCommunicationDisabled,
|
||||
AutoModerationQuarantineUser,
|
||||
|
||||
CreatorMonetizationRequestCreated = 150,
|
||||
CreatorMonetizationTermsAccepted,
|
||||
@@ -232,6 +233,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_name?: string;
|
||||
/**
|
||||
@@ -241,6 +243,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_trigger_type?: AuditLogRuleTriggerType;
|
||||
/**
|
||||
@@ -272,6 +275,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
|
||||
|
||||
4
deno/payloads/v10/guild.ts
generated
4
deno/payloads/v10/guild.ts
generated
@@ -803,6 +803,10 @@ export enum GuildMemberFlags {
|
||||
* Member has dismissed the DM settings upsell
|
||||
*/
|
||||
DmSettingsUpsellAcknowledged = 1 << 9,
|
||||
/**
|
||||
* Member's guild tag is blocked by AutoMod
|
||||
*/
|
||||
AutoModQuarantinedGuildTag = 1 << 10,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ApplicationCommandOptionType } from './shared.ts';
|
||||
|
||||
export interface APIApplicationCommandChannelOption
|
||||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Channel> {
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[];
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM | ChannelType.GuildDirectory>[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase<
|
||||
|
||||
4
deno/payloads/v9/auditLog.ts
generated
4
deno/payloads/v9/auditLog.ts
generated
@@ -207,6 +207,7 @@ export enum AuditLogEvent {
|
||||
AutoModerationBlockMessage,
|
||||
AutoModerationFlagToChannel,
|
||||
AutoModerationUserCommunicationDisabled,
|
||||
AutoModerationQuarantineUser,
|
||||
|
||||
CreatorMonetizationRequestCreated = 150,
|
||||
CreatorMonetizationTermsAccepted,
|
||||
@@ -232,6 +233,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_name?: string;
|
||||
/**
|
||||
@@ -241,6 +243,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_trigger_type?: AuditLogRuleTriggerType;
|
||||
/**
|
||||
@@ -272,6 +275,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
|
||||
|
||||
4
deno/payloads/v9/guild.ts
generated
4
deno/payloads/v9/guild.ts
generated
@@ -795,6 +795,10 @@ export enum GuildMemberFlags {
|
||||
* Member has dismissed the DM settings upsell
|
||||
*/
|
||||
DmSettingsUpsellAcknowledged = 1 << 9,
|
||||
/**
|
||||
* Member's guild tag is blocked by AutoMod
|
||||
*/
|
||||
AutoModQuarantinedGuildTag = 1 << 10,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -250,6 +250,8 @@ export default config([
|
||||
|
||||
'djs/**/*',
|
||||
'.yarn/*',
|
||||
|
||||
'_generated_/**/*',
|
||||
],
|
||||
},
|
||||
commonRuleset,
|
||||
|
||||
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord-api-types",
|
||||
"version": "0.38.15",
|
||||
"version": "0.38.17",
|
||||
"description": "Discord API typings that are kept up to date for use in bot library creation.",
|
||||
"homepage": "https://discord-api-types.dev",
|
||||
"workspaces": [
|
||||
@@ -96,7 +96,8 @@
|
||||
"scripts": {
|
||||
"build:ci": "tsc --noEmit --incremental false",
|
||||
"build:deno": "node ./scripts/deno.mjs",
|
||||
"build:node": "tsc && run-p 'esm:*'",
|
||||
"build:generated": "tsx ./scripts/generate-prettier-routes-interface.ts",
|
||||
"build:node": "yarn build:generated && tsc && run-p 'esm:*'",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
||||
"ci:pr": "run-s changelog lint build:deno && node ./scripts/bump-website-version.mjs",
|
||||
"clean:deno": "rimraf deno/",
|
||||
@@ -113,7 +114,7 @@
|
||||
"lint": "prettier --write . && eslint --format=pretty --fix --ext mjs,ts \"{gateway,payloads,rest,rpc,voice,utils}/**/*.ts\" \"{globals,v*}.ts\" \"scripts/**/*.mjs\"",
|
||||
"postinstallDev": "is-ci || husky",
|
||||
"prepack": "run-s clean test:lint build:node",
|
||||
"postpack": "run-s clean:node build:deno",
|
||||
"postpack": "run-s clean:node build:deno && git checkout -- './deno/**/*.ts' './rest/**/*.ts'",
|
||||
"test:lint": "prettier --check . && eslint --format=pretty --ext mjs,ts \"{gateway,payloads,rest,rpc,voice,utils}/**/*.ts\" \"{globals,v*}.ts\" \"scripts/**/*.mjs\"",
|
||||
"test:types": "tsc -p tests"
|
||||
},
|
||||
@@ -126,6 +127,7 @@
|
||||
"author": "Vlad Frangu <me@vladfrangu.dev>",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"_generated_/**/*.{js,js.map,d.ts,d.ts.map,mjs}",
|
||||
"{gateway,payloads,rest,rpc,voice,utils}/**/*.{js,js.map,d.ts,d.ts.map,mjs}",
|
||||
"{globals,v*}.{js,js.map,d.ts,d.ts.map,mjs}"
|
||||
],
|
||||
@@ -155,8 +157,9 @@
|
||||
"prettier": "^3.5.3",
|
||||
"pretty-quick": "^4.1.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"ts-morph": "^26.0.0",
|
||||
"tsutils": "^3.21.0",
|
||||
"tsx": "^4.19.4",
|
||||
"tsx": "^4.20.3",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.33.0"
|
||||
},
|
||||
@@ -206,7 +209,7 @@
|
||||
},
|
||||
"packageManager": "yarn@4.9.2",
|
||||
"volta": {
|
||||
"node": "24.3.0",
|
||||
"node": "24.4.1",
|
||||
"yarn": "4.9.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ApplicationCommandOptionType } from './shared';
|
||||
|
||||
export interface APIApplicationCommandChannelOption
|
||||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Channel> {
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[];
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM | ChannelType.GuildDirectory>[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase<
|
||||
|
||||
@@ -207,6 +207,7 @@ export enum AuditLogEvent {
|
||||
AutoModerationBlockMessage,
|
||||
AutoModerationFlagToChannel,
|
||||
AutoModerationUserCommunicationDisabled,
|
||||
AutoModerationQuarantineUser,
|
||||
|
||||
CreatorMonetizationRequestCreated = 150,
|
||||
CreatorMonetizationTermsAccepted,
|
||||
@@ -232,6 +233,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_name?: string;
|
||||
/**
|
||||
@@ -241,6 +243,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_trigger_type?: AuditLogRuleTriggerType;
|
||||
/**
|
||||
@@ -272,6 +275,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
|
||||
|
||||
@@ -803,6 +803,10 @@ export enum GuildMemberFlags {
|
||||
* Member has dismissed the DM settings upsell
|
||||
*/
|
||||
DmSettingsUpsellAcknowledged = 1 << 9,
|
||||
/**
|
||||
* Member's guild tag is blocked by AutoMod
|
||||
*/
|
||||
AutoModQuarantinedGuildTag = 1 << 10,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ApplicationCommandOptionType } from './shared';
|
||||
|
||||
export interface APIApplicationCommandChannelOption
|
||||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Channel> {
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[];
|
||||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM | ChannelType.GuildDirectory>[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase<
|
||||
|
||||
@@ -207,6 +207,7 @@ export enum AuditLogEvent {
|
||||
AutoModerationBlockMessage,
|
||||
AutoModerationFlagToChannel,
|
||||
AutoModerationUserCommunicationDisabled,
|
||||
AutoModerationQuarantineUser,
|
||||
|
||||
CreatorMonetizationRequestCreated = 150,
|
||||
CreatorMonetizationTermsAccepted,
|
||||
@@ -232,6 +233,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_name?: string;
|
||||
/**
|
||||
@@ -241,6 +243,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
auto_moderation_rule_trigger_type?: AuditLogRuleTriggerType;
|
||||
/**
|
||||
@@ -272,6 +275,7 @@ export interface APIAuditLogOptions {
|
||||
* - AUTO_MODERATION_BLOCK_MESSAGE
|
||||
* - AUTO_MODERATION_FLAG_TO_CHANNEL
|
||||
* - AUTO_MODERATION_USER_COMMUNICATION_DISABLED
|
||||
* - AUTO_MODERATION_QUARANTINE_USER
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
|
||||
|
||||
@@ -795,6 +795,10 @@ export enum GuildMemberFlags {
|
||||
* Member has dismissed the DM settings upsell
|
||||
*/
|
||||
DmSettingsUpsellAcknowledged = 1 << 9,
|
||||
/**
|
||||
* Member's guild tag is blocked by AutoMod
|
||||
*/
|
||||
AutoModQuarantinedGuildTag = 1 << 10,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"semanticCommits": "enabled",
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true,
|
||||
"schedule": ["before 1pm on friday"]
|
||||
"schedule": ["before 1pm on friday"],
|
||||
"automerge": true
|
||||
},
|
||||
"ignorePaths": ["website/"],
|
||||
"packageRules": [
|
||||
@@ -12,7 +13,8 @@
|
||||
"matchUpdateTypes": ["patch", "minor"],
|
||||
"matchCurrentVersion": "!/^0/",
|
||||
"groupName": "patch/minor dependencies",
|
||||
"groupSlug": "all-non-major"
|
||||
"groupSlug": "all-non-major",
|
||||
"automerge": true
|
||||
},
|
||||
{
|
||||
"groupName": "eslint/prettier",
|
||||
|
||||
232
scripts/generate-prettier-routes-interface.ts
Normal file
232
scripts/generate-prettier-routes-interface.ts
Normal file
@@ -0,0 +1,232 @@
|
||||
import { readdirSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import type {
|
||||
InterfaceDeclaration,
|
||||
ObjectLiteralExpression,
|
||||
ParameterDeclaration,
|
||||
ParameterDeclarationStructure,
|
||||
TypeParameterDeclaration,
|
||||
TypeParameterDeclarationStructure,
|
||||
} from 'ts-morph';
|
||||
import { Project, SyntaxKind } from 'ts-morph';
|
||||
|
||||
const RoutesInterfaceName = 'RoutesDeclarations';
|
||||
const CDNRoutesInterfaceName = 'CDNRoutesDeclarations';
|
||||
|
||||
const isInWebsite = __dirname.includes('website');
|
||||
|
||||
const extraPath = isInWebsite ? '../' : '';
|
||||
|
||||
const versions = readdirSync(join(__dirname, extraPath, '../rest')).filter((dir) => /^v\d+$/.exec(dir));
|
||||
|
||||
const generatedRestDirectory = join(__dirname, extraPath, '../_generated_/rest');
|
||||
const globalsFilePath = join(__dirname, extraPath, '../globals.ts');
|
||||
|
||||
function parameterDeclarationToStructure(parameter: ParameterDeclaration): ParameterDeclarationStructure {
|
||||
const obj = parameter.getStructure();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
obj.hasQuestionToken = obj.hasQuestionToken || Boolean(obj.initializer);
|
||||
|
||||
delete obj.initializer;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function typeParameterToStructure(typeParameter: TypeParameterDeclaration): TypeParameterDeclarationStructure {
|
||||
// eslint-disable-next-line sonarjs/prefer-immediate-return
|
||||
const obj = typeParameter.getStructure();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function handleTypeParameter(typeParameter: TypeParameterDeclaration, allSeen: Set<string>) {
|
||||
const extendsClause = typeParameter.getConstraint();
|
||||
|
||||
if (!extendsClause) {
|
||||
return;
|
||||
}
|
||||
|
||||
const type = extendsClause.getText();
|
||||
|
||||
if (allSeen.has(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
allSeen.add(type);
|
||||
|
||||
if (type === 'StorePageAssetFormat') {
|
||||
allSeen.add('ImageFormat');
|
||||
}
|
||||
}
|
||||
|
||||
function handleObject(object: ObjectLiteralExpression, interfaceToAddTo: InterfaceDeclaration) {
|
||||
const seenTypeParameters = new Set<string>();
|
||||
|
||||
for (const property of object.getPropertiesWithComments()) {
|
||||
const castedMethod = property.asKindOrThrow(SyntaxKind.MethodDeclaration);
|
||||
|
||||
const methodName = castedMethod.getName();
|
||||
const methodParameters = castedMethod.getParameters();
|
||||
let methodReturnType = castedMethod.getReturnType().getText();
|
||||
const methodDocs = castedMethod.getJsDocs();
|
||||
|
||||
const returnBody = castedMethod
|
||||
.getChildren()
|
||||
?.at(-1)
|
||||
?.getChildren()
|
||||
?.at(1)
|
||||
?.getChildren()
|
||||
?.at(-1)
|
||||
?.asKindOrThrow(SyntaxKind.ReturnStatement);
|
||||
|
||||
const asExpression = returnBody?.getChildrenOfKind(SyntaxKind.AsExpression)[0];
|
||||
|
||||
const unionType = asExpression?.getChildrenOfKind(SyntaxKind.UnionType)?.[0];
|
||||
|
||||
// Override with union if it exists in the cast
|
||||
if (unionType) {
|
||||
methodReturnType = unionType
|
||||
.getText()
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
if (methodReturnType.startsWith('| ')) {
|
||||
methodReturnType = methodReturnType.slice(2);
|
||||
}
|
||||
|
||||
const typeParameters = castedMethod.getTypeParameters();
|
||||
|
||||
for (const typeParameter of typeParameters) {
|
||||
handleTypeParameter(typeParameter, seenTypeParameters);
|
||||
}
|
||||
|
||||
interfaceToAddTo.addMethod({
|
||||
name: methodName,
|
||||
parameters: methodParameters.map(parameterDeclarationToStructure),
|
||||
typeParameters: typeParameters.map(typeParameterToStructure),
|
||||
returnType: methodReturnType,
|
||||
leadingTrivia:
|
||||
methodDocs
|
||||
.map((doc) => doc.getText().replaceAll('Routes.', `${RoutesInterfaceName}.`))
|
||||
.join('\n')
|
||||
.replaceAll('\t', '') + '\n',
|
||||
});
|
||||
|
||||
for (const overload of castedMethod.getOverloads()) {
|
||||
const typeParameters = overload.getTypeParameters();
|
||||
|
||||
for (const typeParameter of typeParameters) {
|
||||
handleTypeParameter(typeParameter, seenTypeParameters);
|
||||
}
|
||||
|
||||
interfaceToAddTo.addMethod({
|
||||
name: overload.getName(),
|
||||
parameters: overload.getParameters().map(parameterDeclarationToStructure),
|
||||
typeParameters: typeParameters.map(typeParameterToStructure),
|
||||
returnType: overload.getReturnType().getText(),
|
||||
leadingTrivia:
|
||||
overload
|
||||
.getJsDocs()
|
||||
.map((doc) => doc.getText().replaceAll('Routes.', `${RoutesInterfaceName}.`))
|
||||
.join('\n')
|
||||
.replaceAll('\t', '') + '\n',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return seenTypeParameters;
|
||||
}
|
||||
|
||||
for (const version of versions) {
|
||||
console.log(`Generating interfaces for ${version}...`);
|
||||
|
||||
const inputFilePath = join(__dirname, extraPath, `../rest/${version}/index.ts`);
|
||||
const generatedRestInterfacesFilePath = join(__dirname, extraPath, `../_generated_/rest/${version}/interfaces.ts`);
|
||||
|
||||
const project = new Project({});
|
||||
|
||||
project.addSourceFileAtPathIfExists(inputFilePath);
|
||||
project.addSourceFileAtPathIfExists(globalsFilePath);
|
||||
project.createDirectory(generatedRestDirectory);
|
||||
|
||||
const generatedRestInterfacesFile = project.createSourceFile(generatedRestInterfacesFilePath, undefined, {
|
||||
overwrite: true,
|
||||
});
|
||||
|
||||
const routesDeclarationInterface = generatedRestInterfacesFile.addInterface({
|
||||
name: RoutesInterfaceName,
|
||||
leadingTrivia: '// Automatically generated interface from the Routes object.\n',
|
||||
isExported: true,
|
||||
});
|
||||
|
||||
const cdnRoutesDeclarationInterface = generatedRestInterfacesFile.addInterface({
|
||||
name: CDNRoutesInterfaceName,
|
||||
leadingTrivia: '// Automatically generated interface from the CDN Routes object.\n',
|
||||
isExported: true,
|
||||
});
|
||||
|
||||
generatedRestInterfacesFile.addImportDeclaration({
|
||||
moduleSpecifier: '../../../globals',
|
||||
namedImports: ['Snowflake'],
|
||||
isTypeOnly: true,
|
||||
});
|
||||
|
||||
const routesObjectFile = project.getSourceFileOrThrow(inputFilePath);
|
||||
|
||||
routesObjectFile.addImportDeclaration({
|
||||
moduleSpecifier: `../../_generated_/rest/${version}/interfaces`,
|
||||
isTypeOnly: true,
|
||||
namedImports: [RoutesInterfaceName, CDNRoutesInterfaceName],
|
||||
});
|
||||
|
||||
routesObjectFile.addExportDeclaration({
|
||||
isTypeOnly: true,
|
||||
moduleSpecifier: `../../_generated_/rest/${version}/interfaces`,
|
||||
leadingTrivia: '// Exports all generated interfaces from the REST API.\n',
|
||||
});
|
||||
|
||||
const routesObject = routesObjectFile.getVariableDeclarationOrThrow('Routes');
|
||||
const cdnRoutesObject = routesObjectFile.getVariableDeclaration('CDNRoutes');
|
||||
|
||||
if (!cdnRoutesObject) {
|
||||
console.log('Skipping type generation for', version);
|
||||
continue;
|
||||
}
|
||||
|
||||
const routesObjectChildren = routesObject.getChildren();
|
||||
const cdnRoutesObjectChildren = cdnRoutesObject.getChildren();
|
||||
|
||||
const [routesIdentifier] = routesObjectChildren;
|
||||
|
||||
const routesObjectDeclaration = routesObject.getInitializerOrThrow();
|
||||
const [cdnRoutesIdentifier] = cdnRoutesObjectChildren;
|
||||
const cdnRoutesObjectDeclaration = cdnRoutesObject.getInitializerOrThrow();
|
||||
|
||||
const importsNeededForRoutes = handleObject(
|
||||
routesObjectDeclaration.asKindOrThrow(SyntaxKind.ObjectLiteralExpression),
|
||||
routesDeclarationInterface,
|
||||
);
|
||||
|
||||
const importsNeededForCDNRoutes = handleObject(
|
||||
cdnRoutesObjectDeclaration.asKindOrThrow(SyntaxKind.ObjectLiteralExpression),
|
||||
cdnRoutesDeclarationInterface,
|
||||
);
|
||||
|
||||
const typesToImportFromOriginalFile = new Set<string>([...importsNeededForRoutes, ...importsNeededForCDNRoutes]);
|
||||
|
||||
if (typesToImportFromOriginalFile.size > 0) {
|
||||
generatedRestInterfacesFile.addImportDeclaration({
|
||||
moduleSpecifier: `../../../rest/${version}/index`,
|
||||
isTypeOnly: true,
|
||||
namedImports: [...typesToImportFromOriginalFile].sort((a, b) => a.localeCompare(b)),
|
||||
});
|
||||
}
|
||||
|
||||
routesIdentifier.replaceWithText(`Routes: ${RoutesInterfaceName}`);
|
||||
cdnRoutesIdentifier.replaceWithText(`CDNRoutes: ${CDNRoutesInterfaceName}`);
|
||||
|
||||
project.saveSync();
|
||||
}
|
||||
980
website/package-lock.json
generated
980
website/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"docusaurus": "docusaurus",
|
||||
"start": "npm run clean && docusaurus start",
|
||||
"build": "npm run clean && cross-env NODE_OPTIONS=\"--max_old_space_size=7500\" docusaurus build",
|
||||
"build": "npm run clean && cp ../scripts/generate-prettier-routes-interface.ts ./scripts/generate-prettier-routes-interface.ts && npx tsx ./scripts/generate-prettier-routes-interface.ts && cross-env NODE_OPTIONS=\"--max_old_space_size=7500\" docusaurus build",
|
||||
"swizzle": "docusaurus swizzle",
|
||||
"deploy": "docusaurus deploy",
|
||||
"clear": "docusaurus clear",
|
||||
@@ -47,7 +47,8 @@
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"sass": "^1.81.0",
|
||||
"swr": "^2.2.5"
|
||||
"swr": "^2.2.5",
|
||||
"ts-morph": "^26.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@apify/docusaurus-plugin-typedoc-api": "^4.3.1",
|
||||
@@ -66,6 +67,7 @@
|
||||
"patch-package": "^8.0.0",
|
||||
"prettier": "^3.4.1",
|
||||
"pretty-quick": "^4.0.0",
|
||||
"tsx": "^4.20.3",
|
||||
"typedoc": "^0.27.1",
|
||||
"typedoc-plugin-djs-links": "^2.2.1",
|
||||
"typedoc-plugin-markdown": "^4.3.0",
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"entryPoints":{"v10":{"path":"v10.ts","label":"API v10"},"v9":{"path":"v9.ts","label":"API v9"},"voice/v4":{"path":"voice/v4.ts","label":"Voice v4"},"voice/v8":{"path":"voice/v8.ts","label":"Voice v8"},"globals":{"path":"globals.ts","label":"Global Types"}},"packageRoot":"/home/runner/work/discord-api-types/discord-api-types/","packagePath":"./","packageSlug":"discord-api-types","packageName":"discord-api-types","packageVersion":"0.38.15"}]
|
||||
[{"entryPoints":{"v10":{"path":"v10.ts","label":"API v10"},"v9":{"path":"v9.ts","label":"API v9"},"voice/v4":{"path":"voice/v4.ts","label":"Voice v4"},"voice/v8":{"path":"voice/v8.ts","label":"Voice v8"},"globals":{"path":"globals.ts","label":"Global Types"}},"packageRoot":"/home/runner/work/discord-api-types/discord-api-types/","packagePath":"./","packageSlug":"discord-api-types","packageName":"discord-api-types","packageVersion":"0.38.17"}]
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
@@ -1,3 +1,3 @@
|
||||
[
|
||||
"0.38.15"
|
||||
"0.38.17"
|
||||
]
|
||||
Reference in New Issue
Block a user