mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
chore(packages): add more docs and improve types
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import DisconnectReason from './DisconnectReason.js'
|
||||
|
||||
/**
|
||||
* Humanized disconnect reasons for logs
|
||||
*/
|
||||
const HumanizedDisconnectReason = {
|
||||
[DisconnectReason.InvalidPacket]: 'has sent invalid packet',
|
||||
[DisconnectReason.Generic]: 'has been disconnected for unknown reasons',
|
||||
|
||||
@@ -44,33 +44,6 @@ export const PacketSchema = special<Packet>(input => {
|
||||
return false
|
||||
}, 'Invalid packet data')
|
||||
|
||||
// merge([
|
||||
// object({
|
||||
// op: nativeEnum(Operation, 'Not a valid operation number'),
|
||||
// }),
|
||||
// object({
|
||||
// d: special<Packet['d']>(input => {
|
||||
// if (
|
||||
// typeof input === 'object' &&
|
||||
// input &&
|
||||
// 'op' in input &&
|
||||
// typeof input.op === 'number' &&
|
||||
// input.op in Operation &&
|
||||
// 'd' in input &&
|
||||
// typeof input.d === 'object'
|
||||
// ) {
|
||||
// try {
|
||||
// PacketDataSchemas[input.op as Operation].parse(input)
|
||||
// return true
|
||||
// } catch {
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
// return false
|
||||
// }, 'Invalid packet data'),
|
||||
// }),
|
||||
// ])
|
||||
|
||||
/**
|
||||
* Schema to validate packet data for each possible operations
|
||||
*/
|
||||
@@ -118,6 +91,7 @@ export const PacketDataSchemas = {
|
||||
}),
|
||||
} as const satisfies Record<
|
||||
Operation,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
ObjectSchema<any> | AnySchema | NullSchema
|
||||
>
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Uncapitalizes the first letter of a string
|
||||
* @param str The string to uncapitalize
|
||||
* @returns The uncapitalized string
|
||||
*/
|
||||
export function uncapitalize<T extends string>(str: T): Uncapitalize<T> {
|
||||
return (str.charAt(0).toLowerCase() + str.slice(1)) as Uncapitalize<T>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user