@chrisdothtml/job-scraper 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/cache.d.ts +64 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +146 -0
- package/dist/cache.js.map +1 -0
- package/dist/companies.d.ts +89 -0
- package/dist/companies.d.ts.map +1 -0
- package/dist/companies.js +244 -0
- package/dist/companies.js.map +1 -0
- package/dist/companies.seed.d.ts +9 -0
- package/dist/companies.seed.d.ts.map +1 -0
- package/dist/companies.seed.js +455 -0
- package/dist/companies.seed.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +16 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +17 -0
- package/dist/paths.js.map +1 -0
- package/dist/platform/browser.d.ts +3 -0
- package/dist/platform/browser.d.ts.map +1 -0
- package/dist/platform/browser.js +103 -0
- package/dist/platform/browser.js.map +1 -0
- package/dist/platform/node.d.ts +3 -0
- package/dist/platform/node.d.ts.map +1 -0
- package/dist/platform/node.js +106 -0
- package/dist/platform/node.js.map +1 -0
- package/dist/platform/types.d.ts +46 -0
- package/dist/platform/types.d.ts.map +1 -0
- package/dist/platform/types.js +2 -0
- package/dist/platform/types.js.map +1 -0
- package/dist/resolve.d.ts +89 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +379 -0
- package/dist/resolve.js.map +1 -0
- package/dist/scrapers/AshbyScraper.d.ts +16 -0
- package/dist/scrapers/AshbyScraper.d.ts.map +1 -0
- package/dist/scrapers/AshbyScraper.js +207 -0
- package/dist/scrapers/AshbyScraper.js.map +1 -0
- package/dist/scrapers/GitHubScraper.d.ts +8 -0
- package/dist/scrapers/GitHubScraper.d.ts.map +1 -0
- package/dist/scrapers/GitHubScraper.js +61 -0
- package/dist/scrapers/GitHubScraper.js.map +1 -0
- package/dist/scrapers/GoogleScraper.d.ts +8 -0
- package/dist/scrapers/GoogleScraper.d.ts.map +1 -0
- package/dist/scrapers/GoogleScraper.js +83 -0
- package/dist/scrapers/GoogleScraper.js.map +1 -0
- package/dist/scrapers/GreenhouseScraper.d.ts +28 -0
- package/dist/scrapers/GreenhouseScraper.d.ts.map +1 -0
- package/dist/scrapers/GreenhouseScraper.js +68 -0
- package/dist/scrapers/GreenhouseScraper.js.map +1 -0
- package/dist/scrapers/LeverScraper.d.ts +13 -0
- package/dist/scrapers/LeverScraper.d.ts.map +1 -0
- package/dist/scrapers/LeverScraper.js +58 -0
- package/dist/scrapers/LeverScraper.js.map +1 -0
- package/dist/scrapers/NetflixScraper.d.ts +8 -0
- package/dist/scrapers/NetflixScraper.d.ts.map +1 -0
- package/dist/scrapers/NetflixScraper.js +60 -0
- package/dist/scrapers/NetflixScraper.js.map +1 -0
- package/dist/scrapers/NvidiaScraper.d.ts +8 -0
- package/dist/scrapers/NvidiaScraper.d.ts.map +1 -0
- package/dist/scrapers/NvidiaScraper.js +61 -0
- package/dist/scrapers/NvidiaScraper.js.map +1 -0
- package/dist/scrapers/RipplingScraper.d.ts +10 -0
- package/dist/scrapers/RipplingScraper.d.ts.map +1 -0
- package/dist/scrapers/RipplingScraper.js +64 -0
- package/dist/scrapers/RipplingScraper.js.map +1 -0
- package/dist/scrapers/Scraper.d.ts +134 -0
- package/dist/scrapers/Scraper.d.ts.map +1 -0
- package/dist/scrapers/Scraper.js +224 -0
- package/dist/scrapers/Scraper.js.map +1 -0
- package/dist/scrapers/ShopifyScraper.d.ts +16 -0
- package/dist/scrapers/ShopifyScraper.d.ts.map +1 -0
- package/dist/scrapers/ShopifyScraper.js +104 -0
- package/dist/scrapers/ShopifyScraper.js.map +1 -0
- package/dist/scrapers/SmartRecruitersScraper.d.ts +13 -0
- package/dist/scrapers/SmartRecruitersScraper.d.ts.map +1 -0
- package/dist/scrapers/SmartRecruitersScraper.js +66 -0
- package/dist/scrapers/SmartRecruitersScraper.js.map +1 -0
- package/dist/scrapers/UberScraper.d.ts +14 -0
- package/dist/scrapers/UberScraper.d.ts.map +1 -0
- package/dist/scrapers/UberScraper.js +94 -0
- package/dist/scrapers/UberScraper.js.map +1 -0
- package/dist/scrapers/WorkableScraper.d.ts +12 -0
- package/dist/scrapers/WorkableScraper.d.ts.map +1 -0
- package/dist/scrapers/WorkableScraper.js +67 -0
- package/dist/scrapers/WorkableScraper.js.map +1 -0
- package/dist/scrapers/WorkdayScraper.d.ts +14 -0
- package/dist/scrapers/WorkdayScraper.d.ts.map +1 -0
- package/dist/scrapers/WorkdayScraper.js +85 -0
- package/dist/scrapers/WorkdayScraper.js.map +1 -0
- package/dist/scrapers/index.d.ts +41 -0
- package/dist/scrapers/index.d.ts.map +1 -0
- package/dist/scrapers/index.js +46 -0
- package/dist/scrapers/index.js.map +1 -0
- package/dist/search.d.ts +75 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +225 -0
- package/dist/search.js.map +1 -0
- package/dist/sniff.d.ts +43 -0
- package/dist/sniff.d.ts.map +1 -0
- package/dist/sniff.js +124 -0
- package/dist/sniff.js.map +1 -0
- package/dist/utils/misc.d.ts +15 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +31 -0
- package/dist/utils/misc.js.map +1 -0
- package/package.json +70 -0
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { CorsError } from "./cache.js";
|
|
2
|
+
import { addCompanyDomain, findCompany, findCompanyByDomain, isBoardDomain, normalizeCompanyName, normalizeDomain, registerCompany, slugMatchesCompany, } from "./companies.js";
|
|
3
|
+
import { discoverableScrapers, getScraper, isScraperName, scraperNames, scrapers, } from "./scrapers/index.js";
|
|
4
|
+
import { BoardShapeError, } from "./scrapers/Scraper.js";
|
|
5
|
+
import { searchForBoards } from "./search.js";
|
|
6
|
+
import { sniffPage } from "./sniff.js";
|
|
7
|
+
/** Thrown when no scraper in this package can serve the requested company */
|
|
8
|
+
export class UnresolvedCompanyError extends Error {
|
|
9
|
+
input;
|
|
10
|
+
blocked;
|
|
11
|
+
constructor(input, message,
|
|
12
|
+
/**
|
|
13
|
+
* Whether the browser blocked any board or page tried along the way (see
|
|
14
|
+
* `CorsError`). When it did, the company may well resolve from Node,
|
|
15
|
+
* which doesn't enforce CORS.
|
|
16
|
+
*/
|
|
17
|
+
blocked = false) {
|
|
18
|
+
super((message ?? `Could not resolve a scraper for '${input}'`) +
|
|
19
|
+
(blocked
|
|
20
|
+
? ` (some job boards were blocked by the browser's CORS policy; it may resolve from Node)`
|
|
21
|
+
: ''));
|
|
22
|
+
this.input = input;
|
|
23
|
+
this.blocked = blocked;
|
|
24
|
+
this.name = 'UnresolvedCompanyError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const DEFAULT_MIN_JOBS = 3;
|
|
28
|
+
/**
|
|
29
|
+
* Turns loose input (a company name, a URL, an explicit scraper) into a
|
|
30
|
+
* concrete company record. Companies found by probing are added to the
|
|
31
|
+
* registry so the next call is a plain lookup.
|
|
32
|
+
*/
|
|
33
|
+
export async function resolveCompany(input) {
|
|
34
|
+
return resolveJob(input);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Like `resolveCompany`, but also recovers the job id when the input was a
|
|
38
|
+
* job posting URL.
|
|
39
|
+
*/
|
|
40
|
+
export async function resolveJob(input) {
|
|
41
|
+
const options = normalizeInput(input);
|
|
42
|
+
const { scraper, slug } = options;
|
|
43
|
+
const minJobs = options.minJobs ?? DEFAULT_MIN_JOBS;
|
|
44
|
+
let jobId = null;
|
|
45
|
+
if (!options.company && !options.url && !slug) {
|
|
46
|
+
throw new TypeError('A company name, URL, or slug is required');
|
|
47
|
+
}
|
|
48
|
+
if (scraper && !isScraperName(scraper)) {
|
|
49
|
+
throw new TypeError(`Unknown scraper: ${scraper}`);
|
|
50
|
+
}
|
|
51
|
+
const url = options.url ? URL.parse(options.url) : null;
|
|
52
|
+
const host = url && normalizeDomain(url.hostname);
|
|
53
|
+
// every name worth trying, best first. The caller's own name outranks
|
|
54
|
+
// anything guessed from the URL, and each gains a careers-stripped form
|
|
55
|
+
const names = new NameCandidates();
|
|
56
|
+
names.add(options.company);
|
|
57
|
+
// what went wrong with candidates along the way, so that a failure can say
|
|
58
|
+
// *why* rather than shrugging with a generic "not found"
|
|
59
|
+
const misses = { shapeErrors: [], blocked: false };
|
|
60
|
+
/**
|
|
61
|
+
* Records the company's own careers domain on the way out, so the next URL
|
|
62
|
+
* on it is a plain lookup. Board hosts are excluded: `parseUrl` already
|
|
63
|
+
* knows them, and claiming one would point every company's jobs at this one
|
|
64
|
+
*/
|
|
65
|
+
const resolved = async (result) => {
|
|
66
|
+
if (host && !isBoardDomain(host) && ownDomain(host, result.name)) {
|
|
67
|
+
await addCompanyDomain(result.name, host);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
if (url) {
|
|
72
|
+
// 1. a URL a scraper recognizes names the board outright, so trust it
|
|
73
|
+
const parsed = parseJobUrl(url.href, scraper);
|
|
74
|
+
if (parsed) {
|
|
75
|
+
const known = await findCompany(parsed.name);
|
|
76
|
+
return resolved({
|
|
77
|
+
...parsed,
|
|
78
|
+
// prefer a real display name over one derived from a slug
|
|
79
|
+
name: options.company ?? known?.name ?? parsed.name,
|
|
80
|
+
discovered: false,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
jobId = jobIdFromUrl(url);
|
|
84
|
+
// 2. a domain this company has been seen on before. This is the whole
|
|
85
|
+
// point of storing domains: a bespoke careers site (`pinterestcareers.com`)
|
|
86
|
+
// otherwise has to earn its way through every step below, every time
|
|
87
|
+
const byDomain = await findCompanyByDomain(url.hostname);
|
|
88
|
+
if (byDomain && (!scraper || byDomain.scraper === scraper)) {
|
|
89
|
+
return {
|
|
90
|
+
...byDomain,
|
|
91
|
+
name: options.company ?? byDomain.name,
|
|
92
|
+
jobId,
|
|
93
|
+
discovered: false,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// 3. the hostname usually carries the company name (`careers.acme.com`)
|
|
97
|
+
names.add(companyNameFromUrl(url));
|
|
98
|
+
const byHost = await findKnown(names, scraper);
|
|
99
|
+
if (byHost) {
|
|
100
|
+
return resolved({ ...byHost, jobId, discovered: false });
|
|
101
|
+
}
|
|
102
|
+
// 4. read the page itself. It's likely a board embedded on the company's
|
|
103
|
+
// own domain, and the markup still has to name the board it loads
|
|
104
|
+
const page = await sniffPage(url.href);
|
|
105
|
+
if (page.blocked)
|
|
106
|
+
misses.blocked = true;
|
|
107
|
+
const [embedded] = page.boards;
|
|
108
|
+
if (embedded) {
|
|
109
|
+
const known = await findCompany(embedded.slug);
|
|
110
|
+
return resolved({
|
|
111
|
+
name: options.company ?? known?.name ?? embedded.slug,
|
|
112
|
+
scraper: embedded.scraper,
|
|
113
|
+
slug: embedded.slug,
|
|
114
|
+
// deliberately not `embedded.jobId`: that's whichever posting the
|
|
115
|
+
// page happened to link first, not the one the caller asked for
|
|
116
|
+
jobId,
|
|
117
|
+
discovered: false,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// 5. no board in the markup, but the page still says who it belongs to.
|
|
121
|
+
// `og:site_name` and JSON-LD beat the hostname, which is why they're
|
|
122
|
+
// tried before falling back to it for discovery below
|
|
123
|
+
names.prepend(page.names);
|
|
124
|
+
const byName = await findKnown(names, scraper);
|
|
125
|
+
if (byName) {
|
|
126
|
+
return resolved({ ...byName, jobId, discovered: false });
|
|
127
|
+
}
|
|
128
|
+
if (names.empty && !slug) {
|
|
129
|
+
throw new UnresolvedCompanyError(url.href, `No scraper recognizes '${url.href}'`, misses.blocked);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
names.add(slug);
|
|
133
|
+
const name = names.primary;
|
|
134
|
+
// 6. caller pinned the board explicitly
|
|
135
|
+
if (scraper && slug) {
|
|
136
|
+
return { name, scraper, slug, jobId, discovered: false };
|
|
137
|
+
}
|
|
138
|
+
// 7. already known
|
|
139
|
+
const known = await findKnown(names, scraper);
|
|
140
|
+
if (known) {
|
|
141
|
+
return resolved({ ...known, jobId, discovered: false });
|
|
142
|
+
}
|
|
143
|
+
// 8. probe the boards that can be addressed by a guessable slug. A URL
|
|
144
|
+
// carrying a board's own tracking params (`?gh_jid=`) says which board to
|
|
145
|
+
// try first, even when nothing else about the page does
|
|
146
|
+
const hinted = url ? boardHints(url) : [];
|
|
147
|
+
const candidates = scraper
|
|
148
|
+
? [scraper]
|
|
149
|
+
: [...hinted, ...discoverableScrapers.filter((s) => !hinted.includes(s))];
|
|
150
|
+
const found = await discoverBoard(names.all, slug, candidates, minJobs, misses);
|
|
151
|
+
if (found) {
|
|
152
|
+
await registerCompany(found);
|
|
153
|
+
return resolved({ ...found, jobId, discovered: true });
|
|
154
|
+
}
|
|
155
|
+
// 9. ask the web which board they're on. This is the only route to boards
|
|
156
|
+
// whose slug isn't derivable from the name at all, Workday especially
|
|
157
|
+
if (options.search ?? true) {
|
|
158
|
+
const searched = await searchForBoards(name);
|
|
159
|
+
for (const board of searched) {
|
|
160
|
+
if (scraper && board.scraper !== scraper)
|
|
161
|
+
continue;
|
|
162
|
+
// a search for a company that other job posts name-drop (an HR vendor,
|
|
163
|
+
// say) surfaces boards belonging to entirely different companies, so
|
|
164
|
+
// the slug has to look like the company before we'll believe it
|
|
165
|
+
if (!slugMatchesCompany(board.slug, name))
|
|
166
|
+
continue;
|
|
167
|
+
// the search told us where to look; the board still has to confirm it
|
|
168
|
+
const ScraperClass = scrapers[board.scraper];
|
|
169
|
+
if (!(await hasCompanyBoard(ScraperClass, board.slug, minJobs, misses))) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const company = { name, scraper: board.scraper, slug: board.slug };
|
|
173
|
+
await registerCompany(company);
|
|
174
|
+
return resolved({
|
|
175
|
+
...company,
|
|
176
|
+
jobId: jobId ?? board.jobId,
|
|
177
|
+
discovered: true,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// nothing resolved; if a candidate along the way looked like the right
|
|
182
|
+
// board but a fallback couldn't parse its page, that's more useful to the
|
|
183
|
+
// caller than a blanket "couldn't find it"
|
|
184
|
+
if (misses.shapeErrors.length > 0)
|
|
185
|
+
throw misses.shapeErrors[0];
|
|
186
|
+
throw new UnresolvedCompanyError(name, undefined, misses.blocked);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Runs `hasCompanyBoard` on a throwaway instance, recording a `BoardShapeError` or `CorsError` in
|
|
190
|
+
* `misses` instead of letting it abort the candidate loop it's called from.
|
|
191
|
+
* A board the browser won't let us reach is no match, not a failure: the
|
|
192
|
+
* company may well be on one of the boards it can reach.
|
|
193
|
+
*/
|
|
194
|
+
async function hasCompanyBoard(ScraperClass, slug, minJobs, misses) {
|
|
195
|
+
const instance = new ScraperClass(slug);
|
|
196
|
+
try {
|
|
197
|
+
return await instance.hasCompanyBoard(minJobs);
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
if (err instanceof BoardShapeError)
|
|
201
|
+
misses.shapeErrors.push(err);
|
|
202
|
+
else if (err instanceof CorsError)
|
|
203
|
+
misses.blocked = true;
|
|
204
|
+
else
|
|
205
|
+
throw err;
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
instance.dispose();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// words a company tacks onto its own name when it runs a careers site of its
|
|
213
|
+
// own: `pinterestcareers.com`, `lifeatacme.io`, "Figma Careers"
|
|
214
|
+
const SITE_PREFIX = /^(?:life[-_. ]?at|work[-_. ]?at|join[-_. ]?us|join)[-_. ]?/i;
|
|
215
|
+
const SITE_SUFFIX = /[-_. ]?(?:careers?|jobs?|hiring|talent|recruiting|apply)$/i;
|
|
216
|
+
/**
|
|
217
|
+
* Alternate readings of a company name. A careers domain or page title names
|
|
218
|
+
* the site rather than the company, so `pinterestcareers` has to be allowed
|
|
219
|
+
* to mean `pinterest`, otherwise a company already in the registry is missed
|
|
220
|
+
* purely because the link went through its own careers site.
|
|
221
|
+
*/
|
|
222
|
+
export function companyNameCandidates(name) {
|
|
223
|
+
const stripped = name
|
|
224
|
+
.replace(SITE_PREFIX, '')
|
|
225
|
+
.replace(SITE_SUFFIX, '')
|
|
226
|
+
.trim();
|
|
227
|
+
return stripped && stripped !== name ? [name, stripped] : [name];
|
|
228
|
+
}
|
|
229
|
+
/** An ordered, de-duplicated set of names to try, best first */
|
|
230
|
+
class NameCandidates {
|
|
231
|
+
#names = [];
|
|
232
|
+
get all() {
|
|
233
|
+
return this.#names;
|
|
234
|
+
}
|
|
235
|
+
get primary() {
|
|
236
|
+
return this.#names[0];
|
|
237
|
+
}
|
|
238
|
+
get empty() {
|
|
239
|
+
return this.#names.length === 0;
|
|
240
|
+
}
|
|
241
|
+
add(...values) {
|
|
242
|
+
for (const value of values.flat()) {
|
|
243
|
+
if (value && !this.#names.includes(value))
|
|
244
|
+
this.#names.push(value);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/** Adds names ahead of what's already there, keeping their own order */
|
|
248
|
+
prepend(values) {
|
|
249
|
+
const existing = this.#names;
|
|
250
|
+
this.#names = [];
|
|
251
|
+
this.add(...values);
|
|
252
|
+
this.add(...existing);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** The first candidate name the registry knows, trying stripped forms too */
|
|
256
|
+
async function findKnown(names, scraper) {
|
|
257
|
+
for (const name of names.all) {
|
|
258
|
+
for (const candidate of companyNameCandidates(name)) {
|
|
259
|
+
const known = await findCompany(candidate);
|
|
260
|
+
if (known && (!scraper || known.scraper === scraper))
|
|
261
|
+
return known;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Whether a hostname plausibly belongs to the company itself, rather than to
|
|
268
|
+
* an aggregator that merely lists their jobs. Only the company's own domains
|
|
269
|
+
* are worth remembering; recording `linkedin.com` would hand every later
|
|
270
|
+
* LinkedIn link to whichever company was looked up first.
|
|
271
|
+
*/
|
|
272
|
+
function ownDomain(hostname, companyName) {
|
|
273
|
+
// short names match too much of too many hostnames to be evidence
|
|
274
|
+
return (normalizeCompanyName(companyName).length >= 4 &&
|
|
275
|
+
slugMatchesCompany(hostname, companyName));
|
|
276
|
+
}
|
|
277
|
+
/** Boards named by a URL's own tracking params, e.g. `?gh_jid=` for Greenhouse */
|
|
278
|
+
export function boardHints(url) {
|
|
279
|
+
return scraperNames.filter((name) => scrapers[name].urlHintParams.some((param) => url.searchParams.has(param)));
|
|
280
|
+
}
|
|
281
|
+
// subdomains that name the job board rather than the company
|
|
282
|
+
const BOARD_SUBDOMAINS = new Set([
|
|
283
|
+
'apply',
|
|
284
|
+
'boards',
|
|
285
|
+
'careers',
|
|
286
|
+
'jobs',
|
|
287
|
+
'job-boards',
|
|
288
|
+
'explore',
|
|
289
|
+
'www',
|
|
290
|
+
]);
|
|
291
|
+
/**
|
|
292
|
+
* Best-effort company name from a careers URL hosted on the company's own
|
|
293
|
+
* domain, e.g. `https://careers.acme.com/...` -> `acme`.
|
|
294
|
+
*/
|
|
295
|
+
export function companyNameFromUrl(url) {
|
|
296
|
+
const labels = url.hostname.split('.').filter(Boolean);
|
|
297
|
+
while (labels.length > 2 && BOARD_SUBDOMAINS.has(labels[0]))
|
|
298
|
+
labels.shift();
|
|
299
|
+
// everything from here on is the public suffix
|
|
300
|
+
return labels.length > 1 ? labels[0] : null;
|
|
301
|
+
}
|
|
302
|
+
// query params boards use to address a single posting when the path doesn't
|
|
303
|
+
const JOB_ID_PARAMS = ['gh_jid', 'pid', 'jobId', 'job_id', 'lever-job-id'];
|
|
304
|
+
/** Best-effort job id from a URL no scraper claimed */
|
|
305
|
+
export function jobIdFromUrl(url) {
|
|
306
|
+
for (const param of JOB_ID_PARAMS) {
|
|
307
|
+
const value = url.searchParams.get(param);
|
|
308
|
+
if (value)
|
|
309
|
+
return value;
|
|
310
|
+
}
|
|
311
|
+
// a trailing all-digits segment is an id often enough to be worth trying;
|
|
312
|
+
// anything looser matches too many ordinary careers pages
|
|
313
|
+
const last = url.pathname.split('/').filter(Boolean).at(-1);
|
|
314
|
+
return last && /^\d+$/.test(last) ? last : null;
|
|
315
|
+
}
|
|
316
|
+
/** Builds the scraper instance for a resolved company */
|
|
317
|
+
export function createScraper(company) {
|
|
318
|
+
const ScraperClass = getScraper(company.scraper);
|
|
319
|
+
return new ScraperClass(company.slug);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Asks each scraper whether it recognizes the URL. Returns the board it
|
|
323
|
+
* belongs to, plus the job id when the URL addresses a single posting.
|
|
324
|
+
*/
|
|
325
|
+
export function parseJobUrl(input, only) {
|
|
326
|
+
let url;
|
|
327
|
+
try {
|
|
328
|
+
url = new URL(input);
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
for (const name of only ? [only] : scraperNames) {
|
|
334
|
+
const parsed = scrapers[name].parseUrl(url);
|
|
335
|
+
if (!parsed)
|
|
336
|
+
continue;
|
|
337
|
+
return {
|
|
338
|
+
// the slug is the only name a URL carries; callers with a better one
|
|
339
|
+
// overwrite it
|
|
340
|
+
name: parsed.slug,
|
|
341
|
+
scraper: name,
|
|
342
|
+
slug: parsed.slug,
|
|
343
|
+
jobId: parsed.jobId,
|
|
344
|
+
discovered: false,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Tries each scraper's slug guesses against its board. Probes run in
|
|
351
|
+
* parallel, but the result follows `candidates` order so that the most
|
|
352
|
+
* common board wins a tie. A board with fewer than `minJobs` real postings
|
|
353
|
+
* doesn't count as an answer.
|
|
354
|
+
*/
|
|
355
|
+
async function discoverBoard(names, slug, candidates, minJobs, misses) {
|
|
356
|
+
// every reading of the name gets probed, since a careers-site name and the
|
|
357
|
+
// company's real one produce different slugs (`pinterestcareers` vs
|
|
358
|
+
// `pinterest`). Whichever answers is also the name we register it under
|
|
359
|
+
const readings = [...new Set(names.flatMap(companyNameCandidates))];
|
|
360
|
+
const probes = candidates.flatMap((scraper) => {
|
|
361
|
+
const ScraperClass = scrapers[scraper];
|
|
362
|
+
return readings.flatMap((companyName) => {
|
|
363
|
+
const slugs = slug ? [slug] : ScraperClass.slugCandidates(companyName);
|
|
364
|
+
return slugs.map(async (slug) => {
|
|
365
|
+
const exists = await hasCompanyBoard(ScraperClass, slug, minJobs, misses);
|
|
366
|
+
return exists ? { name: companyName, scraper, slug } : null;
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
// `Promise.all` rather than `any`, so the ordering above is what decides
|
|
371
|
+
const results = await Promise.all(probes);
|
|
372
|
+
return results.find((result) => result !== null) ?? null;
|
|
373
|
+
}
|
|
374
|
+
function normalizeInput(input) {
|
|
375
|
+
if (typeof input !== 'string')
|
|
376
|
+
return input;
|
|
377
|
+
return URL.canParse(input) ? { url: input } : { company: input };
|
|
378
|
+
}
|
|
379
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,kBAAkB,GAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,GAET,MAAM,qBAAqB,CAAC;AAC7B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ACJ,OAAO,EACP,MAAM,CACP,CAAC;gBACF,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YAC9D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,yEAAyE;IACzE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;AAC3D,CAAC;AAED,SAAS,cAAc,CAAC,KAA4B;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Scraper, type ListedJob, type ParsedUrl } from './Scraper.ts';
|
|
2
|
+
export default class AshbyScraper extends Scraper {
|
|
3
|
+
private jobsCache;
|
|
4
|
+
private usingFallback;
|
|
5
|
+
static readonly discoverable = true;
|
|
6
|
+
static readonly boardDomains: string[];
|
|
7
|
+
static readonly urlHintParams: string[];
|
|
8
|
+
static parseUrl(url: URL): ParsedUrl | null;
|
|
9
|
+
jobUrl(id: string): string;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
getJobsList(testing?: boolean): Promise<ListedJob[]>;
|
|
12
|
+
private getJobsListViaApi;
|
|
13
|
+
private getJobsListViaAppData;
|
|
14
|
+
getJobContent(id: string): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=AshbyScraper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AshbyScraper.d.ts","sourceRoot":"","sources":["../../src/scrapers/AshbyScraper.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,OAAO,EACP,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAmLtB,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAO,CAAC,SAAS,CAAmC;IAGpD,OAAO,CAAC,aAAa,CAAS;IAE9B,MAAM,CAAC,QAAQ,CAAC,YAAY,QAAQ;IACpC,MAAM,CAAC,QAAQ,CAAC,YAAY,WAAwB;IACpD,MAAM,CAAC,QAAQ,CAAC,aAAa,WAAiB;IAE9C,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAQ3C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI1B,OAAO;IAID,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YAW1C,iBAAiB;YA4BjB,qBAAqB;IAmC7B,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAmDjD"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { cachedFetch, HttpError } from "../cache.js";
|
|
2
|
+
import { time } from "../utils/misc.js";
|
|
3
|
+
import { BoardShapeError, JobNotFoundError, Scraper, } from "./Scraper.js";
|
|
4
|
+
function formatAddress(sec) {
|
|
5
|
+
if (!sec.address)
|
|
6
|
+
return sec.location;
|
|
7
|
+
const { addressLocality, addressCountry } = sec.address.postalAddress;
|
|
8
|
+
return ([addressLocality, addressCountry].filter(Boolean).join(', ') || sec.location);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Pulls the `window.__appData = {...}` object out of a hosted board page.
|
|
12
|
+
* It's JSON.stringify output inlined into a `<script>` tag, so braces inside
|
|
13
|
+
* strings are always escaped and can't unbalance a depth count; that makes
|
|
14
|
+
* bracket-matching safe here in a way it wouldn't be for hand-written JS.
|
|
15
|
+
*/
|
|
16
|
+
function extractAppData(html, scraperName, slug) {
|
|
17
|
+
const marker = 'window.__appData = ';
|
|
18
|
+
const start = html.indexOf(marker);
|
|
19
|
+
if (start === -1) {
|
|
20
|
+
throw new BoardShapeError(scraperName, slug, `page loaded but '${marker.trim()}' wasn't found in it`);
|
|
21
|
+
}
|
|
22
|
+
let depth = 0;
|
|
23
|
+
let end = -1;
|
|
24
|
+
for (let i = start + marker.length; i < html.length; i++) {
|
|
25
|
+
if (html[i] === '{')
|
|
26
|
+
depth++;
|
|
27
|
+
else if (html[i] === '}' && --depth === 0) {
|
|
28
|
+
end = i + 1;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (end === -1) {
|
|
33
|
+
throw new BoardShapeError(scraperName, slug, 'found the app data marker, but its object never closed');
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(html.slice(start + marker.length, end));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new BoardShapeError(scraperName, slug, 'found the app data marker, but its content is not valid JSON');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// `jobBoard`/`posting` being explicitly `null` is Ashby's own way of saying
|
|
43
|
+
// "no such org" or "no such job", for a page that otherwise loads fine (200,
|
|
44
|
+
// well-formed app data). Callers check for that themselves before calling
|
|
45
|
+
// these, so anything reaching these asserts and still not matching really is
|
|
46
|
+
// an unexpected shape, not a plain miss.
|
|
47
|
+
function isNullField(data, key) {
|
|
48
|
+
return (!!data &&
|
|
49
|
+
typeof data === 'object' &&
|
|
50
|
+
data[key] === null);
|
|
51
|
+
}
|
|
52
|
+
function assertListingShape(data, scraperName, slug) {
|
|
53
|
+
const jobBoard = data?.jobBoard;
|
|
54
|
+
const jobPostings = jobBoard?.jobPostings;
|
|
55
|
+
if (!jobBoard ||
|
|
56
|
+
typeof jobBoard !== 'object' ||
|
|
57
|
+
!Array.isArray(jobPostings) ||
|
|
58
|
+
!jobPostings.every((job) => job && typeof job.id === 'string' && typeof job.title === 'string')) {
|
|
59
|
+
throw new BoardShapeError(scraperName, slug, 'app data no longer has the expected `jobBoard.jobPostings[]` shape');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function assertDetailShape(data, scraperName, slug) {
|
|
63
|
+
const posting = data?.posting;
|
|
64
|
+
if (!posting ||
|
|
65
|
+
typeof posting !== 'object' ||
|
|
66
|
+
typeof posting.id !== 'string' ||
|
|
67
|
+
typeof posting.title !== 'string' ||
|
|
68
|
+
typeof posting.descriptionHtml !== 'string') {
|
|
69
|
+
throw new BoardShapeError(scraperName, slug, 'app data no longer has the expected `posting` shape');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export default class AshbyScraper extends Scraper {
|
|
73
|
+
jobsCache = new Map();
|
|
74
|
+
// set once getJobsList has had to fall back, so getJobContent knows not
|
|
75
|
+
// to expect the API-shaped cache above to ever fill
|
|
76
|
+
usingFallback = false;
|
|
77
|
+
static discoverable = true;
|
|
78
|
+
static boardDomains = ['jobs.ashbyhq.com'];
|
|
79
|
+
static urlHintParams = ['ashby_jid'];
|
|
80
|
+
static parseUrl(url) {
|
|
81
|
+
if (url.hostname !== 'jobs.ashbyhq.com')
|
|
82
|
+
return null;
|
|
83
|
+
const [slug, id] = url.pathname.split('/').filter(Boolean);
|
|
84
|
+
if (!slug)
|
|
85
|
+
return null;
|
|
86
|
+
return { slug, jobId: id ?? null };
|
|
87
|
+
}
|
|
88
|
+
jobUrl(id) {
|
|
89
|
+
return `https://jobs.ashbyhq.com/${this.companySlug}/${id}`;
|
|
90
|
+
}
|
|
91
|
+
dispose() {
|
|
92
|
+
this.jobsCache.clear();
|
|
93
|
+
}
|
|
94
|
+
async getJobsList(testing = false) {
|
|
95
|
+
try {
|
|
96
|
+
return await this.getJobsListViaApi(testing);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
// only a missing board falls back; any other failure (network, rate
|
|
100
|
+
// limit, a genuine 5xx) should surface as itself
|
|
101
|
+
if (!(err instanceof HttpError) || err.status !== 404)
|
|
102
|
+
throw err;
|
|
103
|
+
return this.getJobsListViaAppData(testing);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async getJobsListViaApi(testing) {
|
|
107
|
+
const url = `https://api.ashbyhq.com/posting-api/job-board/${this.companySlug}?includeCompensation=true`;
|
|
108
|
+
const res = (await cachedFetch
|
|
109
|
+
.call({ cache: !testing, cacheTTL: time.day }, url)
|
|
110
|
+
.then((r) => r.json()));
|
|
111
|
+
this.jobsCache.clear();
|
|
112
|
+
for (const posting of res.jobs) {
|
|
113
|
+
this.jobsCache.set(posting.id, posting);
|
|
114
|
+
}
|
|
115
|
+
return res.jobs.map((posting) => {
|
|
116
|
+
const locations = [posting.location];
|
|
117
|
+
for (const sec of posting.secondaryLocations) {
|
|
118
|
+
const loc = formatAddress(sec);
|
|
119
|
+
if (loc && !locations.includes(loc))
|
|
120
|
+
locations.push(loc);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
id: posting.id,
|
|
124
|
+
url: posting.jobUrl,
|
|
125
|
+
title: posting.title,
|
|
126
|
+
location: locations.join(', '),
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
// some orgs disable the public posting-api but still serve the hosted
|
|
131
|
+
// page, which server-renders the same data into `window.__appData`
|
|
132
|
+
async getJobsListViaAppData(testing) {
|
|
133
|
+
const url = `https://jobs.ashbyhq.com/${this.companySlug}`;
|
|
134
|
+
const res = await cachedFetch.call({ cache: !testing, cacheTTL: time.day }, url);
|
|
135
|
+
const html = await res.text();
|
|
136
|
+
const data = extractAppData(html, this.constructor.name, this.companySlug);
|
|
137
|
+
this.usingFallback = true;
|
|
138
|
+
this.jobsCache.clear();
|
|
139
|
+
// a page that loads fine but explicitly says there's no board here
|
|
140
|
+
// (rather than an unexpected shape) is a plain miss, same as the API's
|
|
141
|
+
// own 404 for an unknown slug
|
|
142
|
+
if (isNullField(data, 'jobBoard'))
|
|
143
|
+
return [];
|
|
144
|
+
assertListingShape(data, this.constructor.name, this.companySlug);
|
|
145
|
+
return data.jobBoard.jobPostings.map((posting) => {
|
|
146
|
+
const locations = [posting.locationName];
|
|
147
|
+
for (const sec of posting.secondaryLocations ?? []) {
|
|
148
|
+
if (sec.locationName && !locations.includes(sec.locationName)) {
|
|
149
|
+
locations.push(sec.locationName);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
id: posting.id,
|
|
154
|
+
url: this.jobUrl(posting.id),
|
|
155
|
+
title: posting.title,
|
|
156
|
+
location: locations.filter(Boolean).join(', '),
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
async getJobContent(id) {
|
|
161
|
+
// whether the API works or not is only known once a listing has been
|
|
162
|
+
// fetched at least once on this instance; `fetchJob` builds a fresh
|
|
163
|
+
// scraper per call, so this can't assume `getJobsList` already ran
|
|
164
|
+
if (this.jobsCache.size === 0 && !this.usingFallback) {
|
|
165
|
+
await this.getJobsList();
|
|
166
|
+
}
|
|
167
|
+
if (!this.usingFallback) {
|
|
168
|
+
return JSON.stringify(await this.fromJobsList(this.jobsCache, id));
|
|
169
|
+
}
|
|
170
|
+
const url = this.jobUrl(id);
|
|
171
|
+
let res;
|
|
172
|
+
try {
|
|
173
|
+
res = await cachedFetch.call({ cacheTTL: time.day }, url);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
if (err instanceof HttpError && err.status === 404) {
|
|
177
|
+
throw new JobNotFoundError(id, this.companySlug);
|
|
178
|
+
}
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
181
|
+
const html = await res.text();
|
|
182
|
+
const data = extractAppData(html, this.constructor.name, this.companySlug);
|
|
183
|
+
// same as the listing page: a page that loads fine but explicitly says
|
|
184
|
+
// there's no such posting is a plain miss, not a shape mismatch
|
|
185
|
+
if (isNullField(data, 'posting')) {
|
|
186
|
+
throw new JobNotFoundError(id, this.companySlug);
|
|
187
|
+
}
|
|
188
|
+
assertDetailShape(data, this.constructor.name, this.companySlug);
|
|
189
|
+
const { posting } = data;
|
|
190
|
+
const location = [
|
|
191
|
+
posting.locationName,
|
|
192
|
+
...(posting.secondaryLocationNames ?? []),
|
|
193
|
+
]
|
|
194
|
+
.filter(Boolean)
|
|
195
|
+
.join(', ');
|
|
196
|
+
// key names match what `readListingFields` (Scraper.ts) already looks
|
|
197
|
+
// for, so `getJob()` picks up title/location/url without a scraper-side
|
|
198
|
+
// override
|
|
199
|
+
return JSON.stringify({
|
|
200
|
+
title: posting.title,
|
|
201
|
+
location,
|
|
202
|
+
jobUrl: url,
|
|
203
|
+
descriptionHtml: posting.descriptionHtml,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=AshbyScraper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AshbyScraper.js","sourceRoot":"","sources":["../../src/scrapers/AshbyScraper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,OAAO,GAGR,MAAM,cAAc,CAAC;AA2DtB,SAAS,aAAa,CAAC,GAA2B;IAChD,IAAI,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAC;IACtC,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;IACtE,OAAO,CACL,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAC7E,CAAC;AACJ,C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AI,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACnD,CAAC;QAED,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAEjE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACzB,MAAM,QAAQ,GAAG;YACf,OAAO,CAAC,YAAY;YACpB,GAAG,CAAC,OAAO,CAAC,sBAAsB,IAAI,EAAE,CAAC;SAC1C;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,sEAAsE;QACtE,wEAAwE;QACxE,WAAW;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ;YACR,MAAM,EAAE,GAAG;YACX,eAAe,EAAE,OAAO,CAAC,eAAe;SACzC,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Scraper, type ListedJob, type ParsedUrl } from './Scraper.ts';
|
|
2
|
+
export default class GitHubScraper extends Scraper {
|
|
3
|
+
static parseUrl(url: URL): ParsedUrl | null;
|
|
4
|
+
jobUrl(id: string): string;
|
|
5
|
+
getJobsList(testing?: boolean): Promise<ListedJob[]>;
|
|
6
|
+
getJobContent(id: string): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=GitHubScraper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubScraper.d.ts","sourceRoot":"","sources":["../../src/scrapers/GitHubScraper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AA2BvE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAM3C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAIpB,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAiClD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAcjD"}
|