forked from WorldBrain/Memex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
100 lines (89 loc) · 2.28 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
export type VisitInput = number
export type BookmarkInput = number
export type PageID = string
export type PageScore = number
export type SearchResult = [PageID, PageScore]
export type TermsIndexName = 'terms' | 'urlTerms' | 'titleTerms'
export type PageResultsMap = Map<PageID, PageScore>
export interface SearchParams {
domains: string[]
domainsExclude: string[]
tags: string[]
terms: string[]
termsExclude: string[]
bookmarks: boolean
endDate?: number
startDate?: number
skip?: number
limit?: number
lists: string[]
}
export interface FilteredURLs {
include: Set<string>
exclude: Set<string>
isDataFiltered: boolean
isAllowed(url: string): boolean
}
/**
* @typedef {Object} VisitInteraction
* @property {number} duration Time user was active during visit (ms).
* @property {number} scrollPx Y-axis pixel scrolled to at point in time.
* @property {number} scrollPerc
* @property {number} scrollMaxPx Furthest y-axis pixel scrolled to during visit.
* @property {number} scrollMaxPerc
*/
export interface VisitInteraction {
duration: number
scrollPx: number
scrollPerc: number
scrollMaxPx: number
scrollMaxPerc: number
}
/**
* @typedef {Object} PageAddRequest
* @property {any} pageData TODO: type
* @property {number[]} [visits=[]] Opt. visit times to assoc. with Page.
* @property {number} [bookmark] Opt. bookmark time to assoc. with Page.
*/
export interface PageAddRequest {
pageDoc: PageDoc
visits: VisitInput[]
bookmark: BookmarkInput
rejectNoContent?: boolean
}
export interface PageDoc {
content: Partial<PageContent>
url: string
favIconURI?: string
screenshotURI?: string
[extra: string]: any
}
export interface PageContent {
fullText: string
title: string
lang?: string
canonicalUrl?: string
description?: string
keywords?: string[]
}
export interface PipelineReq {
pageDoc: PageDoc
rejectNoContent?: boolean
}
export interface PipelineRes {
url: string
// Display data
fullUrl: string
fullTitle: string
// Indexed data
domain: string
hostname: string
tags: string[]
terms: string[]
urlTerms: string[]
titleTerms: string[]
// Misc.
favIconURI?: string
screenshotURI?: string
text: string
}