mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
fix(api)!: align error codes with throw sites and image bounds (#2488)
This commit is contained in:
1 parent
4534822355
commit
d5bfa5a73d
99 files changed
+857
-4853
No files matched your search
@@ -20,7 +20,7 @@ import {
|
||||
import {ChannelNicknameOverrides} from '@fluxer/schema/src/domains/channel/ChannelSchemas';
|
||||
import {ReadStateResponse} from '@fluxer/schema/src/domains/gateway/GatewaySchemas';
|
||||
import {ChannelOverwriteTypeSchema, GeneralChannelNameType} from '@fluxer/schema/src/primitives/ChannelValidators';
|
||||
import {createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {base64LengthForBytes, createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {ContentWarningLevelSchema} from '@fluxer/schema/src/primitives/GuildValidators';
|
||||
import {QueryBooleanType} from '@fluxer/schema/src/primitives/QueryValidators';
|
||||
import {
|
||||
@@ -118,7 +118,7 @@ const ChannelUpdateCommon = ChannelCommonBase.extend({
|
||||
'Legacy: setting true maps to nsfw_override=true; setting false maps to nsfw_override=null (inherit). Prefer nsfw_override.',
|
||||
),
|
||||
...ChannelContentWarningFields,
|
||||
icon: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
icon: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded icon image for group DM channels'),
|
||||
owner_id: SnowflakeType.nullish().describe('ID of the new owner for group DM channels'),
|
||||
@@ -181,7 +181,7 @@ const ChannelUpdateLinkRequest = ChannelUpdateCommon.extend({
|
||||
const ChannelUpdateGroupDmRequest = z.object({
|
||||
type: createNamedLiteral(ChannelTypes.GROUP_DM, 'GROUP_DM', 'Channel type (group DM)'),
|
||||
name: GeneralChannelNameType.nullish().describe('The name of the group DM'),
|
||||
icon: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
icon: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded icon image for the group DM'),
|
||||
owner_id: SnowflakeType.nullish().describe('ID of the new owner of the group DM'),
|
||||
|
||||
@@ -20,7 +20,7 @@ import {SudoVerificationSchema} from '@fluxer/schema/src/domains/auth/AuthSchema
|
||||
import {GuildFeatureSchema} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas';
|
||||
import {TemplateSerializedGuild} from '@fluxer/schema/src/domains/guild/GuildTemplateSchemas';
|
||||
import {VanityURLCodeType} from '@fluxer/schema/src/primitives/ChannelValidators';
|
||||
import {createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {base64LengthForBytes, createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {
|
||||
ContentWarningLevelSchema,
|
||||
DefaultMessageNotificationsSchema,
|
||||
@@ -52,7 +52,7 @@ function coerceBlankStringToNull(value: unknown): unknown {
|
||||
|
||||
export const GuildCreateRequest = z.object({
|
||||
name: createStringType(1, 100).describe('The name of the guild (1-100 characters)'),
|
||||
icon: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
icon: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded image data for the guild icon'),
|
||||
empty_features: z.boolean().optional().describe('Whether to create the guild without default features'),
|
||||
@@ -64,7 +64,7 @@ export type GuildCreateRequest = z.infer<typeof GuildCreateRequest>;
|
||||
export const GuildUpdateRequest = z
|
||||
.object({
|
||||
name: createStringType(1, 100).describe('The name of the guild (1-100 characters)'),
|
||||
icon: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
icon: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded image data for the guild icon'),
|
||||
system_channel_id: SnowflakeType.nullish().describe('The ID of the channel where system messages are sent'),
|
||||
@@ -108,13 +108,13 @@ export const GuildUpdateRequest = z
|
||||
GuildExplicitContentFilterSchema,
|
||||
'Level of content filtering for explicit media',
|
||||
),
|
||||
banner: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
banner: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded image data for the guild banner'),
|
||||
splash: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
splash: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded image data for the guild splash screen'),
|
||||
embed_splash: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
embed_splash: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded image data for the embedded invite splash'),
|
||||
splash_card_alignment: SplashCardAlignmentSchema.optional().describe(
|
||||
@@ -148,10 +148,10 @@ export const GuildMemberUpdateRequest = z.object({
|
||||
.optional()
|
||||
.transform((ids) => (ids ? new Set(ids) : undefined))
|
||||
.describe(`Array of role IDs to assign to the member (max ${MAX_GUILD_ROLES})`),
|
||||
avatar: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
avatar: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded image data for the member guild avatar'),
|
||||
banner: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
banner: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded image data for the member guild banner'),
|
||||
bio: createStringType(1, 320).nullish().describe('The member guild profile bio (1-320 characters)'),
|
||||
@@ -208,7 +208,7 @@ export const GuildEmojiCreateRequest = z.object({
|
||||
name: createStringType(2, 32)
|
||||
.refine((value) => /^[a-zA-Z0-9_]+$/.test(value), 'Emoji name can only contain letters, numbers, and underscores')
|
||||
.describe('The name of the emoji (2-32 characters, alphanumeric and underscores only)'),
|
||||
image: createBase64StringType(1, Math.ceil(EMOJI_MAX_SIZE * (4 / 3))).describe(
|
||||
image: createBase64StringType(1, base64LengthForBytes(EMOJI_MAX_SIZE)).describe(
|
||||
'Base64-encoded image data for the emoji',
|
||||
),
|
||||
});
|
||||
@@ -247,7 +247,7 @@ export const GuildStickerCreateRequest = z.object({
|
||||
.optional()
|
||||
.default([])
|
||||
.describe(`Array of autocomplete/suggestion tags (max ${MAX_GUILD_STICKER_TAGS} tags, each 1-30 characters)`),
|
||||
image: createBase64StringType(1, Math.ceil(STICKER_MAX_SIZE * (4 / 3))).describe(
|
||||
image: createBase64StringType(1, base64LengthForBytes(STICKER_MAX_SIZE)).describe(
|
||||
'Base64-encoded image data for the sticker',
|
||||
),
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
UserAuthenticatorTypesDescriptions,
|
||||
} from '@fluxer/constants/src/UserConstants';
|
||||
import {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas';
|
||||
import {createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {base64LengthForBytes, createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {
|
||||
createBitflagInt32Type,
|
||||
createInt32EnumType,
|
||||
@@ -448,10 +448,10 @@ export type ApplicationUpdateRequest = z.infer<typeof ApplicationUpdateRequest>;
|
||||
export const BotProfileUpdateRequest = z.object({
|
||||
username: UsernameType.optional().describe('The username of the bot'),
|
||||
discriminator: DiscriminatorType.optional().describe('The discriminator of the bot'),
|
||||
avatar: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
avatar: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('The avatar image as base64'),
|
||||
banner: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
banner: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('The banner image as base64'),
|
||||
bio: createStringType(0, 1024).nullish().describe('The bio or description of the bot'),
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
SYNCED_PREFERENCES_MAX_ENCODED_LENGTH,
|
||||
} from '@fluxer/schema/src/domains/user/SyncedPreferencesCodec';
|
||||
import {isValidSingleUnicodeEmoji} from '@fluxer/schema/src/primitives/EmojiValidators';
|
||||
import {createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {base64LengthForBytes, createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {LocaleSchema} from '@fluxer/schema/src/primitives/LocaleSchema';
|
||||
import {createQueryIntegerType, DateTimeType, QueryBooleanType} from '@fluxer/schema/src/primitives/QueryValidators';
|
||||
import {
|
||||
@@ -68,10 +68,10 @@ export const UserUpdateRequest = z
|
||||
email: EmailType.describe('The email address for the account'),
|
||||
new_password: PasswordType.describe('The new password to set'),
|
||||
password: PasswordType.describe('The current password for verification'),
|
||||
avatar: createBase64StringType(1, AVATAR_MAX_SIZE * 1.33)
|
||||
avatar: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded avatar image'),
|
||||
banner: createBase64StringType(1, AVATAR_MAX_SIZE * 1.33)
|
||||
banner: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('Base64-encoded profile banner image'),
|
||||
bio: createStringType(1, 320).nullish().describe('User biography text (max 320 characters)'),
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
RichEmbedRequest,
|
||||
} from '@fluxer/schema/src/domains/message/MessageRequestSchemas';
|
||||
import {AllowedMentionsRequest, MessageReferenceRequest} from '@fluxer/schema/src/domains/message/SharedMessageSchemas';
|
||||
import {createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {base64LengthForBytes, createBase64StringType} from '@fluxer/schema/src/primitives/FileValidators';
|
||||
import {QueryBooleanType} from '@fluxer/schema/src/primitives/QueryValidators';
|
||||
import {
|
||||
coerceNumberFromString,
|
||||
@@ -31,7 +31,7 @@ import {z} from 'zod';
|
||||
|
||||
export const WebhookCreateRequest = z.object({
|
||||
name: WebhookNameType.describe('The name of the webhook'),
|
||||
avatar: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
avatar: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('The avatar image as a base64-encoded data URI'),
|
||||
});
|
||||
@@ -41,7 +41,7 @@ export type WebhookCreateRequest = z.infer<typeof WebhookCreateRequest>;
|
||||
export const WebhookUpdateRequest = z
|
||||
.object({
|
||||
name: WebhookNameType.describe('The new name of the webhook'),
|
||||
avatar: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
avatar: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('The new avatar image as a base64-encoded data URI'),
|
||||
channel_id: SnowflakeType.describe('The ID of the channel to move the webhook to'),
|
||||
@@ -53,7 +53,7 @@ export type WebhookUpdateRequest = z.infer<typeof WebhookUpdateRequest>;
|
||||
export const WebhookTokenUpdateRequest = z
|
||||
.object({
|
||||
name: WebhookNameType.describe('The new name of the webhook'),
|
||||
avatar: createBase64StringType(1, Math.ceil(AVATAR_MAX_SIZE * (4 / 3)))
|
||||
avatar: createBase64StringType(1, base64LengthForBytes(AVATAR_MAX_SIZE))
|
||||
.nullish()
|
||||
.describe('The new avatar image as a base64-encoded data URI'),
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user