Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding types for translations #607

Merged
merged 3 commits into from
Feb 1, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
}[Keys];

export type RequireOnlyTwo<T, Keys extends keyof T = keyof T> = Pick<
T,
Exclude<keyof T, Keys>
> &
{
[K in Keys]-?: Required<Pick<T, K>> & RequireOnlyOne<Omit<T, K>>;
}[Keys];

export type UnknownType = Record<string, unknown>;

export type Unpacked<T> = T extends (infer U)[]
Expand Down Expand Up @@ -77,6 +85,7 @@ export type AppSettingsAPIResponse<
url_enrichment?: boolean;
}
>;
auto_translation_enabled?: boolean;
before_message_send_hook_url?: string;
custom_action_handler_url?: string;
disable_auth_checks?: boolean;
Expand Down Expand Up @@ -130,6 +139,8 @@ export type ChannelResponse<
frozen: boolean;
id: string;
type: string;
auto_translation_enabled?: boolean;
auto_translation_language?: TranslationLanguages;
config?: ChannelConfigWithInfo<CommandType>;
created_at?: string;
created_by?: UserResponse<UserType> | null;
Expand Down Expand Up @@ -434,6 +445,9 @@ export type MessageResponse<
command_info?: { name?: string };
created_at?: string;
deleted_at?: string;
i18n?: RequireAtLeastOne<Record<`${TranslationLanguages}_text`, string>> & {
language: TranslationLanguages;
};
latest_reactions?: ReactionResponse<ReactionType, UserType>[];
mentioned_users?: UserResponse<UserType>[];
own_reactions?: ReactionResponse<ReactionType, UserType>[] | null;
Expand Down Expand Up @@ -635,6 +649,7 @@ export type UserResponse<UserType = UnknownType> = User<UserType> & {
created_at?: string;
deactivated_at?: string;
deleted_at?: string;
language?: TranslationLanguages;
last_active?: string;
online?: boolean;
shadow_banned?: boolean;
Expand Down Expand Up @@ -1265,6 +1280,7 @@ export type AppSettings = {
p12_cert?: string;
team_id?: string;
};
auto_translation_enabled?: boolean;
custom_action_handler_url?: string;
disable_auth_checks?: boolean;
disable_permissions_checks?: boolean;
Expand Down Expand Up @@ -1656,3 +1672,60 @@ export type User<UserType = UnknownType> = UserType & {
};

export type TypingStartEvent = Event;

export type TranslationLanguages =
| 'af'
| 'am'
| 'ar'
| 'az'
| 'bg'
| 'bn'
| 'bs'
| 'cs'
| 'da'
| 'de'
| 'el'
| 'en'
| 'es'
| 'es-MX'
| 'et'
| 'fa'
| 'fa-AF'
| 'fi'
| 'fr'
| 'fr-CA'
| 'ha'
| 'he'
| 'hi'
| 'hr'
| 'hu'
| 'id'
| 'it'
| 'ja'
| 'ka'
| 'ko'
| 'lv'
| 'ms'
| 'nl'
| 'no'
| 'pl'
| 'ps'
| 'pt'
| 'ro'
| 'ru'
| 'sk'
| 'sl'
| 'so'
| 'sq'
| 'sr'
| 'sv'
| 'sw'
| 'ta'
| 'th'
| 'tl'
| 'tr'
| 'uk'
| 'ur'
| 'vi'
| 'zh'
| 'zh-TW';