mirror of
https://github.com/spacebarchat/server.git
synced 2026-09-25 13:24:42 +00:00
Add float/base64str types for ajv
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -19,3 +19,15 @@
|
||||
export type StringStringDictionary = {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* @TJS-type: number
|
||||
* @TJS-format: float
|
||||
*/
|
||||
export type float = number;
|
||||
|
||||
/**
|
||||
* @TJS-type: string
|
||||
* @TJS-format: byte
|
||||
*/
|
||||
export type base64str = string;
|
||||
|
||||
@@ -43,7 +43,7 @@ export const ajv = new Ajv({
|
||||
allErrors: true,
|
||||
parseDate: true,
|
||||
allowDate: true,
|
||||
schemas: schemas,
|
||||
// schemas: schemas,
|
||||
coerceTypes: true,
|
||||
messages: true,
|
||||
strict: true,
|
||||
@@ -52,6 +52,7 @@ export const ajv = new Ajv({
|
||||
});
|
||||
|
||||
addFormats(ajv);
|
||||
ajv.addSchema(schemas);
|
||||
|
||||
export function validateSchema<G extends object>(schema: string, data: G): G {
|
||||
const valid = ajv.validate(schema, data);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { PartialUser } from "@spacebar/schemas";
|
||||
import { base64str, float, PartialUser } from "@spacebar/schemas";
|
||||
|
||||
export interface PublicAttachment {
|
||||
filename: string;
|
||||
@@ -39,8 +39,8 @@ export interface PublicAttachment {
|
||||
placeholder?: string;
|
||||
|
||||
// voice messages
|
||||
duration_secs?: number;
|
||||
waveform?: string; // base64 byte array
|
||||
duration_secs?: float;
|
||||
waveform?: base64str; // base64 byte array
|
||||
|
||||
// clips
|
||||
title?: string; // clips only? Documentation kinda sucks...
|
||||
|
||||
@@ -17,14 +17,27 @@
|
||||
*/
|
||||
|
||||
import { Snowflake } from "../Identifiers";
|
||||
import { InteractionType, AllowedMentions, MessageReference, ApplicationCommandType, BaseMessageComponents, Embed, PollAnswer, PollMedia, PublicUser } from "@spacebar/schemas";
|
||||
import {
|
||||
InteractionType,
|
||||
AllowedMentions,
|
||||
MessageReference,
|
||||
ApplicationCommandType,
|
||||
BaseMessageComponents,
|
||||
Embed,
|
||||
PollAnswer,
|
||||
PollMedia,
|
||||
PublicUser,
|
||||
float,
|
||||
base64str,
|
||||
} from "@spacebar/schemas";
|
||||
|
||||
export type BaseMessageCreateAttachment = {
|
||||
filename: string;
|
||||
title?: string; // clips only?
|
||||
description?: string; // alt text
|
||||
duration_secs?: number; //flat
|
||||
waveform?: string; //base64 byte array
|
||||
|
||||
duration_secs?: float; //flat
|
||||
waveform?: base64str; //base64 byte array
|
||||
|
||||
is_clip?: boolean;
|
||||
is_thumbnail?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user