snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
3791
packages/rest-typings/CHANGELOG.md
Normal file
3791
packages/rest-typings/CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
85
packages/rest-typings/README.md
Normal file
85
packages/rest-typings/README.md
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
# @rocket.chat/rest-typings
|
||||
|
||||
Package containing all Rocket.Chat rest endpoint definitions
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are always welcome!
|
||||
However we have some recommendations.
|
||||
- Check if your implementation matches your definitions, a bad definition is worse than none.
|
||||
- Use the generic types we created for paging.
|
||||
- Create functions that assert properties (very useful for the backend)
|
||||
- Do tests to ensure that your assertions are correct.
|
||||
- Avoid incomplete and unknow typings
|
||||
|
||||
### Good examples of what not to do:
|
||||
|
||||
#### If you have an endpoint that accepts name or id, both are not optional, one of them is required
|
||||
|
||||
```typescript
|
||||
|
||||
type EndPointTestGetParams = { name?: string; id?: string; } // WRONG!
|
||||
|
||||
type EndPointTestGetParams = { name: string; } | { id: string; } // Better :)
|
||||
````
|
||||
|
||||
#### If you have an endpoint that accepts name or id, both are not optional, one of them is required
|
||||
|
||||
```typescript
|
||||
export const isEndPointTestGetParams = (props: any) is EndPointTestGetParams => 'name' in prop || 'id' in prop; // WRONG!
|
||||
|
||||
// .... Better
|
||||
|
||||
|
||||
import Ajv from 'ajv';
|
||||
|
||||
const ajv = new Ajv();
|
||||
const endPointTestGetParams = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['name'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['id'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isEndPointTestGetParams = ajv.compile<EndPointTestGetParams>(endPointTestGetParams);
|
||||
```
|
||||
## Optimizations
|
||||
|
||||
we use interfaces to register endpoints, so if you use a custom version, or miss an endpoint, you don't necessarily need to recompile the code, you can do it in your own code
|
||||
|
||||
```typescript
|
||||
declare module '@rocket.chat/rest-typings' {
|
||||
interface Endpoints {
|
||||
'custom/endpoint': {
|
||||
GET: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{
|
||||
some: string[];
|
||||
}>;
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
38
packages/rest-typings/package.json
Normal file
38
packages/rest-typings/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@rocket.chat/rest-typings",
|
||||
"version": "8.8.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/RocketChat/Rocket.Chat.git",
|
||||
"directory": "packages/rest-typings"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"/dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && tsc",
|
||||
"dev": "tsc --watch --preserveWatchOutput",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rocket.chat/core-typings": "workspace:^",
|
||||
"@rocket.chat/message-parser": "workspace:^",
|
||||
"@rocket.chat/ui-kit": "workspace:~",
|
||||
"ajv": "^8.20.0",
|
||||
"ajv-formats": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rocket.chat/apps-engine": "workspace:^",
|
||||
"@types/jest": "~30.0.0",
|
||||
"eslint": "~9.39.5",
|
||||
"mongodb": "6.16.0",
|
||||
"typescript": "~5.9.3"
|
||||
},
|
||||
"volta": {
|
||||
"extends": "../../package.json"
|
||||
}
|
||||
}
|
||||
24
packages/rest-typings/src/apps/appLogsExportProps.ts
Normal file
24
packages/rest-typings/src/apps/appLogsExportProps.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { AppLogsProps } from './appLogsProps';
|
||||
import { ajvQuery } from '../v1/Ajv';
|
||||
|
||||
export type AppLogsExportProps = Omit<AppLogsProps, 'appId' | 'offset' | 'query'> & {
|
||||
type: 'json' | 'csv';
|
||||
};
|
||||
|
||||
const AppLogsExportPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
logLevel: { type: 'string', enum: ['0', '1', '2'], nullable: true },
|
||||
method: { type: 'string', nullable: true },
|
||||
instanceId: { type: 'string', nullable: true },
|
||||
startDate: { type: 'string', format: 'date-time', nullable: true },
|
||||
endDate: { type: 'string', format: 'date-time', nullable: true },
|
||||
type: { type: 'string', enum: ['json', 'csv'] },
|
||||
count: { type: 'number', minimum: 1, nullable: true },
|
||||
sort: { type: 'string', nullable: true },
|
||||
},
|
||||
required: ['type'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isAppLogsExportProps = ajvQuery.compile<AppLogsExportProps>(AppLogsExportPropsSchema);
|
||||
29
packages/rest-typings/src/apps/appLogsProps.ts
Normal file
29
packages/rest-typings/src/apps/appLogsProps.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { PaginatedRequest } from '../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../v1/Ajv';
|
||||
|
||||
export type AppLogsProps = PaginatedRequest<{
|
||||
appId?: string;
|
||||
logLevel?: '0' | '1' | '2';
|
||||
instanceId?: string;
|
||||
method?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
}>;
|
||||
|
||||
const AppLogsPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
appId: { type: 'string', nullable: true },
|
||||
logLevel: { type: 'string', enum: ['0', '1', '2'], nullable: true },
|
||||
instanceId: { type: 'string', nullable: true },
|
||||
method: { type: 'string', nullable: true },
|
||||
startDate: { type: 'string', format: 'date-time', nullable: true },
|
||||
endDate: { type: 'string', format: 'date-time', nullable: true },
|
||||
offset: { type: 'number', minimum: 0, nullable: true },
|
||||
count: { type: 'number', minimum: 0, nullable: true },
|
||||
sort: { type: 'string', nullable: true },
|
||||
},
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isAppLogsProps = ajvQuery.compile<AppLogsProps>(AppLogsPropsSchema);
|
||||
262
packages/rest-typings/src/apps/index.ts
Normal file
262
packages/rest-typings/src/apps/index.ts
Normal file
@@ -0,0 +1,262 @@
|
||||
import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import type { IApiEndpointMetadata } from '@rocket.chat/apps-engine/definition/api';
|
||||
import type { IExternalComponent } from '@rocket.chat/apps-engine/definition/externalComponent';
|
||||
import type { IPermission } from '@rocket.chat/apps-engine/definition/permissions/IPermission';
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import type { IUIActionButton } from '@rocket.chat/apps-engine/definition/ui';
|
||||
import type {
|
||||
AppCategory,
|
||||
AppScreenshot,
|
||||
App,
|
||||
FeaturedAppsSection,
|
||||
ILogItem,
|
||||
AppRequestFilter,
|
||||
AppRequest,
|
||||
} from '@rocket.chat/core-typings';
|
||||
import type * as UiKit from '@rocket.chat/ui-kit';
|
||||
|
||||
import type { AppLogsExportProps } from './appLogsExportProps';
|
||||
import type { AppLogsProps } from './appLogsProps';
|
||||
import type { PaginatedResult } from '../helpers/PaginatedResult';
|
||||
|
||||
export * from './appLogsExportProps';
|
||||
export * from './appLogsProps';
|
||||
|
||||
export type AppsEndpoints = {
|
||||
'/apps/count': {
|
||||
GET: () => { totalMarketplaceEnabled: number; totalPrivateEnabled: number; maxMarketplaceApps: number; maxPrivateApps: number };
|
||||
};
|
||||
|
||||
'/apps/externalComponents': {
|
||||
GET: () => { externalComponents: IExternalComponent[] };
|
||||
};
|
||||
|
||||
'/apps/incompatibleModal': {
|
||||
GET: (params: { appId: string; appVersion: string; action: string }) => { url: string };
|
||||
};
|
||||
|
||||
'/apps/:id': {
|
||||
GET:
|
||||
| ((params: { marketplace?: 'true' | 'false'; version?: string; appVersion?: string; update?: 'true' | 'false' }) => {
|
||||
app: App;
|
||||
})
|
||||
| (() => {
|
||||
app: App;
|
||||
});
|
||||
DELETE: () => {
|
||||
app: App;
|
||||
success: boolean;
|
||||
};
|
||||
POST: (params: { marketplace: boolean; version: string; permissionsGranted?: IPermission[]; appId: string; url?: string }) => {
|
||||
app: App;
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/actionButtons': {
|
||||
GET: () => IUIActionButton[];
|
||||
};
|
||||
|
||||
'/apps/languages': {
|
||||
GET: () => {
|
||||
apps: {
|
||||
id: string;
|
||||
languages: { [language: string]: { [key: string]: string } };
|
||||
}[];
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/logs': {
|
||||
GET: (params: AppLogsProps) => PaginatedResult<{
|
||||
logs: ILogItem[];
|
||||
}>;
|
||||
};
|
||||
|
||||
'/apps/public/:appId/get-sidebar-icon': {
|
||||
GET: (params: { icon: string }) => unknown;
|
||||
};
|
||||
|
||||
'/apps/:id/settings': {
|
||||
GET: () => {
|
||||
settings: ISetting[];
|
||||
};
|
||||
POST: (params: { settings: ISetting[] }) => { updated: ISetting[]; success: boolean };
|
||||
};
|
||||
|
||||
'/apps/:id/settings/:settingId': {
|
||||
GET: () => {
|
||||
setting: ISetting;
|
||||
};
|
||||
POST: (params: { setting: ISetting }) => { success: boolean };
|
||||
};
|
||||
|
||||
'/apps/:id/screenshots': {
|
||||
GET: () => {
|
||||
screenshots: AppScreenshot[];
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/:id/languages': {
|
||||
GET: () => {
|
||||
languages: { [language: string]: { [key: string]: string } };
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/:id/logs': {
|
||||
GET: (params: Omit<AppLogsProps, 'appId'>) => PaginatedResult<{
|
||||
logs: ILogItem[];
|
||||
}>;
|
||||
};
|
||||
|
||||
'/apps/:id/logs/distinctValues': {
|
||||
GET: () => { success: boolean; instanceIds: string[]; methods: string[] };
|
||||
};
|
||||
|
||||
'/apps/:id/export-logs': {
|
||||
GET: (params: AppLogsExportProps) => Buffer;
|
||||
};
|
||||
|
||||
'/apps/:id/apis': {
|
||||
GET: () => {
|
||||
apis: IApiEndpointMetadata[];
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/bundles/:id/apps': {
|
||||
GET: () => {
|
||||
apps: App[];
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/:id/sync': {
|
||||
POST: () => {
|
||||
app: App;
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/:id/status': {
|
||||
GET: () => {
|
||||
status: string;
|
||||
clusterStatus: App['clusterStatus'];
|
||||
};
|
||||
POST: (params: { status: AppStatus }) => {
|
||||
status: AppStatus;
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/:id/versions': {
|
||||
GET: () => {
|
||||
apps: App[];
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/:id/icon': {
|
||||
GET: () => {
|
||||
statusCode: 200;
|
||||
headers: {
|
||||
'Content-Length': number;
|
||||
'Content-Type': string;
|
||||
};
|
||||
body: Buffer;
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/featured-apps': {
|
||||
GET: () => {
|
||||
sections: FeaturedAppsSection[];
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/marketplace': {
|
||||
GET: (params: {
|
||||
purchaseType?: 'buy' | 'subscription';
|
||||
version?: string;
|
||||
appId?: string;
|
||||
details?: 'true' | 'false';
|
||||
isAdminUser?: string;
|
||||
}) => App[];
|
||||
};
|
||||
|
||||
'/apps/categories': {
|
||||
GET: () => AppCategory[];
|
||||
};
|
||||
|
||||
'/apps/buildExternalUrl': {
|
||||
GET: (params: { purchaseType?: 'buy' | 'subscription'; appId?: string; details?: 'true' | 'false' }) => {
|
||||
url: string;
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/installed': {
|
||||
GET: (params: { includeClusterStatus?: 'true' | 'false' }) => { success: true; apps: App[] } | { success: false; error: string };
|
||||
};
|
||||
|
||||
'/apps/buildExternalAppRequest': {
|
||||
GET: (params: { appId?: string }) => {
|
||||
url: string;
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/app-request': {
|
||||
GET: (params: { appId: string; q?: AppRequestFilter; sort?: string; limit?: number; offset?: number }) => {
|
||||
data: AppRequest[] | null;
|
||||
meta: {
|
||||
limit: 25 | 50 | 100;
|
||||
offset: number;
|
||||
sort: string;
|
||||
filter: string;
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/app-request/stats': {
|
||||
GET: () => {
|
||||
data: {
|
||||
totalSeen: number;
|
||||
totalUnseen: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/app-request/markAsSeen': {
|
||||
POST: (params: { unseenRequests: Array<string> }) => { succes: boolean };
|
||||
};
|
||||
|
||||
'/apps/notify-admins': {
|
||||
POST: (params: { appId: string; appName: string; appVersion: string; message: string }) => void;
|
||||
};
|
||||
|
||||
'/apps/externalComponentEvent': {
|
||||
POST: (params: { externalComponent: string; event: 'IPostExternalComponentOpened' | 'IPostExternalComponentClosed' }) => {
|
||||
result: any;
|
||||
};
|
||||
};
|
||||
|
||||
'/apps': {
|
||||
POST: {
|
||||
(
|
||||
params:
|
||||
| {
|
||||
appId: string;
|
||||
marketplace: boolean;
|
||||
version: string;
|
||||
permissionsGranted?: IPermission[];
|
||||
url?: string;
|
||||
}
|
||||
| { url: string },
|
||||
):
|
||||
| {
|
||||
app: App;
|
||||
}
|
||||
| {
|
||||
buff: {
|
||||
data: ArrayLike<number>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
'/apps/ui.interaction/:id': {
|
||||
POST: (params: UiKit.UserInteraction) => UiKit.ServerInteraction | Record<string, never>;
|
||||
};
|
||||
};
|
||||
82
packages/rest-typings/src/default/index.ts
Normal file
82
packages/rest-typings/src/default/index.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { ajvQuery } from '../v1/Ajv';
|
||||
|
||||
type OpenAPIJSONEndpoint = { withUndocumented?: boolean };
|
||||
|
||||
const OpenAPIJSONEndpointSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
withUndocumented: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isOpenAPIJSONEndpoint = ajvQuery.compile<OpenAPIJSONEndpoint>(OpenAPIJSONEndpointSchema);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export interface DefaultEndpoints {
|
||||
'/info': {
|
||||
GET: () =>
|
||||
| {
|
||||
info: {
|
||||
build: {
|
||||
arch: string;
|
||||
cpus: number;
|
||||
date: string;
|
||||
freeMemory: number;
|
||||
nodeVersion: string;
|
||||
osRelease: string;
|
||||
platform: string;
|
||||
totalMemory: number;
|
||||
};
|
||||
commit: {
|
||||
author?: string;
|
||||
branch?: string;
|
||||
date?: string;
|
||||
hash?: string;
|
||||
subject?: string;
|
||||
tag?: string;
|
||||
};
|
||||
marketplaceApiVersion: string;
|
||||
version: string;
|
||||
tag?: string;
|
||||
branch?: string;
|
||||
};
|
||||
}
|
||||
| {
|
||||
version: string | undefined;
|
||||
};
|
||||
};
|
||||
'/docs/json': {
|
||||
GET: (params: OpenAPIJSONEndpoint) => {
|
||||
openapi: string;
|
||||
info: {
|
||||
title: string;
|
||||
description: string;
|
||||
version: string;
|
||||
};
|
||||
servers: {
|
||||
url: string;
|
||||
}[];
|
||||
components: {
|
||||
securitySchemes: {
|
||||
userId: {
|
||||
type: string;
|
||||
in: string;
|
||||
name: string;
|
||||
};
|
||||
authToken: {
|
||||
type: string;
|
||||
in: string;
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
schemas: unknown;
|
||||
};
|
||||
paths: Record<string, Record<string, unknown>>;
|
||||
};
|
||||
};
|
||||
}
|
||||
29
packages/rest-typings/src/experimental/index.ts
Normal file
29
packages/rest-typings/src/experimental/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Opt-in typings for experimental REST endpoints (`/api/experimental/...`).
|
||||
*
|
||||
* These are intentionally **not** merged into the `Endpoints` union exported
|
||||
* from the package root, so the stable typed client surface (`PathPattern`,
|
||||
* `Method`, `Path`, the SDK) stays free of unstable paths. Consumers who want
|
||||
* typed experimental calls import `ExperimentalEndpoints` explicitly.
|
||||
*
|
||||
* Endpoints under this namespace carry **no semver promise**: they may change
|
||||
* shape or be removed in any release without a deprecation cycle. See
|
||||
* `docs/experimental-api-endpoints.md`.
|
||||
*
|
||||
* Declare new experimental endpoints here, following the per-resource style of
|
||||
* the `/v1` endpoint types (e.g. `v1/calendar`). Every path key must begin with
|
||||
* `/experimental/`. For example:
|
||||
*
|
||||
* ```ts
|
||||
* export type ExperimentalEndpoints = {
|
||||
* '/experimental/example.info': {
|
||||
* GET: (params: { id: string }) => { id: string; value: number };
|
||||
* };
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
export type ExperimentalEndpoints = {
|
||||
'/experimental/rooms.setCategory': {
|
||||
POST: (params: { roomIds: string[]; category: string | null }) => { success: true };
|
||||
};
|
||||
};
|
||||
1
packages/rest-typings/src/helpers/Deprecated.ts
Normal file
1
packages/rest-typings/src/helpers/Deprecated.ts
Normal file
@@ -0,0 +1 @@
|
||||
export type Deprecated<T> = (T & { warning: string }) | T;
|
||||
9
packages/rest-typings/src/helpers/IGetRoomRoles.ts
Normal file
9
packages/rest-typings/src/helpers/IGetRoomRoles.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface IGetRoomRoles {
|
||||
_id: string;
|
||||
rid: string;
|
||||
u: {
|
||||
_id: string;
|
||||
username: string;
|
||||
};
|
||||
roles: string[];
|
||||
}
|
||||
7
packages/rest-typings/src/helpers/PaginatedRequest.ts
Normal file
7
packages/rest-typings/src/helpers/PaginatedRequest.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export type PaginatedRequest<T = Record<string, boolean | number | string | object>, S extends string = string> = {
|
||||
count?: number;
|
||||
offset?: number;
|
||||
sort?: `{ "${S}": ${1 | -1} }` | string;
|
||||
/* deprecated */
|
||||
query?: string;
|
||||
} & T;
|
||||
5
packages/rest-typings/src/helpers/PaginatedResult.ts
Normal file
5
packages/rest-typings/src/helpers/PaginatedResult.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export type PaginatedResult<T = Record<string, boolean | number | string | object>> = {
|
||||
count: number;
|
||||
offset: number;
|
||||
total: number;
|
||||
} & T;
|
||||
7
packages/rest-typings/src/helpers/ReplacePlaceholders.ts
Normal file
7
packages/rest-typings/src/helpers/ReplacePlaceholders.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export type ReplacePlaceholders<TPath extends string> = string extends TPath
|
||||
? TPath
|
||||
: TPath extends `${infer Start}:${string}/${infer Rest}`
|
||||
? `${Start}${string}/${ReplacePlaceholders<Rest>}`
|
||||
: TPath extends `${infer Start}:${string}`
|
||||
? `${Start}${string}`
|
||||
: TPath;
|
||||
3
packages/rest-typings/src/helpers/WithItemCount.ts
Normal file
3
packages/rest-typings/src/helpers/WithItemCount.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type WithItemCount<T = Record<string, unknown>> = T & {
|
||||
count: { total: number }[];
|
||||
};
|
||||
285
packages/rest-typings/src/index.ts
Normal file
285
packages/rest-typings/src/index.ts
Normal file
@@ -0,0 +1,285 @@
|
||||
import type { KeyOfEach } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { AppsEndpoints } from './apps';
|
||||
import type { DefaultEndpoints } from './default';
|
||||
import type { ReplacePlaceholders } from './helpers/ReplacePlaceholders';
|
||||
import type { AISearchEndpoints } from './v1/aiSearch';
|
||||
import type { AssetsEndpoints } from './v1/assets';
|
||||
import type { AuthEndpoints } from './v1/auth';
|
||||
import type { AutoTranslateEndpoints } from './v1/autoTranslate';
|
||||
import type { BannersEndpoints } from './v1/banners';
|
||||
import type { CalendarEndpoints } from './v1/calendar';
|
||||
import type { ChannelsEndpoints } from './v1/channels';
|
||||
import type { ChatEndpoints } from './v1/chat';
|
||||
import type { CloudEndpoints } from './v1/cloud';
|
||||
import type { CommandsEndpoints } from './v1/commands';
|
||||
import type { CustomUserStatusEndpoints } from './v1/customUserStatus';
|
||||
import type { DirectoryEndpoint } from './v1/directory';
|
||||
import type { ImEndpoints, DmEndpoints } from './v1/dm';
|
||||
import type { E2eEndpoints } from './v1/e2e';
|
||||
import type { EmailInboxEndpoints } from './v1/email-inbox';
|
||||
import type { EmojiCustomEndpoints } from './v1/emojiCustom';
|
||||
import type { FederationEndpoints } from './v1/federation';
|
||||
import type { GroupsEndpoints } from './v1/groups';
|
||||
import type { ImportEndpoints } from './v1/import';
|
||||
import type { InstancesEndpoints } from './v1/instances';
|
||||
import type { IntegrationsEndpoints } from './v1/integrations';
|
||||
import type { IntegrationHooksEndpoints } from './v1/integrations/hooks';
|
||||
import type { InvitesEndpoints } from './v1/invites';
|
||||
import type { LDAPEndpoints } from './v1/ldap';
|
||||
import type { LicensesEndpoints } from './v1/licenses';
|
||||
import type { MailerEndpoints } from './v1/mailer';
|
||||
import type { MeEndpoints } from './v1/me';
|
||||
import type { MiscEndpoints } from './v1/misc';
|
||||
import type { ModerationEndpoints } from './v1/moderation';
|
||||
import type { OmnichannelEndpoints } from './v1/omnichannel';
|
||||
import type { PresenceEndpoints } from './v1/presence';
|
||||
import type { PushEndpoints } from './v1/push';
|
||||
import type { RolesEndpoints } from './v1/roles';
|
||||
import type { RoomsEndpoints } from './v1/rooms';
|
||||
import type { ServerEventsEndpoints } from './v1/server-events';
|
||||
import type { SettingsEndpoints } from './v1/settings';
|
||||
import type { SetupWizardEndpoints } from './v1/setupWizard';
|
||||
import type { StatisticsEndpoints } from './v1/statistics';
|
||||
import type { SubscriptionsEndpoints } from './v1/subscriptionsEndpoints';
|
||||
import type { TeamsEndpoints } from './v1/teams';
|
||||
import type { TwoFactorChallengesEndpoints } from './v1/twoFactorChallenges';
|
||||
import type { UsersEndpoints } from './v1/users';
|
||||
import type { VideoConferenceEndpoints } from './v1/videoConference';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export interface Endpoints
|
||||
extends
|
||||
AISearchEndpoints,
|
||||
ChannelsEndpoints,
|
||||
MeEndpoints,
|
||||
ModerationEndpoints,
|
||||
BannersEndpoints,
|
||||
ChatEndpoints,
|
||||
CommandsEndpoints,
|
||||
CloudEndpoints,
|
||||
CommandsEndpoints,
|
||||
CustomUserStatusEndpoints,
|
||||
DmEndpoints,
|
||||
DirectoryEndpoint,
|
||||
EmojiCustomEndpoints,
|
||||
GroupsEndpoints,
|
||||
ImEndpoints,
|
||||
LDAPEndpoints,
|
||||
RoomsEndpoints,
|
||||
PushEndpoints,
|
||||
RolesEndpoints,
|
||||
TeamsEndpoints,
|
||||
SettingsEndpoints,
|
||||
SetupWizardEndpoints,
|
||||
UsersEndpoints,
|
||||
AppsEndpoints,
|
||||
OmnichannelEndpoints,
|
||||
StatisticsEndpoints,
|
||||
LicensesEndpoints,
|
||||
MiscEndpoints,
|
||||
PresenceEndpoints,
|
||||
InstancesEndpoints,
|
||||
IntegrationsEndpoints,
|
||||
IntegrationHooksEndpoints,
|
||||
VideoConferenceEndpoints,
|
||||
InvitesEndpoints,
|
||||
E2eEndpoints,
|
||||
AssetsEndpoints,
|
||||
EmailInboxEndpoints,
|
||||
MailerEndpoints,
|
||||
SubscriptionsEndpoints,
|
||||
AutoTranslateEndpoints,
|
||||
ImportEndpoints,
|
||||
FederationEndpoints,
|
||||
CalendarEndpoints,
|
||||
AuthEndpoints,
|
||||
ImportEndpoints,
|
||||
ServerEventsEndpoints,
|
||||
TwoFactorChallengesEndpoints,
|
||||
DefaultEndpoints {}
|
||||
|
||||
type OperationsByPathPatternAndMethod<
|
||||
TEndpoints extends Endpoints,
|
||||
TPathPattern extends keyof TEndpoints,
|
||||
TMethod extends KeyOfEach<TEndpoints[TPathPattern]> = KeyOfEach<TEndpoints[TPathPattern]>,
|
||||
> = TMethod extends any
|
||||
? {
|
||||
pathPattern: TPathPattern;
|
||||
method: TMethod;
|
||||
fn: TEndpoints[TPathPattern][TMethod];
|
||||
path: ReplacePlaceholders<TPathPattern extends string ? TPathPattern : never>;
|
||||
params: GetParams<TEndpoints[TPathPattern][TMethod]>;
|
||||
result: GetResult<TEndpoints[TPathPattern][TMethod]>;
|
||||
}
|
||||
: never;
|
||||
|
||||
type OperationsByPathPattern<TEndpoints extends Endpoints, TPathPattern extends keyof TEndpoints> = TPathPattern extends any
|
||||
? OperationsByPathPatternAndMethod<TEndpoints, TPathPattern>
|
||||
: never;
|
||||
|
||||
type Operations = OperationsByPathPattern<Endpoints, keyof Endpoints>;
|
||||
|
||||
export type PathPattern = Operations['pathPattern'];
|
||||
|
||||
export type Method = Operations['method'];
|
||||
|
||||
export type Path = Operations['path'];
|
||||
|
||||
type MethodToPathMap = {
|
||||
[TOperation in Operations as TOperation['method']]: TOperation['path'];
|
||||
};
|
||||
|
||||
type MethodToPathWithParamsMap = {
|
||||
[TOperation in Operations as Parameters<TOperation['fn']> extends { length: 0 } ? never : TOperation['method']]: TOperation['path'];
|
||||
};
|
||||
|
||||
type MethodToPathWithoutParamsMap = {
|
||||
[
|
||||
TOperation in Operations as Parameters<TOperation['fn']> extends { length: 0 }
|
||||
? TOperation['method']
|
||||
: undefined extends Parameters<TOperation['fn']>[0]
|
||||
? TOperation['method']
|
||||
: never
|
||||
]: TOperation['path'];
|
||||
};
|
||||
|
||||
export type PathFor<TMethod extends Method> = MethodToPathMap[TMethod];
|
||||
|
||||
export type PathWithParamsFor<TMethod extends Method> = MethodToPathWithParamsMap[TMethod extends keyof MethodToPathWithParamsMap
|
||||
? TMethod
|
||||
: never];
|
||||
|
||||
export type PathWithoutParamsFor<TMethod extends Method> = MethodToPathWithoutParamsMap[TMethod extends keyof MethodToPathWithoutParamsMap
|
||||
? TMethod
|
||||
: never];
|
||||
|
||||
type MethodToPathPatternToParamsMap = {
|
||||
[TMethod in Method]: {
|
||||
[TPathPattern in keyof Endpoints]: TMethod extends keyof Endpoints[TPathPattern]
|
||||
? Endpoints[TPathPattern][TMethod] extends infer TOperation
|
||||
? TOperation extends (...args: any) => any
|
||||
? Parameters<TOperation>[0]
|
||||
: never
|
||||
: never
|
||||
: never;
|
||||
};
|
||||
};
|
||||
|
||||
type MethodToPathPatternToResultMap = {
|
||||
[TMethod in Method]: {
|
||||
[TPathPattern in keyof Endpoints]: TMethod extends keyof Endpoints[TPathPattern]
|
||||
? Endpoints[TPathPattern][TMethod] extends infer TOperation
|
||||
? TOperation extends (...args: any) => any
|
||||
? ReturnType<TOperation>
|
||||
: never
|
||||
: never
|
||||
: never;
|
||||
};
|
||||
};
|
||||
|
||||
export type ParamsFor<TMethod extends Method, TPathPattern extends PathPattern> = MethodToPathPatternToParamsMap[TMethod][TPathPattern];
|
||||
|
||||
export type ResultFor<TMethod extends Method, TPathPattern extends PathPattern> = MethodToPathPatternToResultMap[TMethod][TPathPattern];
|
||||
|
||||
export type MatchPathPattern<TPath extends Path> = TPath extends any ? Extract<Operations, { path: TPath }>['pathPattern'] : never;
|
||||
|
||||
export type JoinPathPattern<TBasePath extends string, TSubPathPattern extends string> = Extract<
|
||||
PathPattern,
|
||||
`${TBasePath}${TSubPathPattern extends '' ? TSubPathPattern : `/${TSubPathPattern}`}` | TSubPathPattern
|
||||
>;
|
||||
|
||||
type GetParams<TOperation> = TOperation extends (...args: any) => any ? Parameters<TOperation>[0] : never;
|
||||
|
||||
type GetResult<TOperation> = TOperation extends (...args: any) => any ? ReturnType<TOperation> : never;
|
||||
|
||||
export type OperationParams<TMethod extends Method, TPathPattern extends PathPattern> = TMethod extends keyof Endpoints[TPathPattern]
|
||||
? GetParams<Endpoints[TPathPattern][TMethod]>
|
||||
: never;
|
||||
|
||||
export type OperationResult<TMethod extends Method, TPathPattern extends PathPattern> = TMethod extends keyof Endpoints[TPathPattern]
|
||||
? GetResult<Endpoints[TPathPattern][TMethod]>
|
||||
: never;
|
||||
|
||||
export type UrlParams<T extends string> = string extends T
|
||||
? Record<string, string>
|
||||
: T extends `${string}:${infer Param}/${infer Rest}`
|
||||
? { [k in Param | keyof UrlParams<Rest>]: string }
|
||||
: T extends `${string}:${infer Param}`
|
||||
? { [k in Param]: string }
|
||||
: undefined | Record<string, never>;
|
||||
|
||||
export type MethodOf<TPathPattern extends PathPattern> = TPathPattern extends any ? keyof Endpoints[TPathPattern] : never;
|
||||
|
||||
export * from './apps';
|
||||
export type * from './v1/presence';
|
||||
export * from './v1/roles';
|
||||
export * from './v1/settings';
|
||||
export * from './v1/teams';
|
||||
export * from './v1/videoConference';
|
||||
export * from './v1/assets';
|
||||
export * from './v1/aiSearch';
|
||||
export * from './v1/channels';
|
||||
export * from './v1/customSounds';
|
||||
export type * from './v1/customUserStatus';
|
||||
export * from './v1/subscriptionsEndpoints';
|
||||
export type * from './v1/mailer';
|
||||
export * from './v1/me/meSuccessResponse';
|
||||
export * from './v1/mailer/MailerParamsPOST';
|
||||
export * from './v1/mailer/MailerUnsubscribeParamsPOST';
|
||||
export * from './v1/misc';
|
||||
export * from './v1/invites';
|
||||
export * from './v1/dm';
|
||||
export * from './v1/dm/DmHistoryProps';
|
||||
export * from './v1/integrations';
|
||||
export * from './v1/licenses';
|
||||
export * from './v1/omnichannel';
|
||||
export * from './v1/push';
|
||||
export type * from './helpers/IGetRoomRoles';
|
||||
export type * from './helpers/PaginatedRequest';
|
||||
export type * from './helpers/PaginatedResult';
|
||||
export type * from './helpers/ReplacePlaceholders';
|
||||
export type * from './helpers/WithItemCount';
|
||||
export * from './v1/emojiCustom';
|
||||
export type * from './v1/instances';
|
||||
export * from './v1/ldap';
|
||||
export * from './v1/saml';
|
||||
export * from './v1/users';
|
||||
export * from './v1/users/UsersSetAvatarParamsPOST';
|
||||
export * from './v1/users/UsersSetPreferenceParamsPOST';
|
||||
export * from './v1/users/UsersUpdateOwnBasicInfoParamsPOST';
|
||||
export * from './v1/users/UsersUpdateParamsPOST';
|
||||
export * from './v1/users/UsersCheckUsernameAvailabilityParamsGET';
|
||||
export * from './v1/users/UsersSendConfirmationEmailParamsPOST';
|
||||
export * from './v1/users/UsersGetAvatarParamsGET';
|
||||
export * from './v1/users/UsersPresenceParamsGET';
|
||||
export * from './v1/users/UsersRequestDataDownloadParamsGET';
|
||||
export * from './v1/users/UsersGetPresenceParamsGET';
|
||||
export * from './v1/users/UsersGetStatusParamsGET';
|
||||
export * from './v1/moderation';
|
||||
export * from './v1/server-events';
|
||||
export * from './v1/statistics';
|
||||
|
||||
export * from './v1/autotranslate/AutotranslateGetSupportedLanguagesParamsGET';
|
||||
export * from './v1/autotranslate/AutotranslateSaveSettingsParamsPOST';
|
||||
export * from './v1/e2e/e2eSetUserPublicAndPrivateKeysParamsPOST';
|
||||
export * from './v1/e2e';
|
||||
export * from './v1/import';
|
||||
export * from './v1/email-inbox';
|
||||
export * from './v1/calendar';
|
||||
export * from './v1/federation';
|
||||
export * from './v1/rooms';
|
||||
export * from './v1/groups';
|
||||
export * from './v1/chat';
|
||||
export * from './v1/auth';
|
||||
export * from './v1/cloud';
|
||||
export * from './v1/banners';
|
||||
export * from './default';
|
||||
export * from './v1/twoFactorChallenges';
|
||||
|
||||
// Opt-in experimental endpoint typings. Deliberately NOT part of the `Endpoints`
|
||||
// union above — see ./experimental for the rationale.
|
||||
export type * from './experimental';
|
||||
|
||||
// Export the ajv instance for use in other packages
|
||||
export * from './v1/Ajv';
|
||||
145
packages/rest-typings/src/v1/Ajv.ts
Normal file
145
packages/rest-typings/src/v1/Ajv.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import Ajv from 'ajv/dist/2020';
|
||||
import addFormats from 'ajv-formats';
|
||||
|
||||
const ajv = new Ajv({
|
||||
coerceTypes: true,
|
||||
allowUnionTypes: true,
|
||||
code: { source: true },
|
||||
discriminator: true,
|
||||
});
|
||||
|
||||
/** AJV instance for query param validation; coerces types (e.g. string "50" → number, "c" → ["c"]) for URL query strings. */
|
||||
const ajvQuery = new Ajv({
|
||||
coerceTypes: 'array',
|
||||
allowUnionTypes: true,
|
||||
code: { source: true },
|
||||
discriminator: true,
|
||||
});
|
||||
|
||||
// TODO: keep ajv extension here
|
||||
addFormats(ajv);
|
||||
addFormats(ajvQuery);
|
||||
|
||||
ajv.addFormat('basic_email', /^[^@]+@[^@]+$/);
|
||||
ajv.addFormat(
|
||||
'rfc_email',
|
||||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
|
||||
);
|
||||
ajvQuery.addFormat('basic_email', /^[^@]+@[^@]+$/);
|
||||
ajvQuery.addFormat(
|
||||
'rfc_email',
|
||||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
|
||||
);
|
||||
ajv.addKeyword({
|
||||
keyword: 'isNotEmpty',
|
||||
type: 'string',
|
||||
validate: (_schema: unknown, data: unknown): boolean => typeof data === 'string' && !!data.trim(),
|
||||
});
|
||||
ajvQuery.addKeyword({
|
||||
keyword: 'isNotEmpty',
|
||||
type: 'string',
|
||||
validate: (_schema: unknown, data: unknown): boolean => typeof data === 'string' && !!data.trim(),
|
||||
});
|
||||
export { ajv, ajvQuery };
|
||||
|
||||
type BadRequestErrorResponse = {
|
||||
success: false;
|
||||
error?: unknown;
|
||||
errorType?: string;
|
||||
stack?: string;
|
||||
details?: string | object | object[];
|
||||
};
|
||||
|
||||
const BadRequestErrorResponseSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
success: { type: 'boolean', enum: [false] },
|
||||
stack: { type: 'string' },
|
||||
error: { type: 'string' },
|
||||
errorType: { type: 'string' },
|
||||
details: { anyOf: [{ type: 'string' }, { type: 'object' }, { type: 'array' }] },
|
||||
},
|
||||
required: ['success'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const validateBadRequestErrorResponse = ajv.compile<BadRequestErrorResponse>(BadRequestErrorResponseSchema);
|
||||
|
||||
type UnauthorizedErrorResponse = {
|
||||
success: false;
|
||||
status?: string;
|
||||
message?: string;
|
||||
error?: string;
|
||||
errorType?: string;
|
||||
};
|
||||
|
||||
const UnauthorizedErrorResponseSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
success: { type: 'boolean', enum: [false] },
|
||||
status: { type: 'string' },
|
||||
message: { type: 'string' },
|
||||
error: { type: 'string' },
|
||||
errorType: { type: 'string' },
|
||||
},
|
||||
required: ['success'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const validateUnauthorizedErrorResponse = ajv.compile<UnauthorizedErrorResponse>(UnauthorizedErrorResponseSchema);
|
||||
|
||||
type ForbiddenErrorResponse = {
|
||||
success: false;
|
||||
status?: string;
|
||||
message?: string;
|
||||
error?: string;
|
||||
errorType?: string;
|
||||
};
|
||||
|
||||
const ForbiddenErrorResponseSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
success: { type: 'boolean', enum: [false] },
|
||||
status: { type: 'string' },
|
||||
message: { type: 'string' },
|
||||
error: { type: 'string' },
|
||||
errorType: { type: 'string' },
|
||||
},
|
||||
required: ['success'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const validateForbiddenErrorResponse = ajv.compile<ForbiddenErrorResponse>(ForbiddenErrorResponseSchema);
|
||||
|
||||
type NotFoundErrorResponse = {
|
||||
success: false;
|
||||
error: string;
|
||||
};
|
||||
|
||||
const NotFoundErrorResponseSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
success: { type: 'boolean', enum: [false] },
|
||||
error: { type: 'string' },
|
||||
},
|
||||
required: ['success', 'error'],
|
||||
};
|
||||
|
||||
export const validateNotFoundErrorResponse = ajv.compile<NotFoundErrorResponse>(NotFoundErrorResponseSchema);
|
||||
|
||||
type InternalErrorResponse = {
|
||||
success: false;
|
||||
error: string;
|
||||
};
|
||||
|
||||
const InternalErrorResponseSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
success: { type: 'boolean', enum: [false] },
|
||||
error: { type: 'string' },
|
||||
},
|
||||
required: ['success', 'error'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const validateInternalErrorResponse = ajv.compile<InternalErrorResponse>(InternalErrorResponseSchema);
|
||||
112
packages/rest-typings/src/v1/aiSearch.ts
Normal file
112
packages/rest-typings/src/v1/aiSearch.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import type { IRoom } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajv, ajvQuery } from './Ajv';
|
||||
|
||||
type AISearch = {
|
||||
query: string;
|
||||
intelligentCount?: number;
|
||||
rid?: string;
|
||||
rids?: string;
|
||||
roomNames?: string;
|
||||
fromUsername?: string;
|
||||
fromUsernames?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
};
|
||||
|
||||
const AISearchSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: { type: 'string', minLength: 1, pattern: '\\S', maxLength: 500 },
|
||||
intelligentCount: { type: 'number' },
|
||||
rid: { type: 'string', maxLength: 256 },
|
||||
rids: { type: 'string', maxLength: 4096 },
|
||||
roomNames: { type: 'string', maxLength: 4096 },
|
||||
fromUsername: { type: 'string', maxLength: 256 },
|
||||
fromUsernames: { type: 'string', maxLength: 4096 },
|
||||
startDate: {
|
||||
anyOf: [
|
||||
{ type: 'string', maxLength: 0 },
|
||||
{ type: 'string', format: 'date' },
|
||||
{ type: 'string', format: 'date-time' },
|
||||
],
|
||||
},
|
||||
endDate: {
|
||||
anyOf: [
|
||||
{ type: 'string', maxLength: 0 },
|
||||
{ type: 'string', format: 'date' },
|
||||
{ type: 'string', format: 'date-time' },
|
||||
],
|
||||
},
|
||||
},
|
||||
required: ['query'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isAISearchProps = ajvQuery.compile<AISearch>(AISearchSchema);
|
||||
|
||||
export type SearchAnswer = {
|
||||
query: string;
|
||||
messages: {
|
||||
_id: string;
|
||||
score?: number;
|
||||
}[];
|
||||
};
|
||||
|
||||
const SearchAnswerSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: { type: 'string', minLength: 1, pattern: '\\S', maxLength: 500 },
|
||||
messages: {
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
maxItems: 20,
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
_id: { type: 'string', minLength: 1, maxLength: 128 },
|
||||
score: { type: 'number', minimum: 0, maximum: 1 },
|
||||
},
|
||||
required: ['_id'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['query', 'messages'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isSearchAnswerProps = ajv.compile<SearchAnswer>(SearchAnswerSchema);
|
||||
|
||||
export type AISearchResult = {
|
||||
_id: string;
|
||||
rid?: string;
|
||||
msgId?: string;
|
||||
text: string;
|
||||
score?: number;
|
||||
ts?: string;
|
||||
u?: { username: string; name?: string };
|
||||
room?: Pick<IRoom, '_id' | 't' | 'name' | 'fname'>;
|
||||
};
|
||||
|
||||
export type AISearchEndpoints = {
|
||||
'/v1/ai.search': {
|
||||
GET: (params: AISearch) => {
|
||||
intelligent: AISearchResult[];
|
||||
meta: {
|
||||
intelligentSearchEnabled: boolean;
|
||||
intelligentSearchConfigured: boolean;
|
||||
answerGenerationConfigured: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
'/v1/ai.search.answer': {
|
||||
POST: (params: SearchAnswer) => {
|
||||
answer: string;
|
||||
provider: { name: string; model: string };
|
||||
};
|
||||
};
|
||||
'/v1/ai.llm.models': {
|
||||
GET: () => { data: { key: string; label: string }[] };
|
||||
};
|
||||
};
|
||||
43
packages/rest-typings/src/v1/assets.ts
Normal file
43
packages/rest-typings/src/v1/assets.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { IRocketChatAssets } from '@rocket.chat/core-typings';
|
||||
import type { JSONSchemaType } from 'ajv';
|
||||
|
||||
import { ajv } from './Ajv';
|
||||
|
||||
export type AssetsUnsetAssetProps = { assetName: keyof IRocketChatAssets; refreshAllClients?: boolean };
|
||||
|
||||
export type AssetsSetAssetProps = { asset: string | ArrayBuffer; assetName: keyof IRocketChatAssets; refreshAllClients?: boolean };
|
||||
|
||||
export type AssetsEndpoints = {
|
||||
'/v1/assets.setAsset': {
|
||||
POST: (params: AssetsSetAssetProps) => void;
|
||||
};
|
||||
|
||||
'/v1/assets.unsetAsset': {
|
||||
POST: (params: AssetsUnsetAssetProps) => void;
|
||||
};
|
||||
};
|
||||
|
||||
const assetsUnsetAssetPropsSchema: JSONSchemaType<AssetsUnsetAssetProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
assetName: { type: 'string' },
|
||||
refreshAllClients: { type: 'boolean', nullable: true },
|
||||
},
|
||||
required: ['assetName'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
const assetsSetAssetPropsSchema: JSONSchemaType<AssetsSetAssetProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
assetName: { type: 'string' },
|
||||
asset: { type: 'string' },
|
||||
refreshAllClients: { type: 'boolean', nullable: true },
|
||||
},
|
||||
required: ['assetName'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isAssetsUnsetAssetProps = ajv.compile(assetsUnsetAssetPropsSchema);
|
||||
|
||||
export const isAssetsSetAssetProps = ajv.compile(assetsSetAssetPropsSchema);
|
||||
44
packages/rest-typings/src/v1/auth.ts
Normal file
44
packages/rest-typings/src/v1/auth.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { ajv } from './Ajv';
|
||||
|
||||
type Password = string | { hashed: string };
|
||||
|
||||
type EmailLogin = { email: string };
|
||||
type UsernameLogin = { username: string };
|
||||
type UserLogin = { user: UsernameLogin | EmailLogin | string };
|
||||
|
||||
export type LoginProps = (EmailLogin | UsernameLogin | UserLogin) & { code?: string; password?: Password };
|
||||
|
||||
type LogoutResponse = {
|
||||
message: string;
|
||||
};
|
||||
|
||||
export type AuthEndpoints = {
|
||||
'/v1/login': {
|
||||
POST: (params: LoginProps) => Record<string, any>;
|
||||
};
|
||||
|
||||
'/v1/logout': {
|
||||
POST: () => LogoutResponse;
|
||||
GET: () => LogoutResponse;
|
||||
};
|
||||
};
|
||||
|
||||
const loginPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
user: { type: 'object', nullable: true },
|
||||
username: { type: 'string', nullable: true },
|
||||
password: {
|
||||
oneOf: [
|
||||
{ type: 'string', nullable: true },
|
||||
{ type: 'object', nullable: true },
|
||||
],
|
||||
},
|
||||
email: { type: 'string', nullable: true },
|
||||
code: { type: 'string', nullable: true },
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isLoginProps = ajv.compile(loginPropsSchema);
|
||||
13
packages/rest-typings/src/v1/autoTranslate.ts
Normal file
13
packages/rest-typings/src/v1/autoTranslate.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ISupportedLanguage } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { AutotranslateGetSupportedLanguagesParamsGET } from './autotranslate/AutotranslateGetSupportedLanguagesParamsGET';
|
||||
import type { AutotranslateSaveSettingsParamsPOST } from './autotranslate/AutotranslateSaveSettingsParamsPOST';
|
||||
|
||||
export type AutoTranslateEndpoints = {
|
||||
'/v1/autotranslate.getSupportedLanguages': {
|
||||
GET: (params: AutotranslateGetSupportedLanguagesParamsGET) => { languages: ISupportedLanguage[] };
|
||||
};
|
||||
'/v1/autotranslate.saveSettings': {
|
||||
POST: (params: AutotranslateSaveSettingsParamsPOST) => void;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type AutotranslateGetSupportedLanguagesParamsGET = {
|
||||
targetLanguage: string;
|
||||
};
|
||||
|
||||
const AutotranslateGetSupportedLanguagesParamsGETSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
targetLanguage: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['targetLanguage'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isAutotranslateGetSupportedLanguagesParamsGET = ajvQuery.compile<AutotranslateGetSupportedLanguagesParamsGET>(
|
||||
AutotranslateGetSupportedLanguagesParamsGETSchema,
|
||||
);
|
||||
@@ -0,0 +1,33 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type AutotranslateSaveSettingsParamsPOST = {
|
||||
roomId: string;
|
||||
field: 'autoTranslate' | 'autoTranslateLanguage';
|
||||
value: boolean | string;
|
||||
defaultLanguage?: string;
|
||||
};
|
||||
|
||||
const AutotranslateSaveSettingsParamsPostSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
field: {
|
||||
enum: ['autoTranslate', 'autoTranslateLanguage'],
|
||||
},
|
||||
value: {
|
||||
anyOf: [{ type: 'boolean' }, { type: 'string' }],
|
||||
},
|
||||
defaultLanguage: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'field', 'value'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isAutotranslateSaveSettingsParamsPOST = ajv.compile<AutotranslateSaveSettingsParamsPOST>(
|
||||
AutotranslateSaveSettingsParamsPostSchema,
|
||||
);
|
||||
61
packages/rest-typings/src/v1/banners.ts
Normal file
61
packages/rest-typings/src/v1/banners.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import type { BannerPlatform, IBanner } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajv, ajvQuery } from './Ajv';
|
||||
|
||||
type BannersId = {
|
||||
platform: BannerPlatform;
|
||||
};
|
||||
|
||||
type Banners = {
|
||||
platform: BannerPlatform;
|
||||
};
|
||||
|
||||
const BannersSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
platform: {
|
||||
type: 'string',
|
||||
enum: ['web', 'mobile'],
|
||||
},
|
||||
},
|
||||
required: ['platform'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isBannersProps = ajvQuery.compile<Banners>(BannersSchema);
|
||||
|
||||
type BannersDismiss = {
|
||||
bannerId: string;
|
||||
};
|
||||
|
||||
const BannersDismissSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
bannerId: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
required: ['bannerId'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isBannersDismissProps = ajv.compile<BannersDismiss>(BannersDismissSchema);
|
||||
|
||||
export type BannersEndpoints = {
|
||||
'/v1/banners/:id': {
|
||||
GET: (params: BannersId) => {
|
||||
banners: IBanner[];
|
||||
};
|
||||
};
|
||||
|
||||
'/v1/banners': {
|
||||
GET: (params: Banners) => {
|
||||
banners: IBanner[];
|
||||
};
|
||||
};
|
||||
|
||||
'/v1/banners.dismiss': {
|
||||
POST: (params: BannersDismiss) => void;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
import type { JSONSchemaType } from 'ajv';
|
||||
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type CalendarEventCreateProps = {
|
||||
startTime: string;
|
||||
endTime?: string;
|
||||
externalId?: string;
|
||||
subject: string;
|
||||
description: string;
|
||||
meetingUrl?: string;
|
||||
reminderMinutesBeforeStart?: number;
|
||||
busy?: boolean;
|
||||
};
|
||||
|
||||
const calendarEventCreatePropsSchema: JSONSchemaType<CalendarEventCreateProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
startTime: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
endTime: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
externalId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
meetingUrl: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
reminderMinutesBeforeStart: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
busy: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['startTime', 'subject', 'description'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCalendarEventCreateProps = ajv.compile(calendarEventCreatePropsSchema);
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { ICalendarEvent } from '@rocket.chat/core-typings';
|
||||
import type { JSONSchemaType } from 'ajv';
|
||||
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type CalendarEventDeleteProps = {
|
||||
eventId: ICalendarEvent['_id'];
|
||||
};
|
||||
|
||||
const calendarEventDeletePropsSchema: JSONSchemaType<CalendarEventDeleteProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
eventId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['eventId'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCalendarEventDeleteProps = ajv.compile(calendarEventDeletePropsSchema);
|
||||
@@ -0,0 +1,56 @@
|
||||
import type { JSONSchemaType } from 'ajv';
|
||||
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type CalendarEventImportProps = {
|
||||
startTime: string;
|
||||
endTime?: string;
|
||||
externalId: string;
|
||||
subject: string;
|
||||
description: string;
|
||||
meetingUrl?: string;
|
||||
reminderMinutesBeforeStart?: number;
|
||||
busy?: boolean;
|
||||
};
|
||||
|
||||
const calendarEventImportPropsSchema: JSONSchemaType<CalendarEventImportProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
startTime: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
endTime: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
externalId: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
meetingUrl: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
reminderMinutesBeforeStart: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
busy: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['startTime', 'externalId', 'subject', 'description'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCalendarEventImportProps = ajv.compile(calendarEventImportPropsSchema);
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { JSONSchemaType } from 'ajv';
|
||||
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type CalendarEventInfoProps = { id: string };
|
||||
|
||||
const calendarEventInfoPropsSchema: JSONSchemaType<CalendarEventInfoProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
},
|
||||
required: ['id'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCalendarEventInfoProps = ajvQuery.compile(calendarEventInfoPropsSchema);
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { JSONSchemaType } from 'ajv';
|
||||
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type CalendarEventListProps = { date: string };
|
||||
|
||||
const calendarEventListPropsSchema: JSONSchemaType<CalendarEventListProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
date: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
},
|
||||
required: ['date'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCalendarEventListProps = ajvQuery.compile(calendarEventListPropsSchema);
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { ICalendarEvent } from '@rocket.chat/core-typings';
|
||||
import type { JSONSchemaType } from 'ajv';
|
||||
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type CalendarEventUpdateProps = {
|
||||
eventId: ICalendarEvent['_id'];
|
||||
startTime: string;
|
||||
endTime?: string;
|
||||
subject: string;
|
||||
description: string;
|
||||
meetingUrl?: string;
|
||||
reminderMinutesBeforeStart?: number;
|
||||
busy?: boolean;
|
||||
};
|
||||
|
||||
const calendarEventUpdatePropsSchema: JSONSchemaType<CalendarEventUpdateProps> = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
eventId: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
startTime: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
endTime: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
},
|
||||
meetingUrl: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
reminderMinutesBeforeStart: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
busy: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['eventId', 'startTime', 'subject', 'description'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCalendarEventUpdateProps = ajv.compile(calendarEventUpdatePropsSchema);
|
||||
41
packages/rest-typings/src/v1/calendar/index.ts
Normal file
41
packages/rest-typings/src/v1/calendar/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import type { ICalendarEvent } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { CalendarEventCreateProps } from './CalendarEventCreateProps';
|
||||
import type { CalendarEventDeleteProps } from './CalendarEventDeleteProps';
|
||||
import type { CalendarEventImportProps } from './CalendarEventImportProps';
|
||||
import type { CalendarEventInfoProps } from './CalendarEventInfoProps';
|
||||
import type { CalendarEventListProps } from './CalendarEventListProps';
|
||||
import type { CalendarEventUpdateProps } from './CalendarEventUpdateProps';
|
||||
|
||||
export * from './CalendarEventCreateProps';
|
||||
export * from './CalendarEventDeleteProps';
|
||||
export * from './CalendarEventImportProps';
|
||||
export * from './CalendarEventInfoProps';
|
||||
export * from './CalendarEventUpdateProps';
|
||||
export * from './CalendarEventListProps';
|
||||
|
||||
export type CalendarEndpoints = {
|
||||
'/v1/calendar-events.create': {
|
||||
POST: (params: CalendarEventCreateProps) => { id: ICalendarEvent['_id'] };
|
||||
};
|
||||
|
||||
'/v1/calendar-events.list': {
|
||||
GET: (params: CalendarEventListProps) => { data: ICalendarEvent[] };
|
||||
};
|
||||
|
||||
'/v1/calendar-events.info': {
|
||||
GET: (params: CalendarEventInfoProps) => { event: ICalendarEvent };
|
||||
};
|
||||
|
||||
'/v1/calendar-events.import': {
|
||||
POST: (params: CalendarEventImportProps) => { id: ICalendarEvent['_id'] };
|
||||
};
|
||||
|
||||
'/v1/calendar-events.update': {
|
||||
POST: (params: CalendarEventUpdateProps) => void;
|
||||
};
|
||||
|
||||
'/v1/calendar-events.delete': {
|
||||
POST: (params: CalendarEventDeleteProps) => void;
|
||||
};
|
||||
};
|
||||
39
packages/rest-typings/src/v1/channels/ChannelsAddAllProps.ts
Normal file
39
packages/rest-typings/src/v1/channels/ChannelsAddAllProps.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsAddAllProps = ({ roomId: string } | { roomName: string }) & {
|
||||
activeUsersOnly?: 'true' | 'false' | 1 | 0;
|
||||
};
|
||||
const channelsAddAllPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
activeUsersOnly: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
activeUsersOnly: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsAddAllProps = ajv.compile<ChannelsAddAllProps>(channelsAddAllPropsSchema);
|
||||
@@ -0,0 +1,29 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsArchiveProps = { roomId: string } | { roomName: string };
|
||||
const channelsArchivePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsArchiveProps = ajv.compile<ChannelsArchiveProps>(channelsArchivePropsSchema);
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { IRoom } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsConvertToTeamProps =
|
||||
{ channelId: IRoom['_id']; channelName?: never } | { channelName: Exclude<IRoom['name'], undefined>; channelId?: never };
|
||||
|
||||
const channelsConvertToTeamPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
channelId: { type: 'string' },
|
||||
},
|
||||
required: ['channelId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
channelName: { type: 'string' },
|
||||
},
|
||||
required: ['channelName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsConvertToTeamProps = ajv.compile<ChannelsConvertToTeamProps>(channelsConvertToTeamPropsSchema);
|
||||
71
packages/rest-typings/src/v1/channels/ChannelsCreateProps.ts
Normal file
71
packages/rest-typings/src/v1/channels/ChannelsCreateProps.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsCreateProps = {
|
||||
name: string;
|
||||
members?: string[];
|
||||
teams?: string[];
|
||||
readOnly?: boolean;
|
||||
customFields?: Record<string, any>;
|
||||
extraData?: {
|
||||
broadcast?: boolean;
|
||||
encrypted?: boolean;
|
||||
teamId?: string;
|
||||
topic?: string;
|
||||
federated?: boolean;
|
||||
};
|
||||
excludeSelf?: boolean;
|
||||
};
|
||||
|
||||
const channelsCreatePropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
},
|
||||
members: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
},
|
||||
teams: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
},
|
||||
readOnly: {
|
||||
type: 'boolean',
|
||||
},
|
||||
customFields: {
|
||||
type: 'object',
|
||||
},
|
||||
excludeSelf: {
|
||||
type: 'boolean',
|
||||
},
|
||||
extraData: {
|
||||
// extraData is spread verbatim into createRoom. Keep it closed (additionalProperties: false)
|
||||
// so callers can't inject arbitrary room fields (default/featured/retention/abacAttributes/...).
|
||||
// The create modal only sends the fields declared below.
|
||||
type: 'object',
|
||||
properties: {
|
||||
broadcast: {
|
||||
type: 'boolean',
|
||||
},
|
||||
encrypted: {
|
||||
type: 'boolean',
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
},
|
||||
topic: {
|
||||
type: 'string',
|
||||
},
|
||||
federated: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
required: ['name'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isChannelsCreateProps = ajv.compile<ChannelsCreateProps>(channelsCreatePropsSchema);
|
||||
30
packages/rest-typings/src/v1/channels/ChannelsDeleteProps.ts
Normal file
30
packages/rest-typings/src/v1/channels/ChannelsDeleteProps.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsDeleteProps = { roomId: string } | { roomName: string };
|
||||
|
||||
const channelsDeletePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsDeleteProps = ajv.compile<ChannelsDeleteProps>(channelsDeletePropsSchema);
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsFilesListProps = PaginatedRequest<
|
||||
({ roomId: string; roomName?: string } | { roomId?: string; roomName: string }) & {
|
||||
name?: string;
|
||||
typeGroup?: string;
|
||||
query?: string;
|
||||
onlyConfirmed?: boolean;
|
||||
}
|
||||
>;
|
||||
|
||||
const channelsFilesListPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
roomName: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
typeGroup: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
onlyConfirmed: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
oneOf: [
|
||||
{ type: 'object', required: ['roomId'] },
|
||||
{ type: 'object', required: ['roomName'] },
|
||||
],
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isChannelsFilesListProps = ajvQuery.compile<ChannelsFilesListProps>(channelsFilesListPropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsGetAllUserMentionsByChannelProps = PaginatedRequest<{ roomId: string }>;
|
||||
|
||||
const channelsGetAllUserMentionsByChannelPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isChannelsGetAllUserMentionsByChannelProps = ajvQuery.compile<ChannelsGetAllUserMentionsByChannelProps>(
|
||||
channelsGetAllUserMentionsByChannelPropsSchema,
|
||||
);
|
||||
@@ -0,0 +1,39 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsGetIntegrationsProps =
|
||||
{ roomId: string; includeAllPublicChannels?: string } | { roomName: string; includeAllPublicChannels?: string };
|
||||
|
||||
const channelsGetIntegrationsPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
includeAllPublicChannels: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
includeAllPublicChannels: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsGetIntegrationsProps = ajv.compile<ChannelsGetIntegrationsProps>(channelsGetIntegrationsPropsSchema);
|
||||
114
packages/rest-typings/src/v1/channels/ChannelsHistoryProps.ts
Normal file
114
packages/rest-typings/src/v1/channels/ChannelsHistoryProps.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsHistoryProps = PaginatedRequest<
|
||||
({ roomId: string } | { roomName: string }) & {
|
||||
latest?: string;
|
||||
showThreadMessages?: 'false' | 'true';
|
||||
oldest?: string;
|
||||
unreads?: 'true' | 'false';
|
||||
inclusive?: 'false' | 'true';
|
||||
}
|
||||
>;
|
||||
const channelsHistoryPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
latest: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
nullable: true,
|
||||
},
|
||||
showThreadMessages: {
|
||||
type: 'string',
|
||||
enum: ['false', 'true'],
|
||||
nullable: true,
|
||||
},
|
||||
oldest: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
nullable: true,
|
||||
},
|
||||
inclusive: {
|
||||
type: 'string',
|
||||
enum: ['false', 'true'],
|
||||
nullable: true,
|
||||
},
|
||||
unreads: {
|
||||
type: 'string',
|
||||
enum: ['true', 'false'],
|
||||
nullable: true,
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
latest: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
nullable: true,
|
||||
},
|
||||
showThreadMessages: {
|
||||
type: 'string',
|
||||
enum: ['false', 'true'],
|
||||
nullable: true,
|
||||
},
|
||||
oldest: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
nullable: true,
|
||||
},
|
||||
inclusive: {
|
||||
type: 'string',
|
||||
enum: ['false', 'true'],
|
||||
nullable: true,
|
||||
},
|
||||
unreads: {
|
||||
type: 'string',
|
||||
enum: ['true', 'false'],
|
||||
nullable: true,
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsHistoryProps = ajvQuery.compile<ChannelsHistoryProps>(channelsHistoryPropsSchema);
|
||||
56
packages/rest-typings/src/v1/channels/ChannelsInviteProps.ts
Normal file
56
packages/rest-typings/src/v1/channels/ChannelsInviteProps.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsInviteProps =
|
||||
| { roomId: string; userId?: string; username?: string; user?: string }
|
||||
| { roomName: string; userId?: string; username?: string; user?: string };
|
||||
|
||||
const channelsInvitePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
user: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
user: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsInviteProps = ajv.compile<ChannelsInviteProps>(channelsInvitePropsSchema);
|
||||
38
packages/rest-typings/src/v1/channels/ChannelsJoinProps.ts
Normal file
38
packages/rest-typings/src/v1/channels/ChannelsJoinProps.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsJoinProps = { roomId: string; joinCode?: string } | { roomName: string; joinCode?: string };
|
||||
|
||||
const channelsJoinPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
joinCode: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
joinCode: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsJoinProps = ajv.compile<ChannelsJoinProps>(channelsJoinPropsSchema);
|
||||
36
packages/rest-typings/src/v1/channels/ChannelsKickProps.ts
Normal file
36
packages/rest-typings/src/v1/channels/ChannelsKickProps.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsKickProps = { roomId: string; userId: string } | { roomName: string; userId: string };
|
||||
|
||||
const channelsKickPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'userId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'userId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsKickProps = ajv.compile<ChannelsKickProps>(channelsKickPropsSchema);
|
||||
30
packages/rest-typings/src/v1/channels/ChannelsLeaveProps.ts
Normal file
30
packages/rest-typings/src/v1/channels/ChannelsLeaveProps.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsLeaveProps = { roomId: string } | { roomName: string };
|
||||
|
||||
const channelsLeavePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsLeaveProps = ajv.compile<ChannelsLeaveProps>(channelsLeavePropsSchema);
|
||||
36
packages/rest-typings/src/v1/channels/ChannelsListProps.ts
Normal file
36
packages/rest-typings/src/v1/channels/ChannelsListProps.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsListProps = PaginatedRequest<{
|
||||
_id?: string;
|
||||
/* deprecated */
|
||||
fields?: string;
|
||||
}>;
|
||||
|
||||
const channelsListPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
_id: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
},
|
||||
fields: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isChannelsListProps = ajvQuery.compile<ChannelsListProps>(channelsListPropsSchema);
|
||||
@@ -0,0 +1,53 @@
|
||||
import type { IRoom } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsMessagesProps = PaginatedRequest<
|
||||
{
|
||||
roomId: IRoom['_id'];
|
||||
mentionIds?: string;
|
||||
starredIds?: string;
|
||||
pinned?: string;
|
||||
query?: Record<string, any>;
|
||||
},
|
||||
'ts'
|
||||
>;
|
||||
|
||||
const channelsMessagesPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
mentionIds: {
|
||||
type: 'string',
|
||||
},
|
||||
starredIds: {
|
||||
type: 'string',
|
||||
},
|
||||
pinned: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isChannelsMessagesProps = ajvQuery.compile<ChannelsMessagesProps>(channelsMessagesPropsSchema);
|
||||
@@ -0,0 +1,54 @@
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsModeratorsProps =
|
||||
| { roomId: string; userId?: string; username?: string; user?: string }
|
||||
| { roomName: string; userId?: string; username?: string; user?: string };
|
||||
|
||||
const channelsModeratorsPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: { type: 'string' },
|
||||
userId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
user: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: { type: 'string' },
|
||||
userId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
user: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsModeratorsProps = ajvQuery.compile<ChannelsModeratorsProps>(channelsModeratorsPropsSchema);
|
||||
19
packages/rest-typings/src/v1/channels/ChannelsOnlineProps.ts
Normal file
19
packages/rest-typings/src/v1/channels/ChannelsOnlineProps.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsOnlineProps = { _id?: string; query?: Record<string, any> };
|
||||
const channelsOnlyPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
_id: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
export const isChannelsOnlineProps = ajvQuery.compile<ChannelsOnlineProps>(channelsOnlyPropsSchema);
|
||||
76
packages/rest-typings/src/v1/channels/ChannelsOpenProps.ts
Normal file
76
packages/rest-typings/src/v1/channels/ChannelsOpenProps.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsOpenProps =
|
||||
| {
|
||||
roomId: string;
|
||||
query?: string; // { 'mentions._id': { $in: string[] } } | { 'starred._id': { $in: string[] } } | { pinned: boolean };
|
||||
sort?: { ts: 1 | -1 };
|
||||
}
|
||||
| {
|
||||
roomName: string;
|
||||
query?: string;
|
||||
sort?: { ts: 1 | -1 };
|
||||
};
|
||||
|
||||
const channelsOpenPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ts: {
|
||||
type: 'number',
|
||||
enum: [1, -1],
|
||||
},
|
||||
},
|
||||
required: ['ts'],
|
||||
|
||||
additionalProperties: false,
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ts: {
|
||||
type: 'number',
|
||||
enum: [1, -1],
|
||||
},
|
||||
},
|
||||
required: ['ts'],
|
||||
|
||||
additionalProperties: false,
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsOpenProps = ajv.compile<ChannelsOpenProps>(channelsOpenPropsSchema);
|
||||
36
packages/rest-typings/src/v1/channels/ChannelsRenameProps.ts
Normal file
36
packages/rest-typings/src/v1/channels/ChannelsRenameProps.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsRenameProps = { roomId: string; name: string } | { roomName: string; name: string };
|
||||
|
||||
const channelsRenamePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'name'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'name'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsRenameProps = ajv.compile<ChannelsRenameProps>(channelsRenamePropsSchema);
|
||||
29
packages/rest-typings/src/v1/channels/ChannelsRolesProps.ts
Normal file
29
packages/rest-typings/src/v1/channels/ChannelsRolesProps.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type ChannelsRolesProps = { roomId: string } | { roomName: string };
|
||||
const channelsRolesPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsRolesProps = ajvQuery.compile<ChannelsRolesProps>(channelsRolesPropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetAnnouncementProps = { roomId: string; announcement: string } | { roomName: string; announcement: string };
|
||||
|
||||
const channelsSetAnnouncementPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
announcement: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'announcement'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
announcement: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'announcement'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetAnnouncementProps = ajv.compile<ChannelsSetAnnouncementProps>(channelsSetAnnouncementPropsSchema);
|
||||
@@ -0,0 +1,37 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetCustomFieldsProps =
|
||||
{ roomId: string; customFields: Record<string, any> } | { roomName: string; customFields: Record<string, any> };
|
||||
|
||||
const channelsSetCustomFieldsPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
customFields: {
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'customFields'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
customFields: {
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'customFields'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetCustomFieldsProps = ajv.compile<ChannelsSetCustomFieldsProps>(channelsSetCustomFieldsPropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetDefaultProps = { roomId: string; default: boolean } | { roomName: string; default: boolean };
|
||||
|
||||
const channelsSetDefaultPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
default: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'default'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
default: {
|
||||
type: 'default',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'default'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetDefaultProps = ajv.compile<ChannelsSetDefaultProps>(channelsSetDefaultPropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetDescriptionProps = { roomId: string; description: string } | { roomName: string; description: string };
|
||||
|
||||
const channelsSetDescriptionPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'description'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'description'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetDescriptionProps = ajv.compile<ChannelsSetDescriptionProps>(channelsSetDescriptionPropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetJoinCodeProps = { roomId: string; joinCode: string } | { roomName: string; joinCode: string };
|
||||
|
||||
const channelsSetJoinCodePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'description'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'description'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetJoinCodeProps = ajv.compile<ChannelsSetJoinCodeProps>(channelsSetJoinCodePropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetPurposeProps = { roomId: string; purpose: string } | { roomName: string; purpose: string };
|
||||
|
||||
const channelsSetPurposePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
purpose: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'purpose'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
purpose: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'purpose'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetPurposeProps = ajv.compile<ChannelsSetPurposeProps>(channelsSetPurposePropsSchema);
|
||||
@@ -0,0 +1,28 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetReadOnlyProps = { roomId: string; readOnly: boolean } | { roomName: string; readOnly: boolean };
|
||||
|
||||
const channelsSetReadOnlyPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: { type: 'string' },
|
||||
readOnly: { type: 'boolean' },
|
||||
},
|
||||
required: ['roomId', 'readOnly'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: { type: 'string' },
|
||||
readOnly: { type: 'boolean' },
|
||||
},
|
||||
required: ['roomName', 'readOnly'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetReadOnlyProps = ajv.compile<ChannelsSetReadOnlyProps>(channelsSetReadOnlyPropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetTopicProps = { roomId: string; topic: string } | { roomName: string; topic: string };
|
||||
|
||||
const channelsSetTopicPropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
topic: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'topic'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
topic: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'topic'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetTopicProps = ajv.compile<ChannelsSetTopicProps>(channelsSetTopicPropsSchema);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsSetTypeProps = { roomId: string; type: string } | { roomName: string; type: string };
|
||||
|
||||
const channelsSetTypePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'type'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName', 'type'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsSetTypeProps = ajv.compile<ChannelsSetTypeProps>(channelsSetTypePropsSchema);
|
||||
@@ -0,0 +1,29 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type ChannelsUnarchiveProps = { roomId: string } | { roomName: string };
|
||||
const channelsUnarchivePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isChannelsUnarchiveProps = ajv.compile<ChannelsUnarchiveProps>(channelsUnarchivePropsSchema);
|
||||
245
packages/rest-typings/src/v1/channels/channels.ts
Normal file
245
packages/rest-typings/src/v1/channels/channels.ts
Normal file
@@ -0,0 +1,245 @@
|
||||
import type { IUploadWithUser, IMessage, IRoom, ITeam, IUser, IIntegration } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { ChannelsAddAllProps } from './ChannelsAddAllProps';
|
||||
import type { ChannelsArchiveProps } from './ChannelsArchiveProps';
|
||||
import type { ChannelsConvertToTeamProps } from './ChannelsConvertToTeamProps';
|
||||
import type { ChannelsCreateProps } from './ChannelsCreateProps';
|
||||
import type { ChannelsDeleteProps } from './ChannelsDeleteProps';
|
||||
import type { ChannelsFilesListProps } from './ChannelsFilesListProps';
|
||||
import type { ChannelsGetAllUserMentionsByChannelProps } from './ChannelsGetAllUserMentionsByChannelProps';
|
||||
import type { ChannelsGetIntegrationsProps } from './ChannelsGetIntegrationsProps';
|
||||
import type { ChannelsHistoryProps } from './ChannelsHistoryProps';
|
||||
import type { ChannelsInviteProps } from './ChannelsInviteProps';
|
||||
import type { ChannelsJoinProps } from './ChannelsJoinProps';
|
||||
import type { ChannelsKickProps } from './ChannelsKickProps';
|
||||
import type { ChannelsLeaveProps } from './ChannelsLeaveProps';
|
||||
import type { ChannelsListProps } from './ChannelsListProps';
|
||||
import type { ChannelsMessagesProps } from './ChannelsMessagesProps';
|
||||
import type { ChannelsModeratorsProps } from './ChannelsModeratorsProps';
|
||||
import type { ChannelsOnlineProps } from './ChannelsOnlineProps';
|
||||
import type { ChannelsOpenProps } from './ChannelsOpenProps';
|
||||
import type { ChannelsRenameProps } from './ChannelsRenameProps';
|
||||
import type { ChannelsRolesProps } from './ChannelsRolesProps';
|
||||
import type { ChannelsSetAnnouncementProps } from './ChannelsSetAnnouncementProps';
|
||||
import type { ChannelsSetCustomFieldsProps } from './ChannelsSetCustomFieldsProps';
|
||||
import type { ChannelsSetDefaultProps } from './ChannelsSetDefaultProps';
|
||||
import type { ChannelsSetDescriptionProps } from './ChannelsSetDescriptionProps';
|
||||
import type { ChannelsSetJoinCodeProps } from './ChannelsSetJoinCodeProps';
|
||||
import type { ChannelsSetPurposeProps } from './ChannelsSetPurposeProps';
|
||||
import type { ChannelsSetReadOnlyProps } from './ChannelsSetReadOnlyProps';
|
||||
import type { ChannelsSetTopicProps } from './ChannelsSetTopicProps';
|
||||
import type { ChannelsSetTypeProps } from './ChannelsSetTypeProps';
|
||||
import type { ChannelsUnarchiveProps } from './ChannelsUnarchiveProps';
|
||||
import type { IGetRoomRoles } from '../../helpers/IGetRoomRoles';
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import type { PaginatedResult } from '../../helpers/PaginatedResult';
|
||||
|
||||
export * from './ChannelsFilesListProps';
|
||||
export * from './ChannelsListProps';
|
||||
export * from './ChannelsOnlineProps';
|
||||
|
||||
export type ChannelsEndpoints = {
|
||||
'/v1/channels.files': {
|
||||
GET: (params: ChannelsFilesListProps) => PaginatedResult<{
|
||||
files: IUploadWithUser[];
|
||||
}>;
|
||||
};
|
||||
'/v1/channels.members': {
|
||||
GET: (
|
||||
params: PaginatedRequest<
|
||||
{ roomId: string; filter?: string; status?: string[] } | { roomName: string; filter?: string; status?: string[] }
|
||||
>,
|
||||
) => PaginatedResult<{
|
||||
members: IUser[];
|
||||
}>;
|
||||
};
|
||||
'/v1/channels.history': {
|
||||
GET: (params: ChannelsHistoryProps) => {
|
||||
messages: IMessage[];
|
||||
firstUnread?: IMessage;
|
||||
unreadNotLoaded?: number;
|
||||
};
|
||||
};
|
||||
'/v1/channels.archive': {
|
||||
POST: (params: ChannelsArchiveProps) => void;
|
||||
};
|
||||
'/v1/channels.unarchive': {
|
||||
POST: (params: ChannelsUnarchiveProps) => void;
|
||||
};
|
||||
'/v1/channels.create': {
|
||||
POST: (params: ChannelsCreateProps) => {
|
||||
channel: Omit<IRoom, 'joinCode' | 'members' | 'importIds' | 'e2e'>;
|
||||
};
|
||||
};
|
||||
'/v1/channels.convertToTeam': {
|
||||
POST: (params: ChannelsConvertToTeamProps) => {
|
||||
team: ITeam;
|
||||
};
|
||||
};
|
||||
'/v1/channels.info': {
|
||||
GET: (params: { roomId: string } | { roomName: string }) => { channel: IRoom };
|
||||
};
|
||||
'/v1/channels.counters': {
|
||||
GET: (params: { roomId: string; userId: string } | { roomName: string; userId: string }) => {
|
||||
joined: boolean;
|
||||
members: number | null;
|
||||
unreads: number | null;
|
||||
unreadsFrom: Date | null;
|
||||
msgs: number | null;
|
||||
latest: Date | null;
|
||||
userMentions: number | null;
|
||||
};
|
||||
};
|
||||
'/v1/channels.join': {
|
||||
POST: (params: ChannelsJoinProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.close': {
|
||||
POST: (params: { roomId: string } | { roomName: string }) => void;
|
||||
};
|
||||
'/v1/channels.kick': {
|
||||
POST: (params: ChannelsKickProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.delete': {
|
||||
POST: (params: ChannelsDeleteProps) => void;
|
||||
};
|
||||
'/v1/channels.leave': {
|
||||
POST: (params: ChannelsLeaveProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.addModerator': {
|
||||
POST: (params: ChannelsModeratorsProps) => void;
|
||||
};
|
||||
'/v1/channels.removeModerator': {
|
||||
POST: (params: ChannelsModeratorsProps) => void;
|
||||
};
|
||||
'/v1/channels.addOwner': {
|
||||
POST: (params: ChannelsModeratorsProps) => void;
|
||||
};
|
||||
'/v1/channels.removeOwner': {
|
||||
POST: (params: ChannelsModeratorsProps) => void;
|
||||
};
|
||||
'/v1/channels.addLeader': {
|
||||
POST: (params: ChannelsModeratorsProps) => void;
|
||||
};
|
||||
'/v1/channels.removeLeader': {
|
||||
POST: (params: ChannelsModeratorsProps) => void;
|
||||
};
|
||||
'/v1/channels.roles': {
|
||||
GET: (params: ChannelsRolesProps) => { roles: IGetRoomRoles[] };
|
||||
};
|
||||
'/v1/channels.messages': {
|
||||
GET: (params: ChannelsMessagesProps) => PaginatedResult<{
|
||||
messages: IMessage[];
|
||||
}>;
|
||||
};
|
||||
'/v1/channels.open': {
|
||||
POST: (params: ChannelsOpenProps) => void;
|
||||
};
|
||||
'/v1/channels.setReadOnly': {
|
||||
POST: (params: ChannelsSetReadOnlyProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.addAll': {
|
||||
POST: (params: ChannelsAddAllProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.anonymousread': {
|
||||
GET: (params: PaginatedRequest<{ roomId: string } | { roomName: string }>) => PaginatedResult<{
|
||||
messages: IMessage[];
|
||||
}>;
|
||||
};
|
||||
'/v1/channels.setAnnouncement': {
|
||||
POST: (params: ChannelsSetAnnouncementProps) => {
|
||||
announcement: string;
|
||||
};
|
||||
};
|
||||
'/v1/channels.getAllUserMentionsByChannel': {
|
||||
GET: (params: ChannelsGetAllUserMentionsByChannelProps) => PaginatedResult<{
|
||||
mentions: IMessage[];
|
||||
}>;
|
||||
};
|
||||
'/v1/channels.moderators': {
|
||||
GET: (params: { roomId: string } | { roomName: string }) => { moderators: Pick<IUser, '_id' | 'name' | 'username'>[] };
|
||||
};
|
||||
'/v1/channels.getIntegrations': {
|
||||
GET: (params: ChannelsGetIntegrationsProps) => {
|
||||
count: number;
|
||||
offset: number;
|
||||
integrations: IIntegration[];
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
'/v1/channels.invite': {
|
||||
POST: (params: ChannelsInviteProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.list': {
|
||||
GET: (params: ChannelsListProps) => {
|
||||
count: number;
|
||||
offset: number;
|
||||
channels: IRoom[];
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
'/v1/channels.list.joined': {
|
||||
GET: (params: ChannelsListProps) => {
|
||||
count: number;
|
||||
offset: number;
|
||||
channels: IRoom[];
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
'/v1/channels.online': {
|
||||
GET: (params: ChannelsOnlineProps) => {
|
||||
online: Pick<IUser, '_id' | 'username'>[];
|
||||
};
|
||||
};
|
||||
'/v1/channels.rename': {
|
||||
POST: (params: ChannelsRenameProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.setCustomFields': {
|
||||
POST: (params: ChannelsSetCustomFieldsProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.setDescription': {
|
||||
POST: (params: ChannelsSetDescriptionProps) => {
|
||||
description: string;
|
||||
};
|
||||
};
|
||||
'/v1/channels.setPurpose': {
|
||||
POST: (params: ChannelsSetPurposeProps) => {
|
||||
purpose: string;
|
||||
};
|
||||
};
|
||||
'/v1/channels.setTopic': {
|
||||
POST: (params: ChannelsSetTopicProps) => {
|
||||
topic: string;
|
||||
};
|
||||
};
|
||||
'/v1/channels.setType': {
|
||||
POST: (params: ChannelsSetTypeProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.setDefault': {
|
||||
POST: (params: ChannelsSetDefaultProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
'/v1/channels.setJoinCode': {
|
||||
POST: (params: ChannelsSetJoinCodeProps) => {
|
||||
channel: IRoom;
|
||||
};
|
||||
};
|
||||
};
|
||||
19
packages/rest-typings/src/v1/channels/index.ts
Normal file
19
packages/rest-typings/src/v1/channels/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export * from './channels';
|
||||
|
||||
export * from './ChannelsAddAllProps';
|
||||
export * from './ChannelsArchiveProps';
|
||||
export * from './ChannelsConvertToTeamProps';
|
||||
export * from './ChannelsCreateProps';
|
||||
export * from './ChannelsDeleteProps';
|
||||
export * from './ChannelsGetAllUserMentionsByChannelProps';
|
||||
export * from './ChannelsHistoryProps';
|
||||
export * from './ChannelsJoinProps';
|
||||
export * from './ChannelsKickProps';
|
||||
export * from './ChannelsLeaveProps';
|
||||
export * from './ChannelsMessagesProps';
|
||||
export * from './ChannelsModeratorsProps';
|
||||
export * from './ChannelsOpenProps';
|
||||
export * from './ChannelsRolesProps';
|
||||
export * from './ChannelsSetAnnouncementProps';
|
||||
export * from './ChannelsSetReadOnlyProps';
|
||||
export * from './ChannelsUnarchiveProps';
|
||||
1086
packages/rest-typings/src/v1/chat.ts
Normal file
1086
packages/rest-typings/src/v1/chat.ts
Normal file
File diff suppressed because it is too large
Load Diff
112
packages/rest-typings/src/v1/cloud.ts
Normal file
112
packages/rest-typings/src/v1/cloud.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import type { CloudRegistrationIntentData, CloudConfirmationPollData, CloudRegistrationStatus } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajv, ajvQuery } from './Ajv';
|
||||
|
||||
type CloudManualRegister = {
|
||||
cloudBlob: string;
|
||||
};
|
||||
|
||||
const CloudManualRegisterSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
cloudBlob: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['cloudBlob'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCloudManualRegisterProps = ajv.compile<CloudManualRegister>(CloudManualRegisterSchema);
|
||||
|
||||
type CloudCreateRegistrationIntent = {
|
||||
resend: boolean;
|
||||
email: string;
|
||||
};
|
||||
|
||||
const CloudCreateRegistrationIntentSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
resend: {
|
||||
type: 'boolean',
|
||||
},
|
||||
email: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['resend', 'email'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCloudCreateRegistrationIntentProps = ajv.compile<CloudCreateRegistrationIntent>(CloudCreateRegistrationIntentSchema);
|
||||
|
||||
type CloudConfirmationPoll = {
|
||||
deviceCode: string;
|
||||
resend?: string;
|
||||
};
|
||||
|
||||
const CloudConfirmationPollSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
deviceCode: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
required: ['deviceCode'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCloudConfirmationPollProps = ajvQuery.compile<CloudConfirmationPoll>(CloudConfirmationPollSchema);
|
||||
|
||||
type CloudConnectWorkspace = { token: string };
|
||||
|
||||
const CloudConnectWorkspaceSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
token: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
required: ['token'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCloudConnectWorkspaceProps = ajv.compile<CloudConnectWorkspace>(CloudConnectWorkspaceSchema);
|
||||
|
||||
export type CloudEndpoints = {
|
||||
'/v1/cloud.manualRegister': {
|
||||
POST: (params: CloudManualRegister) => void;
|
||||
};
|
||||
'/v1/cloud.createRegistrationIntent': {
|
||||
POST: (params: CloudCreateRegistrationIntent) => {
|
||||
intentData: CloudRegistrationIntentData;
|
||||
};
|
||||
};
|
||||
'/v1/cloud.registerPreIntent': {
|
||||
POST: () => {
|
||||
offline: boolean;
|
||||
};
|
||||
};
|
||||
'/v1/cloud.confirmationPoll': {
|
||||
GET: (params: CloudConfirmationPoll) => {
|
||||
pollData: CloudConfirmationPollData;
|
||||
};
|
||||
};
|
||||
'/v1/cloud.registrationStatus': {
|
||||
GET: () => { registrationStatus: CloudRegistrationStatus };
|
||||
};
|
||||
'/v1/cloud.workspaceRegisterData': {
|
||||
GET: () => { registerData: string };
|
||||
};
|
||||
'/v1/cloud.syncWorkspace': {
|
||||
POST: () => { success: boolean };
|
||||
};
|
||||
'/v1/cloud.removeLicense': {
|
||||
POST: () => { success: boolean };
|
||||
};
|
||||
'/v1/cloud.connectWorkspace': {
|
||||
POST: (params: CloudConnectWorkspace) => { success: boolean };
|
||||
};
|
||||
};
|
||||
26
packages/rest-typings/src/v1/commands.ts
Normal file
26
packages/rest-typings/src/v1/commands.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { SlashCommandPreviews } from '@rocket.chat/core-typings';
|
||||
|
||||
export type CommandsEndpoints = {
|
||||
'/v1/commands.run': {
|
||||
POST: (params: { command: string; params?: string; roomId: string; tmid?: string; triggerId?: string }) => {
|
||||
result: unknown;
|
||||
};
|
||||
};
|
||||
'/v1/commands.preview': {
|
||||
GET: (params: { command: string; params?: string; roomId: string }) => {
|
||||
preview: SlashCommandPreviews;
|
||||
};
|
||||
POST: (params: {
|
||||
command: string;
|
||||
params?: string;
|
||||
roomId: string;
|
||||
previewItem: {
|
||||
id: string;
|
||||
type: string;
|
||||
value: string;
|
||||
};
|
||||
triggerId: string;
|
||||
tmid?: string;
|
||||
}) => void;
|
||||
};
|
||||
};
|
||||
104
packages/rest-typings/src/v1/customSounds.ts
Normal file
104
packages/rest-typings/src/v1/customSounds.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import type { ICustomSound } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajvQuery, ajv } from './Ajv';
|
||||
import { type PaginatedRequest } from '../helpers/PaginatedRequest';
|
||||
|
||||
type CustomSoundsGetOne = { _id: ICustomSound['_id'] };
|
||||
|
||||
const CustomSoundsGetOneSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
_id: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
required: ['_id'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCustomSoundsGetOneProps = ajvQuery.compile<CustomSoundsGetOne>(CustomSoundsGetOneSchema);
|
||||
|
||||
type CustomSoundsList = PaginatedRequest<{ name?: string }>;
|
||||
|
||||
const CustomSoundsListSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCustomSoundsListProps = ajvQuery.compile<CustomSoundsList>(CustomSoundsListSchema);
|
||||
|
||||
type CustomSoundsCreate = Pick<ICustomSound, 'name'>;
|
||||
|
||||
const CustomSoundsCreateSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
required: ['name'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCustomSoundsCreateProps = ajv.compile<CustomSoundsCreate>(CustomSoundsCreateSchema);
|
||||
|
||||
type CustomSoundsUpdate = Pick<ICustomSound, '_id' | 'name'>;
|
||||
|
||||
const CustomSoundsUpdateSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
_id: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
required: ['_id', 'name'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCustomSoundsUpdateProps = ajv.compile<CustomSoundsUpdate>(CustomSoundsUpdateSchema);
|
||||
|
||||
type CustomSoundsDelete = { _id: ICustomSound['_id'] };
|
||||
|
||||
const CustomSoundsDeleteSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
_id: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
required: ['_id'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isCustomSoundsDeleteProps = ajv.compile<CustomSoundsDelete>(CustomSoundsDeleteSchema);
|
||||
17
packages/rest-typings/src/v1/customUserStatus.ts
Normal file
17
packages/rest-typings/src/v1/customUserStatus.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { ICustomUserStatus } from '@rocket.chat/core-typings';
|
||||
|
||||
export type CustomUserStatusEndpoints = {
|
||||
'/v1/custom-user-status.create': {
|
||||
POST: (params: { name: string; statusType?: string }) => {
|
||||
customUserStatus: ICustomUserStatus;
|
||||
};
|
||||
};
|
||||
'/v1/custom-user-status.delete': {
|
||||
POST: (params: { customUserStatusId: string }) => void;
|
||||
};
|
||||
'/v1/custom-user-status.update': {
|
||||
POST: (params: { _id: string; name?: string; statusType?: string }) => {
|
||||
customUserStatus: ICustomUserStatus;
|
||||
};
|
||||
};
|
||||
};
|
||||
51
packages/rest-typings/src/v1/directory.ts
Normal file
51
packages/rest-typings/src/v1/directory.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { IDirectoryChannelResult, IDirectoryUserResult } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajv } from './Ajv';
|
||||
import type { PaginatedRequest } from '../helpers/PaginatedRequest';
|
||||
import type { PaginatedResult } from '../helpers/PaginatedResult';
|
||||
|
||||
type DirectoryProps = PaginatedRequest<{ text?: string; type?: string; workspace?: string; query?: string }>;
|
||||
|
||||
const DirectorySchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
text: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
workspace: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isDirectoryProps = ajv.compile<DirectoryProps>(DirectorySchema);
|
||||
|
||||
export type DirectoryEndpoint = {
|
||||
'/v1/directory': {
|
||||
GET: (params: DirectoryProps) => PaginatedResult<{ result: (IDirectoryUserResult | IDirectoryChannelResult)[] }>;
|
||||
};
|
||||
};
|
||||
23
packages/rest-typings/src/v1/dm/DmBlockUserProps.ts
Normal file
23
packages/rest-typings/src/v1/dm/DmBlockUserProps.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type DmBlockUserProps = {
|
||||
roomId: string;
|
||||
block: boolean;
|
||||
};
|
||||
|
||||
const DmBlockUserPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
block: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
required: ['roomId', 'block'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isDmBlockUserProps = ajv.compile<DmBlockUserProps>(DmBlockUserPropsSchema);
|
||||
41
packages/rest-typings/src/v1/dm/DmCreateProps.ts
Normal file
41
packages/rest-typings/src/v1/dm/DmCreateProps.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type DmCreateProps = (
|
||||
| {
|
||||
usernames: string;
|
||||
}
|
||||
| {
|
||||
username: string;
|
||||
}
|
||||
) & { excludeSelf?: boolean };
|
||||
|
||||
export const isDmCreateProps = ajv.compile<DmCreateProps>({
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
usernames: {
|
||||
type: 'string',
|
||||
},
|
||||
excludeSelf: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
required: ['usernames'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
username: {
|
||||
type: 'string',
|
||||
},
|
||||
excludeSelf: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
required: ['username'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
60
packages/rest-typings/src/v1/dm/DmFileProps.ts
Normal file
60
packages/rest-typings/src/v1/dm/DmFileProps.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type DmFileProps = PaginatedRequest<
|
||||
({ roomId: string; username?: string } | { roomId?: string; username: string }) & {
|
||||
name?: string;
|
||||
typeGroup?: string;
|
||||
query?: string;
|
||||
onlyConfirmed?: boolean;
|
||||
}
|
||||
>;
|
||||
|
||||
const dmFilesListPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
typeGroup: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
onlyConfirmed: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
oneOf: [
|
||||
{ type: 'object', required: ['roomId'] },
|
||||
{ type: 'object', required: ['username'] },
|
||||
],
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isDmFileProps = ajvQuery.compile<DmFileProps>(dmFilesListPropsSchema);
|
||||
54
packages/rest-typings/src/v1/dm/DmHistoryProps.ts
Normal file
54
packages/rest-typings/src/v1/dm/DmHistoryProps.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type DmHistoryProps = PaginatedRequest<{
|
||||
roomId: string;
|
||||
latest?: string;
|
||||
oldest?: string;
|
||||
inclusive?: 'false' | 'true';
|
||||
unreads?: 'true' | 'false';
|
||||
showThreadMessages?: 'false' | 'true';
|
||||
}>;
|
||||
|
||||
const DmHistoryPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
latest: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
showThreadMessages: {
|
||||
type: 'string',
|
||||
enum: ['false', 'true'],
|
||||
},
|
||||
oldest: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
inclusive: {
|
||||
type: 'string',
|
||||
enum: ['false', 'true'],
|
||||
},
|
||||
unreads: {
|
||||
type: 'string',
|
||||
enum: ['true', 'false'],
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isDmHistoryProps = ajvQuery.compile<DmHistoryProps>(DmHistoryPropsSchema);
|
||||
34
packages/rest-typings/src/v1/dm/DmLeaveProps.ts
Normal file
34
packages/rest-typings/src/v1/dm/DmLeaveProps.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type DmLeaveProps =
|
||||
| {
|
||||
roomId: string;
|
||||
}
|
||||
| { roomName: string };
|
||||
|
||||
const DmLeavePropsSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['roomName'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const isDmLeaveProps = ajv.compile<DmLeaveProps>(DmLeavePropsSchema);
|
||||
83
packages/rest-typings/src/v1/dm/DmMembersProps.ts
Normal file
83
packages/rest-typings/src/v1/dm/DmMembersProps.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type DmMemberProps = PaginatedRequest<
|
||||
(
|
||||
| {
|
||||
roomId: string;
|
||||
}
|
||||
| {
|
||||
username: string;
|
||||
}
|
||||
) & {
|
||||
status?: string[];
|
||||
filter?: string;
|
||||
}
|
||||
>;
|
||||
|
||||
export const isDmMemberProps = ajvQuery.compile<DmMemberProps>({
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
status: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
username: {
|
||||
type: 'string',
|
||||
},
|
||||
status: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
required: ['username'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
85
packages/rest-typings/src/v1/dm/DmMessagesProps.ts
Normal file
85
packages/rest-typings/src/v1/dm/DmMessagesProps.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import { ajvQuery } from '../Ajv';
|
||||
|
||||
export type DmMessagesProps = PaginatedRequest<
|
||||
({ roomId: string } | { username: string }) & {
|
||||
query?: string;
|
||||
mentionIds?: string;
|
||||
starredIds?: string;
|
||||
pinned?: string;
|
||||
fields?: string;
|
||||
}
|
||||
>;
|
||||
|
||||
export const isDmMessagesProps = ajvQuery.compile<DmMessagesProps>({
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
mentionIds: {
|
||||
type: 'string',
|
||||
},
|
||||
starredIds: {
|
||||
type: 'string',
|
||||
},
|
||||
pinned: {
|
||||
type: 'string',
|
||||
},
|
||||
fields: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
required: ['roomId'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
username: {
|
||||
type: 'string',
|
||||
},
|
||||
mentionIds: {
|
||||
type: 'string',
|
||||
},
|
||||
starredIds: {
|
||||
type: 'string',
|
||||
},
|
||||
pinned: {
|
||||
type: 'string',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
},
|
||||
fields: {
|
||||
type: 'string',
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
required: ['username'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
15
packages/rest-typings/src/v1/dm/dm.ts
Normal file
15
packages/rest-typings/src/v1/dm/dm.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { ImEndpoints } from './im';
|
||||
|
||||
export type DmEndpoints = {
|
||||
'/v1/dm.create': ImEndpoints['/v1/im.create'];
|
||||
'/v1/dm.counters': ImEndpoints['/v1/im.counters'];
|
||||
'/v1/dm.files': ImEndpoints['/v1/im.files'];
|
||||
'/v1/dm.history': ImEndpoints['/v1/im.history'];
|
||||
'/v1/dm.members': ImEndpoints['/v1/im.members'];
|
||||
'/v1/dm.messages': ImEndpoints['/v1/im.messages'];
|
||||
'/v1/dm.messages.others': ImEndpoints['/v1/im.messages.others'];
|
||||
'/v1/dm.list': ImEndpoints['/v1/im.list'];
|
||||
'/v1/dm.list.everyone': ImEndpoints['/v1/im.list.everyone'];
|
||||
'/v1/dm.open': ImEndpoints['/v1/im.open'];
|
||||
'/v1/dm.setTopic': ImEndpoints['/v1/im.setTopic'];
|
||||
};
|
||||
83
packages/rest-typings/src/v1/dm/im.ts
Normal file
83
packages/rest-typings/src/v1/dm/im.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import type { IMessage, IRoom, IUser, IUploadWithUser, ISubscription } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { DmBlockUserProps } from './DmBlockUserProps';
|
||||
import type { DmCreateProps } from './DmCreateProps';
|
||||
import type { DmFileProps } from './DmFileProps';
|
||||
import type { DmHistoryProps } from './DmHistoryProps';
|
||||
import type { DmLeaveProps } from './DmLeaveProps';
|
||||
import type { DmMemberProps } from './DmMembersProps';
|
||||
import type { DmMessagesProps } from './DmMessagesProps';
|
||||
import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
|
||||
import type { PaginatedResult } from '../../helpers/PaginatedResult';
|
||||
|
||||
type DmKickProps = {
|
||||
roomId: string;
|
||||
};
|
||||
|
||||
export type ImEndpoints = {
|
||||
'/v1/im.create': {
|
||||
POST: (params: DmCreateProps) => {
|
||||
room: IRoom & { rid: IRoom['_id'] };
|
||||
};
|
||||
};
|
||||
'/v1/im.kick': {
|
||||
POST: (params: DmKickProps) => void;
|
||||
};
|
||||
'/v1/im.leave': {
|
||||
POST: (params: DmLeaveProps) => void;
|
||||
};
|
||||
'/v1/im.counters': {
|
||||
GET: (params: { roomId: string; userId?: string }) => {
|
||||
joined: boolean;
|
||||
unreads: number | null;
|
||||
unreadsFrom: string | null;
|
||||
msgs: number | null;
|
||||
members: number | null;
|
||||
latest: string | null;
|
||||
userMentions: number | null;
|
||||
};
|
||||
};
|
||||
'/v1/im.files': {
|
||||
GET: (params: DmFileProps) => PaginatedResult<{
|
||||
files: IUploadWithUser[];
|
||||
}>;
|
||||
};
|
||||
'/v1/im.history': {
|
||||
GET: (params: DmHistoryProps) => {
|
||||
messages: Pick<IMessage, '_id' | 'rid' | 'msg' | 'ts' | '_updatedAt' | 'u'>[];
|
||||
};
|
||||
};
|
||||
|
||||
'/v1/im.members': {
|
||||
GET: (params: DmMemberProps) => PaginatedResult<{
|
||||
members: (Pick<IUser, '_id' | 'status' | 'name' | 'username' | 'utcOffset'> & {
|
||||
subscription: Pick<ISubscription, '_id' | 'status' | 'ts' | 'roles'>;
|
||||
})[];
|
||||
}>;
|
||||
};
|
||||
'/v1/im.messages': {
|
||||
GET: (params: DmMessagesProps) => PaginatedResult<{
|
||||
messages: IMessage[];
|
||||
}>;
|
||||
};
|
||||
'/v1/im.messages.others': {
|
||||
GET: (params: PaginatedRequest<{ roomId: IRoom['_id']; query?: string; fields?: string }>) => PaginatedResult<{ messages: IMessage[] }>;
|
||||
};
|
||||
'/v1/im.list': {
|
||||
GET: (params: PaginatedRequest<{ fields?: string }>) => PaginatedResult<{ ims: IRoom[] }>;
|
||||
};
|
||||
'/v1/im.list.everyone': {
|
||||
GET: (params: PaginatedRequest<{ query: string; fields?: string }>) => PaginatedResult<{ ims: IRoom[] }>;
|
||||
};
|
||||
'/v1/im.open': {
|
||||
POST: (params: { roomId: string }) => void;
|
||||
};
|
||||
'/v1/im.setTopic': {
|
||||
POST: (params: { roomId: string; topic?: string }) => {
|
||||
topic?: string;
|
||||
};
|
||||
};
|
||||
'/v1/im.blockUser': {
|
||||
POST: (params: DmBlockUserProps) => void;
|
||||
};
|
||||
};
|
||||
8
packages/rest-typings/src/v1/dm/index.ts
Normal file
8
packages/rest-typings/src/v1/dm/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export type * from './dm';
|
||||
export type * from './im';
|
||||
export * from './DmBlockUserProps';
|
||||
export * from './DmCreateProps';
|
||||
export * from './DmFileProps';
|
||||
export * from './DmLeaveProps';
|
||||
export * from './DmMembersProps';
|
||||
export * from './DmMessagesProps';
|
||||
33
packages/rest-typings/src/v1/e2e.ts
Normal file
33
packages/rest-typings/src/v1/e2e.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { ajv } from './Ajv';
|
||||
|
||||
type E2eSetUserPublicAndPrivateKeysProps = {
|
||||
public_key: string;
|
||||
private_key: string;
|
||||
force?: boolean;
|
||||
};
|
||||
|
||||
const E2eSetUserPublicAndPrivateKeysSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
public_key: {
|
||||
type: 'string',
|
||||
},
|
||||
private_key: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['public_key', 'private_key'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isE2eSetUserPublicAndPrivateKeysProps = ajv.compile<E2eSetUserPublicAndPrivateKeysProps>(E2eSetUserPublicAndPrivateKeysSchema);
|
||||
|
||||
export type E2eEndpoints = {
|
||||
'/v1/e2e.setUserPublicAndPrivateKeys': {
|
||||
POST: (params: E2eSetUserPublicAndPrivateKeysProps) => void;
|
||||
};
|
||||
|
||||
'/v1/e2e.requestSubscriptionKeys': {
|
||||
POST: () => void;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type e2eSetUserPublicAndPrivateKeysParamsPOST = {
|
||||
public_key: string;
|
||||
private_key: string;
|
||||
force?: boolean;
|
||||
};
|
||||
|
||||
const e2eSetUserPublicAndPrivateKeysParamsPOSTSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
public_key: {
|
||||
type: 'string',
|
||||
},
|
||||
private_key: {
|
||||
type: 'string',
|
||||
},
|
||||
force: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['public_key', 'private_key'],
|
||||
};
|
||||
|
||||
export const ise2eSetUserPublicAndPrivateKeysParamsPOST = ajv.compile<e2eSetUserPublicAndPrivateKeysParamsPOST>(
|
||||
e2eSetUserPublicAndPrivateKeysParamsPOSTSchema,
|
||||
);
|
||||
180
packages/rest-typings/src/v1/email-inbox.ts
Normal file
180
packages/rest-typings/src/v1/email-inbox.ts
Normal file
@@ -0,0 +1,180 @@
|
||||
import type { IEmailInbox } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajv, ajvQuery } from './Ajv';
|
||||
import type { PaginatedRequest } from '../helpers/PaginatedRequest';
|
||||
import type { PaginatedResult } from '../helpers/PaginatedResult';
|
||||
|
||||
type EmailInboxListProps = PaginatedRequest<{ query?: string }>;
|
||||
|
||||
const EmailInboxListPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
count: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
offset: {
|
||||
type: 'number',
|
||||
nullable: true,
|
||||
},
|
||||
sort: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isEmailInboxList = ajvQuery.compile<EmailInboxListProps>(EmailInboxListPropsSchema);
|
||||
|
||||
type EmailInboxProps = {
|
||||
_id?: string;
|
||||
name: string;
|
||||
email: string;
|
||||
active: boolean; // POST method
|
||||
description?: string;
|
||||
senderInfo?: string;
|
||||
department?: string;
|
||||
smtp: {
|
||||
password: string;
|
||||
port: number;
|
||||
secure: boolean;
|
||||
server: string;
|
||||
username: string;
|
||||
};
|
||||
imap: {
|
||||
password: string;
|
||||
port: number;
|
||||
secure: boolean;
|
||||
server: string;
|
||||
username: string;
|
||||
maxRetries?: number;
|
||||
};
|
||||
};
|
||||
|
||||
const EmailInboxPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
_id: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
},
|
||||
email: {
|
||||
type: 'string',
|
||||
},
|
||||
active: {
|
||||
type: 'boolean',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
},
|
||||
senderInfo: {
|
||||
type: 'string',
|
||||
},
|
||||
department: {
|
||||
type: 'string',
|
||||
},
|
||||
|
||||
smtp: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
password: {
|
||||
type: 'string',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
},
|
||||
secure: {
|
||||
type: 'boolean',
|
||||
},
|
||||
server: {
|
||||
type: 'string',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['password', 'port', 'secure', 'server', 'username'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
|
||||
imap: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
password: {
|
||||
type: 'string',
|
||||
},
|
||||
port: {
|
||||
type: 'number',
|
||||
},
|
||||
secure: {
|
||||
type: 'boolean',
|
||||
},
|
||||
server: {
|
||||
type: 'string',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
},
|
||||
maxRetries: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
required: ['password', 'port', 'secure', 'server', 'username'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
|
||||
required: ['name', 'email', 'active', 'smtp', 'imap'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isEmailInbox = ajv.compile<EmailInboxProps>(EmailInboxPropsSchema);
|
||||
|
||||
type EmailInboxSearchProps = {
|
||||
email: string;
|
||||
};
|
||||
|
||||
const EmailInboxSearchPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
email: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['email'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isEmailInboxSearch = ajvQuery.compile<EmailInboxSearchProps>(EmailInboxSearchPropsSchema);
|
||||
|
||||
export type EmailInboxEndpoints = {
|
||||
'/v1/email-inbox.list': {
|
||||
GET: (params: EmailInboxListProps) => PaginatedResult<{ emailInboxes: IEmailInbox[] }>;
|
||||
};
|
||||
|
||||
'/v1/email-inbox': {
|
||||
POST: (params: EmailInboxProps) => { _id: string };
|
||||
};
|
||||
|
||||
'/v1/email-inbox/:_id': {
|
||||
GET: () => IEmailInbox | null;
|
||||
DELETE: () => { _id: string };
|
||||
};
|
||||
|
||||
'/v1/email-inbox.search': {
|
||||
GET: (params: EmailInboxSearchProps) => { emailInbox: IEmailInbox | null };
|
||||
};
|
||||
|
||||
'/v1/email-inbox.send-test/:_id': {
|
||||
POST: () => { _id: string };
|
||||
};
|
||||
};
|
||||
69
packages/rest-typings/src/v1/emojiCustom.ts
Normal file
69
packages/rest-typings/src/v1/emojiCustom.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import type { ICustomEmojiDescriptor, IEmojiCustom } from '@rocket.chat/core-typings';
|
||||
|
||||
import { ajv, ajvQuery } from './Ajv';
|
||||
import type { PaginatedRequest } from '../helpers/PaginatedRequest';
|
||||
import type { PaginatedResult } from '../helpers/PaginatedResult';
|
||||
|
||||
type emojiCustomDeleteProps = {
|
||||
emojiId: ICustomEmojiDescriptor['_id'];
|
||||
};
|
||||
|
||||
const emojiCustomDeletePropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
emojiId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['emojiId'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isEmojiCustomDelete = ajv.compile<emojiCustomDeleteProps>(emojiCustomDeletePropsSchema);
|
||||
|
||||
type emojiCustomList = { query?: string; updatedSince?: string; _updatedAt?: string; _id?: string };
|
||||
|
||||
const emojiCustomListSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: {
|
||||
type: 'string',
|
||||
},
|
||||
updatedSince: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
_updatedAt: {
|
||||
type: 'string',
|
||||
},
|
||||
_id: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isEmojiCustomList = ajvQuery.compile<emojiCustomList>(emojiCustomListSchema);
|
||||
|
||||
export type EmojiCustomEndpoints = {
|
||||
'/v1/emoji-custom.all': {
|
||||
GET: (params: PaginatedRequest<{ name?: string }, 'name'>) => PaginatedResult<{
|
||||
emojis: IEmojiCustom[];
|
||||
}>;
|
||||
};
|
||||
'/v1/emoji-custom.list': {
|
||||
GET: (params: emojiCustomList) => {
|
||||
emojis: {
|
||||
update: IEmojiCustom[];
|
||||
remove: IEmojiCustom[];
|
||||
};
|
||||
};
|
||||
};
|
||||
'/v1/emoji-custom.delete': {
|
||||
POST: (params: emojiCustomDeleteProps) => void;
|
||||
};
|
||||
'/v1/emoji-custom.update': {
|
||||
POST: (params: { emoji: ICustomEmojiDescriptor }) => void;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type FederationAddServerProps = {
|
||||
serverName: string;
|
||||
};
|
||||
|
||||
const FederationAddServerPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
serverName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['serverName'],
|
||||
};
|
||||
|
||||
export const isFederationAddServerProps = ajv.compile<FederationAddServerProps>(FederationAddServerPropsSchema);
|
||||
@@ -0,0 +1,32 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type FederationJoinExternalPublicRoomProps = {
|
||||
externalRoomId: `!${string}:${string}`;
|
||||
roomName?: string;
|
||||
pageToken?: string;
|
||||
};
|
||||
ajv.addFormat('matrix-room-id', (externalRoomId) => Boolean(externalRoomId?.charAt(0) === '!' && externalRoomId?.includes(':')));
|
||||
|
||||
const FederationJoinExternalPublicRoomPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
externalRoomId: {
|
||||
type: 'string',
|
||||
format: 'matrix-room-id',
|
||||
},
|
||||
roomName: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
pageToken: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['externalRoomId'],
|
||||
};
|
||||
|
||||
export const isFederationJoinExternalPublicRoomProps = ajv.compile<FederationJoinExternalPublicRoomProps>(
|
||||
FederationJoinExternalPublicRoomPropsSchema,
|
||||
);
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { FederationPaginatedRequest } from '.';
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type FederationSearchPublicRoomsProps = FederationPaginatedRequest<{
|
||||
serverName?: string;
|
||||
roomName?: string;
|
||||
}>;
|
||||
|
||||
const federationSearchPublicRoomsPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
serverName: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
roomName: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
pageToken: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isFederationSearchPublicRoomsProps = ajv.compile<FederationSearchPublicRoomsProps>(federationSearchPublicRoomsPropsSchema);
|
||||
@@ -0,0 +1,18 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type FederationRemoveServerProps = {
|
||||
serverName: string;
|
||||
};
|
||||
|
||||
const FederationRemoveServerPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
serverName: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['serverName'],
|
||||
};
|
||||
|
||||
export const isFederationRemoveServerProps = ajv.compile<FederationRemoveServerProps>(FederationRemoveServerPropsSchema);
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type FederationVerifyMatrixIdProps = {
|
||||
matrixIds: string[];
|
||||
};
|
||||
|
||||
const FederationVerifyMatrixIdPropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
matrixIds: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
uniqueItems: true,
|
||||
minItems: 1,
|
||||
maxItems: 15,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['matrixIds'],
|
||||
};
|
||||
|
||||
export const isFederationVerifyMatrixIdProps = ajv.compile<FederationVerifyMatrixIdProps>(FederationVerifyMatrixIdPropsSchema);
|
||||
18
packages/rest-typings/src/v1/federation/index.ts
Normal file
18
packages/rest-typings/src/v1/federation/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export type FederationPaginatedRequest<T = Record<string, boolean | number | string | object>> = {
|
||||
count?: number;
|
||||
pageToken?: string;
|
||||
} & T;
|
||||
|
||||
export type FederationPaginatedResult<T = Record<string, boolean | number | string | object>> = {
|
||||
count: number;
|
||||
nextPageToken?: string;
|
||||
previousPageToken?: string;
|
||||
total: number;
|
||||
} & T;
|
||||
|
||||
export type * from './rooms';
|
||||
export * from './FederationJoinExternalPublicRoomProps';
|
||||
export * from './FederationPublicRoomsProps';
|
||||
export * from './FederationAddServerProps';
|
||||
export * from './FederationRemoveServerProps';
|
||||
export * from './FederationVerifyMatrixIdProps';
|
||||
37
packages/rest-typings/src/v1/federation/rooms.ts
Normal file
37
packages/rest-typings/src/v1/federation/rooms.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { FederationAddServerProps, FederationPaginatedResult, FederationRemoveServerProps } from '.';
|
||||
import type { FederationJoinExternalPublicRoomProps } from './FederationJoinExternalPublicRoomProps';
|
||||
import type { FederationSearchPublicRoomsProps } from './FederationPublicRoomsProps';
|
||||
import type { FederationVerifyMatrixIdProps } from './FederationVerifyMatrixIdProps';
|
||||
|
||||
export interface IFederationPublicRooms {
|
||||
id: string;
|
||||
name: string;
|
||||
canonicalAlias: string;
|
||||
joinedMembers: number;
|
||||
canJoin: boolean;
|
||||
topic?: string;
|
||||
pageToken?: string;
|
||||
}
|
||||
|
||||
export type FederationEndpoints = {
|
||||
'/v1/federation/searchPublicRooms': {
|
||||
GET: (params: FederationSearchPublicRoomsProps) => FederationPaginatedResult<{
|
||||
rooms: IFederationPublicRooms[];
|
||||
}>;
|
||||
};
|
||||
'/v1/federation/joinExternalPublicRoom': {
|
||||
POST: (params: FederationJoinExternalPublicRoomProps) => void;
|
||||
};
|
||||
'/v1/federation/listServersByUser': {
|
||||
GET: () => { servers: { name: string; default: boolean; local: boolean }[] };
|
||||
};
|
||||
'/v1/federation/addServerByUser': {
|
||||
POST: (params: FederationAddServerProps) => void;
|
||||
};
|
||||
'/v1/federation/removeServerByUser': {
|
||||
POST: (params: FederationRemoveServerProps) => void;
|
||||
};
|
||||
'/v1/federation/matrixIds.verify': {
|
||||
GET: (params: FederationVerifyMatrixIdProps) => { results: Map<string, string> };
|
||||
};
|
||||
};
|
||||
54
packages/rest-typings/src/v1/groups/BaseProps.ts
Normal file
54
packages/rest-typings/src/v1/groups/BaseProps.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type GroupsBaseProps = { roomId: string; roomName?: string } | { roomId?: string; roomName: string };
|
||||
|
||||
export const withGroupBaseProperties = (properties: Record<string, any> = {}, required: string[] = []) => ({
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomId: {
|
||||
type: 'string',
|
||||
},
|
||||
...properties,
|
||||
},
|
||||
required: ['roomId'].concat(required),
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
roomName: {
|
||||
type: 'string',
|
||||
},
|
||||
...properties,
|
||||
},
|
||||
required: ['roomName'].concat(required),
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export type BaseProps = GroupsBaseProps;
|
||||
export const baseSchema = withGroupBaseProperties();
|
||||
export const withBaseProps = ajv.compile<BaseProps>(baseSchema);
|
||||
|
||||
export type WithUserId = GroupsBaseProps &
|
||||
(
|
||||
| { userId: string; username?: string; user?: string; userIds?: string[]; usernames?: string[] }
|
||||
| { userId?: string; username: string; user?: string; userIds?: string[]; usernames?: string[] }
|
||||
| { userId?: string; username?: string; user: string; userIds?: string[]; usernames?: string[] }
|
||||
| { userId?: string; username?: string; user?: string; userIds: string[]; usernames?: string[] }
|
||||
| { userId?: string; username?: string; user?: string; userIds?: string[]; usernames: string[] }
|
||||
);
|
||||
export const withUserIdSchema = withGroupBaseProperties(
|
||||
{
|
||||
userId: { type: 'string', nullable: true },
|
||||
username: { type: 'string', nullable: true },
|
||||
user: { type: 'string', nullable: true },
|
||||
userIds: { type: 'array', items: { type: 'string' }, nullable: true },
|
||||
usernames: { type: 'array', items: { type: 'string' }, nullable: true },
|
||||
},
|
||||
[],
|
||||
);
|
||||
export const withUserIdProps = ajv.compile<WithUserId>(withUserIdSchema);
|
||||
14
packages/rest-typings/src/v1/groups/GroupsAddAllProps.ts
Normal file
14
packages/rest-typings/src/v1/groups/GroupsAddAllProps.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ajv } from '../Ajv';
|
||||
import type { GroupsBaseProps } from './BaseProps';
|
||||
import { withGroupBaseProperties } from './BaseProps';
|
||||
|
||||
export type GroupsAddAllProps = GroupsBaseProps & {
|
||||
activeUsersOnly?: 'true' | 'false' | 1 | 0;
|
||||
};
|
||||
const groupsAddAllPropsSchema = withGroupBaseProperties({
|
||||
activeUsersOnly: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
});
|
||||
export const isGroupsAddAllProps = ajv.compile<GroupsAddAllProps>(groupsAddAllPropsSchema);
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { WithUserId } from './BaseProps';
|
||||
import { withUserIdProps } from './BaseProps';
|
||||
|
||||
export type GroupsAddLeaderProps = WithUserId;
|
||||
export const isGroupsAddLeaderProps = withUserIdProps;
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { WithUserId } from './BaseProps';
|
||||
import { withUserIdProps } from './BaseProps';
|
||||
|
||||
export type GroupsAddModeratorProps = WithUserId;
|
||||
export const isGroupsAddModeratorProps = withUserIdProps;
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { WithUserId } from './BaseProps';
|
||||
import { withUserIdProps } from './BaseProps';
|
||||
|
||||
export type GroupsAddOwnerProps = WithUserId;
|
||||
export const isGroupsAddOwnerProps = withUserIdProps;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { ajv } from '../Ajv';
|
||||
import type { GroupsBaseProps } from './BaseProps';
|
||||
import { withGroupBaseProperties } from './BaseProps';
|
||||
|
||||
export type GroupsArchiveProps = GroupsBaseProps;
|
||||
|
||||
const GroupsArchivePropsSchema = withGroupBaseProperties();
|
||||
|
||||
export const isGroupsArchiveProps = ajv.compile<GroupsArchiveProps>(GroupsArchivePropsSchema);
|
||||
6
packages/rest-typings/src/v1/groups/GroupsCloseProps.ts
Normal file
6
packages/rest-typings/src/v1/groups/GroupsCloseProps.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { BaseProps } from './BaseProps';
|
||||
import { withBaseProps } from './BaseProps';
|
||||
|
||||
export type GroupsCloseProps = BaseProps;
|
||||
|
||||
export const isGroupsCloseProps = withBaseProps;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { ajv } from '../Ajv';
|
||||
import type { GroupsBaseProps } from './BaseProps';
|
||||
import { withGroupBaseProperties } from './BaseProps';
|
||||
|
||||
export type GroupsConvertToTeamProps = GroupsBaseProps;
|
||||
|
||||
const GroupsConvertToTeamPropsSchema = withGroupBaseProperties();
|
||||
|
||||
export const isGroupsConvertToTeamProps = ajv.compile<GroupsConvertToTeamProps>(GroupsConvertToTeamPropsSchema);
|
||||
14
packages/rest-typings/src/v1/groups/GroupsCountersProps.ts
Normal file
14
packages/rest-typings/src/v1/groups/GroupsCountersProps.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ajv } from '../Ajv';
|
||||
import type { GroupsBaseProps } from './BaseProps';
|
||||
import { withGroupBaseProperties } from './BaseProps';
|
||||
|
||||
export type GroupsCountersProps = GroupsBaseProps & { userId?: string };
|
||||
|
||||
const GroupsCountersPropsSchema = withGroupBaseProperties({
|
||||
userId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
});
|
||||
|
||||
export const isGroupsCountersProps = ajv.compile<GroupsCountersProps>(GroupsCountersPropsSchema);
|
||||
72
packages/rest-typings/src/v1/groups/GroupsCreateProps.ts
Normal file
72
packages/rest-typings/src/v1/groups/GroupsCreateProps.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { ajv } from '../Ajv';
|
||||
|
||||
export type GroupsCreateProps = {
|
||||
name: string;
|
||||
members?: string[];
|
||||
customFields?: Record<string, any>;
|
||||
readOnly?: boolean;
|
||||
extraData?: {
|
||||
broadcast: boolean;
|
||||
encrypted: boolean;
|
||||
teamId?: string;
|
||||
};
|
||||
excludeSelf?: boolean;
|
||||
};
|
||||
|
||||
const GroupsCreatePropsSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
},
|
||||
members: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
nullable: true,
|
||||
},
|
||||
readOnly: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
excludeSelf: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
customFields: {
|
||||
type: 'object',
|
||||
nullable: true,
|
||||
},
|
||||
extraData: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
broadcast: {
|
||||
type: 'boolean',
|
||||
},
|
||||
encrypted: {
|
||||
type: 'boolean',
|
||||
},
|
||||
federated: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
topic: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
dependencies: {
|
||||
extraData: { required: ['broadcast', 'encrypted'] },
|
||||
},
|
||||
additionalProperties: false,
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
required: ['name'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
|
||||
export const isGroupsCreateProps = ajv.compile<GroupsCreateProps>(GroupsCreatePropsSchema);
|
||||
9
packages/rest-typings/src/v1/groups/GroupsDeleteProps.ts
Normal file
9
packages/rest-typings/src/v1/groups/GroupsDeleteProps.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ajv } from '../Ajv';
|
||||
import type { GroupsBaseProps } from './BaseProps';
|
||||
import { withGroupBaseProperties } from './BaseProps';
|
||||
|
||||
export type GroupsDeleteProps = GroupsBaseProps;
|
||||
|
||||
const GroupsDeletePropsSchema = withGroupBaseProperties();
|
||||
|
||||
export const isGroupsDeleteProps = ajv.compile<GroupsDeleteProps>(GroupsDeletePropsSchema);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user