-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
71 lines (64 loc) · 1.46 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
export interface ReviewTimeline {
shelved: string;
started: string | null;
finished: string | null;
progress: {
percent: number;
date: string;
}[];
}
export interface RawReview {
reviewId: number;
bookUrl: string;
timeline: ReviewTimeline;
}
export interface RawBook {
url: string;
title: string;
description: string;
authorUrl: string;
imageUrl: string;
isbn: number | null;
pageCount: number;
genreHierarchy: string[][]; // genres appear in order of importance
positionInSeries?: number;
series?: {
url: string;
name: string;
};
}
export interface Author {
url: string;
name: string;
birthDate: string | null;
deathDate: string | null;
genres: string[] | null;
websiteUrl: string | null;
twitterUrl: string | null;
}
export interface Series {
url: string;
name: string;
works: {
primary: number;
total: number;
};
}
// Designed for data storage. Items are deduplicated and indexed at the
// top-level.
export type Extract = {
reviews: RawReview[];
booksByUrl: Record<string, RawBook>;
authorsByUrl: Record<string, Author>;
seriesByUrl: Record<string, Series>;
genreUrls: Record<string, string>;
};
// The types below are designed for ease-of use. This library provides
// functions to convert an Extract to these types.
export type Book = Omit<RawBook, 'authorUrl' | 'seriesUrl'> & {
author: Author;
series?: Series;
};
export type Review = Omit<RawReview, 'bookUrl'> & {
book: Book;
};