import type { FromSchema } from 'json-schema-to-ts'; import { mediaRefSchema } from './media'; const USERNAME_PATTERN = '^[a-zA-Z0-9_]{3,32}$'; export const createDirectBodySchema = { type: 'object', additionalProperties: false, required: ['username'], properties: { username: { type: 'string', pattern: USERNAME_PATTERN }, }, } as const; export const createGroupBodySchema = { type: 'object', additionalProperties: false, required: ['title'], properties: { title: { type: 'string', minLength: 1, maxLength: 100 }, members: { type: 'array', maxItems: 200, items: { type: 'string', pattern: USERNAME_PATTERN }, }, }, } as const; export const addMemberBodySchema = { type: 'object', additionalProperties: false, required: ['username'], properties: { username: { type: 'string', pattern: USERNAME_PATTERN }, }, } as const; export const sendMessageBodySchema = { type: 'object', additionalProperties: false, required: ['clientMsgId'], properties: { // Caption; may be empty for a media-only message. content: { type: 'string', maxLength: 16000 }, clientMsgId: { type: 'string', minLength: 1, maxLength: 64 }, contentType: { type: 'string', enum: ['text', 'text/ciphertext'] }, encryption: { type: ['string', 'null'] }, // Object key returned by the media upload URL + its metadata. mediaKey: { type: 'string', minLength: 1, maxLength: 255 }, media: mediaRefSchema, }, } as const; export const addContactBodySchema = { type: 'object', additionalProperties: false, required: ['username'], properties: { username: { type: 'string', pattern: USERNAME_PATTERN }, }, } as const; export type CreateDirectBody = FromSchema; export type CreateGroupBody = FromSchema; export type AddMemberBody = FromSchema; export type SendMessageBody = FromSchema; export type AddContactBody = FromSchema;