RocketChat/Rocket.Chat

View on GitHub
packages/rest-typings/src/v1/teams/TeamsRemoveMemberProps.ts

Summary

Maintainability
B
5 hrs
Test Coverage
import Ajv from 'ajv';

const ajv = new Ajv();

export type TeamsRemoveMemberProps = ({ teamId: string } | { teamName: string }) & {
    userId: string;
    rooms?: Array<string>;
};

const teamsRemoveMemberPropsSchema = {
    oneOf: [
        {
            type: 'object',
            properties: {
                teamId: {
                    type: 'string',
                },
                userId: {
                    type: 'string',
                },
                rooms: {
                    type: 'array',
                    items: {
                        type: 'string',
                    },
                    minItems: 1,
                    uniqueItems: true,
                    nullable: true,
                },
            },
            required: ['teamId', 'userId'],
            additionalProperties: false,
        },
        {
            type: 'object',
            properties: {
                teamName: {
                    type: 'string',
                },
                userId: {
                    type: 'string',
                },
                rooms: {
                    type: 'array',
                    items: {
                        type: 'string',
                    },
                    minItems: 1,
                    uniqueItems: true,
                    nullable: true,
                },
            },
            required: ['teamName', 'userId'],
            additionalProperties: false,
        },
    ],
};

export const isTeamsRemoveMemberProps = ajv.compile<TeamsRemoveMemberProps>(teamsRemoveMemberPropsSchema);