Skip to content

Commit

Permalink
Use types from openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Aug 8, 2023
1 parent 02b81f1 commit 1bed4fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 36 deletions.
7 changes: 2 additions & 5 deletions src/@types/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ limitations under the License.

import { UnstableValue } from "../NamespacedValue";
import { IClientWellKnown } from "../client";
import { operations } from "./matrix-client-server";

// disable lint because these are wire responses
/* eslint-disable camelcase */

/**
* Represents a response to the CSAPI `/refresh` endpoint.
*/
export interface IRefreshTokenResponse {
access_token: string;
expires_in_ms: number;
refresh_token: string;
}
export type IRefreshTokenResponse = operations["refresh"]["responses"]["200"]["schema"];

/* eslint-enable camelcase */

Expand Down
37 changes: 6 additions & 31 deletions src/@types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { IRoomEventFilter } from "../filter";
import { Direction } from "../models/event-timeline";
import { PushRuleAction } from "./PushRules";
import { IRoomEvent } from "../sync-accumulator";
import { EventType, RelationType, RoomType } from "./event";
import { EventType, RelationType } from "./event";
import { operations } from "./matrix-client-server";

// allow camelcase as these are things that go onto the wire
/* eslint-disable camelcase */
Expand Down Expand Up @@ -76,12 +77,7 @@ export interface ISendEventResponse {
event_id: string;
}

export interface IPresenceOpts {
// One of "online", "offline" or "unavailable"
presence: "online" | "offline" | "unavailable";
// The status message to attach.
status_msg?: string;
}
export type IPresenceOpts = operations["setPresence"]["parameters"]["body"]["presenceState"];

export interface IPaginateOpts {
// true to fill backwards, false to go forwards
Expand Down Expand Up @@ -161,20 +157,7 @@ export interface ICreateRoomOpts {
room_version?: string;
}

export interface IRoomDirectoryOptions {
server?: string;
limit?: number;
since?: string;

// Filter parameters
filter?: {
// String to search for
generic_search_term?: string;
room_types?: Array<RoomType | null>;
};
include_all_networks?: boolean;
third_party_instance_id?: string;
}
export type IRoomDirectoryOptions = operations["queryPublicRooms"]["parameters"]["body"]["body"];

export interface IAddThreePidOnlyBody {
auth?: {
Expand Down Expand Up @@ -242,17 +225,9 @@ export interface INotificationsResponse {
notifications: INotification[];
}

export interface IFilterResponse {
filter_id: string;
}
export type IFilterResponse = operations["defineFilter"]["responses"]["200"]["schema"];

export interface ITagsResponse {
tags: {
[tagId: string]: {
order: number;
};
};
}
export type ITagsResponse = operations["getRoomTags"]["responses"]["200"]["schema"];

export interface IStatusResponse extends IPresenceOpts {
currently_active?: boolean;
Expand Down

0 comments on commit 1bed4fa

Please sign in to comment.