Skip to content

Commit 1cac8c3

Browse files
refactor: move custom sounds list query validation schema to rest-typings package (#39263)
1 parent b570388 commit 1cac8c3

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

apps/meteor/app/api/server/v1/custom-sounds.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { ICustomSound } from '@rocket.chat/core-typings';
22
import { CustomSounds } from '@rocket.chat/models';
3-
import type { PaginatedRequest, PaginatedResult } from '@rocket.chat/rest-typings';
3+
import type { PaginatedResult } from '@rocket.chat/rest-typings';
44
import {
55
isCustomSoundsGetOneProps,
6+
isCustomSoundsListProps,
67
ajv,
78
validateBadRequestErrorResponse,
89
validateNotFoundErrorResponse,
@@ -15,38 +16,6 @@ import type { ExtractRoutesFromAPI } from '../ApiClass';
1516
import { API } from '../api';
1617
import { getPaginationItems } from '../helpers/getPaginationItems';
1718

18-
type CustomSoundsList = PaginatedRequest<{ name?: string }>;
19-
20-
const CustomSoundsListSchema = {
21-
type: 'object',
22-
properties: {
23-
count: {
24-
type: 'number',
25-
nullable: true,
26-
},
27-
offset: {
28-
type: 'number',
29-
nullable: true,
30-
},
31-
sort: {
32-
type: 'string',
33-
nullable: true,
34-
},
35-
name: {
36-
type: 'string',
37-
nullable: true,
38-
},
39-
query: {
40-
type: 'string',
41-
nullable: true,
42-
},
43-
},
44-
required: [],
45-
additionalProperties: false,
46-
};
47-
48-
export const isCustomSoundsListProps = ajv.compile<CustomSoundsList>(CustomSoundsListSchema);
49-
5019
const customSoundsEndpoints = API.v1
5120
.get(
5221
'custom-sounds.list',

packages/rest-typings/src/v1/customSounds.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ICustomSound } from '@rocket.chat/core-typings';
22

33
import { ajv } from './Ajv';
4+
import { type PaginatedRequest } from '../helpers/PaginatedRequest';
45

56
type CustomSoundsGetOne = { _id: ICustomSound['_id'] };
67

@@ -17,3 +18,35 @@ const CustomSoundsGetOneSchema = {
1718
};
1819

1920
export const isCustomSoundsGetOneProps = ajv.compile<CustomSoundsGetOne>(CustomSoundsGetOneSchema);
21+
22+
type CustomSoundsList = PaginatedRequest<{ name?: string }>;
23+
24+
const CustomSoundsListSchema = {
25+
type: 'object',
26+
properties: {
27+
count: {
28+
type: 'number',
29+
nullable: true,
30+
},
31+
offset: {
32+
type: 'number',
33+
nullable: true,
34+
},
35+
sort: {
36+
type: 'string',
37+
nullable: true,
38+
},
39+
name: {
40+
type: 'string',
41+
nullable: true,
42+
},
43+
query: {
44+
type: 'string',
45+
nullable: true,
46+
},
47+
},
48+
required: [],
49+
additionalProperties: false,
50+
};
51+
52+
export const isCustomSoundsListProps = ajv.compile<CustomSoundsList>(CustomSoundsListSchema);

0 commit comments

Comments
 (0)