-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding all type definitions to main zulip-js project, updated babel t…
…o copy type definition files to lib/ in build script
- Loading branch information
Showing
17 changed files
with
1,012 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Config } from "./zuliprc"; | ||
import { ZulipSuccessResponse, ZulipErrorResponse } from "./types"; | ||
|
||
export function api( | ||
baseUrl: string, | ||
config: Config, | ||
method: any, | ||
params: any | ||
): Promise<ZulipSuccessResponse | ZulipErrorResponse>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import fetch from "isomorphic-fetch"; | ||
import FormData from "isomorphic-form-data"; | ||
|
||
export { | ||
fetch, | ||
FormData, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Config } from "./zuliprc"; | ||
import { AccountsClient } from "./resources/accounts"; | ||
import { StreamsClient } from "./resources/streams"; | ||
import { QueuesClient } from "./resources/queues"; | ||
import { EventsClient } from "./resources/events"; | ||
import { UsersClient } from "./resources/users"; | ||
import { EmojisClient } from "./resources/emojis"; | ||
import { TypingClient } from "./resources/typing"; | ||
import { ReactionsClient } from "./resources/reactions"; | ||
import { ServerClient } from "./resources/server"; | ||
import { FiltersClient } from "./resources/filters"; | ||
import { MessagesClient } from "./resources/messages"; | ||
|
||
export type HttpMethod = | ||
| "GET" | ||
| "HEAD" | ||
| "POST" | ||
| "PUT" | ||
| "DELETE" | ||
| "TRACE" | ||
| "OPTIONS" | ||
| "CONNECT" | ||
| "PATCH"; | ||
|
||
export interface Params { | ||
[key: string]: any; | ||
[key: number]: any; | ||
} | ||
|
||
export interface ZuliprcConfig { | ||
zuliprc: string; | ||
} | ||
|
||
export interface ZulipClient { | ||
config: Config; | ||
callEndpoint: typeof callEndpoint; | ||
accounts: AccountsClient; | ||
streams: StreamsClient; | ||
messages: MessagesClient; | ||
queues: QueuesClient; | ||
events: EventsClient; | ||
users: UsersClient; | ||
emojis: EmojisClient; | ||
typing: TypingClient; | ||
reactions: ReactionsClient; | ||
server: ServerClient; | ||
filters: FiltersClient; | ||
} | ||
|
||
export type InitialConfig = ZuliprcConfig | Pick<Config, "realm">; | ||
|
||
export function getCallEndpoint(config: Config): typeof callEndpoint; | ||
|
||
export function callEndpoint(endpoint: string, method: HttpMethod, params: Params): Promise<unknown>; | ||
|
||
export function resources(config: Config): ZulipClient; | ||
|
||
export function zulip(initialConfig: Partial<InitialConfig>): Promise<unknown>; | ||
|
||
export * from "./types"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Config } from "../zuliprc"; | ||
import { RetrieverClient, ZulipSuccessResponse, ZulipErrorResponse } from "../types"; | ||
|
||
export type AccountsClient = RetrieverClient; | ||
|
||
// SECTION GET ACCOUNTS | ||
// TODO Find documentation on Get Accounts | ||
export interface GetAccountsParams { } | ||
export type GetAccountsResponse = GetAccountsSuccess | GetAccountsError; | ||
export interface GetAccountsSuccess extends ZulipSuccessResponse { } | ||
export interface GetAccountsError extends ZulipErrorResponse { } | ||
|
||
export default function accounts(config: Config): AccountsClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Config } from "../zuliprc"; | ||
import { RetrieverClient, ZulipSuccessResponse, ZulipErrorResponse } from "../types"; | ||
|
||
export type EmojisClient = RetrieverClient; | ||
|
||
// SECTION GET EMOJIS | ||
export interface GetEmojisParams { } | ||
|
||
export type GetEmojisResponse = GetEmojisSuccess | GetEmojisError; | ||
|
||
export interface GetEmojisSuccess extends ZulipSuccessResponse { | ||
emoji: { | ||
[key: number]: Emoji; | ||
} | ||
} | ||
|
||
export interface Emoji { | ||
author: { | ||
email: string; | ||
full_name: string; | ||
id: number; | ||
}, | ||
deactivated: boolean; | ||
id: string; | ||
name: string; | ||
source_url: string; | ||
} | ||
|
||
export interface GetEmojisError extends ZulipErrorResponse { } | ||
|
||
// SECTION UPLOAD EMOJIS | ||
// TODO Find documentation on Get Emojis | ||
export interface UploadEmojisParams { } | ||
|
||
export type UploadEmojisResponse = UploadEmojisSuccess | UploadEmojisError; | ||
|
||
export interface UploadEmojisSuccess extends ZulipSuccessResponse { } | ||
|
||
export interface UploadEmojisError extends ZulipErrorResponse { } | ||
|
||
|
||
export default function emojis(config: Config): EmojisClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Config } from "../zuliprc"; | ||
import { RetrieverClient, ZulipSuccessResponse, ZulipErrorResponse } from "../types"; | ||
|
||
export type EventsClient = RetrieverClient; | ||
|
||
// SECTION GET EVENTS | ||
export interface GetEventsParams { | ||
/** "1375801870:2942" No The ID of a queue that you registered via POST /api/v1/register (see Register a queue). */ | ||
queue_id?: string; | ||
/** -1 No The highest event ID in this queue that you've received and wish to acknowledge. See the code for call_on_each_event in the zulip Python module for an example implementation of correctly processing each event exactly once. */ | ||
last_event_id?: number; | ||
/** true No Set to true if the client is requesting a nonblocking reply. If not specified, the request will block until either a new event is available or a few minutes have passed, in which case the server will send the client a heartbeat event. Defaults to false. */ | ||
dont_block?: boolean; | ||
} | ||
|
||
export type GetEventsResponse = GetEventsSuccess | GetEventsError; | ||
|
||
export interface GetEventsSuccess extends ZulipSuccessResponse { | ||
events: Event[] | ||
} | ||
|
||
export type Event = MessageEvent | any; | ||
|
||
export interface MessageEvent { | ||
avatar_url: string; | ||
client: string; | ||
content: string; | ||
content_type: string; | ||
display_recipient: string; | ||
id: number; | ||
recipient_id: number; | ||
sender_email: string; | ||
sender_full_name: string; | ||
sender_id: number; | ||
sender_realm_str: string; | ||
sender_short_name: string; | ||
subject: string; | ||
subject_links: string[], | ||
timestamp: number; | ||
type: string; | ||
} | ||
|
||
export interface GetEventsError extends ZulipErrorResponse { | ||
code: string; | ||
queue_id: string; | ||
} | ||
|
||
export function events(config: Config): EventsClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Config } from "../zuliprc"; | ||
import { RetrieverClient } from "../types"; | ||
|
||
export type FiltersClient = RetrieverClient; | ||
|
||
// SECTION GET FILTERS FOR REALM | ||
// TODO Find documentation on Get Filters for Realm | ||
|
||
export function filters(config: Config): FiltersClient; |
Oops, something went wrong.