Options
All
  • Public
  • Public/Protected
  • All
Menu

@neelkamath/omni-chat - v3.0.0

Omni Chat API JavaScript wrapper library.

The Omni Chat API consists of a REST API, and a GraphQL API.

The REST API is used for tasks not well suited for GraphQL such as image uploads. Use the wrapper functions which have the same name as the operation name in Omni Chat Backend's REST API docs (e.g., getProfileImage) to interact with the REST API.

In order to avoid the under-fetching and over-fetching problems posed by REST APIs, the GraphQL API is the primary interface. Use the queryOrMutate and subscribe functions to handle queries and mutations, and subscriptions respectively.

Use the isValid*Scalar() (e.g., isValidUsernameScalar) functions to validate GraphQL scalars.

Index

Type aliases

ApiUrl

ApiUrl: string

For example, 'chat.example.com' and 'localhost:8080' are valid but 'http://chat.example.com' is invalid.

Bio

Bio: string

A user's bio which cannot exceed 2,500 characters, disallows leading and trailing whitespace, and uses GitHub Flavored Markdown.

ContextMessageId

ContextMessageId: number

The user might want to give their message a context, such as when replying to a message sent several messages ago. In this case, this is the ID of the message being replied to.

Cursor

Cursor: string

A cursor for pagination.

DateTime

DateTime: string

Complies with ISO 8601.

GroupChatDescription

GroupChatDescription: string

At most 1,000 characters, disallows leading and trailing whitespace, and uses GitHub Flavored Markdown.

GroupChatPublicity

GroupChatPublicity: "NOT_INVITABLE" | "INVITABLE" | "PUBLIC"
  • 'NOT_INVITABLE': Users cannot join the chat via an invite code.
  • 'INVITABLE': Users can join the chat via an invite code.
  • 'PUBLIC': People can search for, and view public chats without an account. Invite codes are permanently turned on. Anyone with an account can join a public chat. A frontend UI may allow for a search engine to index the chat should the administrator allow for it. A chat must be made public when it's being created because chats can't switch between being public after they've been created.

GroupChatTitle

GroupChatTitle: string

1-70 characters, of which at least one isn't whitespace. Leading and trailing whitespace is disallowed.

HttpProtocol

HttpProtocol: "http" | "https"

HTTPS is strongly recommended for production.

Id

Id: string

The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable.

ImageType

ImageType: "ORIGINAL" | "THUMBNAIL"

MessageText

MessageText: string

1-10,000 characters, of which at least one isn't whitespace. Uses GitHub Flavored Markdown. Leading and trailing whitespace is disallowed.

Name

Name: string

A name must neither contain whitespace nor exceed 30 characters.

Password

Password: string

A password which contains non-whitespace characters.

Placeholder

Placeholder: ""

GraphQL mandates data be returned for every operation, and data be present in every type. However, certain operations and types don't have relevant data. This type, which is an empty string, indicates such.

Username

Username: string

A username must be 1-30 characters long. Only lowercase English letters (a-z), English numbers (0-9), periods, and underscores are allowed.

Uuid

Uuid: string

WebSocketProtocol

WebSocketProtocol: "ws" | "wss"

WSS is strongly recommended for production.

Functions

getAudioMessage

  • getAudioMessage(config: HttpApiConfig, accessToken: string | undefined, messageId: number): Promise<AudioFile>

getDocMessage

  • getDocMessage(config: HttpApiConfig, accessToken: string | undefined, messageId: number): Promise<DocFile>

getGroupChatImage

getHealthCheck

  • getHealthCheck(__namedParameters: HttpApiConfig): Promise<boolean>
  • Check if all systems are operational. For example, a backend developer building atop Omni Chat can program the server to automatically restart when it becomes "unhealthy".

    Parameters

    Returns Promise<boolean>

    Whether the backend is "healthy".

getImageMessage

getProfileImage

getVideoMessage

  • getVideoMessage(config: HttpApiConfig, accessToken: string | undefined, messageId: number): Promise<VideoFile>

isValidBioScalar

  • isValidBioScalar(value: string): boolean

isValidDateTimeScalar

  • isValidDateTimeScalar(value: string): boolean

isValidGroupChatDescriptionScalar

  • isValidGroupChatDescriptionScalar(value: string): boolean

isValidGroupChatTitleScalar

  • isValidGroupChatTitleScalar(value: string): boolean

isValidMessageTextScalar

  • isValidMessageTextScalar(value: string): boolean

isValidNameScalar

  • isValidNameScalar(value: string): boolean

isValidPasswordScalar

  • isValidPasswordScalar(value: string): boolean

isValidUsernameScalar

  • isValidUsernameScalar(value: string): boolean

isValidUuidScalar

  • isValidUuidScalar(value: string): boolean

patchGroupChatImage

  • patchGroupChatImage(__namedParameters: HttpApiConfig, accessToken: string, chatId: number, image: File): Promise<void>

patchProfileImage

  • patchProfileImage(__namedParameters: HttpApiConfig, accessToken: string, image: File): Promise<void>

postAudioMessage

postDocMessage

postImageMessage

postVideoMessage

queryOrMutate

subscribe

Generated using TypeDoc