-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
store.ts
174 lines (164 loc) 路 3.14 KB
/
store.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import {Browser, LoadEvent} from 'puppeteer';
export type Element = {
container?: string;
text: string[];
};
export type Pricing = {
container: string;
euroFormat?: boolean;
};
export type Brand =
| 'test:brand'
| 'amd'
| 'asrock'
| 'asus'
| 'corsair'
| 'evga'
| 'gainward'
| 'gigabyte'
| 'inno3d'
| 'kfa2'
| 'microsoft'
| 'msi'
| 'nvidia'
| 'palit'
| 'pny'
| 'sapphire'
| 'sony'
| 'xfx'
| 'powercolor'
| 'zotac';
export type Series =
| 'test:series'
| '3070'
| '3080'
| '3090'
| 'rx6800'
| 'rx6800xt'
| 'rx6900xt'
| 'ryzen5600'
| 'ryzen5800'
| 'ryzen5900'
| 'ryzen5950'
| 'sonyps5c'
| 'sonyps5de'
| 'sf'
| 'xboxsx'
| 'xboxss';
export type Model =
| 'test:model'
| '5600x'
| '5800x'
| '5900x'
| '5950x'
| '600 platinum'
| '750 platinum'
| 'amd reference'
| 'amp extreme holo'
| 'amp holo'
| 'aorus master'
| 'aorus xtreme'
| 'aorus'
| 'dual fan'
| 'dual oc'
| 'dual'
| 'eagle oc'
| 'eagle'
| 'founders edition'
| 'ftw3 ultra'
| 'ftw3'
| 'gamerock oc'
| 'gaming oc'
| 'gaming pro oc'
| 'gaming pro'
| 'gaming x trio'
| 'gaming x3'
| 'gaming'
| 'ichill x2'
| 'ichill x3'
| 'ichill x4'
| 'nitro oc se'
| 'nitro oc'
| 'phantom gs'
| 'phoenix gs oc'
| 'phoenix gs'
| 'phoenix'
| 'ps5 console'
| 'ps5 digital'
| 'sg oc'
| 'sg'
| 'strix lc'
| 'strix oc'
| 'strix'
| 'trinity oc'
| 'trinity'
| 'tuf oc'
| 'tuf'
| 'turbo'
| 'twin edge oc'
| 'twin edge'
| 'twin x2 oc'
| 'twin x2'
| 'uprising'
| 'ventus 2x oc'
| 'ventus 2x'
| 'ventus 3x oc'
| 'ventus 3x'
| 'vision oc'
| 'vision'
| 'xbox series s'
| 'xbox series x'
| 'xc3 black'
| 'xc3 ultra'
| 'xc3'
| 'xlr8 revel'
| 'xlr8 uprising';
export type Link = {
brand: Brand;
itemNumber?: string;
series: Series;
model: Model;
url: string;
cartUrl?: string;
openCartAction?: (browser: Browser) => Promise<string>;
screenshot?: string;
};
export type LabelQuery = Element[] | Element | string[];
export type Labels = {
bannedSeller?: LabelQuery;
captcha?: LabelQuery;
container?: string;
inStock?: LabelQuery;
outOfStock?: LabelQuery;
maxPrice?: Pricing;
};
export type StatusCodeRangeArray = Array<number | [number, number]>;
export type Store = {
realTimeInventoryLookup?: (itemNumber: string) => Promise<boolean>;
/**
* The range of status codes which will trigger backoff, i.e. an increasing
* delay between requests. Setting an empty array will disable the feature.
* If not defined, the default range will be used: 403.
*/
backoffStatusCodes?: StatusCodeRangeArray;
disableAdBlocker?: boolean;
links: Link[];
linksBuilder?: {
builder: (docElement: cheerio.Cheerio, series: Series) => Link[];
ttl?: number;
urls: Array<{series: Series; url: string | string[]}>;
};
labels: Labels;
name: string;
setupAction?: (browser: Browser) => void;
/**
* The range of status codes which considered successful, i.e. without error
* allowing request parsing to continue. Setting an empty array will cause
* all requests to fail. If not defined, the default range will be used:
* 0 -> 399 inclusive.
*/
successStatusCodes?: StatusCodeRangeArray;
waitUntil?: LoadEvent;
minPageSleep?: number;
maxPageSleep?: number;
};