fix(api): support int53 attachment sizes (#1261)

This commit is contained in:
Hampus authored and GitHub committed 2026-07-02 23:41:55 +02:00
1 parent 40d1e90a3c
commit 3a8ed1012f
22 files changed
+289 -89

No files matched your search

@@ -7,6 +7,7 @@ import {
createBitflagInt32Type,
createStringType,
Int32Type,
NonNegativeSafeIntegerType,
SnowflakeType,
} from '@fluxer/schema/src/primitives/SchemaPrimitives';
import {z} from 'zod';
@@ -41,7 +42,7 @@ export const ClientUploadedAttachmentRequest = ClientAttachmentBase.extend({
upload_filename: createStringType(1, 4096).describe(
'Temporary upload key returned by the attachment upload endpoint',
),
file_size: coerceNumberFromString(Int32Type).describe('Uploaded file size in bytes'),
file_size: coerceNumberFromString(NonNegativeSafeIntegerType).describe('Uploaded file size in bytes'),
content_type: createStringType(1, 255).describe('MIME type of the uploaded file'),
});
@@ -2,14 +2,19 @@
import {ATTACHMENT_UPLOAD_MAX_CHUNKS, MAX_ATTACHMENTS_PER_MESSAGE} from '@fluxer/constants/src/LimitConstants';
import {FilenameType} from '@fluxer/schema/src/primitives/FileValidators';
import {coerceNumberFromString, createStringType, Int32Type} from '@fluxer/schema/src/primitives/SchemaPrimitives';
import {
coerceNumberFromString,
createStringType,
Int32Type,
NonNegativeSafeIntegerType,
} from '@fluxer/schema/src/primitives/SchemaPrimitives';
import {URLType} from '@fluxer/schema/src/primitives/UrlValidators';
import {z} from 'zod';
export const PresignedAttachmentUploadRequestItem = z.object({
id: coerceNumberFromString(Int32Type).describe('The client-side identifier for this attachment'),
filename: FilenameType.describe('The name of the file that will be uploaded'),
file_size: coerceNumberFromString(Int32Type).describe('Expected file size in bytes'),
file_size: coerceNumberFromString(NonNegativeSafeIntegerType).describe('Expected file size in bytes'),
content_type: createStringType(1, 255).describe('MIME type the client will upload'),
});
@@ -29,7 +34,7 @@ const PresignedAttachmentUploadBase = z.object({
id: coerceNumberFromString(Int32Type).describe('The client-side identifier for this attachment'),
filename: FilenameType.describe('The original filename for this upload'),
upload_filename: createStringType(1, 4096).describe('Temporary upload key to reference in message send payloads'),
file_size: coerceNumberFromString(Int32Type).describe('Expected file size in bytes'),
file_size: coerceNumberFromString(NonNegativeSafeIntegerType).describe('Expected file size in bytes'),
content_type: createStringType(1, 255).describe('Expected MIME type for this upload'),
});
const PresignedAttachmentUploadSinglepart = PresignedAttachmentUploadBase.extend({
@@ -45,7 +50,7 @@ const PresignedAttachmentUploadPart = z.object({
const PresignedAttachmentUploadMultipart = PresignedAttachmentUploadBase.extend({
upload_mode: z.literal('multipart'),
upload_id: createStringType(1, 1024).describe('S3 multipart upload identifier; required to complete the upload'),
part_size: coerceNumberFromString(Int32Type).describe('Size in bytes of each part except the last'),
part_size: coerceNumberFromString(NonNegativeSafeIntegerType).describe('Size in bytes of each part except the last'),
parts: z
.array(PresignedAttachmentUploadPart)
.min(1)
@@ -11,7 +11,12 @@ import type {GuildMemberData} from '@fluxer/schema/src/domains/guild/GuildMember
import {type MessageEmbed, MessageEmbedResponse} from '@fluxer/schema/src/domains/message/EmbedSchemas';
import {type UserPartial, UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas';
import {MessageReferenceTypeSchema, MessageTypeSchema} from '@fluxer/schema/src/primitives/MessageValidators';
import {createBitflagInt32Type, Int32Type, SnowflakeStringType} from '@fluxer/schema/src/primitives/SchemaPrimitives';
import {
createBitflagInt32Type,
Int32Type,
NonNegativeSafeIntegerType,
SnowflakeStringType,
} from '@fluxer/schema/src/primitives/SchemaPrimitives';
import {z} from 'zod';
export const MessageAttachmentResponse = z.object({
@@ -21,7 +26,7 @@ export const MessageAttachmentResponse = z.object({
description: z.string().nullish().describe('The description of the attachment'),
content_type: z.string().nullish().describe('The MIME type of the attachment'),
content_hash: z.string().nullish().describe('The hash of the attachment content'),
size: Int32Type.describe('The size of the attachment in bytes'),
size: NonNegativeSafeIntegerType.describe('The size of the attachment in bytes'),
url: z.string().nullish().describe('The URL of the attachment'),
proxy_url: z.string().nullish().describe('The proxied URL of the attachment'),
width: Int32Type.nullish().describe('The width of the attachment in pixels (for images/videos)'),