]> git.r.bdr.sh - rbdr/forum/commitdiff
Add type definitions
authorRuben Beltran del Rio <redacted>
Sun, 1 May 2022 13:01:31 +0000 (15:01 +0200)
committerRuben Beltran del Rio <redacted>
Sun, 1 May 2022 13:01:31 +0000 (15:01 +0200)
src/lib/data/types.d.ts [new file with mode: 0644]
src/lib/data/vendor.d.ts [new file with mode: 0644]

diff --git a/src/lib/data/types.d.ts b/src/lib/data/types.d.ts
new file mode 100644 (file)
index 0000000..2498bf7
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * These types are the structures that we can expect
+ * from the API.
+ */
+
+export type Topic = {
+       id: string;
+       title: string;
+       ttl: number;
+       updated_at: number;
+       tags: Tag[];
+       posts: Post[];
+       forum: Forum;
+};
+
+export type Post = {
+       id: string;
+       created_at: number;
+       title: string;
+       text: string;
+       topic: Topic;
+       author: Author;
+};
+
+export type Tag = {
+       id: string;
+       weight: number;
+       topics: Topic[];
+};
+
+export type Forum = {
+       id: string;
+       glyph: string;
+       label: string;
+       position: number;
+       topics: Topic[];
+};
+
+export type Author = {
+       id: string;
+       handle: string;
+};
diff --git a/src/lib/data/vendor.d.ts b/src/lib/data/vendor.d.ts
new file mode 100644 (file)
index 0000000..98e2d46
--- /dev/null
@@ -0,0 +1,15 @@
+declare module 'language-name-map' {
+       export type LanguageNameMap = {
+               [languageCode: string]: LanguageName;
+       };
+
+       export type LanguageName = {
+               name: string;
+               native: string;
+               dir: 'rtl' | 'ltr';
+       };
+
+       export function getLangNameFromCode(langCode: string): LanguageName;
+       export function getLangCodeList(): string[];
+       export const languageNameMap: LanguageNameMap;
+}